versacompiler 1.0.4 → 2.0.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 +357 -145
  2. package/dist/compiler/compile.js +1120 -0
  3. package/dist/compiler/error-reporter.js +467 -0
  4. package/dist/compiler/linter.js +72 -0
  5. package/dist/{services → compiler}/minify.js +40 -31
  6. package/dist/compiler/parser.js +30 -0
  7. package/dist/compiler/tailwindcss.js +39 -0
  8. package/dist/compiler/transformTStoJS.js +16 -0
  9. package/dist/compiler/transforms.js +544 -0
  10. package/dist/compiler/typescript-error-parser.js +282 -0
  11. package/dist/compiler/typescript-sync-validator.js +230 -0
  12. package/dist/compiler/typescript-worker-thread.cjs +457 -0
  13. package/dist/compiler/typescript-worker.js +309 -0
  14. package/dist/compiler/typescript.js +382 -0
  15. package/dist/compiler/vuejs.js +296 -0
  16. package/dist/hrm/VueHRM.js +353 -0
  17. package/dist/hrm/errorScreen.js +23 -1
  18. package/dist/hrm/getInstanciaVue.js +313 -0
  19. package/dist/hrm/initHRM.js +140 -0
  20. package/dist/main.js +287 -0
  21. package/dist/servicios/browserSync.js +177 -0
  22. package/dist/servicios/chokidar.js +178 -0
  23. package/dist/servicios/logger.js +33 -0
  24. package/dist/servicios/readConfig.js +429 -0
  25. package/dist/utils/module-resolver.js +506 -0
  26. package/dist/utils/promptUser.js +48 -0
  27. package/dist/utils/resolve-bin.js +29 -0
  28. package/dist/utils/utils.js +21 -48
  29. package/dist/wrappers/eslint-node.js +145 -0
  30. package/dist/wrappers/oxlint-node.js +120 -0
  31. package/dist/wrappers/tailwind-node.js +92 -0
  32. package/package.json +62 -15
  33. package/dist/hrm/devMode.js +0 -249
  34. package/dist/hrm/instanciaVue.js +0 -35
  35. package/dist/hrm/setupHMR.js +0 -57
  36. package/dist/index.js +0 -873
  37. package/dist/services/acorn.js +0 -29
  38. package/dist/services/linter.js +0 -55
  39. package/dist/services/typescript.js +0 -89
  40. package/dist/services/vueLoader.js +0 -324
  41. package/dist/services/vuejs.js +0 -259
