Skip to content

Commit

Permalink
chore: upgrade dev dependencies and fix eslint errors/warnings (twili…
Browse files Browse the repository at this point in the history
  • Loading branch information
childish-sambino committed Mar 12, 2020
1 parent d30ba2e commit 151e3cc
Show file tree
Hide file tree
Showing 14 changed files with 1,218 additions and 949 deletions.
2,037 changes: 1,141 additions & 896 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@
"@oclif/dev-cli": "^1.22.2",
"@oclif/test": "^1.2.5",
"@twilio/cli-test": "^2.0.2",
"aws-sdk": "^2.612.0",
"aws-sdk": "^2.638.0",
"chai": "^4.2.0",
"eslint": "^4.19.1",
"eslint-config-oclif": "^1.5.1",
"eslint-plugin-mocha": "^5.2.1",
"globby": "^10.0.1",
"mocha": "^6.2.2",
"nock": "^11.7.0",
"nyc": "^14.1.1",
"rimraf": "^2.7.1",
"sinon": "^7.5.0",
"eslint": "^6.8.0",
"eslint-config-oclif": "^3.1.0",
"eslint-plugin-mocha": "^6.3.0",
"globby": "^11.0.0",
"mocha": "^7.1.0",
"nock": "^12.0.2",
"nyc": "^15.0.0",
"sinon": "^9.0.1",
"tmp": "^0.1.0"
},
"engines": {
Expand Down Expand Up @@ -105,7 +104,7 @@
"url": "https://github.com/twilio/twilio-cli.git"
},
"scripts": {
"postpack": "rimraf oclif.manifest.json npm-shrinkwrap.json",
"postpack": "rm -f oclif.manifest.json npm-shrinkwrap.json",
"posttest": "eslint --ignore-path .gitignore . && npm audit",
"prepack": "oclif-dev manifest && oclif-dev readme && npm shrinkwrap && git checkout -- package-lock.json",
"test": "nyc --check-coverage --lines 90 --reporter=html --reporter=text mocha --forbid-only \"test/**/*.test.js\"",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/email/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class Send extends BaseCommand {
try {
const coded = fs.readFileSync(filePath, 'base64');
return coded;
} catch (err) {
this.logger.debug(err);
} catch (error) {
this.logger.debug(error);
throw new TwilioCliError('Unable to read the file: ' + filePath);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/phone-numbers/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class NumberUpdate extends TwilioClientCommand {
}

// Build the new prop value using the tunnel URL.
// eslint-disable-next-line require-atomic-updates
props[propName] = newBaseUrl + url.pathname + url.search;
}

Expand Down
12 changes: 6 additions & 6 deletions src/commands/profiles/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ class ProfilesCreate extends BaseCommand {
// Don't log the response since it contains the account auth token.
await twilioClient.api.accounts(this.accountSid).fetch();
return true;
} catch (err) {
} catch (error) {
this.logger.error('Could not validate the provided credentials. Not saving.');
this.logger.debug(err);
this.logger.debug(error);
return false;
}
}
Expand All @@ -218,9 +218,9 @@ class ProfilesCreate extends BaseCommand {
getUsername() {
try {
return os.userInfo().username;
} catch (err) {
} catch (error) {
// Throws a SystemError if a user has no username or homedir.
this.logger.debug(err);
this.logger.debug(error);
}
}

Expand All @@ -232,8 +232,8 @@ class ProfilesCreate extends BaseCommand {
try {
apiKey = await twilioClient.newKeys.create({ friendlyName: apiKeyFriendlyName });
this.logger.debug(apiKey);
} catch (err) {
this.logger.debug(err);
} catch (error) {
this.logger.debug(error);
throw new TwilioCliError('Could not create an API Key.');
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/profiles/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ProfilesRemove extends TwilioClientCommand {
try {
await this.twilioClient.api.keys(credentials.apiKey).remove();
this.logger.info('The API Key has been deleted from The Twilio console.');
} catch (err) {
} catch (error) {
this.logger.error('Could not delete the API Key. See: https://www.twilio.com/console/runtime/api-keys to delete the API Key from The Twilio Console.');
this.logger.debug(err.message);
this.logger.debug(error.message);
}
}
if (keyVerdict === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/init/twilio-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TwilioRestApiPlugin extends Plugin {
/**
* Attempts to get the hostname from first path's server. Falls back to using the domain name.
*
* @param actionDefinition - action containing domain paths
* @param {Object} actionDefinition - action containing domain paths
* @returns {string} - Target hostname for the action
*/
getHostname(actionDefinition) {
Expand Down
6 changes: 3 additions & 3 deletions src/services/api-schema/schema-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const TwilioSchemaValidator = require('./twilio-validator');
* Validates an object's value against a given schema. Uses the Twilio schema
* validator.
*
* @param schema {Object} - object to validate against
* @param value {Object} - object to validate
* @param logger {Logger} - debug logger
* @param {Object} schema - object to validate against
* @param {Object} value - object to validate
* @param {Logger} logger - debug logger
* @returns {Array} - validation errors strings
*/
function validateSchema(schema, value, logger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class IncomingPhoneNumberHelper {
if (sid) {
try {
response = await this.twilioClient.incomingPhoneNumbers(sid).fetch();
} catch (err) {
const errorMessage = err.code === 20404 ? 'Could not find phone number ' + userInput : err.message;
} catch (error) {
const errorMessage = error.code === 20404 ? 'Could not find phone number ' + userInput : error.message;
throw new TwilioCliError(errorMessage);
}
return response;
Expand All @@ -22,8 +22,8 @@ class IncomingPhoneNumberHelper {
let matches;
try {
matches = await this.twilioClient.incomingPhoneNumbers.list({ phoneNumber: userInput });
} catch (err) {
throw new TwilioCliError(err.message);
} catch (error) {
throw new TwilioCliError(error.message);
}

if (matches && matches.length > 0) return matches[0];
Expand Down
4 changes: 4 additions & 0 deletions src/services/twilio-api/get-flag-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const getFlagName = paramName => {

/**
* Converts a Twilio API parameter into a Twilio CLI flag.
*
* @param {Object} parameter - Twilio API parameter
* @param {Object} actionDefinition - action containing topic, command, and domain names
* @returns {Object} - Twilio CLI flag configuration
*/
const getFlagConfig = (parameter, actionDefinition) => {
let flagName = getFlagName(parameter.name);
Expand Down
4 changes: 4 additions & 0 deletions test/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require: test/helpers/init.js
recursive: true
reporter: spec
timeout: 10000
54 changes: 36 additions & 18 deletions test/base-commands/twilio-api-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ describe('base-commands', () => {
};

const getCommandClass = (actionDefinition = callCreateActionDefinition) => {
const NewCommandClass = class extends TwilioApiCommand { };
const NewCommandClass = class extends TwilioApiCommand {
};
NewCommandClass.actionDefinition = actionDefinition;
NewCommandClass.actionDefinition.topicName = 'api:' + getTopicName(NewCommandClass.actionDefinition);
TwilioApiCommand.setUpNewCommandClass(NewCommandClass);
Expand Down Expand Up @@ -119,9 +120,12 @@ describe('base-commands', () => {
.stdout()
.stderr()
.twilioCreateCommand(getCommandClass(), [
'--from', '+15555555555',
'--to', '+14155555555',
'--url', 'http://example.com/'
'--from',
'+15555555555',
'--to',
'+14155555555',
'--url',
'http://example.com/'
])
.do(ctx => {
ctx.testCmd.twilioApi = { create: sinon.stub().returns(fakeCallResponse) };
Expand All @@ -137,9 +141,12 @@ describe('base-commands', () => {
.stdout()
.stderr()
.twilioCreateCommand(getCommandClass(callListActionDefinition), [
'--start-time-after', 'after-this',
'--start-time-before', 'before-that',
'--limit', '1'
'--start-time-after',
'after-this',
'--start-time-before',
'before-that',
'--limit',
'1'
])
.do(ctx => {
ctx.testCmd.twilioApi = { list: sinon.stub().returns([]) };
Expand Down Expand Up @@ -175,9 +182,12 @@ describe('base-commands', () => {
.twilioCliEnv(Config)
.stderr()
.twilioCreateCommand(getCommandClass(numberUpdateActionDefinition), [
'--sid', fakeCallResponse.sid,
'--account-sid', 'AC012',
'--target-account-sid', 'AC123'
'--sid',
fakeCallResponse.sid,
'--account-sid',
'AC012',
'--target-account-sid',
'AC123'
])
.do(ctx => {
ctx.testCmd.twilioApi = { update: sinon.stub().returns({}) };
Expand All @@ -193,10 +203,14 @@ describe('base-commands', () => {
.twilioCliEnv(Config)
.stderr()
.twilioCommand(getCommandClass(), [
'--from', '+15555555555',
'--to', '+14155555555',
'--url', 'http://example.com/',
'--application-sid', 'ap12345678901234567890123456789012' // Lower-cased 'ap'
'--from',
'+15555555555',
'--to',
'+14155555555',
'--url',
'http://example.com/',
'--application-sid',
'ap12345678901234567890123456789012' // Lower-cased 'ap'
])
.catch(/Cannot execute command/)
.it('exits with a failure code and prints validation errors', ctx => {
Expand All @@ -210,10 +224,14 @@ describe('base-commands', () => {
.stderr()
.twilioCreateCommand(getCommandClass(), [
'--skip-parameter-validation',
'--from', '+15555555555',
'--to', '+14155555555',
'--url', 'http://example.com/',
'--application-sid', 'ap12345678901234567890123456789012' // Lower-cased 'ap'
'--from',
'+15555555555',
'--to',
'+14155555555',
'--url',
'http://example.com/',
'--application-sid',
'ap12345678901234567890123456789012' // Lower-cased 'ap'
])
.do(ctx => {
ctx.testCmd.twilioApi = { create: sinon.stub().returns(fakeCallResponse) };
Expand Down
6 changes: 4 additions & 2 deletions test/hooks/init/buy-phone-number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ describe('hooks', () => {
.twilioFakeProfile(ConfigData)
.twilioCliEnv(Config)
.twilioCreateCommand(getBuyLocalCommand(), [
'--country-code', TEST_COUNTRY_CODE,
'--area-code', TEST_AREA_CODE
'--country-code',
TEST_COUNTRY_CODE,
'--area-code',
TEST_AREA_CODE
])
.stderr()
.do(ctx => {
Expand Down
4 changes: 0 additions & 4 deletions test/mocha.opts

This file was deleted.

0 comments on commit 151e3cc

Please sign in to comment.