Skip to content

Commit

Permalink
hackfix-this-is-not-that-great
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-bompart committed Mar 12, 2024
1 parent 8488ce2 commit 0a0b0e3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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() {
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/core/src/lib/snapshot/snapshotReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 0a0b0e3

Please sign in to comment.