@@ -0,0 +1,145 @@
1
+ import path from 'node:path'; // Añadir importación de path
2
+ import { cwd } from 'node:process'; // Añadir importación de cwd
3
+ import { execa } from 'execa';
4
+ import { resolveBin } from '../utils/resolve-bin.js';
5
+ export class ESLintNode {
6
+ binPath;
7
+ fix;
8
+ configFile;
9
+ quiet;
10
+ deny;
11
+ allow;
12
+ noIgnore;
13
+ ignorePath;
14
+ ignorePattern;
15
+ formats;
16
+ additionalArgs;
17
+ constructor(options = {}) {
18
+ this.binPath = options.binPath || ESLintNode.getDefaultBinPath();
19
+ this.fix = options.fix || false;
20
+ this.configFile = options.configFile;
21
+ this.quiet = options.quiet || false;
22
+ this.deny = options.deny;
23
+ this.allow = options.allow;
24
+ this.noIgnore = options.noIgnore || false;
25
+ this.ignorePath = options.ignorePath;
26
+ this.ignorePattern = options.ignorePattern;
27
+ this.formats = options.formats || ['json']; // Por defecto, solo 'json'
28
+ this.additionalArgs = options.additionalArgs;
29
+ }
30
+ static getDefaultBinPath() {
31
+ try {
32
+ return resolveBin('eslint', { executable: 'eslint' });
33
+ }
34
+ catch (error) {
35
+ console.error("Error al resolver el binario de ESLint. Asegúrate de que 'eslint' esté instalado y en el PATH, o provee la opción 'binPath'.", error);
36
+ throw new Error('Error al resolver el binario de ESLint.');
37
+ }
38
+ }
39
+ async version() {
40
+ const { stdout: version } = await execa(this.binPath, ['--version']);
41
+ return version;
42
+ }
43
+ /**
44
+ * Ejecuta ESLint para los formatos configurados y devuelve los resultados.
45
+ * @param paths Rutas o patrones glob para los archivos a lint.
46
+ * @returns Un objeto donde cada clave es un formato y el valor es el resultado (parseado si es JSON).
47
+ */
48
+ async run(paths = []) {
49
+ const results = {};
50
+ const targetPaths = paths.length > 0 ? paths : ['.'];
51
+ const projectRoot = cwd(); // Obtener la ruta raíz del proyecto
52
+ await Promise.all(this.formats.map(async (format) => {
53
+ const cliArgs = this.toCliArgs(format, targetPaths);
54
+ try {
55
+ const { stdout, stderr, exitCode } = await execa(this.binPath, cliArgs, { reject: false });
56
+ if (exitCode !== 0 &&
57
+ format !== 'json' &&
58
+ format !== 'sarif') {
59
+ if (stderr && !stdout) {
60
+ console.warn(`ESLint para formato '${format}' finalizó con código ${exitCode} y stderr: ${stderr}`);
61
+ }
62
+ }
63
+ if (format === 'json') {
64
+ // ESLint devuelve un array de archivos con mensajes anidados
65
+ // Necesitamos aplanar esta estructura para que coincida con lo que espera el compilador
66
+ const eslintOutput = JSON.parse(stdout || '[]');
67
+ const flattenedResults = [];
68
+ for (const fileResult of eslintOutput) {
69
+ for (const message of fileResult.messages || []) {
70
+ // Calcular ruta relativa
71
+ const relativeFilePath = path
72
+ .relative(projectRoot, fileResult.filePath)
73
+ .replace(/\\/g, '/');
74
+ flattenedResults.push({
75
+ filePath: relativeFilePath, // Usar ruta relativa
76
+ file: relativeFilePath, // Alias para compatibilidad
77
+ message: message.message,
78
+ severity: message.severity,
79
+ ruleId: message.ruleId,
80
+ line: message.line,
81
+ column: message.column,
82
+ });
83
+ }
84
+ }
85
+ results[format] = flattenedResults;
86
+ }
87
+ else if (format === 'sarif') {
88
+ results[format] = JSON.parse(stdout || '{}');
89
+ }
90
+ else {
91
+ results[format] = stdout;
92
+ }
93
+ }
94
+ catch (error) {
95
+ console.error(`Error ejecutando ESLint para formato '${format}':`, error.shortMessage || error.message);
96
+ results[format] = {
97
+ error: error.shortMessage || error.message,
98
+ details: error,
99
+ };
100
+ }
101
+ }));
102
+ return results;
103
+ }
104
+ /**
105
+ * Construye el array de argumentos para pasar al CLI de ESLint para un formato específico.
106
+ */
107
+ toCliArgs(format, paths) {
108
+ const args = [];
109
+ // Opciones directas
110
+ if (this.fix)
111
+ args.push('--fix');
112
+ if (this.configFile)
113
+ args.push('--config', this.configFile);
114
+ if (this.quiet)
115
+ args.push('--quiet');
116
+ if (this.noIgnore)
117
+ args.push('--no-ignore');
118
+ if (this.ignorePath)
119
+ args.push('--ignore-path', this.ignorePath);
120
+ if (this.deny)
121
+ this.deny.forEach(rule => args.push('--rule', `${rule}:error`));
122
+ if (this.allow)
123
+ this.allow.forEach(rule => args.push('--rule', `${rule}:off`));
124
+ if (this.ignorePattern)
125
+ this.ignorePattern.forEach(pattern => args.push('--ignore-pattern', pattern));
126
+ // Formato
127
+ if (format !== 'stylish') {
128
+ args.push('--format', format);
129
+ }
130
+ // Argumentos adicionales
131
+ if (this.additionalArgs)
132
+ args.push(...this.additionalArgs);
133
+ // Rutas/patrones
134
+ args.push(...paths);
135
+ return args;
136
+ }
137
+ /**
138
+ * Método estático para crear una instancia de ESLintNode, similar al código de referencia.
139
+ * @param options Opciones de configuración.
140
+ */
141
+ static create(options) {
142
+ return new ESLintNode(options);
143
+ }
144
+ }
145
+ //# sourceMappingURL=eslint-node.js.map
@@ -0,0 +1,120 @@
1
+ import { execa } from 'execa';
2
+ import { resolveBin } from '../utils/resolve-bin.js';
3
+ export class OxlintNode {
4
+ binPath;
5
+ fix;
6
+ configFile;
7
+ tsconfigPath;
8
+ quiet;
9
+ deny;
10
+ allow;
11
+ noIgnore;
12
+ ignorePath;
13
+ ignorePattern;
14
+ formats;
15
+ additionalArgs;
16
+ constructor(options = {}) {
17
+ this.binPath = options.binPath || OxlintNode.getDefaultBinPath();
18
+ this.fix = options.fix || false;
19
+ this.configFile = options.configFile;
20
+ this.tsconfigPath = options.tsconfigPath;
21
+ this.quiet = options.quiet || false;
22
+ this.deny = options.deny;
23
+ this.allow = options.allow;
24
+ this.noIgnore = options.noIgnore || false;
25
+ this.ignorePath = options.ignorePath;
26
+ this.ignorePattern = options.ignorePattern;
27
+ this.formats = options.formats || ['json']; // Por defecto, solo 'json'
28
+ this.additionalArgs = options.additionalArgs;
29
+ }
30
+ static getDefaultBinPath() {
31
+ try {
32
+ return resolveBin('oxlint', { executable: 'oxlint' });
33
+ }
34
+ catch (error) {
35
+ console.error("Error al resolver el binario de Oxlint. Asegúrate de que 'oxlint' esté instalado y en el PATH, o provee la opción 'binPath'.", error);
36
+ throw new Error('Error al resolver el binario de Oxlint.');
37
+ }
38
+ }
39
+ async version() {
40
+ const { stdout: version } = await execa(this.binPath, ['--version']);
41
+ return version;
42
+ }
43
+ /**
44
+ * Ejecuta Oxlint para los formatos configurados y devuelve los resultados.
45
+ * @param paths Rutas o patrones glob para los archivos a lint.
46
+ * @returns Un objeto donde cada clave es un formato y el valor es el resultado (parseado si es JSON).
47
+ */
48
+ async run(paths = []) {
49
+ const results = {};
50
+ const targetPaths = paths.length > 0 ? paths : ['.'];
51
+ await Promise.all(this.formats.map(async (format) => {
52
+ const cliArgs = this.toCliArgs(format, targetPaths);
53
+ try {
54
+ const { stdout, stderr, exitCode } = await execa(this.binPath, cliArgs, { reject: false });
55
+ if (exitCode !== 0 &&
56
+ format !== 'json' &&
57
+ format !== 'sarif') {
58
+ if (stderr && !stdout) {
59
+ console.warn(`Oxlint para formato '${format}' finalizó con código ${exitCode} y stderr: ${stderr}`);
60
+ }
61
+ }
62
+ results[format] =
63
+ format === 'json' || format === 'sarif'
64
+ ? JSON.parse(stdout || '{}')
65
+ : stdout;
66
+ }
67
+ catch (error) {
68
+ console.error(`Error ejecutando Oxlint para formato '${format}':`, error.shortMessage || error.message);
69
+ results[format] = {
70
+ error: error.shortMessage || error.message,
71
+ details: error,
72
+ };
73
+ }
74
+ }));
75
+ return results;
76
+ }
77
+ /**
78
+ * Construye el array de argumentos para pasar al CLI de Oxlint para un formato específico.
79
+ */
80
+ toCliArgs(format, paths) {
81
+ const args = [];
82
+ // Opciones directas
83
+ if (this.fix)
84
+ args.push('--fix');
85
+ if (this.configFile)
86
+ args.push('--config', this.configFile);
87
+ if (this.tsconfigPath)
88
+ args.push('--tsconfig', this.tsconfigPath); // Añadido
89
+ if (this.quiet)
90
+ args.push('--quiet');
91
+ if (this.noIgnore)
92
+ args.push('--no-ignore');
93
+ if (this.ignorePath)
94
+ args.push('--ignore-path', this.ignorePath);
95
+ if (this.deny)
96
+ this.deny.forEach(rule => args.push('--deny', rule));
97
+ if (this.allow)
98
+ this.allow.forEach(rule => args.push('--allow', rule));
99
+ if (this.ignorePattern)
100
+ this.ignorePattern.forEach(pattern => args.push('--ignore-pattern', pattern));
101
+ // Formato
102
+ if (format !== 'default') {
103
+ args.push('--format', format);
104
+ }
105
+ // Argumentos adicionales
106
+ if (this.additionalArgs)
107
+ args.push(...this.additionalArgs);
108
+ // Rutas/patrones
109
+ args.push(...paths);
110
+ return args;
111
+ }
112
+ /**
113
+ * Método estático para crear una instancia de OxlintNode, similar al código de referencia.
114
+ * @param options Opciones de configuración.
115
+ */
116
+ static create(options) {
117
+ return new OxlintNode(options);
118
+ }
119
+ }
120
+ //# sourceMappingURL=oxlint-node.js.map
@@ -0,0 +1,92 @@
1
+ import { execa } from 'execa';
2
+ import { resolveBin } from '../utils/resolve-bin.js';
3
+ export class TailwindNode {
4
+ binPath;
5
+ input;
6
+ output;
7
+ content;
8
+ minify;
9
+ additionalArgs;
10
+ configFile;
11
+ /**
12
+ * Crea una instancia de TailwindNode.
13
+ * @param options Opciones para la compilación.
14
+ */
15
+ constructor(options) {
16
+ if (!options.input) {
17
+ throw new Error('La opción "input" es requerida.');
18
+ }
19
+ if (!options.output) {
20
+ throw new Error('La opción "output" es requerida.');
21
+ }
22
+ this.binPath = options.binPath || TailwindNode.getDefaultBinPath();
23
+ this.input = options.input;
24
+ this.output = options.output;
25
+ this.content = options.content;
26
+ this.minify = options.minify || false;
27
+ this.additionalArgs = options.additionalArgs;
28
+ this.configFile = options.configFile;
29
+ }
30
+ /**
31
+ * Intenta resolver la ruta al ejecutable de Tailwind CSS.
32
+ */
33
+ static getDefaultBinPath() {
34
+ try {
35
+ return resolveBin('tailwindcss', {
36
+ executable: 'tailwindcss',
37
+ });
38
+ }
39
+ catch (error) {
40
+ console.error("Error al resolver el binario de Tailwind CSS. Asegúrate de que esté instalado y en el PATH, o provee la opción 'binPath'.", error);
41
+ throw new Error('Error al resolver el binario de Tailwind CSS.');
42
+ }
43
+ }
44
+ /**
45
+ * Ejecuta el proceso de compilación de Tailwind CSS.
46
+ * @returns Una promesa que resuelve con el resultado de la compilación.
47
+ */
48
+ async run() {
49
+ const cliArgs = this.toCliArgs();
50
+ try {
51
+ const result = await execa(this.binPath, cliArgs);
52
+ return {
53
+ success: true,
54
+ message: `Tailwind CSS compilado exitosamente desde ${this.input} a ${this.output}`,
55
+ details: result,
56
+ };
57
+ }
58
+ catch (error) {
59
+ const execaError = error; // error de execa
60
+ console.error(`Error en la compilación de Tailwind CSS: ${execaError.message}`);
61
+ if (execaError.stderr) {
62
+ console.error(`Stderr: ${execaError.stderr}`);
63
+ }
64
+ return {
65
+ success: false,
66
+ message: `Error en la compilación de Tailwind CSS: ${execaError.shortMessage || execaError.message}`,
67
+ details: execaError,
68
+ };
69
+ }
70
+ }
71
+ /**
72
+ * Construye el array de argumentos para pasar al CLI de Tailwind CSS.
73
+ */
74
+ toCliArgs() {
75
+ const args = ['-i', this.input, '-o', this.output];
76
+ if (this.configFile) {
77
+ args.push('--config', this.configFile);
78
+ }
79
+ if (this.content && this.content.length > 0) {
80
+ args.push('--content');
81
+ args.push(...this.content);
82
+ }
83
+ if (this.minify) {
84
+ args.push('--minify');
85
+ }
86
+ if (this.additionalArgs && this.additionalArgs.length > 0) {
87
+ args.push(...this.additionalArgs);
88
+ }
89
+ return args;
90
+ }
91
+ }
92
+ //# sourceMappingURL=tailwind-node.js.map
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "versacompiler",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "Una herramienta para compilar y minificar archivos .vue, .js y .ts para proyectos de Vue 3 con soporte para TypeScript.",
5
- "main": "dist/index.js",
5
+ "main": "dist/main.js",
6
6
  "bin": {
7
- "versacompiler": "dist/index.js"
7
+ "versacompiler": "dist/main.js"
8
8
  },
