UNPKG

adpa-enterprise-framework-automation

Version:

Modular, standards-compliant Node.js/TypeScript automation framework for enterprise requirements, project, and data management. Provides CLI and API for BABOK v3, PMBOK 7th Edition, and DMBOK 2.0 (in progress). Production-ready Express.js API with TypeSpe

95 lines (92 loc) • 2.99 kB
/** * Migration Helper Script * Assists with gradual migration of imports and function calls */ import fs from 'fs/promises'; import path from 'path'; import { glob } from 'glob'; const MIGRATION_PATTERNS = { imports: { old: /import.*from.*['"]\.\.\/modules\/llmProcessor['"];?/, new: /import.*from.*['"]\.\.\/modules\/llmProcessor-migration['"];?/ }, requires: { old: /(?:const|let|var).*=\s*require\(['"].*llmProcessor\.(?:js|cjs)['"]\);?/, new: /(?:const|let|var).*=\s*require\(['"].*llmProcessor-migration\.(?:js|cjs)['"]\);?/ } }; class MigrationHelper { /** * Analyze current migration status */ async analyzeMigrationStatus(rootDir) { const stats = { total: 0, migrated: 0, remaining: 0, files: { needsMigration: [], alreadyMigrated: [] } }; // Find all JS/TS files const files = glob.sync('**/*.{js,ts,mjs,cjs}', { cwd: rootDir, ignore: ['**/node_modules/**', '**/dist/**'] }); for (const file of files) { const fullPath = path.join(rootDir, file); const content = await fs.readFile(fullPath, 'utf-8'); const hasOldImport = this.hasOldImport(content); const hasNewImport = this.hasNewImport(content); if (hasOldImport || hasNewImport) { stats.total++; if (hasOldImport) { stats.remaining++; stats.files.needsMigration.push(file); } else { stats.migrated++; stats.files.alreadyMigrated.push(file); } } } return stats; } /** * Check if file has old import style */ hasOldImport(content) { return MIGRATION_PATTERNS.imports.old.test(content) || MIGRATION_PATTERNS.requires.old.test(content); } /** * Check if file has new import style */ hasNewImport(content) { return MIGRATION_PATTERNS.imports.new.test(content) || MIGRATION_PATTERNS.requires.new.test(content); } /** * Generate migration report */ generateReport(stats) { const percentComplete = ((stats.migrated / stats.total) * 100).toFixed(1); return ` šŸ“Š Migration Progress Report ========================== Overall Progress: ${percentComplete}% Complete ------------------------------------------- Total Files: ${stats.total} Migrated: ${stats.migrated} Remaining: ${stats.remaining} Files Needing Migration: ---------------------- ${stats.files.needsMigration.map(f => `- ${f}`).join('\n')} Already Migrated Files: --------------------- ${stats.files.alreadyMigrated.map(f => `- ${f}`).join('\n')} `; } } export const migrationHelper = new MigrationHelper(); //# sourceMappingURL=migrationHelper.js.map