@astryxdesign/cli 0.7.14 → 0.7.15-canary.gea16e8d

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 (129) hide show
  1. package/api/doctor/_adapter.d.mts +1 -0
  2. package/api/doctor/_adapter.mjs +8 -0
  3. package/api/doctor/_authoring-audit.d.mts +42 -0
  4. package/api/doctor/_authoring-audit.mjs +106 -0
  5. package/api/doctor/doctor.d.mts +7 -0
  6. package/api/doctor/doctor.mjs +24 -39
  7. package/api/search/_adapter.mjs +124 -3
  8. package/api/search/_candidate-score.mjs +63 -9
  9. package/api/search/_entries.d.mts +10 -0
  10. package/api/search/_entries.mjs +68 -1
  11. package/api/search/_gather-templates.d.mts +11 -0
  12. package/api/search/_gather-templates.mjs +22 -2
  13. package/api/search/_words.mjs +26 -6
  14. package/api/swizzle/copy/copy.mjs +1 -1
  15. package/api/theme/_adapter.mjs +20 -9
  16. package/api/theme/build/build.d.mts +15 -1
  17. package/api/theme/build/build.mjs +132 -32
  18. package/api/theme/targets/targets.d.mts +8 -0
  19. package/api/theme/targets/targets.mjs +14 -1
  20. package/api/theme/themeBuild.doc.mjs +6 -3
  21. package/api/theme/themeEject.doc.mjs +3 -3
  22. package/api/theme/themeTargets.doc.mjs +1 -1
  23. package/api/theme-edit/_adapter.d.mts +46 -3
  24. package/api/theme-edit/_adapter.mjs +372 -109
  25. package/api/theme-edit/_check.d.mts +6 -3
  26. package/api/theme-edit/_check.mjs +665 -87
  27. package/api/theme-edit/_color.mjs +4 -2
  28. package/api/theme-edit/_compiler.d.mts +2 -1
  29. package/api/theme-edit/_compiler.mjs +27 -13
  30. package/api/theme-edit/_context.d.mts +2 -1
  31. package/api/theme-edit/_context.mjs +47 -8
  32. package/api/theme-edit/_edit.d.mts +9 -3
  33. package/api/theme-edit/_edit.mjs +484 -66
  34. package/api/theme-edit/_how-commands.d.mts +33 -7
  35. package/api/theme-edit/_how-commands.mjs +57 -45
  36. package/api/theme-edit/_how-question.d.mts +4 -0
  37. package/api/theme-edit/_how-question.mjs +1004 -223
  38. package/api/theme-edit/_how.mjs +96 -9
  39. package/api/theme-edit/_palette.d.mts +38 -13
  40. package/api/theme-edit/_palette.mjs +620 -223
  41. package/api/theme-edit/_parts.mjs +63 -7
  42. package/api/theme-edit/_png.d.mts +4 -4
  43. package/api/theme-edit/_png.mjs +4 -2
  44. package/api/theme-edit/_preview-app.d.mts +6 -0
  45. package/api/theme-edit/_preview-app.mjs +1194 -207
  46. package/api/theme-edit/_preview.mjs +2 -2
  47. package/api/theme-edit/_project.d.mts +12 -1
  48. package/api/theme-edit/_project.mjs +37 -6
  49. package/api/theme-edit/_settings.d.mts +104 -33
  50. package/api/theme-edit/_settings.mjs +818 -118
  51. package/api/theme-edit/_tables.d.mts +7 -0
  52. package/api/theme-edit/_tables.mjs +61 -0
  53. package/api/theme-edit/theme-edit.type.d.mts +11 -1
  54. package/api/theme-edit/theme-edit.type.mjs +4 -3
  55. package/api/theme-edit/themeEditHow.doc.mjs +6 -0
  56. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  57. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  58. package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
  59. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
  60. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  61. package/api/upgrade/_adapter.d.mts +1 -0
  62. package/assets/codemods/run-codemod.mjs +61 -0
  63. package/assets/codemods/runner.mjs +5 -4
  64. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
  65. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
  66. package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
  67. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
  68. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
  69. package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
  70. package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
  71. package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
  72. package/assets/docs/tree/calendars.doc.mjs +1 -3
  73. package/assets/docs.generated.json +2 -1
  74. package/assets/self-audit.generated.json +1 -0
  75. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
  76. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
  77. package/assets/templates/components.generated.json +1 -1
  78. package/clients/cli/bin/astryx.mjs +19 -15
  79. package/clients/cli/build-id.generated.json +1 -0
  80. package/clients/cli/commands/ensure-core-built.mjs +12 -5
  81. package/clients/cli/commands/experimental/theme.mjs +178 -78
  82. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  83. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
  84. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
  85. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  86. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  87. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  88. package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
  89. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  90. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  91. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
  93. package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
  94. package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
  95. package/clients/cli/commands/manifest.mjs +5 -2
  96. package/clients/cli/commands/theme.mjs +118 -22
  97. package/clients/cli/index.mjs +9 -3
  98. package/clients/cli/lib/manifest.mjs +37 -0
  99. package/clients/cli/lib/resolve-theme.mjs +2 -1
  100. package/clients/cli/manifest.generated.json +1 -0
  101. package/foundation/discovery/module-exports.mjs +16 -2
  102. package/foundation/discovery/stored-self-audit.d.mts +31 -0
  103. package/foundation/discovery/stored-self-audit.mjs +119 -0
  104. package/foundation/discovery/template-adapter.d.mts +48 -2
  105. package/foundation/discovery/template-adapter.mjs +51 -19
  106. package/foundation/discovery/template-needs.d.mts +6 -0
  107. package/foundation/discovery/template-needs.mjs +20 -1
  108. package/foundation/discovery/template-source-tree.d.mts +7 -0
  109. package/foundation/discovery/template-source-tree.mjs +15 -0
  110. package/foundation/discovery/theme-discovery.d.mts +2 -1
  111. package/foundation/discovery/theme-discovery.mjs +2 -8
  112. package/foundation/discovery/theme-module-extensions.d.mts +18 -0
  113. package/foundation/discovery/theme-module-extensions.mjs +30 -0
  114. package/foundation/doc-compiler/import.mjs +12 -11
  115. package/foundation/doc-compiler/stored-docs.d.mts +18 -12
  116. package/foundation/doc-compiler/stored-docs.mjs +52 -19
  117. package/foundation/env/private-dir.d.mts +17 -0
  118. package/foundation/env/private-dir.mjs +42 -0
  119. package/foundation/fs/gather-cache.d.mts +108 -0
  120. package/foundation/fs/gather-cache.mjs +724 -0
  121. package/foundation/fs/module-loader.mjs +7 -1
  122. package/foundation/fs/read-record.d.mts +31 -1
  123. package/foundation/fs/read-record.mjs +100 -7
  124. package/foundation/integrations/validate-contributions.mjs +24 -11
  125. package/foundation/release/cache.d.mts +11 -2
  126. package/foundation/release/cache.mjs +59 -10
  127. package/foundation/release/folder-lock.d.mts +21 -0
  128. package/foundation/release/folder-lock.mjs +171 -0
  129. package/package.json +8 -6
