gm-plugkit 2.0.2086 → 2.0.2087

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.
@@ -211,6 +211,38 @@ function proactiveKillForNewInstall(installedVersion) {
211
211
  } catch (_) {}
212
212
  }
213
213
 
214
+ function resolveWindowsExe(cmd) {
215
+ if (process.platform !== 'win32') return cmd;
216
+ try {
217
+ const r = spawnSync('where', [cmd], {
218
+ encoding: 'utf-8',
219
+ stdio: ['ignore', 'pipe', 'ignore'],
220
+ windowsHide: true,
221
+ timeout: 800,
222
+ });
223
+ if (r.status !== 0) return cmd;
224
+ const lines = (r.stdout || '').split(/\r?\n/).map(l => l.trim()).filter(Boolean);
225
+ const exe = lines.find(l => /\.exe$/i.test(l));
226
+ const shim = lines.find(l => /\.(cmd|bat)$/i.test(l));
227
+ return exe || shim || cmd;
228
+ } catch {
229
+ return cmd;
230
+ }
231
+ }
232
+
233
+ function resolveNpmCliJs(shimPath) {
234
+ const candidates = [];
235
+ try {
236
+ const shimDir = path.dirname(shimPath);
237
+ candidates.push(path.join(shimDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'));
238
+ } catch (_) {}
239
+ candidates.push(
240
+ path.join('C:', 'Program Files', 'nodejs', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
241
+ path.join(process.env.APPDATA || '', 'npm', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
242
+ );
243
+ return candidates.find(p => { try { return fs.existsSync(p); } catch (_) { return false; } }) || null;
244
+ }
245
+
214
246
  function ensureNextStepWiring(cwd) {
215
247
  const changes = [];
216
248
  const gmDir = path.join(cwd, '.gm');
@@ -278,4 +310,6 @@ module.exports = {
278
310
  killSpoolWatcherInCwd,
279
311
  proactiveKillForNewInstall,
280
312
  ensureNextStepWiring,
313
+ resolveWindowsExe,
314
+ resolveNpmCliJs,
281
315
  };
package/bootstrap.js CHANGED
@@ -29,27 +29,10 @@ const {
29
29
  killSpoolWatcherInCwd,
30
30
  proactiveKillForNewInstall,
31
31
  ensureNextStepWiring: ensureNextStepWiringShared,
32
+ resolveWindowsExe,
33
+ resolveNpmCliJs,
32
34
  } = shared;
33
35
 
34
- function resolveWindowsExe(cmd) {
35
- if (process.platform !== 'win32') return cmd;
36
- try {
37
- const r = spawnSync('where', [cmd], {
38
- encoding: 'utf-8',
39
- stdio: ['ignore', 'pipe', 'ignore'],
40
- windowsHide: true,
41
- timeout: 800,
42
- });
43
- if (r.status !== 0) return cmd;
44
- const lines = (r.stdout || '').split(/\r?\n/).map(l => l.trim()).filter(Boolean);
45
- const exe = lines.find(l => /\.exe$/i.test(l));
46
- const shim = lines.find(l => /\.(cmd|bat)$/i.test(l));
47
- return exe || shim || cmd;
48
- } catch {
49
- return cmd;
50
- }
51
- }
52
-
53
36
  const NPM_PACKAGE = 'plugkit-wasm';
54
37
  const ATTEMPT_TIMEOUT_MS = 10 * 60 * 1000;
55
38
  const MAX_ATTEMPTS = 3;
@@ -248,11 +231,13 @@ async function extractNpmPackageWasm(destPath, version) {
248
231
  fs.writeFileSync(path.join(tempDir, 'package.json'), JSON.stringify({ name: 'plugkit-extract', version: '0.0.0', private: true }));
249
232
 
250
233
  const cmd = resolveWindowsExe('npm');
251
- const args = ['install', '--no-audit', '--no-fund', '--no-save', NPM_PACKAGE + '@' + version];
234
+ const installArgs = ['install', '--no-audit', '--no-fund', '--no-save', NPM_PACKAGE + '@' + version];
252
235
  const isCmdShim = process.platform === 'win32' && /\.(cmd|bat)$/i.test(cmd);
236
+ const npmCliJs = isCmdShim ? resolveNpmCliJs(cmd) : null;
253
237
 
254
- const spawnCmd = isCmdShim ? `"${cmd}"` : cmd;
255
- const spawnArgs = isCmdShim ? args.map(a => /[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a) : args;
238
+ const spawnCmd = npmCliJs ? process.execPath : (isCmdShim ? `"${cmd}"` : cmd);
239
+ const rawArgs = npmCliJs ? [npmCliJs, ...installArgs] : installArgs;
240
+ const spawnArgs = (isCmdShim && !npmCliJs) ? rawArgs.map(a => /[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a) : rawArgs;
256
241
 
257
242
  const result = spawnSync(spawnCmd, spawnArgs, {
258
243
  cwd: tempDir,
@@ -260,7 +245,7 @@ async function extractNpmPackageWasm(destPath, version) {
260
245
  timeout: ATTEMPT_TIMEOUT_MS,
261
246
  encoding: 'utf8',
262
247
  windowsHide: true,
263
- ...(isCmdShim ? { shell: true } : {}),
248
+ ...((isCmdShim && !npmCliJs) ? { shell: true } : {}),
264
249
  });
265
250
 
266
251
  if (result.error) throw result.error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.2086",
3
+ "version": "2.0.2087",
4
4
  "description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform wasm, verifies SHA256, and launches agentplug-runner (the native wasm host) as the spool watcher daemon.",
5
5
  "main": "index.js",
6
6
  "bin": {