@ran-sh/dsh-crew 0.5.5 → 0.5.6

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": "@ran-sh/dsh-crew",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "type": "module",
5
5
  "main": "./src/hub/entry.mjs",
6
6
  "bin": {
@@ -49,8 +49,23 @@ import {
49
49
  export const CREW_APP_DIRNAME = 'app';
50
50
  export const RELEASES_DIRNAME = 'releases';
51
51
  export const CURRENT_POINTER_FILENAME = 'current.json';
52
- export const KEEP_RELEASES = 2;
53
- export const INCOMPLETE_MARKER = '.dsh-crew-incomplete';
52
+ export const KEEP_RELEASES = 2;
53
+ export const INCOMPLETE_MARKER = '.dsh-crew-incomplete';
54
+
55
+ export function npmCliInvocation(args, {
56
+ platform = process.platform,
57
+ environment = process.env,
58
+ } = {}) {
59
+ if (platform !== 'win32') return { command: 'npm', args: [...args] };
60
+ const unsafe = args.find((arg) => /[\0\r\n"%!^&|<>]/.test(String(arg)));
61
+ if (unsafe !== undefined) throw new Error(`unsafe npm argument: ${unsafe}`);
62
+ const commandLine = ['npm.cmd', ...args.map((arg) => `"${String(arg)}"`)].join(' ');
63
+ return {
64
+ command: environment.ComSpec || environment.COMSPEC || 'cmd.exe',
65
+ args: ['/d', '/s', '/c', commandLine],
66
+ windowsVerbatimArguments: true,
67
+ };
68
+ }
54
69
 
55
70
  const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
56
71
 
@@ -217,13 +232,18 @@ export function copyProductionDependencyTree({
217
232
  return { copied, missing, missingOptional };
218
233
  }
219
234
 
220
- function defaultNpmInstaller(stageRoot, log) {
221
- const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
222
- const result = spawnSync(npm, [
223
- 'install', '--prefix', stageRoot,
224
- '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund',
225
- '--no-package-lock', '--loglevel=error',
226
- ], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], shell: process.platform === 'win32', timeout: 600_000, windowsHide: true, env: sanitizedPackageManagerEnv() });
235
+ function defaultNpmInstaller(stageRoot, log) {
236
+ const npmArgs = [
237
+ 'install', '--prefix', stageRoot,
238
+ '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund',
239
+ '--no-package-lock', '--loglevel=error',
240
+ ];
241
+ const invocation = npmCliInvocation(npmArgs);
242
+ const result = spawnSync(invocation.command, invocation.args, {
243
+ encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 600_000,
244
+ windowsHide: true, windowsVerbatimArguments: invocation.windowsVerbatimArguments,
245
+ env: sanitizedPackageManagerEnv(),
246
+ });
227
247
  if (result.status !== 0) {
228
248
  log(`- npm fallback install failed (${result.status}): ${(result.stderr || result.stdout || '').trim().slice(-300)}`);
229
249
  return false;
@@ -759,13 +779,15 @@ export function resolveUpdateCandidate({
759
779
  mkdirSync(tmpDir, { recursive: true });
760
780
  try {
761
781
  const effectiveSpec = process.env.DSH_CREW_UPDATE_SPEC ?? spec;
762
- const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
763
- const packArgs = ['pack', effectiveSpec, '--pack-destination', tmpDir, '--json', '--loglevel=error'];
764
- log(`- resolving update candidate from the configured npm registry (${effectiveSpec})`);
765
- const packed = runner(npm, packArgs, {
766
- encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], shell: process.platform === 'win32',
767
- timeout: 600_000, windowsHide: true, env: sanitizedPackageManagerEnv(),
768
- });
782
+ const packArgs = ['pack', effectiveSpec, '--pack-destination', tmpDir, '--json', '--loglevel=error'];
783
+ log(`- resolving update candidate from the configured npm registry (${effectiveSpec})`);
784
+ const invocation = npmCliInvocation(packArgs);
785
+ const packed = runner(invocation.command, invocation.args, {
786
+ encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
787
+ timeout: 600_000, windowsHide: true,
788
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
789
+ env: sanitizedPackageManagerEnv(),
790
+ });
769
791
  if (packed.status !== 0) {
770
792
  return { ok: false, code: 'REGISTRY_PACK_FAILED', detail: `${effectiveSpec}: ${(packed.stderr || packed.stdout || '').trim().slice(-300)}` };
771
793
  }
@@ -8,7 +8,7 @@
8
8
  // Keep this module pure and dependency-free so Hub, MCP and tests all use the
9
9
  // exact same compatibility rules.
10
10
 
11
- export const RUNTIME_VERSION = '0.5.5';
11
+ export const RUNTIME_VERSION = '0.5.6';
12
12
  export const HUB_PROTOCOL_VERSION = 1;
13
13
 
14
14
  export const HUB_CAPABILITIES = Object.freeze([