-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathupdate.js
52 lines (40 loc) · 1.36 KB
/
update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { TwilioClientCommand } = require("@twilio/cli-core").baseCommands,
AutopilotCore = require("@dabblelab/autopilot-core"),
ora = require("ora"),
path = require("path"),
{ convertYargsOptionsToOclifFlags, normalizeFlags } = require("../../utils"),
{ options, describe } = require("../../lib/options/update");
class UpdateAssistant extends TwilioClientCommand {
async run() {
await super.run();
let { flags } = await this.parse(UpdateAssistant);
flags = normalizeFlags(flags);
if (!flags.hasOwnProperty("schema")) {
console.log(`The '--schema' argument is required`);
return;
}
let spinner = await ora();
try {
let schema = flags.schema;
spinner.start("Updating bot...");
let fullPath = `${path.resolve()}/${schema}`,
assistantUniqueName = flags.uniqueName || false;
const assistant = await AutopilotCore.updateAssistant(
fullPath,
this.twilioClient,
assistantUniqueName
);
spinner.stop();
console.log(`Bot "${assistant.uniqueName}" was updated`);
} catch (err) {
spinner.stop();
console.error(`ERROR: ${err}`);
}
}
}
UpdateAssistant.description = describe;
UpdateAssistant.flags = Object.assign(
convertYargsOptionsToOclifFlags(options),
{ profile: TwilioClientCommand.flags.profile }
);
module.exports = UpdateAssistant;