@astryxdesign/cli 0.7.5-canary.cd53c2d → 0.7.5-canary.cdd75ae

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 (48) hide show
  1. package/README.md +2 -2
  2. package/api/upgrade/_adapter.d.mts +47 -2
  3. package/api/upgrade/_adapter.mjs +58 -2
  4. package/api/upgrade/run/failure-receipt.test.mjs +212 -0
  5. package/api/upgrade/run/outcomes.test.mjs +646 -0
  6. package/api/upgrade/run/run.d.mts +36 -0
  7. package/api/upgrade/run/run.mjs +670 -44
  8. package/api/upgrade/upgrade.doc.mjs +4 -4
  9. package/api/upgrade/upgrade.mjs +19 -4
  10. package/api/upgrade/upgrade.type.d.mts +36 -1
  11. package/api/upgrade/upgrade.type.mjs +29 -4
  12. package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
  13. package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
  14. package/assets/codemods/integration-runner.mjs +8 -2
  15. package/assets/codemods/integration-runner.protection.test.mjs +53 -0
  16. package/assets/codemods/outcome.mjs +79 -0
  17. package/assets/codemods/outcome.test.mjs +40 -0
  18. package/assets/codemods/parse.mjs +94 -0
  19. package/assets/codemods/run-codemod.mjs +109 -5
  20. package/assets/codemods/runner.mjs +119 -13
  21. package/assets/codemods/transform-prop.mjs +99 -49
  22. package/assets/codemods/transform-prop.test.mjs +36 -1
  23. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
  24. package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
  25. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
  26. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
  27. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +24 -4
  28. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
  29. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
  30. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +6 -3
  31. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  32. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
  33. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
  34. package/assets/templates/pages/library/page.tsx +1 -2
  35. package/authoring/codemod/type.ts +10 -0
  36. package/clients/cli/commands/upgrade.doc.mjs +47 -2
  37. package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
  38. package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
  39. package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
  40. package/clients/cli/commands/upgrade.mjs +9 -2
  41. package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
  42. package/foundation/response/base.d.ts +7 -0
  43. package/foundation/response/error-codes.doc.mjs +3 -2
  44. package/foundation/response/error-codes.mjs +1 -1
  45. package/foundation/response/json.d.mts +10 -3
  46. package/foundation/response/json.mjs +16 -4
  47. package/foundation/response/response-types.doc.mjs +1 -1
  48. package/package.json +10 -9
@@ -5,19 +5,34 @@
5
5
  *
6
6
  * Static keys directly inside a theme's `components` object move to their
7
7
  * canonical target. A theme is a `defineTheme()` call imported from Astryx, an
8
- * object typed as an Astryx theme (annotation, `as`, or `satisfies`), or a
9
- * direct theme object with a static `name` whose component entries are style
10
- * objects. CSS selectors move the same target classes, keep the owner scope of
11
- * the per-component clear-icon aliases, and replace target-qualified bare
12
- * prop/state classes with reflected `data-*` selectors using the final 0.6
13
- * runtime contract. A known bare class that cannot be classified for its target
14
- * gets a TODO. Dynamic theme keys, unqualified classes, declarations, comments,
8
+ * object typed as an Astryx theme (annotation, `as`, or `satisfies`), or the
9
+ * direct theme object a same-stem theme descriptor (`<stem>.doc.mjs`) declares:
10
+ * the top-level binding exported as `<stem>`, with a static `name` and
11
+ * component entries that are style objects. Shape alone is not proof: a
12
+ * look-alike object anywhere else, including another object in the same theme
13
+ * source, is left unchanged. CSS selectors move the same target classes, keep
14
+ * the owner scope of the per-component clear-icon aliases, and replace
15
+ * target-qualified bare prop/state classes with reflected `data-*` selectors
16
+ * using the final 0.6 runtime contract. A known bare class that cannot be
17
+ * classified for its target gets a TODO. Dynamic theme keys, unqualified classes, declarations, comments,
15
18
  * and strings containing CSS are left for manual review.
16
19
  */
17
20
 
21
+ import * as fs from 'node:fs';
18
22
  import path from 'node:path';
