From 17970490e7844315373827f44ef8dd80f4c0181a Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 25 Aug 2022 16:38:25 -0400 Subject: [PATCH] feat(cli): extract source into a plugin (#899) --- package-lock.json | 850 +++--------------- package.json | 2 +- packages/angular/package.json | 2 +- packages/cli-e2e/package.json | 2 +- packages/cli/commons-dev/.gitignore | 5 +- packages/cli/commons-dev/package.json | 2 +- .../src/testUtils/jestSnapshotUtils.ts | 3 + .../cli/commons-dev/src/testUtils/utils.ts | 15 + packages/cli/commons/.gitignore | 5 +- packages/cli/commons/package.json | 6 +- .../commons/src/analytics/amplitudeClient.ts | 14 + .../src}/analytics/eventUtils.ts | 10 +- .../commons/src/analytics/identifier.spec.ts | 199 ++++ .../cli/commons/src/analytics/identifier.ts | 123 +++ .../src/errors/apiError.ts} | 5 +- .../src}/errors/unknownError.ts | 5 +- .../src}/preconditions/trackable.spec.ts | 2 +- .../src}/preconditions/trackable.ts | 4 +- .../src/lib => commons/src}/utils/string.ts | 0 packages/cli/core/bin/dev | 0 packages/cli/core/package.json | 21 +- .../cli/core/src/__stub__/configuration.ts | 4 +- .../core/src/__test__/preconditionUtils.ts | 4 +- .../cli/core/src/commands/auth/login.spec.ts | 10 +- packages/cli/core/src/commands/auth/login.ts | 8 +- .../cli/core/src/commands/auth/token.spec.ts | 12 +- packages/cli/core/src/commands/auth/token.ts | 8 +- .../cli/core/src/commands/config/get.spec.ts | 8 +- packages/cli/core/src/commands/config/get.ts | 6 +- .../cli/core/src/commands/config/set.spec.ts | 10 +- packages/cli/core/src/commands/config/set.ts | 10 +- .../cli/core/src/commands/org/create.spec.ts | 10 +- packages/cli/core/src/commands/org/create.ts | 8 +- .../cli/core/src/commands/org/list.spec.ts | 8 +- packages/cli/core/src/commands/org/list.ts | 6 +- .../src/commands/org/resources/list.spec.ts | 10 +- .../core/src/commands/org/resources/list.ts | 8 +- .../org/resources/model/create.spec.ts | 10 +- .../commands/org/resources/model/create.ts | 8 +- .../commands/org/resources/monitor.spec.ts | 8 +- .../src/commands/org/resources/monitor.ts | 6 +- .../commands/org/resources/preview.spec.ts | 33 +- .../src/commands/org/resources/preview.ts | 8 +- .../src/commands/org/resources/pull.spec.ts | 19 +- .../core/src/commands/org/resources/pull.ts | 8 +- .../src/commands/org/resources/push.spec.ts | 29 +- .../core/src/commands/org/resources/push.ts | 8 +- .../core/src/commands/org/search/dump.spec.ts | 10 +- .../cli/core/src/commands/org/search/dump.ts | 8 +- .../src/commands/ui/create/angular.spec.ts | 14 +- .../core/src/commands/ui/create/angular.ts | 12 +- .../src/commands/ui/create/atomic.spec.ts | 14 +- .../cli/core/src/commands/ui/create/atomic.ts | 12 +- .../core/src/commands/ui/create/react.spec.ts | 14 +- .../cli/core/src/commands/ui/create/react.ts | 12 +- .../core/src/commands/ui/create/vue.spec.ts | 14 +- .../cli/core/src/commands/ui/create/vue.ts | 12 +- .../src/hooks/analytics/analytics.spec.ts | 12 +- .../cli/core/src/hooks/analytics/analytics.ts | 6 +- .../src/hooks/analytics/identifier.spec.ts | 12 +- .../core/src/hooks/analytics/identifier.ts | 8 +- .../commandNotFound/commandNotFound.spec.ts | 2 +- .../hooks/commandNotFound/commandNotFound.ts | 2 +- .../core/src/hooks/init/set-global-config.ts | 2 +- .../hooks/init/termination-signals.spec.ts | 8 +- .../src/hooks/init/termination-signals.ts | 7 +- .../cli/core/src/hooks/postrun/postrun.ts | 2 +- .../preconditions/binPreconditionsFactory.ts | 2 +- .../lib/decorators/preconditions/git.spec.ts | 2 +- .../lib/decorators/preconditions/node.spec.ts | 2 +- .../lib/decorators/preconditions/npx.spec.ts | 2 +- .../src/lib/errors/InvalidCommandError.ts | 2 +- .../cli/core/src/lib/errors/platformError.ts | 4 +- .../cli/core/src/lib/errors/processError.ts | 2 +- .../cli/core/src/lib/errors/projectError.ts | 2 +- .../cli/core/src/lib/errors/snapshotErrors.ts | 4 +- .../cli/core/src/lib/errors/vaultErrors.ts | 6 +- .../core/src/lib/flags/platformCommonFlags.ts | 2 +- .../core/src/lib/oauth/authorizationError.ts | 2 +- packages/cli/core/src/lib/oauth/oauth.spec.ts | 2 +- packages/cli/core/src/lib/oauth/oauth.ts | 2 +- .../src/lib/oauth/oauthClientServer.spec.ts | 2 +- .../snapshot/pullModel/validation/errors.ts | 2 +- .../reportPreviewer/reportPreviewer.ts | 2 +- .../core/src/lib/snapshot/snapshot.spec.ts | 4 +- .../core/src/lib/snapshot/snapshotCommon.ts | 4 +- .../src/lib/snapshot/snapshotFactory.spec.ts | 4 +- .../core/src/lib/snapshot/snapshotFactory.ts | 2 +- .../lib/snapshot/snapshotUrlBuilder.spec.ts | 10 +- .../src/lib/snapshot/snapshotUrlBuilder.ts | 6 +- .../vaultEntriesFunctions/interfaces.ts | 2 +- .../transferFromOrganization.spec.ts | 6 +- .../transferFromOrganization.ts | 2 +- .../src/lib/snapshot/vaultHandler.spec.ts | 4 +- .../cli/core/src/lib/snapshot/vaultHandler.ts | 4 +- packages/cli/core/src/lib/utils/cli.spec.ts | 6 +- packages/cli/core/src/lib/utils/cli.ts | 5 +- packages/cli/core/tsconfig.json | 3 +- packages/cli/source/.eslintignore | 1 + packages/cli/source/.eslintrc.js | 5 + packages/cli/source/.gitignore | 15 + packages/cli/source/.prettierrc.js | 5 + packages/cli/source/LICENSE | 201 +++++ packages/cli/source/bin/dev | 17 + packages/cli/source/bin/dev.cmd | 3 + packages/cli/source/bin/run | 5 + packages/cli/source/bin/run.cmd | 3 + packages/cli/source/jest.config.js | 17 + packages/cli/source/package.json | 84 ++ packages/cli/source/project.json | 5 + .../src/commands/source/catalog/add.spec.ts | 58 +- .../src/commands/source/catalog/add.ts | 21 +- .../src/commands/source/catalog/new.spec.ts | 26 +- .../src/commands/source/catalog/new.ts | 14 +- .../src/commands/source}/list.spec.ts | 8 +- .../src/commands/source/list.ts | 8 +- .../src/commands/source/push/add.spec.ts | 27 +- .../src/commands/source/push/add.ts | 18 +- .../src/commands/source/push/delete.spec.ts | 10 +- .../src/commands/source/push/delete.ts | 8 +- .../src/commands/source/push}/list.spec.ts | 8 +- .../src/commands/source/push/list.ts | 6 +- .../src/commands/source/push/new.spec.ts | 29 +- .../src/commands/source/push/new.ts | 10 +- packages/cli/source/src/index.ts | 1 + .../lib}/__snapshots__/addCommon.spec.ts.snap | 0 .../push => source/src/lib}/addCommon.spec.ts | 2 +- .../lib/push => source/src/lib}/addCommon.ts | 6 +- .../src/lib/commonFlags.ts} | 0 .../src/lib/getFileNames.ts} | 0 .../src/lib/testsUtils/axiosMocks.ts} | 0 .../batchUploadDocumentsFromFilesReturn.ts | 2 +- .../push => source/src/lib}/userFeedback.ts | 4 +- packages/cli/source/tsconfig.json | 10 + packages/cra-template/template.json | 2 +- 135 files changed, 1324 insertions(+), 1144 deletions(-) create mode 100644 packages/cli/commons-dev/src/testUtils/jestSnapshotUtils.ts create mode 100644 packages/cli/commons-dev/src/testUtils/utils.ts create mode 100644 packages/cli/commons/src/analytics/amplitudeClient.ts rename packages/cli/{core/src/hooks => commons/src}/analytics/eventUtils.ts (79%) create mode 100644 packages/cli/commons/src/analytics/identifier.spec.ts create mode 100644 packages/cli/commons/src/analytics/identifier.ts rename packages/cli/{core/src/lib/errors/APIError.ts => commons/src/errors/apiError.ts} (94%) rename packages/cli/{core/src/lib => commons/src}/errors/unknownError.ts (79%) rename packages/cli/{core/src/lib/decorators => commons/src}/preconditions/trackable.spec.ts (97%) rename packages/cli/{core/src/lib/decorators => commons/src}/preconditions/trackable.ts (94%) rename packages/cli/{core/src/lib => commons/src}/utils/string.ts (100%) mode change 100644 => 100755 packages/cli/core/bin/dev create mode 100644 packages/cli/source/.eslintignore create mode 100644 packages/cli/source/.eslintrc.js create mode 100644 packages/cli/source/.gitignore create mode 100644 packages/cli/source/.prettierrc.js create mode 100644 packages/cli/source/LICENSE create mode 100644 packages/cli/source/bin/dev create mode 100644 packages/cli/source/bin/dev.cmd create mode 100755 packages/cli/source/bin/run create mode 100644 packages/cli/source/bin/run.cmd create mode 100644 packages/cli/source/jest.config.js create mode 100644 packages/cli/source/package.json create mode 100644 packages/cli/source/project.json rename packages/cli/{core => source}/src/commands/source/catalog/add.spec.ts (89%) rename packages/cli/{core => source}/src/commands/source/catalog/add.ts (89%) rename packages/cli/{core => source}/src/commands/source/catalog/new.spec.ts (79%) rename packages/cli/{core => source}/src/commands/source/catalog/new.ts (73%) rename packages/cli/{core/src/commands/source/push => source/src/commands/source}/list.spec.ts (90%) rename packages/cli/{core => source}/src/commands/source/list.ts (88%) rename packages/cli/{core => source}/src/commands/source/push/add.spec.ts (93%) rename packages/cli/{core => source}/src/commands/source/push/add.ts (88%) rename packages/cli/{core => source}/src/commands/source/push/delete.spec.ts (96%) rename packages/cli/{core => source}/src/commands/source/push/delete.ts (95%) rename packages/cli/{core/src/commands/source => source/src/commands/source/push}/list.spec.ts (90%) rename packages/cli/{core => source}/src/commands/source/push/list.ts (91%) rename packages/cli/{core => source}/src/commands/source/push/new.spec.ts (77%) rename packages/cli/{core => source}/src/commands/source/push/new.ts (79%) create mode 100644 packages/cli/source/src/index.ts rename packages/cli/{core/src/lib/push => source/src/lib}/__snapshots__/addCommon.spec.ts.snap (100%) rename packages/cli/{core/src/lib/push => source/src/lib}/addCommon.spec.ts (95%) rename packages/cli/{core/src/lib/push => source/src/lib}/addCommon.ts (94%) rename packages/cli/{core/src/lib/flags/sourceCommonFlags.ts => source/src/lib/commonFlags.ts} (100%) rename packages/cli/{core/src/lib/utils/file.ts => source/src/lib/getFileNames.ts} (100%) rename packages/cli/{core/src/lib/push/testUtils.ts => source/src/lib/testsUtils/axiosMocks.ts} (100%) rename packages/cli/{core/src/__stub__ => source/src/lib/testsUtils}/batchUploadDocumentsFromFilesReturn.ts (91%) rename packages/cli/{core/src/lib/push => source/src/lib}/userFeedback.ts (88%) create mode 100644 packages/cli/source/tsconfig.json diff --git a/package-lock.json b/package-lock.json index 65b92d3685..437b64dd2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "@coveord/platform-client": "34.7.0", "@nrwl/cli": "latest", "@nrwl/workspace": "latest", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@typescript-eslint/eslint-plugin": "5.33.1", "@typescript-eslint/parser": "5.33.1", "abortcontroller-polyfill": "1.7.3", @@ -663,6 +663,17 @@ "node": "^12.22 || ^14.13 || >=16" } }, + "node_modules/@angular/cli/node_modules/npm-bundled": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-2.0.0.tgz", + "integrity": "sha512-ZnkDgpakv39F6w9D6uZNmmXohXEHW5EC1MDziHvXeLeyBmJ/FpfM1n+v8PkQ2Y1TcNHzuAVTZQIgabkgskR77A==", + "dependencies": { + "npm-normalize-package-bin": "^1.0.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, "node_modules/@angular/cli/node_modules/npm-install-checks": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-5.0.0.tgz", @@ -689,13 +700,13 @@ } }, "node_modules/@angular/cli/node_modules/npm-packlist": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-5.1.2.tgz", - "integrity": "sha512-rQiBDNmt1H1jNhFEo9ilTD7ZJXd6cvHSmBK+waIBu886v6OyLWjZqb1RD9viR7rgG0AAe29FYnOXcO26TRxT/Q==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-5.1.3.tgz", + "integrity": "sha512-263/0NGrn32YFYi4J533qzrQ/krmmrWwhKkzwTuM4f/07ug51odoaNjUexxO4vxlzURHcmYMH1QjvHjsNDKLVg==", "dependencies": { "glob": "^8.0.1", "ignore-walk": "^5.0.1", - "npm-bundled": "^1.1.2", + "npm-bundled": "^2.0.0", "npm-normalize-package-bin": "^2.0.0" }, "bin": { @@ -3143,6 +3154,10 @@ "resolved": "packages/cli-e2e", "link": true }, + "node_modules/@coveo/cli-plugin-source": { + "resolved": "packages/cli/source", + "link": true + }, "node_modules/@coveo/cra-template": { "resolved": "packages/cra-template", "link": true @@ -3681,27 +3696,6 @@ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" } }, - "node_modules/@jest/expect-utils": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-28.1.3.tgz", - "integrity": "sha512-wvbi9LUrHJLn3NlDW6wF2hvIMtd4JUl2QNVrjq+IBSHirgfrR3o9RnVtxzdEGO2n9JyIWwHnLfby5KzqBGg2YA==", - "dev": true, - "dependencies": { - "jest-get-type": "^28.0.2" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/@jest/expect-utils/node_modules/jest-get-type": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", - "dev": true, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, "node_modules/@jest/fake-timers": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-27.5.1.tgz", @@ -3774,18 +3768,6 @@ } } }, - "node_modules/@jest/schemas": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-28.1.3.tgz", - "integrity": "sha512-/l/VWsdt/aBXgjshLWOFyFt3IVdYypu5y2Wn2rOO1un6nkqIn8SLXzgIMYXFyYsRWDyF5EthmKJMIdJvk08grg==", - "dev": true, - "dependencies": { - "@sinclair/typebox": "^0.24.1" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, "node_modules/@jest/source-map": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-27.5.1.tgz", @@ -6672,12 +6654,6 @@ "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==" }, - "node_modules/@sinclair/typebox": { - "version": "0.24.28", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.28.tgz", - "integrity": "sha512-dgJd3HLOkLmz4Bw50eZx/zJwtBq65nms3N9VBYu5LTjJ883oBFkTyXRlCB/ZGGwqYpJJHA5zW2Ibhl5ngITfow==", - "dev": true - }, "node_modules/@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -7170,9 +7146,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "17.0.45", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", - "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==" + "version": "16.11.53", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.53.tgz", + "integrity": "sha512-3yJerjVV8GlGSWCjEPal2cDymbQEE/1bhUr1NdW5apDPZo6EjBaqHxR7AC4wKmZ24Hzqcz+tgJyAGe9qcGHw7w==" }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", @@ -49875,9 +49851,9 @@ } }, "node_modules/tough-cookie": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.1.tgz", - "integrity": "sha512-Ns3k8QxkEzIfLZbRwLOrMPDqRa1BEAl4BzNNAOYY4BhBmEkf+HvP467F4NrD9loK3NcYflWOpUH3LJg0ehq/rQ==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", + "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", "dependencies": { "psl": "^1.1.33", "punycode": "^2.1.1", @@ -51990,7 +51966,7 @@ "@coveo/headless": "latest", "@types/fs-extra": "9.0.13", "@types/jest": "27.5.2", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "fs-extra": "10.1.0", "jest": "27.5.1", "prettier": "2.7.1", @@ -52210,7 +52186,7 @@ "@types/fs-extra": "9.0.13", "@types/is-running": "2.1.0", "@types/jest": "27.5.2", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@types/tmp": "0.2.3", "@types/wait-on": "5.3.1", "chrome-launcher": "0.15.1", @@ -52269,9 +52245,11 @@ "name": "@coveo/cli-commons", "version": "1.34.3", "dependencies": { + "@amplitude/node": "1.10.0", "@coveord/platform-client": "34.7.0", "@oclif/core": "1.14.2", "abortcontroller-polyfill": "1.7.3", + "chalk": "4.1.2", "fs-extra": "10.1.0", "https-proxy-agent": "5.0.1", "isomorphic-fetch": "3.0.0", @@ -52280,7 +52258,7 @@ }, "devDependencies": { "@coveo/cli-commons-dev": "1.34.3", - "@types/jest": "^28.1.7", + "@types/jest": "27.5.2", "typescript": "4.7.4" } }, @@ -52292,350 +52270,10 @@ "tslib": "2.4.0" }, "devDependencies": { - "@types/jest": "28.1.7", + "@types/jest": "27.5.2", "typescript": "4.7.4" } }, - "packages/cli/commons-dev/node_modules/@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dev": true, - "dependencies": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/@types/jest": { - "version": "28.1.7", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-28.1.7.tgz", - "integrity": "sha512-acDN4VHD40V24tgu0iC44jchXavRNVFXQ/E6Z5XNsswgoSO/4NgsXoEYmPUGookKldlZQyIpmrEXsHI9cA3ZTA==", - "dev": true, - "dependencies": { - "expect": "^28.0.0", - "pretty-format": "^28.0.0" - } - }, - "packages/cli/commons-dev/node_modules/@types/yargs": { - "version": "17.0.11", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.11.tgz", - "integrity": "sha512-aB4y9UDUXTSMxmM4MH+YnuR0g5Cph3FLQBoWoMB21DSvFVAxRVEHEMx3TLh+zUZYMCQtKiqazz0Q4Rre31f/OA==", - "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "packages/cli/commons-dev/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "packages/cli/commons-dev/node_modules/diff-sequences": { - "version": "28.1.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-28.1.1.tgz", - "integrity": "sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw==", - "dev": true, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/expect": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", - "integrity": "sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g==", - "dev": true, - "dependencies": { - "@jest/expect-utils": "^28.1.3", - "jest-get-type": "^28.0.2", - "jest-matcher-utils": "^28.1.3", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/jest-diff": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-28.1.3.tgz", - "integrity": "sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==", - "dev": true, - "dependencies": { - "chalk": "^4.0.0", - "diff-sequences": "^28.1.1", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/jest-get-type": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", - "dev": true, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/jest-matcher-utils": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz", - "integrity": "sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw==", - "dev": true, - "dependencies": { - "chalk": "^4.0.0", - "jest-diff": "^28.1.3", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dev": true, - "dependencies": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dev": true, - "dependencies": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons-dev/node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true - }, - "packages/cli/commons/node_modules/@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dev": true, - "dependencies": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/@types/jest": { - "version": "28.1.8", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-28.1.8.tgz", - "integrity": "sha512-8TJkV++s7B6XqnDrzR1m/TT0A0h948Pnl/097veySPN67VRAgQ4gZ7n2KfJo2rVq6njQjdxU3GCCyDvAeuHoiw==", - "dev": true, - "dependencies": { - "expect": "^28.0.0", - "pretty-format": "^28.0.0" - } - }, - "packages/cli/commons/node_modules/@types/yargs": { - "version": "17.0.11", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.11.tgz", - "integrity": "sha512-aB4y9UDUXTSMxmM4MH+YnuR0g5Cph3FLQBoWoMB21DSvFVAxRVEHEMx3TLh+zUZYMCQtKiqazz0Q4Rre31f/OA==", - "dev": true, - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "packages/cli/commons/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "packages/cli/commons/node_modules/diff-sequences": { - "version": "28.1.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-28.1.1.tgz", - "integrity": "sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw==", - "dev": true, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/expect": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", - "integrity": "sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g==", - "dev": true, - "dependencies": { - "@jest/expect-utils": "^28.1.3", - "jest-get-type": "^28.0.2", - "jest-matcher-utils": "^28.1.3", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/jest-diff": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-28.1.3.tgz", - "integrity": "sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==", - "dev": true, - "dependencies": { - "chalk": "^4.0.0", - "diff-sequences": "^28.1.1", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/jest-get-type": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", - "dev": true, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/jest-matcher-utils": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz", - "integrity": "sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw==", - "dev": true, - "dependencies": { - "chalk": "^4.0.0", - "jest-diff": "^28.1.3", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dev": true, - "dependencies": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dev": true, - "dependencies": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "packages/cli/commons/node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true - }, "packages/cli/core": { "name": "@coveo/cli", "version": "1.34.3", @@ -52643,6 +52281,7 @@ "dependencies": { "@amplitude/identify": "^1.9.0", "@amplitude/node": "^1.9.0", + "@coveo/cli-commons": "1.34.3", "@coveo/push-api-client": "^2.4.4", "@coveord/platform-client": "34.7.0", "@oclif/core": "1.14.2", @@ -52654,7 +52293,7 @@ "archiver": "^5.3.0", "async-retry": "^1.3.1", "axios": "^0.27.0", - "chalk": "^4.1.1", + "chalk": "4.1.2", "cli-progress": "^3.9.1", "extract-zip": "^2.0.1", "fs-extra": "^10.0.0", @@ -52677,8 +52316,8 @@ "@amplitude/types": "1.10.0", "@babel/core": "7.18.10", "@coveo/angular": "1.34.3", - "@coveo/cli-commons": "1.34.3", "@coveo/cli-commons-dev": "1.34.3", + "@coveo/cli-plugin-source": "1.34.3", "@coveo/cra-template": "1.34.3", "@coveo/create-atomic": "1.34.3", "@coveo/vue-cli-plugin-typescript": "1.34.3", @@ -52690,7 +52329,7 @@ "@types/inquirer": "8.2.3", "@types/jest": "27.5.2", "@types/json2csv": "5.0.3", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@types/semver": "7.3.12", "@types/tmp": "0.2.3", "chai": "4.3.6", @@ -52766,6 +52405,43 @@ "semver": "bin/semver.js" } }, + "packages/cli/source": { + "name": "@coveo/cli-plugin-source", + "version": "1.34.3", + "license": "Apache-2.0", + "dependencies": { + "@coveo/cli-commons": "1.34.3", + "@coveo/push-api-client": "2.5.8", + "@coveord/platform-client": "34.7.0", + "@oclif/core": "1.14.2", + "@oclif/plugin-help": "5.1.12", + "@oclif/plugin-plugins": "2.1.0", + "chalk": "4.1.2", + "jsonschema": "1.4.1", + "ts-dedent": "2.2.0" + }, + "bin": { + "coveo": "bin/run" + }, + "devDependencies": { + "@coveo/cli-commons-dev": "1.34.3", + "@oclif/test": "2.1.1", + "@types/jest": "27.5.2", + "@types/node": "16.11.53", + "eslint": "8.22.0", + "jest": "27.5.1", + "oclif": "3.1.2", + "stdout-stderr": "^0.1.13", + "strip-ansi": "6.0.1", + "ts-jest": "27.1.5", + "ts-node": "10.9.1", + "tslib": "2.4.0", + "typescript": "4.7.4" + }, + "engines": { + "node": ">=14.15.1 <18" + } + }, "packages/cra-template": { "name": "@coveo/cra-template", "version": "1.34.3", @@ -53618,6 +53294,14 @@ "which": "^2.0.2" } }, + "npm-bundled": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-2.0.0.tgz", + "integrity": "sha512-ZnkDgpakv39F6w9D6uZNmmXohXEHW5EC1MDziHvXeLeyBmJ/FpfM1n+v8PkQ2Y1TcNHzuAVTZQIgabkgskR77A==", + "requires": { + "npm-normalize-package-bin": "^1.0.1" + } + }, "npm-install-checks": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-5.0.0.tgz", @@ -53638,13 +53322,13 @@ } }, "npm-packlist": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-5.1.2.tgz", - "integrity": "sha512-rQiBDNmt1H1jNhFEo9ilTD7ZJXd6cvHSmBK+waIBu886v6OyLWjZqb1RD9viR7rgG0AAe29FYnOXcO26TRxT/Q==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-5.1.3.tgz", + "integrity": "sha512-263/0NGrn32YFYi4J533qzrQ/krmmrWwhKkzwTuM4f/07ug51odoaNjUexxO4vxlzURHcmYMH1QjvHjsNDKLVg==", "requires": { "glob": "^8.0.1", "ignore-walk": "^5.0.1", - "npm-bundled": "^1.1.2", + "npm-bundled": "^2.0.0", "npm-normalize-package-bin": "^2.0.0" }, "dependencies": { @@ -55306,7 +54990,7 @@ "@schematics/angular": "^14.0.1", "@types/fs-extra": "9.0.13", "@types/jest": "27.5.2", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "fs-extra": "10.1.0", "jest": "27.5.1", "jest-config": "^27.4.7", @@ -55357,6 +55041,7 @@ "@coveo/angular": "1.34.3", "@coveo/cli-commons": "1.34.3", "@coveo/cli-commons-dev": "1.34.3", + "@coveo/cli-plugin-source": "1.34.3", "@coveo/cra-template": "1.34.3", "@coveo/create-atomic": "1.34.3", "@coveo/push-api-client": "^2.4.4", @@ -55375,7 +55060,7 @@ "@types/inquirer": "8.2.3", "@types/jest": "27.5.2", "@types/json2csv": "5.0.3", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@types/semver": "7.3.12", "@types/tmp": "0.2.3", "abortcontroller-polyfill": "^1.7.1", @@ -55383,7 +55068,7 @@ "async-retry": "^1.3.1", "axios": "^0.27.0", "chai": "4.3.6", - "chalk": "^4.1.1", + "chalk": "4.1.2", "cli-progress": "^3.9.1", "eslint": "8.22.0", "extract-zip": "^2.0.1", @@ -55448,304 +55133,28 @@ "@coveo/cli-commons": { "version": "file:packages/cli/commons", "requires": { + "@amplitude/node": "1.10.0", "@coveo/cli-commons-dev": "1.34.3", "@coveord/platform-client": "34.7.0", "@oclif/core": "1.14.2", - "@types/jest": "^28.1.7", + "@types/jest": "27.5.2", "abortcontroller-polyfill": "1.7.3", + "chalk": "4.1.2", "fs-extra": "10.1.0", "https-proxy-agent": "5.0.1", "isomorphic-fetch": "3.0.0", "semver": "7.3.7", "ts-dedent": "2.2.0", "typescript": "4.7.4" - }, - "dependencies": { - "@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dev": true, - "requires": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - } - }, - "@types/jest": { - "version": "28.1.8", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-28.1.8.tgz", - "integrity": "sha512-8TJkV++s7B6XqnDrzR1m/TT0A0h948Pnl/097veySPN67VRAgQ4gZ7n2KfJo2rVq6njQjdxU3GCCyDvAeuHoiw==", - "dev": true, - "requires": { - "expect": "^28.0.0", - "pretty-format": "^28.0.0" - } - }, - "@types/yargs": { - "version": "17.0.11", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.11.tgz", - "integrity": "sha512-aB4y9UDUXTSMxmM4MH+YnuR0g5Cph3FLQBoWoMB21DSvFVAxRVEHEMx3TLh+zUZYMCQtKiqazz0Q4Rre31f/OA==", - "dev": true, - "requires": { - "@types/yargs-parser": "*" - } - }, - "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true - }, - "diff-sequences": { - "version": "28.1.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-28.1.1.tgz", - "integrity": "sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw==", - "dev": true - }, - "expect": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", - "integrity": "sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g==", - "dev": true, - "requires": { - "@jest/expect-utils": "^28.1.3", - "jest-get-type": "^28.0.2", - "jest-matcher-utils": "^28.1.3", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3" - } - }, - "jest-diff": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-28.1.3.tgz", - "integrity": "sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "diff-sequences": "^28.1.1", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - } - }, - "jest-get-type": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", - "dev": true - }, - "jest-matcher-utils": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz", - "integrity": "sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "jest-diff": "^28.1.3", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - } - }, - "jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - } - }, - "jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dev": true, - "requires": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - } - }, - "pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dev": true, - "requires": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - } - }, - "react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true - } } }, "@coveo/cli-commons-dev": { "version": "file:packages/cli/commons-dev", "requires": { - "@types/jest": "28.1.7", + "@types/jest": "27.5.2", "fancy-test": "2.0.0", "tslib": "2.4.0", "typescript": "4.7.4" - }, - "dependencies": { - "@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dev": true, - "requires": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - } - }, - "@types/jest": { - "version": "28.1.7", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-28.1.7.tgz", - "integrity": "sha512-acDN4VHD40V24tgu0iC44jchXavRNVFXQ/E6Z5XNsswgoSO/4NgsXoEYmPUGookKldlZQyIpmrEXsHI9cA3ZTA==", - "dev": true, - "requires": { - "expect": "^28.0.0", - "pretty-format": "^28.0.0" - } - }, - "@types/yargs": { - "version": "17.0.11", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.11.tgz", - "integrity": "sha512-aB4y9UDUXTSMxmM4MH+YnuR0g5Cph3FLQBoWoMB21DSvFVAxRVEHEMx3TLh+zUZYMCQtKiqazz0Q4Rre31f/OA==", - "dev": true, - "requires": { - "@types/yargs-parser": "*" - } - }, - "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true - }, - "diff-sequences": { - "version": "28.1.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-28.1.1.tgz", - "integrity": "sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw==", - "dev": true - }, - "expect": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", - "integrity": "sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g==", - "dev": true, - "requires": { - "@jest/expect-utils": "^28.1.3", - "jest-get-type": "^28.0.2", - "jest-matcher-utils": "^28.1.3", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3" - } - }, - "jest-diff": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-28.1.3.tgz", - "integrity": "sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "diff-sequences": "^28.1.1", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - } - }, - "jest-get-type": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", - "dev": true - }, - "jest-matcher-utils": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz", - "integrity": "sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "jest-diff": "^28.1.3", - "jest-get-type": "^28.0.2", - "pretty-format": "^28.1.3" - } - }, - "jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - } - }, - "jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dev": true, - "requires": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - } - }, - "pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dev": true, - "requires": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - } - }, - "react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true - } } }, "@coveo/cli-e2e": { @@ -55762,7 +55171,7 @@ "@types/fs-extra": "9.0.13", "@types/is-running": "2.1.0", "@types/jest": "27.5.2", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@types/tmp": "0.2.3", "@types/wait-on": "5.3.1", "abortcontroller-polyfill": "1.7.3", @@ -55819,6 +55228,33 @@ } } }, + "@coveo/cli-plugin-source": { + "version": "file:packages/cli/source", + "requires": { + "@coveo/cli-commons": "1.34.3", + "@coveo/cli-commons-dev": "1.34.3", + "@coveo/push-api-client": "2.5.8", + "@coveord/platform-client": "34.7.0", + "@oclif/core": "1.14.2", + "@oclif/plugin-help": "5.1.12", + "@oclif/plugin-plugins": "2.1.0", + "@oclif/test": "2.1.1", + "@types/jest": "27.5.2", + "@types/node": "16.11.53", + "chalk": "4.1.2", + "eslint": "8.22.0", + "jest": "27.5.1", + "jsonschema": "1.4.1", + "oclif": "3.1.2", + "stdout-stderr": "^0.1.13", + "strip-ansi": "6.0.1", + "ts-dedent": "2.2.0", + "ts-jest": "27.1.5", + "ts-node": "10.9.1", + "tslib": "2.4.0", + "typescript": "4.7.4" + } + }, "@coveo/cra-template": { "version": "file:packages/cra-template", "requires": { @@ -56643,23 +56079,6 @@ "jest-mock": "^27.5.1" } }, - "@jest/expect-utils": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-28.1.3.tgz", - "integrity": "sha512-wvbi9LUrHJLn3NlDW6wF2hvIMtd4JUl2QNVrjq+IBSHirgfrR3o9RnVtxzdEGO2n9JyIWwHnLfby5KzqBGg2YA==", - "dev": true, - "requires": { - "jest-get-type": "^28.0.2" - }, - "dependencies": { - "jest-get-type": { - "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", - "dev": true - } - } - }, "@jest/fake-timers": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-27.5.1.tgz", @@ -56715,15 +56134,6 @@ "v8-to-istanbul": "^8.1.0" } }, - "@jest/schemas": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-28.1.3.tgz", - "integrity": "sha512-/l/VWsdt/aBXgjshLWOFyFt3IVdYypu5y2Wn2rOO1un6nkqIn8SLXzgIMYXFyYsRWDyF5EthmKJMIdJvk08grg==", - "dev": true, - "requires": { - "@sinclair/typebox": "^0.24.1" - } - }, "@jest/source-map": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-27.5.1.tgz", @@ -59087,12 +58497,6 @@ "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==" }, - "@sinclair/typebox": { - "version": "0.24.28", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.28.tgz", - "integrity": "sha512-dgJd3HLOkLmz4Bw50eZx/zJwtBq65nms3N9VBYu5LTjJ883oBFkTyXRlCB/ZGGwqYpJJHA5zW2Ibhl5ngITfow==", - "dev": true - }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -59554,9 +58958,9 @@ "dev": true }, "@types/node": { - "version": "17.0.45", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", - "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==" + "version": "16.11.53", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.53.tgz", + "integrity": "sha512-3yJerjVV8GlGSWCjEPal2cDymbQEE/1bhUr1NdW5apDPZo6EjBaqHxR7AC4wKmZ24Hzqcz+tgJyAGe9qcGHw7w==" }, "@types/normalize-package-data": { "version": "2.4.1", @@ -92254,9 +91658,9 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, "tough-cookie": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.1.tgz", - "integrity": "sha512-Ns3k8QxkEzIfLZbRwLOrMPDqRa1BEAl4BzNNAOYY4BhBmEkf+HvP467F4NrD9loK3NcYflWOpUH3LJg0ehq/rQ==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", + "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", "requires": { "psl": "^1.1.33", "punycode": "^2.1.1", diff --git a/package.json b/package.json index 9b17a1629f..addfaeb52a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@coveord/platform-client": "34.7.0", "@nrwl/cli": "latest", "@nrwl/workspace": "latest", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@typescript-eslint/eslint-plugin": "5.33.1", "@typescript-eslint/parser": "5.33.1", "abortcontroller-polyfill": "1.7.3", diff --git a/packages/angular/package.json b/packages/angular/package.json index 68d840b879..48e956222d 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -43,7 +43,7 @@ "@coveo/headless": "latest", "@types/fs-extra": "9.0.13", "@types/jest": "27.5.2", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "fs-extra": "10.1.0", "jest": "27.5.1", "prettier": "2.7.1", diff --git a/packages/cli-e2e/package.json b/packages/cli-e2e/package.json index a14d77f84d..d0fa04c8f2 100644 --- a/packages/cli-e2e/package.json +++ b/packages/cli-e2e/package.json @@ -42,7 +42,7 @@ "@types/fs-extra": "9.0.13", "@types/is-running": "2.1.0", "@types/jest": "27.5.2", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@types/tmp": "0.2.3", "@types/wait-on": "5.3.1", "chrome-launcher": "0.15.1", diff --git a/packages/cli/commons-dev/.gitignore b/packages/cli/commons-dev/.gitignore index f1ff06d608..fe8b070070 100644 --- a/packages/cli/commons-dev/.gitignore +++ b/packages/cli/commons-dev/.gitignore @@ -1 +1,4 @@ -lib/ \ No newline at end of file +lib/ +src/**/*.js +src/**/*.js.map +src/**/*.d.ts \ No newline at end of file diff --git a/packages/cli/commons-dev/package.json b/packages/cli/commons-dev/package.json index 33b7524ac9..ce7f5b3049 100644 --- a/packages/cli/commons-dev/package.json +++ b/packages/cli/commons-dev/package.json @@ -12,7 +12,7 @@ "tslib": "2.4.0" }, "devDependencies": { - "@types/jest": "28.1.7", + "@types/jest": "27.5.2", "typescript": "4.7.4" }, "scripts": { diff --git a/packages/cli/commons-dev/src/testUtils/jestSnapshotUtils.ts b/packages/cli/commons-dev/src/testUtils/jestSnapshotUtils.ts new file mode 100644 index 0000000000..c7dc4395dd --- /dev/null +++ b/packages/cli/commons-dev/src/testUtils/jestSnapshotUtils.ts @@ -0,0 +1,3 @@ +// See https://github.com/oclif/core/blob/f996086397158b5beafc4254718c78fd93d23b1b/src/errors/errors/cli.ts#L55-L60 +export const formatCliLog = (input: string) => + input.replaceAll(/\r\n/gm, '\n').replaceAll(/»/g, '›'); diff --git a/packages/cli/commons-dev/src/testUtils/utils.ts b/packages/cli/commons-dev/src/testUtils/utils.ts new file mode 100644 index 0000000000..89c5cbc248 --- /dev/null +++ b/packages/cli/commons-dev/src/testUtils/utils.ts @@ -0,0 +1,15 @@ +import {Command} from '@oclif/core'; + +export const getFakeCommand = ( + overrideConfig?: Record +): Command => { + const fakeCommand = { + id: 'foo', + warn: jest.fn(), + log: jest.fn(), + parse: jest.fn().mockReturnValue({flags: {}}), + ...overrideConfig, + }; + + return fakeCommand as unknown as Command; +}; diff --git a/packages/cli/commons/.gitignore b/packages/cli/commons/.gitignore index f1ff06d608..fe8b070070 100644 --- a/packages/cli/commons/.gitignore +++ b/packages/cli/commons/.gitignore @@ -1 +1,4 @@ -lib/ \ No newline at end of file +lib/ +src/**/*.js +src/**/*.js.map +src/**/*.d.ts \ No newline at end of file diff --git a/packages/cli/commons/package.json b/packages/cli/commons/package.json index 59a9a052a2..0f54b2d854 100644 --- a/packages/cli/commons/package.json +++ b/packages/cli/commons/package.json @@ -6,13 +6,15 @@ ], "devDependencies": { "@coveo/cli-commons-dev": "1.34.3", - "@types/jest": "^28.1.7", + "@types/jest": "27.5.2", "typescript": "4.7.4" }, "dependencies": { + "@amplitude/node": "1.10.0", "@coveord/platform-client": "34.7.0", "@oclif/core": "1.14.2", "abortcontroller-polyfill": "1.7.3", + "chalk": "4.1.2", "fs-extra": "10.1.0", "https-proxy-agent": "5.0.1", "isomorphic-fetch": "3.0.0", @@ -20,7 +22,7 @@ "ts-dedent": "2.2.0" }, "scripts": { - "build": "tsc", + "build": "tsc -p tsconfig.json", "prepublish": "npm run build", "npm:publish:template": "npm publish --access public --registry http://localhost:4873" } diff --git a/packages/cli/commons/src/analytics/amplitudeClient.ts b/packages/cli/commons/src/analytics/amplitudeClient.ts new file mode 100644 index 0000000000..87fd6ade92 --- /dev/null +++ b/packages/cli/commons/src/analytics/amplitudeClient.ts @@ -0,0 +1,14 @@ +import {init, NodeClient} from '@amplitude/node'; + +const analyticsAPIKey = 'af28cba7acfd392c324bebd399e2d9ea'; + +export interface AmplitudeClient extends NodeClient { + identified: boolean; +} + +// TODO: CDX-667: support proxy +export const amplitudeClient = init(analyticsAPIKey); + +export const flush = async () => { + await amplitudeClient.flush(); +}; diff --git a/packages/cli/core/src/hooks/analytics/eventUtils.ts b/packages/cli/commons/src/analytics/eventUtils.ts similarity index 79% rename from packages/cli/core/src/hooks/analytics/eventUtils.ts rename to packages/cli/commons/src/analytics/eventUtils.ts index beb9122ff9..aef7fd42e4 100644 --- a/packages/cli/core/src/hooks/analytics/eventUtils.ts +++ b/packages/cli/commons/src/analytics/eventUtils.ts @@ -1,12 +1,8 @@ import type {Event} from '@amplitude/types'; import {validate} from 'jsonschema'; -import { - APIError, - APIErrorResponse, - APIErrorSchema, -} from '../../lib/errors/APIError'; -import {CLIBaseError} from '@coveo/cli-commons/lib/errors/cliBaseError'; -import {UnknownError} from '../../lib/errors/unknownError'; +import {APIError, APIErrorResponse, APIErrorSchema} from '../errors/apiError'; +import {CLIBaseError} from '../errors/cliBaseError'; +import {UnknownError} from '../errors/unknownError'; export function buildEvent( eventName: string, diff --git a/packages/cli/commons/src/analytics/identifier.spec.ts b/packages/cli/commons/src/analytics/identifier.spec.ts new file mode 100644 index 0000000000..960bcde2d7 --- /dev/null +++ b/packages/cli/commons/src/analytics/identifier.spec.ts @@ -0,0 +1,199 @@ +jest.mock('@amplitude/node'); +jest.mock('@amplitude/identify'); +jest.mock('@coveord/platform-client'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); + +import os from 'os'; +import {Identify} from '@amplitude/identify'; +import {Config, Configuration} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {Identifier} from './identifier'; +import PlatformClient from '@coveord/platform-client'; +import { + configurationMock, + defaultConfiguration, +} from '../../__stub__/configuration'; +import type {Interfaces} from '@oclif/core'; +import type {NodeClient} from '@amplitude/node'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; + +describe('identifier', () => { + const mockedGlobalConfig = jest.mocked(globalConfig); + const mockedConfig = jest.mocked(Config); + const mockedIdentify = jest.mocked(Identify, true); + const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); + const mockedPlatformClient = jest.mocked(PlatformClient); + const mockUserGet = jest.fn(); + const mockSetIdentity = jest.fn(); + const mockedLogEvent = jest.fn(); + const mockedOsVersion = jest.spyOn(os, 'release'); + + let identity: Awaited>; + + const getDummyAmplitudeClient = () => + ({ + logEvent: mockedLogEvent, + } as unknown as NodeClient); + + const doMockOS = () => { + mockedOsVersion.mockReturnValue('21.3.4'); + }; + const doMockIdentify = () => { + mockedIdentify.prototype.set.mockImplementation(mockSetIdentity); + }; + const doMockPlatformClient = (email = '') => { + mockedPlatformClient.mockImplementation( + () => + ({ + initialize: () => Promise.resolve(), + user: { + get: mockUserGet.mockResolvedValue({ + email, + }), + }, + organization: { + get: jest.fn().mockResolvedValue({type: 'Production'}), + }, + } as unknown as PlatformClient) + ); + }; + const doMockConfiguration = ( + overrideConfiguration?: Partial + ) => { + mockedConfig.mockImplementation( + configurationMock({...defaultConfiguration, ...overrideConfiguration}) + ); + }; + const doMockAuthenticatedClient = () => { + mockedAuthenticatedClient.mockImplementation( + () => + ({ + getClient: () => + Promise.resolve( + mockedPlatformClient.getMockImplementation()!({ + accessToken: 'foo', + organizationId: 'bar', + }) + ), + cfg: mockedConfig.getMockImplementation()!('./'), + } as unknown as AuthenticatedClient) + ); + }; + + const mockForInternalUser = async () => { + doMockConfiguration(); + doMockPlatformClient('bob@coveo.com'); + }; + const mockForExternalUser = async () => { + doMockConfiguration(); + doMockPlatformClient('bob@acme.com'); + }; + const mockForAnonymousUser = async () => { + doMockConfiguration({anonymous: true}); + doMockPlatformClient(); + }; + + beforeAll(() => { + mockedGlobalConfig.get.mockReturnValue({ + configDir: 'the_config_dir', + version: '1.2.3', + platform: 'darwin', + } as Interfaces.Config); + }); + + beforeEach(() => { + doMockOS(); + doMockIdentify(); + doMockAuthenticatedClient(); + }); + + describe('when the user is internal', () => { + beforeEach(async () => { + await mockForInternalUser(); + identity = await new Identifier().getIdentity(); + }); + + afterEach(() => { + mockUserGet.mockClear(); + mockedPlatformClient.mockClear(); + }); + + it('should not set platform information', async () => { + expect(mockSetIdentity).not.toHaveBeenCalledWith( + 'organization_type', + 'Production' + ); + expect(mockSetIdentity).not.toHaveBeenCalledWith('environment', 'dev'); + expect(mockSetIdentity).not.toHaveBeenCalledWith('region', 'us'); + }); + + it('should set the user ID (unhashed)', async () => { + expect(identity.userId).toBe('bob@coveo.com'); + }); + + it('should set is_internal_user to true', async () => { + expect(mockSetIdentity).toHaveBeenCalledWith('is_internal_user', true); + }); + + it('should identify event with (un-hashed) email', async () => { + expect(identity.userId).toBe('bob@coveo.com'); + }); + + it('should always identify events with a device ID', async () => { + expect(identity.deviceId).toBeDefined(); + }); + }); + + describe('when the user is external', () => { + beforeEach(async () => { + await mockForExternalUser(); + identity = await new Identifier().getIdentity(); + }); + + it('should set the user ID (hashed)', async () => { + expect(identity.userId).not.toBeNull(); + expect(identity.userId).not.toBe('bob@acme.com'); + }); + + it('should set is_internal_user to false', async () => { + expect(mockSetIdentity).toHaveBeenCalledWith('is_internal_user', false); + }); + }); + + describe('when the user is anonymous', () => { + beforeEach(async () => { + await mockForAnonymousUser(); + identity = await new Identifier().getIdentity(); + }); + + it('should set the user ID', async () => { + expect(identity.userId).not.toBeNull(); + }); + }); + + describe('when logging for every user type', () => { + beforeEach(async () => { + identity = await new Identifier().getIdentity(); + identity.identify(getDummyAmplitudeClient()); + }); + + it('should add the CLI version to the event', async () => { + expect(mockedLogEvent).toHaveBeenCalledWith( + expect.objectContaining({app_version: '1.2.3'}) + ); + }); + + it('should add the OS information to the event', async () => { + expect(mockedLogEvent).toHaveBeenCalledWith( + expect.objectContaining({ + app_version: '1.2.3', + os_name: 'darwin', + os_version: '21.3.4', + platform: 'darwin', + }) + ); + }); + }); +}); diff --git a/packages/cli/commons/src/analytics/identifier.ts b/packages/cli/commons/src/analytics/identifier.ts new file mode 100644 index 0000000000..be2769b90e --- /dev/null +++ b/packages/cli/commons/src/analytics/identifier.ts @@ -0,0 +1,123 @@ +import os from 'os'; +import {Identify} from '@amplitude/identify'; +import {machineId} from 'node-machine-id'; +import {createHash} from 'crypto'; +import {AuthenticatedClient} from '../platform/authenticatedClient'; +import PlatformClient from '@coveord/platform-client'; +import {camelToSnakeCase} from '../utils/string'; +import type {NodeClient} from '@amplitude/node'; +import globalConfig from '../config/globalConfig'; +import {Configuration} from '../config/config'; + +export class Identifier { + private authenticatedClient: AuthenticatedClient; + + public constructor() { + this.authenticatedClient = new AuthenticatedClient(); + } + + public async getIdentity() { + const platformClient = await this.authenticatedClient.getClient(); + await platformClient.initialize(); + + const identifier = new Identify(); + const {userId, isInternalUser} = await this.getAnalyticsInfo( + platformClient + ); + const deviceId = await machineId(); + const identity = { + ...this.getShellInfo(), + ...this.getDeviceInfo(), + ...{isInternalUser}, + }; + + Object.entries(identity).forEach(([key, value]) => { + identifier.set(camelToSnakeCase(key), value); + }); + + const identify = (amplitudeClient: NodeClient) => { + const identifyEvent = { + ...identifier.identifyUser(userId, deviceId), + ...this.getAmplitudeBaseEventProperties(), + ...this.getOrganizationIdentifier(), + }; + amplitudeClient.logEvent(identifyEvent); + }; + + return {userId, deviceId, identify}; + } + + private getOrganizationIdentifier() { + const {environment, region, organization} = this.configuration; + return {environment, region, organization}; + } + + private hash(word: string) { + const hash = createHash('sha256').update(word); + return hash.digest('hex').toString(); + } + + private async getAnalyticsInfo(platformClient: PlatformClient) { + return this.configuration.anonymous + ? this.getApiKeyInfo() + : this.getUserInfo(platformClient); + } + + private async getApiKeyInfo() { + const identifier = this.configuration.accessToken + ?.split('-') + .pop() as string; + return { + userId: this.hash(identifier), + isInternalUser: false, + }; + } + + private async getUserInfo(platformClient: PlatformClient) { + const {email} = await platformClient.user.get(); + const isInternalUser = email.match(/@coveo\.com$/) !== null; + + return { + userId: isInternalUser ? email : this.hash(email), + isInternalUser, + }; + } + + private getAmplitudeBaseEventProperties() { + const {version, platform} = globalConfig.get(); + return { + app_version: version, + os_version: os.release(), + os_name: platform, + platform, + }; + } + + private getDeviceInfo() { + const {arch, windows, bin, userAgent, debug} = globalConfig.get(); + return { + arch, + windows, + bin, + userAgent, + debug, + }; + } + + private getShellInfo() { + const {shell} = globalConfig.get(); + const { + TERM_PROGRAM_VERSION: termProgramVersion, + TERM_PROGRAM: termProgram, + } = process.env; + return { + shell, + ...(termProgramVersion && {termProgramVersion}), + ...(termProgram && {termProgram}), + }; + } + + private get configuration(): Configuration { + return this.authenticatedClient.cfg.get(); + } +} diff --git a/packages/cli/core/src/lib/errors/APIError.ts b/packages/cli/commons/src/errors/apiError.ts similarity index 94% rename from packages/cli/core/src/lib/errors/APIError.ts rename to packages/cli/commons/src/errors/apiError.ts index ac82873a61..61b316672e 100644 --- a/packages/cli/core/src/lib/errors/APIError.ts +++ b/packages/cli/commons/src/errors/apiError.ts @@ -1,9 +1,6 @@ import {red} from 'chalk'; import dedent from 'ts-dedent'; -import { - PrintableError, - SeverityLevel, -} from '@coveo/cli-commons/lib/errors/printableError'; +import {PrintableError, SeverityLevel} from './printableError'; export interface APIErrorResponse { message: string; diff --git a/packages/cli/core/src/lib/errors/unknownError.ts b/packages/cli/commons/src/errors/unknownError.ts similarity index 79% rename from packages/cli/core/src/lib/errors/unknownError.ts rename to packages/cli/commons/src/errors/unknownError.ts index 057aee8b41..0ca60a8987 100644 --- a/packages/cli/core/src/lib/errors/unknownError.ts +++ b/packages/cli/commons/src/errors/unknownError.ts @@ -1,7 +1,4 @@ -import { - PrintableError, - SeverityLevel, -} from '@coveo/cli-commons/lib/errors/printableError'; +import {PrintableError, SeverityLevel} from './printableError'; export class UnknownError extends PrintableError { public name = 'Unknown CLI Error'; diff --git a/packages/cli/core/src/lib/decorators/preconditions/trackable.spec.ts b/packages/cli/commons/src/preconditions/trackable.spec.ts similarity index 97% rename from packages/cli/core/src/lib/decorators/preconditions/trackable.spec.ts rename to packages/cli/commons/src/preconditions/trackable.spec.ts index 061028d3dc..3340692cbf 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/trackable.spec.ts +++ b/packages/cli/commons/src/preconditions/trackable.spec.ts @@ -1,5 +1,5 @@ import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {getFakeCommand} from './testsUtils/utils'; +import {getFakeCommand} from '@coveo/cli-commons-dev/lib/testUtils/utils'; import {Trackable} from './trackable'; describe('trackable', () => { diff --git a/packages/cli/core/src/lib/decorators/preconditions/trackable.ts b/packages/cli/commons/src/preconditions/trackable.ts similarity index 94% rename from packages/cli/core/src/lib/decorators/preconditions/trackable.ts rename to packages/cli/commons/src/preconditions/trackable.ts index aa1624168f..9c3e09b179 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/trackable.ts +++ b/packages/cli/commons/src/preconditions/trackable.ts @@ -1,6 +1,6 @@ import type {Command} from '@oclif/core'; -import {flush} from '../../../hooks/analytics/analytics'; -import {buildError, buildEvent} from '../../../hooks/analytics/eventUtils'; +import {flush} from '../analytics/amplitudeClient'; +import {buildError, buildEvent} from '../analytics/eventUtils'; export interface TrackableOptions { /** diff --git a/packages/cli/core/src/lib/utils/string.ts b/packages/cli/commons/src/utils/string.ts similarity index 100% rename from packages/cli/core/src/lib/utils/string.ts rename to packages/cli/commons/src/utils/string.ts diff --git a/packages/cli/core/bin/dev b/packages/cli/core/bin/dev old mode 100644 new mode 100755 diff --git a/packages/cli/core/package.json b/packages/cli/core/package.json index 939f3b2952..31178ab007 100644 --- a/packages/cli/core/package.json +++ b/packages/cli/core/package.json @@ -9,6 +9,7 @@ "dependencies": { "@amplitude/identify": "^1.9.0", "@amplitude/node": "^1.9.0", + "@coveo/cli-commons": "1.34.3", "@coveo/push-api-client": "^2.4.4", "@coveord/platform-client": "34.7.0", "@oclif/core": "1.14.2", @@ -20,7 +21,7 @@ "archiver": "^5.3.0", "async-retry": "^1.3.1", "axios": "^0.27.0", - "chalk": "^4.1.1", + "chalk": "4.1.2", "cli-progress": "^3.9.1", "extract-zip": "^2.0.1", "fs-extra": "^10.0.0", @@ -40,7 +41,7 @@ "@amplitude/types": "1.10.0", "@babel/core": "7.18.10", "@coveo/angular": "1.34.3", - "@coveo/cli-commons": "1.34.3", + "@coveo/cli-plugin-source": "1.34.3", "@coveo/cli-commons-dev": "1.34.3", "@coveo/cra-template": "1.34.3", "@coveo/create-atomic": "1.34.3", @@ -53,7 +54,7 @@ "@types/inquirer": "8.2.3", "@types/jest": "27.5.2", "@types/json2csv": "5.0.3", - "@types/node": "17.0.45", + "@types/node": "16.11.53", "@types/semver": "7.3.12", "@types/tmp": "0.2.3", "chai": "4.3.6", @@ -110,7 +111,8 @@ "@oclif/plugin-help", "@oclif/plugin-update", "@oclif/plugin-version", - "@oclif/plugin-plugins" + "@oclif/plugin-plugins", + "@coveo/cli-plugin-source" ], "oclif": { "additionalHelpFlags": [ @@ -147,15 +149,6 @@ }, "ui:create": { "description": "create a user interface powered by different front end frameworks and Coveo Headless" - }, - "source": { - "description": "manage Coveo sources" - }, - "source:push": { - "description": "manage Coveo Push API sources" - }, - "source:catalog": { - "description": "manage Coveo Catalog sources" } }, "hooks": { @@ -179,7 +172,7 @@ "scripts": { "build": "rimraf lib && tsc -p tsconfig.json", "test": "jest --colors", - "lint": "prettier --config .prettierrc.js --check . && eslint .", + "lint": "prettier --check . && eslint .", "release:phase2": "node --experimental-specifier-resolution=node ../../../scripts/releaseV2/phase2-bump-all-packages.mjs", "postpack": "rimraf oclif.manifest.json", "prepublishOnly": "rimraf lib && npm run build && oclif manifest && oclif readme" diff --git a/packages/cli/core/src/__stub__/configuration.ts b/packages/cli/core/src/__stub__/configuration.ts index db6aaf0974..85854abfb6 100644 --- a/packages/cli/core/src/__stub__/configuration.ts +++ b/packages/cli/core/src/__stub__/configuration.ts @@ -1,6 +1,6 @@ import {Region} from '@coveord/platform-client'; -import type {Config, Configuration} from '@coveo/cli-commons/lib/config/config'; -import {PlatformEnvironment} from '@coveo/cli-commons/lib/platform/environment'; +import type {Config, Configuration} from '@coveo/cli-commons/src/config/config'; +import {PlatformEnvironment} from '@coveo/cli-commons/src/platform/environment'; export const defaultConfiguration = { environment: PlatformEnvironment.Dev, diff --git a/packages/cli/core/src/__test__/preconditionUtils.ts b/packages/cli/core/src/__test__/preconditionUtils.ts index 41d69b16d2..ac2c2bb567 100644 --- a/packages/cli/core/src/__test__/preconditionUtils.ts +++ b/packages/cli/core/src/__test__/preconditionUtils.ts @@ -1,6 +1,6 @@ import {Command} from '@oclif/core'; -import {PreconditionFunction} from '@coveo/cli-commons/lib/preconditions'; -import {PreconditionError} from '@coveo/cli-commons/lib/errors/preconditionError'; +import {PreconditionFunction} from '@coveo/cli-commons/src/preconditions'; +import {PreconditionError} from '@coveo/cli-commons/src/errors/preconditionError'; const thrower = (reason: string) => { throw new PreconditionError(`${reason} Precondition Error`); diff --git a/packages/cli/core/src/commands/auth/login.spec.ts b/packages/cli/core/src/commands/auth/login.spec.ts index 30581e5220..14d21c792d 100644 --- a/packages/cli/core/src/commands/auth/login.spec.ts +++ b/packages/cli/core/src/commands/auth/login.spec.ts @@ -1,13 +1,13 @@ jest.mock('../../lib/oauth/oauth'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('@coveord/platform-client'); import {Region} from '@coveord/platform-client'; import {test} from '@oclif/test'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {OAuth} from '../../lib/oauth/oauth'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; const mockedOAuth = jest.mocked(OAuth, true); const mockedConfig = jest.mocked(Config, true); const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); diff --git a/packages/cli/core/src/commands/auth/login.ts b/packages/cli/core/src/commands/auth/login.ts index 3ac3b7c10e..686b75fecd 100644 --- a/packages/cli/core/src/commands/auth/login.ts +++ b/packages/cli/core/src/commands/auth/login.ts @@ -1,11 +1,11 @@ import {Command, Flags} from '@oclif/core'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {OAuth} from '../../lib/oauth/oauth'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {PlatformEnvironment} from '@coveo/cli-commons/lib/platform/environment'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {PlatformEnvironment} from '@coveo/cli-commons/src/platform/environment'; import {Region} from '@coveord/platform-client'; import {withEnvironment, withRegion} from '../../lib/flags/platformCommonFlags'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class Login extends Command { private configuration!: Config; diff --git a/packages/cli/core/src/commands/auth/token.spec.ts b/packages/cli/core/src/commands/auth/token.spec.ts index f8508c3017..cb277b415f 100644 --- a/packages/cli/core/src/commands/auth/token.spec.ts +++ b/packages/cli/core/src/commands/auth/token.spec.ts @@ -1,13 +1,13 @@ jest.mock('../../lib/oauth/oauth'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('@coveord/platform-client'); import {Region} from '@coveord/platform-client'; import {test} from '@oclif/test'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {PlatformEnvironment} from '@coveo/cli-commons/lib/platform/environment'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {PlatformEnvironment} from '@coveo/cli-commons/src/platform/environment'; const mockedConfig = jest.mocked(Config, true); const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); diff --git a/packages/cli/core/src/commands/auth/token.ts b/packages/cli/core/src/commands/auth/token.ts index 2adbe4d7ea..31dca6045f 100644 --- a/packages/cli/core/src/commands/auth/token.ts +++ b/packages/cli/core/src/commands/auth/token.ts @@ -1,10 +1,10 @@ import {Command, Flags} from '@oclif/core'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {PlatformEnvironment} from '@coveo/cli-commons/lib/platform/environment'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {PlatformEnvironment} from '@coveo/cli-commons/src/platform/environment'; import {Region} from '@coveord/platform-client'; import {withEnvironment, withRegion} from '../../lib/flags/platformCommonFlags'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class Token extends Command { private configuration!: Config; diff --git a/packages/cli/core/src/commands/config/get.spec.ts b/packages/cli/core/src/commands/config/get.spec.ts index 5732996a4a..a9b11a1430 100644 --- a/packages/cli/core/src/commands/config/get.spec.ts +++ b/packages/cli/core/src/commands/config/get.spec.ts @@ -1,9 +1,9 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {test} from '@oclif/test'; -const mockedConfig = jest.mocked(Config); +const mockedConfig = jest.mocked(Config, true); describe('config:get', () => { const mockGet = jest.fn(); diff --git a/packages/cli/core/src/commands/config/get.ts b/packages/cli/core/src/commands/config/get.ts index 25cc1ac335..7cc2a814ee 100644 --- a/packages/cli/core/src/commands/config/get.ts +++ b/packages/cli/core/src/commands/config/get.ts @@ -1,7 +1,7 @@ import {Command} from '@oclif/core'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {ConfigRenderer} from '@coveo/cli-commons/lib/config/configRenderer'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {ConfigRenderer} from '@coveo/cli-commons/src/config/configRenderer'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class Get extends Command { public static description = 'Display the current configuration.'; diff --git a/packages/cli/core/src/commands/config/set.spec.ts b/packages/cli/core/src/commands/config/set.spec.ts index e689ae0726..8d9b74fa50 100644 --- a/packages/cli/core/src/commands/config/set.spec.ts +++ b/packages/cli/core/src/commands/config/set.spec.ts @@ -1,11 +1,11 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; const mockedConfig = jest.mocked(Config); const mockedClient = jest.mocked(AuthenticatedClient); diff --git a/packages/cli/core/src/commands/config/set.ts b/packages/cli/core/src/commands/config/set.ts index 3132377c41..0b7d348a45 100644 --- a/packages/cli/core/src/commands/config/set.ts +++ b/packages/cli/core/src/commands/config/set.ts @@ -1,13 +1,13 @@ import {CliUx, Command, Flags} from '@oclif/core'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {InvalidCommandError} from '../../lib/errors/InvalidCommandError'; -import {ConfigRenderer} from '@coveo/cli-commons/lib/config/configRenderer'; +import {ConfigRenderer} from '@coveo/cli-commons/src/config/configRenderer'; export default class Set extends Command { public static description = 'Modify the current configuration.'; diff --git a/packages/cli/core/src/commands/org/create.spec.ts b/packages/cli/core/src/commands/org/create.spec.ts index 3df6ea4bec..2c4ea3b4e6 100644 --- a/packages/cli/core/src/commands/org/create.spec.ts +++ b/packages/cli/core/src/commands/org/create.spec.ts @@ -1,12 +1,12 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {OrganizationCreationOrigin} from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient, true); const mockedConfig = jest.mocked(Config, true); diff --git a/packages/cli/core/src/commands/org/create.ts b/packages/cli/core/src/commands/org/create.ts index 52aa4629db..142d44b21f 100644 --- a/packages/cli/core/src/commands/org/create.ts +++ b/packages/cli/core/src/commands/org/create.ts @@ -1,14 +1,14 @@ import {Command, Flags, CliUx} from '@oclif/core'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { Preconditions, IsAuthenticated, -} from '@coveo/cli-commons/lib/preconditions/'; +} from '@coveo/cli-commons/src/preconditions/'; import {OrganizationCreationOrigin} from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {bold} from 'chalk'; import dedent from 'ts-dedent'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class Create extends Command { public static description = 'Create a new test Coveo organization.'; diff --git a/packages/cli/core/src/commands/org/list.spec.ts b/packages/cli/core/src/commands/org/list.spec.ts index 25cd48ee58..b8ef58f64d 100644 --- a/packages/cli/core/src/commands/org/list.spec.ts +++ b/packages/cli/core/src/commands/org/list.spec.ts @@ -1,10 +1,10 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {OrganizationModel} from '@coveord/platform-client'; const mockedClient = jest.mocked(AuthenticatedClient); diff --git a/packages/cli/core/src/commands/org/list.ts b/packages/cli/core/src/commands/org/list.ts index 582e246871..bd39b7e4d1 100644 --- a/packages/cli/core/src/commands/org/list.ts +++ b/packages/cli/core/src/commands/org/list.ts @@ -1,11 +1,11 @@ import {Command, CliUx} from '@oclif/core'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { Preconditions, IsAuthenticated, -} from '@coveo/cli-commons/lib/preconditions/'; +} from '@coveo/cli-commons/src/preconditions/'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {recordable} from '../../lib/utils/record'; export default class List extends Command { diff --git a/packages/cli/core/src/commands/org/resources/list.spec.ts b/packages/cli/core/src/commands/org/resources/list.spec.ts index 670a175c5b..443774b6a4 100644 --- a/packages/cli/core/src/commands/org/resources/list.spec.ts +++ b/packages/cli/core/src/commands/org/resources/list.spec.ts @@ -1,12 +1,12 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {test} from '@oclif/test'; import {ResourceSnapshotsModel} from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); const mockedConfig = jest.mocked(Config); diff --git a/packages/cli/core/src/commands/org/resources/list.ts b/packages/cli/core/src/commands/org/resources/list.ts index ea43985ba6..aabb515805 100644 --- a/packages/cli/core/src/commands/org/resources/list.ts +++ b/packages/cli/core/src/commands/org/resources/list.ts @@ -1,13 +1,13 @@ import {Command, CliUx} from '@oclif/core'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {getTargetOrg} from '../../../lib/snapshot/snapshotCommon'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import dedent from 'ts-dedent'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {recordable} from '../../../lib/utils/record'; import {organization} from '../../../lib/flags/snapshotCommonFlags'; diff --git a/packages/cli/core/src/commands/org/resources/model/create.spec.ts b/packages/cli/core/src/commands/org/resources/model/create.spec.ts index 8b9f52e302..e145a267e3 100644 --- a/packages/cli/core/src/commands/org/resources/model/create.spec.ts +++ b/packages/cli/core/src/commands/org/resources/model/create.spec.ts @@ -1,17 +1,17 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../../hooks/analytics/analytics'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('open'); import {Region} from '@coveord/platform-client'; import test from '@oclif/test'; import open from 'open'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { DEFAULT_ENVIRONMENT, DEFAULT_REGION, PlatformEnvironment, -} from '@coveo/cli-commons/lib/platform/environment'; +} from '@coveo/cli-commons/src/platform/environment'; const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); const mockedConfig = jest.fn(); diff --git a/packages/cli/core/src/commands/org/resources/model/create.ts b/packages/cli/core/src/commands/org/resources/model/create.ts index 417bab4e47..f29b30bdef 100644 --- a/packages/cli/core/src/commands/org/resources/model/create.ts +++ b/packages/cli/core/src/commands/org/resources/model/create.ts @@ -2,11 +2,11 @@ import {Command} from '@oclif/core'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {Trackable} from '../../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import open from 'open'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {createSnapshotUrl} from '@coveo/cli-commons/lib/platform/url'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {createSnapshotUrl} from '@coveo/cli-commons/src/platform/url'; import dedent from 'ts-dedent'; export default class Create extends Command { diff --git a/packages/cli/core/src/commands/org/resources/monitor.spec.ts b/packages/cli/core/src/commands/org/resources/monitor.spec.ts index e09ae0b95a..2e01cb20ce 100644 --- a/packages/cli/core/src/commands/org/resources/monitor.spec.ts +++ b/packages/cli/core/src/commands/org/resources/monitor.spec.ts @@ -1,11 +1,11 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/snapshot/snapshotReporter'); jest.mock('../../../lib/snapshot/snapshotFactory'); -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {ResourceSnapshotsReportType} from '@coveord/platform-client'; import {test} from '@oclif/test'; import {getDummySnapshotModel} from '../../../__stub__/resourceSnapshotsModel'; diff --git a/packages/cli/core/src/commands/org/resources/monitor.ts b/packages/cli/core/src/commands/org/resources/monitor.ts index 39d3ac3e8c..883e725d76 100644 --- a/packages/cli/core/src/commands/org/resources/monitor.ts +++ b/packages/cli/core/src/commands/org/resources/monitor.ts @@ -1,11 +1,11 @@ import {ResourceSnapshotsReportModel} from '@coveord/platform-client'; import {Command, CliUx} from '@oclif/core'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {organization, wait} from '../../../lib/flags/snapshotCommonFlags'; import {SnapshotReportStatus} from '../../../lib/snapshot/reportPreviewer/reportPreviewerDataModels'; import {ReportViewerStyles} from '../../../lib/snapshot/reportPreviewer/reportPreviewerStyles'; 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 4fb594c7b9..587bc9f14b 100644 --- a/packages/cli/core/src/commands/org/resources/preview.spec.ts +++ b/packages/cli/core/src/commands/org/resources/preview.spec.ts @@ -1,8 +1,8 @@ jest.mock('../../../lib/decorators/preconditions/git'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/snapshot/snapshot'); jest.mock('../../../lib/snapshot/snapshotFactory'); jest.mock('../../../lib/project/project'); @@ -11,7 +11,7 @@ import {test} from '@oclif/test'; import {Project} from '../../../lib/project/project'; import {join, normalize} from 'path'; import {cwd} from 'process'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {SnapshotFactory} from '../../../lib/snapshot/snapshotFactory'; import {Snapshot} from '../../../lib/snapshot/snapshot'; import {SnapshotReporter} from '../../../lib/snapshot/snapshotReporter'; @@ -23,7 +23,7 @@ import { } from '../../../__stub__/resourceSnapshotsReportModel'; import {CliUx, Command} from '@oclif/core'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {IsGitInstalled} from '../../../lib/decorators/preconditions'; const mockedSnapshotFactory = jest.mocked(SnapshotFactory, true); @@ -54,14 +54,19 @@ const mockProject = () => { ); }; -const mockConfig = () => { +const doMockConfig = () => { mockedConfigGet.mockReturnValue({ region: 'us', - organization: 'foo', + organization: 'default-org', environment: 'prod', }); - mockedConfig.prototype.get = mockedConfigGet; + mockedConfig.mockImplementation( + () => + ({ + get: mockedConfigGet, + } as unknown as Config) + ); }; const mockAuthenticatedClient = () => { @@ -142,7 +147,7 @@ describe('org:resources:preview', () => { }; beforeAll(() => { - mockConfig(); + doMockConfig(); mockProject(); mockAuthenticatedClient(); }); @@ -181,7 +186,7 @@ describe('org:resources:preview', () => { .stderr() .command(['org:resources:preview']) .it('should use cwd as project', () => { - expect(mockedProject).toHaveBeenCalledWith(cwd(), 'foo'); + expect(mockedProject).toHaveBeenCalledWith(cwd(), 'default-org'); }); test @@ -191,7 +196,7 @@ describe('org:resources:preview', () => { .it('should work with default connected org', () => { expect(mockedSnapshotFactory.createFromZip).toHaveBeenCalledWith( normalize(join('path', 'to', 'resources.zip')), - 'foo', + 'default-org', expect.objectContaining({}) ); }); @@ -217,7 +222,7 @@ describe('org:resources:preview', () => { mockedSnapshotFactory.createFromExistingSnapshot ).toHaveBeenCalledWith( 'some-snapshot-id', - 'foo', + 'default-org', expect.objectContaining({}) ); }); @@ -229,7 +234,7 @@ describe('org:resources:preview', () => { .it('should set a 60 seconds wait', () => { expect(mockedSnapshotFactory.createFromZip).toHaveBeenCalledWith( normalize(join('path', 'to', 'resources.zip')), - 'foo', + 'default-org', {wait: 60} ); }); @@ -241,7 +246,7 @@ describe('org:resources:preview', () => { .it('should set a 312 seconds wait', () => { expect(mockedSnapshotFactory.createFromZip).toHaveBeenCalledWith( normalize(join('path', 'to', 'resources.zip')), - 'foo', + 'default-org', {wait: 312} ); }); diff --git a/packages/cli/core/src/commands/org/resources/preview.ts b/packages/cli/core/src/commands/org/resources/preview.ts index f04eaef9a6..d7a529f07b 100644 --- a/packages/cli/core/src/commands/org/resources/preview.ts +++ b/packages/cli/core/src/commands/org/resources/preview.ts @@ -2,18 +2,18 @@ import {Command, Flags} from '@oclif/core'; import {blueBright} from 'chalk'; import {cwd} from 'process'; import dedent from 'ts-dedent'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import {IsGitInstalled} from '../../../lib/decorators/preconditions/git'; import { writeLinkPrivilege, writeSnapshotPrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {SnapshotOperationTimeoutError} from '../../../lib/errors'; import { PreviewLevelValue, 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 13fb5db0a9..490e560bce 100644 --- a/packages/cli/core/src/commands/org/resources/pull.spec.ts +++ b/packages/cli/core/src/commands/org/resources/pull.spec.ts @@ -1,23 +1,23 @@ jest.mock('../../../lib/decorators/preconditions/git'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/snapshot/snapshotFactory'); jest.mock('../../../lib/project/project'); jest.mock('../../../lib/utils/process'); import {join} from 'path'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {ResourceSnapshotsReportType} from '@coveord/platform-client'; import {test} from '@oclif/test'; import {getDummySnapshotModel} from '../../../__stub__/resourceSnapshotsModel'; import {getSuccessReport} from '../../../__stub__/resourceSnapshotsReportModel'; import {SnapshotFactory} from '../../../lib/snapshot/snapshotFactory'; import {Snapshot} from '../../../lib/snapshot/snapshot'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {Command, CliUx} from '@oclif/core'; -import {PreconditionError} from '@coveo/cli-commons/lib/errors/preconditionError'; +import {PreconditionError} from '@coveo/cli-commons/src/errors/preconditionError'; import {cwd} from 'process'; import {Project} from '../../../lib/project/project'; import {IsGitInstalled} from '../../../lib/decorators/preconditions'; @@ -41,7 +41,12 @@ const doMockConfig = () => { environment: 'prod', }); - mockedConfig.prototype.get = mockedConfigGet; + mockedConfig.mockImplementation( + () => + ({ + get: mockedConfigGet, + } as unknown as Config) + ); }; const doMockPreconditions = () => { diff --git a/packages/cli/core/src/commands/org/resources/pull.ts b/packages/cli/core/src/commands/org/resources/pull.ts index 77915f7ac4..64e4d46fec 100644 --- a/packages/cli/core/src/commands/org/resources/pull.ts +++ b/packages/cli/core/src/commands/org/resources/pull.ts @@ -6,15 +6,15 @@ import {resolve} from 'path'; import {cwd} from 'process'; import dedent from 'ts-dedent'; import {formatOrgId} from '../../../lib/commonPromptUtils/formater'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import {IsGitInstalled} from '../../../lib/decorators/preconditions/git'; -import {writeSnapshotPrivilege} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +import {writeSnapshotPrivilege} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {SnapshotOperationTimeoutError} from '../../../lib/errors'; import {ProcessAbort} from '../../../lib/errors/processError'; import { diff --git a/packages/cli/core/src/commands/org/resources/push.spec.ts b/packages/cli/core/src/commands/org/resources/push.spec.ts index 8559621741..d8f49538f5 100644 --- a/packages/cli/core/src/commands/org/resources/push.spec.ts +++ b/packages/cli/core/src/commands/org/resources/push.spec.ts @@ -1,7 +1,7 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/snapshot/snapshot'); jest.mock('../../../lib/snapshot/snapshotFactory'); jest.mock('../../../lib/project/project'); @@ -10,7 +10,7 @@ import {CliUx} from '@oclif/core'; import {test} from '@oclif/test'; import {Project} from '../../../lib/project/project'; import {join, normalize} from 'path'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {SnapshotFactory} from '../../../lib/snapshot/snapshotFactory'; import {Snapshot} from '../../../lib/snapshot/snapshot'; import {SnapshotReporter} from '../../../lib/snapshot/snapshotReporter'; @@ -20,7 +20,7 @@ import { getMissingVaultEntryReport, getSuccessReport, } from '../../../__stub__/resourceSnapshotsReportModel'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; const mockedSnapshotFactory = jest.mocked(SnapshotFactory, true); const mockedConfig = jest.mocked(Config); @@ -50,14 +50,19 @@ const mockProject = () => { ); }; -const mockConfig = () => { +const doMockConfig = () => { mockedConfigGet.mockReturnValue({ region: 'us', - organization: 'foo', + organization: 'default-org', environment: 'prod', }); - mockedConfig.prototype.get = mockedConfigGet; + mockedConfig.mockImplementation( + () => + ({ + get: mockedConfigGet, + } as unknown as Config) + ); }; const mockSnapshotFactory = async () => { @@ -153,7 +158,7 @@ const mockSnapshotFactoryReturningSnapshotWithMissingVaultEntries = describe('org:resources:push', () => { beforeAll(() => { - mockConfig(); + doMockConfig(); mockProject(); mockAuthenticatedClient(); }); @@ -222,7 +227,7 @@ describe('org:resources:push', () => { .it('should work with default connected org', () => { expect(mockedSnapshotFactory.createFromZip).toHaveBeenCalledWith( normalize(join('path', 'to', 'resources.zip')), - 'foo', + 'default-org', expect.objectContaining({}) ); }); @@ -249,7 +254,7 @@ describe('org:resources:push', () => { .it('should set a 60 seconds wait', () => { expect(mockedSnapshotFactory.createFromZip).toHaveBeenCalledWith( normalize(join('path', 'to', 'resources.zip')), - 'foo', + 'default-org', {wait: 60} ); }); @@ -262,7 +267,7 @@ describe('org:resources:push', () => { .it('should set a 99 seconds wait', () => { expect(mockedSnapshotFactory.createFromZip).toHaveBeenCalledWith( normalize(join('path', 'to', 'resources.zip')), - 'foo', + 'default-org', {wait: 99} ); }); diff --git a/packages/cli/core/src/commands/org/resources/push.ts b/packages/cli/core/src/commands/org/resources/push.ts index 359728c800..9d88e3280e 100644 --- a/packages/cli/core/src/commands/org/resources/push.ts +++ b/packages/cli/core/src/commands/org/resources/push.ts @@ -3,7 +3,7 @@ import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import {Snapshot} from '../../../lib/snapshot/snapshot'; import {red, green, bold} from 'chalk'; import {SnapshotReporter} from '../../../lib/snapshot/snapshotReporter'; @@ -17,7 +17,7 @@ import { getMissingVaultEntriesReportHandler, getErrorReportHandler, } from '../../../lib/snapshot/snapshotCommon'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {cwd} from 'process'; import {Project} from '../../../lib/project/project'; import { @@ -29,8 +29,8 @@ import { import { writeLinkPrivilege, writeSnapshotPrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {confirmWithAnalytics} from '../../../lib/utils/cli'; import {SnapshotReportStatus} from '../../../lib/snapshot/reportPreviewer/reportPreviewerDataModels'; diff --git a/packages/cli/core/src/commands/org/search/dump.spec.ts b/packages/cli/core/src/commands/org/search/dump.spec.ts index c3a7f1af48..3730ad6215 100644 --- a/packages/cli/core/src/commands/org/search/dump.spec.ts +++ b/packages/cli/core/src/commands/org/search/dump.spec.ts @@ -1,14 +1,14 @@ jest.mock('@coveord/platform-client'); jest.mock('fs-extra'); jest.mock('json2csv'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); import {test} from '@oclif/test'; import {Parser} from 'json2csv'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); const mockedConfig = jest.mocked(Config); const mockedSearch = jest.fn(); diff --git a/packages/cli/core/src/commands/org/search/dump.ts b/packages/cli/core/src/commands/org/search/dump.ts index 82fb6c4d97..103c26a965 100644 --- a/packages/cli/core/src/commands/org/search/dump.ts +++ b/packages/cli/core/src/commands/org/search/dump.ts @@ -5,13 +5,13 @@ import {SingleBar} from 'cli-progress'; import PlatformClient from '@coveord/platform-client'; import {dirSync} from 'tmp'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { Preconditions, IsAuthenticated, -} from '@coveo/cli-commons/lib/preconditions'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {without} from '../../../lib/utils/list'; import {join} from 'path'; import dedent from 'ts-dedent'; diff --git a/packages/cli/core/src/commands/ui/create/angular.spec.ts b/packages/cli/core/src/commands/ui/create/angular.spec.ts index bfb39f4f18..3e874064c7 100644 --- a/packages/cli/core/src/commands/ui/create/angular.spec.ts +++ b/packages/cli/core/src/commands/ui/create/angular.spec.ts @@ -1,21 +1,21 @@ jest.mock('../../../lib/decorators/preconditions/npm'); jest.mock('../../../lib/decorators/preconditions/node'); jest.mock('../../../lib/decorators/preconditions/ng'); -jest.mock('@coveo/cli-commons/lib/preconditions/apiKeyPrivilege'); +jest.mock('@coveo/cli-commons/src/preconditions/apiKeyPrivilege'); jest.mock('../../../lib/utils/process'); jest.mock('../../../lib/oauth/oauth'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/utils/misc'); jest.mock('@coveord/platform-client'); import {test} from '@oclif/test'; import {spawnProcess} from '../../../lib/utils/process'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import PlatformClient from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { IsNpmVersionInRange, IsNodeVersionInRange, @@ -24,7 +24,7 @@ import {getPackageVersion} from '../../../lib/utils/misc'; import {IsNgVersionInRange} from '../../../lib/decorators/preconditions/ng'; import {configurationMock} from '../../../__stub__/configuration'; import {mockPreconditions} from '../../../__test__/preconditionUtils'; -import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/lib/preconditions'; +import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/src/preconditions'; describe('ui:create:angular', () => { const mockedConfig = jest.mocked(Config); diff --git a/packages/cli/core/src/commands/ui/create/angular.ts b/packages/cli/core/src/commands/ui/create/angular.ts index e535eaf42b..d6d7f9bf49 100644 --- a/packages/cli/core/src/commands/ui/create/angular.ts +++ b/packages/cli/core/src/commands/ui/create/angular.ts @@ -1,8 +1,8 @@ import {Command, Flags} from '@oclif/core'; -import {platformUrl} from '@coveo/cli-commons/lib/platform/environment'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {platformUrl} from '@coveo/cli-commons/src/platform/environment'; +import {Config} from '@coveo/cli-commons/src/config/config'; import {spawnProcess} from '../../../lib/utils/process'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {getPackageVersion} from '../../../lib/utils/misc'; import { IsNodeVersionInRange, @@ -12,14 +12,14 @@ import { HasNecessaryCoveoPrivileges, Preconditions, IsAuthenticated, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import {appendCmdIfWindows} from '../../../lib/utils/os'; import {IsNgVersionInRange} from '../../../lib/decorators/preconditions/ng'; import { createApiKeyPrivilege, impersonatePrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class Angular extends Command { public static templateName = '@coveo/angular'; diff --git a/packages/cli/core/src/commands/ui/create/atomic.spec.ts b/packages/cli/core/src/commands/ui/create/atomic.spec.ts index ff445e50d8..5ecc4e7767 100644 --- a/packages/cli/core/src/commands/ui/create/atomic.spec.ts +++ b/packages/cli/core/src/commands/ui/create/atomic.spec.ts @@ -1,26 +1,26 @@ jest.mock('child_process'); jest.mock('../../../lib/decorators/preconditions/npx'); jest.mock('../../../lib/decorators/preconditions/node'); -jest.mock('@coveo/cli-commons/lib/preconditions/apiKeyPrivilege'); +jest.mock('@coveo/cli-commons/src/preconditions/apiKeyPrivilege'); jest.mock('../../../lib/utils/process'); jest.mock('../../../lib/oauth/oauth'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/utils/misc'); jest.mock('@coveord/platform-client'); import {test} from '@oclif/test'; import {spawnProcess} from '../../../lib/utils/process'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import PlatformClient from '@coveord/platform-client'; -import {Config, Configuration} from '@coveo/cli-commons/lib/config/config'; +import {Config, Configuration} from '@coveo/cli-commons/src/config/config'; import { IsNpxInstalled, IsNodeVersionInRange, } from '../../../lib/decorators/preconditions/'; -import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/lib/preconditions'; +import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/src/preconditions'; import {getPackageVersion} from '../../../lib/utils/misc'; import {configurationMock} from '../../../__stub__/configuration'; import {mockPreconditions} from '../../../__test__/preconditionUtils'; diff --git a/packages/cli/core/src/commands/ui/create/atomic.ts b/packages/cli/core/src/commands/ui/create/atomic.ts index c0f0698b4a..6609723526 100644 --- a/packages/cli/core/src/commands/ui/create/atomic.ts +++ b/packages/cli/core/src/commands/ui/create/atomic.ts @@ -7,18 +7,18 @@ import { Preconditions, IsAuthenticated, HasNecessaryCoveoPrivileges, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import { createApiKeyPrivilege, impersonatePrivilege, viewSearchPagesPrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; import {appendCmdIfWindows} from '../../../lib/utils/os'; import {spawnProcess} from '../../../lib/utils/process'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {platformUrl} from '@coveo/cli-commons/lib/platform/environment'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {platformUrl} from '@coveo/cli-commons/src/platform/environment'; import {getPackageVersion} from '../../../lib/utils/misc'; export default class Atomic extends Command { diff --git a/packages/cli/core/src/commands/ui/create/react.spec.ts b/packages/cli/core/src/commands/ui/create/react.spec.ts index c743ce41d0..8d48accd8b 100644 --- a/packages/cli/core/src/commands/ui/create/react.spec.ts +++ b/packages/cli/core/src/commands/ui/create/react.spec.ts @@ -1,26 +1,26 @@ jest.mock('child_process'); jest.mock('../../../lib/decorators/preconditions/npx'); jest.mock('../../../lib/decorators/preconditions/node'); -jest.mock('@coveo/cli-commons/lib/preconditions/apiKeyPrivilege'); +jest.mock('@coveo/cli-commons/src/preconditions/apiKeyPrivilege'); jest.mock('../../../lib/utils/process'); jest.mock('../../../lib/oauth/oauth'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/utils/misc'); jest.mock('@coveord/platform-client'); import {test} from '@oclif/test'; import {spawnProcess, spawnProcessOutput} from '../../../lib/utils/process'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import PlatformClient from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { IsNpxInstalled, IsNodeVersionInRange, } from '../../../lib/decorators/preconditions/'; -import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/lib/preconditions'; +import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/src/preconditions'; import {getPackageVersion} from '../../../lib/utils/misc'; import {configurationMock} from '../../../__stub__/configuration'; import {mockPreconditions} from '../../../__test__/preconditionUtils'; diff --git a/packages/cli/core/src/commands/ui/create/react.ts b/packages/cli/core/src/commands/ui/create/react.ts index e495d89a8e..ce99ebfdf1 100644 --- a/packages/cli/core/src/commands/ui/create/react.ts +++ b/packages/cli/core/src/commands/ui/create/react.ts @@ -1,7 +1,7 @@ import {Command, Flags} from '@oclif/core'; -import {Config} from '@coveo/cli-commons/lib/config/config'; -import {platformUrl} from '@coveo/cli-commons/lib/platform/environment'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import {platformUrl} from '@coveo/cli-commons/src/platform/environment'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {spawnProcess, spawnProcessOutput} from '../../../lib/utils/process'; import {getPackageVersion} from '../../../lib/utils/misc'; import {appendCmdIfWindows} from '../../../lib/utils/os'; @@ -9,12 +9,12 @@ import { Preconditions, IsAuthenticated, HasNecessaryCoveoPrivileges, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import { createApiKeyPrivilege, impersonatePrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import { IsNodeVersionInRange, IsNpxInstalled, diff --git a/packages/cli/core/src/commands/ui/create/vue.spec.ts b/packages/cli/core/src/commands/ui/create/vue.spec.ts index e189b7a313..70a075761e 100644 --- a/packages/cli/core/src/commands/ui/create/vue.spec.ts +++ b/packages/cli/core/src/commands/ui/create/vue.spec.ts @@ -1,25 +1,25 @@ jest.mock('../../../lib/decorators/preconditions/npx'); jest.mock('../../../lib/decorators/preconditions/node'); -jest.mock('@coveo/cli-commons/lib/preconditions/apiKeyPrivilege'); +jest.mock('@coveo/cli-commons/src/preconditions/apiKeyPrivilege'); jest.mock('../../../lib/utils/process'); jest.mock('../../../lib/oauth/oauth'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../../lib/utils/misc'); jest.mock('@coveord/platform-client'); import {test} from '@oclif/test'; import {spawnProcess} from '../../../lib/utils/process'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import PlatformClient from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { IsNodeVersionInRange, IsNpxInstalled, } from '../../../lib/decorators/preconditions/'; -import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/lib/preconditions'; +import {HasNecessaryCoveoPrivileges} from '@coveo/cli-commons/src/preconditions'; import {getPackageVersion} from '../../../lib/utils/misc'; import {configurationMock} from '../../../__stub__/configuration'; import {mockPreconditions} from '../../../__test__/preconditionUtils'; diff --git a/packages/cli/core/src/commands/ui/create/vue.ts b/packages/cli/core/src/commands/ui/create/vue.ts index 64be3eb19e..468f85f039 100644 --- a/packages/cli/core/src/commands/ui/create/vue.ts +++ b/packages/cli/core/src/commands/ui/create/vue.ts @@ -1,21 +1,21 @@ import {Command, Flags} from '@oclif/core'; import {resolve} from 'path'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { Preconditions, IsAuthenticated, HasNecessaryCoveoPrivileges, -} from '@coveo/cli-commons/lib/preconditions'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {platformUrl} from '@coveo/cli-commons/lib/platform/environment'; +} from '@coveo/cli-commons/src/preconditions'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {platformUrl} from '@coveo/cli-commons/src/platform/environment'; import {spawnProcess} from '../../../lib/utils/process'; import {getPackageVersion} from '../../../lib/utils/misc'; import {appendCmdIfWindows} from '../../../lib/utils/os'; import { createApiKeyPrivilege, impersonatePrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import { IsNodeVersionInRange, IsNpxInstalled, diff --git a/packages/cli/core/src/hooks/analytics/analytics.spec.ts b/packages/cli/core/src/hooks/analytics/analytics.spec.ts index e1b72e7868..fc34a8fcad 100644 --- a/packages/cli/core/src/hooks/analytics/analytics.spec.ts +++ b/packages/cli/core/src/hooks/analytics/analytics.spec.ts @@ -1,22 +1,22 @@ jest.mock('jsonschema'); jest.mock('@amplitude/node'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('@coveord/platform-client'); -jest.mock('@coveo/cli-commons/lib/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; import { AuthenticatedClient, AuthenticationStatus, getAuthenticationStatus, -} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +} from '@coveo/cli-commons/src/platform/authenticatedClient'; import hook, {AnalyticsHook} from './analytics'; import {Interfaces} from '@oclif/core'; import {PlatformClient} from '@coveord/platform-client'; import {configurationMock} from '../../__stub__/configuration'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; const mockedGlobalConfig = jest.mocked(globalConfig); const mockedConfig = jest.mocked(Config); const mockedPlatformClient = jest.mocked(PlatformClient); diff --git a/packages/cli/core/src/hooks/analytics/analytics.ts b/packages/cli/core/src/hooks/analytics/analytics.ts index 975793ca72..25d497c3b4 100644 --- a/packages/cli/core/src/hooks/analytics/analytics.ts +++ b/packages/cli/core/src/hooks/analytics/analytics.ts @@ -4,7 +4,7 @@ import { AuthenticatedClient, AuthenticationStatus, getAuthenticationStatus, -} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {amplitudeClient} from './amplitudeClient'; import {Identifier} from './identifier'; @@ -34,10 +34,6 @@ const hook = async function (options: AnalyticsHook) { }); }; -export const flush = async () => { - await amplitudeClient.flush(); -}; - const augmentEvent = async ( event: Event, identifier: Awaited> diff --git a/packages/cli/core/src/hooks/analytics/identifier.spec.ts b/packages/cli/core/src/hooks/analytics/identifier.spec.ts index b065b11066..960bcde2d7 100644 --- a/packages/cli/core/src/hooks/analytics/identifier.spec.ts +++ b/packages/cli/core/src/hooks/analytics/identifier.spec.ts @@ -1,14 +1,14 @@ jest.mock('@amplitude/node'); jest.mock('@amplitude/identify'); jest.mock('@coveord/platform-client'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('@coveo/cli-commons/lib/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); import os from 'os'; import {Identify} from '@amplitude/identify'; -import {Config, Configuration} from '@coveo/cli-commons/lib/config/config'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {Config, Configuration} from '@coveo/cli-commons/src/config/config'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {Identifier} from './identifier'; import PlatformClient from '@coveord/platform-client'; import { @@ -17,7 +17,7 @@ import { } from '../../__stub__/configuration'; import type {Interfaces} from '@oclif/core'; import type {NodeClient} from '@amplitude/node'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; describe('identifier', () => { const mockedGlobalConfig = jest.mocked(globalConfig); diff --git a/packages/cli/core/src/hooks/analytics/identifier.ts b/packages/cli/core/src/hooks/analytics/identifier.ts index 246301ba2a..1b29f82c9f 100644 --- a/packages/cli/core/src/hooks/analytics/identifier.ts +++ b/packages/cli/core/src/hooks/analytics/identifier.ts @@ -2,12 +2,12 @@ import os from 'os'; import {Identify} from '@amplitude/identify'; import {machineId} from 'node-machine-id'; import {createHash} from 'crypto'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import PlatformClient from '@coveord/platform-client'; -import {camelToSnakeCase} from '../../lib/utils/string'; +import {camelToSnakeCase} from '@coveo/cli-commons/src/utils/string'; import type {NodeClient} from '@amplitude/node'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; -import {Configuration} from '@coveo/cli-commons/lib/config/config'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; +import {Configuration} from '@coveo/cli-commons/src/config/config'; export class Identifier { private authenticatedClient: AuthenticatedClient; diff --git a/packages/cli/core/src/hooks/commandNotFound/commandNotFound.spec.ts b/packages/cli/core/src/hooks/commandNotFound/commandNotFound.spec.ts index 3f498ff4cf..3da301e3e8 100644 --- a/packages/cli/core/src/hooks/commandNotFound/commandNotFound.spec.ts +++ b/packages/cli/core/src/hooks/commandNotFound/commandNotFound.spec.ts @@ -1,5 +1,5 @@ jest.mock('../analytics/analytics'); -jest.mock('@coveo/cli-commons/lib/config/config'); +jest.mock('@coveo/cli-commons/src/config/config'); import {test} from '@oclif/test'; import analytics from '../analytics/analytics'; diff --git a/packages/cli/core/src/hooks/commandNotFound/commandNotFound.ts b/packages/cli/core/src/hooks/commandNotFound/commandNotFound.ts index 0083716082..2f068c8ea8 100644 --- a/packages/cli/core/src/hooks/commandNotFound/commandNotFound.ts +++ b/packages/cli/core/src/hooks/commandNotFound/commandNotFound.ts @@ -1,6 +1,6 @@ +import {buildEvent} from '@coveo/cli-commons/src/analytics/eventUtils'; import {Hook} from '@oclif/core'; import {CLIError} from '@oclif/core/lib/errors'; -import {buildEvent} from '../analytics/eventUtils'; const hook: Hook<'command_not_found'> = async function (options) { await this.config.runHook('analytics', { diff --git a/packages/cli/core/src/hooks/init/set-global-config.ts b/packages/cli/core/src/hooks/init/set-global-config.ts index 164f1444a3..a119a3e0cc 100644 --- a/packages/cli/core/src/hooks/init/set-global-config.ts +++ b/packages/cli/core/src/hooks/init/set-global-config.ts @@ -1,6 +1,6 @@ import {handleTerminationSignals} from './termination-signals'; import {Hook} from '@oclif/core'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; const hook: Hook<'init'> = async function (opts) { handleTerminationSignals(); diff --git a/packages/cli/core/src/hooks/init/termination-signals.spec.ts b/packages/cli/core/src/hooks/init/termination-signals.spec.ts index 34d3091fae..cf5832da10 100644 --- a/packages/cli/core/src/hooks/init/termination-signals.spec.ts +++ b/packages/cli/core/src/hooks/init/termination-signals.spec.ts @@ -1,10 +1,10 @@ -jest.mock('../analytics/analytics'); -jest.mock('@coveo/cli-commons/lib/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/analytics/amplitudeClient'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); import type {Interfaces} from '@oclif/core'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {flush} from '../analytics/analytics'; +import {flush} from '@coveo/cli-commons/src/analytics/amplitudeClient'; import {handleTerminationSignals, exitSignals} from './termination-signals'; type supportedExitSignals = typeof exitSignals[number]; diff --git a/packages/cli/core/src/hooks/init/termination-signals.ts b/packages/cli/core/src/hooks/init/termination-signals.ts index 609335592a..d32a5df719 100644 --- a/packages/cli/core/src/hooks/init/termination-signals.ts +++ b/packages/cli/core/src/hooks/init/termination-signals.ts @@ -1,7 +1,6 @@ -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; -import {flush} from '../analytics/analytics'; -import {buildEvent} from '../analytics/eventUtils'; - +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; +import {flush} from '@coveo/cli-commons/src/analytics/amplitudeClient'; +import {buildEvent} from '@coveo/cli-commons/src/analytics/eventUtils'; export const exitSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'] as const; export function handleTerminationSignals() { diff --git a/packages/cli/core/src/hooks/postrun/postrun.ts b/packages/cli/core/src/hooks/postrun/postrun.ts index e07cb365ef..82712717e1 100644 --- a/packages/cli/core/src/hooks/postrun/postrun.ts +++ b/packages/cli/core/src/hooks/postrun/postrun.ts @@ -1,5 +1,5 @@ import {Hook} from '@oclif/core'; -import {flush} from '../analytics/analytics'; +import {flush} from '@coveo/cli-commons/src/analytics/amplitudeClient'; const hook: Hook<'postrun'> = async function (_options) { await flush(); diff --git a/packages/cli/core/src/lib/decorators/preconditions/binPreconditionsFactory.ts b/packages/cli/core/src/lib/decorators/preconditions/binPreconditionsFactory.ts index 6d46c7f6fd..68f6901b4c 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/binPreconditionsFactory.ts +++ b/packages/cli/core/src/lib/decorators/preconditions/binPreconditionsFactory.ts @@ -2,7 +2,7 @@ import type {Command} from '@oclif/core'; import {dedent} from 'ts-dedent'; import {spawnProcessOutput, SpawnProcessOutput} from '../../utils/process'; import {satisfies, validRange} from 'semver'; -import {PreconditionError} from '@coveo/cli-commons/lib/errors/preconditionError'; +import {PreconditionError} from '@coveo/cli-commons/src/errors/preconditionError'; export enum PreconditionErrorCategoryBin { MissingBin = 'Missing Bin', diff --git a/packages/cli/core/src/lib/decorators/preconditions/git.spec.ts b/packages/cli/core/src/lib/decorators/preconditions/git.spec.ts index b42e104649..1388e42624 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/git.spec.ts +++ b/packages/cli/core/src/lib/decorators/preconditions/git.spec.ts @@ -6,7 +6,7 @@ import {getFakeCommand} from './testsUtils/utils'; import {IsGitInstalled} from './git'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {PreconditionError} from '@coveo/cli-commons/lib/errors/preconditionError'; +import {PreconditionError} from '@coveo/cli-commons/src/errors/preconditionError'; describe('IsGitInstalled', () => { const mockedSpawnProcessOutput = jest.mocked(spawnProcessOutput); diff --git a/packages/cli/core/src/lib/decorators/preconditions/node.spec.ts b/packages/cli/core/src/lib/decorators/preconditions/node.spec.ts index 88947352d4..77b96b64d7 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/node.spec.ts +++ b/packages/cli/core/src/lib/decorators/preconditions/node.spec.ts @@ -6,7 +6,7 @@ import {getFakeCommand} from './testsUtils/utils'; import {IsNodeVersionInRange} from './node'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {PreconditionError} from '@coveo/cli-commons/lib/errors/preconditionError'; +import {PreconditionError} from '@coveo/cli-commons/src/errors/preconditionError'; describe('IsNodeVersionInRange', () => { const mockedSpawnProcessOutput = jest.mocked(spawnProcessOutput); diff --git a/packages/cli/core/src/lib/decorators/preconditions/npx.spec.ts b/packages/cli/core/src/lib/decorators/preconditions/npx.spec.ts index af2fb2e68b..f1586e4184 100644 --- a/packages/cli/core/src/lib/decorators/preconditions/npx.spec.ts +++ b/packages/cli/core/src/lib/decorators/preconditions/npx.spec.ts @@ -7,7 +7,7 @@ import {getFakeCommand} from './testsUtils/utils'; import {IsNpxInstalled} from './npx'; import {appendCmdIfWindows} from '../../utils/os'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {PreconditionError} from '@coveo/cli-commons/lib/errors/preconditionError'; +import {PreconditionError} from '@coveo/cli-commons/src/errors/preconditionError'; describe('IsNpxInstalled', () => { const mockedSpawnProcessOutput = jest.mocked(spawnProcessOutput); diff --git a/packages/cli/core/src/lib/errors/InvalidCommandError.ts b/packages/cli/core/src/lib/errors/InvalidCommandError.ts index 7485368644..9341b0669e 100644 --- a/packages/cli/core/src/lib/errors/InvalidCommandError.ts +++ b/packages/cli/core/src/lib/errors/InvalidCommandError.ts @@ -1,4 +1,4 @@ -import {CLIBaseError} from '@coveo/cli-commons/lib/errors/cliBaseError'; +import {CLIBaseError} from '@coveo/cli-commons/src/errors/cliBaseError'; export class InvalidCommandError extends CLIBaseError { public name = 'Invalid Command Error'; diff --git a/packages/cli/core/src/lib/errors/platformError.ts b/packages/cli/core/src/lib/errors/platformError.ts index 8b7c6b085b..ab461a4494 100644 --- a/packages/cli/core/src/lib/errors/platformError.ts +++ b/packages/cli/core/src/lib/errors/platformError.ts @@ -1,8 +1,8 @@ -import {PlatformPrivilege} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; +import {PlatformPrivilege} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; import { PrintableError, SeverityLevel, -} from '@coveo/cli-commons/lib/errors/printableError'; +} from '@coveo/cli-commons/src/errors/printableError'; export class MissingPrivilegeError extends PrintableError { public constructor( diff --git a/packages/cli/core/src/lib/errors/processError.ts b/packages/cli/core/src/lib/errors/processError.ts index 55819dba3e..3f970bafae 100644 --- a/packages/cli/core/src/lib/errors/processError.ts +++ b/packages/cli/core/src/lib/errors/processError.ts @@ -1,7 +1,7 @@ import { PrintableError, SeverityLevel, -} from '@coveo/cli-commons/lib/errors/printableError'; +} from '@coveo/cli-commons/src/errors/printableError'; export class ProcessAbort extends PrintableError { public name = 'Operation Aborted'; diff --git a/packages/cli/core/src/lib/errors/projectError.ts b/packages/cli/core/src/lib/errors/projectError.ts index 2afb91e095..a0af1534cd 100644 --- a/packages/cli/core/src/lib/errors/projectError.ts +++ b/packages/cli/core/src/lib/errors/projectError.ts @@ -1,4 +1,4 @@ -import {CLIBaseError} from '@coveo/cli-commons/lib/errors/cliBaseError'; +import {CLIBaseError} from '@coveo/cli-commons/src/errors/cliBaseError'; export class InvalidProjectError extends CLIBaseError { public name = 'Invalid Project Error'; diff --git a/packages/cli/core/src/lib/errors/snapshotErrors.ts b/packages/cli/core/src/lib/errors/snapshotErrors.ts index 89ac876c4e..0df07b6130 100644 --- a/packages/cli/core/src/lib/errors/snapshotErrors.ts +++ b/packages/cli/core/src/lib/errors/snapshotErrors.ts @@ -1,12 +1,12 @@ import {blueBright} from 'chalk'; import dedent from 'ts-dedent'; -import {Configuration} from '@coveo/cli-commons/lib/config/config'; +import {Configuration} from '@coveo/cli-commons/src/config/config'; import {Snapshot} from '../snapshot/snapshot'; import {SnapshotUrlBuilder} from '../snapshot/snapshotUrlBuilder'; import { PrintableError, SeverityLevel, -} from '@coveo/cli-commons/lib/errors/printableError'; +} from '@coveo/cli-commons/src/errors/printableError'; interface DetailedReportable extends PrintableError { snapshot: Snapshot; diff --git a/packages/cli/core/src/lib/errors/vaultErrors.ts b/packages/cli/core/src/lib/errors/vaultErrors.ts index f0bfbfd57e..c4a0ca0a3d 100644 --- a/packages/cli/core/src/lib/errors/vaultErrors.ts +++ b/packages/cli/core/src/lib/errors/vaultErrors.ts @@ -1,10 +1,10 @@ import dedent from 'ts-dedent'; -import {Plurable, pluralizeIfNeeded} from '../utils/string'; +import {Plurable, pluralizeIfNeeded} from '@coveo/cli-commons/src/utils/string'; import { PrintableError, SeverityLevel, -} from '@coveo/cli-commons/lib/errors/printableError'; -import {CLIBaseError} from '@coveo/cli-commons/lib/errors/cliBaseError'; +} from '@coveo/cli-commons/src/errors/printableError'; +import {CLIBaseError} from '@coveo/cli-commons/src/errors/cliBaseError'; export class InvalidVaultEntryError extends PrintableError { public name = 'Invalid Vault Entries'; diff --git a/packages/cli/core/src/lib/flags/platformCommonFlags.ts b/packages/cli/core/src/lib/flags/platformCommonFlags.ts index d3b46bed8e..bb8c8cfd96 100644 --- a/packages/cli/core/src/lib/flags/platformCommonFlags.ts +++ b/packages/cli/core/src/lib/flags/platformCommonFlags.ts @@ -4,7 +4,7 @@ import { DEFAULT_ENVIRONMENT, DEFAULT_REGION, PlatformEnvironment, -} from '@coveo/cli-commons/lib/platform/environment'; +} from '@coveo/cli-commons/src/platform/environment'; export const withRegion = (withDefault = true) => ({ region: Flags.string({ diff --git a/packages/cli/core/src/lib/oauth/authorizationError.ts b/packages/cli/core/src/lib/oauth/authorizationError.ts index 549c818ab4..70caf2167e 100644 --- a/packages/cli/core/src/lib/oauth/authorizationError.ts +++ b/packages/cli/core/src/lib/oauth/authorizationError.ts @@ -1,6 +1,6 @@ import dedent from 'ts-dedent'; import type {URL} from 'url'; -import {CLIBaseError} from '@coveo/cli-commons/lib/errors/cliBaseError'; +import {CLIBaseError} from '@coveo/cli-commons/src/errors/cliBaseError'; export class AuthorizationError extends CLIBaseError { public name = 'Authorization Error'; diff --git a/packages/cli/core/src/lib/oauth/oauth.spec.ts b/packages/cli/core/src/lib/oauth/oauth.spec.ts index d7c9ef512e..af1e321fce 100644 --- a/packages/cli/core/src/lib/oauth/oauth.spec.ts +++ b/packages/cli/core/src/lib/oauth/oauth.spec.ts @@ -5,7 +5,7 @@ import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; import { PlatformEnvironment, platformUrl, -} from '@coveo/cli-commons/lib/platform/environment'; +} from '@coveo/cli-commons/src/platform/environment'; import {OAuth} from './oauth'; import {OAuthClientServer} from './oauthClientServer'; import open from 'open'; diff --git a/packages/cli/core/src/lib/oauth/oauth.ts b/packages/cli/core/src/lib/oauth/oauth.ts index 9c572aca9f..9c4a877514 100644 --- a/packages/cli/core/src/lib/oauth/oauth.ts +++ b/packages/cli/core/src/lib/oauth/oauth.ts @@ -4,7 +4,7 @@ import { DEFAULT_REGION, PlatformEnvironment, platformUrl, -} from '@coveo/cli-commons/lib/platform/environment'; +} from '@coveo/cli-commons/src/platform/environment'; import {Region} from '@coveord/platform-client'; import {randomBytes} from 'crypto'; import {AuthorizationServiceConfiguration, ClientConfig} from './oauthConfig'; diff --git a/packages/cli/core/src/lib/oauth/oauthClientServer.spec.ts b/packages/cli/core/src/lib/oauth/oauthClientServer.spec.ts index c46436812b..b1eb3dcc2d 100644 --- a/packages/cli/core/src/lib/oauth/oauthClientServer.spec.ts +++ b/packages/cli/core/src/lib/oauth/oauthClientServer.spec.ts @@ -15,7 +15,7 @@ import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; import { PlatformEnvironment, platformUrl, -} from '@coveo/cli-commons/lib/platform/environment'; +} from '@coveo/cli-commons/src/platform/environment'; import {InvalidStateError} from './authorizationError'; import {OAuthClientServer} from './oauthClientServer'; import {AuthorizationServiceConfiguration, ClientConfig} from './oauthConfig'; diff --git a/packages/cli/core/src/lib/snapshot/pullModel/validation/errors.ts b/packages/cli/core/src/lib/snapshot/pullModel/validation/errors.ts index 0ed5bb8352..f3b827f240 100644 --- a/packages/cli/core/src/lib/snapshot/pullModel/validation/errors.ts +++ b/packages/cli/core/src/lib/snapshot/pullModel/validation/errors.ts @@ -1,5 +1,5 @@ import {ValidationError} from 'jsonschema'; -import {CLIBaseError} from '@coveo/cli-commons/lib/errors/cliBaseError'; +import {CLIBaseError} from '@coveo/cli-commons/src/errors/cliBaseError'; abstract class BaseSPMError extends CLIBaseError { public name = 'Snapshot Pull Model Error'; diff --git a/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts b/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts index dce5947d79..a925db27f6 100644 --- a/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts +++ b/packages/cli/core/src/lib/snapshot/reportPreviewer/reportPreviewer.ts @@ -11,7 +11,7 @@ import { import dedent from 'ts-dedent'; import {recordable} from '../../utils/record'; import type {ResourceSnapshotType} from '@coveord/platform-client'; -import {Plurable, pluralizeIfNeeded} from '../../utils/string'; +import {Plurable, pluralizeIfNeeded} from '@coveo/cli-commons/src/utils/string'; import {labels} from '../snapshotConstant'; export class ReportViewer { diff --git a/packages/cli/core/src/lib/snapshot/snapshot.spec.ts b/packages/cli/core/src/lib/snapshot/snapshot.spec.ts index 76436d3624..ee957cb85e 100644 --- a/packages/cli/core/src/lib/snapshot/snapshot.spec.ts +++ b/packages/cli/core/src/lib/snapshot/snapshot.spec.ts @@ -15,7 +15,7 @@ import { import {Snapshot} from './snapshot'; //#region Mocks -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('fs-extra'); jest.mock('async-retry'); jest.mock('./snapshotReporter'); @@ -23,7 +23,7 @@ jest.mock('./reportPreviewer/reportPreviewer'); jest.mock('../project/project'); jest.mock('./expandedPreviewer/expandedPreviewer'); -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {ensureFileSync, writeJSONSync} from 'fs-extra'; import retry from 'async-retry'; import {SnapshotReporter} from './snapshotReporter'; diff --git a/packages/cli/core/src/lib/snapshot/snapshotCommon.ts b/packages/cli/core/src/lib/snapshot/snapshotCommon.ts index d7c102f17b..308e7a4cf6 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotCommon.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotCommon.ts @@ -4,9 +4,9 @@ import {SnapshotFactory} from './snapshotFactory'; import {Snapshot, WaitUntilDoneOptions} from './snapshot'; import {red, green} from 'chalk'; import {normalize} from 'path'; -import {Config, Configuration} from '@coveo/cli-commons/lib/config/config'; +import {Config, Configuration} from '@coveo/cli-commons/src/config/config'; import {SnapshotGenericError} from '../errors/snapshotErrors'; -import {PrintableError} from '@coveo/cli-commons/lib/errors/printableError'; +import {PrintableError} from '@coveo/cli-commons/src/errors/printableError'; import {SnapshotReporter} from './snapshotReporter'; import {SnapshotReportStatus} from './reportPreviewer/reportPreviewerDataModels'; import { diff --git a/packages/cli/core/src/lib/snapshot/snapshotFactory.spec.ts b/packages/cli/core/src/lib/snapshot/snapshotFactory.spec.ts index e341661cd8..e149dd004f 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotFactory.spec.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotFactory.spec.ts @@ -1,4 +1,4 @@ -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('fs'); jest.mock('./snapshot'); @@ -6,7 +6,7 @@ import {ResourceSnapshotType} from '@coveord/platform-client'; import {readFileSync} from 'fs'; import {join} from 'path'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {SnapshotPullModelResources} from './pullModel/interfaces'; import {Snapshot} from './snapshot'; import {SnapshotFactory} from './snapshotFactory'; diff --git a/packages/cli/core/src/lib/snapshot/snapshotFactory.ts b/packages/cli/core/src/lib/snapshot/snapshotFactory.ts index 476c7004e9..ec48ba19f8 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotFactory.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotFactory.ts @@ -4,7 +4,7 @@ import { ResourceSnapshotSupportedFileTypes, } from '@coveord/platform-client'; import {readFileSync} from 'fs'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {SnapshotPullModelResources} from './pullModel/interfaces'; import {Snapshot, WaitUntilDoneOptions} from './snapshot'; diff --git a/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.spec.ts b/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.spec.ts index 6cdfc2764f..09a4247d98 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.spec.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.spec.ts @@ -1,15 +1,15 @@ -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); import {Region, ResourceSnapshotsReportType} from '@coveord/platform-client'; import {getDummySnapshotModel} from '../../__stub__/resourceSnapshotsModel'; import {getSuccessReport} from '../../__stub__/resourceSnapshotsReportModel'; -import {Configuration} from '@coveo/cli-commons/lib/config/config'; +import {Configuration} from '@coveo/cli-commons/src/config/config'; import {Snapshot} from './snapshot'; import {SnapshotUrlBuilder} from './snapshotUrlBuilder'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {PlatformEnvironment} from '@coveo/cli-commons/lib/platform/environment'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {PlatformEnvironment} from '@coveo/cli-commons/src/platform/environment'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {CurrentSchemaVersion} from '@coveo/cli-commons/lib/config/configSchemaVersion'; +import {CurrentSchemaVersion} from '@coveo/cli-commons/src/config/configSchemaVersion'; const createSnapshot = async () => { const snapshotID = 'my-snapshot'; diff --git a/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.ts b/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.ts index fdad90323c..796208d664 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotUrlBuilder.ts @@ -1,7 +1,7 @@ -import {Configuration} from '@coveo/cli-commons/lib/config/config'; +import {Configuration} from '@coveo/cli-commons/src/config/config'; import {Snapshot} from './snapshot'; -import {snapshotApplyUrl} from '@coveo/cli-commons/lib/platform/url'; -import {PlatformUrlOptions} from '@coveo/cli-commons/lib/platform/environment'; +import {snapshotApplyUrl} from '@coveo/cli-commons/src/platform/url'; +import {PlatformUrlOptions} from '@coveo/cli-commons/src/platform/environment'; export class SnapshotUrlBuilder { public constructor(private config: Configuration) {} diff --git a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/interfaces.ts b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/interfaces.ts index f4b38166bc..b330a39009 100644 --- a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/interfaces.ts +++ b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/interfaces.ts @@ -1,4 +1,4 @@ -import type {Configuration} from '@coveo/cli-commons/lib/config/config'; +import type {Configuration} from '@coveo/cli-commons/src/config/config'; import type {Snapshot} from '../snapshot'; import type {SnapshotReporter} from '../snapshotReporter'; 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 29bde2613c..e825618089 100644 --- a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.spec.ts +++ b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.spec.ts @@ -1,4 +1,4 @@ -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('../../project/project'); jest.mock('../snapshot'); jest.mock('../snapshotReporter'); @@ -9,9 +9,9 @@ jest.mock('../../errors/vaultErrors'); import PlatformClient, {VaultFetchStrategy} from '@coveord/platform-client'; import {confirm} from '@oclif/core/lib/cli-ux/prompt'; import {warn} from '@oclif/core/lib/errors/index'; -import {Configuration} from '@coveo/cli-commons/lib/config/config'; +import {Configuration} from '@coveo/cli-commons/src/config/config'; import {SnapshotMissingVaultEntriesFromOriginError} from '../../errors/vaultErrors'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {Project} from '../../project/project'; import {Snapshot} from '../snapshot'; import {SnapshotReporter} from '../snapshotReporter'; diff --git a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts index 063ca031d4..93a4a48976 100644 --- a/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts +++ b/packages/cli/core/src/lib/snapshot/vaultEntriesFunctions/transferFromOrganization.ts @@ -3,7 +3,7 @@ import {CliUx} from '@oclif/core'; import {bold, green, red} from 'chalk'; import dedent from 'ts-dedent'; import {SnapshotMissingVaultEntriesFromOriginError} from '../../errors/vaultErrors'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {Project} from '../../project/project'; import type {VaultEntryAttributes} from '../snapshotReporter'; import type {VaultTransferFunctionsParam} from './interfaces'; diff --git a/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts b/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts index c6e7a060bf..3ddf11385f 100644 --- a/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts +++ b/packages/cli/core/src/lib/snapshot/vaultHandler.spec.ts @@ -1,11 +1,11 @@ jest.mock('open'); jest.mock('fs-extra'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); import {ResourceSnapshotType} from '@coveord/platform-client'; import {VaultEntryAttributes} from './snapshotReporter'; import {VaultHandler} from './vaultHandler'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {readJsonSync, rmSync, writeJsonSync} from 'fs-extra'; import open from 'open'; import {CliUx} from '@oclif/core'; diff --git a/packages/cli/core/src/lib/snapshot/vaultHandler.ts b/packages/cli/core/src/lib/snapshot/vaultHandler.ts index df08e5e421..6cd6f34886 100644 --- a/packages/cli/core/src/lib/snapshot/vaultHandler.ts +++ b/packages/cli/core/src/lib/snapshot/vaultHandler.ts @@ -14,10 +14,10 @@ import { InvalidVaultFileError, MissingVaultEntryValueError, } from '../errors/vaultErrors'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {Snapshot} from './snapshot'; import {VaultEntryAttributes} from './snapshotReporter'; -import {Plurable, pluralizeIfNeeded} from '../utils/string'; +import {Plurable, pluralizeIfNeeded} from '@coveo/cli-commons/src/utils/string'; import {ProcessAbort} from '../../lib/errors/processError'; import dedent from 'ts-dedent'; diff --git a/packages/cli/core/src/lib/utils/cli.spec.ts b/packages/cli/core/src/lib/utils/cli.spec.ts index 73b4e23d5b..b0cbed2c31 100644 --- a/packages/cli/core/src/lib/utils/cli.spec.ts +++ b/packages/cli/core/src/lib/utils/cli.spec.ts @@ -1,9 +1,9 @@ -jest.mock('../../hooks/analytics/analytics'); -jest.mock('@coveo/cli-commons/lib/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); import {Interfaces, CliUx} from '@oclif/core'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; import {confirmWithAnalytics} from './cli'; const mockedGlobalConfig = jest.mocked(globalConfig); diff --git a/packages/cli/core/src/lib/utils/cli.ts b/packages/cli/core/src/lib/utils/cli.ts index 8a29a844ab..a068cc7472 100644 --- a/packages/cli/core/src/lib/utils/cli.ts +++ b/packages/cli/core/src/lib/utils/cli.ts @@ -1,6 +1,7 @@ import {CliUx} from '@oclif/core'; -import {buildEvent} from '../../hooks/analytics/eventUtils'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; + +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; +import {buildEvent} from '@coveo/cli-commons/src/analytics/eventUtils'; /** * diff --git a/packages/cli/core/tsconfig.json b/packages/cli/core/tsconfig.json index ba46d5e9a9..548301abf4 100644 --- a/packages/cli/core/tsconfig.json +++ b/packages/cli/core/tsconfig.json @@ -5,5 +5,6 @@ "rootDir": "src", "types": ["node", "jest"] }, - "include": ["src/**/*", "src/typings/**/*.d.ts"] + "include": ["src/**/*", "src/typings/**/*.d.ts"], + "exclude": ["**/*.spec.ts"] } diff --git a/packages/cli/source/.eslintignore b/packages/cli/source/.eslintignore new file mode 100644 index 0000000000..9b1c8b133c --- /dev/null +++ b/packages/cli/source/.eslintignore @@ -0,0 +1 @@ +/dist diff --git a/packages/cli/source/.eslintrc.js b/packages/cli/source/.eslintrc.js new file mode 100644 index 0000000000..14097a40a5 --- /dev/null +++ b/packages/cli/source/.eslintrc.js @@ -0,0 +1,5 @@ +const base = require('@coveo/cli-commons-dev/.eslintrc'); + +module.exports = { + ...base, +}; diff --git a/packages/cli/source/.gitignore b/packages/cli/source/.gitignore new file mode 100644 index 0000000000..0b62686bc8 --- /dev/null +++ b/packages/cli/source/.gitignore @@ -0,0 +1,15 @@ +*-debug.log +*-error.log +/.nyc_output +/dist +/lib +/package-lock.json +/tmp +/yarn.lock +node_modules +oclif.manifest.json +src/**/*.js +src/**/*.js.map +src/**/*.d.ts +src/coverage +the_config_dir \ No newline at end of file diff --git a/packages/cli/source/.prettierrc.js b/packages/cli/source/.prettierrc.js new file mode 100644 index 0000000000..348c706ccc --- /dev/null +++ b/packages/cli/source/.prettierrc.js @@ -0,0 +1,5 @@ +const base = require('@coveo/cli-commons-dev/.prettierrc'); + +module.exports = { + ...base, +}; diff --git a/packages/cli/source/LICENSE b/packages/cli/source/LICENSE new file mode 100644 index 0000000000..0748d4e6c7 --- /dev/null +++ b/packages/cli/source/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 COVEO + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/cli/source/bin/dev b/packages/cli/source/bin/dev new file mode 100644 index 0000000000..bbc3f51d59 --- /dev/null +++ b/packages/cli/source/bin/dev @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +const oclif = require('@oclif/core') + +const path = require('path') +const project = path.join(__dirname, '..', 'tsconfig.json') + +// In dev mode -> use ts-node and dev plugins +process.env.NODE_ENV = 'development' + +require('ts-node').register({project}) + +// In dev mode, always show stack traces +oclif.settings.debug = true; + +// Start the CLI +oclif.run().then(oclif.flush).catch(oclif.Errors.handle) diff --git a/packages/cli/source/bin/dev.cmd b/packages/cli/source/bin/dev.cmd new file mode 100644 index 0000000000..077b57ae75 --- /dev/null +++ b/packages/cli/source/bin/dev.cmd @@ -0,0 +1,3 @@ +@echo off + +node "%~dp0\dev" %* \ No newline at end of file diff --git a/packages/cli/source/bin/run b/packages/cli/source/bin/run new file mode 100755 index 0000000000..a7635de86e --- /dev/null +++ b/packages/cli/source/bin/run @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +const oclif = require('@oclif/core') + +oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle')) diff --git a/packages/cli/source/bin/run.cmd b/packages/cli/source/bin/run.cmd new file mode 100644 index 0000000000..968fc30758 --- /dev/null +++ b/packages/cli/source/bin/run.cmd @@ -0,0 +1,3 @@ +@echo off + +node "%~dp0\run" %* diff --git a/packages/cli/source/jest.config.js b/packages/cli/source/jest.config.js new file mode 100644 index 0000000000..3c0385752b --- /dev/null +++ b/packages/cli/source/jest.config.js @@ -0,0 +1,17 @@ +const {defaults} = require('jest-config'); + +module.exports = { + rootDir: 'src/', + preset: 'ts-jest', + testEnvironment: 'node', + verbose: true, + collectCoverage: true, + coveragePathIgnorePatterns: [ + ...defaults.coveragePathIgnorePatterns, + '/__test__/', + '/__stub__/', + ], + clearMocks: true, + testTimeout: 60e3, + testMatch: ['**/?(*.)+(spec|test).?(it.)[jt]s?(x)'], +}; diff --git a/packages/cli/source/package.json b/packages/cli/source/package.json new file mode 100644 index 0000000000..7aca405f82 --- /dev/null +++ b/packages/cli/source/package.json @@ -0,0 +1,84 @@ +{ + "name": "@coveo/cli-plugin-source", + "version": "1.34.3", + "description": "Manage Coveo Sources with the Coveo CLI", + "author": "Coveo", + "bin": { + "coveo": "./bin/run" + }, + "homepage": "https://github.com/coveo/cli", + "license": "Apache-2.0", + "main": "dist/index.js", + "repository": "coveo/cli", + "files": [ + "/bin", + "/lib", + "/npm-shrinkwrap.json", + "/oclif.manifest.json" + ], + "dependencies": { + "@coveo/cli-commons": "1.34.3", + "@coveo/push-api-client": "2.5.8", + "@coveord/platform-client": "34.7.0", + "@oclif/core": "1.14.2", + "@oclif/plugin-help": "5.1.12", + "@oclif/plugin-plugins": "2.1.0", + "chalk": "4.1.2", + "jsonschema": "1.4.1", + "ts-dedent": "2.2.0" + }, + "devDependencies": { + "@coveo/cli-commons-dev": "1.34.3", + "@oclif/test": "2.1.1", + "@types/jest": "27.5.2", + "@types/node": "16.11.53", + "eslint": "8.22.0", + "jest": "27.5.1", + "oclif": "3.1.2", + "stdout-stderr": "^0.1.13", + "strip-ansi": "6.0.1", + "ts-jest": "27.1.5", + "ts-node": "10.9.1", + "tslib": "2.4.0", + "typescript": "4.7.4" + }, + "oclif": { + "bin": "coveo", + "dirname": "coveo", + "repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/cli/source/<%- commandPath %>", + "description": "Coveo CLI - Source Plugin", + "commands": "./lib/commands", + "plugins": [ + "@oclif/plugin-help", + "@oclif/plugin-plugins" + ], + "topicSeparator": ":", + "topics": { + "source": { + "description": "manage Coveo sources" + }, + "source:push": { + "description": "manage Coveo Push API sources" + }, + "source:catalog": { + "description": "manage Coveo Catalog sources" + } + } + }, + "scripts": { + "build": "tsc -p tsconfig.json", + "test": "jest --colors", + "lint": "prettier --config .prettierrc.js --check . && eslint .", + "release:phase2": "node --experimental-specifier-resolution=node ../../../scripts/releaseV2/phase2-bump-all-packages.mjs", + "postpack": "rimraf oclif.manifest.json", + "prepublishOnly": "rimraf lib && npm run build && oclif manifest && oclif readme" + }, + "engines": { + "node": ">=14.15.1 <18" + }, + "bugs": "https://github.com/coveo/cli/issues", + "keywords": [ + "oclif" + ], + "types": "lib/index.d.ts" +} diff --git a/packages/cli/source/project.json b/packages/cli/source/project.json new file mode 100644 index 0000000000..221b78546a --- /dev/null +++ b/packages/cli/source/project.json @@ -0,0 +1,5 @@ +{ + "root": "packages/cli/source", + "sourceRoot": "packages/cli/source/src", + "projectType": "application" +} diff --git a/packages/cli/core/src/commands/source/catalog/add.spec.ts b/packages/cli/source/src/commands/source/catalog/add.spec.ts similarity index 89% rename from packages/cli/core/src/commands/source/catalog/add.spec.ts rename to packages/cli/source/src/commands/source/catalog/add.spec.ts index f962909c46..15bc29661c 100644 --- a/packages/cli/core/src/commands/source/catalog/add.spec.ts +++ b/packages/cli/source/src/commands/source/catalog/add.spec.ts @@ -1,22 +1,26 @@ -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/analytics/amplitudeClient'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); -jest.mock('@coveo/cli-commons/lib/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); jest.mock('@coveo/push-api-client'); import stripAnsi from 'strip-ansi'; import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {CatalogSource, DocumentBuilder} from '@coveo/push-api-client'; import {cwd} from 'process'; import {join} from 'path'; -import {APIError} from '../../../lib/errors/APIError'; +import {APIError} from '@coveo/cli-commons/src/errors/apiError'; import {Interfaces} from '@oclif/core'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; +import {Config} from '@coveo/cli-commons/src/config/config'; + import { BatchUploadDocumentsError, BatchUploadDocumentsSuccess, -} from '../../../__stub__/batchUploadDocumentsFromFilesReturn'; +} from '../../../lib/testsUtils/batchUploadDocumentsFromFilesReturn'; const mockedGlobalConfig = jest.mocked(globalConfig); const mockedClient = jest.mocked(AuthenticatedClient); const mockedSource = jest.mocked(CatalogSource); @@ -27,6 +31,8 @@ const mockSourceGet = jest.fn(); const mockSetSourceStatus = jest.fn(); const mockBatchUpdate = jest.fn(); const mockBatchStream = jest.fn(); +const mockedConfigGet = jest.fn(); +const mockedConfig = jest.mocked(Config, true); describe('source:catalog:add', () => { const pathToStub = join(cwd(), 'src', '__stub__'); @@ -87,13 +93,12 @@ describe('source:catalog:add', () => { }, }), cfg: { - get: () => - Promise.resolve({ - accessToken: 'the_token', - organization: 'the_org', - region: 'au', - environment: 'prod', - }), + get: () => ({ + accessToken: 'the_token', + organization: 'the_org', + region: 'au', + environment: 'prod', + }), }, } as unknown as AuthenticatedClient) ); @@ -110,14 +115,31 @@ describe('source:catalog:add', () => { ); }; + const doMockConfig = () => { + mockedGlobalConfig.get.mockReturnValue({ + configDir: 'the_config_dir', + version: '1.2.3', + platform: 'darwin', + } as Interfaces.Config); + mockedConfigGet.mockReturnValue({ + region: 'us', + organization: 'default-org', + environment: 'prod', + }); + + mockedConfig.mockImplementation( + () => + ({ + get: mockedConfigGet, + } as unknown as Config) + ); + }; + beforeAll(() => { + doMockConfig(); doMockDocumentBuilder(); doMockAuthenticatedClient(); doMockSource(); - - mockedGlobalConfig.get.mockReturnValue({ - configDir: 'the_config_dir', - } as Interfaces.Config); }); beforeEach(() => { diff --git a/packages/cli/core/src/commands/source/catalog/add.ts b/packages/cli/source/src/commands/source/catalog/add.ts similarity index 89% rename from packages/cli/core/src/commands/source/catalog/add.ts rename to packages/cli/source/src/commands/source/catalog/add.ts index 8a6ce19859..5d4349e401 100644 --- a/packages/cli/core/src/commands/source/catalog/add.ts +++ b/packages/cli/source/src/commands/source/catalog/add.ts @@ -4,30 +4,29 @@ import { BuiltInTransformers, } from '@coveo/push-api-client'; import {Command, Flags, CliUx} from '@oclif/core'; -import {green, red} from 'chalk'; +import {green, red, bold} from 'chalk'; import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import { readOrganizationPrivilege, writeFieldsPrivilege, writeSourceContentPrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import { withFiles, withCreateMissingFields, withMaxConcurrent, withNormalizeInvalidFields, -} from '../../../lib/flags/sourceCommonFlags'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {errorMessage, successMessage} from '../../../lib/push/userFeedback'; -import {getFileNames} from '../../../lib/utils/file'; -import {bold} from 'chalk'; +} from '../../../lib/commonFlags'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {errorMessage, successMessage} from '../../../lib/userFeedback'; +import {getFileNames} from '../../../lib/getFileNames'; import dedent from 'ts-dedent'; -import {formatErrorMessage} from '../../../lib/push/addCommon'; +import {formatErrorMessage} from '../../../lib/addCommon'; const fullUploadDescription = `Controls the way your items are added to your catalog source. @@ -96,7 +95,7 @@ export default class SourceCatalogAdd extends Command { CliUx.ux.action.start('Processing files'); const {accessToken, organization, environment, region} = - await new AuthenticatedClient().cfg.get(); + new AuthenticatedClient().cfg.get(); const source = new CatalogSource(accessToken!, organization, { environment, region, diff --git a/packages/cli/core/src/commands/source/catalog/new.spec.ts b/packages/cli/source/src/commands/source/catalog/new.spec.ts similarity index 79% rename from packages/cli/core/src/commands/source/catalog/new.spec.ts rename to packages/cli/source/src/commands/source/catalog/new.spec.ts index a2c488b99b..1fd06d0338 100644 --- a/packages/cli/core/src/commands/source/catalog/new.spec.ts +++ b/packages/cli/source/src/commands/source/catalog/new.spec.ts @@ -1,13 +1,17 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {SourceType, SourceVisibility} from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; +import type {Interfaces} from '@oclif/core'; +const mockedGlobalConfig = jest.mocked(globalConfig); const mockedConfig = jest.mocked(Config); const mockedConfigGet = jest.fn(); const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); @@ -38,13 +42,23 @@ const doMockAuthenticatedClient = () => { }; const doMockConfig = () => { + mockedGlobalConfig.get.mockReturnValue({ + configDir: 'the_config_dir', + version: '1.2.3', + platform: 'darwin', + } as Interfaces.Config); mockedConfigGet.mockReturnValue({ region: 'us', organization: 'default-org', environment: 'prod', }); - mockedConfig.prototype.get = mockedConfigGet; + mockedConfig.mockImplementation( + () => + ({ + get: mockedConfigGet, + } as unknown as Config) + ); }; describe('source:catalog:new', () => { diff --git a/packages/cli/core/src/commands/source/catalog/new.ts b/packages/cli/source/src/commands/source/catalog/new.ts similarity index 73% rename from packages/cli/core/src/commands/source/catalog/new.ts rename to packages/cli/source/src/commands/source/catalog/new.ts index 68cab2919e..8e1e419ba3 100644 --- a/packages/cli/core/src/commands/source/catalog/new.ts +++ b/packages/cli/source/src/commands/source/catalog/new.ts @@ -6,13 +6,13 @@ import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {writeSourceContentPrivilege} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; -import {withSourceVisibility} from '../../../lib/flags/sourceCommonFlags'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +} from '@coveo/cli-commons/src/preconditions'; +import {writeSourceContentPrivilege} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {withSourceVisibility} from '../../../lib/commonFlags'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; -export default class SourceCataloghNew extends Command { +export default class SourceCatalogNew extends Command { public static description = 'Create a new catalog source in a Coveo organization'; @@ -34,7 +34,7 @@ export default class SourceCataloghNew extends Command { HasNecessaryCoveoPrivileges(writeSourceContentPrivilege) ) public async run() { - const {flags, args} = await this.parse(SourceCataloghNew); + const {flags, args} = await this.parse(SourceCatalogNew); const authenticatedClient = new AuthenticatedClient(); const platformClient = await authenticatedClient.getClient(); diff --git a/packages/cli/core/src/commands/source/push/list.spec.ts b/packages/cli/source/src/commands/source/list.spec.ts similarity index 90% rename from packages/cli/core/src/commands/source/push/list.spec.ts rename to packages/cli/source/src/commands/source/list.spec.ts index e94db6d2cc..c661e3b3df 100644 --- a/packages/cli/core/src/commands/source/push/list.spec.ts +++ b/packages/cli/source/src/commands/source/list.spec.ts @@ -1,11 +1,11 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/analytics/amplitudeClient'); +jest.mock('@coveo/cli-commons/src/config/config'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('@coveord/platform-client'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { SourceModel, SourceStatusType, diff --git a/packages/cli/core/src/commands/source/list.ts b/packages/cli/source/src/commands/source/list.ts similarity index 88% rename from packages/cli/core/src/commands/source/list.ts rename to packages/cli/source/src/commands/source/list.ts index e41930caf7..f0edeb3626 100644 --- a/packages/cli/core/src/commands/source/list.ts +++ b/packages/cli/source/src/commands/source/list.ts @@ -3,10 +3,10 @@ import {Command, CliUx} from '@oclif/core'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +} from '@coveo/cli-commons/src/preconditions'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import dedent from 'ts-dedent'; -import {Trackable} from '../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class SourceList extends Command { public static description = @@ -21,7 +21,7 @@ export default class SourceList extends Command { public async run() { const {flags} = await this.parse(SourceList); const authenticatedClient = new AuthenticatedClient(); - const org = (await authenticatedClient.cfg.get()).organization; + const org = authenticatedClient.cfg.get().organization; const platformClient = await authenticatedClient.getClient(); const sources = await platformClient.source.list({ diff --git a/packages/cli/core/src/commands/source/push/add.spec.ts b/packages/cli/source/src/commands/source/push/add.spec.ts similarity index 93% rename from packages/cli/core/src/commands/source/push/add.spec.ts rename to packages/cli/source/src/commands/source/push/add.spec.ts index 56b71c0240..c8be585379 100644 --- a/packages/cli/core/src/commands/source/push/add.spec.ts +++ b/packages/cli/source/src/commands/source/push/add.spec.ts @@ -1,22 +1,22 @@ -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); -jest.mock('@coveo/cli-commons/lib/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); jest.mock('@coveo/push-api-client'); import stripAnsi from 'strip-ansi'; import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {DocumentBuilder, PushSource} from '@coveo/push-api-client'; import {cwd} from 'process'; import {join} from 'path'; -import {APIError} from '../../../lib/errors/APIError'; -import globalConfig from '@coveo/cli-commons/lib/config/globalConfig'; +import {APIError} from '@coveo/cli-commons/src/errors/apiError'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; import {Interfaces} from '@oclif/core'; import { BatchUploadDocumentsError, BatchUploadDocumentsSuccess, -} from '../../../__stub__/batchUploadDocumentsFromFilesReturn'; +} from '../../../lib/testsUtils/batchUploadDocumentsFromFilesReturn'; const mockedGlobalConfig = jest.mocked(globalConfig); const mockedClient = jest.mocked(AuthenticatedClient); const mockedSource = jest.mocked(PushSource); @@ -87,13 +87,12 @@ describe('source:push:add', () => { }, }), cfg: { - get: () => - Promise.resolve({ - accessToken: 'the_token', - organization: 'the_org', - region: 'au', - environment: 'prod', - }), + get: () => ({ + accessToken: 'the_token', + organization: 'the_org', + region: 'au', + environment: 'prod', + }), }, } as unknown as AuthenticatedClient) ); diff --git a/packages/cli/core/src/commands/source/push/add.ts b/packages/cli/source/src/commands/source/push/add.ts similarity index 88% rename from packages/cli/core/src/commands/source/push/add.ts rename to packages/cli/source/src/commands/source/push/add.ts index 2f82a1356a..7513955afd 100644 --- a/packages/cli/core/src/commands/source/push/add.ts +++ b/packages/cli/source/src/commands/source/push/add.ts @@ -10,23 +10,23 @@ import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import { readOrganizationPrivilege, writeFieldsPrivilege, writeSourceContentPrivilege, -} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import { withNormalizeInvalidFields, withCreateMissingFields, withFiles, withMaxConcurrent, -} from '../../../lib/flags/sourceCommonFlags'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; -import {formatErrorMessage} from '../../../lib/push/addCommon'; -import {errorMessage, successMessage} from '../../../lib/push/userFeedback'; -import {getFileNames} from '../../../lib/utils/file'; +} from '../../../lib/commonFlags'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; +import {formatErrorMessage} from '../../../lib/addCommon'; +import {errorMessage, successMessage} from '../../../lib/userFeedback'; +import {getFileNames} from '../../../lib/getFileNames'; export default class SourcePushAdd extends Command { public static description = @@ -112,7 +112,7 @@ export default class SourcePushAdd extends Command { public async getSource() { const {accessToken, organization, environment, region} = - await new AuthenticatedClient().cfg.get(); + new AuthenticatedClient().cfg.get(); return new PushSource(accessToken!, organization, { environment, region, diff --git a/packages/cli/core/src/commands/source/push/delete.spec.ts b/packages/cli/source/src/commands/source/push/delete.spec.ts similarity index 96% rename from packages/cli/core/src/commands/source/push/delete.spec.ts rename to packages/cli/source/src/commands/source/push/delete.spec.ts index abec21e84d..aafefcebe1 100644 --- a/packages/cli/core/src/commands/source/push/delete.spec.ts +++ b/packages/cli/source/src/commands/source/push/delete.spec.ts @@ -1,16 +1,16 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('@coveo/push-api-client'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {PushSource} from '@coveo/push-api-client'; import { doMockAxiosError, doMockAxiosSuccess, -} from '../../../lib/push/testUtils'; +} from '../../../lib/testsUtils/axiosMocks'; const mockedClient = jest.mocked(AuthenticatedClient); const mockedSource = jest.mocked(PushSource); diff --git a/packages/cli/core/src/commands/source/push/delete.ts b/packages/cli/source/src/commands/source/push/delete.ts similarity index 95% rename from packages/cli/core/src/commands/source/push/delete.ts rename to packages/cli/source/src/commands/source/push/delete.ts index 7cced6244b..2260514a74 100644 --- a/packages/cli/core/src/commands/source/push/delete.ts +++ b/packages/cli/source/src/commands/source/push/delete.ts @@ -1,18 +1,18 @@ import {Command, Flags} from '@oclif/core'; import {PushSource} from '@coveo/push-api-client'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; +} from '@coveo/cli-commons/src/preconditions'; import dedent from 'ts-dedent'; import {green, red} from 'chalk'; import { AxiosResponse, errorMessage, successMessage, -} from '../../../lib/push/userFeedback'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +} from '../../../lib/userFeedback'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; export default class SourcePushDelete extends Command { public static description = diff --git a/packages/cli/core/src/commands/source/list.spec.ts b/packages/cli/source/src/commands/source/push/list.spec.ts similarity index 90% rename from packages/cli/core/src/commands/source/list.spec.ts rename to packages/cli/source/src/commands/source/push/list.spec.ts index f784c8de41..18f1edb17b 100644 --- a/packages/cli/core/src/commands/source/list.spec.ts +++ b/packages/cli/source/src/commands/source/push/list.spec.ts @@ -1,11 +1,11 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../hooks/analytics/analytics'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); jest.mock('@coveord/platform-client'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import { SourceModel, SourceStatusType, diff --git a/packages/cli/core/src/commands/source/push/list.ts b/packages/cli/source/src/commands/source/push/list.ts similarity index 91% rename from packages/cli/core/src/commands/source/push/list.ts rename to packages/cli/source/src/commands/source/push/list.ts index 7c84b4bfb7..856eb98210 100644 --- a/packages/cli/core/src/commands/source/push/list.ts +++ b/packages/cli/source/src/commands/source/push/list.ts @@ -3,10 +3,10 @@ import {Command, CliUx} from '@oclif/core'; import { IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +} from '@coveo/cli-commons/src/preconditions'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import dedent from 'ts-dedent'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; import {magenta} from 'chalk'; import SourceList from '../list'; diff --git a/packages/cli/core/src/commands/source/push/new.spec.ts b/packages/cli/source/src/commands/source/push/new.spec.ts similarity index 77% rename from packages/cli/core/src/commands/source/push/new.spec.ts rename to packages/cli/source/src/commands/source/push/new.spec.ts index 3ea69d3734..50649fc168 100644 --- a/packages/cli/core/src/commands/source/push/new.spec.ts +++ b/packages/cli/source/src/commands/source/push/new.spec.ts @@ -1,14 +1,17 @@ -jest.mock('@coveo/cli-commons/lib/config/config'); -jest.mock('../../../hooks/analytics/analytics'); - -jest.mock('@coveo/cli-commons/lib/platform/authenticatedClient'); +jest.mock('@coveo/cli-commons/src/config/config'); +jest.mock('@coveo/cli-commons/src/config/globalConfig'); +jest.mock('@coveo/cli-commons/src/preconditions/trackable'); +jest.mock('@coveo/cli-commons/src/platform/authenticatedClient'); import {test} from '@oclif/test'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; import {SourceVisibility} from '@coveord/platform-client'; -import {Config} from '@coveo/cli-commons/lib/config/config'; +import {Config} from '@coveo/cli-commons/src/config/config'; +import globalConfig from '@coveo/cli-commons/src/config/globalConfig'; +import type {Interfaces} from '@oclif/core'; -const mockedConfig = jest.mocked(Config); +const mockedGlobalConfig = jest.mocked(globalConfig); +const mockedConfig = jest.mocked(Config, true); const mockedConfigGet = jest.fn(); const mockedAuthenticatedClient = jest.mocked(AuthenticatedClient); const mockEvaluate = jest.fn(); @@ -38,13 +41,23 @@ const doMockAuthenticatedClient = () => { }; const doMockConfig = () => { + mockedGlobalConfig.get.mockReturnValue({ + configDir: 'the_config_dir', + version: '1.2.3', + platform: 'darwin', + } as Interfaces.Config); mockedConfigGet.mockReturnValue({ region: 'us', organization: 'default-org', environment: 'prod', }); - mockedConfig.prototype.get = mockedConfigGet; + mockedConfig.mockImplementation( + () => + ({ + get: mockedConfigGet, + } as unknown as Config) + ); }; describe('source:push:new', () => { diff --git a/packages/cli/core/src/commands/source/push/new.ts b/packages/cli/source/src/commands/source/push/new.ts similarity index 79% rename from packages/cli/core/src/commands/source/push/new.ts rename to packages/cli/source/src/commands/source/push/new.ts index 3dbff67e40..6e8400cf0a 100644 --- a/packages/cli/core/src/commands/source/push/new.ts +++ b/packages/cli/source/src/commands/source/push/new.ts @@ -6,11 +6,11 @@ import { HasNecessaryCoveoPrivileges, IsAuthenticated, Preconditions, -} from '@coveo/cli-commons/lib/preconditions'; -import {writeSourceContentPrivilege} from '@coveo/cli-commons/lib/preconditions/platformPrivilege'; -import {Trackable} from '../../../lib/decorators/preconditions/trackable'; -import {withSourceVisibility} from '../../../lib/flags/sourceCommonFlags'; -import {AuthenticatedClient} from '@coveo/cli-commons/lib/platform/authenticatedClient'; +} from '@coveo/cli-commons/src/preconditions'; +import {writeSourceContentPrivilege} from '@coveo/cli-commons/src/preconditions/platformPrivilege'; +import {Trackable} from '@coveo/cli-commons/src/preconditions/trackable'; +import {withSourceVisibility} from '../../../lib/commonFlags'; +import {AuthenticatedClient} from '@coveo/cli-commons/src/platform/authenticatedClient'; export default class SourcePushNew extends Command { public static description = diff --git a/packages/cli/source/src/index.ts b/packages/cli/source/src/index.ts new file mode 100644 index 0000000000..9ea8fd0691 --- /dev/null +++ b/packages/cli/source/src/index.ts @@ -0,0 +1 @@ +export {run} from '@oclif/core'; diff --git a/packages/cli/core/src/lib/push/__snapshots__/addCommon.spec.ts.snap b/packages/cli/source/src/lib/__snapshots__/addCommon.spec.ts.snap similarity index 100% rename from packages/cli/core/src/lib/push/__snapshots__/addCommon.spec.ts.snap rename to packages/cli/source/src/lib/__snapshots__/addCommon.spec.ts.snap diff --git a/packages/cli/core/src/lib/push/addCommon.spec.ts b/packages/cli/source/src/lib/addCommon.spec.ts similarity index 95% rename from packages/cli/core/src/lib/push/addCommon.spec.ts rename to packages/cli/source/src/lib/addCommon.spec.ts index 211e338ebc..6a1b64faeb 100644 --- a/packages/cli/core/src/lib/push/addCommon.spec.ts +++ b/packages/cli/source/src/lib/addCommon.spec.ts @@ -1,7 +1,7 @@ import {stdout} from 'stdout-stderr'; import {BuiltInTransformers, errors} from '@coveo/push-api-client'; import {fancyIt} from '@coveo/cli-commons-dev/lib/testUtils/it'; -import {formatCliLog} from '../../__test__/jestSnapshotUtils'; +import {formatCliLog} from '@coveo/cli-commons-dev/lib/testUtils/jestSnapshotUtils'; import {formatErrorMessage} from './addCommon'; describe('addCommon', () => { diff --git a/packages/cli/core/src/lib/push/addCommon.ts b/packages/cli/source/src/lib/addCommon.ts similarity index 94% rename from packages/cli/core/src/lib/push/addCommon.ts rename to packages/cli/source/src/lib/addCommon.ts index c17f8b66e6..93a0d667bc 100644 --- a/packages/cli/core/src/lib/push/addCommon.ts +++ b/packages/cli/source/src/lib/addCommon.ts @@ -1,11 +1,11 @@ import {CliUx} from '@oclif/core'; import {red, dim, green} from 'chalk'; import {BuiltInTransformers, errors} from '@coveo/push-api-client'; -import {withNormalizeInvalidFields} from '../flags/sourceCommonFlags'; -import {pluralizeIfNeeded} from '../utils/string'; +import {withNormalizeInvalidFields} from './commonFlags'; +import {pluralizeIfNeeded} from '@coveo/cli-commons/src/utils/string'; import dedent from 'ts-dedent'; -const allowedCharRegExp = new RegExp('^[a-z]+[a-z0-9_]*$'); +const allowedCharRegExp = /^[a-z]+[a-z0-9_]*$/; interface PrintableUnsupportedField { original: string; normalized: string; diff --git a/packages/cli/core/src/lib/flags/sourceCommonFlags.ts b/packages/cli/source/src/lib/commonFlags.ts similarity index 100% rename from packages/cli/core/src/lib/flags/sourceCommonFlags.ts rename to packages/cli/source/src/lib/commonFlags.ts diff --git a/packages/cli/core/src/lib/utils/file.ts b/packages/cli/source/src/lib/getFileNames.ts similarity index 100% rename from packages/cli/core/src/lib/utils/file.ts rename to packages/cli/source/src/lib/getFileNames.ts diff --git a/packages/cli/core/src/lib/push/testUtils.ts b/packages/cli/source/src/lib/testsUtils/axiosMocks.ts similarity index 100% rename from packages/cli/core/src/lib/push/testUtils.ts rename to packages/cli/source/src/lib/testsUtils/axiosMocks.ts diff --git a/packages/cli/core/src/__stub__/batchUploadDocumentsFromFilesReturn.ts b/packages/cli/source/src/lib/testsUtils/batchUploadDocumentsFromFilesReturn.ts similarity index 91% rename from packages/cli/core/src/__stub__/batchUploadDocumentsFromFilesReturn.ts rename to packages/cli/source/src/lib/testsUtils/batchUploadDocumentsFromFilesReturn.ts index 0559d91d2e..3f80f2055b 100644 --- a/packages/cli/core/src/__stub__/batchUploadDocumentsFromFilesReturn.ts +++ b/packages/cli/source/src/lib/testsUtils/batchUploadDocumentsFromFilesReturn.ts @@ -1,5 +1,5 @@ import {DocumentBuilder} from '@coveo/push-api-client'; -import {doMockAxiosError, doMockAxiosSuccess} from '../lib/push/testUtils'; +import {doMockAxiosError, doMockAxiosSuccess} from './axiosMocks'; export class BatchUploadDocumentsSuccess { public onBatchUpload(callback: Function) { diff --git a/packages/cli/core/src/lib/push/userFeedback.ts b/packages/cli/source/src/lib/userFeedback.ts similarity index 88% rename from packages/cli/core/src/lib/push/userFeedback.ts rename to packages/cli/source/src/lib/userFeedback.ts index 5c39e2654b..a720f1a625 100644 --- a/packages/cli/core/src/lib/push/userFeedback.ts +++ b/packages/cli/source/src/lib/userFeedback.ts @@ -6,8 +6,8 @@ import { APIError, AxiosErrorFromAPI, AxiosErrorFromAPISchema, -} from '../errors/APIError'; -import {UnknownError} from '../errors/unknownError'; +} from '@coveo/cli-commons/src/errors/apiError'; +import {UnknownError} from '@coveo/cli-commons/src/errors/unknownError'; export interface AxiosResponse { status: number; diff --git a/packages/cli/source/tsconfig.json b/packages/cli/source/tsconfig.json new file mode 100644 index 0000000000..d2435321b6 --- /dev/null +++ b/packages/cli/source/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@coveo/cli-commons-dev/tsconfig.json", + "compilerOptions": { + "outDir": "lib", + "rootDir": "src", + "types": ["node", "jest"] + }, + "include": ["src/**/*"], + "exclude": ["**/*.spec.ts"] +} diff --git a/packages/cra-template/template.json b/packages/cra-template/template.json index 1c65e76ac0..61626cb4b5 100644 --- a/packages/cra-template/template.json +++ b/packages/cra-template/template.json @@ -19,7 +19,7 @@ "@testing-library/react": "12.1.4", "@testing-library/user-event": "^13.5.0", "@types/jest": "27.4.1", - "@types/node": "16.10.3", + "@types/node": "16.11.53", "@types/react": "17.0.43", "@types/react-dom": "17.0.14", "@types/react-router-dom": "5.3.3"