@package-pal/cli 0.0.44 → 0.0.46
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 +14 -14
- package/src/lib/install/functions/exec.js +20 -3
- package/src/lib/install/functions/get-platform-info.js +1 -1
- package/src/lib/install/functions/link-existing-binary.js +2 -2
- package/src/lib/install/functions/load-missing-binary.js +7 -7
- package/src/lib/install/functions/prepare-binary.js +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@package-pal/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "CLI tool exposing core PackagePal functionality.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"package",
|
|
@@ -13,24 +13,24 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"tar": "^7.5.
|
|
16
|
+
"tar": "^7.5.9"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@clack/prompts": "^
|
|
20
|
-
"@stricli/core": "^1.2.
|
|
21
|
-
"@package-pal/core": "0.0.
|
|
22
|
-
"@package-pal/util": "0.0.
|
|
23
|
-
"@types/bun": "^1.3.
|
|
19
|
+
"@clack/prompts": "^1.1.0",
|
|
20
|
+
"@stricli/core": "^1.2.6",
|
|
21
|
+
"@package-pal/core": "0.0.9",
|
|
22
|
+
"@package-pal/util": "0.0.10",
|
|
23
|
+
"@types/bun": "^1.3.10",
|
|
24
24
|
"typescript": "^5.9.3"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
|
-
"@package-pal/cli-linux-x64": "0.0.
|
|
28
|
-
"@package-pal/cli-linux-x64-musl": "0.0.
|
|
29
|
-
"@package-pal/cli-linux-arm64": "0.0.
|
|
30
|
-
"@package-pal/cli-linux-arm64-musl": "0.0.
|
|
31
|
-
"@package-pal/cli-darwin-arm64": "0.0.
|
|
32
|
-
"@package-pal/cli-darwin-x64": "0.0.
|
|
33
|
-
"@package-pal/cli-windows-x64": "0.0.
|
|
27
|
+
"@package-pal/cli-linux-x64": "0.0.17",
|
|
28
|
+
"@package-pal/cli-linux-x64-musl": "0.0.17",
|
|
29
|
+
"@package-pal/cli-linux-arm64": "0.0.17",
|
|
30
|
+
"@package-pal/cli-linux-arm64-musl": "0.0.17",
|
|
31
|
+
"@package-pal/cli-darwin-arm64": "0.0.17",
|
|
32
|
+
"@package-pal/cli-darwin-x64": "0.0.17",
|
|
33
|
+
"@package-pal/cli-windows-x64": "0.0.17"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=18"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from 'child_process';
|
|
2
|
+
import { isDefined } from '@package-pal/util';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @param {string} binPath
|
|
@@ -8,7 +9,23 @@ import { execFileSync } from 'child_process';
|
|
|
8
9
|
export const exec = (
|
|
9
10
|
binPath, args = process.argv.slice(2), stdio = 'inherit',
|
|
10
11
|
) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
try {
|
|
13
|
+
return execFileSync(
|
|
14
|
+
binPath, args, { stdio },
|
|
15
|
+
);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
const exitError
|
|
18
|
+
= (stdio === 'inherit'
|
|
19
|
+
&& typeof error === 'object'
|
|
20
|
+
&& error !== null
|
|
21
|
+
&& 'status' in error
|
|
22
|
+
&& typeof error.status === 'number')
|
|
23
|
+
? error.status
|
|
24
|
+
: undefined;
|
|
25
|
+
if (isDefined(exitError)) {
|
|
26
|
+
process.exit(exitError);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
14
31
|
};
|
|
@@ -17,7 +17,7 @@ export const getPlatformInfo = () => {
|
|
|
17
17
|
break;
|
|
18
18
|
|
|
19
19
|
case 'linux':
|
|
20
|
-
let isMusl
|
|
20
|
+
let isMusl;
|
|
21
21
|
try {
|
|
22
22
|
// The report will not have a glibcVersionRuntime property if musl is being used.
|
|
23
23
|
/** @type {{ header?: { glibcVersionRuntime?: unknown } }} */
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
export const linkExistingBinary = ({
|
|
9
9
|
platform, targetBinPath, outputBinPath,
|
|
10
10
|
}) => {
|
|
11
|
-
const
|
|
11
|
+
const isWindows = platform === 'win32';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @param {string | undefined} method
|
|
@@ -27,7 +27,7 @@ export const linkExistingBinary = ({
|
|
|
27
27
|
errs.push(e);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (!
|
|
30
|
+
if (!isWindows) {
|
|
31
31
|
try {
|
|
32
32
|
symlinkSync(targetBinPath, outputBinPath);
|
|
33
33
|
verifyLinked('symlinkSync');
|
|
@@ -27,7 +27,7 @@ const tryDownloadAndExtract = (
|
|
|
27
27
|
reject(new Error(`Failed to download binary: Redirect location missing.`));
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
tryDownloadAndExtract(
|
|
31
31
|
res.headers.location, binExecutableName, outputBinDir,
|
|
32
32
|
)
|
|
33
33
|
.then(resolve)
|
|
@@ -65,22 +65,22 @@ const downloadAndExtract = async (
|
|
|
65
65
|
await tryDownloadAndExtract(
|
|
66
66
|
tarballUrl, binExecutableName, outputBinDir,
|
|
67
67
|
);
|
|
68
|
+
try {
|
|
69
|
+
chmodSync(join(outputBinDir, binExecutableName), 0o755);
|
|
70
|
+
} catch {
|
|
71
|
+
//
|
|
72
|
+
}
|
|
68
73
|
return;
|
|
69
74
|
} catch (error) {
|
|
70
75
|
if (attempt < maxAttempts) {
|
|
71
76
|
const delay = initialBackoffMs * 2 ** (attempt - 1);
|
|
72
77
|
console.warn(`Download failed (attempt ${attempt.toString()}), retrying in ${delay.toString()}ms...`);
|
|
78
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
73
79
|
} else {
|
|
74
80
|
throw error;
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
chmodSync(join(outputBinDir, binExecutableName), 0o755);
|
|
81
|
-
} catch {
|
|
82
|
-
//
|
|
83
|
-
}
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
/**
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
chmodSync,
|
|
3
3
|
mkdirSync, rmSync,
|
|
4
4
|
} from 'fs';
|
|
5
|
+
import { join } from 'path';
|
|
5
6
|
import { linkExistingBinary } from './link-existing-binary.js';
|
|
6
7
|
import { loadMissingBinary } from './load-missing-binary.js';
|
|
7
8
|
import { validateBinaryVersion } from './validate-binary-version.js';
|
|
@@ -22,6 +23,17 @@ export const prepareBinary = ({
|
|
|
22
23
|
|
|
23
24
|
// Windows can't be optimised to run the binary directly (.exe).
|
|
24
25
|
if (platform === 'win32') {
|
|
26
|
+
if (!targetBinPath) {
|
|
27
|
+
const downloadBinarySourceDir = join(
|
|
28
|
+
outputBinDir, 'source', 'bin',
|
|
29
|
+
);
|
|
30
|
+
mkdirSync(downloadBinarySourceDir, { recursive: true });
|
|
31
|
+
return loadMissingBinary({
|
|
32
|
+
binExecutableName,
|
|
33
|
+
targetPackage,
|
|
34
|
+
outputBinDir: downloadBinarySourceDir,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
25
37
|
return;
|
|
26
38
|
}
|
|
27
39
|
|