@astryxdesign/cli 0.7.5-canary.fccd771 → 0.7.5

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 (117) hide show
  1. package/CHANGELOG.md +91 -3
  2. package/README.md +2 -2
  3. package/api/hook/detail/detail.test.mjs +11 -0
  4. package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
  5. package/api/integration/pack-check.mjs +10 -4
  6. package/api/integration/pack-check.test.mjs +5 -1
  7. package/api/swizzle/copy/copy.mjs +1 -1
  8. package/api/template/tokenizer-showcase.test.mjs +47 -0
  9. package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
  10. package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
  11. package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
  12. package/api/theme/build/build.icon-variants.test.mjs +105 -0
  13. package/api/theme/build/build.mjs +371 -113
  14. package/api/theme/build/build.project-core.test.mjs +63 -8
  15. package/api/theme/build/build.test.mjs +77 -0
  16. package/api/theme/build/icon-imports.d.mts +12 -2
  17. package/api/theme/build/icon-imports.mjs +36 -11
  18. package/api/upgrade/_adapter.d.mts +47 -2
  19. package/api/upgrade/_adapter.mjs +58 -2
  20. package/api/upgrade/run/failure-receipt.test.mjs +212 -0
  21. package/api/upgrade/run/outcomes.test.mjs +646 -0
  22. package/api/upgrade/run/run.d.mts +36 -0
  23. package/api/upgrade/run/run.mjs +670 -44
  24. package/api/upgrade/upgrade.doc.mjs +4 -4
  25. package/api/upgrade/upgrade.mjs +19 -4
  26. package/api/upgrade/upgrade.type.d.mts +36 -1
  27. package/api/upgrade/upgrade.type.mjs +29 -4
  28. package/assets/codemods/__tests__/registry.test.mjs +1 -0
  29. package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
  30. package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
  31. package/assets/codemods/integration-runner.mjs +8 -2
  32. package/assets/codemods/integration-runner.protection.test.mjs +53 -0
  33. package/assets/codemods/outcome.mjs +79 -0
  34. package/assets/codemods/outcome.test.mjs +40 -0
  35. package/assets/codemods/parse.mjs +94 -0
  36. package/assets/codemods/registry.mjs +1 -0
  37. package/assets/codemods/run-codemod.mjs +109 -5
  38. package/assets/codemods/runner.mjs +119 -13
  39. package/assets/codemods/transform-prop.mjs +99 -49
  40. package/assets/codemods/transform-prop.test.mjs +36 -1
  41. package/assets/codemods/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +1 -1
  42. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
  43. package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
  44. package/assets/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +1 -1
  45. package/assets/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +1 -1
  46. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +1 -1
  47. package/assets/codemods/transforms/v0.2.0/remove-tablist-orientation.mjs +1 -1
  48. package/assets/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs +1 -1
  49. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
  50. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
  51. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +143 -70
  52. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
  53. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
  54. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +23 -78
  55. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
  56. package/assets/codemods/transforms/v0.7.5/index.mjs +20 -0
  57. package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +315 -0
  58. package/assets/docs/README.md +13 -13
  59. package/assets/docs/author-a-theme.doc.mjs +5 -1
  60. package/assets/docs/getting-started.doc.mjs +5 -5
  61. package/assets/docs/icons.doc.mjs +82 -1
  62. package/assets/docs/motion.doc.mjs +1 -1
  63. package/assets/docs/theme.doc.dense.mjs +8 -0
  64. package/assets/docs/theme.doc.mjs +16 -0
  65. package/assets/docs/theme.doc.zh.mjs +11 -0
  66. package/assets/docs/tree/i18n-library-integration.doc.mjs +1 -1
  67. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  68. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  69. package/assets/docs/tree/tokens-color.doc.mjs +145 -1
  70. package/assets/docs/tree/tokens-ease.doc.mjs +4 -0
  71. package/assets/docs/tree/tokens.doc.mjs +1 -1
  72. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
  73. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
  74. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
  75. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
  76. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
  77. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
  78. package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
  79. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +13 -6
  80. package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
  81. package/assets/templates/pages/library/page.tsx +1 -2
  82. package/assets/templates/pages/table-comparison/page.tsx +12 -3
  83. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
  84. package/assets/templates/themes/butter/butterTheme.ts +47 -44
  85. package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
  86. package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
  87. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
  88. package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
  89. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
  90. package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
  91. package/assets/templates/themes/stone/stoneTheme.ts +46 -21
  92. package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
  93. package/assets/theme.template.ts +19 -6
  94. package/authoring/codemod/type.ts +10 -0
  95. package/authoring/config/config.doc.mjs +1 -1
  96. package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
  97. package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
  98. package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
  99. package/clients/cli/commands/upgrade.doc.mjs +47 -2
  100. package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
  101. package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
  102. package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
  103. package/clients/cli/commands/upgrade.mjs +9 -2
  104. package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
  105. package/foundation/agent-docs/agent-docs.mjs +1 -0
  106. package/foundation/agent-docs/agent-docs.test.mjs +5 -0
  107. package/foundation/config/project.d.mts +1 -1
  108. package/foundation/config/project.mjs +1 -1
  109. package/foundation/debug/redact.test.mjs +1 -1
  110. package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
  111. package/foundation/response/base.d.ts +7 -0
  112. package/foundation/response/error-codes.doc.mjs +3 -2
  113. package/foundation/response/error-codes.mjs +1 -1
  114. package/foundation/response/json.d.mts +10 -3
  115. package/foundation/response/json.mjs +16 -4
  116. package/foundation/response/response-types.doc.mjs +1 -1
  117. package/package.json +13 -12
