versacompiler 2.3.5 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/compiler/compile.js +205 -205
- package/dist/compiler/integrity-validator.js +9 -11
- package/dist/compiler/minify.js +4 -5
- package/dist/compiler/transforms.js +1 -1
- package/dist/compiler/typescript-error-parser.js +0 -133
- package/dist/compiler/typescript-sync-validator.js +12 -7
- package/dist/compiler/typescript-worker-pool.js +153 -34
- package/dist/compiler/typescript-worker-thread.cjs +68 -59
- package/dist/compiler/vuejs.js +12 -6
- package/dist/hrm/initHRM.js +2 -2
- package/dist/main.js +4 -4
- package/dist/servicios/file-watcher.js +3 -1
- package/dist/servicios/readConfig.js +11 -1
- package/package.json +30 -30
package/dist/compiler/compile.js
CHANGED
|
@@ -386,63 +386,31 @@ class OptimizedModuleManager {
|
|
|
386
386
|
this.startBackgroundPreloading();
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
// Lazy loading helper functions
|
|
389
|
+
// Lazy loading helper functions - delegan al OptimizedModuleManager para evitar duplicación
|
|
390
|
+
const moduleManagerRef = () => OptimizedModuleManager.getInstance();
|
|
390
391
|
async function loadChalk() {
|
|
391
|
-
|
|
392
|
-
chalk = (await import('chalk')).default;
|
|
393
|
-
}
|
|
394
|
-
return chalk;
|
|
392
|
+
return moduleManagerRef().ensureModuleLoaded('chalk');
|
|
395
393
|
}
|
|
396
394
|
async function loadLinter() {
|
|
397
|
-
|
|
398
|
-
const linterModule = await import('./linter.js');
|
|
399
|
-
ESLint = linterModule.ESLint;
|
|
400
|
-
OxLint = linterModule.OxLint;
|
|
401
|
-
}
|
|
402
|
-
return { ESLint, OxLint };
|
|
395
|
+
return moduleManagerRef().ensureModuleLoaded('linter');
|
|
403
396
|
}
|
|
404
397
|
async function loadMinify() {
|
|
405
|
-
|
|
406
|
-
const minifyModule = await import('./minify.js');
|
|
407
|
-
// ✨ Usar minifyWithTemplates para minificar templates HTML ANTES del JS
|
|
408
|
-
minifyJS = minifyModule.minifyWithTemplates;
|
|
409
|
-
}
|
|
410
|
-
return minifyJS;
|
|
398
|
+
return moduleManagerRef().ensureModuleLoaded('minify');
|
|
411
399
|
}
|
|
412
400
|
async function loadParser() {
|
|
413
|
-
|
|
414
|
-
const parserModule = await import('./parser.js');
|
|
415
|
-
getCodeFile = parserModule.getCodeFile;
|
|
416
|
-
}
|
|
417
|
-
return getCodeFile;
|
|
401
|
+
return moduleManagerRef().ensureModuleLoaded('parser');
|
|
418
402
|
}
|
|
419
403
|
async function loadTailwind() {
|
|
420
|
-
|
|
421
|
-
const tailwindModule = await import('./tailwindcss.js');
|
|
422
|
-
generateTailwindCSS = tailwindModule.generateTailwindCSS;
|
|
423
|
-
}
|
|
424
|
-
return generateTailwindCSS;
|
|
404
|
+
return moduleManagerRef().ensureModuleLoaded('tailwind');
|
|
425
405
|
}
|
|
426
406
|
async function loadTransforms() {
|
|
427
|
-
|
|
428
|
-
const transformsModule = await import('./transforms.js');
|
|
429
|
-
estandarizaCode = transformsModule.estandarizaCode;
|
|
430
|
-
}
|
|
431
|
-
return estandarizaCode;
|
|
407
|
+
return moduleManagerRef().ensureModuleLoaded('transforms');
|
|
432
408
|
}
|
|
433
409
|
async function loadTypeScript() {
|
|
434
|
-
|
|
435
|
-
const typescriptModule = await import('./typescript-manager.js');
|
|
436
|
-
preCompileTS = typescriptModule.preCompileTS;
|
|
437
|
-
}
|
|
438
|
-
return preCompileTS;
|
|
410
|
+
return moduleManagerRef().ensureModuleLoaded('typescript');
|
|
439
411
|
}
|
|
440
412
|
async function loadVue() {
|
|
441
|
-
|
|
442
|
-
const vueModule = await import('./vuejs.js');
|
|
443
|
-
preCompileVue = vueModule.preCompileVue;
|
|
444
|
-
}
|
|
445
|
-
return preCompileVue;
|
|
413
|
+
return moduleManagerRef().ensureModuleLoaded('vue');
|
|
446
414
|
}
|
|
447
415
|
// Almacenamiento global de errores y resultados
|
|
448
416
|
const compilationErrors = [];
|
|
@@ -465,6 +433,10 @@ class SmartCompilationCache {
|
|
|
465
433
|
maxEntries = 200; // Reducido para tests de estrés
|
|
466
434
|
maxMemory = 50 * 1024 * 1024; // 50MB límite (reducido)
|
|
467
435
|
currentMemoryUsage = 0;
|
|
436
|
+
// Cache para dependencyHash con TTL de 5 minutos para evitar stat() redundantes
|
|
437
|
+
_cachedDepHash = null;
|
|
438
|
+
_depHashExpiry = 0;
|
|
439
|
+
DEP_HASH_TTL = 5 * 60 * 1000; // 5 minutos
|
|
468
440
|
// ✨ ISSUE #3: Sistema de vigilancia de dependencias
|
|
469
441
|
fileWatchers = new Map(); // chokidar watchers
|
|
470
442
|
dependencyGraph = new Map(); // archivo -> dependencias
|
|
@@ -472,6 +444,7 @@ class SmartCompilationCache {
|
|
|
472
444
|
packageJsonPath = path.join(cwd(), 'package.json');
|
|
473
445
|
nodeModulesPath = path.join(cwd(), 'node_modules');
|
|
474
446
|
isWatchingDependencies = false;
|
|
447
|
+
_depWatcherFailed = false; // Flag para indicar que el watcher de deps falló
|
|
475
448
|
/**
|
|
476
449
|
* Genera hash SHA-256 del contenido del archivo
|
|
477
450
|
*/ async generateContentHash(filePath) {
|
|
@@ -529,6 +502,11 @@ class SmartCompilationCache {
|
|
|
529
502
|
* Incluye vigilancia de package.json, node_modules y versiones instaladas
|
|
530
503
|
*/
|
|
531
504
|
async generateDependencyHash() {
|
|
505
|
+
// Retornar hash cacheado si sigue vigente (evita 10+ stat() por ciclo)
|
|
506
|
+
const now = Date.now();
|
|
507
|
+
if (this._cachedDepHash && now < this._depHashExpiry) {
|
|
508
|
+
return this._cachedDepHash;
|
|
509
|
+
}
|
|
532
510
|
try {
|
|
533
511
|
const hash = createHash('sha256');
|
|
534
512
|
// 1. Hash del package.json con versiones
|
|
@@ -589,16 +567,29 @@ class SmartCompilationCache {
|
|
|
589
567
|
// node_modules no existe
|
|
590
568
|
hash.update('nmtime:none');
|
|
591
569
|
}
|
|
592
|
-
|
|
570
|
+
const result = hash.digest('hex').substring(0, 16);
|
|
571
|
+
this._cachedDepHash = result;
|
|
572
|
+
this._depHashExpiry = Date.now() + this.DEP_HASH_TTL;
|
|
573
|
+
return result;
|
|
593
574
|
}
|
|
594
575
|
catch (error) {
|
|
595
576
|
// Incluir información del error en el hash para debugging
|
|
596
|
-
|
|
577
|
+
const result = createHash('sha256')
|
|
597
578
|
.update(`error:${error instanceof Error ? error.message : 'unknown'}`)
|
|
598
579
|
.digest('hex')
|
|
599
580
|
.substring(0, 16);
|
|
581
|
+
this._cachedDepHash = result;
|
|
582
|
+
this._depHashExpiry = Date.now() + this.DEP_HASH_TTL;
|
|
583
|
+
return result;
|
|
600
584
|
}
|
|
601
585
|
}
|
|
586
|
+
/**
|
|
587
|
+
* Invalida el cache de dependencyHash (llamar cuando package.json cambie)
|
|
588
|
+
*/
|
|
589
|
+
invalidateDepHashCache() {
|
|
590
|
+
this._cachedDepHash = null;
|
|
591
|
+
this._depHashExpiry = 0;
|
|
592
|
+
}
|
|
602
593
|
/**
|
|
603
594
|
* Genera clave de cache granular que incluye todos los factores
|
|
604
595
|
*/
|
|
@@ -617,35 +608,21 @@ class SmartCompilationCache {
|
|
|
617
608
|
if (!entry)
|
|
618
609
|
return false;
|
|
619
610
|
try {
|
|
620
|
-
//
|
|
621
|
-
await
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
// Verificar si la configuración ha cambiado
|
|
611
|
+
// Ejecutar todas las verificaciones independientes en paralelo
|
|
612
|
+
const [currentContentHash, currentDependencyHash, fileStat, _outputStat] = await Promise.all([
|
|
613
|
+
this.generateContentHash(filePath),
|
|
614
|
+
this.generateDependencyHash(),
|
|
615
|
+
stat(filePath),
|
|
616
|
+
stat(entry.outputPath),
|
|
617
|
+
]);
|
|
618
|
+
// Los hashes síncronos son baratos, evaluarlos tras el await
|
|
629
619
|
const currentConfigHash = this.generateConfigHash();
|
|
630
|
-
if (entry.configHash !== currentConfigHash) {
|
|
631
|
-
this.cache.delete(filePath);
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
// Verificar si las variables de entorno han cambiado
|
|
635
620
|
const currentEnvHash = this.generateEnvHash();
|
|
636
|
-
if (entry.
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const currentDependencyHash = await this.generateDependencyHash();
|
|
642
|
-
if (entry.dependencyHash !== currentDependencyHash) {
|
|
643
|
-
this.cache.delete(filePath);
|
|
644
|
-
return false;
|
|
645
|
-
}
|
|
646
|
-
// Verificar tiempo de modificación como backup
|
|
647
|
-
const stats = await stat(filePath);
|
|
648
|
-
if (stats.mtimeMs > entry.mtime) {
|
|
621
|
+
if (entry.contentHash !== currentContentHash ||
|
|
622
|
+
entry.configHash !== currentConfigHash ||
|
|
623
|
+
entry.envHash !== currentEnvHash ||
|
|
624
|
+
entry.dependencyHash !== currentDependencyHash ||
|
|
625
|
+
fileStat.mtimeMs > entry.mtime) {
|
|
649
626
|
this.cache.delete(filePath);
|
|
650
627
|
return false;
|
|
651
628
|
}
|
|
@@ -728,7 +705,27 @@ class SmartCompilationCache {
|
|
|
728
705
|
if (entry) {
|
|
729
706
|
this.currentMemoryUsage -= entry.size;
|
|
730
707
|
this.cache.delete(oldestKey);
|
|
708
|
+
// Podar el grafo de dependencias para evitar entradas obsoletas
|
|
709
|
+
this.pruneDependencyGraph(oldestKey);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Elimina entradas obsoletas del grafo de dependencias para un archivo
|
|
715
|
+
*/
|
|
716
|
+
pruneDependencyGraph(filePath) {
|
|
717
|
+
const deps = this.dependencyGraph.get(filePath);
|
|
718
|
+
if (deps) {
|
|
719
|
+
for (const dep of deps) {
|
|
720
|
+
const reverseDeps = this.reverseDependencyGraph.get(dep);
|
|
721
|
+
if (reverseDeps) {
|
|
722
|
+
reverseDeps.delete(filePath);
|
|
723
|
+
if (reverseDeps.size === 0) {
|
|
724
|
+
this.reverseDependencyGraph.delete(dep);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
731
727
|
}
|
|
728
|
+
this.dependencyGraph.delete(filePath);
|
|
732
729
|
}
|
|
733
730
|
}
|
|
734
731
|
/**
|
|
@@ -834,6 +831,7 @@ class SmartCompilationCache {
|
|
|
834
831
|
});
|
|
835
832
|
packageWatcher.on('change', () => {
|
|
836
833
|
logger.info('📦 package.json modificado - invalidando cache de dependencias');
|
|
834
|
+
this.invalidateDepHashCache();
|
|
837
835
|
this.invalidateByDependencyChange();
|
|
838
836
|
});
|
|
839
837
|
this.fileWatchers.set('package.json', packageWatcher);
|
|
@@ -846,12 +844,12 @@ class SmartCompilationCache {
|
|
|
846
844
|
depth: 1, // Solo primer nivel para performance
|
|
847
845
|
ignored: /(^|[/\\])\../, // Ignorar archivos ocultos
|
|
848
846
|
});
|
|
849
|
-
nodeModulesWatcher.on('addDir', (
|
|
850
|
-
logger.info(`📦 Nueva dependencia instalada: ${
|
|
847
|
+
nodeModulesWatcher.on('addDir', (dirPath) => {
|
|
848
|
+
logger.info(`📦 Nueva dependencia instalada: ${dirPath.split(/[/\\]/).pop()}`);
|
|
851
849
|
this.invalidateByDependencyChange();
|
|
852
850
|
});
|
|
853
|
-
nodeModulesWatcher.on('unlinkDir', (
|
|
854
|
-
logger.info(`📦 Dependencia eliminada: ${
|
|
851
|
+
nodeModulesWatcher.on('unlinkDir', (dirPath) => {
|
|
852
|
+
logger.info(`📦 Dependencia eliminada: ${dirPath.split(/[/\\]/).pop()}`);
|
|
855
853
|
this.invalidateByDependencyChange();
|
|
856
854
|
});
|
|
857
855
|
this.fileWatchers.set('node_modules', nodeModulesWatcher);
|
|
@@ -861,6 +859,8 @@ class SmartCompilationCache {
|
|
|
861
859
|
}
|
|
862
860
|
catch (error) {
|
|
863
861
|
logger.warn('⚠️ No se pudo iniciar vigilancia de dependencias:', error);
|
|
862
|
+
// Marcar fallo para que el sistema lo tenga en cuenta
|
|
863
|
+
this._depWatcherFailed = true;
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
/**
|
|
@@ -1044,19 +1044,19 @@ async function handleCompilationError(error, fileName, stage, mode, isVerbose =
|
|
|
1044
1044
|
registerCompilationError(fileName, stage, errorMessage, 'error', errorDetails);
|
|
1045
1045
|
registerCompilationResult(stage, 1, 0, [fileName]); // Mostrar error inmediatamente solo en modo individual y watch
|
|
1046
1046
|
if (mode === 'individual' || mode === 'watch') {
|
|
1047
|
-
const
|
|
1047
|
+
const chalkLib = await loadChalk();
|
|
1048
1048
|
const baseName = path.basename(fileName);
|
|
1049
1049
|
const stageColor = await getStageColor(stage);
|
|
1050
1050
|
if (isVerbose) {
|
|
1051
1051
|
// Modo verbose: Mostrar error completo con contexto
|
|
1052
|
-
logger.error(
|
|
1053
|
-
logger.error(
|
|
1052
|
+
logger.error(chalkLib.red(`❌ Error en etapa ${stageColor(stage)} - ${baseName}:`));
|
|
1053
|
+
logger.error(chalkLib.red(errorMessage));
|
|
1054
1054
|
if (errorDetails && (stage === 'typescript' || stage === 'vue')) {
|
|
1055
1055
|
// Mostrar stack trace limitado para TypeScript y Vue
|
|
1056
1056
|
const stackLines = errorDetails.split('\n').slice(0, 5);
|
|
1057
1057
|
stackLines.forEach(line => {
|
|
1058
1058
|
if (line.trim()) {
|
|
1059
|
-
logger.error(
|
|
1059
|
+
logger.error(chalkLib.gray(` ${line.trim()}`));
|
|
1060
1060
|
}
|
|
1061
1061
|
});
|
|
1062
1062
|
}
|
|
@@ -1064,9 +1064,9 @@ async function handleCompilationError(error, fileName, stage, mode, isVerbose =
|
|
|
1064
1064
|
else {
|
|
1065
1065
|
// Modo normal: Mostrar error simplificado
|
|
1066
1066
|
const firstLine = errorMessage.split('\n')[0];
|
|
1067
|
-
logger.error(
|
|
1068
|
-
logger.error(
|
|
1069
|
-
logger.info(
|
|
1067
|
+
logger.error(chalkLib.red(`❌ Error en ${stageColor(stage)}: ${baseName}`));
|
|
1068
|
+
logger.error(chalkLib.red(` ${firstLine}`));
|
|
1069
|
+
logger.info(chalkLib.yellow(`💡 Usa --verbose para ver detalles completos`));
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
1072
1072
|
// En modo 'all', los errores se acumulan silenciosamente para el resumen final
|
|
@@ -1080,7 +1080,7 @@ function registerCompilationSuccess(fileName, stage) {
|
|
|
1080
1080
|
/**
|
|
1081
1081
|
* Limpia todos los errores y resultados acumulados
|
|
1082
1082
|
*/
|
|
1083
|
-
function clearCompilationState() {
|
|
1083
|
+
export function clearCompilationState() {
|
|
1084
1084
|
compilationErrors.length = 0;
|
|
1085
1085
|
compilationResults.length = 0;
|
|
1086
1086
|
}
|
|
@@ -1088,25 +1088,25 @@ function clearCompilationState() {
|
|
|
1088
1088
|
* Muestra un resumen detallado de todos los errores de compilación
|
|
1089
1089
|
*/
|
|
1090
1090
|
async function displayCompilationSummary(isVerbose = false, totalTime) {
|
|
1091
|
-
const
|
|
1091
|
+
const chalkLib = await loadChalk();
|
|
1092
1092
|
if (compilationErrors.length === 0 && compilationResults.length === 0) {
|
|
1093
|
-
logger.info(
|
|
1093
|
+
logger.info(chalkLib.green('✅ No hay errores de compilación para mostrar.'));
|
|
1094
1094
|
if (totalTime) {
|
|
1095
|
-
logger.info(
|
|
1095
|
+
logger.info(chalkLib.bold(`\n⏱️ TIEMPO TOTAL DE COMPILACIÓN: ${totalTime}`));
|
|
1096
1096
|
}
|
|
1097
1097
|
return;
|
|
1098
1098
|
}
|
|
1099
1099
|
// 🎨 Header moderno del resumen
|
|
1100
1100
|
const summaryLine = '━'.repeat(40);
|
|
1101
1101
|
logger.info('');
|
|
1102
|
-
logger.info(
|
|
1103
|
-
logger.info(
|
|
1102
|
+
logger.info(chalkLib.bold.cyan('📊 Resumen de Compilación'));
|
|
1103
|
+
logger.info(chalkLib.gray(summaryLine)); // ⏱️ Tiempo total con formato elegante
|
|
1104
1104
|
if (totalTime) {
|
|
1105
|
-
logger.info(
|
|
1105
|
+
logger.info(chalkLib.bold(`⏱️ Tiempo Total: ${chalkLib.green(totalTime)}`));
|
|
1106
1106
|
logger.info('');
|
|
1107
1107
|
} // 🔧 Estadísticas por etapa con mejor formato
|
|
1108
1108
|
if (compilationResults.length > 0) {
|
|
1109
|
-
logger.info(
|
|
1109
|
+
logger.info(chalkLib.bold.blue('🔧 Estadísticas por Etapa:'));
|
|
1110
1110
|
for (const result of compilationResults) {
|
|
1111
1111
|
const totalFiles = result.success + result.errors;
|
|
1112
1112
|
const successRate = totalFiles > 0
|
|
@@ -1114,20 +1114,20 @@ async function displayCompilationSummary(isVerbose = false, totalTime) {
|
|
|
1114
1114
|
: 0;
|
|
1115
1115
|
// Iconos y colores dinámicos por etapa
|
|
1116
1116
|
const stageIcon = getStageIcon(result.stage);
|
|
1117
|
-
const statusColor = result.errors === 0 ?
|
|
1117
|
+
const statusColor = result.errors === 0 ? chalkLib.green : chalkLib.red;
|
|
1118
1118
|
const progressBar = createProgressBarWithPercentage(successRate, 20);
|
|
1119
|
-
logger.info(` ${stageIcon} ${
|
|
1119
|
+
logger.info(` ${stageIcon} ${chalkLib.bold(result.stage)}`);
|
|
1120
1120
|
logger.info(` ${statusColor('●')} ${result.success}/${totalFiles} archivos ${statusColor(`(${successRate}%)`)}`);
|
|
1121
1121
|
logger.info(` ${progressBar}`);
|
|
1122
1122
|
if (result.errors > 0) {
|
|
1123
|
-
logger.info(` ${
|
|
1123
|
+
logger.info(` ${chalkLib.red('⚠')} ${result.errors} ${result.errors === 1 ? 'error' : 'errores'}`);
|
|
1124
1124
|
}
|
|
1125
1125
|
logger.info('');
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
1128
|
// Mostrar errores detallados
|
|
1129
1129
|
if (compilationErrors.length > 0) {
|
|
1130
|
-
logger.info(
|
|
1130
|
+
logger.info(chalkLib.red(`\n❌ Se encontraron ${compilationErrors.length} errores:`));
|
|
1131
1131
|
// Agrupar errores por archivo para mejor organización
|
|
1132
1132
|
const errorsByFile = new Map();
|
|
1133
1133
|
compilationErrors.forEach(error => {
|
|
@@ -1142,9 +1142,9 @@ async function displayCompilationSummary(isVerbose = false, totalTime) {
|
|
|
1142
1142
|
const baseName = path.basename(filePath);
|
|
1143
1143
|
const errorCount = fileErrors.filter(e => e.severity === 'error').length;
|
|
1144
1144
|
const warningCount = fileErrors.filter(e => e.severity === 'warning').length;
|
|
1145
|
-
logger.info(
|
|
1146
|
-
logger.info(
|
|
1147
|
-
logger.info(
|
|
1145
|
+
logger.info(chalkLib.cyan(`\n📄 ${fileIndex}. ${baseName}`));
|
|
1146
|
+
logger.info(chalkLib.gray(` Ruta: ${filePath}`));
|
|
1147
|
+
logger.info(chalkLib.yellow(` ${errorCount} errores, ${warningCount} advertencias`));
|
|
1148
1148
|
for (const error of fileErrors) {
|
|
1149
1149
|
const icon = error.severity === 'error' ? '❌' : '⚠️';
|
|
1150
1150
|
const stageColor = await getStageColor(error.stage);
|
|
@@ -1154,12 +1154,12 @@ async function displayCompilationSummary(isVerbose = false, totalTime) {
|
|
|
1154
1154
|
const detailLines = error.details.split('\n').slice(0, 5);
|
|
1155
1155
|
detailLines.forEach(line => {
|
|
1156
1156
|
if (line.trim()) {
|
|
1157
|
-
logger.info(
|
|
1157
|
+
logger.info(chalkLib.gray(` ${line.trim()}`));
|
|
1158
1158
|
}
|
|
1159
1159
|
});
|
|
1160
1160
|
}
|
|
1161
1161
|
if (error.help) {
|
|
1162
|
-
logger.info(
|
|
1162
|
+
logger.info(chalkLib.blue(` 💡 ${error.help}`));
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
1165
|
fileIndex++;
|
|
@@ -1170,44 +1170,44 @@ async function displayCompilationSummary(isVerbose = false, totalTime) {
|
|
|
1170
1170
|
// Header elegante para estadísticas finales
|
|
1171
1171
|
const statLine = '═'.repeat(50);
|
|
1172
1172
|
logger.info('');
|
|
1173
|
-
logger.info(
|
|
1174
|
-
logger.info(
|
|
1175
|
-
logger.info(
|
|
1173
|
+
logger.info(chalkLib.bold.cyan(statLine));
|
|
1174
|
+
logger.info(chalkLib.bold.cyan(' 📊 RESUMEN FINAL'));
|
|
1175
|
+
logger.info(chalkLib.bold.cyan(statLine));
|
|
1176
1176
|
// Estadísticas con iconos y colores modernos
|
|
1177
1177
|
logger.info('');
|
|
1178
|
-
logger.info(
|
|
1179
|
-
logger.info(` 📁 Archivos afectados: ${
|
|
1180
|
-
logger.info(` ${totalErrors > 0 ?
|
|
1181
|
-
logger.info(` ${totalWarnings > 0 ?
|
|
1178
|
+
logger.info(chalkLib.bold('🎯 Resultados:'));
|
|
1179
|
+
logger.info(` 📁 Archivos afectados: ${chalkLib.cyan.bold(totalFiles)}`);
|
|
1180
|
+
logger.info(` ${totalErrors > 0 ? chalkLib.red('●') : chalkLib.green('○')} Errores: ${totalErrors > 0 ? chalkLib.red.bold(totalErrors) : chalkLib.green.bold('0')}`);
|
|
1181
|
+
logger.info(` ${totalWarnings > 0 ? chalkLib.yellow('●') : chalkLib.green('○')} Advertencias: ${totalWarnings > 0 ? chalkLib.yellow.bold(totalWarnings) : chalkLib.green.bold('0')}`);
|
|
1182
1182
|
logger.info('');
|
|
1183
1183
|
// Estado final con diseño visual atractivo
|
|
1184
1184
|
if (totalErrors > 0) {
|
|
1185
|
-
logger.info(
|
|
1186
|
-
logger.info(
|
|
1185
|
+
logger.info(chalkLib.red.bold('🚨 COMPILACIÓN COMPLETADA CON ERRORES'));
|
|
1186
|
+
logger.info(chalkLib.red(' Por favor revisa y corrige los problemas anteriores.'));
|
|
1187
1187
|
}
|
|
1188
1188
|
else if (totalWarnings > 0) {
|
|
1189
|
-
logger.info(
|
|
1190
|
-
logger.info(
|
|
1189
|
+
logger.info(chalkLib.yellow.bold('⚠️ COMPILACIÓN COMPLETADA CON ADVERTENCIAS'));
|
|
1190
|
+
logger.info(chalkLib.yellow(' Considera revisar las advertencias anteriores.'));
|
|
1191
1191
|
}
|
|
1192
1192
|
else {
|
|
1193
|
-
logger.info(
|
|
1194
|
-
logger.info(
|
|
1193
|
+
logger.info(chalkLib.green.bold('✅ COMPILACIÓN EXITOSA'));
|
|
1194
|
+
logger.info(chalkLib.green(' ¡Todos los archivos se compilaron sin problemas!'));
|
|
1195
1195
|
}
|
|
1196
1196
|
logger.info('');
|
|
1197
|
-
logger.info(
|
|
1197
|
+
logger.info(chalkLib.bold.cyan(statLine));
|
|
1198
1198
|
}
|
|
1199
1199
|
else {
|
|
1200
1200
|
// Caso exitoso sin errores
|
|
1201
1201
|
const successLine = '═'.repeat(50);
|
|
1202
1202
|
logger.info('');
|
|
1203
|
-
logger.info(
|
|
1204
|
-
logger.info(
|
|
1205
|
-
logger.info(
|
|
1203
|
+
logger.info(chalkLib.bold.green(successLine));
|
|
1204
|
+
logger.info(chalkLib.bold.green(' ✨ ÉXITO'));
|
|
1205
|
+
logger.info(chalkLib.bold.green(successLine));
|
|
1206
1206
|
logger.info('');
|
|
1207
|
-
logger.info(
|
|
1208
|
-
logger.info(
|
|
1207
|
+
logger.info(chalkLib.green.bold('🎉 COMPILACIÓN COMPLETADA EXITOSAMENTE'));
|
|
1208
|
+
logger.info(chalkLib.green(' ¡No se encontraron errores ni advertencias!'));
|
|
1209
1209
|
logger.info('');
|
|
1210
|
-
logger.info(
|
|
1210
|
+
logger.info(chalkLib.bold.green(successLine));
|
|
1211
1211
|
}
|
|
1212
1212
|
logger.info('');
|
|
1213
1213
|
}
|
|
@@ -1215,7 +1215,7 @@ async function displayCompilationSummary(isVerbose = false, totalTime) {
|
|
|
1215
1215
|
* Muestra errores del linter con formato visual moderno y profesional
|
|
1216
1216
|
*/
|
|
1217
1217
|
async function displayLinterErrors(errors) {
|
|
1218
|
-
const
|
|
1218
|
+
const chalkLib = await loadChalk();
|
|
1219
1219
|
// Agrupar errores por archivo
|
|
1220
1220
|
const errorsByFile = new Map();
|
|
1221
1221
|
errors.forEach(error => {
|
|
@@ -1228,22 +1228,22 @@ async function displayLinterErrors(errors) {
|
|
|
1228
1228
|
const totalWarnings = errors.filter(e => e.severity === 'warning').length;
|
|
1229
1229
|
const totalFiles = errorsByFile.size;
|
|
1230
1230
|
// Header estilo moderno con gradiente visual
|
|
1231
|
-
logger.info(
|
|
1232
|
-
logger.info(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
logger.info(
|
|
1231
|
+
logger.info(chalkLib.bold.rgb(255, 120, 120)('╭─────────────────────────────────────────────────────────────╮'));
|
|
1232
|
+
logger.info(chalkLib.bold.rgb(255, 120, 120)('│ ') +
|
|
1233
|
+
chalkLib.bold.white('🔍 LINTER REPORT') +
|
|
1234
|
+
chalkLib.bold.rgb(255, 120, 120)(' │'));
|
|
1235
|
+
logger.info(chalkLib.bold.rgb(255, 120, 120)('╰─────────────────────────────────────────────────────────────╯'));
|
|
1236
1236
|
// Resumen con iconos profesionales
|
|
1237
|
-
const errorIcon = totalErrors > 0 ?
|
|
1238
|
-
const warningIcon = totalWarnings > 0 ?
|
|
1237
|
+
const errorIcon = totalErrors > 0 ? chalkLib.red('●') : chalkLib.green('○');
|
|
1238
|
+
const warningIcon = totalWarnings > 0 ? chalkLib.yellow('●') : chalkLib.green('○');
|
|
1239
1239
|
logger.info('');
|
|
1240
|
-
logger.info(
|
|
1241
|
-
logger.info(` ${errorIcon} ${
|
|
1242
|
-
logger.info(` ${warningIcon} ${
|
|
1243
|
-
logger.info(` 📁 ${
|
|
1240
|
+
logger.info(chalkLib.bold('📊 Summary:'));
|
|
1241
|
+
logger.info(` ${errorIcon} ${chalkLib.bold(totalErrors)} ${chalkLib.red('errors')}`);
|
|
1242
|
+
logger.info(` ${warningIcon} ${chalkLib.bold(totalWarnings)} ${chalkLib.yellow('warnings')}`);
|
|
1243
|
+
logger.info(` 📁 ${chalkLib.bold(totalFiles)} ${chalkLib.cyan('files')}`);
|
|
1244
1244
|
logger.info('');
|
|
1245
1245
|
if (totalErrors === 0 && totalWarnings === 0) {
|
|
1246
|
-
logger.info(
|
|
1246
|
+
logger.info(chalkLib.green.bold('✨ All checks passed! No issues found.'));
|
|
1247
1247
|
return;
|
|
1248
1248
|
}
|
|
1249
1249
|
// Mostrar errores por archivo con formato elegante
|
|
@@ -1252,29 +1252,29 @@ async function displayLinterErrors(errors) {
|
|
|
1252
1252
|
await displayFileErrorsGroup(filePath, fileErrors, fileIndex, totalFiles);
|
|
1253
1253
|
fileIndex++;
|
|
1254
1254
|
if (fileIndex <= totalFiles) {
|
|
1255
|
-
logger.info(
|
|
1255
|
+
logger.info(chalkLib.gray('─'.repeat(80))); // Separador entre archivos
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
1258
|
// Footer con estadísticas
|
|
1259
1259
|
logger.info('');
|
|
1260
|
-
logger.info(
|
|
1261
|
-
logger.info(
|
|
1262
|
-
|
|
1260
|
+
logger.info(chalkLib.bold.rgb(255, 120, 120)('╭─────────────────────────────────────────────────────────────╮'));
|
|
1261
|
+
logger.info(chalkLib.bold.rgb(255, 120, 120)('│ ') +
|
|
1262
|
+
chalkLib.bold.white(`Found ${totalErrors + totalWarnings} issues in ${totalFiles} files`) +
|
|
1263
1263
|
' '.repeat(Math.max(0, 52 -
|
|
1264
1264
|
`Found ${totalErrors + totalWarnings} issues in ${totalFiles} files`
|
|
1265
1265
|
.length)) +
|
|
1266
|
-
|
|
1267
|
-
logger.info(
|
|
1266
|
+
chalkLib.bold.rgb(255, 120, 120)(' │'));
|
|
1267
|
+
logger.info(chalkLib.bold.rgb(255, 120, 120)('╰─────────────────────────────────────────────────────────────╯'));
|
|
1268
1268
|
}
|
|
1269
1269
|
/**
|
|
1270
1270
|
* Muestra un grupo de errores para un archivo específico con formato moderno
|
|
1271
1271
|
*/
|
|
1272
1272
|
async function displayFileErrorsGroup(filePath, fileErrors, _fileIndex, _totalFiles) {
|
|
1273
|
-
const
|
|
1273
|
+
const chalkLib = await loadChalk();
|
|
1274
1274
|
// Header del archivo con iconos de estado
|
|
1275
1275
|
const errorCount = fileErrors.filter(e => e.severity === 'error').length;
|
|
1276
1276
|
const warningCount = fileErrors.filter(e => e.severity === 'warning').length;
|
|
1277
|
-
const statusIcon = errorCount > 0 ?
|
|
1277
|
+
const statusIcon = errorCount > 0 ? chalkLib.red('✕') : chalkLib.yellow('⚠');
|
|
1278
1278
|
const fileIcon = filePath.endsWith('.vue')
|
|
1279
1279
|
? '🎨'
|
|
1280
1280
|
: filePath.endsWith('.ts')
|
|
@@ -1283,8 +1283,8 @@ async function displayFileErrorsGroup(filePath, fileErrors, _fileIndex, _totalFi
|
|
|
1283
1283
|
? '📜'
|
|
1284
1284
|
: '📄';
|
|
1285
1285
|
logger.info('');
|
|
1286
|
-
logger.info(
|
|
1287
|
-
logger.info(
|
|
1286
|
+
logger.info(chalkLib.bold(`${statusIcon} ${fileIcon} ${chalkLib.cyan(path.relative(process.cwd(), filePath))}`));
|
|
1287
|
+
logger.info(chalkLib.gray(` ${errorCount} errors, ${warningCount} warnings`));
|
|
1288
1288
|
logger.info('');
|
|
1289
1289
|
// Mostrar cada error con formato elegante
|
|
1290
1290
|
for (let i = 0; i < fileErrors.length; i++) {
|
|
@@ -1296,21 +1296,21 @@ async function displayFileErrorsGroup(filePath, fileErrors, _fileIndex, _totalFi
|
|
|
1296
1296
|
* Muestra un error individual con formato visual moderno tipo ESLint/Prettier
|
|
1297
1297
|
*/
|
|
1298
1298
|
async function displayModernLinterError(error, filePath, errorIndex, totalErrorsInFile) {
|
|
1299
|
-
const
|
|
1299
|
+
const chalkLib = await loadChalk();
|
|
1300
1300
|
const fs = await import('node:fs/promises');
|
|
1301
1301
|
// Determinar tipo y color del error
|
|
1302
1302
|
const isError = error.severity === 'error';
|
|
1303
|
-
const typeColor = isError ?
|
|
1303
|
+
const typeColor = isError ? chalkLib.red : chalkLib.yellow;
|
|
1304
1304
|
const typeIcon = isError ? '✕' : '⚠';
|
|
1305
1305
|
const line = error.line || 1;
|
|
1306
1306
|
const column = error.column || 1;
|
|
1307
1307
|
const ruleId = error.ruleId || error.from || 'unknown';
|
|
1308
1308
|
// Línea principal del error con formato moderno
|
|
1309
|
-
const errorHeader = ` ${typeColor(typeIcon)} ${
|
|
1310
|
-
const ruleInfo = `${
|
|
1311
|
-
const locationInfo = `${
|
|
1309
|
+
const errorHeader = ` ${typeColor(typeIcon)} ${chalkLib.bold(error.message)}`;
|
|
1310
|
+
const ruleInfo = `${chalkLib.gray(ruleId)}`;
|
|
1311
|
+
const locationInfo = `${chalkLib.blue(`${line}:${column}`)}`;
|
|
1312
1312
|
logger.info(errorHeader);
|
|
1313
|
-
logger.info(` ${
|
|
1313
|
+
logger.info(` ${chalkLib.gray('at')} ${locationInfo} ${chalkLib.gray('·')} ${ruleInfo}`);
|
|
1314
1314
|
// Mostrar código con contexto
|
|
1315
1315
|
try {
|
|
1316
1316
|
const absolutePath = path.resolve(filePath);
|
|
@@ -1332,27 +1332,27 @@ async function displayModernLinterError(error, filePath, errorIndex, totalErrors
|
|
|
1332
1332
|
const isErrorLine = i === lineNum;
|
|
1333
1333
|
if (isErrorLine) {
|
|
1334
1334
|
// Línea con el error - destacada
|
|
1335
|
-
logger.info(` ${
|
|
1335
|
+
logger.info(` ${chalkLib.red('>')} ${chalkLib.gray(lineNumStr)} ${chalkLib.gray('│')} ${currentLine}`);
|
|
1336
1336
|
// Indicador de posición del error
|
|
1337
1337
|
const pointer = ' '.repeat(Math.max(0, column - 1)) + typeColor('^');
|
|
1338
|
-
logger.info(` ${
|
|
1338
|
+
logger.info(` ${chalkLib.gray(' ')} ${chalkLib.gray(' '.repeat(maxLineNumWidth))} ${chalkLib.gray('│')} ${pointer}`);
|
|
1339
1339
|
}
|
|
1340
1340
|
else {
|
|
1341
1341
|
// Líneas de contexto
|
|
1342
|
-
logger.info(` ${
|
|
1342
|
+
logger.info(` ${chalkLib.gray(' ')} ${chalkLib.gray(lineNumStr)} ${chalkLib.gray('│')} ${chalkLib.gray(currentLine)}`);
|
|
1343
1343
|
}
|
|
1344
1344
|
}
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
1347
|
catch {
|
|
1348
1348
|
// Si no se puede leer el archivo, mostrar formato simplificado
|
|
1349
|
-
logger.info(` ${
|
|
1349
|
+
logger.info(` ${chalkLib.gray('│')} ${chalkLib.gray('(Unable to read file content)')}`);
|
|
1350
1350
|
}
|
|
1351
1351
|
// Mostrar ayuda si está disponible
|
|
1352
1352
|
if (error.help) {
|
|
1353
1353
|
logger.info('');
|
|
1354
1354
|
const helpText = error.help.replace(/^Regla \w+: /, '').trim();
|
|
1355
|
-
logger.info(` ${
|
|
1355
|
+
logger.info(` ${chalkLib.blue('💡')} ${chalkLib.blue('Help:')} ${chalkLib.gray(helpText)}`);
|
|
1356
1356
|
}
|
|
1357
1357
|
// Separador entre errores (solo si no es el último)
|
|
1358
1358
|
if (errorIndex < totalErrorsInFile) {
|
|
@@ -1364,14 +1364,14 @@ async function displayModernLinterError(error, filePath, errorIndex, totalErrors
|
|
|
1364
1364
|
* @deprecated Use displayModernLinterError instead
|
|
1365
1365
|
*/
|
|
1366
1366
|
async function _displaySingleLinterError(error, filePath) {
|
|
1367
|
-
const
|
|
1367
|
+
const chalkLib = await loadChalk();
|
|
1368
1368
|
const fs = await import('node:fs/promises');
|
|
1369
1369
|
const icon = error.severity === 'error' ? '×' : '⚠';
|
|
1370
1370
|
const ruleInfo = error.help || '';
|
|
1371
1371
|
const line = error.line || 'N/A';
|
|
1372
1372
|
const column = error.column || 10; // Columna por defecto si no está disponible
|
|
1373
1373
|
// Línea principal del error
|
|
1374
|
-
const mainErrorLine = `${
|
|
1374
|
+
const mainErrorLine = `${chalkLib.red(icon)} ${chalkLib.cyan(`${error.from}(${ruleInfo.replace(/^Regla \w+: /, '')})`)}: ${error.message}`;
|
|
1375
1375
|
logger.info(mainErrorLine);
|
|
1376
1376
|
// Intentar leer el contenido del archivo para mostrar contexto
|
|
1377
1377
|
try {
|
|
@@ -1381,7 +1381,7 @@ async function _displaySingleLinterError(error, filePath) {
|
|
|
1381
1381
|
const lineNum = parseInt(line.toString()) - 1; // Convertir a índice 0-based
|
|
1382
1382
|
if (lineNum >= 0 && lineNum < lines.length) {
|
|
1383
1383
|
// Mostrar ubicación
|
|
1384
|
-
logger.info(
|
|
1384
|
+
logger.info(chalkLib.blue(` ╭─[${filePath}:${line}:${column}]`));
|
|
1385
1385
|
// Mostrar líneas de contexto
|
|
1386
1386
|
const startLine = Math.max(0, lineNum - 1);
|
|
1387
1387
|
const endLine = Math.min(lines.length - 1, lineNum + 1);
|
|
@@ -1391,38 +1391,38 @@ async function _displaySingleLinterError(error, filePath) {
|
|
|
1391
1391
|
const prefix = currentLineNum.toString().padStart(2, ' ');
|
|
1392
1392
|
if (i === lineNum) {
|
|
1393
1393
|
// Línea con el error
|
|
1394
|
-
logger.info(
|
|
1394
|
+
logger.info(chalkLib.blue(` ${prefix} │ `) + currentLine);
|
|
1395
1395
|
// Mostrar el indicador de error
|
|
1396
1396
|
const indent = ' '.repeat(prefix.length + 3); // Espacios para alinear
|
|
1397
1397
|
const pointer = ' '.repeat(Math.max(0, (column || 1) - 1)) +
|
|
1398
|
-
|
|
1399
|
-
logger.info(
|
|
1398
|
+
chalkLib.red('───────┬──────');
|
|
1399
|
+
logger.info(chalkLib.blue(indent + '·') + pointer);
|
|
1400
1400
|
// Mensaje de ubicación específica
|
|
1401
1401
|
const messageIndent = ' '.repeat(Math.max(0, (column || 1) + 6));
|
|
1402
|
-
logger.info(
|
|
1402
|
+
logger.info(chalkLib.blue(indent + '·') +
|
|
1403
1403
|
messageIndent +
|
|
1404
|
-
|
|
1405
|
-
|
|
1404
|
+
chalkLib.red('╰── ') +
|
|
1405
|
+
chalkLib.gray(getErrorLocationMessage(error)));
|
|
1406
1406
|
}
|
|
1407
1407
|
else {
|
|
1408
1408
|
// Líneas de contexto
|
|
1409
|
-
logger.info(
|
|
1409
|
+
logger.info(chalkLib.blue(` ${prefix} │ `) + chalkLib.gray(currentLine));
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
|
-
logger.info(
|
|
1412
|
+
logger.info(chalkLib.blue(' ╰────'));
|
|
1413
1413
|
}
|
|
1414
1414
|
}
|
|
1415
1415
|
catch {
|
|
1416
1416
|
// Si no se puede leer el archivo, mostrar formato simplificado
|
|
1417
|
-
logger.info(
|
|
1418
|
-
logger.info(
|
|
1419
|
-
|
|
1420
|
-
logger.info(
|
|
1417
|
+
logger.info(chalkLib.blue(` ╭─[${filePath}:${line}:${column}]`));
|
|
1418
|
+
logger.info(chalkLib.blue(' │ ') +
|
|
1419
|
+
chalkLib.gray('(No se pudo leer el contenido del archivo)'));
|
|
1420
|
+
logger.info(chalkLib.blue(' ╰────'));
|
|
1421
1421
|
}
|
|
1422
1422
|
// Mostrar ayuda si está disponible
|
|
1423
1423
|
if (error.help) {
|
|
1424
1424
|
const helpMessage = error.help.replace(/^Regla \w+: /, '');
|
|
1425
|
-
logger.info(
|
|
1425
|
+
logger.info(chalkLib.blue(' help: ') + chalkLib.yellow(helpMessage));
|
|
1426
1426
|
}
|
|
1427
1427
|
logger.info(''); // Espacio entre errores
|
|
1428
1428
|
}
|
|
@@ -1451,22 +1451,22 @@ function getErrorLocationMessage(error) {
|
|
|
1451
1451
|
* Obtiene el color apropiado para cada etapa de compilación
|
|
1452
1452
|
*/
|
|
1453
1453
|
async function getStageColor(stage) {
|
|
1454
|
-
const
|
|
1454
|
+
const chalkLib = await loadChalk();
|
|
1455
1455
|
switch (stage) {
|
|
1456
1456
|
case 'vue':
|
|
1457
|
-
return
|
|
1457
|
+
return chalkLib.green;
|
|
1458
1458
|
case 'typescript':
|
|
1459
|
-
return
|
|
1459
|
+
return chalkLib.blue;
|
|
1460
1460
|
case 'standardization':
|
|
1461
|
-
return
|
|
1461
|
+
return chalkLib.yellow;
|
|
1462
1462
|
case 'minification':
|
|
1463
|
-
return
|
|
1463
|
+
return chalkLib.red;
|
|
1464
1464
|
case 'tailwind':
|
|
1465
|
-
return
|
|
1465
|
+
return chalkLib.magenta;
|
|
1466
1466
|
case 'file-read':
|
|
1467
|
-
return
|
|
1467
|
+
return chalkLib.gray;
|
|
1468
1468
|
default:
|
|
1469
|
-
return
|
|
1469
|
+
return chalkLib.white;
|
|
1470
1470
|
}
|
|
1471
1471
|
}
|
|
1472
1472
|
export function normalizeRuta(ruta) {
|
|
@@ -1569,8 +1569,8 @@ async function compileJS(inPath, outPath, mode = 'individual') {
|
|
|
1569
1569
|
let start = Date.now();
|
|
1570
1570
|
const extension = path.extname(inPath); // Asegurar que el parser esté cargado
|
|
1571
1571
|
await moduleManager.ensureModuleLoaded('parser');
|
|
1572
|
-
const
|
|
1573
|
-
const result = await
|
|
1572
|
+
const getCodeFileLib = await loadParser();
|
|
1573
|
+
const result = await getCodeFileLib(inPath);
|
|
1574
1574
|
let code = result.code;
|
|
1575
1575
|
const error = result.error;
|
|
1576
1576
|
timings.fileRead = Date.now() - start;
|
|
@@ -1594,11 +1594,11 @@ async function compileJS(inPath, outPath, mode = 'individual') {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
// Asegurar que el módulo Vue esté cargado
|
|
1596
1596
|
await moduleManager.ensureModuleLoaded('vue');
|
|
1597
|
-
const
|
|
1598
|
-
if (typeof
|
|
1599
|
-
throw new Error(`loadVue devolvió ${typeof
|
|
1597
|
+
const preCompileVueLib = await loadVue();
|
|
1598
|
+
if (typeof preCompileVueLib !== 'function') {
|
|
1599
|
+
throw new Error(`loadVue devolvió ${typeof preCompileVueLib} en lugar de una función para archivo: ${inPath}`);
|
|
1600
1600
|
}
|
|
1601
|
-
vueResult = await
|
|
1601
|
+
vueResult = await preCompileVueLib(code, inPath, env.isPROD === 'true');
|
|
1602
1602
|
timings.vueCompile = Date.now() - start;
|
|
1603
1603
|
if (vueResult === undefined || vueResult === null) {
|
|
1604
1604
|
throw new Error(`preCompileVue devolvió ${vueResult} para archivo: ${inPath}`);
|
|
@@ -1627,12 +1627,12 @@ async function compileJS(inPath, outPath, mode = 'individual') {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
// Asegurar que el módulo TypeScript esté cargado
|
|
1629
1629
|
await moduleManager.ensureModuleLoaded('typescript');
|
|
1630
|
-
const
|
|
1631
|
-
if (typeof
|
|
1632
|
-
throw new Error(`loadTypeScript devolvió ${typeof
|
|
1630
|
+
const preCompileTSLib = await loadTypeScript();
|
|
1631
|
+
if (typeof preCompileTSLib !== 'function') {
|
|
1632
|
+
throw new Error(`loadTypeScript devolvió ${typeof preCompileTSLib} en lugar de una función para archivo: ${inPath}`);
|
|
1633
1633
|
}
|
|
1634
1634
|
// 🚀 OPTIMIZACIÓN: Pasar scriptInfo directamente sin crear objeto nuevo
|
|
1635
|
-
tsResult = await
|
|
1635
|
+
tsResult = await preCompileTSLib(code, inPath, vueResult?.scriptInfo);
|
|
1636
1636
|
timings.tsCompile = Date.now() - start;
|
|
1637
1637
|
if (tsResult === undefined || tsResult === null) {
|
|
1638
1638
|
throw new Error(`preCompileTS devolvió ${tsResult} para archivo: ${inPath}`);
|
|
@@ -1666,8 +1666,8 @@ async function compileJS(inPath, outPath, mode = 'individual') {
|
|
|
1666
1666
|
start = Date.now();
|
|
1667
1667
|
// Asegurar que el módulo de transformaciones esté cargado
|
|
1668
1668
|
await moduleManager.ensureModuleLoaded('transforms');
|
|
1669
|
-
const
|
|
1670
|
-
const resultSTD = await
|
|
1669
|
+
const estandarizaCodeLib = await loadTransforms();
|
|
1670
|
+
const resultSTD = await estandarizaCodeLib(code, inPath);
|
|
1671
1671
|
timings.standardization = Date.now() - start;
|
|
1672
1672
|
if (resultSTD === undefined || resultSTD === null) {
|
|
1673
1673
|
throw new Error(`estandarizaCode devolvió ${resultSTD} para archivo: ${inPath}`);
|
|
@@ -1690,9 +1690,9 @@ async function compileJS(inPath, outPath, mode = 'individual') {
|
|
|
1690
1690
|
}
|
|
1691
1691
|
// Asegurar que el módulo de minificación esté cargado
|
|
1692
1692
|
await moduleManager.ensureModuleLoaded('minify');
|
|
1693
|
-
const
|
|
1693
|
+
const minifyJSLib = await loadMinify();
|
|
1694
1694
|
const beforeMinification = code; // Guardar código antes de minificar
|
|
1695
|
-
const resultMinify = await
|
|
1695
|
+
const resultMinify = await minifyJSLib(code, inPath, true);
|
|
1696
1696
|
timings.minification = Date.now() - start;
|
|
1697
1697
|
if (resultMinify === undefined || resultMinify === null) {
|
|
1698
1698
|
throw new Error(`minifyJS devolvió ${resultMinify} para archivo: ${inPath}`);
|
|
@@ -1757,8 +1757,8 @@ export async function initCompile(ruta, compileTailwind = true, mode = 'individu
|
|
|
1757
1757
|
// Generar TailwindCSS si está habilitado
|
|
1758
1758
|
if (compileTailwind && Boolean(env.TAILWIND)) {
|
|
1759
1759
|
await moduleManager.ensureModuleLoaded('tailwind');
|
|
1760
|
-
const
|
|
1761
|
-
const resultTW = await
|
|
1760
|
+
const generateTailwindCSSLib = await loadTailwind();
|
|
1761
|
+
const resultTW = await generateTailwindCSSLib();
|
|
1762
1762
|
if (typeof resultTW !== 'boolean') {
|
|
1763
1763
|
if (resultTW?.success) {
|
|
1764
1764
|
logger.info(`🎨 ${resultTW.message}`);
|
|
@@ -1805,8 +1805,8 @@ export async function initCompile(ruta, compileTailwind = true, mode = 'individu
|
|
|
1805
1805
|
logger.info(`🔚 Destino: ${outFile}`);
|
|
1806
1806
|
logger.info(`⏱️ Tiempo: ${elapsedTime}`);
|
|
1807
1807
|
}
|
|
1808
|
-
const
|
|
1809
|
-
logger.info(
|
|
1808
|
+
const chalkLib = await loadChalk();
|
|
1809
|
+
logger.info(chalkLib.green(`✅ Compilación exitosa: ${path.basename(file)}`));
|
|
1810
1810
|
}
|
|
1811
1811
|
return {
|
|
1812
1812
|
success: true,
|
|
@@ -2020,11 +2020,11 @@ export async function runLinter(showResult = false) {
|
|
|
2020
2020
|
const parsedLinterEnv = JSON.parse(linterENV);
|
|
2021
2021
|
if (Array.isArray(parsedLinterEnv)) {
|
|
2022
2022
|
// Cargar dependencias de linting de forma lazy
|
|
2023
|
-
const { ESLint, OxLint } = await loadLinter();
|
|
2023
|
+
const { ESLint: ESLintLib, OxLint: OxLintLib } = await loadLinter();
|
|
2024
2024
|
for (const item of parsedLinterEnv) {
|
|
2025
2025
|
if (item.name.toLowerCase() === 'eslint') {
|
|
2026
2026
|
logger.info(`🔧 Ejecutando ESLint con config: ${item.configFile || 'por defecto'}`);
|
|
2027
|
-
const eslintPromise =
|
|
2027
|
+
const eslintPromise = ESLintLib(item)
|
|
2028
2028
|
.then((eslintResult) => {
|
|
2029
2029
|
if (eslintResult && eslintResult.json) {
|
|
2030
2030
|
// Procesar resultados de ESLint
|
|
@@ -2091,7 +2091,7 @@ export async function runLinter(showResult = false) {
|
|
|
2091
2091
|
}
|
|
2092
2092
|
else if (item.name.toLowerCase() === 'oxlint') {
|
|
2093
2093
|
logger.info(`🔧 Ejecutando OxLint con config: ${item.configFile || 'por defecto'}`);
|
|
2094
|
-
const oxlintPromise =
|
|
2094
|
+
const oxlintPromise = OxLintLib(item)
|
|
2095
2095
|
.then((oxlintResult) => {
|
|
2096
2096
|
if (oxlintResult &&
|
|
2097
2097
|
oxlintResult['json'] &&
|
|
@@ -2156,8 +2156,8 @@ export async function runLinter(showResult = false) {
|
|
|
2156
2156
|
await displayLinterErrors(linterErrors);
|
|
2157
2157
|
}
|
|
2158
2158
|
else {
|
|
2159
|
-
const
|
|
2160
|
-
logger.info(
|
|
2159
|
+
const chalkLib = await loadChalk();
|
|
2160
|
+
logger.info(chalkLib.green('✅ No se encontraron errores ni advertencias de linting.'));
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
2163
|
else {
|
|
@@ -2361,8 +2361,8 @@ export async function initCompileAll() {
|
|
|
2361
2361
|
logger.info(`🔚 Destino: ${pathDist}\n`);
|
|
2362
2362
|
// Fase 3: TailwindCSS
|
|
2363
2363
|
progressManager.updateProgress('🎨 Generando TailwindCSS...');
|
|
2364
|
-
const
|
|
2365
|
-
const resultTW = await
|
|
2364
|
+
const generateTailwindCSSLib = await loadTailwind();
|
|
2365
|
+
const resultTW = await generateTailwindCSSLib();
|
|
2366
2366
|
if (typeof resultTW !== 'boolean') {
|
|
2367
2367
|
if (resultTW?.success) {
|
|
2368
2368
|
logger.info(`🎨 ${resultTW.message}\n`);
|
|
@@ -2453,9 +2453,9 @@ export async function initCompileAll() {
|
|
|
2453
2453
|
// ⚠️ Warning si los hilos son muy pocos para el tamaño del proyecto
|
|
2454
2454
|
const optimalThreads = Math.min(cpuCount * 2, 24);
|
|
2455
2455
|
if (fileCount > 50 && maxConcurrency < optimalThreads * 0.5) {
|
|
2456
|
-
const
|
|
2457
|
-
logger.warn(
|
|
2458
|
-
logger.info(
|
|
2456
|
+
const chalkLib = await loadChalk();
|
|
2457
|
+
logger.warn(chalkLib.yellow(`⚠️ Solo se usarán ${maxConcurrency} hilos para ${fileCount} archivos.`));
|
|
2458
|
+
logger.info(chalkLib.yellow(` 💡 Tip: export VERSACOMPILER_MAX_THREADS=${optimalThreads}`));
|
|
2459
2459
|
}
|
|
2460
2460
|
// ⚠️ ADVERTENCIA: Si los hilos son muy bajos para el tamaño del proyecto
|
|
2461
2461
|
if (fileCount > 50 && maxConcurrency < 8) {
|