@orbit-tools/cli 0.28.0 → 0.28.1
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 +1 -1
- package/scripts/install-binary.js +20 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbit-tools/cli",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"mcpName": "io.github.constellation-works/orbit",
|
|
5
5
|
"description": "npm proxy for the Orbit CLI. Downloads the matching native binary from GitHub Releases on install and forwards all invocations.",
|
|
6
6
|
"bin": {
|
|
@@ -321,6 +321,24 @@ function extractTarGz(archivePath, destDir) {
|
|
|
321
321
|
validateExtractedBinary(path.join(destDir, 'orbit'));
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
// Stage the binary beside `destPath` and rename it into place so `destPath`
|
|
325
|
+
// only ever holds a complete, executable file. The bin shim treats an existing
|
|
326
|
+
// file as installed, so a partial copy (ENOSPC, kill) must never land there.
|
|
327
|
+
function installBinary(sourcePath, destPath, fsImpl = fs) {
|
|
328
|
+
const tempPath = path.join(
|
|
329
|
+
path.dirname(destPath),
|
|
330
|
+
`.${path.basename(destPath)}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`
|
|
331
|
+
);
|
|
332
|
+
try {
|
|
333
|
+
fsImpl.copyFileSync(sourcePath, tempPath, fs.constants.COPYFILE_EXCL);
|
|
334
|
+
fsImpl.chmodSync(tempPath, 0o755);
|
|
335
|
+
fsImpl.renameSync(tempPath, destPath);
|
|
336
|
+
} catch (err) {
|
|
337
|
+
fsImpl.rmSync(tempPath, { force: true });
|
|
338
|
+
throw err;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
324
342
|
async function main() {
|
|
325
343
|
if (process.env.ORBIT_SKIP_DOWNLOAD === '1') {
|
|
326
344
|
log('ORBIT_SKIP_DOWNLOAD=1 set; skipping binary download.');
|
|
@@ -375,8 +393,7 @@ async function main() {
|
|
|
375
393
|
if (!fs.existsSync(extractedBinary)) {
|
|
376
394
|
fail(`extracted archive did not contain 'orbit' binary at ${extractedBinary}`);
|
|
377
395
|
}
|
|
378
|
-
|
|
379
|
-
fs.chmodSync(BIN_PATH, 0o755);
|
|
396
|
+
installBinary(extractedBinary, BIN_PATH);
|
|
380
397
|
} finally {
|
|
381
398
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
382
399
|
}
|
|
@@ -395,6 +412,7 @@ module.exports = {
|
|
|
395
412
|
acknowledgeTrustedPublicKeyOverride,
|
|
396
413
|
acknowledgeTrustedKeysOverride,
|
|
397
414
|
extractTarGz,
|
|
415
|
+
installBinary,
|
|
398
416
|
normalizeTrustedReleaseKeys,
|
|
399
417
|
readTrustedReleaseKeys,
|
|
400
418
|
validateArchiveMembers,
|