@routr/ctl 2.0.8-alpha.23 → 2.0.8-alpha.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,51 +34,51 @@ class UpdateCommand extends base_1.BaseCommand {
34
34
  async run() {
35
35
  const { args, flags } = await this.parse(UpdateCommand);
36
36
  const { endpoint, insecure } = flags;
37
- const api = new sdk_1.default.Credentials({ endpoint, insecure });
38
- this.log("This utility will help you update an existing set of Credentials.");
39
- this.log("Press ^C at any time to quit.");
40
- const credentialsFromDB = await api.getCredentials(args.ref);
41
- const answers = await inquirer_1.default.prompt([
42
- {
43
- name: "name",
44
- message: "Friendly Name",
45
- type: "input",
46
- default: credentialsFromDB.name,
47
- validate: validators_1.nameValidator
48
- },
49
- {
50
- name: "username",
51
- message: "Username",
52
- type: "input",
53
- default: credentialsFromDB.username,
54
- validate: validators_1.usernameValidator
55
- },
56
- {
57
- name: "password",
58
- message: "Password",
59
- type: "password"
60
- },
61
- {
62
- name: "confirm",
63
- message: "Ready?",
64
- type: "confirm"
37
+ try {
38
+ const api = new sdk_1.default.Credentials({ endpoint, insecure });
39
+ const credentialsFromDB = await api.getCredentials(args.ref);
40
+ this.log("This utility will help you update an existing set of Credentials.");
41
+ this.log("Press ^C at any time to quit.");
42
+ const answers = await inquirer_1.default.prompt([
43
+ {
44
+ name: "name",
45
+ message: "Friendly Name",
46
+ type: "input",
47
+ default: credentialsFromDB.name,
48
+ validate: validators_1.nameValidator
49
+ },
50
+ {
51
+ name: "username",
52
+ message: "Username",
53
+ type: "input",
54
+ default: credentialsFromDB.username,
55
+ validate: validators_1.usernameValidator
56
+ },
57
+ {
58
+ name: "password",
59
+ message: "Password",
60
+ type: "password"
61
+ },
62
+ {
63
+ name: "confirm",
64
+ message: "Ready?",
65
+ type: "confirm"
66
+ }
67
+ ]);
68
+ answers.ref = args.ref;
69
+ if (!answers.confirm) {
70
+ this.warn("Aborted");
65
71
  }
66
- ]);
67
- answers.ref = args.ref;
68
- if (!answers.confirm) {
69
- this.warn("Aborted");
70
- }
71
- else {
72
- try {
72
+ else {
73
73
  core_1.CliUx.ux.action.start(`Updating Credentials for ${answers.name}`);
74
74
  const acl = await api.updateCredentials(answers);
75
75
  await core_1.CliUx.ux.wait(1000);
76
76
  core_1.CliUx.ux.action.stop(acl.ref);
77
77
  }
78
- catch (e) {
79
- core_1.CliUx.ux.action.stop();
80
- throw new errors_1.CLIError(e.message);
81
- }
78
+ }
79
+ catch (e) {
80
+ core_1.CliUx.ux.action.stop();
81
+ throw new errors_1.CLIError(e.message);
82
82
  }
83
83
  }
84
84
  }
@@ -58,105 +58,105 @@ class CreateCommand extends base_1.BaseCommand {
58
58
  async run() {
59
59
  const { flags } = await this.parse(CreateCommand);
60
60
  const { endpoint, insecure } = flags;
61
- this.log("This utility will help you create a new Domain.");
62
- this.log("Press ^C at any time to quit.");
63
- // TODO: Fix hardcoded pageSize
64
- const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
65
- pageSize: 25,
66
- pageToken: ""
67
- });
68
- const aclChoices = acls.items.map((acl) => {
69
- return {
70
- name: acl.name,
71
- value: acl.ref
72
- };
73
- });
74
- // TODO: Fix hardcoded pageSize
75
- const numbers = await new sdk_1.default.Numbers({ endpoint, insecure }).listNumbers({
76
- pageSize: 25,
77
- pageToken: ""
78
- });
79
- const numberChoices = numbers.items.map((number) => {
80
- return {
81
- name: number.name,
82
- value: number.ref
83
- };
84
- });
85
- const group1 = await inquirer_1.default.prompt([
86
- {
87
- name: "name",
88
- message: "Friendly Name",
89
- type: "input",
90
- validate: validators_1.nameValidator
91
- },
92
- {
93
- name: "domainUri",
94
- message: "SIP URI",
95
- type: "input",
96
- validate: validators_1.domainUriValidator
97
- },
98
- {
99
- name: "accessControlListRef",
100
- message: "IP Access Control List",
101
- type: "list",
102
- choices: [{ name: "None", value: undefined }, ...aclChoices]
103
- },
104
- {
105
- name: "addEgressRule",
106
- message: "Add an Egress Rule?",
107
- type: "confirm",
108
- default: false,
109
- when: numberChoices.length > 0
110
- }
111
- ]);
112
- const group2Questions = [
113
- {
114
- name: "numberRef",
115
- message: "Number",
116
- type: "list",
117
- choices: [{ name: "None", value: undefined }, ...numberChoices],
118
- when: numberChoices.length > 0
119
- },
120
- {
121
- name: "rule",
122
- message: "Rule",
123
- type: "input",
124
- default: ".*",
125
- when: (answers) => answers.numberRef
126
- },
127
- {
128
- name: "addEgressRule",
129
- message: "Add another Egress Rule?",
130
- type: "confirm",
131
- default: false,
132
- when: (answers) => answers.numberRef
133
- }
134
- ];
135
- let addEgressRule = group1.addEgressRule;
136
- const egressPolicies = [];
137
- // eslint-disable-next-line no-loops/no-loops
138
- while (addEgressRule) {
139
- const group2 = await inquirer_1.default.prompt(group2Questions);
140
- if (group2.numberRef) {
141
- egressPolicies.push({
142
- numberRef: group2.numberRef,
143
- rule: group2.rule
144
- });
61
+ try {
62
+ // TODO: Fix hardcoded pageSize
63
+ const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
64
+ pageSize: 25,
65
+ pageToken: ""
66
+ });
67
+ const aclChoices = acls.items.map((acl) => {
68
+ return {
69
+ name: acl.name,
70
+ value: acl.ref
71
+ };
72
+ });
73
+ // TODO: Fix hardcoded pageSize
74
+ const numbers = await new sdk_1.default.Numbers({ endpoint, insecure }).listNumbers({
75
+ pageSize: 25,
76
+ pageToken: ""
77
+ });
78
+ const numberChoices = numbers.items.map((number) => {
79
+ return {
80
+ name: number.name,
81
+ value: number.ref
82
+ };
83
+ });
84
+ this.log("This utility will help you create a new Domain.");
85
+ this.log("Press ^C at any time to quit.");
86
+ const group1 = await inquirer_1.default.prompt([
87
+ {
88
+ name: "name",
89
+ message: "Friendly Name",
90
+ type: "input",
91
+ validate: validators_1.nameValidator
92
+ },
93
+ {
94
+ name: "domainUri",
95
+ message: "SIP URI",
96
+ type: "input",
97
+ validate: validators_1.domainUriValidator
98
+ },
99
+ {
100
+ name: "accessControlListRef",
101
+ message: "IP Access Control List",
102
+ type: "list",
103
+ choices: [{ name: "None", value: undefined }, ...aclChoices]
104
+ },
105
+ {
106
+ name: "addEgressRule",
107
+ message: "Add an Egress Rule?",
108
+ type: "confirm",
109
+ default: false,
110
+ when: numberChoices.length > 0
111
+ }
112
+ ]);
113
+ const group2Questions = [
114
+ {
115
+ name: "numberRef",
116
+ message: "Number",
117
+ type: "list",
118
+ choices: [{ name: "None", value: undefined }, ...numberChoices],
119
+ when: numberChoices.length > 0
120
+ },
121
+ {
122
+ name: "rule",
123
+ message: "Rule",
124
+ type: "input",
125
+ default: ".*",
126
+ when: (answers) => answers.numberRef
127
+ },
128
+ {
129
+ name: "addEgressRule",
130
+ message: "Add another Egress Rule?",
131
+ type: "confirm",
132
+ default: false,
133
+ when: (answers) => answers.numberRef
134
+ }
135
+ ];
136
+ let addEgressRule = group1.addEgressRule;
137
+ const egressPolicies = [];
138
+ // eslint-disable-next-line no-loops/no-loops
139
+ while (addEgressRule) {
140
+ const group2 = await inquirer_1.default.prompt(group2Questions);
141
+ if (group2.numberRef) {
142
+ egressPolicies.push({
143
+ numberRef: group2.numberRef,
144
+ rule: group2.rule
145
+ });
146
+ }
147
+ addEgressRule = group2.addEgressRule;
145
148
  }
146
- addEgressRule = group2.addEgressRule;
147
- }
148
- const group3 = await inquirer_1.default.prompt([
149
- {
150
- name: "confirm",
151
- message: "Ready?",
152
- type: "confirm"
149
+ const group3 = await inquirer_1.default.prompt([
150
+ {
151
+ name: "confirm",
152
+ message: "Ready?",
153
+ type: "confirm"
154
+ }
155
+ ]);
156
+ if (!group3.confirm) {
157
+ this.warn("Aborted");
153
158
  }
154
- ]);
155
- if (!group3.confirm) {
156
- this.warn("Aborted");
157
- }
158
- else {
159
- try {
159
+ else {
160
160
  core_1.CliUx.ux.action.start(`Creating Domain ${group1.name}`);
161
161
  const api = new sdk_1.default.Domains({ endpoint, insecure });
162
162
  const domains = await api.createDomain({
@@ -166,14 +166,14 @@ class CreateCommand extends base_1.BaseCommand {
166
166
  await core_1.CliUx.ux.wait(1000);
167
167
  core_1.CliUx.ux.action.stop(domains.ref);
168
168
  }
169
- catch (e) {
170
- core_1.CliUx.ux.action.stop();
171
- if (e.code === grpc.status.ALREADY_EXISTS) {
172
- throw new errors_1.CLIError("This Domain already exist");
173
- }
174
- else {
175
- throw new errors_1.CLIError(e.message);
176
- }
169
+ }
170
+ catch (e) {
171
+ core_1.CliUx.ux.action.stop();
172
+ if (e.code === grpc.status.ALREADY_EXISTS) {
173
+ throw new errors_1.CLIError("This Domain already exist");
174
+ }
175
+ else {
176
+ throw new errors_1.CLIError(e.message);
177
177
  }
178
178
  }
179
179
  }
@@ -34,103 +34,103 @@ class UpdateCommand extends base_1.BaseCommand {
34
34
  async run() {
35
35
  const { args, flags } = await this.parse(UpdateCommand);
36
36
  const { endpoint, insecure } = flags;
37
- const api = new sdk_1.default.Domains({ endpoint, insecure });
38
- this.log("This utility will help you update an existing Domain.");
39
- this.log("Press ^C at any time to quit.");
40
- this.warn("Adding Egress Policies will delete existing ones.");
41
- const domainFromDB = await api.getDomain(args.ref);
42
- // TODO: Fix hardcoded pageSize
43
- const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
44
- pageSize: 25,
45
- pageToken: ""
46
- });
47
- const aclChoices = acls.items.map((acl) => {
48
- return {
49
- name: acl.name,
50
- value: acl.ref
51
- };
52
- });
53
- // TODO: Fix hardcoded pageSize
54
- const numbers = await new sdk_1.default.Numbers({ endpoint, insecure }).listNumbers({
55
- pageSize: 25,
56
- pageToken: ""
57
- });
58
- const numberChoices = numbers.items.map((number) => {
59
- return {
60
- name: number.name,
61
- value: number.ref
62
- };
63
- });
64
- const group1 = await inquirer_1.default.prompt([
65
- {
66
- name: "name",
67
- message: "Friendly Name",
68
- type: "input",
69
- default: domainFromDB.name,
70
- validate: validators_1.nameValidator
71
- },
72
- {
73
- name: "accessControlListRef",
74
- message: "IP Access Control List",
75
- type: "list",
76
- choices: [{ name: "None", value: undefined }, ...aclChoices],
77
- default: domainFromDB.accessControlListRef
78
- },
79
- {
80
- name: "addEgressRule",
81
- message: "Add an Egress Rule?",
82
- type: "confirm",
83
- default: false,
84
- when: aclChoices.length > 0
37
+ try {
38
+ const api = new sdk_1.default.Domains({ endpoint, insecure });
39
+ const domainFromDB = await api.getDomain(args.ref);
40
+ // TODO: Fix hardcoded pageSize
41
+ const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
42
+ pageSize: 25,
43
+ pageToken: ""
44
+ });
45
+ const aclChoices = acls.items.map((acl) => {
46
+ return {
47
+ name: acl.name,
48
+ value: acl.ref
49
+ };
50
+ });
51
+ // TODO: Fix hardcoded pageSize
52
+ const numbers = await new sdk_1.default.Numbers({ endpoint, insecure }).listNumbers({
53
+ pageSize: 25,
54
+ pageToken: ""
55
+ });
56
+ const numberChoices = numbers.items.map((number) => {
57
+ return {
58
+ name: number.name,
59
+ value: number.ref
60
+ };
61
+ });
62
+ this.log("This utility will help you update an existing Domain.");
63
+ this.log("Press ^C at any time to quit.");
64
+ this.warn("Adding Egress Policies will delete existing ones.");
65
+ const group1 = await inquirer_1.default.prompt([
66
+ {
67
+ name: "name",
68
+ message: "Friendly Name",
69
+ type: "input",
70
+ default: domainFromDB.name,
71
+ validate: validators_1.nameValidator
72
+ },
73
+ {
74
+ name: "accessControlListRef",
75
+ message: "IP Access Control List",
76
+ type: "list",
77
+ choices: [{ name: "None", value: undefined }, ...aclChoices],
78
+ default: domainFromDB.accessControlListRef
79
+ },
80
+ {
81
+ name: "addEgressRule",
82
+ message: "Add an Egress Rule?",
83
+ type: "confirm",
84
+ default: false,
85
+ when: aclChoices.length > 0
86
+ }
87
+ ]);
88
+ const group2Questions = [
89
+ {
90
+ name: "numberRef",
91
+ message: "Number",
92
+ type: "list",
93
+ choices: [{ name: "None", value: undefined }, ...numberChoices]
94
+ },
95
+ {
96
+ name: "rule",
97
+ message: "Rule",
98
+ type: "input",
99
+ default: ".*",
100
+ when: (answers) => answers.numberRef
101
+ },
102
+ {
103
+ name: "addEgressRule",
104
+ message: "Add another Egress Rule?",
105
+ type: "confirm",
106
+ default: false,
107
+ when: (answers) => answers.numberRef
108
+ }
109
+ ];
110
+ let addEgressRule = group1.addEgressRule;
111
+ const egressPolicies = [];
112
+ // eslint-disable-next-line no-loops/no-loops
113
+ while (addEgressRule) {
114
+ const group2 = await inquirer_1.default.prompt(group2Questions);
115
+ if (group2.numberRef) {
116
+ egressPolicies.push({
117
+ numberRef: group2.numberRef,
118
+ rule: group2.rule
119
+ });
120
+ }
121
+ addEgressRule = group2.addEgressRule;
85
122
  }
86
- ]);
87
- const group2Questions = [
88
- {
89
- name: "numberRef",
90
- message: "Number",
91
- type: "list",
92
- choices: [{ name: "None", value: undefined }, ...numberChoices]
93
- },
94
- {
95
- name: "rule",
96
- message: "Rule",
97
- type: "input",
98
- default: ".*",
99
- when: (answers) => answers.numberRef
100
- },
101
- {
102
- name: "addEgressRule",
103
- message: "Add another Egress Rule?",
104
- type: "confirm",
105
- default: false,
106
- when: (answers) => answers.numberRef
123
+ const group3 = await inquirer_1.default.prompt([
124
+ {
125
+ name: "confirm",
126
+ message: "Ready?",
127
+ type: "confirm"
128
+ }
129
+ ]);
130
+ if (!group3.confirm) {
131
+ this.warn("Aborted");
107
132
  }
108
- ];
109
- let addEgressRule = group1.addEgressRule;
110
- const egressPolicies = [];
111
- // eslint-disable-next-line no-loops/no-loops
112
- while (addEgressRule) {
113
- const group2 = await inquirer_1.default.prompt(group2Questions);
114
- if (group2.numberRef) {
115
- egressPolicies.push({
116
- numberRef: group2.numberRef,
117
- rule: group2.rule
118
- });
119
- }
120
- addEgressRule = group2.addEgressRule;
121
- }
122
- const group3 = await inquirer_1.default.prompt([
123
- {
124
- name: "confirm",
125
- message: "Ready?",
126
- type: "confirm"
127
- }
128
- ]);
129
- if (!group3.confirm) {
130
- this.warn("Aborted");
131
- }
132
- else {
133
- try {
133
+ else {
134
134
  core_1.CliUx.ux.action.start(`Updating Domain ${group1.name}`);
135
135
  const domain = await api.updateDomain({
136
136
  ref: domainFromDB.ref,
@@ -140,10 +140,10 @@ class UpdateCommand extends base_1.BaseCommand {
140
140
  await core_1.CliUx.ux.wait(1000);
141
141
  core_1.CliUx.ux.action.stop(domain.ref);
142
142
  }
143
- catch (e) {
144
- core_1.CliUx.ux.action.stop();
145
- throw new errors_1.CLIError(e.message);
146
- }
143
+ }
144
+ catch (e) {
145
+ core_1.CliUx.ux.action.stop();
146
+ throw new errors_1.CLIError(e.message);
147
147
  }
148
148
  }
149
149
  }