@zuke-build/cli 2.7.0 → 2.9.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 +4 -1
- package/mod.d.ts +1 -1
- package/mod.js +27 -7
- package/package.json +1 -1
- package/src/cache.d.ts +4 -0
- package/src/cache.js +18 -2
- package/src/deno_isolated.js +1 -1
- package/src/deno_path.d.ts +1 -1
- package/src/deno_path.js +7 -2
- package/src/dependencies.d.ts +17 -0
- package/src/dependencies.js +60 -11
- package/src/dispatch.d.ts +10 -0
- package/src/dispatch.js +19 -2
- package/src/import.d.ts +6 -0
- package/src/import.js +1 -0
- package/src/launcher.d.ts +6 -0
- package/src/launcher.js +14 -1
- package/src/mcp_config.d.ts +2 -0
- package/src/mcp_config.js +1 -1
- package/src/npm_path.d.ts +16 -0
- package/src/npm_path.js +78 -0
- package/src/project.d.ts +14 -1
- package/src/project.js +21 -4
- package/src/records.d.ts +2 -0
- package/src/records.js +7 -3
- package/src/relock.js +116 -59
- package/src/setup.d.ts +9 -1
- package/src/setup.js +224 -30
- package/src/toml.js +1 -1
- package/src/translate.js +1 -1
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -194,6 +194,9 @@ interface ProjectHost
|
|
|
194
194
|
Remove a file.
|
|
195
195
|
deno(denoArgs: string[], cwd: string): Promise<number>
|
|
196
196
|
Run `deno <denoArgs>` in `cwd`, returning its exit code.
|
|
197
|
+
npm(npmArgs: string[], cwd: string): Promise<number>
|
|
198
|
+
Run `npm <npmArgs>` in `cwd`, a Node project's root, returning its exit
|
|
199
|
+
code.
|
|
197
200
|
denoVersion(): string
|
|
198
201
|
The version of the Deno that runs the command.
|
|
199
202
|
|
|
@@ -243,7 +246,7 @@ interface SetupFlags
|
|
|
243
246
|
The SDK whose build to scaffold (`--sdk python`): a `build.py` the engine
|
|
244
247
|
runs, in place of a `zuke.ts`. Unset: a TypeScript build.
|
|
245
248
|
runtime?: string
|
|
246
|
-
The runtime of a TypeScript build (`--runtime deno|node`). Unset:
|
|
249
|
+
The runtime of a TypeScript build (`--runtime deno|node`). Unset: the project's own, else Node; asked when interactive.
|
|
247
250
|
zuke?: string
|
|
248
251
|
The `zuke` release an SDK build's launchers run (`--zuke`), whose engine
|
|
249
252
|
`zuke.json` pins. Unset: this zuke's own release.
|
package/mod.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface SetupFlags {
|
|
|
62
62
|
* runs, in place of a `zuke.ts`. Unset: a TypeScript build.
|
|
63
63
|
*/
|
|
64
64
|
sdk?: string;
|
|
65
|
-
/** The runtime of a TypeScript build (`--runtime deno|node`). Unset:
|
|
65
|
+
/** The runtime of a TypeScript build (`--runtime deno|node`). Unset: the project's own, else Node; asked when interactive. */
|
|
66
66
|
runtime?: string;
|
|
67
67
|
/**
|
|
68
68
|
* The `zuke` release an SDK build's launchers run (`--zuke`), whose engine
|
package/mod.js
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { ConsoleTasks } from "@zuke/console";
|
|
21
21
|
import { assertBuildFileName, NEW_BUILD_FILE } from "./src/build_file.js";
|
|
22
|
-
import { defaultHost, existingBuildFile, runSetup, unrelatedBuildFile, } from "./src/setup.js";
|
|
22
|
+
import { defaultHost, existingBuildFile, existingRuntime, runSetup, unrelatedBuildFile, } from "./src/setup.js";
|
|
23
23
|
import { runImport } from "./src/import.js";
|
|
24
24
|
import { defaultStarActions, promptStar, } from "./src/star.js";
|
|
25
25
|
import { VERSION } from "./src/version.js";
|
|
26
26
|
import { installLabel, installSource, } from "./src/install_source.js";
|
|
27
27
|
import { DENO_PIN } from "./src/deno_pin.js";
|
|
28
|
-
import { buildLabel, defaultBuildProbe, defaultBuildRunner, embeddedEngineNotice, locateBuild, NO_LOCK_NOTICE, runBuild, runningNotice, servingEngine, } from "./src/dispatch.js";
|
|
28
|
+
import { buildLabel, defaultBuildProbe, defaultBuildRunner, DENO_SUPPORT_NOTICE, embeddedEngineNotice, locateBuild, NO_LOCK_NOTICE, owesDenoSupportNotice, runBuild, runningNotice, servingEngine, } from "./src/dispatch.js";
|
|
29
29
|
import { absolutePath, logoLines, resolveDocSpec, RuntimeTasks, } from "@zuke/core";
|
|
30
30
|
import { runDenoIsolated } from "./src/deno_isolated.js";
|
|
31
31
|
import { defaultDenoHost, firstSet } from "./src/deno_path.js";
|
|
@@ -228,7 +228,8 @@ const SDK_BOOTSTRAP_QUESTION = "Launchers: download the pinned, checksum-verifie
|
|
|
228
228
|
"use, rather than require zuke on PATH? [y/n]";
|
|
229
229
|
/** The launcher question when the build's kind is not known yet (`import`). */
|
|
230
230
|
const ANY_BOOTSTRAP_QUESTION = "Launchers: download their pinned, checksum-verified runtime (Deno for a " +
|
|
231
|
-
"TypeScript build, zuke for a Python one
|
|
231
|
+
"TypeScript build on Deno, zuke for a Python one; a Node build's always " +
|
|
232
|
+
"do) when it is missing? [y/n]";
|
|
232
233
|
/**
|
|
233
234
|
* Which launchers to scaffold. A flag decides outright; otherwise the wizard
|
|
234
235
|
* asks `question` when it is interactive, and the default — bootstrap —
|
|
@@ -320,7 +321,8 @@ Setup options:
|
|
|
320
321
|
--name <Class> Build class name (default: MyBuild)
|
|
321
322
|
--build-file <name> TypeScript build file name (default: build.ts, or the project's own)
|
|
322
323
|
--launcher-name <name> Launcher base name when a zuke/ directory is in the way
|
|
323
|
-
--runtime deno|node Runtime of a TypeScript build (default:
|
|
324
|
+
--runtime deno|node Runtime of a TypeScript build (default: node, or the project's own); node scaffolds a
|
|
325
|
+
package.json and Node launchers, and converts a Deno project in place
|
|
324
326
|
--sdk python Scaffold a build.py and launchers that run the zuke binary (no Deno)
|
|
325
327
|
--zuke <version> The zuke release those launchers run (default: this one)
|
|
326
328
|
--mcp Also write .mcp.json registering the build's MCP server
|
|
@@ -336,6 +338,7 @@ Import options:
|
|
|
336
338
|
--name <Class> Build class name (default: MyBuild)
|
|
337
339
|
--from <source> Force a source: package.json, makefile or pyproject (default: auto-detect)
|
|
338
340
|
--zuke <version> The zuke release a pyproject.toml import's launchers run (default: this one)
|
|
341
|
+
--runtime deno|node Runtime of a generated zuke.ts (default: node, or the project's own)
|
|
339
342
|
--mcp Also write .mcp.json registering the build's MCP server
|
|
340
343
|
--allow-run …with --allow-run, so an agent may execute targets (implies --mcp)
|
|
341
344
|
--bootstrap Launchers download their pinned, checksum-verified runtime when missing (default):
|
|
@@ -433,6 +436,13 @@ async function askBuildFile(dir, suggested, host, prompter) {
|
|
|
433
436
|
}
|
|
434
437
|
throw new Error(refusal);
|
|
435
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* The runtime `zuke setup` picks when `--runtime` does not: the project's
|
|
441
|
+
* own, so a re-run never converts it, and Node for a new project.
|
|
442
|
+
*/
|
|
443
|
+
async function defaultRuntime(dir, host) {
|
|
444
|
+
return await existingRuntime(dir, host) ?? "node";
|
|
445
|
+
}
|
|
436
446
|
/** Run the `setup` subcommand. */
|
|
437
447
|
async function commandSetup(args, host, prompter, starActions, paint, upgradeHost) {
|
|
438
448
|
const flags = parseSetupFlags(args);
|
|
@@ -458,13 +468,15 @@ async function commandSetup(args, host, prompter, starActions, paint, upgradeHos
|
|
|
458
468
|
force = prompter.confirm("Overwrite existing files if present?");
|
|
459
469
|
}
|
|
460
470
|
if (sdk === undefined && runtime === undefined) {
|
|
461
|
-
const answer = prompter.ask("Runtime (deno or node)",
|
|
471
|
+
const answer = prompter.ask("Runtime (deno or node)", await defaultRuntime(dir, host)).trim();
|
|
462
472
|
if (!isRuntime(answer)) {
|
|
463
473
|
throw new Error(`zuke setup: unknown runtime "${answer}" — answer deno or node.`);
|
|
464
474
|
}
|
|
465
475
|
runtime = answer;
|
|
466
476
|
}
|
|
467
477
|
}
|
|
478
|
+
if (sdk === undefined)
|
|
479
|
+
runtime ??= await defaultRuntime(dir, host);
|
|
468
480
|
// A Node launcher always bootstraps and names no Deno, so it is not asked.
|
|
469
481
|
const bootstrapDeno = runtime === "node" ? undefined : resolveBootstrapDeno(flags, prompter, interactive, sdk === undefined ? BOOTSTRAP_QUESTION : SDK_BOOTSTRAP_QUESTION);
|
|
470
482
|
const where = dir === "." ? "the current directory" : dir;
|
|
@@ -553,6 +565,9 @@ async function commandImport(args, host, prompter, paint, upgradeHost) {
|
|
|
553
565
|
force = prompter.confirm("Overwrite existing files if present?");
|
|
554
566
|
}
|
|
555
567
|
}
|
|
568
|
+
// Like setup: the project's own runtime, else Node. A build.py ignores it.
|
|
569
|
+
const runtime = runtimeOption(flags.runtime) ??
|
|
570
|
+
await defaultRuntime(dir, host);
|
|
556
571
|
const bootstrapDeno = resolveBootstrapDeno(flags, prompter, interactive, ANY_BOOTSTRAP_QUESTION);
|
|
557
572
|
const result = await runImport({
|
|
558
573
|
dir,
|
|
@@ -562,6 +577,7 @@ async function commandImport(args, host, prompter, paint, upgradeHost) {
|
|
|
562
577
|
from: flags.from,
|
|
563
578
|
mcp: mcpOption(flags),
|
|
564
579
|
bootstrapDeno,
|
|
580
|
+
runtime,
|
|
565
581
|
pin: () => binaryPin(flags, upgradeHost, "zuke import"),
|
|
566
582
|
}, host);
|
|
567
583
|
if (result.source === null) {
|
|
@@ -631,8 +647,12 @@ async function forwardToBuild(args, probe, runner, engine) {
|
|
|
631
647
|
const fallback = embeddedEngineNotice(location, engine);
|
|
632
648
|
if (fallback !== undefined)
|
|
633
649
|
output.error(fallback);
|
|
634
|
-
// A launcher
|
|
635
|
-
//
|
|
650
|
+
// A launcher prints its own notices; the CLI says where a Deno build
|
|
651
|
+
// stands only when the launcher it goes through does not.
|
|
652
|
+
if (await owesDenoSupportNotice(location, probe)) {
|
|
653
|
+
output.error(DENO_SUPPORT_NOTICE);
|
|
654
|
+
}
|
|
655
|
+
// Only the bare `deno run` a launcher stands in for is this notice's.
|
|
636
656
|
// A hosted build has no Deno config for Deno to write a lock into, so
|
|
637
657
|
// the launchers say nothing there, and neither does this.
|
|
638
658
|
if (location.launcher === null && !location.frozen &&
|
package/package.json
CHANGED
package/src/cache.d.ts
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* moved. `--min-dep-age` passes Deno's `--minimum-dependency-age` through,
|
|
9
9
|
* and only matters for a resolution the lock does not have yet.
|
|
10
10
|
*
|
|
11
|
+
* In a project whose build runs on Node it runs `npm ci --ignore-scripts`,
|
|
12
|
+
* which installs exactly what `package-lock.json` pins, or `npm install
|
|
13
|
+
* --ignore-scripts` to write the first lock when there is none.
|
|
14
|
+
*
|
|
11
15
|
* @module
|
|
12
16
|
*/
|
|
13
17
|
import type { BuildProbe } from "./dispatch.ts";
|
package/src/cache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2026 the Zuke contributors
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { installArgs, parseInstallFlags, projectLocation, } from "./project.js";
|
|
3
|
+
import { installArgs, nodeInstallFlags, parseInstallFlags, projectLocation, } from "./project.js";
|
|
4
4
|
/**
|
|
5
5
|
* Run `zuke cache <args>` from `cwd`, reporting through `log`, and return the
|
|
6
6
|
* exit code.
|
|
@@ -10,7 +10,23 @@ import { installArgs, parseInstallFlags, projectLocation, } from "./project.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export async function runCache(args, log, host, paint, cwd, probe) {
|
|
12
12
|
const flags = parseInstallFlags("cache", args);
|
|
13
|
-
const { root, build } = await projectLocation(cwd, probe, "cache");
|
|
13
|
+
const { root, build, runtime } = await projectLocation(cwd, probe, "cache");
|
|
14
|
+
if (runtime === "node") {
|
|
15
|
+
nodeInstallFlags("cache", flags);
|
|
16
|
+
const locked = (await host.entry(`${root}/package-lock.json`)) !== "missing";
|
|
17
|
+
const npmArgs = [locked ? "ci" : "install", "--ignore-scripts"];
|
|
18
|
+
if (flags.dryRun) {
|
|
19
|
+
log(`Would cache the build's dependencies: npm ${npmArgs.join(" ")}`);
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
const code = await host.npm(npmArgs, root);
|
|
23
|
+
if (code !== 0) {
|
|
24
|
+
log(paint.fail(`zuke cache: npm ${npmArgs[0]} exited ${code}.`));
|
|
25
|
+
return code;
|
|
26
|
+
}
|
|
27
|
+
log(paint.ok("Installed everything the build imports."));
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
14
30
|
const denoArgs = installArgs("cache", flags, host.denoVersion(), build);
|
|
15
31
|
if (flags.dryRun) {
|
|
16
32
|
log(`Would cache the build's dependencies: deno ${denoArgs.join(" ")}`);
|
package/src/deno_isolated.js
CHANGED
|
@@ -43,7 +43,7 @@ export async function runDenoIsolated(denoArgs, prefix) {
|
|
|
43
43
|
const cwd = await FileTasks.makeTempDirectory((s) => s.prefix(prefix));
|
|
44
44
|
try {
|
|
45
45
|
await FileTasks.writeText(`${cwd}/deno.json`, ISOLATED_DENO_CONFIG);
|
|
46
|
-
const child = spawnDeno(denoArgs, {
|
|
46
|
+
const child = await spawnDeno(denoArgs, {
|
|
47
47
|
cwd,
|
|
48
48
|
stdin: "null",
|
|
49
49
|
stdout: "piped",
|
package/src/deno_path.d.ts
CHANGED
|
@@ -112,4 +112,4 @@ export interface DenoSpawnOptions {
|
|
|
112
112
|
*
|
|
113
113
|
* @throws {DenoNotFoundError} when every candidate is missing.
|
|
114
114
|
*/
|
|
115
|
-
export declare function spawnDeno(args: string[], options?: DenoSpawnOptions, candidates?: readonly string[]): ChildProcess
|
|
115
|
+
export declare function spawnDeno(args: string[], options?: DenoSpawnOptions, candidates?: readonly string[]): Promise<ChildProcess>;
|
package/src/deno_path.js
CHANGED
|
@@ -163,12 +163,12 @@ function cwdUsable(cwd) {
|
|
|
163
163
|
*
|
|
164
164
|
* @throws {DenoNotFoundError} when every candidate is missing.
|
|
165
165
|
*/
|
|
166
|
-
export function spawnDeno(args, options = {}, candidates = denoCandidates()) {
|
|
166
|
+
export async function spawnDeno(args, options = {}, candidates = denoCandidates()) {
|
|
167
167
|
const tried = [];
|
|
168
168
|
for (const command of candidates) {
|
|
169
169
|
tried.push(command);
|
|
170
170
|
try {
|
|
171
|
-
|
|
171
|
+
const child = ProcessTasks.spawn(command, (s) => {
|
|
172
172
|
s.args(...args);
|
|
173
173
|
if (options.cwd !== undefined)
|
|
174
174
|
s.cwd(options.cwd);
|
|
@@ -187,6 +187,11 @@ export function spawnDeno(args, options = {}, candidates = denoCandidates()) {
|
|
|
187
187
|
s.env(name, value);
|
|
188
188
|
return s;
|
|
189
189
|
});
|
|
190
|
+
// On Node a command that cannot start throws nothing: the child has no
|
|
191
|
+
// process, and its status rejects with why.
|
|
192
|
+
if (child.pid === -1)
|
|
193
|
+
await child.status;
|
|
194
|
+
return child;
|
|
190
195
|
}
|
|
191
196
|
catch (error) {
|
|
192
197
|
// Not installed here; the next candidate may be. Anything else — a
|
package/src/dependencies.d.ts
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
* `--minimum-dependency-age` flag. Both honour the project's own
|
|
12
12
|
* `minimumDependencyAge` in `deno.json`, which Deno reads for them.
|
|
13
13
|
*
|
|
14
|
+
* In a project whose build runs on Node they run `npm install` and
|
|
15
|
+
* `npm uninstall` instead, with `--ignore-scripts`, and change `package.json`:
|
|
16
|
+
* a bare name becomes the alias `@zuke/<name>` for `npm:@zuke-build/<name>@^1`,
|
|
17
|
+
* as `zuke setup --runtime node` writes it, and an `npm:` specifier passes
|
|
18
|
+
* through. A JSR package has no npm install, so it is refused there.
|
|
19
|
+
*
|
|
14
20
|
* @module
|
|
15
21
|
*/
|
|
16
22
|
import type { BuildProbe } from "./dispatch.ts";
|
|
@@ -27,6 +33,17 @@ export type DependencyCommand = "add" | "remove";
|
|
|
27
33
|
* read, or a name no registry accepts — rather than handing it to Deno.
|
|
28
34
|
*/
|
|
29
35
|
export declare function dependencySpecifier(command: DependencyCommand, name: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* The `npm install` / `npm uninstall` operand for `specifier`, one
|
|
38
|
+
* {@link dependencySpecifier} returned: a Zuke package becomes its
|
|
39
|
+
* `@zuke/<name>` alias (to add) or that alias (to remove), and an `npm:`
|
|
40
|
+
* specifier is npm's own, without the prefix. A removal names the package
|
|
41
|
+
* alone, as `npm uninstall` takes it.
|
|
42
|
+
*
|
|
43
|
+
* @throws {Error} naming `command` on any other JSR package, which npm
|
|
44
|
+
* cannot install.
|
|
45
|
+
*/
|
|
46
|
+
export declare function npmOperand(command: DependencyCommand, specifier: string): string;
|
|
30
47
|
/**
|
|
31
48
|
* Parse `zuke add`'s or `zuke remove`'s arguments: one or more packages, and
|
|
32
49
|
* `--dry-run`.
|
package/src/dependencies.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) 2026 the Zuke contributors
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { projectLocation } from "./project.js";
|
|
4
|
+
import { zukeNpmDependency } from "./starter.js";
|
|
4
5
|
import { projectConfigText } from "./version_report.js";
|
|
5
6
|
/** A bare Zuke package name, as `zuke add docker` takes it. */
|
|
6
7
|
const BARE_NAME = /^[a-z0-9][a-z0-9-]*$/;
|
|
@@ -27,6 +28,37 @@ export function dependencySpecifier(command, name) {
|
|
|
27
28
|
"(docker), a scoped JSR name (@scope/name), or a jsr: or npm: " +
|
|
28
29
|
"specifier.");
|
|
29
30
|
}
|
|
31
|
+
/** The `@zuke/<name>` a Zuke package's specifier names, if it is one. */
|
|
32
|
+
const ZUKE_JSR = /^jsr:@zuke\/([a-z0-9][a-z0-9-]*)$/;
|
|
33
|
+
/**
|
|
34
|
+
* The `npm install` / `npm uninstall` operand for `specifier`, one
|
|
35
|
+
* {@link dependencySpecifier} returned: a Zuke package becomes its
|
|
36
|
+
* `@zuke/<name>` alias (to add) or that alias (to remove), and an `npm:`
|
|
37
|
+
* specifier is npm's own, without the prefix. A removal names the package
|
|
38
|
+
* alone, as `npm uninstall` takes it.
|
|
39
|
+
*
|
|
40
|
+
* @throws {Error} naming `command` on any other JSR package, which npm
|
|
41
|
+
* cannot install.
|
|
42
|
+
*/
|
|
43
|
+
export function npmOperand(command, specifier) {
|
|
44
|
+
const zuke = ZUKE_JSR.exec(specifier)?.[1];
|
|
45
|
+
if (zuke !== undefined) {
|
|
46
|
+
return command === "add"
|
|
47
|
+
? `@zuke/${zuke}@${zukeNpmDependency(zuke)}`
|
|
48
|
+
: `@zuke/${zuke}`;
|
|
49
|
+
}
|
|
50
|
+
if (specifier.startsWith("npm:")) {
|
|
51
|
+
const spec = specifier.slice("npm:".length);
|
|
52
|
+
if (command === "add")
|
|
53
|
+
return spec;
|
|
54
|
+
// `name@range` names `name`; a scoped name's own `@` comes first.
|
|
55
|
+
const at = spec.indexOf("@", 1);
|
|
56
|
+
return at === -1 ? spec : spec.slice(0, at);
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`zuke ${command}: ${specifier} is a JSR package, and this project's build ` +
|
|
59
|
+
"runs on Node, which installs from npm. Pass its npm name as " +
|
|
60
|
+
"npm:<name>.");
|
|
61
|
+
}
|
|
30
62
|
/**
|
|
31
63
|
* Parse `zuke add`'s or `zuke remove`'s arguments: one or more packages, and
|
|
32
64
|
* `--dry-run`.
|
|
@@ -55,26 +87,43 @@ export function parseDependencyArgs(command, args) {
|
|
|
55
87
|
*/
|
|
56
88
|
export async function runDependencies(command, args, log, host, paint, cwd, probe) {
|
|
57
89
|
const { specifiers, dryRun } = parseDependencyArgs(command, args);
|
|
58
|
-
const { root } = await projectLocation(cwd, probe, command);
|
|
59
|
-
const
|
|
90
|
+
const { root, runtime } = await projectLocation(cwd, probe, command);
|
|
91
|
+
const node = runtime === "node";
|
|
92
|
+
const tool = node ? "npm" : "deno";
|
|
93
|
+
const toolArgs = node
|
|
94
|
+
? [
|
|
95
|
+
command === "add" ? "install" : "uninstall",
|
|
96
|
+
"--ignore-scripts",
|
|
97
|
+
...specifiers.map((specifier) => npmOperand(command, specifier)),
|
|
98
|
+
]
|
|
99
|
+
: [command, ...specifiers];
|
|
60
100
|
if (dryRun) {
|
|
61
|
-
log(`Would run in ${root}:
|
|
101
|
+
log(`Would run in ${root}: ${tool} ${toolArgs.join(" ")}`);
|
|
62
102
|
return 0;
|
|
63
103
|
}
|
|
64
|
-
const
|
|
104
|
+
const manifest = node ? "package.json" : "deno.json";
|
|
105
|
+
// What the report names: the packages as the manifest spells them.
|
|
106
|
+
const named = (node
|
|
107
|
+
? specifiers.map((specifier) => npmOperand("remove", specifier))
|
|
108
|
+
: specifiers).join(", ");
|
|
109
|
+
const config = node
|
|
110
|
+
? () => host.readText(`${root}/package.json`).catch(() => undefined)
|
|
111
|
+
: () => projectConfigText((path) => host.readText(path), root);
|
|
65
112
|
const before = await config();
|
|
66
|
-
const code =
|
|
113
|
+
const code = node
|
|
114
|
+
? await host.npm(toolArgs, root)
|
|
115
|
+
: await host.deno(toolArgs, root);
|
|
67
116
|
if (code !== 0) {
|
|
68
|
-
log(paint.fail(`zuke ${command}:
|
|
117
|
+
log(paint.fail(`zuke ${command}: ${tool} ${toolArgs[0]} exited ${code}.`));
|
|
69
118
|
return code;
|
|
70
119
|
}
|
|
71
|
-
// `deno remove`
|
|
72
|
-
//
|
|
120
|
+
// `deno remove` and `npm uninstall` exit 0 when they find nothing to
|
|
121
|
+
// remove; an unchanged manifest is how that shows.
|
|
73
122
|
if (command === "remove" && (await config()) === before) {
|
|
74
|
-
log(paint.fail(`zuke remove: nothing was removed; this project's
|
|
75
|
-
`${
|
|
123
|
+
log(paint.fail(`zuke remove: nothing was removed; this project's ${manifest} has no ` +
|
|
124
|
+
`${named}.`));
|
|
76
125
|
return 1;
|
|
77
126
|
}
|
|
78
|
-
log(paint.ok(`${command === "add" ? "Added" : "Removed"} ${
|
|
127
|
+
log(paint.ok(`${command === "add" ? "Added" : "Removed"} ${named}.`));
|
|
79
128
|
return 0;
|
|
80
129
|
}
|
package/src/dispatch.d.ts
CHANGED
|
@@ -201,6 +201,16 @@ export declare const NODE = "node";
|
|
|
201
201
|
* or no launcher to go to, which {@link runBuild} refuses instead.
|
|
202
202
|
*/
|
|
203
203
|
export declare function embeddedEngineNotice(location: BuildLocation, engine: EmbeddedEngine | undefined): string | undefined;
|
|
204
|
+
/** The launchers' notice for a build on Deno, verbatim. */
|
|
205
|
+
export declare const DENO_SUPPORT_NOTICE: string;
|
|
206
|
+
/**
|
|
207
|
+
* Whether `zuke` prints {@link DENO_SUPPORT_NOTICE} before running the build
|
|
208
|
+
* at `location`: a build on Deno that no launcher runs, or whose launcher
|
|
209
|
+
* was written before the launchers printed it themselves. A custom launcher
|
|
210
|
+
* that does not print it and calls `zuke` itself hears it twice. A build on Node,
|
|
211
|
+
* or one another SDK hosts, is told nothing.
|
|
212
|
+
*/
|
|
213
|
+
export declare function owesDenoSupportNotice(location: BuildLocation, probe: BuildProbe): Promise<boolean>;
|
|
204
214
|
/** The launchers' notice for a run without a lockfile, verbatim. */
|
|
205
215
|
export declare const NO_LOCK_NOTICE: string;
|
|
206
216
|
/**
|
package/src/dispatch.js
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
* @module
|
|
45
45
|
*/
|
|
46
46
|
import { absolutePath, CONFIG_FILE, EnvTasks, FileTasks, ProcessTasks, RuntimeTasks, } from "@zuke/core";
|
|
47
|
-
import { noLockNotice } from "./launcher.js";
|
|
47
|
+
import { denoSupportNotice, noLockNotice } from "./launcher.js";
|
|
48
48
|
import { BINARY_INSTALL_DOCS } from "./binary_pin.js";
|
|
49
49
|
import { BUILD_FILE, buildFileNamed } from "./build_file.js";
|
|
50
50
|
import { runtimeNamed } from "./runtime_field.js";
|
|
@@ -465,6 +465,23 @@ export function embeddedEngineNotice(location, engine) {
|
|
|
465
465
|
`run ${CONFIG_FILE}'s ${location.engine}, so the project's launcher ` +
|
|
466
466
|
"runs it";
|
|
467
467
|
}
|
|
468
|
+
/** The launchers' notice for a build on Deno, verbatim. */
|
|
469
|
+
export const DENO_SUPPORT_NOTICE = denoSupportNotice("—");
|
|
470
|
+
/**
|
|
471
|
+
* Whether `zuke` prints {@link DENO_SUPPORT_NOTICE} before running the build
|
|
472
|
+
* at `location`: a build on Deno that no launcher runs, or whose launcher
|
|
473
|
+
* was written before the launchers printed it themselves. A custom launcher
|
|
474
|
+
* that does not print it and calls `zuke` itself hears it twice. A build on Node,
|
|
475
|
+
* or one another SDK hosts, is told nothing.
|
|
476
|
+
*/
|
|
477
|
+
export async function owesDenoSupportNotice(location, probe) {
|
|
478
|
+
if (location.engine !== null || location.runtime !== "deno")
|
|
479
|
+
return false;
|
|
480
|
+
// runBuild skips the launcher when this is a launcher's own call, or one
|
|
481
|
+
// inherited from a build a launcher started: then nothing else says it.
|
|
482
|
+
return location.launcher === null || !viaLauncher(location) ||
|
|
483
|
+
!(await probe.readText(location.launcher)).includes(DENO_SUPPORT_NOTICE);
|
|
484
|
+
}
|
|
468
485
|
/** The launchers' notice for a run without a lockfile, verbatim. */
|
|
469
486
|
export const NO_LOCK_NOTICE = noLockNotice("—");
|
|
470
487
|
/**
|
|
@@ -518,7 +535,7 @@ function signalPlan(child) {
|
|
|
518
535
|
*/
|
|
519
536
|
export const defaultBuildRunner = async (root, args, program, env) => {
|
|
520
537
|
const child = program === undefined
|
|
521
|
-
? spawnDeno(args, {
|
|
538
|
+
? await spawnDeno(args, {
|
|
522
539
|
cwd: root,
|
|
523
540
|
stdin: "inherit",
|
|
524
541
|
stdout: "inherit",
|
package/src/import.d.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @module
|
|
24
24
|
*/
|
|
25
|
+
import type { ProjectRuntime } from "./runtime_field.ts";
|
|
25
26
|
import type { BinaryPin } from "./binary_pin.ts";
|
|
26
27
|
import { type McpSetupOptions, type ScaffoldImports, type SetupHost, type SetupResult } from "./setup.ts";
|
|
27
28
|
/** A task discovered in an existing project, before identifier normalisation. */
|
|
@@ -104,6 +105,11 @@ export interface ImportOptions {
|
|
|
104
105
|
mcp?: McpSetupOptions;
|
|
105
106
|
/** Which launchers to scaffold (see {@link "./setup.ts".SetupOptions.bootstrapDeno}). */
|
|
106
107
|
bootstrapDeno?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* The runtime a generated `zuke.ts` runs on (see
|
|
110
|
+
* {@link "./setup.ts".SetupOptions.runtime}); a `build.py` ignores it.
|
|
111
|
+
*/
|
|
112
|
+
runtime?: ProjectRuntime;
|
|
107
113
|
/**
|
|
108
114
|
* Resolve the pin of the `zuke` release a Python build's launchers run,
|
|
109
115
|
* whose engine its `zuke.json` pins. Called only when a `pyproject.toml` is
|
package/src/import.js
CHANGED
|
@@ -271,6 +271,7 @@ export async function runImport(options, host) {
|
|
|
271
271
|
imports: translation.imports,
|
|
272
272
|
mcp: options.mcp,
|
|
273
273
|
bootstrapDeno: options.bootstrapDeno,
|
|
274
|
+
runtime: translation.python ? undefined : options.runtime,
|
|
274
275
|
sdk: translation.python ? { pin: await options.pin() } : undefined,
|
|
275
276
|
}, host);
|
|
276
277
|
return {
|
package/src/launcher.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ import { type DenoPin } from "./deno_pin.ts";
|
|
|
9
9
|
* sources are kept ASCII).
|
|
10
10
|
*/
|
|
11
11
|
export declare function noLockNotice(dash: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The line a build on Deno prints from its launcher, or from the CLI when it
|
|
14
|
+
* runs the build itself: how long Deno support is confirmed, and the command
|
|
15
|
+
* that moves the project to Node. `dash` as for {@link noLockNotice}.
|
|
16
|
+
*/
|
|
17
|
+
export declare function denoSupportNotice(dash: string): string;
|
|
12
18
|
export interface LauncherOptions {
|
|
13
19
|
/**
|
|
14
20
|
* Bootstrap a pinned, checksum-verified Deno when none is on `PATH`
|
package/src/launcher.js
CHANGED
|
@@ -48,6 +48,15 @@ export function noLockNotice(dash) {
|
|
|
48
48
|
return `zuke: no deno.lock here yet ${dash} running without lockfile ` +
|
|
49
49
|
"verification so Deno can write one.";
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The line a build on Deno prints from its launcher, or from the CLI when it
|
|
53
|
+
* runs the build itself: how long Deno support is confirmed, and the command
|
|
54
|
+
* that moves the project to Node. `dash` as for {@link noLockNotice}.
|
|
55
|
+
*/
|
|
56
|
+
export function denoSupportNotice(dash) {
|
|
57
|
+
return `zuke: builds on Deno are supported until October 2027 ${dash} run ` +
|
|
58
|
+
"zuke setup --runtime node to move this project to Node.";
|
|
59
|
+
}
|
|
51
60
|
/** The build file a launcher with `options` runs, checked before it is written into a script. */
|
|
52
61
|
function buildFileOf(options) {
|
|
53
62
|
return assertBuildFileName(options.buildFile ?? BUILD_FILE);
|
|
@@ -239,6 +248,7 @@ ${bashResolveDeno(options, pin)}
|
|
|
239
248
|
# then on --frozen fails the build if the module graph changed. Say so when
|
|
240
249
|
# skipping, so a deleted lockfile downgrades verification visibly instead of
|
|
241
250
|
# silently.
|
|
251
|
+
echo "${denoSupportNotice("—")}" >&2
|
|
242
252
|
if [ -f deno.lock ]; then
|
|
243
253
|
exec "$deno_bin" run -A --frozen ${build} "$@"
|
|
244
254
|
else
|
|
@@ -392,10 +402,13 @@ ${pwshResolveDeno(options, pin)}
|
|
|
392
402
|
# skipping, so a deleted lockfile downgrades verification visibly instead of
|
|
393
403
|
# silently.
|
|
394
404
|
$denoArgs = @("run", "-A")
|
|
405
|
+
# Both notices go to stderr: Write-Warning lands on stdout for a caller that
|
|
406
|
+
# ran this with -File, and stdout is the build's (--list --json, mcp).
|
|
407
|
+
[Console]::Error.WriteLine("${denoSupportNotice("-")}")
|
|
395
408
|
if (Test-Path (Join-Path $dir "deno.lock")) {
|
|
396
409
|
$denoArgs += "--frozen"
|
|
397
410
|
} else {
|
|
398
|
-
|
|
411
|
+
[Console]::Error.WriteLine("${noLockNotice("-")}")
|
|
399
412
|
}
|
|
400
413
|
$denoArgs += (Join-Path $dir "${build}")
|
|
401
414
|
& $deno @denoArgs @args
|
package/src/mcp_config.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export type McpConfig = {
|
|
|
55
55
|
/** The text is not JSON. */
|
|
56
56
|
state: "unparseable";
|
|
57
57
|
};
|
|
58
|
+
/** Whether `value` is a well-formed server entry: a command and its arguments. */
|
|
59
|
+
export declare function isServerEntry(value: unknown): value is McpServerEntry;
|
|
58
60
|
/**
|
|
59
61
|
* Parse an `.mcp.json` text and classify its `zuke` entry. This is the only
|
|
60
62
|
* place the text is parsed: {@link mergeMcpConfig} takes the document it
|
package/src/mcp_config.js
CHANGED
|
@@ -55,7 +55,7 @@ export function nodeMcpEntry(allowRun, buildFile) {
|
|
|
55
55
|
return { command: "node", args: [buildFile, ...mcpArgs(allowRun)] };
|
|
56
56
|
}
|
|
57
57
|
/** Whether `value` is a well-formed server entry: a command and its arguments. */
|
|
58
|
-
function isServerEntry(value) {
|
|
58
|
+
export function isServerEntry(value) {
|
|
59
59
|
return isRecord(value) && typeof value.command === "string" &&
|
|
60
60
|
Array.isArray(value.args) &&
|
|
61
61
|
value.args.every((arg) => typeof arg === "string");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type DenoHost } from "./deno_path.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The npm executables to try, in order: the bare name for `PATH`, then the
|
|
4
|
+
* one beside the pinned Node the launchers cache. That one is left out when
|
|
5
|
+
* the environment names no absolute directory to find it in.
|
|
6
|
+
*/
|
|
7
|
+
export declare function npmCandidates(host?: DenoHost): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Run `npm <args>` in `cwd` with the terminal's output, trying each candidate
|
|
10
|
+
* in order and skipping the ones that are not installed, and return its exit
|
|
11
|
+
* code. The cached npm runs with its Node first on `PATH`, which its script
|
|
12
|
+
* needs to start.
|
|
13
|
+
*
|
|
14
|
+
* @throws {Error} naming every candidate tried when none is installed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function runNpm(args: string[], cwd: string, candidates?: readonly string[]): Promise<number>;
|
package/src/npm_path.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright (c) 2026 the Zuke contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* Finding the npm that changes a Node project's dependencies.
|
|
5
|
+
*
|
|
6
|
+
* `zuke add`, `remove`, `cache` and `relock` run npm in a project whose
|
|
7
|
+
* `zuke.json` says `"runtime": "node"`. The order mirrors the project's own
|
|
8
|
+
* launchers: whatever `PATH` resolves first, then the pinned Node they
|
|
9
|
+
* download into `ZUKE_NODE_HOME` (`~/.zuke/node` by default), so a project
|
|
10
|
+
* whose only Node is the one `./zuke` fetched still works. As in
|
|
11
|
+
* `deno_path.ts`, a candidate is tried by spawning it, which leaves `PATHEXT`
|
|
12
|
+
* (`npm.cmd` on Windows) to the OS.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { absolutePath, FileTasks, ProcessTasks } from "@zuke/core";
|
|
17
|
+
import { defaultDenoHost, firstSet, pathWithDeno, } from "./deno_path.js";
|
|
18
|
+
import { NODE_PIN } from "./node_pin.js";
|
|
19
|
+
/**
|
|
20
|
+
* The npm executables to try, in order: the bare name for `PATH`, then the
|
|
21
|
+
* one beside the pinned Node the launchers cache. That one is left out when
|
|
22
|
+
* the environment names no absolute directory to find it in.
|
|
23
|
+
*/
|
|
24
|
+
export function npmCandidates(host = defaultDenoHost) {
|
|
25
|
+
const candidates = ["npm"];
|
|
26
|
+
const explicit = firstSet(host, "ZUKE_NODE_HOME");
|
|
27
|
+
const home = firstSet(host, "HOME", "USERPROFILE");
|
|
28
|
+
try {
|
|
29
|
+
const root = explicit !== undefined
|
|
30
|
+
? absolutePath(explicit)
|
|
31
|
+
: home !== undefined
|
|
32
|
+
? absolutePath(home)(".zuke", "node")
|
|
33
|
+
: undefined;
|
|
34
|
+
if (root !== undefined) {
|
|
35
|
+
const release = root(`v${NODE_PIN.version}`);
|
|
36
|
+
candidates.push(host.windows() ? release("npm.cmd").path : release("bin", "npm").path);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// A relative ZUKE_NODE_HOME or HOME names no place to look.
|
|
41
|
+
}
|
|
42
|
+
return candidates;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Run `npm <args>` in `cwd` with the terminal's output, trying each candidate
|
|
46
|
+
* in order and skipping the ones that are not installed, and return its exit
|
|
47
|
+
* code. The cached npm runs with its Node first on `PATH`, which its script
|
|
48
|
+
* needs to start.
|
|
49
|
+
*
|
|
50
|
+
* @throws {Error} naming every candidate tried when none is installed.
|
|
51
|
+
*/
|
|
52
|
+
export async function runNpm(args, cwd, candidates = npmCandidates()) {
|
|
53
|
+
for (const command of candidates) {
|
|
54
|
+
// A path that is not there is skipped before spawning: Windows reports
|
|
55
|
+
// spawning one as an error that is not a plain "not found".
|
|
56
|
+
const isPath = command.includes("/") || command.includes("\\");
|
|
57
|
+
if (isPath && !(await FileTasks.exists(command)))
|
|
58
|
+
continue;
|
|
59
|
+
try {
|
|
60
|
+
const out = await ProcessTasks.run(command, (s) => {
|
|
61
|
+
s.args(...args).cwd(cwd).stdin("null").stdout("inherit")
|
|
62
|
+
.stderr("inherit");
|
|
63
|
+
for (const [name, value] of Object.entries(pathWithDeno(command))) {
|
|
64
|
+
s.env(name, value);
|
|
65
|
+
}
|
|
66
|
+
return s;
|
|
67
|
+
});
|
|
68
|
+
return out.code;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (!FileTasks.isNotFound(error))
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`zuke: this is a Node project, and no npm was found — tried ` +
|
|
76
|
+
`${candidates.join(", ")}. Run the project's ./zuke once, which ` +
|
|
77
|
+
`installs a pinned Node, or put Node ${NODE_PIN.version.split(".")[0]} or newer on PATH.`);
|
|
78
|
+
}
|