Feat/workspace health core fix (#3863)
* feat: add deletion support on sync metadata command * fix: remove debug * feat: wip workspace health command add --fix option fix: remove test * feat: core of --fix option for workspace-health
This commit is contained in:
@ -2,6 +2,7 @@ import { Command, CommandRunner, Option } from 'nest-commander';
|
||||
import chalk from 'chalk';
|
||||
|
||||
import { WorkspaceHealthMode } from 'src/workspace/workspace-health/interfaces/workspace-health-options.interface';
|
||||
import { WorkspaceHealthFixKind } from 'src/workspace/workspace-health/interfaces/workspace-health-fix-kind.interface';
|
||||
|
||||
import { WorkspaceHealthService } from 'src/workspace/workspace-health/workspace-health.service';
|
||||
|
||||
@ -9,6 +10,7 @@ interface WorkspaceHealthCommandOptions {
|
||||
workspaceId: string;
|
||||
verbose?: boolean;
|
||||
mode?: WorkspaceHealthMode;
|
||||
fix?: WorkspaceHealthFixKind;
|
||||
}
|
||||
|
||||
@Command({
|
||||
@ -44,6 +46,14 @@ export class WorkspaceHealthCommand extends CommandRunner {
|
||||
console.groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (options.fix) {
|
||||
await this.workspaceHealthService.fixIssues(
|
||||
options.workspaceId,
|
||||
issues,
|
||||
options.fix,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Option({
|
||||
@ -55,6 +65,19 @@ export class WorkspaceHealthCommand extends CommandRunner {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Option({
|
||||
flags: '-f, --fix [kind]',
|
||||
description: 'fix issues',
|
||||
required: false,
|
||||
})
|
||||
fix(value: string): WorkspaceHealthFixKind {
|
||||
if (!Object.values(WorkspaceHealthFixKind).includes(value as any)) {
|
||||
throw new Error(`Invalid fix kind ${value}`);
|
||||
}
|
||||
|
||||
return value as WorkspaceHealthFixKind;
|
||||
}
|
||||
|
||||
@Option({
|
||||
flags: '-v, --verbose',
|
||||
description: 'Detailed output',
|
||||
@ -71,6 +94,10 @@ export class WorkspaceHealthCommand extends CommandRunner {
|
||||
defaultValue: WorkspaceHealthMode.All,
|
||||
})
|
||||
parseMode(value: string): WorkspaceHealthMode {
|
||||
if (!Object.values(WorkspaceHealthMode).includes(value as any)) {
|
||||
throw new Error(`Invalid mode ${value}`);
|
||||
}
|
||||
|
||||
return value as WorkspaceHealthMode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user