@astryxdesign/cli 0.7.1-canary.ff40b78 → 0.7.1

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.
@@ -40,9 +40,48 @@ const gothicSyntax = defineSyntaxTheme({
40
40
  property: '#7cc5b3', // Verdigris
41
41
  punctuation: '#7a8290', // Mid neutral
42
42
  background: '#101314',
43
+ // Diff rows on the near-black background: any lighter wash lowers every
44
+ // light token's contrast, so the rows take opaque hues at the
45
+ // background's own luminance — a deep green and a deep red that read as
46
+ // colour, not brightness — and every token keeps the contrast it has on
47
+ // the plain background. Markers: forest moss and blood crimson.
48
+ added: '#081408',
49
+ removed: '#1e0a0a',
50
+ 'added-marker': '#a3c987',
51
+ 'removed-marker': '#d97580',
43
52
  },
44
53
  });
45
54
 
55
+ /**
56
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
57
+ * reuse it for their `secondary` trigger so every secondary control in this
58
+ * theme matches (AST-079 FR2).
59
+ *
60
+ * Primary inherits default — light pill with dark text via
61
+ * --color-accent / --color-on-accent (matches the cream badge).
62
+ * Secondary uses the dark-slate "neutral" badge treatment.
63
+ */
64
+ const SECONDARY_BUTTON = {
65
+ backgroundColor: 'var(--color-background-gray)',
66
+ color: 'var(--color-text-gray)',
67
+ borderColor: 'transparent',
68
+ borderWidth: '0',
69
+ } as const;
70
+
71
+ /**
72
+ * The secondary Button treatment on Selector and MultiSelector triggers
73
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
74
+ * group's edges instead (FR6).
75
+ */
76
+ const SECONDARY_SELECTOR = {
77
+ ':not(.astryx-input-group *)': {
78
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
79
+ color: SECONDARY_BUTTON.color,
80
+ borderColor: SECONDARY_BUTTON.borderColor,
81
+ borderWidth: SECONDARY_BUTTON.borderWidth,
82
+ },
83
+ } as const;
84
+
46
85
  export const gothicTheme = defineTheme({
47
86
  name: 'gothic',
48
87
 
@@ -227,15 +266,7 @@ export const gothicTheme = defineTheme({
227
266
 
228
267
  components: {
229
268
  button: {
230
- // Primary inherits default — light pill with dark text via
231
- // --color-accent / --color-on-accent (matches the cream badge).
232
- // Secondary uses the dark-slate "neutral" badge treatment.
233
- 'variant:secondary': {
234
- backgroundColor: 'var(--color-background-gray)',
235
- color: 'var(--color-text-gray)',
236
- borderColor: 'transparent',
237
- borderWidth: '0',
238
- },
269
+ 'variant:secondary': SECONDARY_BUTTON,
239
270
  'variant:ghost': {
240
271
  ':hover': {
241
272
  backgroundColor: 'var(--color-overlay-hover)',
@@ -248,6 +279,10 @@ export const gothicTheme = defineTheme({
248
279
  color: 'var(--color-text-red)',
249
280
  },
250
281
  },
282
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
283
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
284
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
285
+ 'complex-selector': {'variant:secondary': SECONDARY_BUTTON},
251
286
 
252
287
  badge: {
253
288
  base: {
@@ -56,9 +56,60 @@ const stoneSyntax = defineSyntaxTheme({
56
56
  property: ['#4e6357', '#94b2a0'], // Teal T40 / T70
57
57
  punctuation: ['#5e5e5e', '#ababb0'], // Stone Neutral T40 / T70
58
58
  background: ['#f3f3f5', '#171719'],
59
+ // Diff rows: the muted green/red at 25% in light and 20% in dark keep
60
+ // every token at or above 4.5:1 on the tint; the markers are the tinted
61
+ // text tokens (8.1:1 light, 8.8:1 dark on their tints).
62
+ added: ['#d0e9ce40', '#b4cdb233'],
63
+ removed: ['#f9dcd740', '#dcc0bc33'],
64
+ 'added-marker': ['#374c36', '#d0e9ce'],
65
+ 'removed-marker': ['#58413e', '#f9dcd7'],
59
66
  },
60
67
  });
61
68
 
69
+ /**
70
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
71
+ * reuse it for their `secondary` trigger so every secondary control in this
72
+ * theme matches (AST-079 FR2).
73
+ */
74
+ const SECONDARY_BUTTON = {
75
+ backgroundColor: 'transparent',
76
+ borderWidth: '1.5px',
77
+ borderStyle: 'solid',
78
+ borderColor: 'var(--color-border-emphasized)',
79
+ ':hover': {
80
+ backgroundColor: 'var(--color-neutral)',
81
+ },
82
+ } as const;
83
+
84
+ /**
85
+ * The secondary Button treatment on Selector and MultiSelector triggers
86
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
87
+ * group's edges instead (FR6). The hover stays off disabled and read-only
88
+ * triggers, which carry `data-disabled` and `data-readonly`.
89
+ */
90
+ const SECONDARY_SELECTOR = {
91
+ ':not(.astryx-input-group *)': {
92
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
93
+ borderWidth: SECONDARY_BUTTON.borderWidth,
94
+ borderStyle: SECONDARY_BUTTON.borderStyle,
95
+ borderColor: SECONDARY_BUTTON.borderColor,
96
+ },
97
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
98
+ SECONDARY_BUTTON[':hover'],
99
+ } as const;
100
+
101
+ /**
102
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
103
+ * the hover kept off a disabled trigger, whose inner button is disabled.
104
+ */
105
+ const SECONDARY_COMPLEX_SELECTOR = {
106
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
107
+ borderWidth: SECONDARY_BUTTON.borderWidth,
108
+ borderStyle: SECONDARY_BUTTON.borderStyle,
109
+ borderColor: SECONDARY_BUTTON.borderColor,
110
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
111
+ } as const;
112
+
62
113
  export const stoneTheme = defineTheme({
63
114
  name: 'stone',
64
115
 
@@ -262,15 +313,7 @@ export const stoneTheme = defineTheme({
262
313
  base: {
263
314
  borderRadius: 'var(--radius-full)',
264
315
  },
265
- 'variant:secondary': {
266
- backgroundColor: 'transparent',
267
- borderWidth: '1.5px',
268
- borderStyle: 'solid',
269
- borderColor: 'var(--color-border-emphasized)',
270
- ':hover': {
271
- backgroundColor: 'var(--color-neutral)',
272
- },
273
- },
316
+ 'variant:secondary': SECONDARY_BUTTON,
274
317
  'variant:destructive': {
275
318
  backgroundColor: 'var(--color-background-red)',
276
319
  color: 'var(--color-text-red)',
@@ -389,8 +432,12 @@ export const stoneTheme = defineTheme({
389
432
  'number-input': INPUT_STATUS_VARS,
390
433
  'date-input': INPUT_STATUS_VARS,
391
434
  'time-input': INPUT_STATUS_VARS,
392
- selector: INPUT_STATUS_VARS,
393
- 'multi-selector': INPUT_STATUS_VARS,
435
+ selector: {...INPUT_STATUS_VARS, 'variant:secondary': SECONDARY_SELECTOR},
436
+ 'multi-selector': {
437
+ ...INPUT_STATUS_VARS,
438
+ 'variant:secondary': SECONDARY_SELECTOR,
439
+ },
440
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
394
441
  typeahead: INPUT_STATUS_VARS,
395
442
  tokenizer: INPUT_STATUS_VARS,
396
443
 
@@ -29,9 +29,64 @@ const y2kSyntax = defineSyntaxTheme({
29
29
  property: ['#3c6755', '#87b5a1'],
30
30
  punctuation: ['#5e5e5e', '#ababab'],
31
31
  background: ['#FFF6ED', '#190f00'],
32
+ // Diff rows: the muted green/red at 25% in light and 20% in dark keep
33
+ // every token at or above 4.5:1 on the tint. Markers: the tinted text
34
+ // tokens in light (7.3:1 / 7.9:1); in dark those tokens are near-black,
35
+ // so the string and tag colours mark the rows (5.1:1 each).
36
+ added: ['#C5E17A40', '#C5E17A33'],
37
+ removed: ['#FFC5C340', '#FFC5C333'],
38
+ 'added-marker': ['#3a5500', '#a5af8b'],
39
+ 'removed-marker': ['#8b1d24', '#d19f9d'],
32
40
  },
33
41
  });
34
42
 
43
+ /**
44
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
45
+ * reuse it for their `secondary` trigger so every secondary control in this
46
+ * theme matches (AST-079 FR2).
47
+ */
48
+ const SECONDARY_BUTTON = {
49
+ backgroundColor: 'var(--color-background-green)',
50
+ borderWidth: '1px',
51
+ borderStyle: 'solid',
52
+ borderColor: 'var(--color-text-green)',
53
+ color: 'var(--color-text-green)',
54
+ ':hover': {
55
+ backgroundColor: 'var(--color-border-green)',
56
+ },
57
+ } as const;
58
+
59
+ /**
60
+ * The secondary Button treatment on Selector and MultiSelector triggers
61
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
62
+ * group's edges instead (FR6). The hover stays off disabled and read-only
63
+ * triggers, which carry `data-disabled` and `data-readonly`.
64
+ */
65
+ const SECONDARY_SELECTOR = {
66
+ ':not(.astryx-input-group *)': {
67
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
68
+ borderWidth: SECONDARY_BUTTON.borderWidth,
69
+ borderStyle: SECONDARY_BUTTON.borderStyle,
70
+ borderColor: SECONDARY_BUTTON.borderColor,
71
+ color: SECONDARY_BUTTON.color,
72
+ },
73
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
74
+ SECONDARY_BUTTON[':hover'],
75
+ } as const;
76
+
77
+ /**
78
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
79
+ * the hover kept off a disabled trigger, whose inner button is disabled.
80
+ */
81
+ const SECONDARY_COMPLEX_SELECTOR = {
82
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
83
+ borderWidth: SECONDARY_BUTTON.borderWidth,
84
+ borderStyle: SECONDARY_BUTTON.borderStyle,
85
+ borderColor: SECONDARY_BUTTON.borderColor,
86
+ color: SECONDARY_BUTTON.color,
87
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
88
+ } as const;
89
+
35
90
  export const y2kTheme = defineTheme({
36
91
  name: 'y2k',
37
92
 
@@ -256,16 +311,7 @@ export const y2kTheme = defineTheme({
256
311
  color: 'var(--color-background-body)',
257
312
  borderColor: 'transparent',
258
313
  },
259
- 'variant:secondary': {
260
- backgroundColor: 'var(--color-background-green)',
261
- borderWidth: '1px',
262
- borderStyle: 'solid',
263
- borderColor: 'var(--color-text-green)',
264
- color: 'var(--color-text-green)',
265
- ':hover': {
266
- backgroundColor: 'var(--color-border-green)',
267
- },
268
- },
314
+ 'variant:secondary': SECONDARY_BUTTON,
269
315
  'variant:ghost': {
270
316
  borderColor: 'transparent',
271
317
  },
@@ -277,6 +323,10 @@ export const y2kTheme = defineTheme({
277
323
  borderColor: 'var(--color-text-red)',
278
324
  },
279
325
  },
326
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
327
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
328
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
329
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
280
330
 
281
331
  badge: {
282
332
  base: {
@@ -112,9 +112,11 @@ function resolveCliBin() {
112
112
  * @param {{out?: string, iconsSpecifier?: string, detail?: string}} options -
113
113
  * Parsed command options that affect generated output, plus the detail
114
114
  * level the user chose.
115
+ * @param {(child: import('node:child_process').ChildProcess) => void} [onSpawn] -
116
+ * Receives the child, so a watcher that stops can stop it too.
115
117
  * @returns {Promise<number>}
116
118
  */
117
- function runThemeBuildOnceChild(file, options) {
119
+ function runThemeBuildOnceChild(file, options, onSpawn) {
118
120
  const cliBin = resolveCliBin();
119
121
  // A detail level the user chose applies to every rebuild.
120
122
  const args = options.detail
@@ -128,6 +130,7 @@ function runThemeBuildOnceChild(file, options) {
128
130
  stdio: 'inherit',
129
131
  env: process.env,
130
132
  });
133
+ onSpawn?.(child);
131
134
  child.on('close', code => resolve(code ?? 0));
132
135
  child.on('error', () => resolve(1));
133
136
  });
@@ -139,7 +142,9 @@ function runThemeBuildOnceChild(file, options) {
139
142
  * Rebuilds are serialized: one at a time, in the order the changes arrived, so
140
143
  * the log stays readable. Each rebuild runs in a child process so a build error
141
144
  * (which the single-build path reports via a hard exit) is contained and the
142
- * watcher keeps running.
145
+ * watcher keeps running. Stopping ends the watch at once: queued changes are
146
+ * dropped, the signal reaches a rebuild in progress, as Ctrl-C in a terminal
147
+ * reaches the whole process group, and "Stopped watching." is the last line.
143
148
  *
144
149
  * @param {Array<{file: string, filePath: string}>} entries - The theme file
145
150
  * arguments as the user passed them, with their resolved absolute paths.
@@ -159,6 +164,11 @@ async function runThemeBuildWatch(entries, options) {
159
164
  }
160
165
 
161
166
  let building = false;
167
+ let stopped = false;
168
+ /** @type {import('node:child_process').ChildProcess | null} */
169
+ let rebuildChild = null;
170
+ /** @type {Promise<void> | null} */
171
+ let rebuildDone = null;
162
172
  /** @type {Set<{file: string, filePath: string}>} */
163
173
  const queued = new Set();
164
174
  /** @type {Map<string, ReturnType<typeof setTimeout>>} */
@@ -166,6 +176,7 @@ async function runThemeBuildWatch(entries, options) {
166
176
 
167
177
  /** @param {{file: string, filePath: string}} entry */
168
178
  const rebuild = async entry => {
179
+ if (stopped) return;
169
180
  if (building) {
170
181
  // Coalesce changes that land mid-build into a single follow-up run.
171
182
  queued.add(entry);
@@ -173,8 +184,16 @@ async function runThemeBuildWatch(entries, options) {
173
184
  }
174
185
  building = true;
175
186
  emit(text(`\nChange detected — rebuilding ${rel(entry.filePath)}...`));
176
- await runThemeBuildOnceChild(entry.file, options);
187
+ const done = runThemeBuildOnceChild(entry.file, options, child => {
188
+ rebuildChild = child;
189
+ });
190
+ rebuildDone = done.then(() => {});
191
+ await done;
192
+ rebuildChild = null;
193
+ rebuildDone = null;
177
194
  building = false;
195
+ // A stop during this build has already ended the watch.
196
+ if (stopped) return;
178
197
  emit(text(watchingLine));
179
198
  const next = queued.values().next();
180
199
  if (!next.done) {
@@ -205,9 +224,18 @@ async function runThemeBuildWatch(entries, options) {
205
224
  emit(text(watchingLine));
206
225
 
207
226
  await new Promise((/** @type {(value?: void) => void} */ resolve) => {
208
- const stop = () => {
227
+ /** @param {NodeJS.Signals} signal */
228
+ const stop = async signal => {
229
+ process.removeListener('SIGINT', stop);
230
+ process.removeListener('SIGTERM', stop);
231
+ stopped = true;
232
+ queued.clear();
209
233
  for (const d of debounces.values()) clearTimeout(d);
210
234
  for (const w of watchers) w.close();
235
+ // A rebuild in progress would otherwise keep the process alive after
236
+ // "Stopped watching.". In a terminal, Ctrl-C already reached it.
237
+ rebuildChild?.kill(signal);
238
+ await rebuildDone;
211
239
  emit(text('\nStopped watching.'));
212
240
  resolve();
213
241
  };
@@ -124,7 +124,8 @@ describe('theme build --watch', () => {
124
124
  const rebuilt = await waitFor(
125
125
  () => {
126
126
  try {
127
- if (fs.readFileSync(cssFile, 'utf-8').includes('#010203')) return true;
127
+ if (fs.readFileSync(cssFile, 'utf-8').includes('#010203'))
128
+ return true;
128
129
  } catch {
129
130
  // CSS mid-write; fall through to re-touch.
130
131
  }
@@ -157,6 +158,63 @@ describe('theme build --watch', () => {
157
158
  expect(stdout).toMatch(/Stopped watching/);
158
159
  }, 30_000);
159
160
 
161
+ it('stops at once when interrupted mid-rebuild, and drops a queued change', async () => {
162
+ const themeFile = path.join(tmpDir, 'ws.mjs');
163
+ fs.writeFileSync(
164
+ themeFile,
165
+ `export default { name: 'ws', tokens: { '--color-bg': '#ffffff' } };\n`,
166
+ );
167
+ // Top-level await holds every rebuild of this version in progress for 20 s,
168
+ // far longer than a stop may take.
169
+ const slow =
170
+ `await new Promise(resolve => setTimeout(resolve, 20000));\n` +
171
+ `export default { name: 'ws', tokens: { '--color-bg': '#010203' } };\n`;
172
+
173
+ const child = spawn(
174
+ process.execPath,
175
+ [CLI_BIN, 'theme', 'build', 'ws.mjs', '--watch'],
176
+ {cwd: tmpDir, env: {...process.env, FORCE_COLOR: '0'}},
177
+ );
178
+ let stdout = '';
179
+ child.stdout.on('data', d => (stdout += d.toString()));
180
+ child.stderr.on('data', d => (stdout += d.toString()));
181
+ const exited = new Promise(resolve =>
182
+ child.once('exit', () => resolve(Date.now())),
183
+ );
184
+
185
+ let stoppedAt;
186
+ try {
187
+ expect(await waitFor(() => /Watching/i.test(stdout))).toBe(true);
188
+ // Start the slow rebuild, re-touching in case a watch event is dropped.
189
+ const started = await waitFor(
190
+ () => {
191
+ if (/rebuilding ws\.mjs/.test(stdout)) return true;
192
+ fs.writeFileSync(themeFile, slow);
193
+ return false;
194
+ },
195
+ {timeout: 20000, interval: 200},
196
+ );
197
+ expect(started).toBe(true);
198
+ // Queue a change behind the rebuild in progress (debounce is 100 ms).
199
+ fs.writeFileSync(themeFile, `${slow}// queued\n`);
200
+ await new Promise(resolve => setTimeout(resolve, 500));
201
+ } finally {
202
+ stoppedAt = Date.now();
203
+ child.kill('SIGINT');
204
+ }
205
+
206
+ const exitedAt = await Promise.race([
207
+ exited,
208
+ new Promise(resolve => setTimeout(() => resolve(null), 15000)),
209
+ ]);
210
+ if (exitedAt === null) child.kill('SIGKILL');
211
+ // Finishing the interrupted rebuild, or starting the queued one, takes 20 s.
212
+ expect(exitedAt).not.toBeNull();
213
+ expect(exitedAt - stoppedAt).toBeLessThan(10000);
214
+ expect(stdout.match(/rebuilding/g)).toHaveLength(1);
215
+ expect(stdout.trimEnd().endsWith('Stopped watching.')).toBe(true);
216
+ }, 60_000);
217
+
160
218
  it.each([
161
219
  [[], false],
162
220
  [['--detail', 'full'], true],
@@ -219,7 +277,10 @@ describe('theme build --watch', () => {
219
277
  );
220
278
  expect(built).toBe(true);
221
279
  await waitFor(() => /Watching w1\.mjs, w2\.mjs/.test(stdout));
222
- const firstCssBefore = fs.readFileSync(path.join(tmpDir, 'w1.css'), 'utf-8');
280
+ const firstCssBefore = fs.readFileSync(
281
+ path.join(tmpDir, 'w1.css'),
282
+ 'utf-8',
283
+ );
223
284
 
224
285
  const changed = `export default { name: 'w2', tokens: { '--color-bg': '#010203' } };\n`;
225
286
  fs.writeFileSync(second, changed);
@@ -6,6 +6,7 @@
6
6
 
7
7
  import * as fs from 'node:fs';
8
8
  import * as path from 'node:path';
9
+ import {listDir, listDirEntries, pathExists} from '../fs/listing-cache.mjs';
9
10
  import {existsCaseExact} from '../fs/paths.mjs';
10
11
  import {CORE_PROVIDER_ID} from '../identity/providers.mjs';
11
12
  import {loadComponentDoc} from './component-loader.mjs';
@@ -52,8 +53,8 @@ function isComponentSourceFile(fileName, dirPath) {
52
53
  if (BARE_COMPONENT_FILE_RE.test(fileName)) {
53
54
  const base = fileName.replace(/\.tsx$/, '');
54
55
  return (
55
- fs.existsSync(path.join(dirPath, `${base}.doc.mjs`)) ||
56
- fs.existsSync(path.join(dirPath, `XDS${base}.doc.mjs`))
56
+ pathExists(path.join(dirPath, `${base}.doc.mjs`)) ||
57
+ pathExists(path.join(dirPath, `XDS${base}.doc.mjs`))
57
58
  );
58
59
  }
59
60
  return false;
@@ -132,8 +133,8 @@ export function discoverComponents(coreDir) {
132
133
  function collectXDSFiles(dirPath) {
133
134
  /** @type {string[]} */
134
135
  const results = [];
135
- if (!fs.existsSync(dirPath)) return results;
136
- const entries = fs.readdirSync(dirPath, {withFileTypes: true});
136
+ if (!pathExists(dirPath)) return results;
137
+ const entries = listDirEntries(dirPath);
137
138
  for (const entry of entries) {
138
139
  if (entry.isDirectory()) {
139
140
  results.push(...collectXDSFiles(path.join(dirPath, entry.name)));
@@ -144,7 +145,7 @@ export function discoverComponents(coreDir) {
144
145
  return results;
145
146
  }
146
147
 
147
- const topEntries = fs.readdirSync(srcDir, {withFileTypes: true});
148
+ const topEntries = listDirEntries(srcDir);
148
149
  for (const entry of topEntries) {
149
150
  if (!entry.isDirectory() || SKIP_DIRS.has(entry.name)) continue;
150
151
 
@@ -154,10 +155,10 @@ export function discoverComponents(coreDir) {
154
155
  // Read the group from the directory's .doc.mjs file (if it exists)
155
156
  // Check both {Name}.doc.mjs and Astryx{Name}.doc.mjs naming conventions
156
157
  let docFile = path.join(dirPath, `${entry.name}.doc.mjs`);
157
- if (!fs.existsSync(docFile)) {
158
+ if (!pathExists(docFile)) {
158
159
  docFile = path.join(dirPath, `XDS${entry.name}.doc.mjs`);
159
160
  }
160
- const {group, hiddenComponents, hidden} = fs.existsSync(docFile)
161
+ const {group, hiddenComponents, hidden} = pathExists(docFile)
161
162
  ? readDocMeta(docFile)
162
163
  : {group: null, hiddenComponents: new Set(), hidden: false};
163
164
 
@@ -171,10 +172,10 @@ export function discoverComponents(coreDir) {
171
172
  // Check for a per-component doc file that overrides the directory group
172
173
  let compGroup = group;
173
174
  let compDoc = path.join(dirPath, `${componentName}.doc.mjs`);
174
- if (!fs.existsSync(compDoc)) {
175
+ if (!pathExists(compDoc)) {
175
176
  compDoc = path.join(dirPath, `XDS${componentName}.doc.mjs`);
176
177
  }
177
- const hasComponentDoc = fs.existsSync(compDoc);
178
+ const hasComponentDoc = pathExists(compDoc);
178
179
  if (hasComponentDoc) {
179
180
  const compMeta = readDocMeta(compDoc);
180
181
  if (compMeta.group) compGroup = compMeta.group;
@@ -183,7 +184,7 @@ export function discoverComponents(coreDir) {
183
184
  // Skip components without any .doc.mjs file (directory-level or
184
185
  // component-level). They can't be documented, so surfacing them in
185
186
  // the component list leads to broken docs-site links.
186
- if (!fs.existsSync(docFile) && !hasComponentDoc) continue;
187
+ if (!pathExists(docFile) && !hasComponentDoc) continue;
187
188
 
188
189
  if (!componentGroups.has(componentName)) {
189
190
  componentGroups.set(componentName, compGroup);
@@ -251,7 +252,7 @@ export function findComponentReadme(coreDir, name) {
251
252
  if (existsCaseExact(directXds, srcDir)) return directXds;
252
253
 
253
254
  // Nested match: src/*/{name}/{Name}.doc.mjs or src/*/{name}/Astryx{Name}.doc.mjs
254
- const entries = fs.readdirSync(srcDir, {withFileTypes: true});
255
+ const entries = listDirEntries(srcDir);
255
256
  for (const entry of entries) {
256
257
  if (!entry.isDirectory()) continue;
257
258
  const nested = path.join(srcDir, entry.name, name, exactDoc);
@@ -275,7 +276,7 @@ export function findComponentReadme(coreDir, name) {
275
276
  if (sourcePath) {
276
277
  let dir = path.dirname(sourcePath);
277
278
  while (dir.startsWith(srcDir)) {
278
- const dirEntries = fs.readdirSync(dir);
279
+ const dirEntries = listDir(dir);
279
280
  for (const f of dirEntries) {
280
281
  if (f.endsWith('.doc.mjs')) return path.join(dir, f);
281
282
  }
@@ -318,8 +319,8 @@ export function findComponentSource(coreDir, name) {
318
319
  * @returns {string | null}
319
320
  */
320
321
  function searchDir(dirPath) {
321
- if (!fs.existsSync(dirPath)) return null;
322
- const entries = fs.readdirSync(dirPath, {withFileTypes: true});
322
+ if (!pathExists(dirPath)) return null;
323
+ const entries = listDirEntries(dirPath);
323
324
 
324
325
  // Check for an exact match (prefixed or bare) first
325
326
  for (const candidate of candidateFiles) {
@@ -345,7 +346,7 @@ export function findComponentSource(coreDir, name) {
345
346
  }
346
347
 
347
348
  // Search nested (component might be under a parent dir)
348
- const entries = fs.readdirSync(srcDir, {withFileTypes: true});
349
+ const entries = listDirEntries(srcDir);
349
350
  for (const entry of entries) {
350
351
  if (!entry.isDirectory()) continue;
351
352
  const nestedDir = path.join(srcDir, entry.name, name);
@@ -369,7 +370,7 @@ export function findComponentSource(coreDir, name) {
369
370
  export function resolveImportPath(coreDir, componentName) {
370
371
  const srcDir = path.join(coreDir, 'src');
371
372
  const pkgPath = path.join(coreDir, 'package.json');
372
- const pkg = fs.existsSync(pkgPath)
373
+ const pkg = pathExists(pkgPath)
373
374
  ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
374
375
  : null;
375
376
 
@@ -522,14 +523,14 @@ function readPackageExports(packageDir) {
522
523
  * @returns {Record<string, string[]>}
523
524
  */
524
525
  export function discoverExternalComponentsGrouped(docsDir) {
525
- if (!fs.existsSync(docsDir)) return {};
526
+ if (!pathExists(docsDir)) return {};
526
527
 
527
528
  /** @type {Map<string, string|null>} componentName → group */
528
529
  const componentGroups = new Map();
529
530
 
530
531
  /** @param {string} dirPath */
531
532
  function scanDir(dirPath) {
532
- const entries = fs.readdirSync(dirPath, {withFileTypes: true});
533
+ const entries = listDirEntries(dirPath);
533
534
  for (const entry of entries) {
534
535
  if (entry.name === 'node_modules' || entry.name === '__tests__') continue;
535
536
  const fullPath = path.join(dirPath, entry.name);
@@ -593,7 +594,7 @@ export function discoverExternalComponentsGrouped(docsDir) {
593
594
  * @returns {string | null}
594
595
  */
595
596
  export function findExternalComponentDoc(docsDir, name) {
596
- if (!fs.existsSync(docsDir)) return null;
597
+ if (!pathExists(docsDir)) return null;
597
598
  const target = `${name}.doc.mjs`;
598
599
 
599
600
  /**
@@ -601,7 +602,7 @@ export function findExternalComponentDoc(docsDir, name) {
601
602
  * @returns {string | null}
602
603
  */
603
604
  function scanDir(dirPath) {
604
- const entries = fs.readdirSync(dirPath, {withFileTypes: true});
605
+ const entries = listDirEntries(dirPath);
605
606
  for (const entry of entries) {
606
607
  if (entry.name === 'node_modules' || entry.name === '__tests__') continue;
607
608
  const fullPath = path.join(dirPath, entry.name);
@@ -642,7 +643,7 @@ function integrationSourceForDoc(docPath) {
642
643
  const dir = path.dirname(docPath);
643
644
  const base = path.basename(docPath).replace(/\.doc\.(ts|mjs|js)$/, '');
644
645
  const candidate = path.join(dir, `${base}.tsx`);
645
- return fs.existsSync(candidate) ? candidate : null;
646
+ return pathExists(candidate) ? candidate : null;
646
647
  }
647
648
 
648
649
  /**
@@ -656,14 +657,14 @@ function integrationSourceForDoc(docPath) {
656
657
  */
657
658
  export function discoverIntegrationComponents(integration) {
658
659
  const componentsDir = integration?.components;
659
- if (!componentsDir || !fs.existsSync(componentsDir)) return [];
660
+ if (!componentsDir || !pathExists(componentsDir)) return [];
660
661
 
661
662
  /** @type {Map<string, {name: string, package: string, docPath: string, sourcePath: string|null, issuesUrl: string|undefined, group: string|null}>} */
662
663
  const byName = new Map();
663
664
 
664
665
  /** @param {string} dirPath */
665
666
  function scanDir(dirPath) {
666
- const entries = fs.readdirSync(dirPath, {withFileTypes: true});
667
+ const entries = listDirEntries(dirPath);
667
668
  for (const entry of entries) {
668
669
  if (entry.name === 'node_modules' || entry.name === '__tests__') continue;
669
670
  const fullPath = path.join(dirPath, entry.name);
@@ -757,18 +758,18 @@ export async function discoverValidIntegrationComponents(integration) {
757
758
  */
758
759
  export function findIntegrationComponentDoc(integration, name) {
759
760
  const componentsDir = integration?.components;
760
- if (!componentsDir || !fs.existsSync(componentsDir)) return null;
761
+ if (!componentsDir || !pathExists(componentsDir)) return null;
761
762
 
762
763
  /**
763
764
  * @param {string} dirPath
764
765
  * @returns {string | null}
765
766
  */
766
767
  function scanDir(dirPath) {
767
- const entries = fs.readdirSync(dirPath, {withFileTypes: true});
768
+ const entries = listDirEntries(dirPath);
768
769
  // Exact same-stem match (precedence order) first in this dir.
769
770
  for (const suffix of INTEGRATION_DOC_SUFFIXES) {
770
771
  const candidate = path.join(dirPath, `${name}${suffix}`);
771
- if (fs.existsSync(candidate)) return candidate;
772
+ if (pathExists(candidate)) return candidate;
772
773
  }
773
774
  for (const entry of entries) {
774
775
  if (entry.name === 'node_modules' || entry.name === '__tests__') continue;