@astryxdesign/cli 0.7.2-canary.621784f → 0.7.2-canary.64e1dde
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 +12 -12
- package/api/discover/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +152 -48
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/integration/_adapter.d.mts +10 -0
- package/api/integration/_adapter.mjs +13 -0
- package/api/integration/authoring-checks.mjs +14 -3
- package/api/integration/authoring-checks.test.mjs +326 -0
- package/api/integration/authoring-checks.type.d.mts +50 -0
- package/api/integration/authoring-checks.type.mjs +21 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +9 -3
- package/api/integration/integrationDocConflicts.doc.mjs +17 -5
- package/api/integration/pack-check.mjs +292 -7
- package/api/integration/pack-check.test.mjs +341 -0
- package/api/integration/validateIntegration.doc.mjs +3 -1
- package/api/search/search.d.mts +72 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.mjs +501 -37
- package/api/search/search.test.mjs +139 -0
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +110 -13
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
- package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +6 -18
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +2 -2
- package/assets/docs/tree/check-your-docs.doc.mjs +16 -7
- package/assets/docs/tree/checks.doc.mjs +7 -7
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +3 -5
- package/assets/docs/tree/component-imports.doc.mjs +2 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -16
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +3 -3
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
- package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
- package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
- package/assets/docs/tree/integrations.doc.mjs +8 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/links.doc.mjs +5 -4
- package/assets/docs/tree/migration-setup.doc.mjs +3 -2
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +3 -7
- package/assets/docs/tree/publishing.doc.mjs +2 -2
- package/assets/docs/tree/quick-start.doc.mjs +37 -21
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +5 -7
- package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
- package/assets/docs/tree/single-component.doc.mjs +12 -4
- package/assets/docs/tree/start-a-template.doc.mjs +3 -3
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +2 -2
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -8
- package/assets/docs/tree/upgrading.doc.mjs +4 -4
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +6 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +2 -2
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/command/command.doc.mjs +14 -12
- package/authoring/doctypes/component/component.doc.mjs +29 -26
- package/authoring/doctypes/component/type.ts +7 -5
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +11 -10
- package/authoring/doctypes/schema/schema.doc.mjs +9 -9
- package/authoring/doctypes/template/template.doc.mjs +2 -2
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/integration/integration.doc.mjs +4 -3
- package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +17 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +34 -3
- package/clients/cli/commands/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-check.test.mjs +65 -0
- package/clients/cli/commands/integration.mjs +2 -3
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/setup-nudge.test.mjs +79 -1
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/index.mjs +29 -5
- package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
- package/foundation/agent-docs/agent-doc-state.mjs +38 -0
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/discovery/authoring-self-docs.mjs +1 -1
- package/foundation/discovery/copied-passages.d.mts +208 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-types.d.mts +1 -1
- package/foundation/discovery/doc-types.mjs +3 -3
- package/foundation/discovery/doc-types.test.mjs +48 -0
- package/foundation/discovery/docs-discovery.d.mts +7 -0
- package/foundation/discovery/docs-discovery.mjs +26 -2
- package/foundation/discovery/project-typescript.d.mts +11 -2
- package/foundation/discovery/project-typescript.mjs +32 -4
- package/foundation/discovery/prop-drift.d.mts +1 -1
- package/foundation/discovery/prop-drift.mjs +2 -2
- package/foundation/discovery/prop-drift.test.mjs +55 -2
- package/foundation/discovery/type-text.mjs +1 -1
- package/foundation/discovery/type-text.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +10 -2
- package/foundation/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/response/response-types.doc.mjs +7 -6
- package/package.json +11 -11
- package/scripts/postinstall.mjs +3 -3
|
@@ -358,7 +358,8 @@ function printComponentConflicts(data) {
|
|
|
358
358
|
// An [ok] after a failed check reads as a pass: say nothing it could not check.
|
|
359
359
|
const failed = data.issues.some(issue => issue.severity === 'error');
|
|
360
360
|
if (data.conflicts.length === 0) {
|
|
361
|
-
if (!failed)
|
|
361
|
+
if (!failed)
|
|
362
|
+
output.push(text('[ok] No component names conflict with Core.'));
|
|
362
363
|
} else {
|
|
363
364
|
output.push(
|
|
364
365
|
records(data.conflicts, {
|
|
@@ -389,7 +390,11 @@ function printDocConflicts(data) {
|
|
|
389
390
|
section(
|
|
390
391
|
`Checking integration docs: ${integrationLabel(data) ?? '(local package)'}`,
|
|
391
392
|
),
|
|
392
|
-
|
|
393
|
+
// A copied passage is listed below with its pair, so its issue is not
|
|
394
|
+
// printed twice.
|
|
395
|
+
...issueBlocks(
|
|
396
|
+
data.issues.filter(issue => issue.code !== 'copied_passage'),
|
|
397
|
+
),
|
|
393
398
|
];
|
|
394
399
|
if (
|
|
395
400
|
!data.issues.some(
|
|
@@ -412,6 +417,32 @@ function printDocConflicts(data) {
|
|
|
412
417
|
}),
|
|
413
418
|
);
|
|
414
419
|
}
|
|
420
|
+
const copied = data.copiedPassages ?? [];
|
|
421
|
+
if (copied.length === 0) {
|
|
422
|
+
if (!data.issues.some(issue => issue.severity === 'error')) {
|
|
423
|
+
output.push(text('[ok] No topic copies a passage from another.'));
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
output.push(
|
|
427
|
+
text(
|
|
428
|
+
`[warn] ${copied.length} copied passage(s) (copied_passage): two topics say the same thing word for word. Keep the text in one and link to it from the other.`,
|
|
429
|
+
),
|
|
430
|
+
records(copied, {
|
|
431
|
+
fields: [
|
|
432
|
+
'topic',
|
|
433
|
+
'section',
|
|
434
|
+
'line',
|
|
435
|
+
'otherTopic',
|
|
436
|
+
'otherOwner',
|
|
437
|
+
'owner',
|
|
438
|
+
'text',
|
|
439
|
+
'words',
|
|
440
|
+
'passages',
|
|
441
|
+
'message',
|
|
442
|
+
],
|
|
443
|
+
}),
|
|
444
|
+
);
|
|
445
|
+
}
|
|
415
446
|
emit(...output);
|
|
416
447
|
}
|
|
417
448
|
|
|
@@ -455,7 +486,7 @@ async function runIntegrationValidation(program, pkg) {
|
|
|
455
486
|
noPackage
|
|
456
487
|
? 'Nothing was validated: no package.json found. Run this command inside a package directory.'
|
|
457
488
|
: 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
|
|
458
|
-
|
|
489
|
+
'To validate an installed integration: astryx doctor integration validate <package>',
|
|
459
490
|
),
|
|
460
491
|
);
|
|
461
492
|
} else printIntegrationValidation(result.data);
|
|
@@ -16,6 +16,8 @@ export const doc = {
|
|
|
16
16
|
'Reports a missing component, variant, layout, styling, accessibility, API, or documentation capability to the package that owns it: the --package you name, else the integration whose component replaces it, else the one package that provides the component, else Core. ' +
|
|
17
17
|
'Every configured handler receives the report: the project config handler first, then each integration handler in config order. Public handlers run only with --confirm-public; internal handlers always run. A failing handler does not stop the others. ' +
|
|
18
18
|
"With no handler it files a GitHub issue for the owning package, only with --confirm-public (without it nothing is sent), or returns the package's issues URL when that is not on GitHub. " +
|
|
19
|
+
"With --to <package>, the report goes only to that integration's issues URL instead, under the same --confirm-public rule. " +
|
|
20
|
+
'When loaded integrations name their own issues URLs, the output lists every destination: an agent asks the person where to file and passes their choice with --to; it never picks a package itself, and without a choice the default is used. ' +
|
|
19
21
|
'The report records whether an agent or a person ran it.',
|
|
20
22
|
fn: 'gapReport',
|
|
21
23
|
args: [
|
|
@@ -55,13 +57,19 @@ export const doc = {
|
|
|
55
57
|
flag: '--confirm-public',
|
|
56
58
|
param: 'options.confirmPublic',
|
|
57
59
|
description:
|
|
58
|
-
'Allow public delivery: public handlers run, and
|
|
60
|
+
'Allow public delivery: public handlers run, and a GitHub issues URL gets an issue filed with your gh login',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
flag: '--to <package>',
|
|
64
|
+
param: 'options.to',
|
|
65
|
+
description:
|
|
66
|
+
"Send the report only to this loaded integration's issues URL, as the person chose; the destinations the output lists are the choices",
|
|
59
67
|
},
|
|
60
68
|
{
|
|
61
69
|
flag: '--list-categories',
|
|
62
70
|
param: 'options.listCategories',
|
|
63
71
|
description:
|
|
64
|
-
'List valid report categories without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
|
|
72
|
+
'List valid report categories, and the destinations when there is more than one, without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
|
|
65
73
|
},
|
|
66
74
|
],
|
|
67
75
|
examples: [
|
|
@@ -70,6 +78,10 @@ export const doc = {
|
|
|
70
78
|
label: 'Prepare a report (nothing public happens without --confirm-public)',
|
|
71
79
|
cli: "astryx gap-report Button --category missing_variant --reason 'Need a compact size'",
|
|
72
80
|
},
|
|
81
|
+
{
|
|
82
|
+
label: 'File where the person chose',
|
|
83
|
+
cli: "astryx gap-report Button --category missing_variant --reason 'Need a compact size' --to @acme/widgets",
|
|
84
|
+
},
|
|
73
85
|
],
|
|
74
86
|
exitCodes: [
|
|
75
87
|
{
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {gapReport as gapReportApi} from '../../../api/gap-report/gap-report.mjs';
|
|
8
8
|
import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
|
|
9
9
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
10
|
-
import {emit, record, records, section} from '../formatters/index.mjs';
|
|
10
|
+
import {emit, record, records, section, text} from '../formatters/index.mjs';
|
|
11
11
|
import {cliError} from '../lib/cli-error.mjs';
|
|
12
12
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
13
13
|
import {doc as gapReportCommand} from './gap-report.doc.mjs';
|
|
@@ -19,7 +19,7 @@ export function registerGapReport(program) {
|
|
|
19
19
|
fn: gapReportFn,
|
|
20
20
|
action: async (
|
|
21
21
|
/** @type {string|undefined} */ component,
|
|
22
|
-
/** @type {{category?: string, reason?: string, additionalContext?: string, package?: string, confirmPublic?: boolean, listCategories?: boolean}} */ options,
|
|
22
|
+
/** @type {{category?: string, reason?: string, additionalContext?: string, package?: string, confirmPublic?: boolean, listCategories?: boolean, to?: string}} */ options,
|
|
23
23
|
) => {
|
|
24
24
|
/** @type {Awaited<ReturnType<typeof gapReportApi>>} */
|
|
25
25
|
let result;
|
|
@@ -35,6 +35,7 @@ export function registerGapReport(program) {
|
|
|
35
35
|
package: options.package,
|
|
36
36
|
confirmPublic: options.confirmPublic,
|
|
37
37
|
listCategories: options.listCategories,
|
|
38
|
+
to: options.to,
|
|
38
39
|
});
|
|
39
40
|
} catch (error) {
|
|
40
41
|
const err =
|
|
@@ -78,6 +79,9 @@ export function registerGapReport(program) {
|
|
|
78
79
|
section('Gap report categories'),
|
|
79
80
|
records(result.data, {fields: ['value', 'label']}),
|
|
80
81
|
);
|
|
82
|
+
if (result.meta) {
|
|
83
|
+
emit(...destinationBlocks(result.meta.destinations, result.meta.ask));
|
|
84
|
+
}
|
|
81
85
|
return answered;
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -119,8 +123,26 @@ export function registerGapReport(program) {
|
|
|
119
123
|
);
|
|
120
124
|
}
|
|
121
125
|
|
|
126
|
+
if (result.data.destinations && result.data.ask) {
|
|
127
|
+
emit(...destinationBlocks(result.data.destinations, result.data.ask));
|
|
128
|
+
}
|
|
129
|
+
|
|
122
130
|
if (isFailure) process.exitCode = 1;
|
|
123
131
|
return answered;
|
|
124
132
|
},
|
|
125
133
|
});
|
|
126
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The destinations a report can go to, then the line telling an agent to ask
|
|
138
|
+
* the person (architecture:cli-surface INV36).
|
|
139
|
+
* @param {import('../../../api/gap-report/gap-report.type.mjs').GapReportDestination[]} destinations
|
|
140
|
+
* @param {string} ask
|
|
141
|
+
*/
|
|
142
|
+
function destinationBlocks(destinations, ask) {
|
|
143
|
+
return [
|
|
144
|
+
section('Destinations'),
|
|
145
|
+
records(destinations, {fields: ['to', 'default', 'issuesUrl']}),
|
|
146
|
+
text(ask),
|
|
147
|
+
];
|
|
148
|
+
}
|
|
@@ -331,3 +331,82 @@ describe('gap-report control docs', () => {
|
|
|
331
331
|
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
332
332
|
});
|
|
333
333
|
});
|
|
334
|
+
|
|
335
|
+
describe('gap-report destinations in text', () => {
|
|
336
|
+
it('lists the destinations and tells the agent to ask the person', async () => {
|
|
337
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-dest-'));
|
|
338
|
+
try {
|
|
339
|
+
fs.writeFileSync(
|
|
340
|
+
path.join(cwd, 'package.json'),
|
|
341
|
+
JSON.stringify({name: 'fixture-app'}),
|
|
342
|
+
);
|
|
343
|
+
const pkg = path.join(cwd, 'node_modules', '@test', 'widgets');
|
|
344
|
+
fs.mkdirSync(pkg, {recursive: true});
|
|
345
|
+
fs.writeFileSync(
|
|
346
|
+
path.join(pkg, 'package.json'),
|
|
347
|
+
JSON.stringify({name: '@test/widgets', version: '1.0.0'}),
|
|
348
|
+
);
|
|
349
|
+
fs.writeFileSync(
|
|
350
|
+
path.join(pkg, 'astryx.integration.mjs'),
|
|
351
|
+
"export default {issuesUrl: 'https://tracker.example/widgets'};\n",
|
|
352
|
+
);
|
|
353
|
+
fs.writeFileSync(
|
|
354
|
+
path.join(cwd, 'astryx.config.mjs'),
|
|
355
|
+
`export default {
|
|
356
|
+
integrations: ['@test/widgets'],
|
|
357
|
+
gapReport: {audience: 'internal', handle: () => ({status: 'filed', message: 'shared'})},
|
|
358
|
+
};\n`,
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const listed = await runCli(['gap-report', '--list-categories'], {cwd});
|
|
362
|
+
expect(listed.status).toBe(0);
|
|
363
|
+
expect(listed.stdout).toContain('Destinations');
|
|
364
|
+
expect(listed.stdout).toMatch(/^default:\s+true$/m);
|
|
365
|
+
expect(listed.stdout).toMatch(/^to:\s+@test\/widgets$/m);
|
|
366
|
+
expect(listed.stdout).toMatch(
|
|
367
|
+
/^issuesUrl:\s+https:\/\/tracker\.example\/widgets$/m,
|
|
368
|
+
);
|
|
369
|
+
expect(listed.stdout).toMatch(/ask the person/i);
|
|
370
|
+
|
|
371
|
+
const filed = await runCli(
|
|
372
|
+
[
|
|
373
|
+
'gap-report',
|
|
374
|
+
'Button',
|
|
375
|
+
'--category',
|
|
376
|
+
'docs_gap',
|
|
377
|
+
'--reason',
|
|
378
|
+
'Need a keyboard example',
|
|
379
|
+
],
|
|
380
|
+
{cwd},
|
|
381
|
+
);
|
|
382
|
+
expect(filed.status).toBe(0);
|
|
383
|
+
expect(filed.stdout).toContain('Destinations');
|
|
384
|
+
expect(filed.stdout).toMatch(/ask the person/i);
|
|
385
|
+
|
|
386
|
+
const chosen = await runCli(
|
|
387
|
+
[
|
|
388
|
+
'gap-report',
|
|
389
|
+
'Button',
|
|
390
|
+
'--category',
|
|
391
|
+
'docs_gap',
|
|
392
|
+
'--reason',
|
|
393
|
+
'Need a keyboard example',
|
|
394
|
+
'--to',
|
|
395
|
+
'@test/widgets',
|
|
396
|
+
'--json',
|
|
397
|
+
],
|
|
398
|
+
{cwd},
|
|
399
|
+
);
|
|
400
|
+
expect(chosen.status).toBe(0);
|
|
401
|
+
expect(JSON.parse(chosen.stdout).data.deliveries).toEqual([
|
|
402
|
+
expect.objectContaining({
|
|
403
|
+
handler: 'issuesUrl',
|
|
404
|
+
status: 'routed_only',
|
|
405
|
+
url: 'https://tracker.example/widgets',
|
|
406
|
+
}),
|
|
407
|
+
]);
|
|
408
|
+
} finally {
|
|
409
|
+
fs.rmSync(cwd, {recursive: true, force: true});
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
});
|
|
@@ -117,6 +117,23 @@ describe('astryx integration check', () => {
|
|
|
117
117
|
expect(run.status).toBe(1);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
it('--strict prints each finding once: its message above, its code in the failing list', async () => {
|
|
121
|
+
const id = await coreTemplateId();
|
|
122
|
+
writePackage({id});
|
|
123
|
+
|
|
124
|
+
const run = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
125
|
+
const json = await runCli(
|
|
126
|
+
['integration', 'check', '--strict', '--json'],
|
|
127
|
+
tmpDir,
|
|
128
|
+
);
|
|
129
|
+
const [failure] = JSON.parse(json.stdout.trim()).data.failures;
|
|
130
|
+
|
|
131
|
+
expect(run.stdout.split(failure.message).length - 1).toBe(1);
|
|
132
|
+
expect(
|
|
133
|
+
run.stdout.slice(run.stdout.indexOf('Failing under --strict')),
|
|
134
|
+
).toContain('template_id_conflict');
|
|
135
|
+
});
|
|
136
|
+
|
|
120
137
|
it('--json carries each check with its own envelope, the --strict failures, and exits as the text does', async () => {
|
|
121
138
|
const id = await coreTemplateId();
|
|
122
139
|
writePackage({id});
|
|
@@ -265,3 +282,51 @@ describe('astryx integration check', () => {
|
|
|
265
282
|
expect(run.status).toBe(1);
|
|
266
283
|
});
|
|
267
284
|
});
|
|
285
|
+
|
|
286
|
+
describe('a copied passage', () => {
|
|
287
|
+
const passage =
|
|
288
|
+
'Themes cannot style the layer that holds a menu or a popover, so a menu ' +
|
|
289
|
+
'keeps the default surface color until the next release adds a token for it.';
|
|
290
|
+
|
|
291
|
+
function writeCopiedDocs() {
|
|
292
|
+
fs.writeFileSync(
|
|
293
|
+
path.join(tmpDir, 'package.json'),
|
|
294
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
295
|
+
);
|
|
296
|
+
fs.writeFileSync(
|
|
297
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
298
|
+
`export default {docs: './docs'};\n`,
|
|
299
|
+
);
|
|
300
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
301
|
+
for (const name of ['acme-setup', 'acme-menus']) {
|
|
302
|
+
const doc = {
|
|
303
|
+
type: 'generic',
|
|
304
|
+
name,
|
|
305
|
+
title: 'Fixture',
|
|
306
|
+
description: 'Fixture topic.',
|
|
307
|
+
sections: [
|
|
308
|
+
{title: 'Overview', content: [{type: 'prose', text: passage}]},
|
|
309
|
+
],
|
|
310
|
+
};
|
|
311
|
+
fs.writeFileSync(
|
|
312
|
+
path.join(tmpDir, 'docs', `${name}.doc.mjs`),
|
|
313
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
|
|
319
|
+
writeCopiedDocs();
|
|
320
|
+
|
|
321
|
+
const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
|
|
322
|
+
expect(doctor.status).toBe(0);
|
|
323
|
+
expect(doctor.stdout).toContain('1 copied passage(s)');
|
|
324
|
+
|
|
325
|
+
const loose = await runCli(['integration', 'check'], tmpDir);
|
|
326
|
+
expect(loose.status).toBe(0);
|
|
327
|
+
|
|
328
|
+
const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
329
|
+
expect(strict.status).toBe(1);
|
|
330
|
+
expect(strict.stdout).toContain('copied_passage');
|
|
331
|
+
});
|
|
332
|
+
});
|
|
@@ -155,7 +155,8 @@ async function checkPackage(program, options) {
|
|
|
155
155
|
: data.name;
|
|
156
156
|
emit(
|
|
157
157
|
// --strict lists each warning and each skipped check again, as the
|
|
158
|
-
// error it now is,
|
|
158
|
+
// error it now is: by check, code and place only, since the check's own
|
|
159
|
+
// output above already printed its message and fix once.
|
|
159
160
|
...(data.failures.length > 0
|
|
160
161
|
? [
|
|
161
162
|
section('Failing under --strict'),
|
|
@@ -166,8 +167,6 @@ async function checkPackage(program, options) {
|
|
|
166
167
|
'code',
|
|
167
168
|
'component',
|
|
168
169
|
'prop',
|
|
169
|
-
'message',
|
|
170
|
-
'fix',
|
|
171
170
|
'file',
|
|
172
171
|
'line',
|
|
173
172
|
],
|
|
@@ -143,7 +143,11 @@ describe('--json contract: supported commands emit valid envelopes', () => {
|
|
|
143
143
|
const parsed = parseJson(stdout);
|
|
144
144
|
expect(parsed.type).toBe('discover.list');
|
|
145
145
|
expect(parsed.data).toEqual([]);
|
|
146
|
-
expect(parsed.meta).
|
|
146
|
+
expect(parsed.meta.configured).toBe(false);
|
|
147
|
+
// The official list the CLI carries is always a source.
|
|
148
|
+
expect(parsed.meta.sources).toEqual([
|
|
149
|
+
expect.objectContaining({name: 'Astryx', status: 'fresh'}),
|
|
150
|
+
]);
|
|
147
151
|
});
|
|
148
152
|
|
|
149
153
|
it('astryx template --json emits a typed envelope', async () => {
|
|
@@ -16,9 +16,24 @@ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
18
|
import * as os from 'node:os';
|
|
19
|
-
import {
|
|
19
|
+
import {fileURLToPath} from 'node:url';
|
|
20
|
+
import {
|
|
21
|
+
isAstryxInitialized,
|
|
22
|
+
isAstryxPromptInReach,
|
|
23
|
+
} from '../../../foundation/agent-docs/agent-docs.mjs';
|
|
20
24
|
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
21
25
|
|
|
26
|
+
/** This source checkout: the tests run the CLI from it. */
|
|
27
|
+
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
|
|
28
|
+
|
|
29
|
+
/** Is `dir` inside a git repository? The temp folder normally is not. */
|
|
30
|
+
function insideRepository(dir) {
|
|
31
|
+
for (let d = path.resolve(dir); ; d = path.dirname(d)) {
|
|
32
|
+
if (fs.existsSync(path.join(d, '.git'))) return true;
|
|
33
|
+
if (path.dirname(d) === d) return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
const MARKER = '<!-- ASTRYX:START -->';
|
|
23
38
|
const NUDGE = /finish setup and install the Astryx agent prompt/;
|
|
24
39
|
|
|
@@ -61,6 +76,41 @@ describe('isAstryxInitialized — centralized setup check (one place)', () => {
|
|
|
61
76
|
});
|
|
62
77
|
});
|
|
63
78
|
|
|
79
|
+
// Agents read the agent docs between the repository root and the folder they
|
|
80
|
+
// work in, so a monorepo initialized at its root is set up in every package.
|
|
81
|
+
describe('isAstryxPromptInReach — up to the repository root', () => {
|
|
82
|
+
it('finds init\'s block at the repository root from a workspace package', () => {
|
|
83
|
+
fs.mkdirSync(path.join(tmp, '.git'));
|
|
84
|
+
write('AGENTS.md', MARKER);
|
|
85
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
86
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'packages/app'))).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('treats a worktree .git file as the repository root', () => {
|
|
90
|
+
write('.git', 'gitdir: /elsewhere\n');
|
|
91
|
+
write('CLAUDE.md', MARKER);
|
|
92
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
93
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'packages/app'))).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('does not look above the repository root', () => {
|
|
97
|
+
write('AGENTS.md', MARKER);
|
|
98
|
+
fs.mkdirSync(path.join(tmp, 'repo/.git'), {recursive: true});
|
|
99
|
+
write('repo/pkg/package.json', '{"name":"pkg"}');
|
|
100
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'repo/pkg'))).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it.skipIf(insideRepository(os.tmpdir()))(
|
|
104
|
+
'checks only the folder itself outside a repository',
|
|
105
|
+
() => {
|
|
106
|
+
write('AGENTS.md', MARKER);
|
|
107
|
+
write('pkg/package.json', '{"name":"pkg"}');
|
|
108
|
+
expect(isAstryxPromptInReach(tmp)).toBe(true);
|
|
109
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'pkg'))).toBe(false);
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
64
114
|
describe('enforcement layer 3 — per-command setup nudge', () => {
|
|
65
115
|
const asProject = () => write('package.json', '{"name":"t"}');
|
|
66
116
|
|
|
@@ -99,4 +149,32 @@ describe('enforcement layer 3 — per-command setup nudge', () => {
|
|
|
99
149
|
asProject();
|
|
100
150
|
expect((await runCli(['init'], tmp)).stderr).not.toMatch(NUDGE);
|
|
101
151
|
});
|
|
152
|
+
|
|
153
|
+
it('is quiet in a workspace package when init\'s block is at the repository root', async () => {
|
|
154
|
+
fs.mkdirSync(path.join(tmp, '.git'));
|
|
155
|
+
write('AGENTS.md', MARKER);
|
|
156
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
157
|
+
const r = await runCli(['docs', 'tokens'], path.join(tmp, 'packages/app'));
|
|
158
|
+
expect(r.stderr).not.toMatch(NUDGE);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('still nudges in a workspace package with no block up to the repository root', async () => {
|
|
162
|
+
fs.mkdirSync(path.join(tmp, '.git'));
|
|
163
|
+
write('AGENTS.md', 'project notes, no astryx block');
|
|
164
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
165
|
+
const r = await runCli(['docs', 'tokens'], path.join(tmp, 'packages/app'));
|
|
166
|
+
expect(r.stderr).toMatch(NUDGE);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// The tests run the CLI from this checkout, so a project inside it is the
|
|
170
|
+
// contributor flow. The same project in the temp folder nudges (above).
|
|
171
|
+
it('is quiet inside the source checkout the CLI runs from', async () => {
|
|
172
|
+
const inside = fs.mkdtempSync(path.join(REPO, '.astryx-setup-nudge-'));
|
|
173
|
+
try {
|
|
174
|
+
fs.writeFileSync(path.join(inside, 'package.json'), '{"name":"t"}');
|
|
175
|
+
expect((await runCli(['docs', 'tokens'], inside)).stderr).not.toMatch(NUDGE);
|
|
176
|
+
} finally {
|
|
177
|
+
fs.rmSync(inside, {recursive: true, force: true});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
102
180
|
});
|
|
@@ -91,14 +91,16 @@ export function registerSwizzle(program) {
|
|
|
91
91
|
),
|
|
92
92
|
];
|
|
93
93
|
|
|
94
|
-
// StyleX build requirement — swizzled StyleX source
|
|
95
|
-
//
|
|
94
|
+
// StyleX build requirement — swizzled StyleX source throws on import
|
|
95
|
+
// ("Unexpected 'stylex.create' call at runtime") unless the consumer's
|
|
96
|
+
// build runs a StyleX compiler, so the page does not render at all.
|
|
96
97
|
if (usesStyleX) {
|
|
97
98
|
out.push(
|
|
98
99
|
text(
|
|
99
100
|
[
|
|
100
101
|
`${WARN} These components use StyleX and require a StyleX compiler in your build.`,
|
|
101
|
-
|
|
102
|
+
` Without one, importing them throws "Unexpected 'stylex.create' call at runtime"`,
|
|
103
|
+
' and the page does not render. See setup per framework:',
|
|
102
104
|
` ${run} docs styling`,
|
|
103
105
|
' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font -',
|
|
104
106
|
' use an SWC-based StyleX transform instead (covered in the guide).',
|
|
@@ -15,8 +15,16 @@ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
|
15
15
|
import * as fs from 'node:fs';
|
|
16
16
|
import * as path from 'node:path';
|
|
17
17
|
import * as os from 'node:os';
|
|
18
|
+
import {createRequire} from 'node:module';
|
|
19
|
+
import {fileURLToPath} from 'node:url';
|
|
18
20
|
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
19
21
|
|
|
22
|
+
/** The StyleX runtime that Core ships with, resolved the way Core resolves it. */
|
|
23
|
+
const CORE_PACKAGE = path.resolve(
|
|
24
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
25
|
+
'../../../../core/package.json',
|
|
26
|
+
);
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
29
|
* Build a fake @astryxdesign/core under <project>/node_modules with a single
|
|
22
30
|
* swizzleable Button component (bare `Button.tsx`, no doc).
|
|
@@ -303,12 +311,21 @@ describe('swizzle — StyleX build setup note (#3373)', () => {
|
|
|
303
311
|
const humanResult = await runCli(['swizzle', 'Styled', '-f'], project);
|
|
304
312
|
expect(humanResult.code).toBe(0);
|
|
305
313
|
expect(humanResult.stdout).toMatch(/StyleX compiler/i);
|
|
306
|
-
expect(humanResult.stdout).toMatch(/
|
|
314
|
+
expect(humanResult.stdout).toMatch(/importing them throws "Unexpected 'stylex\.create' call at runtime"/);
|
|
315
|
+
expect(humanResult.stdout).not.toMatch(/unstyled/i);
|
|
307
316
|
expect(humanResult.stdout).toMatch(/next\/font/i);
|
|
308
317
|
// The fixture has no `astryx` bin installed, so the note names the scoped package.
|
|
309
318
|
expect(humanResult.stdout).toMatch(/@astryxdesign\/cli docs styling/);
|
|
310
319
|
});
|
|
311
320
|
|
|
321
|
+
// The note quotes what StyleX does without a compiler; this keeps it true.
|
|
322
|
+
it('matches what the StyleX runtime does when styles are not compiled', () => {
|
|
323
|
+
const stylex = createRequire(CORE_PACKAGE)('@stylexjs/stylex');
|
|
324
|
+
expect(() => stylex.create({root: {color: 'red'}})).toThrow(
|
|
325
|
+
/Unexpected 'stylex\.create' call at runtime/,
|
|
326
|
+
);
|
|
327
|
+
});
|
|
328
|
+
|
|
312
329
|
it('does not print the StyleX note for components without StyleX', async () => {
|
|
313
330
|
buildStyleXCore(project);
|
|
314
331
|
writeProjectPackageJson(project);
|
|
@@ -30,7 +30,7 @@ export const doc = {
|
|
|
30
30
|
{
|
|
31
31
|
flag: '--family',
|
|
32
32
|
description:
|
|
33
|
-
'Build the selected extension family into one keyed CSS, JS, and declaration set, written beside the family root theme file, which must be inside the working directory (ERR_PATH_TRAVERSAL). Requires --family-key; refused with --out or --watch (ERR_THEME_INVALID)',
|
|
33
|
+
'Build the selected extension family into one keyed CSS, JS, and declaration set, written beside the family root theme file, which must be inside the working directory to build (ERR_PATH_TRAVERSAL); --check only reads, so it compares outputs anywhere. Requires --family-key; refused with --out or --watch (ERR_THEME_INVALID)',
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
flag: '--family-key <key>',
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
flag: '-o, --out <path>',
|
|
42
42
|
param: 'options.out',
|
|
43
43
|
description:
|
|
44
|
-
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source).
|
|
44
|
+
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
flag: '--icons-specifier <specifier>',
|
|
@@ -116,6 +116,20 @@ export const doc = {
|
|
|
116
116
|
],
|
|
117
117
|
related: ['init', 'doctor'],
|
|
118
118
|
notes: [
|
|
119
|
+
{type: 'heading', level: 3, text: 'A CLI older than your Core'},
|
|
120
|
+
{
|
|
121
|
+
type: 'prose',
|
|
122
|
+
text:
|
|
123
|
+
'Core codemods ship inside the CLI, so a CLI older than the installed @astryxdesign/core has none for ' +
|
|
124
|
+
'the releases after its own version. upgrade then says it cannot finish, never reports your code as up to date, ' +
|
|
125
|
+
'and prints the same upgrade pinned to the CLI release that matches your Core, such as ' +
|
|
126
|
+
'`cd <project> && npx @astryxdesign/cli@<core-version> upgrade --from <old-version> --path <source-dir> --apply`. ' +
|
|
127
|
+
'It changes to the folder this run used and names the directory it scanned as an absolute path, both with ' +
|
|
128
|
+
'symbolic links resolved, so pasted from any folder it upgrades the same code. It is written for a POSIX shell (sh, bash, zsh), or for PowerShell on Windows, ' +
|
|
129
|
+
'with each argument quoted for that shell; cmd.exe is not a target. The codemods this CLI has still run. ' +
|
|
130
|
+
'It exits 0, so a script checks the JSON: the result carries `cliBehindCore` with `cliVersion` (the newest release ' +
|
|
131
|
+
'this CLI has codemods for) and `command`.',
|
|
132
|
+
},
|
|
119
133
|
{type: 'heading', level: 3, text: 'Protected files'},
|
|
120
134
|
{
|
|
121
135
|
type: 'prose',
|