@loucompanion/forge-bridge 0.1.3-dev.7b1dc795c37f → 0.1.3-dev.9853a1d8c458

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/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const forgeBridgeVersion = "0.1.3-dev.7b1dc795c37f";
1
+ export declare const forgeBridgeVersion = "0.1.3-dev.9853a1d8c458";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const forgeBridgeVersion = "0.1.3-dev.7b1dc795c37f";
1
+ export const forgeBridgeVersion = "0.1.3-dev.9853a1d8c458";
@@ -30,3 +30,14 @@ export declare function createDirectoryLink(sourcePath: string, targetPath: stri
30
30
  export declare function lockfilesDiffer(baseCheckoutPath: string, worktreePath: string, packageRootRelative: string): Promise<boolean>;
31
31
  export declare function requiresInstallFallback(entry: WarmPathEntry, baseCheckoutPath: string, worktreePath: string, sourceExists: boolean): Promise<string | null>;
32
32
  export declare function declaresNativeModules(packageRootPath: string): Promise<boolean>;
33
+ export interface NpmLaunchOptions {
34
+ readonly env?: NodeJS.ProcessEnv;
35
+ readonly execPath?: string;
36
+ readonly platform?: NodeJS.Platform;
37
+ readonly homeDir?: string;
38
+ readonly candidates?: readonly string[];
39
+ }
40
+ export declare function resolveNpmLaunch(args: readonly string[], options?: NpmLaunchOptions): {
41
+ command: string;
42
+ args: readonly string[];
43
+ };
@@ -1,4 +1,6 @@
1
+ import { existsSync, realpathSync } from "node:fs";
1
2
  import fs from "node:fs/promises";
3
+ import os from "node:os";
2
4
  import path from "node:path";
3
5
  import { NodeProcessRunner } from "../shared/process/process.js";
4
6
  import { isSubPath } from "../shared/path/path.js";
@@ -184,7 +186,8 @@ async function runInstallFallback(entry, worktreePath, reason, executor) {
184
186
  if (entry.ecosystem === "node") {
185
187
  const lockPath = path.join(cwd, "package-lock.json");
186
188
  const args = (await pathExists(lockPath)) ? ["ci"] : ["install"];
187
- await executor.run(cwd, "npm", args);
189
+ const launch = resolveNpmLaunch(args);
190
+ await executor.run(cwd, launch.command, launch.args);
188
191
  return { ecosystem: entry.ecosystem, packageRoot: entry.packageRoot, reason, command: `npm ${args.join(" ")}` };
189
192
  }
190
193
  if (entry.ecosystem === "python") {
@@ -286,6 +289,47 @@ async function sha256File(filePath) {
286
289
  const content = await fs.readFile(filePath);
287
290
  return crypto.createHash("sha256").update(content).digest("hex");
288
291
  }
292
+ export function resolveNpmLaunch(args, options = {}) {
293
+ const env = options.env ?? process.env;
294
+ const execPath = options.execPath ?? process.execPath;
295
+ const npmExecPath = env.npm_execpath;
296
+ if (npmExecPath) {
297
+ return { command: execPath, args: [npmExecPath, ...args] };
298
+ }
299
+ const platform = options.platform ?? process.platform;
300
+ if (platform !== "win32") {
301
+ for (const candidate of options.candidates ?? defaultNpmCliCandidates(execPath, options.homeDir ?? os.homedir())) {
302
+ const resolvedCandidate = tryResolveNpmCandidate(candidate);
303
+ if (resolvedCandidate) {
304
+ return { command: execPath, args: [resolvedCandidate, ...args] };
305
+ }
306
+ }
307
+ }
308
+ return { command: "npm", args };
309
+ }
310
+ function tryResolveNpmCandidate(candidate) {
311
+ try {
312
+ if (!existsSync(candidate)) {
313
+ return null;
314
+ }
315
+ return realpathSync(candidate);
316
+ }
317
+ catch {
318
+ return null;
319
+ }
320
+ }
321
+ function defaultNpmCliCandidates(execPath, homeDir) {
322
+ const execDir = path.dirname(execPath);
323
+ return [
324
+ path.join(execDir, "npm"),
325
+ path.join(execDir, "npm-cli.js"),
326
+ path.join(execDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
327
+ "/usr/bin/npm",
328
+ "/usr/local/bin/npm",
329
+ path.join(homeDir, ".npm-global", "bin", "npm"),
330
+ path.join(homeDir, ".npm-global", "lib", "node_modules", "npm", "bin", "npm-cli.js")
331
+ ];
332
+ }
289
333
  const defaultCommandExecutor = {
290
334
  async run(cwd, command, args) {
291
335
  const result = await defaultProcessRunner.run({ command, cwd, args });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loucompanion/forge-bridge",
3
- "version": "0.1.3-dev.7b1dc795c37f",
3
+ "version": "0.1.3-dev.9853a1d8c458",
4
4
  "description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",