@_linked/cli 1.46.1 → 1.47.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/CHANGELOG.md +113 -0
- package/README.md +48 -36
- package/hooks/drift.cjs +169 -0
- package/hooks/git-hook.cjs +170 -0
- package/hooks/hook-shim.cjs +63 -0
- package/hooks/lock-at-rest.cjs +268 -0
- package/hooks/manifests.cjs +216 -0
- package/hooks/platform.cjs +25 -0
- package/lib/esm/app-release/build-backend.d.ts.map +1 -1
- package/lib/esm/app-release/build-backend.js +2 -1
- package/lib/esm/app-release/build-backend.js.map +1 -1
- package/lib/esm/cli-methods.d.ts.map +1 -1
- package/lib/esm/cli-methods.js +166 -150
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.js +20 -22
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/commands/build-app.d.ts.map +1 -1
- package/lib/esm/commands/build-app.js +2 -1
- package/lib/esm/commands/build-app.js.map +1 -1
- package/lib/esm/commands/build-package.d.ts.map +1 -1
- package/lib/esm/commands/build-package.js +6 -2
- package/lib/esm/commands/build-package.js.map +1 -1
- package/lib/esm/commands/localize.d.ts +9 -15
- package/lib/esm/commands/localize.d.ts.map +1 -1
- package/lib/esm/commands/localize.js +43 -74
- package/lib/esm/commands/localize.js.map +1 -1
- package/lib/esm/commands/setup-publish.d.ts.map +1 -1
- package/lib/esm/commands/setup-publish.js +22 -15
- package/lib/esm/commands/setup-publish.js.map +1 -1
- package/lib/esm/commands/start.d.ts +8 -0
- package/lib/esm/commands/start.d.ts.map +1 -1
- package/lib/esm/commands/start.js +20 -8
- package/lib/esm/commands/start.js.map +1 -1
- package/lib/esm/installed-packages.d.ts +5 -13
- package/lib/esm/installed-packages.d.ts.map +1 -1
- package/lib/esm/installed-packages.js +5 -38
- package/lib/esm/installed-packages.js.map +1 -1
- package/lib/esm/lifecycle.d.ts +35 -22
- package/lib/esm/lifecycle.d.ts.map +1 -1
- package/lib/esm/lifecycle.js +62 -36
- package/lib/esm/lifecycle.js.map +1 -1
- package/lib/esm/localize/adopt.d.ts +5 -5
- package/lib/esm/localize/adopt.d.ts.map +1 -1
- package/lib/esm/localize/adopt.js +46 -55
- package/lib/esm/localize/adopt.js.map +1 -1
- package/lib/esm/localize/app-root.d.ts +16 -0
- package/lib/esm/localize/app-root.d.ts.map +1 -0
- package/lib/esm/localize/app-root.js +94 -0
- package/lib/esm/localize/app-root.js.map +1 -0
- package/lib/esm/localize/app-setup.d.ts +21 -0
- package/lib/esm/localize/app-setup.d.ts.map +1 -0
- package/lib/esm/localize/app-setup.js +178 -0
- package/lib/esm/localize/app-setup.js.map +1 -0
- package/lib/esm/localize/delocalize.d.ts.map +1 -1
- package/lib/esm/localize/delocalize.js +169 -104
- package/lib/esm/localize/delocalize.js.map +1 -1
- package/lib/esm/localize/drift-hook.d.ts +18 -0
- package/lib/esm/localize/drift-hook.d.ts.map +1 -0
- package/lib/esm/localize/drift-hook.js +37 -0
- package/lib/esm/localize/drift-hook.js.map +1 -0
- package/lib/esm/localize/drift.d.ts +36 -0
- package/lib/esm/localize/drift.d.ts.map +1 -0
- package/lib/esm/localize/drift.js +34 -0
- package/lib/esm/localize/drift.js.map +1 -0
- package/lib/esm/localize/errors.d.ts +14 -8
- package/lib/esm/localize/errors.d.ts.map +1 -1
- package/lib/esm/localize/errors.js +14 -8
- package/lib/esm/localize/errors.js.map +1 -1
- package/lib/esm/localize/fsops.d.ts +11 -27
- package/lib/esm/localize/fsops.d.ts.map +1 -1
- package/lib/esm/localize/fsops.js +40 -115
- package/lib/esm/localize/fsops.js.map +1 -1
- package/lib/esm/localize/git-hooks.d.ts +33 -0
- package/lib/esm/localize/git-hooks.d.ts.map +1 -0
- package/lib/esm/localize/git-hooks.js +146 -0
- package/lib/esm/localize/git-hooks.js.map +1 -0
- package/lib/esm/localize/hook-module.d.ts +6 -0
- package/lib/esm/localize/hook-module.d.ts.map +1 -0
- package/lib/esm/localize/hook-module.js +37 -0
- package/lib/esm/localize/hook-module.js.map +1 -0
- package/lib/esm/localize/index.d.ts +14 -15
- package/lib/esm/localize/index.d.ts.map +1 -1
- package/lib/esm/localize/index.js +8 -9
- package/lib/esm/localize/index.js.map +1 -1
- package/lib/esm/localize/list.d.ts +6 -10
- package/lib/esm/localize/list.d.ts.map +1 -1
- package/lib/esm/localize/list.js +49 -189
- package/lib/esm/localize/list.js.map +1 -1
- package/lib/esm/localize/localize.d.ts +46 -62
- package/lib/esm/localize/localize.d.ts.map +1 -1
- package/lib/esm/localize/localize.js +411 -285
- package/lib/esm/localize/localize.js.map +1 -1
- package/lib/esm/localize/members.d.ts +13 -0
- package/lib/esm/localize/members.d.ts.map +1 -0
- package/lib/esm/localize/members.js +46 -0
- package/lib/esm/localize/members.js.map +1 -0
- package/lib/esm/localize/resolve.d.ts +1 -2
- package/lib/esm/localize/resolve.d.ts.map +1 -1
- package/lib/esm/localize/resolve.js +3 -5
- package/lib/esm/localize/resolve.js.map +1 -1
- package/lib/esm/localize/run.d.ts +1 -0
- package/lib/esm/localize/run.d.ts.map +1 -1
- package/lib/esm/localize/run.js +11 -6
- package/lib/esm/localize/run.js.map +1 -1
- package/lib/esm/localize/setup-lockfile.d.ts +13 -0
- package/lib/esm/localize/setup-lockfile.d.ts.map +1 -0
- package/lib/esm/localize/setup-lockfile.js +80 -0
- package/lib/esm/localize/setup-lockfile.js.map +1 -0
- package/lib/esm/utils/createPackageLocation.d.ts +4 -13
- package/lib/esm/utils/createPackageLocation.d.ts.map +1 -1
- package/lib/esm/utils/createPackageLocation.js +12 -21
- package/lib/esm/utils/createPackageLocation.js.map +1 -1
- package/lib/esm/utils/packageSetup.d.ts +5 -2
- package/lib/esm/utils/packageSetup.d.ts.map +1 -1
- package/lib/esm/utils/packageSetup.js +9 -3
- package/lib/esm/utils/packageSetup.js.map +1 -1
- package/lib/esm/utils/platform.d.ts +24 -0
- package/lib/esm/utils/platform.d.ts.map +1 -0
- package/lib/esm/utils/platform.js +62 -0
- package/lib/esm/utils/platform.js.map +1 -0
- package/lib/esm/utils/shapeReferences.d.ts.map +1 -1
- package/lib/esm/utils/shapeReferences.js +3 -2
- package/lib/esm/utils/shapeReferences.js.map +1 -1
- package/lib/esm/utils/spawn.d.ts +65 -0
- package/lib/esm/utils/spawn.d.ts.map +1 -0
- package/lib/esm/utils/spawn.js +181 -0
- package/lib/esm/utils/spawn.js.map +1 -0
- package/lib/esm/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +19 -5
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/vite-config.d.ts +5 -12
- package/lib/esm/vite-config.d.ts.map +1 -1
- package/lib/esm/vite-config.js +41 -33
- package/lib/esm/vite-config.js.map +1 -1
- package/package.json +4 -3
- package/lib/esm/localize/ensure.d.ts +0 -44
- package/lib/esm/localize/ensure.d.ts.map +0 -1
- package/lib/esm/localize/ensure.js +0 -151
- package/lib/esm/localize/ensure.js.map +0 -1
- package/lib/esm/localize/manifest.d.ts +0 -63
- package/lib/esm/localize/manifest.d.ts.map +0 -1
- package/lib/esm/localize/manifest.js +0 -133
- package/lib/esm/localize/manifest.js.map +0 -1
- package/lib/esm/localize/one-copy-hook.d.ts +0 -16
- package/lib/esm/localize/one-copy-hook.d.ts.map +0 -1
- package/lib/esm/localize/one-copy-hook.js +0 -20
- package/lib/esm/localize/one-copy-hook.js.map +0 -1
- package/lib/esm/localize/provided.d.ts +0 -28
- package/lib/esm/localize/provided.d.ts.map +0 -1
- package/lib/esm/localize/provided.js +0 -89
- package/lib/esm/localize/provided.js.map +0 -1
- package/lib/esm/localize/prune.d.ts +0 -165
- package/lib/esm/localize/prune.d.ts.map +0 -1
- package/lib/esm/localize/prune.js +0 -619
- package/lib/esm/localize/prune.js.map +0 -1
- package/lib/esm/localize/relink.d.ts +0 -13
- package/lib/esm/localize/relink.d.ts.map +0 -1
- package/lib/esm/localize/relink.js +0 -179
- package/lib/esm/localize/relink.js.map +0 -1
- package/lib/esm/localized-dedupe.d.ts +0 -26
- package/lib/esm/localized-dedupe.d.ts.map +0 -1
- package/lib/esm/localized-dedupe.js +0 -139
- package/lib/esm/localized-dedupe.js.map +0 -1
- package/lib/esm/utils/relinkHooks.d.ts +0 -19
- package/lib/esm/utils/relinkHooks.d.ts.map +0 -1
- package/lib/esm/utils/relinkHooks.js +0 -74
- package/lib/esm/utils/relinkHooks.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../src/localize/prune.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACzD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AA0B/C,6FAA6F;AAC7F,MAAM,UAAU,aAAa,CAC3B,OAAsC,EACtC,IAA2B;IAE3B,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,OAAO;QACL,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACxD,OAAO,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,KAA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AAC;QAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAAE,SAAS;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACxD,IAAI,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;YAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE,EAAE,GAAG;IAC/B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM;YAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;IAAC,WAAM,CAAC;QACP,kBAAkB;IACpB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC","sourcesContent":["/**\n * Pruning -- stop a checkout's own `node_modules` holding a second copy of\n * something the app already provides. On by default after every install in a\n * checkout and on every `--relink`; `--no-prune` (`{prune: false}`) skips it.\n *\n * `shouldPrune(opts)` is the one place that default lives.\n *\n * Why it is needed. `npm install` inside a checkout (localize.ts, step 3)\n * installs what the CHECKOUT's lockfile says: its own copy of every\n * dependency, often older than the app's. Node resolves a module from the\n * importer's REAL path and takes the first `node_modules` it meets going up,\n * so a localized `A` that imports `B` gets `A/node_modules/B` -- a registry\n * copy -- and never the localized `B`; and a framework package that holds a\n * registry of classes (or React) loads once per copy. Measured with three\n * localized `@_linked/*` packages: plain Node and `tsx` loaded three copies of\n * the same core.\n *\n * What it does. For every localized checkout, each package at the top of its\n * `node_modules` that is a CANDIDATE in that checkout (below) is removed when\n * the app provides it -- `<appRoot>/node_modules/<name>` exists -- at a\n * version that satisfies every range that resolves to that copy: the\n * checkout's own declaration and that of every installed package that would\n * load it. Node's upward search then finds the app's copy instead. Nothing\n * else in the checkout moves.\n *\n * The candidates start from `providedPackages` (provided.ts) -- the one rule\n * the run-time check and Vite's dedupe use too -- and are taken PER CHECKOUT:\n *\n * - a **localized sibling** -- always counts as provided, whatever the range,\n * because the live checkout is the point of localizing it. A range it does\n * not satisfy is said out loud, never acted on;\n * - one of **this checkout's own runtime dependencies** (`dependencies`,\n * `peerDependencies`, `optionalDependencies`) that the rule provides -- the\n * app has it at a version satisfying every localized checkout's range;\n * - `react` and `react-dom`.\n *\n * Nothing else is touched -- this checkout's devDependency stays even when\n * another checkout depends on the same package at runtime, so the checkout's\n * tooling does not come to depend on the app's. A runtime dependency the rule\n * leaves out because a localized range misses the app's version is kept and\n * reported, like any other copy kept below.\n *\n * Never removed, candidate or not:\n *\n * - a copy whose ranges the app's version does not satisfy;\n * - a copy whose own dependencies would resolve to something else from the\n * app's copy than they do from the checkout (`contextChange` below): the\n * checkout keeps its own copies of whatever failed the guard, and removing\n * the copy would mix the two -- measured as a checkout's `tsc` seeing two\n * React type sets;\n * - anything in a checkout that is not under the app root, because then the\n * upward search never reaches the app's `node_modules` and the removed\n * package would simply be missing;\n * - anything in a checkout recorded with `prune: false` (localized with\n * `--no-prune`).\n *\n * Kept copies are reported once per checkout, as a summary; `--list` gives\n * each one's reason. A removal can make another copy removable, so a prune\n * repeats until a pass removes nothing.\n *\n * A package with a `bin` is NOT exempt. Measured in a checkout under an app\n * root with its own `@_linked/cli` removed: `npx linked build`,\n * `npm exec linked -- --help`, a script running `npm exec linked` and a script\n * running a bare `linked` all resolved `linked` to the app root's copy,\n * because npm puts every ancestor's `node_modules/.bin` on the PATH. The\n * removed package's links in the checkout's `node_modules/.bin` are removed\n * with it, so nothing dangles.\n *\n * It never runs npm and never touches the checkout's `package.json` or\n * `package-lock.json`. `npm install` in the checkout puts the copies back;\n * `ensure` (ensure.ts) is the install-then-prune step every in-checkout\n * install goes through, and the run-time check (`checkOneCopy`) takes them out\n * again before `linked start` and friends.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {isInside, isSymlink, readJson} from './fsops.js';\nimport semver from 'semver';\nimport {providedPackages} from './provided.js';\nimport type {ProvidedSkip} from './provided.js';\n\nimport type {ManifestEntry} from './manifest.js';\nimport type {Deps} from './run.js';\n\n/** What pruning reads from a command's options. */\nexport interface PruneOptions {\n /** On unless explicitly false. */\n prune?: boolean;\n}\n\n/** Limit a prune to some checkouts and/or some dependency names. */\nexport interface PruneScope {\n /** Only these localized packages' checkouts. */\n owners?: string[];\n /** Only these dependency names (the first pass; later passes take every candidate of `owners`). */\n deps?: string[];\n}\n\n/** The rule's names (every localized sibling among them) and what the rule skipped. */\nexport interface Candidates {\n names: Set<string>;\n skipped: Map<string, ProvidedSkip>;\n}\n\n/** The rule (`providedPackages`, provided.ts) over `entries`, plus every entry (sibling). */\nexport function candidatesFor(\n entries: Record<string, ManifestEntry>,\n deps: Pick<Deps, 'appRoot'>,\n): Candidates {\n const rule = providedPackages(deps.appRoot, Object.keys(entries));\n return {\n names: new Set([...rule.names, ...Object.keys(entries)]),\n skipped: new Map(rule.skipped.map((s) => [s.name, s])),\n };\n}\n\n/**\n * Does the app's installed `version` satisfy `range`? `null` means \"cannot\n * tell\" -- a dist-tag, `file:`, `npm:`, `workspace:`, a git URL, or a version\n * that is not one -- and every caller then keeps the copy. The failure mode is\n * therefore always the safe one: a copy kept that could have gone, never a\n * copy removed that was needed.\n *\n * npm's own `semver` decides, so prereleases follow npm's rule: `1.3.0-beta.1`\n * satisfies a range only when one of its comparators names a prerelease on\n * the same `major.minor.patch`.\n */\nexport function satisfies(version: string, range: string): boolean | null {\n if (typeof version !== 'string' || typeof range !== 'string') return null;\n if (semver.valid(version) === null) return null;\n if (semver.validRange(range) === null) return null;\n return semver.satisfies(version, range);\n}\n\n/** Pruning is on unless a caller says `{prune: false}`. */\nexport function shouldPrune(opts: PruneOptions = {}): boolean {\n return opts.prune !== false;\n}\n\n/** Is pruning on for this recorded checkout? `--no-prune` at localize/adopt records `prune: false`. */\nexport function prunesEntry(entry: Pick<ManifestEntry, 'prune'>): boolean {\n return entry.prune !== false;\n}\n\nconst REQUIRE_FIELDS = [\n 'dependencies',\n 'peerDependencies',\n 'optionalDependencies',\n];\nconst DECLARE_FIELDS = [\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n];\n/** Candidates in every checkout, declared or not: a second React breaks hooks whoever loads it. */\nconst ALWAYS_CANDIDATES = new Set(['react', 'react-dom']);\n/** prune repeats until a pass removes nothing, at most this many passes. */\nexport const MAX_PRUNE_PASSES = 5;\n\n/** A range that resolves to a copy: who asks, and what. */\ninterface Ask {\n from: string;\n range: string;\n}\n\n/** One copy in a checkout's `node_modules`, and what pruning decides about it. */\nexport interface PruneDecision {\n /** The localized package whose checkout holds the copy. */\n ownerName: string;\n /** Its checkout, relative to the app root. */\n owner: string;\n dep: string;\n /** `<nm>/<dep>`, absolute. */\n dir: string;\n /** `dir` relative to the app root. */\n where: string;\n nm: string;\n version: string;\n /** The app's version. */\n app: string;\n sibling: boolean;\n action: 'remove' | 'keep';\n /**\n * Why a copy stays: `range` -- a range that loads it is one the app's\n * version misses (or one that cannot be read); `context` -- removing it\n * would change what its own dependencies resolve to.\n */\n reason?: 'range' | 'context';\n /** The ranges the app's version does not satisfy (`range`), or a sibling's drift (`remove`). */\n unmet: Ask[];\n /** `context`: the dependency that would resolve elsewhere, and both versions. */\n context?: {dep: string; here: string; app: string | null};\n}\n\n/** What a plan found, without touching anything. */\nexport interface PrunePlan {\n remove: PruneDecision[];\n keep: PruneDecision[];\n /** Checkouts left alone because they are not under the app root. */\n outside: {name: string; path: string}[];\n}\n\n/**\n * Per-call caches: a requirement index per `node_modules` (built once, see\n * `RequirementIndex`) and the package.json files read along the way.\n */\nexport interface PruneCache {\n indexes: Map<string, RequirementIndex>;\n /** How many indexes were built -- each is one read of a whole tree. */\n builds: number;\n}\n\nexport function newPruneCache(): PruneCache {\n return {indexes: new Map(), builds: 0};\n}\n\n/**\n * Decide, for every recorded checkout and every candidate copy in its\n * `node_modules`, whether pruning removes it -- without removing anything.\n * `pruneProvided` applies it; the run-time check (`checkOneCopy`) and\n * `--list` call it on its own, which is why it has to be cheap: a copy whose\n * checkout's own range rules it out is decided from that `package.json`\n * alone, and every other range comes from one requirement index per\n * `node_modules`, built at most once per call.\n *\n * Candidates are PER OWNER: a copy is a candidate in checkout O when the rule\n * provides it AND it is a localized sibling, `react`/`react-dom`, or one of\n * O's own runtime dependencies (`dependencies`, `peerDependencies`,\n * `optionalDependencies`). O's devDependencies are O's tooling, whatever\n * another checkout declares at runtime.\n */\nexport function planPrune(\n entries: Record<string, ManifestEntry>,\n deps: Pick<Deps, 'appRoot'>,\n scope: PruneScope = {},\n cache: PruneCache = newPruneCache(),\n candidates: Candidates = candidatesFor(entries, deps),\n): PrunePlan {\n const plan: PrunePlan = {remove: [], keep: [], outside: []};\n const appRoot = realOrSelf(deps.appRoot);\n const only = scope.deps ? new Set(scope.deps) : null;\n\n for (const [name, entry] of Object.entries(entries)) {\n if (scope.owners && !scope.owners.includes(name)) continue;\n if (!prunesEntry(entry)) continue;\n const pkgDir = path.join(deps.appRoot, entry.path);\n if (!fs.existsSync(path.join(pkgDir, 'package.json'))) continue;\n if (!isInside(realOrSelf(pkgDir), appRoot)) {\n plan.outside.push({name, path: entry.path});\n continue;\n }\n const pkg = readJson(path.join(pkgDir, 'package.json')) ?? {};\n const runtime = new Set(\n REQUIRE_FIELDS.flatMap((f) => Object.keys(pkg[f] ?? {})),\n );\n // The names that can be a decision here, looked up directly rather than\n // by listing node_modules (thousands of entries per checkout): this\n // checkout's candidates, and what the rule skipped that it declares.\n const names = new Set<string>();\n for (const n of candidates.names) {\n if (entries[n] || ALWAYS_CANDIDATES.has(n) || runtime.has(n))\n names.add(n);\n }\n for (const n of candidates.skipped.keys()) {\n if (declared(pkg, DECLARE_FIELDS, n) !== undefined) names.add(n);\n }\n names.delete(name);\n const ctx = {name, entry, pkg, names, entries, candidates, only, deps};\n for (const nm of nodeModulesRoots(pkgDir, entry)) {\n for (const d of decideIn(nm, ctx, cache)) {\n (d.action === 'remove' ? plan.remove : plan.keep).push(d);\n }\n }\n }\n return plan;\n}\n\n/**\n * @param entries the localized packages: every one counts as a sibling\n * @param opts unused beyond `prune`, which callers check with `shouldPrune`\n * @param deps `{appRoot, log, warn}`\n * @param scope prune only some checkouts / names (the run-time check)\n *\n * A removal can make another copy removable -- the copy that went was the one\n * asking a range the app misses, or the one a sibling copy's dependency\n * resolved to -- so it plans and removes again until a pass removes nothing\n * (at most `MAX_PRUNE_PASSES`): one call converges. A checkout recorded with\n * `prune: false` is never touched.\n */\nexport function pruneProvided(\n entries: Record<string, ManifestEntry>,\n opts: PruneOptions,\n deps: Pick<Deps, 'appRoot' | 'log' | 'warn'>,\n scope: PruneScope = {},\n cache: PruneCache = newPruneCache(),\n): {removed: PruneDecision[]; kept: PruneDecision[]} {\n const removed: PruneDecision[] = [];\n let kept: PruneDecision[] = [];\n const candidates = candidatesFor(entries, deps);\n\n for (let pass = 0; pass < MAX_PRUNE_PASSES; pass++) {\n const passScope = pass === 0 ? scope : {owners: scope.owners};\n const plan = planPrune(entries, deps, passScope, cache, candidates);\n if (pass === 0) {\n for (const o of plan.outside) {\n deps.log(\n `[localize] ${o.name}: ${o.path} is outside the app root, so Node cannot reach the app's ` +\n `node_modules from it — its own dependencies are left as they are.`,\n );\n }\n }\n for (const d of plan.remove) {\n fs.rmSync(d.dir, {recursive: true, force: true});\n removeEmptyScope(d.nm, d.dep);\n removeBinLinksInto(d.nm, d.dir);\n removed.push(d);\n }\n kept = plan.keep;\n if (!plan.remove.length) break;\n }\n\n report(removed, kept, deps);\n return {removed, kept};\n}\n\n/**\n * Is `dep` -- declared by a checkout at `range` -- something the app provides,\n * so that its absence from the checkout's own `node_modules` is not a\n * dependency gone missing? `--relink` asks this before reinstalling a\n * checkout, so a copy pruned on purpose does not trigger a reinstall on every\n * postinstall. `pkg` is the checkout's `package.json`: only what would be a\n * candidate in THAT checkout counts.\n */\nexport function isProvidedByApp(\n dep: string,\n range: string | undefined,\n entries: Record<string, ManifestEntry>,\n candidates: Candidates,\n deps: Pick<Deps, 'appRoot'>,\n pkg?: any,\n): boolean {\n const app = appCopy(dep, deps);\n if (!app) return false;\n if (entries[dep]) return true;\n if (!candidates.names.has(dep)) return false;\n if (\n pkg &&\n !ALWAYS_CANDIDATES.has(dep) &&\n declared(pkg, REQUIRE_FIELDS, dep) === undefined\n )\n return false;\n return range === undefined || satisfies(app.version, range) === true;\n}\n\nfunction decideIn(nm: string, ctx, cache: PruneCache): PruneDecision[] {\n const out: PruneDecision[] = [];\n const {name: owner, entry, pkg, names, entries, candidates, only, deps} = ctx;\n\n for (const dep of [...names].sort()) {\n if (only && !only.has(dep)) continue;\n const skip = candidates.skipped.get(dep);\n const inRule = candidates.names.has(dep);\n const sibling = Boolean(entries[dep]);\n const dir = path.join(nm, dep);\n const nested = readJson(path.join(dir, 'package.json'));\n if (!nested) continue;\n const app = appCopy(dep, deps);\n if (!app) continue; // the app does not provide it, so this copy is the only one\n if (realOrSelf(dir) === app.real) continue; // already the app's copy\n\n const base = {\n ownerName: owner,\n owner: entry.path,\n dep,\n dir,\n where: path.relative(deps.appRoot, dir),\n nm,\n version: nested.version,\n app: app.version,\n sibling,\n };\n\n if (!inRule) {\n // The rule leaves it out: a localized checkout asks a range the app\n // misses. Said for a checkout that declares it; a copy it only has\n // transitively is none of its business.\n if (declared(pkg, DECLARE_FIELDS, dep) === undefined) continue;\n out.push({...base, action: 'keep', reason: 'range', unmet: skip!.asks});\n continue;\n }\n\n const own = declared(pkg, DECLARE_FIELDS, dep);\n const ownAsk = own === undefined ? [] : [{from: owner, range: own}];\n if (sibling) {\n // Always removed: the live checkout is the point of localizing it. A\n // range it misses is drift, said out loud and never acted on.\n const ranges = [...ownAsk, ...requirementIndex(nm, cache).asks(dep)];\n out.push({\n ...base,\n action: 'remove',\n unmet: ranges.filter((r) => satisfies(app.version, r.range) === false),\n });\n continue;\n }\n\n // The checkout's own range first: when it rules the copy out, no index is needed.\n if (own !== undefined && satisfies(app.version, own) !== true) {\n out.push({...base, action: 'keep', reason: 'range', unmet: ownAsk});\n continue;\n }\n const unmet = requirementIndex(nm, cache)\n .asks(dep)\n .filter((r) => satisfies(app.version, r.range) !== true);\n if (unmet.length) {\n out.push({...base, action: 'keep', reason: 'range', unmet});\n continue;\n }\n const context = contextChange(dir, app.real, nested);\n if (context) {\n out.push({\n ...base,\n action: 'keep',\n reason: 'context',\n unmet: [],\n context,\n });\n continue;\n }\n out.push({...base, action: 'remove', unmet: []});\n }\n return out;\n}\n\n/**\n * Would removing the copy at `copyDir` change what ITS OWN dependencies\n * resolve to? Removing it hands its importers the app's copy, which resolves\n * its dependencies from the app root -- while the checkout keeps its own copy\n * of everything that failed the guard. Measured: a checkout kept its\n * `react`/`@types/react` 18 (its range), lost `prism-react-renderer` (in\n * range), and the app's copy of that resolved `react` -- and with it the\n * types -- to the app's 19: the checkout's own `tsc` saw both React type sets\n * and failed. So the copy stays when any of its `dependencies`,\n * `peerDependencies` or `optionalDependencies` (and the `@types/` package\n * TypeScript would take for it) resolves, from the copy's place in the\n * checkout, to a different package than from the app's copy: a different real\n * path that is not the same `name@version`, or nothing at all from the app's.\n * The same version at another path is the same code, so it does not count; a\n * dependency the checkout cannot resolve either is no change.\n */\nfunction contextChange(\n copyDir: string,\n appReal: string,\n pkg: any,\n): PruneDecision['context'] | undefined {\n const names = new Set<string>();\n for (const f of REQUIRE_FIELDS) {\n for (const d of Object.keys(pkg[f] ?? {})) {\n names.add(d);\n names.add(typesPackageFor(d));\n }\n }\n for (const d of names) {\n const here = resolveFrom(copyDir, d);\n if (!here) continue;\n const there = resolveFrom(appReal, d);\n if (!there) return {dep: d, here: here.version, app: null};\n if (here.real !== there.real && here.version !== there.version)\n return {dep: d, here: here.version, app: there.version};\n }\n return undefined;\n}\n\n/** `react` → `@types/react`; `@scope/name` → `@types/scope__name`; an `@types/` name is itself. */\nfunction typesPackageFor(name: string): string {\n if (name.startsWith('@types/')) return name;\n return `@types/${name.startsWith('@') ? name.slice(1).replace('/', '__') : name}`;\n}\n\n/** Node's upward search for `name` from the directory `from`: the first `node_modules/<name>`. */\nfunction resolveFrom(\n from: string,\n name: string,\n): {real: string; version: string} | null {\n for (let dir = from; ;) {\n if (path.basename(dir) !== 'node_modules') {\n const candidate = path.join(dir, 'node_modules', name);\n const pkg = readJson(path.join(candidate, 'package.json'));\n if (pkg)\n return {real: realOrSelf(candidate), version: String(pkg.version)};\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\n/**\n * Every range that would load a copy at the top of one `node_modules`: the\n * requirements (`dependencies`, `peerDependencies`, `optionalDependencies`) of\n * every installed package under it, read ONCE per `node_modules`, then asked\n * per name. A package counts for `<nm>/<dep>` when nothing between it and\n * `nm` holds its own `dep` -- Node would load the top-level copy.\n *\n * Read from npm's hidden lockfile (`node_modules/.package-lock.json`, which\n * npm rewrites on every install in that tree) when there is one: measured\n * over 21 checkouts, parsing all of them took ~45 ms where walking the same\n * 16,800 package.json files took 0.8 s warm and 3.4 s cold. Without one (a\n * tree npm did not write) the tree is walked, once. Either way a requirer is\n * checked against the disk when asked about -- what an earlier prune removed\n * asks nothing, and a copy is shadowed only by a directory that exists.\n */\nexport interface RequirementIndex {\n asks(dep: string): Ask[];\n}\n\n/** An installed package under a `node_modules`, located only when asked about. */\ninterface Installed {\n name: string;\n version: string;\n /** Its path below `nm`, `/`-separated: `a/node_modules/@s/b`. */\n rel: string;\n located?: {dir: string; between: string[]};\n}\n\ninterface Requirer {\n installed: Installed;\n range: string;\n}\n\n/** The package's directory, and the `node_modules` directories between `nm` and it (its own included). */\nfunction locate(nm: string, i: Installed): {dir: string; between: string[]} {\n if (!i.located) {\n const segs = i.rel.split('/');\n const dir = path.join(nm, ...segs);\n const between = [path.join(dir, 'node_modules')];\n for (let k = 0; k < segs.length; k++) {\n if (segs[k] === 'node_modules')\n between.push(path.join(nm, ...segs.slice(0, k + 1)));\n }\n i.located = {dir, between};\n }\n return i.located;\n}\n\nfunction requirementIndex(nm: string, cache: PruneCache): RequirementIndex {\n let index = cache.indexes.get(nm);\n if (!index) {\n cache.builds++;\n const byDep = fromHiddenLockfile(nm) ?? fromWalk(nm);\n index = {\n asks(dep) {\n const out: Ask[] = [];\n for (const {installed, range} of byDep.get(dep) ?? []) {\n if (installed.name === dep) continue;\n const {dir, between} = locate(nm, installed);\n if (!fs.existsSync(path.join(dir, 'package.json'))) continue;\n if (between.some((d) => fs.existsSync(path.join(d, dep)))) continue;\n out.push({from: `${installed.name}@${installed.version}`, range});\n }\n return out;\n },\n };\n cache.indexes.set(nm, index);\n }\n return index;\n}\n\n/** Record what the package at `rel` (below `nm`) requires. */\nfunction addRequirer(\n byDep: Map<string, Requirer[]>,\n rel: string,\n pkg: any,\n): void {\n const at = rel.lastIndexOf('/node_modules/');\n const installed: Installed = {\n name: at === -1 ? rel : rel.slice(at + '/node_modules/'.length),\n version: pkg.version,\n rel,\n };\n const seen = new Set<string>();\n for (const f of REQUIRE_FIELDS) {\n for (const [dep, range] of Object.entries<any>(pkg[f] ?? {})) {\n if (typeof range !== 'string' || seen.has(dep)) continue;\n seen.add(dep);\n let list = byDep.get(dep);\n if (!list) byDep.set(dep, (list = []));\n list.push({installed, range});\n }\n }\n}\n\nconst NODE_MODULES_PREFIX = 'node_modules/';\n\nfunction fromHiddenLockfile(nm: string): Map<string, Requirer[]> | null {\n const lock = readJson(path.join(nm, '.package-lock.json'));\n if (!lock?.packages || typeof lock.packages !== 'object') return null;\n const byDep = new Map<string, Requirer[]>();\n for (const [key, meta] of Object.entries<any>(lock.packages)) {\n if (!key.startsWith(NODE_MODULES_PREFIX) || !meta || meta.link) continue;\n addRequirer(byDep, key.slice(NODE_MODULES_PREFIX.length), meta);\n }\n return byDep;\n}\n\nfunction fromWalk(nm: string): Map<string, Requirer[]> {\n const byDep = new Map<string, Requirer[]>();\n const walk = (dir: string, prefix: string) => {\n for (const name of topLevelPackages(dir)) {\n const pkgDir = path.join(dir, name);\n if (isSymlink(pkgDir)) continue; // resolves from its real path, which is not here\n const rel = prefix + name;\n const pkg = readJson(path.join(pkgDir, 'package.json'));\n if (pkg) addRequirer(byDep, rel, pkg);\n const inner = path.join(pkgDir, 'node_modules');\n if (fs.existsSync(inner)) walk(inner, `${rel}/node_modules/`);\n }\n };\n walk(nm, '');\n return byDep;\n}\n\nfunction report(removed: PruneDecision[], kept: PruneDecision[], deps) {\n const byOwner = new Map<string, PruneDecision[]>();\n for (const r of removed)\n byOwner.set(r.owner, [...(byOwner.get(r.owner) ?? []), r]);\n for (const [owner, list] of byOwner) {\n deps.log(\n `[localize] ${owner}: removed its own copies of what the app provides — ` +\n list\n .map(\n (r) =>\n `${r.dep}@${r.version} (app: ${r.sibling ? `localized, ${r.app}` : r.app})`,\n )\n .join(', '),\n );\n for (const r of list) {\n for (const d of r.unmet) {\n deps.warn(\n `[localize] ${owner}: ${d.from} asks ${r.dep}@${d.range}; the localized checkout is ${r.app}. ` +\n `It is used anyway — that is what localizing it means — but the range is now fiction.`,\n );\n }\n }\n }\n const keptBy = new Map<string, PruneDecision[]>();\n for (const k of kept)\n keptBy.set(k.owner, [...(keptBy.get(k.owner) ?? []), k]);\n for (const [owner, list] of keptBy) {\n const one = list.length === 1;\n deps.warn(\n `[localize] ${owner}: kept ${list.length} own ${one ? 'copy' : 'copies'} the app's cannot ` +\n `replace: ${summarizeKept(list)} — so the app loads ${one ? 'it' : 'them'} twice. ` +\n `\\`linked localize --list\\` says why.`,\n );\n }\n}\n\nconst SUMMARY_LIMIT = 8;\n\n/** `react@18.3.1 (app 19.2.0), prism-react-renderer@2.4.1 (its react would change), … and 4 more` */\nexport function summarizeKept(list: PruneDecision[]): string {\n const shown = list.slice(0, SUMMARY_LIMIT).map(keptShort);\n const more = list.length - shown.length;\n return shown.join(', ') + (more > 0 ? `, … and ${more} more` : '');\n}\n\nfunction keptShort(k: PruneDecision): string {\n return k.reason === 'context'\n ? `${k.dep}@${k.version} (its ${k.context!.dep} would change)`\n : `${k.dep}@${k.version} (app ${k.app})`;\n}\n\n/** The full reason a copy stays, for `--list`. */\nexport function explainKept(k: PruneDecision): string {\n if (k.reason === 'context') {\n const c = k.context!;\n return (\n `${k.where}@${k.version}: from the checkout its ${c.dep} is ${c.here}, from the app's copy ` +\n `${c.app === null ? 'nothing' : c.app} — removing it would change what it loads`\n );\n }\n return (\n `${k.where}@${k.version}: ` +\n k.unmet.map((u) => `${u.from} asks ${k.dep}@${u.range}`).join(', ') +\n `, and the app has ${k.dep}@${k.app}` +\n (k.unmet.some((u) => satisfies(k.app, u.range) === null)\n ? ' (or the range is one localize cannot read)'\n : '')\n );\n}\n\nfunction declared(pkg, fields, dep) {\n for (const f of fields) if (pkg[f]?.[dep] !== undefined) return pkg[f][dep];\n return undefined;\n}\n\n/** The app's own copy of `dep`: `<appRoot>/node_modules/<dep>`, followed through a link. */\nfunction appCopy(dep, deps) {\n const dir = path.join(deps.appRoot, 'node_modules', dep);\n const pkg = readJson(path.join(dir, 'package.json'));\n if (!pkg?.version) return null;\n return {version: pkg.version, real: realOrSelf(dir)};\n}\n\n/** The package dir's `node_modules`, and the clone root's when the package is a monorepo subdir. */\nexport function nodeModulesRoots(pkgDir, entry) {\n const roots = [path.join(pkgDir, 'node_modules')];\n if (entry.subdir) {\n const rel = path.normalize(entry.subdir);\n if (pkgDir.endsWith(path.sep + rel))\n roots.push(path.join(pkgDir.slice(0, -(rel.length + 1)), 'node_modules'));\n }\n return roots.filter((d) => fs.existsSync(d));\n}\n\n/** Package names directly under a `node_modules`, scoped ones as `@scope/name`. */\nfunction topLevelPackages(nm) {\n const out = [];\n let items;\n try {\n items = fs.readdirSync(nm, {withFileTypes: true});\n } catch {\n return out;\n }\n for (const item of items) {\n if (item.name.startsWith('.')) continue;\n if (item.name.startsWith('@')) {\n let inner = [];\n try {\n inner = fs.readdirSync(path.join(nm, item.name));\n } catch {\n /* not a directory */\n }\n for (const sub of inner)\n if (!sub.startsWith('.')) out.push(`${item.name}/${sub}`);\n } else {\n out.push(item.name);\n }\n }\n return out;\n}\n\n/** Links in `<nm>/.bin` that pointed into a package just removed: dangling now. */\nfunction removeBinLinksInto(nm, removedDir) {\n const bin = path.join(nm, '.bin');\n let names;\n try {\n names = fs.readdirSync(bin);\n } catch {\n return;\n }\n for (const name of names) {\n const link = path.join(bin, name);\n if (!isSymlink(link)) continue;\n const target = path.resolve(bin, fs.readlinkSync(link));\n if (isInside(target, removedDir)) fs.unlinkSync(link);\n }\n}\n\nfunction removeEmptyScope(nm, dep) {\n if (!dep.startsWith('@')) return;\n const scope = path.join(nm, dep.split('/')[0]);\n try {\n if (!fs.readdirSync(scope).length) fs.rmdirSync(scope);\n } catch {\n /* already gone */\n }\n}\n\nexport function realOrSelf(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return p;\n }\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { PruneOptions } from './prune.js';
|
|
2
|
-
import type { Deps } from './run.js';
|
|
3
|
-
/**
|
|
4
|
-
* @param {object} deps
|
|
5
|
-
* @param {{prune?: boolean}} [opts] unless `prune` is
|
|
6
|
-
* false, every checkout's own copies of what the app provides are removed
|
|
7
|
-
* after relinking (see prune.ts), and a dependency missing from a checkout
|
|
8
|
-
* because it was pruned is not mistaken for one a root install took. A
|
|
9
|
-
* checkout recorded with `prune: false` (localized with `--no-prune`) is
|
|
10
|
-
* neither pruned nor excused.
|
|
11
|
-
*/
|
|
12
|
-
export declare function relink(deps: Deps, opts?: PruneOptions): number;
|
|
13
|
-
//# sourceMappingURL=relink.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relink.d.ts","sourceRoot":"","sources":["../../../src/localize/relink.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAEnC;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,YAAiB,GAAG,MAAM,CAiElE"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `--relink` -- the `postinstall` hook. Recreate every recorded symlink after
|
|
3
|
-
* an install removed it (`npm ci` deletes `node_modules` and exits 0).
|
|
4
|
-
*
|
|
5
|
-
* Three rules, each of which is the difference between a useful hook and one
|
|
6
|
-
* everybody disables:
|
|
7
|
-
*
|
|
8
|
-
* - **It always exits 0.** A postinstall that fails an install because of a
|
|
9
|
-
* developer's private state is worse than the problem it solves.
|
|
10
|
-
* - **With no manifest it produces NO output at all.** That is the CI case and
|
|
11
|
-
* the fresh-clone case. Any output there and people learn to ignore this
|
|
12
|
-
* hook's output, which is the one thing it can never become.
|
|
13
|
-
* - **It never runs npm at the consumer root.** A postinstall that installs
|
|
14
|
-
* the root, recurses. A test asserts it.
|
|
15
|
-
*
|
|
16
|
-
* It DOES run `npm install` inside a checkout whose dependencies are gone, and
|
|
17
|
-
* only then. Measured on npm 11: a root `npm install` treats a linked checkout
|
|
18
|
-
* that sits under the root as part of the root's tree, marks its dependencies
|
|
19
|
-
* `extraneous` and prunes them -- for a localized published dependency as
|
|
20
|
-
* much as for an undeclared one. Putting the link back without the
|
|
21
|
-
* dependencies leaves a checkout that cannot build. That install runs in the
|
|
22
|
-
* checkout, never at the root, so it cannot re-enter this hook; and it runs
|
|
23
|
-
* only when a declared dependency is missing, so an ordinary install stays
|
|
24
|
-
* silent and fast.
|
|
25
|
-
*/
|
|
26
|
-
import fs from 'node:fs';
|
|
27
|
-
import path from 'node:path';
|
|
28
|
-
import { readManifest } from './manifest.js';
|
|
29
|
-
import { isSymlink, readJson, writeLink } from './fsops.js';
|
|
30
|
-
import { declaredRange } from './localize.js';
|
|
31
|
-
import { candidatesFor, isProvidedByApp, pruneProvided, prunesEntry, shouldPrune, } from './prune.js';
|
|
32
|
-
import { ensure } from './ensure.js';
|
|
33
|
-
/**
|
|
34
|
-
* @param {object} deps
|
|
35
|
-
* @param {{prune?: boolean}} [opts] unless `prune` is
|
|
36
|
-
* false, every checkout's own copies of what the app provides are removed
|
|
37
|
-
* after relinking (see prune.ts), and a dependency missing from a checkout
|
|
38
|
-
* because it was pruned is not mistaken for one a root install took. A
|
|
39
|
-
* checkout recorded with `prune: false` (localized with `--no-prune`) is
|
|
40
|
-
* neither pruned nor excused.
|
|
41
|
-
*/
|
|
42
|
-
export function relink(deps, opts = {}) {
|
|
43
|
-
let manifest;
|
|
44
|
-
try {
|
|
45
|
-
manifest = readManifest(deps.appRoot, deps);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
// Even a refusal is only a warning here: never fail an install.
|
|
49
|
-
deps.warn(`[localize] ${e.message}`);
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
if (!manifest.exists)
|
|
53
|
-
return 0;
|
|
54
|
-
const names = Object.keys(manifest.entries);
|
|
55
|
-
if (!names.length)
|
|
56
|
-
return 0;
|
|
57
|
-
let relinked = 0;
|
|
58
|
-
for (const name of names) {
|
|
59
|
-
const entry = manifest.entries[name];
|
|
60
|
-
const checkout = path.join(deps.appRoot, entry.path);
|
|
61
|
-
if (!fs.existsSync(checkout)) {
|
|
62
|
-
deps.warn(`[localize] ${name} is recorded as local but ${entry.path} is gone — using the registry ` +
|
|
63
|
-
`copy. ` +
|
|
64
|
-
(entry.repo
|
|
65
|
-
? `\`linked localize ${name}\` to re-clone.`
|
|
66
|
-
: `It has no recorded repository, so restore the checkout by hand, then ` +
|
|
67
|
-
`\`linked localize ${name} --adopt\`.`));
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
reinstallIfPruned(name, entry, manifest.entries, opts, deps);
|
|
71
|
-
if (isSymlink(path.join(deps.appRoot, 'node_modules', name))) {
|
|
72
|
-
// Already linked; rewriting it would be noise on every install.
|
|
73
|
-
const existing = fs.realpathSync(path.join(deps.appRoot, 'node_modules', name));
|
|
74
|
-
if (existing === fs.realpathSync(checkout))
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
writeLink(deps.appRoot, name, checkout);
|
|
78
|
-
relinked++;
|
|
79
|
-
deps.log(`[localize] relinked ${name} -> ${entry.path} (branch ${entry.branch})`);
|
|
80
|
-
warnRangeDrift(name, entry, checkout, deps);
|
|
81
|
-
}
|
|
82
|
-
if (relinked) {
|
|
83
|
-
deps.log(`[localize] ${relinked} local package${relinked === 1 ? '' : 's'} relinked. ` +
|
|
84
|
-
'`linked localize --list` for detail.');
|
|
85
|
-
}
|
|
86
|
-
if (shouldPrune(opts)) {
|
|
87
|
-
try {
|
|
88
|
-
pruneProvided(manifest.entries, opts, deps);
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
// Never fail an install over it.
|
|
92
|
-
deps.warn(`[localize] pruning failed: ${e.message}`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return 0;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Restore a checkout's own `node_modules` when a root install pruned it: any
|
|
99
|
-
* declared dependency (or devDependency -- the checkout's build needs those)
|
|
100
|
-
* missing from it. A failure warns; the hook still exits 0.
|
|
101
|
-
*/
|
|
102
|
-
function reinstallIfPruned(name, entry, entries, opts, deps) {
|
|
103
|
-
const checkout = path.join(deps.appRoot, entry.path);
|
|
104
|
-
// When pruning, a dependency the app provides is absent on purpose -- unless
|
|
105
|
-
// this checkout was localized with `--no-prune`, when nothing is.
|
|
106
|
-
const candidates = shouldPrune(opts) && prunesEntry(entry)
|
|
107
|
-
? candidatesFor(entries, deps)
|
|
108
|
-
: null;
|
|
109
|
-
const provided = candidates
|
|
110
|
-
? (dep, range, pkg) => isProvidedByApp(dep, range, entries, candidates, deps, pkg)
|
|
111
|
-
: () => false;
|
|
112
|
-
const missing = missingDependencies(checkout, cloneRootOf(entry, deps), provided);
|
|
113
|
-
if (!missing.length)
|
|
114
|
-
return;
|
|
115
|
-
deps.log(`[localize] ${name}: ${missing.length} of its dependencies are gone from ${entry.path}/node_modules ` +
|
|
116
|
-
`(a root install prunes a checkout under the root) — reinstalling it`);
|
|
117
|
-
try {
|
|
118
|
-
ensure(entry, deps, opts);
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
deps.warn(`[localize] ${name}: ${e.message}\n` +
|
|
122
|
-
`Retry with \`linked localize --reinstall ${name}\`.`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Declared dependency names found in neither the checkout's own `node_modules`
|
|
127
|
-
* nor, for a package inside a monorepo, the clone root's -- where a workspaces
|
|
128
|
-
* install hoists them. Checking only the package directory there would find
|
|
129
|
-
* every hoisted dependency "missing" and reinstall on every postinstall.
|
|
130
|
-
*/
|
|
131
|
-
function missingDependencies(checkout, cloneRoot, provided = () => false) {
|
|
132
|
-
const pkg = readJson(path.join(checkout, 'package.json'));
|
|
133
|
-
if (!pkg)
|
|
134
|
-
return [];
|
|
135
|
-
const declared = Object.assign(Object.assign({}, pkg.devDependencies), pkg.dependencies);
|
|
136
|
-
const roots = cloneRoot === checkout ? [checkout] : [checkout, cloneRoot];
|
|
137
|
-
return Object.keys(declared).filter((dep) => !roots.some((root) => fs.existsSync(path.join(root, 'node_modules', dep))) && !provided(dep, declared[dep], pkg));
|
|
138
|
-
}
|
|
139
|
-
/** The clone a `subdir` entry lives in: its path with the subdir taken off the end. */
|
|
140
|
-
function cloneRootOf(entry, deps) {
|
|
141
|
-
const pkgDir = path.join(deps.appRoot, entry.path);
|
|
142
|
-
if (!entry.subdir)
|
|
143
|
-
return pkgDir;
|
|
144
|
-
const rel = path.normalize(entry.subdir);
|
|
145
|
-
return pkgDir.endsWith(path.sep + rel)
|
|
146
|
-
? pkgDir.slice(0, -(rel.length + 1))
|
|
147
|
-
: pkgDir;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* npm matches a link by NAME and never checks the range, so a checkout at
|
|
151
|
-
* 2.0.99 silently satisfies `^3.0.0` and `npm ls` does not flag it. This warns
|
|
152
|
-
* and never errors, and the range is never used to decide whether a checkout
|
|
153
|
-
* is usable -- only to say out loud that the declared range is now fiction.
|
|
154
|
-
*/
|
|
155
|
-
function warnRangeDrift(name, entry, checkout, deps) {
|
|
156
|
-
var _a;
|
|
157
|
-
const declared = declaredRange(name, deps);
|
|
158
|
-
const version = (_a = readJson(path.join(checkout, 'package.json'))) === null || _a === void 0 ? void 0 : _a.version;
|
|
159
|
-
if (!declared || !version)
|
|
160
|
-
return;
|
|
161
|
-
if (sameMajor(version, declared) &&
|
|
162
|
-
(!entry.range || entry.range === declared))
|
|
163
|
-
return;
|
|
164
|
-
deps.warn(`[localize] ${name}: checkout is ${version}, package.json asks ${declared}` +
|
|
165
|
-
(entry.range ? ` (recorded ${entry.range})` : '') +
|
|
166
|
-
` — the symlink wins; npm does NOT check the range.`);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Deliberately crude: enough to spot obvious drift for a warning, never used
|
|
170
|
-
* to gate anything. Real semver (`satisfies` in prune.ts) here would invite
|
|
171
|
-
* someone to treat the answer as a constraint.
|
|
172
|
-
*/
|
|
173
|
-
function sameMajor(version, range) {
|
|
174
|
-
const m = /^[\^~]?(\d+)\./.exec(range);
|
|
175
|
-
if (!m)
|
|
176
|
-
return true;
|
|
177
|
-
return version.split('.')[0] === m[1];
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=relink.js.map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,OAAO,EAAE,KAAK;IAC/B,MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/**\n * `--relink` -- the `postinstall` hook. Recreate every recorded symlink after\n * an install removed it (`npm ci` deletes `node_modules` and exits 0).\n *\n * Three rules, each of which is the difference between a useful hook and one\n * everybody disables:\n *\n * - **It always exits 0.** A postinstall that fails an install because of a\n * developer's private state is worse than the problem it solves.\n * - **With no manifest it produces NO output at all.** That is the CI case and\n * the fresh-clone case. Any output there and people learn to ignore this\n * hook's output, which is the one thing it can never become.\n * - **It never runs npm at the consumer root.** A postinstall that installs\n * the root, recurses. A test asserts it.\n *\n * It DOES run `npm install` inside a checkout whose dependencies are gone, and\n * only then. Measured on npm 11: a root `npm install` treats a linked checkout\n * that sits under the root as part of the root's tree, marks its dependencies\n * `extraneous` and prunes them -- for a localized published dependency as\n * much as for an undeclared one. Putting the link back without the\n * dependencies leaves a checkout that cannot build. That install runs in the\n * checkout, never at the root, so it cannot re-enter this hook; and it runs\n * only when a declared dependency is missing, so an ordinary install stays\n * silent and fast.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {readManifest} from './manifest.js';\nimport {isSymlink, readJson, writeLink} from './fsops.js';\nimport {declaredRange} from './localize.js';\nimport {\n candidatesFor,\n isProvidedByApp,\n pruneProvided,\n prunesEntry,\n shouldPrune,\n} from './prune.js';\nimport {ensure} from './ensure.js';\nimport type {PruneOptions} from './prune.js';\nimport type {Deps} from './run.js';\n\n/**\n * @param {object} deps\n * @param {{prune?: boolean}} [opts] unless `prune` is\n * false, every checkout's own copies of what the app provides are removed\n * after relinking (see prune.ts), and a dependency missing from a checkout\n * because it was pruned is not mistaken for one a root install took. A\n * checkout recorded with `prune: false` (localized with `--no-prune`) is\n * neither pruned nor excused.\n */\nexport function relink(deps: Deps, opts: PruneOptions = {}): number {\n let manifest;\n try {\n manifest = readManifest(deps.appRoot, deps);\n } catch (e) {\n // Even a refusal is only a warning here: never fail an install.\n deps.warn(`[localize] ${e.message}`);\n return 0;\n }\n\n if (!manifest.exists) return 0;\n const names = Object.keys(manifest.entries);\n if (!names.length) return 0;\n\n let relinked = 0;\n for (const name of names) {\n const entry = manifest.entries[name];\n const checkout = path.join(deps.appRoot, entry.path);\n\n if (!fs.existsSync(checkout)) {\n deps.warn(\n `[localize] ${name} is recorded as local but ${entry.path} is gone — using the registry ` +\n `copy. ` +\n (entry.repo\n ? `\\`linked localize ${name}\\` to re-clone.`\n : `It has no recorded repository, so restore the checkout by hand, then ` +\n `\\`linked localize ${name} --adopt\\`.`),\n );\n continue;\n }\n\n reinstallIfPruned(name, entry, manifest.entries, opts, deps);\n\n if (isSymlink(path.join(deps.appRoot, 'node_modules', name))) {\n // Already linked; rewriting it would be noise on every install.\n const existing = fs.realpathSync(\n path.join(deps.appRoot, 'node_modules', name),\n );\n if (existing === fs.realpathSync(checkout)) continue;\n }\n\n writeLink(deps.appRoot, name, checkout);\n relinked++;\n deps.log(\n `[localize] relinked ${name} -> ${entry.path} (branch ${entry.branch})`,\n );\n warnRangeDrift(name, entry, checkout, deps);\n }\n\n if (relinked) {\n deps.log(\n `[localize] ${relinked} local package${relinked === 1 ? '' : 's'} relinked. ` +\n '`linked localize --list` for detail.',\n );\n }\n\n if (shouldPrune(opts)) {\n try {\n pruneProvided(manifest.entries, opts, deps);\n } catch (e) {\n // Never fail an install over it.\n deps.warn(`[localize] pruning failed: ${e.message}`);\n }\n }\n return 0;\n}\n\n/**\n * Restore a checkout's own `node_modules` when a root install pruned it: any\n * declared dependency (or devDependency -- the checkout's build needs those)\n * missing from it. A failure warns; the hook still exits 0.\n */\nfunction reinstallIfPruned(name, entry, entries, opts, deps) {\n const checkout = path.join(deps.appRoot, entry.path);\n // When pruning, a dependency the app provides is absent on purpose -- unless\n // this checkout was localized with `--no-prune`, when nothing is.\n const candidates =\n shouldPrune(opts) && prunesEntry(entry)\n ? candidatesFor(entries, deps)\n : null;\n const provided = candidates\n ? (dep, range, pkg) =>\n isProvidedByApp(dep, range, entries, candidates, deps, pkg)\n : () => false;\n const missing = missingDependencies(\n checkout,\n cloneRootOf(entry, deps),\n provided,\n );\n if (!missing.length) return;\n deps.log(\n `[localize] ${name}: ${missing.length} of its dependencies are gone from ${entry.path}/node_modules ` +\n `(a root install prunes a checkout under the root) — reinstalling it`,\n );\n try {\n ensure(entry, deps, opts);\n } catch (e) {\n deps.warn(\n `[localize] ${name}: ${e.message}\\n` +\n `Retry with \\`linked localize --reinstall ${name}\\`.`,\n );\n }\n}\n\n/**\n * Declared dependency names found in neither the checkout's own `node_modules`\n * nor, for a package inside a monorepo, the clone root's -- where a workspaces\n * install hoists them. Checking only the package directory there would find\n * every hoisted dependency \"missing\" and reinstall on every postinstall.\n */\nfunction missingDependencies(\n checkout: string,\n cloneRoot: string,\n provided: (dep: string, range: string, pkg: any) => boolean = () => false,\n): string[] {\n const pkg = readJson(path.join(checkout, 'package.json'));\n if (!pkg) return [];\n const declared = {...pkg.devDependencies, ...pkg.dependencies};\n const roots = cloneRoot === checkout ? [checkout] : [checkout, cloneRoot];\n return Object.keys(declared).filter(\n (dep) =>\n !roots.some((root) =>\n fs.existsSync(path.join(root, 'node_modules', dep)),\n ) && !provided(dep, declared[dep], pkg),\n );\n}\n\n/** The clone a `subdir` entry lives in: its path with the subdir taken off the end. */\nfunction cloneRootOf(entry, deps) {\n const pkgDir = path.join(deps.appRoot, entry.path);\n if (!entry.subdir) return pkgDir;\n const rel = path.normalize(entry.subdir);\n return pkgDir.endsWith(path.sep + rel)\n ? pkgDir.slice(0, -(rel.length + 1))\n : pkgDir;\n}\n\n/**\n * npm matches a link by NAME and never checks the range, so a checkout at\n * 2.0.99 silently satisfies `^3.0.0` and `npm ls` does not flag it. This warns\n * and never errors, and the range is never used to decide whether a checkout\n * is usable -- only to say out loud that the declared range is now fiction.\n */\nfunction warnRangeDrift(name, entry, checkout, deps) {\n const declared = declaredRange(name, deps);\n const version = readJson(path.join(checkout, 'package.json'))?.version;\n if (!declared || !version) return;\n if (\n sameMajor(version, declared) &&\n (!entry.range || entry.range === declared)\n )\n return;\n deps.warn(\n `[localize] ${name}: checkout is ${version}, package.json asks ${declared}` +\n (entry.range ? ` (recorded ${entry.range})` : '') +\n ` — the symlink wins; npm does NOT check the range.`,\n );\n}\n\n/**\n * Deliberately crude: enough to spot obvious drift for a warning, never used\n * to gate anything. Real semver (`satisfies` in prune.ts) here would invite\n * someone to treat the answer as a constraint.\n */\nfunction sameMajor(version, range) {\n const m = /^[\\^~]?(\\d+)\\./.exec(range);\n if (!m) return true;\n return version.split('.')[0] === m[1];\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface SkippedDedupe {
|
|
2
|
-
name: string;
|
|
3
|
-
reason: 'range' | 'nested';
|
|
4
|
-
/** For `range`: who asks what, and what the app has. */
|
|
5
|
-
asks?: {
|
|
6
|
-
from: string;
|
|
7
|
-
range: string;
|
|
8
|
-
}[];
|
|
9
|
-
appVersion?: string;
|
|
10
|
-
/** For `nested`: one registry install that carries its own copy. */
|
|
11
|
-
nestedAt?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface LocalizedDedupe {
|
|
14
|
-
names: string[];
|
|
15
|
-
skipped: SkippedDedupe[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* `providedPackages` (localize/provided.ts) -- the one rule pruning and the
|
|
19
|
-
* run-time check use too -- minus the Vite-only exclusion: a checkout's
|
|
20
|
-
* dependency some registry install nests its own copy of. A localized package
|
|
21
|
-
* and react / react-dom are never excluded that way.
|
|
22
|
-
*/
|
|
23
|
-
export declare function localizedDedupe(appRoot?: string): Promise<LocalizedDedupe>;
|
|
24
|
-
/** One line for the dev log about the ranges the app does not satisfy; null when there are none. */
|
|
25
|
-
export declare function describeSkipped(skipped: SkippedDedupe[]): string | null;
|
|
26
|
-
//# sourceMappingURL=localized-dedupe.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localized-dedupe.d.ts","sourceRoot":"","sources":["../../src/localized-dedupe.ts"],"names":[],"mappings":"AAwCA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3B,wDAAwD;IACxD,IAAI,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,OAAO,GAAE,MAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC,CAc1B;AAED,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,GAAG,IAAI,CAavE"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* What Vite's `resolve.dedupe` lists: the packages a LOCALIZED checkout could
|
|
12
|
-
* otherwise load a second copy of.
|
|
13
|
-
*
|
|
14
|
-
* The duplicates come from localization, not from being a linked package. A
|
|
15
|
-
* localized checkout (`linked localize`) is a git clone under the app root with
|
|
16
|
-
* its own `npm install`, so its `node_modules` holds its own copy of what it
|
|
17
|
-
* depends on — often older than the app's, and a registry copy of any sibling
|
|
18
|
-
* that is localized too. Vite serves the checkout's source and resolves its
|
|
19
|
-
* imports from there, so without a dedupe the dev server loads those copies next
|
|
20
|
-
* to the app's (measured: three `@_linked/core` in one SSR process).
|
|
21
|
-
*
|
|
22
|
-
* So the list is:
|
|
23
|
-
*
|
|
24
|
-
* - every localized package — always, whatever a range says: the live checkout
|
|
25
|
-
* is the point of localizing it, for every importer;
|
|
26
|
-
* - every runtime dependency a localized checkout declares (`dependencies`,
|
|
27
|
-
* `peerDependencies`, `optionalDependencies` — what its source imports) that
|
|
28
|
-
* the app has at a version satisfying EVERY localized checkout's range for it;
|
|
29
|
-
* - `react` and `react-dom` when the app has them.
|
|
30
|
-
*
|
|
31
|
-
* A dedupe resolves the name from the app root for EVERY importer and checks no
|
|
32
|
-
* version — measured: a checkout asking `motion@^13` got the app's 12.43.0. Two
|
|
33
|
-
* cases are therefore left out:
|
|
34
|
-
*
|
|
35
|
-
* - a range the app's version does not satisfy: the checkout keeps its own copy
|
|
36
|
-
* (reported, see `describeSkipped`);
|
|
37
|
-
* - a name some registry install in the app nests its own copy of. npm only
|
|
38
|
-
* nests when the hoisted copy does not satisfy that package, so deduping the
|
|
39
|
-
* name would hand it the wrong version.
|
|
40
|
-
*
|
|
41
|
-
* Plain Node, `tsx`, `tsc` and test runners never read this list; for them the
|
|
42
|
-
* checkout's copies are removed from disk instead -- by every localize install
|
|
43
|
-
* (`ensure`) and by the run-time check before `linked start`, `script`,
|
|
44
|
-
* `call`, `build-all` and `linked localize --ensure` (localize/ensure.ts).
|
|
45
|
-
*/
|
|
46
|
-
import fs from 'node:fs';
|
|
47
|
-
import path from 'node:path';
|
|
48
|
-
import { providedPackages } from './localize/provided.js';
|
|
49
|
-
/**
|
|
50
|
-
* `providedPackages` (localize/provided.ts) -- the one rule pruning and the
|
|
51
|
-
* run-time check use too -- minus the Vite-only exclusion: a checkout's
|
|
52
|
-
* dependency some registry install nests its own copy of. A localized package
|
|
53
|
-
* and react / react-dom are never excluded that way.
|
|
54
|
-
*/
|
|
55
|
-
export function localizedDedupe() {
|
|
56
|
-
return __awaiter(this, arguments, void 0, function* (appRoot = process.cwd()) {
|
|
57
|
-
const provided = providedPackages(appRoot);
|
|
58
|
-
const skipped = [...provided.skipped];
|
|
59
|
-
const nested = provided.dependencies.length
|
|
60
|
-
? nestedCopies(path.join(appRoot, 'node_modules'))
|
|
61
|
-
: new Map();
|
|
62
|
-
const drop = new Set();
|
|
63
|
-
for (const name of provided.dependencies) {
|
|
64
|
-
if (!nested.has(name))
|
|
65
|
-
continue;
|
|
66
|
-
skipped.push({ name, reason: 'nested', nestedAt: nested.get(name) });
|
|
67
|
-
if (name !== 'react' && name !== 'react-dom')
|
|
68
|
-
drop.add(name);
|
|
69
|
-
}
|
|
70
|
-
const names = provided.names.filter((name) => !drop.has(name));
|
|
71
|
-
return { names, skipped };
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/** One line for the dev log about the ranges the app does not satisfy; null when there are none. */
|
|
75
|
-
export function describeSkipped(skipped) {
|
|
76
|
-
const range = skipped.filter((s) => s.reason === 'range');
|
|
77
|
-
if (!range.length)
|
|
78
|
-
return null;
|
|
79
|
-
return (`[linked] dedupe: ${range.length} package${range.length === 1 ? '' : 's'} a localized checkout ` +
|
|
80
|
-
`keeps its own copy of, because the app's version is outside its range: ` +
|
|
81
|
-
range
|
|
82
|
-
.map((s) => `${s.name} (${s.asks.map((a) => `${a.from} asks ${a.range}`).join(', ')}; app ${s.appVersion})`)
|
|
83
|
-
.join(', '));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Every package name nested below the top level of `nm` — a registry install's
|
|
87
|
-
* private copy — mapped to one place it sits. Symlinks (localized checkouts,
|
|
88
|
-
* workspaces) are not followed: their trees are not the app's install.
|
|
89
|
-
*/
|
|
90
|
-
function nestedCopies(nm) {
|
|
91
|
-
const out = new Map();
|
|
92
|
-
const walk = (dir, depth) => {
|
|
93
|
-
for (const name of packageNames(dir)) {
|
|
94
|
-
const pkgDir = path.join(dir, name);
|
|
95
|
-
let stat;
|
|
96
|
-
try {
|
|
97
|
-
stat = fs.lstatSync(pkgDir);
|
|
98
|
-
}
|
|
99
|
-
catch (_a) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (stat.isSymbolicLink())
|
|
103
|
-
continue;
|
|
104
|
-
if (depth > 0 && !out.has(name))
|
|
105
|
-
out.set(name, path.relative(path.dirname(nm), pkgDir));
|
|
106
|
-
walk(path.join(pkgDir, 'node_modules'), depth + 1);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
walk(nm, 0);
|
|
110
|
-
return out;
|
|
111
|
-
}
|
|
112
|
-
function packageNames(nm) {
|
|
113
|
-
let entries;
|
|
114
|
-
try {
|
|
115
|
-
entries = fs.readdirSync(nm);
|
|
116
|
-
}
|
|
117
|
-
catch (_a) {
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
const out = [];
|
|
121
|
-
for (const entry of entries) {
|
|
122
|
-
if (entry.startsWith('.'))
|
|
123
|
-
continue;
|
|
124
|
-
if (entry.startsWith('@')) {
|
|
125
|
-
try {
|
|
126
|
-
for (const sub of fs.readdirSync(path.join(nm, entry)))
|
|
127
|
-
out.push(`${entry}/${sub}`);
|
|
128
|
-
}
|
|
129
|
-
catch (_b) {
|
|
130
|
-
/* not a directory */
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
out.push(entry);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return out;
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=localized-dedupe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localized-dedupe.js","sourceRoot":"","sources":["../../src/localized-dedupe.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAiBxD;;;;;GAKG;AACH,MAAM,UAAgB,eAAe;yDACnC,UAAkB,OAAO,CAAC,GAAG,EAAE;QAE/B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAoB,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,MAAM;YACzC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAClD,CAAC,CAAC,IAAI,GAAG,EAAkB,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAS;YAChC,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC;YACnE,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,WAAW;gBAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,KAAK,GAAG,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,CAAC;gBACP,qBAAqB;YACvB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * What Vite's `resolve.dedupe` lists: the packages a LOCALIZED checkout could\n * otherwise load a second copy of.\n *\n * The duplicates come from localization, not from being a linked package. A\n * localized checkout (`linked localize`) is a git clone under the app root with\n * its own `npm install`, so its `node_modules` holds its own copy of what it\n * depends on — often older than the app's, and a registry copy of any sibling\n * that is localized too. Vite serves the checkout's source and resolves its\n * imports from there, so without a dedupe the dev server loads those copies next\n * to the app's (measured: three `@_linked/core` in one SSR process).\n *\n * So the list is:\n *\n * - every localized package — always, whatever a range says: the live checkout\n * is the point of localizing it, for every importer;\n * - every runtime dependency a localized checkout declares (`dependencies`,\n * `peerDependencies`, `optionalDependencies` — what its source imports) that\n * the app has at a version satisfying EVERY localized checkout's range for it;\n * - `react` and `react-dom` when the app has them.\n *\n * A dedupe resolves the name from the app root for EVERY importer and checks no\n * version — measured: a checkout asking `motion@^13` got the app's 12.43.0. Two\n * cases are therefore left out:\n *\n * - a range the app's version does not satisfy: the checkout keeps its own copy\n * (reported, see `describeSkipped`);\n * - a name some registry install in the app nests its own copy of. npm only\n * nests when the hoisted copy does not satisfy that package, so deduping the\n * name would hand it the wrong version.\n *\n * Plain Node, `tsx`, `tsc` and test runners never read this list; for them the\n * checkout's copies are removed from disk instead -- by every localize install\n * (`ensure`) and by the run-time check before `linked start`, `script`,\n * `call`, `build-all` and `linked localize --ensure` (localize/ensure.ts).\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport {providedPackages} from './localize/provided.js';\n\nexport interface SkippedDedupe {\n name: string;\n reason: 'range' | 'nested';\n /** For `range`: who asks what, and what the app has. */\n asks?: {from: string; range: string}[];\n appVersion?: string;\n /** For `nested`: one registry install that carries its own copy. */\n nestedAt?: string;\n}\n\nexport interface LocalizedDedupe {\n names: string[];\n skipped: SkippedDedupe[];\n}\n\n/**\n * `providedPackages` (localize/provided.ts) -- the one rule pruning and the\n * run-time check use too -- minus the Vite-only exclusion: a checkout's\n * dependency some registry install nests its own copy of. A localized package\n * and react / react-dom are never excluded that way.\n */\nexport async function localizedDedupe(\n appRoot: string = process.cwd(),\n): Promise<LocalizedDedupe> {\n const provided = providedPackages(appRoot);\n const skipped: SkippedDedupe[] = [...provided.skipped];\n const nested = provided.dependencies.length\n ? nestedCopies(path.join(appRoot, 'node_modules'))\n : new Map<string, string>();\n const drop = new Set<string>();\n for (const name of provided.dependencies) {\n if (!nested.has(name)) continue;\n skipped.push({name, reason: 'nested', nestedAt: nested.get(name)});\n if (name !== 'react' && name !== 'react-dom') drop.add(name);\n }\n const names = provided.names.filter((name) => !drop.has(name));\n return {names, skipped};\n}\n\n/** One line for the dev log about the ranges the app does not satisfy; null when there are none. */\nexport function describeSkipped(skipped: SkippedDedupe[]): string | null {\n const range = skipped.filter((s) => s.reason === 'range');\n if (!range.length) return null;\n return (\n `[linked] dedupe: ${range.length} package${range.length === 1 ? '' : 's'} a localized checkout ` +\n `keeps its own copy of, because the app's version is outside its range: ` +\n range\n .map(\n (s) =>\n `${s.name} (${s.asks!.map((a) => `${a.from} asks ${a.range}`).join(', ')}; app ${s.appVersion})`,\n )\n .join(', ')\n );\n}\n\n/**\n * Every package name nested below the top level of `nm` — a registry install's\n * private copy — mapped to one place it sits. Symlinks (localized checkouts,\n * workspaces) are not followed: their trees are not the app's install.\n */\nfunction nestedCopies(nm: string): Map<string, string> {\n const out = new Map<string, string>();\n const walk = (dir: string, depth: number) => {\n for (const name of packageNames(dir)) {\n const pkgDir = path.join(dir, name);\n let stat: fs.Stats;\n try {\n stat = fs.lstatSync(pkgDir);\n } catch {\n continue;\n }\n if (stat.isSymbolicLink()) continue;\n if (depth > 0 && !out.has(name))\n out.set(name, path.relative(path.dirname(nm), pkgDir));\n walk(path.join(pkgDir, 'node_modules'), depth + 1);\n }\n };\n walk(nm, 0);\n return out;\n}\n\nfunction packageNames(nm: string): string[] {\n let entries: string[];\n try {\n entries = fs.readdirSync(nm);\n } catch {\n return [];\n }\n const out: string[] = [];\n for (const entry of entries) {\n if (entry.startsWith('.')) continue;\n if (entry.startsWith('@')) {\n try {\n for (const sub of fs.readdirSync(path.join(nm, entry)))\n out.push(`${entry}/${sub}`);\n } catch {\n /* not a directory */\n }\n } else {\n out.push(entry);\n }\n }\n return out;\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const RELINK_COMMAND = "linked localize --relink";
|
|
2
|
-
/** The npm lifecycle scripts that run {@link RELINK_COMMAND}. See the module header. */
|
|
3
|
-
export declare const RELINK_HOOKS: readonly ["postinstall", "dependencies"];
|
|
4
|
-
/**
|
|
5
|
-
* Make sure each of the app's {@link RELINK_HOOKS} runs {@link RELINK_COMMAND}:
|
|
6
|
-
* set it when absent, append it with `&&` to a script that does something
|
|
7
|
-
* else, and leave a script that already relinks alone. Mutates `pkg`.
|
|
8
|
-
*
|
|
9
|
-
* @returns the hooks it added the command to (empty when nothing changed).
|
|
10
|
-
*/
|
|
11
|
-
export declare function ensureRelinkHooks(pkg: Record<string, any>): string[];
|
|
12
|
-
/**
|
|
13
|
-
* {@link ensureRelinkHooks} on a `package.json` file, keeping its indentation
|
|
14
|
-
* and trailing newline. A missing or unparseable file is left alone.
|
|
15
|
-
*
|
|
16
|
-
* @returns the hooks it added (empty when nothing changed or nothing could be).
|
|
17
|
-
*/
|
|
18
|
-
export declare function ensureRelinkHooksInFile(pkgPath: string): string[];
|
|
19
|
-
//# sourceMappingURL=relinkHooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relinkHooks.d.ts","sourceRoot":"","sources":["../../../src/utils/relinkHooks.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,cAAc,6BAA6B,CAAC;AAEzD,wFAAwF;AACxF,eAAO,MAAM,YAAY,0CAA2C,CAAC;AAKrE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,CAYpE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBjE"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The app scripts that put `linked localize`'s links back after npm removed
|
|
3
|
-
* them. Shared by `create-package` (which sets them up before it adopts a new
|
|
4
|
-
* package) and by `localize` / `adopt` (which add them when they record a
|
|
5
|
-
* package into an app that does not have them yet).
|
|
6
|
-
*
|
|
7
|
-
* Why TWO hooks, both running the same command: npm runs an app's root
|
|
8
|
-
* `postinstall` only on a bare `npm install` / `npm ci`. It runs a root
|
|
9
|
-
* `dependencies` script after ANY command that changes `node_modules` --
|
|
10
|
-
* `npm install <name>`, `npm update`, `npm uninstall`, `npm dedupe` (npm's
|
|
11
|
-
* arborist, `reify.js`). Each of those replaces a localized link with the
|
|
12
|
-
* registry copy, silently, so `postinstall` alone leaves most of them
|
|
13
|
-
* unguarded. A bare `npm install` runs both scripts; `--relink` is idempotent
|
|
14
|
-
* and silent when there is nothing to do, so running twice costs nothing.
|
|
15
|
-
*
|
|
16
|
-
* With no `local-packages.json` the command prints nothing and exits 0, so the
|
|
17
|
-
* hooks are safe to commit for everyone.
|
|
18
|
-
*/
|
|
19
|
-
import fs from 'fs';
|
|
20
|
-
export const RELINK_COMMAND = 'linked localize --relink';
|
|
21
|
-
/** The npm lifecycle scripts that run {@link RELINK_COMMAND}. See the module header. */
|
|
22
|
-
export const RELINK_HOOKS = ['postinstall', 'dependencies'];
|
|
23
|
-
/** Also matches the retired `linked-localize --relink` spelling. */
|
|
24
|
-
const RELINKS = /localize\s+--relink/;
|
|
25
|
-
/**
|
|
26
|
-
* Make sure each of the app's {@link RELINK_HOOKS} runs {@link RELINK_COMMAND}:
|
|
27
|
-
* set it when absent, append it with `&&` to a script that does something
|
|
28
|
-
* else, and leave a script that already relinks alone. Mutates `pkg`.
|
|
29
|
-
*
|
|
30
|
-
* @returns the hooks it added the command to (empty when nothing changed).
|
|
31
|
-
*/
|
|
32
|
-
export function ensureRelinkHooks(pkg) {
|
|
33
|
-
var _a;
|
|
34
|
-
pkg.scripts = (_a = pkg.scripts) !== null && _a !== void 0 ? _a : {};
|
|
35
|
-
const added = [];
|
|
36
|
-
for (const hook of RELINK_HOOKS) {
|
|
37
|
-
const current = pkg.scripts[hook];
|
|
38
|
-
if (current && RELINKS.test(current))
|
|
39
|
-
continue;
|
|
40
|
-
pkg.scripts[hook] = current
|
|
41
|
-
? `${current} && ${RELINK_COMMAND}`
|
|
42
|
-
: RELINK_COMMAND;
|
|
43
|
-
added.push(hook);
|
|
44
|
-
}
|
|
45
|
-
return added;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* {@link ensureRelinkHooks} on a `package.json` file, keeping its indentation
|
|
49
|
-
* and trailing newline. A missing or unparseable file is left alone.
|
|
50
|
-
*
|
|
51
|
-
* @returns the hooks it added (empty when nothing changed or nothing could be).
|
|
52
|
-
*/
|
|
53
|
-
export function ensureRelinkHooksInFile(pkgPath) {
|
|
54
|
-
var _a, _b;
|
|
55
|
-
let text;
|
|
56
|
-
let pkg;
|
|
57
|
-
try {
|
|
58
|
-
text = fs.readFileSync(pkgPath, 'utf8');
|
|
59
|
-
pkg = JSON.parse(text);
|
|
60
|
-
}
|
|
61
|
-
catch (_c) {
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
if (!pkg || typeof pkg !== 'object' || Array.isArray(pkg))
|
|
65
|
-
return [];
|
|
66
|
-
const added = ensureRelinkHooks(pkg);
|
|
67
|
-
if (!added.length)
|
|
68
|
-
return added;
|
|
69
|
-
const indent = (_b = (_a = /^[ \t]+(?=")/m.exec(text)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 2;
|
|
70
|
-
const eol = text.endsWith('\n') ? '\n' : '';
|
|
71
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + eol);
|
|
72
|
-
return added;
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=relinkHooks.js.map
|