versacompiler 2.1.0 → 2.2.0

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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/compiler/compile.js +2520 -25
  3. package/dist/compiler/error-reporter.js +467 -38
  4. package/dist/compiler/linter.js +72 -1
  5. package/dist/compiler/minify.js +272 -1
  6. package/dist/compiler/minifyTemplate.js +230 -1
  7. package/dist/compiler/module-resolution-optimizer.js +844 -1
  8. package/dist/compiler/parser.js +336 -1
  9. package/dist/compiler/performance-monitor.js +204 -56
  10. package/dist/compiler/tailwindcss.js +39 -1
  11. package/dist/compiler/transform-optimizer.js +392 -1
  12. package/dist/compiler/transformTStoJS.js +16 -1
  13. package/dist/compiler/transforms.js +554 -1
  14. package/dist/compiler/typescript-compiler.js +172 -2
  15. package/dist/compiler/typescript-error-parser.js +281 -10
  16. package/dist/compiler/typescript-manager.js +304 -2
  17. package/dist/compiler/typescript-sync-validator.js +295 -31
  18. package/dist/compiler/typescript-worker-pool.js +936 -1
  19. package/dist/compiler/typescript-worker-thread.cjs +466 -22
  20. package/dist/compiler/typescript-worker.js +339 -1
  21. package/dist/compiler/vuejs.js +396 -37
  22. package/dist/hrm/VueHRM.js +359 -1
  23. package/dist/hrm/errorScreen.js +83 -1
  24. package/dist/hrm/getInstanciaVue.js +313 -1
  25. package/dist/hrm/initHRM.js +586 -1
  26. package/dist/main.js +353 -7
  27. package/dist/servicios/browserSync.js +589 -2
  28. package/dist/servicios/file-watcher.js +425 -4
  29. package/dist/servicios/logger.js +63 -3
  30. package/dist/servicios/readConfig.js +399 -53
  31. package/dist/utils/excluded-modules.js +37 -1
  32. package/dist/utils/module-resolver.js +466 -1
  33. package/dist/utils/promptUser.js +48 -2
  34. package/dist/utils/proxyValidator.js +68 -1
  35. package/dist/utils/resolve-bin.js +58 -1
  36. package/dist/utils/utils.js +21 -1
  37. package/dist/utils/vue-types-setup.js +435 -241
  38. package/dist/wrappers/eslint-node.js +1 -1
  39. package/dist/wrappers/oxlint-node.js +122 -1
  40. package/dist/wrappers/tailwind-node.js +94 -1
  41. package/package.json +106 -103
