@package-pal/cli 0.0.23 → 0.0.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@package-pal/cli",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "CLI tool exposing core PackagePal functionality.",
5
5
  "keywords": [
6
6
  "package",
@@ -25,13 +25,13 @@
25
25
  "yoctocolors": "^2.1.1"
26
26
  },
27
27
  "optionalDependencies": {
28
- "@package-pal/cli-linux-x64": "0.0.2",
29
- "@package-pal/cli-linux-x64-musl": "0.0.2",
30
- "@package-pal/cli-linux-arm64": "0.0.2",
31
- "@package-pal/cli-linux-arm64-musl": "0.0.2",
32
- "@package-pal/cli-darwin-arm64": "0.0.2",
33
- "@package-pal/cli-darwin-x64": "0.0.2",
34
- "@package-pal/cli-windows-x64": "0.0.2"
28
+ "@package-pal/cli-linux-x64": "0.0.3",
29
+ "@package-pal/cli-linux-x64-musl": "0.0.3",
30
+ "@package-pal/cli-linux-arm64": "0.0.3",
31
+ "@package-pal/cli-linux-arm64-musl": "0.0.3",
32
+ "@package-pal/cli-darwin-arm64": "0.0.3",
33
+ "@package-pal/cli-darwin-x64": "0.0.3",
34
+ "@package-pal/cli-windows-x64": "0.0.3"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=18"
@@ -1,11 +1,14 @@
1
- import { execFileSync } from 'child_process';
2
-
3
- /**
4
- * @param {string} binPath
5
- * @param {string[]} args
6
- */
7
- export const exec = (binPath, args = process.argv.slice(2)) => {
8
- return execFileSync(
9
- binPath, args, { stdio: 'inherit' },
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 prevDownloadedBinPath = join(downloadBinarySourceDir, binExecutableName);
36
- if (!existsSync(prevDownloadedBinPath)) {
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
  };
@@ -3,12 +3,13 @@ import {
3
3
  } from 'fs';
4
4
  import { linkExistingBinary } from './link-existing-binary.js';
5
5
  import { loadMissingBinary } from './load-missing-binary.js';
6
+ import { validateBinaryVersion } from './validate-binary-version.js';
6
7
 
7
8
  /**
8
- * @param {{ platform: Bun.Platform, binExecutableName: string, targetPackage: string, targetBinPath: string | null, outputBinDir: string, outputBinBasePath: string, outputBinPath: string }} options
9
+ * @param {{ platform: Bun.Platform, binExecutableName: string, targetPackage: string, targetVersion: string, targetBinPath: string | null, outputBinDir: string, outputBinBasePath: string, outputBinPath: string }} options
9
10
  */
10
11
  export const prepareBinary = ({
11
- platform, binExecutableName, targetPackage, targetBinPath, outputBinDir, outputBinBasePath, outputBinPath,
12
+ platform, binExecutableName, targetPackage, targetVersion, targetBinPath, outputBinDir, outputBinBasePath, outputBinPath,
12
13
  }) => {
13
14
  rmSync(outputBinBasePath, { force: true });
14
15
  rmSync(outputBinPath, { force: true });
@@ -16,12 +17,19 @@ export const prepareBinary = ({
16
17
 
17
18
  if (targetBinPath) {
18
19
  console.info(`Expected CLI binary package is available in '${targetBinPath}'.`);
20
+ validateBinaryVersion(targetVersion, targetPackage);
21
+
22
+ // Windows can't be optimised to run the binary directly (.exe).
23
+ if (platform === 'win32') {
24
+ return;
25
+ }
26
+
19
27
  linkExistingBinary({
20
28
  platform,
21
29
  targetBinPath,
22
30
  outputBinPath,
23
31
  });
24
- return Promise.resolve();
32
+ return;
25
33
  }
26
34
 
27
35
  console.warn(`Expected CLI binary was not found for '${targetPackage}'.`);
@@ -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(targetBinPath).toString()
9
- .trim();
10
-
11
- if (stdout.toLowerCase() !== targetVersion.toLowerCase()) {
12
- throw new Error(`'${targetBinPath}' binary version mismatch; expected ${targetVersion}, got ${stdout}.`);
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
- // Windows can't be optimised to run the binary directly (.exe).
12
- if (platform !== 'win32') {
13
- const {
14
- outputBinDir, binExecutableName, outputBinBasePath, outputBinPath, targetBinPath, targetVersion,
15
- } = getPathInfo({
16
- platform,
17
- targetPackage,
18
- });
11
+ const {
12
+ outputBinDir, binExecutableName, outputBinBasePath, outputBinPath, targetBinPath, targetVersion,
13
+ } = getPathInfo({
14
+ platform,
15
+ targetPackage,
16
+ });
19
17
 
20
- await prepareBinary({
21
- platform,
22
- binExecutableName,
23
- targetPackage,
24
- targetBinPath,
25
- outputBinDir,
26
- outputBinBasePath,
27
- outputBinPath,
28
- });
29
- validateBinaryVersion(targetVersion, outputBinPath);
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
  }