@apex-actions/cli 0.99.0 → 0.100.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.
package/README.md CHANGED
@@ -125,7 +125,6 @@ refused · 2 usage or configuration · 3 not found on `delete`.
125
125
  - `src/application/` — use cases over ports
126
126
  - `src/infrastructure/` — adapters: the engine and runner binaries, the REST API
127
127
  - Documentation is the root's: decisions in `docs/adrs/cli/`, the rest by category in `docs/` (TASK-0526)
128
- - `VERSION` — the release version, which `version:sync` writes from the root (ADR-0048); never edited by hand
129
128
 
130
129
  ## Licence
131
130
 
package/dist/cli/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { packageVersion } from '../src/infrastructure/binary-install.js';
3
3
  import { buildProgram } from './program.js';
4
- // The version from the nearest `package.json` — what ships, and what `version:check` keeps equal to
5
- // `VERSION` (see `packageVersion`); it also names which engine and runner the CLI downloads.
4
+ // The version from the nearest `package.json` — the tag's, written at publish (ADR-0053; see `packageVersion`);
5
+ // it also names which engine and runner the CLI downloads.
6
6
  buildProgram(packageVersion()).parse(process.argv);
@@ -12,24 +12,35 @@ import { promisify } from 'node:util';
12
12
  * platform and a SHA256SUMS file per command, under the lockstep version.
13
13
  */
14
14
  export const DIST_BASE = 'https://apexactions.com/dl';
15
- /**
16
- * The CLI's version, from the nearest `package.json` above this file.
17
- *
18
- * `VERSION` is the source of truth in the repository and is not in the published package; what ships is
19
- * `package.json`, and `version:check` guarantees the two agree. Walking up survives the layout differing
20
- * between `tsx` (`src/…`) and a tarball (`dist/src/…`).
21
- */
22
- export const packageVersion = (from = import.meta.dirname) => {
15
+ /** What every workspace's `package.json` says in the repository: a constant, not a release (ADR-0053). */
16
+ const UNRELEASED = '0.0.0';
17
+ /** The first directory at or above `from` that `read` succeeds in, read; undefined when none does. */
18
+ const nearest = (from, read) => {
23
19
  for (let dir = from;; dir = dirname(dir)) {
24
20
  try {
25
- return JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).version;
21
+ return read(dir);
26
22
  }
27
23
  catch {
28
24
  if (dirname(dir) === dir)
29
- return '0.0.0-unknown';
25
+ return undefined;
30
26
  }
31
27
  }
32
28
  };
29
+ /**
30
+ * The CLI's version, from the nearest `package.json` above this file.
31
+ *
32
+ * In the repository a workspace's `package.json` carries `0.0.0` and the release is the root `VERSION` alone
33
+ * (ADR-0053), so a release changes nothing a build hashes; `publish.yml` writes the tag's version into the package
34
+ * it publishes, and that is what an installed CLI reads. A checkout's `0.0.0` reads on to the root `VERSION`, so a
35
+ * development CLI downloads the last release's binaries rather than ones nobody published. Walking up survives the
36
+ * layout differing between `tsx` (`src/…`) and a tarball (`dist/src/…`).
37
+ */
38
+ export const packageVersion = (from = import.meta.dirname) => {
39
+ const declared = nearest(from, (dir) => JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).version);
40
+ if (declared !== undefined && declared !== UNRELEASED)
41
+ return declared;
42
+ return nearest(from, (dir) => readFileSync(join(dir, 'VERSION'), 'utf8').trim()) ?? '0.0.0-unknown';
43
+ };
33
44
  /** Node's names to Go's, for the four targets that are published; anything else has no download. */
34
45
  export const platformOf = (platform, arch) => {
35
46
  const os = platform === 'darwin' ? 'darwin' : platform === 'linux' ? 'linux' : undefined;
@@ -111,4 +111,11 @@ describe('the names', () => {
111
111
  writeFileSync(join(root, 'package.json'), JSON.stringify({ version: '9.8.7' }));
112
112
  expect(packageVersion(join(root, 'dist', 'src'))).toBe('9.8.7');
113
113
  });
114
+ it("reads a checkout's 0.0.0 on to the root VERSION, the release (ADR-0053)", () => {
115
+ const root = mkdtempSync(join(tmpdir(), 'repo-'));
116
+ mkdirSync(join(root, 'apps', 'cli', 'src'), { recursive: true });
117
+ writeFileSync(join(root, 'VERSION'), '0.99.0\n');
118
+ writeFileSync(join(root, 'apps', 'cli', 'package.json'), JSON.stringify({ version: '0.0.0' }));
119
+ expect(packageVersion(join(root, 'apps', 'cli', 'src'))).toBe('0.99.0');
120
+ });
114
121
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apex-actions/cli",
3
- "version": "0.99.0",
3
+ "version": "0.100.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "//files": "Without this npm ships src, test and the CI config alongside the binary a user installs.",
6
6
  "files": [