@danhachuel/thunderbolt 0.4.82 → 0.4.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.4.82",
3
+ "version": "0.4.83",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",
package/scripts/cli.mjs CHANGED
@@ -26,12 +26,13 @@ const venvPython = platform() === "win32" ? join(venvDir, "Scripts", "python.exe
26
26
  const python = process.env.THUNDERBOLT_PYTHON || process.env.HERMES_PYTHON || (existsSync(venvPython) ? venvPython : (platform() === "win32" ? "python" : "python3"));
27
27
  const main = resolve(root, "app", "main.py");
28
28
  const settingsPath = join(thunderboltHome, "storage", "state", "settings.json");
29
+ const pythonEnvironment = { ...process.env, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1" };
29
30
 
30
31
  function run(command, commandArgs, label = "comando", environment = process.env) {
31
32
  console.log(`Thunderbolt: a iniciar ${label}...`);
32
33
  const result = spawnSync(command, commandArgs, {
33
34
  stdio: "inherit",
34
- env: environment,
35
+ env: { ...pythonEnvironment, ...environment, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1" },
35
36
  cwd: root,
36
37
  windowsHide: false,
37
38
  });
@@ -47,12 +48,12 @@ function run(command, commandArgs, label = "comando", environment = process.env)
47
48
  }
48
49
 
49
50
  function pythonVersion() {
50
- return spawnSync(python, ["-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8" });
51
+ return spawnSync(python, ["-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8", env: pythonEnvironment });
51
52
  }
52
53
 
53
54
  function moduleAvailable(moduleName) {
54
55
  const code = `import importlib.util,sys; sys.exit(0 if importlib.util.find_spec(${JSON.stringify(moduleName)}) else 1)`;
55
- return spawnSync(python, ["-c", code], { stdio: "ignore" }).status === 0;
56
+ return spawnSync(python, ["-c", code], { stdio: "ignore", env: pythonEnvironment }).status === 0;
56
57
  }
57
58
 
58
59
  function configuredMoneyPrinterPath() {
@@ -152,6 +153,8 @@ ensureRuntimeStorage();
152
153
  const storageDir = process.env.THUNDERBOLT_STORAGE_DIR || join(thunderboltHome, "storage");
153
154
  const runtimeEnv = {
154
155
  ...process.env,
156
+ PYTHONIOENCODING: "utf-8",
157
+ PYTHONUTF8: "1",
155
158
  THUNDERBOLT_STORAGE_DIR: storageDir,
156
159
  STREAMLIT_BROWSER_GATHER_USAGE_STATS: "false",
157
160
  STREAMLIT_SERVER_HEADLESS: "true",
@@ -254,7 +257,7 @@ function startStreamlit() {
254
257
  child = spawn(python, ["-m", "streamlit", "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
255
258
  cwd: root,
256
259
  stdio: "inherit",
257
- env: { ...runtimeEnv, THUNDERBOLT_LAUNCHER_RESTART: "1" },
260
+ env: { ...runtimeEnv, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1", THUNDERBOLT_LAUNCHER_RESTART: "1" },
258
261
  windowsHide: false,
259
262
  });
260
263
  child.on("error", (error) => {
@@ -42,6 +42,7 @@ const defaultMpt = process.env.MONEYPRINTER_PATH || join(thunderboltHome, "Money
42
42
  const dependencyStatePath = join(thunderboltHome, "storage", "state", "install-state.json");
43
43
  const forceDeps = args.includes("--force-deps");
44
44
  const refreshMoneyPrinter = args.includes("--refresh-moneyprinter");
45
+ const pythonEnvironment = { ...process.env, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1" };
45
46
 
46
47
  function legacyRoots() {
47
48
  const userProfile = process.env.USERPROFILE || home;
@@ -63,12 +64,12 @@ function commandExists(command) {
63
64
 
64
65
  function run(command, commandArgs, options = {}) {
65
66
  console.log(`\n> ${command} ${commandArgs.join(" ")}`);
66
- const result = spawnSync(command, commandArgs, { stdio: "inherit", ...options });
67
+ const result = spawnSync(command, commandArgs, { stdio: "inherit", env: pythonEnvironment, ...options, env: { ...pythonEnvironment, ...(options.env || {}) } });
67
68
  if (result.status !== 0) process.exit(result.status || 1);
68
69
  }
69
70
 
70
71
  function probePython(command, commandArgs = []) {
71
- const result = spawnSync(command, [...commandArgs, "-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8" });
72
+ const result = spawnSync(command, [...commandArgs, "-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8", env: pythonEnvironment });
72
73
  if (result.status !== 0) return null;
73
74
  const versionText = result.stdout.trim();
74
75
  const version = versionText.split(".").map(Number);