@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a860a50

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 (291) hide show
  1. package/README.md +32 -18
  2. package/api/build/build.doc.mjs +3 -3
  3. package/api/build/build.test.mjs +14 -3
  4. package/api/build/build.type.d.mts +36 -2
  5. package/api/build/build.type.mjs +25 -4
  6. package/api/build/help/help.d.mts +8 -5
  7. package/api/build/help/help.mjs +56 -6
  8. package/api/component/component.doc.mjs +11 -2
  9. package/api/component/component.mjs +29 -0
  10. package/api/component/component.test.mjs +38 -0
  11. package/api/component/component.type.d.mts +17 -7
  12. package/api/component/component.type.mjs +27 -20
  13. package/api/discover/discover.doc.mjs +1 -1
  14. package/api/discover/discover.type.d.mts +4 -4
  15. package/api/discover/discover.type.mjs +10 -10
  16. package/api/docs/_adapter.d.mts +30 -27
  17. package/api/docs/_adapter.mjs +154 -124
  18. package/api/docs/compiled-topics.test.mjs +78 -0
  19. package/api/docs/detail/detail.d.mts +0 -15
  20. package/api/docs/detail/detail.mjs +14 -78
  21. package/api/docs/detail/section/section.mjs +22 -18
  22. package/api/docs/detail/section/section.test.mjs +4 -3
  23. package/api/docs/docs.type.d.mts +4 -4
  24. package/api/docs/docs.type.mjs +10 -10
  25. package/api/docs/index/index.mjs +6 -5
  26. package/api/doctor/doctor.mjs +3 -7
  27. package/api/gap-report/gap-report.doc.mjs +7 -4
  28. package/api/hook/hook.type.d.mts +3 -3
  29. package/api/hook/hook.type.mjs +11 -11
  30. package/api/init/init.doc.mjs +4 -0
  31. package/api/init/init.test.mjs +41 -1
  32. package/api/init/remove/remove.mjs +1 -1
  33. package/api/init/run/run.mjs +20 -10
  34. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  35. package/api/integration/add-contribution.mjs +16 -3
  36. package/api/integration/add-contribution.test.mjs +84 -4
  37. package/api/integration/integrationAdd.doc.mjs +7 -4
  38. package/api/integration/integrationAddComponent.doc.mjs +1 -1
  39. package/api/integration/pack-check.mjs +49 -7
  40. package/api/integration/pack-check.test.mjs +249 -0
  41. package/api/integration/validate-integration.mjs +2 -0
  42. package/api/integration/validate-integration.test.mjs +91 -0
  43. package/api/integration/validateIntegration.doc.mjs +1 -1
  44. package/api/json/envelope-types.test.mjs +76 -0
  45. package/api/json/parseResponse.doc.mjs +2 -2
  46. package/api/layout/expand/expand.mjs +7 -5
  47. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  48. package/api/layout/grammar/grammar.mjs +2 -1
  49. package/api/layout/layoutExpand.doc.mjs +1 -1
  50. package/api/search/search-return-type.test.mjs +54 -0
  51. package/api/search/search.d.mts +2 -9
  52. package/api/search/search.doc.mjs +5 -1
  53. package/api/search/search.mjs +15 -8
  54. package/api/search/search.test.mjs +34 -0
  55. package/api/search/search.type.d.mts +1 -1
  56. package/api/search/search.type.mjs +1 -1
  57. package/api/swizzle/copy/copy.mjs +28 -11
  58. package/api/swizzle/swizzle.doc.mjs +1 -1
  59. package/api/swizzle/swizzle.type.d.mts +2 -2
  60. package/api/swizzle/swizzle.type.mjs +2 -2
  61. package/api/template/copy/copy.mjs +17 -23
  62. package/api/template/copy/copy.test.mjs +17 -0
  63. package/api/template/template.doc.mjs +2 -1
  64. package/api/template/template.type.d.mts +5 -5
  65. package/api/template/template.type.mjs +12 -12
  66. package/api/theme/add/add.binary.test.mjs +91 -0
  67. package/api/theme/add/add.mjs +15 -2
  68. package/api/theme/build/build.mjs +133 -42
  69. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  70. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  71. package/api/theme/build/build.test.mjs +127 -0
  72. package/api/theme/build/font-warning.mjs +3 -3
  73. package/api/theme/build/font-warning.test.mjs +5 -2
  74. package/api/theme/palette/generate/generate.mjs +8 -3
  75. package/api/theme/palette/generate/generate.test.mjs +96 -0
  76. package/api/theme/palette/generate/generator.d.mts +10 -13
  77. package/api/theme/palette/generate/generator.mjs +15 -4
  78. package/api/theme/palette/generate/generator.test.mjs +10 -0
  79. package/api/theme/template/template.mjs +11 -2
  80. package/api/theme/template/template.test.mjs +15 -0
  81. package/api/theme/theme.type.d.mts +170 -11
  82. package/api/theme/theme.type.mjs +94 -27
  83. package/api/theme/themeBuild.doc.mjs +7 -4
  84. package/api/theme/themeTemplate.doc.mjs +4 -1
  85. package/api/upgrade/_adapter.mjs +27 -4
  86. package/api/upgrade/list/list.mjs +2 -1
  87. package/api/upgrade/list/list.test.mjs +73 -0
  88. package/api/upgrade/status/status.mjs +2 -2
  89. package/api/upgrade/upgrade.doc.mjs +2 -1
  90. package/api/upgrade/upgrade.type.d.mts +8 -4
  91. package/api/upgrade/upgrade.type.mjs +11 -10
  92. package/assets/codemods/integration-discovery.mjs +40 -2
  93. package/assets/codemods/integration-discovery.test.mjs +58 -0
  94. package/assets/codemods/term-log.mjs +32 -8
  95. package/assets/codemods/term-log.test.mjs +19 -1
  96. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
  97. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
  98. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  99. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  100. package/assets/docs/cli-integrations.doc.mjs +9 -0
  101. package/assets/docs/styling-libraries.doc.mjs +1 -1
  102. package/assets/docs/working-with-ai.doc.mjs +1 -1
  103. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  104. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  105. package/authoring/_shared/contract.ts +22 -0
  106. package/authoring/codemod/codemod.doc.mjs +6 -1
  107. package/authoring/codemod/parse.d.mts +8 -8
  108. package/authoring/codemod/parse.mjs +8 -6
  109. package/authoring/config/config.doc.mjs +1 -1
  110. package/authoring/config/debug-composition.test.mjs +92 -0
  111. package/authoring/config/parse.d.mts +13 -13
  112. package/authoring/config/parse.mjs +8 -8
  113. package/authoring/config/type.ts +18 -6
  114. package/authoring/debug/parse.d.mts +4 -4
  115. package/authoring/debug/parse.mjs +3 -3
  116. package/authoring/doctypes/_schema.d.mts +121 -11
  117. package/authoring/doctypes/_schema.mjs +144 -13
  118. package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
  119. package/authoring/doctypes/base/type.ts +8 -4
  120. package/authoring/doctypes/command/command.doc.mjs +3 -2
  121. package/authoring/doctypes/command/parse.d.mts +2 -2
  122. package/authoring/doctypes/command/parse.mjs +1 -1
  123. package/authoring/doctypes/command/type.ts +2 -2
  124. package/authoring/doctypes/component/component.doc.mjs +5 -2
  125. package/authoring/doctypes/component/parse.d.mts +2 -2
  126. package/authoring/doctypes/component/parse.mjs +1 -1
  127. package/authoring/doctypes/component/type.ts +1 -1
  128. package/authoring/doctypes/enum/parse.d.mts +2 -2
  129. package/authoring/doctypes/enum/parse.mjs +1 -1
  130. package/authoring/doctypes/enum/type.ts +1 -1
  131. package/authoring/doctypes/function/function.doc.mjs +4 -0
  132. package/authoring/doctypes/function/parse.d.mts +2 -2
  133. package/authoring/doctypes/function/parse.mjs +1 -1
  134. package/authoring/doctypes/function/type.ts +1 -1
  135. package/authoring/doctypes/hook/hook.doc.mjs +4 -0
  136. package/authoring/doctypes/hook/parse.d.mts +2 -2
  137. package/authoring/doctypes/hook/parse.mjs +1 -1
  138. package/authoring/doctypes/hook/type.ts +1 -1
  139. package/authoring/doctypes/legacy.d.mts +6 -6
  140. package/authoring/doctypes/legacy.mjs +3 -3
  141. package/authoring/doctypes/load-contract.test.mjs +207 -0
  142. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
  143. package/authoring/doctypes/namespace/parse.d.mts +2 -2
  144. package/authoring/doctypes/namespace/parse.mjs +1 -1
  145. package/authoring/doctypes/namespace/type.ts +2 -2
  146. package/authoring/doctypes/parse.d.mts +18 -18
  147. package/authoring/doctypes/parse.mjs +9 -9
  148. package/authoring/doctypes/reference/parse.d.mts +2 -2
  149. package/authoring/doctypes/reference/parse.mjs +1 -1
  150. package/authoring/doctypes/reference/reference.doc.mjs +6 -2
  151. package/authoring/doctypes/reference/type.ts +1 -1
  152. package/authoring/doctypes/schema/parse.d.mts +2 -2
  153. package/authoring/doctypes/schema/parse.mjs +1 -1
  154. package/authoring/doctypes/schema/type.ts +2 -2
  155. package/authoring/doctypes/template/parse.d.mts +92 -1
  156. package/authoring/doctypes/template/parse.mjs +33 -1
  157. package/authoring/doctypes/template/template.doc.mjs +4 -0
  158. package/authoring/doctypes/template/type.ts +4 -1
  159. package/authoring/doctypes/types.ts +10 -10
  160. package/authoring/gap-report/parse.d.mts +9 -9
  161. package/authoring/gap-report/parse.mjs +6 -6
  162. package/authoring/gap-report/type.ts +1 -1
  163. package/authoring/identity/identity.doc.mjs +3 -2
  164. package/authoring/identity/type.ts +10 -10
  165. package/authoring/index.d.ts +19 -19
  166. package/authoring/integration/parse.d.mts +2 -2
  167. package/authoring/integration/parse.mjs +1 -1
  168. package/authoring/integration/schema.d.mts +4 -4
  169. package/authoring/integration/schema.mjs +3 -3
  170. package/authoring/integration/type.ts +1 -1
  171. package/clients/cli/command-load-failure.test.mjs +83 -0
  172. package/clients/cli/commands/blog.mjs +23 -8
  173. package/clients/cli/commands/blog.test.mjs +42 -1
  174. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  175. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  176. package/clients/cli/commands/build-theme.mjs +5 -5
  177. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  178. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  179. package/clients/cli/commands/build.doc.mjs +4 -1
  180. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  181. package/clients/cli/commands/build.mjs +32 -47
  182. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  183. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  184. package/clients/cli/commands/component/index.mjs +2 -7
  185. package/clients/cli/commands/component-package.test.mjs +18 -0
  186. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  187. package/clients/cli/commands/component.test.mjs +19 -0
  188. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  189. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  190. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  191. package/clients/cli/commands/discover.doc.mjs +4 -2
  192. package/clients/cli/commands/discover.mjs +3 -3
  193. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  194. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  195. package/clients/cli/commands/doctor.mjs +6 -16
  196. package/clients/cli/commands/doctor.test.mjs +42 -0
  197. package/clients/cli/commands/gap-report.doc.mjs +16 -5
  198. package/clients/cli/commands/gap-report.test.mjs +72 -0
  199. package/clients/cli/commands/hook/index.mjs +7 -17
  200. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  201. package/clients/cli/commands/init.doc.mjs +19 -8
  202. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  203. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  204. package/clients/cli/commands/integration-add.doc.mjs +21 -5
  205. package/clients/cli/commands/integration-authoring.test.mjs +13 -9
  206. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  207. package/clients/cli/commands/json-contract.test.mjs +33 -0
  208. package/clients/cli/commands/layout-check.doc.mjs +14 -3
  209. package/clients/cli/commands/layout-expand.doc.mjs +21 -4
  210. package/clients/cli/commands/layout.doc.mjs +2 -2
  211. package/clients/cli/commands/layout.mjs +21 -9
  212. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  213. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  214. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  215. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  216. package/clients/cli/commands/search.doc.mjs +5 -2
  217. package/clients/cli/commands/search.mjs +13 -2
  218. package/clients/cli/commands/search.test.mjs +61 -0
  219. package/clients/cli/commands/swizzle.doc.mjs +2 -1
  220. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  221. package/clients/cli/commands/template.doc.mjs +28 -6
  222. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  223. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  224. package/clients/cli/commands/theme-add.doc.mjs +2 -1
  225. package/clients/cli/commands/theme-build.doc.mjs +7 -6
  226. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  227. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  228. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  229. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  230. package/clients/cli/commands/upgrade.doc.mjs +17 -6
  231. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  232. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  233. package/clients/cli/index.mjs +13 -30
  234. package/clients/cli/latest-version-env.test.mjs +50 -0
  235. package/clients/cli/lib/cli-error.test.mjs +7 -0
  236. package/clients/cli/lib/component-format.mjs +9 -9
  237. package/clients/cli/lib/component-format.test.mjs +1 -1
  238. package/clients/cli/lib/define-command.mjs +32 -6
  239. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  240. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  241. package/clients/cli/lib/hook-format.mjs +5 -5
  242. package/clients/cli/lib/json-shim.mjs +38 -2
  243. package/clients/cli/lib/json-shim.test.mjs +83 -0
  244. package/clients/cli/lib/manifest.d.ts +2 -0
  245. package/clients/cli/lib/manifest.mjs +22 -0
  246. package/clients/cli/lib/manifest.test.mjs +17 -0
  247. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  248. package/foundation/agent-docs/agent-docs.mjs +69 -3
  249. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  250. package/foundation/config/integration-debug.test.mjs +28 -3
  251. package/foundation/config/project.mjs +123 -9
  252. package/foundation/config/project.test.mjs +126 -0
  253. package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
  254. package/foundation/discovery/docs-discovery.d.mts +4 -0
  255. package/foundation/discovery/docs-discovery.mjs +16 -2
  256. package/foundation/discovery/docs-discovery.test.mjs +47 -11
  257. package/foundation/discovery/template-adapter.d.mts +14 -5
  258. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  259. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  260. package/foundation/discovery/template-adapter.mjs +292 -25
  261. package/foundation/discovery/theming-targets.test.mjs +4 -0
  262. package/foundation/doc-compiler/compile.d.mts +162 -0
  263. package/foundation/doc-compiler/compile.mjs +262 -0
  264. package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
  265. package/foundation/doc-compiler/ir.d.mts +9 -0
  266. package/foundation/doc-compiler/ir.mjs +287 -0
  267. package/foundation/doc-compiler/lenses.d.mts +33 -0
  268. package/foundation/doc-compiler/lenses.mjs +127 -0
  269. package/foundation/fs/module-loader.d.mts +1 -0
  270. package/foundation/fs/module-loader.mjs +50 -1
  271. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  272. package/foundation/fs/path-safety.d.mts +3 -2
  273. package/foundation/fs/path-safety.mjs +49 -19
  274. package/foundation/fs/path-safety.test.mjs +50 -0
  275. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  276. package/foundation/integrations/autolink.mjs +6 -1
  277. package/foundation/response/base.d.ts +8 -4
  278. package/foundation/response/error-codes.doc.mjs +1 -2
  279. package/foundation/response/error-codes.mjs +1 -1
  280. package/foundation/response/error-codes.test.mjs +83 -0
  281. package/foundation/response/json-contract.test.mjs +11 -0
  282. package/foundation/response/json.d.mts +4 -2
  283. package/foundation/response/json.mjs +8 -10
  284. package/foundation/response/response-types.doc.mjs +3 -3
  285. package/foundation/xle/expand.d.mts +2 -0
  286. package/foundation/xle/expand.mjs +3 -2
  287. package/foundation/xle/expand.test.mjs +54 -0
  288. package/package.json +9 -11
  289. package/clients/cli/lib/update-check.mjs +0 -83
  290. package/clients/cli/lib/update-check.test.mjs +0 -137
  291. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -0,0 +1,188 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx upgrade` documents how its flags interact and when it exits 1,
5
+ * and behaves as documented. Option text is read from the generated manifest
6
+ * (the same strings `--help` prints); exit codes from the CommandDoc.
7
+ */
8
+
9
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
10
+ import * as fs from 'node:fs';
11
+ import * as os from 'node:os';
12
+ import * as path from 'node:path';
13
+ import {runCli} from '../../../test-utils/run-cli.mjs';
14
+ import {doc as upgradeDoc} from './upgrade.doc.mjs';
15
+
16
+ const SLOW = 30_000;
17
+
18
+ /** @type {string} */
19
+ let tmpDir;
20
+
21
+ beforeEach(() => {
22
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-upgrade-flags-'));
23
+ fs.writeFileSync(path.join(tmpDir, 'package.json'), JSON.stringify({name: 'consumer'}));
24
+ fs.mkdirSync(path.join(tmpDir, 'src'));
25
+ fs.writeFileSync(path.join(tmpDir, 'src', 'index.ts'), 'const foo = 1;\n');
26
+ });
27
+
28
+ afterEach(() => {
29
+ fs.rmSync(tmpDir, {recursive: true, force: true});
30
+ });
31
+
32
+ /** @param {string} name @param {string} version */
33
+ function installPackage(name, version) {
34
+ const dir = path.join(tmpDir, 'node_modules', ...name.split('/'));
35
+ fs.mkdirSync(dir, {recursive: true});
36
+ fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({name, version}));
37
+ }
38
+
39
+ /** @param {string} rel @param {string} body */
40
+ function write(rel, body) {
41
+ fs.mkdirSync(path.dirname(path.join(tmpDir, rel)), {recursive: true});
42
+ fs.writeFileSync(path.join(tmpDir, rel), body);
43
+ }
44
+
45
+ /**
46
+ * upgrade's option descriptions from the manifest, keyed by long flag.
47
+ * @returns {Promise<Record<string, string>>}
48
+ */
49
+ async function upgradeOptions() {
50
+ const {stdout} = await runCli(['--json', 'manifest'], tmpDir);
51
+ const upgrade = JSON.parse(stdout).data.commands.find(
52
+ (/** @type {{name: string}} */ c) => c.name === 'upgrade',
53
+ );
54
+ return Object.fromEntries(
55
+ upgrade.options.map((/** @type {{flag: string, description: string}} */ o) => [
56
+ o.flag.match(/--[a-z-]+/)?.[0],
57
+ o.description,
58
+ ]),
59
+ );
60
+ }
61
+
62
+ /** @param {string[]} args */
63
+ async function upgradeJson(args) {
64
+ const result = await runCli(['--json', 'upgrade', ...args], tmpDir);
65
+ return {status: result.status, envelope: JSON.parse(result.stdout)};
66
+ }
67
+
68
+ const exit1 = () => upgradeDoc.exitCodes?.find(e => e.code === 1)?.when ?? '';
69
+
70
+ const MIGRATION_FLAGS = [
71
+ ['--from', '0.5.0'],
72
+ ['--force'],
73
+ ['--codemod', 'x'],
74
+ ['--skip-codemod', 'x'],
75
+ ['--integration', 'x'],
76
+ ['--install-deps'],
77
+ ];
78
+
79
+ describe('astryx upgrade flag interactions', () => {
80
+ it('--list: help says it ignores every other flag but --registry, and it does', async () => {
81
+ const options = await upgradeOptions();
82
+ expect(options['--list']).toMatch(/Every other flag is ignored, except --registry/);
83
+
84
+ installPackage('@astryxdesign/core', '0.6.0');
85
+ const listed = await upgradeJson([
86
+ '--list',
87
+ '--from',
88
+ 'bogus',
89
+ '--codemod',
90
+ 'bogus',
91
+ '--apply',
92
+ '--path',
93
+ '../outside',
94
+ ]);
95
+ expect(listed.status).toBe(0);
96
+ expect(listed.envelope.type).toBe('upgrade.list');
97
+
98
+ const refused = await upgradeJson(['--list', '--registry']);
99
+ expect(refused.status).toBe(1);
100
+ expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
101
+ }, SLOW);
102
+
103
+ it('--registry: help names every flag it refuses, and each exits 1', async () => {
104
+ const options = await upgradeOptions();
105
+ for (const [flag] of MIGRATION_FLAGS) expect(options['--registry']).toContain(flag);
106
+ expect(options['--registry']).toContain('--list');
107
+ expect(options['--registry']).toContain('ERR_INVALID_ARGUMENT');
108
+
109
+ for (const flag of MIGRATION_FLAGS) {
110
+ const {status, envelope} = await upgradeJson(['--registry', ...flag]);
111
+ expect(status, flag[0]).toBe(1);
112
+ expect(envelope.code, flag[0]).toBe('ERR_INVALID_ARGUMENT');
113
+ }
114
+ }, SLOW);
115
+
116
+ it('--codemod: help says it runs optional codemods and skips the composition check, and it does', async () => {
117
+ const options = await upgradeOptions();
118
+ expect(options['--codemod']).toMatch(/Optional codemods run only when named here/);
119
+ expect(options['--codemod']).toMatch(/skips the check of ShadCN-copied compositions/);
120
+
121
+ installPackage('@astryxdesign/core', '0.0.15');
122
+ // An unreadable receipt leaves a registry item unresolved.
123
+ write('src/components/.astryx/broken.json', '{}');
124
+
125
+ const normal = await upgradeJson(['--from', '0.0.14']);
126
+ expect(normal.status).toBe(1);
127
+ expect(normal.envelope.data.registryCompositions.invalid).toBe(1);
128
+
129
+ // 0.0.15 ships one optional codemod, which only runs when named.
130
+ const named = await upgradeJson(['--from', '0.0.14', '--codemod', 'migrate-theme-selectors-to-data-attrs']);
131
+ expect(named.status).toBe(0);
132
+ expect(named.envelope.data.codemods).toBe(1);
133
+ expect(named.envelope.data.registryCompositions).toBeUndefined();
134
+ expect(normal.envelope.data.codemods).toBe(6);
135
+ }, SLOW);
136
+
137
+ it('--from: help names the legacy @xds/core target, which upgrade falls back to', async () => {
138
+ const options = await upgradeOptions();
139
+ expect(options['--from']).toMatch(/legacy @xds\/core/);
140
+
141
+ installPackage('@xds/core', '0.0.20');
142
+ const {status, envelope} = await upgradeJson(['--from', '0.0.19']);
143
+ expect(status).toBe(0);
144
+ expect(envelope.data.to).toBe('0.0.20');
145
+ }, SLOW);
146
+ });
147
+
148
+ describe('astryx upgrade exit codes', () => {
149
+ it('lists a missing core, which exits 1 in both modes', async () => {
150
+ expect(exit1()).toMatch(/no installed @astryxdesign\/core/);
151
+ const text = await runCli(['upgrade', '--from', '0.5.0'], tmpDir);
152
+ const json = await upgradeJson(['--from', '0.5.0']);
153
+ expect(text.status).toBe(1);
154
+ expect(json.status).toBe(1);
155
+ expect(json.envelope.code).toBe('ERR_VERSION_DETECT');
156
+ }, SLOW);
157
+
158
+ it('lists an astryx.config no codemod repairs, which exits 1', async () => {
159
+ expect(exit1()).toMatch(/astryx\.config that fails validation/);
160
+ installPackage('@astryxdesign/core', '0.6.0');
161
+ write('astryx.config.mjs', "export default {theme: 'neutral'};\n");
162
+ const {status, envelope} = await upgradeJson(['--from', '0.5.0']);
163
+ expect(status).toBe(1);
164
+ expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');
165
+ }, SLOW);
166
+
167
+ it('lists a post-codemod hook failure, which exits 1', async () => {
168
+ expect(exit1()).toMatch(/post-codemod hook failure/);
169
+ installPackage('@astryxdesign/core', '0.6.0');
170
+ write(
171
+ 'src/panel.tsx',
172
+ "import {useResizable} from '@astryxdesign/core';\nexport const r = () => useResizable({minSizePx: 200});\n",
173
+ );
174
+ write(
175
+ 'astryx.config.mjs',
176
+ "export default {hooks: {postCodemod: [{buildCommand: () => { throw new Error('formatter crashed'); }}]}};\n",
177
+ );
178
+ const {status, envelope} = await upgradeJson(['--from', '0.5.0']);
179
+ expect(status).toBe(1);
180
+ expect(envelope.code).toBe('ERR_CODEMOD_FAILED');
181
+ expect(envelope.error).toMatch(/Post-codemod hook failed/);
182
+ }, SLOW);
183
+
184
+ it('lists a missing jscodeshift and the refused flag combinations', () => {
185
+ expect(exit1()).toMatch(/jscodeshift missing and not installed/);
186
+ expect(exit1()).toMatch(/--registry with --list or a migration flag/);
187
+ });
188
+ });
@@ -0,0 +1,88 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Subprocess test: a post-codemod hook that prints must not corrupt the
5
+ * `upgrade --json` envelope. Stdout carries exactly one envelope; the hook's
6
+ * output goes to stderr.
7
+ */
8
+
9
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
10
+ import {spawnSync} from 'node:child_process';
11
+ import * as fs from 'node:fs';
12
+ import * as path from 'node:path';
13
+ import * as os from 'node:os';
14
+ import {fileURLToPath} from 'node:url';
15
+
16
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
+ const CLI = path.resolve(__dirname, '..', 'bin', 'astryx.mjs');
18
+
19
+ let tmpDir;
20
+
21
+ /** @param {string} rel @param {string} body */
22
+ function write(rel, body) {
23
+ const file = path.join(tmpDir, rel);
24
+ fs.mkdirSync(path.dirname(file), {recursive: true});
25
+ fs.writeFileSync(file, body);
26
+ }
27
+
28
+ /** @param {string[]} args */
29
+ function runCli(args) {
30
+ return spawnSync(process.execPath, [CLI, ...args], {
31
+ cwd: tmpDir,
32
+ encoding: 'utf8',
33
+ timeout: 60_000,
34
+ stdio: ['ignore', 'pipe', 'pipe'],
35
+ env: {...process.env, FORCE_COLOR: '0', CI: ''},
36
+ });
37
+ }
38
+
39
+ beforeEach(() => {
40
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-upgrade-hook-output-'));
41
+ write('package.json', JSON.stringify({name: 'consumer', private: true}));
42
+ write(
43
+ 'node_modules/@astryxdesign/core/package.json',
44
+ JSON.stringify({name: '@astryxdesign/core', version: '0.6.0'}),
45
+ );
46
+ write(
47
+ 'src/panel.tsx',
48
+ "import {useResizable} from '@astryxdesign/core';\n" +
49
+ 'export const usePanel = () => useResizable({defaultSize: 250, minSizePx: 200});\n',
50
+ );
51
+ write(
52
+ 'astryx.config.mjs',
53
+ 'export default {hooks: {postCodemod: [{name: "noisy", buildCommand: ({files}) => {\n' +
54
+ ' console.log("hook saw " + files.join(","));\n' +
55
+ ' process.stdout.write("hook raw write\\n");\n' +
56
+ ' return null;\n' +
57
+ '}}]}};\n',
58
+ );
59
+ });
60
+
61
+ afterEach(() => {
62
+ fs.rmSync(tmpDir, {recursive: true, force: true});
63
+ });
64
+
65
+ describe('upgrade post-codemod hook output', () => {
66
+ it('keeps --json stdout to one envelope and sends hook output to stderr', () => {
67
+ const r = runCli([
68
+ '--json',
69
+ 'upgrade',
70
+ '--from',
71
+ '0.5.0',
72
+ '--codemod',
73
+ 'rename-resizable-pixel-bounds',
74
+ '--apply',
75
+ ]);
76
+
77
+ expect(r.signal).toBeNull();
78
+ expect(r.status).toBe(0);
79
+ const envelope = JSON.parse(r.stdout);
80
+ expect(envelope.type).toBe('upgrade.run');
81
+ expect(envelope.data.filesChanged).toBe(1);
82
+ expect(r.stderr).toContain('hook saw src/panel.tsx');
83
+ expect(r.stderr).toContain('hook raw write');
84
+ expect(fs.readFileSync(path.join(tmpDir, 'src/panel.tsx'), 'utf8')).toContain(
85
+ 'minSize: 200',
86
+ );
87
+ });
88
+ });
@@ -16,7 +16,6 @@ import {Command, Option} from 'commander';
16
16
  import {fileURLToPath} from 'node:url';
17
17
  import * as fs from 'node:fs';
18
18
  import * as path from 'node:path';
19
- import {checkForUpdate} from './lib/update-check.mjs';
20
19
  import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
21
20
  import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';
22
21
  import {buildManifest} from './lib/manifest.mjs';
@@ -25,7 +24,8 @@ import {emit, section, text, records} from './formatters/index.mjs';
25
24
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
26
25
  import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
27
26
  import {installJsonShim} from './lib/json-shim.mjs';
28
- import {markReportsResult} from './lib/define-command.mjs';
27
+ import {addExitCodesHelp, markReportsResult} from './lib/define-command.mjs';
28
+ import {doc as manifestDoc} from './commands/manifest.doc.mjs';
29
29
  import {isAstryxInitialized} from '../../foundation/agent-docs/agent-docs.mjs';
30
30
  import * as debug from '../../foundation/debug/index.mjs';
31
31
 
@@ -275,7 +275,6 @@ const commands = [
275
275
  {name: 'doctor', path: './commands/doctor.mjs', register: 'registerDoctor'},
276
276
  ];
277
277
 
278
- const UPDATE_HINT_COMMANDS = new Set(['component', 'docs']);
279
278
  const SETUP_NUDGE_EXEMPT = new Set(['init', 'agent-docs']);
280
279
 
281
280
  /**
@@ -352,7 +351,7 @@ export async function createProgram() {
352
351
  )
353
352
  .option(
354
353
  '--json',
355
- 'Output as typed JSON. Success envelope: { type, data }. Error envelope: { error, suggestions? }.',
354
+ 'Output as typed JSON. Success envelope: { apiVersion, type, data, meta? }. Error envelope: { apiVersion, error, code, suggestions? }.',
356
355
  )
357
356
  .addHelpCommand('help', 'Show all commands')
358
357
  .action((options, cmd) => {
@@ -499,25 +498,6 @@ export async function createProgram() {
499
498
  process.exit(1);
500
499
  });
501
500
 
502
- /**
503
- * Post-action hook: print update hint after any command output.
504
- * Only fires for commands that produce output agents read (component, docs, etc.).
505
- * Suppressed when --json is active to avoid contaminating stdout.
506
- */
507
- program.hook('postAction', (thisCommand, actionCommand) => {
508
- if (program.opts().json) return;
509
- try {
510
- if (UPDATE_HINT_COMMANDS.has(actionCommand.name())) {
511
- const hint = checkForUpdate();
512
- if (hint) {
513
- console.error(`\n${hint}`);
514
- }
515
- }
516
- } catch {
517
- // Never let update check break the CLI
518
- }
519
- });
520
-
521
501
  /**
522
502
  * Enforcement layer 3 — setup nudge. If this project hasn't run `astryx init`
523
503
  * yet (no Astryx marker in any agent-doc file — see isAstryxInitialized), remind
@@ -557,16 +537,18 @@ export async function createProgram() {
557
537
  mod[cmd.register](program);
558
538
  } catch (e) {
559
539
  // Command fails to load but CLI still works
540
+ const reason = /** @type {any} */ (e).message;
560
541
  const stub = program
561
542
  .command(cmd.name)
562
- .description(`(failed to load: ${/** @type {any} */ (e).message})`)
543
+ .description(`(failed to load: ${reason})`)
563
544
  .action(() => {
564
545
  // Nothing loaded, so nothing was answered — say that rather than
565
546
  // leaving the run's result unreported.
566
547
  debug.recordCommandResult(debug.NO_RESULT_SET);
567
- console.error(`Command "${cmd.name}" failed to load:`);
568
- console.error(/** @type {any} */ (e).message);
569
- process.exit(1);
548
+ // cliError, so --json still gets its one envelope.
549
+ cliError(`Command "${cmd.name}" failed to load: ${reason}`, {
550
+ code: ERROR_CODES.ERR_UNKNOWN,
551
+ });
570
552
  });
571
553
  markReportsResult(stub);
572
554
  }
@@ -601,20 +583,21 @@ export async function createProgram() {
601
583
  }
602
584
  // Human-readable summary as greppable records (agents should use --json).
603
585
  // One record per command: name, whether it supports --json, and the
604
- // description.
586
+ // description. Field names are the manifest entry's own keys.
605
587
  emit(
606
588
  section(`${manifest.name} v${manifest.version} (${manifest.commands.length} commands)`),
607
589
  records(
608
590
  manifest.commands.map(c => ({
609
- command: c.name,
591
+ name: c.name,
610
592
  json: c.json ? 'yes' : '',
611
593
  description: c.description || '',
612
594
  })),
613
- {fields: ['command', 'json', 'description']},
595
+ {fields: ['name', 'json', 'description']},
614
596
  ),
615
597
  text(`Run \`${getCliInvocation()} manifest --json\` for the full structured manifest.`),
