Skip to content

Commit 8efd8c7

Browse files
add bot name paramter in init command and resolved issues #15 and #16
1 parent b87030e commit 8efd8c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1116
-853
lines changed

README.md

Lines changed: 133 additions & 184 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 31 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@dabblelab/plugin-autopilot",
33
"description": "Create, Update, Delete, List, Simulate, Import and Export Twilio Autopilot Assistant",
4-
"version": "1.0.0-beta.17",
4+
"version": "1.0.0-beta.18",
55
"author": "Steve Tingiris",
66
"bugs": "https://github.com/tingiris/twilio-cli-autopilot-plugin/issues",
77
"dependencies": {
8-
"@dabblelab/autopilot-core": "^1.0.0-beta.11",
8+
"@dabblelab/autopilot-core": "^1.0.0-beta.12",
99
"@oclif/command": "^1.5.19",
1010
"@oclif/config": "^1.13.3",
1111
"@oclif/plugin-help": "^2.2.1",
@@ -15,7 +15,8 @@
1515
"ora": "^3.4.0",
1616
"pkg-install": "^1.0.0",
1717
"pretty-json-stringify": "0.0.2",
18-
"request-promise": "^4.2.4",
18+
"request": "^2.88.0",
19+
"request-promise": "^4.2.5",
1920
"simple-git": "^1.124.0",
2021
"twilio-run": "^2.1.1",
2122
"underscore": "^1.9.1"

src/commands/autopilot/create.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const {flags} = require('@oclif/command'),
2-
{ TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
1+
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
32
AutopilotCore = require('@dabblelab/autopilot-core'),
43
ora = require('ora'),
5-
path = require('path');
4+
path = require('path'),
5+
{ convertYargsOptionsToOclifFlags, normalizeFlags } = require('../../utils'),
6+
{ options, describe } = require('../../lib/options/create');
67

78
class CreateAssistant extends TwilioClientCommand {
89

@@ -11,9 +12,12 @@ class CreateAssistant extends TwilioClientCommand {
1112

1213
try{
1314

14-
let { flags, args } = this.parse(CreateAssistant),
15-
schema = flags.schema,
16-
clonedAssistant = '';
15+
let { flags } = this.parse(CreateAssistant);
16+
17+
flags = normalizeFlags(flags);
18+
19+
let schema = flags.schema,
20+
clonedAssistant = '';
1721

1822
if(schema == 'templates'){
1923

@@ -27,7 +31,7 @@ class CreateAssistant extends TwilioClientCommand {
2731
spinner.start('Creating assistant...');
2832
let fullPath = `${path.resolve()}/${schema}`
2933

30-
const assistant = await AutopilotCore.createAssistant(fullPath,this.twilioClient);
34+
const assistant = await AutopilotCore.createAssistant(fullPath, this.twilioClient);
3135

3236
spinner.stop()
3337

@@ -41,18 +45,11 @@ class CreateAssistant extends TwilioClientCommand {
4145
}
4246
}
4347

44-
CreateAssistant.description = `Create an assistant`;
48+
CreateAssistant.description = describe;
4549

4650
CreateAssistant.flags = Object.assign(
47-
{
48-
schema : flags.string({
49-
char : 's',
50-
description : 'schema path',
51-
default : "templates",
52-
required : true
53-
})
54-
},
55-
TwilioClientCommand.flags
51+
convertYargsOptionsToOclifFlags(options),
52+
{ profile: TwilioClientCommand.flags.profile }
5653
)
5754

5855
module.exports = CreateAssistant

src/commands/autopilot/delete.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
const {flags} = require('@oclif/command'),
2-
{ TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
1+
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
32
AutopilotCore = require('@dabblelab/autopilot-core'),
4-
ora = require('ora');
3+
ora = require('ora'),
4+
{ convertYargsOptionsToOclifFlags, normalizeFlags } = require('../../utils'),
5+
{ options, describe } = require('../../lib/options/delete');
56

67
class DeleteAssistant extends TwilioClientCommand {
78

89
async runCommand() {
910

1011
let { flags } = this.parse(DeleteAssistant);
1112

13+
flags = normalizeFlags(flags);
14+
1215
if (!flags.hasOwnProperty('assistantSid')) {
13-
console.log(`The '--assistantSid' argument is required`);
16+
console.log(`The '--assistant-sid' argument is required`);
1417
return;
1518
}
1619
let spinner = ora().start('Deleting assistant...');
@@ -23,7 +26,7 @@ class DeleteAssistant extends TwilioClientCommand {
2326
const result = await AutopilotCore.deleteAssistant(sid, this.twilioClient);
2427

2528
spinner.stop();
26-
console.log(`\nRemoved assistant with UniqueName: ${sid}`);
29+
console.log(`Assistant "${sid}" was deleted`);
2730
}catch(err){
2831

2932
spinner.stop();
@@ -33,20 +36,11 @@ class DeleteAssistant extends TwilioClientCommand {
3336
}
3437
}
3538

36-
DeleteAssistant.description = `Delete an assistant`;
39+
DeleteAssistant.description = describe;
3740

3841
DeleteAssistant.flags = Object.assign(
39-
{
40-
assistantSid : flags.string({
41-
char : 's',
42-
description : 'assistant sid',
43-
required : true
44-
}),
45-
uniqueName : flags.string({
46-
description : 'assistant uniqueName'
47-
})
48-
},
49-
TwilioClientCommand.flags
42+
convertYargsOptionsToOclifFlags(options),
43+
{ profile: TwilioClientCommand.flags.profile }
5044
)
5145

5246
module.exports = DeleteAssistant

src/commands/autopilot/deploy.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
22
path = require('path'),
3-
{flags} = require('@oclif/command'),
43
AutopilotCore = require('@dabblelab/autopilot-core'),
54
ora = require('ora');
65

7-
const {
8-
handler,
9-
cliInfo,
10-
describe,
11-
} = require('../../lib/serverless/deploy');
12-
const {
13-
convertYargsOptionsToOclifFlags,
14-
normalizeFlags,
15-
createExternalCliOptions,
16-
} = require('../../utils');
17-
18-
const updateTaskURL = require('../../lib/serverless/updateTaskURL');
6+
const { handler } = require('../../lib/serverless/deploy'),
7+
{ convertYargsOptionsToOclifFlags, normalizeFlags, createExternalCliOptions } = require('../../utils'),
8+
updateTaskURL = require('../../lib/serverless/updateTaskURL'),
9+
{options, describe} = require('../../lib/options/deploy');
10+
11+
1912
class AssistantsDeploy extends TwilioClientCommand {
2013
constructor(argv, config, secureStorage) {
2114
super(argv, config, secureStorage);
@@ -55,7 +48,7 @@ class AssistantsDeploy extends TwilioClientCommand {
5548
await AutopilotCore.createAssistant(fullPath, this.twilioClient);
5649
}
5750

58-
spinner.text = 'Model successfully deployed.'
51+
spinner.text = 'Model successfully deployed'
5952
spinner.succeed();
6053
}
6154

@@ -75,15 +68,7 @@ class AssistantsDeploy extends TwilioClientCommand {
7568
AssistantsDeploy.description = describe;
7669

7770
AssistantsDeploy.flags = Object.assign(
78-
convertYargsOptionsToOclifFlags(cliInfo.options),
79-
{
80-
'target' : flags.string({
81-
char : 't',
82-
description : `deploy function, model or all of them. Options can only be "all", "function" or "model".`,
83-
default : 'all',
84-
options : ['all', 'function', 'model']
85-
})
86-
},
71+
convertYargsOptionsToOclifFlags(options),
8772
{ profile: TwilioClientCommand.flags.profile }
8873
);
8974

src/commands/autopilot/export.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const {flags} = require('@oclif/command'),
2-
{ TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
1+
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands,
32
AutopilotCore = require('@dabblelab/autopilot-core'),
4-
ora = require('ora');
3+
ora = require('ora'),
4+
{ convertYargsOptionsToOclifFlags, normalizeFlags } = require('../../utils'),
5+
{ options, describe } = require('../../lib/options/export');
56

67
class ExportAssistants extends TwilioClientCommand {
78

@@ -11,6 +12,8 @@ class ExportAssistants extends TwilioClientCommand {
1112
try{
1213

1314
let { flags } = this.parse(ExportAssistants);
15+
flags = normalizeFlags(flags);
16+
1417
let assistantSid = flags.uniqueName || flags.assistantSid || '',
1518
seletedAssistant = assistantSid;
1619

@@ -45,7 +48,7 @@ class ExportAssistants extends TwilioClientCommand {
4548
spinner.start(`Exporting assistant...`);
4649
const assistant = await AutopilotCore.exportAssistant(seletedAssistant, this.twilioClient);
4750
spinner.stop();
48-
console.log(`\nFile exported in ${assistant.filename}`);
51+
console.log(`File exported in "${assistant.filename}"`);
4952
}catch(err){
5053

5154
spinner.stop();
@@ -54,19 +57,11 @@ class ExportAssistants extends TwilioClientCommand {
5457
}
5558
}
5659

57-
ExportAssistants.description = `Export an assistant`;
60+
ExportAssistants.description = describe;
5861

5962
ExportAssistants.flags = Object.assign(
60-
{
61-
assistantSid : flags.string({
62-
char : 's',
63-
description : 'assistant sid'
64-
}),
65-
uniqueName : flags.string({
66-
description : 'assistant uniqueName'
67-
})
68-
},
69-
TwilioClientCommand.flags
63+
convertYargsOptionsToOclifFlags(options),
64+
{ profile: TwilioClientCommand.flags.profile }
7065
)
7166

7267
module.exports = ExportAssistants

0 commit comments

Comments
 (0)