@astryxdesign/cli 0.6.3-canary.d0d49a4 → 0.6.3-canary.db4e378

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 (206) hide show
  1. package/README.md +86 -72
  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 +35 -1
  5. package/api/build/build.type.mjs +24 -3
  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 +12 -3
  9. package/api/component/component.mjs +31 -2
  10. package/api/component/component.test.mjs +38 -0
  11. package/api/component/component.type.d.mts +16 -5
  12. package/api/component/component.type.mjs +13 -5
  13. package/api/component/detail/blocks/blocks.d.mts +2 -1
  14. package/api/component/detail/blocks/blocks.mjs +4 -3
  15. package/api/component/list/list.d.mts +0 -5
  16. package/api/component/list/list.mjs +37 -9
  17. package/api/discover/discover.doc.mjs +1 -1
  18. package/api/gap-report/gap-report.doc.mjs +7 -4
  19. package/api/init/init.doc.mjs +4 -0
  20. package/api/init/init.test.mjs +41 -1
  21. package/api/init/remove/remove.mjs +1 -1
  22. package/api/init/run/run.mjs +20 -10
  23. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  24. package/api/integration/add-contribution.mjs +11 -0
  25. package/api/integration/add-contribution.test.mjs +80 -0
  26. package/api/integration/integrationAdd.doc.mjs +7 -4
  27. package/api/integration/integrationAddComponent.doc.mjs +1 -1
  28. package/api/integration/validate-integration.mjs +2 -0
  29. package/api/integration/validate-integration.test.mjs +91 -0
  30. package/api/integration/validateIntegration.doc.mjs +1 -1
  31. package/api/json/envelope-types.test.mjs +76 -0
  32. package/api/json/parseResponse.doc.mjs +2 -2
  33. package/api/layout/expand/expand.mjs +7 -5
  34. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  35. package/api/layout/grammar/grammar.mjs +2 -1
  36. package/api/layout/layoutExpand.doc.mjs +1 -1
  37. package/api/search/search-return-type.test.mjs +54 -0
  38. package/api/search/search.d.mts +2 -9
  39. package/api/search/search.doc.mjs +5 -1
  40. package/api/search/search.mjs +10 -3
  41. package/api/search/search.test.mjs +34 -0
  42. package/api/swizzle/copy/copy.mjs +28 -11
  43. package/api/swizzle/swizzle.doc.mjs +1 -1
  44. package/api/template/copy/copy.mjs +17 -23
  45. package/api/template/copy/copy.test.mjs +17 -0
  46. package/api/template/template.doc.mjs +2 -1
  47. package/api/theme/add/add.binary.test.mjs +91 -0
  48. package/api/theme/add/add.mjs +20 -3
  49. package/api/theme/add/add.staging.test.mjs +66 -0
  50. package/api/theme/build/build.mjs +114 -37
  51. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  52. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  53. package/api/theme/build/font-warning.mjs +3 -3
  54. package/api/theme/build/font-warning.test.mjs +5 -2
  55. package/api/theme/palette/generate/generate.mjs +7 -2
  56. package/api/theme/palette/generate/generate.test.mjs +96 -0
  57. package/api/theme/palette/generate/generator.mjs +8 -1
  58. package/api/theme/palette/generate/generator.test.mjs +10 -0
  59. package/api/theme/template/template.mjs +11 -2
  60. package/api/theme/template/template.test.mjs +15 -0
  61. package/api/theme/themeBuild.doc.mjs +7 -4
  62. package/api/theme/themeTemplate.doc.mjs +4 -1
  63. package/api/upgrade/_adapter.mjs +27 -4
  64. package/api/upgrade/list/list.mjs +2 -1
  65. package/api/upgrade/list/list.test.mjs +73 -0
  66. package/api/upgrade/status/status.mjs +2 -2
  67. package/api/upgrade/upgrade.doc.mjs +2 -1
  68. package/api/upgrade/upgrade.type.d.mts +4 -0
  69. package/api/upgrade/upgrade.type.mjs +1 -0
  70. package/assets/codemods/term-log.mjs +32 -8
  71. package/assets/codemods/term-log.test.mjs +19 -1
  72. package/assets/codemods/transform-prop.mjs +109 -0
  73. package/assets/codemods/transform-prop.test.mjs +95 -0
  74. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  75. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  76. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  77. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  78. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  79. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  80. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  81. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  82. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  83. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  84. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  85. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  86. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  87. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  88. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  89. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  90. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  91. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  92. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  93. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  94. package/authoring/config/config.doc.mjs +1 -1
  95. package/authoring/config/debug-composition.test.mjs +92 -0
  96. package/authoring/config/type.ts +15 -3
  97. package/clients/cli/command-load-failure.test.mjs +83 -0
  98. package/clients/cli/commands/blog.mjs +23 -8
  99. package/clients/cli/commands/blog.test.mjs +42 -1
  100. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  101. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  102. package/clients/cli/commands/build-theme.mjs +5 -5
  103. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  104. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  105. package/clients/cli/commands/build.doc.mjs +4 -1
  106. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  107. package/clients/cli/commands/build.mjs +32 -47
  108. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  109. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  110. package/clients/cli/commands/component/index.mjs +2 -7
  111. package/clients/cli/commands/component-package.test.mjs +46 -0
  112. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  113. package/clients/cli/commands/component.test.mjs +19 -0
  114. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  115. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  116. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  117. package/clients/cli/commands/discover.doc.mjs +4 -2
  118. package/clients/cli/commands/discover.mjs +3 -3
  119. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  120. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  121. package/clients/cli/commands/doctor.mjs +6 -16
  122. package/clients/cli/commands/doctor.test.mjs +42 -0
  123. package/clients/cli/commands/gap-report.doc.mjs +16 -5
  124. package/clients/cli/commands/gap-report.test.mjs +72 -0
  125. package/clients/cli/commands/hook/index.mjs +7 -17
  126. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  127. package/clients/cli/commands/init.doc.mjs +19 -8
  128. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  129. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  130. package/clients/cli/commands/integration-add.doc.mjs +21 -5
  131. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  132. package/clients/cli/commands/json-contract.test.mjs +33 -0
  133. package/clients/cli/commands/layout-check.doc.mjs +14 -3
  134. package/clients/cli/commands/layout-expand.doc.mjs +21 -4
  135. package/clients/cli/commands/layout.doc.mjs +2 -2
  136. package/clients/cli/commands/layout.mjs +21 -9
  137. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  138. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  139. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  140. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  141. package/clients/cli/commands/search.doc.mjs +6 -3
  142. package/clients/cli/commands/search.mjs +17 -7
  143. package/clients/cli/commands/search.test.mjs +75 -0
  144. package/clients/cli/commands/swizzle.doc.mjs +2 -1
  145. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  146. package/clients/cli/commands/template.doc.mjs +28 -6
  147. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  148. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  149. package/clients/cli/commands/theme-add.doc.mjs +2 -1
  150. package/clients/cli/commands/theme-build.doc.mjs +7 -6
  151. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  152. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  153. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  154. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  155. package/clients/cli/commands/upgrade.doc.mjs +17 -6
  156. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  157. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  158. package/clients/cli/index.mjs +13 -30
  159. package/clients/cli/latest-version-env.test.mjs +50 -0
  160. package/clients/cli/lib/cli-error.test.mjs +7 -0
  161. package/clients/cli/lib/component-format.mjs +9 -9
  162. package/clients/cli/lib/component-format.test.mjs +1 -1
  163. package/clients/cli/lib/define-command.mjs +32 -6
  164. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  165. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  166. package/clients/cli/lib/hook-format.mjs +5 -5
  167. package/clients/cli/lib/json-shim.mjs +38 -2
  168. package/clients/cli/lib/json-shim.test.mjs +83 -0
  169. package/clients/cli/lib/manifest.d.ts +2 -0
  170. package/clients/cli/lib/manifest.mjs +22 -0
  171. package/clients/cli/lib/manifest.test.mjs +17 -0
  172. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  173. package/foundation/agent-docs/agent-docs.mjs +69 -3
  174. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  175. package/foundation/config/integration-debug.test.mjs +28 -3
  176. package/foundation/config/project.mjs +123 -9
  177. package/foundation/config/project.test.mjs +126 -0
  178. package/foundation/discovery/template-adapter.d.mts +14 -5
  179. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  180. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  181. package/foundation/discovery/template-adapter.mjs +292 -25
  182. package/foundation/discovery/theming-targets.test.mjs +4 -0
  183. package/foundation/fs/module-loader.d.mts +1 -0
  184. package/foundation/fs/module-loader.mjs +50 -1
  185. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  186. package/foundation/fs/path-safety.d.mts +3 -2
  187. package/foundation/fs/path-safety.mjs +49 -19
  188. package/foundation/fs/path-safety.test.mjs +50 -0
  189. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  190. package/foundation/integrations/autolink.mjs +6 -1
  191. package/foundation/response/base.d.ts +8 -4
  192. package/foundation/response/error-codes.doc.mjs +1 -2
  193. package/foundation/response/error-codes.mjs +1 -1
  194. package/foundation/response/error-codes.test.mjs +83 -0
  195. package/foundation/response/json-contract.test.mjs +11 -0
  196. package/foundation/response/json.d.mts +4 -2
  197. package/foundation/response/json.mjs +8 -10
  198. package/foundation/response/response-types.doc.mjs +10 -10
  199. package/foundation/response/response-types.doc.test.mjs +158 -0
  200. package/foundation/xle/expand.d.mts +2 -0
  201. package/foundation/xle/expand.mjs +3 -2
  202. package/foundation/xle/expand.test.mjs +54 -0
  203. package/package.json +9 -9
  204. package/clients/cli/lib/update-check.mjs +0 -83
  205. package/clients/cli/lib/update-check.test.mjs +0 -137
  206. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -0,0 +1,158 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The response-types EnumDoc names every field of the responses below,