9
9
  "publishConfig": {
10
10
  "access": "public"
@@ -16,10 +16,17 @@
16
16
  ],
17
17
  "type": "module",
18
18
  "scripts": {
19
- "dev": "node --watch dist/index.js",
20
- "compile": "node dist/index.js",
21
- "compile-dev": "node dist/index.js --all",
22
- "compile-prod": "node dist/index.js --all --prod"
19
+ "dev": "tsx --watch src/main.ts --watch --verbose --tailwind",
20
+ "compile": "tsx src/main.ts --all",
21
+ "test": "jest --config jest.config.js",
22
+ "build": "tsx src/main.ts --all -t --clean -y",
23
+ "lint": "oxlint --fix --config .oxlintrc.json",
24
+ "lint:eslint": "eslint --ext .js,.ts,.vue src/ --fix",
25
+ "perf": "scripts\\run-performance.bat",
26
+ "perf:test": "jest tests/performance.test.ts --config jest.config.js --testTimeout=300000",
27
+ "perf:report": "node scripts/generate-performance-report.js",
28
+ "perf:open": "start performance-results/dashboard.html",
29
+ "perf:clean": "rmdir /s /q performance-results 2>nul || echo 'Performance results cleaned'"
23
30
  },
24
31
  "keywords": [
25
32
  "vue",
@@ -27,26 +34,66 @@
27
34
  "minifier",
28
35
  "vue3",
29
36
  "versacompiler",
30
- "typescript"
37
+ "typescript",
38
+ "linter"
31
39
  ],
