@fonoster/ctl 0.3.2 → 0.3.6-alpha.10

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.
Files changed (49) hide show
  1. package/README.md +173 -52
  2. package/dist/base/delete.js +10 -5
  3. package/dist/commands/agents/create.js +6 -6
  4. package/dist/commands/agents/get.js +4 -4
  5. package/dist/commands/agents/list.js +2 -2
  6. package/dist/commands/agents/update.js +5 -5
  7. package/dist/commands/apps/create.d.ts +6 -0
  8. package/dist/commands/apps/create.js +186 -0
  9. package/dist/commands/apps/delete.d.ts +9 -0
  10. package/dist/commands/apps/delete.js +36 -0
  11. package/dist/commands/apps/list.d.ts +10 -0
  12. package/dist/commands/apps/list.js +89 -0
  13. package/dist/commands/apps/update.d.ts +9 -0
  14. package/dist/commands/apps/update.js +205 -0
  15. package/dist/commands/auth/login.js +8 -8
  16. package/dist/commands/auth/logout.js +5 -5
  17. package/dist/commands/bug.js +2 -5
  18. package/dist/commands/domains/create.js +6 -6
  19. package/dist/commands/domains/get.js +4 -4
  20. package/dist/commands/domains/list.js +2 -2
  21. package/dist/commands/domains/update.js +5 -5
  22. package/dist/commands/feedback.js +2 -5
  23. package/dist/commands/numbers/create.js +6 -6
  24. package/dist/commands/numbers/get.js +4 -4
  25. package/dist/commands/numbers/list.js +2 -2
  26. package/dist/commands/numbers/update.js +20 -9
  27. package/dist/commands/projects/create.js +6 -6
  28. package/dist/commands/projects/get.js +4 -4
  29. package/dist/commands/projects/list.js +2 -2
  30. package/dist/commands/projects/renew.js +5 -5
  31. package/dist/commands/projects/use.js +5 -5
  32. package/dist/commands/providers/create.js +7 -7
  33. package/dist/commands/providers/get.js +4 -4
  34. package/dist/commands/providers/list.js +2 -2
  35. package/dist/commands/providers/update.js +5 -5
  36. package/dist/commands/secrets/create.d.ts +14 -0
  37. package/dist/commands/secrets/create.js +64 -0
  38. package/dist/commands/secrets/delete.d.ts +10 -0
  39. package/dist/commands/secrets/delete.js +57 -0
  40. package/dist/commands/secrets/list.d.ts +10 -0
  41. package/dist/commands/secrets/list.js +71 -0
  42. package/dist/data/voices.d.ts +1 -0
  43. package/dist/data/voices.js +319 -0
  44. package/dist/decorators/project_guard.d.ts +9 -0
  45. package/dist/decorators/project_guard.js +26 -0
  46. package/dist/help.d.ts +3 -1
  47. package/dist/help.js +21 -16
  48. package/oclif.manifest.json +1 -1
  49. package/package.json +24 -43
