This is an automated email from the ASF dual-hosted git repository.

dgrove 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 911c792  Add debug flag to generate method and deploy command (#24)
911c792 is described below

commit 911c79272fe578b9fc43ad80530460bd940f3055
Author: Olivier Tardieu <[email protected]>
AuthorDate: Tue Feb 12 13:03:21 2019 -0500

    Add debug flag to generate method and deploy command (#24)
---
 bin/deploy.js | 5 +++--
 client.js     | 4 ++--
 conductor.js  | 5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/bin/deploy.js b/bin/deploy.js
index 433bdc1..c2b2519 100755
--- a/bin/deploy.js
+++ b/bin/deploy.js
@@ -25,7 +25,7 @@ const minimist = require('minimist')
 const path = require('path')
 
 const argv = minimist(process.argv.slice(2), {
-  string: ['apihost', 'auth', 'source', 'annotation', 'annotation-file'],
+  string: ['apihost', 'auth', 'source', 'annotation', 'annotation-file', 
'debug'],
   boolean: ['insecure', 'version', 'overwrite'],
   alias: { auth: 'u', insecure: 'i', version: 'v', annotation: 'a', 
'annotation-file': 'A', overwrite: 'w' }
 })
@@ -46,6 +46,7 @@ if (argv._.length !== 2 || path.extname(argv._[1]) !== 
'.json') {
   console.error('  -u, --auth KEY                    authorization KEY')
   console.error('  -v, --version                     output the composer 
version')
   console.error('  -w, --overwrite                   overwrite actions if 
already defined')
+  console.error('  --debug LIST                      comma-separated list of 
debug flags')
   process.exit(1)
 }
 let composition
@@ -85,7 +86,7 @@ try {
   console.error(error)
   process.exit(400 - 256) // Bad Request
 }
-client(options).compositions.deploy(composition, argv.overwrite)
+client(options).compositions.deploy(composition, argv.overwrite, argv.debug)
   .then(actions => {
     const names = actions.map(action => action.name)
     console.log(`ok: created action${actions.length > 1 ? 's' : ''} ${names}`)
diff --git a/client.js b/client.js
index 82fbae1..2309e62 100644
--- a/client.js
+++ b/client.js
@@ -63,8 +63,8 @@ class Compositions {
     this.actions = wsk.actions
   }
 
-  deploy (composition, overwrite) {
-    const actions = (composition.actions || 
[]).concat(conductor.generate(composition))
+  deploy (composition, overwrite, debug) {
+    const actions = (composition.actions || 
[]).concat(conductor.generate(composition, debug))
     return actions.reduce((promise, action) => promise.then(() => overwrite && 
this.actions.delete(action).catch(() => { }))
       .then(() => this.actions.create(action)), Promise.resolve())
       .then(() => actions)
diff --git a/conductor.js b/conductor.js
index 2cf9845..be3fb45 100644
--- a/conductor.js
+++ b/conductor.js
@@ -25,9 +25,10 @@ const { minify } = require('terser')
 const version = require('./package.json').version
 
 // synthesize conductor action code from composition
-function generate ({ name, composition, ast, version: composer, annotations = 
[] }) {
-  const code = `// generated by composer v${composer} and conductor 
v${version}\n\nconst composition = ${JSON.stringify(composition, null, 
4)}\n\n// do not edit below this point\n\n` +
+function generate ({ name, composition, ast, version: composer, annotations = 
[] }, debug) {
+  let code = `// generated by composer v${composer} and conductor 
v${version}\n\nconst composition = ${JSON.stringify(composition, null, 
4)}\n\n// do not edit below this point\n\n` +
     minify(`const main=(${main})(composition)`, { output: { max_line_len: 127 
} }).code
+  if (debug) code = `process.env.DEBUG='${debug}'\n\n` + code
   annotations = annotations.concat([{ key: 'conductor', value: ast }, { key: 
'composerVersion', value: composer }, { key: 'conductorVersion', value: version 
}])
   return { name, action: { exec: { kind: 'nodejs:default', code }, annotations 
} }
 }

Reply via email to