32
40
  "author": "Jorge Jara H (kriollone@gmail.com)",
33
41
  "license": "MIT",
34
42
  "dependencies": {
35
- "acorn": "^8.14.1",
43
+ "@vue/compiler-dom": "^3.5.16",
44
+ "@vue/reactivity": "^3.5.16",
45
+ "@vue/runtime-core": "^3.5.16",
46
+ "@vue/runtime-dom": "^3.5.16",
36
47
  "browser-sync": "^3.0.4",
37
48
  "chalk": "5.4.1",
38
49
  "chokidar": "^4.0.3",
50
+ "enhanced-resolve": "^5.18.1",
51
+ "execa": "^9.6.0",
52
+ "find-root": "^1.1.0",
53
+ "fs-extra": "^11.3.0",
39
54
  "get-port": "^7.1.0",
40
- "oxc-minify": "^0.69.0",
55
+ "oxc-minify": "^0.72.3",
56
+ "oxc-parser": "^0.72.3",
57
+ "oxc-transform": "^0.72.3",
58
+ "resolve": "^1.22.10",
59
+ "tsx": "^4.19.4",
41
60
  "typescript": "^5.8.3",
42
- "vue": "3.5.13"
61
+ "vue": "3.5.16",
62
+ "yargs": "^18.0.0"
43
63
  },
