@package-pal/cli 0.0.24 → 0.0.26
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/src/lib/install/functions/exec.js +14 -11
- package/src/lib/install/functions/launch-fallback.js +3 -6
- package/src/lib/install/functions/prepare-binary.js +41 -33
- package/src/lib/install/functions/validate-binary-version.js +16 -14
- package/src/lib/install/install-binary.js +17 -19
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { execFileSync } from 'child_process';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} binPath
|
|
5
|
-
* @param {string[]} args
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} binPath
|
|
5
|
+
* @param {string[]} args
|
|
6
|
+
* @param {import('child_process').StdioOptions} stdio
|
|
7
|
+
*/
|
|
8
|
+
export const exec = (
|
|
9
|
+
binPath, args = process.argv.slice(2), stdio = 'inherit',
|
|
10
|
+
) => {
|
|
11
|
+
return execFileSync(
|
|
12
|
+
binPath, args, { stdio },
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -27,13 +27,12 @@ export const launchFallback = async () => {
|
|
|
27
27
|
force: true,
|
|
28
28
|
recursive: true,
|
|
29
29
|
});
|
|
30
|
-
validateBinaryVersion(targetVersion, targetBinPath);
|
|
31
30
|
|
|
32
31
|
return exec(targetBinPath);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
const
|
|
36
|
-
if (!existsSync(
|
|
34
|
+
const downloadBinPath = join(downloadBinarySourceDir, binExecutableName);
|
|
35
|
+
if (!existsSync(downloadBinPath)) {
|
|
37
36
|
rmSync(downloadBinarySourceDir, {
|
|
38
37
|
force: true,
|
|
39
38
|
recursive: true,
|
|
@@ -44,10 +43,8 @@ export const launchFallback = async () => {
|
|
|
44
43
|
targetPackage,
|
|
45
44
|
outputBinDir: downloadBinarySourceDir,
|
|
46
45
|
});
|
|
46
|
+
validateBinaryVersion(targetVersion, downloadBinPath);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const downloadBinPath = join(downloadBinarySourceDir, binExecutableName);
|
|
50
|
-
validateBinaryVersion(targetVersion, downloadBinPath);
|
|
51
|
-
|
|
52
49
|
return exec(downloadBinPath);
|
|
53
50
|
};
|
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mkdirSync, rmSync,
|
|
3
|
-
} from 'fs';
|
|
4
|
-
import { linkExistingBinary } from './link-existing-binary.js';
|
|
5
|
-
import { loadMissingBinary } from './load-missing-binary.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
rmSync(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
mkdirSync, rmSync,
|
|
3
|
+
} from 'fs';
|
|
4
|
+
import { linkExistingBinary } from './link-existing-binary.js';
|
|
5
|
+
import { loadMissingBinary } from './load-missing-binary.js';
|
|
6
|
+
import { validateBinaryVersion } from './validate-binary-version.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {{ platform: Bun.Platform, binExecutableName: string, targetPackage: string, targetVersion: string, targetBinPath: string | null, outputBinDir: string, outputBinBasePath: string, outputBinPath: string }} options
|
|
10
|
+
*/
|
|
11
|
+
export const prepareBinary = ({
|
|
12
|
+
platform, binExecutableName, targetPackage, targetVersion, targetBinPath, outputBinDir, outputBinBasePath, outputBinPath,
|
|
13
|
+
}) => {
|
|
14
|
+
rmSync(outputBinBasePath, { force: true });
|
|
15
|
+
rmSync(outputBinPath, { force: true });
|
|
16
|
+
mkdirSync(outputBinDir, { recursive: true });
|
|
17
|
+
|
|
18
|
+
if (targetBinPath) {
|
|
19
|
+
console.info(`Expected CLI binary package is available in '${targetBinPath}'.`);
|
|
20
|
+
validateBinaryVersion(targetVersion, targetBinPath);
|
|
21
|
+
|
|
22
|
+
// Windows can't be optimised to run the binary directly (.exe).
|
|
23
|
+
if (platform === 'win32') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
linkExistingBinary({
|
|
28
|
+
platform,
|
|
29
|
+
targetBinPath,
|
|
30
|
+
outputBinPath,
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.warn(`Expected CLI binary was not found for '${targetPackage}'.`);
|
|
36
|
+
return loadMissingBinary({
|
|
37
|
+
binExecutableName,
|
|
38
|
+
targetPackage,
|
|
39
|
+
outputBinDir,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { exec } from './exec.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} targetVersion
|
|
5
|
-
* @param {string} targetBinPath
|
|
6
|
-
*/
|
|
7
|
-
export const validateBinaryVersion = (targetVersion, targetBinPath) => {
|
|
8
|
-
const stdout = exec(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
1
|
+
import { exec } from './exec.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} targetVersion
|
|
5
|
+
* @param {string} targetBinPath
|
|
6
|
+
*/
|
|
7
|
+
export const validateBinaryVersion = (targetVersion, targetBinPath) => {
|
|
8
|
+
const stdout = exec(
|
|
9
|
+
targetBinPath, undefined, 'pipe',
|
|
10
|
+
).toString()
|
|
11
|
+
.trim();
|
|
12
|
+
|
|
13
|
+
if (stdout.toLowerCase() !== targetVersion.toLowerCase()) {
|
|
14
|
+
throw new Error(`'${targetBinPath}' binary version mismatch; expected ${targetVersion}, got ${stdout}.`);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -8,26 +8,24 @@ try {
|
|
|
8
8
|
platform, targetPackage,
|
|
9
9
|
} = getPlatformInfo();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
targetPackage,
|
|
18
|
-
});
|
|
11
|
+
const {
|
|
12
|
+
outputBinDir, binExecutableName, outputBinBasePath, outputBinPath, targetBinPath, targetVersion,
|
|
13
|
+
} = getPathInfo({
|
|
14
|
+
platform,
|
|
15
|
+
targetPackage,
|
|
16
|
+
});
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
await prepareBinary({
|
|
19
|
+
platform,
|
|
20
|
+
binExecutableName,
|
|
21
|
+
targetPackage,
|
|
22
|
+
targetVersion,
|
|
23
|
+
targetBinPath,
|
|
24
|
+
outputBinDir,
|
|
25
|
+
outputBinBasePath,
|
|
26
|
+
outputBinPath,
|
|
27
|
+
});
|
|
28
|
+
validateBinaryVersion(targetVersion, outputBinPath);
|
|
31
29
|
} catch (e) {
|
|
32
30
|
throw new Error('Post install failed to install CLI binary.', { cause: e });
|
|
33
31
|
}
|