@astryxdesign/cli 0.7.0-canary.f3a2181 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/api/doctor/doctor.d.mts +30 -2
  3. package/api/doctor/doctor.doc.mjs +2 -1
  4. package/api/doctor/doctor.mjs +153 -3
  5. package/api/doctor/doctor.test.mjs +250 -4
  6. package/assets/codemods/__tests__/registry.test.mjs +1 -0
  7. package/assets/codemods/registry.mjs +1 -0
  8. package/assets/codemods/transforms/next/index.mjs +1 -35
  9. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +202 -0
  10. package/assets/codemods/transforms/v0.7.0/index.mjs +52 -0
  11. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +254 -0
  12. package/assets/templates/themes/matcha/matchaTheme.ts +14 -14
  13. package/assets/templates/themes/y2k/y2kTheme.ts +10 -10
  14. package/assets/theme.template.ts +1 -1
  15. package/clients/cli/commands/doctor.doc.mjs +1 -1
  16. package/clients/cli/commands/doctor.test.mjs +33 -0
  17. package/package.json +9 -9
  18. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -0
  19. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/migrate-field-input-styling.test.mjs +0 -0
  20. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -0
  21. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/validate-data-token-ownership.test.mjs +0 -0
  22. /package/assets/codemods/transforms/{next → v0.7.0}/migrate-deprecated-theme-surface-v0.6-data.mjs +0 -0
  23. /package/assets/codemods/transforms/{next → v0.7.0}/migrate-deprecated-theme-surface.mjs +0 -0
  24. /package/assets/codemods/transforms/{next → v0.7.0}/migrate-field-input-styling.mjs +0 -0
  25. /package/assets/codemods/transforms/{next → v0.7.0}/preserve-bottom-sheet-content-padding.mjs +0 -0
  26. /package/assets/codemods/transforms/{next → v0.7.0}/validate-data-token-ownership.mjs +0 -0