616
598
  );
617
599
  });
600
+ addExitCodesHelp(manifestCommand, manifestDoc.exitCodes);
618
601
  markReportsResult(manifestCommand);
619
602
 
620
603
  // Hidden command used by package.json postinstall scripts
@@ -0,0 +1,50 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file ASTRYX_LATEST_VERSION is not a CLI control: setting it changes nothing
5
+ * a command prints. It used to append an update hint to `component` and
6
+ * `docs`.
7
+ */
8
+
9
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
10
+ import * as fs from 'node:fs';
11
+ import * as os from 'node:os';
12
+ import * as path from 'node:path';
13
+ import {runCli} from '../../test-utils/run-cli.mjs';
14
+
15
+ const VARIABLE = 'ASTRYX_LATEST_VERSION';
16
+
17
+ /** @type {string} */
18
+ let dir;
19
+ /** @type {string | undefined} */
20
+ let saved;
21
+
22
+ beforeEach(() => {
23
+ saved = process.env[VARIABLE];
24
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-latest-version-'));
25
+ // A project on an old core, so a "newer version" hint would have a reason to fire.
26
+ fs.writeFileSync(
27
+ path.join(dir, 'package.json'),
28
+ JSON.stringify({name: 'app', private: true, dependencies: {'@astryxdesign/core': '^0.0.1'}}),
29
+ );
30
+ });
31
+
32
+ afterEach(() => {
33
+ if (saved === undefined) delete process.env[VARIABLE];
34
+ else process.env[VARIABLE] = saved;
35
+ fs.rmSync(dir, {recursive: true, force: true});
36
+ });
37
+
38
+ describe('ASTRYX_LATEST_VERSION', () => {
39
+ it('does not change what astryx docs prints', async () => {
40
+ delete process.env[VARIABLE];
41
+ const without = await runCli(['docs'], {cwd: dir});
42
+ process.env[VARIABLE] = '999.0.0';
43
+ const withVariable = await runCli(['docs'], {cwd: dir});
44
+
45
+ expect(withVariable.status).toBe(without.status);
46
+ expect(withVariable.stdout).toBe(without.stdout);
47
+ expect(withVariable.stderr).toBe(without.stderr);
48
+ expect(withVariable.stderr).not.toMatch(/newer version/i);
49
+ });
50
+ });
@@ -133,6 +133,13 @@ describe('cliError — JSON mode', () => {
133
133
  expect(env.suggestions).toEqual([{name: 'Button', reason: 'closest match'}]);
134
134
  });
