@@ -13,8 +13,27 @@ var flowservice = require('./flowservice.js');
13
13
var prettyprint = false ;
14
14
var compat = false ;
15
15
16
+ var tenantDomain ;
17
+ var tenantUser ;
18
+ var tenantPw ;
19
+
16
20
const { Command, Option } = require ( 'commander' ) ;
17
21
const { exit } = require ( 'process' ) ;
22
+ const readline = require ( 'readline-sync' ) ;
23
+
24
+ function readFromConsole ( question , isPassword )
25
+ {
26
+ var answer ;
27
+ if ( isPassword !== undefined && isPassword !== null && isPassword == true )
28
+ {
29
+ answer = readline . question ( "\x1b[32m" + question + "\x1b[0m" , { hideEchoBack : true } ) ;
30
+ }
31
+ else
32
+ {
33
+ answer = readline . question ( "\x1b[32m" + question + "\x1b[0m" ) ;
34
+ }
35
+ return answer ;
36
+ }
18
37
19
38
function checkOptions ( ) {
20
39
if ( program . opts ( ) . verbose == true ) {
@@ -26,6 +45,27 @@ function checkOptions(){
26
45
prettyprint = true ;
27
46
}
28
47
48
+ if ( program . opts ( ) . domain == undefined ) {
49
+ tenantDomain = readFromConsole ( 'Please type your tenant domain name: ' ) ;
50
+ }
51
+ else {
52
+ tenantDomain = program . opts ( ) . domain
53
+ }
54
+
55
+ if ( program . opts ( ) . user == undefined ) {
56
+ tenantUser = readFromConsole ( 'Please type your tenant User ID: ' ) ;
57
+ }
58
+ else {
59
+ tenantUser = program . opts ( ) . user
60
+ }
61
+
62
+ if ( program . opts ( ) . password == undefined ) {
63
+ tenantPw = readFromConsole ( 'Please type your tenant User Password: ' , true ) ;
64
+ }
65
+ else {
66
+ tenantPw = program . opts ( ) . password
67
+ }
68
+
29
69
}
30
70
31
71
function debug ( message ) {
@@ -38,9 +78,10 @@ program
38
78
. version ( '2022.07.1' )
39
79
40
80
//required options
41
- . requiredOption ( '-d, --domain <tenantDomain>' , 'Tenant Doamin Name, e.g. "tenant.int-aws-us.webmethods.io"' )
42
- . requiredOption ( '-u, --user <userid>' , 'Tenant User ID' )
43
- . requiredOption ( '-p, --password <password>' , 'Tenant User Password' )
81
+ . option ( '-d, --domain <tenantDomain>' , 'Tenant Doamin Name, e.g. "tenant.int-aws-us.webmethods.io"' )
82
+ . option ( '-u, --user <userid>' , 'Tenant User ID' )
83
+ . option ( '-p, --password <password>' , 'Tenant User Password' )
84
+ //.requiredOption('-p, --password <password>', 'Tenant User Password')
44
85
45
86
//options
46
87
. addOption ( new Option ( '-t, --timeout <delay>' , 'timeout in seconds' ) . default ( 60 , 'one minute' ) )
@@ -122,12 +163,12 @@ Examples:
122
163
project-publish fl65d3aa87fc1783ea5cf8c8 'My deployment' 'target.int-aws-us.webmethods.io' 'targetuser' 'targetpassword' '{"output":{"workflows":["fla73a20e13dd6736cf9c355","fl3cfd145262bbc5d44acff3"],"flows":["mapLeads"],"rest_api":[],"soap_api":[],"listener":[],"messaging":[]}}'
123
164
124
165
125
- \x1b[32m/Publish Project to another tenant:\x1b[0m
126
- $ node wmiocli.js
127
- -d tenant.int-aws-us.webmethods.io
128
- -u user
129
- -p password
130
- project-publish fl65d3aa87fc1783ea5cf8c8 'My deployment'
166
+ \x1b[32m/Deploy published Project in the tenant with the given name and deploy version :\x1b[0m
167
+ $ node wmiocli.js
168
+ -d tenant.int-aws-us.webmethods.io
169
+ -u user
170
+ -p password
171
+ project-deploy projectName 1
131
172
132
173
\x1b[4mWorkflow\x1b[0m
133
174
@@ -197,7 +238,38 @@ Examples:
197
238
-d tenant.int-aws-us.webmethods.io
198
239
-u user
199
240
-p password
200
- flowservice-execute fl65d3aa87fc1783ea5cf8c8 myFlowService
241
+ flowservice-execute fl65d3aa87fc1783ea5cf8c8 myFlowService
242
+
243
+
244
+ \x1b[4mRoles\x1b[0m
245
+
246
+ \x1b[32mGet roles list or individual role\x1b[0m
247
+ $ node wmiocli.js
248
+ -d tenant.int-aws-us.webmethods.io
249
+ -u user
250
+ -p password
251
+ role [role-name]
252
+
253
+ \x1b[32mCreates a role\x1b[0m
254
+ $ node wmiocli.js
255
+ -d tenant.int-aws-us.webmethods.io
256
+ -u user
257
+ -p password
258
+ role-create 'rolename' 'role description' 'project 1 name,r,w,e;project 2 name,r;'
259
+
260
+ \x1b[32mUpdates a role with a provided Id\x1b[0m
261
+ $ node wmiocli.js
262
+ -d tenant.int-aws-us.webmethods.io
263
+ -u user
264
+ -p password
265
+ role-update 'roleId' 'rolename' 'role description' 'project 1 name,r,w,e;project 2 name,r;'
266
+
267
+ \x1b[32mDelete a role with a provided Id\x1b[0m
268
+ $ node wmiocli.js
269
+ -d tenant.int-aws-us.webmethods.io
270
+ -u user
271
+ -p password
272
+ role-delete 'roleId'
201
273
` )
202
274
203
275
. showSuggestionAfterError ( )
@@ -212,7 +284,7 @@ program.command('project [project-name]')
212
284
. description ( 'Lists all projects or view an individual project, specified via project name or uid' )
213
285
. action ( ( projectName ) => {
214
286
checkOptions ( ) ;
215
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
287
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
216
288
var resp = project . list ( projectName ) ;
217
289
if ( resp ) console . log ( resp ) ;
218
290
} ) ;
@@ -221,7 +293,7 @@ program.command('project-assets <project-name>')
221
293
. description ( 'Lists project assets from given project name or uid' )
222
294
. action ( ( projectName ) => {
223
295
checkOptions ( ) ;
224
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
296
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
225
297
var resp = project . listAssets ( projectName ) ;
226
298
if ( resp ) console . log ( resp ) ;
227
299
} ) ;
@@ -230,31 +302,31 @@ program.command('project-create <project-name>')
230
302
. description ( 'Create project with given name' )
231
303
. action ( ( projectName ) => {
232
304
checkOptions ( ) ;
233
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
305
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
234
306
project . create ( projectName ) ;
235
307
} ) ;
236
308
237
309
program . command ( 'project-update <project-id> <project-name>' )
238
310
. description ( 'Update project with new name' )
239
311
. action ( ( projectId , projectName ) => {
240
312
checkOptions ( ) ;
241
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
313
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
242
314
project . update ( projectId , projectName ) ;
243
315
} ) ;
244
316
245
317
program . command ( 'project-delete <project-id>' )
246
318
. description ( 'Delete project with given id' )
247
319
. action ( ( projectId ) => {
248
320
checkOptions ( ) ;
249
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
321
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
250
322
project . del ( projectId ) ;
251
323
} ) ;
252
324
253
325
program . command ( 'project-publish <project-id> <publish-name> <target-tenant-domain-name> <target-user-id> <target-user-password> <assets-json>' )
254
326
. description ( 'Pubilsh project to another tenant with given id' )
255
327
. action ( ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) => {
256
328
checkOptions ( ) ;
257
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
329
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
258
330
project . pub ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) ;
259
331
260
332
} ) ;
@@ -263,7 +335,7 @@ program.command('project-deploy <projectName> <version>')
263
335
. description ( 'deploy published project with given version into tenant' )
264
336
. action ( ( projectName , version ) => {
265
337
checkOptions ( ) ;
266
- project . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
338
+ project . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
267
339
project . deploy ( projectName , version ) ;
268
340
} ) ;
269
341
@@ -276,7 +348,7 @@ program.command('role [role-id]')
276
348
. description ( 'Lists all roles or views an individual role' )
277
349
. action ( ( roleId ) => {
278
350
checkOptions ( ) ;
279
- role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
351
+ role . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint )
280
352
var resp = role . list ( roleId ) ;
281
353
if ( resp ) console . log ( resp ) ;
282
354
} ) ;
@@ -285,23 +357,23 @@ program.command('role-create <role-name> <role-description> <roles-list>')
285
357
. 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;' )
286
358
. action ( ( roleName , roleDescription , rolesList ) => {
287
359
checkOptions ( ) ;
288
- role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
360
+ role . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
289
361
role . insert ( roleName , roleDescription , rolesList ) ;
290
362
} ) ;
291
363
292
364
program . command ( 'role-update <role-id> <role-name> <role-description> <roles-list>' )
293
365
. 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;' )
294
366
. action ( ( roleId , roleName , roleDescription , rolesList ) => {
295
367
checkOptions ( ) ;
296
- role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
368
+ role . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
297
369
role . update ( roleId , roleName , roleDescription , rolesList ) ;
298
370
} ) ;
299
371
300
- program . command ( 'role-delete <role-name >' )
301
- . description ( 'Delete a roles with the given role name ' )
302
- . action ( ( roleId , roleName , roleDescription , rolesList ) => {
372
+ program . command ( 'role-delete <roleId >' )
373
+ . description ( 'Delete a roles with the given role id ' )
374
+ . action ( ( roleId ) => {
303
375
checkOptions ( ) ;
304
- role . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
376
+ role . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
305
377
role . del ( roleId ) ;
306
378
} ) ;
307
379
@@ -318,7 +390,7 @@ program.command('user')
318
390
. description ( 'Lists all users' )
319
391
. action ( ( ) => {
320
392
checkOptions ( ) ;
321
- user . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
393
+ user . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
322
394
user . list ( undefined ) ;
323
395
} ) ;
324
396
@@ -328,7 +400,7 @@ program.command('user-role-assignment <user-id> <role-names>')
328
400
checkOptions ( ) ;
329
401
debug ( "userId: " + userId ) ;
330
402
debug ( "Roles: " + roleNames ) ;
331
- user . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
403
+ user . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , program . opts ( ) . prettyprint ) ;
332
404
user . assignRoles ( userId , roleNames ) ;
333
405
} ) ;
334
406
@@ -341,7 +413,7 @@ program.command('workflow-export <project-id> <workflow-id> <filename>')
341
413
. description ( 'Export workflow with id <workflow-id> from project <project-id>' )
342
414
. action ( ( projectId , workflowId , filename ) => {
343
415
checkOptions ( ) ;
344
- wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
416
+ wf . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
345
417
wf . exportwf ( workflowId , filename ) ;
346
418
} ) ;
347
419
@@ -350,7 +422,7 @@ program.command('workflow-import <project-id> <filename>')
350
422
. action ( ( projectId , filename ) => {
351
423
checkOptions ( ) ;
352
424
debug ( "Importing Workflow" ) ;
353
- wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
425
+ wf . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
354
426
wf . importwf ( filename ) ;
355
427
} ) ;
356
428
@@ -359,23 +431,23 @@ program.command('workflow-delete <project-id> <workflow-id>')
359
431
. action ( ( projectId , workflowId ) => {
360
432
checkOptions ( ) ;
361
433
debug ( "Deleting Workflow [" + workflowId + "]" ) ;
362
- wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
434
+ wf . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
363
435
wf . deletewf ( workflowId ) ;
364
436
} ) ;
365
437
366
438
program . command ( 'workflow-execute <project-id> <workflow-id>' )
367
439
. description ( 'Execute workflow <workflow-id> from project <project-id>' )
368
440
. action ( ( projectId , workflowId ) => {
369
441
checkOptions ( ) ;
370
- wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
442
+ wf . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
371
443
wf . runwf ( workflowId )
372
444
} ) ;
373
445
374
446
program . command ( 'workflow-status <project-id> <run-id>' )
375
447
. description ( 'Gets Execution status for workflow execution <run-id>' )
376
448
. action ( ( projectId , runId ) => {
377
449
checkOptions ( ) ;
378
- wf . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
450
+ wf . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
379
451
wf . statuswf ( runId ) ;
380
452
} ) ;
381
453
@@ -388,33 +460,36 @@ program.command('flowservice-export <project-id> <flow-name> <file-name>')
388
460
. description ( 'Export FlowService with name <flow-name> from project <project-id>' )
389
461
. action ( ( projectId , flowName , filename ) => {
390
462
checkOptions ( ) ;
391
- flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
463
+ flowservice . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
392
464
flowservice . exportFlowService ( flowName , filename ) ;
393
465
} ) ;
394
466
395
467
program . command ( 'flowservice-import <project-id> <filename>' )
396
468
. description ( 'Import FlowService from <filename> into project <project-id>' )
397
469
. action ( ( projectId , filename ) => {
398
470
checkOptions ( ) ;
399
- flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
471
+ flowservice . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
400
472
flowservice . importFlowService ( filename ) ;
401
473
} ) ;
402
474
403
475
program . command ( 'flowservice-delete <project-id> <flow-name>' )
404
476
. description ( 'Delete FlowService <flow-name> from project <project-id>' )
405
477
. action ( ( projectId , flowName ) => {
406
478
checkOptions ( ) ;
407
- flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
479
+ flowservice . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
408
480
flowservice . deleteFlowService ( flowName ) ;
409
481
} ) ;
410
482
411
483
program . command ( 'flowservice-execute <project-id> <flow-name> [input-json]' )
412
484
. description ( 'Execute FlowService <flow-name> from project <project-id> with data <input-json>' )
413
485
. action ( ( projectId , flowName , inputJson ) => {
414
486
checkOptions ( ) ;
415
- flowservice . init ( program . opts ( ) . domain , program . opts ( ) . user , program . opts ( ) . password , program . opts ( ) . timeout , projectId ) ;
487
+ flowservice . init ( tenantDomain , tenantUser , tenantPw , program . opts ( ) . timeout , projectId ) ;
416
488
flowservice . runFlowService ( flowName , inputJson ) ;
417
489
} ) ;
418
490
491
+
419
492
program . parse ( ) ;
420
493
494
+
495
+
0 commit comments