@saleso.innovations/bridge 0.1.35 → 0.1.37
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/update.d.ts.map +1 -1
- package/dist/update.js +38 -12
- package/package.json +1 -1
package/dist/update.d.ts.map
CHANGED
|
@@ -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;
|
|
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,6 +4,41 @@ 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 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
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function formatNpmInstallFailure(result) {
|
|
32
|
+
const detail = [result.stderr, result.stdout].filter(Boolean).join("\n").trim();
|
|
33
|
+
if (detail) {
|
|
34
|
+
const tail = detail.length > 500 ? `…${detail.slice(-500)}` : detail;
|
|
35
|
+
return `npm install failed:\n${tail}`;
|
|
36
|
+
}
|
|
37
|
+
if (result.error) {
|
|
38
|
+
return `npm install failed: ${result.error.message}`;
|
|
39
|
+
}
|
|
40
|
+
return "npm install failed (no output)";
|
|
41
|
+
}
|
|
7
42
|
export function runBridgeUpdate(options = {}) {
|
|
8
43
|
const tag = options.tag ?? "latest";
|
|
9
44
|
const bridgeDir = resolveBridgeInstallDir();
|
|
@@ -11,19 +46,10 @@ export function runBridgeUpdate(options = {}) {
|
|
|
11
46
|
mkdirSync(bridgeDir, { recursive: true });
|
|
12
47
|
ensureBridgeNpmRegistry(bridgeDir);
|
|
13
48
|
console.log(`Updating ${BRIDGE_PACKAGE}@${tag} in ${bridgeDir} (registry: ${NPM_PUBLIC_REGISTRY})...`);
|
|
14
|
-
const npm =
|
|
15
|
-
"install",
|
|
16
|
-
"--prefix",
|
|
17
|
-
bridgeDir,
|
|
18
|
-
`${BRIDGE_PACKAGE}@${tag}`,
|
|
19
|
-
"--registry",
|
|
20
|
-
NPM_PUBLIC_REGISTRY,
|
|
21
|
-
"--no-fund",
|
|
22
|
-
"--no-audit",
|
|
23
|
-
"--omit=dev",
|
|
24
|
-
], { stdio: "inherit", env: process.env });
|
|
49
|
+
const npm = runNpmInstall(bridgeDir, tag);
|
|
25
50
|
if (npm.status !== 0) {
|
|
26
|
-
|
|
51
|
+
console.error(formatNpmInstallFailure(npm));
|
|
52
|
+
throw new Error(formatNpmInstallFailure(npm));
|
|
27
53
|
}
|
|
28
54
|
const cliPath = bridgeCliPath(bridgeDir);
|
|
29
55
|
linkBridgeCli(cliPath);
|