135
135
 
136
+ it('replaces an unregistered code with ERR_UNKNOWN', () => {
137
+ expect(() =>
138
+ cliError('EACCES: permission denied', {code: 'EACCES'}),
139
+ ).toThrow('__exit_1__');
140
+ expect(JSON.parse(stdout[0]).code).toBe('ERR_UNKNOWN');
141
+ });
142
+
136
143
  it('always exits 1 in JSON mode (custom exitCode is ignored — contract)', () => {
137
144
  expect(() => cliError('msg', {exitCode: 2})).toThrow('__exit_1__');
138
145
  expect(exitCode).toBe(1);
@@ -71,7 +71,7 @@ function formatPropsTable(props) {
71
71
  lines.push('| Prop | Type | Default | Description |');
72
72
  lines.push('|------|------|---------|-------------|');
73
73
  for (const p of props) {
74
- const def = p.default ? `\`${mdCell(p.default)}\`` : '—';
74
+ const def = p.default ? `\`${mdCell(p.default)}\`` : '-';
75
75
  const req = p.required ? ' **(required)**' : '';
76
76
  lines.push(
77
77
  `| \`${mdCell(p.name)}\` | \`${mdCell(p.type)}\` | ${def} | ${mdCell(p.description)}${req} |`,
@@ -190,11 +190,11 @@ function formatTargetsTable(docs, themeData) {
190
190
  ...themeVariants.map((/** @type {string} */ v) => `${v}*`),
191
191
  ];
192
192
 
193
- const variantsStr = variantParts.length > 0 ? variantParts.join(', ') : '—';
194
- const statesStr = states.length > 0 ? states.join(', ') : '—';
193
+ const variantsStr = variantParts.length > 0 ? variantParts.join(', ') : '-';
194
+ const statesStr = states.length > 0 ? states.join(', ') : '-';
195
195
  const dataAttrs = getTargetDataAttributes(target);
196
196
  const dataAttrsStr =
197
- dataAttrs.length > 0 ? dataAttrs.map(attr => `\`${attr}\``).join(', ') : '—';
197
+ dataAttrs.length > 0 ? dataAttrs.map(attr => `\`${attr}\``).join(', ') : '-';
198
198
 
199
199
  const className = target.deprecatedFor
200
200
  ? `\`${target.className}\` _(deprecated; use \`${target.deprecatedFor}\`)_`
@@ -342,7 +342,7 @@ export function formatFull(docs, options = {}) {
342
342
  const publicVars = docs.theming.vars.filter((/** @type {any} */ v) => !v.private && !v.derived);
343
343
 
344
344
  if (publicVars.length > 0) {
345
- sections.push('**Themeable CSS variables** — additional properties that can be overridden in `defineTheme` component overrides.\n');
345
+ sections.push('**Themeable CSS variables** - additional properties that can be overridden in `defineTheme` component overrides.\n');
346
346
  const varLines = [];
347
347
  varLines.push('| CSS Variable | Default | Description |');
348
348
  varLines.push('|-------------|---------|-------------|');
@@ -544,7 +544,7 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
544
544
  signatureProps.length > 0
545
545
  ? `${displayName}(${signatureProps.join(', ')})`
546
546
  : displayName;
547
- output.push(importHint ? `${sigStr} ← from '${importHint}'` : sigStr);
547
+ output.push(importHint ? `${sigStr} <- from '${importHint}'` : sigStr);
548
548
 
549
549
  // Description (shortened)
550
550
  if (description) {
@@ -569,7 +569,7 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
569
569
  // Derived properties (if any)
570
570
  if (docs.theming?.derived?.length) {
571
571
  const derivedNames = docs.theming.derived
572
- .map((/** @type {any} */ d) => d.expand === 'container' ? `${d.property} → container tokens` : `${d.property} → ${(d.vars || []).join(', ')}`)
572
+ .map((/** @type {any} */ d) => d.expand === 'container' ? `${d.property} -> container tokens` : `${d.property} -> ${(d.vars || []).join(', ')}`)
573
573
  .join('; ');
574
574
  output.push(` Derived: ${derivedNames}`);
575
575
  }
@@ -579,7 +579,7 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
579
579
  const { themeData = null } = options;
580
580
  const targetParts = docs.theming.targets.map((/** @type {any} */ t) => {
581
581
  const parts = [t.className];
582
- if (t.deprecatedFor) parts.push(`deprecated→${t.deprecatedFor}`);
582
+ if (t.deprecatedFor) parts.push(`deprecated->${t.deprecatedFor}`);
583
583
  const dataAttrs = getTargetDataAttributes(t);
584
584
  if (dataAttrs.length) parts.push(`preferred attrs: ${dataAttrs.join(', ')}`);
585
585
  if (t.visualProps?.length) parts.push(`variants: ${t.visualProps.join(', ')}`);
@@ -595,7 +595,7 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
595
595
 
596
596
  // Other props
597
597
  if (otherProps.length > 0) {
598
- output.push(` ${otherProps.join(' · ')}`);
598
+ output.push(` ${otherProps.join(', ')}`);
599
599
  }
600
600
 
601
601
  // First code example
@@ -157,7 +157,7 @@ describe('deprecated theming target guidance', () => {
157
157
 
158
158
  it('keeps the replacement in brief agent guidance', () => {
159
159
  expect(formatBrief(docs, 'Example')).toContain(
160
- 'astryx-old-target deprecated→new-target',
160
+ 'astryx-old-target deprecated->new-target',
161
161
  );
162
162
  });
163
163
  });
@@ -25,6 +25,7 @@
25
25
  */
26
26
 
27
27
  import {recordCommandResult} from '../../../foundation/debug/index.mjs';
28
+ import {text} from '../formatters/index.mjs';
28
29
 
29
30
  /**
30
31
  * Marks a Commander command that reports what it answered with, and says HOW:
@@ -78,6 +79,21 @@ export function markReportsResult(cmd) {
78
79
  return cmd;
79
80
  }
80
81
 
82
+ /** The CommandDoc and wrapped FunctionDoc a command was built from. */
83
+ export const COMMAND_DOCS = Symbol.for('astryx.command.docs');
84
+
85
+ /**
86
+ * The docs a command was built from; undefined for a hand-registered command.
87
+ * @param {import('commander').Command} cmd
88
+ * @returns {{
89
+ * doc: import('@astryxdesign/cli/authoring').CommandDoc,
90
+ * fn?: import('@astryxdesign/cli/authoring').FunctionDoc,
91
+ * } | undefined}
92
+ */
93
+ export function commandDocsOf(cmd) {
94
+ return /** @type {any} */ (cmd)?.[COMMAND_DOCS];
95
+ }
96
+
81
97
  /**
82
98
  * Build a Commander command from a CommandDoc and attach it to `parent`.
83
99
  *
@@ -102,6 +118,7 @@ export function defineCommand(parent, doc, {fn, action} = {}) {
102
118
  .join(' ');
103
119
 
104
120
  const cmd = parent.command(argSpec ? `${token} ${argSpec}` : token);
121
+ Object.defineProperty(cmd, COMMAND_DOCS, {value: {doc, fn}, configurable: true});
105
122
  if (doc.summary) cmd.description(doc.summary);
106
123
 
107
124
  const paramDesc = (/** @type {string | undefined} */ name) =>
@@ -126,12 +143,10 @@ export function defineCommand(parent, doc, {fn, action} = {}) {
126
143
  cmd.addOption(option);
127
144
  }
128
145
 
129
- // `choices` and `examples` are doc metadata surfaced by `astryx docs` and the
130
- // doc site; they are intentionally NOT injected into `--help` here. Choices
131
- // stay described in the option text (Commander `.choices()` would also change
132
- // validation from the api layer's ERR_INVALID_ARGUMENT), and the current CLI
133
- // help carries no per-command examples epilog. Keeping both out preserves the
134
- // exact `--help`/manifest surface as registrations migrate to this converter.
146
+ // Help ends with the documented exit codes. `choices` stay in the option
147
+ // text: Commander `.choices()` would replace the api layer's
148
+ // ERR_INVALID_ARGUMENT validation.
149
+ addExitCodesHelp(cmd, doc.exitCodes);
135
150
 
136
151
  if (action) {
137
152
  // The recording seam. An action's job ends at "here is what I answered
@@ -149,3 +164,14 @@ export function defineCommand(parent, doc, {fn, action} = {}) {
149
164
  }
150
165
  return cmd;
151
166
  }
167
+
168
+ /**
169
+ * End `cmd`'s help with a CommandDoc's exit codes.
170
+ * @param {import('commander').Command} cmd
171
+ * @param {import('@astryxdesign/cli/authoring').CommandDoc['exitCodes']} exitCodes
172
+ */
173
+ export function addExitCodesHelp(cmd, exitCodes) {
174
+ if (!exitCodes?.length) return;
175
+ const lines = exitCodes.map(({code, when}) => ` ${code} ${when}`);
176
+ cmd.addHelpText('after', `\n${text(['Exit codes:', ...lines].join('\n')).toString()}`);
177
+ }