From 0be02371b934212739961e1e5f51a21ae218ec4f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Sep 2020 11:36:11 +0530 Subject: [PATCH] fix issue #33 --- README.md | 54 ++++++++++++++++++------------------ package.json | 3 +- src/lib/serverless/deploy.js | 8 ++++-- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index d7b9bd5..3a4c805 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ OPTIONS -s, --schema=schema (required) [default: templates] path to schema file ``` -_See code: [src/commands/autopilot/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/create.js)_ +_See code: [src/commands/autopilot/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/create.js)_ ## `twilio autopilot:delete` @@ -124,7 +124,7 @@ OPTIONS --unique-name=unique-name assistant unique name ``` -_See code: [src/commands/autopilot/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/delete.js)_ +_See code: [src/commands/autopilot/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/delete.js)_ ## `twilio autopilot:export` @@ -140,7 +140,7 @@ OPTIONS --unique-name=unique-name assistant unique name ``` -_See code: [src/commands/autopilot/export.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/export.js)_ +_See code: [src/commands/autopilot/export.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/export.js)_ ## `twilio autopilot:list` @@ -156,7 +156,7 @@ OPTIONS https://www.twilio.com/docs/autopilot/api/assistant#assistant-properties ``` -_See code: [src/commands/autopilot/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/list.js)_ +_See code: [src/commands/autopilot/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/list.js)_ ## `twilio autopilot:update` @@ -172,7 +172,7 @@ OPTIONS --unique-name=unique-name assistant unique name ``` -_See code: [src/commands/autopilot/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/update.js)_ +_See code: [src/commands/autopilot/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/update.js)_ ## `twilio autopilot:init` @@ -190,7 +190,7 @@ OPTIONS --url=url the url to the template list or the git repo ``` -_See code: [src/commands/autopilot/init.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/init.js)_ +_See code: [src/commands/autopilot/init.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/init.js)_ ## `twilio autopilot:deploy` @@ -210,7 +210,7 @@ OPTIONS --override-existing-project Deploys Serverless project to existing service if a naming conflict has been found. ``` -_See code: [src/commands/autopilot/deploy.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/deploy.js)_ +_See code: [src/commands/autopilot/deploy.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/deploy.js)_ ## `twilio autopilot:fields:create` @@ -233,7 +233,7 @@ OPTIONS --unique-name=unique-name (required) field unique name ``` -_See code: [src/commands/autopilot/fields/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fields/create.js)_ +_See code: [src/commands/autopilot/fields/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fields/create.js)_ ## `twilio autopilot:fields:delete` @@ -252,7 +252,7 @@ OPTIONS --task-sid=task-sid task sid ``` -_See code: [src/commands/autopilot/fields/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fields/delete.js)_ +_See code: [src/commands/autopilot/fields/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fields/delete.js)_ ## `twilio autopilot:fields:list` @@ -270,7 +270,7 @@ OPTIONS --task-sid=task-sid task sid ``` -_See code: [src/commands/autopilot/fields/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fields/list.js)_ +_See code: [src/commands/autopilot/fields/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fields/list.js)_ ## `twilio autopilot:fieldtypes:create` @@ -287,7 +287,7 @@ OPTIONS --unique-name=unique-name (required) unique name for the field type ``` -_See code: [src/commands/autopilot/fieldtypes/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fieldtypes/create.js)_ +_See code: [src/commands/autopilot/fieldtypes/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fieldtypes/create.js)_ ## `twilio autopilot:fieldtypes:list` @@ -304,7 +304,7 @@ OPTIONS https://www.twilio.com/docs/autopilot/api/field-type#fieldtype-properties ``` -_See code: [src/commands/autopilot/fieldtypes/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fieldtypes/list.js)_ +_See code: [src/commands/autopilot/fieldtypes/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fieldtypes/list.js)_ ## `twilio autopilot:fieldtypes:update` @@ -322,7 +322,7 @@ OPTIONS --unique-name=unique-name field unique name ``` -_See code: [src/commands/autopilot/fieldtypes/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fieldtypes/update.js)_ +_See code: [src/commands/autopilot/fieldtypes/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fieldtypes/update.js)_ ## `twilio autopilot:fieldvalues:upload` @@ -339,7 +339,7 @@ OPTIONS --file-name=file-name (required) a CSV file of field values (one on each row with synonyms in columns) ``` -_See code: [src/commands/autopilot/fieldvalues/upload.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/fieldvalues/upload.js)_ +_See code: [src/commands/autopilot/fieldvalues/upload.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/fieldvalues/upload.js)_ ## `twilio autopilot:tasks:create` @@ -356,7 +356,7 @@ OPTIONS --unique-name=unique-name (required) unique name for task ``` -_See code: [src/commands/autopilot/tasks/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/tasks/create.js)_ +_See code: [src/commands/autopilot/tasks/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/tasks/create.js)_ ## `twilio autopilot:tasks:delete` @@ -372,7 +372,7 @@ OPTIONS --task-sid=task-sid task sid ``` -_See code: [src/commands/autopilot/tasks/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/tasks/delete.js)_ +_See code: [src/commands/autopilot/tasks/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/tasks/delete.js)_ ## `twilio autopilot:tasks:list` @@ -389,7 +389,7 @@ OPTIONS https://www.twilio.com/docs/autopilot/api/task#task-properties ``` -_See code: [src/commands/autopilot/tasks/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/tasks/list.js)_ +_See code: [src/commands/autopilot/tasks/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/tasks/list.js)_ ## `twilio autopilot:tasks:update` @@ -407,7 +407,7 @@ OPTIONS --unique-name=unique-name task unique name to update ``` -_See code: [src/commands/autopilot/tasks/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/tasks/update.js)_ +_See code: [src/commands/autopilot/tasks/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/tasks/update.js)_ ## `twilio autopilot:samples:upload` @@ -424,7 +424,7 @@ OPTIONS --task-sid=task-sid task sid ``` -_See code: [src/commands/autopilot/samples/upload.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/samples/upload.js)_ +_See code: [src/commands/autopilot/samples/upload.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/samples/upload.js)_ ## `twilio autopilot:import [TYPE]` @@ -451,7 +451,7 @@ DESCRIPTION -> twilio autopilot:import alexa --model [--redirectURL ] ``` -_See code: [src/commands/autopilot/import.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/import.js)_ +_See code: [src/commands/autopilot/import.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/import.js)_ ## `twilio autopilot:webhooks:create` @@ -470,7 +470,7 @@ OPTIONS -w, --webhook-unique-name=webhook-unique-name (required) unique name for webhook ``` -_See code: [src/commands/autopilot/webhooks/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/webhooks/create.js)_ +_See code: [src/commands/autopilot/webhooks/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/webhooks/create.js)_ ## `twilio autopilot:webhooks:delete` @@ -486,7 +486,7 @@ OPTIONS --webhook-sid=webhook-sid SID of the webhook to delete ``` -_See code: [src/commands/autopilot/webhooks/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/webhooks/delete.js)_ +_See code: [src/commands/autopilot/webhooks/delete.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/webhooks/delete.js)_ ## `twilio autopilot:webhooks:list` @@ -506,7 +506,7 @@ OPTIONS ``` -_See code: [src/commands/autopilot/webhooks/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/webhooks/list.js)_ +_See code: [src/commands/autopilot/webhooks/list.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/webhooks/list.js)_ ## `twilio autopilot:webhooks:update` @@ -526,7 +526,7 @@ OPTIONS --webhook-sid=webhook-sid SID of the webhook to update ``` -_See code: [src/commands/autopilot/webhooks/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/webhooks/update.js)_ +_See code: [src/commands/autopilot/webhooks/update.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/webhooks/update.js)_ ## `twilio autopilot:modelbuilds:create` @@ -542,7 +542,7 @@ OPTIONS -u, --callbackURL=callbackURL URL to get notified of model build status ``` -_See code: [src/commands/autopilot/modelbuilds/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/modelbuilds/create.js)_ +_See code: [src/commands/autopilot/modelbuilds/create.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/modelbuilds/create.js)_ ## `twilio autopilot:simulate` @@ -558,7 +558,7 @@ OPTIONS -t, --text=text (required) User text input ``` -_See code: [src/commands/autopilot/simulate.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/simulate.js)_ +_See code: [src/commands/autopilot/simulate.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/simulate.js)_ ## `twilio autopilot:queries:export` @@ -574,7 +574,7 @@ OPTIONS -s, --assistant-sid=assistant-sid (required) assistant sid ``` -_See code: [src/commands/autopilot/queries/export.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.2/src/commands/autopilot/queries/export.js)_ +_See code: [src/commands/autopilot/queries/export.js](https://github.com/dabblelab/twilio-cli-autopilot-plugin/blob/v1.0.3-beta.0/src/commands/autopilot/queries/export.js)_ ## `twilio help [COMMAND]` diff --git a/package.json b/package.json index ee76217..a185dd5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@dabblelab/plugin-autopilot", "description": "Create, Update, Delete, List, Simulate, Import and Export Twilio Autopilot Assistant", - "version": "1.0.2", + "version": "1.0.3-beta.0", "author": "Steve Tingiris", "bugs": "https://github.com/tingiris/twilio-cli-autopilot-plugin/issues", "dependencies": { @@ -9,6 +9,7 @@ "@oclif/command": "^1.5.19", "@oclif/config": "^1.13.3", "@oclif/plugin-help": "^2.2.3", + "@twilio-labs/serverless-api": "^3.0.0", "@twilio/cli-core": "^4.4.0", "csv-parse": "^4.8.2", "extract-zip": "^1.6.7", diff --git a/src/lib/serverless/deploy.js b/src/lib/serverless/deploy.js index bcb9f72..4c53982 100644 --- a/src/lib/serverless/deploy.js +++ b/src/lib/serverless/deploy.js @@ -58,7 +58,7 @@ function handleError(err, spinner, flags, config) { function handler(flags, externalCliOptions) { return __awaiter(this, void 0, void 0, function* () { logger_1.setLogLevelByName(flags.logLevel); - const cwd = path_1.default.resolve(process.cwd(), 'function'); + const cwd = path_1.default.resolve(flags.cwd || process.cwd(), 'function'); flags.cwd = cwd; const command = utils_2.getFullCommand(flags); yield project_structure_1.default(cwd, command, true); @@ -67,6 +67,7 @@ function handler(flags, externalCliOptions) { config = yield deploy_1.getConfigFromFlags(flags, externalCliOptions); } catch (err) { + console.log(err); debug(err); logError(err.message); process.exit(1); @@ -81,6 +82,7 @@ function handler(flags, externalCliOptions) { check_credentials_1.checkConfigForCredentials(config); const spinner = logger_1.getOraSpinner('Deploying Function').start(); try { + const client = new serverless_api_1.TwilioServerlessApiClient(config); client.on('status-update', evt => { spinner.text = evt.message + '\n'; @@ -89,7 +91,7 @@ function handler(flags, externalCliOptions) { spinner.text = 'Serverless function successfully deployed'; spinner.succeed(); const { serviceSid, buildSid } = result; - yield utils_1.saveLatestDeploymentData(config.cwd, serviceSid, buildSid, config.accountSid.startsWith('AC') + yield utils_1.saveLatestDeploymentData(config.cwd, serviceSid, buildSid, config.accountSid && config.accountSid.startsWith('AC') ? config.accountSid : externalCliOptions && externalCliOptions.accountSid); @@ -98,6 +100,8 @@ function handler(flags, externalCliOptions) { }; } catch (err) { + + console.log(err); handleError(err, spinner, flags, config); } });