@_linked/cli 1.41.1 → 1.43.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +21 -54
  3. package/lib/esm/cli-methods.js +2 -2
  4. package/lib/esm/cli-methods.js.map +1 -1
  5. package/lib/esm/cli.js +13 -1
  6. package/lib/esm/cli.js.map +1 -1
  7. package/lib/esm/commands/localize.d.ts +6 -15
  8. package/lib/esm/commands/localize.d.ts.map +1 -1
  9. package/lib/esm/commands/localize.js +26 -35
  10. package/lib/esm/commands/localize.js.map +1 -1
  11. package/lib/esm/commands/setup-publish.d.ts +26 -1
  12. package/lib/esm/commands/setup-publish.d.ts.map +1 -1
  13. package/lib/esm/commands/setup-publish.js +107 -9
  14. package/lib/esm/commands/setup-publish.js.map +1 -1
  15. package/lib/esm/installed-packages.d.ts +12 -12
  16. package/lib/esm/installed-packages.d.ts.map +1 -1
  17. package/lib/esm/installed-packages.js +37 -27
  18. package/lib/esm/installed-packages.js.map +1 -1
  19. package/lib/esm/lifecycle.d.ts +4 -3
  20. package/lib/esm/lifecycle.d.ts.map +1 -1
  21. package/lib/esm/lifecycle.js +6 -14
  22. package/lib/esm/lifecycle.js.map +1 -1
  23. package/lib/esm/localize/adopt.d.ts +10 -0
  24. package/lib/esm/localize/adopt.d.ts.map +1 -0
  25. package/lib/esm/localize/adopt.js +76 -0
  26. package/lib/esm/localize/adopt.js.map +1 -0
  27. package/lib/esm/localize/delocalize.d.ts +6 -0
  28. package/lib/esm/localize/delocalize.d.ts.map +1 -0
  29. package/lib/esm/localize/delocalize.js +138 -0
  30. package/lib/esm/localize/delocalize.js.map +1 -0
  31. package/lib/esm/localize/ensure.d.ts +26 -0
  32. package/lib/esm/localize/ensure.d.ts.map +1 -0
  33. package/lib/esm/localize/ensure.js +152 -0
  34. package/lib/esm/localize/ensure.js.map +1 -0
  35. package/lib/esm/localize/errors.d.ts +23 -0
  36. package/lib/esm/localize/errors.d.ts.map +1 -0
  37. package/lib/esm/localize/errors.js +26 -0
  38. package/lib/esm/localize/errors.js.map +1 -0
  39. package/lib/esm/localize/fsops.d.ts +36 -0
  40. package/lib/esm/localize/fsops.d.ts.map +1 -0
  41. package/lib/esm/localize/fsops.js +155 -0
  42. package/lib/esm/localize/fsops.js.map +1 -0
  43. package/lib/esm/localize/index.d.ts +29 -0
  44. package/lib/esm/localize/index.d.ts.map +1 -0
  45. package/lib/esm/localize/index.js +22 -0
  46. package/lib/esm/localize/index.js.map +1 -0
  47. package/lib/esm/localize/list.d.ts +18 -0
  48. package/lib/esm/localize/list.d.ts.map +1 -0
  49. package/lib/esm/localize/list.js +174 -0
  50. package/lib/esm/localize/list.js.map +1 -0
  51. package/lib/esm/localize/localize.d.ts +84 -0
  52. package/lib/esm/localize/localize.d.ts.map +1 -0
  53. package/lib/esm/localize/localize.js +354 -0
  54. package/lib/esm/localize/localize.js.map +1 -0
  55. package/lib/esm/localize/manifest.d.ts +54 -0
  56. package/lib/esm/localize/manifest.d.ts.map +1 -0
  57. package/lib/esm/localize/manifest.js +133 -0
  58. package/lib/esm/localize/manifest.js.map +1 -0
  59. package/lib/esm/localize/provided.d.ts +28 -0
  60. package/lib/esm/localize/provided.d.ts.map +1 -0
  61. package/lib/esm/localize/provided.js +89 -0
  62. package/lib/esm/localize/provided.js.map +1 -0
  63. package/lib/esm/localize/prune.d.ts +58 -0
  64. package/lib/esm/localize/prune.d.ts.map +1 -0
  65. package/lib/esm/localize/prune.js +390 -0
  66. package/lib/esm/localize/prune.js.map +1 -0
  67. package/lib/esm/localize/relink.d.ts +11 -0
  68. package/lib/esm/localize/relink.d.ts.map +1 -0
  69. package/lib/esm/localize/relink.js +174 -0
  70. package/lib/esm/localize/relink.js.map +1 -0
  71. package/lib/esm/localize/resolve.d.ts +47 -0
  72. package/lib/esm/localize/resolve.d.ts.map +1 -0
  73. package/lib/esm/localize/resolve.js +153 -0
  74. package/lib/esm/localize/resolve.js.map +1 -0
  75. package/lib/esm/localize/run.d.ts +35 -0
  76. package/lib/esm/localize/run.d.ts.map +1 -0
  77. package/lib/esm/localize/run.js +30 -0
  78. package/lib/esm/localize/run.js.map +1 -0
  79. package/lib/esm/localized-dedupe.d.ts +6 -0
  80. package/lib/esm/localized-dedupe.d.ts.map +1 -1
  81. package/lib/esm/localized-dedupe.js +23 -66
  82. package/lib/esm/localized-dedupe.js.map +1 -1
  83. package/package.json +1 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.43.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#224](https://github.com/linked-fw/cli/pull/224) [`51d38d1`](https://github.com/linked-fw/cli/commit/51d38d1392afd212e6c5b656d343a8f581cc42bf) Thanks [@flyon](https://github.com/flyon)! - `linked setup-publish` now also sets up what every linked-cm package needed by hand:
8
+
9
+ - an `.npmrc` with `allow-remote=all` (npm 12 otherwise fails `npm install` with EALLOWREMOTE on bundled tarballs), plus `legacy-peer-deps=true` in linked-cm, whose CI installs that way. Keys the repo already sets are kept.
10
+ - a `renovate.json` stub extending `<org>/renovate-config`, unless the repo already has a Renovate config.
11
+ - `@changesets/cli` ^3 and `@changesets/changelog-github` ^1, the versions the fleet runs.
12
+
13
+ The lockfile step now keeps the existing lockfile's resolutions and resolves under the repo's `.npmrc`, instead of re-resolving from scratch with `--legacy-peer-deps` everywhere.
14
+
15
+ ## 1.42.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#222](https://github.com/linked-fw/cli/pull/222) [`4f7ce0c`](https://github.com/linked-fw/cli/commit/4f7ce0ca420d585eb1e286281c122638362de2ae) Thanks [@flyon](https://github.com/flyon)! - Localize is now part of the cli. `linked localize` and `linked delocalize` no longer load the separate `@_linked/localize` package, which is no longer a dependency and will be deprecated in favour of `linked localize`; its `linked-localize` binary is not replaced. The guide is in `docs/localize.md`.
20
+
21
+ New:
22
+
23
+ - `linked localize --ensure` removes every localized checkout's own copy of a package the app provides and exits 0. It never runs npm and prints nothing when there is nothing to remove — for an app's npm `pre*` scripts.
24
+ - `linked localize --reinstall <pkg>` runs `npm install` inside that package's checkout and then prunes it. Use it instead of a hand-run `npm install` in a checkout.
25
+ - A run-time one-copy check before `linked start`, `linked script`, `linked call` and `linked build-all`: stat-only, it removes a checkout's own copy of what the app provides with one line of output.
26
+ - `linked localize --list` shows directories in `packages-local/` that `local-packages.json` does not record, as `UNRECORDED` (they do not fail `--check`).
27
+
28
+ One rule now says what the app provides: the localized packages, plus their runtime dependencies (`dependencies`, `peerDependencies`, `optionalDependencies`) that the app has at a version satisfying every localized range, plus `react` and `react-dom`. Pruning, the run-time check and Vite's `resolve.dedupe` all use it.
29
+
30
+ Behaviour change: pruning now also removes a checkout's own copy of tooling or other runtime dependencies the app provides in range (for example `vite` or `typescript` declared in `dependencies`); the checkout resolves the app's copy instead. devDependencies are no longer candidates.
31
+
3
32
  ## 1.41.1
