@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72
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.
- package/README.md +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/component/component-replacement.test.mjs +12 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +164 -13
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +11 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +154 -43
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +115 -1
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/init/run/run.mjs +1 -0
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +44 -0
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +191 -29
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +19 -14
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.dense.mjs +3 -3
- package/assets/docs/principles.doc.mjs +4 -4
- package/assets/docs/principles.doc.zh.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout.doc.mjs +23 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/responsive.doc.mjs +0 -4
- package/assets/docs/tree/scaffold.doc.mjs +0 -5
- package/assets/docs/tree/side-panels.doc.mjs +0 -1
- package/assets/docs/tree/structure.doc.mjs +0 -4
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/use-a-theme.doc.mjs +162 -47
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/component/index.mjs +4 -1
- package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.test.mjs +16 -13
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +50 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/search.test.mjs +6 -2
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +4 -3
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +13 -3
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +18 -2
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
package/api/doctor/doctor.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import * as fs from 'node:fs';
|
|
|
24
24
|
import * as path from 'node:path';
|
|
25
25
|
|
|
26
26
|
import {MIN_NODE_VERSION, isNodeVersionSupported} from '../../foundation/env/node-version.mjs';
|
|
27
|
+
import {AGENT_DOC_PATHS} from '../../foundation/agent-docs/agent-doc-state.mjs';
|
|
27
28
|
import {CLI_ROOT, findCoreDir, findInstalledPackage} from '../../foundation/fs/paths.mjs';
|
|
28
29
|
import {explainPackageManager, getCliInvocation} from '../../foundation/env/package-manager.mjs';
|
|
29
30
|
import {
|
|
@@ -50,7 +51,7 @@ import {
|
|
|
50
51
|
import {typedEdges} from '../docs/node/node.mjs';
|
|
51
52
|
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
52
53
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
53
|
-
import {checkAppThemes} from './theme-checks.mjs';
|
|
54
|
+
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* @typedef {'pass'|'warn'|'fail'|'info'} DoctorStatus
|
|
@@ -85,6 +86,9 @@ import {checkAppThemes} from './theme-checks.mjs';
|
|
|
85
86
|
* Combined project-level integration issues, including cross-package template replacement warnings.
|
|
86
87
|
* @property {Error|null} [configError] - Error thrown while resolving the config
|
|
87
88
|
* path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
|
|
89
|
+
* @property {string|null} [projectError] - Why the CLI could not load the
|
|
90
|
+
* project from its config, when it could not. Checks that need the loaded
|
|
91
|
+
* project quote it when they skip, so a skip says what was found.
|
|
88
92
|
*/
|
|
89
93
|
|
|
90
94
|
/* ── helpers ──────────────────────────────────────────────────────────── */
|
|
@@ -113,6 +117,64 @@ function pkgVersion(dir) {
|
|
|
113
117
|
return pkg?.version ?? null;
|
|
114
118
|
}
|
|
115
119
|
|
|
120
|
+
/**
|
|
121
|
+
* The first line of an error message, bounded for a one-line check message.
|
|
122
|
+
* @param {string} message
|
|
123
|
+
* @returns {string}
|
|
124
|
+
*/
|
|
125
|
+
function firstLine(message) {
|
|
126
|
+
return String(message).split('\n')[0].slice(0, 300);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The message of a check that needs the loaded project and could not have it.
|
|
131
|
+
* It carries the reason the CLI gave, so the line says what Doctor found
|
|
132
|
+
* instead of only that it did not look.
|
|
133
|
+
* @param {DoctorContext} ctx
|
|
134
|
+
* @param {string} what
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
function skippedBecause(ctx, what) {
|
|
138
|
+
return ctx.projectError
|
|
139
|
+
? `Skipped — ${what}: ${firstLine(ctx.projectError)}`
|
|
140
|
+
: `Skipped — ${what}.`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Integrations one message names before it counts the rest. */
|
|
144
|
+
const NAMED_INTEGRATIONS = 10;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @param {Array<{name?: string, __spec?: string}>} integrations
|
|
148
|
+
* @returns {string}
|
|
149
|
+
*/
|
|
150
|
+
function nameIntegrations(integrations) {
|
|
151
|
+
const names = integrations.map(
|
|
152
|
+
integration => integration.name ?? integration.__spec ?? '(integration)',
|
|
153
|
+
);
|
|
154
|
+
return names.length <= NAMED_INTEGRATIONS
|
|
155
|
+
? names.join(', ')
|
|
156
|
+
: `${names.slice(0, NAMED_INTEGRATIONS).join(', ')} and ${names.length - NAMED_INTEGRATIONS} more`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The project's root: the folder of its config, else of the nearest
|
|
161
|
+
* package.json above the working directory (where the config is looked for),
|
|
162
|
+
* else the working directory.
|
|
163
|
+
* @param {DoctorContext} ctx
|
|
164
|
+
* @returns {string}
|
|
165
|
+
*/
|
|
166
|
+
function projectRootOf(ctx) {
|
|
167
|
+
if (ctx.configPath) return path.dirname(ctx.configPath);
|
|
168
|
+
let dir = ctx.cwd;
|
|
169
|
+
for (let i = 0; i < 50; i++) {
|
|
170
|
+
if (fs.existsSync(path.join(dir, 'package.json'))) return dir;
|
|
171
|
+
const parent = path.dirname(dir);
|
|
172
|
+
if (parent === dir) break;
|
|
173
|
+
dir = parent;
|
|
174
|
+
}
|
|
175
|
+
return ctx.cwd;
|
|
176
|
+
}
|
|
177
|
+
|
|
116
178
|
/* ── individual checks ────────────────────────────────────────────────── */
|
|
117
179
|
|
|
118
180
|
/**
|
|
@@ -255,6 +317,18 @@ export async function checkConfig(ctx) {
|
|
|
255
317
|
fix: 'Export a default object from astryx.config.mjs, e.g. `export default { integrations: [] };`.',
|
|
256
318
|
};
|
|
257
319
|
}
|
|
320
|
+
// Importing is not the whole test: the CLI also validates the config, and
|
|
321
|
+
// a config it rejects leaves every project-aware command without the
|
|
322
|
+
// project. That config is not clean, so this warns (exit code unchanged).
|
|
323
|
+
if (ctx.projectError) {
|
|
324
|
+
return {
|
|
325
|
+
id: 'config',
|
|
326
|
+
label: 'astryx.config.mjs',
|
|
327
|
+
status: 'warn',
|
|
328
|
+
message: `astryx.config.mjs loads, but the CLI could not load the project from it: ${firstLine(ctx.projectError)}`,
|
|
329
|
+
fix: 'Fix what the message names. `astryx docs authoring config` lists every field astryx.config accepts.',
|
|
330
|
+
};
|
|
331
|
+
}
|
|
258
332
|
return {
|
|
259
333
|
id: 'config',
|
|
260
334
|
label: 'astryx.config.mjs',
|
|
@@ -304,7 +378,7 @@ export function checkImplicitIntegrations(ctx) {
|
|
|
304
378
|
id,
|
|
305
379
|
label,
|
|
306
380
|
status: 'info',
|
|
307
|
-
message: '
|
|
381
|
+
message: skippedBecause(ctx, 'the project configuration could not be read'),
|
|
308
382
|
};
|
|
309
383
|
}
|
|
310
384
|
|
|
@@ -407,27 +481,30 @@ function describeUnreadableManifests(failures) {
|
|
|
407
481
|
* @returns {DoctorCheck}
|
|
408
482
|
*/
|
|
409
483
|
export function checkAgentDocs(ctx) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
484
|
+
// Every file init can write (one shared list), looked for in the working
|
|
485
|
+
// directory and in the project root: run from src/, the docs sit at the root.
|
|
486
|
+
const dirs = [...new Set([ctx.cwd, projectRootOf(ctx)])];
|
|
487
|
+
const present = dirs.flatMap(dir =>
|
|
488
|
+
AGENT_DOC_PATHS.map(rel => path.join(dir, rel)).filter(abs =>
|
|
489
|
+
fs.existsSync(abs),
|
|
490
|
+
),
|
|
491
|
+
);
|
|
492
|
+
/** @param {string} abs */
|
|
493
|
+
const shown = abs => path.relative(ctx.cwd, abs) || path.basename(abs);
|
|
417
494
|
|
|
418
495
|
if (present.length === 0) {
|
|
419
496
|
return {
|
|
420
497
|
id: 'agent-docs',
|
|
421
498
|
label: 'AI agent docs',
|
|
422
499
|
status: 'info',
|
|
423
|
-
message:
|
|
500
|
+
message: `No agent docs found: looked for ${AGENT_DOC_PATHS.join(', ')} in ${dirs.map(dir => path.relative(ctx.cwd, dir) || '.').join(' and ')}.`,
|
|
424
501
|
fix: `Generate agent docs with \`${getCliInvocation(ctx.cwd)} init --features agents\`.`,
|
|
425
502
|
};
|
|
426
503
|
}
|
|
427
504
|
|
|
428
|
-
const withMarkers = present.filter(
|
|
505
|
+
const withMarkers = present.filter(abs => {
|
|
429
506
|
try {
|
|
430
|
-
const content = fs.readFileSync(
|
|
507
|
+
const content = fs.readFileSync(abs, 'utf-8');
|
|
431
508
|
return (
|
|
432
509
|
(content.includes('<!-- ASTRYX:START -->') || content.includes('<!-- XDS:START -->')) &&
|
|
433
510
|
(content.includes('<!-- ASTRYX:END -->') || content.includes('<!-- XDS:END -->'))
|
|
@@ -442,7 +519,7 @@ export function checkAgentDocs(ctx) {
|
|
|
442
519
|
id: 'agent-docs',
|
|
443
520
|
label: 'AI agent docs',
|
|
444
521
|
status: 'warn',
|
|
445
|
-
message: `Agent docs present (${present.join(', ')}) but no Astryx section markers found.`,
|
|
522
|
+
message: `Agent docs present (${present.map(shown).join(', ')}) but no Astryx section markers found.`,
|
|
446
523
|
fix: `Add the Astryx section to your agent docs with \`${getCliInvocation(ctx.cwd)} init --features agents\`.`,
|
|
447
524
|
};
|
|
448
525
|
}
|
|
@@ -451,7 +528,7 @@ export function checkAgentDocs(ctx) {
|
|
|
451
528
|
id: 'agent-docs',
|
|
452
529
|
label: 'AI agent docs',
|
|
453
530
|
status: 'pass',
|
|
454
|
-
message: `Astryx agent docs section present in ${withMarkers.join(', ')}.`,
|
|
531
|
+
message: `Astryx agent docs section present in ${withMarkers.map(shown).join(', ')}.`,
|
|
455
532
|
};
|
|
456
533
|
}
|
|
457
534
|
|
|
@@ -546,15 +623,31 @@ export function checkIntegrationIssues(ctx) {
|
|
|
546
623
|
id: 'integration-issues',
|
|
547
624
|
label: 'Integration contributions',
|
|
548
625
|
status: 'info',
|
|
549
|
-
message:
|
|
626
|
+
message: skippedBecause(
|
|
627
|
+
ctx,
|
|
628
|
+
'the project integration graph could not be loaded',
|
|
629
|
+
),
|
|
550
630
|
};
|
|
551
631
|
}
|
|
552
632
|
if (issues.length === 0) {
|
|
633
|
+
// "No problems" is a finding only when something was looked at.
|
|
634
|
+
const checked = (ctx.integrations ?? []).filter(
|
|
635
|
+
integration => integration.__loadError == null,
|
|
636
|
+
);
|
|
637
|
+
if (checked.length === 0) {
|
|
638
|
+
return {
|
|
639
|
+
id: 'integration-issues',
|
|
640
|
+
label: 'Integration contributions',
|
|
641
|
+
status: 'info',
|
|
642
|
+
message:
|
|
643
|
+
'No integration is loaded, so there are no integration contributions to check.',
|
|
644
|
+
};
|
|
645
|
+
}
|
|
553
646
|
return {
|
|
554
647
|
id: 'integration-issues',
|
|
555
648
|
label: 'Integration contributions',
|
|
556
649
|
status: 'pass',
|
|
557
|
-
message: '
|
|
650
|
+
message: `${checked.length} loaded integration${checked.length === 1 ? '' : 's'} checked (${nameIntegrations(checked)}): contributions and cross-package relationships are valid.`,
|
|
558
651
|
};
|
|
559
652
|
}
|
|
560
653
|
const errors = issues.filter(issue => issue.severity === 'error').length;
|
|
@@ -651,7 +744,7 @@ export function checkProviderIdentity(ctx) {
|
|
|
651
744
|
id,
|
|
652
745
|
label,
|
|
653
746
|
status: 'info',
|
|
654
|
-
message: '
|
|
747
|
+
message: skippedBecause(ctx, 'the project configuration could not be read'),
|
|
655
748
|
};
|
|
656
749
|
}
|
|
657
750
|
|
|
@@ -1151,33 +1244,48 @@ export async function runChecks(options = {}) {
|
|
|
1151
1244
|
let integrationIssues = null;
|
|
1152
1245
|
/** @type {Array<{spec: string, error: string}>|null} */
|
|
1153
1246
|
let autolinkFailures = null;
|
|
1247
|
+
/** @type {string|null} */
|
|
1248
|
+
let projectError = null;
|
|
1249
|
+
/** @type {import('../../foundation/config/project.mjs').Project | null} */
|
|
1250
|
+
let project = null;
|
|
1154
1251
|
try {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
//
|
|
1158
|
-
//
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
entry.candidate.source === 'autolinked',
|
|
1164
|
-
)
|
|
1165
|
-
.map(entry => ({
|
|
1166
|
-
spec: entry.candidate.spec ?? entry.label,
|
|
1167
|
-
error: entry.error ?? 'its manifest could not be loaded',
|
|
1168
|
-
}));
|
|
1252
|
+
project = await Project.load(cwd);
|
|
1253
|
+
} catch (err) {
|
|
1254
|
+
// A project the CLI cannot load leaves the checks that need it
|
|
1255
|
+
// skipped. The reason is kept: those checks and the config
|
|
1256
|
+
// check quote it, so a skip is never silent.
|
|
1257
|
+
projectError = err instanceof Error ? err.message : String(err);
|
|
1258
|
+
}
|
|
1259
|
+
if (project) {
|
|
1169
1260
|
try {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
)
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1261
|
+
integrations = project.loadedIntegrations;
|
|
1262
|
+
// An installed dependency whose manifest cannot be loaded is kept out of
|
|
1263
|
+
// loadedIntegrations on purpose. The provider ledger still records it.
|
|
1264
|
+
autolinkFailures = [...providerLedgerOf(project).values()]
|
|
1265
|
+
.filter(
|
|
1266
|
+
entry =>
|
|
1267
|
+
entry.outcome === 'load-failed' &&
|
|
1268
|
+
entry.candidate.source === 'autolinked',
|
|
1269
|
+
)
|
|
1270
|
+
.map(entry => ({
|
|
1271
|
+
spec: entry.candidate.spec ?? entry.label,
|
|
1272
|
+
error: entry.error ?? 'its manifest could not be loaded',
|
|
1273
|
+
}));
|
|
1274
|
+
try {
|
|
1275
|
+
docsCatalog = await project.docs();
|
|
1276
|
+
docsCatalogIssues = (await project.issues()).filter(
|
|
1277
|
+
issue => issue.code === 'invalid_doc',
|
|
1278
|
+
);
|
|
1279
|
+
} catch (err) {
|
|
1280
|
+
docsCatalog = null;
|
|
1281
|
+
docsCatalogError = err instanceof Error ? err.message : String(err);
|
|
1282
|
+
}
|
|
1283
|
+
integrationIssues = await project.issues();
|
|
1284
|
+
} catch {
|
|
1285
|
+
// Best-effort: once the project has loaded, a later read that throws
|
|
1286
|
+
// leaves the remaining fields at their defaults. It is no reason to
|
|
1287
|
+
// blame the config, so it never becomes projectError.
|
|
1177
1288
|
}
|
|
1178
|
-
integrationIssues = await project.issues();
|
|
1179
|
-
} catch {
|
|
1180
|
-
// Best-effort: a missing or invalid config leaves integrations unavailable.
|
|
1181
1289
|
}
|
|
1182
1290
|
|
|
1183
1291
|
/** @type {DoctorContext} */
|
|
@@ -1193,15 +1301,18 @@ export async function runChecks(options = {}) {
|
|
|
1193
1301
|
integrationIssues,
|
|
1194
1302
|
autolinkFailures,
|
|
1195
1303
|
configError,
|
|
1304
|
+
projectError,
|
|
1196
1305
|
};
|
|
1197
1306
|
|
|
1198
1307
|
/** @type {DoctorCheck[]} */
|
|
1199
1308
|
const checks = [];
|
|
1200
|
-
// Run the
|
|
1309
|
+
// Run the theme checks and config check after the environment checks. The
|
|
1310
|
+
// released `themes` check keeps its place, ahead of the app-theme checks.
|
|
1201
1311
|
for (const fn of SYNC_CHECKS) {
|
|
1202
1312
|
checks.push(fn(ctx));
|
|
1203
1313
|
if (fn === checkVersionAlignment) {
|
|
1204
|
-
|
|
1314
|
+
const appThemeChecks = await checkAppThemes(cwd);
|
|
1315
|
+
checks.push(checkThemes(cwd, appThemeChecks), ...appThemeChecks);
|
|
1205
1316
|
checks.push(await checkConfig(ctx));
|
|
1206
1317
|
}
|
|
1207
1318
|
}
|
|
@@ -1018,3 +1018,107 @@ describe('doctor says what it could not check', () => {
|
|
|
1018
1018
|
expect(check.message).toContain('could not be read');
|
|
1019
1019
|
});
|
|
1020
1020
|
});
|
|
1021
|
+
|
|
1022
|
+
describe('doctor says why it skipped and what it checked', () => {
|
|
1023
|
+
const CORE_STUB = {
|
|
1024
|
+
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
1025
|
+
name: '@astryxdesign/core',
|
|
1026
|
+
version: '0.6.3',
|
|
1027
|
+
}),
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
/** A project under the working directory, so its config can be imported. */
|
|
1031
|
+
function cwdProject(files) {
|
|
1032
|
+
const dir = fs.mkdtempSync(
|
|
1033
|
+
path.join(process.cwd(), '.astryx-doctor-shape-'),
|
|
1034
|
+
);
|
|
1035
|
+
tmpDirs.push(dir);
|
|
1036
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
1037
|
+
const abs = path.join(dir, rel);
|
|
1038
|
+
fs.mkdirSync(path.dirname(abs), {recursive: true});
|
|
1039
|
+
fs.writeFileSync(abs, content);
|
|
1040
|
+
}
|
|
1041
|
+
return dir;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
it(
|
|
1045
|
+
'warns, and quotes the reason, when the CLI cannot load the project from a config that imports',
|
|
1046
|
+
async () => {
|
|
1047
|
+
const dir = cwdProject({
|
|
1048
|
+
'package.json': '{"name":"app"}',
|
|
1049
|
+
...CORE_STUB,
|
|
1050
|
+
'astryx.config.mjs': "export default { integrations: 'oops' };\n",
|
|
1051
|
+
});
|
|
1052
|
+
const {checks, summary} = (await doctor({cwd: dir})).data;
|
|
1053
|
+
const by = Object.fromEntries(checks.map(c => [c.id, c]));
|
|
1054
|
+
expect(by.config.status).toBe('warn');
|
|
1055
|
+
expect(by.config.message).toMatch(
|
|
1056
|
+
/^astryx\.config\.mjs loads, but the CLI could not load the project from it: .*integrations/,
|
|
1057
|
+
);
|
|
1058
|
+
expect(by.config.fix).toContain('astryx docs authoring config');
|
|
1059
|
+
for (const id of ['implicit-integrations', 'provider-identity']) {
|
|
1060
|
+
expect(by[id].message).toMatch(
|
|
1061
|
+
/^Skipped — the project configuration could not be read: .*integrations/,
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
expect(by['integration-issues'].message).toMatch(
|
|
1065
|
+
/^Skipped — the project integration graph could not be loaded: .*integrations/,
|
|
1066
|
+
);
|
|
1067
|
+
// A warning: the exit code a released CLI gave this project is unchanged.
|
|
1068
|
+
expect(summary.fail).toBe(0);
|
|
1069
|
+
},
|
|
1070
|
+
SLOW,
|
|
1071
|
+
);
|
|
1072
|
+
|
|
1073
|
+
it(
|
|
1074
|
+
'passes the config check when the CLI loads the project from it',
|
|
1075
|
+
async () => {
|
|
1076
|
+
const dir = cwdProject({
|
|
1077
|
+
'package.json': '{"name":"app"}',
|
|
1078
|
+
...CORE_STUB,
|
|
1079
|
+
'astryx.config.mjs': 'export default { integrations: [] };\n',
|
|
1080
|
+
});
|
|
1081
|
+
const by = Object.fromEntries(
|
|
1082
|
+
(await doctor({cwd: dir})).data.checks.map(c => [c.id, c]),
|
|
1083
|
+
);
|
|
1084
|
+
expect(by.config.status).toBe('pass');
|
|
1085
|
+
expect(by['implicit-integrations'].message).not.toContain('Skipped');
|
|
1086
|
+
},
|
|
1087
|
+
SLOW,
|
|
1088
|
+
);
|
|
1089
|
+
|
|
1090
|
+
it('says there is nothing to check when no integration is loaded', () => {
|
|
1091
|
+
expect(
|
|
1092
|
+
checkIntegrationIssues({integrationIssues: [], integrations: []}),
|
|
1093
|
+
).toEqual({
|
|
1094
|
+
id: 'integration-issues',
|
|
1095
|
+
label: 'Integration contributions',
|
|
1096
|
+
status: 'info',
|
|
1097
|
+
message:
|
|
1098
|
+
'No integration is loaded, so there are no integration contributions to check.',
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
it('names what it checked when every loaded integration is clean', () => {
|
|
1103
|
+
expect(
|
|
1104
|
+
checkIntegrationIssues({
|
|
1105
|
+
integrationIssues: [],
|
|
1106
|
+
integrations: [{name: '@acme/widgets'}],
|
|
1107
|
+
}),
|
|
1108
|
+
).toMatchObject({
|
|
1109
|
+
status: 'pass',
|
|
1110
|
+
message:
|
|
1111
|
+
'1 loaded integration checked (@acme/widgets): contributions and cross-package relationships are valid.',
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
it('bounds the names it lists', () => {
|
|
1116
|
+
const integrations = Array.from({length: 12}, (_, i) => ({
|
|
1117
|
+
name: `@acme/kit-${i}`,
|
|
1118
|
+
}));
|
|
1119
|
+
const c = checkIntegrationIssues({integrationIssues: [], integrations});
|
|
1120
|
+
expect(c.message).toMatch(
|
|
1121
|
+
/^12 loaded integrations checked \(.* and 2 more\): /,
|
|
1122
|
+
);
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
@@ -1,6 +1,18 @@
|
|
|
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
|
+
* The `themes` check that every released doctor report carries. Its id is
|
|
6
|
+
* stable, so it stays beside the app-theme checks. Without a generated theme
|
|
7
|
+
* module it reports what it always has: whether an `@astryxdesign/theme-*`
|
|
8
|
+
* package is installed, and whether the app's package.json names a theme in
|
|
9
|
+
* `astryx.theme`. With a generated module it reports the overall result of the
|
|
10
|
+
* app-theme checks.
|
|
11
|
+
* @param {string} cwd
|
|
12
|
+
* @param {DoctorCheck[]} appChecks - the checks {@link checkAppThemes} returned
|
|
13
|
+
* @returns {DoctorCheck}
|
|
14
|
+
*/
|
|
15
|
+
export function checkThemes(cwd: string, appChecks: DoctorCheck[]): DoctorCheck;
|
|
4
16
|
/**
|
|
5
17
|
* Run all ten app-theme checks.
|
|
6
18
|
* @param {string} cwd
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
findDoctorCoreDir,
|
|
18
18
|
findDoctorInstalledPackage,
|
|
19
19
|
isLocalThemeOwner,
|
|
20
|
+
listDoctorThemePackages,
|
|
20
21
|
listProjectSourceFiles,
|
|
21
22
|
planThemeAppWrite,
|
|
22
23
|
readPackageJson,
|
|
@@ -52,6 +53,8 @@ const CHECKS = [
|
|
|
52
53
|
['theme-global-rules', 'Cross-theme global CSS rules'],
|
|
53
54
|
];
|
|
54
55
|
|
|
56
|
+
const APP_THEME_CHECK_IDS = new Set(CHECKS.map(([id]) => id));
|
|
57
|
+
|
|
55
58
|
/**
|
|
56
59
|
* @param {string} message
|
|
57
60
|
* @param {Error|null} [moduleError]
|
|
@@ -385,6 +388,117 @@ function unmigratedCopyCheck(projectDir) {
|
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Whether the app's package.json names a theme in `astryx.theme`.
|
|
393
|
+
* @param {string} cwd
|
|
394
|
+
*/
|
|
395
|
+
function appPackageNamesTheme(cwd) {
|
|
396
|
+
let state;
|
|
397
|
+
try {
|
|
398
|
+
state = readThemeState(cwd);
|
|
399
|
+
} catch {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
const pkg = readPackageJson(state.packageFile);
|
|
403
|
+
return Boolean(pkg?.astryx?.theme);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The `themes` check that every released doctor report carries. Its id is
|
|
408
|
+
* stable, so it stays beside the app-theme checks. Without a generated theme
|
|
409
|
+
* module it reports what it always has: whether an `@astryxdesign/theme-*`
|
|
410
|
+
* package is installed, and whether the app's package.json names a theme in
|
|
411
|
+
* `astryx.theme`. With a generated module it reports the overall result of the
|
|
412
|
+
* app-theme checks.
|
|
413
|
+
* @param {string} cwd
|
|
414
|
+
* @param {DoctorCheck[]} appChecks - the checks {@link checkAppThemes} returned
|
|
415
|
+
* @returns {DoctorCheck}
|
|
416
|
+
*/
|
|
417
|
+
export function checkThemes(cwd, appChecks) {
|
|
418
|
+
const label = 'Theme packages';
|
|
419
|
+
const managed = appChecks.some(
|
|
420
|
+
check => APP_THEME_CHECK_IDS.has(check.id) && check.status !== 'info',
|
|
421
|
+
);
|
|
422
|
+
if (managed) {
|
|
423
|
+
// A check passes only on its own evidence, so the rollup passes only when
|
|
424
|
+
// every check it summarizes passed. An `info` result here means a check
|
|
425
|
+
// could not prove its evidence.
|
|
426
|
+
const needsWork = appChecks.filter(
|
|
427
|
+
check => check.status === 'fail' || check.status === 'warn',
|
|
428
|
+
);
|
|
429
|
+
const unproven = appChecks.filter(check => check.status === 'info');
|
|
430
|
+
if (needsWork.length > 0) {
|
|
431
|
+
const ids = needsWork.map(check => check.id).join(', ');
|
|
432
|
+
return {
|
|
433
|
+
id: 'themes',
|
|
434
|
+
label,
|
|
435
|
+
status: needsWork.some(check => check.status === 'fail')
|
|
436
|
+
? 'fail'
|
|
437
|
+
: 'warn',
|
|
438
|
+
message:
|
|
439
|
+
needsWork.length === 1
|
|
440
|
+
? `One theme check needs attention: ${ids}.`
|
|
441
|
+
: `${needsWork.length} theme checks need attention: ${ids}.`,
|
|
442
|
+
fix:
|
|
443
|
+
needsWork.length === 1
|
|
444
|
+
? `Follow the fix on the ${ids} check.`
|
|
445
|
+
: `Follow the fix on each of these checks: ${ids}.`,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
if (unproven.length > 0) {
|
|
449
|
+
const ids = unproven.map(check => check.id).join(', ');
|
|
450
|
+
return {
|
|
451
|
+
id: 'themes',
|
|
452
|
+
label,
|
|
453
|
+
status: 'info',
|
|
454
|
+
message:
|
|
455
|
+
unproven.length === 1
|
|
456
|
+
? `One theme check could not prove its result: ${ids}.`
|
|
457
|
+
: `${unproven.length} theme checks could not prove their results: ${ids}.`,
|
|
458
|
+
fix:
|
|
459
|
+
unproven.length === 1
|
|
460
|
+
? `See the ${ids} check.`
|
|
461
|
+
: `See each of these checks: ${ids}.`,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
id: 'themes',
|
|
466
|
+
label,
|
|
467
|
+
status: 'pass',
|
|
468
|
+
message:
|
|
469
|
+
'App themes come from the generated theme module, and every theme check passes.',
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const run = getCliInvocation(cwd);
|
|
474
|
+
const packages = listDoctorThemePackages(cwd);
|
|
475
|
+
if (packages.length === 0) {
|
|
476
|
+
return {
|
|
477
|
+
id: 'themes',
|
|
478
|
+
label,
|
|
479
|
+
status: 'warn',
|
|
480
|
+
message: 'No @astryxdesign/theme-* packages are installed.',
|
|
481
|
+
fix: `Install a theme, e.g. \`npm install @astryxdesign/theme-neutral\`, then add it to the app with \`${run} theme add neutral --import\`.`,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const names = packages.join(', ');
|
|
485
|
+
if (!appPackageNamesTheme(cwd)) {
|
|
486
|
+
return {
|
|
487
|
+
id: 'themes',
|
|
488
|
+
label,
|
|
489
|
+
status: 'warn',
|
|
490
|
+
message: `Theme package(s) installed (${names}) but no theme appears wired.`,
|
|
491
|
+
fix: `Add one to the app with \`${run} theme add <slug> --import\`.`,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
return {
|
|
495
|
+
id: 'themes',
|
|
496
|
+
label,
|
|
497
|
+
status: 'pass',
|
|
498
|
+
message: `Theme package(s) installed (${names}); wired via package.json astryx.theme.`,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
388
502
|
/**
|
|
389
503
|
* Run all ten app-theme checks.
|
|
390
504
|
* @param {string} cwd
|
|
@@ -622,7 +736,7 @@ export async function checkAppThemes(cwd) {
|
|
|
622
736
|
label: 'App imports the theme module',
|
|
623
737
|
status: 'warn',
|
|
624
738
|
message: `Could not prove that project source imports ${state.module.path}${importEvidence.parseFailures ? `; ${importEvidence.parseFailures} source file(s) could not be parsed` : ''}.`,
|
|
625
|
-
fix: `Import {themes, defaultThemeSlug} from the generated module and render <Theme theme={themes[defaultThemeSlug]}>.`,
|
|
739
|
+
fix: `Import {themes, defaultThemeSlug} from the generated module and {Theme} from '@astryxdesign/core', then render <Theme theme={themes[defaultThemeSlug]}>.`,
|
|
626
740
|
});
|
|
627
741
|
}
|
|
628
742
|
|