From 0a0b0e3bb0a9281577be0ea4bc1f417ccfc47ab8 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Tue, 12 Mar 2024 17:40:06 -0400 Subject: [PATCH 1/6] hackfix-this-is-not-that-great --- .../expandedPreviewer/expandedPreviewer.ts | 6 ++--- .../core/src/lib/snapshot/snapshotReporter.ts | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts b/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts index 5f77e36420..43b6f9f355 100644 --- a/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts +++ b/packages/cli/core/src/lib/snapshot/expandedPreviewer/expandedPreviewer.ts @@ -15,6 +15,7 @@ import {DotFolder} from '../../project/dotFolder'; import {cwd} from 'process'; import {buildResourcesToExport} from '../pullModel/validation/model'; import {startSpinner, stopSpinner} from '@coveo/cli-commons/utils/ux'; +import {SnapshotReporter} from '../snapshotReporter'; export class ExpandedPreviewer { private static readonly previewDirectoryName = 'preview'; @@ -28,9 +29,8 @@ export class ExpandedPreviewer { private readonly projectToPreview: Project, private readonly shouldDelete: boolean ) { - this.resourcesToPreview = Object.keys( - report.resourceOperationResults - ) as ResourceSnapshotType[]; + const reporter = new SnapshotReporter(report); + this.resourcesToPreview = reporter.getAffectedResourceTypes(); } private static get previewDirectory() { diff --git a/packages/cli/core/src/lib/snapshot/snapshotReporter.ts b/packages/cli/core/src/lib/snapshot/snapshotReporter.ts index 4414edace1..2ada47b21a 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotReporter.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotReporter.ts @@ -67,6 +67,30 @@ export class SnapshotReporter { ) > 0; } + public getAffectedResourceTypes(): ResourceSnapshotType[] { + const isResourceTypeReportAffected = ( + report: ResourceSnapshotsReportOperationModel + ) => { + for (const operation of Object.values(report)) { + if (operation > 0) { + return true; + } + } + return false; + }; + const changedResourcesTypes: ResourceSnapshotType[] = []; + for (const resourceType of Object.keys(this.report.resourceOperations)) { + if ( + isResourceTypeReportAffected( + this.report.resourceOperations[resourceType] + ) + ) { + changedResourcesTypes.push(resourceType as ResourceSnapshotType); + } + } + return changedResourcesTypes; + } + public hasChangedResources() { const totalUnchanges = this.getOperationTypeTotalCount('resourcesUnchanged'); From 93c444dbc7d63027ad884b75e52f9a718770557e Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 14 Mar 2024 13:51:23 -0400 Subject: [PATCH 2/6] snap update --- .../__snapshots__/atomic.specs.ts.snap | 16 ++--- packages/cli/core/src/lib/ui/shared.ts | 59 ++++++++++--------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/packages/cli-e2e/__tests__/__snapshots__/atomic.specs.ts.snap b/packages/cli-e2e/__tests__/__snapshots__/atomic.specs.ts.snap index df1bee79bb..b0cee6f7dd 100644 --- a/packages/cli-e2e/__tests__/__snapshots__/atomic.specs.ts.snap +++ b/packages/cli-e2e/__tests__/__snapshots__/atomic.specs.ts.snap @@ -86,11 +86,11 @@ HashedFolder { HashedFolder { "children": [ HashedFile { - "hash": "61GVF7l8bCVXW00H2rtInTKwoqY=", + "hash": "e5DQ3kRU03Vmp2BC+mjlSypQjKE=", "name": "index.css", }, ], - "hash": "FQZ6fv/Z/8DhwZWuUbrLwgTt6r8=", + "hash": "IMDEBLQ/slaFFRst+lJYHMRm07E=", "name": "style", }, HashedFolder { @@ -104,7 +104,7 @@ HashedFolder { "name": "utils", }, ], - "hash": "pBlrdRw5yuMk/S0mFDAUBGrEvMs=", + "hash": "K9gD9O4uCLlQbxYAgmEW6K+5EAw=", "name": "src", }, HashedFile { @@ -112,7 +112,7 @@ HashedFolder { "name": "tsconfig.json", }, ], - "hash": "MX8XJmhwXYKcItyHsBvb0tWTjlM=", + "hash": "TZXkS/G4E85OYZrwyJxf/QI7lJ8=", "name": "normalizedDir", } `; @@ -329,11 +329,11 @@ HashedFolder { HashedFolder { "children": [ HashedFile { - "hash": "/limo6D9Trxh05AOjVfMeecwXR8=", + "hash": "xbqB+xpmHNlBnQf+PCHR+rT3tfg=", "name": "index.css", }, ], - "hash": "/ARqEzx1ZY/+YdpH3eOpUbZnjj8=", + "hash": "Z+bQXHQFJdpSE56ncUOv3fWRy6w=", "name": "style", }, HashedFolder { @@ -347,7 +347,7 @@ HashedFolder { "name": "utils", }, ], - "hash": "FJTdsvHKymcS4bWGsVDxdv5+xI0=", + "hash": "9IWPASf2gKXfg4rrJ+k4DSwv4c4=", "name": "src", }, HashedFile { @@ -355,7 +355,7 @@ HashedFolder { "name": "tsconfig.json", }, ], - "hash": "fXSss5dlkGuizSP8OXlIF3OvP2Q=", + "hash": "20bLNlmkPR5jmaL2CitCTveWor8=", "name": "normalizedDir", } `; diff --git a/packages/cli/core/src/lib/ui/shared.ts b/packages/cli/core/src/lib/ui/shared.ts index 2c1f29dd1e..725476505d 100644 --- a/packages/cli/core/src/lib/ui/shared.ts +++ b/packages/cli/core/src/lib/ui/shared.ts @@ -1,37 +1,38 @@ -import {confirm, promptChoices, prompt} from '@coveo/cli-commons/utils/ux'; +// import {confirm, promptChoices, prompt} from '@coveo/cli-commons/utils/ux'; import PlatformClient from '@coveo/platform-client'; -import inquirer from 'inquirer'; +// import inquirer from 'inquirer'; -const manuallyEnterSearchHub = () => - prompt('Enter the search hub you want to use', ''); +// const manuallyEnterSearchHub = () => +// prompt('Enter the search hub you want to use', ''); export async function promptForSearchHub(client: PlatformClient) { - const createSearchHub = await confirm( - 'An API key will be created against your organization. We strongly recommends that you associate this API key with a search hub. Would you like to do so now ? (y/n)', - false - ); - if (!createSearchHub) { - return; - } + return ''; + // const createSearchHub = await confirm( + // 'An API key will be created against your organization. We strongly recommends that you associate this API key with a search hub. Would you like to do so now ? (y/n)', + // false + // ); + // if (!createSearchHub) { + // return; + // } - const availableHubs = await client.searchUsageMetrics.searchHubs.list(); - if (availableHubs.hubs.length === 0) { - return await manuallyEnterSearchHub(); - } + // const availableHubs = await client.searchUsageMetrics.searchHubs.list(); + // if (availableHubs.hubs.length === 0) { + // return await manuallyEnterSearchHub(); + // } - const choice = await promptChoices( - 'Use an existing search hub, or create a new one?', - [ - new inquirer.Separator(), - 'Create a new one', - new inquirer.Separator(), - ...availableHubs.hubs.map((hub) => hub.name), - ], - '' - ); + // const choice = await promptChoices( + // 'Use an existing search hub, or create a new one?', + // [ + // new inquirer.Separator(), + // 'Create a new one', + // new inquirer.Separator(), + // ...availableHubs.hubs.map((hub) => hub.name), + // ], + // '' + // ); - if (choice === 'Create a new one') { - return await manuallyEnterSearchHub(); - } - return choice; + // if (choice === 'Create a new one') { + // return await manuallyEnterSearchHub(); + // } + // return choice; } From 4ac0445b8bac0ddc6e43c7223ff6c33ad7918538 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 14 Mar 2024 14:34:43 -0400 Subject: [PATCH 3/6] derpo --- packages/cli/core/src/lib/ui/shared.ts | 59 +++++++++++++------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/packages/cli/core/src/lib/ui/shared.ts b/packages/cli/core/src/lib/ui/shared.ts index 725476505d..2c1f29dd1e 100644 --- a/packages/cli/core/src/lib/ui/shared.ts +++ b/packages/cli/core/src/lib/ui/shared.ts @@ -1,38 +1,37 @@ -// import {confirm, promptChoices, prompt} from '@coveo/cli-commons/utils/ux'; +import {confirm, promptChoices, prompt} from '@coveo/cli-commons/utils/ux'; import PlatformClient from '@coveo/platform-client'; -// import inquirer from 'inquirer'; +import inquirer from 'inquirer'; -// const manuallyEnterSearchHub = () => -// prompt('Enter the search hub you want to use', ''); +const manuallyEnterSearchHub = () => + prompt('Enter the search hub you want to use', ''); export async function promptForSearchHub(client: PlatformClient) { - return ''; - // const createSearchHub = await confirm( - // 'An API key will be created against your organization. We strongly recommends that you associate this API key with a search hub. Would you like to do so now ? (y/n)', - // false - // ); - // if (!createSearchHub) { - // return; - // } + const createSearchHub = await confirm( + 'An API key will be created against your organization. We strongly recommends that you associate this API key with a search hub. Would you like to do so now ? (y/n)', + false + ); + if (!createSearchHub) { + return; + } - // const availableHubs = await client.searchUsageMetrics.searchHubs.list(); - // if (availableHubs.hubs.length === 0) { - // return await manuallyEnterSearchHub(); - // } + const availableHubs = await client.searchUsageMetrics.searchHubs.list(); + if (availableHubs.hubs.length === 0) { + return await manuallyEnterSearchHub(); + } - // const choice = await promptChoices( - // 'Use an existing search hub, or create a new one?', - // [ - // new inquirer.Separator(), - // 'Create a new one', - // new inquirer.Separator(), - // ...availableHubs.hubs.map((hub) => hub.name), - // ], - // '' - // ); + const choice = await promptChoices( + 'Use an existing search hub, or create a new one?', + [ + new inquirer.Separator(), + 'Create a new one', + new inquirer.Separator(), + ...availableHubs.hubs.map((hub) => hub.name), + ], + '' + ); - // if (choice === 'Create a new one') { - // return await manuallyEnterSearchHub(); - // } - // return choice; + if (choice === 'Create a new one') { + return await manuallyEnterSearchHub(); + } + return choice; } From 4c94360dc4a4bb0d8e77c956fbd35623dd24f849 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 14 Mar 2024 15:00:32 -0400 Subject: [PATCH 4/6] ignore uncheckedindexed.ts warning --- packages/cli-e2e/__tests__/angular.specs.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli-e2e/__tests__/angular.specs.ts b/packages/cli-e2e/__tests__/angular.specs.ts index 8496597800..3daf7a5f6d 100644 --- a/packages/cli-e2e/__tests__/angular.specs.ts +++ b/packages/cli-e2e/__tests__/angular.specs.ts @@ -240,7 +240,9 @@ describe('ui:create:angular', () => { message.indexOf('Warnings while compiling') === -1 && message.indexOf( 'require function is used in a way in which dependencies cannot be statically extracted' - ) === -1 + ) === -1 && + message.indexOf('@reduxjs/toolkit/dist/uncheckedindexed.ts') === + -1 ) ).toEqual([]); }, From 9f58e01628ad0f5194c8cfa2605989cd9408e514 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 14 Mar 2024 15:03:25 -0400 Subject: [PATCH 5/6] Update packages/cli/core/src/lib/snapshot/snapshotReporter.ts Co-authored-by: Olivier Lamothe --- packages/cli/core/src/lib/snapshot/snapshotReporter.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/cli/core/src/lib/snapshot/snapshotReporter.ts b/packages/cli/core/src/lib/snapshot/snapshotReporter.ts index 2ada47b21a..d3b7155062 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotReporter.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotReporter.ts @@ -71,13 +71,8 @@ export class SnapshotReporter { const isResourceTypeReportAffected = ( report: ResourceSnapshotsReportOperationModel ) => { - for (const operation of Object.values(report)) { - if (operation > 0) { - return true; - } - } - return false; - }; + + Object.values(report).reduce((operation, total) => operation + total, 0) === 0; const changedResourcesTypes: ResourceSnapshotType[] = []; for (const resourceType of Object.keys(this.report.resourceOperations)) { if ( From b027b7ca87f014dbaf4464a25b59640ddb1ceb2a Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 14 Mar 2024 16:10:04 -0400 Subject: [PATCH 6/6] derp --- packages/cli/core/src/lib/snapshot/snapshotReporter.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/cli/core/src/lib/snapshot/snapshotReporter.ts b/packages/cli/core/src/lib/snapshot/snapshotReporter.ts index d3b7155062..05b33b7203 100644 --- a/packages/cli/core/src/lib/snapshot/snapshotReporter.ts +++ b/packages/cli/core/src/lib/snapshot/snapshotReporter.ts @@ -70,9 +70,11 @@ export class SnapshotReporter { public getAffectedResourceTypes(): ResourceSnapshotType[] { const isResourceTypeReportAffected = ( report: ResourceSnapshotsReportOperationModel - ) => { - - Object.values(report).reduce((operation, total) => operation + total, 0) === 0; + ) => + Object.values(report).reduce( + (operation, total) => operation + total, + 0 + ) === 0; const changedResourcesTypes: ResourceSnapshotType[] = []; for (const resourceType of Object.keys(this.report.resourceOperations)) { if (