@@ -1,6 +1,31 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * One change a command makes.
6
+ * @typedef {object} Step
7
+ * @property {'set' | 'undo'} verb
8
+ * @property {string} thing
9
+ * @property {string} [value]
10
+ * @property {string} [on]
11
+ * @property {string} [when]
12
+ * @property {string} [state]
13
+ * @property {string} [mode]
14
+ */
15
+ /**
16
+ * The theme the commands of one answer are for, and the checks they pass.
17
+ * @typedef {object} HowTheme
18
+ * @property {string} slug
19
+ * @property {boolean} exists - false when the app has no theme: the commands name {@link EXAMPLE_THEME} and the answer starts with `new`.
20
+ * @property {string[]} themes - Every theme the editor made in the app.
21
+ * @property {string | null} note - Which theme the commands are for when the app has several, or that it has none.
22
+ * @property {'named' | 'only' | 'last-changed' | 'none'} chosenBy - How the theme was picked.
23
+ * @property {number} undoSteps - How many changes `undo` can step back.
24
+ * @property {boolean} bodyFontReachesHeadings - Whether `font X --on body` also changes the heading font in this release.
25
+ * @property {import('./_settings.mjs').ThemeData} data
26
+ * @property {{light: Record<string, string>, dark: Record<string, string>}} base
27
+ * @property {(steps: Step[]) => {ok: true} | {ok: false, why: string}} check
28
+ */
4
29
  /**
5
30
  * The theme an answer's commands are for: the one named, the only one, or
6
31
  * the one changed last; with none, a theme the answer first makes.
@@ -10,13 +35,6 @@
10
35
  * @returns {Promise<HowTheme>}
11
36
  */