4
33
 
5
34
  ### Patch Changes
package/README.md CHANGED
@@ -227,10 +227,10 @@ linked app-doctor # in an app: check optimizeDeps.include and Re
227
227
 
228
228
  ### Developing a dependency from a git checkout
229
229
 
230
- `linked localize` clones an npm dependency, installs inside the checkout, builds
231
- it with `linked build` and symlinks it into `node_modules` — **without** touching
232
- `package.json` or `package-lock.json`, so the manifest still describes the
233
- released dependency and CI is unaffected.
230
+ `linked localize` clones an npm dependency, installs inside the checkout, builds it with
231
+ `linked build` and symlinks it into `node_modules` — **without** touching `package.json` or
232
+ `package-lock.json`, so the manifest still describes the released dependency and CI is unaffected.
233
+ Full guide: [docs/localize.md](docs/localize.md).
234
234
 
235
235
  ```bash
236
236
  linked localize @_linked/rdfs # clone, install, build, symlink into node_modules
@@ -238,61 +238,28 @@ linked localize # report what is localized (same as --list)
238
238
  linked localize --list --check # exit 1 when something recorded is not actually linked
239
239
  linked localize --relink # recreate the recorded symlinks — run this from postinstall
240
240
  linked localize @_linked/rdfs --adopt # link a checkout already in packages-local/_linked-rdfs, no clone
241
+ linked localize --reinstall @_linked/rdfs # npm install inside the checkout, then prune it
242
+ linked localize --ensure # remove checkouts' own copies of what the app provides; exit 0
241
243
  linked delocalize @_linked/rdfs # unlink and forget, keeping the checkout
242
244
  linked delocalize --purge # undo everything and delete the checkouts
243
245
  ```
244
246
 
245
247
  Checkouts go in `packages-local/` under the npm name with the scope flattened:
246
- `@_linked/rdfs` → `packages-local/_linked-rdfs`.
247
-
248
- `npm install <name>` — with a package name — does not run the app's own `postinstall`, so it
249
- replaces every localized link with the registry copy and prunes the checkouts' dependencies,
250
- silently. Run `linked localize --relink` after it (a bare `npm install` runs the hook itself).
251
-
252
- Name packages exactly as npm names them (`@_linked/rdfs`, `lodash`): the
253
- repository is read from the package's published `repository` field, so there is
254
- no short-name expansion and no org guessing. `--dir` moves the checkout
255
- directory (default `packages-local`), `--repo`/`--subdir` cover a package whose
256
- published metadata does not point at the right place, and `--build "<cmd>"`
257
- replaces `linked build` (an empty string builds nothing). A failing build only
258
- warns — a package whose build is broken is usually why you localized it.
259
-
260
- **One copy of each framework package.** A checkout's own install leaves its own
261
- `@_linked/core` (pinned by the checkout's lockfile, often older than the app's)
262
- and a registry copy of any localized sibling in its `node_modules`, and Node
263
- loads those instead of the app's. So after installing, and on every `--relink`,
264
- `linked localize` removes from every checkout's `node_modules` its own copy of
265
- a linked package the app has installed, `react` and `react-dom` (plus its
266
- peerDependencies) when the app has a version that satisfies the checkout's range; a localized sibling always
267
- counts. A copy the app's version does not satisfy is kept, with a warning naming
268
- the package, the range and the app's version. The checkout still builds and runs
269
- its tests, resolving those packages from the app — this CLI included: npm puts
270
- every ancestor's `node_modules/.bin` on the `PATH`, so `npx linked build` in a
271
- checkout runs the app's `linked`. `--no-prune` keeps every checkout's
272
- `node_modules` as npm left it. The
273
- A linked package is one whose `package.json` says `"linkedPackage": true` — the
274
- definition `build-all` and `linked build` use — whatever its npm scope;
275
- `@_linked/localize`, a plain tool, is not one.
276
-
277
- The dev server gets the same guarantee from Vite's `resolve.dedupe`, which
278
- `createViteConfig` derives from what is localized: the localized packages
279
- themselves, plus every runtime dependency a localized checkout declares that the
280
- app has at a version satisfying the checkout's range, plus React. A dependency
281
- whose range the app does not satisfy keeps the checkout's own copy (the dev log
282
- says which), and so does a name some registry install nests its own copy of —
283
- a dedupe hands every importer the app's copy without checking versions. With
284
- nothing localized, only React is deduped. The dedupe covers what Vite loads; the
285
- removal on disk covers plain Node, `tsx` and test runners, which never read it.
286
-
287
- The work is done by [`@_linked/localize`](https://www.npmjs.com/package/@_linked/localize),
288
- which is dependency-free and framework-agnostic; this CLI supplies the
289
- build command and the list of what an app provides. That package's own binary, `linked-localize`, is the same mechanism with
290
- three differences: it builds nothing unless given `--build "<cmd>"`, it treats only localized
291
- siblings and peerDependencies as provided unless given `--provided "<name>,…"`,
292
- and its verbs are subcommands —
293
- `linked-localize adopt <pkg>` and `linked-localize remove <pkg>` where this CLI has
294
- `linked localize --adopt <pkg>` and `linked delocalize <pkg>`. In a linked app, use
295
- `linked localize`.
248
+ `@_linked/rdfs` → `packages-local/_linked-rdfs`. `--list` also flags a directory there that
249
+ `local-packages.json` does not record (`UNRECORDED`).
250
+
251
+ **One copy of each package the app provides.** A checkout's own install leaves its own copies of
252
+ what it depends on, and Node loads those instead of the app's. One rule says what the app provides:
253
+ the localized packages, plus every runtime dependency (`dependencies`, `peerDependencies`,
254
+ `optionalDependencies`) a localized checkout declares that the app has at a version satisfying
255
+ every localized range, plus `react` and `react-dom`. After every install in a checkout and on every
256
+ `--relink`, the checkouts' own copies of those are removed; `linked start`, `script`, `call` and
257
+ `build-all` re-check first (stat-only, one line of output when it removes something), and
258
+ `createViteConfig` derives Vite's `resolve.dedupe` from the same rule. `--no-prune` keeps every
259
+ checkout's `node_modules` as npm left it.
260
+
261
+ Localize used to be the separate `@_linked/localize` package (binary `linked-localize`), now
262
+ deprecated; `linked localize` replaces it.
296
263
 
297
264
  ### Registry / dev utilities
298
265
 
@@ -1869,7 +1869,7 @@ export const createPackage = (name_1, uriBase_1, ...args_1) => __awaiter(void 0,
1869
1869
  else {
1870
1870
  // localize's own naming, so `linked localize` and this command can never
1871
1871
  // disagree about where a package lives.
1872
- const { checkoutNameFor, DEFAULT_DIR } = yield import('@_linked/localize');
1872
+ const { checkoutNameFor, DEFAULT_DIR } = yield import('./localize/index.js');
1873
1873
  targetFolder = path.join(appRoot, DEFAULT_DIR, checkoutNameFor(name));
1874
1874
  }
1875
1875
  if (fs.existsSync(targetFolder)) {
@@ -2057,7 +2057,7 @@ function installOwnRepoPackage(name, targetFolder, appRoot, decision) {
2057
2057
  log(`Added \`${RELINK_COMMAND}\` to the app's postinstall, so npm install keeps the link`);
2058
2058
  }
2059
2059
  const { adoptPackage } = yield import('./commands/localize.js');
2060
- const { EXIT_WARNED } = yield import('@_linked/localize');
2060
+ const { EXIT_WARNED } = yield import('./localize/index.js');
2061
2061
  // Only the build command matters here: adopt always installs with npm, so
2062
2062
  // the package-manager half of the plan does not apply.
2063
2063
  const { buildCommand } = planPackageSetup('', path.join(getScriptDir(), 'launch.js'), process.execPath);