@@ -0,0 +1,254 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Codemod: rename emptySearchResultsText to emptySearchText
5
+ *
6
+ * `emptySearchResultsText` was renamed to `emptySearchText` (`spec:AST-056`
7
+ * FR1) and the old name is removed in a minor release. The new prop takes a
8
+ * `ReactNode`, so every old `string` value stays valid and the rename never
9
+ * changes a value.
10
+ *
11
+ * A straight rename at the JSX boundary, through the shared `transformProp`
12
+ * helper: the prop on an imported `Tokenizer`, `Typeahead`, or `BaseTypeahead`
13
+ * element, and the key on `ChatComposerInput` trigger objects written inline
14
+ * in its `triggers` prop. Like every transform built on the helper it does
15
+ * not follow variables, helpers, spreads, wrappers, or types. Where it cannot
16
+ * attribute the value it leaves a TODO instead of choosing a winner: the new
17
+ * name already set, any spread onto one of these elements (whether or not the
18
+ * element writes the old name itself — a spread may carry either name or the
19
+ * triggers), a `triggers` value that is not an inline object or array, or a
20
+ * trigger object with a spread or computed key. A value forwarded through a
21
+ * spread is the one case the type checker cannot report after the removal,
22
+ * which is why every spread gets the TODO.
23
+ */
24
+
25
+ import {transformProp} from '../../transform-prop.mjs';
26
+
27
+ export const meta = {
28
+ title: 'Rename emptySearchResultsText to emptySearchText',
29
+ description:
30
+ 'Renames the removed `emptySearchResultsText` prop to `emptySearchText` ' +
31
+ 'on imported Tokenizer, Typeahead, and BaseTypeahead elements, and the ' +
32
+ "same key on trigger objects written inline in ChatComposerInput's " +
33
+ '`triggers`. Leaves a TODO where the new name is already set, on every ' +
34
+ 'spread onto these elements, where the triggers value is not written ' +
35
+ 'inline, and on a trigger object with a spread or computed key.',
36
+ };
37
+
38
+ const OLD_NAME = 'emptySearchResultsText';
39
+ const NEW_NAME = 'emptySearchText';
40
+ const CORE_IMPORT_RE = /^@(astryxdesign|xds)\/core(?:\/|$)/;
41
+
42
+ const COMPONENTS = new Map([
43
+ ['Tokenizer', new Set([OLD_NAME])],
44
+ ['Typeahead', new Set([OLD_NAME])],
45
+ ['BaseTypeahead', new Set([OLD_NAME])],
46
+ ['ChatComposerInput', new Set(['triggers'])],
47
+ ]);
48
+
49
+ const BOTH_SET_COMMENT =
50
+ ' TODO(astryx upgrade): emptySearchResultsText was removed and ' +
51
+ 'emptySearchText is already set here; delete the old one if the new value ' +
52
+ 'is what you want. ';
53
+ const UNREADABLE_OBJECT_COMMENT =
54
+ ' TODO(astryx upgrade): emptySearchResultsText was removed. Rename it to ' +
55
+ 'emptySearchText by hand; this object has a spread or computed key. ';
56
+ const SPREAD_COMMENT =
57
+ ' TODO(astryx upgrade): emptySearchResultsText was removed. This element ' +
58
+ 'spreads props that may carry either name; rename to emptySearchText ' +
59
+ 'where the props are built and delete the old one. ';
60
+ const OPAQUE_TRIGGERS_COMMENT =
61
+ ' TODO(astryx upgrade): emptySearchResultsText was removed. These triggers ' +
62
+ 'are built elsewhere; rename the key to emptySearchText where they are ' +
63
+ 'built. ';
64
+
65
+ const TYPE_WRAPPERS = new Set([
66
+ 'TSAsExpression',
67
+ 'TSSatisfiesExpression',
68
+ 'TSTypeAssertion',
69
+ 'TSNonNullExpression',
70
+ 'TypeCastExpression',
71
+ 'ParenthesizedExpression',
72
+ ]);
73
+
74
+ /** @param {any} node */
75
+ function unwrap(node) {
76
+ let current = node;
77
+ while (current && TYPE_WRAPPERS.has(current.type)) {
78
+ current = current.expression;
79
+ }
80
+ return current;
81
+ }
82
+
83
+ /** @param {any} property */
84
+ function staticPropertyName(property) {
85
+ if (property.computed) return null;
86
+ const key = property.key;
87
+ if (key?.type === 'Identifier') return key.name;
88
+ if (key?.type === 'StringLiteral' || key?.type === 'Literal') {
89
+ return typeof key.value === 'string' ? key.value : null;
90
+ }
91
+ return null;
92
+ }
93
+
94
+ /**
95
+ * Attach a comment to a node once (re-running the codemod adds nothing).
96
+ * @param {any} j @param {any} node @param {string} text
97
+ */
98
+ function addComment(j, node, text) {
99
+ node.comments ??= [];
100
+ if (node.comments.some((/** @type {any} */ c) => c.value === text)) {
101
+ return false;
102
+ }
103
+ node.comments.push(j.commentBlock(text, true, false));
104
+ return true;
105
+ }
106
+
107
+ /**
108
+ * Rename the key on one trigger object literal.
109
+ * @param {any} j @param {any} object @returns {boolean}
110
+ */
111
+ function renameTriggerKey(j, object) {
112
+ const old = object.properties.find(
113
+ (/** @type {any} */ property) => staticPropertyName(property) === OLD_NAME,
114
+ );
115
+ const unreadable = object.properties.find(
116
+ (/** @type {any} */ property) =>
117
+ property.type === 'SpreadElement' ||
118
+ property.type === 'SpreadProperty' ||
119
+ property.computed,
120
+ );
121
+ // A spread or computed key may carry the removed key itself, so the
122
+ // object gets the TODO whether or not it writes the old name.
123
+ if (unreadable) {
124
+ return addComment(j, old ?? unreadable, UNREADABLE_OBJECT_COMMENT);
125
+ }
126
+ if (!old) return false;
127
+ const already = object.properties.some(
128
+ (/** @type {any} */ property) => staticPropertyName(property) === NEW_NAME,
129
+ );
130
+ if (already) return addComment(j, old, BOTH_SET_COMMENT);
131
+ old.key = j.identifier(NEW_NAME);
132
+ if (old.shorthand) old.shorthand = false;
133
+ return true;
134
+ }
135
+
136
+ /** @param {any} fileInfo @param {any} api */
137
+ export default function transform(fileInfo, api) {
138
+ const j = api.jscodeshift;
139
+ const root = j(fileInfo.source);
140
+ let changed = false;
141
+
142
+ transformProp(
143
+ root,
144
+ j,
145
+ {
146
+ matchesImport: source => CORE_IMPORT_RE.test(source),
147
+ components: COMPONENTS,
148
+ },
149
+ (propPath, {component}) => {
150
+ const prop = propPath.node;
151
+ const attributes = propPath.parent.node.attributes ?? [];
152
+ const hasSpread = attributes.some(
153
+ (/** @type {any} */ attribute) =>
154
+ attribute.type === 'JSXSpreadAttribute',
155
+ );
156
+ if (component === 'ChatComposerInput') {
157
+ // `triggers={[{...}, {...}]}` or `triggers={{...}}`: rename the key
158
+ // on each object written inline; a value built elsewhere, or an
159
+ // element whose spread may carry triggers, gets a TODO.
160
+ const value =
161
+ prop.value?.type === 'JSXExpressionContainer'
162
+ ? unwrap(prop.value.expression)
163
+ : null;
164
+ const items =
165
+ value?.type === 'ArrayExpression'
166
+ ? value.elements.map((/** @type {any} */ e) => unwrap(e))
167
+ : [value];
168
+ let opaque = hasSpread;
169
+ for (const item of items) {
170
+ if (item?.type === 'ObjectExpression') {
171
+ changed = renameTriggerKey(j, item) || changed;
172
+ } else {
173
+ opaque = true;
174
+ }
175
+ }
176
+ if (opaque) {
177
+ changed = addComment(j, prop, OPAQUE_TRIGGERS_COMMENT) || changed;
178
+ }
179
+ return;
180
+ }
181
+ if (hasSpread) {
182
+ changed = addComment(j, prop, SPREAD_COMMENT) || changed;
183
+ return;
184
+ }
185
+ const already = attributes.some(
186
+ (/** @type {any} */ attribute) =>
187
+ attribute.type === 'JSXAttribute' &&
188
+ attribute.name?.name === NEW_NAME,
189
+ );
190
+ if (already) {
191
+ changed = addComment(j, prop, BOTH_SET_COMMENT) || changed;
192
+ return;
193
+ }
194
+ prop.name.name = NEW_NAME;
195
+ changed = true;
196
+ },
197
+ );
198
+
199
+ // Every spread onto one of these elements that the prop pass did not reach
200
+ // (the element writes neither the old name nor, for ChatComposerInput,
201
+ // `triggers`): the spread may carry the removed key, so it gets the TODO.
202
+ for (const [component, props] of COMPONENTS) {
203
+ const sentinel = `__astryx_spread_${component}`;
204
+ root
205
+ .find(j.JSXOpeningElement)
206
+ .filter((/** @type {any} */ path) =>
207
+ (path.node.attributes ?? []).some(
208
+ (/** @type {any} */ attribute) =>
209
+ attribute.type === 'JSXSpreadAttribute',
210
+ ),
211
+ )
212
+ .forEach((/** @type {any} */ path) => {
213
+ const attributes = path.node.attributes ?? [];
214
+ const names = new Set(
215
+ attributes
216
+ .filter((/** @type {any} */ a) => a.type === 'JSXAttribute')
217
+ .map((/** @type {any} */ a) => a.name?.name),
218
+ );
219
+ if ([...props].some(name => names.has(name))) return;
220
+ // Let the shared helper decide whether this element is the imported
221
+ // component: give it a sentinel prop to find, then take it back.
222
+ const marker = j.jsxAttribute(j.jsxIdentifier(sentinel));
223
+ path.node.attributes = [...attributes, marker];
224
+ let matched = false;
225
+ transformProp(
226
+ root,
227
+ j,
228
+ {
229
+ matchesImport: source => CORE_IMPORT_RE.test(source),
230
+ components: new Map([[component, new Set([sentinel])]]),
231
+ },
232
+ propPath => {
233
+ if (propPath.node === marker) matched = true;
234
+ },
235
+ );
236
+ path.node.attributes = attributes;
237
+ if (!matched) return;
238
+ const spread = attributes.find(
239
+ (/** @type {any} */ attribute) =>
240
+ attribute.type === 'JSXSpreadAttribute',
241
+ );
242
+ changed =
243
+ addComment(
244
+ j,
245
+ spread,
246
+ component === 'ChatComposerInput'
247
+ ? OPAQUE_TRIGGERS_COMMENT
248
+ : SPREAD_COMMENT,
249
+ ) || changed;
250
+ });
251
+ }
252
+
253
+ return changed ? root.toSource({quote: 'single'}) : null;
254
+ }
@@ -180,20 +180,20 @@ export const matchaTheme = defineTheme({
180
180
  // =========================================================================
181
181
  // Spacing
182
182
  // =========================================================================
183
- '--spacing-0-5': '3px',
184
- '--spacing-1': '6px',
185
- '--spacing-1-5': '9px',
186
- '--spacing-2': '12px',
187
- '--spacing-3': '18px',
188
- '--spacing-4': '24px',
189
- '--spacing-5': '30px',
190
- '--spacing-6': '36px',
191
- '--spacing-7': '42px',
192
- '--spacing-8': '48px',
193
- '--spacing-9': '54px',
194
- '--spacing-10': '60px',
195
- '--spacing-11': '66px',
196
- '--spacing-12': '72px',
183
+ '--spacing-0-5': '0.1875rem',
184
+ '--spacing-1': '0.375rem',
185
+ '--spacing-1-5': '0.5625rem',
186
+ '--spacing-2': '0.75rem',
187
+ '--spacing-3': '1.125rem',
188
+ '--spacing-4': '1.5rem',
189
+ '--spacing-5': '1.875rem',
190
+ '--spacing-6': '2.25rem',
191
+ '--spacing-7': '2.625rem',
192
+ '--spacing-8': '3rem',
193
+ '--spacing-9': '3.375rem',
194
+ '--spacing-10': '3.75rem',
195
+ '--spacing-11': '4.125rem',
196
+ '--spacing-12': '4.5rem',
197
197
 
198
198
  // =========================================================================
199
199
  // Radius — soft and rounded
@@ -63,16 +63,16 @@ export const y2kTheme = defineTheme({
63
63
  // =========================================================================
64
64
  // Spacing — comfortable preset (base=6)
65
65
  // =========================================================================
66
- '--spacing-0-5': '3px',
67
- '--spacing-1': '6px',
68
- '--spacing-1-5': '9px',
69
- '--spacing-2': '12px',
70
- '--spacing-3': '18px',
71
- '--spacing-4': '24px',
72
- '--spacing-5': '30px',
73
- '--spacing-6': '36px',
74
- '--spacing-7': '42px',
75
- '--spacing-8': '48px',
66
+ '--spacing-0-5': '0.1875rem',
67
+ '--spacing-1': '0.375rem',
68
+ '--spacing-1-5': '0.5625rem',
69
+ '--spacing-2': '0.75rem',
70
+ '--spacing-3': '1.125rem',
71
+ '--spacing-4': '1.5rem',
72
+ '--spacing-5': '1.875rem',
73
+ '--spacing-6': '2.25rem',
74
+ '--spacing-7': '2.625rem',
75
+ '--spacing-8': '3rem',
76
76
 
77
77
  // Size — comfortable preset
78
78
  '--size-element-sm': '32px',
@@ -373,7 +373,7 @@ export const myTheme = defineTheme({
373
373
  // {
374
374
  // // Narrow at every pointer precision.
375
375
  // when: {width: {below: 'md'}},
376
- // value: {tokens: {'--spacing-4': '12px'}},
376
+ // value: {tokens: {'--spacing-4': '0.75rem'}},
377
377
  // },
378
378
  // {
379
379
  // // Taller controls under a finger or stylus at every width.
@@ -16,7 +16,7 @@ export const doc = {
16
16
  summary: 'Diagnose Astryx projects and integration packages',
17
17
  description:
18
18
  'Runs read-only project health diagnostics by default: Node version, @astryxdesign/core ' +
19
- 'install and version alignment, theme packages, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
19
+ 'install and version alignment, theme packages, generated app themes when present, earlier copied-theme migration, config, integrations (every one astryx.config names must load, linked without a config entry, ' +
20
20
  'provider identity, contribution issues), agent docs, core peer dependencies, package manager, ' +
21
21
  "and the docs the CLI reads. It writes nothing, but loading astryx.config runs that file's code. " +
22
22
  'The `integration` subcommands provide authoring checks for one integration package.',
@@ -403,3 +403,36 @@ describe('doctor — text output mirrors the JSON', () => {
403
403
  }
404
404
  }, 60_000);
405
405
  });
406
+
407
+ describe('doctor — a configured integration that cannot load', () => {
408
+ it('sets exit code 1 and reports it in the JSON', async () => {
409
+ const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-exit-'));
410
+ const prevCwd = process.cwd();
411
+ const prevExit = process.exitCode;
412
+ process.exitCode = undefined;
413
+ try {
414
+ fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"app"}');
415
+ fs.writeFileSync(
416
+ path.join(dir, 'astryx.config.mjs'),
417
+ "export default { integrations: ['@acme/missing'] };\n",
418
+ );
419
+ const coreDir = path.join(dir, 'node_modules', '@astryxdesign', 'core');
420
+ fs.mkdirSync(coreDir, {recursive: true});
421
+ fs.writeFileSync(
422
+ path.join(coreDir, 'package.json'),
423
+ JSON.stringify({name: '@astryxdesign/core', version: '0.6.3'}),
424
+ );
425
+ process.chdir(dir);
426
+ await createProgram().parseAsync(['node', 'astryx', '--json', 'doctor']);
427
+ expect(process.exitCode).toBe(1);
428
+ const {data} = JSON.parse(logCalls.join('\n'));
429
+ expect(
430
+ data.checks.find(c => c.id === 'configured-integrations'),
431
+ ).toMatchObject({status: 'fail'});
432
+ } finally {
433
+ process.chdir(prevCwd);
434
+ process.exitCode = prevExit;
435
+ fs.rmSync(dir, {recursive: true, force: true});
436
+ }
437
+ }, 60_000);
438
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.0-canary.f3a2181",
3
+ "version": "0.7.0",
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",
@@ -101,10 +101,10 @@
101
101
  "zod": "^4.4.3"
102
102
  },
103
103
  "peerDependencies": {
104
- "@astryxdesign/charts": "0.7.0-canary.f3a2181",
105
- "@astryxdesign/core": "0.7.0-canary.f3a2181",
106
- "@astryxdesign/lab": "0.7.0-canary.f3a2181",
107
- "@astryxdesign/theme-neutral": "0.7.0-canary.f3a2181"
104
+ "@astryxdesign/charts": "*",
105
+ "@astryxdesign/core": "*",
106
+ "@astryxdesign/lab": "*",
107
+ "@astryxdesign/theme-neutral": "*"
108
108
  },
109
109
  "peerDependenciesMeta": {
110
110
  "@astryxdesign/charts": {
@@ -121,10 +121,10 @@
121
121
  }
122
122
  },
123
123
  "devDependencies": {
124
- "@astryxdesign/charts": "0.7.0-canary.f3a2181",
125
- "@astryxdesign/core": "0.7.0-canary.f3a2181",
126
- "@astryxdesign/lab": "0.7.0-canary.f3a2181",
127
- "@astryxdesign/theme-neutral": "0.7.0-canary.f3a2181",
124
+ "@astryxdesign/charts": "*",
125
+ "@astryxdesign/core": "*",
126
+ "@astryxdesign/lab": "*",
127
+ "@astryxdesign/theme-neutral": "*",
128
128
  "@heroicons/react": "^2.2.0",
129
129
  "@stylexjs/stylex": "^0.19.0",
130
130
  "@types/babel__core": "^7.20.5",