12
37
  export function howTheme(ctx: import("./_settings.mjs").Ctx, cwd: string, name: string | undefined): Promise<HowTheme>;
13
- /**
14
- * One word of a command as a shell takes it: plain when it is only safe
15
- * characters, otherwise in double quotes with the characters a shell
16
- * expands escaped.
17
- * @param {string} v
18
- */
19
- export function shellWord(v: string): string;
20
38
  /**
21
39
  * A step as the command a person runs.
22
40
  * @param {Step} st
@@ -77,6 +95,14 @@ export type HowTheme = {
77
95
  * - How the theme was picked.
78
96
  */
79
97
  chosenBy: "named" | "only" | "last-changed" | "none";
98
+ /**
99
+ * - How many changes `undo` can step back.
100
+ */
101
+ undoSteps: number;
102
+ /**
103
+ * - Whether `font X --on body` also changes the heading font in this release.
104
+ */
105
+ bodyFontReachesHeadings: boolean;
80
106
  data: import("./_settings.mjs").ThemeData;
81
107
  base: {
82
108
  light: Record<string, string>;
@@ -8,14 +8,20 @@
8
8
  * @position api/theme-edit — imported by _how.mjs and _how-question.mjs
9
9
  */
10
10
 
11
- import * as fs from 'node:fs';
12
- import * as path from 'node:path';
13
11
  import {AstryxError} from '../error.mjs';
14
12
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
15
13
  import {checkSetting} from './_check.mjs';
16
14
  import {baseResolved} from './_project.mjs';
17
- import {compileTheme, keyOf, loadTheme, themeFiles} from './_settings.mjs';
15
+ import {
16
+ compileTheme,
17
+ editedThemes,
18
+ keyOf,
19
+ loadTheme,
20
+ readHistory,
21
+ themeFiles,
22
+ } from './_settings.mjs';
18
23
  import {LIKE, P} from './_tables.mjs';
24
+ import {quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
19
25
 
20
26
  /** The theme name commands use when the app has no theme yet. */
21
27
  export const EXAMPLE_THEME = 'my-theme';
@@ -40,39 +46,13 @@ export const EXAMPLE_THEME = 'my-theme';
40
46
  * @property {string[]} themes - Every theme the editor made in the app.
41
47
  * @property {string | null} note - Which theme the commands are for when the app has several, or that it has none.
42
48
  * @property {'named' | 'only' | 'last-changed' | 'none'} chosenBy - How the theme was picked.
49
+ * @property {number} undoSteps - How many changes `undo` can step back.
50
+ * @property {boolean} bodyFontReachesHeadings - Whether `font X --on body` also changes the heading font in this release.
43
51
  * @property {import('./_settings.mjs').ThemeData} data
44
52
  * @property {{light: Record<string, string>, dark: Record<string, string>}} base
45
53
  * @property {(steps: Step[]) => {ok: true} | {ok: false, why: string}} check
46
54
  */
47
55
 
48
- /**
49
- * The themes the editor made in the app, the one an editor command changed
50
- * last first.
51
- * @param {string} cwd
52
- * @returns {string[]}
53
- */
54
- function editorThemes(cwd) {
55
- const root = path.join(cwd, 'themes');
56
- if (!fs.existsSync(root)) return [];
57
- return (
58
- fs
59
- .readdirSync(root)
60
- .filter(d => fs.existsSync(themeFiles(cwd, d).settings))
61
- // The undo history is written only by an editor command, so its time is
62
- // the last change made here; a checkout or touch of the settings file
63
- // does not move it.
64
- .map(d => {
65
- const f = themeFiles(cwd, d);
66
- const t =
67
- [f.history, f.settingsTs, f.settings].find(x => fs.existsSync(x)) ??
68
- f.settings;
69
- return {d, t: fs.statSync(t).mtimeMs};
70
- })
71
- .sort((a, b) => b.t - a.t || a.d.localeCompare(b.d))
72
- .map(x => x.d)
73
- );
74
- }
75
-
76
56
  /**
77
57
  * The theme an answer's commands are for: the one named, the only one, or
78
58
  * the one changed last; with none, a theme the answer first makes.
@@ -82,7 +62,7 @@ function editorThemes(cwd) {
82
62
  * @returns {Promise<HowTheme>}
83
63
  */
84
64
  export async function howTheme(ctx, cwd, name) {
85
- const themes = editorThemes(cwd);
65
+ const themes = editedThemes(cwd, 'changed');
86
66
  /** @type {import('./_settings.mjs').ThemeData | null} */
87
67
  let data = null;
88
68
  let slug = name ?? themes[0] ?? EXAMPLE_THEME;
@@ -115,6 +95,45 @@ export async function howTheme(ctx, cwd, name) {
115
95
  const compiled = (/** @type {import('./_settings.mjs').ThemeData} */ d) =>
116
96
  JSON.stringify([d.mode, compileTheme(ctx, d, base)]);
117
97
  const before = compiled(theme);
98
+ // Whether a body font setting also moves the heading font: Core gives
99
+ // headings the body family when a theme names no heading family, so it is
100
+ // read from Core, and stays right when that changes.
101
+ const {core} = ctx.project;
102
+ /** @param {any} typography */
103
+ const headingOf = typography => {
104
+ try {
105
+ return core.resolveThemeTokens(
106
+ core.defineTheme({
107
+ name: 'how-probe',
108
+ ...(typography ? {typography} : {}),
109
+ }),
110
+ {mode: 'light'},
111
+ )['--font-family-heading'];
112
+ } catch {
113
+ return null;
114
+ }
115
+ };
116
+ const fontless = {
117
+ ...theme,
118
+ settings: theme.settings.filter(
119
+ x => x.thing !== 'font' || x.on === 'heading',
120
+ ),
121
+ };
122
+ const bodyFontReachesHeadings =
123
+ headingOf(compileTheme(ctx, fontless, base).typography) !==
124
+ headingOf(
125
+ compileTheme(
126
+ ctx,
127
+ {
128
+ ...fontless,
129
+ settings: [
130
+ ...fontless.settings,
131
+ {thing: 'font', value: 'courier', on: 'body', source: 'dial'},
132
+ ],
133
+ },
134
+ base,
135
+ ).typography,
136
+ );
118
137
  return {
119
138
  slug,
120
139
  exists,
@@ -129,6 +148,10 @@ export async function howTheme(ctx, cwd, name) {
129
148
  : 'last-changed',
130
149
  data: theme,
131
150
  base,
151
+ undoSteps: exists
152
+ ? readHistory(themeFiles(cwd, slug).history).steps.length
153
+ : 0,
154
+ bodyFontReachesHeadings,
132
155
  check(steps) {
133
156
  /** @type {import('./_settings.mjs').ThemeData} */
134
157
  const d = JSON.parse(JSON.stringify(theme));
@@ -194,17 +217,6 @@ function apply(ctx, slug, d, st) {
194
217
  else d.settings.push(s);
195
218
  }
196
219
 
197
- /**
198
- * One word of a command as a shell takes it: plain when it is only safe
199
- * characters, otherwise in double quotes with the characters a shell
200
- * expands escaped.
201
- * @param {string} v
202
- */
203
- export function shellWord(v) {
204
- if (/^[A-Za-z0-9_.,:%+\-/=@]+$/.test(v)) return v;
205
- return `"${v.replace(/["\\$`]/g, c => `\\${c}`)}"`;
206
- }
207
-
208
220
  /**
209
221
  * A step as the command a person runs.
210
222
  * @param {Step} st
@@ -215,8 +227,8 @@ export function render(st, slug) {
215
227
  P,
216
228
  st.verb,
217
229
  slug,
218
- shellWord(st.thing),
219
- ...(st.value != null ? [shellWord(st.value)] : []),
230
+ quoteCommandArgument(st.thing),
231
+ ...(st.value != null ? [quoteCommandArgument(st.value)] : []),
220
232
  ...(st.on ? ['--on', st.on] : []),
221
233
  ...(st.when ? ['--when', st.when] : []),
222
234
  ...(st.state ? ['--state', st.state] : []),
@@ -43,6 +43,10 @@ export type Clause = {
43
43
  * - CSS written as `prop: value`
44
44
  */
45
45
  decl: Record<string, string>;
46
+ /**
47
+ * - family names the clause writes in quotes
48
+ */
49
+ quoted?: string[] | undefined;
46
50
  };
47
51
  export type Step = import("./_how-commands.mjs").Step;
48
52
  /**