From commits-return-7057-archive-asf-public=cust-asf.ponee.io@openwhisk.apache.org Fri Mar 29 19:24:39 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id D50CE180629 for ; Fri, 29 Mar 2019 20:24:38 +0100 (CET) Received: (qmail 7887 invoked by uid 500); 29 Mar 2019 19:24:37 -0000 Mailing-List: contact commits-help@openwhisk.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwhisk.apache.org Delivered-To: mailing list commits@openwhisk.apache.org Received: (qmail 7878 invoked by uid 99); 29 Mar 2019 19:24:37 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Mar 2019 19:24:37 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 4D6EA85B59; Fri, 29 Mar 2019 19:24:37 +0000 (UTC) Date: Fri, 29 Mar 2019 19:24:37 +0000 To: "commits@openwhisk.apache.org" Subject: [incubator-openwhisk-composer] branch master updated: Improve write-to-file logic in compose command (#36) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155388747726.23873.6954731746987593134@gitbox.apache.org> From: tardieu@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-openwhisk-composer X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 2bd55afb38b883f3c88aa6fbabf51783184738ea X-Git-Newrev: f916cb04d53278767e971f068ca6cfce8366690b X-Git-Rev: f916cb04d53278767e971f068ca6cfce8366690b X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. tardieu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-composer.git The following commit(s) were added to refs/heads/master by this push: new f916cb0 Improve write-to-file logic in compose command (#36) f916cb0 is described below commit f916cb04d53278767e971f068ca6cfce8366690b Author: Olivier Tardieu AuthorDate: Fri Mar 29 15:24:33 2019 -0400 Improve write-to-file logic in compose command (#36) --- bin/compose.js | 24 ++++++++++++++---------- docs/COMMANDS.md | 23 ++++++++++++++++++++--- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/bin/compose.js b/bin/compose.js index a9cd01a..64aba12 100755 --- a/bin/compose.js +++ b/bin/compose.js @@ -54,7 +54,7 @@ if (argv._.length !== 1 || path.extname(argv._[0]) !== '.js') { console.error(' compose composition.js [flags]') console.error('Flags:') console.error(' --ast only output the ast for the composition') - console.error(' --file write output to .json file with path and name matching input file') + console.error(' --file write output to a file next to the input file') console.error(' --js output the conductor action code for the composition') console.error(' -o FILE write output to FILE') console.error(' -v, --version output the composer version') @@ -63,6 +63,7 @@ if (argv._.length !== 1 || path.extname(argv._[0]) !== '.js') { } let composition +let file try { composition = composer.parse(require(path.resolve(argv._[0]))) // load and validate composition composition = composition.compile() @@ -72,16 +73,19 @@ try { process.exit(422 - 256) // Unprocessable Entity } if (argv.js) { - console.log(conductor.generate(composition, argv.debug).action.exec.code) + composition = conductor.generate(composition, argv.debug).action.exec.code } else { if (argv.ast) composition = composition.ast composition = JSON.stringify(composition, null, 4) - if (argv.o) { - fs.writeFileSync(argv.o, composition.concat('\n'), { encoding: 'utf8' }) - } else if (argv.file) { - const { dir, name } = path.parse(argv._[0]) - fs.writeFileSync(path.format({ dir, name, ext: '.json' }), composition.concat('\n'), { encoding: 'utf8' }) - } else { - console.log(composition) - } +} +if (argv.o) { + file = argv.o +} else if (argv.file) { + const { dir, name } = path.parse(argv._[0]) + file = path.format({ dir, name, ext: argv.js ? '.conductor.js' : '.json' }) +} +if (file) { + fs.writeFileSync(file, composition.concat('\n'), { encoding: 'utf8' }) +} else { + console.log(composition) } diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md index ca74c80..673035c 100644 --- a/docs/COMMANDS.md +++ b/docs/COMMANDS.md @@ -39,21 +39,29 @@ Usage: compose composition.js [flags] Flags: --ast only output the ast for the composition + --file write output to a file next to the input file --js output the conductor action code for the composition + -o FILE write output to FILE -v, --version output the composer version --debug LIST comma-separated list of debug flags (when using --js flag) ``` The `compose` command takes a Javascript module that exports a composition object (for example [demo.js](../samples/demo.js)) and compiles this object to a -portable JSON format on the standard output. +portable JSON format on the standard output or in file. ``` -compose demo.js > demo.json +compose demo.js -o demo.json ``` If the `--ast` option is specified, the `compose` command only outputs a JSON representation of the Abstract Syntax Tree for the composition. If the `--js` option is specified, the `compose` command outputs the conductor -action code for the composition. +action code for the composition instead of the generated JSON. + +If the `-o` option is used, the `compose` command outputs to the specified file. + +If the `--file` option is specified, the `compose` command outputs to a file +next to the input file with a `.json` or `.conductor.js` extension (if the +`--js` option is specified). # Deploy @@ -68,6 +76,8 @@ Flags: -A, --annotation-file KEY=FILE add KEY annotation with FILE content --apihost HOST API HOST -i, --insecure bypass certificate checking + --kind KIND the KIND of the conductor action runtime + -t, --timeout LIMIT the timeout LIMIT in milliseconds for the conductor action -u, --auth KEY authorization KEY -v, --version output the composer version -w, --overwrite overwrite actions if already defined @@ -93,6 +103,13 @@ definitions. More precisely, it deletes the deployed actions before recreating them. As a result, default parameters, limits, and annotations on preexisting actions are lost. +The `--timeout` option specifies the timeout for the conductor action. + +The `--kind` option specifies the kind for the conductor action runtime. By +default, the `nodejs:default` OpenWhisk runtime is used. The chosen runtime must +be based on Node.js. Other Node.js runtimes may or may not be compatible with +Composer. + ### Annotations The `deploy` command implicitly annotates the deployed composition action with