qwenproxy-cli 1.3.5 → 1.4.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.
package/bin/qwenproxy.js CHANGED
@@ -107,14 +107,24 @@ if (firstArg === "start" || rawArgs.includes("--server")) {
107
107
  scriptArgs = ["--tui", ...rawArgs];
108
108
  }
109
109
 
110
- const targetPath = path.resolve(packageRoot, scriptFile);
110
+ const distFile = scriptFile.replace(/^src[\\/]/, "dist/").replace(/\.ts$/, ".js");
111
+ const distPath = path.resolve(packageRoot, distFile);
112
+ let targetPath = path.resolve(packageRoot, scriptFile);
113
+ let runWithTsx = true;
114
+
115
+ if (fs.existsSync(distPath)) {
116
+ targetPath = distPath;
117
+ runWithTsx = false;
118
+ }
111
119
 
112
120
  // Resolve tsx loader relative to the package installation rather than cwd
113
121
  let tsxLoaderArg = "tsx";
114
- try {
115
- const tsxEntry = require.resolve("tsx");
116
- tsxLoaderArg = pathToFileURL(tsxEntry).href;
117
- } catch {}
122
+ if (runWithTsx) {
123
+ try {
124
+ const tsxEntry = require.resolve("tsx");
125
+ tsxLoaderArg = pathToFileURL(tsxEntry).href;
126
+ } catch {}
127
+ }
118
128
 
119
129
  // Ensure Playwright Chromium is installed only for commands that need the browser
120
130
  const browserCommands = ["start", "tui", "login"];
@@ -183,15 +193,23 @@ if (isBrowserCommand) {
183
193
  console.log("✓ [QwenProxy] Navegador instalado com sucesso!\n");
184
194
  // Automatically prune older, unused browser builds to free up disk space
185
195
  try {
186
- const { cleanPlaywrightBrowsers } = await import("../src/clean-cache.ts");
187
- await cleanPlaywrightBrowsers(true);
196
+ const cleanModule = fs.existsSync(path.resolve(packageRoot, "dist/clean-cache.js"))
197
+ ? await import("../dist/clean-cache.js")
198
+ : await import("../src/clean-cache.ts");
199
+ if (cleanModule.cleanPlaywrightBrowsers) {
200
+ await cleanModule.cleanPlaywrightBrowsers(true);
201
+ }
188
202
  } catch {}
189
203
  }
190
204
  }
191
205
  } catch {}
192
206
  }
193
207
 
194
- const child = spawn(process.execPath, ["--import", tsxLoaderArg, targetPath, ...scriptArgs], {
208
+ const nodeArgs = runWithTsx
209
+ ? ["--import", tsxLoaderArg, targetPath, ...scriptArgs]
210
+ : [targetPath, ...scriptArgs];
211
+
212
+ const child = spawn(process.execPath, nodeArgs, {
195
213
  stdio: "inherit",
196
214
  cwd: process.cwd(),
197
215
  env: process.env,