zyrk 0.6.5 → 0.6.7
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 +64 -17
- 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/fetch/registry.d.ts +8 -0
- package/dist/fetch/registry.d.ts.map +1 -1
- package/dist/fetch/registry.js +37 -3
- package/dist/install/budgets.d.ts +5 -0
- package/dist/install/budgets.d.ts.map +1 -1
- package/dist/install/budgets.js +11 -4
- package/dist/install/registry.d.ts.map +1 -1
- package/dist/install/registry.js +2 -0
- package/dist/install/run.d.ts.map +1 -1
- package/dist/install/run.js +4 -0
- package/dist/lockfile/write.d.ts.map +1 -1
- package/dist/lockfile/write.js +16 -0
- package/dist/resolve/resolver.d.ts +2 -1
- package/dist/resolve/resolver.d.ts.map +1 -1
- package/dist/resolve/resolver.js +33 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,6 +27,14 @@ the shared store, exact dependency context, mutation rules, and cleanup contract
|
|
|
27
27
|
central to its design. Storage savings, speed, and framework compatibility will
|
|
28
28
|
be reported only after reproducible measurements and compatibility tests.
|
|
29
29
|
|
|
30
|
+
### The name and the idea
|
|
31
|
+
|
|
32
|
+
The project began as **snpm**, short for “space-efficient npm.” That name was
|
|
33
|
+
already in use, so it became **nexu**; npm's package-name similarity policy
|
|
34
|
+
then blocked publishing that name, and the project became **zyrk**. The names
|
|
35
|
+
changed, while the goal stayed the same: make shared package storage practical,
|
|
36
|
+
careful, and useful in everyday Node.js development.
|
|
37
|
+
|
|
30
38
|
## Try the current CLI
|
|
31
39
|
|
|
32
40
|
Install from npm:
|
|
@@ -46,11 +54,17 @@ From a checkout:
|
|
|
46
54
|
```bash
|
|
47
55
|
git clone https://github.com/kingjethro999/zyrk.git zyrk
|
|
48
56
|
cd zyrk
|
|
49
|
-
npm
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
npm install --global zyrk@0.6.6
|
|
58
|
+
zyrk install --frozen-lockfile
|
|
59
|
+
zyrk --help
|
|
60
|
+
zyrk --version
|
|
52
61
|
```
|
|
53
62
|
|
|
63
|
+
The global npm install bootstraps the `zyrk` executable. Project dependencies
|
|
64
|
+
are installed by zyrk itself. On a fresh checkout, use the published bootstrap
|
|
65
|
+
version first because the source checkout's own development dependencies are
|
|
66
|
+
needed to run its local CLI.
|
|
67
|
+
|
|
54
68
|
### One-line install (shell)
|
|
55
69
|
|
|
56
70
|
Linux / macOS:
|
|
@@ -194,9 +208,13 @@ limited to one newly created direct child directory. If generation exits without
|
|
|
194
208
|
a valid manifest, zyrk reports failure and retains any generated files for review.
|
|
195
209
|
|
|
196
210
|
For Next.js 16.4.2 with dependencies in the external shared store, use
|
|
197
|
-
`zyrk run dev -- --webpack` and `zyrk run build -- --webpack
|
|
198
|
-
Turbopack
|
|
199
|
-
|
|
211
|
+
`zyrk run dev -- --webpack` and `zyrk run build -- --webpack`, or explicitly opt
|
|
212
|
+
into Turbopack with `zyrk next --turbopack` before normal `zyrk run dev` / build.
|
|
213
|
+
The [Turbopack guide](docs/next-turbopack.md) explains the experimental additional
|
|
214
|
+
roots, preserved configuration, portable local-state lookup, and deployment
|
|
215
|
+
boundary. The [Next compatibility report](docs/next-compatibility.md) records
|
|
216
|
+
the tested scaffold, native install, build and HTTP runtime. These checks cover
|
|
217
|
+
Linux x64; they do not establish universal framework or device support.
|
|
200
218
|
|
|
201
219
|
Other initializers control their own dependency-install step and may invoke
|
|
202
220
|
another package manager. Use their skip-install option, when available, then run
|
|
@@ -355,15 +373,25 @@ own options and configuration.
|
|
|
355
373
|
## Develop and contribute
|
|
356
374
|
|
|
357
375
|
```bash
|
|
358
|
-
npm
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
376
|
+
npm install --global zyrk@0.6.6 # bootstrap the CLI, once per machine
|
|
377
|
+
zyrk install --frozen-lockfile
|
|
378
|
+
zyrk run setup:hooks
|
|
379
|
+
zyrk run typecheck
|
|
380
|
+
zyrk run test
|
|
381
|
+
zyrk run check
|
|
382
|
+
zyrk run format:check
|
|
383
|
+
zyrk run format
|
|
365
384
|
```
|
|
366
385
|
|
|
386
|
+
Linux and macOS development, CI, and release verification use zyrk to install
|
|
387
|
+
the repository's dependencies. The Windows contract job continues to use npm
|
|
388
|
+
while native Windows filesystem and link behavior is being validated. npm is
|
|
389
|
+
also used to publish the package; that is a registry operation, not a project
|
|
390
|
+
dependency install. Vercel deployments should set the install command to
|
|
391
|
+
the commands in [web/vercel.json](web/vercel.json) and set the Vercel project
|
|
392
|
+
root directory to `web/`. The included site uses zyrk for project dependencies
|
|
393
|
+
after npm bootstraps the CLI.
|
|
394
|
+
|
|
367
395
|
The commit hook runs the full check gate, increments the version in
|
|
368
396
|
`package.json`, `package-lock.json`, and `VERSION`, and creates a matching version
|
|
369
397
|
tag after the commit. Keep changes focused and never bypass the hooks.
|
|
@@ -408,10 +436,29 @@ lists each unique package/version linked after the project transaction commits.
|
|
|
408
436
|
Source counts differ from dependency contexts when peers split a package.
|
|
409
437
|
`--json` disables progress.
|
|
410
438
|
|
|
411
|
-
Install resolution has a five-minute deadline
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
439
|
+
Install resolution has a five-minute deadline, registry requests (including
|
|
440
|
+
archive downloads) have a fifteen-minute deadline, a complete fetch operation
|
|
441
|
+
has a fifteen-minute deadline, and each archive extraction has a two-minute
|
|
442
|
+
deadline. On a slow or unreliable connection, increase the request and complete
|
|
443
|
+
fetch deadlines together. For example, this gives a single request up to 30
|
|
444
|
+
minutes and the entire fetch phase up to 45 minutes:
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
ZYRK_REQUEST_TIMEOUT_MS=1800000 ZYRK_FETCH_TIMEOUT_MS=2700000 zyrk install
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
To keep the settings for future commands in the current shell, use
|
|
451
|
+
`export ZYRK_REQUEST_TIMEOUT_MS=1800000` and
|
|
452
|
+
`export ZYRK_FETCH_TIMEOUT_MS=2700000`. Both values are milliseconds.
|
|
453
|
+
Resolution and extraction timeouts accept `1` to `900000` (15 minutes); request
|
|
454
|
+
and whole-fetch timeouts accept `1` to `3600000` (60 minutes). For a very slow
|
|
455
|
+
connection, the largest supported combination is:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
ZYRK_REQUEST_TIMEOUT_MS=3600000 ZYRK_FETCH_TIMEOUT_MS=3600000 zyrk install
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
These are finite deadlines; graph, archive-entry, and byte limits still apply.
|
|
415
462
|
|
|
416
463
|
Platform gates run the complete check on Ubuntu and macOS/Node 24 and a
|
|
417
464
|
Windows CLI/artifact contract suite, including paths with spaces and Unicode.
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v0.6.
|
|
1
|
+
v0.6.7
|
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",
|
|
@@ -97,7 +100,7 @@ export function helpText(version) {
|
|
|
97
100
|
}
|
|
98
101
|
lines.push("", "Registry publishing and account commands (via your npm):");
|
|
99
102
|
lines.push(...delegatedHelpLines());
|
|
100
|
-
lines.push("", "Install timeouts: ZYRK_RESOLVE_TIMEOUT_MS and ZYRK_EXTRACT_TIMEOUT_MS (1..900000 ms).", "zyrk never installs packages globally and never runs npm to do it.", "Need a global package? Run npm directly: npm install --global <package-spec>");
|
|
103
|
+
lines.push("", "Install timeouts: ZYRK_RESOLVE_TIMEOUT_MS and ZYRK_EXTRACT_TIMEOUT_MS (1..900000 ms); ZYRK_REQUEST_TIMEOUT_MS (1..3600000 ms); ZYRK_FETCH_TIMEOUT_MS (1..3600000 ms).", "zyrk never installs packages globally and never runs npm to do it.", "Need a global package? Run npm directly: npm install --global <package-spec>");
|
|
101
104
|
return `${lines.join("\n")}\n`;
|
|
102
105
|
}
|
|
103
106
|
function ok(stdout, parsed) {
|
|
@@ -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")) {
|
|
@@ -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
|
+
}
|
package/dist/fetch/registry.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ import type { Logger } from "../log.ts";
|
|
|
13
13
|
import { type HashedBytes } from "../util/integrity.ts";
|
|
14
14
|
/** 512 MiB: large for an npm package, small enough to bound mishaps. */
|
|
15
15
|
export declare const DEFAULT_MAX_TARBALL_BYTES: number;
|
|
16
|
+
/** Bounds the complete metadata closure while allowing large framework graphs. */
|
|
17
|
+
export declare const DEFAULT_MAX_TOTAL_METADATA_BYTES: number;
|
|
18
|
+
/** Fifteen minutes per registry operation, including archive transfer. */
|
|
19
|
+
export declare const DEFAULT_REQUEST_DEADLINE_MS = 900000;
|
|
16
20
|
/** Default registry for tool environments (SPEC 13.1). */
|
|
17
21
|
export declare const DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
18
22
|
export interface PackumentDist {
|
|
@@ -92,6 +96,10 @@ export declare class RegistryClient {
|
|
|
92
96
|
packument(name: string, options?: {
|
|
93
97
|
signal?: AbortSignal;
|
|
94
98
|
}): Promise<Packument>;
|
|
99
|
+
/** Fetch one exact version without transferring every release in a packument. */
|
|
100
|
+
versionManifest(name: string, version: string, options?: {
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
}): Promise<PackumentVersion>;
|
|
95
103
|
/** Registry advisory request; private names may never follow an external redirect. */
|
|
96
104
|
auditAdvisories(packages: Readonly<Record<string, readonly string[]>>, options?: {
|
|
97
105
|
signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/fetch/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAc9B,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,QAAoB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,gCAAgC,C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B,CACvC,IAAI,EAAE,aAAa,GAClB,MAAM,GAAG,SAAS,CAQpB;AAgDD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAqB9D"}
|
package/dist/fetch/registry.js
CHANGED
|
@@ -17,6 +17,10 @@ import { assertIntegrityOk, canonicalStrongSri, IntegrityHasher, base64FromHex,
|
|
|
17
17
|
const transport = createRequire(import.meta.url)("make-fetch-happen");
|
|
18
18
|
/** 512 MiB: large for an npm package, small enough to bound mishaps. */
|
|
19
19
|
export const DEFAULT_MAX_TARBALL_BYTES = 512 * 1024 * 1024;
|
|
20
|
+
/** Bounds the complete metadata closure while allowing large framework graphs. */
|
|
21
|
+
export const DEFAULT_MAX_TOTAL_METADATA_BYTES = 256 * 1024 * 1024;
|
|
22
|
+
/** Fifteen minutes per registry operation, including archive transfer. */
|
|
23
|
+
export const DEFAULT_REQUEST_DEADLINE_MS = 900_000;
|
|
20
24
|
/** Default registry for tool environments (SPEC 13.1). */
|
|
21
25
|
export const DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
22
26
|
/** npm's abbreviated packument media type, used for installs. */
|
|
@@ -66,9 +70,9 @@ export class RegistryClient {
|
|
|
66
70
|
(scope.pathname.startsWith(boundary.pathname) ||
|
|
67
71
|
boundary.pathname.startsWith(scope.pathname)));
|
|
68
72
|
this.#maxMetadataBytes = positiveLimit(options.maxMetadataBytes ?? 32 * 1024 * 1024, "maxMetadataBytes");
|
|
69
|
-
this.#maxTotalMetadataBytes = positiveLimit(options.maxTotalMetadataBytes ??
|
|
73
|
+
this.#maxTotalMetadataBytes = positiveLimit(options.maxTotalMetadataBytes ?? DEFAULT_MAX_TOTAL_METADATA_BYTES, "maxTotalMetadataBytes");
|
|
70
74
|
this.#maxMetadataVersions = positiveLimit(options.maxMetadataVersions ?? 100_000, "maxMetadataVersions");
|
|
71
|
-
this.#requestDeadlineMs = positiveLimit(options.requestDeadlineMs ??
|
|
75
|
+
this.#requestDeadlineMs = positiveLimit(options.requestDeadlineMs ?? DEFAULT_REQUEST_DEADLINE_MS, "requestDeadlineMs");
|
|
72
76
|
positiveLimit(this.#maxTarballBytes, "maxTarballBytes");
|
|
73
77
|
this.#signal = options.signal;
|
|
74
78
|
const { scopedRegistries, ...baseOptions } = options;
|
|
@@ -143,6 +147,33 @@ export class RegistryClient {
|
|
|
143
147
|
}
|
|
144
148
|
return validatePackument(raw, name, this.#origin, this.#maxMetadataVersions);
|
|
145
149
|
}
|
|
150
|
+
/** Fetch one exact version without transferring every release in a packument. */
|
|
151
|
+
async versionManifest(name, version, options = {}) {
|
|
152
|
+
const selected = this.forPackage(name);
|
|
153
|
+
if (selected !== this)
|
|
154
|
+
return selected.versionManifest(name, version, options);
|
|
155
|
+
const url = `${this.#registry}${escapePackageName(name)}/${encodeURIComponent(version)}`;
|
|
156
|
+
this.#logger?.debug("fetching exact version metadata", {
|
|
157
|
+
name,
|
|
158
|
+
version,
|
|
159
|
+
url,
|
|
160
|
+
});
|
|
161
|
+
let raw;
|
|
162
|
+
try {
|
|
163
|
+
raw = await this.#withRequest(url, `${INSTALL_V1_ACCEPT}, application/json`, (response) => this.#readMetadata(response), options.signal);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
throw mapFetchError(error, `fetch metadata for ${name}@${version}`);
|
|
167
|
+
}
|
|
168
|
+
const validated = validatePackument({ name, versions: { [version]: raw } }, name, this.#origin, 1);
|
|
169
|
+
const entry = validated.versions[version];
|
|
170
|
+
if (entry === undefined)
|
|
171
|
+
throw new ZyrkError("ZYRK_RESOLUTION_FAILED", `registry has no version ${version} of ${name}`, {
|
|
172
|
+
detail: { name, version },
|
|
173
|
+
remedy: "check the requested version exists in the configured registry",
|
|
174
|
+
});
|
|
175
|
+
return entry;
|
|
176
|
+
}
|
|
146
177
|
/** Registry advisory request; private names may never follow an external redirect. */
|
|
147
178
|
async auditAdvisories(packages, options = {}) {
|
|
148
179
|
for (const [name, versions] of Object.entries(packages)) {
|
|
@@ -414,7 +445,10 @@ export class RegistryClient {
|
|
|
414
445
|
throw resourceLimit("redirect count", 10, "registry redirect configuration");
|
|
415
446
|
}
|
|
416
447
|
catch (error) {
|
|
417
|
-
|
|
448
|
+
// A bounded body consumer can stop while the decoder still has source
|
|
449
|
+
// bytes arriving. Abort the transport before closing the exposed stream
|
|
450
|
+
// so compressed responses cannot write into a closed decompressor.
|
|
451
|
+
cancel();
|
|
418
452
|
if (timedOut || signals.some((source) => source.aborted))
|
|
419
453
|
throw resourceLimit("request deadline or cancellation", this.#requestDeadlineMs, "requestDeadlineMs");
|
|
420
454
|
throw error;
|
|
@@ -3,5 +3,10 @@ import type { ExtractionLimits } from "../extract/tarball.ts";
|
|
|
3
3
|
export declare function installBudgets(env: NodeJS.ProcessEnv): {
|
|
4
4
|
resolveBudget: Partial<ResolverLimits>;
|
|
5
5
|
extractBudget: Partial<ExtractionLimits>;
|
|
6
|
+
fetchBudget: {
|
|
7
|
+
deadlineMs: number;
|
|
8
|
+
};
|
|
6
9
|
};
|
|
10
|
+
/** Bound slow registry transfers while allowing large framework archives. */
|
|
11
|
+
export declare function registryRequestDeadline(env: NodeJS.ProcessEnv): number;
|
|
7
12
|
//# sourceMappingURL=budgets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budgets.d.ts","sourceRoot":"","sources":["../../src/install/budgets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"budgets.d.ts","sourceRoot":"","sources":["../../src/install/budgets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAyB9D,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG;IACtD,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACvC,aAAa,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACzC,WAAW,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,CAYA;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAEtE"}
|
package/dist/install/budgets.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** Public, bounded install timeout configuration. Node and byte limits stay intact. */
|
|
2
2
|
import { ZyrkError } from "../errors.js";
|
|
3
|
-
function timeout(env, key, fallback) {
|
|
3
|
+
function timeout(env, key, fallback, maximum = 900000) {
|
|
4
4
|
const raw = env[key];
|
|
5
5
|
if (raw === undefined)
|
|
6
6
|
return fallback;
|
|
7
7
|
if (!/^[0-9]+$/.test(raw) ||
|
|
8
8
|
!Number.isSafeInteger(Number(raw)) ||
|
|
9
9
|
Number(raw) < 1 ||
|
|
10
|
-
Number(raw) >
|
|
11
|
-
throw new ZyrkError("ZYRK_POLICY_DENIED", `Cannot configure install: ${key} must be an integer from 1 to
|
|
12
|
-
remedy: `Set ${key} to a timeout in milliseconds from 1 to
|
|
10
|
+
Number(raw) > maximum)
|
|
11
|
+
throw new ZyrkError("ZYRK_POLICY_DENIED", `Cannot configure install: ${key} must be an integer from 1 to ${maximum}.`, {
|
|
12
|
+
remedy: `Set ${key} to a timeout in milliseconds from 1 to ${maximum}, or unset it to use the default.`,
|
|
13
13
|
});
|
|
14
14
|
return Number(raw);
|
|
15
15
|
}
|
|
@@ -21,5 +21,12 @@ export function installBudgets(env) {
|
|
|
21
21
|
extractBudget: {
|
|
22
22
|
maxDurationMs: timeout(env, "ZYRK_EXTRACT_TIMEOUT_MS", 120000),
|
|
23
23
|
},
|
|
24
|
+
fetchBudget: {
|
|
25
|
+
deadlineMs: timeout(env, "ZYRK_FETCH_TIMEOUT_MS", 900000, 3600000),
|
|
26
|
+
},
|
|
24
27
|
};
|
|
25
28
|
}
|
|
29
|
+
/** Bound slow registry transfers while allowing large framework archives. */
|
|
30
|
+
export function registryRequestDeadline(env) {
|
|
31
|
+
return timeout(env, "ZYRK_REQUEST_TIMEOUT_MS", 900000, 3600000);
|
|
32
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/install/registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAoB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/install/registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAoB,MAAM,sBAAsB,CAAC;AAMxE,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,cAAc,CAAC,CAwI1B"}
|
package/dist/install/registry.js
CHANGED
|
@@ -8,6 +8,7 @@ import { RegistryClient, DEFAULT_REGISTRY } from "../fetch/registry.js";
|
|
|
8
8
|
import { isErrno } from "../util/fsx.js";
|
|
9
9
|
import { findProjectBoundary } from "../config/paths.js";
|
|
10
10
|
import { cleanUrl } from "./lock.js";
|
|
11
|
+
import { registryRequestDeadline } from "./budgets.js";
|
|
11
12
|
export async function installRegistry(options) {
|
|
12
13
|
let registry = DEFAULT_REGISTRY;
|
|
13
14
|
const auth = {};
|
|
@@ -97,6 +98,7 @@ export async function installRegistry(options) {
|
|
|
97
98
|
return new RegistryClient({
|
|
98
99
|
registry,
|
|
99
100
|
scopedRegistries,
|
|
101
|
+
requestDeadlineMs: registryRequestDeadline(options.env),
|
|
100
102
|
userAgent: `zyrk/${options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,SAAS,GACT,cAAc,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CAC3B,CAAC;AA4GF,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAsyBxB"}
|
package/dist/install/run.js
CHANGED
|
@@ -102,6 +102,7 @@ export async function installProject(options) {
|
|
|
102
102
|
...options,
|
|
103
103
|
resolveBudget: { ...budgets.resolveBudget, ...options.resolveBudget },
|
|
104
104
|
extractBudget: { ...budgets.extractBudget, ...options.extractBudget },
|
|
105
|
+
fetchBudget: { ...budgets.fetchBudget, ...options.fetchBudget },
|
|
105
106
|
};
|
|
106
107
|
if (await findWorkspaceRoot(options.projectDir)) {
|
|
107
108
|
const { installWorkspaceProject } = await import("./workspace-install.js");
|
|
@@ -272,6 +273,9 @@ export async function installProject(options) {
|
|
|
272
273
|
packument: (name) => options.registry.packument(name, {
|
|
273
274
|
signal: operation.operation.signal,
|
|
274
275
|
}),
|
|
276
|
+
versionManifest: (name, version) => options.registry.versionManifest(name, version, {
|
|
277
|
+
signal: operation.operation.signal,
|
|
278
|
+
}),
|
|
275
279
|
},
|
|
276
280
|
requirements: Object.entries(allDeps)
|
|
277
281
|
.map(([name, spec]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/lockfile/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,kBAA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BAAmB,GAAG;IAChC,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,mBAAmB,CAAC;IAChC,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACzB,CAAC;AAEF,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,CAAC,CAqPrB"}
|
package/dist/lockfile/write.js
CHANGED
|
@@ -94,7 +94,23 @@ export async function writeLockfile(options) {
|
|
|
94
94
|
: `npm:${target.name}@${target.version}`;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
const npmMetadata = {};
|
|
98
|
+
const existingEntry = existingPackages[location];
|
|
99
|
+
if (existingEntry !== undefined) {
|
|
100
|
+
for (const field of [
|
|
101
|
+
"license",
|
|
102
|
+
"funding",
|
|
103
|
+
"deprecated",
|
|
104
|
+
"hasInstallScript",
|
|
105
|
+
"inBundle",
|
|
106
|
+
]) {
|
|
107
|
+
if (Object.hasOwn(existingEntry, field)) {
|
|
108
|
+
npmMetadata[field] = existingEntry[field];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
97
112
|
packages[location] = {
|
|
113
|
+
...npmMetadata,
|
|
98
114
|
name: node.name,
|
|
99
115
|
version: node.version,
|
|
100
116
|
resolved: node.tarballUrl,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type Packument } from "../fetch/registry.ts";
|
|
1
|
+
import { type Packument, type PackumentVersion } from "../fetch/registry.ts";
|
|
2
2
|
import { type OverridePolicy } from "./overrides.ts";
|
|
3
3
|
export type MetadataProvider = {
|
|
4
4
|
readonly origin: string;
|
|
5
5
|
originFor?(name: string): string;
|
|
6
6
|
packument(name: string): Promise<Packument>;
|
|
7
|
+
versionManifest?(name: string, version: string): Promise<PackumentVersion>;
|
|
7
8
|
};
|
|
8
9
|
export type EdgeKind = "prod" | "optional" | "peer";
|
|
9
10
|
export type ResolvedEdge = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/resolve/resolver.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/resolve/resolver.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,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O,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAmCzB"}
|
package/dist/resolve/resolver.js
CHANGED
|
@@ -70,6 +70,7 @@ class ResolverState {
|
|
|
70
70
|
provider;
|
|
71
71
|
overrides;
|
|
72
72
|
packuments = new Map();
|
|
73
|
+
versionManifests = new Map();
|
|
73
74
|
peerless = new Map();
|
|
74
75
|
peerBearing = new Map();
|
|
75
76
|
freshPeers = new Map();
|
|
@@ -142,6 +143,23 @@ class ResolverState {
|
|
|
142
143
|
this.packuments.set(name, pending);
|
|
143
144
|
return pending;
|
|
144
145
|
}
|
|
146
|
+
versionManifestOf(name, version) {
|
|
147
|
+
const key = `${name}\0${version}`;
|
|
148
|
+
const cached = this.versionManifests.get(key);
|
|
149
|
+
if (cached !== undefined)
|
|
150
|
+
return cached;
|
|
151
|
+
this.checkBudget();
|
|
152
|
+
let timer;
|
|
153
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
154
|
+
timer = setTimeout(() => reject(budgetError("resolution deadline exceeded")), Math.max(1, this.expires - Date.now()));
|
|
155
|
+
});
|
|
156
|
+
const pending = Promise.race([
|
|
157
|
+
this.provider.versionManifest(name, version),
|
|
158
|
+
deadline,
|
|
159
|
+
]).finally(() => clearTimeout(timer));
|
|
160
|
+
this.versionManifests.set(key, pending);
|
|
161
|
+
return pending;
|
|
162
|
+
}
|
|
145
163
|
/**
|
|
146
164
|
* Build (or reuse) the occurrence for one dependency edge. Peerless
|
|
147
165
|
* packages share one occurrence per name@version; packages declaring
|
|
@@ -442,6 +460,21 @@ class ResolverState {
|
|
|
442
460
|
// Version selection
|
|
443
461
|
// ---------------------------------------------------------------------------
|
|
444
462
|
async function selectVersion(state, req) {
|
|
463
|
+
if (req.targetKind === "exact" && state.provider.versionManifest) {
|
|
464
|
+
try {
|
|
465
|
+
return {
|
|
466
|
+
version: req.targetSpec,
|
|
467
|
+
entry: await state.versionManifestOf(req.realName, req.targetSpec),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
// Registries and older test adapters may expose only packuments. Keep
|
|
472
|
+
// the optimization opportunistic when the exact endpoint is absent.
|
|
473
|
+
if (!(error instanceof ZyrkError) || error.detail?.status !== 404) {
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
445
478
|
const packument = await state.packumentOf(req.realName);
|
|
446
479
|
const fail = (message, remedy) => new ZyrkError("ZYRK_RESOLUTION_FAILED", message, {
|
|
447
480
|
detail: { name: req.realName, spec: req.targetSpec },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zyrk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Storage-efficient Node package manager: one verified store per user, shared across projects through links.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"version:bump": "node scripts/bump-version.js",
|
|
21
21
|
"setup:hooks": "git config core.hooksPath .githooks",
|
|
22
22
|
"build": "tsc -p tsconfig.build.json",
|
|
23
|
-
"prepublishOnly": "
|
|
23
|
+
"prepublishOnly": "node bin/zyrk.js run build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"make-fetch-happen": "16.0.1",
|