@saleso.innovations/bridge 0.1.36 → 0.1.38

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.
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,sBAAsB,GAAG;IACnC,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AA+BF,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,IAAI,CA2C1E"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,sBAAsB,GAAG;IACnC,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAyCF,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,IAAI,CA4B1E"}
package/dist/update.js CHANGED
@@ -4,21 +4,29 @@ import { homedir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { BRIDGE_PACKAGE, bridgeCliPath, ensureBridgeNpmRegistry, readInstalledBridgeVersion, resolveBridgeInstallDir, } from "./bridgePaths.js";
6
6
  import { NPM_PUBLIC_REGISTRY } from "./constants.js";
7
- function resolveNpmPath() {
8
- const pathParts = [
9
- process.env.PATH,
10
- "/usr/local/bin",
11
- "/usr/bin",
12
- "/bin",
13
- process.env.HOME ? `${process.env.HOME}/.local/bin` : null,
14
- process.env.HOME ? `${process.env.HOME}/.nvm/current/bin` : null,
15
- ].filter((value) => Boolean(value));
16
- const env = { ...process.env, PATH: pathParts.join(":") };
17
- const lookup = spawnSync("which", ["npm"], { encoding: "utf8", env });
18
- return {
19
- executable: lookup.status === 0 && lookup.stdout.trim() ? lookup.stdout.trim() : "npm",
20
- env,
21
- };
7
+ function shellSingleQuote(value) {
8
+ return `'${value.replace(/'/g, `'\"'\"'`)}'`;
9
+ }
10
+ /**
11
+ * Run npm through a login shell so nvm/fnm and other profile PATH tweaks match SSH.
12
+ * The cleos-bridge systemd unit only sets NODE_ENV, so direct `spawnSync("npm")` fails with ENOENT.
13
+ */
14
+ function runNpmInstall(bridgeDir, tag) {
15
+ const home = process.env.HOME ?? homedir();
16
+ const cmd = [
17
+ "npm install",
18
+ `--prefix ${shellSingleQuote(bridgeDir)}`,
19
+ shellSingleQuote(`${BRIDGE_PACKAGE}@${tag}`),
20
+ "--registry",
21
+ shellSingleQuote(NPM_PUBLIC_REGISTRY),
22
+ "--no-fund",
23
+ "--no-audit",
24
+ "--omit=dev",
25
+ ].join(" ");
26
+ return spawnSync("/bin/bash", ["-lc", cmd], {
27
+ encoding: "utf8",
28
+ env: { ...process.env, HOME: home },
29
+ });
22
30
  }
23
31
  function formatNpmInstallFailure(result) {
24
32
  const detail = [result.stderr, result.stdout].filter(Boolean).join("\n").trim();
@@ -29,7 +37,7 @@ function formatNpmInstallFailure(result) {
29
37
  if (result.error) {
30
38
  return `npm install failed: ${result.error.message}`;
31
39
  }
32
- return "npm install failed (no output; npm may be missing from the bridge service PATH)";
40
+ return "npm install failed (no output)";
33
41
  }
34
42
  export function runBridgeUpdate(options = {}) {
35
43
  const tag = options.tag ?? "latest";
@@ -37,19 +45,8 @@ export function runBridgeUpdate(options = {}) {
37
45
  const beforeVersion = readInstalledBridgeVersion(bridgeDir);
38
46
  mkdirSync(bridgeDir, { recursive: true });
39
47
  ensureBridgeNpmRegistry(bridgeDir);
40
- const { executable: npmExecutable, env } = resolveNpmPath();
41
48
  console.log(`Updating ${BRIDGE_PACKAGE}@${tag} in ${bridgeDir} (registry: ${NPM_PUBLIC_REGISTRY})...`);
42
- const npm = spawnSync(npmExecutable, [
43
- "install",
44
- "--prefix",
45
- bridgeDir,
46
- `${BRIDGE_PACKAGE}@${tag}`,
47
- "--registry",
48
- NPM_PUBLIC_REGISTRY,
49
- "--no-fund",
50
- "--no-audit",
51
- "--omit=dev",
52
- ], { encoding: "utf8", env });
49
+ const npm = runNpmInstall(bridgeDir, tag);
53
50
  if (npm.status !== 0) {
54
51
  console.error(formatNpmInstallFailure(npm));
55
52
  throw new Error(formatNpmInstallFailure(npm));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saleso.innovations/bridge",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "description": "Connect your Hermes agent to the Cleos iOS app via pairing code.",
5
5
  "type": "module",
6
6
  "license": "MIT",