@oondemand/oon-core-front 0.3.41 → 0.3.42

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 (2) hide show
  1. package/bin/cli.js +34 -6
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -16,21 +16,49 @@
16
16
 
17
17
  import path from "node:path";
18
18
  import fs from "node:fs";
19
+ import { createRequire } from "node:module";
19
20
  import { spawnSync } from "node:child_process";
20
21
 
21
22
  const cmd = process.argv[2];
22
23
  const cwd = process.cwd();
23
24
 
25
+ function resolveViteEntry() {
26
+ const projectRequire = createRequire(path.join(cwd, "package.json"));
27
+ const vitePackageJson = projectRequire.resolve("vite/package.json");
28
+ const entry = path.join(path.dirname(vitePackageJson), "bin", "vite.js");
29
+
30
+ if (!fs.existsSync(entry)) {
31
+ throw new Error(`Entrada do Vite não encontrada em ${entry}.`);
32
+ }
33
+
34
+ return entry;
35
+ }
36
+
24
37
  function runVite(args) {
25
- const bin = path.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "vite.cmd" : "vite");
26
- const exec = fs.existsSync(bin) ? bin : "vite";
27
- const r = spawnSync(exec, args, { stdio: "inherit", cwd });
28
- if (r.error) {
29
- console.error("Falha ao executar vite:", r.error.message);
38
+ let entry;
39
+
40
+ try {
41
+ entry = resolveViteEntry();
42
+ } catch (error) {
43
+ const message = error instanceof Error ? error.message : String(error);
44
+ console.error("Falha ao localizar vite:", message);
30
45
  console.error("Instale o vite no projeto da Central: npm i -D vite");
31
46
  process.exit(1);
32
47
  }
33
- process.exit(r.status || 0);
48
+
49
+ // Executar o arquivo JavaScript do Vite pelo próprio Node evita o EINVAL
50
+ // do spawnSync ao tentar abrir diretamente vite.cmd no Windows.
51
+ const result = spawnSync(process.execPath, [entry, ...args], {
52
+ stdio: "inherit",
53
+ cwd,
54
+ });
55
+
56
+ if (result.error) {
57
+ console.error("Falha ao executar vite:", result.error.message);
58
+ process.exit(1);
59
+ }
60
+
61
+ process.exit(result.status ?? 0);
34
62
  }
35
63
 
36
64
  function readEnv(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oondemand/oon-core-front",
3
- "version": "0.3.41",
3
+ "version": "0.3.42",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oondemand/oon-platform.git",