@_linked/cli 1.46.2 → 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.
Files changed (167) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/README.md +48 -36
  3. package/hooks/drift.cjs +169 -0
  4. package/hooks/git-hook.cjs +170 -0
  5. package/hooks/hook-shim.cjs +63 -0
  6. package/hooks/lock-at-rest.cjs +268 -0
  7. package/hooks/manifests.cjs +216 -0
  8. package/hooks/platform.cjs +25 -0
  9. package/lib/esm/app-release/build-backend.d.ts.map +1 -1
  10. package/lib/esm/app-release/build-backend.js +2 -1
  11. package/lib/esm/app-release/build-backend.js.map +1 -1
  12. package/lib/esm/cli-methods.d.ts.map +1 -1
  13. package/lib/esm/cli-methods.js +166 -150
  14. package/lib/esm/cli-methods.js.map +1 -1
  15. package/lib/esm/cli.js +20 -22
  16. package/lib/esm/cli.js.map +1 -1
  17. package/lib/esm/commands/build-app.d.ts.map +1 -1
  18. package/lib/esm/commands/build-app.js +2 -1
  19. package/lib/esm/commands/build-app.js.map +1 -1
  20. package/lib/esm/commands/build-package.d.ts.map +1 -1
  21. package/lib/esm/commands/build-package.js +6 -2
  22. package/lib/esm/commands/build-package.js.map +1 -1
  23. package/lib/esm/commands/localize.d.ts +9 -15
  24. package/lib/esm/commands/localize.d.ts.map +1 -1
  25. package/lib/esm/commands/localize.js +43 -74
  26. package/lib/esm/commands/localize.js.map +1 -1
  27. package/lib/esm/commands/setup-publish.d.ts.map +1 -1
  28. package/lib/esm/commands/setup-publish.js +22 -15
  29. package/lib/esm/commands/setup-publish.js.map +1 -1
  30. package/lib/esm/commands/start.d.ts +8 -0
  31. package/lib/esm/commands/start.d.ts.map +1 -1
  32. package/lib/esm/commands/start.js +20 -8
  33. package/lib/esm/commands/start.js.map +1 -1
  34. package/lib/esm/installed-packages.d.ts +5 -13
  35. package/lib/esm/installed-packages.d.ts.map +1 -1
  36. package/lib/esm/installed-packages.js +5 -38
  37. package/lib/esm/installed-packages.js.map +1 -1
  38. package/lib/esm/lifecycle.d.ts +35 -22
  39. package/lib/esm/lifecycle.d.ts.map +1 -1
  40. package/lib/esm/lifecycle.js +62 -36
  41. package/lib/esm/lifecycle.js.map +1 -1
  42. package/lib/esm/localize/adopt.d.ts +5 -5
  43. package/lib/esm/localize/adopt.d.ts.map +1 -1
  44. package/lib/esm/localize/adopt.js +46 -55
  45. package/lib/esm/localize/adopt.js.map +1 -1
  46. package/lib/esm/localize/app-root.d.ts +16 -0
  47. package/lib/esm/localize/app-root.d.ts.map +1 -0
  48. package/lib/esm/localize/app-root.js +94 -0
  49. package/lib/esm/localize/app-root.js.map +1 -0
  50. package/lib/esm/localize/app-setup.d.ts +21 -0
  51. package/lib/esm/localize/app-setup.d.ts.map +1 -0
  52. package/lib/esm/localize/app-setup.js +178 -0
  53. package/lib/esm/localize/app-setup.js.map +1 -0
  54. package/lib/esm/localize/delocalize.d.ts.map +1 -1
  55. package/lib/esm/localize/delocalize.js +169 -104
  56. package/lib/esm/localize/delocalize.js.map +1 -1
  57. package/lib/esm/localize/drift-hook.d.ts +18 -0
  58. package/lib/esm/localize/drift-hook.d.ts.map +1 -0
  59. package/lib/esm/localize/drift-hook.js +37 -0
  60. package/lib/esm/localize/drift-hook.js.map +1 -0
  61. package/lib/esm/localize/drift.d.ts +36 -0
  62. package/lib/esm/localize/drift.d.ts.map +1 -0
  63. package/lib/esm/localize/drift.js +34 -0
  64. package/lib/esm/localize/drift.js.map +1 -0
  65. package/lib/esm/localize/errors.d.ts +14 -8
  66. package/lib/esm/localize/errors.d.ts.map +1 -1
  67. package/lib/esm/localize/errors.js +14 -8
  68. package/lib/esm/localize/errors.js.map +1 -1
  69. package/lib/esm/localize/fsops.d.ts +11 -27
  70. package/lib/esm/localize/fsops.d.ts.map +1 -1
  71. package/lib/esm/localize/fsops.js +40 -115
  72. package/lib/esm/localize/fsops.js.map +1 -1
  73. package/lib/esm/localize/git-hooks.d.ts +33 -0
  74. package/lib/esm/localize/git-hooks.d.ts.map +1 -0
  75. package/lib/esm/localize/git-hooks.js +146 -0
  76. package/lib/esm/localize/git-hooks.js.map +1 -0
  77. package/lib/esm/localize/hook-module.d.ts +6 -0
  78. package/lib/esm/localize/hook-module.d.ts.map +1 -0
  79. package/lib/esm/localize/hook-module.js +37 -0
  80. package/lib/esm/localize/hook-module.js.map +1 -0
  81. package/lib/esm/localize/index.d.ts +14 -15
  82. package/lib/esm/localize/index.d.ts.map +1 -1
  83. package/lib/esm/localize/index.js +8 -9
  84. package/lib/esm/localize/index.js.map +1 -1
  85. package/lib/esm/localize/list.d.ts +6 -10
  86. package/lib/esm/localize/list.d.ts.map +1 -1
  87. package/lib/esm/localize/list.js +49 -189
  88. package/lib/esm/localize/list.js.map +1 -1
  89. package/lib/esm/localize/localize.d.ts +46 -62
  90. package/lib/esm/localize/localize.d.ts.map +1 -1
  91. package/lib/esm/localize/localize.js +411 -285
  92. package/lib/esm/localize/localize.js.map +1 -1
  93. package/lib/esm/localize/members.d.ts +13 -0
  94. package/lib/esm/localize/members.d.ts.map +1 -0
  95. package/lib/esm/localize/members.js +46 -0
  96. package/lib/esm/localize/members.js.map +1 -0
  97. package/lib/esm/localize/resolve.d.ts +1 -2
  98. package/lib/esm/localize/resolve.d.ts.map +1 -1
  99. package/lib/esm/localize/resolve.js +3 -5
  100. package/lib/esm/localize/resolve.js.map +1 -1
  101. package/lib/esm/localize/run.d.ts +1 -0
  102. package/lib/esm/localize/run.d.ts.map +1 -1
  103. package/lib/esm/localize/run.js +11 -6
  104. package/lib/esm/localize/run.js.map +1 -1
  105. package/lib/esm/localize/setup-lockfile.d.ts +13 -0
  106. package/lib/esm/localize/setup-lockfile.d.ts.map +1 -0
  107. package/lib/esm/localize/setup-lockfile.js +80 -0
  108. package/lib/esm/localize/setup-lockfile.js.map +1 -0
  109. package/lib/esm/utils/createPackageLocation.d.ts +4 -13
  110. package/lib/esm/utils/createPackageLocation.d.ts.map +1 -1
  111. package/lib/esm/utils/createPackageLocation.js +12 -21
  112. package/lib/esm/utils/createPackageLocation.js.map +1 -1
  113. package/lib/esm/utils/packageSetup.d.ts +5 -2
  114. package/lib/esm/utils/packageSetup.d.ts.map +1 -1
  115. package/lib/esm/utils/packageSetup.js +9 -3
  116. package/lib/esm/utils/packageSetup.js.map +1 -1
  117. package/lib/esm/utils/platform.d.ts +24 -0
  118. package/lib/esm/utils/platform.d.ts.map +1 -0
  119. package/lib/esm/utils/platform.js +62 -0
  120. package/lib/esm/utils/platform.js.map +1 -0
  121. package/lib/esm/utils/shapeReferences.d.ts.map +1 -1
  122. package/lib/esm/utils/shapeReferences.js +3 -2
  123. package/lib/esm/utils/shapeReferences.js.map +1 -1
  124. package/lib/esm/utils/spawn.d.ts +65 -0
  125. package/lib/esm/utils/spawn.d.ts.map +1 -0
  126. package/lib/esm/utils/spawn.js +181 -0
  127. package/lib/esm/utils/spawn.js.map +1 -0
  128. package/lib/esm/utils.d.ts.map +1 -1
  129. package/lib/esm/utils.js +19 -5
  130. package/lib/esm/utils.js.map +1 -1
  131. package/lib/esm/vite-config.d.ts +5 -12
  132. package/lib/esm/vite-config.d.ts.map +1 -1
  133. package/lib/esm/vite-config.js +41 -33
  134. package/lib/esm/vite-config.js.map +1 -1
  135. package/package.json +4 -3
  136. package/lib/esm/localize/ensure.d.ts +0 -44
  137. package/lib/esm/localize/ensure.d.ts.map +0 -1
  138. package/lib/esm/localize/ensure.js +0 -151
  139. package/lib/esm/localize/ensure.js.map +0 -1
  140. package/lib/esm/localize/manifest.d.ts +0 -63
  141. package/lib/esm/localize/manifest.d.ts.map +0 -1
  142. package/lib/esm/localize/manifest.js +0 -133
  143. package/lib/esm/localize/manifest.js.map +0 -1
  144. package/lib/esm/localize/one-copy-hook.d.ts +0 -16
  145. package/lib/esm/localize/one-copy-hook.d.ts.map +0 -1
  146. package/lib/esm/localize/one-copy-hook.js +0 -20
  147. package/lib/esm/localize/one-copy-hook.js.map +0 -1
  148. package/lib/esm/localize/provided.d.ts +0 -28
  149. package/lib/esm/localize/provided.d.ts.map +0 -1
  150. package/lib/esm/localize/provided.js +0 -89
  151. package/lib/esm/localize/provided.js.map +0 -1
  152. package/lib/esm/localize/prune.d.ts +0 -182
  153. package/lib/esm/localize/prune.d.ts.map +0 -1
  154. package/lib/esm/localize/prune.js +0 -703
  155. package/lib/esm/localize/prune.js.map +0 -1
  156. package/lib/esm/localize/relink.d.ts +0 -13
  157. package/lib/esm/localize/relink.d.ts.map +0 -1
  158. package/lib/esm/localize/relink.js +0 -181
  159. package/lib/esm/localize/relink.js.map +0 -1
  160. package/lib/esm/localized-dedupe.d.ts +0 -26
  161. package/lib/esm/localized-dedupe.d.ts.map +0 -1
  162. package/lib/esm/localized-dedupe.js +0 -139
  163. package/lib/esm/localized-dedupe.js.map +0 -1
  164. package/lib/esm/utils/relinkHooks.d.ts +0 -19
  165. package/lib/esm/utils/relinkHooks.d.ts.map +0 -1
  166. package/lib/esm/utils/relinkHooks.js +0 -74
  167. package/lib/esm/utils/relinkHooks.js.map +0 -1
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"relinkHoo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AAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACrE,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,MAAM,GAAG,MAAA,MAAA,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,0CAAG,CAAC,CAAC,mCAAI,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * The app scripts that put `linked localize`'s links back after npm removed\n * them. Shared by `create-package` (which sets them up before it adopts a new\n * package) and by `localize` / `adopt` (which add them when they record a\n * package into an app that does not have them yet).\n *\n * Why TWO hooks, both running the same command: npm runs an app's root\n * `postinstall` only on a bare `npm install` / `npm ci`. It runs a root\n * `dependencies` script after ANY command that changes `node_modules` --\n * `npm install <name>`, `npm update`, `npm uninstall`, `npm dedupe` (npm's\n * arborist, `reify.js`). Each of those replaces a localized link with the\n * registry copy, silently, so `postinstall` alone leaves most of them\n * unguarded. A bare `npm install` runs both scripts; `--relink` is idempotent\n * and silent when there is nothing to do, so running twice costs nothing.\n *\n * With no `local-packages.json` the command prints nothing and exits 0, so the\n * hooks are safe to commit for everyone.\n */\nimport fs from 'fs';\n\nexport const RELINK_COMMAND = 'linked localize --relink';\n\n/** The npm lifecycle scripts that run {@link RELINK_COMMAND}. See the module header. */\nexport const RELINK_HOOKS = ['postinstall', 'dependencies'] as const;\n\n/** Also matches the retired `linked-localize --relink` spelling. */\nconst RELINKS = /localize\\s+--relink/;\n\n/**\n * Make sure each of the app's {@link RELINK_HOOKS} runs {@link RELINK_COMMAND}:\n * set it when absent, append it with `&&` to a script that does something\n * else, and leave a script that already relinks alone. Mutates `pkg`.\n *\n * @returns the hooks it added the command to (empty when nothing changed).\n */\nexport function ensureRelinkHooks(pkg: Record<string, any>): string[] {\n pkg.scripts = pkg.scripts ?? {};\n const added: string[] = [];\n for (const hook of RELINK_HOOKS) {\n const current: string | undefined = pkg.scripts[hook];\n if (current && RELINKS.test(current)) continue;\n pkg.scripts[hook] = current\n ? `${current} && ${RELINK_COMMAND}`\n : RELINK_COMMAND;\n added.push(hook);\n }\n return added;\n}\n\n/**\n * {@link ensureRelinkHooks} on a `package.json` file, keeping its indentation\n * and trailing newline. A missing or unparseable file is left alone.\n *\n * @returns the hooks it added (empty when nothing changed or nothing could be).\n */\nexport function ensureRelinkHooksInFile(pkgPath: string): string[] {\n let text: string;\n let pkg: Record<string, any>;\n try {\n text = fs.readFileSync(pkgPath, 'utf8');\n pkg = JSON.parse(text);\n } catch {\n return [];\n }\n if (!pkg || typeof pkg !== 'object' || Array.isArray(pkg)) return [];\n const added = ensureRelinkHooks(pkg);\n if (!added.length) return added;\n const indent = /^[ \\t]+(?=\")/m.exec(text)?.[0] ?? 2;\n const eol = text.endsWith('\\n') ? '\\n' : '';\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + eol);\n return added;\n}\n"]}