@package-pal/cli 0.0.34 → 0.0.36
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 +12 -12
- package/src/lib/install/functions/get-path-info.js +21 -6
- package/src/lib/install/functions/launch-fallback.js +3 -3
- package/src/lib/install/functions/load-missing-binary.js +2 -0
- package/src/lib/install/functions/prepare-binary.js +9 -3
- package/src/lib/install/functions/validate-binary-version.js +20 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@package-pal/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "CLI tool exposing core PackagePal functionality.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"package",
|
|
@@ -13,25 +13,25 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"tar": "^7.
|
|
16
|
+
"tar": "^7.5.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@package-pal/core": "0.0.
|
|
20
|
-
"@package-pal/util": "0.0.
|
|
19
|
+
"@package-pal/core": "0.0.4",
|
|
20
|
+
"@package-pal/util": "0.0.6",
|
|
21
21
|
"@clack/prompts": "^0.11.0",
|
|
22
22
|
"@stricli/core": "^1.2.0",
|
|
23
23
|
"@types/bun": "^1.2.19",
|
|
24
24
|
"typescript": "^5.9.2",
|
|
25
|
-
"yoctocolors": "^2.1.
|
|
25
|
+
"yoctocolors": "^2.1.2"
|
|
26
26
|
},
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"@package-pal/cli-linux-x64": "0.0.
|
|
29
|
-
"@package-pal/cli-linux-x64-musl": "0.0.
|
|
30
|
-
"@package-pal/cli-linux-arm64": "0.0.
|
|
31
|
-
"@package-pal/cli-linux-arm64-musl": "0.0.
|
|
32
|
-
"@package-pal/cli-darwin-arm64": "0.0.
|
|
33
|
-
"@package-pal/cli-darwin-x64": "0.0.
|
|
34
|
-
"@package-pal/cli-windows-x64": "0.0.
|
|
28
|
+
"@package-pal/cli-linux-x64": "0.0.10",
|
|
29
|
+
"@package-pal/cli-linux-x64-musl": "0.0.10",
|
|
30
|
+
"@package-pal/cli-linux-arm64": "0.0.10",
|
|
31
|
+
"@package-pal/cli-linux-arm64-musl": "0.0.10",
|
|
32
|
+
"@package-pal/cli-darwin-arm64": "0.0.10",
|
|
33
|
+
"@package-pal/cli-darwin-x64": "0.0.10",
|
|
34
|
+
"@package-pal/cli-windows-x64": "0.0.10"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=18"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
1
2
|
import { createRequire } from 'module';
|
|
2
3
|
import {
|
|
3
4
|
dirname, join, resolve,
|
|
@@ -16,12 +17,12 @@ export const getPathInfo = ({
|
|
|
16
17
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
18
|
const binName = Object.keys(packageJson.bin)[0];
|
|
18
19
|
if (!binName) {
|
|
19
|
-
throw new Error(`Expected '${
|
|
20
|
+
throw new Error(`Expected '${packageJson.name}' bin name.`);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
24
|
-
throw new Error(`Expected '${
|
|
23
|
+
const baseVersion = packageJson.version;
|
|
24
|
+
if (!baseVersion) {
|
|
25
|
+
throw new Error(`Expected '${packageJson.name}' version.`);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const packageRootDir = resolve(
|
|
@@ -34,13 +35,26 @@ export const getPathInfo = ({
|
|
|
34
35
|
const outputBinPath = join(outputBinDir, binExecutableName);
|
|
35
36
|
|
|
36
37
|
/** @type {string | null} */
|
|
37
|
-
let targetBinPath;
|
|
38
|
+
let targetBinPath = null;
|
|
39
|
+
/** @type {string | null} */
|
|
40
|
+
let targetVersion = null;
|
|
38
41
|
try {
|
|
39
42
|
targetBinPath = require.resolve(join(
|
|
40
43
|
'@package-pal', targetPackage, 'bin', binExecutableName,
|
|
41
44
|
));
|
|
45
|
+
|
|
46
|
+
if (targetBinPath) {
|
|
47
|
+
const targetPackageRoot = dirname(dirname(targetBinPath));
|
|
48
|
+
const targetPackageJsonPath = join(targetPackageRoot, 'package.json');
|
|
49
|
+
/** @type {Record<string, unknown> | null} */
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
51
|
+
const targetPackageJson = JSON.parse(readFileSync(targetPackageJsonPath, { encoding: 'utf8' }));
|
|
52
|
+
if (typeof targetPackageJson?.version === 'string') {
|
|
53
|
+
targetVersion = targetPackageJson.version;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
} catch {
|
|
43
|
-
|
|
57
|
+
//
|
|
44
58
|
}
|
|
45
59
|
|
|
46
60
|
return {
|
|
@@ -51,6 +65,7 @@ export const getPathInfo = ({
|
|
|
51
65
|
outputBinBasePath,
|
|
52
66
|
outputBinPath,
|
|
53
67
|
targetBinPath,
|
|
68
|
+
baseVersion,
|
|
54
69
|
targetVersion,
|
|
55
70
|
};
|
|
56
71
|
};
|
|
@@ -13,7 +13,7 @@ export const launchFallback = async () => {
|
|
|
13
13
|
platform, targetPackage,
|
|
14
14
|
} = getPlatformInfo();
|
|
15
15
|
const {
|
|
16
|
-
targetBinPath, binExecutableName, outputBinDir,
|
|
16
|
+
targetBinPath, binExecutableName, outputBinDir,
|
|
17
17
|
} = getPathInfo({
|
|
18
18
|
platform,
|
|
19
19
|
targetPackage,
|
|
@@ -38,12 +38,12 @@ export const launchFallback = async () => {
|
|
|
38
38
|
recursive: true,
|
|
39
39
|
});
|
|
40
40
|
mkdirSync(downloadBinarySourceDir, { recursive: true });
|
|
41
|
-
await loadMissingBinary({
|
|
41
|
+
const downloadTargetVersion = await loadMissingBinary({
|
|
42
42
|
binExecutableName,
|
|
43
43
|
targetPackage,
|
|
44
44
|
outputBinDir: downloadBinarySourceDir,
|
|
45
45
|
});
|
|
46
|
-
validateBinaryVersion(
|
|
46
|
+
validateBinaryVersion(downloadTargetVersion, downloadBinPath);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return exec(downloadBinPath);
|
|
@@ -7,7 +7,7 @@ import { loadMissingBinary } from './load-missing-binary.js';
|
|
|
7
7
|
import { validateBinaryVersion } from './validate-binary-version.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @param {{ platform: Bun.Platform, binExecutableName: string, targetPackage: string, targetVersion: string, targetBinPath: string | null, outputBinDir: string, outputBinBasePath: string, outputBinPath: string }} options
|
|
10
|
+
* @param {{ platform: Bun.Platform, binExecutableName: string, targetPackage: string, targetVersion: string | null, targetBinPath: string | null, outputBinDir: string, outputBinBasePath: string, outputBinPath: string }} options
|
|
11
11
|
*/
|
|
12
12
|
export const prepareBinary = ({
|
|
13
13
|
platform, binExecutableName, targetPackage, targetVersion, targetBinPath, outputBinDir, outputBinBasePath, outputBinPath,
|
|
@@ -25,8 +25,14 @@ export const prepareBinary = ({
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
rmSync(outputBinBasePath, {
|
|
29
|
-
|
|
28
|
+
rmSync(outputBinBasePath, {
|
|
29
|
+
force: true,
|
|
30
|
+
recursive: true,
|
|
31
|
+
});
|
|
32
|
+
rmSync(outputBinPath, {
|
|
33
|
+
force: true,
|
|
34
|
+
recursive: true,
|
|
35
|
+
});
|
|
30
36
|
mkdirSync(outputBinDir, { recursive: true });
|
|
31
37
|
|
|
32
38
|
if (targetBinPath) {
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { exec } from './exec.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} targetVersion
|
|
5
|
-
* @param {string} targetBinPath
|
|
6
|
-
*/
|
|
7
|
-
export const validateBinaryVersion = (targetVersion, targetBinPath) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { exec } from './exec.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string | null} targetVersion
|
|
5
|
+
* @param {string} targetBinPath
|
|
6
|
+
*/
|
|
7
|
+
export const validateBinaryVersion = (targetVersion, targetBinPath) => {
|
|
8
|
+
if (!targetVersion) {
|
|
9
|
+
throw new Error(`'${targetBinPath}' no binary version found.`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const stdout = exec(
|
|
13
|
+
targetBinPath, ['-v'], 'pipe',
|
|
14
|
+
).toString()
|
|
15
|
+
.trim();
|
|
16
|
+
|
|
17
|
+
if (stdout.toLowerCase() !== targetVersion.toLowerCase()) {
|
|
18
|
+
throw new Error(`'${targetBinPath}' binary version mismatch; expected ${targetVersion}, got ${stdout}.`);
|
|
19
|
+
}
|
|
20
|
+
};
|