19
23
  import postcss from 'postcss';
20
24
  import selectorParser from 'postcss-selector-parser';
25
+ import {readThemeDescriptorValue} from '../../../../foundation/discovery/theme-discovery.mjs';
26
+ import {
27
+ importedComponents,
28
+ resolveImportedComponent,
29
+ } from '../../transform-prop.mjs';
30
+ import {
31
+ isCodemodParseError,
32
+ markParseError,
33
+ parseCss,
34
+ processSelector,
35
+ } from '../../parse.mjs';
21
36
  import {migrateAstryxThemeSelectors} from '../v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs';
22
37
  import {
23
38
  V06_THEME_SELECTOR_DYNAMIC_AXES,
@@ -195,7 +210,7 @@ function ownerScope(owner) {
195
210
  function unclassifiedBareClasses(selectorText) {
196
211
  /** @type {Set<string>} */
197
212
  const found = new Set();
198
- selectorParser(selectors => {
213
+ processSelector(selectorText, selectors => {
199
214
  selectors.walk((/** @type {any} */ node) => {
200
215
  if (node.type !== 'selector') return;
201
216
  /** @type {any[][]} */
@@ -223,19 +238,23 @@ function unclassifiedBareClasses(selectorText) {
223
238
  }
224
239
  }
225
240
  });
226
- }).processSync(selectorText, {lossless: true});
241
+ });
227
242
  return [...found].sort();
228
243
  }
229
244
 
230
- /** @param {string} selector */
245
+ /** @param {string | import('postcss').Rule} selector selector text, or the rule that holds it */
231
246
  function finishSelectorText(selector) {
232
- return selectorParser(selectors => {
247
+ return processSelector(selector, selectors => {
233
248
  selectors.each(finishSelectorMigration);
234
- }).processSync(selector, {lossless: true});
249
+ });
235
250
  }
236
251
 
237
- /** @param {string} params */
238
- function finishScopeParams(params) {
252
+ /**
253
+ * Migrate each parenthesized selector group of an `@scope` prelude.
254
+ * @param {string} params
255
+ * @param {(selector: string, start: number) => string} [finish] migrates one group; `start` is its offset in `params`
256
+ */
257
+ function finishScopeParams(params, finish = finishSelectorText) {
239
258
  let result = '';
240
259
  let last = 0;
241
260
  let depth = 0;
@@ -272,7 +291,7 @@ function finishScopeParams(params) {
272
291
  if (char === ')' && depth > 0) {
273
292
  depth--;
274
293
  if (depth === 0 && groupStart >= 0) {
275
- result += finishSelectorText(params.slice(groupStart, index));
294
+ result += finish(params.slice(groupStart, index), groupStart);
276
295
  result += ')';
277
296
  last = index + 1;
278
297
  groupStart = -1;
@@ -284,15 +303,39 @@ function finishScopeParams(params) {
284
303
 
285
304
  /** @param {string} source @param {string} from */
286
305
  function migrateCss(source, from) {
306
+ // Parse every selector of the stylesheet as written first, so one the
307
+ // selector parser rejects is reported at its line and column in the file,
308
+ // not in the migrated text below.
309
+ const original = parseCss(source, {from});
310
+ original.walkRules(rule => {
311
+ processSelector(rule, () => {});
312
+ });
313
+ original.walkAtRules('scope', atRule => {
314
+ const offset =
315
+ `@${atRule.name}`.length + (atRule.raws.afterName ?? '').length;
316
+ finishScopeParams(atRule.params, (selector, start) => {
317
+ try {
318
+ processSelector(selector, () => {});
319
+ } catch (err) {
320
+ if (!isCodemodParseError(err)) throw err;
321
+ throw markParseError(
322
+ atRule.error(/** @type {Error} */ (err).message, {
323
+ index: offset + start,
324
+ }),
325
+ );
326
+ }
327
+ return selector;
328
+ });
329
+ });
287
330
  const migrated = migrateAstryxThemeSelectors(source, from, SELECTOR_DATA);
288
- const root = postcss.parse(migrated, {from});
331
+ const root = parseCss(migrated, {from});
289
332
  /** @type {Set<string>} */
290
333
  const existingComments = new Set();
291
334
  root.walkComments(comment => {
292
335
  existingComments.add(comment.text.trim());
293
336
  });
294
337
  root.walkRules(rule => {
295
- rule.selector = finishSelectorText(rule.selector);
338
+ rule.selector = finishSelectorText(rule);
296
339
  const tokens = unclassifiedBareClasses(rule.selector);
297
340
  if (tokens.length === 0) return;
298
341
  const list = tokens.map(token => `.${token}`).join(', ');
@@ -338,15 +381,88 @@ const TS_WRAPPERS = new Set([
338
381
  ]);
339
382
 
340
383
  /**
341
- * Local names that refer to Astryx's `defineTheme`, its theme types, or an
342
- * Astryx namespace import.
343
- * @param {any} root @param {any} j
384
+ * The export name a same-stem theme descriptor beside this file declares
385
+ * (`brandTheme` for `brandTheme.ts` beside `brandTheme.doc.mjs`), or null. The
386
+ * descriptor is read statically, never executed; an unreadable or non-theme
387
+ * descriptor is not proof.
388
+ * @param {string} filePath
389
+ * @returns {string | null}
390
+ */
391
+ function describedThemeExportName(filePath) {
392
+ const stem = path.basename(filePath, path.extname(filePath));
393
+ const docPath = path.join(path.dirname(filePath), `${stem}.doc.mjs`);
394
+ if (!fs.existsSync(docPath)) return null;
395
+ try {
396
+ return readThemeDescriptorValue(docPath, `Theme descriptor ${docPath}`)
397
+ .type === 'theme'
398
+ ? stem
399
+ : null;
400
+ } catch {
401
+ return null;
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Top-level local names this module exports under `exportName`: an exported
407
+ * declaration of that name, or a source-less `export {local as exportName}`.
408
+ * @param {any} root @param {any} j @param {string} exportName
409
+ */
410
+ function localNamesExportedAs(root, j, exportName) {
411
+ /** @type {Set<string>} */
412
+ const locals = new Set();
413
+ root
414
+ .find(j.ExportNamedDeclaration)
415
+ .forEach((/** @type {any} */ exportPath) => {
416
+ const node = exportPath.node;
417
+ if (node.exportKind === 'type' || node.source) return;
418
+ for (const declarator of node.declaration?.declarations ?? []) {
419
+ if (declarator.id?.name === exportName) locals.add(exportName);
420
+ }
421
+ for (const specifier of node.specifiers ?? []) {
422
+ const exported = specifier.exported?.name ?? specifier.exported?.value;
423
+ const local = specifier.local?.name ?? specifier.local?.value;
424
+ if (
425
+ specifier.exportKind !== 'type' &&
426
+ exported === exportName &&
427
+ typeof local === 'string'
428
+ ) {
429
+ locals.add(local);
430
+ }
431
+ }
432
+ });
433
+ return locals;
434
+ }
435
+
436
+ /**
437
+ * Astryx's `defineTheme` imports (resolved at each call site, so a shadowing
438
+ * parameter or local never counts), its theme types, an Astryx namespace
439
+ * import, and the binding a theme descriptor declares.
440
+ * @param {any} root @param {any} j @param {string} filePath
344
441
  */
345
- function astryxThemeBindings(root, j) {
442
+ function astryxThemeBindings(root, j, filePath) {
443
+ /** @type {Set<string> | undefined} */
444
+ let describedLocals;
346
445
  const bindings = {
347
- defineTheme: new Set(),
446
+ defineTheme: importedComponents(root, j, {
447
+ matchesImport: source => ASTRYX_MODULE.test(source),
448
+ components: new Map([['defineTheme', new Set()]]),
449
+ }),
348
450
  themeTypes: new Set(),
349
451
  namespaces: new Set(),
452
+ /**
453
+ * Top-level locals exported under the descriptor's name. Read lazily:
454
+ * only a direct theme-shaped object needs the descriptor.
455
+ * @returns {Set<string>}
456
+ */
457
+ describedThemeLocals() {
458
+ if (describedLocals == null) {
459
+ const exportName = describedThemeExportName(filePath);
460
+ describedLocals = exportName
461
+ ? localNamesExportedAs(root, j, exportName)
462
+ : new Set();
463
+ }
464
+ return describedLocals;
465
+ },
350
466
  };
351
467
  root.find(j.ImportDeclaration).forEach((/** @type {any} */ importPath) => {
352
468
  const source = importPath.node.source?.value;
@@ -358,7 +474,6 @@ function astryxThemeBindings(root, j) {
358
474
  bindings.namespaces.add(local);
359
475
  } else if (specifier.type === 'ImportSpecifier') {
360
476
  const imported = specifier.imported?.name ?? specifier.imported?.value;
361
- if (imported === 'defineTheme') bindings.defineTheme.add(local);
362
477
  if (THEME_TYPE_NAMES.has(imported)) bindings.themeTypes.add(local);
363
478
  }
364
479
  }
@@ -379,20 +494,80 @@ function namesBinding(name, locals, namespaces, members) {
379
494
  );
380
495
  }
381
496
 
382
- /** @param {any} typeNode @param {ReturnType<typeof astryxThemeBindings>} bindings */
383
- function isAstryxThemeType(typeNode, bindings) {
497
+ /** @param {any} typeNode @param {any} usePath @param {ReturnType<typeof astryxThemeBindings>} bindings */
498
+ function isAstryxThemeType(typeNode, usePath, bindings) {
384
499
  const node = typeNode?.typeAnnotation ?? typeNode;
385
- return (
386
- node?.type === 'TSTypeReference' &&
387
- namesBinding(
500
+ if (
501
+ node?.type !== 'TSTypeReference' ||
502
+ !namesBinding(
388
503
  node.typeName,
389
504
  bindings.themeTypes,
390
505
  bindings.namespaces,
391
506
  THEME_TYPE_NAMES,
392
507
  )
508
+ ) {
509
+ return false;
510
+ }
511
+ const root =
512
+ node.typeName.type === 'Identifier' ? node.typeName : node.typeName.left;
513
+ return isModuleTypeBinding(usePath, root.name);
514
+ }
515
+
516
+ /** @param {any} statement @param {string} name */
517
+ function statementDeclares(statement, name) {
518
+ const node =
519
+ statement?.type === 'ExportNamedDeclaration' ||
520
+ statement?.type === 'ExportDefaultDeclaration'
521
+ ? statement.declaration
522
+ : statement;
523
+ if (node?.id?.type === 'Identifier' && node.id.name === name) return true;
524
+ return (node?.declarations ?? []).some(
525
+ (/** @type {any} */ declarator) =>
526
+ declarator.id?.type === 'Identifier' && declarator.id.name === name,
393
527
  );
394
528
  }
395
529
 
530
+ /**
531
+ * True when a type-position `name` at `path` can only mean the module-scope
532
+ * import: no enclosing type parameter, parameter, or block-level declaration
533
+ * (type alias, interface, enum, class, namespace, function, or variable)
534
+ * reuses the name. Anything this cannot rule out counts as shadowed.
535
+ * @param {any} path @param {string} name
536
+ */
537
+ function isModuleTypeBinding(path, name) {
538
+ const valueScope = path.scope?.lookup(name);
539
+ if (valueScope != null && valueScope.path.node.type !== 'Program') {
540
+ return false;
541
+ }
542
+ for (let current = path; current != null; current = current.parent) {
543
+ const node = current.node;
544
+ if (node.type === 'Program') return true;
545
+ const typeParameters = node.typeParameters?.params ?? [];
546
+ if (
547
+ typeParameters.some(
548
+ (/** @type {any} */ parameter) =>
549
+ (parameter.name?.name ?? parameter.name) === name,
550
+ )
551
+ ) {
552
+ return false;
553
+ }
554
+ const statements =
555
+ node.type === 'SwitchCase'
556
+ ? node.consequent
557
+ : node.type !== 'ClassBody' && Array.isArray(node.body)
558
+ ? node.body
559
+ : [];
560
+ if (
561
+ statements.some((/** @type {any} */ statement) =>
562
+ statementDeclares(statement, name),
563
+ )
564
+ ) {
565
+ return false;
566
+ }
567
+ }
568
+ return false;
569
+ }
570
+
396
571
  /**
397
572
  * True for a theme object whose shape alone identifies it: a static string
398
573
  * `name` beside a `components` map whose entries are all style objects.
@@ -426,16 +601,45 @@ function isDirectThemeObject(node) {
426
601
  );
427
602
  }
428
603
 
604
+ /**
605
+ * True when this object literal initializes the top-level binding that the
606
+ * file's theme descriptor declares, directly or through TypeScript wrappers.
607
+ * @param {any} objectPath @param {ReturnType<typeof astryxThemeBindings>} bindings
608
+ */
609
+ function isDescribedThemeBinding(objectPath, bindings) {
610
+ let parent = objectPath.parent;
611
+ while (parent != null && TS_WRAPPERS.has(parent.node.type)) {
612
+ parent = parent.parent;
613
+ }
614
+ const declarator = parent?.node;
615
+ if (
616
+ declarator?.type !== 'VariableDeclarator' ||
617
+ declarator.id?.type !== 'Identifier'
618
+ ) {
619
+ return false;
620
+ }
621
+ const declaration = parent.parent;
622
+ const container = declaration?.parent?.node;
623
+ const topLevel =
624
+ container?.type === 'Program' ||
625
+ (container?.type === 'ExportNamedDeclaration' &&
626
+ declaration.parent.parent?.node.type === 'Program');
627
+ return topLevel && bindings.describedThemeLocals().has(declarator.id.name);
628
+ }
629
+
429
630
  /**
430
631
  * True when this object literal is an Astryx theme: the argument of an
431
- * imported `defineTheme()`, typed as an Astryx theme, or a direct theme object.
632
+ * imported `defineTheme()`, typed as an Astryx theme, or the direct theme
633
+ * object a theme descriptor declares.
432
634
  * @param {any} objectPath @param {ReturnType<typeof astryxThemeBindings>} bindings
433
635
  */
434
636
  function isThemeRoot(objectPath, bindings) {
435
637
  let child = objectPath;
436
638
  let parent = objectPath.parent;
437
639
  while (parent != null && TS_WRAPPERS.has(parent.node.type)) {
438
- if (isAstryxThemeType(parent.node.typeAnnotation, bindings)) return true;
640
+ if (isAstryxThemeType(parent.node.typeAnnotation, parent, bindings)) {
641
+ return true;
642
+ }
439
643
  child = parent;
440
644
  parent = parent.parent;
441
645
  }
@@ -443,22 +647,20 @@ function isThemeRoot(objectPath, bindings) {
443
647
  if (
444
648
  node?.type === 'CallExpression' &&
445
649
  node.arguments?.[0] === child.node &&
446
- namesBinding(
447
- node.callee,
448
- bindings.defineTheme,
449
- bindings.namespaces,
450
- new Set(['defineTheme']),
451
- )
650
+ resolveImportedComponent(node.callee, parent, bindings.defineTheme)
452
651
  ) {
453
652
  return true;
454
653
  }
455
654
  if (
456
655
  node?.type === 'VariableDeclarator' &&
457
- isAstryxThemeType(node.id?.typeAnnotation, bindings)
656
+ isAstryxThemeType(node.id?.typeAnnotation, parent, bindings)
458
657
  ) {
459
658
  return true;
460
659
  }
461
- return isDirectThemeObject(objectPath.node);
660
+ return (
661
+ isDirectThemeObject(objectPath.node) &&
662
+ isDescribedThemeBinding(objectPath, bindings)
663
+ );
462
664
  }
463
665
 
464
666
  /**
@@ -567,10 +769,10 @@ function addScopeTodo(property, oldKey, owner, j) {
567
769
  ];
568
770
  }
569
771
 
570
- /** @param {string} source @param {any} j */
571
- function migrateStaticThemeKeys(source, j) {
772
+ /** @param {string} source @param {string} filePath @param {any} j */
773
+ function migrateStaticThemeKeys(source, filePath, j) {
572
774
  const root = j(source);
573
- const bindings = astryxThemeBindings(root, j);
775
+ const bindings = astryxThemeBindings(root, j, filePath);
574
776
  let changed = false;
575
777
 
576
778
  root.find(j.ObjectExpression).forEach((/** @type {any} */ objectPath) => {
@@ -620,5 +822,5 @@ export default function migrateDeprecatedThemeSurface(file, api) {
620
822
  const result = migrateCss(file.source, file.path);
621
823
  return result === file.source ? undefined : result;
622
824
  }
623
- return migrateStaticThemeKeys(file.source, api.jscodeshift);
825
+ return migrateStaticThemeKeys(file.source, file.path, api.jscodeshift);
624
826
  }
@@ -4,8 +4,9 @@
4
4
  * @file Reject stale generated theme CSS that still owns data-token defaults.
5
5
  *
6
6
  * @input Generated theme CSS
7
- * @output No rewritten source; an upgrade error for a generated theme
8
- * stylesheet that still declares data-color defaults at `:root`
7
+ * @output No rewritten source; a regeneration report (`RegenerationRequired`,
8
+ * with `astryx theme build`) for a generated theme stylesheet that still
9
+ * declares data-color defaults at `:root`
9
10
  * @position Next-release upgrade validation for spec:AST-066 FR19
10
11
  *
11
12
  * Raw `var(--color-data-*)` uses are not checked: prebuilt
@@ -15,6 +16,7 @@
15
16
  */
16
17
 
17
18
  import * as path from 'node:path';
19
+ import {RegenerationRequired} from '../../outcome.mjs';
18
20
 
19
21
  export const meta = {
20
22
  title: 'Validate data-token ownership',
@@ -36,8 +38,9 @@ export default function validateDataTokenOwnership(file) {
36
38
  file.source.includes(GENERATED_THEME_HEADER) &&
37
39
  ROOT_DATA_DECLARATION.test(file.source)
38
40
  ) {
39
- throw new Error(
41
+ throw new RegenerationRequired(
40
42
  'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults come from @astryxdesign/core/astryx.css in prebuilt mode, and in a source build from the @astryxdesign/build PostCSS integration or dataVars imports.',
43
+ {commands: ['astryx theme build']},
41
44
  );
42
45
  }
43
46
  return undefined;
@@ -142,7 +142,7 @@ const overrides = stylex.create({
142
142
  },
143
143
  {
144
144
  type: 'prose',
145
- text: 'The upgrade treats a `components` map as a theme when it belongs to a `defineTheme()` call imported from Astryx, an object typed as an Astryx theme, or a theme object with a static `name` whose component entries are style objects. It leaves computed theme keys, unqualified classes, unknown consumer classes, declarations, comments, and CSS inside JavaScript or TypeScript strings unchanged. It adds `TODO(astryx upgrade)` when a map has both an old and a canonical key, and when a bare class Astryx once emitted has no known meaning on the target it qualifies. Review each TODO by hand.',
145
+ text: 'The upgrade treats a `components` map as a theme when it belongs to a `defineTheme()` call imported from Astryx, an object typed as an Astryx theme, or the theme object a same-stem theme descriptor (`<stem>.doc.mjs`) declares: the top-level binding exported as `<stem>`, with a static `name` and component entries that are style objects. A look-alike object anywhere else, such as a theme object from another library in the same file, is not an Astryx theme. It leaves computed theme keys, unqualified classes, unknown consumer classes, declarations, comments, and CSS inside JavaScript or TypeScript strings unchanged. It adds `TODO(astryx upgrade)` when a map has both an old and a canonical key, and when a bare class Astryx once emitted has no known meaning on the target it qualifies. Review each TODO by hand.',
146
146
  },
147
147
  ],
148
148
  },
@@ -7,7 +7,7 @@ export const doc = {
7
7
  name: 'Code — Snippet',
8
8
  displayName: 'Code — Snippet',
9
9
  description:
10
- 'Short terminal commands with a copy button and no line numbers. Use for install instructions or one-liner commands that readers will paste directly.',
10
+ 'Short terminal commands with no header: the copy button sits in its own column beside the code, so a one-line command reads as a single row and a long line ends before the button instead of running under it. Use for install instructions or one-liner commands that readers will paste directly.',
11
11
  isReady: true,
12
12
  aspectRatio: 16 / 9,
13
13
  componentsUsed: ['CodeBlock', 'Stack'],
@@ -11,13 +11,21 @@ export default function CodeBlockBashCommand() {
11
11
  <CodeBlock
12
12
  code="npm install @astryxdesign/core"
13
13
  language="bash"
14
- hasCopyButton
14
+ hasLanguageLabel={false}
15
15
  style={{width: '100%'}}
16
16
  />
17
17
  <CodeBlock
18
18
  code="yarn add @astryxdesign/theme-neutral"
19
19
  language="bash"
20
- hasCopyButton
20
+ hasLanguageLabel={false}
21
+ style={{width: '100%'}}
22
+ />
23
+ <CodeBlock
24
+ code={
25
+ 'astryx upgrade --from 0.6.0 --apply --path apps/web/src --install-deps\nnpm run build'
26
+ }
27
+ language="bash"
28
+ hasLanguageLabel={false}
21
29
  style={{width: '100%'}}
22
30
  />
23
31
  </VStack>
@@ -193,8 +193,7 @@ const ITEMS: LibraryItem[] = [
193
193
  {
194
194
  id: '18',
195
195
  name: 'MobileNav',
196
- description:
197
- 'Bottom tab bar for mobile viewports with icon and label slots.',
196
+ description: 'Slide-out navigation drawer for mobile viewports.',
198
197
  category: 'Navigation',
199
198
  type: 'Pattern',
200
199
  imageUrl:
@@ -141,6 +141,16 @@ export interface CodemodRunResult {
141
141
  generated: boolean;
142
142
  command?: string;
143
143
  }>;
144
+ /**
145
+ * Protected files left for manual review because their own source does not
146
+ * parse, so no change can be proven in them. They do not fail the run.
147
+ */
148
+ declinedCandidates?: Array<{
149
+ file: string;
150
+ codemod: string;
151
+ location?: string;
152
+ reason: string;
153
+ }>;
144
154
  errors: Array<{file: string; codemod: string; error: string}>;
145
155
  }
146
156
 
@@ -108,14 +108,17 @@ export const doc = {
108
108
  ],
109
109
  outsideProject: 'own',
110
110
  exitCodes: [
111
- {code: 0, when: 'success, including complete dry-run previews'},
111
+ {
112
+ code: 0,
113
+ when: 'success, including complete dry-run previews and runs whose only findings are manual migrations',
114
+ },
112
115
  {
113
116
  code: 1,
114
117
  when:
115
118
  'missing or invalid --from, --registry with --list or a migration flag, a --path escape, ' +
116
119
  'no installed @astryxdesign/core (or legacy @xds/core), jscodeshift missing and not installed by --install-deps, ' +
117
120
  'an astryx.config that fails validation and that no pending config codemod repairs, ' +
118
- 'an unreadable or invalid protection declaration, a protected file that still requires a codemod change, ' +
121
+ 'an unreadable or invalid protection declaration, a protected file that still requires a codemod change, a generated file that must be regenerated, ' +
119
122
  'an unknown codemod, a codemod or post-codemod hook failure, or unresolved registry items',
120
123
  },
121
124
  ],
@@ -157,6 +160,13 @@ export const doc = {
157
160
  'it is an installed dependency (such as anything in `node_modules`), is inside `.git`, `.hg`, or `.sl`, is a symbolic link, or is outside the project',
158
161
  ],
159
162
  },
163
+ {
164
+ type: 'prose',
165
+ text:
166
+ 'upgrade does not scan installed dependencies or version-control folders at all, including through a symbolic link: ' +
167
+ 'a symlinked `node_modules`, or a link whose target is inside one or inside a package store such as `.yarn/cache`, is skipped. ' +
168
+ 'Other symbolically linked folders are scanned so a change they need is reported, but nothing is written through them.',
169
+ },
160
170
  {
161
171
  type: 'prose',
162
172
  text:
@@ -194,5 +204,40 @@ export const doc = {
194
204
  '`Command:` line in its header, such as `// Command: pnpm run gen:panel`; upgrade prints it as ' +
195
205
  '`Regenerate with: <command>` and lists it in `commands`.',
196
206
  },
207
+ {
208
+ type: 'prose',
209
+ text:
210
+ 'A protected file a codemod cannot parse, such as a vendored bundle written for another toolchain, cannot need a ' +
211
+ 'change the codemod can prove, and upgrade never writes it. upgrade skips it, lists it under ' +
212
+ '`declinedCandidates` with the parse error and where it occurred, and carries on; on its own it does not fail the run. ' +
213
+ 'If another codemod in the same upgrade still requires a change to that file (the 0.6.0 theme selector migration, for one, ' +
214
+ 'adds a TODO comment above a selector it cannot parse), the file is listed once, under `protectedFiles`, and the run is ' +
215
+ 'incomplete as for any protected file. A file upgrade owns that does not parse still fails the run with ERR_CODEMOD_FAILED.',
216
+ },
217
+ {type: 'heading', level: 3, text: 'Manual migrations and regeneration'},
218
+ {
219
+ type: 'prose',
220
+ text:
221
+ 'Some changes a codemod can find but not make. upgrade lists them in the result, so a script can keep the rest of the run and act on each. ' +
222
+ 'Code a codemod can identify but cannot migrate safely is a manual migration: upgrade lists each file with its line, ' +
223
+ 'the codemod and what to change, finishes the run, and exits 0. With --json they are in `declinedCandidates`, one row per file (each finding in `reason` starts with `manual migration needed (<codemod>):`, and a file with several findings lists them all, joined by `; `), and `complete` stays true. ' +
224
+ 'A generated file that must be rebuilt is listed in `regenerate` with the command that rebuilds it, such as `astryx theme build`: a protected generated file a codemod still needs to change ' +
225
+ '(also in `protectedFiles`), or a generated output a codemod found out of date (also in `protectedFiles`, with the rule that protects it, when the project marks it generated). With --apply, upgrade runs your `hooks.postCodemod` commands and checks again. ' +
226
+ 'If a protected file still needs rebuilding, the run is incomplete exactly as for any protected file: it exits 1 and the result says `complete: false` and `errorCode: "ERR_CODEMOD_PROTECTED"`. ' +
227
+ 'If a file nothing protects still needs rebuilding, no protected file is in the way: the codemod could not make a required change, so it is also in `errors` and the run fails with `ERR_CODEMOD_FAILED`, as described below. ' +
228
+ 'Either way, rebuild it, then run the same upgrade again. ' +
229
+ 'When a codemod also failed, the failure is reported as below, and the receipt it carries still lists `declinedCandidates` and `regenerate`, ' +
230
+ 'unless a protected file to regenerate also remains, in which case the run returns `ERR_CODEMOD_PROTECTED` with the failure in `errors`.',
231
+ },
232
+ {type: 'heading', level: 3, text: 'A failed codemod'},
233
+ {
234
+ type: 'prose',
235
+ text:
236
+ 'When a codemod or a `hooks.postCodemod` command fails, upgrade still makes every other change, exits 1 with ERR_CODEMOD_FAILED, and does not refresh the agent docs. ' +
237
+ 'With --json, the result is the usual error, `{"error": ..., "code": "ERR_CODEMOD_FAILED"}`, plus a `receipt`: the same fields a finished run returns, with `complete: false`, ' +
238
+ 'each failure in `errors`, and every file upgrade changed (or would change) in `modifiedFiles`, so a script can review, keep, or revert them. ' +
239
+ 'An error that stops the run after codemods have written files, such as an astryx.config that fails validation, carries a `receipt` too. ' +
240
+ 'Rerun past a failed codemod with --skip-codemod.',
241
+ },
197
242
  ],
198
243
  };