@@ -11,11 +11,12 @@ var wf = require('./workflow.js');
1111var dbg = require ( './debug.js' ) ;
1212var flowservice = require ( './flowservice.js' ) ;
1313var prettyprint = false ;
14+ var compat = false ;
1415
1516const { Command, Option } = require ( 'commander' ) ;
1617const { exit } = require ( 'process' ) ;
1718
18- function checkEnableDebug ( ) {
19+ function checkOptions ( ) {
1920 if ( program . opts ( ) . verbose == true ) {
2021 dbg . enableDebug ( ) ;
2122 }
@@ -24,6 +25,7 @@ function checkEnableDebug(){
2425 {
2526 prettyprint = true ;
2627 }
28+
2729}
2830
2931function debug ( message ) {
@@ -33,7 +35,7 @@ const program = new Command();
3335program
3436
3537//Program Info
36- . version ( '2022.04 .1' )
38+ . version ( '2022.07 .1' )
3739
3840//required options
3941 . requiredOption ( '-d, --domain <tenantDomain>' , 'Tenant Doamin Name, e.g. "tenant.int-aws-us.webmethods.io"' )
@@ -44,6 +46,7 @@ program
4446 . addOption ( new Option ( '-t, --timeout <delay>' , 'timeout in seconds' ) . default ( 60 , 'one minute' ) )
4547 . option ( '--prettyprint' , 'Pretty Print JSON output' )
4648 . option ( '--verbose' , 'Verbose output useful for diagnosing issues' )
49+
4750
4851//Additional help
4952 . addHelpText ( 'before' , `
@@ -208,7 +211,7 @@ Examples:
208211program . command ( 'project [project-name]' )
209212. description ( 'Lists all projects or view an individual project, specified via project name or uid' )
210213. action ( ( projectName ) => {
211- checkEnableDebug ( ) ;
214+ checkOptions ( ) ;
212215 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
213216 var resp = project . list ( projectName ) ;
214217 if ( resp ) console . log ( resp ) ;
@@ -217,7 +220,7 @@ program.command('project [project-name]')
217220program . command ( 'project-assets <project-name>' )
218221. description ( 'Lists project assets from given project name or uid' )
219222. action ( ( projectName ) => {
220- checkEnableDebug ( ) ;
223+ checkOptions ( ) ;
221224 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
222225 var resp = project . listAssets ( projectName ) ;
223226 if ( resp ) console . log ( resp ) ;
@@ -226,31 +229,31 @@ program.command('project-assets <project-name>')
226229program . command ( 'project-create <project-name>' )
227230. description ( 'Create project with given name' )
228231. action ( ( projectName ) => {
229- checkEnableDebug ( ) ;
232+ checkOptions ( ) ;
230233 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
231234 project . create ( projectName ) ;
232235} ) ;
233236
234237program . command ( 'project-update <project-id> <project-name>' )
235238. description ( 'Update project with new name' )
236239. action ( ( projectId , projectName ) => {
237- checkEnableDebug ( ) ;
240+ checkOptions ( ) ;
238241 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
239242 project . update ( projectId , projectName ) ;
240243} ) ;
241244
242245program . command ( 'project-delete <project-id>' )
243246. description ( 'Delete project with given id' )
244247. action ( ( projectId ) => {
245- checkEnableDebug ( ) ;
248+ checkOptions ( ) ;
246249 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
247250 project . del ( projectId ) ;
248251} ) ;
249252
250253program . command ( 'project-publish <project-id> <publish-name> <target-tenant-domain-name> <target-user-id> <target-user-password> <assets-json>' )
251254. description ( 'Pubilsh project to another tenant with given id' )
252255. action ( ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) => {
253- checkEnableDebug ( ) ;
256+ checkOptions ( ) ;
254257 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
255258 project . pub ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) ;
256259
@@ -259,7 +262,7 @@ program.command('project-publish <project-id> <publish-name> <target-tenant-doma
259262program . command ( 'project-deploy <projectName> <version>' )
260263. description ( 'deploy published project with given version into tenant' )
261264. action ( ( projectName , version ) => {
262- checkEnableDebug ( ) ;
265+ checkOptions ( ) ;
263266 project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
264267 project . deploy ( projectName , version ) ;
265268} ) ;
@@ -272,7 +275,7 @@ program.command('project-deploy <projectName> <version>')
272275program . command ( 'role [role-id]' )
273276. description ( 'Lists all roles or views an individual role' )
274277. action ( ( roleId ) => {
275- checkEnableDebug ( ) ;
278+ checkOptions ( ) ;
276279 role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
277280 var resp = role . list ( roleId ) ;
278281 if ( resp ) console . log ( resp ) ;
@@ -281,23 +284,23 @@ program.command('role [role-id]')
281284program . command ( 'role-create <role-name> <role-description> <roles-list>' )
282285. description ( 'Create roles and specify the permissions for that role. Roles-list should be provided as follows projectName,r,w,e;project name 2,r;' )
283286. action ( ( roleName , roleDescription , rolesList ) => {
284- checkEnableDebug ( ) ;
287+ checkOptions ( ) ;
285288 role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
286289 role . insert ( roleName , roleDescription , rolesList ) ;
287290} ) ;
288291
289292program . command ( 'role-update <role-id> <role-name> <role-description> <roles-list>' )
290293. description ( 'Create roles and specify the permissions for that role. Roles-list should be provided as follows projectName,r,w,e;project name 2,r;' )
291294. action ( ( roleId , roleName , roleDescription , rolesList ) => {
292- checkEnableDebug ( ) ;
295+ checkOptions ( ) ;
293296 role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
294297 role . update ( roleId , roleName , roleDescription , rolesList ) ;
295298} ) ;
296299
297300program . command ( 'role-delete <role-name>' )
298301. description ( 'Delete a roles with the given role name' )
299302. action ( ( roleId , roleName , roleDescription , rolesList ) => {
300- checkEnableDebug ( ) ;
303+ checkOptions ( ) ;
301304 role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
302305 role . del ( roleId ) ;
303306} ) ;
@@ -314,15 +317,15 @@ program.command('role-delete <role-name>')
314317program . command ( 'user' )
315318. description ( 'Lists all users' )
316319. action ( ( ) => {
317- checkEnableDebug ( ) ;
320+ checkOptions ( ) ;
318321 user . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
319322 user . list ( undefined ) ;
320323} ) ;
321324
322325program . command ( 'user-role-assignment <user-id> <role-names>' )
323326. description ( 'Assigns a user to roles' )
324327. action ( ( userId , roleNames ) => {
325- checkEnableDebug ( ) ;
328+ checkOptions ( ) ;
326329 debug ( "userId: " + userId ) ;
327330 debug ( "Roles: " + roleNames ) ;
328331 user . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
@@ -337,15 +340,15 @@ program.command('user-role-assignment <user-id> <role-names>')
337340program . command ( 'workflow-export <project-id> <workflow-id> <filename>' )
338341. description ( 'Export workflow with id <workflow-id> from project <project-id>' )
339342. action ( ( projectId , workflowId , filename ) => {
340- checkEnableDebug ( ) ;
343+ checkOptions ( ) ;
341344 wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
342345 wf . exportwf ( workflowId , filename ) ;
343346} ) ;
344347
345348program . command ( 'workflow-import <project-id> <filename>' )
346349. description ( 'Import workflow into project <project-id> from file <filename>' )
347350. action ( ( projectId , filename ) => {
348- checkEnableDebug ( ) ;
351+ checkOptions ( ) ;
349352 debug ( "Importing Workflow" ) ;
350353 wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
351354 wf . importwf ( filename ) ;
@@ -354,7 +357,7 @@ program.command('workflow-import <project-id> <filename>')
354357program . command ( 'workflow-delete <project-id> <workflow-id>' )
355358. description ( 'Delete workflow <workflow-id> from project <project-id>' )
356359. action ( ( projectId , workflowId ) => {
357- checkEnableDebug ( ) ;
360+ checkOptions ( ) ;
358361 debug ( "Deleting Workflow [" + workflowId + "]" ) ;
359362 wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
360363 wf . deletewf ( workflowId ) ;
@@ -363,15 +366,15 @@ program.command('workflow-delete <project-id> <workflow-id>')
363366program . command ( 'workflow-execute <project-id> <workflow-id>' )
364367 . description ( 'Execute workflow <workflow-id> from project <project-id>' )
365368. action ( ( projectId , workflowId ) => {
366- checkEnableDebug ( ) ;
369+ checkOptions ( ) ;
367370 wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
368371 wf . runwf ( workflowId )
369372} ) ;
370373
371374program . command ( 'workflow-status <project-id> <run-id>' )
372375. description ( 'Gets Execution status for workflow execution <run-id>' )
373376. action ( ( projectId , runId ) => {
374- checkEnableDebug ( ) ;
377+ checkOptions ( ) ;
375378 wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
376379 wf . statuswf ( runId ) ;
377380} ) ;
@@ -384,31 +387,31 @@ program.command('workflow-status <project-id> <run-id>')
384387program . command ( 'flowservice-export <project-id> <flow-name> <file-name>' )
385388. description ( 'Export FlowService with name <flow-name> from project <project-id>' )
386389. action ( ( projectId , flowName , filename ) => {
387- checkEnableDebug ( ) ;
390+ checkOptions ( ) ;
388391 flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
389392 flowservice . exportFlowService ( flowName , filename ) ;
390393} ) ;
391394
392395program . command ( 'flowservice-import <project-id> <filename>' )
393396. description ( 'Import FlowService from <filename> into project <project-id>' )
394397. action ( ( projectId , filename ) => {
395- checkEnableDebug ( ) ;
398+ checkOptions ( ) ;
396399 flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
397400 flowservice . importFlowService ( filename ) ;
398401} ) ;
399402
400403program . command ( 'flowservice-delete <project-id> <flow-name>' )
401404. description ( 'Delete FlowService <flow-name> from project <project-id>' )
402405. action ( ( projectId , flowName ) => {
403- checkEnableDebug ( ) ;
406+ checkOptions ( ) ;
404407 flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
405408 flowservice . deleteFlowService ( flowName ) ;
406409} ) ;
407410
408411program . command ( 'flowservice-execute <project-id> <flow-name> [input-json]' )
409412 . description ( 'Execute FlowService <flow-name> from project <project-id> with data <input-json>' )
410413. action ( ( projectId , flowName , inputJson ) => {
411- checkEnableDebug ( ) ;
414+ checkOptions ( ) ;
412415 flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
413416 flowservice . runFlowService ( flowName , inputJson ) ;
414417} ) ;
0 commit comments