45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
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;
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 |