@@ -13,8 +13,27 @@ var flowservice = require('./flowservice.js');
1313var prettyprint = false ;
1414var compat = false ;
1515
16+ var tenantDomain ;
17+ var tenantUser ;
18+ var tenantPw ;
19+
1620const { Command, Option } = require ( 'commander' ) ;
1721const { 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+ }
1837
1938function checkOptions ( ) {
2039 if ( program . opts ( ) . verbose == true ) {
@@ -26,6 +45,27 @@ function checkOptions(){
2645 prettyprint = true ;
2746 }
2847
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+
2969}
3070
3171function debug ( message ) {
@@ -38,9 +78,10 @@ program
3878 . version ( '2022.07.1' )
3979
4080//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')
4485
4586//options
4687 . addOption ( new Option ( '-t, --timeout <delay>' , 'timeout in seconds' ) . default ( 60 , 'one minute' ) )
@@ -122,12 +163,12 @@ Examples:
122163 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":[]}}'
123164
124165
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
131172
132173 \x1b[4mWorkflow\x1b[0m
133174
@@ -197,7 +238,38 @@ Examples:
197238 -d tenant.int-aws-us.webmethods.io
198239 -u user
199240 -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'
201273` )
202274
203275 . showSuggestionAfterError ( )
@@ -212,7 +284,7 @@ program.command('project [project-name]')
212284. description ( 'Lists all projects or view an individual project, specified via project name or uid' )
213285. action ( ( projectName ) => {
214286 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 )
216288 var resp = project . list ( projectName ) ;
217289 if ( resp ) console . log ( resp ) ;
218290} ) ;
@@ -221,7 +293,7 @@ program.command('project-assets <project-name>')
221293. description ( 'Lists project assets from given project name or uid' )
222294. action ( ( projectName ) => {
223295 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 )
225297 var resp = project . listAssets ( projectName ) ;
226298 if ( resp ) console . log ( resp ) ;
227299} ) ;
@@ -230,31 +302,31 @@ program.command('project-create <project-name>')
230302. description ( 'Create project with given name' )
231303. action ( ( projectName ) => {
232304 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 )
234306 project . create ( projectName ) ;
235307} ) ;
236308
237309program . command ( 'project-update <project-id> <project-name>' )
238310. description ( 'Update project with new name' )
239311. action ( ( projectId , projectName ) => {
240312 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 )
242314 project . update ( projectId , projectName ) ;
243315} ) ;
244316
245317program . command ( 'project-delete <project-id>' )
246318. description ( 'Delete project with given id' )
247319. action ( ( projectId ) => {
248320 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 )
250322 project . del ( projectId ) ;
251323} ) ;
252324
253325program . command ( 'project-publish <project-id> <publish-name> <target-tenant-domain-name> <target-user-id> <target-user-password> <assets-json>' )
254326. description ( 'Pubilsh project to another tenant with given id' )
255327. action ( ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) => {
256328 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 )
258330 project . pub ( projectId , publishName , targetTenantDomainName , targetUserId , targetUserPassword , assetsJson ) ;
259331
260332} ) ;
@@ -263,7 +335,7 @@ program.command('project-deploy <projectName> <version>')
263335. description ( 'deploy published project with given version into tenant' )
264336. action ( ( projectName , version ) => {
265337 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 )
267339 project . deploy ( projectName , version ) ;
268340} ) ;
269341
@@ -276,7 +348,7 @@ program.command('role [role-id]')
276348. description ( 'Lists all roles or views an individual role' )
277349. action ( ( roleId ) => {
278350 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 )
280352 var resp = role . list ( roleId ) ;
281353 if ( resp ) console . log ( resp ) ;
282354} ) ;
@@ -285,23 +357,23 @@ program.command('role-create <role-name> <role-description> <roles-list>')
285357. 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;' )
286358. action ( ( roleName , roleDescription , rolesList ) => {
287359 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 ) ;
289361 role . insert ( roleName , roleDescription , rolesList ) ;
290362} ) ;
291363
292364program . command ( 'role-update <role-id> <role-name> <role-description> <roles-list>' )
293365. 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;' )
294366. action ( ( roleId , roleName , roleDescription , rolesList ) => {
295367 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 ) ;
297369 role . update ( roleId , roleName , roleDescription , rolesList ) ;
298370} ) ;
299371
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 ) => {
303375 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 ) ;
305377 role . del ( roleId ) ;
306378} ) ;
307379
@@ -318,7 +390,7 @@ program.command('user')
318390. description ( 'Lists all users' )
319391. action ( ( ) => {
320392 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 ) ;
322394 user . list ( undefined ) ;
323395} ) ;
324396
@@ -328,7 +400,7 @@ program.command('user-role-assignment <user-id> <role-names>')
328400 checkOptions ( ) ;
329401 debug ( "userId: " + userId ) ;
330402 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 ) ;
332404 user . assignRoles ( userId , roleNames ) ;
333405} ) ;
334406
@@ -341,7 +413,7 @@ program.command('workflow-export <project-id> <workflow-id> <filename>')
341413. description ( 'Export workflow with id <workflow-id> from project <project-id>' )
342414. action ( ( projectId , workflowId , filename ) => {
343415 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 ) ;
345417 wf . exportwf ( workflowId , filename ) ;
346418} ) ;
347419
@@ -350,7 +422,7 @@ program.command('workflow-import <project-id> <filename>')
350422. action ( ( projectId , filename ) => {
351423 checkOptions ( ) ;
352424 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 ) ;
354426 wf . importwf ( filename ) ;
355427} ) ;
356428
@@ -359,23 +431,23 @@ program.command('workflow-delete <project-id> <workflow-id>')
359431. action ( ( projectId , workflowId ) => {
360432 checkOptions ( ) ;
361433 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 ) ;
363435 wf . deletewf ( workflowId ) ;
364436} ) ;
365437
366438program . command ( 'workflow-execute <project-id> <workflow-id>' )
367439 . description ( 'Execute workflow <workflow-id> from project <project-id>' )
368440. action ( ( projectId , workflowId ) => {
369441 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 ) ;
371443 wf . runwf ( workflowId )
372444} ) ;
373445
374446program . command ( 'workflow-status <project-id> <run-id>' )
375447. description ( 'Gets Execution status for workflow execution <run-id>' )
376448. action ( ( projectId , runId ) => {
377449 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 ) ;
379451 wf . statuswf ( runId ) ;
380452} ) ;
381453
@@ -388,33 +460,36 @@ program.command('flowservice-export <project-id> <flow-name> <file-name>')
388460. description ( 'Export FlowService with name <flow-name> from project <project-id>' )
389461. action ( ( projectId , flowName , filename ) => {
390462 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 ) ;
392464 flowservice . exportFlowService ( flowName , filename ) ;
393465} ) ;
394466
395467program . command ( 'flowservice-import <project-id> <filename>' )
396468. description ( 'Import FlowService from <filename> into project <project-id>' )
397469. action ( ( projectId , filename ) => {
398470 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 ) ;
400472 flowservice . importFlowService ( filename ) ;
401473} ) ;
402474
403475program . command ( 'flowservice-delete <project-id> <flow-name>' )
404476. description ( 'Delete FlowService <flow-name> from project <project-id>' )
405477. action ( ( projectId , flowName ) => {
406478 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 ) ;
408480 flowservice . deleteFlowService ( flowName ) ;
409481} ) ;
410482
411483program . command ( 'flowservice-execute <project-id> <flow-name> [input-json]' )
412484 . description ( 'Execute FlowService <flow-name> from project <project-id> with data <input-json>' )
413485. action ( ( projectId , flowName , inputJson ) => {
414486 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 ) ;
416488 flowservice . runFlowService ( flowName , inputJson ) ;
417489} ) ;
418490
491+
419492program . parse ( ) ;
420493
494+
495+
0 commit comments