From 55170a581be2cb62c825040f4fa023fabf5eb4f8 Mon Sep 17 00:00:00 2001 From: ylakhdar Date: Mon, 25 Sep 2023 13:00:01 -0400 Subject: [PATCH 1/3] package major bump --- package-lock.json | 196 +++++++++++++++++++++++++++++- packages/cli/commons/package.json | 2 +- packages/cli/core/package.json | 2 +- packages/cli/source/package.json | 2 +- 4 files changed, 194 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index b6345d1999..9ff808c420 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6976,7 +6976,6 @@ "version": "3.11.0", "resolved": "https://registry.npmjs.org/@types/cli-progress/-/cli-progress-3.11.0.tgz", "integrity": "sha512-XhXhBv1R/q2ahF3BM7qT5HLzJNlIL0wbcGyZVjqOTqAybAnsLisd7gy1UCyIqpL+5Iv6XhlSyzjLCnI2sIdbCg==", - "dev": true, "dependencies": { "@types/node": "*" } @@ -9487,7 +9486,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", - "dev": true, "engines": { "node": ">=8" } @@ -30621,7 +30619,7 @@ "@amplitude/analytics-node": "^1.3.3", "@amplitude/analytics-types": "^2.1.2", "@coveo/platform-client": "44.1.0", - "@oclif/core": "1.24.0", + "@oclif/core": "2.15.0", "abortcontroller-polyfill": "1.7.5", "chalk": "4.1.2", "fs-extra": "11.1.1", @@ -30661,6 +30659,44 @@ "resolved": "https://registry.npmjs.org/@amplitude/analytics-types/-/analytics-types-2.1.2.tgz", "integrity": "sha512-ASKwH9g+5gglTHr7h7miK8J/ofIzuEtGRDCjnZAtRbE6+laoOfCLYPPJXMYz0k1x+rIhLO/6I6WWjT7zchmpyA==" }, + "packages/cli/commons/node_modules/@oclif/core": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-2.15.0.tgz", + "integrity": "sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==", + "dependencies": { + "@types/cli-progress": "^3.11.0", + "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.12.0", + "debug": "^4.3.4", + "ejs": "^3.1.8", + "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", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "supports-color": "^8.1.1", + "supports-hyperlinks": "^2.2.0", + "ts-node": "^10.9.1", + "tslib": "^2.5.0", + "widest-line": "^3.1.0", + "wordwrap": "^1.0.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, "packages/cli/commons/node_modules/is-ci": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", @@ -30672,6 +30708,30 @@ "is-ci": "bin.js" } }, + "packages/cli/commons/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "packages/cli/commons/node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, "packages/cli/core": { "name": "@coveo/cli", "version": "2.6.2", @@ -30682,7 +30742,7 @@ "@coveo/cli-commons": "2.6.0", "@coveo/cli-plugin-source": "2.0.12", "@coveo/platform-client": "44.1.0", - "@oclif/core": "1.24.0", + "@oclif/core": "2.15.0", "@oclif/plugin-help": "5.1.23", "@oclif/plugin-plugins": "2.1.12", "@oclif/plugin-update": "3.0.12", @@ -30769,6 +30829,68 @@ "integrity": "sha512-ASKwH9g+5gglTHr7h7miK8J/ofIzuEtGRDCjnZAtRbE6+laoOfCLYPPJXMYz0k1x+rIhLO/6I6WWjT7zchmpyA==", "dev": true }, + "packages/cli/core/node_modules/@oclif/core": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-2.15.0.tgz", + "integrity": "sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==", + "dependencies": { + "@types/cli-progress": "^3.11.0", + "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.12.0", + "debug": "^4.3.4", + "ejs": "^3.1.8", + "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", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "supports-color": "^8.1.1", + "supports-hyperlinks": "^2.2.0", + "ts-node": "^10.9.1", + "tslib": "^2.5.0", + "widest-line": "^3.1.0", + "wordwrap": "^1.0.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "packages/cli/core/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "packages/cli/core/node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, "packages/cli/source": { "name": "@coveo/cli-plugin-source", "version": "2.0.12", @@ -30777,7 +30899,7 @@ "@coveo/cli-commons": "2.6.0", "@coveo/platform-client": "44.1.0", "@coveo/push-api-client": "3.1.15", - "@oclif/core": "1.24.0", + "@oclif/core": "2.15.0", "@oclif/plugin-help": "5.1.23", "@oclif/plugin-plugins": "2.1.12", "chalk": "4.1.2", @@ -30806,6 +30928,68 @@ "node": "^16.13.0 || ^18.12.0" } }, + "packages/cli/source/node_modules/@oclif/core": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-2.15.0.tgz", + "integrity": "sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==", + "dependencies": { + "@types/cli-progress": "^3.11.0", + "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.12.0", + "debug": "^4.3.4", + "ejs": "^3.1.8", + "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", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "supports-color": "^8.1.1", + "supports-hyperlinks": "^2.2.0", + "ts-node": "^10.9.1", + "tslib": "^2.5.0", + "widest-line": "^3.1.0", + "wordwrap": "^1.0.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "packages/cli/source/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "packages/cli/source/node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, "packages/ui/angular": { "name": "@coveo/angular", "version": "1.36.0", @@ -31409,6 +31593,8 @@ "bin": { "git-lock": "git-lock.mjs", "git-publish-all": "git-publish-all.mjs", + "github-publish": "create-github-release.mjs", + "is-cli-release": "is-cli-release.mjs", "npm-publish": "npm-publish-package.mjs" }, "devDependencies": { diff --git a/packages/cli/commons/package.json b/packages/cli/commons/package.json index 52f8b1de3c..d8f2fd51cb 100644 --- a/packages/cli/commons/package.json +++ b/packages/cli/commons/package.json @@ -27,7 +27,7 @@ "@amplitude/analytics-node": "^1.3.3", "@amplitude/analytics-types": "^2.1.2", "@coveo/platform-client": "44.1.0", - "@oclif/core": "1.24.0", + "@oclif/core": "2.15.0", "abortcontroller-polyfill": "1.7.5", "chalk": "4.1.2", "fs-extra": "11.1.1", diff --git a/packages/cli/core/package.json b/packages/cli/core/package.json index 382717d3ee..87213b91fd 100644 --- a/packages/cli/core/package.json +++ b/packages/cli/core/package.json @@ -12,7 +12,7 @@ "@coveo/cli-commons": "2.6.0", "@coveo/cli-plugin-source": "2.0.12", "@coveo/platform-client": "44.1.0", - "@oclif/core": "1.24.0", + "@oclif/core": "2.15.0", "@oclif/plugin-help": "5.1.23", "@oclif/plugin-plugins": "2.1.12", "@oclif/plugin-update": "3.0.12", diff --git a/packages/cli/source/package.json b/packages/cli/source/package.json index ce8a3c79fa..00a30681f1 100644 --- a/packages/cli/source/package.json +++ b/packages/cli/source/package.json @@ -17,7 +17,7 @@ "@coveo/cli-commons": "2.6.0", "@coveo/platform-client": "44.1.0", "@coveo/push-api-client": "3.1.15", - "@oclif/core": "1.24.0", + "@oclif/core": "2.15.0", "@oclif/plugin-help": "5.1.23", "@oclif/plugin-plugins": "2.1.12", "chalk": "4.1.2", From b677162fe00c06c05b8b57812e2fd66759c3c638 Mon Sep 17 00:00:00 2001 From: ylakhdar Date: Mon, 25 Sep 2023 13:00:17 -0400 Subject: [PATCH 2/3] Apply migration changes --- .../cli/commons/src/command/cliCommand.ts | 2 +- .../cli/commons/src/config/config.spec.ts | 2 +- packages/cli/commons/src/config/config.ts | 13 +++++------ .../cli/commons/src/config/configRenderer.ts | 4 ++-- .../src/preconditions/apiKeyPrivilege.ts | 2 +- packages/cli/commons/src/utils/ux.spec.ts | 12 +++++----- packages/cli/commons/src/utils/ux.ts | 14 ++++++------ .../cli/core/src/commands/atomic/component.ts | 15 ++++++++----- packages/cli/core/src/commands/atomic/init.ts | 11 ++++++---- packages/cli/core/src/commands/config/get.ts | 21 ++++++++++-------- packages/cli/core/src/commands/config/set.ts | 7 +++--- packages/cli/core/src/commands/org/create.ts | 11 +++++----- packages/cli/core/src/commands/org/list.ts | 6 ++--- .../core/src/commands/org/resources/list.ts | 6 ++--- .../src/commands/org/resources/monitor.ts | 20 ++++++++--------- .../commands/org/resources/preview.spec.ts | 4 ++-- .../src/commands/org/resources/pull.spec.ts | 8 +++---- .../core/src/commands/org/resources/pull.ts | 15 +++++++------ .../core/src/commands/org/resources/push.ts | 5 ++--- .../cli/core/src/commands/org/search/dump.ts | 8 +++---- .../core/src/commands/ui/create/angular.ts | 11 +++++----- .../cli/core/src/commands/ui/create/atomic.ts | 11 +++++----- .../cli/core/src/commands/ui/create/react.ts | 11 +++++----- .../cli/core/src/commands/ui/create/vue.ts | 11 +++++----- packages/cli/core/src/commands/ui/deploy.ts | 5 ++--- .../lib/decorators/preconditions/ng.spec.ts | 4 ++-- .../core/src/lib/flags/snapshotCommonFlags.ts | 4 ++-- packages/cli/core/src/lib/project/project.ts | 4 ++-- .../expandedPreviewer.spec.ts | 4 +--- .../expandedPreviewer/expandedPreviewer.ts | 4 ++-- .../reportPreviewer/reportPreviewer.ts | 22 +++++++++---------- .../transferFromOrganization.spec.ts | 6 ++--- .../transferFromOrganization.ts | 10 ++++----- .../src/lib/snapshot/vaultHandler.spec.ts | 6 ++--- .../cli/core/src/lib/snapshot/vaultHandler.ts | 10 ++++----- .../source/src/commands/source/catalog/add.ts | 11 +++++----- .../source/src/commands/source/catalog/new.ts | 12 +++++----- .../cli/source/src/commands/source/list.ts | 6 ++--- .../source/src/commands/source/push/add.ts | 10 ++++----- .../source/src/commands/source/push/delete.ts | 11 +++++----- .../source/src/commands/source/push/new.ts | 12 +++++----- packages/cli/source/src/lib/addCommon.ts | 8 +++---- packages/cli/source/src/lib/addDisplay.ts | 14 +++++------- packages/cli/source/src/lib/commonFlags.ts | 4 ++-- packages/cli/source/src/lib/getFileNames.ts | 4 ++-- packages/cli/source/src/lib/userFeedback.ts | 6 ++--- 46 files changed, 199 insertions(+), 208 deletions(-) diff --git a/packages/cli/commons/src/command/cliCommand.ts b/packages/cli/commons/src/command/cliCommand.ts index 97d77bdc6a..d0374a791e 100644 --- a/packages/cli/commons/src/command/cliCommand.ts +++ b/packages/cli/commons/src/command/cliCommand.ts @@ -11,7 +11,7 @@ import {Trackable} from '../preconditions/trackable'; * @extends {Command} */ export abstract class CLICommand extends Command { - public abstract run(): PromiseLike; + public abstract run(): Promise; /** * If you extend or overwrite the catch method in your command class, make sure it returns `return super.catch(err)` diff --git a/packages/cli/commons/src/config/config.spec.ts b/packages/cli/commons/src/config/config.spec.ts index 5d00cd69f6..796cce3311 100644 --- a/packages/cli/commons/src/config/config.spec.ts +++ b/packages/cli/commons/src/config/config.spec.ts @@ -1,6 +1,6 @@ const mockedUxError = jest.fn(); jest.mock('@oclif/core', () => ({ - CliUx: {ux: {error: mockedUxError}}, + ux: {error: mockedUxError}, })); jest.mock('./configErrors'); jest.mock('fs-extra'); diff --git a/packages/cli/commons/src/config/config.ts b/packages/cli/commons/src/config/config.ts index eef35d8929..b5f02fb436 100644 --- a/packages/cli/commons/src/config/config.ts +++ b/packages/cli/commons/src/config/config.ts @@ -1,5 +1,5 @@ import {Region} from '@coveo/platform-client'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import { pathExistsSync, createFileSync, @@ -52,20 +52,19 @@ export class Config { return content; } catch (e) { if (e instanceof IncompatibleConfigurationError) { - CliUx.ux.error( + ux.error( dedent` The configuration at ${this.configPath} is not compatible with this version of the CLI: ${e.message}`, {exit: false} ); } else { - CliUx.ux.error( - `Error while reading configuration at ${this.configPath}`, - {exit: false} - ); + ux.error(`Error while reading configuration at ${this.configPath}`, { + exit: false, + }); } this.replace(DefaultConfig); - CliUx.ux.error( + ux.error( `Configuration has been reset to default value: ${JSON.stringify( DefaultConfig )}`, diff --git a/packages/cli/commons/src/config/configRenderer.ts b/packages/cli/commons/src/config/configRenderer.ts index 28b710a474..05acce01f3 100644 --- a/packages/cli/commons/src/config/configRenderer.ts +++ b/packages/cli/commons/src/config/configRenderer.ts @@ -1,4 +1,4 @@ -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {BaseConfiguration, Config} from './config'; export class ConfigRenderer { @@ -17,6 +17,6 @@ export class ConfigRenderer { {} ); - CliUx.ux.styledJSON(allowedConfig); + ux.styledJSON(allowedConfig); } } diff --git a/packages/cli/commons/src/preconditions/apiKeyPrivilege.ts b/packages/cli/commons/src/preconditions/apiKeyPrivilege.ts index d1d59544d5..ea8170acf4 100644 --- a/packages/cli/commons/src/preconditions/apiKeyPrivilege.ts +++ b/packages/cli/commons/src/preconditions/apiKeyPrivilege.ts @@ -2,7 +2,7 @@ import PlatformClient, { PrivilegeEvaluatorModel, PrivilegeModel, } from '@coveo/platform-client'; -import {FlagOutput} from '@oclif/core/lib/interfaces'; +import {FlagOutput} from '@oclif/core/lib/interfaces/parser'; import {CLICommand} from '../command/cliCommand'; import {Config} from '../config/config'; import globalConfig from '../config/globalConfig'; diff --git a/packages/cli/commons/src/utils/ux.spec.ts b/packages/cli/commons/src/utils/ux.spec.ts index efc6e9a7d2..264aedbb03 100644 --- a/packages/cli/commons/src/utils/ux.spec.ts +++ b/packages/cli/commons/src/utils/ux.spec.ts @@ -1,4 +1,4 @@ -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {CLICommand} from '../command/cliCommand'; import {stderr} from 'stdout-stderr'; import {startSpinner, stopSpinner, shouldUseColor, formatOrgId} from './ux'; @@ -31,8 +31,8 @@ describe('ux', () => { // @oclif/core has an issue preventing the first stream write to be properly mocked. // This is a bodge. stderr.start(); - CliUx.ux.action.start('test'); - CliUx.ux.action.stop(); + ux.action.start('test'); + ux.action.stop(); stderr.stop(); }); beforeEach(() => { @@ -48,14 +48,14 @@ describe('ux', () => { describe('startSpinner() & stopSpinner()', () => { describe('when spinner is ended with no argument', () => { it('no spinner should be running', () => { - expect(CliUx.ux.action.running).toBe(false); + expect(ux.action.running).toBe(false); }); it('should start a spinner instance', () => { startSpinner('something'); - expect(CliUx.ux.action.running).toBe(true); + expect(ux.action.running).toBe(true); stopSpinner(); - expect(CliUx.ux.action.running).toBe(false); + expect(ux.action.running).toBe(false); }); it('should stop running task without error', () => { diff --git a/packages/cli/commons/src/utils/ux.ts b/packages/cli/commons/src/utils/ux.ts index e68e5027d7..3875ad1271 100644 --- a/packages/cli/commons/src/utils/ux.ts +++ b/packages/cli/commons/src/utils/ux.ts @@ -1,4 +1,4 @@ -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import isCi from 'is-ci'; import {red, green, magenta} from 'chalk'; @@ -15,24 +15,24 @@ export function shouldUseColor() { } export function startSpinner(task: string, status?: string) { - if (CliUx.ux.action.running) { - CliUx.ux.action.stop(green('✔')); + if (ux.action.running) { + ux.action.stop(green('✔')); } - CliUx.ux.action.start(task, status); + ux.action.start(task, status); } export function stopSpinner(options?: {success?: boolean}) { - if (!CliUx.ux.action.running) { + if (!ux.action.running) { return; } const defaultOptions = {success: true}; const {success} = {...defaultOptions, ...options}; const symbol = success ? green('✔') : red.bold('!'); - CliUx.ux.action.stop(`${symbol}`.trimEnd()); + ux.action.stop(`${symbol}`.trimEnd()); } export const formatOrgId = (orgId: TemplateStringsArray | string) => shouldUseColor() ? magenta(orgId) : orgId; export const confirm = (message: string, ciDefault: boolean) => - isCi ? Promise.resolve(ciDefault) : CliUx.ux.confirm(message); + isCi ? Promise.resolve(ciDefault) : ux.confirm(message); diff --git a/packages/cli/core/src/commands/atomic/component.ts b/packages/cli/core/src/commands/atomic/component.ts index 3de2e97208..1aaf8d1858 100644 --- a/packages/cli/core/src/commands/atomic/component.ts +++ b/packages/cli/core/src/commands/atomic/component.ts @@ -1,6 +1,6 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; import {UnknownError} from '@coveo/cli-commons/errors/unknownError'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import inquirer from 'inquirer'; import npf from '@coveo/cli-commons/npm/npf'; import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; @@ -9,7 +9,7 @@ import {handleForkedProcess} from '../../lib/utils/process'; import {SubprocessError} from '../../lib/errors/subprocessError'; import {isAggregatedErrorLike} from '../../lib/utils/errorSchemas'; -export default class AtomicInit extends CLICommand { +export default class AtomicComponent extends CLICommand { public static description = 'Scaffold a new custom component. Meant to be executed in a component library created using the `coveo atomic:init --lib` command, or in an npm project, or in an empty folder.'; public static aliases = ['atomic:cmp']; @@ -26,9 +26,12 @@ export default class AtomicInit extends CLICommand { }), }; - public static args = [ - {name: 'name', description: 'The name of your component.', required: true}, - ]; + public static args = { + name: Args.string({ + description: 'The name of your component.', + required: true, + }), + }; @Trackable() public async run(): Promise { @@ -50,7 +53,7 @@ export default class AtomicInit extends CLICommand { } private async getSpawnOptions() { - const {args, flags} = await this.parse(AtomicInit); + const {args, flags} = await this.parse(AtomicComponent); const type = flags.type || (await this.askType()); const initializerPackage = this.getInitializerPackage(type); diff --git a/packages/cli/core/src/commands/atomic/init.ts b/packages/cli/core/src/commands/atomic/init.ts index 9521202eeb..478704d7eb 100644 --- a/packages/cli/core/src/commands/atomic/init.ts +++ b/packages/cli/core/src/commands/atomic/init.ts @@ -2,7 +2,7 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; import {Config} from '@coveo/cli-commons/config/config'; import {Before} from '@coveo/cli-commons/decorators/before'; import {UnknownError} from '@coveo/cli-commons/errors/unknownError'; -import {Flags} from '@oclif/core'; +import {Flags, Args} from '@oclif/core'; import inquirer from 'inquirer'; import { atomicAppPreconditions, @@ -28,9 +28,12 @@ export default class AtomicInit extends CLICommand { }), }; - public static args = [ - {name: 'name', description: 'The name of your project.', required: true}, - ]; + public static args = { + name: Args.string({ + description: 'The name of your project.', + required: true, + }), + }; public async run(): Promise { const {args, flags} = await this.parse(AtomicInit); diff --git a/packages/cli/core/src/commands/config/get.ts b/packages/cli/core/src/commands/config/get.ts index 005a838e41..885c9901b0 100644 --- a/packages/cli/core/src/commands/config/get.ts +++ b/packages/cli/core/src/commands/config/get.ts @@ -1,21 +1,21 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Config} from '@coveo/cli-commons/config/config'; +import {BaseConfiguration, Config} from '@coveo/cli-commons/config/config'; import {ConfigRenderer} from '@coveo/cli-commons/config/configRenderer'; import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; -import type {Example} from '@oclif/core/lib/interfaces'; +import {Args, Command} from '@oclif/core'; export default class Get extends CLICommand { public static description = 'Display the current Coveo CLI configuration.'; - public static args = [ - { - name: 'key', + public static args = { + key: Args.string({ description: 'The config key for which to show the value', required: false, - }, - ]; + options: Config.userFacingConfigKeys, + }), + }; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: 'coveo config:get', description: 'Get all the configuration values', @@ -34,7 +34,10 @@ export default class Get extends CLICommand { public async run() { const {args} = await this.parse(Get); const cfg = new Config(this.config.configDir); - const keysToRender = args.key ? [args.key] : undefined; + const keysToRender = args.key + ? // TODO: find a better solution + [args.key as keyof BaseConfiguration] + : undefined; ConfigRenderer.render(cfg, keysToRender); } } diff --git a/packages/cli/core/src/commands/config/set.ts b/packages/cli/core/src/commands/config/set.ts index 1565a3d326..ecedac2c43 100644 --- a/packages/cli/core/src/commands/config/set.ts +++ b/packages/cli/core/src/commands/config/set.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {CliUx, Flags} from '@oclif/core'; +import {ux, Flags, Command} from '@oclif/core'; import {Config} from '@coveo/cli-commons/config/config'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import { @@ -9,7 +9,6 @@ import { import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; import {InvalidCommandError} from '../../lib/errors/InvalidCommandError'; import {ConfigRenderer} from '@coveo/cli-commons/config/configRenderer'; -import type {Example} from '@oclif/core/lib/interfaces'; export default class Set extends CLICommand { public static description = 'Modify the current Coveo CLI configuration.'; @@ -33,7 +32,7 @@ export default class Set extends CLICommand { }), }; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: 'coveo config:set --organization myOrgId', description: 'connect to a different organization', @@ -46,7 +45,7 @@ export default class Set extends CLICommand { const {flags} = await this.parse(Set); // TODO CDX-1246 if (flags.environment || flags.region) { - CliUx.ux.error( + ux.error( 'To connect to a different region or environment, use the `auth:login` command' ); } diff --git a/packages/cli/core/src/commands/org/create.ts b/packages/cli/core/src/commands/org/create.ts index a4787ebd91..a25f681f15 100644 --- a/packages/cli/core/src/commands/org/create.ts +++ b/packages/cli/core/src/commands/org/create.ts @@ -4,7 +4,7 @@ import { startSpinner, stopSpinner, } from '@coveo/cli-commons/utils/ux'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import { Preconditions, @@ -27,14 +27,13 @@ export default class Create extends CLICommand { }), }; - public static args = [ - { - name: 'name', + public static args = { + name: Args.string({ helpValue: 'neworg-prod', description: 'The name to assign to the new organization.', required: true, - }, - ]; + }), + }; @Trackable() @Preconditions(IsAuthenticated()) diff --git a/packages/cli/core/src/commands/org/list.ts b/packages/cli/core/src/commands/org/list.ts index aa6862023a..4e3950d4dd 100644 --- a/packages/cli/core/src/commands/org/list.ts +++ b/packages/cli/core/src/commands/org/list.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import { Preconditions, @@ -12,7 +12,7 @@ export default class List extends CLICommand { public static description = 'List Coveo organizations.'; public static flags = { - ...CliUx.ux.table.flags(), + ...ux.table.flags(), }; @Trackable() @@ -25,7 +25,7 @@ export default class List extends CLICommand { 'You do not have access to any organization. Make sure you are logged in the correct environment and region, with coveo auth:login' ); } else { - CliUx.ux.table( + ux.table( recordable(orgs), { id: {}, diff --git a/packages/cli/core/src/commands/org/resources/list.ts b/packages/cli/core/src/commands/org/resources/list.ts index e888d529b5..69449ec57b 100644 --- a/packages/cli/core/src/commands/org/resources/list.ts +++ b/packages/cli/core/src/commands/org/resources/list.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import {Config} from '@coveo/cli-commons/config/config'; import { @@ -16,7 +16,7 @@ export default class List extends CLICommand { public static description = 'List available Snapshots in an organization'; public static flags = { - ...CliUx.ux.table.flags(), + ...ux.table.flags(), ...organization( 'The unique identifier of the organization containing the snapshots.' ), @@ -42,7 +42,7 @@ export default class List extends CLICommand { return; } - CliUx.ux.table( + ux.table( recordable(snapshots), { id: {}, diff --git a/packages/cli/core/src/commands/org/resources/monitor.ts b/packages/cli/core/src/commands/org/resources/monitor.ts index 96d41b9a55..e60e74892a 100644 --- a/packages/cli/core/src/commands/org/resources/monitor.ts +++ b/packages/cli/core/src/commands/org/resources/monitor.ts @@ -1,6 +1,6 @@ import {ResourceSnapshotsReportModel} from '@coveo/platform-client'; import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {CliUx} from '@oclif/core'; +import {Args, Command, ux} from '@oclif/core'; import {Config} from '@coveo/cli-commons/config/config'; import { IsAuthenticated, @@ -14,7 +14,6 @@ import {Snapshot, WaitUntilDoneOptions} from '../../../lib/snapshot/snapshot'; import {SnapshotFactory} from '../../../lib/snapshot/snapshotFactory'; import {SnapshotReporter} from '../../../lib/snapshot/snapshotReporter'; import {startSpinner} from '@coveo/cli-commons/utils/ux'; -import {Example} from '@oclif/core/lib/interfaces'; import {organization} from '../../../lib/flags/platformCommonFlags'; import {getTargetOrg} from '../../../lib/utils/platform'; @@ -28,15 +27,14 @@ export default class Monitor extends CLICommand { ), }; - public static args = [ - { - name: 'snapshotId', + public static args = { + snapshotId: Args.string({ description: 'The unique identifier of the target snapshot.', required: true, - }, - ]; + }), + }; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: 'coveo org:resources:monitor --organization myorgid --snapshotId mysnapshotid', @@ -68,7 +66,7 @@ export default class Monitor extends CLICommand { private getErrorHandler() { return function (this: SnapshotReporter) { - CliUx.ux.log(ReportViewerStyles.error(this.resultCode)); + ux.log(ReportViewerStyles.error(this.resultCode)); }; } @@ -78,13 +76,13 @@ export default class Monitor extends CLICommand { const header = ReportViewerStyles.header( `Monitoring snapshot ${snapshotId}` ); - CliUx.ux.log(''); + ux.log(''); startSpinner(header); } private refresh(report: ResourceSnapshotsReportModel) { const reporter = new SnapshotReporter(report); - CliUx.ux.action.status = reporter.status; + ux.action.status = reporter.status; } private async getSnapshot(): Promise { diff --git a/packages/cli/core/src/commands/org/resources/preview.spec.ts b/packages/cli/core/src/commands/org/resources/preview.spec.ts index fd773c9960..4a6b677d97 100644 --- a/packages/cli/core/src/commands/org/resources/preview.spec.ts +++ b/packages/cli/core/src/commands/org/resources/preview.spec.ts @@ -25,7 +25,7 @@ import { getMissingVaultEntryReport, getSuccessReport, } from '../../../__stub__/resourceSnapshotsReportModel'; -import {CliUx, Command} from '@oclif/core'; +import {ux, Command} from '@oclif/core'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import {IsGitInstalled} from '../../../lib/decorators/preconditions'; @@ -420,7 +420,7 @@ describe('org:resources:preview', () => { test .stdout() .stderr() - .stub(CliUx.ux, 'confirm', () => () => Promise.resolve(false)) + .stub(ux, 'confirm', () => () => Promise.resolve(false)) .command(['org:resources:preview']) .catch(/Your destination organization is missing vault entries/) .it('should throw an error for invalid snapshots'); diff --git a/packages/cli/core/src/commands/org/resources/pull.spec.ts b/packages/cli/core/src/commands/org/resources/pull.spec.ts index 64d178bafd..7f026e6c38 100644 --- a/packages/cli/core/src/commands/org/resources/pull.spec.ts +++ b/packages/cli/core/src/commands/org/resources/pull.spec.ts @@ -19,7 +19,7 @@ import {getSuccessReport} from '../../../__stub__/resourceSnapshotsReportModel'; import {SnapshotFactory} from '../../../lib/snapshot/snapshotFactory'; import {Snapshot} from '../../../lib/snapshot/snapshot'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {PreconditionError} from '@coveo/cli-commons/errors/preconditionError'; import {cwd} from 'process'; import {Project} from '../../../lib/project/project'; @@ -270,7 +270,7 @@ describe('org:resources:pull', () => { test .stdout() .stderr() - .stub(CliUx.ux, 'confirm', () => () => Promise.resolve(true)) + .stub(ux, 'confirm', () => () => Promise.resolve(true)) .command([ 'org:resources:pull', '-m', @@ -296,7 +296,7 @@ describe('org:resources:pull', () => { test .stdout() .stderr() - .stub(CliUx.ux, 'confirm', () => () => Promise.resolve(true)) + .stub(ux, 'confirm', () => () => Promise.resolve(true)) .command([ 'org:resources:pull', '-m', @@ -323,7 +323,7 @@ describe('org:resources:pull', () => { test .stdout() .stderr() - .stub(CliUx.ux, 'confirm', () => () => Promise.resolve(true)) + .stub(ux, 'confirm', () => () => Promise.resolve(true)) .command([ 'org:resources:pull', '-m', diff --git a/packages/cli/core/src/commands/org/resources/pull.ts b/packages/cli/core/src/commands/org/resources/pull.ts index 93783bdad5..96e4ae52a4 100644 --- a/packages/cli/core/src/commands/org/resources/pull.ts +++ b/packages/cli/core/src/commands/org/resources/pull.ts @@ -5,7 +5,7 @@ import { stopSpinner, } from '@coveo/cli-commons/utils/ux'; -import {Flags} from '@oclif/core'; +import {Command, Flags} from '@oclif/core'; import {blueBright} from 'chalk'; import {readJsonSync} from 'fs-extra'; import {resolve} from 'path'; @@ -37,7 +37,6 @@ import {SnapshotFactory} from '../../../lib/snapshot/snapshotFactory'; import {confirmWithAnalytics} from '../../../lib/utils/cli'; import {spawnProcess} from '../../../lib/utils/process'; import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Example} from '@oclif/core/lib/interfaces'; import {organization} from '../../../lib/flags/platformCommonFlags'; import {getTargetOrg} from '../../../lib/utils/platform'; @@ -55,6 +54,8 @@ const PullCommandStrings = { `, }; +const getAllResourceTypes = () => Object.values(ResourceSnapshotType); + export default class Pull extends CLICommand { public static description = 'Pull resources from an organization'; @@ -76,14 +77,14 @@ export default class Pull extends CLICommand { description: 'Overwrite resources directory if it exists.', default: false, }), - resourceTypes: Flags.enum({ + resourceTypes: Flags.custom({ char: 'r', helpValue: 'type1 type2', description: 'The resources types to pull from the organization.', multiple: true, - options: allowedResourceType, - default: allowedResourceType, - }), + options: getAllResourceTypes(), + default: () => Promise.resolve(getAllResourceTypes()), + })(), model: Flags.custom({ parse: (input: string): Promise => { const model = readJsonSync(resolve(input)); @@ -99,7 +100,7 @@ export default class Pull extends CLICommand { }), }; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: 'coveo org:resources:pull', description: diff --git a/packages/cli/core/src/commands/org/resources/push.ts b/packages/cli/core/src/commands/org/resources/push.ts index f2938ddede..cc143b8daf 100644 --- a/packages/cli/core/src/commands/org/resources/push.ts +++ b/packages/cli/core/src/commands/org/resources/push.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Command, Flags} from '@oclif/core'; import {formatOrgId, startSpinner} from '@coveo/cli-commons/utils/ux'; import { HasNecessaryCoveoPrivileges, @@ -31,7 +31,6 @@ import { import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; import {confirmWithAnalytics} from '../../../lib/utils/cli'; import {SnapshotReportStatus} from '../../../lib/snapshot/reportPreviewer/reportPreviewerDataModels'; -import {Example} from '@oclif/core/lib/interfaces'; import {getTargetOrg} from '../../../lib/utils/platform'; import {organization} from '../../../lib/flags/platformCommonFlags'; @@ -52,7 +51,7 @@ export default class Push extends CLICommand { }), }; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: 'coveo org:resources:push', description: diff --git a/packages/cli/core/src/commands/org/search/dump.ts b/packages/cli/core/src/commands/org/search/dump.ts index cd3a6882ab..858c0cc699 100644 --- a/packages/cli/core/src/commands/org/search/dump.ts +++ b/packages/cli/core/src/commands/org/search/dump.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags, CliUx} from '@oclif/core'; +import {Command, Flags, ux} from '@oclif/core'; import {readJSONSync, writeFileSync, writeJSONSync} from 'fs-extra'; import {Parser} from 'json2csv'; import {SingleBar} from 'cli-progress'; @@ -17,7 +17,7 @@ import {without} from '../../../lib/utils/list'; import {join} from 'path'; import dedent from 'ts-dedent'; import {formatOrgId} from '@coveo/cli-commons/utils/ux'; -import {Example} from '@oclif/core/lib/interfaces'; + type ResponseExceededMaximumSizeError = {message: string; type: string}; interface RawResult { @@ -52,7 +52,7 @@ export default class Dump extends CLICommand { Note: DictionnaryFields/Values are experimentally supported. In case of failure, you should exclude them using the \`-x\` flag. `; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: 'coveo org:search:dump --source "My Web Source" "My Sitemap Source"', @@ -299,7 +299,7 @@ export default class Dump extends CLICommand { } private getProgressBar() { - return CliUx.ux.progress({ + return ux.progress({ format: 'Progress | {bar} | ETA: {eta}s | {value}/{total} results', }) as SingleBar; } diff --git a/packages/cli/core/src/commands/ui/create/angular.ts b/packages/cli/core/src/commands/ui/create/angular.ts index 0657804c33..5c7ed244d4 100644 --- a/packages/cli/core/src/commands/ui/create/angular.ts +++ b/packages/cli/core/src/commands/ui/create/angular.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {platformUrl} from '@coveo/cli-commons/platform/environment'; import {Config} from '@coveo/cli-commons/config/config'; import {spawnProcess} from '../../../lib/utils/process'; @@ -49,13 +49,12 @@ export default class Angular extends CLICommand { }), }; - public static args = [ - { - name: 'name', + public static args = { + name: Args.string({ description: 'The name of the application to create.', required: true, - }, - ]; + }), + }; @Trackable({ eventName: 'ui create', diff --git a/packages/cli/core/src/commands/ui/create/atomic.ts b/packages/cli/core/src/commands/ui/create/atomic.ts index 8ff78af2d9..87e604d586 100644 --- a/packages/cli/core/src/commands/ui/create/atomic.ts +++ b/packages/cli/core/src/commands/ui/create/atomic.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {Preconditions} from '@coveo/cli-commons/preconditions/index'; import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; import {Config} from '@coveo/cli-commons/config/config'; @@ -14,13 +14,12 @@ export default class Atomic extends CLICommand { public static description = "Create a Coveo Headless-powered search page with Coveo's own Atomic framework. See and ."; public static examples = ['$ coveo ui:create:atomic myapp']; - public static args = [ - { - name: 'name', + public static args = { + name: Args.string({ description: 'The name of the application to create.', required: true, - }, - ]; + }), + }; public static flags = { version: Flags.string({ char: 'v', diff --git a/packages/cli/core/src/commands/ui/create/react.ts b/packages/cli/core/src/commands/ui/create/react.ts index d2032a45d1..9be28b1bc8 100644 --- a/packages/cli/core/src/commands/ui/create/react.ts +++ b/packages/cli/core/src/commands/ui/create/react.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {Config} from '@coveo/cli-commons/config/config'; import {platformUrl} from '@coveo/cli-commons/platform/environment'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; @@ -56,13 +56,12 @@ export default class React extends CLICommand { }), }; - public static args = [ - { - name: 'name', + public static args = { + name: Args.string({ description: 'The name of the application to create.', required: true, - }, - ]; + }), + }; @Trackable({ eventName: 'ui create', diff --git a/packages/cli/core/src/commands/ui/create/vue.ts b/packages/cli/core/src/commands/ui/create/vue.ts index 2185ae1273..48ab28c61c 100644 --- a/packages/cli/core/src/commands/ui/create/vue.ts +++ b/packages/cli/core/src/commands/ui/create/vue.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {join} from 'node:path'; import {Config} from '@coveo/cli-commons/config/config'; import { @@ -51,13 +51,12 @@ export default class Vue extends CLICommand { '$ coveo ui:create:vue-v=1.2.3 myVueProject', ]; - public static args = [ - { - name: 'name', + public static args = { + name: Args.string({ description: 'The name of the application to create.', required: true, - }, - ]; + }), + }; @Trackable({ eventName: 'ui create', diff --git a/packages/cli/core/src/commands/ui/deploy.ts b/packages/cli/core/src/commands/ui/deploy.ts index 965e857ba7..07fec760fb 100644 --- a/packages/cli/core/src/commands/ui/deploy.ts +++ b/packages/cli/core/src/commands/ui/deploy.ts @@ -11,11 +11,10 @@ import { import type {HostedPage, New} from '@coveo/platform-client'; import type PlatformClient from '@coveo/platform-client'; import {createSearchPagesPrivilege} from '@coveo/cli-commons/preconditions/platformPrivilege'; -import {Flags} from '@oclif/core'; +import {Command, Flags} from '@oclif/core'; import {readJsonSync, ensureDirSync, readFileSync} from 'fs-extra'; import {DeployConfigError} from '../../lib/errors/deployErrors'; import {join} from 'path'; -import {Example} from '@oclif/core/lib/interfaces'; import {confirm, startSpinner, stopSpinner} from '@coveo/cli-commons/utils/ux'; import {getTargetOrg} from '../../lib/utils/platform'; import {Config} from '@coveo/cli-commons/config/config'; @@ -129,7 +128,7 @@ export default class Deploy extends CLICommand { ), }; - public static examples: Example[] = [ + public static examples: Command.Example[] = [ { command: '<%= config.bin %> <%= command.id %>', description: diff --git a/packages/cli/core/src/lib/decorators/preconditions/ng.spec.ts b/packages/cli/core/src/lib/decorators/preconditions/ng.spec.ts index d04fc198d9..fd8237988b 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/ng.spec.ts +++ b/packages/cli/core/src/lib/decorators/preconditions/ng.spec.ts @@ -6,7 +6,7 @@ import {spawnProcessOutput} from '../../utils/process'; import {getFakeCommand} from '@coveo/cli-commons/utils/getFakeCommand'; import {IsNgVersionInRange} from './ng'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {appendCmdIfWindows} from '@coveo/cli-commons/utils/os'; import {getPackageVersion} from '../../utils/misc'; import {fancyIt} from '@coveo/cli-commons-dev/testUtils/it'; @@ -22,7 +22,7 @@ describe('IsNgInstalled', () => { }; const mockConfirm = () => { - Object.defineProperty(CliUx.ux, 'confirm', {value: jest.fn()}); + Object.defineProperty(ux, 'confirm', {value: jest.fn()}); }; let fakeCommand: CLICommand; diff --git a/packages/cli/core/src/lib/flags/snapshotCommonFlags.ts b/packages/cli/core/src/lib/flags/snapshotCommonFlags.ts index 5a0a56ce23..2bd22a6ca3 100644 --- a/packages/cli/core/src/lib/flags/snapshotCommonFlags.ts +++ b/packages/cli/core/src/lib/flags/snapshotCommonFlags.ts @@ -19,13 +19,13 @@ export const wait = () => ({ }); export const previewLevel = () => ({ - previewLevel: Flags.enum({ + previewLevel: Flags.custom({ char: 'p', description: 'The verbosity of the preview. The `light` preview is faster to generate but only contains a limited amount of information, as opposed to the `detailed` preview that takes more time to generate, but returns a diff representation of all the changes to apply.', options: Object.values(PreviewLevelValue), default: PreviewLevelValue.Detailed, - }), + })(), }); export const snapshotId = () => ({ diff --git a/packages/cli/core/src/lib/project/project.ts b/packages/cli/core/src/lib/project/project.ts index ebea1fd4fc..8776dac7c4 100644 --- a/packages/cli/core/src/lib/project/project.ts +++ b/packages/cli/core/src/lib/project/project.ts @@ -6,7 +6,7 @@ import { rmSync, } from 'fs'; import {join} from 'path'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import archiver from 'archiver'; import {InvalidProjectError} from '../errors'; import extract from 'extract-zip'; @@ -97,7 +97,7 @@ export class Project { if (cachedManifest) { writeJsonSync(this.resourceManifestPath, cachedManifest); } - CliUx.ux.error(error as string | Error); + ux.error(error as string | Error); } } diff --git a/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.spec.ts b/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.spec.ts index 5b4c9d4a01..2394d3d9e9 100644 --- a/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.spec.ts +++ b/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.spec.ts @@ -3,9 +3,7 @@ jest.mock('@coveo/cli-commons/utils/ux'); const mockedUxInfo = jest.fn(); jest.mock('@oclif/core', () => ({ - CliUx: { - ux: {info: mockedUxInfo}, - }, + ux: {info: mockedUxInfo}, })); jest.mock('./filesDiffProcessor'); diff --git a/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts b/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts index ca18bcbacf..b1a840bd7a 100644 --- a/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts +++ b/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts @@ -4,7 +4,7 @@ import type { } from '@coveo/platform-client'; import {existsSync, mkdirSync, readdirSync, rmSync} from 'node:fs'; import {join, relative, resolve} from 'node:path'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {Project} from '../../project/project'; import {spawnProcess, spawnProcessOutput} from '../../utils/process'; import {SnapshotFactory} from '../snapshotFactory'; @@ -56,7 +56,7 @@ export class ExpandedPreviewer { await this.applySnapshotToPreview(dirPath); const commitHash = await this.getCommitHash(dirPath); stopSpinner({success: true}); - CliUx.ux.info(dedent` + ux.info(dedent` A Git repository representing the modification has been created here: ${dirPath} diff --git a/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts b/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts index 78eea996d8..b3b5fb9f01 100644 --- a/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts +++ b/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts @@ -1,4 +1,4 @@ -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {red, italic, green, yellow, ChalkFunction} from 'chalk'; import {ReportViewerSection} from './reportPreviewerSection'; import {ReportViewerStyles} from './reportPreviewerStyles'; @@ -71,7 +71,7 @@ export class ReportViewer { const entries = Array.from(this.missingVaultEntries).map( ({vaultEntryId}) => vaultEntryId ); - CliUx.ux.log( + ux.log( yellow( `Missing vault ${pluralizeIfNeeded( ReportViewer.entryPlurable, @@ -87,7 +87,7 @@ export class ReportViewer { this: SnapshotReporter ) => void | Promise { return function (this: SnapshotReporter) { - CliUx.ux.log(dedent`${green('No resources to change')}. + ux.log(dedent`${green('No resources to change')}. The target organization already matches the configuration.`); return; @@ -109,11 +109,11 @@ export class ReportViewer { ); if (changedResources.length === 0) { - CliUx.ux.log(ReportViewerStyles.header('\nNo changes detected')); + ux.log(ReportViewerStyles.header('\nNo changes detected')); return; } - CliUx.ux.table(recordable(changedResources), { + ux.table(recordable(changedResources), { resourceName: { header: ReportViewerStyles.header('\nPreviewing snapshot changes:'), get: (resource) => this.createSection(resource), @@ -144,8 +144,8 @@ export class ReportViewer { allErrors: Map, Set>, totalCount: number ) { - CliUx.ux.log(ReportViewerStyles.header('Error Report:')); - CliUx.ux.log( + ux.log(ReportViewerStyles.header('Error Report:')); + ux.log( ReportViewerStyles.error( ` ${totalCount} ${pluralizeIfNeeded( ReportViewer.resourcePlurable, @@ -164,7 +164,7 @@ export class ReportViewer { resourceSnapshotType: string, errorOfThisResourceType: Set ) { - CliUx.ux.log(`\n ${this.prettyPrintResourceName(resourceSnapshotType)}`); + ux.log(`\n ${this.prettyPrintResourceName(resourceSnapshotType)}`); ReportViewer.printAbridgedMessages( Array.from(errorOfThisResourceType), ReportViewer.errorPlurable, @@ -179,14 +179,14 @@ export class ReportViewer { ) { let remainingErrorsToPrint = ReportViewer.maximumNumberOfErrorsToPrint; for (let j = 0; j < messages.length && remainingErrorsToPrint > 0; j++) { - CliUx.ux.log(chalker(` • ${messages[j]}`)); + ux.log(chalker(` • ${messages[j]}`)); remainingErrorsToPrint--; } const unprintedMessages = messages.length - ReportViewer.maximumNumberOfErrorsToPrint; if (unprintedMessages > 0) { - CliUx.ux.log( + ux.log( italic( ` (${unprintedMessages} more ${pluralizeIfNeeded( plurable, @@ -198,6 +198,6 @@ export class ReportViewer { } private printNewLine() { - CliUx.ux.log(''); + ux.log(''); } } diff --git a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.spec.ts b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.spec.ts index 211411e5a9..60dc29ed6b 100644 --- a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.spec.ts +++ b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.spec.ts @@ -1,7 +1,7 @@ const mockedCliConfirm = jest.fn(); const mockedCliWarn = jest.fn(); jest.mock('@oclif/core', () => ({ - CliUx: {ux: {warn: mockedCliWarn, confirm: mockedCliConfirm}}, + ux: {warn: mockedCliWarn, confirm: mockedCliConfirm}, })); jest.mock('@coveo/cli-commons/platform/authenticatedClient'); jest.mock('../../project/project'); @@ -18,7 +18,7 @@ import { confirm, } from '@coveo/cli-commons/utils/ux'; import PlatformClient, {VaultFetchStrategy} from '@coveo/platform-client'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {Configuration} from '@coveo/cli-commons/config/config'; import {SnapshotMissingVaultEntriesFromOriginError} from '../../errors/vaultErrors'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; @@ -36,7 +36,7 @@ describe('#tryTransferFromOrganization', () => { SnapshotMissingVaultEntriesFromOriginError ); const mockedCliConfirm = jest.mocked(confirm); - const mockedCliWarn = jest.mocked(CliUx.ux.warn); + const mockedCliWarn = jest.mocked(ux.warn); const mockedVaultList = jest.fn(); const mockedVaultImport = jest.fn(); const mockedGetClient = jest.fn(); diff --git a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts index e071100d97..fd0fe83705 100644 --- a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts +++ b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts @@ -1,5 +1,5 @@ import {VaultFetchStrategy, VaultEntryModel} from '@coveo/platform-client'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import { formatOrgId, startSpinner, @@ -40,7 +40,7 @@ export async function tryTransferFromOrganization({ const authenticatedClient = new AuthenticatedClient(); if (!(await authenticatedClient.getUserHasAccessToOrg(originOrgId))) { - CliUx.ux.warn(dedent` + ux.warn(dedent` We mapped this snapshot to ${formatOrgId(originOrgId)}. If you want to transfer the vault entries from ${formatOrgId( originOrgId @@ -57,7 +57,7 @@ export async function tryTransferFromOrganization({ ); if (missingEntriesFromOrigin.length > 0) { - CliUx.ux.warn( + ux.warn( new SnapshotMissingVaultEntriesFromOriginError( originOrgId, snapshot.targetId, @@ -82,8 +82,8 @@ export async function tryTransferFromOrganization({ return true; } catch (error) { stopSpinner({success: false}); - CliUx.ux.warn('Error encountered while transferring vault entries`'); - CliUx.ux.warn(typeof error === 'string' ? error : JSON.stringify(error)); + ux.warn('Error encountered while transferring vault entries`'); + ux.warn(typeof error === 'string' ? error : JSON.stringify(error)); return false; } } diff --git a/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts b/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts index 57e8462d2c..5360f8e8b6 100644 --- a/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts +++ b/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts @@ -8,7 +8,7 @@ import {VaultHandler} from './vaultHandler'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import {readJsonSync, rmSync, writeJsonSync} from 'fs-extra'; import open from 'open'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {ProcessAbort} from '../errors/processError'; import {stdout, stderr} from 'stdout-stderr'; @@ -19,10 +19,10 @@ const mockedWriteJsonSync = jest.mocked(writeJsonSync); const mockedReadJsonSync = jest.mocked(readJsonSync); const mockedRmSync = jest.mocked(rmSync); const mockedOpen = jest.mocked(open); -const mockedCliUx = jest.spyOn(CliUx.ux, 'warn'); +const mockedCliUx = jest.spyOn(ux, 'warn'); const doMockPrompt = () => { - Object.defineProperty(CliUx.ux, 'prompt', {value: mockedPrompt}); + Object.defineProperty(ux, 'prompt', {value: mockedPrompt}); }; const doMockAuthenticatedClient = () => { mockedAuthenticatedClient.mockImplementation( diff --git a/packages/cli/core/src/lib/snapshot/vaultHandler.ts b/packages/cli/core/src/lib/snapshot/vaultHandler.ts index 461438d64a..3264ad088a 100644 --- a/packages/cli/core/src/lib/snapshot/vaultHandler.ts +++ b/packages/cli/core/src/lib/snapshot/vaultHandler.ts @@ -3,7 +3,7 @@ import { VaultValueType, VaultVisibilityType, } from '@coveo/platform-client'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {readJsonSync, rmSync, writeJsonSync} from 'fs-extra'; import open from 'open'; import {join} from 'path'; @@ -42,7 +42,7 @@ export class VaultHandler { private async ensureValidityOrAbort(entries: VaultEntryAttributes[]) { let valid = false; while (!valid) { - const key = await CliUx.ux.prompt('', { + const key = await ux.prompt('', { type: 'single', required: false, prompt: `\n${inverse('Press any key to continue. Press q to abort')}\n`, @@ -54,8 +54,8 @@ export class VaultHandler { this.ensureEntriesValidity(entries); valid = true; } catch (error) { - CliUx.ux.log(''); - CliUx.ux.warn(`${error}`); + ux.log(''); + ux.warn(`${error}`); await this.openFile(false); } } @@ -88,7 +88,7 @@ export class VaultHandler { private async openFile(print = true) { if (print) { - CliUx.ux.log(dedent`\nOpening file ${this.vaultEntryFilePath}. + ux.log(dedent`\nOpening file ${this.vaultEntryFilePath}. Please fill out all the vault entries from the JSON file.`); } await open(this.vaultEntryFilePath); diff --git a/packages/cli/source/src/commands/source/catalog/add.ts b/packages/cli/source/src/commands/source/catalog/add.ts index 90c10e4682..32f207dc11 100644 --- a/packages/cli/source/src/commands/source/catalog/add.ts +++ b/packages/cli/source/src/commands/source/catalog/add.ts @@ -1,6 +1,6 @@ import {CatalogSource, BuiltInTransformers} from '@coveo/push-api-client'; import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {startSpinner} from '@coveo/cli-commons/utils/ux'; import {bold} from 'chalk'; import { @@ -58,14 +58,13 @@ export default class SourceCatalogAdd extends CLICommand { }), }; - public static args = [ - { - name: 'sourceId', + public static args = { + sourceId: Args.string({ required: true, description: 'The identifier of the Catalog source on which to perform the add operation. See `source:list` to obtain the identifier.', - }, - ]; + }), + }; private display = new AddDisplay(); diff --git a/packages/cli/source/src/commands/source/catalog/new.ts b/packages/cli/source/src/commands/source/catalog/new.ts index 1647520712..dd5c4cf913 100644 --- a/packages/cli/source/src/commands/source/catalog/new.ts +++ b/packages/cli/source/src/commands/source/catalog/new.ts @@ -11,6 +11,7 @@ import {writeSourceContentPrivilege} from '@coveo/cli-commons/preconditions/plat import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import {withSourceVisibility} from '../../../lib/commonFlags'; import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; +import {Args} from '@oclif/core'; export default class SourceCatalogNew extends CLICommand { public static description = @@ -20,13 +21,12 @@ export default class SourceCatalogNew extends CLICommand { ...withSourceVisibility(), }; - public static args = [ - { - name: 'name', - description: 'The name of the source to create.', + public static args = { + name: Args.string({ + description: 'The name of the application to create.', required: true, - }, - ]; + }), + }; @Trackable() @Preconditions( diff --git a/packages/cli/source/src/commands/source/list.ts b/packages/cli/source/src/commands/source/list.ts index 04eb27a54c..2cac6b0e47 100644 --- a/packages/cli/source/src/commands/source/list.ts +++ b/packages/cli/source/src/commands/source/list.ts @@ -1,6 +1,6 @@ import {FilterHostType, SourceModel} from '@coveo/platform-client'; import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import { IsAuthenticated, Preconditions, @@ -15,7 +15,7 @@ export default class SourceList extends CLICommand { 'List all available push sources in your Coveo organization'; public static flags = { - ...CliUx.ux.table.flags(), + ...ux.table.flags(), }; @Trackable() @@ -43,7 +43,7 @@ export default class SourceList extends CLICommand { return; } - CliUx.ux.table( + ux.table( this.flattenSourceModels(sources.sourceModels), { id: {}, diff --git a/packages/cli/source/src/commands/source/push/add.ts b/packages/cli/source/src/commands/source/push/add.ts index 60813ef888..99e4602f0f 100644 --- a/packages/cli/source/src/commands/source/push/add.ts +++ b/packages/cli/source/src/commands/source/push/add.ts @@ -26,6 +26,7 @@ import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClie import {formatErrorMessage} from '../../../lib/addCommon'; import {getFileNames} from '../../../lib/getFileNames'; import {AddDisplay} from '../../../lib/addDisplay'; +import {Args} from '@oclif/core'; export default class SourcePushAdd extends CLICommand { public static description = @@ -38,14 +39,13 @@ export default class SourcePushAdd extends CLICommand { ...withNormalizeInvalidFields(), }; - public static args = [ - { - name: 'sourceId', + public static args = { + sourceId: Args.string({ required: true, description: 'The identifier of the source on which to perform the add operation. See source:list to obtain the identifier.', - }, - ]; + }), + }; private display = new AddDisplay(); diff --git a/packages/cli/source/src/commands/source/push/delete.ts b/packages/cli/source/src/commands/source/push/delete.ts index 84a8f9d7a5..246eaf2791 100644 --- a/packages/cli/source/src/commands/source/push/delete.ts +++ b/packages/cli/source/src/commands/source/push/delete.ts @@ -1,5 +1,5 @@ import {CLICommand} from '@coveo/cli-commons/command/cliCommand'; -import {Flags} from '@oclif/core'; +import {Args, Flags} from '@oclif/core'; import {PushSource} from '@coveo/push-api-client'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; import { @@ -39,14 +39,13 @@ export default class SourcePushDelete extends CLICommand { }), }; - public static args = [ - { - name: 'sourceId', + public static args = { + sourceId: Args.string({ required: true, description: 'The identifier of the Push source on which to perform the delete operation. To retrieve the list of available Push source identifiers, use the `source:push:list` command.', - }, - ]; + }), + }; @Trackable() // TODO: Check privileges? diff --git a/packages/cli/source/src/commands/source/push/new.ts b/packages/cli/source/src/commands/source/push/new.ts index d2381d2388..cc36204065 100644 --- a/packages/cli/source/src/commands/source/push/new.ts +++ b/packages/cli/source/src/commands/source/push/new.ts @@ -11,6 +11,7 @@ import {writeSourceContentPrivilege} from '@coveo/cli-commons/preconditions/plat import {Trackable} from '@coveo/cli-commons/preconditions/trackable'; import {withSourceVisibility} from '../../../lib/commonFlags'; import {AuthenticatedClient} from '@coveo/cli-commons/platform/authenticatedClient'; +import {Args} from '@oclif/core'; export default class SourcePushNew extends CLICommand { public static description = @@ -20,13 +21,12 @@ export default class SourcePushNew extends CLICommand { ...withSourceVisibility(), }; - public static args = [ - { - name: 'name', - description: 'The name of the source to create.', + public static args = { + name: Args.string({ + description: 'The name of the application to create.', required: true, - }, - ]; + }), + }; @Trackable() @Preconditions( diff --git a/packages/cli/source/src/lib/addCommon.ts b/packages/cli/source/src/lib/addCommon.ts index 7980d0f29a..2bfcf60268 100644 --- a/packages/cli/source/src/lib/addCommon.ts +++ b/packages/cli/source/src/lib/addCommon.ts @@ -1,4 +1,4 @@ -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {red, dim, green} from 'chalk'; import {BuiltInTransformers, errors} from '@coveo/push-api-client'; import {withNormalizeInvalidFields} from './commonFlags'; @@ -74,12 +74,12 @@ const printInvalidFieldTable = (fields: {valid: boolean}[]) => { } const fixable = fields[0].valid; - CliUx.ux.log( + ux.log( ` ${count} ${pluralized} detected in your data can${ fixable ? '' : 'not' } be normalized` ); - CliUx.ux.table(fields, { + ux.table(fields, { original: {header: 'Original'}, normalized: {header: 'Normalized'}, }); @@ -88,7 +88,7 @@ const printInvalidFieldTable = (fields: {valid: boolean}[]) => { export const logNewLine = (lines = 1) => { for (let i = 0; i < lines; i++) { - CliUx.ux.log(''); + ux.log(''); } }; diff --git a/packages/cli/source/src/lib/addDisplay.ts b/packages/cli/source/src/lib/addDisplay.ts index eb4f2a9761..ff4fa159d0 100644 --- a/packages/cli/source/src/lib/addDisplay.ts +++ b/packages/cli/source/src/lib/addDisplay.ts @@ -2,7 +2,7 @@ import {green} from 'chalk'; import {UploadBatchCallbackData} from '@coveo/push-api-client'; import {errorMessage, successMessage} from './userFeedback'; import {Plurable, pluralizeIfNeeded} from '@coveo/cli-commons/utils/string'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import {UploadProgress} from '@coveo/push-api-client/dist/definitions/interfaces'; import {logNewLine} from './addCommon'; @@ -73,22 +73,18 @@ export class AddDisplay { return `${count}${total ? ['/', total].join('') : ''}`; }; - CliUx.ux.styledHeader('Push Summary'); + ux.styledHeader('Push Summary'); - CliUx.ux.log( + ux.log( `${formatCount(added)} ${pluralized(added)} successfully sent to the API` ); if (failed > 0) { - CliUx.ux.log( - `${formatCount(failed)} ${pluralized(failed)} failed to be sent` - ); + ux.log(`${formatCount(failed)} ${pluralized(failed)} failed to be sent`); } if (remaining && remaining > 0) { - CliUx.ux.log( - `${formatCount(remaining)} unprocessed ${pluralized(remaining)}` - ); + ux.log(`${formatCount(remaining)} unprocessed ${pluralized(remaining)}`); } logNewLine(); diff --git a/packages/cli/source/src/lib/commonFlags.ts b/packages/cli/source/src/lib/commonFlags.ts index 3f6f81a938..743bc1cf92 100644 --- a/packages/cli/source/src/lib/commonFlags.ts +++ b/packages/cli/source/src/lib/commonFlags.ts @@ -42,7 +42,7 @@ export const withNormalizeInvalidFields = () => ({ }); export const withSourceVisibility = () => ({ - sourceVisibility: Flags.enum({ + sourceVisibility: Flags.custom({ options: [ SourceVisibility.PRIVATE, SourceVisibility.SECURED, @@ -52,5 +52,5 @@ export const withSourceVisibility = () => ({ 'Controls the content security option that should be applied to the items in a source. See https://docs.coveo.com/en/1779/index-content/content-security', default: SourceVisibility.SECURED, char: 'v', - }), + })(), }); diff --git a/packages/cli/source/src/lib/getFileNames.ts b/packages/cli/source/src/lib/getFileNames.ts index 6385877bc5..f5c22b5c81 100644 --- a/packages/cli/source/src/lib/getFileNames.ts +++ b/packages/cli/source/src/lib/getFileNames.ts @@ -1,4 +1,4 @@ -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; export interface FilesOrFolders { file?: string[]; // TODO: CDX-856: remove flag @@ -15,7 +15,7 @@ export function getFileNames(entries: FilesOrFolders, commandName: string) { ]; if (entryNames.length === 0) { - CliUx.ux.error( + ux.error( `You must set the \`files\` flag. Use \`${commandName} --help\` to get more information.` ); } diff --git a/packages/cli/source/src/lib/userFeedback.ts b/packages/cli/source/src/lib/userFeedback.ts index 18f710299f..d3f27317fa 100644 --- a/packages/cli/source/src/lib/userFeedback.ts +++ b/packages/cli/source/src/lib/userFeedback.ts @@ -1,7 +1,7 @@ import {green} from 'chalk'; import dedent from 'ts-dedent'; import {wrapError} from '@coveo/cli-commons/errors/wrapError'; -import {CliUx} from '@oclif/core'; +import {ux} from '@oclif/core'; import type {Response} from 'undici'; import {errors} from '@coveo/push-api-client'; @@ -13,7 +13,7 @@ export const successMessage = (tagLine: string, res?: Response) => { message += `Status code: ${green(res.status, res.statusText)} `; } - CliUx.ux.log(message); + ux.log(message); }; export const errorMessage = ( @@ -28,6 +28,6 @@ export const errorMessage = ( if (options.exit) { throw error; } else { - CliUx.ux.warn(error.message); + ux.warn(error.message); } }; From cc331e9766ca461dc78a87c5ea8ae81547fbbcec Mon Sep 17 00:00:00 2001 From: ylakhdar Date: Mon, 25 Sep 2023 13:42:46 -0400 Subject: [PATCH 3/3] fix lint --- packages/cli/core/src/commands/org/resources/pull.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/cli/core/src/commands/org/resources/pull.ts b/packages/cli/core/src/commands/org/resources/pull.ts index 96e4ae52a4..152dd0ca1d 100644 --- a/packages/cli/core/src/commands/org/resources/pull.ts +++ b/packages/cli/core/src/commands/org/resources/pull.ts @@ -54,8 +54,6 @@ const PullCommandStrings = { `, }; -const getAllResourceTypes = () => Object.values(ResourceSnapshotType); - export default class Pull extends CLICommand { public static description = 'Pull resources from an organization'; @@ -82,8 +80,8 @@ export default class Pull extends CLICommand { helpValue: 'type1 type2', description: 'The resources types to pull from the organization.', multiple: true, - options: getAllResourceTypes(), - default: () => Promise.resolve(getAllResourceTypes()), + options: allowedResourceType, + default: () => Promise.resolve(allowedResourceType), })(), model: Flags.custom({ parse: (input: string): Promise => {