@zuke-build/cli 0.0.0-stage → 2.6.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/LICENSE +21 -0
- package/README.md +343 -2
- package/mod.d.ts +99 -0
- package/mod.js +893 -0
- package/package.json +35 -4
- package/src/binary_launcher.d.ts +49 -0
- package/src/binary_launcher.js +327 -0
- package/src/binary_pin.d.ts +47 -0
- package/src/binary_pin.js +117 -0
- package/src/build_file.d.ts +25 -0
- package/src/build_file.js +65 -0
- package/src/cache.d.ts +23 -0
- package/src/cache.js +26 -0
- package/src/deno_isolated.d.ts +14 -0
- package/src/deno_isolated.js +70 -0
- package/src/deno_path.d.ts +115 -0
- package/src/deno_path.js +205 -0
- package/src/deno_pin.d.ts +37 -0
- package/src/deno_pin.js +32 -0
- package/src/dependencies.d.ts +48 -0
- package/src/dependencies.js +80 -0
- package/src/dispatch.d.ts +220 -0
- package/src/dispatch.js +538 -0
- package/src/embedded_engine.d.ts +28 -0
- package/src/embedded_engine.js +21 -0
- package/src/engine_pin.d.ts +56 -0
- package/src/engine_pin.js +196 -0
- package/src/fs.d.ts +14 -0
- package/src/fs.js +25 -0
- package/src/import.d.ts +132 -0
- package/src/import.js +289 -0
- package/src/install_source.d.ts +79 -0
- package/src/install_source.js +104 -0
- package/src/launcher.d.ts +37 -0
- package/src/launcher.js +464 -0
- package/src/mcp_config.d.ts +63 -0
- package/src/mcp_config.js +86 -0
- package/src/output.d.ts +38 -0
- package/src/output.js +43 -0
- package/src/paint.d.ts +42 -0
- package/src/paint.js +38 -0
- package/src/project.d.ts +69 -0
- package/src/project.js +132 -0
- package/src/pyproject.d.ts +30 -0
- package/src/pyproject.js +156 -0
- package/src/python_build.d.ts +27 -0
- package/src/python_build.js +197 -0
- package/src/records.d.ts +9 -0
- package/src/records.js +13 -0
- package/src/relock.d.ts +11 -0
- package/src/relock.js +182 -0
- package/src/setup.d.ts +251 -0
- package/src/setup.js +601 -0
- package/src/star.d.ts +44 -0
- package/src/star.js +100 -0
- package/src/starter.d.ts +55 -0
- package/src/starter.js +126 -0
- package/src/toml.d.ts +32 -0
- package/src/toml.js +354 -0
- package/src/translate.d.ts +69 -0
- package/src/translate.js +198 -0
- package/src/upgrade.d.ts +113 -0
- package/src/upgrade.js +344 -0
- package/src/version.d.ts +11 -0
- package/src/version.js +13 -0
- package/src/version_report.d.ts +55 -0
- package/src/version_report.js +187 -0
- package/zuke.js +8 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forwarding a build command from the global `zuke` to the project's build.
|
|
3
|
+
*
|
|
4
|
+
* The global command (`deno install -A -g -n zuke jsr:@zuke/cli`) owns only
|
|
5
|
+
* `setup`, `import`, `doc` and `upgrade`. Everything else — `zuke ci`, `zuke --list`,
|
|
6
|
+
* `zuke graph`, `zuke mcp` — belongs to the build in the current project, so
|
|
7
|
+
* `main` forwards it: it walks up from the working directory to the nearest
|
|
8
|
+
* `zuke.json` (the repository-root marker `zuke setup` writes), then runs the
|
|
9
|
+
* executable `./zuke` launcher beside it, from the root, stdio inherited.
|
|
10
|
+
* That is the delegation a global `gradle` makes to a checkout's wrapper: one
|
|
11
|
+
* global word, the project's own launcher, build and lock deciding what
|
|
12
|
+
* actually runs — a pinned Deno, an exported environment variable, a lock kept
|
|
13
|
+
* somewhere other than `./deno.lock` all apply to `zuke` exactly as to
|
|
14
|
+
* `./zuke`. A root with no executable launcher (and every root on Windows,
|
|
15
|
+
* whose files report no mode) gets the launcher's own invocation instead:
|
|
16
|
+
* `deno run -A zuke.ts`, with `--frozen` once a `deno.lock` exists.
|
|
17
|
+
*
|
|
18
|
+
* Discovery has a trust gate, because it runs code the caller never named:
|
|
19
|
+
* a `zuke.json` planted in a shared parent (`/tmp`, a shared checkout tree)
|
|
20
|
+
* would otherwise have `zuke ci` in any directory below it run a stranger's
|
|
21
|
+
* `zuke.ts` with `-A`. So, as git's `safe.directory` does, a build is refused
|
|
22
|
+
* when its root directory is owned by another user or is world-writable (so
|
|
23
|
+
* anyone could have planted the files in it). Deno then does a walk of its
|
|
24
|
+
* own — it discovers `deno.json` and `package.json` in the root's ancestors,
|
|
25
|
+
* and an import map planted there rewrites what `zuke.ts` imports — so the
|
|
26
|
+
* gate also refuses any such ancestor config file owned by another user. The
|
|
27
|
+
* error names what was refused and the two ways forward: run that project's
|
|
28
|
+
* own `./zuke` launcher — an explicit act on a file the caller names — or fix
|
|
29
|
+
* the ownership. Where the platform has no file ownership to compare
|
|
30
|
+
* (Windows), the gate is inert. A hosted build's launcher starts `zuke` in
|
|
31
|
+
* the root it sits in, so that root, named in {@link LAUNCHER_ROOT_ENV}, is
|
|
32
|
+
* not judged either: running the launcher was the explicit act.
|
|
33
|
+
*
|
|
34
|
+
* A build another SDK hosts (a `zuke.json` and no `zuke.ts`) needs nothing
|
|
35
|
+
* from Deno's stack. The standalone binary runs it on its built-in engine,
|
|
36
|
+
* or, for a pin that engine cannot serve, through the project's launcher,
|
|
37
|
+
* which downloads the `zuke` release it pins; it never falls back to Deno.
|
|
38
|
+
*
|
|
39
|
+
* Locating and planning are pure given a probe, so the routing is
|
|
40
|
+
* unit-testable; the spawn goes through the injectable {@link BuildRunner}.
|
|
41
|
+
*
|
|
42
|
+
* @module
|
|
43
|
+
*/
|
|
44
|
+
import { type RuntimeFacts } from "@zuke/core";
|
|
45
|
+
import { type EmbeddedEngine } from "./embedded_engine.ts";
|
|
46
|
+
/**
|
|
47
|
+
* Deno's own config files, in the order it prefers them: a `deno.json` wins
|
|
48
|
+
* over a `deno.jsonc` beside it.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DENO_CONFIG_FILES: readonly ["deno.json", "deno.jsonc"];
|
|
51
|
+
/** The lockfile whose presence turns on `--frozen`, as in the launchers. */
|
|
52
|
+
export declare const LOCK_FILE = "deno.lock";
|
|
53
|
+
/** The POSIX launcher a forwarded command runs, beside {@link CONFIG_FILE}. */
|
|
54
|
+
export declare const LAUNCHER_FILE = "zuke";
|
|
55
|
+
/**
|
|
56
|
+
* Set to `1` in a launcher's environment, so a launcher that itself calls the
|
|
57
|
+
* global `zuke` gets the bare `deno run` instead of itself again, endlessly.
|
|
58
|
+
*/
|
|
59
|
+
export declare const FORWARDED_ENV = "ZUKE_FORWARDED";
|
|
60
|
+
/**
|
|
61
|
+
* Set by a hosted build's launcher to its own directory, so the `zuke` it
|
|
62
|
+
* starts does not refuse that root at the trust gate: the caller named the
|
|
63
|
+
* project by running the launcher inside it.
|
|
64
|
+
*/
|
|
65
|
+
export declare const LAUNCHER_ROOT_ENV = "ZUKE_LAUNCHER_ROOT";
|
|
66
|
+
/** Where a forwarded command runs, and how. */
|
|
67
|
+
export interface BuildLocation {
|
|
68
|
+
/** The absolute repository root: the directory holding `zuke.json`. */
|
|
69
|
+
root: string;
|
|
70
|
+
/** Whether a `deno.lock` sits at the root, so the run passes `--frozen`. */
|
|
71
|
+
frozen: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The absolute path of the executable `zuke` launcher at the root, run in
|
|
74
|
+
* place of `deno run` — or `null` when there is none, or the platform
|
|
75
|
+
* reports no file mode to tell (Windows).
|
|
76
|
+
*/
|
|
77
|
+
launcher: string | null;
|
|
78
|
+
/**
|
|
79
|
+
* The build file's name: the one the root's `zuke.json` names in its
|
|
80
|
+
* `build` field, `zuke.ts` when it names none.
|
|
81
|
+
*/
|
|
82
|
+
build: string;
|
|
83
|
+
/**
|
|
84
|
+
* The `@zuke/engine` release that runs the build when the root has no
|
|
85
|
+
* build file: the `engine` field of its `zuke.json`, which then describes a
|
|
86
|
+
* build another SDK hosts. `null` when the root has its own build file.
|
|
87
|
+
*/
|
|
88
|
+
engine: string | null;
|
|
89
|
+
}
|
|
90
|
+
/** What the trust gate needs to know about a filesystem entry. */
|
|
91
|
+
export interface Ownership {
|
|
92
|
+
/** The numeric owner, or `null` where the platform reports none (Windows). */
|
|
93
|
+
uid: number | null;
|
|
94
|
+
/** The permission bits, or `null` where the platform reports none. */
|
|
95
|
+
mode: number | null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The filesystem questions discovery asks, injectable so the walk and its
|
|
99
|
+
* trust gate are testable without a filesystem or a second user.
|
|
100
|
+
*/
|
|
101
|
+
export interface BuildProbe {
|
|
102
|
+
/** Whether a path exists (the link itself, not its target). */
|
|
103
|
+
exists(path: string): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* The owner and mode of what a path resolves to, or `null` when nothing is
|
|
106
|
+
* there.
|
|
107
|
+
*/
|
|
108
|
+
ownership(path: string): Promise<Ownership | null>;
|
|
109
|
+
/** The path with every link resolved. */
|
|
110
|
+
realPath(path: string): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* The target a symlink names, exactly as written in the link (possibly
|
|
113
|
+
* relative to the link's directory), or `null` when `path` is not a link.
|
|
114
|
+
*/
|
|
115
|
+
readLink(path: string): Promise<string | null>;
|
|
116
|
+
/** The current user's numeric id, or `null` where the platform has none. */
|
|
117
|
+
uid(): number | null;
|
|
118
|
+
/** The text of a file. */
|
|
119
|
+
readText(path: string): Promise<string>;
|
|
120
|
+
}
|
|
121
|
+
/** The real, `Deno`-backed {@link BuildProbe}. */
|
|
122
|
+
export declare const defaultBuildProbe: BuildProbe;
|
|
123
|
+
/**
|
|
124
|
+
* Thrown when the build discovery found cannot be trusted — see the module
|
|
125
|
+
* docs for why it is refused rather than run.
|
|
126
|
+
*/
|
|
127
|
+
export declare class UntrustedBuildError extends Error {
|
|
128
|
+
/** The error's name, as reported by `String(error)` and stack traces. */
|
|
129
|
+
name: string;
|
|
130
|
+
/** The directory holding the `zuke.json` that was found. */
|
|
131
|
+
readonly root: string;
|
|
132
|
+
/** What the gate refused, as a clause: "the directory … ". */
|
|
133
|
+
readonly reason: string;
|
|
134
|
+
/**
|
|
135
|
+
* Build the refusal for `root`, explaining `reason` and the ways forward.
|
|
136
|
+
*
|
|
137
|
+
* @param root The directory holding the `zuke.json` that was found.
|
|
138
|
+
* @param reason What the gate refused, as a clause: "the directory … ".
|
|
139
|
+
*/
|
|
140
|
+
constructor(root: string, reason: string);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Walk up from `cwd` to the nearest directory holding {@link CONFIG_FILE},
|
|
144
|
+
* asking `probe`. Returns `null` when no ancestor has one — the caller is not
|
|
145
|
+
* inside a Zuke project. A root equal to `vouched`, the directory of the
|
|
146
|
+
* launcher that started this process ({@link LAUNCHER_ROOT_ENV}), is not
|
|
147
|
+
* held to the trust gate.
|
|
148
|
+
*
|
|
149
|
+
* @throws {UntrustedBuildError} when the root found fails the trust gate (see
|
|
150
|
+
* the module docs).
|
|
151
|
+
*/
|
|
152
|
+
export declare function locateBuild(cwd: string, probe: BuildProbe, vouched?: string | undefined): Promise<BuildLocation | null>;
|
|
153
|
+
/** The field of `zuke.json` naming the `@zuke/engine` release that runs a build with no `zuke.ts`. */
|
|
154
|
+
export declare const ENGINE_FIELD = "engine";
|
|
155
|
+
/**
|
|
156
|
+
* The build `location` runs, as the CLI names it to a person: the root's
|
|
157
|
+
* `zuke.ts`, or for a build another SDK hosts its `zuke.json` and the engine
|
|
158
|
+
* that runs it: the binary's own `engine` when it serves the pin, else the
|
|
159
|
+
* release the file pins.
|
|
160
|
+
*/
|
|
161
|
+
export declare function buildLabel(location: BuildLocation, engine?: EmbeddedEngine): string;
|
|
162
|
+
/** The module that runs a build another SDK hosts: `@zuke/engine` at `version`. */
|
|
163
|
+
export declare function engineSpecifier(version: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* The `deno` argv for a forwarded command — the launchers' invocation, with
|
|
166
|
+
* `--frozen` only when the location has a lockfile to verify against. Pure.
|
|
167
|
+
*/
|
|
168
|
+
export declare function buildRunArgs(location: BuildLocation, args: string[]): string[];
|
|
169
|
+
/**
|
|
170
|
+
* The binary's `engine`, when it is the one to run `location`: a hosted build
|
|
171
|
+
* whose pinned release it serves. `undefined` for a `zuke.ts` build, for a
|
|
172
|
+
* run without an embedded engine, and for a pin it cannot serve.
|
|
173
|
+
*/
|
|
174
|
+
export declare function servingEngine(location: BuildLocation, engine: EmbeddedEngine | undefined): EmbeddedEngine | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Run a forwarded command through `runner`. A hosted build whose pin the
|
|
177
|
+
* binary's own `engine` serves runs on it: the binary again, in engine mode,
|
|
178
|
+
* with `args` as they are, launcher or not. Otherwise the root's launcher with
|
|
179
|
+
* `args` when it has one and this is not already a launcher's own `zuke` call
|
|
180
|
+
* (see {@link FORWARDED_ENV}), else Deno with {@link buildRunArgs} — except a
|
|
181
|
+
* hosted build in the binary or on Node, which never falls back to Deno: a
|
|
182
|
+
* project another SDK hosts needs nothing from Deno's stack. `runtime` is the
|
|
183
|
+
* one this CLI runs on.
|
|
184
|
+
* @throws {Error} for a hosted build the binary cannot serve, or a CLI on
|
|
185
|
+
* Node cannot run, when no launcher can run it either, naming how to get a
|
|
186
|
+
* zuke that does.
|
|
187
|
+
*/
|
|
188
|
+
export declare function runBuild(runner: BuildRunner, location: BuildLocation, args: string[], env?: Readonly<Record<string, string>>, engine?: EmbeddedEngine, runtime?: RuntimeFacts["name"]): Promise<number>;
|
|
189
|
+
/**
|
|
190
|
+
* The stderr line for a hosted build the binary's own `engine` cannot serve,
|
|
191
|
+
* which then goes to the project's launcher; `undefined` when there is
|
|
192
|
+
* nothing to say: no engine compiled in, a `zuke.ts` build, a pin it serves,
|
|
193
|
+
* or no launcher to go to, which {@link runBuild} refuses instead.
|
|
194
|
+
*/
|
|
195
|
+
export declare function embeddedEngineNotice(location: BuildLocation, engine: EmbeddedEngine | undefined): string | undefined;
|
|
196
|
+
/** The launchers' notice for a run without a lockfile, verbatim. */
|
|
197
|
+
export declare const NO_LOCK_NOTICE: string;
|
|
198
|
+
/**
|
|
199
|
+
* The stderr line naming the build a forwarded command runs, printed when
|
|
200
|
+
* that build is not in the working directory — so a run that discovery chose
|
|
201
|
+
* is never silent about what it chose.
|
|
202
|
+
*/
|
|
203
|
+
export declare function runningNotice(location: BuildLocation, engine?: EmbeddedEngine): string;
|
|
204
|
+
/**
|
|
205
|
+
* Runs `program <args>` from `root` — Deno when `program` is omitted, else the
|
|
206
|
+
* project's launcher at that path — and resolves to its exit code: the
|
|
207
|
+
* injectable subprocess seam, so the forwarding is testable without a build.
|
|
208
|
+
* `env` adds variables to the environment the child inherits.
|
|
209
|
+
*/
|
|
210
|
+
export type BuildRunner = (root: string, args: string[], program?: string, env?: Readonly<Record<string, string>>) => Promise<number>;
|
|
211
|
+
/**
|
|
212
|
+
* The default {@link BuildRunner}: spawn the launcher as-is, since choosing a
|
|
213
|
+
* Deno is its job, or else Deno — {@link spawnDeno} finds it, and puts it
|
|
214
|
+
* first on the child's `PATH` as the launchers do. Stdio is inherited, because
|
|
215
|
+
* `zuke mcp` speaks JSON-RPC over the same stdin/stdout and a build may
|
|
216
|
+
* prompt. For the build's lifetime the parent handles signals as
|
|
217
|
+
* {@link signalPlan} says, so an interrupted build is never orphaned with its
|
|
218
|
+
* exit code lost.
|
|
219
|
+
*/
|
|
220
|
+
export declare const defaultBuildRunner: BuildRunner;
|