@@ -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 core_1 = require("@oclif/core");
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
+ core_1.CliUx.ux.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 core_1.CliUx.ux.wait(1000);
171
+ core_1.CliUx.ux.action.stop(result.ref);
172
+ }
173
+ catch (e) {
174
+ core_1.CliUx.ux.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;
@@ -0,0 +1,10 @@
1
+ import "../../config";
2
+ import { Command } from "@oclif/command";
3
+ export default class ListCommand extends Command {
4
+ static description: string;
5
+ static flags: {
6
+ size: import("@oclif/parser/lib/flags").IOptionFlag<number>;
7
+ };
8
+ static aliases: string[];
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,89 @@
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 domains_1 = require("@fonoster/domains");
11
+ const errors_1 = require("@oclif/errors");
12
+ const command_1 = require("@oclif/command");
13
+ const core_1 = require("@oclif/core");
14
+ const config_1 = require("../../config");
15
+ const project_guard_1 = require("../../decorators/project_guard");
16
+ const Apps = require("@fonoster/apps");
17
+ class ListCommand extends command_1.Command {
18
+ async run() {
19
+ const { flags } = this.parse(ListCommand);
20
+ try {
21
+ const apps = new Apps((0, config_1.getProjectConfig)());
22
+ let firstBatch = true;
23
+ let pageToken = "1";
24
+ const pageSize = flags.size;
25
+ const view = domains_1.CommonPB.View.BASIC;
26
+ // while (true) {
27
+ // Get a list
28
+ const result = await apps.listApps({ pageSize, pageToken, view });
29
+ const list = result.apps;
30
+ pageToken = result.nextPageToken;
31
+ /**
32
+ * @todo Uncomment when pagination is applied in backend.
33
+ *
34
+ * if (list.length > 0 && !firstBatch) {
35
+ const answer: any = await inquirer.prompt([
36
+ {name: "q", message: "More", type: "confirm"}
37
+ ]);
38
+
39
+ if (!answer.q) break;
40
+ }
41
+ */
42
+ // if (list.length < 1) break;
43
+ const showTable = (showHeader, data) => {
44
+ core_1.CliUx.ux.table(data, {
45
+ ref: { minWidth: 15 },
46
+ name: { header: "Name", minWidth: 15 },
47
+ projectId: {
48
+ header: "Project ID",
49
+ minWidth: 15,
50
+ get: (row) => row.intentsEngineConfig?.projectId || "N/A"
51
+ },
52
+ voice: {
53
+ header: "Voice",
54
+ minWidth: 20,
55
+ get: (row) => row.speechConfig?.voice || "N/A"
56
+ },
57
+ welcomeIntentId: {
58
+ header: "Welcome Intent ID",
59
+ minWidth: 15,
60
+ get: (row) => row.intentsEngineConfig?.welcomeIntentId || "N/A"
61
+ }
62
+ }, { "no-header": !showHeader });
63
+ };
64
+ showTable(firstBatch, list);
65
+ firstBatch = false;
66
+ // if (!pageToken) break;
67
+ // }
68
+ }
69
+ catch (e) {
70
+ throw new errors_1.CLIError(e.message);
71
+ }
72
+ }
73
+ }
74
+ ListCommand.description = `list all Fonoster Apps you have access to
75
+ ...
76
+ List all Fonoster Apps you have access to
77
+ `;
78
+ ListCommand.flags = {
79
+ size: command_1.flags.integer({
80
+ char: "s",
81
+ default: 25,
82
+ description: "number of result per page"
83
+ })
84
+ };
85
+ ListCommand.aliases = ["apps:ls"];
86
+ __decorate([
87
+ (0, project_guard_1.ProjectGuard)()
88
+ ], ListCommand.prototype, "run", null);
89
+ exports.default = ListCommand;
@@ -0,0 +1,9 @@
1
+ import "../../config";
2
+ import { Command } from "@oclif/command";
3
+ export default class UpdateCommand extends Command {
4
+ static args: {
5
+ name: string;
6
+ }[];
7
+ static description: string;
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,205 @@
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 core_1 = require("@oclif/core");
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 UpdateCommand extends command_1.Command {
21
+ async run() {
22
+ try {
23
+ const { args } = this.parse(UpdateCommand);
24
+ if (!args.ref)
25
+ throw new errors_1.CLIError("Please provide the reference of your Fonoster Application");
26
+ const { secrets: response } = await new Secrets((0, config_1.getProjectConfig)()).listSecrets({
27
+ pageSize: 25,
28
+ pageToken: "1"
29
+ });
30
+ const secrets = response.map(({ name }) => name) || [];
31
+ const appsManager = new Apps((0, config_1.getProjectConfig)());
32
+ const app = await appsManager.getApp(args.ref);
33
+ if (!app)
34
+ throw new errors_1.CLIError("App not found");
35
+ const answers = await inquirer.prompt([
36
+ {
37
+ name: "name",
38
+ message: "Application Name",
39
+ type: "input",
40
+ default: app.name,
41
+ validate: (value) => validator(value, "You must enter a name for your Application, try something friendly.")
42
+ },
43
+ {
44
+ name: "speechConfig.voice",
45
+ message: "Voice name",
46
+ type: "list",
47
+ default: app.speechConfig.voice,
48
+ choices: voices_1.voices,
49
+ validate: (value) => validator(value, "You must select a voice")
50
+ },
51
+ {
52
+ name: "speechConfig.secretName",
53
+ message: "Speech Config Secret",
54
+ type: "list",
55
+ choices: secrets,
56
+ default: app.speechConfig.secretName,
57
+ validate: (value) => validator(value, "You must select a secret")
58
+ },
59
+ {
60
+ name: "intentsEngineConfig.welcomeIntentId",
61
+ message: "Type the welcome intent ID (e.g. WELCOME)",
62
+ type: "input",
63
+ default: app.intentsEngineConfig.welcomeIntentId
64
+ },
65
+ {
66
+ name: "engine",
67
+ message: "Select Intents Engine Type",
68
+ type: "list",
69
+ choices: ["DialogflowES"],
70
+ validate: (value) => validator(value, "You must select a engine")
71
+ },
72
+ {
73
+ name: "intentsEngineConfig.projectId",
74
+ message: "Type a project ID",
75
+ type: "input",
76
+ default: app.intentsEngineConfig.projectId,
77
+ validate: (value) => validator(value, "You must enter a project ID for your Application.")
78
+ },
79
+ {
80
+ name: "intentsEngineConfig.secretName",
81
+ message: "Intents Engine Secret",
82
+ type: "list",
83
+ choices: secrets,
84
+ default: app.intentsEngineConfig.secretName,
85
+ validate: (value) => validator(value, "You must select a secret")
86
+ },
87
+ {
88
+ name: "intentsEngineConfig.agent",
89
+ message: "Type a agent",
90
+ type: "input",
91
+ default: app.intentsEngineConfig.agent,
92
+ when: (answers) => answers.engine === "DialogflowES",
93
+ validate: (value) => validator(value, "You must enter a agent for your Application.")
94
+ },
95
+ {
96
+ name: "intentsEngineConfig.location",
97
+ message: "Type a location",
98
+ type: "input",
99
+ default: app.intentsEngineConfig.location,
100
+ when: (answers) => answers.engine === "DialogflowES",
101
+ validate: (value) => validator(value, "You must enter a location for your Application.")
102
+ },
103
+ {
104
+ name: "showAdvanceOptions",
105
+ message: "Show advance options?",
106
+ type: "confirm",
107
+ default: true
108
+ },
109
+ {
110
+ name: "initialDtmf",
111
+ message: "Initial DTMF (optional)",
112
+ type: "input",
113
+ default: app.initialDtmf,
114
+ when: (answers) => answers.showAdvanceOptions,
115
+ validate: (value) => {
116
+ const regex = /^[0-9*#]*$/;
117
+ if (value && !regex.test(value)) {
118
+ return "You must enter a valid DTMF. It’s a string that allows 1234567890#*";
119
+ }
120
+ return true;
121
+ }
122
+ },
123
+ {
124
+ name: "activationIntentId",
125
+ message: "Type the activation intent ID (optional)",
126
+ type: "input",
127
+ default: app.activationIntentId,
128
+ when: (answers) => answers.showAdvanceOptions
129
+ },
130
+ {
131
+ name: "activationTimeout",
132
+ message: "Type the activation timeout (e.g. 15000)",
133
+ type: "input",
134
+ default: app.activationTimeout,
135
+ when: (answers) => answers.showAdvanceOptions,
136
+ validate: (value) => {
137
+ const regex = /^[0-9]*$/;
138
+ if (value && !regex.test(value)) {
139
+ return "You must enter a valid timeout. It’s a number in milliseconds";
140
+ }
141
+ return true;
142
+ }
143
+ },
144
+ {
145
+ name: "interactionTimeout",
146
+ message: "Type the interaction timeout (e.g. 10000)",
147
+ type: "input",
148
+ default: app.interactionTimeout,
149
+ when: (answers) => answers.showAdvanceOptions,
150
+ validate: (value) => {
151
+ const regex = /^[0-9]*$/;
152
+ if (value && !regex.test(value)) {
153
+ return "You must enter a valid timeout. It’s a number in milliseconds";
154
+ }
155
+ return true;
156
+ }
157
+ },
158
+ {
159
+ name: "transferConfig.message",
160
+ message: "Type a transfer message (e.g. Please wait while we transfer you)",
161
+ type: "input",
162
+ default: app.transferConfig.message,
163
+ when: (answers) => answers.showAdvanceOptions
164
+ },
165
+ {
166
+ name: "intentsEngineConfig.emulateTelephonyPlatform",
167
+ message: "Emulate Telephony Platform",
168
+ type: "confirm",
169
+ default: app.intentsEngineConfig.emulateTelephonyPlatform,
170
+ when: (answers) => answers.showAdvanceOptions
171
+ }
172
+ ]);
173
+ const confirmPrompt = await inquirer.prompt([
174
+ {
175
+ name: "confirm",
176
+ message: "Ready to update your App?",
177
+ type: "confirm"
178
+ }
179
+ ]);
180
+ if (!confirmPrompt.confirm)
181
+ return console.log("Aborted");
182
+ core_1.CliUx.ux.action.start(`Updating App ${answers.name}`);
183
+ const apps = new Apps((0, config_1.getProjectConfig)());
184
+ delete answers.showAdvanceOptions;
185
+ delete answers.engine;
186
+ answers.ref = args.ref;
187
+ const result = await apps.updateApp(answers);
188
+ await core_1.CliUx.ux.wait(1000);
189
+ core_1.CliUx.ux.action.stop(`App ${result.ref} updated`);
190
+ }
191
+ catch (e) {
192
+ core_1.CliUx.ux.action.stop();
193
+ throw new errors_1.CLIError(e.code === 9 ? "This App already exist" : e.message);
194
+ }
195
+ }
196
+ }
197
+ UpdateCommand.args = [{ name: "ref" }];
198
+ UpdateCommand.description = `update a new Fonoster App
199
+ ...
200
+ Update a new Fonoster App
201
+ `;
202
+ __decorate([
203
+ (0, project_guard_1.ProjectGuard)()
204
+ ], UpdateCommand.prototype, "run", null);
205
+ exports.default = UpdateCommand;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../config");
4
4
  const errors_1 = require("@oclif/errors");
5
5
  const command_1 = require("@oclif/command");
6
- const cli_ux_1 = require("cli-ux");
6
+ const core_1 = require("@oclif/core");
7
7
  const config_1 = require("../../config");
8
8
  const Projects = require("@fonoster/projects");
9
9
  const inquirer = require("inquirer");
@@ -40,23 +40,23 @@ class default_1 extends command_1.Command {
40
40
  }
41
41
  else {
42
42
  try {
43
- cli_ux_1.cli.action.start(`Accessing endpoint ${answers.endpoint}`);
43
+ core_1.CliUx.ux.action.start(`Accessing endpoint ${answers.endpoint}`);
44
44
  try {
45
45
  const projects = new Projects(answers);
46
46
  await projects.listProjects();
47
47
  answers.confirm = void 0;
48
48
  (0, config_1.setConfig)(answers);
49
- await cli_ux_1.cli.wait(1000);
50
- cli_ux_1.cli.action.stop("Done");
49
+ await core_1.CliUx.ux.wait(1000);
50
+ core_1.CliUx.ux.action.stop("Done");
51
51
  }
52
52
  catch (e) {
53
- console.log(e);
54
- await cli_ux_1.cli.wait(1000);
55
- cli_ux_1.cli.action.stop("Invalid credentials or endpoint");
53
+ console.error(e.message);
54
+ await core_1.CliUx.ux.wait(1000);
55
+ core_1.CliUx.ux.action.stop("Invalid credentials or endpoint");
56
56
  }
57
57
  }
58
58
  catch (e) {
59
- cli_ux_1.cli.action.stop();
59
+ core_1.CliUx.ux.action.stop();
60
60
  throw new errors_1.CLIError(e.message);
61
61
  }
62
62
  }
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("../../config");
4
4
  const errors_1 = require("@oclif/errors");
5
5
  const command_1 = require("@oclif/command");
6
- const cli_ux_1 = require("cli-ux");
6
+ const core_1 = require("@oclif/core");
7
7
  const path_1 = require("path");
8
8
  const os_1 = require("os");
9
9
  const BASE_DIR = (0, path_1.join)((0, os_1.homedir)(), ".fonoster");
10
10
  const fs = require("fs");
11
11
  class default_1 extends command_1.Command {
12
12
  async run() {
13
- cli_ux_1.cli.action.start(`Login out`);
13
+ core_1.CliUx.ux.action.start(`Login out`);
14
14
  try {
15
15
  fs.rmSync(BASE_DIR, { recursive: true });
16
- await cli_ux_1.cli.wait(1000);
17
- cli_ux_1.cli.action.stop("Done");
16
+ await core_1.CliUx.ux.wait(1000);
17
+ core_1.CliUx.ux.action.stop("Done");
18
18
  }
19
19
  catch (e) {
20
- cli_ux_1.cli.action.stop();
20
+ core_1.CliUx.ux.action.stop();
21
21
  throw new errors_1.CLIError(e.message);
22
22
  }
23
23
  }
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  require("../config");
7
- const cli_ux_1 = __importDefault(require("cli-ux"));
4
+ const core_1 = require("@oclif/core");
8
5
  const command_1 = require("@oclif/command");
9
6
  class default_1 extends command_1.Command {
10
7
  async run() {
11
- await cli_ux_1.default.open("https://github.com/fonoster/fonoster/issues/new?assignees=&labels=&template=bug_report.md&title=");
8
+ await core_1.CliUx.ux.open("https://github.com/fonoster/fonoster/issues/new?assignees=&labels=&template=bug_report.md&title=");
12
9
  }
13
10
  }
14
11
  exports.default = default_1;