@@ -1,53 +1,399 @@
1
- import{normalize as e,relative as d,resolve as f}from"node:path";import*as p from"node:process";import{env as m}from"node:process";import{pathToFileURL as h}from"node:url";import{logger as g}from"./logger.js";const _=/^[a-zA-Z0-9.\-_/\\:@ ()[\]]+$/,v=[/\.\./,/[;&|`$]/,/\$\(/,/`.*`/,/\|\s*[a-zA-Z]/];export function validatePath(m){if(!m||typeof m!=`string`)return!1;if(m.length>260)return g.warn(`Ruta demasiado larga: ${m.length} caracteres`),!1;let h=e(m),v=f(p.cwd(),h);return d(p.cwd(),v).startsWith(`..`)||h.includes(`..`)?(g.error(`Detectado intento de path traversal: ${m}`),!1):_.test(m)?!0:(g.error(`Caracteres no permitidos en la ruta: ${m}`),!1)}export function validateCommand(e){if(!e||typeof e!=`string`)return!1;if(e.length>260)return g.warn(`Comando demasiado largo: ${e.length} caracteres`),!1;for(let d of v)if(d.test(e))return g.error(`Detectado patrón peligroso en comando: ${e}`),!1;return[`.exe`,`.cmd`,`.bat`,`.sh`,`.js`,`.ts`].some(d=>e.toLowerCase().includes(d)||e.startsWith(`./node_modules/.bin/`)||e.startsWith(`npx `))?!0:(g.error(`Comando no permitido: ${e}`),!1)}export function validateBundlers(e){if(!Array.isArray(e))return g.error(`bundlers debe ser un array`),!1;for(let d of e){if(!d||typeof d!=`object`)return g.error(`Cada entrada de bundler debe ser un objeto`),!1;if(!d.name||typeof d.name!=`string`)return g.error(`Cada entrada de bundler debe tener un nombre válido`),!1;if(!d.fileInput||typeof d.fileInput!=`string`)return g.error(`Cada entrada de bundler debe tener un fileInput válido`),!1;if(!validatePath(d.fileInput))return g.error(`Ruta de entrada no válida: ${d.fileInput}`),!1;if(!d.fileOutput||typeof d.fileOutput!=`string`)return g.error(`Cada entrada de bundler debe tener un fileOutput válido`),!1;if(!validatePath(d.fileOutput))return g.error(`Ruta de salida no válida: ${d.fileOutput}`),!1}return!0}export function validateConfigStructure(e){if(!e||typeof e!=`object`)return g.error(`La configuración debe ser un objeto`),!1;if(!e.compilerOptions||typeof e.compilerOptions!=`object`)return g.error(`compilerOptions es requerido y debe ser un objeto`),!1;if(!e.compilerOptions.pathsAlias||typeof e.compilerOptions.pathsAlias!=`object`)return g.error(`pathsAlias es requerido y debe ser un objeto`),!1;for(let[d,f]of Object.entries(e.compilerOptions.pathsAlias)){if(!Array.isArray(f))return g.error(`pathsAlias["${d}"] debe ser un array`),!1;for(let e of f){if(typeof e!=`string`)return g.error(`Todas las rutas en pathsAlias["${d}"] deben ser strings`),!1;if(!validatePath(e.replace(`/*`,``)))return g.error(`Ruta no válida en pathsAlias["${d}"]: ${e}`),!1}}if(e.compilerOptions.sourceRoot&&!validatePath(e.compilerOptions.sourceRoot)||e.compilerOptions.outDir&&!validatePath(e.compilerOptions.outDir))return!1;if(e.linter&&e.linter!==!1){if(!Array.isArray(e.linter))return g.error(`linter debe ser un array o false`),!1;for(let d of e.linter)if(!validateLinter(d))return!1}return!0}export function validateLinter(e){if(!e||typeof e!=`object`)return g.error(`Cada linter debe ser un objeto`),!1;if(!e.name||typeof e.name!=`string`)return g.error(`Linter debe tener un nombre válido`),!1;if(!e.bin||typeof e.bin!=`string`)return g.error(`Linter debe tener un bin válido`),!1;if(!validateCommand(e.bin))return!1;if(!e.configFile||typeof e.configFile!=`string`)return g.error(`Linter debe tener un configFile válido`),!1;if(!validatePath(e.configFile))return!1;if(e.paths&&!Array.isArray(e.paths))return g.error(`linter.paths debe ser un array`),!1;if(e.paths){for(let d of e.paths)if(typeof d!=`string`||!validatePath(d))return g.error(`Ruta de linter no válida: ${d}`),!1}return e.fix!==void 0&&typeof e.fix!=`boolean`?(g.error(`Linter fix debe ser un booleano`),!1):!0}export function validateConfigSize(e){try{let d=JSON.stringify(e);return d.length>1048576?(g.error(`Configuración demasiado grande: ${d.length} bytes`),!1):!0}catch(e){return g.error(`Error al serializar configuración (posible referencia circular):`,e),!1}}function y(e){return!e||typeof e!=`string`?``:e.endsWith(`/`)||e.endsWith(`\\`)?e.slice(0,-1):e}function b(e,d=`false`){try{return e==null?d:JSON.stringify(e)}catch(e){return g.warn(`Error al serializar objeto, usando valor por defecto:`,e),d}}export async function dynamicImport(e){return import(e)}export function withTimeout(e,d,f){let p=new Promise((e,p)=>setTimeout(()=>p(Error(f)),d));return Promise.race([e,p])}export async function readConfig(){try{if(!m.PATH_CONFIG_FILE)throw Error(`La variable de entorno PATH_CONFIG_FILE no está definida.`);if(!validatePath(m.PATH_CONFIG_FILE))throw Error(`Ruta de configuración no válida: ${m.PATH_CONFIG_FILE}`);let e=h(m.PATH_CONFIG_FILE).href,d=await withTimeout(dynamicImport(e),1e4,`Timeout al cargar configuración`);if(!d)throw Error(`No se pudo leer el archivo de configuración.`);let f=d.default||d;if(!validateConfigSize(f))throw Error(`Configuración demasiado grande o contiene referencias circulares.`);if(!validateConfigStructure(f))throw Error(`El archivo de configuración no tiene una estructura válida.`);let p={...f.compilerOptions.pathsAlias};for(let e in p){let d=p[e];if(d&&Array.isArray(d))for(let e=0;e<d.length;e++)typeof d[e]==`string`&&d[e]!==void 0&&(d[e]=d[e].replace(`/*`,``))}m.PATH_ALIAS=b(p,`{}`),m.tailwindcss=b(f?.tailwindConfig,`false`),m.proxyUrl=String(f?.proxyConfig?.proxyUrl||``),m.AssetsOmit=String(f?.proxyConfig?.assetsOmit||!1),m.linter=b(f?.linter,`false`),m.tsconfigFile=f?.tsconfig||`./tsconfig.json`;let _=y(f?.compilerOptions?.sourceRoot||`./src`),v=y(f?.compilerOptions?.outDir||`./dist`);if(!validatePath(_))throw Error(`sourceRoot no válido: ${_}`);if(!validatePath(v))throw Error(`outDir no válido: ${v}`);return m.PATH_SOURCE=_,m.PATH_DIST=v,m.aditionalWatch=b(f?.aditionalWatch,`[]`),m.bundlers=b(f?.bundlers,`false`),f.compilerOptions.sourceRoot||(m.tsConfig=b(f,`{}`)),g.info(`✅ Configuration loaded and validated successfully`),!0}catch(e){return g.error(`🚩 Error al leer el archivo ${m.PATH_CONFIG_FILE}: ${e}`,e),!1}}export async function initConfig(){try{let e=await dynamicImport(`fs`),d=(await dynamicImport(`path`)).resolve(p.cwd(),m.PATH_CONFIG_FILE||`versacompile.config.ts`);if(!validatePath(d))throw Error(`Ruta de configuración no válida: ${d}`);return e.existsSync(d)?(g.warn(`🚩 El archivo de configuración '${m.PATH_CONFIG_FILE}' ya existe.`),!0):(e.writeFileSync(d,`// Archivo de configuración de VersaCompiler
2
- export default {
3
- tsconfig: './tsconfig.json',
4
- compilerOptions: {
5
- sourceRoot: './src',
6
- outDir: './dist',
7
- pathsAlias: {
8
- '/dist/examples/*': ['src/*'],
9
- '/dist/public/*': ['public/*'],
10
- },
11
- },
12
- proxyConfig: {
13
- proxyUrl: '',
14
- assetsOmit: true,
15
- },
16
- aditionalWatch: ['./app/templates/**/*.twig', './app/templates/**/*.html'],
17
- // puede dejar en false o no agregarlo si no quiere que se ejecute el compilador de tailwind
18
- tailwindConfig: {
19
- bin: './node_modules/.bin/tailwindcss',
20
- input: './src/css/input.css',
21
- output: './public/css/output.css',
22
- },
23
- linter: [
24
- {
25
- name: 'eslint',
26
- bin: './node_modules/.bin/eslint',
27
- configFile: './.eslintrc.json',
28
- fix: false,
29
- paths: ['src/']
30
- },
31
- {
32
- name: 'oxlint',
33
- bin: './node_modules/.bin/oxlint',
34
- configFile: './.oxlintrc.json',
35
- fix: false,
36
- paths: ['src/']
37
- },
38
- ],
39
- // Configuración de bundlers
40
- bundlers: [
41
- {
42
- name: 'appLoader',
43
- fileInput: './public/module/appLoader.js',
44
- fileOutput: './public/module/appLoader.prod.js',
45
- },
46
- {
47
- name: 'mainApp',
48
- fileInput: './src/main.ts',
49
- fileOutput: './dist/main.bundle.js',
50
- }
51
- ],
52
- };
53
- `,`utf8`),g.info(`🚩 Archivo de configuración '${m.PATH_CONFIG_FILE}' creado correctamente.`),!0)}catch(e){return g.error(`🚩 Error al crear el archivo de configuración: ${e}`,e),!1}}
1
+ import { normalize, relative, resolve } from 'node:path';
2
+ import * as process from 'node:process';
3
+ import { env } from 'node:process';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { logger } from './logger.js';
6
+ /**
7
+ * Utilidades de seguridad para validar configuraciones
8
+ */
9
+ const MAX_PATH_LENGTH = 260; // Windows MAX_PATH limit
10
+ const MAX_CONFIG_SIZE = 1024 * 1024; // 1MB max config size
11
+ const ALLOWED_PATH_CHARS = /^[a-zA-Z0-9.\-_/\\:@ ()[\]]+$/;
12
+ const DANGEROUS_PATTERNS = [
13
+ /\.\./, // Path traversal
14
+ /[;&|`$]/, // Command injection characters
15
+ /\$\(/, // Command substitution
16
+ /`.*`/, // Backtick execution
17
+ /\|\s*[a-zA-Z]/, // Pipe to commands
18
+ ];
19
+ export function validatePath(pathStr) {
20
+ if (!pathStr || typeof pathStr !== 'string') {
21
+ return false;
22
+ }
23
+ if (pathStr.length > MAX_PATH_LENGTH) {
24
+ logger.warn(`Ruta demasiado larga: ${pathStr.length} caracteres`);
25
+ return false;
26
+ }
27
+ // Normalizar la ruta para detectar path traversal
28
+ const normalizedPath = normalize(pathStr);
29
+ const resolvedPath = resolve(process.cwd(), normalizedPath);
30
+ const relativePath = relative(process.cwd(), resolvedPath);
31
+ // Verificar si la ruta trata de salir del directorio actual
32
+ if (relativePath.startsWith('..') || normalizedPath.includes('..')) {
33
+ logger.error(`Detectado intento de path traversal: ${pathStr}`);
34
+ return false;
35
+ }
36
+ // Verificar caracteres permitidos
37
+ if (!ALLOWED_PATH_CHARS.test(pathStr)) {
38
+ logger.error(`Caracteres no permitidos en la ruta: ${pathStr}`);
39
+ return false;
40
+ }
41
+ return true;
42
+ }
43
+ export function validateCommand(command) {
44
+ if (!command || typeof command !== 'string') {
45
+ return false;
46
+ }
47
+ if (command.length > MAX_PATH_LENGTH) {
48
+ logger.warn(`Comando demasiado largo: ${command.length} caracteres`);
49
+ return false;
50
+ }
51
+ // Verificar patrones peligrosos
52
+ for (const pattern of DANGEROUS_PATTERNS) {
53
+ if (pattern.test(command)) {
54
+ logger.error(`Detectado patrón peligroso en comando: ${command}`);
55
+ return false;
56
+ }
57
+ }
58
+ // Solo permitir comandos que terminen en extensiones seguras
59
+ const allowedExecutables = ['.exe', '.cmd', '.bat', '.sh', '.js', '.ts'];
60
+ const hasAllowedExtension = allowedExecutables.some(ext => command.toLowerCase().includes(ext) ||
61
+ command.startsWith('./node_modules/.bin/') ||
62
+ command.startsWith('npx '));
63
+ if (!hasAllowedExtension) {
64
+ logger.error(`Comando no permitido: ${command}`);
65
+ return false;
66
+ }
67
+ return true;
68
+ }
69
+ export function validateBundlers(bundlers) {
70
+ if (!Array.isArray(bundlers)) {
71
+ logger.error('bundlers debe ser un array');
72
+ return false;
73
+ }
74
+ for (const entry of bundlers) {
75
+ if (!entry || typeof entry !== 'object') {
76
+ logger.error('Cada entrada de bundler debe ser un objeto');
77
+ return false;
78
+ }
79
+ if (!entry.name || typeof entry.name !== 'string') {
80
+ logger.error('Cada entrada de bundler debe tener un nombre válido');
81
+ return false;
82
+ }
83
+ if (!entry.fileInput || typeof entry.fileInput !== 'string') {
84
+ logger.error('Cada entrada de bundler debe tener un fileInput válido');
85
+ return false;
86
+ }
87
+ if (!validatePath(entry.fileInput)) {
88
+ logger.error(`Ruta de entrada no válida: ${entry.fileInput}`);
89
+ return false;
90
+ }
91
+ if (!entry.fileOutput || typeof entry.fileOutput !== 'string') {
92
+ logger.error('Cada entrada de bundler debe tener un fileOutput válido');
93
+ return false;
94
+ }
95
+ if (!validatePath(entry.fileOutput)) {
96
+ logger.error(`Ruta de salida no válida: ${entry.fileOutput}`);
97
+ return false;
98
+ }
99
+ }
100
+ return true;
101
+ }
102
+ export function validateConfigStructure(config) {
103
+ if (!config || typeof config !== 'object') {
104
+ logger.error('La configuración debe ser un objeto');
105
+ return false;
106
+ }
107
+ if (!config.compilerOptions || typeof config.compilerOptions !== 'object') {
108
+ logger.error('compilerOptions es requerido y debe ser un objeto');
109
+ return false;
110
+ }
111
+ if (!config.compilerOptions.pathsAlias || typeof config.compilerOptions.pathsAlias !== 'object') {
112
+ logger.error('pathsAlias es requerido y debe ser un objeto');
113
+ return false;
114
+ }
115
+ // Validar pathsAlias
116
+ for (const [key, value] of Object.entries(config.compilerOptions.pathsAlias)) {
117
+ if (!Array.isArray(value)) {
118
+ logger.error(`pathsAlias["${key}"] debe ser un array`);
119
+ return false;
120
+ }
121
+ for (const p of value) {
122
+ if (typeof p !== 'string') {
123
+ logger.error(`Todas las rutas en pathsAlias["${key}"] deben ser strings`);
124
+ return false;
125
+ }
126
+ if (!validatePath(p.replace('/*', ''))) {
127
+ logger.error(`Ruta no válida en pathsAlias["${key}"]: ${p}`);
128
+ return false;
129
+ }
130
+ }
131
+ }
132
+ // Validar sourceRoot si existe
133
+ if (config.compilerOptions.sourceRoot && !validatePath(config.compilerOptions.sourceRoot)) {
134
+ return false;
135
+ }
136
+ // Validar outDir si existe
137
+ if (config.compilerOptions.outDir && !validatePath(config.compilerOptions.outDir)) {
138
+ return false;
139
+ }
140
+ // Validar linter si existe
141
+ if (config.linter && config.linter !== false) {
142
+ if (!Array.isArray(config.linter)) {
143
+ logger.error('linter debe ser un array o false');
144
+ return false;
145
+ }
146
+ for (const linter of config.linter) {
147
+ if (!validateLinter(linter)) {
148
+ return false;
149
+ }
150
+ }
151
+ }
152
+ return true;
153
+ }
154
+ export function validateLinter(linter) {
155
+ if (!linter || typeof linter !== 'object') {
156
+ logger.error('Cada linter debe ser un objeto');
157
+ return false;
158
+ }
159
+ if (!linter.name || typeof linter.name !== 'string') {
160
+ logger.error('Linter debe tener un nombre válido');
161
+ return false;
162
+ }
163
+ if (!linter.bin || typeof linter.bin !== 'string') {
164
+ logger.error('Linter debe tener un bin válido');
165
+ return false;
166
+ }
167
+ if (!validateCommand(linter.bin)) {
168
+ return false;
169
+ }
170
+ if (!linter.configFile || typeof linter.configFile !== 'string') {
171
+ logger.error('Linter debe tener un configFile válido');
172
+ return false;
173
+ }
174
+ if (!validatePath(linter.configFile)) {
175
+ return false;
176
+ }
177
+ if (linter.paths && !Array.isArray(linter.paths)) {
178
+ logger.error('linter.paths debe ser un array');
179
+ return false;
180
+ }
181
+ if (linter.paths) {
182
+ for (const p of linter.paths) {
183
+ if (typeof p !== 'string' || !validatePath(p)) {
184
+ logger.error(`Ruta de linter no válida: ${p}`);
185
+ return false;
186
+ }
187
+ }
188
+ }
189
+ if (linter.fix !== undefined && typeof linter.fix !== 'boolean') {
190
+ logger.error('Linter fix debe ser un booleano');
191
+ return false;
192
+ }
193
+ return true;
194
+ }
195
+ export function validateConfigSize(config) {
196
+ try {
197
+ const configString = JSON.stringify(config);
198
+ if (configString.length > MAX_CONFIG_SIZE) {
199
+ logger.error(`Configuración demasiado grande: ${configString.length} bytes`);
200
+ return false;
201
+ }
202
+ return true;
203
+ }
204
+ catch (error) {
205
+ logger.error('Error al serializar configuración (posible referencia circular):', error);
206
+ return false;
207
+ }
208
+ }
209
+ /**
210
+ * Limpia y normaliza una ruta eliminando barras finales
211
+ */
212
+ function cleanPath(path) {
213
+ if (!path || typeof path !== 'string') {
214
+ return '';
215
+ }
216
+ return path.endsWith('/') || path.endsWith('\\') ? path.slice(0, -1) : path;
217
+ }
218
+ /**
219
+ * Serializa de forma segura un objeto a JSON
220
+ */
221
+ function safeJsonStringify(obj, fallback = 'false') {
222
+ try {
223
+ if (obj === null || obj === undefined) {
224
+ return fallback;
225
+ }
226
+ return JSON.stringify(obj);
227
+ }
228
+ catch (error) {
229
+ logger.warn('Error al serializar objeto, usando valor por defecto:', error);
230
+ return fallback;
231
+ }
232
+ }
233
+ /**
234
+ * Wrapper para el import dinámico que permite mejor testing
235
+ */
236
+ export async function dynamicImport(url) {
237
+ return import(url);
238
+ }
239
+ /**
240
+ * Timeout wrapper para promises
241
+ */
242
+ export function withTimeout(promise, timeoutMs, errorMessage) {
243
+ const timeoutPromise = new Promise((resolve, reject) => setTimeout(() => reject(new Error(errorMessage)), timeoutMs));
244
+ return Promise.race([promise, timeoutPromise]);
245
+ }
246
+ /**
247
+ * Lee y valida el archivo de configuración de forma segura
248
+ */
249
+ export async function readConfig() {
250
+ try {
251
+ // Validar variable de entorno
252
+ if (!env.PATH_CONFIG_FILE) {
253
+ throw new Error('La variable de entorno PATH_CONFIG_FILE no está definida.');
254
+ }
255
+ // Validar la ruta del archivo de configuración
256
+ if (!validatePath(env.PATH_CONFIG_FILE)) {
257
+ throw new Error(`Ruta de configuración no válida: ${env.PATH_CONFIG_FILE}`);
258
+ }
259
+ // Convertir la ruta del archivo a una URL file://
260
+ const configFileUrl = pathToFileURL(env.PATH_CONFIG_FILE).href;
261
+ // Importar con timeout para prevenir ataques DoS
262
+ const importPromise = dynamicImport(configFileUrl);
263
+ const data = await withTimeout(importPromise, 10000, 'Timeout al cargar configuración');
264
+ if (!data) {
265
+ throw new Error('No se pudo leer el archivo de configuración.');
266
+ }
267
+ const tsConfig = data.default || data;
268
+ // Validar tamaño de configuración
269
+ if (!validateConfigSize(tsConfig)) {
270
+ throw new Error('Configuración demasiado grande o contiene referencias circulares.');
271
+ }
272
+ // Validar estructura de configuración
273
+ if (!validateConfigStructure(tsConfig)) {
274
+ throw new Error('El archivo de configuración no tiene una estructura válida.');
275
+ }
276
+ // Procesar pathsAlias de forma segura
277
+ const pathAlias = { ...tsConfig.compilerOptions.pathsAlias }; // Eliminar /* de las rutas de alias
278
+ for (const key in pathAlias) {
279
+ const values = pathAlias[key];
280
+ if (values && Array.isArray(values)) {
281
+ for (let i = 0; i < values.length; i++) {
282
+ if (typeof values[i] === 'string' &&
283
+ values[i] !== undefined) {
284
+ values[i] = values[i].replace('/*', '');
285
+ }
286
+ }
287
+ }
288
+ }
289
+ // Establecer variables de entorno de forma segura
290
+ env.PATH_ALIAS = safeJsonStringify(pathAlias, '{}');
291
+ env.tailwindcss = safeJsonStringify(tsConfig?.tailwindConfig, 'false');
292
+ env.proxyUrl = String(tsConfig?.proxyConfig?.proxyUrl || '');
293
+ env.AssetsOmit = String(tsConfig?.proxyConfig?.assetsOmit || false);
294
+ env.linter = safeJsonStringify(tsConfig?.linter, 'false');
295
+ env.tsconfigFile = tsConfig?.tsconfig || './tsconfig.json';
296
+ // Validar y limpiar rutas
297
+ const sourceRoot = cleanPath(tsConfig?.compilerOptions?.sourceRoot || './src');
298
+ const outDir = cleanPath(tsConfig?.compilerOptions?.outDir || './dist');
299
+ if (!validatePath(sourceRoot)) {
300
+ throw new Error(`sourceRoot no válido: ${sourceRoot}`);
301
+ }
302
+ if (!validatePath(outDir)) {
303
+ throw new Error(`outDir no válido: ${outDir}`);
304
+ }
305
+ env.PATH_SOURCE = sourceRoot;
306
+ env.PATH_DIST = outDir;
307
+ env.aditionalWatch = safeJsonStringify(tsConfig?.aditionalWatch, '[]');
308
+ env.bundlers = safeJsonStringify(tsConfig?.bundlers, 'false');
309
+ // Configuración adicional para compatibilidad
310
+ if (!tsConfig.compilerOptions.sourceRoot) {
311
+ env.tsConfig = safeJsonStringify(tsConfig, '{}');
312
+ }
313
+ logger.info('✅ Configuration loaded and validated successfully');
314
+ return true;
315
+ }
316
+ catch (error) {
317
+ logger.error(`🚩 Error al leer el archivo ${env.PATH_CONFIG_FILE}: ${error}`, error);
318
+ return false;
319
+ }
320
+ }
321
+ /**
322
+ * Inicializa un archivo de configuración seguro por defecto
323
+ */
324
+ export async function initConfig() {
325
+ try {
326
+ const fs = await dynamicImport('fs');
327
+ const path = await dynamicImport('path');
328
+ const configPath = path.resolve(process.cwd(), env.PATH_CONFIG_FILE || 'versacompile.config.ts');
329
+ // Validar que la ruta de destino sea segura
330
+ if (!validatePath(configPath)) {
331
+ throw new Error(`Ruta de configuración no válida: ${configPath}`);
332
+ }
333
+ if (fs.existsSync(configPath)) {
334
+ logger.warn(`🚩 El archivo de configuración '${env.PATH_CONFIG_FILE}' ya existe.`);
335
+ return true;
336
+ }
337
+ const configContent = `// Archivo de configuración de VersaCompiler
338
+ export default {
339
+ tsconfig: './tsconfig.json',
340
+ compilerOptions: {
341
+ sourceRoot: './src',
342
+ outDir: './dist',
343
+ pathsAlias: {
344
+ '/dist/examples/*': ['src/*'],
345
+ '/dist/public/*': ['public/*'],
346
+ },
347
+ },
348
+ proxyConfig: {
349
+ proxyUrl: '',
350
+ assetsOmit: true,
351
+ },
352
+ aditionalWatch: ['./app/templates/**/*.twig', './app/templates/**/*.html'],
353
+ // puede dejar en false o no agregarlo si no quiere que se ejecute el compilador de tailwind
354
+ tailwindConfig: {
355
+ bin: './node_modules/.bin/tailwindcss',
356
+ input: './src/css/input.css',
357
+ output: './public/css/output.css',
358
+ },
359
+ linter: [
360
+ {
361
+ name: 'eslint',
362
+ bin: './node_modules/.bin/eslint',
363
+ configFile: './.eslintrc.json',
364
+ fix: false,
365
+ paths: ['src/']
366
+ },
367
+ {
368
+ name: 'oxlint',
369
+ bin: './node_modules/.bin/oxlint',
370
+ configFile: './.oxlintrc.json',
371
+ fix: false,
372
+ paths: ['src/']
373
+ },
374
+ ],
375
+ // Configuración de bundlers
376
+ bundlers: [
377
+ {
378
+ name: 'appLoader',
379
+ fileInput: './public/module/appLoader.js',
380
+ fileOutput: './public/module/appLoader.prod.js',
381
+ },
382
+ {
383
+ name: 'mainApp',
384
+ fileInput: './src/main.ts',
385
+ fileOutput: './dist/main.bundle.js',
386
+ }
387
+ ],
388
+ };
389
+ `;
390
+ fs.writeFileSync(configPath, configContent, 'utf8');
391
+ logger.info(`🚩 Archivo de configuración '${env.PATH_CONFIG_FILE}' creado correctamente.`);
392
+ return true;
393
+ }
394
+ catch (error) {
395
+ logger.error(`🚩 Error al crear el archivo de configuración: ${error}`, error);
396
+ return false;
397
+ }
398
+ }
399
+ //# sourceMappingURL=readConfig.js.map
@@ -1 +1,37 @@
1
- export const EXCLUDED_MODULES=new Set([`vue/compiler-sfc`,`vue/dist/vue.runtime.esm-bundler`,`@vue/compiler-sfc`,`@vue/compiler-dom`,`@vue/runtime-core`,`@vue/runtime-dom`,`oxc-parser`,`oxc-parser/wasm`,`oxc-minify`,`oxc-minify/browser`,`@oxc-parser/binding-wasm32-wasi`,`@oxc-minify/binding-wasm32-wasi`,`typescript`,`typescript/lib/typescript`,`yargs`,`yargs/helpers`,`yargs-parser`,`chalk`,`browser-sync`,`chokidar`,`get-port`,`execa`,`find-root`,`fs-extra`,`minimatch`]);
1
+ /**
2
+ * Lista centralizada de módulos excluidos de la resolución automática
3
+ * Estos módulos se mantienen con su importación original sin transformar
4
+ */
5
+ export const EXCLUDED_MODULES = new Set([
6
+ // Módulos de Vue.js que requieren resolución específica
7
+ 'vue/compiler-sfc',
8
+ 'vue/dist/vue.runtime.esm-bundler',
9
+ '@vue/compiler-sfc',
10
+ '@vue/compiler-dom',
11
+ '@vue/runtime-core',
12
+ '@vue/runtime-dom',
13
+ // Módulos de oxc-parser que tienen dependencias específicas de WASM
14
+ 'oxc-parser',
15
+ 'oxc-parser/wasm',
16
+ 'oxc-minify',
17
+ 'oxc-minify/browser',
18
+ '@oxc-parser/binding-wasm32-wasi',
19
+ '@oxc-minify/binding-wasm32-wasi',
20
+ // Módulos de TypeScript que pueden tener resoluciones complejas
21
+ 'typescript',
22
+ 'typescript/lib/typescript',
23
+ // Módulos de herramientas de build y utilidades que deben mantenerse originales
24
+ 'yargs',
25
+ 'yargs/helpers',
26
+ 'yargs-parser',
27
+ 'chalk',
28
+ 'browser-sync',
29
+ 'chokidar',
30
+ 'get-port',
31
+ 'execa',
32
+ 'find-root',
33
+ 'fs-extra',
34
+ 'minimatch', // ✅ Incluir minimatch aquí
35
+ 'minify-html-literals',
36
+ ]);
37
+ //# sourceMappingURL=excluded-modules.js.map