@anvil-di/anvil-cli 0.0.3 → 0.0.5
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/LICENSE +1 -1
- package/README.md +16 -16
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2026
|
|
189
|
+
Copyright 2026 Mike Sulak
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# `@
|
|
1
|
+
# `@anvil-di/anvil-cli`
|
|
2
2
|
|
|
3
|
-
Native binary launcher for [`@
|
|
3
|
+
Native binary launcher for [`@anvil-di/anvil`](https://github.com/msulak13/tsdi) — installs the right prebuilt CLI for your platform, exposes it as an `anvil` command, and provides a programmatic API for tooling that needs to invoke codegen (like [`@anvil-di/anvil-unplugin`](https://www.npmjs.com/package/@anvil-di/anvil-unplugin)).
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install -D @
|
|
9
|
-
pnpm add -D @
|
|
10
|
-
yarn add -D @
|
|
8
|
+
npm install -D @anvil-di/anvil-cli # adds the launcher + npm picks one platform package
|
|
9
|
+
pnpm add -D @anvil-di/anvil-cli # pnpm honors optionalDependencies by default
|
|
10
|
+
yarn add -D @anvil-di/anvil-cli # yarn honors optionalDependencies by default
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The `@
|
|
13
|
+
The `@anvil-di/anvil-cli` package itself ships zero binaries. Its `optionalDependencies` field lists every supported platform; npm's `os`/`cpu` filtering installs **exactly one** of them (the one matching your machine). The CLI binary lives inside that platform package.
|
|
14
14
|
|
|
15
15
|
## Use as a command
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ The `anvil` shim in `node_modules/.bin` resolves the per-platform package, then
|
|
|
26
26
|
## Use programmatically
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import { resolveBinaryPath, unresolvableBinaryError } from "@
|
|
29
|
+
import { resolveBinaryPath, unresolvableBinaryError } from "@anvil-di/anvil-cli";
|
|
30
30
|
|
|
31
31
|
const binary = resolveBinaryPath();
|
|
32
32
|
if (binary === null) {
|
|
@@ -35,14 +35,14 @@ if (binary === null) {
|
|
|
35
35
|
// `binary` is an absolute path you can pass to execFile / spawn.
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
This is what `@
|
|
38
|
+
This is what `@anvil-di/anvil-unplugin` uses by default. Any tooling that needs the same "find my platform's binary" lookup can use the same API.
|
|
39
39
|
|
|
40
40
|
## Resolution order
|
|
41
41
|
|
|
42
42
|
`resolveBinaryPath()` checks, in order:
|
|
43
43
|
|
|
44
44
|
1. **`ANVIL_CLI_BIN` env var** — if it points at an existing file, that file wins. Useful for tests, monorepo dev (point at `target/release/anvil`), and CI that builds from source.
|
|
45
|
-
2. **`require.resolve("@
|
|
45
|
+
2. **`require.resolve("@anvil-di/anvil-cli-<platform>-<arch>")`** — the per-platform npm package corresponding to the current Node process.
|
|
46
46
|
|
|
47
47
|
If neither resolves, the function returns `null` and `unresolvableBinaryError()` produces a human-readable message diagnosing why (unsupported platform, optional deps skipped during install, etc.).
|
|
48
48
|
|
|
@@ -50,11 +50,11 @@ If neither resolves, the function returns `null` and `unresolvableBinaryError()`
|
|
|
50
50
|
|
|
51
51
|
| Platform | Arch | Package |
|
|
52
52
|
|---|---|---|
|
|
53
|
-
| Linux | x64 | `@
|
|
54
|
-
| Linux | arm64 | `@
|
|
55
|
-
| macOS | x64 (Intel) | `@
|
|
56
|
-
| macOS | arm64 (Apple Silicon) | `@
|
|
57
|
-
| Windows | x64 | `@
|
|
53
|
+
| Linux | x64 | `@anvil-di/anvil-cli-linux-x64` |
|
|
54
|
+
| Linux | arm64 | `@anvil-di/anvil-cli-linux-arm64` |
|
|
55
|
+
| macOS | x64 (Intel) | `@anvil-di/anvil-cli-darwin-x64` |
|
|
56
|
+
| macOS | arm64 (Apple Silicon) | `@anvil-di/anvil-cli-darwin-arm64` |
|
|
57
|
+
| Windows | x64 | `@anvil-di/anvil-cli-win32-x64` |
|
|
58
58
|
|
|
59
59
|
Need another? Open an issue, or build from source:
|
|
60
60
|
|
|
@@ -67,13 +67,13 @@ export ANVIL_CLI_BIN=$PWD/target/release/anvil
|
|
|
67
67
|
|
|
68
68
|
## How releases work
|
|
69
69
|
|
|
70
|
-
The repo's [`release-cli.yml` GitHub Actions workflow](https://github.com/msulak13/tsdi/blob/main/.github/workflows/release-cli.yml) builds the binary on each native runner (linux-x64, linux-arm64 via cross, macos-13, macos-14, windows-latest) and publishes the matching `@
|
|
70
|
+
The repo's [`release-cli.yml` GitHub Actions workflow](https://github.com/msulak13/tsdi/blob/main/.github/workflows/release-cli.yml) builds the binary on each native runner (linux-x64, linux-arm64 via cross, macos-13, macos-14, windows-latest) and publishes the matching `@anvil-di/anvil-cli-<platform>-<arch>` package along with the launcher. The launcher's `optionalDependencies` are pinned to the same version, so a single `npm install @anvil-di/anvil-cli@<version>` always pulls a coherent set.
|
|
71
71
|
|
|
72
72
|
## Why this layout
|
|
73
73
|
|
|
74
74
|
esbuild popularized this pattern because it sidesteps every alternative's failure modes:
|
|
75
75
|
|
|
76
76
|
- **No `postinstall` build step** — no Rust toolchain on user machines, no opaque "compiling…" delay during `npm install`.
|
|
77
|
-
- **No giant universal binary in the launcher** — `npm install @
|
|
77
|
+
- **No giant universal binary in the launcher** — `npm install @anvil-di/anvil-cli` downloads ~4MB, not ~25MB times five.
|
|
78
78
|
- **No conditional logic in the launcher's `package.json`** — npm does the platform filtering for us via `os`/`cpu`.
|
|
79
79
|
- **Hash-pinned reproducibility** — every install gets the exact binary CI built; nothing is recompiled on the user's machine.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvil-di/anvil-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Native binary launcher for the anvil codegen CLI. Resolves the right per-platform package at runtime; mirrors esbuild's distribution model.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"src"
|
|
23
23
|
],
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@anvil-di/anvil-cli-darwin-arm64": "0.0.
|
|
26
|
-
"@anvil-di/anvil-cli-linux-arm64": "0.0.
|
|
27
|
-
"@anvil-di/anvil-cli-linux-x64": "0.0.
|
|
28
|
-
"@anvil-di/anvil-cli-win32-x64": "0.0.
|
|
25
|
+
"@anvil-di/anvil-cli-darwin-arm64": "0.0.5",
|
|
26
|
+
"@anvil-di/anvil-cli-linux-arm64": "0.0.5",
|
|
27
|
+
"@anvil-di/anvil-cli-linux-x64": "0.0.5",
|
|
28
|
+
"@anvil-di/anvil-cli-win32-x64": "0.0.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.0",
|