@@ -0,0 +1,350 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx upgrade` end to end: generated files to rebuild are listed in
5
+ * `regenerate` with their commands. A file the project protects keeps the run
6
+ * incomplete (ERR_CODEMOD_PROTECTED, as for any protected file); one nothing
7
+ * protects stays a codemod error (ERR_CODEMOD_FAILED). A declared
8
+ * regeneration clears them, and a real codemod failure keeps its
9
+ * ERR_CODEMOD_FAILED error.
10
+ * Manual migrations are covered at the API level in
11
+ * `api/upgrade/run/outcomes.test.mjs`.
12
+ */
13
+
14
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
15
+ import {spawnSync} from 'node:child_process';
16
+ import * as fs from 'node:fs';
17
+ import * as os from 'node:os';
18
+ import * as path from 'node:path';
19
+ import {fileURLToPath} from 'node:url';
20
+ import {CLI_VERSION} from '../../../test-utils/release-fixtures.mjs';
21
+
22
+ const CLI = path.resolve(
23
+ path.dirname(fileURLToPath(import.meta.url)),
24
+ '..',
25
+ 'bin',
26
+ 'astryx.mjs',
27
+ );
28
+ const CODEMOD = 'core:validate-data-token-ownership';
29
+ const STALE_THEME =
30
+ '/* @generated by `astryx theme build` */\n' +
31
+ '@layer astryx-base {\n :root { --color-data-categorical-green: #008000; }\n}\n';
32
+ const FRESH_THEME = '/* @generated by `astryx theme build` */\n.theme {}\n';
33
+ // The generated block below authored rules: the marker is not in the leading
34
+ // comment block, so nothing protects this file (spec:AST-040 FR3).
35
+ const UNPROTECTED_STALE_THEME = `.app { color: red; }\n${STALE_THEME}`;
36
+
37
+ let root;
38
+
39
+ function write(relative, contents) {
40
+ const file = path.join(root, relative);
41
+ fs.mkdirSync(path.dirname(file), {recursive: true});
42
+ fs.writeFileSync(file, contents);
43
+ }
44
+
45
+ function read(relative) {
46
+ return fs.readFileSync(path.join(root, relative), 'utf8');
47
+ }
48
+
49
+ function run(args, {json = true, cwd = root} = {}) {
50
+ const result = spawnSync(
51
+ process.execPath,
52
+ [CLI, ...(json ? ['--json'] : []), 'upgrade', ...args],
53
+ {
54
+ cwd,
55
+ encoding: 'utf8',
56
+ timeout: 60_000,
57
+ env: {...process.env, FORCE_COLOR: '0', CI: ''},
58
+ },
59
+ );
60
+ return {...result, envelope: json ? JSON.parse(result.stdout) : null};
61
+ }
62
+
63
+ /** @param {{config?: string}} [options] */
64
+ function seed({config = 'export default {};\n'} = {}) {
65
+ write(
66
+ 'package.json',
67
+ JSON.stringify({
68
+ name: 'consumer',
69
+ private: true,
70
+ dependencies: {'@astryxdesign/core': CLI_VERSION},
71
+ }),
72
+ );
73
+ write(
74
+ 'node_modules/@astryxdesign/core/package.json',
75
+ JSON.stringify({name: '@astryxdesign/core', version: CLI_VERSION}),
76
+ );
77
+ write('astryx.config.mjs', config);
78
+ }
79
+
80
+ const ONLY = ['--from', '0.6.0', '--codemod', 'validate-data-token-ownership'];
81
+
82
+ beforeEach(() => {
83
+ root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-upgrade-outcomes-'));
84
+ });
85
+
86
+ afterEach(() => {
87
+ fs.rmSync(root, {recursive: true, force: true});
88
+ });
89
+
90
+ describe('generated files to regenerate', () => {
91
+ it('are listed with the rebuild command, and in protectedFiles with the declaration that protects them', () => {
92
+ seed();
93
+ write('app/theme.css', STALE_THEME);
94
+
95
+ const applied = run([...ONLY, '--path', '.', '--apply']);
96
+
97
+ expect(applied.status).toBe(1);
98
+ expect(applied.envelope).toMatchObject({
99
+ type: 'upgrade.run',
100
+ data: {
101
+ complete: false,
102
+ errorCode: 'ERR_CODEMOD_PROTECTED',
103
+ errors: [],
104
+ declinedCandidates: [],
105
+ // The stale theme carries an @generated header, so it is a protected
106
+ // file that still requires a change, with its declaration.
107
+ protectedFiles: [
108
+ {
109
+ file: 'app/theme.css',
110
+ codemods: [CODEMOD],
111
+ reasons: ['generated'],
112
+ declarations: [expect.stringContaining('@generated')],
113
+ commands: ['astryx theme build'],
114
+ },
115
+ ],
116
+ regenerate: [
117
+ {
118
+ file: 'app/theme.css',
119
+ codemods: [CODEMOD],
120
+ commands: ['astryx theme build'],
121
+ messages: [expect.stringContaining('Rebuild it')],
122
+ },
123
+ ],
124
+ },
125
+ });
126
+ expect(read('app/theme.css')).toBe(STALE_THEME);
127
+ });
128
+
129
+ it('read as incomplete in text, never as up to date', () => {
130
+ seed();
131
+ write('app/theme.css', STALE_THEME);
132
+
133
+ const text = run([...ONLY, '--path', '.', '--apply'], {json: false});
134
+
135
+ expect(text.status).toBe(1);
136
+ expect(text.stderr).toMatch(
137
+ /ERR_CODEMOD_PROTECTED: 1 protected file still requires a codemod change:\n\s+app\/theme\.css — .*@generated/,
138
+ );
139
+ expect(text.stdout).toMatch(/Regenerate with: astryx theme build/);
140
+ expect(text.stdout).toMatch(/Upgrade incomplete/);
141
+ expect(`${text.stdout}\n${text.stderr}`).not.toMatch(/No changes needed/);
142
+ });
143
+
144
+ it('keep the incomplete result, not a config error, when astryx.config fails validation too', () => {
145
+ seed({config: "export default {theme: 'neutral'};\n"});
146
+ write('app/theme.css', STALE_THEME);
147
+
148
+ const applied = run([...ONLY, '--path', '.', '--apply']);
149
+
150
+ expect(applied.status).toBe(1);
151
+ expect(applied.envelope).toMatchObject({
152
+ type: 'upgrade.run',
153
+ data: {
154
+ complete: false,
155
+ errorCode: 'ERR_CODEMOD_PROTECTED',
156
+ protectedFiles: [expect.objectContaining({file: 'app/theme.css'})],
157
+ regenerate: [
158
+ expect.objectContaining({
159
+ file: 'app/theme.css',
160
+ commands: ['astryx theme build'],
161
+ }),
162
+ ],
163
+ // The config's own error is still listed, as main reports it.
164
+ errors: [
165
+ {
166
+ file: '.',
167
+ codemod: 'config',
168
+ error: expect.stringContaining('astryx.config'),
169
+ },
170
+ ],
171
+ },
172
+ });
173
+
174
+ const configError = applied.envelope.data.errors[0].error;
175
+ const text = run([...ONLY, '--path', '.', '--apply'], {json: false});
176
+ expect(text.status).toBe(1);
177
+ expect(text.stderr).toContain(configError);
178
+ expect(text.stdout).toMatch(/Upgrade incomplete: protected changes remain/);
179
+ });
180
+
181
+ it('include protected generated files with their header command, alongside protectedFiles', () => {
182
+ seed();
183
+ write('.gitattributes', 'generated/** linguist-generated=true\n');
184
+ write(
185
+ 'generated/panel.tsx',
186
+ '// @generated\n// Command: pnpm run gen:panel\n' +
187
+ "import {useResizable} from '@astryxdesign/core';\n" +
188
+ 'export const usePanel = () => useResizable({minSizePx: 200});\n',
189
+ );
190
+
191
+ const applied = run([
192
+ '--from',
193
+ '0.5.0',
194
+ '--codemod',
195
+ 'rename-resizable-pixel-bounds',
196
+ '--path',
197
+ '.',
198
+ '--apply',
199
+ ]);
200
+
201
+ expect(applied.status).toBe(1);
202
+ expect(applied.envelope.data).toMatchObject({
203
+ complete: false,
204
+ errorCode: 'ERR_CODEMOD_PROTECTED',
205
+ protectedFiles: [expect.objectContaining({file: 'generated/panel.tsx'})],
206
+ regenerate: [
207
+ {
208
+ file: 'generated/panel.tsx',
209
+ codemods: ['core:rename-resizable-pixel-bounds'],
210
+ commands: ['pnpm run gen:panel'],
211
+ messages: [],
212
+ },
213
+ ],
214
+ });
215
+ });
216
+
217
+ it('clear once the declared regeneration rebuilds the file', () => {
218
+ const rebuild = `require('node:fs').writeFileSync('app/theme.css', ${JSON.stringify(FRESH_THEME)})`;
219
+ seed({
220
+ config: `export default {hooks: {postCodemod: [{name: 'theme', buildCommand: () => ({command: process.execPath, args: ['-e', ${JSON.stringify(rebuild)}]})}]}};\n`,
221
+ });
222
+ write('app/theme.css', STALE_THEME);
223
+
224
+ const applied = run([...ONLY, '--path', '.', '--apply']);
225
+
226
+ expect(applied.status, applied.stderr).toBe(0);
227
+ expect(applied.envelope.data).toMatchObject({
228
+ complete: true,
229
+ regenerate: [],
230
+ modifiedFiles: ['app/theme.css'],
231
+ });
232
+ expect(read('app/theme.css')).toBe(FRESH_THEME);
233
+ });
234
+
235
+ it('report one nothing protects as a codemod error, not ERR_CODEMOD_PROTECTED', () => {
236
+ seed();
237
+ write('app/theme.css', UNPROTECTED_STALE_THEME);
238
+
239
+ const applied = run([...ONLY, '--path', '.', '--apply']);
240
+
241
+ expect(applied.status).toBe(1);
242
+ expect(applied.envelope).not.toHaveProperty('type');
243
+ expect(applied.envelope).toMatchObject({
244
+ code: 'ERR_CODEMOD_FAILED',
245
+ receipt: {
246
+ complete: false,
247
+ errorCode: 'ERR_CODEMOD_FAILED',
248
+ protectedFiles: [],
249
+ errors: [
250
+ expect.objectContaining({
251
+ file: 'app/theme.css',
252
+ codemod: CODEMOD,
253
+ error: expect.stringContaining('Rebuild it'),
254
+ }),
255
+ ],
256
+ regenerate: [
257
+ expect.objectContaining({
258
+ file: 'app/theme.css',
259
+ commands: ['astryx theme build'],
260
+ }),
261
+ ],
262
+ },
263
+ });
264
+
265
+ const text = run([...ONLY, '--path', '.', '--apply'], {json: false});
266
+ expect(text.status).toBe(1);
267
+ expect(text.stderr).toMatch(
268
+ /1 generated file must be regenerated:\n\s+app\/theme\.css — /,
269
+ );
270
+ expect(text.stderr).not.toMatch(/ERR_CODEMOD_PROTECTED/);
271
+ expect(text.stdout).toMatch(/Regenerate with: astryx theme build/);
272
+ expect(text.stdout).toMatch(/Upgrade failed/);
273
+ expect(`${text.stdout}\n${text.stderr}`).not.toMatch(
274
+ /No changes needed|Done!/,
275
+ );
276
+ });
277
+
278
+ it('name files from the folder the command runs in', () => {
279
+ seed();
280
+ write('app/theme.css', STALE_THEME);
281
+
282
+ const applied = run([...ONLY, '--path', '.', '--apply'], {
283
+ cwd: path.join(root, 'app'),
284
+ });
285
+
286
+ expect(applied.envelope.data).toMatchObject({
287
+ regenerate: [expect.objectContaining({file: 'theme.css'})],
288
+ });
289
+ });
290
+ });
291
+
292
+ describe('a real failure beside them', () => {
293
+ function seedFailing() {
294
+ seed({config: "export default {integrations: ['@acme/widgets']};\n"});
295
+ write(
296
+ 'node_modules/@acme/widgets/package.json',
297
+ JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
298
+ );
299
+ write(
300
+ 'node_modules/@acme/widgets/astryx.integration.mjs',
301
+ "export default {codemods: './codemods'};\n",
302
+ );
303
+ write(
304
+ 'node_modules/@acme/widgets/codemods/0.7.0/fail.mjs',
305
+ "export default {type: 'code', title: 'Fail on boom', transform: file => { if (file.source.includes('boom')) throw new Error('codemod boom'); return undefined; }};\n",
306
+ );
307
+ write('src/broken.ts', 'export const boom = 1;\n');
308
+ }
309
+
310
+ it('keeps the ERR_CODEMOD_FAILED error, whose receipt carries both lists', () => {
311
+ seedFailing();
312
+
313
+ const applied = run(['--from', '0.6.0', '--path', 'src', '--apply']);
314
+
315
+ expect(applied.status).toBe(1);
316
+ expect(applied.envelope).toMatchObject({
317
+ code: 'ERR_CODEMOD_FAILED',
318
+ receipt: {
319
+ complete: false,
320
+ errorCode: 'ERR_CODEMOD_FAILED',
321
+ errors: [
322
+ expect.objectContaining({
323
+ file: 'src/broken.ts',
324
+ codemod: '@acme/widgets:fail',
325
+ }),
326
+ ],
327
+ declinedCandidates: [],
328
+ regenerate: [],
329
+ },
330
+ });
331
+ });
332
+
333
+ it('with a protected file to regenerate, returns the incomplete receipt as for a protected file', () => {
334
+ seedFailing();
335
+ write('src/theme.css', STALE_THEME);
336
+
337
+ const applied = run(['--from', '0.6.0', '--path', 'src', '--apply']);
338
+
339
+ expect(applied.status).toBe(1);
340
+ expect(applied.envelope).toMatchObject({
341
+ type: 'upgrade.run',
342
+ data: {
343
+ complete: false,
344
+ errorCode: 'ERR_CODEMOD_PROTECTED',
345
+ errors: [expect.objectContaining({file: 'src/broken.ts'})],
346
+ regenerate: [expect.objectContaining({file: 'src/theme.css'})],
347
+ },
348
+ });
349
+ });
350
+ });
@@ -673,6 +673,7 @@ export function detectStylingSystem(targetDir) {
673
673
  '@stylexjs/rollup-plugin',
674
674
  '@stylexjs/webpack-plugin',
675
675
  '@stylexjs/nextjs-plugin',
676
+ '@stylexjs/unplugin',
676
677
  'vite-plugin-stylex',
677
678
  'unplugin-stylex',
678
679
  '@stylexswc/unplugin',
@@ -552,6 +552,11 @@ describe('detectStylingSystem', () => {
552
552
  expect(detectStylingSystem(tmpDir)).toBe('stylex');
553
553
  });
554
554
 
555
+ it('detects the official unplugin (the standard Vite path)', () => {
556
+ writePkg({'@stylexjs/unplugin': '0.10.0'});
557
+ expect(detectStylingSystem(tmpDir)).toBe('stylex');
558
+ });
559
+
555
560
  it('detects tailwind when tailwindcss is present', () => {
556
561
  writePkg({tailwindcss: '4.0.0'});
557
562
  expect(detectStylingSystem(tmpDir)).toBe('tailwind');
@@ -44,7 +44,7 @@ export function providerLedgerOf(project: Project): import("../integrations/prov
44
44
  /** Conventional config basenames, in load-precedence order. */
45
45
  export const CONFIG_BASENAMES: string[];
46
46
  /** Default issue tracker used when neither config nor integration routes one. */
47
- export const DEFAULT_ISSUES_URL: "https://github.com/facebook/astryx/issues/new";
47
+ export const DEFAULT_ISSUES_URL: "https://github.com/meta/astryx/issues/new";
48
48
  /**
49
49
  * The single API for reading resolved project configuration. Construct via the
50
50
  * async {@link Project.load} factory.
@@ -330,7 +330,7 @@ export const CONFIG_BASENAMES = [
330
330
 
331
331
  /** Default issue tracker used when neither config nor integration routes one. */
332
332
  export const DEFAULT_ISSUES_URL =
333
- 'https://github.com/facebook/astryx/issues/new';
333
+ 'https://github.com/meta/astryx/issues/new';
334
334
 
335
335
  /**
336
336
  * Whether this project accepts `debug` handlers contributed by the
@@ -305,7 +305,7 @@ describe('credential scrubbing', () => {
305
305
  });
306
306
 
307
307
  it.each([
308
- ['a URL', 'GET https://api.github.com/repos/facebook/astryx/pulls/4812'],
308
+ ['a URL', 'GET https://api.github.com/repos/meta/astryx/pulls/4812'],
309
309
  ['a websocket URL', 'ws://localhost:5173/hmr/client'],
310
310
  ['a proxy URL', 'http://127.0.0.1:8931/a/b/c'],
311
311
  ['a time', 'elapsed 12:30 done'],
@@ -65,12 +65,11 @@ const RUNNERS = {
65
65
  sites: ['importThemeArtifact'],
66
66
  },
67
67
  'api/theme/build/build.mjs': {
68
- runs: "theme source modules, through jiti; eval for legacy theme object literals; the project's installed Core",
68
+ runs: "theme source modules, through jiti; the project's installed Core",
69
69
  sites: [
70
70
  '.evalModule() ×2',
71
71
  '.import()',
72
72
  'createJiti ×5',
73
- 'eval ×2',
74
73
  'import(<computed>) ×3',
75
74
  ],
76
75
  },
@@ -218,10 +217,7 @@ const RUNNERS = {
218
217
  },
219
218
  'clients/cli/commands/hook.mjs': {
220
219
  runs: SELF_DOCS,
221
- sites: [
222
- 'import ../../../api/hook/hook.doc.mjs',
223
- 'import ./hook.doc.mjs',
224
- ],
220
+ sites: ['import ../../../api/hook/hook.doc.mjs', 'import ./hook.doc.mjs'],
225
221
  },
226
222
  'clients/cli/commands/init.mjs': {
227
223
  runs: SELF_DOCS,
@@ -34,6 +34,13 @@ export interface CLIError {
34
34
  error: string;
35
35
  code: ErrorCode;
36
36
  suggestions?: Suggestion[];
37
+ /**
38
+ * What the command had already done when it failed, present only on errors
39
+ * from a command that changes files before it can fail (for example the
40
+ * `upgrade.run` data of a failed `astryx upgrade`). The error is still an
41
+ * error: branch on `code`.
42
+ */
43
+ receipt?: Record<string, unknown>;
37
44
  }
38
45
 
39
46
  /** Returned by the fallback hook for commands without --json support. */
@@ -150,7 +150,8 @@ export const doc = {
150
150
  },
151
151
  {
152
152
  value: 'ERR_CODEMOD_FAILED',
153
- description: 'One or more codemods failed during an upgrade run.',
153
+ description:
154
+ 'A codemod or post-codemod hook failed during an upgrade run; the error carries a `receipt` that lists the files the run already changed.',
154
155
  },
155
156
  {
156
157
  value: 'ERR_CODEMOD_PROTECTED',
@@ -282,7 +283,7 @@ export const doc = {
282
283
  {
283
284
  value: 'ERR_VERSIONS_UNAVAILABLE',
284
285
  description:
285
- 'Nothing could answer this run, and nothing was written: the project\'s own CLI could not start and nothing else could answer, or the Core a command needs outside a project could not be installed.',
286
+ "Nothing could answer this run, and nothing was written: the project's own CLI could not start and nothing else could answer, or the Core a command needs outside a project could not be installed.",
286
287
  },
287
288
  {
288
289
  value: 'ERR_PROJECT_REQUIRED',
@@ -172,7 +172,7 @@ export const ERROR_CODES = Object.freeze({
172
172
  ERR_UNKNOWN_FEATURE: 'ERR_UNKNOWN_FEATURE',
173
173
  /** A `--codemod` value did not match any registered codemod (upgrade). */
174
174
  ERR_UNKNOWN_CODEMOD: 'ERR_UNKNOWN_CODEMOD',
175
- /** One or more codemods failed during an upgrade run. */
175
+ /** One or more codemods, or a post-codemod hook, failed during an upgrade run. */
176
176
  ERR_CODEMOD_FAILED: 'ERR_CODEMOD_FAILED',
177
177
  /** A required codemod change remains blocked by a protected consumer file. */
178
178
  ERR_CODEMOD_PROTECTED: 'ERR_CODEMOD_PROTECTED',
@@ -62,19 +62,26 @@ export function jsonOut(response: {
62
62
  * @param {import('./base').Suggestion[]} [suggestions]
63
63
  * @param {string} [code] - Explicit stable error code. Overrides any code
64
64
  * carried on a thrown Error.
65
- * @returns {{apiVersion: number, error: string, code: string, suggestions?: import('./base').Suggestion[]}}
65
+ * @param {Record<string, unknown>} [receipt] - What the failed command had
66
+ * already done, for a command that changes files before it can fail.
67
+ * Overrides a `receipt` carried on a thrown Error. Additive: the envelope
68
+ * is still an error with its `code`.
69
+ * @returns {{apiVersion: number, error: string, code: string, suggestions?: import('./base').Suggestion[], receipt?: Record<string, unknown>}}
66
70
  */
67
- export function toErrorEnvelope(err: unknown, suggestions?: import("./base").Suggestion[], code?: string): {
71
+ export function toErrorEnvelope(err: unknown, suggestions?: import("./base").Suggestion[], code?: string, receipt?: Record<string, unknown>): {
68
72
  apiVersion: number;
69
73
  error: string;
70
74
  code: string;
71
75
  suggestions?: import("./base").Suggestion[];
76
+ receipt?: Record<string, unknown>;
72
77
  };
73
78
  /**
74
79
  * Output a structured JSON error and exit.
75
80
  * @param {string} message
76
81
  * @param {import('./base').Suggestion[]} [suggestions]
77
82
  * @param {string} [code] - Stable machine-readable error code (error-codes.mjs).
83
+ * @param {Record<string, unknown>} [receipt] - What the command had already
84
+ * done before it failed (see toErrorEnvelope).
78
85
  */
79
- export function jsonError(message: string, suggestions?: import("./base").Suggestion[], code?: string): void;
86
+ export function jsonError(message: string, suggestions?: import("./base").Suggestion[], code?: string, receipt?: Record<string, unknown>): void;
80
87
  export const API_VERSION: 1;
@@ -134,9 +134,13 @@ export function jsonOut(response) {
134
134
  * @param {import('./base').Suggestion[]} [suggestions]
135
135
  * @param {string} [code] - Explicit stable error code. Overrides any code
136
136
  * carried on a thrown Error.
137
- * @returns {{apiVersion: number, error: string, code: string, suggestions?: import('./base').Suggestion[]}}
137
+ * @param {Record<string, unknown>} [receipt] - What the failed command had
138
+ * already done, for a command that changes files before it can fail.
139
+ * Overrides a `receipt` carried on a thrown Error. Additive: the envelope
140
+ * is still an error with its `code`.
141
+ * @returns {{apiVersion: number, error: string, code: string, suggestions?: import('./base').Suggestion[], receipt?: Record<string, unknown>}}
138
142
  */
139
- export function toErrorEnvelope(err, suggestions, code) {
143
+ export function toErrorEnvelope(err, suggestions, code, receipt) {
140
144
  const message =
141
145
  err instanceof Error ? err.message : typeof err === 'string' ? err : String(err);
142
146
  const carried =
@@ -145,6 +149,12 @@ export function toErrorEnvelope(err, suggestions, code) {
145
149
  /** @type {any} */
146
150
  const env = {apiVersion: API_VERSION, error: message, code: resolvedCode};
147
151
  if (Array.isArray(suggestions) && suggestions.length) env.suggestions = suggestions;
152
+ const carriedReceipt =
153
+ err && typeof err === 'object' ? /** @type {any} */ (err).receipt : undefined;
154
+ const resolvedReceipt = receipt ?? carriedReceipt;
155
+ if (resolvedReceipt && typeof resolvedReceipt === 'object') {
156
+ env.receipt = resolvedReceipt;
157
+ }
148
158
  return env;
149
159
  }
150
160
 
@@ -153,10 +163,12 @@ export function toErrorEnvelope(err, suggestions, code) {
153
163
  * @param {string} message
154
164
  * @param {import('./base').Suggestion[]} [suggestions]
155
165
  * @param {string} [code] - Stable machine-readable error code (error-codes.mjs).
166
+ * @param {Record<string, unknown>} [receipt] - What the command had already
167
+ * done before it failed (see toErrorEnvelope).
156
168
  */
157
- export function jsonError(message, suggestions, code) {
169
+ export function jsonError(message, suggestions, code, receipt) {
158
170
  process.__xdsJsonHandled = true;
159
- const err = toErrorEnvelope(message, suggestions, code);
171
+ const err = toErrorEnvelope(message, suggestions, code, receipt);
160
172
  // No-op when cliError already classified this failure — first outcome wins.
161
173
  setOutcome('error', {exitCode: 1, error: new Error(message), code: err.code});
162
174
  console.log(JSON.stringify(err, null, 2));
@@ -388,7 +388,7 @@ export const doc = {
388
388
  {
389
389
  value: 'upgrade.run',
390
390
  description:
391
- 'The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run.',
391
+ 'The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. regenerate lists generated files to rebuild, each with its codemods, commands and messages. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run.',
392
392
  },
393
393
 
394
394
  // manifest
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.5-canary.fccd771",
3
+ "version": "0.7.5",
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",
7
7
  "license": "MIT",
8
- "homepage": "https://github.com/facebook/astryx#readme",
8
+ "homepage": "https://github.com/meta/astryx#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/facebook/astryx.git",
11
+ "url": "git+https://github.com/meta/astryx.git",
12
12
  "directory": "packages/cli"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/facebook/astryx/issues"
15
+ "url": "https://github.com/meta/astryx/issues"
16
16
  },
17
17
  "keywords": [
18
18
  "astryx",
@@ -111,10 +111,10 @@
111
111
  "zod": "^4.4.3"
112
112
  },
113
113
  "peerDependencies": {
114
- "@astryxdesign/charts": "0.7.5-canary.fccd771",
115
- "@astryxdesign/core": "0.7.5-canary.fccd771",
116
- "@astryxdesign/lab": "0.7.5-canary.fccd771",
117
- "@astryxdesign/theme-neutral": "0.7.5-canary.fccd771"
114
+ "@astryxdesign/charts": "*",
115
+ "@astryxdesign/core": "*",
116
+ "@astryxdesign/lab": "*",
117
+ "@astryxdesign/theme-neutral": "*"
118
118
  },
119
119
  "peerDependenciesMeta": {
120
120
  "@astryxdesign/charts": {
@@ -131,10 +131,10 @@
131
131
  }
132
132
  },
133
133
  "devDependencies": {
134
- "@astryxdesign/charts": "0.7.5-canary.fccd771",
135
- "@astryxdesign/core": "0.7.5-canary.fccd771",
136
- "@astryxdesign/lab": "0.7.5-canary.fccd771",
137
- "@astryxdesign/theme-neutral": "0.7.5-canary.fccd771",
134
+ "@astryxdesign/charts": "*",
135
+ "@astryxdesign/core": "*",
136
+ "@astryxdesign/lab": "*",
137
+ "@astryxdesign/theme-neutral": "*",
138
138
  "@heroicons/react": "^2.2.0",
139
139
  "@stylexjs/stylex": "^0.19.0",
140
140
  "@types/babel__core": "^7.20.5",
@@ -146,6 +146,7 @@
146
146
  "postinstall": "node scripts/postinstall.mjs",
147
147
  "test": "cd ../.. && vitest run packages/cli",
148
148
  "test:watch": "cd ../.. && vitest packages/cli",
149
+ "typecheck": "pnpm typecheck:template-docs && pnpm typecheck:strict",
149
150
  "typecheck:template-docs": "tsc --project tsconfig.template-docs.json",
150
151
  "typecheck:json-api": "tsc --project tsconfig.json-api.json",
151
152
  "typecheck:strict": "tsc --project tsconfig.strict.json",