@astryxdesign/cli 0.7.5-canary.577e8ca → 0.7.5-canary.5b691cd

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 (35) hide show
  1. package/README.md +1 -1
  2. package/api/theme/build/build.mjs +9 -4
  3. package/api/upgrade/_adapter.d.mts +45 -2
  4. package/api/upgrade/_adapter.mjs +58 -2
  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 +446 -61
  8. package/api/upgrade/upgrade.doc.mjs +2 -2
  9. package/api/upgrade/upgrade.type.d.mts +24 -0
  10. package/api/upgrade/upgrade.type.mjs +15 -3
  11. package/assets/codemods/outcome.mjs +79 -0
  12. package/assets/codemods/outcome.test.mjs +40 -0
  13. package/assets/codemods/runner.mjs +11 -3
  14. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +24 -4
  15. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +6 -3
  16. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  17. package/assets/docs/tree/tokens-color.doc.mjs +145 -1
  18. package/assets/docs/tree/tokens.doc.mjs +1 -1
  19. package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
  20. package/assets/templates/pages/table-comparison/page.tsx +12 -3
  21. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
  22. package/assets/templates/themes/butter/butterTheme.ts +47 -44
  23. package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
  24. package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
  25. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
  26. package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
  27. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
  28. package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
  29. package/assets/templates/themes/stone/stoneTheme.ts +46 -21
  30. package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
  31. package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
  32. package/clients/cli/commands/upgrade.doc.mjs +20 -2
  33. package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
  34. package/foundation/response/response-types.doc.mjs +1 -1
  35. package/package.json +10 -9
@@ -128,7 +128,7 @@ export const doc = {
128
128
  {
129
129
  type: 'upgrade.run',
130
130
  description:
131
- 'The terminal run receipt: from, to, codemods (count), integrations, agentDocs, agentDocsRefreshed, registryCompositions (when receipts are found), sourcePathFound (false when the resolved `path` does not exist, so nothing was scanned), filesChanged, transformsApplied, modifiedFiles, protectedFiles, declinedCandidates, errors, and complete. When a protected file still requires a change, complete is false and errorCode is ERR_CODEMOD_PROTECTED; the CLI exits nonzero while preserving the structured receipt. A run that fails after its codemods ran throws instead (see throws), and the thrown AstryxError carries the same receipt on `receipt`, with complete false and errorCode set to its code. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run, and command runs the same upgrade with the matching CLI.',
131
+ 'The terminal run receipt: from, to, codemods (count), integrations, agentDocs, agentDocsRefreshed, registryCompositions (when receipts are found), sourcePathFound (false when the resolved `path` does not exist, so nothing was scanned), filesChanged, transformsApplied, modifiedFiles, protectedFiles, declinedCandidates (left unchanged for manual review, including code a codemod identified but cannot migrate; never incomplete), regenerate (generated files to rebuild, with their commands), errors, and complete. When a protected file still requires a change, including a protected file in regenerate, complete is false and errorCode is ERR_CODEMOD_PROTECTED; the CLI exits nonzero while preserving the structured receipt. A run that fails after its codemods ran throws instead (see throws), and the thrown AstryxError carries the same receipt on `receipt`, with complete false and errorCode set to its code. A file in regenerate that nothing protects is such a failure: it is also in errors, and the run throws ERR_CODEMOD_FAILED. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run, and command runs the same upgrade with the matching CLI.',
132
132
  },
133
133
  ],
