From cad6cf3756705ed7241a57ce3fb625042297d86d Mon Sep 17 00:00:00 2001 From: AshAnand34 Date: Thu, 19 Jun 2025 15:10:33 -0700 Subject: [PATCH 1/4] Updated version of @oclif/core in twilio-cli --- package-lock.json | 324 ++++++++---------- package.json | 2 +- src/commands/debugger/logs/list.js | 12 +- src/commands/phone-numbers/update.js | 8 +- .../twilio-help/twilio-command-help.js | 3 +- test/hooks/init/buy-phone-number.test.js | 2 +- test/hooks/init/twilio-api.test.js | 2 +- .../twilio-help/twilio-help-doc.test.js | 2 +- test/services/twilio-help/twilio-help.test.js | 2 +- 9 files changed, 150 insertions(+), 207 deletions(-) diff --git a/package-lock.json b/package-lock.json index e6ba12f65..f1392d778 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@oclif/command": "^1.8.36", - "@oclif/core": "^1.16.0", + "@oclif/core": "^4.3.3", "@oclif/plugin-autocomplete": "^1.3.0", "@oclif/plugin-plugins": "^2.1.0", "@oclif/plugin-update": "^2.1.3", @@ -3019,42 +3019,56 @@ } }, "node_modules/@oclif/core": { - "version": "1.26.2", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-1.26.2.tgz", - "integrity": "sha512-6jYuZgXvHfOIc9GIaS4T3CIKGTjPmfAxuMcbCbMRKJJl4aq/4xeRlEz0E8/hz8HxvxZBGvN2GwAUHlrGWQVrVw==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.4.0.tgz", + "integrity": "sha512-wH5g3SLmbRutnr7UzQBSozRFEAZ7U9YGB/wFuBRr0ZghTgv5DE+KQaf6ZtU7iFb9pvkvoVRnT5XheNAtbjRDaQ==", "license": "MIT", "dependencies": { - "@oclif/linewrap": "^1.0.0", - "@oclif/screen": "^3.0.4", "ansi-escapes": "^4.3.2", - "ansi-styles": "^4.3.0", - "cardinal": "^2.1.1", - "chalk": "^4.1.2", + "ansis": "^3.17.0", "clean-stack": "^3.0.1", - "cli-progress": "^3.10.0", - "debug": "^4.3.4", - "ejs": "^3.1.6", - "fs-extra": "^9.1.0", + "cli-spinners": "^2.9.2", + "debug": "^4.4.0", + "ejs": "^3.1.10", "get-package-type": "^0.1.0", - "globby": "^11.1.0", - "hyperlinker": "^1.0.0", "indent-string": "^4.0.0", "is-wsl": "^2.2.0", - "js-yaml": "^3.14.1", - "natural-orderby": "^2.0.3", - "object-treeify": "^1.1.33", - "password-prompt": "^1.1.2", - "semver": "^7.3.7", + "lilconfig": "^3.1.3", + "minimatch": "^9.0.5", + "semver": "^7.6.3", "string-width": "^4.2.3", - "strip-ansi": "^6.0.1", - "supports-color": "^8.1.1", - "supports-hyperlinks": "^2.2.0", - "tslib": "^2.4.1", + "supports-color": "^8", + "tinyglobby": "^0.2.14", "widest-line": "^3.1.0", + "wordwrap": "^1.0.0", "wrap-ansi": "^7.0.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" + } + }, + "node_modules/@oclif/core/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@oclif/core/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/@oclif/dev-cli": { @@ -3443,62 +3457,6 @@ "node": ">=18.0.0" } }, - "node_modules/@oclif/plugin-not-found/node_modules/@oclif/core": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.3.3.tgz", - "integrity": "sha512-A0mk4nlVE+r34fl91OdglXVPwhhfzM59IhSxnOigqMkwxFgT8z3i2WlUgzmazzvzSccs2KM4N2HkTS3NEvW96g==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-escapes": "^4.3.2", - "ansis": "^3.17.0", - "clean-stack": "^3.0.1", - "cli-spinners": "^2.9.2", - "debug": "^4.4.0", - "ejs": "^3.1.10", - "get-package-type": "^0.1.0", - "indent-string": "^4.0.0", - "is-wsl": "^2.2.0", - "lilconfig": "^3.1.3", - "minimatch": "^9.0.5", - "semver": "^7.6.3", - "string-width": "^4.2.3", - "supports-color": "^8", - "tinyglobby": "^0.2.14", - "widest-line": "^3.1.0", - "wordwrap": "^1.0.0", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@oclif/plugin-not-found/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@oclif/plugin-not-found/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@oclif/plugin-plugins": { "version": "2.4.7", "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-2.4.7.tgz", @@ -3583,6 +3541,45 @@ "node": ">=12.0.0" } }, + "node_modules/@oclif/plugin-update/node_modules/@oclif/core": { + "version": "1.26.2", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-1.26.2.tgz", + "integrity": "sha512-6jYuZgXvHfOIc9GIaS4T3CIKGTjPmfAxuMcbCbMRKJJl4aq/4xeRlEz0E8/hz8HxvxZBGvN2GwAUHlrGWQVrVw==", + "license": "MIT", + "dependencies": { + "@oclif/linewrap": "^1.0.0", + "@oclif/screen": "^3.0.4", + "ansi-escapes": "^4.3.2", + "ansi-styles": "^4.3.0", + "cardinal": "^2.1.1", + "chalk": "^4.1.2", + "clean-stack": "^3.0.1", + "cli-progress": "^3.10.0", + "debug": "^4.3.4", + "ejs": "^3.1.6", + "fs-extra": "^9.1.0", + "get-package-type": "^0.1.0", + "globby": "^11.1.0", + "hyperlinker": "^1.0.0", + "indent-string": "^4.0.0", + "is-wsl": "^2.2.0", + "js-yaml": "^3.14.1", + "natural-orderby": "^2.0.3", + "object-treeify": "^1.1.33", + "password-prompt": "^1.1.2", + "semver": "^7.3.7", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "supports-color": "^8.1.1", + "supports-hyperlinks": "^2.2.0", + "tslib": "^2.4.1", + "widest-line": "^3.1.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@oclif/plugin-version": { "version": "1.3.10", "resolved": "https://registry.npmjs.org/@oclif/plugin-version/-/plugin-version-1.3.10.tgz", @@ -3651,59 +3648,6 @@ "node": ">=18.0.0" } }, - "node_modules/@oclif/plugin-warn-if-update-available/node_modules/@oclif/core": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.3.3.tgz", - "integrity": "sha512-A0mk4nlVE+r34fl91OdglXVPwhhfzM59IhSxnOigqMkwxFgT8z3i2WlUgzmazzvzSccs2KM4N2HkTS3NEvW96g==", - "license": "MIT", - "dependencies": { - "ansi-escapes": "^4.3.2", - "ansis": "^3.17.0", - "clean-stack": "^3.0.1", - "cli-spinners": "^2.9.2", - "debug": "^4.4.0", - "ejs": "^3.1.10", - "get-package-type": "^0.1.0", - "indent-string": "^4.0.0", - "is-wsl": "^2.2.0", - "lilconfig": "^3.1.3", - "minimatch": "^9.0.5", - "semver": "^7.6.3", - "string-width": "^4.2.3", - "supports-color": "^8", - "tinyglobby": "^0.2.14", - "widest-line": "^3.1.0", - "wordwrap": "^1.0.0", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@oclif/plugin-warn-if-update-available/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@oclif/plugin-warn-if-update-available/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@oclif/screen": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/@oclif/screen/-/screen-3.0.8.tgz", @@ -6114,6 +6058,62 @@ "node": ">=14.0.0" } }, + "node_modules/@twilio/cli-test/node_modules/@oclif/core": { + "version": "1.26.2", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-1.26.2.tgz", + "integrity": "sha512-6jYuZgXvHfOIc9GIaS4T3CIKGTjPmfAxuMcbCbMRKJJl4aq/4xeRlEz0E8/hz8HxvxZBGvN2GwAUHlrGWQVrVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oclif/linewrap": "^1.0.0", + "@oclif/screen": "^3.0.4", + "ansi-escapes": "^4.3.2", + "ansi-styles": "^4.3.0", + "cardinal": "^2.1.1", + "chalk": "^4.1.2", + "clean-stack": "^3.0.1", + "cli-progress": "^3.10.0", + "debug": "^4.3.4", + "ejs": "^3.1.6", + "fs-extra": "^9.1.0", + "get-package-type": "^0.1.0", + "globby": "^11.1.0", + "hyperlinker": "^1.0.0", + "indent-string": "^4.0.0", + "is-wsl": "^2.2.0", + "js-yaml": "^3.14.1", + "natural-orderby": "^2.0.3", + "object-treeify": "^1.1.33", + "password-prompt": "^1.1.2", + "semver": "^7.3.7", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "supports-color": "^8.1.1", + "supports-hyperlinks": "^2.2.0", + "tslib": "^2.4.1", + "widest-line": "^3.1.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@twilio/cli-test/node_modules/@oclif/core/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/@twilio/cli-test/node_modules/@sinonjs/fake-timers": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz", @@ -15500,36 +15500,6 @@ "node": ">=18.0.0" } }, - "node_modules/oclif/node_modules/@oclif/core": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.3.3.tgz", - "integrity": "sha512-A0mk4nlVE+r34fl91OdglXVPwhhfzM59IhSxnOigqMkwxFgT8z3i2WlUgzmazzvzSccs2KM4N2HkTS3NEvW96g==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-escapes": "^4.3.2", - "ansis": "^3.17.0", - "clean-stack": "^3.0.1", - "cli-spinners": "^2.9.2", - "debug": "^4.4.0", - "ejs": "^3.1.10", - "get-package-type": "^0.1.0", - "indent-string": "^4.0.0", - "is-wsl": "^2.2.0", - "lilconfig": "^3.1.3", - "minimatch": "^9.0.5", - "semver": "^7.6.3", - "string-width": "^4.2.3", - "supports-color": "^8", - "tinyglobby": "^0.2.14", - "widest-line": "^3.1.0", - "wordwrap": "^1.0.0", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/oclif/node_modules/@oclif/plugin-help": { "version": "6.2.28", "resolved": "https://registry.npmjs.org/@oclif/plugin-help/-/plugin-help-6.2.28.tgz", @@ -15543,16 +15513,6 @@ "node": ">=18.0.0" } }, - "node_modules/oclif/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/oclif/node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -15605,22 +15565,6 @@ "dev": true, "license": "ISC" }, - "node_modules/oclif/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/oclif/node_modules/normalize-package-data": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-6.0.2.tgz", diff --git a/package.json b/package.json index bc2a79442..165f690d6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "version": "oclif readme && git add README.md" }, "dependencies": { - "@oclif/core": "^1.16.0", + "@oclif/core": "^4.3.3", "@oclif/plugin-autocomplete": "^1.3.0", "@oclif/plugin-plugins": "^2.1.0", "@oclif/plugin-update": "^2.1.3", diff --git a/src/commands/debugger/logs/list.js b/src/commands/debugger/logs/list.js index e278cda98..4c6f87a93 100644 --- a/src/commands/debugger/logs/list.js +++ b/src/commands/debugger/logs/list.js @@ -1,6 +1,6 @@ const querystring = require('querystring'); -const { Flags: oclifFlags } = require('@oclif/core'); +const { Flags } = require('@oclif/core'); const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands; const { TwilioCliError } = require('@twilio/cli-core').services.error; const { sleep } = require('@twilio/cli-core').services.JSUtils; @@ -97,24 +97,24 @@ DebuggerLogsList.description = `Show a list of log events generated for the acco Argg, this is only a subset of the log events and live tailing isn't quite ready! Think this is a killer feature? Let us know here: https://airtable.com/shrcFDU1gmKWOqZXe`; DebuggerLogsList.PropertyFlags = { - 'log-level': oclifFlags.enum({ + 'log-level': Flags.string({ options: ['error', 'warning', 'notice', 'debug'], description: 'Only show log events for this log level', }), - 'start-date': oclifFlags.string({ + 'start-date': Flags.string({ description: 'Only show log events on or after this date', }), - 'end-date': oclifFlags.string({ + 'end-date': Flags.string({ description: 'Only show log events on or before this date', }), }; DebuggerLogsList.flags = { - properties: oclifFlags.string({ + properties: Flags.string({ default: 'dateCreated, logLevel, errorCode, alertText', description: 'The event properties you would like to display (JSON output always shows all properties)', }), - streaming: oclifFlags.boolean({ + streaming: Flags.boolean({ char: 's', description: 'Continuously stream incoming log events', }), diff --git a/src/commands/phone-numbers/update.js b/src/commands/phone-numbers/update.js index 7965eab40..0c715921d 100644 --- a/src/commands/phone-numbers/update.js +++ b/src/commands/phone-numbers/update.js @@ -47,7 +47,7 @@ NumberUpdate.PropertyFlags = { 'sms-url': flags.string({ description: 'The URL that Twilio should request when somebody sends an SMS to the new phone number.', }), - 'sms-method': flags.enum({ + 'sms-method': flags.string({ options: ['GET', 'POST'], description: 'The HTTP method Twilio will use when making requests to the SmsUrl.', }), @@ -55,14 +55,14 @@ NumberUpdate.PropertyFlags = { description: 'A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl.', }), - 'sms-fallback-method': flags.enum({ + 'sms-fallback-method': flags.string({ options: ['GET', 'POST'], description: 'The HTTP method that should be used to request the SmsFallbackUrl.', }), 'voice-url': flags.string({ description: 'The URL that Twilio should request when somebody dials the phone number.', }), - 'voice-method': flags.enum({ + 'voice-method': flags.string({ options: ['GET', 'POST'], description: 'The HTTP method Twilio will use when making requests to the VoiceUrl.', }), @@ -70,7 +70,7 @@ NumberUpdate.PropertyFlags = { description: 'A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by VoiceUrl.', }), - 'voice-fallback-method': flags.enum({ + 'voice-fallback-method': flags.string({ options: ['GET', 'POST'], description: 'The HTTP method Twilio will use when requesting the VoiceFallbackUrl.', }), diff --git a/src/services/twilio-help/twilio-command-help.js b/src/services/twilio-help/twilio-command-help.js index dd7507516..b134593c3 100644 --- a/src/services/twilio-help/twilio-command-help.js +++ b/src/services/twilio-help/twilio-command-help.js @@ -4,7 +4,6 @@ const { CommandHelp } = require('@oclif/core'); const chalk = require('chalk'); const indent = require('indent-string'); const stripAnsi = require('strip-ansi'); -const { compact } = require('@oclif/core/lib/config/util'); const urlUtil = require('../hyperlink-utility'); const { getDocLink } = require('../twilio-api'); @@ -61,7 +60,7 @@ class TwilioCommandHelp extends CommandHelp { const body = this.flags(flags1); if (body) flagSections.push({ header: `${name.toUpperCase()} ${header}`, body }); } - return (0, compact)(flagSections); + return flagSections.filter(Boolean); }, }, { diff --git a/test/hooks/init/buy-phone-number.test.js b/test/hooks/init/buy-phone-number.test.js index 750c7dd3b..32b4777f8 100644 --- a/test/hooks/init/buy-phone-number.test.js +++ b/test/hooks/init/buy-phone-number.test.js @@ -75,7 +75,7 @@ describe('hooks', () => { }); setup().it('creates the proper commands', (ctx) => { - expect(ctx.plugin.hooks).to.eql({}); // eql is for comparing objects (== instead of ===) + expect(ctx.plugin?.hooks || {}).to.eql({}); // eql is for comparing objects (== instead of ===) expect(ctx.plugin.topics).to.have.length(1); expect(ctx.plugin.commands).to.have.length(2); diff --git a/test/hooks/init/twilio-api.test.js b/test/hooks/init/twilio-api.test.js index f66d9c129..996e09e58 100644 --- a/test/hooks/init/twilio-api.test.js +++ b/test/hooks/init/twilio-api.test.js @@ -16,7 +16,7 @@ describe('hooks', () => { const plugin = ctx.config.plugins[0]; - expect(plugin.hooks).to.eql({}); // eql is for comparing objects (== instead of ===) + expect(plugin?.hooks || {}).to.eql({}); // eql is for comparing objects (== instead of ===) expect(plugin.topics.length).to.be.greaterThan(20); expect(plugin.commandIDs.length).to.be.greaterThan(plugin.topics.length); expect(plugin.commands.length).to.equal(plugin.commandIDs.length); diff --git a/test/services/twilio-help/twilio-help-doc.test.js b/test/services/twilio-help/twilio-help-doc.test.js index 951a96a46..b575188b4 100644 --- a/test/services/twilio-help/twilio-help-doc.test.js +++ b/test/services/twilio-help/twilio-help-doc.test.js @@ -32,7 +32,7 @@ const testHelp = test const help = ctx.help.formatCommand(dummyHelpCommand); ctx.commandHelp = stripAnsi(help) .split('\n') - .map((s) => s.trimRight()) + .map((s) => s.trimEnd()) .join('\n'); }, }; diff --git a/test/services/twilio-help/twilio-help.test.js b/test/services/twilio-help/twilio-help.test.js index 0c5fc4d09..ff7e64a50 100644 --- a/test/services/twilio-help/twilio-help.test.js +++ b/test/services/twilio-help/twilio-help.test.js @@ -41,7 +41,7 @@ const testHelp = test const help = ctx.help.formatCommand(dummyHelpCommand); ctx.commandHelp = stripAnsi(help) .split('\n') - .map((s) => s.trimRight()) + .map((s) => s.trimEnd()) .join('\n'); }, }; From 3ce24899172d4e3585cbab4657e9c29f2b42978d Mon Sep 17 00:00:00 2001 From: AshAnand34 Date: Thu, 19 Jun 2025 15:28:11 -0700 Subject: [PATCH 2/4] Updated the documents related to the newer versin of oclif/core and oclif/test --- docs/plugins.md | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index bd56f2356..759161045 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -15,7 +15,7 @@ Start by cloning [this repo of an example debugger plugin](https://github.com/tw Once it's cloned, you can poke around to get a sense for the organization and even copy and adapt it for your own plugin use case. -Your plugin directory should following the naming convention `plugin-`. +Your plugin directory should follow the naming convention `plugin-`. Remember to update the `package.json` fields if you start building your own plugin off of this one: * name @@ -26,14 +26,13 @@ Remember to update the `package.json` fields if you start building your own plug And run `npm install`. - ## 3. Add your [topics](https://oclif.io/docs/topics) and [commands](https://oclif.io/docs/commands) Commands go in the `src/commands` folder and should inherit from one of our command base classes. ### TwilioClientCommand -Inherit from `TwilioClientCommand` if your command will need to make Twilio API calls. You will be provided with a `this.twilioClient` to make API calls using the Node.js helper library for Twilio. The client object will already have the necessary credentials and account SID. Just start calling the API. You are also given an `this.httpClient` to make requests to other API's, but you'll need to manage any necessary credentials yourself. +Inherit from `TwilioClientCommand` if your command will need to make Twilio API calls. You will be provided with a `this.twilioClient` to make API calls using the Node.js helper library for Twilio. The client object will already have the necessary credentials and account SID. Just start calling the API. You are also given an `this.httpClient` to make requests to other APIs, but you'll need to manage any necessary credentials yourself. ### TwilioBaseCommand @@ -46,37 +45,49 @@ Finally, the CLI will warn the user if the plugin is hosted outside of the [twil ### Flags -To create flags for your spectacular plugin, you will need the following import: `const { flags } = require('@oclif/command');` - -Additionally, you will need to copy the base class' flags: -```javascript -MySpectacularPlugin.flags = Object.assign({'fave-dessert': flag.string({'description': 'Your favorite dessert', required: true})}, TwilioClientCommand.flags) +To create flags for your plugin, use the following import: +```js +const { Flags } = require('@oclif/core'); +``` +And define your flags like this: +```js +MySpectacularPlugin.flags = { + ...TwilioClientCommand.flags, + 'fave-dessert': Flags.string({ description: 'Your favorite dessert', required: true }), +}; ``` ## 4. Test your plugin with the CLI -You are probably using NPM if you develop a twilio-cli plugin, so install it if you have not already done so: +For local development, clone both the CLI and your plugin repositories. After running `npm install` in both, link your plugin to your local CLI using: -`npm install -g twilio-cli` +``` +./bin/run plugins:link ../plugin- +``` -Follow the set-up instructions in the [twilio-cli Quickstart](https://www.twilio.com/docs/twilio-cli/quickstart). The Quickstart also includes instructions for homebrew installation. +or, if using npm scripts: -For testing, "install" the plugin referencing your plugin's local development folder by linking to your plugin. +``` +npm run plugins:link ../plugin- +``` -Run this command from the CLI folder. This assumes the CLI and your plugin folders are siblings of each other (perhaps in a `~/Projects` folder): +Now, you can run your plugin command from the CLI: ``` -./bin/run plugins:link ../plugin- +twilio my-new-topic:my-new-command --help ``` +## 5. Testing your plugin -Now, you can run your plugin command from the CLI: +Install the latest compatible version of `@oclif/test` for use with `@oclif/core@^4`: ``` -twilio my-new-topic:my-new-command --help +npm install --save-dev @oclif/test ``` -## 5. Publish your plugin to NPM +Refer to the [oclif test documentation](https://oclif.github.io/docs/testing/) for up-to-date testing patterns and helpers. + +## 6. Publish your plugin to NPM Once you have your plugin working, publish it to npmjs.org as a JavaScript package using `npm publish`. The `twilio plugins:install ` command will download your package from NPM. From f6b1ef1602602a618f25a921ef16b9f373e4ab7e Mon Sep 17 00:00:00 2001 From: AshAnand34 Date: Thu, 19 Jun 2025 15:46:12 -0700 Subject: [PATCH 3/4] fix: ensure plugins are checked for installation only if config.plugins is an array --- src/services/plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/plugins.js b/src/services/plugins.js index 599b54722..0991795eb 100644 --- a/src/services/plugins.js +++ b/src/services/plugins.js @@ -20,7 +20,7 @@ exports.isTwilioPlugin = (pluginName) => { }; exports.isPluginInstalled = (config, pluginName) => { - return config.plugins.find((p) => p.name === pluginName); + return Array.isArray(config?.plugins) && config.plugins.find((p) => p.name === pluginName); }; exports.getSupportedPlugin = (commandId) => { From 27755873c2ac9be71d0b6e7f958ed05409bf5479 Mon Sep 17 00:00:00 2001 From: AshAnand34 Date: Thu, 19 Jun 2025 15:51:56 -0700 Subject: [PATCH 4/4] Fixing error with this.exit from oclif --- src/hooks/command-not-found.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/command-not-found.js b/src/hooks/command-not-found.js index c3d0d0b8d..1aa66511c 100644 --- a/src/hooks/command-not-found.js +++ b/src/hooks/command-not-found.js @@ -33,7 +33,7 @@ module.exports = async function commandNotFound(options) { logger.warn(`Installed plugin ${pluginName}"!`); logger.warn('Please try running the command again'); - this.exit(0); + return; } } };