5
+ * nested entry fields included. Fields come from real responses where one is
6
+ * cheap to produce, else from the canonical typedef.
7
+ */
8
+
9
+ import * as fs from 'node:fs';
10
+ import * as os from 'node:os';
11
+ import * as path from 'node:path';
12
+ import {describe, it, expect} from 'vitest';
13
+ import {doc} from './response-types.doc.mjs';
14
+ import {runCli} from '../../test-utils/run-cli.mjs';
15
+
16
+ /** @param {string} type */
17
+ const describedAs = (type) => doc.members.find((m) => m.value === type)?.description ?? '';
18
+
19
+ /** @param {string} text @param {string} field */
20
+ const names = (text, field) => new RegExp(`(^|\\W)${field}(\\W|$)`).test(text);
21
+
22
+ /**
23
+ * Keys of an object, plus the keys of each nested object or array entry, `depth`
24
+ * levels down.
25
+ * @param {unknown} value @param {number} depth @returns {Set<string>}
26
+ */
27
+ function fieldsOf(value, depth = 2) {
28
+ const out = new Set();
29
+ const visit = (/** @type {unknown} */ v, /** @type {number} */ d) => {
30
+ if (Array.isArray(v)) return v.forEach((item) => visit(item, d));
31
+ if (!v || typeof v !== 'object' || d < 0) return;
32
+ for (const [key, child] of Object.entries(v)) {
33
+ out.add(key);
34
+ visit(child, d - 1);
35
+ }
36
+ };
37
+ visit(value, depth);
38
+ return out;
39
+ }
40
+
41
+ /** @param {string[]} args @param {string} [cwd] */
42
+ async function data(args, cwd) {
43
+ const {status, stdout} = await runCli(['--json', ...args], cwd ? {cwd} : undefined);
44
+ expect(status, stdout).toBe(0);
45
+ return JSON.parse(stdout);
46
+ }
47
+
48
+ /** @param {string} type @param {Iterable<string>} fields */
49
+ function expectNamed(type, fields) {
50
+ const text = describedAs(type);
51
+ const missing = [...fields].filter((f) => !names(text, f));
52
+ expect(missing, `${type} omits`).toEqual([]);
53
+ }
54
+
55
+ describe('response-types EnumDoc names every field', () => {
56
+ it('component.detail: the ownership fields and parentDoc', async () => {
57
+ const res = await data(['component', 'HStack']);
58
+ expect(res.type).toBe('component.detail');
59
+ const ownership = ['package', 'import', 'sourceAvailable', 'parentDoc'];
60
+ for (const f of ownership) expect(Object.keys(res.data)).toContain(f);
61
+ expectNamed('component.detail', ownership);
62
+ // The canonical response type declares parentDoc too.
63
+ const types = fs.readFileSync(
64
+ new URL('../../api/component/component.type.mjs', import.meta.url),
65
+ 'utf8',
66
+ );
67
+ expect(types).toMatch(/@property \{string\} \[parentDoc\]/);
68
+ });
69
+
70
+ it('docs.index', async () => {
71
+ const res = await data(['docs', 'theme', '--index']);
72
+ expect(res.type).toBe('docs.index');
73
+ expectNamed('docs.index', fieldsOf(res.data));
74
+ });
75
+
76
+ it('search, across component, hook, template, and doc results', async () => {
77
+ const mixed = await data(['search', 'dashboard', '--limit', '50']);
78
+ const docsOnly = await data(['search', 'tokens', '--type', 'doc']);
79
+ expect(new Set(mixed.data.results.map((r) => r.domain))).toContain('template');
80
+ expectNamed('search', new Set([...fieldsOf(mixed.data), ...fieldsOf(docsOnly.data)]));
81
+ });
82
+
83
+ it('build.kit, including the hint a thin kit carries', async () => {
84
+ const res = await data(['build', 'zzqx-nothing-matches']);
85
+ expect(res.type).toBe('build.kit');
86
+ expect(res.data.hint).toBeDefined();
87
+ const fields = fieldsOf(res.data, 0);
88
+ for (const f of Object.keys(res.data.hint)) fields.add(f);
89
+ expectNamed('build.kit', fields);
90
+ });
91
+
92
+ it('theme.targets, including deprecatedFor', async () => {
93
+ const res = await data(['theme', 'targets']);
94
+ const fields = fieldsOf(res.data);
95
+ expect(fields).toContain('deprecatedFor');
96
+ expectNamed('theme.targets', fields);
97
+ });
98
+
99
+ it('gap-report.file, including each delivery', async () => {
100
+ const res = await data(['gap-report', 'Button', '--category', 'docs_gap', '--reason', 'probe']);
101
+ expect(res.type).toBe('gap-report.file');
102
+ expect(res.data.deliveries.length).toBeGreaterThan(0);
103
+ expectNamed('gap-report.file', fieldsOf(res.data));
104
+ });
105
+
106
+ it('theme.build, including notices', async () => {
107
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-response-types-'));
108
+ fs.writeFileSync(path.join(cwd, 'package.json'), '{"name":"app","version":"1.0.0"}');
109
+ await data(['theme', 'template', 'starter.ts'], cwd);
110
+ const res = await data(['theme', 'build', 'starter.ts', '--out', 'starter.css'], cwd);
111
+ expect(res.type).toBe('theme.build');
112
+ expectNamed('theme.build', fieldsOf(res.data));
113
+ });
114
+
115
+ it('integration.pack-check (fields from api/integration/pack-check.type.mjs)', () => {
116
+ expectNamed('integration.pack-check', [
117
+ // PackCheckData
118
+ 'name',
119
+ 'version',
120
+ 'packable',
121
+ 'tarball',
122
+ 'inventory',
123
+ 'contributions',
124
+ 'issues',
125
+ // PackCheckTarball
126
+ 'filename',
127
+ 'fileCount',
128
+ 'size',
129
+ 'unpackedSize',
130
+ // PackCheckInventory and PackCheckInventoryRoot
131
+ 'manifest',
132
+ 'roots',
133
+ 'kind',
134
+ 'path',
135
+ 'expectedFiles',
136
+ 'missingFiles',
137
+ 'complete',
138
+ 'packedFiles',
139
+ // contributions, each ContributionIdentities
140
+ 'local',
141
+ 'packed',
142
+ 'themes',
143
+ 'slug',
144
+ 'exportName',
145
+ 'components',
146
+ 'templates',
147
+ 'id',
148
+ 'type',
149
+ 'codemods',
150
+ 'docs',
151
+ 'agentDocsAppend',
152
+ // issues, each AstryxIntegrationIssue
153
+ 'code',
154
+ 'severity',
155
+ 'message',
156
+ ]);
157
+ });
158
+ });
@@ -21,3 +21,5 @@ export function expand(doc: {
21
21
  states: number;
22
22
  todos: string[];
23
23
  };
24
+ /** The most copies one `*N` repeat expands to. */
25
+ export const MAX_REPEAT: 10000;
@@ -20,7 +20,8 @@ import {PAYLOAD_PROPS} from './validate.mjs';
20
20
  import {mergeImports, renderImport, prepareSpliceModule} from './splice.mjs';
21
21
 
22
22
  const INDENT = ' ';
23
- const MAX_REPEAT = 10000;
23
+ /** The most copies one `*N` repeat expands to. */
24
+ export const MAX_REPEAT = 10000;
24
25
 
25
26
  /** @param {string | null | undefined} text */
26
27
  function slugify(text) {
@@ -642,7 +643,7 @@ class Emitter {
642
643
  /** @type {import('./xle-ast').XLENode[]} */
643
644
  const out = [];
644
645
  for (const item of items) {
645
- const count = item.repeat || 1;
646
+ const count = Math.min(item.repeat || 1, MAX_REPEAT);
646
647
  for (let i = 1; i <= count; i++) {
647
648
  const clone = count > 1 ? cloneItem(item) : item;
648
649
  if (count > 1) {
@@ -0,0 +1,54 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Expander tests for the repeat cap. Every path that expands a `*N`
5
+ * repeat — emitted children, table rows, the root count — honours MAX_REPEAT.
6
+ * Uses the real @astryxdesign/core registry.
7
+ */
8
+
9
+ import {describe, it, expect, beforeAll} from 'vitest';
10
+ import {parse} from './parse.mjs';
11
+ import {validate} from './validate.mjs';
12
+ import {buildRegistry} from './registry.mjs';
13
+ import {expand, MAX_REPEAT} from './expand.mjs';
14
+
15
+ /** @type {import('./xle-ast').Registry} */
16
+ let registry;
17
+
18
+ // The registry imports every component doc on first use; warm it once.
19
+ beforeAll(async () => {
20
+ registry = /** @type {import('./xle-ast').Registry} */ (
21
+ /** @type {unknown} */ (await buildRegistry())
22
+ );
23
+ }, 120_000);
24
+
25
+ /**
26
+ * @param {string} expression
27
+ * @returns {string}
28
+ */
29
+ function expandCode(expression) {
30
+ const doc = parse(expression);
31
+ const {errors} = validate(doc, registry, []);
32
+ expect(errors).toEqual([]);
33
+ return expand(doc, registry).code;
34
+ }
35
+
36
+ /**
37
+ * @param {string} code
38
+ * @param {string} component
39
+ */
40
+ function countOpening(code, component) {
41
+ return (code.match(new RegExp(`<(?:XDS)?${component}\\b`, 'g')) || []).length;
42
+ }
43
+
44
+ describe('expand — repeat cap', () => {
45
+ it('caps a repeated child at MAX_REPEAT copies', () => {
46
+ expect(countOpening(expandCode(`V > B*${MAX_REPEAT + 5}`), 'Button')).toBe(MAX_REPEAT);
47
+ });
48
+
49
+ it('caps repeated table rows at MAX_REPEAT copies too', () => {
50
+ expect(countOpening(expandCode(`T > TR*${MAX_REPEAT + 5} > TC`), 'TableRow')).toBe(
51
+ MAX_REPEAT,
52
+ );
53
+ });
54
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.6.3-canary.d0d49a4",
3
+ "version": "0.6.3-canary.db4e378",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -100,10 +100,10 @@
100
100
  "zod": "^4.4.3"
101
101
  },
102
102
  "peerDependencies": {
103
- "@astryxdesign/charts": "0.6.3-canary.d0d49a4",
104
- "@astryxdesign/core": "0.6.3-canary.d0d49a4",
105
- "@astryxdesign/lab": "0.6.3-canary.d0d49a4",
106
- "@astryxdesign/theme-neutral": "0.6.3-canary.d0d49a4"
103
+ "@astryxdesign/charts": "0.6.3-canary.db4e378",
104
+ "@astryxdesign/core": "0.6.3-canary.db4e378",
105
+ "@astryxdesign/lab": "0.6.3-canary.db4e378",
106
+ "@astryxdesign/theme-neutral": "0.6.3-canary.db4e378"
107
107
  },
108
108
  "peerDependenciesMeta": {
109
109
  "@astryxdesign/charts": {
@@ -120,10 +120,10 @@
120
120
  }
121
121
  },
122
122
  "devDependencies": {
123
- "@astryxdesign/charts": "0.6.3-canary.d0d49a4",
124
- "@astryxdesign/core": "0.6.3-canary.d0d49a4",
125
- "@astryxdesign/lab": "0.6.3-canary.d0d49a4",
126
- "@astryxdesign/theme-neutral": "0.6.3-canary.d0d49a4",
123
+ "@astryxdesign/charts": "0.6.3-canary.db4e378",
124
+ "@astryxdesign/core": "0.6.3-canary.db4e378",
125
+ "@astryxdesign/lab": "0.6.3-canary.db4e378",
126
+ "@astryxdesign/theme-neutral": "0.6.3-canary.db4e378",
127
127
  "@heroicons/react": "^2.2.0",
128
128
  "@stylexjs/stylex": "^0.19.0",
129
129
  "@types/babel__core": "^7.20.5",
@@ -1,83 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Check for newer @astryxdesign/core versions via local signals.
5
- *
6
- * Resolution order:
7
- * 1. $ASTRYX_LATEST_VERSION env var
8
- * 2. If unset: no hint (no network calls from this module)
9
- *
10
- * When a newer version is detected, returns a hint string for CLI output.
11
- * Also sets $ASTRYX_LATEST_VERSION for subsequent commands in the same shell.
12
- */
13
-
14
- import * as fs from 'node:fs';
15
- import * as path from 'node:path';
16
- import {semverGt} from '../../../foundation/env/semver.mjs';
17
- import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
18
-
19
- /**
20
- * Read the latest available version from local signals.
21
- * No network calls — purely an env-var check ($ASTRYX_LATEST_VERSION),
22
- * so it takes no arguments.
23
- *
24
- * @returns {string|null} Latest version string, or null if unknown
25
- */
26
- export function getLatestVersion() {
27
- // 1. Check env var (fastest — set by previous CLI run)
28
- const envVersion = process.env.ASTRYX_LATEST_VERSION;
29
- if (envVersion && /^\d+\.\d+\.\d+/.test(envVersion)) {
30
- return envVersion;
31
- }
32
-
33
- return null;
34
- }
35
-
36
- /**
37
- * Get the currently installed @astryxdesign/core version from the consumer's package.json.
38
- *
39
- * @param {string} [cwd] - Project directory
40
- * @returns {string|null} Installed version, or null
41
- */
42
- export function getInstalledVersion(cwd = process.cwd()) {
43
- try {
44
- const pkgPath = path.resolve(cwd, 'package.json');
45
- if (!fs.existsSync(pkgPath)) return null;
46
-
47
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
48
- const deps = {...pkg.dependencies, ...pkg.devDependencies};
49
- const version = deps['@astryxdesign/core'];
50
- if (!version) return null;
51
-
52
- // Strip semver range prefix
53
- return version.replace(/^[^\d]*/, '');
54
- } catch {
55
- return null;
56
- }
57
- }
58
-
59
- /**
60
- * Check for available updates and return a hint string if one exists.
61
- * Also sets $ASTRYX_LATEST_VERSION env var for subsequent commands.
62
- *
63
- * @param {string} [cwd] - Project directory
64
- * @returns {string|null} FYI hint string, or null if up to date / unknown
65
- */
66
- export function checkForUpdate(cwd = process.cwd()) {
67
- const latest = getLatestVersion();
68
- if (!latest) return null;
69
-
70
- // Persist for subsequent commands in this shell session
71
- process.env.ASTRYX_LATEST_VERSION = latest;
72
-
73
- const installed = getInstalledVersion(cwd);
74
- if (!installed) return null;
75
-
76
- // Use semver-aware comparison so '0.0.20' is correctly treated as greater
77
- // than '0.0.5' (lexicographic compare gets that backwards).
78
- if (semverGt(latest, installed)) {
79
- return `FYI: A newer version of @astryxdesign/core (${latest}) is available. Install the new package version, then run: ${getCliInvocation()} upgrade --from <old-version> --apply`;
80
- }
81
-
82
- return null;
83
- }
@@ -1,137 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- import {describe, it, expect, beforeEach, afterEach} from 'vitest';
4
- import * as fs from 'node:fs';
5
- import * as path from 'node:path';
6
- import * as os from 'node:os';
7
- import {
8
- getLatestVersion,
9
- getInstalledVersion,
10
- checkForUpdate,
11
- } from './update-check.mjs';
12
-
13
- let tmpDir;
14
- const originalEnv = {};
15
-
16
- beforeEach(() => {
17
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-update-check-'));
18
- // Save and clear env
19
- originalEnv.ASTRYX_LATEST_VERSION = process.env.ASTRYX_LATEST_VERSION;
20
- delete process.env.ASTRYX_LATEST_VERSION;
21
- });
22
-
23
- afterEach(() => {
24
- fs.rmSync(tmpDir, {recursive: true, force: true});
25
- // Restore env
26
- if (originalEnv.ASTRYX_LATEST_VERSION !== undefined) {
27
- process.env.ASTRYX_LATEST_VERSION = originalEnv.ASTRYX_LATEST_VERSION;
28
- } else {
29
- delete process.env.ASTRYX_LATEST_VERSION;
30
- }
31
- });
32
-
33
- describe('getLatestVersion', () => {
34
- it('reads from ASTRYX_LATEST_VERSION env var', () => {
35
- process.env.ASTRYX_LATEST_VERSION = '0.0.8';
36
- expect(getLatestVersion()).toBe('0.0.8');
37
- });
38
-
39
- it('ignores invalid env var values', () => {
40
- process.env.ASTRYX_LATEST_VERSION = 'not-a-version';
41
- expect(getLatestVersion()).toBeNull();
42
- });
43
-
44
- it('returns null when no signals exist', () => {
45
- fs.writeFileSync(
46
- path.join(tmpDir, 'package.json'),
47
- JSON.stringify({name: 'test'}),
48
- );
49
- expect(getLatestVersion()).toBeNull();
50
- });
51
- });
52
-
53
- describe('getInstalledVersion', () => {
54
- it('reads @astryxdesign/core version from dependencies', () => {
55
- fs.writeFileSync(
56
- path.join(tmpDir, 'package.json'),
57
- JSON.stringify({dependencies: {'@astryxdesign/core': '^0.0.7'}}),
58
- );
59
- expect(getInstalledVersion(tmpDir)).toBe('0.0.7');
60
- });
61
-
62
- it('strips semver range prefix', () => {
63
- fs.writeFileSync(
64
- path.join(tmpDir, 'package.json'),
65
- JSON.stringify({dependencies: {'@astryxdesign/core': '~0.0.5'}}),
66
- );
67
- expect(getInstalledVersion(tmpDir)).toBe('0.0.5');
68
- });
69
-
70
- it('returns null when @astryxdesign/core is not a dependency', () => {
71
- fs.writeFileSync(
72
- path.join(tmpDir, 'package.json'),
73
- JSON.stringify({dependencies: {react: '^19.0.0'}}),
74
- );
75
- expect(getInstalledVersion(tmpDir)).toBeNull();
76
- });
77
- });
78
-
79
- describe('checkForUpdate', () => {
80
- it('returns hint when newer version is available', () => {
81
- process.env.ASTRYX_LATEST_VERSION = '0.0.8';
82
- fs.writeFileSync(
83
- path.join(tmpDir, 'package.json'),
84
- JSON.stringify({dependencies: {'@astryxdesign/core': '^0.0.7'}}),
85
- );
86
-
87
- const hint = checkForUpdate(tmpDir);
88
- expect(hint).toContain('0.0.8');
89
- expect(hint).toContain('astryx upgrade --from <old-version> --apply');
90
- expect(hint).toContain('FYI');
91
- });
92
-
93
- it('returns null when up to date', () => {
94
- process.env.ASTRYX_LATEST_VERSION = '0.0.7';
95
- fs.writeFileSync(
96
- path.join(tmpDir, 'package.json'),
97
- JSON.stringify({dependencies: {'@astryxdesign/core': '^0.0.7'}}),
98
- );
99
-
100
- expect(checkForUpdate(tmpDir)).toBeNull();
101
- });
102
-
103
- it('returns null when no latest version is known', () => {
104
- fs.writeFileSync(
105
- path.join(tmpDir, 'package.json'),
106
- JSON.stringify({dependencies: {'@astryxdesign/core': '^0.0.7'}}),
107
- );
108
-
109
- expect(checkForUpdate(tmpDir)).toBeNull();
110
- });
111
-
112
- it('uses semver (not lexicographic) comparison for double-digit patches', () => {
113
- // Regression: with string compare, '0.0.20' > '0.0.5' is false because
114
- // '2' < '5' lexicographically. Users on 0.0.5 would never be told that
115
- // 0.0.20 is available.
116
- process.env.ASTRYX_LATEST_VERSION = '0.0.20';
117
- fs.writeFileSync(
118
- path.join(tmpDir, 'package.json'),
119
- JSON.stringify({dependencies: {'@astryxdesign/core': '^0.0.5'}}),
120
- );
121
-
122
- const hint = checkForUpdate(tmpDir);
123
- expect(hint).toContain('0.0.20');
124
- });
125
-
126
- it('does not suggest an upgrade when latest < installed (semver)', () => {
127
- // The mirror-image bug: '0.0.9' > '0.0.10' is true under string compare,
128
- // so a stale env hint of 0.0.9 would falsely claim it's "newer" than 0.0.10.
129
- process.env.ASTRYX_LATEST_VERSION = '0.0.9';
130
- fs.writeFileSync(
131
- path.join(tmpDir, 'package.json'),
132
- JSON.stringify({dependencies: {'@astryxdesign/core': '^0.0.10'}}),
133
- );
134
-
135
- expect(checkForUpdate(tmpDir)).toBeNull();
136
- });
137
- });
@@ -1,54 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Guards the update-hint command allowlist.
5
- *
6
- * The post-action update hint only fires for a small set of commands
7
- * (see UPDATE_HINT_COMMANDS in index.mjs). Every name in that set must
8
- * map to a real, registered command — otherwise the entry is dead and
9
- * the hint can never fire for it. This test imports the assembled
10
- * program and verifies the invariant so a stale reference can't creep in.
11
- *
12
- * Historically there was a dead 'doctor' entry in UPDATE_HINT_COMMANDS that
13
- * referenced a command that didn't exist. `doctor` is now a real command
14
- * (the health check), but it is intentionally NOT in the update-hint set —
15
- * the hint is for content commands (component/docs) that agents read, not
16
- * for the diagnostic command. This test pins both invariants.
17
- */
18
-
19
- import {describe, it, expect} from 'vitest';
20
- import {program} from './index.mjs';
21
-
22
- /** Commands the update hint is expected to fire for. */
23
- const HINTED_COMMANDS = ['component', 'docs'];
24
-
25
- /** Real commands that must NOT trigger the update hint. */
26
- const NON_HINTED_COMMANDS = ['doctor'];
27
-
28
- function registeredCommandNames() {
29
- return program.commands.map((c) => c.name());
30
- }
31
-
32
- describe('update hint commands', () => {
33
- it('fires only for real, registered commands', () => {
34
- const registered = new Set(registeredCommandNames());
35
- for (const name of HINTED_COMMANDS) {
36
- expect(registered.has(name)).toBe(true);
37
- }
38
- });
39
-
40
- it('registers the real "doctor" command', () => {
41
- const registered = new Set(registeredCommandNames());
42
- expect(registered.has('doctor')).toBe(true);
43
- });
44
-
45
- it('does not fire the update hint for the doctor command', () => {
46
- // UPDATE_HINT_COMMANDS is intentionally limited to content commands.
47
- // Doctor is a diagnostic; its output should not carry an update hint.
48
- expect(NON_HINTED_COMMANDS).not.toContain('component');
49
- expect(NON_HINTED_COMMANDS).not.toContain('docs');
50
- for (const name of NON_HINTED_COMMANDS) {
51
- expect(HINTED_COMMANDS).not.toContain(name);
52
- }
53
- });
54
- });