134
134
  throws: [
@@ -155,7 +155,7 @@ export const doc = {
155
155
  },
156
156
  {
157
157
  code: 'ERR_CODEMOD_FAILED',
158
- when: "one or more codemods failed, or a post-codemod hook failed, and no protected file still needs a change (otherwise an upgrade.run receipt with complete: false is returned). The error carries the run's receipt on `receipt`: the files already changed, each failure in errors, complete: false",
158
+ when: "one or more codemods failed (including a generated file to regenerate that nothing protects), or a post-codemod hook failed, and no protected file still needs a change (otherwise an upgrade.run receipt with complete: false is returned). The error carries the run's receipt on `receipt`: the files already changed, each failure in errors, complete: false",
159
159
  },
160
160
  {
161
161
  code: 'ERR_CODEMOD_PROTECTION_SOURCE',
@@ -162,6 +162,29 @@ export type ProtectedCodemodFile = {
162
162
  */
163
163
  commands: string[];
164
164
  };
165
+ /**
166
+ * A generated file that must be rebuilt before the upgrade is complete: a
167
+ * protected generated file a codemod still needs to change (also listed in
168
+ * `protectedFiles`), or a generated output a codemod reported out of date.
169
+ */
170
+ export type RegenerateFile = {
171
+ /**
172
+ * Path relative to the folder the command ran in.
173
+ */
174
+ file: string;
175
+ /**
176
+ * Codemods that need the rebuild.
177
+ */
178
+ codemods: string[];
179
+ /**
180
+ * Exact commands that rebuild the file, when known: the generated header's `Command:` line, or the command the codemod names (such as `astryx theme build`).
181
+ */
182
+ commands: string[];
183
+ /**
184
+ * Why a codemod reported the file out of date; empty for a protected generated file that no codemod reported out of date, whose `protectedFiles` entry carries its declarations.
185
+ */
186
+ messages: string[];
187
+ };
165
188
  /**
166
189
  * Present only when the installed `@astryxdesign/core` (the response's `to`) is
167
190
  * newer than the running CLI. Core codemods ship inside the CLI, so this CLI
@@ -193,6 +216,7 @@ export type UpgradeRunResponse = {
193
216
  sourcePathFound: boolean;
194
217
  registryCompositions?: RegistryCompositionSummary | undefined;
195
218
  complete?: boolean | undefined;
219
+ regenerate?: RegenerateFile[] | undefined;
196
220
  errorCode?: string | undefined;
197
221
  filesChanged?: number | undefined;
198
222
  modifiedFiles?: string[] | undefined;
@@ -108,6 +108,17 @@
108
108
  * @property {string[]} commands Exact regeneration commands found in generated headers, when present.
109
109
  */
110
110
 
111
+ /**
112
+ * A generated file that must be rebuilt before the upgrade is complete: a
113
+ * protected generated file a codemod still needs to change (also listed in
114
+ * `protectedFiles`), or a generated output a codemod reported out of date.
115
+ * @typedef {object} RegenerateFile
116
+ * @property {string} file Path relative to the folder the command ran in.
117
+ * @property {string[]} codemods Codemods that need the rebuild.
118
+ * @property {string[]} commands Exact commands that rebuild the file, when known: the generated header's `Command:` line, or the command the codemod names (such as `astryx theme build`).
119
+ * @property {string[]} messages Why a codemod reported the file out of date; empty for a protected generated file that no codemod reported out of date, whose `protectedFiles` entry carries its declarations.
120
+ */
121
+
111
122
  /**
112
123
  * Present only when the installed `@astryxdesign/core` (the response's `to`) is
113
124
  * newer than the running CLI. Core codemods ship inside the CLI, so this CLI
@@ -131,14 +142,15 @@
131
142
  * @property {AgentDocsSummary} data.agentDocs
132
143
  * @property {boolean} data.sourcePathFound Whether the resolved source directory (`path`, default `./src`) exists. False means no source file was read, so a zero `filesChanged` says nothing about the project being migrated.
133
144
  * @property {RegistryCompositionSummary} [data.registryCompositions]
134
- * @property {boolean} [data.complete] False when protected required changes remain. Also false on the receipt a failed run's error carries (`UpgradeFailureReceipt`).
145
+ * @property {boolean} [data.complete] False when protected required changes remain, including a protected file in `regenerate`. Declined candidates alone never make it false. Also false on the receipt a failed run's error carries (`UpgradeFailureReceipt`).
146
+ * @property {RegenerateFile[]} [data.regenerate] Generated files to rebuild, with their commands; rebuild them, then run the same upgrade again. A listed file the project protects (for example with an `@generated` header) is also in `protectedFiles`, with the declaration that protects it and the same commands, and makes the run incomplete with `ERR_CODEMOD_PROTECTED`. A listed file nothing protects is a codemod error: it is also in `errors`, and the run fails with `ERR_CODEMOD_FAILED` (`UpgradeFailureReceipt`).
135
147
  * @property {string} [data.errorCode] Stable incomplete-result code when complete is false: `ERR_CODEMOD_PROTECTED` on a returned receipt; on the receipt a failed run's error carries, the error's own code.
136
148
  * @property {number} [data.filesChanged] Distinct files changed across core + integration codemods (apply mode). One file that four codemods each changed counts once.
137
149
  * @property {string[]} [data.modifiedFiles] Files changed or previewed, relative to the folder the command ran in.
138
150
  * @property {ProtectedCodemodFile[]} [data.protectedFiles] Protected files that still require a codemod change after regeneration.
139
- * @property {Array<{file: string, location?: string, reason: string}>} [data.declinedCandidates] Candidates left unchanged because proof was insufficient, one row per file, for manual review. A protected file whose own source does not parse is listed here, with the parse error's `line:column` as `location` and a `reason` that starts with `unparseable protected file`, instead of failing the run. Declined candidates do not make the run incomplete. Each `file` is relative to the folder the command ran in.
151
+ * @property {Array<{file: string, location?: string, reason: string}>} [data.declinedCandidates] Candidates left unchanged because proof was insufficient, one row per file, for manual review. A protected file whose own source does not parse is listed here, with the parse error's `line:column` as `location` and a `reason` that starts with `unparseable protected file`, instead of failing the run. Code a codemod identified but cannot migrate safely is listed here too, with its line as `location` when known and a `reason` that starts with `manual migration needed (<codemod>):` followed by what to change. A file with several declined findings, of either kind, keeps one row: each finding keeps its own prefix, they are joined by `; `, unparseable-file findings first, then manual migrations, each in the order found, and `location` is the first finding's own location (absent when it has none). A later finding whose location differs from the row's ends with ` (at <location>)`, or ` (location unknown)` when it has none; one without a suffix is at the row's location. Declined candidates do not make the run incomplete. Each `file` is relative to the folder the command ran in.
140
152
  * @property {number} [data.transformsApplied] Total codemod changes. A code or config codemod counts once for each file it changed, so one file changed by four of them counts four times; a project codemod counts once, however many files it writes.
141
- * @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed. On the receipt a failed run's error carries, also a post-codemod hook failure (`codemod: 'post-codemod-hook'`) or the error that stopped the run after codemods wrote files. Each `file` is relative to the folder the command ran in.
153
+ * @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed. On the receipt a failed run's error carries, also a post-codemod hook failure (`codemod: 'post-codemod-hook'`) or the error that stopped the run after codemods wrote files. A returned `ERR_CODEMOD_PROTECTED` result lists them too when a protected file wins over them: a post-codemod hook failure, or an `astryx.config` that fails validation (`{file: '.', codemod: 'config', error}`). Each `file` is relative to the folder the command ran in.
142
154
  * @property {CliBehindCore} [data.cliBehindCore] Present only when the installed Core is newer than this CLI: codemods for the releases after `cliBehindCore.cliVersion` did not run.
143
155
  */
144
156
 
@@ -0,0 +1,79 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Codemod outcomes that are not failures.
5
+ *
6
+ * A core transform throws one of these, instead of a plain Error, when a file
7
+ * needs a change the codemod cannot make itself:
8
+ *
9
+ * - `ManualMigrationRequired`: a person must migrate the code (the codemod can
10
+ * identify it but has no safe rewrite). Reported in the upgrade receipt's
11
+ * `declinedCandidates`; it does not fail the run.
12
+ * - `RegenerationRequired`: a generated file is out of date and its generator
13
+ * must rebuild it. Reported in `regenerate` with the command that does; the
14
+ * run is incomplete until it is rebuilt.
15
+ *
16
+ * Anything else a transform throws is still a codemod failure. The upgrade
17
+ * leaf (`api/upgrade/_adapter.mjs` `withCodemodOutcomes`) catches these around
18
+ * each core transform, so the codemod runners never see them.
19
+ *
20
+ * @input A message, and the source line or regeneration commands
21
+ * @output Error subclasses tagged with a stable outcome kind
22
+ * @position Shared by core codemod transforms and the upgrade leaf
23
+ */
24
+
25
+ const OUTCOME = Symbol.for('astryx.codemod.outcome');
26
+
27
+ /** A person must migrate this code; the codemod has no safe rewrite. */
28
+ export class ManualMigrationRequired extends Error {
29
+ /**
30
+ * @param {string} message What to change, and how.
31
+ * @param {{line?: number | null}} [options] 1-based source line, when known.
32
+ */
33
+ constructor(message, {line} = {}) {
34
+ super(message);
35
+ this.name = 'ManualMigrationRequired';
36
+ /** @type {number | undefined} */
37
+ this.line = typeof line === 'number' ? line : undefined;
38
+ Object.defineProperty(this, OUTCOME, {value: 'manual'});
39
+ }
40
+ }
41
+
42
+ /** A generated file is out of date; its generator must rebuild it. */
43
+ export class RegenerationRequired extends Error {
44
+ /**
45
+ * @param {string} message Why the file is out of date.
46
+ * @param {{commands: string[]}} options Commands that rebuild it.
47
+ */
48
+ constructor(message, {commands}) {
49
+ super(message);
50
+ this.name = 'RegenerationRequired';
51
+ /** @type {string[]} */
52
+ this.commands = [...commands];
53
+ Object.defineProperty(this, OUTCOME, {value: 'regenerate'});
54
+ }
55
+ }
56
+
57
+ /**
58
+ * The outcome a thrown value reports, or null for an ordinary failure.
59
+ * @param {unknown} err
60
+ * @returns {{kind: 'manual', message: string, line?: number} | {kind: 'regenerate', message: string, commands: string[]} | null}
61
+ */
62
+ export function codemodOutcome(err) {
63
+ if (!err || typeof err !== 'object') return null;
64
+ const kind = /** @type {any} */ (err)[OUTCOME];
65
+ const message = /** @type {Error} */ (err).message;
66
+ if (kind === 'manual') {
67
+ const line = /** @type {ManualMigrationRequired} */ (err).line;
68
+ return {kind, message, ...(typeof line === 'number' ? {line} : {})};
69
+ }
70
+ if (kind === 'regenerate') {
71
+ const commands = /** @type {RegenerationRequired} */ (err).commands;
72
+ return {
73
+ kind,
74
+ message,
75
+ commands: Array.isArray(commands) ? [...commands] : [],
76
+ };
77
+ }
78
+ return null;
79
+ }
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+ import {
5
+ ManualMigrationRequired,
6
+ RegenerationRequired,
7
+ codemodOutcome,
8
+ } from './outcome.mjs';
9
+
10
+ describe('codemodOutcome', () => {
11
+ it('reads a manual migration with and without its line', () => {
12
+ expect(codemodOutcome(new ManualMigrationRequired('m', {line: 3}))).toEqual(
13
+ {kind: 'manual', message: 'm', line: 3},
14
+ );
15
+ expect(codemodOutcome(new ManualMigrationRequired('m'))).toEqual({
16
+ kind: 'manual',
17
+ message: 'm',
18
+ });
19
+ });
20
+
21
+ it('reads a regeneration with its commands', () => {
22
+ expect(
23
+ codemodOutcome(new RegenerationRequired('r', {commands: ['gen']})),
24
+ ).toEqual({kind: 'regenerate', message: 'r', commands: ['gen']});
25
+ });
26
+
27
+ it('treats anything else as an ordinary failure', () => {
28
+ expect(codemodOutcome(new Error('boom'))).toBeNull();
29
+ expect(
30
+ codemodOutcome(Object.assign(new Error('x'), {kind: 'manual'})),
31
+ ).toBeNull();
32
+ expect(codemodOutcome('boom')).toBeNull();
33
+ expect(codemodOutcome(undefined)).toBeNull();
34
+ });
35
+
36
+ it('stays an Error, so a runner without the wrapper still reports it', () => {
37
+ expect(new ManualMigrationRequired('m')).toBeInstanceOf(Error);
38
+ expect(new RegenerationRequired('r', {commands: []})).toBeInstanceOf(Error);
39
+ });
40
+ });
@@ -508,6 +508,7 @@ async function runProjectCodemod(
508
508
  * @param {string} [options.root] - Project root a project codemod reads (default: the process cwd)
509
509
  * @param {{root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}} [options.protection] - Preloaded protection resolver
510
510
  * @param {boolean} [options.coversTarget] - False when these codemods stop before the installed target (the CLI is older than Core), so a run with no changes does not say the code is up to date. Default true.
511
+ * @param {unknown[]} [options.outcomes] - Findings the transforms reported instead of changing a file (manual migrations, files to regenerate), filled while the run goes. A run with any does not say the code is up to date; the caller lists them.
511
512
  * @returns {Promise<{totalFilesChanged: number, totalTransformsApplied: number, totalValidationBlocked: number, changedFiles: string[], writtenFiles: string[], stagedContents: Map<string, string>, protectedFiles: import('../../authoring/codemod/type').CodemodRunResult['protectedFiles'], declinedCandidates: NonNullable<import('../../authoring/codemod/type').CodemodRunResult['declinedCandidates']>, errors: Array<{file: string, codemod: string, error: string}>, skippedOptional: Array<{name: string, meta: {title: string, description?: string, fileExtensions?: string[], codemodType?: string}, version: string}>} | {ok: false, reason: string, resolvedPath: string}>}
512
513
  */
513
514
  export async function runCodemods(
@@ -521,6 +522,7 @@ export async function runCodemods(
521
522
  root = process.cwd(),
522
523
  protection: providedProtection,
523
524
  coversTarget = true,
525
+ outcomes,
524
526
  },
525
527
  ) {
526
528
  // No-op stub object so silent mode skips log output entirely without
@@ -735,6 +737,12 @@ export async function runCodemods(
735
737
  // A later codemod can block a file an earlier one declined. The caller
736
738
  // prints declined files once it has reconciled every runner's results.
737
739
  const reportedDeclined = withoutProtected(declinedCandidates, protectedFiles);
740
+ // A generated file a transform reported out of date keeps the run from
741
+ // looking done, as a blocked protected file does.
742
+ const pendingRegeneration = (outcomes ?? []).some(
743
+ outcome =>
744
+ /** @type {{kind?: string} | null} */ (outcome)?.kind === 'regenerate',
745
+ );
738
746
 
739
747
  if (
740
748
  totalFilesChanged === 0 &&
@@ -744,12 +752,12 @@ export async function runCodemods(
744
752
  ) {
745
753
  // Codemods that stop before the installed target cannot vouch for the
746
754
  // code; the caller says what is missing.
747
- if (coversTarget) {
755
+ if (coversTarget && !(outcomes && outcomes.length > 0)) {
748
756
  log.success('No changes needed — your code is already up to date!');
749
757
  }
750
- } else if (apply && protectedFiles.length > 0) {
758
+ } else if (apply && (protectedFiles.length > 0 || pendingRegeneration)) {
751
759
  log.warn(
752
- `Applied ${totalTransformsApplied} owned change${totalTransformsApplied === 1 ? '' : 's'} across ${totalFilesChanged} file${totalFilesChanged === 1 ? '' : 's'}; protected changes remain.`,
760
+ `Applied ${totalTransformsApplied} owned change${totalTransformsApplied === 1 ? '' : 's'} across ${totalFilesChanged} file${totalFilesChanged === 1 ? '' : 's'}; ${protectedFiles.length > 0 ? 'protected changes remain' : 'generated files to regenerate remain'}.`,
753
761
  );
754
762
  } else if (apply) {
755
763
  log.success(
@@ -5,6 +5,7 @@ import * as os from 'node:os';
5
5
  import * as path from 'node:path';
6
6
  import {afterAll, describe, expect, it} from 'vitest';
7
7
  import transform, {meta} from '../validate-data-token-ownership.mjs';
8
+ import {codemodOutcome} from '../../../outcome.mjs';
8
9
  import {upgrade} from '../../../../../api/upgrade/upgrade.mjs';
9
10
 
10
11
  const SLOW = 30_000;
@@ -76,10 +77,20 @@ describe('validate-data-token-ownership', () => {
76
77
  expect(meta.fileExtensions).toEqual(['.css']);
77
78
  });
78
79
 
79
- it('fails on stale generated theme CSS with root data defaults', () => {
80
+ it('reports stale generated theme CSS with root data defaults as a regeneration', () => {
80
81
  expect(() => transform({source: STALE_THEME, path: 'theme.css'})).toThrow(
81
82
  /Rebuild it with `astryx theme build`/,
82
83
  );
84
+ let thrown;
85
+ try {
86
+ transform({source: STALE_THEME, path: 'theme.css'});
87
+ } catch (err) {
88
+ thrown = err;
89
+ }
90
+ expect(codemodOutcome(thrown)).toMatchObject({
91
+ kind: 'regenerate',
92
+ commands: ['astryx theme build'],
93
+ });
83
94
  });
84
95
 
85
96
  it('passes raw data-token uses with or without a fallback', () => {
@@ -136,11 +147,20 @@ describe('validate-data-token-ownership', () => {
136
147
  );
137
148
 
138
149
  it(
139
- 'fails `astryx upgrade --apply` on stale generated theme CSS',
150
+ 'leaves `astryx upgrade --apply` incomplete on stale generated theme CSS, naming the rebuild',
140
151
  async () => {
141
152
  const root = project({...PREBUILT, 'src/theme.css': STALE_THEME});
142
- await expect(runUpgrade(root)).rejects.toMatchObject({
143
- code: 'ERR_CODEMOD_FAILED',
153
+ const res = await runUpgrade(root);
154
+ expect(res.data).toMatchObject({
155
+ complete: false,
156
+ errorCode: 'ERR_CODEMOD_PROTECTED',
157
+ errors: [],
158
+ regenerate: [
159
+ expect.objectContaining({
160
+ file: 'src/theme.css',
161
+ commands: ['astryx theme build'],
162
+ }),
163
+ ],
144
164
  });
145
165
  },
146
166
  SLOW,
@@ -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;
@@ -56,7 +56,7 @@ import {colorVars} from '@astryxdesign/core/theme/tokens.stylex';
56
56
 
57
57
  const styles = stylex.create({
58
58
  trend: {
59
- color: colorVars['--color-success'],
59
+ color: colorVars['--color-text-success'],
60
60
  minWidth: 0,
61
61
  },
62
62
  });
@@ -26,6 +26,55 @@ export const docs = {
26
26
  "type": "prose",
27
27
  "text": "Semantic colors for consistent theming. All colors use light-dark() for automatic mode switching."
28
28
  },
29
+ {
30
+ "type": "prose",
31
+ "text": "Status roles: pick the token by the surface. `<status>` is info, success, warning, or error."
32
+ },
33
+ {
34
+ "type": "table",
35
+ "headers": [
36
+ "Status role",
37
+ "Use it for",
38
+ "Pairs with"
39
+ ],
40
+ "rows": [
41
+ [
42
+ "--color-text-<status>",
43
+ "Status text on the page or a card (4.5:1 or more).",
44
+ "—"
45
+ ],
46
+ [
47
+ "--color-icon-<status>",
48
+ "Status icons on the page or a card. Defaults to the text colour.",
49
+ "—"
50
+ ],
51
+ [
52
+ "--color-border-<status>",
53
+ "Status borders on the page or a card, such as an invalid field. Defaults to the text colour.",
54
+ "—"
55
+ ],
56
+ [
57
+ "--color-<status>",
58
+ "Strong status fill, such as a Badge or StatusDot.",
59
+ "--color-on-<status>"
60
+ ],
61
+ [
62
+ "--color-on-<status>",
63
+ "Text and icons on the strong fill (4.5:1 or more).",
64
+ "--color-<status>"
65
+ ],
66
+ [
67
+ "--color-<status>-muted",
68
+ "Pale status fill, such as a Banner.",
69
+ "--color-on-<status>-muted"
70
+ ],
71
+ [
72
+ "--color-on-<status>-muted",
73
+ "Text and icons on the pale fill (4.5:1 or more).",
74
+ "--color-<status>-muted"
75
+ ]
76
+ ]
77
+ },
29
78
  {
30
79
  "type": "table",
31
80
  "headers": [
@@ -154,6 +203,21 @@ export const docs = {
154
203
  "#AA071E",
155
204
  "#E3193B"
156
205
  ],
206
+ [
207
+ "--color-info",
208
+ "#0064E0",
209
+ "#0064E0"
210
+ ],
211
+ [
212
+ "--color-info-muted",
213
+ "#0082FB33",
214
+ "#0082FB3F"
215
+ ],
216
+ [
217
+ "--color-on-info",
218
+ "#FFFFFF",
219
+ "#FFFFFF"
220
+ ],
157
221
  [
158
222
  "--color-success",
159
223
  "#0D8626",
@@ -182,7 +246,7 @@ export const docs = {
182
246
  [
183
247
  "--color-on-error",
184
248
  "#FFFFFF",
185
- "#FFFFFF"
249
+ "#0A1317"
186
250
  ],
187
251
  [
188
252
  "--color-warning",
@@ -199,6 +263,86 @@ export const docs = {
199
263
  "#0A1317",
200
264
  "#0A1317"
201
265
  ],
266
+ [
267
+ "--color-text-info",
268
+ "var(--color-text-blue)",
269
+ "var(--color-text-blue)"
270
+ ],
271
+ [
272
+ "--color-text-success",
273
+ "var(--color-text-green)",
274
+ "var(--color-text-green)"
275
+ ],
276
+ [
277
+ "--color-text-warning",
278
+ "var(--color-text-yellow)",
279
+ "var(--color-text-yellow)"
280
+ ],
281
+ [
282
+ "--color-text-error",
283
+ "var(--color-text-red)",
284
+ "var(--color-text-red)"
285
+ ],
286
+ [
287
+ "--color-icon-info",
288
+ "var(--color-text-info)",
289
+ "var(--color-text-info)"
290
+ ],
291
+ [
292
+ "--color-icon-success",
293
+ "var(--color-text-success)",
294
+ "var(--color-text-success)"
295
+ ],
296
+ [
297
+ "--color-icon-warning",
298
+ "var(--color-text-warning)",
299
+ "var(--color-text-warning)"
300
+ ],
301
+ [
302
+ "--color-icon-error",
303
+ "var(--color-text-error)",
304
+ "var(--color-text-error)"
305
+ ],
306
+ [
307
+ "--color-border-info",
308
+ "var(--color-text-info)",
309
+ "var(--color-text-info)"
310
+ ],
311
+ [
312
+ "--color-border-success",
313
+ "var(--color-text-success)",
314
+ "var(--color-text-success)"
315
+ ],
316
+ [
317
+ "--color-border-warning",
318
+ "var(--color-text-warning)",
319
+ "var(--color-text-warning)"
320
+ ],
321
+ [
322
+ "--color-border-error",
323
+ "var(--color-text-error)",
324
+ "var(--color-text-error)"
325
+ ],
326
+ [
327
+ "--color-on-info-muted",
328
+ "var(--color-text-blue)",
329
+ "var(--color-text-blue)"
330
+ ],
331
+ [
332
+ "--color-on-success-muted",
333
+ "var(--color-text-green)",
334
+ "var(--color-text-green)"
335
+ ],
336
+ [
337
+ "--color-on-warning-muted",
338
+ "var(--color-text-yellow)",
339
+ "var(--color-text-yellow)"
340
+ ],
341
+ [
342
+ "--color-on-error-muted",
343
+ "var(--color-text-red)",
344
+ "var(--color-text-red)"
345
+ ],
202
346
  [
203
347
  "--color-border",
204
348
  "#05365919",
@@ -2,7 +2,7 @@
2
2
 
3
3
  // AUTO-GENERATED — do not edit manually.
4
4
  // Run: node scripts/generate-token-docs.mjs
5
- // Total: 263 tokens across 15 categories.
5
+ // Total: 282 tokens across 15 categories.
6
6
 
7
7
  /** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
8
8
  export const docs = {
@@ -94,9 +94,9 @@ interface WindowSeries {
94
94
  }
95
95
 
96
96
  const STATUS_STROKE: Record<HealthStatus, string> = {
97
- healthy: 'var(--color-success, #0B991F)',
98
- warning: 'var(--color-warning, #B25000)',
99
- critical: 'var(--color-error, #D6002A)',
97
+ healthy: 'var(--color-text-success)',
98
+ warning: 'var(--color-text-warning)',
99
+ critical: 'var(--color-text-error)',
100
100
  };
101
101
 
102
102
  const STATUS_DOT: Record<HealthStatus, StatusDotVariant> = {
@@ -969,12 +969,21 @@ function uptimeStatus(value: number): {
969
969
  status: string;
970
970
  } {
971
971
  if (value >= 99.95) {
972
- return {color: colorVars['--color-success'], status: 'Operational'};
972
+ return {
973
+ color: colorVars['--color-text-success'],
974
+ status: 'Operational',
975
+ };
973
976
  }
974
977
  if (value >= 99) {
975
- return {color: colorVars['--color-warning'], status: 'Degraded'};
978
+ return {
979
+ color: colorVars['--color-text-warning'],
980
+ status: 'Degraded',
981
+ };
976
982
  }
977
- return {color: colorVars['--color-error'], status: 'Outage'};
983
+ return {
984
+ color: colorVars['--color-text-error'],
985
+ status: 'Outage',
986
+ };
978
987
  }
979
988
 
980
989
  interface UptimeDay {
@@ -11,7 +11,7 @@ export const butterPaletteRefs = {
11
11
  dark: {25: '#52237b', 80: '#ddb9f6', 90: '#f2daff'},
12
12
  },
13
13
  green: {
14
- light: {25: '#004a05', 70: '#7bbf7a', 80: '#a2d7a0', 85: '#b6e3b4', 90: '#caeec8'},
14
+ light: {25: '#004a05', 55: '#4a984a', 70: '#7bbf7a', 80: '#a2d7a0', 85: '#b6e3b4', 90: '#caeec8'},
15
15
  dark: {15: '#013004', 20: '#063c0a', 70: '#83bc82', 80: '#a8d4a6', 90: '#cdedcc'},
16
16
  },
17
17
  neutral: {
@@ -31,7 +31,7 @@ export const butterPaletteRefs = {
31
31
  dark: {15: '#4c0700', 25: '#6f1400', 80: '#ffb09b', 85: '#ffc5b5', 90: '#ffd9cf'},
32
32
  },
33
33
  yellow: {
34
- light: {25: '#443c00', 30: '#514700', 70: '#bfae35', 80: '#dfcf5b', 85: '#f0df72', 90: '#fdee8c', 95: '#fff7c0'},
34
+ light: {25: '#443c00', 30: '#514700', 55: '#958500', 70: '#bfae35', 80: '#dfcf5b', 85: '#f0df72', 90: '#fdee8c', 95: '#fff7c0'},
35
35
  dark: {15: '#2c2600', 25: '#443c00', 70: '#bcae4e', 75: '#cdbe59', 85: '#eedf75', 90: '#fdee8c'},
36
36
  },
37
37
  teal: {
@@ -40,6 +40,7 @@ export const butterPaletteRefs = {
40
40
  },
41
41
  accent: {
42
42
  light: {35: '#194ce8', 40: '#225bff', 55: '#4d82ff'},
43
+ dark: {70: '#81a9ff'},
43
44
  },
44
45
  cyan: {
45
46
  light: {25: '#004649', 80: '#8dd2d3', 90: '#a9eff0'},