zyrk 0.6.3 → 0.6.6
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 +15 -4
- package/VERSION +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +28 -1
- package/dist/commands/next.d.ts +10 -0
- package/dist/commands/next.d.ts.map +1 -0
- package/dist/commands/next.js +185 -0
- package/dist/dlx/next-display.d.ts +2 -0
- package/dist/dlx/next-display.d.ts.map +1 -0
- package/dist/dlx/next-display.js +36 -0
- package/dist/dlx/next.d.ts.map +1 -1
- package/dist/dlx/next.js +7 -1
- package/dist/dlx/run.d.ts +5 -1
- package/dist/dlx/run.d.ts.map +1 -1
- package/dist/dlx/run.js +4 -3
- package/dist/install/progress.d.ts.map +1 -1
- package/dist/install/progress.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,7 +178,14 @@ For `create next-app`, the native adapter accepts resolved create-next-app
|
|
|
178
178
|
scaffold check covers 16.4.2. Other versions fail before execution. zyrk passes the official `--skip-install` flag to
|
|
179
179
|
create-next-app, validates the generated project manifest, then installs its
|
|
180
180
|
dependencies through zyrk using the same store and registry configuration. An
|
|
181
|
-
explicit `--skip-install` leaves the generated project uninstalled.
|
|
181
|
+
explicit `--skip-install` leaves the generated project uninstalled.
|
|
182
|
+
The private initializer displays `Using zyrk.` for native installation, or
|
|
183
|
+
`Scaffolding only; dependency installation skipped.` for an explicit skip. This
|
|
184
|
+
adapts verified upstream display statements without changing shared source
|
|
185
|
+
files, installer execution, generated metadata, or unrelated npm text. An
|
|
186
|
+
unrecognized display contract fails before the initializer runs. Conflicting
|
|
187
|
+
`--use-npm`, `--use-pnpm`, `--use-yarn`, and `--use-bun` selections require an
|
|
188
|
+
explicit `--skip-install`; remove them to install with zyrk. The official
|
|
182
189
|
flag can select create-next-app's configuration defaults instead of prompting
|
|
183
190
|
for each choice; pass its explicit configuration flags to customize them. Its
|
|
184
191
|
interactive project-name prompt remains available. Supply an explicit target
|
|
@@ -187,9 +194,13 @@ limited to one newly created direct child directory. If generation exits without
|
|
|
187
194
|
a valid manifest, zyrk reports failure and retains any generated files for review.
|
|
188
195
|
|
|
189
196
|
For Next.js 16.4.2 with dependencies in the external shared store, use
|
|
190
|
-
`zyrk run dev -- --webpack` and `zyrk run build -- --webpack
|
|
191
|
-
Turbopack
|
|
192
|
-
|
|
197
|
+
`zyrk run dev -- --webpack` and `zyrk run build -- --webpack`, or explicitly opt
|
|
198
|
+
into Turbopack with `zyrk next --turbopack` before normal `zyrk run dev` / build.
|
|
199
|
+
The [Turbopack guide](docs/next-turbopack.md) explains the experimental additional
|
|
200
|
+
roots, preserved configuration, portable local-state lookup, and deployment
|
|
201
|
+
boundary. The [Next compatibility report](docs/next-compatibility.md) records
|
|
202
|
+
the tested scaffold, native install, build and HTTP runtime. These checks cover
|
|
203
|
+
Linux x64; they do not establish universal framework or device support.
|
|
193
204
|
|
|
194
205
|
Other initializers control their own dependency-install step and may invoke
|
|
195
206
|
another package manager. Use their skip-install option, when available, then run
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v0.6.
|
|
1
|
+
v0.6.6
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAe,SAAS,EAAe,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAoB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAM3C,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEhF,eAAO,MAAM,uBAAuB,IAAI,CAAC;AA6DzC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAyBhD;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA6EF;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GACnD,SAAS,CAgDX;AAmBD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1C,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CACxC,CAAC;AAEF,gFAAgF;AAChF,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA8bpE"}
|
package/dist/cli/main.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runNextCommand } from "../commands/next.js";
|
|
1
2
|
import { createInstallProgress } from "./progress.js";
|
|
2
3
|
import { runMaintenanceCommand } from "../commands/maintenance.js";
|
|
3
4
|
import { runDeployCommand } from "../commands/deploy.js";
|
|
@@ -37,6 +38,7 @@ const NATIVE_COMMANDS = [
|
|
|
37
38
|
["exec", "Run an installed executable (never fetches)."],
|
|
38
39
|
["dlx", "Explicitly fetch and run a temporary tool environment."],
|
|
39
40
|
["create", "Scaffold from a create-* starter package."],
|
|
41
|
+
["next", "Explicitly configure Next Turbopack: next --turbopack."],
|
|
40
42
|
["list, why", "Show the installed graph / why a dependency is selected."],
|
|
41
43
|
["doctor", "Diagnose filesystem, links, policy, install-state issues."],
|
|
42
44
|
["approve-builds, rebuild", "Review script permissions / rebuild."],
|
|
@@ -58,6 +60,7 @@ for (const [names] of NATIVE_COMMANDS) {
|
|
|
58
60
|
const IMPLEMENTED_COMMANDS = new Set([
|
|
59
61
|
"dlx",
|
|
60
62
|
"create",
|
|
63
|
+
"next",
|
|
61
64
|
"install",
|
|
62
65
|
"i",
|
|
63
66
|
"add",
|
|
@@ -375,6 +378,30 @@ export async function runCli(options) {
|
|
|
375
378
|
return emit(fail(toZyrkError(error, `zyrk ${parsed.command} failed.`), parsed));
|
|
376
379
|
}
|
|
377
380
|
}
|
|
381
|
+
if (!parsed.help && !parsed.version && parsed.command === "next") {
|
|
382
|
+
try {
|
|
383
|
+
const result = await runNextCommand({
|
|
384
|
+
args: parsed.commandArgs,
|
|
385
|
+
cwd: options.cwd ?? process.cwd(),
|
|
386
|
+
env: options.env,
|
|
387
|
+
});
|
|
388
|
+
return emit({
|
|
389
|
+
exitCode: 0,
|
|
390
|
+
stdout: parsed.json
|
|
391
|
+
? JSON.stringify({
|
|
392
|
+
schemaVersion: CLI_JSON_SCHEMA_VERSION,
|
|
393
|
+
command: "next",
|
|
394
|
+
status: "ok",
|
|
395
|
+
...result,
|
|
396
|
+
}) + "\n"
|
|
397
|
+
: `${result.changed ? "Configured" : "Already configured"} Next Turbopack with the project's strict root and the installed external shared realizations. Experimental additional roots require Next.js 16.4+. Backup: ${result.backup}.\n`,
|
|
398
|
+
stderr: "",
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
return emit(fail(toZyrkError(error, "Next Turbopack configuration failed."), parsed));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
378
405
|
if (!parsed.help &&
|
|
379
406
|
!parsed.version &&
|
|
380
407
|
(parsed.command === "install" || parsed.command === "i")) {
|
|
@@ -621,7 +648,7 @@ async function runToolCommand(command, parsed, options, version) {
|
|
|
621
648
|
options.stderr.write(isNext
|
|
622
649
|
? tail.includes("--skip-install")
|
|
623
650
|
? "zyrk: Next scaffolding only; dependency installation was explicitly skipped.\n"
|
|
624
|
-
: "zyrk: Next
|
|
651
|
+
: "zyrk: Creating Next.js application; dependencies will install with zyrk.\n"
|
|
625
652
|
: "zyrk: This initializer controls its own dependency installation.\n");
|
|
626
653
|
const progress = createInstallProgress(options.stderr, false);
|
|
627
654
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/commands/next.ts"],"names":[],"mappings":"AAqFA,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAC5C,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA0LhE"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** Explicit Next.js configuration editing; ordinary installs never call this. */
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { chmod, copyFile, lstat, readFile, realpath, readdir, rm, writeFile, } from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { satisfies } from "semver";
|
|
6
|
+
import { findProjectBoundary, resolveStoreRoot } from "../config/paths.js";
|
|
7
|
+
import { ZyrkError } from "../errors.js";
|
|
8
|
+
import { lockedGraph } from "../install/lock.js";
|
|
9
|
+
import { selectPlatformGraph } from "../install/platform.js";
|
|
10
|
+
import { validateLockDoc } from "../lockfile/read.js";
|
|
11
|
+
import { manifestFingerprint } from "../lockfile/fingerprints.js";
|
|
12
|
+
import { Store } from "../store/layout.js";
|
|
13
|
+
import { createGraphDoc, contextIdFor } from "../store/graph.js";
|
|
14
|
+
import { packageDirIn, selectRealizationDirs } from "../store/realize.js";
|
|
15
|
+
import { verifyRealization } from "../store/verify.js";
|
|
16
|
+
import { acquireLock } from "../util/locks.js";
|
|
17
|
+
import { isErrno, writeFileAtomic } from "../util/fsx.js";
|
|
18
|
+
import { sha512Hex } from "../util/hash.js";
|
|
19
|
+
import { canonicalJson } from "../util/json.js";
|
|
20
|
+
const HELPER = "next.config.zyrk-turbopack.cjs";
|
|
21
|
+
const DECLARATION = "next.config.zyrk-turbopack.d.cts";
|
|
22
|
+
const MARKER = "// Managed by explicit zyrk next --turbopack; original configuration is preserved.\n";
|
|
23
|
+
const TYPES = "declare function withZyrkTurbopack<T>(configuration: T, projectDir: string): T;\nexport = withZyrkTurbopack;\n";
|
|
24
|
+
const RUNTIME = `// Local paths are discovered at Next startup, never committed into configuration.
|
|
25
|
+
const fs = require("node:fs");
|
|
26
|
+
const path = require("node:path");
|
|
27
|
+
const crypto = require("node:crypto");
|
|
28
|
+
const canonical = value => JSON.stringify(value && typeof value === "object" ? Array.isArray(value) ? value.map(v => JSON.parse(canonical(v))) : Object.fromEntries(Object.keys(value).sort().map(k => [k, JSON.parse(canonical(value[k]))])) : value);
|
|
29
|
+
const inside = (root, file) => { const relative = path.relative(root, file); return relative === "" || (!relative.startsWith(".." + path.sep) && relative !== ".." && !path.isAbsolute(relative)); };
|
|
30
|
+
module.exports = (configuration, directory) => async (phase, context) => {
|
|
31
|
+
if (process.platform === "win32") throw new Error("zyrk Turbopack Windows support has not passed its compatibility gate.");
|
|
32
|
+
const project = fs.realpathSync(directory);
|
|
33
|
+
const state = JSON.parse(fs.readFileSync(path.join(project, "node_modules/.zyrk/install-state.json"), "utf8"));
|
|
34
|
+
if (state.schemaVersion !== 1 || state.readiness !== "ready" || state.linker !== "shared" || typeof state.storeRoot !== "string" || !path.isAbsolute(state.storeRoot)) throw new Error("zyrk Turbopack requires a ready shared installation; run zyrk install.");
|
|
35
|
+
const lock = JSON.parse(fs.readFileSync(path.join(project, "package-lock.json"), "utf8"));
|
|
36
|
+
if (crypto.createHash("sha512").update(canonical(lock)).digest("hex") !== state.lockDigest) throw new Error("zyrk Turbopack installation and lock disagree; run zyrk install.");
|
|
37
|
+
const next = fs.realpathSync(path.join(project, "node_modules/next"));
|
|
38
|
+
const version = JSON.parse(fs.readFileSync(path.join(next, "package.json"), "utf8")).version;
|
|
39
|
+
if (typeof version !== "string" || !/^16\\.(?:[4-9]|[1-9][0-9]+)\\.[0-9]+$/.test(version)) throw new Error("zyrk Turbopack additional roots require stable Next.js 16.4.x through 16.x.");
|
|
40
|
+
const store = fs.realpathSync(path.join(state.storeRoot, "realizations"));
|
|
41
|
+
const direct = Array.isArray(state.direct) && state.direct.find(edge => edge.name === "next");
|
|
42
|
+
if (!direct || fs.realpathSync(direct.target) !== next || !inside(store, next) || inside(project, store) || inside(store, project)) throw new Error("zyrk Turbopack requires the recorded external shared dependency projection.");
|
|
43
|
+
const resolved = await (typeof configuration === "function" ? configuration(phase, context) : configuration);
|
|
44
|
+
if (!resolved || typeof resolved !== "object" || Array.isArray(resolved)) throw new Error("The original Next configuration must return an object.");
|
|
45
|
+
const roots = resolved.experimental?.turbopackAdditionalRoots || {};
|
|
46
|
+
if (roots.zyrkStore && fs.realpathSync(roots.zyrkStore.path) !== store) throw new Error("The existing zyrkStore Turbopack root conflicts with the installed store.");
|
|
47
|
+
return { ...resolved, turbopack: { ...resolved.turbopack, root: project }, experimental: { ...resolved.experimental, turbopackAdditionalRoots: { ...roots, zyrkStore: { path: store } } } };
|
|
48
|
+
};
|
|
49
|
+
`;
|
|
50
|
+
function denied(message) {
|
|
51
|
+
return new ZyrkError("ZYRK_USAGE", message, {
|
|
52
|
+
remedy: "Run zyrk next --turbopack in a ready shared Next.js 16.4+ project; restore or review existing configuration files before retrying.",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function regular(file) {
|
|
56
|
+
const info = await lstat(file);
|
|
57
|
+
if (!info.isFile() || info.isSymbolicLink())
|
|
58
|
+
throw denied("Next configuration editing requires regular files.");
|
|
59
|
+
}
|
|
60
|
+
function wrapper(name, esm) {
|
|
61
|
+
const original = name.replace(/\.(ts|mjs|js)$/, ".zyrk-original.$1");
|
|
62
|
+
if (!esm)
|
|
63
|
+
return `${MARKER}module.exports = require("./${HELPER}")(require("./${original}"), __dirname);\n`;
|
|
64
|
+
const importedOriginal = name.endsWith(".ts")
|
|
65
|
+
? original.slice(0, -3)
|
|
66
|
+
: original;
|
|
67
|
+
const directory = name.endsWith(".mjs") || name.endsWith(".js")
|
|
68
|
+
? 'fileURLToPath(new URL(".", import.meta.url))'
|
|
69
|
+
: "__dirname";
|
|
70
|
+
return `${MARKER}${directory === "__dirname" ? "" : 'import { fileURLToPath } from "node:url";\n'}import original from "./${importedOriginal}";\nimport withZyrkTurbopack from "./${HELPER}";\n\nexport default withZyrkTurbopack(original, ${directory});\n`;
|
|
71
|
+
}
|
|
72
|
+
export async function runNextCommand(options) {
|
|
73
|
+
if (process.platform === "win32")
|
|
74
|
+
throw new ZyrkError("ZYRK_PLATFORM_UNSUPPORTED", "Next Turbopack configuration is not verified on Windows.", {
|
|
75
|
+
remedy: "Use a platform with a verified zyrk store; Windows support remains gated.",
|
|
76
|
+
});
|
|
77
|
+
if (options.args.length !== 1 || options.args[0] !== "--turbopack")
|
|
78
|
+
throw denied("Next configuration editing requires the explicit --turbopack option.");
|
|
79
|
+
const boundary = await findProjectBoundary(options.cwd);
|
|
80
|
+
if (!boundary)
|
|
81
|
+
throw denied("Cannot find a Next project manifest.");
|
|
82
|
+
const project = await realpath(boundary);
|
|
83
|
+
const control = await lstat(path.join(project, ".zyrk-local"));
|
|
84
|
+
if (!control.isDirectory() || control.isSymbolicLink())
|
|
85
|
+
throw denied("Next project control directory is unsafe.");
|
|
86
|
+
const held = await acquireLock(path.join(project, ".zyrk-local/project.lock"), { name: "Next Turbopack configuration" });
|
|
87
|
+
try {
|
|
88
|
+
const state = JSON.parse(await readFile(path.join(project, "node_modules/.zyrk/install-state.json"), "utf8"));
|
|
89
|
+
const doc = validateLockDoc(JSON.parse(await readFile(path.join(project, "package-lock.json"), "utf8")), "project package-lock.json");
|
|
90
|
+
if (state.schemaVersion !== 1 ||
|
|
91
|
+
state.readiness !== "ready" ||
|
|
92
|
+
state.linker !== "shared" ||
|
|
93
|
+
state.lockDigest !== sha512Hex(canonicalJson(doc)))
|
|
94
|
+
throw denied("Next configuration requires a ready shared installation matching its lock.");
|
|
95
|
+
const manifest = JSON.parse(await readFile(path.join(project, "package.json"), "utf8"));
|
|
96
|
+
if (doc.zyrk?.manifest !== manifestFingerprint(manifest))
|
|
97
|
+
throw denied("The Next project manifest differs from its installed lock.");
|
|
98
|
+
const resolved = lockedGraph(doc);
|
|
99
|
+
const selected = selectPlatformGraph({
|
|
100
|
+
...resolved,
|
|
101
|
+
roots: resolved.roots.filter((root) => Array.isArray(state.direct) &&
|
|
102
|
+
state.direct.some((edge) => edge.name === root.name)),
|
|
103
|
+
}, new Set(Object.keys(doc.packages?.[""]?.optionalDependencies ?? {})));
|
|
104
|
+
const next = selected.nodes.find((node) => node.name === "next" &&
|
|
105
|
+
selected.roots.some((root) => root.name === "next" && root.target === node.key));
|
|
106
|
+
if (!next || !satisfies(next.version, ">=16.4.0 <17.0.0"))
|
|
107
|
+
throw denied("The additional-root adapter requires stable Next.js 16.4.x through 16.x.");
|
|
108
|
+
const store = await Store.open({
|
|
109
|
+
root: resolveStoreRoot({ env: options.env }).root,
|
|
110
|
+
});
|
|
111
|
+
store.requireInitialized();
|
|
112
|
+
if (state.storeRoot !== store.root)
|
|
113
|
+
throw denied("The installed Next store differs from the selected user store.");
|
|
114
|
+
const storeRealizations = await realpath(store.paths.realizationsDir);
|
|
115
|
+
const contains = (root, file) => {
|
|
116
|
+
const relative = path.relative(root, file);
|
|
117
|
+
return (relative === "" ||
|
|
118
|
+
(!relative.startsWith(".." + path.sep) &&
|
|
119
|
+
relative !== ".." &&
|
|
120
|
+
!path.isAbsolute(relative)));
|
|
121
|
+
};
|
|
122
|
+
if (contains(project, storeRealizations) ||
|
|
123
|
+
contains(storeRealizations, project))
|
|
124
|
+
throw denied("The Turbopack adapter requires shared realizations outside the project root.");
|
|
125
|
+
const graph = createGraphDoc(selected.nodes.map((node) => ({ ...node, deps: node.edges })));
|
|
126
|
+
const directories = selectRealizationDirs(store, graph);
|
|
127
|
+
await verifyRealization({
|
|
128
|
+
store,
|
|
129
|
+
graph,
|
|
130
|
+
rootKey: next.key,
|
|
131
|
+
contextId: contextIdFor(graph, next.key),
|
|
132
|
+
realizationDirs: directories,
|
|
133
|
+
});
|
|
134
|
+
if ((await realpath(path.join(project, "node_modules/next"))) !==
|
|
135
|
+
(await realpath(packageDirIn(directories.get(next.key), "next"))))
|
|
136
|
+
throw denied("The installed Next link differs from its verified context.");
|
|
137
|
+
const names = (await readdir(project)).filter((name) => ["next.config.ts", "next.config.js", "next.config.mjs"].includes(name));
|
|
138
|
+
if (names.length !== 1)
|
|
139
|
+
throw denied("Select a project with exactly one supported Next configuration file.");
|
|
140
|
+
const name = names[0];
|
|
141
|
+
const original = name.replace(/\.(ts|mjs|js)$/, ".zyrk-original.$1");
|
|
142
|
+
const target = path.join(project, name);
|
|
143
|
+
await regular(target);
|
|
144
|
+
const contents = await readFile(target, "utf8");
|
|
145
|
+
const generated = wrapper(name, name !== "next.config.js" || manifest.type === "module");
|
|
146
|
+
if (contents === generated) {
|
|
147
|
+
for (const file of [original, HELPER, DECLARATION])
|
|
148
|
+
await regular(path.join(project, file));
|
|
149
|
+
if ((await readFile(path.join(project, HELPER), "utf8")) !== RUNTIME ||
|
|
150
|
+
(await readFile(path.join(project, DECLARATION), "utf8")) !== TYPES)
|
|
151
|
+
throw denied("The existing Turbopack adapter was changed; review it before retrying.");
|
|
152
|
+
return { changed: false, config: name, backup: original };
|
|
153
|
+
}
|
|
154
|
+
const created = [];
|
|
155
|
+
let configWriteAttempted = false;
|
|
156
|
+
try {
|
|
157
|
+
await copyFile(target, path.join(project, original), constants.COPYFILE_EXCL);
|
|
158
|
+
created.push(original);
|
|
159
|
+
await chmod(path.join(project, original), 0o444);
|
|
160
|
+
for (const [file, text] of [
|
|
161
|
+
[HELPER, RUNTIME],
|
|
162
|
+
[DECLARATION, TYPES],
|
|
163
|
+
]) {
|
|
164
|
+
await writeFile(path.join(project, file), text, { flag: "wx" });
|
|
165
|
+
created.push(file);
|
|
166
|
+
}
|
|
167
|
+
configWriteAttempted = true;
|
|
168
|
+
await writeFileAtomic(target, generated);
|
|
169
|
+
}
|
|
170
|
+
catch (cause) {
|
|
171
|
+
// The atomic write may have renamed successfully before a durability
|
|
172
|
+
// error. Retain its dependencies and original backup for recovery.
|
|
173
|
+
if (!configWriteAttempted)
|
|
174
|
+
for (const file of created.reverse())
|
|
175
|
+
await rm(path.join(project, file)).catch(() => { });
|
|
176
|
+
if (isErrno(cause, "EEXIST"))
|
|
177
|
+
throw denied("A Next configuration backup or adapter already exists; no existing files were overwritten.");
|
|
178
|
+
throw cause;
|
|
179
|
+
}
|
|
180
|
+
return { changed: true, config: name, backup: original };
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
await held.release();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-display.d.ts","sourceRoot":"","sources":["../../src/dlx/next-display.ts"],"names":[],"mappings":"AAQA,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,IAAI,CAAC,CA8Cf"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** A display-only adaptation of verified create-next-app statement shapes.
|
|
2
|
+
* Official source: v16.4.2 create-app.ts and templates/index.ts. Installer
|
|
3
|
+
* selection and executable logic stay upstream; --skip-install keeps the
|
|
4
|
+
* native zyrk installation separate. Only the private initializer is edited.
|
|
5
|
+
*/
|
|
6
|
+
import { lstat, readFile, writeFile } from "node:fs/promises";
|
|
7
|
+
import { ZyrkError } from "../errors.js";
|
|
8
|
+
export async function adaptNextDisplay(script, version, skipInstall) {
|
|
9
|
+
const file = await lstat(script);
|
|
10
|
+
if (!file.isFile() || file.nlink !== 1 || (file.mode & 0o200) === 0)
|
|
11
|
+
throw new ZyrkError("ZYRK_INTERNAL", "Cannot adapt the Next initializer without an independent writable script.", {
|
|
12
|
+
remedy: "Retry with a private initializer generation; never make shared store files writable.",
|
|
13
|
+
});
|
|
14
|
+
const original = await readFile(script, "utf8");
|
|
15
|
+
// Match complete neighboring statements, not arbitrary output strings. Minifier
|
|
16
|
+
// variable names can vary; the verified statement structure must match once.
|
|
17
|
+
const header = /console\.log\(`Creating a new Next\.js app in \$\{\(0,([A-Za-z_$][\w$]*)\.green\)\(([A-Za-z_$][\w$]*)\)\}\.`\);console\.log\(\);process\.chdir\(\2\);/g;
|
|
18
|
+
const label = /console\.log\(\(0,([A-Za-z_$][\w$]*)\.bold\)\(`Using \$\{[A-Za-z_$][\w$]*\}\.`\)\);(?=console\.log\("\\nInitializing project with template:",[A-Za-z_$][\w$]*,"\\n"\);)/g;
|
|
19
|
+
const headers = [...original.matchAll(header)];
|
|
20
|
+
const labels = [...original.matchAll(label)];
|
|
21
|
+
if (headers.length !== 1 ||
|
|
22
|
+
labels.length !== 1 ||
|
|
23
|
+
headers[0][1] !== labels[0][1])
|
|
24
|
+
throw new ZyrkError("ZYRK_RESOLUTION_FAILED", "Cannot adapt the selected Next initializer: its display contract is unsupported.", {
|
|
25
|
+
detail: { package: "create-next-app", version },
|
|
26
|
+
remedy: "Select create-next-app@16.4.2 or report this version so its upstream display contract can be verified.",
|
|
27
|
+
});
|
|
28
|
+
const message = skipInstall
|
|
29
|
+
? "Scaffolding only; dependency installation skipped."
|
|
30
|
+
: "Using zyrk.";
|
|
31
|
+
const adapted = original
|
|
32
|
+
.replace(label, "")
|
|
33
|
+
.replace(header, (statement, color, target) => statement.slice(0, -`process.chdir(${target});`.length) +
|
|
34
|
+
`console.log((0,${color}.bold)(${JSON.stringify(message)}));console.log();process.chdir(${target});`);
|
|
35
|
+
await writeFile(script, adapted);
|
|
36
|
+
}
|
package/dist/dlx/next.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/dlx/next.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/dlx/next.ts"],"names":[],"mappings":"AASA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAkB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAuC3E,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAEtE;AA4CD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,UAAU,GAAG;IAAE,iBAAiB,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;CAAE,GACzE,OAAO,CAAC,SAAS,CAAC,CAoHpB"}
|
package/dist/dlx/next.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { lstat, readFile, readdir } from "node:fs/promises";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import { satisfies } from "semver";
|
|
8
|
+
import { adaptNextDisplay } from "./next-display.js";
|
|
8
9
|
import { ZyrkError } from "../errors.js";
|
|
9
10
|
import { installProject } from "../install/run.js";
|
|
10
11
|
import { isErrno } from "../util/fsx.js";
|
|
@@ -106,6 +107,11 @@ export async function runNextInitializer(options) {
|
|
|
106
107
|
throw failed("Next initializer target already has a project manifest.");
|
|
107
108
|
const entries = explicit === undefined ? new Set(await readdir(cwd)) : undefined;
|
|
108
109
|
const skipInstall = flags.has("--skip-install");
|
|
110
|
+
if (!skipInstall &&
|
|
111
|
+
[...flags].some((flag) => ["--use-npm", "--use-pnpm", "--use-yarn", "--use-bun"].includes(flag)))
|
|
112
|
+
throw new ZyrkError("ZYRK_USAGE", "Cannot select another dependency installer for zyrk create next-app.", {
|
|
113
|
+
remedy: "Remove --use-npm/--use-pnpm/--use-yarn/--use-bun to install with zyrk, or pass --skip-install to scaffold only.",
|
|
114
|
+
});
|
|
109
115
|
// Insert before -- so it remains an option when the user supplies a literal target.
|
|
110
116
|
const forwarded = [...args];
|
|
111
117
|
if (!skipInstall) {
|
|
@@ -123,7 +129,7 @@ export async function runNextInitializer(options) {
|
|
|
123
129
|
remedy: "Select create-next-app 15.x or 16.x; the native create adapter requires the verified --skip-install contract.",
|
|
124
130
|
});
|
|
125
131
|
},
|
|
126
|
-
});
|
|
132
|
+
}, async ({ script, version }) => adaptNextDisplay(script, version, skipInstall));
|
|
127
133
|
if (result.exitCode !== 0)
|
|
128
134
|
return result;
|
|
129
135
|
let directory = explicit;
|
package/dist/dlx/run.d.ts
CHANGED
|
@@ -57,5 +57,9 @@ export declare function splitDlxSpec(spec: string): {
|
|
|
57
57
|
export declare function runDlx(options: DlxOptions): Promise<DlxResult>;
|
|
58
58
|
/** Initializers copy and rewrite their shipped templates, so their full
|
|
59
59
|
* closure must use independent writable files (I-001, I-002, F-017). */
|
|
60
|
-
export declare function runInitializer(options: DlxOptions
|
|
60
|
+
export declare function runInitializer(options: DlxOptions, prepare?: (tool: {
|
|
61
|
+
script: string;
|
|
62
|
+
name: string;
|
|
63
|
+
version: string;
|
|
64
|
+
}) => Promise<void>): Promise<DlxResult>;
|
|
61
65
|
//# sourceMappingURL=run.d.ts.map
|
package/dist/dlx/run.d.ts.map
CHANGED
|
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ChB,iEAAiE;IACjE,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAqBA;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAEpE;AAED;wEACwE;AACxE,wBAAsB,cAAc,CAClC,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,KAAK,OAAO,CAAC,IAAI,CAAC,GAClB,OAAO,CAAC,SAAS,CAAC,CAEpB"}
|
package/dist/dlx/run.js
CHANGED
|
@@ -59,10 +59,10 @@ export async function runDlx(options) {
|
|
|
59
59
|
}
|
|
60
60
|
/** Initializers copy and rewrite their shipped templates, so their full
|
|
61
61
|
* closure must use independent writable files (I-001, I-002, F-017). */
|
|
62
|
-
export async function runInitializer(options) {
|
|
63
|
-
return runTemporaryTool(options, true);
|
|
62
|
+
export async function runInitializer(options, prepare) {
|
|
63
|
+
return runTemporaryTool(options, true, prepare);
|
|
64
64
|
}
|
|
65
|
-
async function runTemporaryTool(options, writable) {
|
|
65
|
+
async function runTemporaryTool(options, writable, prepare) {
|
|
66
66
|
const { store, registry } = options;
|
|
67
67
|
const args = options.args ?? [];
|
|
68
68
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -148,6 +148,7 @@ async function runTemporaryTool(options, writable) {
|
|
|
148
148
|
if (binTarget === undefined)
|
|
149
149
|
throw internal(`selected bin ${binKey} vanished`);
|
|
150
150
|
const script = await resolveBinScript(toolPkgDir, tool, binKey, binTarget);
|
|
151
|
+
await prepare?.({ script, name: tool.name, version: tool.version });
|
|
151
152
|
const bins = {};
|
|
152
153
|
for (const [name, target] of Object.entries(tool.bin)) {
|
|
153
154
|
bins[name] = await resolveBinScript(toolPkgDir, tool, name, target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/install/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAEhE,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AACjD,iFAAiF;AACjF,wBAAgB,cAAc,CAC5B,UAAU,EAAE,cAAc,CAAC,YAAY,CAAC,EACxC,KAAK,EAAE,MAAM;IAcX,WAAW,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/install/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAEhE,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AACjD,iFAAiF;AACjF,wBAAgB,cAAc,CAC5B,UAAU,EAAE,cAAc,CAAC,YAAY,CAAC,EACxC,KAAK,EAAE,MAAM;IAcX,WAAW,MAAM,OAAO,WAQP,MAAM;IAUvB,QAAQ,MAAM,OAAO,UAAU,QAAQ,GAAG,YAAY;EAMzD;AACD,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,UAAU,EAAE,cAAc,CAAC,YAAY,CAAC,EACxC,QAAQ,EAAE,SAAS,OAAO,EAAE,QAU7B"}
|
package/dist/install/progress.js
CHANGED
|
@@ -12,10 +12,20 @@ export function sourceProgress(onProgress, total) {
|
|
|
12
12
|
return {
|
|
13
13
|
downloading(pkg) {
|
|
14
14
|
let bytes = 0;
|
|
15
|
-
emit({
|
|
15
|
+
emit({
|
|
16
|
+
name: pkg.name,
|
|
17
|
+
version: pkg.version,
|
|
18
|
+
status: "downloading",
|
|
19
|
+
bytes,
|
|
20
|
+
});
|
|
16
21
|
return (chunk) => {
|
|
17
22
|
bytes += chunk;
|
|
18
|
-
emit({
|
|
23
|
+
emit({
|
|
24
|
+
name: pkg.name,
|
|
25
|
+
version: pkg.version,
|
|
26
|
+
status: "downloading",
|
|
27
|
+
bytes,
|
|
28
|
+
});
|
|
19
29
|
};
|
|
20
30
|
},
|
|
21
31
|
verified(pkg, status) {
|
|
@@ -23,7 +33,7 @@ export function sourceProgress(onProgress, total) {
|
|
|
23
33
|
reused++;
|
|
24
34
|
else
|
|
25
35
|
downloaded++;
|
|
26
|
-
emit({
|
|
36
|
+
emit({ name: pkg.name, version: pkg.version, status });
|
|
27
37
|
},
|
|
28
38
|
};
|
|
29
39
|
}
|