44
64
  "devDependencies": {
45
- "@tailwindcss/cli": "^4.1.6",
46
- "@types/node": "^22.15.17",
65
+ "@eslint/eslintrc": "^3.3.1",
66
+ "@tailwindcss/cli": "^4.1.8",
67
+ "@types/browser-sync": "^2.29.0",
68
+ "@types/find-root": "^1.1.4",
69
+ "@types/fs-extra": "^11.0.4",
70
+ "@types/jest": "^29.5.14",
71
+ "@types/mocha": "^10.0.10",
72
+ "@types/node": "^22.15.30",
73
+ "@types/resolve": "^1.20.6",
74
+ "@types/yargs": "^17.0.33",
75
+ "@typescript-eslint/eslint-plugin": "^8.34.0",
76
+ "@typescript-eslint/parser": "^8.34.0",
77
+ "@vue/eslint-config-typescript": "^14.5.0",
78
+ "@vue/test-utils": "^2.4.6",
47
79
  "code-tag": "^1.2.0",
48
- "oxlint": "^0.16.10",
80
+ "eslint": "^9.28.0",
81
+ "eslint-import-resolver-typescript": "^4.4.3",
82
+ "eslint-plugin-import": "^2.31.0",
83
+ "eslint-plugin-oxlint": "^0.17.0",
84
+ "eslint-plugin-promise": "^7.2.1",
85
+ "eslint-plugin-unicorn": "^59.0.1",
86
+ "eslint-plugin-vue": "^10.2.0",
87
+ "happy-dom": "^17.6.3",
88
+ "jest": "^29.7.0",
89
+ "jest-environment-jsdom": "30.0.0-beta.3",
90
+ "jest-environment-node": "30.0.0-beta.3",
91
+ "oxlint": "^0.17.0",
49
92
  "prettier": "3.5.3",
50
- "tailwindcss": "^4.1.6"
93
+ "rimraf": "^6.0.1",
94
+ "sweetalert2": "^11.22.0",
95
+ "tailwindcss": "^4.1.8",
96
+ "ts-jest": "^29.3.4",
97
+ "vue-eslint-parser": "^10.1.3"
51
98
  }
52
99
  }