@@ -11,11 +11,12 @@ var wf = require('./workflow.js');
11
11
var dbg = require ( './debug.js' ) ;
12
12
var flowservice = require ( './flowservice.js' ) ;
13
13
var prettyprint = false ;
14
+ var compat = false ;
14
15
15
16
const { Command, Option } = require ( 'commander' ) ;
16
17
const { exit } = require ( 'process' ) ;
17
18
18
- function checkEnableDebug ( ) {
19
+ function checkOptions ( ) {
19
20
if ( program . opts ( ) . verbose == true ) {
20
21
dbg . enableDebug ( ) ;
21
22
}
@@ -24,6 +25,7 @@ function checkEnableDebug(){
24
25
{
25
26
prettyprint = true ;
26
27
}
28
+
27
29
}
28
30
29
31
function debug ( message ) {
@@ -33,7 +35,7 @@ const program = new Command();
33
35
program
34
36
35
37
//Program Info
36
- . version ( '2022.04 .1' )
38
+ . version ( '2022.07 .1' )
37
39
38
40
//required options
39
41
. requiredOption ( '-d, --domain <tenantDomain>' , 'Tenant Doamin Name, e.g. "tenant.int-aws-us.webmethods.io"' )
@@ -44,6 +46,7 @@ program
44
46
. addOption ( new Option ( '-t, --timeout <delay>' , 'timeout in seconds' ) . default ( 60 , 'one minute' ) )
45
47
. option ( '--prettyprint' , 'Pretty Print JSON output' )
46
48
. option ( '--verbose' , 'Verbose output useful for diagnosing issues' )
49
+
47
50
48
51
//Additional help
49
52
. addHelpText ( 'before' , `
@@ -208,7 +211,7 @@ Examples:
208
211
program . command ( 'project [project-name]' )
209
212
. description ( 'Lists all projects or view an individual project, specified via project name or uid' )
210
213
. action ( ( projectName ) => {
211
- checkEnableDebug ( ) ;
214
+ checkOptions ( ) ;
212
215
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
213
216
var resp = project . list ( projectName ) ;
214
217
if ( resp ) console . log ( resp ) ;
@@ -217,7 +220,7 @@ program.command('project [project-name]')
217
220
program . command ( 'project-assets <project-name>' )
218
221
. description ( 'Lists project assets from given project name or uid' )
219
222
. action ( ( projectName ) => {
220
- checkEnableDebug ( ) ;
223
+ checkOptions ( ) ;
221
224
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
222
225
var resp = project . listAssets ( projectName ) ;
223
226
if ( resp ) console . log ( resp ) ;
@@ -226,31 +229,31 @@ program.command('project-assets <project-name>')
226
229
program . command ( 'project-create <project-name>' )
227
230
. description ( 'Create project with given name' )
228
231
. action ( ( projectName ) => {
229
- checkEnableDebug ( ) ;
232
+ checkOptions ( ) ;
230
233
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
231
234
project . create ( projectName ) ;
232
235
} ) ;
233
236
234
237
program . command ( 'project-update <project-id> <project-name>' )
235
238
. description ( 'Update project with new name' )
236
239
. action ( ( projectId , projectName ) => {
237
- checkEnableDebug ( ) ;
240
+ checkOptions ( ) ;
238
241
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
239
242
project . update ( projectId , projectName ) ;
240
243
} ) ;
241
244
242
245
program . command ( 'project-delete <project-id>' )
243
246
. description ( 'Delete project with given id' )
244
247
. action ( ( projectId ) => {
245
- checkEnableDebug ( ) ;
248
+ checkOptions ( ) ;
246
249
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
247
250
project . del ( projectId ) ;
248
251
} ) ;
249
252
250
253
program . command ( 'project-publish <project-id> <publish-name> <target-tenant-domain-name> <target-user-id> <target-user-password> <assets-json>' )
251
254
. description ( 'Pubilsh project to another tenant with given id' )
252
255
. action ( ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) => {
253
- checkEnableDebug ( ) ;
256
+ checkOptions ( ) ;
254
257
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
255
258
project . pub ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) ;
256
259
@@ -259,7 +262,7 @@ program.command('project-publish <project-id> <publish-name> <target-tenant-doma
259
262
program . command ( 'project-deploy <projectName> <version>' )
260
263
. description ( 'deploy published project with given version into tenant' )
261
264
. action ( ( projectName , version ) => {
262
- checkEnableDebug ( ) ;
265
+ checkOptions ( ) ;
263
266
project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
264
267
project . deploy ( projectName , version ) ;
265
268
} ) ;
@@ -272,7 +275,7 @@ program.command('project-deploy <projectName> <version>')
272
275
program . command ( 'role [role-id]' )
273
276
. description ( 'Lists all roles or views an individual role' )
274
277
. action ( ( roleId ) => {
275
- checkEnableDebug ( ) ;
278
+ checkOptions ( ) ;
276
279
role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
277
280
var resp = role . list ( roleId ) ;
278
281
if ( resp ) console . log ( resp ) ;
@@ -281,23 +284,23 @@ program.command('role [role-id]')
281
284
program . command ( 'role-create <role-name> <role-description> <roles-list>' )
282
285
. 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;' )
283
286
. action ( ( roleName , roleDescription , rolesList ) => {
284
- checkEnableDebug ( ) ;
287
+ checkOptions ( ) ;
285
288
role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
286
289
role . insert ( roleName , roleDescription , rolesList ) ;
287
290
} ) ;
288
291
289
292
program . command ( 'role-update <role-id> <role-name> <role-description> <roles-list>' )
290
293
. 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;' )
291
294
. action ( ( roleId , roleName , roleDescription , rolesList ) => {
292
- checkEnableDebug ( ) ;
295
+ checkOptions ( ) ;
293
296
role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
294
297
role . update ( roleId , roleName , roleDescription , rolesList ) ;
295
298
} ) ;
296
299
297
300
program . command ( 'role-delete <role-name>' )
298
301
. description ( 'Delete a roles with the given role name' )
299
302
. action ( ( roleId , roleName , roleDescription , rolesList ) => {
300
- checkEnableDebug ( ) ;
303
+ checkOptions ( ) ;
301
304
role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
302
305
role . del ( roleId ) ;
303
306
} ) ;
@@ -314,15 +317,15 @@ program.command('role-delete <role-name>')
314
317
program . command ( 'user' )
315
318
. description ( 'Lists all users' )
316
319
. action ( ( ) => {
317
- checkEnableDebug ( ) ;
320
+ checkOptions ( ) ;
318
321
user . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
319
322
user . list ( undefined ) ;
320
323
} ) ;
321
324
322
325
program . command ( 'user-role-assignment <user-id> <role-names>' )
323
326
. description ( 'Assigns a user to roles' )
324
327
. action ( ( userId , roleNames ) => {
325
- checkEnableDebug ( ) ;
328
+ checkOptions ( ) ;
326
329
debug ( "userId: " + userId ) ;
327
330
debug ( "Roles: " + roleNames ) ;
328
331
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>')
337
340
program . command ( 'workflow-export <project-id> <workflow-id> <filename>' )
338
341
. description ( 'Export workflow with id <workflow-id> from project <project-id>' )
339
342
. action ( ( projectId , workflowId , filename ) => {
340
- checkEnableDebug ( ) ;
343
+ checkOptions ( ) ;
341
344
wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
342
345
wf . exportwf ( workflowId , filename ) ;
343
346
} ) ;
344
347
345
348
program . command ( 'workflow-import <project-id> <filename>' )
346
349
. description ( 'Import workflow into project <project-id> from file <filename>' )
347
350
. action ( ( projectId , filename ) => {
348
- checkEnableDebug ( ) ;
351
+ checkOptions ( ) ;
349
352
debug ( "Importing Workflow" ) ;
350
353
wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
351
354
wf . importwf ( filename ) ;
@@ -354,7 +357,7 @@ program.command('workflow-import <project-id> <filename>')
354
357
program . command ( 'workflow-delete <project-id> <workflow-id>' )
355
358
. description ( 'Delete workflow <workflow-id> from project <project-id>' )
356
359
. action ( ( projectId , workflowId ) => {
357
- checkEnableDebug ( ) ;
360
+ checkOptions ( ) ;
358
361
debug ( "Deleting Workflow [" + workflowId + "]" ) ;
359
362
wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
360
363
wf . deletewf ( workflowId ) ;
@@ -363,15 +366,15 @@ program.command('workflow-delete <project-id> <workflow-id>')
363
366
program . command ( 'workflow-execute <project-id> <workflow-id>' )
364
367
. description ( 'Execute workflow <workflow-id> from project <project-id>' )
365
368
. action ( ( projectId , workflowId ) => {
366
- checkEnableDebug ( ) ;
369
+ checkOptions ( ) ;
367
370
wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
368
371
wf . runwf ( workflowId )
369
372
} ) ;
370
373
371
374
program . command ( 'workflow-status <project-id> <run-id>' )
372
375
. description ( 'Gets Execution status for workflow execution <run-id>' )
373
376
. action ( ( projectId , runId ) => {
374
- checkEnableDebug ( ) ;
377
+ checkOptions ( ) ;
375
378
wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
376
379
wf . statuswf ( runId ) ;
377
380
} ) ;
@@ -384,31 +387,31 @@ program.command('workflow-status <project-id> <run-id>')
384
387
program . command ( 'flowservice-export <project-id> <flow-name> <file-name>' )
385
388
. description ( 'Export FlowService with name <flow-name> from project <project-id>' )
386
389
. action ( ( projectId , flowName , filename ) => {
387
- checkEnableDebug ( ) ;
390
+ checkOptions ( ) ;
388
391
flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
389
392
flowservice . exportFlowService ( flowName , filename ) ;
390
393
} ) ;
391
394
392
395
program . command ( 'flowservice-import <project-id> <filename>' )
393
396
. description ( 'Import FlowService from <filename> into project <project-id>' )
394
397
. action ( ( projectId , filename ) => {
395
- checkEnableDebug ( ) ;
398
+ checkOptions ( ) ;
396
399
flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
397
400
flowservice . importFlowService ( filename ) ;
398
401
} ) ;
399
402
400
403
program . command ( 'flowservice-delete <project-id> <flow-name>' )
401
404
. description ( 'Delete FlowService <flow-name> from project <project-id>' )
402
405
. action ( ( projectId , flowName ) => {
403
- checkEnableDebug ( ) ;
406
+ checkOptions ( ) ;
404
407
flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
405
408
flowservice . deleteFlowService ( flowName ) ;
406
409
} ) ;
407
410
408
411
program . command ( 'flowservice-execute <project-id> <flow-name> [input-json]' )
409
412
. description ( 'Execute FlowService <flow-name> from project <project-id> with data <input-json>' )
410
413
. action ( ( projectId , flowName , inputJson ) => {
411
- checkEnableDebug ( ) ;
414
+ checkOptions ( ) ;
412
415
flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
413
416
flowservice . runFlowService ( flowName , inputJson ) ;
414
417
} ) ;
0 commit comments