feat(format): Enhance format module with rollback, diff reporting, and improved parallel execution
This commit is contained in:
39
ts/mod_format/formatters/cleanup.formatter.ts
Normal file
39
ts/mod_format/formatters/cleanup.formatter.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { BaseFormatter } from '../classes.baseformatter.js';
|
||||
import type { IPlannedChange } from '../interfaces.format.js';
|
||||
import * as plugins from '../mod.plugins.js';
|
||||
import * as cleanupFormatter from '../format.cleanup.js';
|
||||
|
||||
export class CleanupFormatter extends BaseFormatter {
|
||||
get name(): string {
|
||||
return 'cleanup';
|
||||
}
|
||||
|
||||
async analyze(): Promise<IPlannedChange[]> {
|
||||
const changes: IPlannedChange[] = [];
|
||||
|
||||
// List of files to remove
|
||||
const filesToRemove = ['yarn.lock', 'package-lock.json', 'tslint.json', 'defaults.yml'];
|
||||
|
||||
for (const file of filesToRemove) {
|
||||
const exists = await plugins.smartfile.fs.fileExists(file);
|
||||
if (exists) {
|
||||
changes.push({
|
||||
type: 'delete',
|
||||
path: file,
|
||||
module: this.name,
|
||||
description: `Remove obsolete file`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
async applyChange(change: IPlannedChange): Promise<void> {
|
||||
switch (change.type) {
|
||||
case 'delete':
|
||||
await this.deleteFile(change.path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user