@inplaysoft/cli 0.10.0 → 0.12.0

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.
Files changed (2) hide show
  1. package/inplay.js +31 -19
  2. package/package.json +7 -7
package/inplay.js CHANGED
@@ -1,32 +1,44 @@
1
1
  #!/usr/bin/env node
2
- // Thin Node wrapper that locates the matching native @inplaysoft/cli-<os>-<arch>
2
+ // Thin Node wrapper that locates the matching native <wrapper>-<os>-<arch>
3
3
  // package and execs its binary. The release workflow ships one binary per
4
4
  // optional-platform package and npm only installs the one that matches the
5
5
  // host's process.platform + process.arch — same pattern as esbuild, swc,
6
6
  // biome, tailwindcss-oxide.
7
+ //
8
+ // One wrapper serves every release channel (#27756): the platform-package
9
+ // prefix is this package's OWN name, read from the package.json npm ships
10
+ // beside it — `@inplaysoft/cli` (prod) resolves `@inplaysoft/cli-linux-x64`,
11
+ // `@inplaysoft/cli-staging` resolves `@inplaysoft/cli-staging-linux-x64`.
12
+ // There is deliberately NO fallback to the prod prefix: a channel wrapper that
13
+ // cannot name itself must fail, never silently run another channel's binary.
7
14
 
8
15
  const { spawnSync } = require('node:child_process');
9
16
 
10
- const PLATFORM_PACKAGES = {
11
- 'darwin-arm64': '@inplaysoft/cli-darwin-arm64',
12
- 'darwin-x64': '@inplaysoft/cli-darwin-x64',
13
- 'linux-arm64': '@inplaysoft/cli-linux-arm64',
14
- 'linux-x64': '@inplaysoft/cli-linux-x64',
15
- 'win32-arm64': '@inplaysoft/cli-win32-arm64',
16
- 'win32-x64': '@inplaysoft/cli-win32-x64',
17
- };
17
+ const SUPPORTED = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-arm64', 'win32-x64'];
18
18
 
19
- const key = `${process.platform}-${process.arch}`;
20
- const pkg = PLATFORM_PACKAGES[key];
21
-
22
- if (!pkg) {
19
+ let wrapper;
20
+ try {
21
+ wrapper = require('./package.json').name;
22
+ } catch (err) {
23
23
  console.error(
24
- `@inplaysoft/cli: unsupported platform ${key}. ` +
25
- `Supported: ${Object.keys(PLATFORM_PACKAGES).join(', ')}.`,
24
+ `inplay: cannot read the wrapper's own package.json (${err.message}).\n` +
25
+ ` Reinstall the inplay CLI package you installed (e.g. npm install -g @inplaysoft/cli).`,
26
26
  );
27
27
  process.exit(1);
28
28
  }
29
+ if (typeof wrapper !== 'string' || !/^@inplaysoft\/cli(-[a-z]+)?$/.test(wrapper)) {
30
+ console.error(`inplay: the wrapper's package.json names '${wrapper}', not an @inplaysoft/cli package. Reinstall it.`);
31
+ process.exit(1);
32
+ }
33
+
34
+ const key = `${process.platform}-${process.arch}`;
35
+
36
+ if (!SUPPORTED.includes(key)) {
37
+ console.error(`${wrapper}: unsupported platform ${key}. Supported: ${SUPPORTED.join(', ')}.`);
38
+ process.exit(1);
39
+ }
29
40
 
41
+ const pkg = `${wrapper}-${key}`;
30
42
  const binName = process.platform === 'win32' ? 'inplay.exe' : 'inplay';
31
43
 
32
44
  let binaryPath;
@@ -35,12 +47,12 @@ try {
35
47
  } catch (err) {
36
48
  // The matching optional-platform package isn't installed. This usually
37
49
  // means npm skipped it because the host advertised a different
38
- // platform/arch than the one running `inplay` (e.g. installing in CI
50
+ // platform/arch than the one running the wrapper (e.g. installing in CI
39
51
  // with --omit=optional, or using a tool that filters optional deps).
40
52
  console.error(
41
- `@inplaysoft/cli: native binary for ${key} is not installed.\n` +
53
+ `${wrapper}: native binary for ${key} is not installed.\n` +
42
54
  ` Try: npm install ${pkg}\n` +
43
- ` Or: reinstall @inplaysoft/cli without --omit=optional.`,
55
+ ` Or: reinstall ${wrapper} without --omit=optional.`,
44
56
  );
45
57
  process.exit(1);
46
58
  }
@@ -51,7 +63,7 @@ const result = spawnSync(binaryPath, process.argv.slice(2), {
51
63
  });
52
64
 
53
65
  if (result.error) {
54
- console.error(`@inplaysoft/cli: failed to spawn ${binaryPath}: ${result.error.message}`);
66
+ console.error(`${wrapper}: failed to spawn ${binaryPath}: ${result.error.message}`);
55
67
  process.exit(1);
56
68
  }
57
69
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inplaysoft/cli",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Inplaysoft Platform command-line interface (inplay).",
5
5
  "bin": {
6
6
  "inplay": "./inplay.js"
@@ -13,12 +13,12 @@
13
13
  "README.md"
14
14
  ],
15
15
  "optionalDependencies": {
16
- "@inplaysoft/cli-darwin-arm64": "0.10.0",
17
- "@inplaysoft/cli-darwin-x64": "0.10.0",
18
- "@inplaysoft/cli-linux-arm64": "0.10.0",
19
- "@inplaysoft/cli-linux-x64": "0.10.0",
20
- "@inplaysoft/cli-win32-arm64": "0.10.0",
21
- "@inplaysoft/cli-win32-x64": "0.10.0"
16
+ "@inplaysoft/cli-darwin-arm64": "0.12.0",
17
+ "@inplaysoft/cli-darwin-x64": "0.12.0",
18
+ "@inplaysoft/cli-linux-arm64": "0.12.0",
19
+ "@inplaysoft/cli-linux-x64": "0.12.0",
20
+ "@inplaysoft/cli-win32-arm64": "0.12.0",
21
+ "@inplaysoft/cli-win32-x64": "0.12.0"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"