@fonoster/ctl 0.3.1 → 0.3.6-alpha.0

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.
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @fonoster/ctl
21
21
  $ fonoster COMMAND
22
22
  running command...
23
23
  $ fonoster (-v|--version|version)
24
- @fonoster/ctl/0.3.1 darwin-x64 node-v14.16.0
24
+ @fonoster/ctl/0.3.6-alpha.0 darwin-x64 node-v14.16.0
25
25
  $ fonoster --help [COMMAND]
26
26
  USAGE
27
27
  $ fonoster COMMAND
@@ -37,6 +37,10 @@ USAGE
37
37
  * [`fonoster agents:get [REF]`](#fonoster-agentsget-ref)
38
38
  * [`fonoster agents:list`](#fonoster-agentslist)
39
39
  * [`fonoster agents:update [REF]`](#fonoster-agentsupdate-ref)
40
+ * [`fonoster apps:create`](#fonoster-appscreate)
41
+ * [`fonoster apps:delete [REF]`](#fonoster-appsdelete-ref)
42
+ * [`fonoster apps:list`](#fonoster-appslist)
43
+ * [`fonoster apps:update [REF]`](#fonoster-appsupdate-ref)
40
44
  * [`fonoster auth:login`](#fonoster-authlogin)
41
45
  * [`fonoster auth:logout`](#fonoster-authlogout)
42
46
  * [`fonoster bug`](#fonoster-bug)
@@ -69,6 +73,9 @@ USAGE
69
73
  * [`fonoster providers:get [REF]`](#fonoster-providersget-ref)
70
74
  * [`fonoster providers:list`](#fonoster-providerslist)
71
75
  * [`fonoster providers:update [REF]`](#fonoster-providersupdate-ref)
76
+ * [`fonoster secrets:create [NAME]`](#fonoster-secretscreate-name)
77
+ * [`fonoster secrets:delete [NAME]`](#fonoster-secretsdelete-name)
78
+ * [`fonoster secrets:list`](#fonoster-secretslist)
72
79
 
73
80
  ## `fonoster agents:create`
74
81
 
@@ -83,7 +90,7 @@ DESCRIPTION
83
90
  Create a new Fonoster Agent
84
91
  ```
85
92
 
86
- _See code: [dist/commands/agents/create.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/agents/create.js)_
93
+ _See code: [dist/commands/agents/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/agents/create.js)_
87
94
 
88
95
  ## `fonoster agents:delete [REF]`
89
96
 
@@ -98,7 +105,7 @@ ALIASES
98
105
  $ fonoster agents:rm
99
106
  ```
100
107
 
101
- _See code: [dist/commands/agents/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/agents/delete.js)_
108
+ _See code: [dist/commands/agents/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/agents/delete.js)_
102
109
 
103
110
  ## `fonoster agents:get [REF]`
104
111
 
@@ -109,7 +116,7 @@ USAGE
109
116
  $ fonoster agents:get [REF]
110
117
  ```
111
118
 
112
- _See code: [dist/commands/agents/get.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/agents/get.js)_
119
+ _See code: [dist/commands/agents/get.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/agents/get.js)_
113
120
 
114
121
  ## `fonoster agents:list`
115
122
 
@@ -130,7 +137,7 @@ ALIASES
130
137
  $ fonoster agents:ls
131
138
  ```
132
139
 
133
- _See code: [dist/commands/agents/list.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/agents/list.js)_
140
+ _See code: [dist/commands/agents/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/agents/list.js)_
134
141
 
135
142
  ## `fonoster agents:update [REF]`
136
143
 
@@ -145,7 +152,73 @@ DESCRIPTION
145
152
  Update a Fonoster Agent
146
153
  ```
147
154
 
148
- _See code: [dist/commands/agents/update.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/agents/update.js)_
155
+ _See code: [dist/commands/agents/update.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/agents/update.js)_
156
+
157
+ ## `fonoster apps:create`
158
+
159
+ create a new Fonoster App
160
+
161
+ ```
162
+ USAGE
163
+ $ fonoster apps:create
164
+
165
+ DESCRIPTION
166
+ ...
167
+ Create a new Fonoster App
168
+ ```
169
+
170
+ _See code: [dist/commands/apps/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/apps/create.js)_
171
+
172
+ ## `fonoster apps:delete [REF]`
173
+
174
+ delete a Fonoster Application
175
+
176
+ ```
177
+ USAGE
178
+ $ fonoster apps:delete [REF]
179
+
180
+ ALIASES
181
+ $ fonoster apps:del
182
+ $ fonoster apps:rm
183
+ ```
184
+
185
+ _See code: [dist/commands/apps/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/apps/delete.js)_
186
+
187
+ ## `fonoster apps:list`
188
+
189
+ list all Fonoster Apps you have access to
190
+
191
+ ```
192
+ USAGE
193
+ $ fonoster apps:list
194
+
195
+ OPTIONS
196
+ -s, --size=size [default: 25] number of result per page
197
+
198
+ DESCRIPTION
199
+ ...
200
+ List all Fonoster Apps you have access to
201
+
202
+ ALIASES
203
+ $ fonoster apps:ls
204
+ ```
205
+
206
+ _See code: [dist/commands/apps/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/apps/list.js)_
207
+
208
+ ## `fonoster apps:update [REF]`
209
+
210
+ update a new Fonoster App
211
+
212
+ ```
213
+ USAGE
214
+ $ fonoster apps:update [REF]
215
+
216
+ DESCRIPTION
217
+ ...
218
+ Update a new Fonoster App
219
+ ```
220
+
221
+ _See code: [dist/commands/apps/update.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/apps/update.js)_
149
222
 
150
223
  ## `fonoster auth:login`
151
224
 
@@ -156,7 +229,7 @@ USAGE
156
229
  $ fonoster auth:login
157
230
  ```
158
231
 
159
- _See code: [dist/commands/auth/login.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/auth/login.js)_
232
+ _See code: [dist/commands/auth/login.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/auth/login.js)_
160
233
 
161
234
  ## `fonoster auth:logout`
162
235
 
@@ -167,7 +240,7 @@ USAGE
167
240
  $ fonoster auth:logout
168
241
  ```
169
242
 
170
- _See code: [dist/commands/auth/logout.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/auth/logout.js)_
243
+ _See code: [dist/commands/auth/logout.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/auth/logout.js)_
171
244
 
172
245
  ## `fonoster bug`
173
246
 
@@ -182,7 +255,7 @@ DESCRIPTION
182
255
  Opens github issues with a predefine bug template
183
256
  ```
184
257
 
185
- _See code: [dist/commands/bug.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/bug.js)_
258
+ _See code: [dist/commands/bug.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/bug.js)_
186
259
 
187
260
  ## `fonoster domains:create`
188
261
 
@@ -197,7 +270,7 @@ DESCRIPTION
197
270
  Create a new Fonoster Domain
198
271
  ```
199
272
 
200
- _See code: [dist/commands/domains/create.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/domains/create.js)_
273
+ _See code: [dist/commands/domains/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/domains/create.js)_
201
274
 
202
275
  ## `fonoster domains:delete [REF]`
203
276
 
@@ -212,7 +285,7 @@ ALIASES
212
285
  $ fonoster domains:rm
213
286
  ```
214
287
 
215
- _See code: [dist/commands/domains/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/domains/delete.js)_
288
+ _See code: [dist/commands/domains/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/domains/delete.js)_
216
289
 
217
290
  ## `fonoster domains:get [REF]`
218
291
 
@@ -223,7 +296,7 @@ USAGE
223
296
  $ fonoster domains:get [REF]
224
297
  ```
225
298
 
226
- _See code: [dist/commands/domains/get.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/domains/get.js)_
299
+ _See code: [dist/commands/domains/get.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/domains/get.js)_
227
300
 
228
301
  ## `fonoster domains:list`
229
302
 
@@ -244,7 +317,7 @@ ALIASES
244
317
  $ fonoster domains:ls
245
318
  ```
246
319
 
247
- _See code: [dist/commands/domains/list.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/domains/list.js)_
320
+ _See code: [dist/commands/domains/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/domains/list.js)_
248
321
 
249
322
  ## `fonoster domains:update [REF]`
250
323
 
@@ -259,7 +332,7 @@ DESCRIPTION
259
332
  Update a Fonoster Domain
260
333
  ```
261
334
 
262
- _See code: [dist/commands/domains/update.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/domains/update.js)_
335
+ _See code: [dist/commands/domains/update.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/domains/update.js)_
263
336
 
264
337
  ## `fonoster feedback`
265
338
 
@@ -274,7 +347,7 @@ DESCRIPTION
274
347
  Help us improve by providing some feedback
275
348
  ```
276
349
 
277
- _See code: [dist/commands/feedback.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/feedback.js)_
350
+ _See code: [dist/commands/feedback.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/feedback.js)_
278
351
 
279
352
  ## `fonoster help [COMMAND]`
280
353
 
@@ -306,7 +379,7 @@ DESCRIPTION
306
379
  Create a new Fonoster Number
307
380
  ```
308
381
 
309
- _See code: [dist/commands/numbers/create.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/numbers/create.js)_
382
+ _See code: [dist/commands/numbers/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/numbers/create.js)_
310
383
 
311
384
  ## `fonoster numbers:delete [REF]`
312
385
 
@@ -321,7 +394,7 @@ ALIASES
321
394
  $ fonoster numbers:rm
322
395
  ```
323
396
 
324
- _See code: [dist/commands/numbers/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/numbers/delete.js)_
397
+ _See code: [dist/commands/numbers/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/numbers/delete.js)_
325
398
 
326
399
  ## `fonoster numbers:get [REF]`
327
400
 
@@ -332,7 +405,7 @@ USAGE
332
405
  $ fonoster numbers:get [REF]
333
406
  ```
334
407
 
335
- _See code: [dist/commands/numbers/get.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/numbers/get.js)_
408
+ _See code: [dist/commands/numbers/get.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/numbers/get.js)_
336
409
 
337
410
  ## `fonoster numbers:list`
338
411
 
@@ -353,7 +426,7 @@ ALIASES
353
426
  $ fonoster numbers:ls
354
427
  ```
355
428
 
356
- _See code: [dist/commands/numbers/list.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/numbers/list.js)_
429
+ _See code: [dist/commands/numbers/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/numbers/list.js)_
357
430
 
358
431
  ## `fonoster numbers:update [REF]`
359
432
 
@@ -368,7 +441,7 @@ DESCRIPTION
368
441
  Update a Fonoster Number
369
442
  ```
370
443
 
371
- _See code: [dist/commands/numbers/update.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/numbers/update.js)_
444
+ _See code: [dist/commands/numbers/update.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/numbers/update.js)_
372
445
 
373
446
  ## `fonoster plugins`
374
447
 
@@ -521,7 +594,7 @@ DESCRIPTION
521
594
  Create a new Fonoster Project
522
595
  ```
523
596
 
524
- _See code: [dist/commands/projects/create.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/projects/create.js)_
597
+ _See code: [dist/commands/projects/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/projects/create.js)_
525
598
 
526
599
  ## `fonoster projects:delete [REF]`
527
600
 
@@ -536,7 +609,7 @@ ALIASES
536
609
  $ fonoster projects:rm
537
610
  ```
538
611
 
539
- _See code: [dist/commands/projects/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/projects/delete.js)_
612
+ _See code: [dist/commands/projects/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/projects/delete.js)_
540
613
 
541
614
  ## `fonoster projects:get [REF]`
542
615
 
@@ -547,7 +620,7 @@ USAGE
547
620
  $ fonoster projects:get [REF]
548
621
  ```
549
622
 
550
- _See code: [dist/commands/projects/get.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/projects/get.js)_
623
+ _See code: [dist/commands/projects/get.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/projects/get.js)_
551
624
 
552
625
  ## `fonoster projects:list`
553
626
 
@@ -565,7 +638,7 @@ ALIASES
565
638
  $ fonoster projects:ls
566
639
  ```
567
640
 
568
- _See code: [dist/commands/projects/list.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/projects/list.js)_
641
+ _See code: [dist/commands/projects/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/projects/list.js)_
569
642
 
570
643
  ## `fonoster projects:renew [REF]`
571
644
 
@@ -580,7 +653,7 @@ DESCRIPTION
580
653
  Renew the credentials of a Fonoster Project
581
654
  ```
582
655
 
583
- _See code: [dist/commands/projects/renew.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/projects/renew.js)_
656
+ _See code: [dist/commands/projects/renew.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/projects/renew.js)_
584
657
 
585
658
  ## `fonoster projects:use [REF]`
586
659
 
@@ -595,7 +668,7 @@ DESCRIPTION
595
668
  Set a default Fonoster Project
596
669
  ```
597
670
 
598
- _See code: [dist/commands/projects/use.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/projects/use.js)_
671
+ _See code: [dist/commands/projects/use.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/projects/use.js)_
599
672
 
600
673
  ## `fonoster providers:create`
601
674
 
@@ -610,7 +683,7 @@ DESCRIPTION
610
683
  Create a new Fonoster Provider
611
684
  ```
612
685
 
613
- _See code: [dist/commands/providers/create.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/providers/create.js)_
686
+ _See code: [dist/commands/providers/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/providers/create.js)_
614
687
 
615
688
  ## `fonoster providers:delete [REF]`
616
689
 
@@ -625,7 +698,7 @@ ALIASES
625
698
  $ fonoster providers:rm
626
699
  ```
627
700
 
628
- _See code: [dist/commands/providers/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/providers/delete.js)_
701
+ _See code: [dist/commands/providers/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/providers/delete.js)_
629
702
 
630
703
  ## `fonoster providers:get [REF]`
631
704
 
@@ -636,7 +709,7 @@ USAGE
636
709
  $ fonoster providers:get [REF]
637
710
  ```
638
711
 
639
- _See code: [dist/commands/providers/get.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/providers/get.js)_
712
+ _See code: [dist/commands/providers/get.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/providers/get.js)_
640
713
 
641
714
  ## `fonoster providers:list`
642
715
 
@@ -657,7 +730,7 @@ ALIASES
657
730
  $ fonoster providers:ls
658
731
  ```
659
732
 
660
- _See code: [dist/commands/providers/list.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/providers/list.js)_
733
+ _See code: [dist/commands/providers/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/providers/list.js)_
661
734
 
662
735
  ## `fonoster providers:update [REF]`
663
736
 
@@ -672,5 +745,53 @@ DESCRIPTION
672
745
  Update a Fonoster Provider
673
746
  ```
674
747
 
675
- _See code: [dist/commands/providers/update.js](https://github.com/fonoster/fonoster/blob/v0.3.1/dist/commands/providers/update.js)_
748
+ _See code: [dist/commands/providers/update.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/providers/update.js)_
749
+
750
+ ## `fonoster secrets:create [NAME]`
751
+
752
+ create a Fonoster secret.
753
+
754
+ ```
755
+ USAGE
756
+ $ fonoster secrets:create [NAME]
757
+
758
+ OPTIONS
759
+ -h, --help show CLI help
760
+ -l, --from-literal=from-literal pass from literal
761
+ -s, --from-stdin pass from stdin
762
+ ```
763
+
764
+ _See code: [dist/commands/secrets/create.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/secrets/create.js)_
765
+
766
+ ## `fonoster secrets:delete [NAME]`
767
+
768
+ remove Fonoster secret
769
+
770
+ ```
771
+ USAGE
772
+ $ fonoster secrets:delete [NAME]
773
+
774
+ ALIASES
775
+ $ fonoster secrets:del
776
+ $ fonoster secrets:rm
777
+ ```
778
+
779
+ _See code: [dist/commands/secrets/delete.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/secrets/delete.js)_
780
+
781
+ ## `fonoster secrets:list`
782
+
783
+ list of the secrets you have access to
784
+
785
+ ```
786
+ USAGE
787
+ $ fonoster secrets:list
788
+
789
+ OPTIONS
790
+ -s, --size=size [default: 25] secrets of result per page
791
+
792
+ ALIASES
793
+ $ fonoster secrets:ls
794
+ ```
795
+
796
+ _See code: [dist/commands/secrets/list.js](https://github.com/fonoster/fonoster/blob/v0.3.6-alpha.0/dist/commands/secrets/list.js)_
676
797
  <!-- commandsstop -->
@@ -6,12 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  require("../config");
7
7
  const command_1 = __importDefault(require("@oclif/command"));
8
8
  const cli_ux_1 = require("cli-ux");
9
+ const errors_1 = require("@oclif/errors");
9
10
  class default_1 extends command_1.default {
10
11
  async deleteResource(API, funcName) {
12
+ if (!this.ref) {
13
+ cli_ux_1.cli.action.stop();
14
+ throw new errors_1.CLIError("You must provide a resource ref before continuing");
15
+ }
11
16
  cli_ux_1.cli.action.start(`Deleting resource ${this.ref}`);
12
- await API[funcName](this.ref);
17
+ const results = await API[funcName](this.ref);
13
18
  await cli_ux_1.cli.wait(1000);
14
- cli_ux_1.cli.action.stop("Done");
19
+ cli_ux_1.cli.action.stop(results ? "Done" : "Failed");
15
20
  }
16
21
  async init() {
17
22
  const { args } = this.parse(this.constructor);
@@ -78,7 +78,7 @@ class default_1 extends command_1.Command {
78
78
  throw new errors_1.CLIError("This Agent already exist");
79
79
  }
80
80
  else {
81
- throw new errors_1.CLIError(e);
81
+ throw new errors_1.CLIError(e.message);
82
82
  }
83
83
  }
84
84
  }
@@ -0,0 +1,6 @@
1
+ import "../../config";
2
+ import { Command } from "@oclif/command";
3
+ export default class CreateCommand extends Command {
4
+ static description: string;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ require("../../config");
10
+ const errors_1 = require("@oclif/errors");
11
+ const command_1 = require("@oclif/command");
12
+ const cli_ux_1 = require("cli-ux");
13
+ const config_1 = require("../../config");
14
+ const project_guard_1 = require("../../decorators/project_guard");
15
+ const voices_1 = require("../../data/voices");
16
+ const Apps = require("@fonoster/apps");
17
+ const Secrets = require("@fonoster/secrets");
18
+ const inquirer = require("inquirer");
19
+ const validator = (value, message = "This field is required") => Boolean(value?.trim()?.length) || message;
20
+ class CreateCommand extends command_1.Command {
21
+ async run() {
22
+ console.log("This utility will help you create a new Fonoster App");
23
+ console.log("Press ^C at any time to quit.\n");
24
+ try {
25
+ const { secrets: response } = await new Secrets((0, config_1.getProjectConfig)()).listSecrets({
26
+ pageSize: 25,
27
+ pageToken: "1"
28
+ });
29
+ const secrets = response.map(({ name }) => name) || [];
30
+ if (secrets.length === 0) {
31
+ throw new errors_1.CLIError("Before adding a App you must create a Secret");
32
+ }
33
+ const answers = await inquirer.prompt([
34
+ {
35
+ name: "name",
36
+ message: "Application Name",
37
+ type: "input",
38
+ validate: (value) => validator(value, "You must enter a name for your Application, try something friendly.")
39
+ },
40
+ {
41
+ name: "speechConfig.voice",
42
+ message: "Voice name",
43
+ type: "list",
44
+ choices: voices_1.voices,
45
+ validate: (value) => validator(value, "You must select a voice")
46
+ },
47
+ {
48
+ name: "speechConfig.secretName",
49
+ message: "Speech Config Secret",
50
+ type: "list",
51
+ choices: secrets,
52
+ validate: (value) => validator(value, "You must select a secret")
53
+ },
54
+ {
55
+ name: "intentsEngineConfig.welcomeIntentId",
56
+ message: "Type the welcome intent ID (e.g. WELCOME)",
57
+ type: "input"
58
+ },
59
+ {
60
+ name: "engine",
61
+ message: "Select Intents Engine Type",
62
+ type: "list",
63
+ choices: ["DialogflowES"],
64
+ validate: (value) => validator(value, "You must select a engine")
65
+ },
66
+ {
67
+ name: "intentsEngineConfig.projectId",
68
+ message: "Type a project ID",
69
+ type: "input",
70
+ validate: (value) => validator(value, "You must enter a project ID for your Application.")
71
+ },
72
+ {
73
+ name: "intentsEngineConfig.secretName",
74
+ message: "Intents Engine Secret",
75
+ type: "list",
76
+ choices: secrets,
77
+ validate: (value) => validator(value, "You must select a secret")
78
+ },
79
+ {
80
+ name: "intentsEngineConfig.agent",
81
+ message: "Type a agent",
82
+ type: "input",
83
+ when: (answers) => answers.engine === "DialogflowES",
84
+ validate: (value) => validator(value, "You must enter a agent for your Application.")
85
+ },
86
+ {
87
+ name: "intentsEngineConfig.location",
88
+ message: "Type a location",
89
+ type: "input",
90
+ when: (answers) => answers.engine === "DialogflowES",
91
+ validate: (value) => validator(value, "You must enter a location for your Application.")
92
+ },
93
+ {
94
+ name: "showAdvanceOptions",
95
+ message: "Show advance options?",
96
+ type: "confirm"
97
+ },
98
+ {
99
+ name: "initialDtmf",
100
+ message: "Initial DTMF (optional)",
101
+ type: "input",
102
+ when: (answers) => answers.showAdvanceOptions,
103
+ validate: (value) => {
104
+ const regex = /^[0-9*#]*$/;
105
+ if (value && !regex.test(value)) {
106
+ return "You must enter a valid DTMF. It’s a string that allows 1234567890#*";
107
+ }
108
+ return true;
109
+ }
110
+ },
111
+ {
112
+ name: "activationIntentId",
113
+ message: "Type the activation intent ID (optional)",
114
+ type: "input",
115
+ when: (answers) => answers.showAdvanceOptions
116
+ },
117
+ {
118
+ name: "activationTimeout",
119
+ message: "Type the activation timeout (e.g. 15000)",
120
+ type: "input",
121
+ when: (answers) => answers.showAdvanceOptions,
122
+ validate: (value) => {
123
+ const regex = /^[0-9]*$/;
124
+ if (value && !regex.test(value)) {
125
+ return "You must enter a valid timeout. It’s a number in milliseconds";
126
+ }
127
+ return true;
128
+ }
129
+ },
130
+ {
131
+ name: "interactionTimeout",
132
+ message: "Type the interaction timeout (e.g. 10000)",
133
+ type: "input",
134
+ when: (answers) => answers.showAdvanceOptions,
135
+ validate: (value) => {
136
+ const regex = /^[0-9]*$/;
137
+ if (value && !regex.test(value)) {
138
+ return "You must enter a valid timeout. It’s a number in milliseconds";
139
+ }
140
+ return true;
141
+ }
142
+ },
143
+ {
144
+ name: "transferConfig.message",
145
+ message: "Type a transfer message (e.g. Please wait while we transfer you)",
146
+ type: "input",
147
+ when: (answers) => answers.showAdvanceOptions
148
+ },
149
+ {
150
+ name: "intentsEngineConfig.emulateTelephonyPlatform",
151
+ message: "Emulate Telephony Platform",
152
+ type: "confirm",
153
+ when: (answers) => answers.showAdvanceOptions
154
+ }
155
+ ]);
156
+ const confirmPrompt = await inquirer.prompt([
157
+ {
158
+ name: "confirm",
159
+ message: "Ready to create your App?",
160
+ type: "confirm"
161
+ }
162
+ ]);
163
+ if (!confirmPrompt.confirm)
164
+ return console.log("Aborted");
165
+ cli_ux_1.cli.action.start(`Creating App ${answers.name}`);
166
+ const apps = new Apps((0, config_1.getProjectConfig)());
167
+ delete answers.showAdvanceOptions;
168
+ delete answers.engine;
169
+ const result = await apps.createApp(answers);
170
+ await cli_ux_1.cli.wait(1000);
171
+ cli_ux_1.cli.action.stop(result.ref);
172
+ }
173
+ catch (e) {
174
+ cli_ux_1.cli.action.stop();
175
+ throw new errors_1.CLIError(e.code === 9 ? "This App already exist" : e.message);
176
+ }
177
+ }
178
+ }
179
+ CreateCommand.description = `create a new Fonoster App
180
+ ...
181
+ Create a new Fonoster App
182
+ `;
183
+ __decorate([
184
+ (0, project_guard_1.ProjectGuard)()
185
+ ], CreateCommand.prototype, "run", null);
186
+ exports.default = CreateCommand;
@@ -0,0 +1,9 @@
1
+ import Command from "../../base/delete";
2
+ export default class DeleteCommand extends Command {
3
+ static description: string;
4
+ static args: {
5
+ name: string;
6
+ }[];
7
+ static aliases: string[];
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const delete_1 = __importDefault(require("../../base/delete"));
13
+ const errors_1 = require("@oclif/errors");
14
+ const config_1 = require("../../config");
15
+ const project_guard_1 = require("../../decorators/project_guard");
16
+ const Apps = require("@fonoster/apps");
17
+ class DeleteCommand extends delete_1.default {
18
+ async run() {
19
+ try {
20
+ await super.deleteResource(new Apps((0, config_1.getProjectConfig)()), "deleteApp");
21
+ }
22
+ catch (e) {
23
+ const message = e.code === 9
24
+ ? "unable to delete: please ensure no Resource is using this Fonoster Application"
25
+ : e.message;
26
+ throw new errors_1.CLIError(message);
27
+ }
28
+ }
29
+ }
30
+ DeleteCommand.description = "delete a Fonoster Application";
31
+ DeleteCommand.args = [{ name: "ref" }];
32
+ DeleteCommand.aliases = ["apps:del", "apps:rm"];
33
+ __decorate([
34
+ (0, project_guard_1.ProjectGuard)()
35
+ ], DeleteCommand.prototype, "run", null);
36
+ exports.default = DeleteCommand;