@zuke-build/cli 0.0.0-stage → 2.7.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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -2
  3. package/mod.d.ts +102 -0
  4. package/mod.js +931 -0
  5. package/package.json +35 -4
  6. package/src/binary_launcher.d.ts +49 -0
  7. package/src/binary_launcher.js +325 -0
  8. package/src/binary_pin.d.ts +47 -0
  9. package/src/binary_pin.js +117 -0
  10. package/src/build_file.d.ts +25 -0
  11. package/src/build_file.js +58 -0
  12. package/src/cache.d.ts +23 -0
  13. package/src/cache.js +26 -0
  14. package/src/deno_isolated.d.ts +14 -0
  15. package/src/deno_isolated.js +70 -0
  16. package/src/deno_path.d.ts +115 -0
  17. package/src/deno_path.js +205 -0
  18. package/src/deno_pin.d.ts +37 -0
  19. package/src/deno_pin.js +32 -0
  20. package/src/dependencies.d.ts +48 -0
  21. package/src/dependencies.js +80 -0
  22. package/src/dispatch.d.ts +229 -0
  23. package/src/dispatch.js +549 -0
  24. package/src/embedded_engine.d.ts +28 -0
  25. package/src/embedded_engine.js +21 -0
  26. package/src/engine_pin.d.ts +56 -0
  27. package/src/engine_pin.js +196 -0
  28. package/src/fs.d.ts +14 -0
  29. package/src/fs.js +25 -0
  30. package/src/import.d.ts +132 -0
  31. package/src/import.js +289 -0
  32. package/src/install_source.d.ts +79 -0
  33. package/src/install_source.js +104 -0
  34. package/src/launcher.d.ts +37 -0
  35. package/src/launcher.js +405 -0
  36. package/src/launcher_shared.d.ts +25 -0
  37. package/src/launcher_shared.js +91 -0
  38. package/src/mcp_config.d.ts +71 -0
  39. package/src/mcp_config.js +96 -0
  40. package/src/node_launcher.d.ts +19 -0
  41. package/src/node_launcher.js +416 -0
  42. package/src/node_pin.d.ts +25 -0
  43. package/src/node_pin.js +30 -0
  44. package/src/output.d.ts +38 -0
  45. package/src/output.js +43 -0
  46. package/src/paint.d.ts +42 -0
  47. package/src/paint.js +38 -0
  48. package/src/project.d.ts +69 -0
  49. package/src/project.js +132 -0
  50. package/src/pyproject.d.ts +30 -0
  51. package/src/pyproject.js +156 -0
  52. package/src/python_build.d.ts +27 -0
  53. package/src/python_build.js +197 -0
  54. package/src/records.d.ts +18 -0
  55. package/src/records.js +31 -0
  56. package/src/relock.d.ts +11 -0
  57. package/src/relock.js +182 -0
  58. package/src/runtime_field.d.ts +15 -0
  59. package/src/runtime_field.js +29 -0
  60. package/src/setup.d.ts +259 -0
  61. package/src/setup.js +693 -0
  62. package/src/star.d.ts +44 -0
  63. package/src/star.js +100 -0
  64. package/src/starter.d.ts +64 -0
  65. package/src/starter.js +138 -0
  66. package/src/toml.d.ts +32 -0
  67. package/src/toml.js +354 -0
  68. package/src/translate.d.ts +69 -0
  69. package/src/translate.js +198 -0
  70. package/src/upgrade.d.ts +113 -0
  71. package/src/upgrade.js +344 -0
  72. package/src/version.d.ts +11 -0
  73. package/src/version.js +13 -0
  74. package/src/version_report.d.ts +55 -0
  75. package/src/version_report.js +187 -0
  76. package/zuke.js +8 -0
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@zuke-build/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.7.0",
4
+ "description": "The zuke command-line tool — scaffold a Zuke project with `zuke setup`, including a starter build, launchers, and tasks.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./mod.d.ts",
10
+ "default": "./mod.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "**/*.js",
15
+ "**/*.d.ts"
16
+ ],
17
+ "bin": {
18
+ "zuke": "zuke.js"
19
+ },
20
+ "engines": {
21
+ "node": ">=24.12"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/zuke-build/zuke.git",
26
+ "directory": "packages/cli"
27
+ },
28
+ "homepage": "https://zuke.build",
29
+ "bugs": {
30
+ "url": "https://github.com/zuke-build/zuke/issues"
31
+ },
32
+ "dependencies": {
33
+ "@zuke/console": "npm:@zuke-build/console@^1.1.0",
34
+ "@zuke/core": "npm:@zuke-build/core@^1.83.0",
35
+ "@zuke/gh": "npm:@zuke-build/gh@^1.6.0"
36
+ }
37
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The `./zuke` and `zuke.ps1` launchers of a project another SDK hosts: a
3
+ * Python build, say, with a `zuke.json` and no `zuke.ts`. They run the
4
+ * standalone `zuke` binary, which carries the engine and every tool wrapper,
5
+ * so the project needs nothing from a stack it does not use — no Deno, no
6
+ * Node — on a laptop or a CI runner. Two variants, as for the Deno launchers
7
+ * in {@link "./launcher.ts"}:
8
+ *
9
+ * - **download** — run the `zuke` release the launcher pins
10
+ * ({@link "./binary_pin.ts"}). On first use, download its archive from the
11
+ * release, verify it against the pinned SHA-256, and keep the binary in
12
+ * `ZUKE_INSTALL` (default `~/.zuke`), one directory per release. Nothing is
13
+ * installed that the pin did not vouch for; `ZUKE_RELEASES_URL` names a
14
+ * mirror, whose download is verified the same way.
15
+ * - **plain** — require `zuke` on `PATH`, and when it is missing print where
16
+ * to get it and exit 1, for a project that must not download its tools.
17
+ *
18
+ * Both set `ZUKE_FORWARDED`, so the `zuke` they start runs the build itself
19
+ * rather than this launcher again, and `ZUKE_LAUNCHER_ROOT` to the
20
+ * launcher's directory: running a launcher is an explicit act on the
21
+ * project it sits in, so the discovery trust gate does not judge that root.
22
+ *
23
+ * @module
24
+ */
25
+ import { type BinaryPin } from "./binary_pin.ts";
26
+ /** Which binary launcher variant to render. */
27
+ export interface BinaryLauncherOptions {
28
+ /**
29
+ * Download the pinned, checksum-verified `zuke` release when it is not
30
+ * already kept (`true`), or require `zuke` on `PATH` and fail closed
31
+ * without it (`false`).
32
+ */
33
+ download: boolean;
34
+ }
35
+ /** The line every binary launcher opens its description with. */
36
+ export declare const BINARY_LAUNCHER_MARKER = "# Zuke launcher for a build another SDK hosts";
37
+ /** The line a plain binary launcher carries, which `zuke upgrade --engine` keeps it plain by. */
38
+ export declare const PLAIN_BINARY_LAUNCHER = "# Runs the zuke on PATH:";
39
+ /**
40
+ * The bash launcher (`./zuke`) of a hosted build: runs the pinned `zuke`
41
+ * release, downloading it first, or the `zuke` on `PATH` (see the module
42
+ * docs for the variants).
43
+ */
44
+ export declare function binaryLauncherBash(options: BinaryLauncherOptions, pin: BinaryPin): string;
45
+ /**
46
+ * The PowerShell launcher (`.\zuke.ps1`) of a hosted build. Mirrors
47
+ * {@link binaryLauncherBash}, variant for variant.
48
+ */
49
+ export declare function binaryLauncherPwsh(options: BinaryLauncherOptions, pin: BinaryPin): string;
@@ -0,0 +1,325 @@
1
+ // Copyright (c) 2026 the Zuke contributors
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * The `./zuke` and `zuke.ps1` launchers of a project another SDK hosts: a
5
+ * Python build, say, with a `zuke.json` and no `zuke.ts`. They run the
6
+ * standalone `zuke` binary, which carries the engine and every tool wrapper,
7
+ * so the project needs nothing from a stack it does not use — no Deno, no
8
+ * Node — on a laptop or a CI runner. Two variants, as for the Deno launchers
9
+ * in {@link "./launcher.ts"}:
10
+ *
11
+ * - **download** — run the `zuke` release the launcher pins
12
+ * ({@link "./binary_pin.ts"}). On first use, download its archive from the
13
+ * release, verify it against the pinned SHA-256, and keep the binary in
14
+ * `ZUKE_INSTALL` (default `~/.zuke`), one directory per release. Nothing is
15
+ * installed that the pin did not vouch for; `ZUKE_RELEASES_URL` names a
16
+ * mirror, whose download is verified the same way.
17
+ * - **plain** — require `zuke` on `PATH`, and when it is missing print where
18
+ * to get it and exit 1, for a project that must not download its tools.
19
+ *
20
+ * Both set `ZUKE_FORWARDED`, so the `zuke` they start runs the build itself
21
+ * rather than this launcher again, and `ZUKE_LAUNCHER_ROOT` to the
22
+ * launcher's directory: running a launcher is an explicit act on the
23
+ * project it sits in, so the discovery trust gate does not judge that root.
24
+ *
25
+ * @module
26
+ */
27
+ import { BINARY_INSTALL_DOCS, BINARY_POSIX_TARGETS, BINARY_RELEASES_URL, BINARY_WINDOWS_TARGET, binaryReleaseTag, } from "./binary_pin.js";
28
+ import { LICENSE_HEADER } from "./launcher_shared.js";
29
+ import { FORWARDED_ENV, LAUNCHER_ROOT_ENV } from "./dispatch.js";
30
+ /** The line every binary launcher opens its description with. */
31
+ export const BINARY_LAUNCHER_MARKER = "# Zuke launcher for a build another SDK hosts";
32
+ /** The line a plain binary launcher carries, which `zuke upgrade --engine` keeps it plain by. */
33
+ export const PLAIN_BINARY_LAUNCHER = "# Runs the zuke on PATH:";
34
+ /* cspell:disable */
35
+ /** The usage lines both scripts open with, for `./zuke` or `.\zuke.ps1`. */
36
+ function usage(command) {
37
+ return `# ${command} # run the default target
38
+ # ${command} <target> # run one target and its prerequisites
39
+ # ${command} --list # list every target`;
40
+ }
41
+ /** The bash launcher's download of the pinned release into `$zuke_bin`. */
42
+ function bashDownload(pin) {
43
+ const arms = BINARY_POSIX_TARGETS.map((target) => ` ${target})\n echo "${pin.checksums[target]}" ;;`).join("\n");
44
+ return `# The pinned release, and the SHA-256 of each platform's archive, from the
45
+ # SHA256SUMS of ${BINARY_RELEASES_URL}/${binaryReleaseTag(pin.version)}.
46
+ # Moved by \`zuke upgrade --engine\`, which rewrites this file; never hand-edit.
47
+ ZUKE_VERSION="${pin.version}"
48
+ zuke_checksum_for() {
49
+ case "$1" in
50
+ ${arms}
51
+ *)
52
+ return 1 ;;
53
+ esac
54
+ }
55
+
56
+ zuke_install="\${ZUKE_INSTALL:-$HOME/.zuke}"
57
+ zuke_bin="$zuke_install/releases/$ZUKE_VERSION/zuke"
58
+
59
+ if [ ! -x "$zuke_bin" ]; then
60
+ echo "zuke: zuke $ZUKE_VERSION is not here yet — downloading it..." >&2
61
+ for cmd in curl tar; do
62
+ if ! command -v "$cmd" >/dev/null 2>&1; then
63
+ echo "zuke: $cmd is required to download zuke; install zuke instead:" >&2
64
+ echo " ${BINARY_INSTALL_DOCS}" >&2
65
+ exit 1
66
+ fi
67
+ done
68
+
69
+ # Map uname's OS/arch spelling to the release's target triple.
70
+ case "$(uname -s)" in
71
+ Linux) os_part="unknown-linux-gnu" ;;
72
+ Darwin) os_part="apple-darwin" ;;
73
+ *)
74
+ echo "zuke: no zuke release is built for $(uname -s); use zuke.ps1 on Windows." >&2
75
+ exit 1
76
+ ;;
77
+ esac
78
+ case "$(uname -m)" in
79
+ x86_64 | amd64) arch_part="x86_64" ;;
80
+ arm64 | aarch64) arch_part="aarch64" ;;
81
+ *)
82
+ echo "zuke: no zuke release is built for the $(uname -m) architecture." >&2
83
+ exit 1
84
+ ;;
85
+ esac
86
+ target="\${arch_part}-\${os_part}"
87
+ expected_sha256="$(zuke_checksum_for "$target")" || {
88
+ echo "zuke: no pinned checksum for $target." >&2
89
+ exit 1
90
+ }
91
+
92
+ asset="zuke-\${ZUKE_VERSION}-\${target}.tar.gz"
93
+ download_url="\${ZUKE_RELEASES_URL:-${BINARY_RELEASES_URL}}/cli-v\${ZUKE_VERSION}/\${asset}"
94
+ work_dir="$(mktemp -d)"
95
+ trap 'rm -rf "$work_dir"' EXIT
96
+ archive="$work_dir/$asset"
97
+
98
+ # The network is occasionally flaky (a transient 5xx from the CDN), so a blip
99
+ # is retried with backoff rather than failing the run.
100
+ attempt=1
101
+ max_attempts=4
102
+ until curl -fsSL -o "$archive" "$download_url"; do
103
+ if [ "$attempt" -ge "$max_attempts" ]; then
104
+ echo "zuke: failed to download $download_url after $max_attempts attempts." >&2
105
+ exit 1
106
+ fi
107
+ delay=$((attempt * 3))
108
+ echo "zuke: download failed (attempt $attempt/$max_attempts); retrying in \${delay}s..." >&2
109
+ sleep "$delay"
110
+ attempt=$((attempt + 1))
111
+ done
112
+
113
+ if command -v sha256sum >/dev/null 2>&1; then
114
+ actual_sha256="$(sha256sum "$archive" | awk '{print $1}')"
115
+ elif command -v shasum >/dev/null 2>&1; then
116
+ actual_sha256="$(shasum -a 256 "$archive" | awk '{print $1}')"
117
+ else
118
+ echo "zuke: neither sha256sum nor shasum is available to verify the download." >&2
119
+ exit 1
120
+ fi
121
+ if [ "$actual_sha256" != "$expected_sha256" ]; then
122
+ echo "zuke: checksum mismatch for $asset:" >&2
123
+ echo " expected $expected_sha256" >&2
124
+ echo " got $actual_sha256" >&2
125
+ exit 1
126
+ fi
127
+
128
+ tar -xzf "$archive" -C "$work_dir" zuke
129
+ mkdir -p "$(dirname "$zuke_bin")"
130
+ # Moved into place in one step, so a run interrupted mid-copy never leaves a
131
+ # binary behind that later runs would trust without verifying.
132
+ mv -f "$work_dir/zuke" "$zuke_bin.$$"
133
+ chmod +x "$zuke_bin.$$"
134
+ mv -f "$zuke_bin.$$" "$zuke_bin"
135
+ # Removed now: the exec below replaces this shell, so the trap never fires.
136
+ rm -rf "$work_dir"
137
+ trap - EXIT
138
+ fi`;
139
+ }
140
+ /** The bash launcher's plain resolution: the `zuke` on `PATH`, or exit 1. */
141
+ function bashPlain() {
142
+ return `if ! command -v zuke >/dev/null 2>&1; then
143
+ echo "zuke: the zuke command is not on PATH. Install it, then re-run this launcher:" >&2
144
+ echo " ${BINARY_INSTALL_DOCS}" >&2
145
+ exit 1
146
+ fi
147
+ zuke_bin="$(command -v zuke)"
148
+ # An empty or "." entry in PATH finds this very script (it ran \`cd\` into its
149
+ # own directory), and so would a zuke linked to it: running that would loop.
150
+ if [ "$zuke_bin" -ef "\${BASH_SOURCE[0]}" ]; then
151
+ echo "zuke: the zuke on PATH is this launcher ($zuke_bin), not the zuke command." >&2
152
+ echo " Install zuke, or drop the empty or . entry from PATH: ${BINARY_INSTALL_DOCS}" >&2
153
+ exit 1
154
+ fi`;
155
+ }
156
+ /**
157
+ * The bash launcher (`./zuke`) of a hosted build: runs the pinned `zuke`
158
+ * release, downloading it first, or the `zuke` on `PATH` (see the module
159
+ * docs for the variants).
160
+ */
161
+ export function binaryLauncherBash(options, pin) {
162
+ const purpose = options.download
163
+ ? `# Runs zuke ${pin.version}, which carries the engine and every tool wrapper, so
164
+ # this project needs nothing installed but its own SDK's tools. On first use
165
+ # it downloads that release, checksum-verified, into ZUKE_INSTALL.
166
+ #
167
+ # Honoured environment variables:
168
+ # ZUKE_INSTALL where zuke releases are kept (default: ~/.zuke)
169
+ # ZUKE_RELEASES_URL a mirror of ${BINARY_RELEASES_URL};
170
+ # what it serves is verified against the pins below`
171
+ : `${PLAIN_BINARY_LAUNCHER} ${BINARY_INSTALL_DOCS}`;
172
+ const resolve = options.download ? bashDownload(pin) : bashPlain();
173
+ return `#!/usr/bin/env bash
174
+ ${LICENSE_HEADER}
175
+ #
176
+ ${BINARY_LAUNCHER_MARKER}.
177
+ #
178
+ ${usage("./zuke")}
179
+ #
180
+ ${purpose}
181
+ set -euo pipefail
182
+
183
+ dir="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd -P)"
184
+ cd "$dir"
185
+
186
+ ${resolve}
187
+
188
+ # zuke runs the build here itself rather than this launcher again, and does not
189
+ # hold this directory to the trust gate: running the launcher named it.
190
+ export ${FORWARDED_ENV}=1
191
+ export ${LAUNCHER_ROOT_ENV}="$dir"
192
+ exec "$zuke_bin" "$@"
193
+ `;
194
+ }
195
+ /** The PowerShell launcher's download of the pinned release into `$zuke`. */
196
+ function pwshDownload(pin) {
197
+ return `# The pinned release, and the SHA-256 of its Windows archive, from the
198
+ # SHA256SUMS of ${BINARY_RELEASES_URL}/${binaryReleaseTag(pin.version)}.
199
+ # Moved by \`zuke upgrade --engine\`, which rewrites this file; never hand-edit.
200
+ $ZukeVersion = "${pin.version}"
201
+ $ZukeSha256 = "${pin.checksums[BINARY_WINDOWS_TARGET]}"
202
+
203
+ if ($PSVersionTable.PSEdition -eq "Core" -and -not $IsWindows) {
204
+ throw "zuke: zuke.ps1 runs the Windows release; on this OS run ./zuke instead."
205
+ }
206
+ $install = if ($env:ZUKE_INSTALL) { $env:ZUKE_INSTALL } else { Join-Path $HOME ".zuke" }
207
+ $zuke = Join-Path $install "releases\\$ZukeVersion\\zuke.exe"
208
+
209
+ if (-not (Test-Path $zuke)) {
210
+ Write-Host "zuke: zuke $ZukeVersion is not here yet - downloading it..."
211
+ # Arm64 Windows runs the x64 release under emulation; nothing else is built.
212
+ $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()
213
+ if ($arch -ne "X64" -and $arch -ne "Arm64") {
214
+ throw "zuke: no zuke release is built for the $arch architecture."
215
+ }
216
+ $asset = "zuke-$ZukeVersion-${BINARY_WINDOWS_TARGET}.zip"
217
+ $base = if ($env:ZUKE_RELEASES_URL) { $env:ZUKE_RELEASES_URL } else { "${BINARY_RELEASES_URL}" }
218
+ $downloadUrl = "$base/cli-v$ZukeVersion/$asset"
219
+ $workDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
220
+ New-Item -ItemType Directory -Path $workDir | Out-Null
221
+ $archive = Join-Path $workDir $asset
222
+ try {
223
+ # The progress bar slows a large download severalfold in Windows PowerShell.
224
+ $ProgressPreference = "SilentlyContinue"
225
+ # The network is occasionally flaky (a transient 5xx from the CDN), so a
226
+ # blip is retried with backoff rather than failing the run.
227
+ $maxAttempts = 4
228
+ for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
229
+ try {
230
+ Invoke-WebRequest -Uri $downloadUrl -OutFile $archive -UseBasicParsing
231
+ break
232
+ } catch {
233
+ if ($attempt -ge $maxAttempts) {
234
+ throw "zuke: failed to download $downloadUrl after $maxAttempts attempts: $_"
235
+ }
236
+ $delay = $attempt * 3
237
+ Write-Host "zuke: download failed (attempt $attempt/$maxAttempts); retrying in \${delay}s..."
238
+ Start-Sleep -Seconds $delay
239
+ }
240
+ }
241
+
242
+ # .NET directly, not the hashing and archive cmdlets: those come from
243
+ # script modules, which Windows PowerShell started from a PowerShell 7
244
+ # session (whose module path it inherits) cannot load.
245
+ $stream = [System.IO.File]::OpenRead($archive)
246
+ try {
247
+ $digest = [System.Security.Cryptography.SHA256]::Create().ComputeHash($stream)
248
+ } finally {
249
+ $stream.Dispose()
250
+ }
251
+ $actualSha256 = -join ($digest | ForEach-Object { $_.ToString("x2") })
252
+ if ($actualSha256 -ne $ZukeSha256) {
253
+ throw "zuke: checksum mismatch for \${asset}: expected $ZukeSha256, got $actualSha256"
254
+ }
255
+
256
+ Add-Type -AssemblyName System.IO.Compression.FileSystem
257
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($archive, (Join-Path $workDir "unpacked"))
258
+ New-Item -ItemType Directory -Force -Path (Split-Path -Parent $zuke) | Out-Null
259
+ # Copied beside the target first, which may cross volumes, then renamed in
260
+ # one step, so a run interrupted mid-copy never leaves a binary behind
261
+ # that later runs would trust without verifying.
262
+ $staged = "$zuke.$PID"
263
+ Move-Item -Force -Path (Join-Path $workDir "unpacked\\zuke.exe") -Destination $staged
264
+ try {
265
+ Move-Item -Force -Path $staged -Destination $zuke
266
+ } catch {
267
+ # A run started alongside this one put it there first, and may be
268
+ # running it, which Windows will not let this replace.
269
+ Remove-Item -Force $staged -ErrorAction SilentlyContinue
270
+ if (-not (Test-Path $zuke)) { throw }
271
+ }
272
+ } finally {
273
+ Remove-Item -Recurse -Force $workDir -ErrorAction SilentlyContinue
274
+ }
275
+ }`;
276
+ }
277
+ /** The PowerShell launcher's plain resolution: the `zuke` on `PATH`, or fail. */
278
+ function pwshPlain() {
279
+ return `$found = Get-Command zuke -CommandType Application -ErrorAction SilentlyContinue
280
+ if (-not $found) {
281
+ throw "zuke: the zuke command is not on PATH. Install it, then re-run this launcher: ${BINARY_INSTALL_DOCS}"
282
+ }
283
+ $zuke = $found.Source`;
284
+ }
285
+ /**
286
+ * The PowerShell launcher (`.\zuke.ps1`) of a hosted build. Mirrors
287
+ * {@link binaryLauncherBash}, variant for variant.
288
+ */
289
+ export function binaryLauncherPwsh(options, pin) {
290
+ const purpose = options.download
291
+ ? `# Runs zuke ${pin.version}, which carries the engine and every tool wrapper, so
292
+ # this project needs nothing installed but its own SDK's tools. On first use
293
+ # it downloads that release, checksum-verified, into ZUKE_INSTALL.
294
+ #
295
+ # Honoured environment variables:
296
+ # ZUKE_INSTALL where zuke releases are kept (default: ~/.zuke)
297
+ # ZUKE_RELEASES_URL a mirror of ${BINARY_RELEASES_URL};
298
+ # what it serves is verified against the pin below`
299
+ : `${PLAIN_BINARY_LAUNCHER} ${BINARY_INSTALL_DOCS}`;
300
+ const resolve = options.download ? pwshDownload(pin) : pwshPlain();
301
+ return `#!/usr/bin/env pwsh
302
+ ${LICENSE_HEADER}
303
+ #
304
+ ${BINARY_LAUNCHER_MARKER} (PowerShell).
305
+ #
306
+ ${usage(".\\zuke.ps1")}
307
+ #
308
+ ${purpose}
309
+
310
+ $ErrorActionPreference = "Stop"
311
+
312
+ $dir = Split-Path -Parent $MyInvocation.MyCommand.Path
313
+ Set-Location $dir
314
+
315
+ ${resolve}
316
+
317
+ # zuke runs the build here itself rather than this launcher again, and does not
318
+ # hold this directory to the trust gate: running the launcher named it.
319
+ $env:${FORWARDED_ENV} = "1"
320
+ $env:${LAUNCHER_ROOT_ENV} = $dir
321
+ & $zuke @args
322
+ exit $LASTEXITCODE
323
+ `;
324
+ }
325
+ /* cspell:enable */
@@ -0,0 +1,47 @@
1
+ /** The repository the `zuke` releases are published from. */
2
+ export declare const BINARY_REPO = "zuke-build/zuke";
3
+ /** Where the launchers download a release's archives from, before the tag. */
4
+ export declare const BINARY_RELEASES_URL = "https://github.com/zuke-build/zuke/releases/download";
5
+ /** Where to get `zuke`, as the launchers and refusals name it. */
6
+ export declare const BINARY_INSTALL_DOCS = "https://github.com/zuke-build/zuke/blob/master/docs/install.md";
7
+ /** The checksum manifest each release publishes beside its archives. */
8
+ export declare const BINARY_CHECKSUMS = "SHA256SUMS";
9
+ /** A platform a `zuke` release ships a binary for, as its archive names it. */
10
+ export type BinaryTarget = "aarch64-apple-darwin" | "x86_64-apple-darwin" | "aarch64-unknown-linux-gnu" | "x86_64-unknown-linux-gnu" | "x86_64-pc-windows-msvc";
11
+ /** The targets the bash launcher can download (Linux and macOS), each a `.tar.gz`. */
12
+ export declare const BINARY_POSIX_TARGETS: readonly BinaryTarget[];
13
+ /** The target the PowerShell launcher downloads, a `.zip` holding `zuke.exe`. */
14
+ export declare const BINARY_WINDOWS_TARGET: BinaryTarget;
15
+ /** The pinned `zuke` release, the engine inside it, and each archive's digest. */
16
+ export interface BinaryPin {
17
+ /** The release, without the tag's `cli-v` prefix, e.g. `"2.4.0"`. */
18
+ readonly version: string;
19
+ /** The `@zuke/engine` release compiled into it. */
20
+ readonly engine: string;
21
+ /** Lowercase hex SHA-256 of each target's archive. */
22
+ readonly checksums: Readonly<Record<BinaryTarget, string>>;
23
+ }
24
+ /** The release tag of a `zuke` version: `cli-v2.4.0`. */
25
+ export declare function binaryReleaseTag(version: string): string;
26
+ /** The archive a target's binary ships in: `zuke-2.4.0-x86_64-unknown-linux-gnu.tar.gz`. */
27
+ export declare function binaryArchiveName(version: string, target: BinaryTarget): string;
28
+ /** What resolving a pin reaches over the network, injectable for tests. */
29
+ export type PinFetch = (url: string) => Promise<Response>;
30
+ /**
31
+ * The digests a `SHA256SUMS` manifest lists, by file name.
32
+ *
33
+ * Strict, since what it reads is pinned into launchers and formulas: a line
34
+ * that is not a digest and a name, or a name listed twice, is refused rather
35
+ * than skipped or overwritten.
36
+ *
37
+ * @throws {Error} naming the first line that is not one, or a repeated name.
38
+ */
39
+ export declare function parseChecksums(text: string): Map<string, string>;
40
+ /**
41
+ * Resolve the pin of `zuke` `version`: every target's archive digest from
42
+ * the release's `SHA256SUMS`, and its engine from the tag's
43
+ * `packages/engine/deno.json`.
44
+ * @throws {Error} when the release has no published binaries, lists no digest
45
+ * for a target, or its engine version cannot be read.
46
+ */
47
+ export declare function resolveBinaryPin(version: string, fetch: PinFetch): Promise<BinaryPin>;
@@ -0,0 +1,117 @@
1
+ // Copyright (c) 2026 the Zuke contributors
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * The standalone `zuke` release a project another SDK hosts runs on, and the
5
+ * SHA-256 of each platform's archive its launchers verify the download
6
+ * against.
7
+ *
8
+ * Such a project has no Deno code, so its launchers bootstrap no Deno: they
9
+ * download the pinned `zuke` binary from its GitHub release, which carries
10
+ * the engine and every tool wrapper. The pin is read once, when `zuke setup`
11
+ * scaffolds the launchers or `zuke upgrade --engine` moves them: the
12
+ * archives' digests from the release's own `SHA256SUMS`, and the engine the
13
+ * release carries from `packages/engine/deno.json` at its tag. A published
14
+ * release is immutable, so the digests the launchers hold stay the release's.
15
+ *
16
+ * @module
17
+ */
18
+ import { isRecord } from "./records.js";
19
+ import { VERSION_PATTERN } from "./version_report.js";
20
+ /** The repository the `zuke` releases are published from. */
21
+ export const BINARY_REPO = "zuke-build/zuke";
22
+ /** Where the launchers download a release's archives from, before the tag. */
23
+ export const BINARY_RELEASES_URL = `https://github.com/${BINARY_REPO}/releases/download`;
24
+ /** Where to get `zuke`, as the launchers and refusals name it. */
25
+ export const BINARY_INSTALL_DOCS = "https://github.com/zuke-build/zuke/blob/master/docs/install.md";
26
+ /** The checksum manifest each release publishes beside its archives. */
27
+ export const BINARY_CHECKSUMS = "SHA256SUMS";
28
+ /** The targets the bash launcher can download (Linux and macOS), each a `.tar.gz`. */
29
+ export const BINARY_POSIX_TARGETS = [
30
+ "aarch64-apple-darwin",
31
+ "x86_64-apple-darwin",
32
+ "aarch64-unknown-linux-gnu",
33
+ "x86_64-unknown-linux-gnu",
34
+ ];
35
+ /** The target the PowerShell launcher downloads, a `.zip` holding `zuke.exe`. */
36
+ export const BINARY_WINDOWS_TARGET = "x86_64-pc-windows-msvc";
37
+ /** The release tag of a `zuke` version: `cli-v2.4.0`. */
38
+ export function binaryReleaseTag(version) {
39
+ return `cli-v${version}`;
40
+ }
41
+ /** The archive a target's binary ships in: `zuke-2.4.0-x86_64-unknown-linux-gnu.tar.gz`. */
42
+ export function binaryArchiveName(version, target) {
43
+ const extension = target === BINARY_WINDOWS_TARGET ? "zip" : "tar.gz";
44
+ return `zuke-${version}-${target}.${extension}`;
45
+ }
46
+ /** A line of a manifest: a digest, two spaces (or a space and `*`), a name. */
47
+ const CHECKSUM_LINE = /^([0-9a-f]{64}) [ *]([^\s/\\]+)$/;
48
+ /**
49
+ * The digests a `SHA256SUMS` manifest lists, by file name.
50
+ *
51
+ * Strict, since what it reads is pinned into launchers and formulas: a line
52
+ * that is not a digest and a name, or a name listed twice, is refused rather
53
+ * than skipped or overwritten.
54
+ *
55
+ * @throws {Error} naming the first line that is not one, or a repeated name.
56
+ */
57
+ export function parseChecksums(text) {
58
+ const sums = new Map();
59
+ for (const line of text.split("\n")) {
60
+ if (line === "")
61
+ continue;
62
+ const match = CHECKSUM_LINE.exec(line);
63
+ if (match === null) {
64
+ throw new Error(`${BINARY_CHECKSUMS}: not a checksum line: ${JSON.stringify(line)}`);
65
+ }
66
+ const [, sha256, name] = match;
67
+ if (sums.has(name)) {
68
+ throw new Error(`${BINARY_CHECKSUMS}: ${name} is listed twice`);
69
+ }
70
+ sums.set(name, sha256);
71
+ }
72
+ return sums;
73
+ }
74
+ /** The text at `url`, or a message naming what was missing. */
75
+ async function fetchText(fetch, url, what) {
76
+ const response = await fetch(url);
77
+ if (!response.ok) {
78
+ await response.body?.cancel();
79
+ throw new Error(`${what} could not be read from ${url} (HTTP ${response.status})`);
80
+ }
81
+ return await response.text();
82
+ }
83
+ /**
84
+ * Resolve the pin of `zuke` `version`: every target's archive digest from
85
+ * the release's `SHA256SUMS`, and its engine from the tag's
86
+ * `packages/engine/deno.json`.
87
+ * @throws {Error} when the release has no published binaries, lists no digest
88
+ * for a target, or its engine version cannot be read.
89
+ */
90
+ export async function resolveBinaryPin(version, fetch) {
91
+ if (!VERSION_PATTERN.test(version)) {
92
+ throw new Error(`"${version}" is not a zuke release such as 2.4.0`);
93
+ }
94
+ const tag = binaryReleaseTag(version);
95
+ const sums = parseChecksums(await fetchText(fetch, `${BINARY_RELEASES_URL}/${tag}/${BINARY_CHECKSUMS}`, `zuke ${version}'s published binaries`));
96
+ const digest = (target) => {
97
+ const name = binaryArchiveName(version, target);
98
+ const sha256 = sums.get(name);
99
+ if (sha256 === undefined) {
100
+ throw new Error(`zuke ${version}'s ${BINARY_CHECKSUMS} lists no digest for ${name}`);
101
+ }
102
+ return sha256;
103
+ };
104
+ const checksums = {
105
+ "aarch64-apple-darwin": digest("aarch64-apple-darwin"),
106
+ "x86_64-apple-darwin": digest("x86_64-apple-darwin"),
107
+ "aarch64-unknown-linux-gnu": digest("aarch64-unknown-linux-gnu"),
108
+ "x86_64-unknown-linux-gnu": digest("x86_64-unknown-linux-gnu"),
109
+ "x86_64-pc-windows-msvc": digest("x86_64-pc-windows-msvc"),
110
+ };
111
+ const config = JSON.parse(await fetchText(fetch, `https://raw.githubusercontent.com/${BINARY_REPO}/${tag}/packages/engine/deno.json`, `the @zuke/engine release inside zuke ${version}`));
112
+ const engine = isRecord(config) ? config.version : undefined;
113
+ if (typeof engine !== "string" || !VERSION_PATTERN.test(engine)) {
114
+ throw new Error(`zuke ${version}'s packages/engine/deno.json names no engine version`);
115
+ }
116
+ return { version, engine, checksums };
117
+ }
@@ -0,0 +1,25 @@
1
+ /** The build file of a project whose `zuke.json` names none. */
2
+ export declare const BUILD_FILE = "zuke.ts";
3
+ /** The build file `zuke setup` gives a new project, recorded in its `zuke.json`. */
4
+ export declare const NEW_BUILD_FILE = "build.ts";
5
+ /** The field of `zuke.json` naming the build file. */
6
+ export declare const BUILD_FIELD = "build";
7
+ /**
8
+ * `name`, when it is a build file name that is safe to write into a launcher
9
+ * and pass to `deno run`.
10
+ *
11
+ * @throws {Error} naming the two places a name comes from, and the rule,
12
+ * otherwise.
13
+ */
14
+ export declare function assertBuildFileName(name: string): string;
15
+ /**
16
+ * The build file a `zuke.json` with the contents `text` names.
17
+ *
18
+ * {@link BUILD_FILE} when the file has no `build` field, and also when it is
19
+ * not a JSON object: the file's presence alone marked a project before the
20
+ * field existed, so an empty or malformed one still means `zuke.ts`.
21
+ *
22
+ * @throws {Error} when the field is there and is not a valid name, see
23
+ * {@link assertBuildFileName}.
24
+ */
25
+ export declare function buildFileNamed(text: string): string;
@@ -0,0 +1,58 @@
1
+ // Copyright (c) 2026 the Zuke contributors
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * The name of a project's build file: `zuke.ts` unless the `build` field of
5
+ * its `zuke.json` names another.
6
+ *
7
+ * The name is written into a shell script, a PowerShell script and JSON, and
8
+ * handed to `deno run`, so one check decides what a name may be and every
9
+ * place that reads or writes it goes through it.
10
+ *
11
+ * @module
12
+ */
13
+ import { forgivingField } from "./records.js";
14
+ /** The build file of a project whose `zuke.json` names none. */
15
+ export const BUILD_FILE = "zuke.ts";
16
+ /** The build file `zuke setup` gives a new project, recorded in its `zuke.json`. */
17
+ export const NEW_BUILD_FILE = "build.ts";
18
+ /** The field of `zuke.json` naming the build file. */
19
+ export const BUILD_FIELD = "build";
20
+ /**
21
+ * A plain file name: letters, digits, dots, dashes and underscores, no
22
+ * leading dash (it would read as an option), ending in `.ts`.
23
+ */
24
+ const BUILD_FILE_NAME = /^[A-Za-z0-9_.][A-Za-z0-9_.-]*\.ts$/;
25
+ /**
26
+ * `name`, when it is a build file name that is safe to write into a launcher
27
+ * and pass to `deno run`.
28
+ *
29
+ * @throws {Error} naming the two places a name comes from, and the rule,
30
+ * otherwise.
31
+ */
32
+ export function assertBuildFileName(name) {
33
+ if (!BUILD_FILE_NAME.test(name)) {
34
+ throw new Error(`zuke: the build file name '${name}' (zuke.json's '${BUILD_FIELD}', ` +
35
+ "or --build-file) is not a plain TypeScript file name: letters, " +
36
+ "digits, dots, dashes and underscores only, not starting with a " +
37
+ "dash, ending in .ts");
38
+ }
39
+ return name;
40
+ }
41
+ /**
42
+ * The build file a `zuke.json` with the contents `text` names.
43
+ *
44
+ * {@link BUILD_FILE} when the file has no `build` field, and also when it is
45
+ * not a JSON object: the file's presence alone marked a project before the
46
+ * field existed, so an empty or malformed one still means `zuke.ts`.
47
+ *
48
+ * @throws {Error} when the field is there and is not a valid name, see
49
+ * {@link assertBuildFileName}.
50
+ */
51
+ export function buildFileNamed(text) {
52
+ const name = forgivingField(text, BUILD_FIELD);
53
+ if (name === undefined)
54
+ return BUILD_FILE;
55
+ // Anything but a string is refused as written: String() would turn the
56
+ // array ["build.ts"] into a name that passes.
57
+ return assertBuildFileName(typeof name === "string" ? name : JSON.stringify(name));
58
+ }