@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.
@@ -36,155 +36,155 @@ class UpdateCommand extends base_1.BaseCommand {
36
36
  const { args, flags } = await this.parse(UpdateCommand);
37
37
  const { endpoint, insecure } = flags;
38
38
  const api = new sdk_1.default.Trunks({ endpoint, insecure });
39
- this.log("This utility will help you update an existing Trunk.");
40
- this.log("Press ^C at any time to quit.");
41
- this.warn("Adding Outbound SIP URIs will delete existing ones.");
42
- const trunkFromDB = await api.getTrunk(args.ref);
43
- // TODO: Add support for pagination
44
- const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
45
- pageSize: 25,
46
- pageToken: ""
47
- });
48
- const aclChoices = acls.items.map((acl) => {
49
- return {
50
- name: acl.name,
51
- value: acl.ref
52
- };
53
- });
54
- const credentials = await new sdk_1.default.Credentials({
55
- endpoint,
56
- insecure
57
- }).listCredentials({
58
- pageSize: 25,
59
- pageToken: ""
60
- });
61
- const credentialsChoice = credentials.items.map((acl) => {
62
- return {
63
- name: acl.name,
64
- value: acl.ref
65
- };
66
- });
67
- const group1 = await inquirer_1.default.prompt([
68
- {
69
- name: "name",
70
- message: "Friendly Name",
71
- type: "input",
72
- default: trunkFromDB.name,
73
- validate: validators_1.nameValidator
74
- },
75
- {
76
- name: "inboundUri",
77
- message: "Inbound SIP URI",
78
- type: "input",
79
- validate: validators_1.inboundUriValidator,
80
- default: trunkFromDB.inboundUri
81
- },
82
- {
83
- name: "accessControlListRef",
84
- message: "IP Access Control List",
85
- type: "list",
86
- default: trunkFromDB.accessControlListRef,
87
- choices: [{ name: "None", value: undefined }, ...aclChoices]
88
- },
89
- {
90
- name: "inboundCredentialsRef",
91
- message: "Inbound Credentials",
92
- type: "list",
93
- default: trunkFromDB.inboundCredentialsRef,
94
- choices: [{ name: "None", value: undefined }, ...credentialsChoice]
95
- },
96
- {
97
- name: "outboundCredentialsRef",
98
- message: "Outbound Credentials",
99
- type: "list",
100
- default: trunkFromDB.outboundCredentialsRef,
101
- choices: [{ name: "None", value: undefined }, ...credentialsChoice]
102
- },
103
- {
104
- name: "addOutboundUri",
105
- message: "Add an Outbound SIP URI?",
106
- type: "confirm",
107
- default: false
39
+ try {
40
+ const trunkFromDB = await api.getTrunk(args.ref);
41
+ // TODO: Add support for pagination
42
+ const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
43
+ pageSize: 25,
44
+ pageToken: ""
45
+ });
46
+ const aclChoices = acls.items.map((acl) => {
47
+ return {
48
+ name: acl.name,
49
+ value: acl.ref
50
+ };
51
+ });
52
+ const credentials = await new sdk_1.default.Credentials({
53
+ endpoint,
54
+ insecure
55
+ }).listCredentials({
56
+ pageSize: 25,
57
+ pageToken: ""
58
+ });
59
+ const credentialsChoice = credentials.items.map((acl) => {
60
+ return {
61
+ name: acl.name,
62
+ value: acl.ref
63
+ };
64
+ });
65
+ this.log("This utility will help you update an existing Trunk.");
66
+ this.log("Press ^C at any time to quit.");
67
+ this.warn("Adding Outbound SIP URIs will delete existing ones.");
68
+ const group1 = await inquirer_1.default.prompt([
69
+ {
70
+ name: "name",
71
+ message: "Friendly Name",
72
+ type: "input",
73
+ default: trunkFromDB.name,
74
+ validate: validators_1.nameValidator
75
+ },
76
+ {
77
+ name: "inboundUri",
78
+ message: "Inbound SIP URI",
79
+ type: "input",
80
+ validate: validators_1.inboundUriValidator,
81
+ default: trunkFromDB.inboundUri
82
+ },
83
+ {
84
+ name: "accessControlListRef",
85
+ message: "IP Access Control List",
86
+ type: "list",
87
+ default: trunkFromDB.accessControlListRef,
88
+ choices: [{ name: "None", value: undefined }, ...aclChoices]
89
+ },
90
+ {
91
+ name: "inboundCredentialsRef",
92
+ message: "Inbound Credentials",
93
+ type: "list",
94
+ default: trunkFromDB.inboundCredentialsRef,
95
+ choices: [{ name: "None", value: undefined }, ...credentialsChoice]
96
+ },
97
+ {
98
+ name: "outboundCredentialsRef",
99
+ message: "Outbound Credentials",
100
+ type: "list",
101
+ default: trunkFromDB.outboundCredentialsRef,
102
+ choices: [{ name: "None", value: undefined }, ...credentialsChoice]
103
+ },
104
+ {
105
+ name: "addOutboundUri",
106
+ message: "Add an Outbound SIP URI?",
107
+ type: "confirm",
108
+ default: false
109
+ }
110
+ ]);
111
+ const group2Questions = [
112
+ {
113
+ name: "host",
114
+ message: "Host",
115
+ type: "input",
116
+ validate: validators_1.hostValidator
117
+ },
118
+ {
119
+ name: "port",
120
+ message: "Post",
121
+ type: "input",
122
+ default: "5060",
123
+ validate: validators_1.portValidator
124
+ },
125
+ {
126
+ name: "transport",
127
+ message: "Transport",
128
+ type: "list",
129
+ choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
130
+ default: common_1.CommonTypes.Transport.UDP
131
+ },
132
+ {
133
+ name: "user",
134
+ message: "User Part",
135
+ type: "input",
136
+ validate: validators_1.optionalUsernameValidator
137
+ },
138
+ {
139
+ name: "priority",
140
+ message: "Priority",
141
+ type: "input",
142
+ default: "10",
143
+ validate: validators_1.priorityValidator
144
+ },
145
+ {
146
+ name: "weight",
147
+ message: "Weight",
148
+ type: "input",
149
+ default: "10",
150
+ validate: validators_1.weightValidator
151
+ },
152
+ {
153
+ name: "addOutboundUri",
154
+ message: "Add another Outbound SIP URI?",
155
+ type: "confirm",
156
+ default: false
157
+ }
158
+ ];
159
+ let addOutboundUri = group1.addOutboundUri;
160
+ const uris = [];
161
+ // eslint-disable-next-line no-loops/no-loops
162
+ while (addOutboundUri) {
163
+ const group2 = await inquirer_1.default.prompt(group2Questions);
164
+ if (group2.numberRef) {
165
+ uris.push({
166
+ host: group2.host,
167
+ port: group2.port,
168
+ transport: group2.transport,
169
+ user: group2.user,
170
+ priority: group2.priority,
171
+ weight: group2.weight,
172
+ enabled: true
173
+ });
174
+ }
175
+ addOutboundUri = group2.addOutboundUri;
108
176
  }
109
- ]);
110
- const group2Questions = [
111
- {
112
- name: "host",
113
- message: "Host",
114
- type: "input",
115
- validate: validators_1.hostValidator
116
- },
117
- {
118
- name: "port",
119
- message: "Post",
120
- type: "input",
121
- default: "5060",
122
- validate: validators_1.portValidator
123
- },
124
- {
125
- name: "transport",
126
- message: "Transport",
127
- type: "list",
128
- choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
129
- default: common_1.CommonTypes.Transport.UDP
130
- },
131
- {
132
- name: "user",
133
- message: "User Part",
134
- type: "input",
135
- validate: validators_1.optionalUsernameValidator
136
- },
137
- {
138
- name: "priority",
139
- message: "Priority",
140
- type: "input",
141
- default: "10",
142
- validate: validators_1.priorityValidator
143
- },
144
- {
145
- name: "weight",
146
- message: "Weight",
147
- type: "input",
148
- default: "10",
149
- validate: validators_1.weightValidator
150
- },
151
- {
152
- name: "addOutboundUri",
153
- message: "Add another Outbound SIP URI?",
154
- type: "confirm",
155
- default: false
177
+ const group3 = await inquirer_1.default.prompt([
178
+ {
179
+ name: "confirm",
180
+ message: "Ready?",
181
+ type: "confirm"
182
+ }
183
+ ]);
184
+ if (!group3.confirm) {
185
+ this.warn("Aborted");
156
186
  }
157
- ];
158
- let addOutboundUri = group1.addOutboundUri;
159
- const uris = [];
160
- // eslint-disable-next-line no-loops/no-loops
161
- while (addOutboundUri) {
162
- const group2 = await inquirer_1.default.prompt(group2Questions);
163
- if (group2.numberRef) {
164
- uris.push({
165
- host: group2.host,
166
- port: group2.port,
167
- transport: group2.transport,
168
- user: group2.user,
169
- priority: group2.priority,
170
- weight: group2.weight,
171
- enabled: true
172
- });
173
- }
174
- addOutboundUri = group2.addOutboundUri;
175
- }
176
- const group3 = await inquirer_1.default.prompt([
177
- {
178
- name: "confirm",
179
- message: "Ready?",
180
- type: "confirm"
181
- }
182
- ]);
183
- if (!group3.confirm) {
184
- this.warn("Aborted");
185
- }
186
- else {
187
- try {
187
+ else {
188
188
  core_1.CliUx.ux.action.start(`Updating Trunk ${group1.name}`);
189
189
  const trunk = await api.updateTrunk({
190
190
  ref: trunkFromDB.ref,
@@ -194,10 +194,10 @@ class UpdateCommand extends base_1.BaseCommand {
194
194
  await core_1.CliUx.ux.wait(1000);
195
195
  core_1.CliUx.ux.action.stop(trunk.ref);
196
196
  }
197
- catch (e) {
198
- core_1.CliUx.ux.action.stop();
199
- throw new errors_1.CLIError(e.message);
200
- }
197
+ }
198
+ catch (e) {
199
+ core_1.CliUx.ux.action.stop();
200
+ throw new errors_1.CLIError(e.message);
201
201
  }
202
202
  }
203
203
  }
package/dist/delete.js CHANGED
@@ -31,9 +31,14 @@ class DeleteCommand extends base_1.BaseCommand {
31
31
  throw new errors_1.CLIError("You must provide a resource ref before continuing");
32
32
  }
33
33
  core_1.CliUx.ux.action.start(`Deleting item ${args.ref}`);
34
- await API[funcName](args.ref);
35
- await core_1.CliUx.ux.wait(1000);
36
- core_1.CliUx.ux.action.stop("Done");
34
+ try {
35
+ await API[funcName](args.ref);
36
+ await core_1.CliUx.ux.wait(1000);
37
+ core_1.CliUx.ux.action.stop("Done");
38
+ }
39
+ catch (e) {
40
+ throw new errors_1.CLIError(e.message);
41
+ }
37
42
  }
38
43
  async catch(err) {
39
44
  return super.catch(err);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.8-alpha.23",
2
+ "version": "2.0.8-alpha.24",
3
3
  "commands": {
4
4
  "acl:create": {
5
5
  "id": "acl:create",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/ctl",
3
- "version": "2.0.8-alpha.23",
3
+ "version": "2.0.8-alpha.24",
4
4
  "description": "Routr Command-Line Tool",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "bin": {
@@ -25,8 +25,8 @@
25
25
  "@oclif/plugin-help": "^5",
26
26
  "@oclif/plugin-plugins": "^2.1.12",
27
27
  "@oclif/plugin-warn-if-update-available": "^2.0.19",
28
- "@routr/common": "^2.0.8-alpha.23",
29
- "@routr/sdk": "^2.0.8-alpha.23",
28
+ "@routr/common": "^2.0.8-alpha.24",
29
+ "@routr/sdk": "^2.0.8-alpha.24",
30
30
  "figlet": "^1.5.2",
31
31
  "fuzzy-search": "^3.2.1",
32
32
  "inquirer": "^8.2.5",
@@ -85,5 +85,5 @@
85
85
  "oclif"
86
86
  ],
87
87
  "types": "dist/index.d.ts",
88
- "gitHead": "1347b753f0dbdd3bdf423f2691867aa250b768af"
88
+ "gitHead": "ee7b11cd563083ef64e796a3bae343b4f40fac1c"
89
89
  }