@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.
- package/LICENSE +21 -0
- package/README.md +353 -2
- package/mod.d.ts +102 -0
- package/mod.js +931 -0
- package/package.json +35 -4
- package/src/binary_launcher.d.ts +49 -0
- package/src/binary_launcher.js +325 -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 +58 -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 +229 -0
- package/src/dispatch.js +549 -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 +405 -0
- package/src/launcher_shared.d.ts +25 -0
- package/src/launcher_shared.js +91 -0
- package/src/mcp_config.d.ts +71 -0
- package/src/mcp_config.js +96 -0
- package/src/node_launcher.d.ts +19 -0
- package/src/node_launcher.js +416 -0
- package/src/node_pin.d.ts +25 -0
- package/src/node_pin.js +30 -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 +18 -0
- package/src/records.js +31 -0
- package/src/relock.d.ts +11 -0
- package/src/relock.js +182 -0
- package/src/runtime_field.d.ts +15 -0
- package/src/runtime_field.js +29 -0
- package/src/setup.d.ts +259 -0
- package/src/setup.js +693 -0
- package/src/star.d.ts +44 -0
- package/src/star.js +100 -0
- package/src/starter.d.ts +64 -0
- package/src/starter.js +138 -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
package/src/relock.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Copyright (c) 2026 the Zuke contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* `zuke relock`: regenerate the project's lockfile from scratch.
|
|
5
|
+
*
|
|
6
|
+
* A project's own `zuke outdated --update` runs on the core the project's
|
|
7
|
+
* lock pins, so a core whose update path is broken cannot move the project
|
|
8
|
+
* off itself: core 1.66 dropped specifiers it still left in other packages'
|
|
9
|
+
* dependency lists, and Deno then refused the whole lock. This command
|
|
10
|
+
* belongs to the global CLI instead, so it works whatever core the project
|
|
11
|
+
* is on.
|
|
12
|
+
*
|
|
13
|
+
* The old lock is copied to a backup file beside it before anything changes,
|
|
14
|
+
* then emptied in place — written through, so a lock that is a symlink to a
|
|
15
|
+
* shared file stays one — and `deno install --entrypoint zuke.ts
|
|
16
|
+
* --frozen=false` resolves it afresh in the project root. A failed install
|
|
17
|
+
* writes the old text back; a run that dies part-way leaves the backup on
|
|
18
|
+
* disk, and the next `relock` refuses to start until it is dealt with.
|
|
19
|
+
*
|
|
20
|
+
* Only the entrypoints it is given are resolved: `zuke.ts`, plus any named on
|
|
21
|
+
* the command line. A resolution only another program needed is dropped, and
|
|
22
|
+
* the report names the JSR packages that went, so a shared lock is not
|
|
23
|
+
* narrowed silently.
|
|
24
|
+
*
|
|
25
|
+
* `--min-dep-age` passes Deno's `--minimum-dependency-age` through, under the
|
|
26
|
+
* name and value forms `outdated --update --min-dep-age` already takes. It
|
|
27
|
+
* matters on Deno 2.9, which by default skips releases from the last day or
|
|
28
|
+
* so: `--min-dep-age 0` resolves the newest published versions.
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import { lockedJsrSpecifiers } from "@zuke/core";
|
|
33
|
+
import { installArgs, parseInstallFlags, projectLocation, } from "./project.js";
|
|
34
|
+
import { lockedCoreVersions, projectConfigText, projectLockPath, } from "./version_report.js";
|
|
35
|
+
/** The suffix of the backup a run keeps while the lock is being rewritten. */
|
|
36
|
+
const BACKUP_SUFFIX = ".relock-backup";
|
|
37
|
+
/** `versions` for a report line: joined, or `none` when the lock had none. */
|
|
38
|
+
function shown(versions) {
|
|
39
|
+
return versions.length > 0 ? versions.join(", ") : "none";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether release `a` is older than release `b`, comparing the numeric core
|
|
43
|
+
* only; `false` for anything this cannot read.
|
|
44
|
+
*/
|
|
45
|
+
function olderThan(a, b) {
|
|
46
|
+
const parse = (v) => /^(\d+)\.(\d+)\.(\d+)/.exec(v)?.slice(1, 4);
|
|
47
|
+
const x = parse(a);
|
|
48
|
+
const y = parse(b);
|
|
49
|
+
if (x === undefined || y === undefined)
|
|
50
|
+
return false;
|
|
51
|
+
for (let i = 0; i < 3; i++) {
|
|
52
|
+
if (Number(x[i]) !== Number(y[i]))
|
|
53
|
+
return Number(x[i]) < Number(y[i]);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/** The emptied lock a run resolves into: `before`'s format version, no entries. */
|
|
58
|
+
function emptied(before) {
|
|
59
|
+
let version = "5";
|
|
60
|
+
try {
|
|
61
|
+
const parsed = JSON.parse(before);
|
|
62
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
63
|
+
version = Reflect.get(parsed, "version") ?? version;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// An unreadable lock is still replaced; the default format is Deno 2's.
|
|
68
|
+
}
|
|
69
|
+
return `${JSON.stringify({ version }, null, 2)}\n`;
|
|
70
|
+
}
|
|
71
|
+
/** The JSR package names `lock` resolves. */
|
|
72
|
+
function jsrPackages(lock) {
|
|
73
|
+
return new Set(lockedJsrSpecifiers(lock).map((entry) => entry.name));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Run `zuke relock <args>` from `cwd`, reporting through `log`, and return
|
|
77
|
+
* the exit code.
|
|
78
|
+
*
|
|
79
|
+
* @throws {Error} with a message for the user when the request cannot be
|
|
80
|
+
* carried out. `main` prints the message and exits 1.
|
|
81
|
+
*/
|
|
82
|
+
export async function runRelock(args, log, host, paint, cwd, probe) {
|
|
83
|
+
const flags = parseInstallFlags("relock", args);
|
|
84
|
+
const { root, build } = await projectLocation(cwd, probe, "relock");
|
|
85
|
+
const lockPath = projectLockPath(root, await projectConfigText((path) => host.readText(path), root));
|
|
86
|
+
if (lockPath === null) {
|
|
87
|
+
throw new Error("zuke relock: this project's deno.json disables its lock, or could " +
|
|
88
|
+
"not be read as JSON, so there is no lock to regenerate.");
|
|
89
|
+
}
|
|
90
|
+
// Regenerating is the point, so a lock the config freezes is not a reason
|
|
91
|
+
// to refuse the write.
|
|
92
|
+
const denoArgs = [
|
|
93
|
+
...installArgs("relock", flags, host.denoVersion(), build),
|
|
94
|
+
"--frozen=false",
|
|
95
|
+
];
|
|
96
|
+
const name = lockPath.startsWith(`${root}/`)
|
|
97
|
+
? lockPath.slice(root.length + 1)
|
|
98
|
+
: lockPath;
|
|
99
|
+
if (flags.dryRun) {
|
|
100
|
+
log(`Would regenerate ${name}: deno ${denoArgs.join(" ")}`);
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const backup = `${lockPath}${BACKUP_SUFFIX}`;
|
|
104
|
+
let leftover = true;
|
|
105
|
+
try {
|
|
106
|
+
await host.readText(backup);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
leftover = false;
|
|
110
|
+
}
|
|
111
|
+
if (leftover) {
|
|
112
|
+
throw new Error(`zuke relock: ${backup} is left from a relock that did not finish. ` +
|
|
113
|
+
`It is the lock as it was before that run: move it back over ${name} ` +
|
|
114
|
+
"to restore it, or delete it to keep the lock as it is, then run " +
|
|
115
|
+
"zuke relock again.");
|
|
116
|
+
}
|
|
117
|
+
let before;
|
|
118
|
+
try {
|
|
119
|
+
before = await host.readText(lockPath);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// No lock yet: there is nothing to back up or put back.
|
|
123
|
+
}
|
|
124
|
+
if (before !== undefined) {
|
|
125
|
+
await host.writeText(backup, before);
|
|
126
|
+
await host.writeText(lockPath, emptied(before));
|
|
127
|
+
}
|
|
128
|
+
const restore = async () => {
|
|
129
|
+
if (before !== undefined)
|
|
130
|
+
await host.writeText(lockPath, before);
|
|
131
|
+
};
|
|
132
|
+
log(`Regenerating ${name}…`);
|
|
133
|
+
let code;
|
|
134
|
+
try {
|
|
135
|
+
code = await host.deno(denoArgs, root);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
await restore();
|
|
139
|
+
if (before !== undefined)
|
|
140
|
+
await host.remove(backup);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
let after;
|
|
144
|
+
if (code === 0) {
|
|
145
|
+
try {
|
|
146
|
+
after = await host.readText(lockPath);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Reported below.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (code !== 0 || after === undefined || after === emptied(before ?? "")) {
|
|
153
|
+
await restore();
|
|
154
|
+
if (before !== undefined)
|
|
155
|
+
await host.remove(backup);
|
|
156
|
+
log(paint.fail(code !== 0
|
|
157
|
+
? `zuke relock: deno install exited ${code}; ${name} is unchanged.`
|
|
158
|
+
: `zuke relock: deno install wrote no ${name}${before === undefined ? "" : "; the old one is restored"}. In a workspace member, Deno keeps the lock at the workspace ` +
|
|
159
|
+
"root: run zuke relock there."));
|
|
160
|
+
return code !== 0 ? code : 1;
|
|
161
|
+
}
|
|
162
|
+
if (before !== undefined)
|
|
163
|
+
await host.remove(backup);
|
|
164
|
+
const was = lockedCoreVersions(before ?? "");
|
|
165
|
+
const now = lockedCoreVersions(after);
|
|
166
|
+
log(paint.ok(`Regenerated ${name}: @zuke/core ${shown(was) === shown(now) ? shown(now) : `${shown(was)} → ${shown(now)}`}`));
|
|
167
|
+
if (was.length === 1 && now.length === 1 && olderThan(now[0], was[0]) &&
|
|
168
|
+
flags.minDepAge === undefined) {
|
|
169
|
+
log("Core resolved older than before: Deno's minimum dependency age " +
|
|
170
|
+
"skips recent releases. Run zuke relock --min-dep-age 0 to resolve " +
|
|
171
|
+
"the newest.");
|
|
172
|
+
}
|
|
173
|
+
const kept = jsrPackages(after);
|
|
174
|
+
const dropped = [...jsrPackages(before ?? "")].filter((p) => !kept.has(p));
|
|
175
|
+
if (dropped.length > 0) {
|
|
176
|
+
log(`No longer locked: ${dropped.join(", ")}. Only ${build}${flags.entrypoints.length > 0
|
|
177
|
+
? ` and ${flags.entrypoints.join(", ")}`
|
|
178
|
+
: ""} were resolved; if another program in this project imports them, ` +
|
|
179
|
+
"name it: zuke relock <entrypoint>.");
|
|
180
|
+
}
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The field of `zuke.json` naming the runtime the build file runs on. */
|
|
2
|
+
export declare const RUNTIME_FIELD = "runtime";
|
|
3
|
+
/** A runtime a project's build file can run on. */
|
|
4
|
+
export type ProjectRuntime = "deno" | "node";
|
|
5
|
+
/** The runtime of a project whose `zuke.json` names none. */
|
|
6
|
+
export declare const DEFAULT_RUNTIME: ProjectRuntime;
|
|
7
|
+
/**
|
|
8
|
+
* The runtime a `zuke.json` with the contents `text` names: its `runtime`
|
|
9
|
+
* field, {@link DEFAULT_RUNTIME} when there is none or the file is not a JSON
|
|
10
|
+
* object (as for the build file's name, the file's presence alone marked a
|
|
11
|
+
* project before the field existed).
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} when the field is there and names no runtime Zuke runs on.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runtimeNamed(text: string): ProjectRuntime;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright (c) 2026 the Zuke contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* The runtime a project's build file runs on: Deno unless the `runtime`
|
|
5
|
+
* field of its `zuke.json` names Node.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { forgivingField } from "./records.js";
|
|
10
|
+
/** The field of `zuke.json` naming the runtime the build file runs on. */
|
|
11
|
+
export const RUNTIME_FIELD = "runtime";
|
|
12
|
+
/** The runtime of a project whose `zuke.json` names none. */
|
|
13
|
+
export const DEFAULT_RUNTIME = "deno";
|
|
14
|
+
/**
|
|
15
|
+
* The runtime a `zuke.json` with the contents `text` names: its `runtime`
|
|
16
|
+
* field, {@link DEFAULT_RUNTIME} when there is none or the file is not a JSON
|
|
17
|
+
* object (as for the build file's name, the file's presence alone marked a
|
|
18
|
+
* project before the field existed).
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} when the field is there and names no runtime Zuke runs on.
|
|
21
|
+
*/
|
|
22
|
+
export function runtimeNamed(text) {
|
|
23
|
+
const runtime = forgivingField(text, RUNTIME_FIELD);
|
|
24
|
+
if (runtime === undefined)
|
|
25
|
+
return DEFAULT_RUNTIME;
|
|
26
|
+
if (runtime === "deno" || runtime === "node")
|
|
27
|
+
return runtime;
|
|
28
|
+
throw new Error(`zuke: zuke.json's '${RUNTIME_FIELD}' is ${JSON.stringify(runtime)}; it names the runtime the build file runs on, "deno" or "node".`);
|
|
29
|
+
}
|
package/src/setup.d.ts
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { isRecord } from "./records.ts";
|
|
2
|
+
import type { ProjectRuntime } from "./runtime_field.ts";
|
|
3
|
+
import type { BinaryPin } from "./binary_pin.ts";
|
|
4
|
+
export { isRecord };
|
|
5
|
+
/**
|
|
6
|
+
* The import map entries a scaffolded build needs, keyed by bare specifier.
|
|
7
|
+
*
|
|
8
|
+
* The scaffolded `zuke.ts` imports `@zuke/core` (and `zuke import`'s output
|
|
9
|
+
* `@zuke/cmd`) by bare specifier, so `deno.json` has to map each one to its
|
|
10
|
+
* `jsr:` dependency — see {@link "./starter.ts".STARTER_IMPORTS} for why the
|
|
11
|
+
* specifier does not go in the source file.
|
|
12
|
+
*/
|
|
13
|
+
export type ScaffoldImports = Readonly<Record<string, string>>;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a `deno.json` document delegates its import map to a separate file
|
|
16
|
+
* and would be broken by growing an `imports` block.
|
|
17
|
+
*
|
|
18
|
+
* Deno ignores the `importMap` field the moment `imports` or `scopes` appears
|
|
19
|
+
* in the config, so writing `imports` beside a lone `importMap` silently
|
|
20
|
+
* disables the project's entire module resolution. A document that already has
|
|
21
|
+
* `imports` or `scopes` is not delegating — Deno is ignoring `importMap` there
|
|
22
|
+
* already — so merging into it changes nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function delegatesImportMap(root: Record<string, unknown>): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Merge the default Zuke tasks and `imports` into a `deno.json` document,
|
|
27
|
+
* preserving the existing content. `existing` is the file text, or `null` to
|
|
28
|
+
* start fresh; `imports` are the bare-specifier mappings the scaffolded build
|
|
29
|
+
* resolves through, and `buildFile` is the file the `zuke` task runs.
|
|
30
|
+
*
|
|
31
|
+
* Merging is additive per key: a task or import the document already declares
|
|
32
|
+
* is left exactly as it is (but for a `zuke` task setup wrote for another
|
|
33
|
+
* build file, which follows the build file), so a project that has pinned `@zuke/core` to a
|
|
34
|
+
* specific version keeps that pin. A document that delegates to an external
|
|
35
|
+
* `importMap` keeps that delegation and grows no `imports` block — see
|
|
36
|
+
* {@link delegatesImportMap}; the caller reports the entry as a manual step
|
|
37
|
+
* instead.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mergeDenoJson(existing: string | null, imports: ScaffoldImports, buildFile: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a `deno.json` text already carries everything the scaffold needs.
|
|
42
|
+
*
|
|
43
|
+
* `"present"` means both the `zuke` task, for this build file, and every
|
|
44
|
+
* scaffold import are already declared, so there is nothing to merge.
|
|
45
|
+
*/
|
|
46
|
+
export type DenoJsonState = "present" | "absent" | "unparseable";
|
|
47
|
+
/**
|
|
48
|
+
* Classify a `deno.json` text by whether the scaffold has anything to add to
|
|
49
|
+
* it: the `zuke` task, or any of `imports`.
|
|
50
|
+
*
|
|
51
|
+
* The imports are part of the question because the build file is written by the
|
|
52
|
+
* same run and imports them by bare specifier. Treating the `zuke` task alone
|
|
53
|
+
* as "already set up" — as this did before the imports existed — would skip the
|
|
54
|
+
* file on a project being re-scaffolded and leave a `zuke.ts` whose specifiers
|
|
55
|
+
* nothing resolves.
|
|
56
|
+
*/
|
|
57
|
+
export declare function denoJsonState(text: string, imports: ScaffoldImports, buildFile: string): DenoJsonState;
|
|
58
|
+
/**
|
|
59
|
+
* The scaffold specifiers `root` maps somewhere other than their `jsr:@zuke/…`
|
|
60
|
+
* dependency, in declaration order.
|
|
61
|
+
*
|
|
62
|
+
* Keeping a mapping the project already declared is the right default — it is
|
|
63
|
+
* how a deliberate version pin, or a link to a local checkout, survives. But
|
|
64
|
+
* the run should not go on to report the dependency as simply "present", so the
|
|
65
|
+
* caller names what it found and leaves the decision to the reader.
|
|
66
|
+
*/
|
|
67
|
+
export declare function remappedImports(root: Record<string, unknown>, imports: ScaffoldImports): string[];
|
|
68
|
+
/** Injected side effects, so {@link runSetup} is unit-testable. */
|
|
69
|
+
export interface SetupHost {
|
|
70
|
+
/** Whether a path exists. */
|
|
71
|
+
exists(path: string): Promise<boolean>;
|
|
72
|
+
/** Whether a path exists and is a directory (a reserved-name collision). */
|
|
73
|
+
isDirectory(path: string): Promise<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a path is a symbolic link, without following it. Scaffolding
|
|
76
|
+
* refuses to write through one: the writes below follow links, so a link
|
|
77
|
+
* planted at a scaffold name by the very repository being set up would
|
|
78
|
+
* redirect them outside the target directory.
|
|
79
|
+
*
|
|
80
|
+
* The guard covers the names scaffolding chooses, which is where the hazard
|
|
81
|
+
* is — the caller never asked for `.gitignore` to be written, so a repository
|
|
82
|
+
* redirecting it is a decision nobody made. It reports what is there when it
|
|
83
|
+
* runs, and a link planted after it would escape it; that is why
|
|
84
|
+
* {@link SetupHost.writeText} does not write through a link either, so the
|
|
85
|
+
* refusal is the friendly answer rather than the only defence.
|
|
86
|
+
*
|
|
87
|
+
* Two things stay out of scope. The directory the caller names with `--dir`
|
|
88
|
+
* is the caller's to name, symlink or not. And a **hard** link is
|
|
89
|
+
* indistinguishable from the file it shares, so no probe can see one; git
|
|
90
|
+
* cannot check one out either, which is what keeps it out of the threat this
|
|
91
|
+
* guards.
|
|
92
|
+
*/
|
|
93
|
+
isSymlink(path: string): Promise<boolean>;
|
|
94
|
+
/** Read a file as UTF-8 text. */
|
|
95
|
+
readText(path: string): Promise<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Whether stdout is an interactive terminal, which decides whether the
|
|
98
|
+
* CLI's own output is rich. Optional: an implementation without it is
|
|
99
|
+
* asked through Deno, the way every other process decides.
|
|
100
|
+
*/
|
|
101
|
+
isTerminal?(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Write UTF-8 text to a file, creating or replacing it.
|
|
104
|
+
*
|
|
105
|
+
* An implementation must not write *through* a symbolic link standing at
|
|
106
|
+
* `path`: the scaffolder's confinement to its target directory rests on this,
|
|
107
|
+
* and the pre-write {@link SetupHost.isSymlink} check alone cannot carry it,
|
|
108
|
+
* since a link can appear after the check.
|
|
109
|
+
*/
|
|
110
|
+
writeText(path: string, content: string): Promise<void>;
|
|
111
|
+
/** Set a file's permission bits (may be unsupported on some platforms). */
|
|
112
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
113
|
+
/** Emit a line of progress output. */
|
|
114
|
+
log(message: string): void;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The real, `Deno`-backed {@link SetupHost}. Every probe reads the link itself
|
|
118
|
+
* rather than its target (see {@link lstatOrNull}), so a symlink is reported
|
|
119
|
+
* as a symlink instead of as whatever it points at.
|
|
120
|
+
*/
|
|
121
|
+
export declare const defaultHost: SetupHost;
|
|
122
|
+
/** Options controlling {@link runSetup}. */
|
|
123
|
+
export interface SetupOptions {
|
|
124
|
+
/** Directory to scaffold into (e.g. `"."`). */
|
|
125
|
+
dir: string;
|
|
126
|
+
/** Overwrite existing files instead of skipping them. */
|
|
127
|
+
force: boolean;
|
|
128
|
+
/** Build class name for the starter build file. */
|
|
129
|
+
name: string;
|
|
130
|
+
/**
|
|
131
|
+
* The TypeScript build file's name (`--build-file`). Omitted: the name the
|
|
132
|
+
* project already has (see {@link existingBuildFile}), or `build.ts` for a
|
|
133
|
+
* new one. Not for {@link SetupOptions.sdk}, whose build is `build.py`.
|
|
134
|
+
*/
|
|
135
|
+
buildFile?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The base name for the launcher scripts (`<name>` and `<name>.ps1`).
|
|
138
|
+
* Defaults to `"zuke"`; override it when a `zuke/` directory already occupies
|
|
139
|
+
* that name in the target directory.
|
|
140
|
+
*/
|
|
141
|
+
launcherName?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The build file's contents: the `zuke.ts`, or with {@link SetupOptions.sdk}
|
|
144
|
+
* the `build.py`. Defaults to {@link starterBuild} (or
|
|
145
|
+
* {@link starterPythonBuild}); `zuke import` passes a build generated from
|
|
146
|
+
* an existing project's tasks instead.
|
|
147
|
+
*/
|
|
148
|
+
buildContent?: string;
|
|
149
|
+
/**
|
|
150
|
+
* The bare specifiers {@link SetupOptions.buildContent} imports, mapped to
|
|
151
|
+
* their `jsr:` dependencies, merged into `deno.json` so they resolve.
|
|
152
|
+
* Defaults to {@link STARTER_IMPORTS}; a caller that supplies its own
|
|
153
|
+
* `buildContent` supplies the imports that build needs (`zuke import` adds
|
|
154
|
+
* `@zuke/cmd` when it generates a command).
|
|
155
|
+
*/
|
|
156
|
+
imports?: ScaffoldImports;
|
|
157
|
+
/**
|
|
158
|
+
* Scaffold launchers that bootstrap their runtime when it is missing (the
|
|
159
|
+
* default), or plain ones that require it on `PATH` and fail closed
|
|
160
|
+
* (`false`). The runtime is a pinned, checksum-verified Deno for a
|
|
161
|
+
* TypeScript build (see {@link "./launcher.ts"}), and the pinned `zuke`
|
|
162
|
+
* release for one another SDK hosts (see {@link "./binary_launcher.ts"}).
|
|
163
|
+
*/
|
|
164
|
+
bootstrapDeno?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Also write an `.mcp.json` registering the build's MCP server (`--mcp`), so
|
|
167
|
+
* an agent client picks the build up from the first commit. `allowRun`
|
|
168
|
+
* adds `--allow-run`, letting the agent execute targets rather than only
|
|
169
|
+
* inspect them. Omitted: no file is written.
|
|
170
|
+
*/
|
|
171
|
+
mcp?: McpSetupOptions;
|
|
172
|
+
/**
|
|
173
|
+
* Scaffold a build the Python SDK describes and `@zuke/engine` runs
|
|
174
|
+
* (`--sdk python`): a starter `build.py` in place of `zuke.ts`, a
|
|
175
|
+
* `zuke.json` naming `sdk.command` and the engine release, and no
|
|
176
|
+
* `deno.json`, since the project has no Deno code of its own. Its
|
|
177
|
+
* launchers run the pinned `zuke` binary, which carries that engine, so
|
|
178
|
+
* nothing in the project needs Deno. Omitted: a TypeScript build.
|
|
179
|
+
*/
|
|
180
|
+
sdk?: SdkSetupOptions;
|
|
181
|
+
/**
|
|
182
|
+
* The runtime the build file runs on (`--runtime`): `"node"` scaffolds a
|
|
183
|
+
* `package.json` in place of `deno.json`, a `zuke.json` with
|
|
184
|
+
* `"runtime": "node"` and launchers that bootstrap Node. Omitted or
|
|
185
|
+
* `"deno"`: today's Deno project. Not with {@link SetupOptions.sdk}.
|
|
186
|
+
*/
|
|
187
|
+
runtime?: ProjectRuntime;
|
|
188
|
+
}
|
|
189
|
+
/** What `--sdk python` scaffolds against. */
|
|
190
|
+
export interface SdkSetupOptions {
|
|
191
|
+
/**
|
|
192
|
+
* The `zuke` release the launchers run; `zuke.json` pins the engine it
|
|
193
|
+
* carries.
|
|
194
|
+
*/
|
|
195
|
+
pin: BinaryPin;
|
|
196
|
+
}
|
|
197
|
+
/** What `--mcp` writes into `.mcp.json`. */
|
|
198
|
+
export interface McpSetupOptions {
|
|
199
|
+
/** Register the server with `--allow-run`, so the agent may run targets. */
|
|
200
|
+
allowRun: boolean;
|
|
201
|
+
}
|
|
202
|
+
/** What happened to one scaffolded file. */
|
|
203
|
+
export type FileStatus = "created" | "overwritten" | "skipped";
|
|
204
|
+
/** The outcome for a single file. */
|
|
205
|
+
export interface FileResult {
|
|
206
|
+
/** The file's name, relative to the setup directory. */
|
|
207
|
+
path: string;
|
|
208
|
+
/** What `setup` did with it. */
|
|
209
|
+
status: FileStatus;
|
|
210
|
+
}
|
|
211
|
+
/** The result of a {@link runSetup} run. */
|
|
212
|
+
export interface SetupResult {
|
|
213
|
+
/** One entry per file `setup` considered. */
|
|
214
|
+
files: FileResult[];
|
|
215
|
+
/**
|
|
216
|
+
* What `setup` could not do, each line naming the problem and the fix.
|
|
217
|
+
*
|
|
218
|
+
* Non-empty means the scaffold is **incomplete**: the `zuke.ts` on disk
|
|
219
|
+
* imports `@zuke/core` by bare specifier, and nothing resolves it until the
|
|
220
|
+
* reader acts. The caller reports these and exits non-zero rather than
|
|
221
|
+
* printing `Next: ./zuke` over a build that cannot start.
|
|
222
|
+
*/
|
|
223
|
+
manualSteps: string[];
|
|
224
|
+
/**
|
|
225
|
+
* Advisory observations about the existing project that `setup` deliberately
|
|
226
|
+
* left alone. Worth printing, but nothing is broken and the exit code stays
|
|
227
|
+
* 0.
|
|
228
|
+
*/
|
|
229
|
+
notes: string[];
|
|
230
|
+
}
|
|
231
|
+
/** Join a directory and file name without pulling in path utilities. */
|
|
232
|
+
export declare function joinPath(dir: string, name: string): string;
|
|
233
|
+
/** The default launcher base name. */
|
|
234
|
+
export declare const DEFAULT_LAUNCHER = "zuke";
|
|
235
|
+
/**
|
|
236
|
+
* The build file the TypeScript project in `dir` already has: the one its
|
|
237
|
+
* `zuke.json` names, `zuke.ts` when it names none, and `zuke.ts` too for a
|
|
238
|
+
* directory that holds one with no `zuke.json` yet. `undefined` for a
|
|
239
|
+
* directory with neither, which is a new project. A `zuke.json` that is a
|
|
240
|
+
* link is not read: scaffolding refuses it.
|
|
241
|
+
*
|
|
242
|
+
* @throws {Error} when `zuke.json` names a build file that is not a valid name.
|
|
243
|
+
*/
|
|
244
|
+
export declare function existingBuildFile(dir: string, host: SetupHost): Promise<string | undefined>;
|
|
245
|
+
/**
|
|
246
|
+
* Whether `name` in `dir` is a file of the project's own that is not a Zuke
|
|
247
|
+
* build: it exists and does not import `@zuke/core`. A new project must not
|
|
248
|
+
* take such a name, because its `zuke.json` would point at an unrelated
|
|
249
|
+
* script, and `--force` would overwrite it.
|
|
250
|
+
*/
|
|
251
|
+
export declare function unrelatedBuildFile(dir: string, name: string, host: SetupHost): Promise<boolean>;
|
|
252
|
+
/**
|
|
253
|
+
* Scaffold Zuke into `options.dir`: a starter build file, the launcher scripts,
|
|
254
|
+
* and a `deno.json` task block. Existing files are skipped unless
|
|
255
|
+
* `options.force` is set; `deno.json` is always merged (never clobbered). Fails
|
|
256
|
+
* up front if a target name is occupied by a directory (see
|
|
257
|
+
* {@link SetupOptions.launcherName}).
|
|
258
|
+
*/
|
|
259
|
+
export declare function runSetup(options: SetupOptions, host?: SetupHost): Promise<SetupResult>;
|