@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
|
@@ -18,6 +18,11 @@ import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter
|
|
|
18
18
|
import {discoverOwnedComponents} from '../../foundation/discovery/component-discovery.mjs';
|
|
19
19
|
import {discoverBuiltinTopics} from '../../foundation/discovery/docs-discovery.mjs';
|
|
20
20
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
21
|
+
import {
|
|
22
|
+
builtinGuideFiles,
|
|
23
|
+
loadTopicModule,
|
|
24
|
+
} from '../../foundation/discovery/docs-discovery.mjs';
|
|
25
|
+
import {proseWords} from '../../foundation/discovery/copied-passages.mjs';
|
|
21
26
|
import {
|
|
22
27
|
integrationComponentConflicts,
|
|
23
28
|
integrationDocConflicts,
|
|
@@ -99,6 +104,44 @@ function writeDocIntegration({name, replaces, extendsTopic}) {
|
|
|
99
104
|
);
|
|
100
105
|
}
|
|
101
106
|
|
|
107
|
+
/**
|
|
108
|
+
* A docs-only package with one generic topic per entry: its prose, and
|
|
109
|
+
* optionally a code block and the Core topic it replaces.
|
|
110
|
+
* @param {{name: string, text: string, code?: string, replaces?: string}[]} topics
|
|
111
|
+
*/
|
|
112
|
+
function writeTopics(topics) {
|
|
113
|
+
fs.writeFileSync(
|
|
114
|
+
path.join(tmpDir, 'package.json'),
|
|
115
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
116
|
+
);
|
|
117
|
+
fs.writeFileSync(
|
|
118
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
119
|
+
`export default {docs: './docs'};\n`,
|
|
120
|
+
);
|
|
121
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
122
|
+
for (const {name, text, code, replaces, extendsTopic} of topics) {
|
|
123
|
+
const blocks = [{type: 'prose', text}];
|
|
124
|
+
if (code != null) blocks.push({type: 'code', lang: 'text', code});
|
|
125
|
+
const doc = {
|
|
126
|
+
type: 'generic',
|
|
127
|
+
name,
|
|
128
|
+
title: 'Fixture',
|
|
129
|
+
description: 'Fixture topic.',
|
|
130
|
+
...(replaces == null ? {} : {replaces}),
|
|
131
|
+
...(extendsTopic == null ? {} : {extends: extendsTopic}),
|
|
132
|
+
sections: [{title: 'Overview', content: blocks}],
|
|
133
|
+
};
|
|
134
|
+
fs.writeFileSync(
|
|
135
|
+
path.join(tmpDir, 'docs', `${name}.doc.mjs`),
|
|
136
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const PASSAGE =
|
|
142
|
+
'Themes cannot style the layer that holds a menu or a popover, so a menu ' +
|
|
143
|
+
'keeps the default surface color until the next release adds a token for it.';
|
|
144
|
+
|
|
102
145
|
beforeEach(() => {
|
|
103
146
|
tmpDir = fs.mkdtempSync(
|
|
104
147
|
path.join(process.cwd(), '.astryx-template-conflicts-'),
|
|
@@ -562,3 +605,286 @@ describe('integrationDocConflicts', () => {
|
|
|
562
605
|
]);
|
|
563
606
|
});
|
|
564
607
|
});
|
|
608
|
+
|
|
609
|
+
describe('integrationDocConflicts copied passages', () => {
|
|
610
|
+
const copied = (/** @type {any} */ result) => result.data.copiedPassages;
|
|
611
|
+
|
|
612
|
+
it('lists a passage two of the package topics repeat, and warns about it', async () => {
|
|
613
|
+
writeTopics([
|
|
614
|
+
{name: 'acme-setup', text: `Read this first. ${PASSAGE}`},
|
|
615
|
+
{name: 'acme-menus', text: `${PASSAGE} See the theme guide.`},
|
|
616
|
+
]);
|
|
617
|
+
|
|
618
|
+
const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
|
|
619
|
+
const [issue, ...rest] = copied(result);
|
|
620
|
+
expect(result.data.issues).toEqual([
|
|
621
|
+
{code: 'copied_passage', severity: 'warning', message: issue.message},
|
|
622
|
+
]);
|
|
623
|
+
|
|
624
|
+
expect(rest).toEqual([]);
|
|
625
|
+
// The passage is about menus, so "acme-menus" keeps it.
|
|
626
|
+
expect(issue).toMatchObject({
|
|
627
|
+
topic: 'acme-setup',
|
|
628
|
+
otherTopic: 'acme-menus',
|
|
629
|
+
otherOwner: 'package',
|
|
630
|
+
owner: 'acme-menus',
|
|
631
|
+
section: 'Overview',
|
|
632
|
+
line: 1,
|
|
633
|
+
words: PASSAGE.split(' ').length,
|
|
634
|
+
passages: 1,
|
|
635
|
+
});
|
|
636
|
+
expect(issue.message).toContain(`${PASSAGE.split(' ').length} words`);
|
|
637
|
+
expect(issue.text).toBe(PASSAGE);
|
|
638
|
+
expect(issue.message).toContain(`"${PASSAGE}"`);
|
|
639
|
+
expect(issue.message).toContain(
|
|
640
|
+
'"acme-menus" keeps it: its name, title or section fits the passage.',
|
|
641
|
+
);
|
|
642
|
+
expect(issue.message).toContain(
|
|
643
|
+
'In "acme-setup", replace that whole passage, from its first word to its last, code ticks included, with {@link generic:acme-menus}.',
|
|
644
|
+
);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
it('reports a passage copied from a Core topic, except into the topic that replaces it', async () => {
|
|
648
|
+
const [file] = builtinGuideFiles();
|
|
649
|
+
const coreDoc = /** @type {any} */ (await loadTopicModule(file));
|
|
650
|
+
const coreText = proseWords(coreDoc)
|
|
651
|
+
.slice(0, 30)
|
|
652
|
+
.map(each => each.word)
|
|
653
|
+
.join(' ');
|
|
654
|
+
|
|
655
|
+
writeTopics([{name: 'acme-copy', text: coreText}]);
|
|
656
|
+
const [issue] = copied(
|
|
657
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
658
|
+
);
|
|
659
|
+
expect(issue.otherOwner).toBe('core');
|
|
660
|
+
expect(issue.message).toContain(`the Core topic "${coreDoc.name}"`);
|
|
661
|
+
expect(issue.owner).toBe(coreDoc.name);
|
|
662
|
+
expect(issue.message).toContain(
|
|
663
|
+
`code ticks included, with {@link @astryxdesign/cli:generic:${coreDoc.name}}.`,
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
fs.rmSync(path.join(tmpDir, 'docs'), {recursive: true, force: true});
|
|
667
|
+
writeTopics([{name: 'acme-own', text: coreText, replaces: coreDoc.name}]);
|
|
668
|
+
expect(
|
|
669
|
+
copied(await integrationDocConflicts(undefined, {cwd: tmpDir})).filter(
|
|
670
|
+
(/** @type {any} */ each) => each.message.includes(`"${coreDoc.name}"`),
|
|
671
|
+
),
|
|
672
|
+
).toEqual([]);
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
it('leaves out boilerplate that three topics share', async () => {
|
|
676
|
+
writeTopics([
|
|
677
|
+
{name: 'acme-fonts', text: PASSAGE},
|
|
678
|
+
{name: 'acme-icons', text: PASSAGE},
|
|
679
|
+
{name: 'acme-media', text: PASSAGE},
|
|
680
|
+
]);
|
|
681
|
+
|
|
682
|
+
expect(
|
|
683
|
+
copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
|
|
684
|
+
).toEqual([]);
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
it('leaves out a run of function words, which states no fact', async () => {
|
|
688
|
+
const glue = 'and it is in the way that you can do it for them';
|
|
689
|
+
writeTopics([
|
|
690
|
+
{name: 'acme-a', text: `Start here. ${glue} first.`},
|
|
691
|
+
{name: 'acme-b', text: `Then ${glue} again.`},
|
|
692
|
+
]);
|
|
693
|
+
|
|
694
|
+
expect(
|
|
695
|
+
copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
|
|
696
|
+
).toEqual([]);
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
it('leaves out a shared phrase under 10 words, and code', async () => {
|
|
700
|
+
const short = PASSAGE.split(' ').slice(0, 9).join(' ');
|
|
701
|
+
writeTopics([
|
|
702
|
+
{name: 'acme-a', text: PASSAGE},
|
|
703
|
+
{name: 'acme-b', text: short},
|
|
704
|
+
{name: 'acme-c', text: 'Run it.', code: PASSAGE},
|
|
705
|
+
]);
|
|
706
|
+
|
|
707
|
+
expect(
|
|
708
|
+
copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
|
|
709
|
+
).toEqual([]);
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
describe('integrationDocConflicts copied passages and extensions', () => {
|
|
714
|
+
const copied = (/** @type {any} */ result) => result.data.copiedPassages;
|
|
715
|
+
|
|
716
|
+
it('links to the page an extension shows on, not to the extension', async () => {
|
|
717
|
+
writeTopics([
|
|
718
|
+
{name: 'acme-menus', text: PASSAGE, extendsTopic: 'theme'},
|
|
719
|
+
{name: 'acme-setup', text: `${PASSAGE} Then run setup.`},
|
|
720
|
+
]);
|
|
721
|
+
|
|
722
|
+
const [issue] = copied(
|
|
723
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
expect(issue).toMatchObject({topic: 'acme-setup', owner: 'acme-menus'});
|
|
727
|
+
expect(issue.message).toContain(
|
|
728
|
+
'with {@link @astryxdesign/cli:generic:theme}.',
|
|
729
|
+
);
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
it('says to delete a copy in a topic that extends its owner', async () => {
|
|
733
|
+
writeTopics([
|
|
734
|
+
{name: 'acme-base', text: PASSAGE},
|
|
735
|
+
{name: 'acme-more', text: PASSAGE, extendsTopic: 'acme-base'},
|
|
736
|
+
]);
|
|
737
|
+
|
|
738
|
+
const [issue] = copied(
|
|
739
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
740
|
+
);
|
|
741
|
+
|
|
742
|
+
expect(issue).toMatchObject({topic: 'acme-more', owner: 'acme-base'});
|
|
743
|
+
expect(issue.message).toContain(
|
|
744
|
+
'"acme-more" and "acme-base" show on the same page ("acme-base"): delete the passage from "acme-more"',
|
|
745
|
+
);
|
|
746
|
+
expect(issue.message).not.toContain('{@link');
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
it('compares pages without regard to case, and for two extensions of one page', async () => {
|
|
750
|
+
writeTopics([
|
|
751
|
+
{name: 'acme-colors', text: PASSAGE, extendsTopic: 'Theme'},
|
|
752
|
+
{name: 'acme-menus', text: PASSAGE, extendsTopic: 'theme'},
|
|
753
|
+
]);
|
|
754
|
+
|
|
755
|
+
const [issue] = copied(
|
|
756
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
757
|
+
);
|
|
758
|
+
|
|
759
|
+
expect(issue.message).toContain('show on the same page ("theme")');
|
|
760
|
+
expect(issue.message).not.toContain('{@link');
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
it('finds the line of the string that holds the copy, whatever it opens with', async () => {
|
|
764
|
+
writeTopics([{name: 'acme-menus', text: PASSAGE}]);
|
|
765
|
+
fs.writeFileSync(
|
|
766
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
767
|
+
[
|
|
768
|
+
'export default {',
|
|
769
|
+
" type: 'generic',",
|
|
770
|
+
" name: 'acme-setup',",
|
|
771
|
+
" title: 'Fixture',",
|
|
772
|
+
" description: 'Fixture topic.',",
|
|
773
|
+
" sections: [{title: 'Overview', content: [",
|
|
774
|
+
" {type: 'prose', text: '`acme` (the CLI) opens here, as {@link generic:acme-menus} says.'},",
|
|
775
|
+
` {type: 'prose', text: '\`acme\` (the CLI) opens here: ${PASSAGE}'},`,
|
|
776
|
+
' ]}],',
|
|
777
|
+
'};',
|
|
778
|
+
'',
|
|
779
|
+
].join('\n'),
|
|
780
|
+
);
|
|
781
|
+
|
|
782
|
+
const [issue] = copied(
|
|
783
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
784
|
+
);
|
|
785
|
+
|
|
786
|
+
expect(issue).toMatchObject({topic: 'acme-setup', line: 8});
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
it('does not list a 9-word sentence that ends in a link', async () => {
|
|
790
|
+
const sentence =
|
|
791
|
+
'Theme tokens control every surface color, as explained in {@link generic:acme-theme}.';
|
|
792
|
+
writeTopics([
|
|
793
|
+
{name: 'acme-colors', text: `Colors first. ${sentence}`},
|
|
794
|
+
{name: 'acme-menus', text: `Menus next. ${sentence}`},
|
|
795
|
+
]);
|
|
796
|
+
|
|
797
|
+
expect(
|
|
798
|
+
copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
|
|
799
|
+
).toEqual([]);
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
it('counts no function word toward which topic a passage fits', async () => {
|
|
803
|
+
writeTopics([
|
|
804
|
+
{name: 'acme-getting-started', text: `${PASSAGE} Then run setup.`},
|
|
805
|
+
{name: 'acme-menus', text: PASSAGE},
|
|
806
|
+
]);
|
|
807
|
+
// Titles that share only function words with the passage.
|
|
808
|
+
for (const [name, title] of [
|
|
809
|
+
['acme-getting-started', 'Get started with the widgets'],
|
|
810
|
+
['acme-menus', 'Menus'],
|
|
811
|
+
]) {
|
|
812
|
+
const file = path.join(tmpDir, 'docs', `${name}.doc.mjs`);
|
|
813
|
+
fs.writeFileSync(
|
|
814
|
+
file,
|
|
815
|
+
fs
|
|
816
|
+
.readFileSync(file, 'utf8')
|
|
817
|
+
.replace('"title":"Fixture"', `"title":"${title}"`),
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
const [issue] = copied(
|
|
822
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
823
|
+
);
|
|
824
|
+
|
|
825
|
+
expect(issue).toMatchObject({
|
|
826
|
+
owner: 'acme-menus',
|
|
827
|
+
topic: 'acme-getting-started',
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
it('finds a copy after a lead-in three topics share', async () => {
|
|
832
|
+
const lead =
|
|
833
|
+
'Every package ships its integration docs as plain modules the CLI reads';
|
|
834
|
+
writeTopics([
|
|
835
|
+
{name: 'acme-menus', text: `${lead}. ${PASSAGE}`},
|
|
836
|
+
{name: 'acme-setup', text: `${lead}. ${PASSAGE} Then run setup.`},
|
|
837
|
+
{name: 'acme-other', text: `${lead}. Nothing else here is shared.`},
|
|
838
|
+
]);
|
|
839
|
+
|
|
840
|
+
const found = copied(
|
|
841
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
842
|
+
);
|
|
843
|
+
|
|
844
|
+
expect(found).toHaveLength(1);
|
|
845
|
+
expect(found[0].text).toBe(PASSAGE);
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
it("links to a package topic that replaces Core's by its own name", async () => {
|
|
849
|
+
writeTopics([
|
|
850
|
+
{name: 'theme', text: PASSAGE, replaces: 'theme'},
|
|
851
|
+
{name: 'acme-setup', text: `${PASSAGE} Then run setup.`},
|
|
852
|
+
]);
|
|
853
|
+
|
|
854
|
+
const found = copied(
|
|
855
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
856
|
+
);
|
|
857
|
+
|
|
858
|
+
for (const each of found) {
|
|
859
|
+
expect(each.message).not.toContain('@astryxdesign/cli:generic:theme');
|
|
860
|
+
}
|
|
861
|
+
expect(
|
|
862
|
+
found.some((/** @type {any} */ each) =>
|
|
863
|
+
each.message.includes('with {@link generic:theme}.'),
|
|
864
|
+
),
|
|
865
|
+
).toBe(true);
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
it('prints no link to a Core topic one of the package topics replaces', async () => {
|
|
869
|
+
const [file] = builtinGuideFiles();
|
|
870
|
+
const coreDoc = /** @type {any} */ (await loadTopicModule(file));
|
|
871
|
+
const coreText = proseWords(coreDoc)
|
|
872
|
+
.slice(0, 30)
|
|
873
|
+
.map(each => each.word)
|
|
874
|
+
.join(' ');
|
|
875
|
+
writeTopics([
|
|
876
|
+
{name: 'acme-own', text: 'Our version.', replaces: coreDoc.name},
|
|
877
|
+
{name: 'acme-copy', text: coreText},
|
|
878
|
+
]);
|
|
879
|
+
|
|
880
|
+
const found = copied(
|
|
881
|
+
await integrationDocConflicts(undefined, {cwd: tmpDir}),
|
|
882
|
+
).filter((/** @type {any} */ each) => each.owner === coreDoc.name);
|
|
883
|
+
|
|
884
|
+
expect(found).toHaveLength(1);
|
|
885
|
+
expect(found[0].message).toContain(
|
|
886
|
+
`"acme-own" replaces the Core topic "${coreDoc.name}"`,
|
|
887
|
+
);
|
|
888
|
+
expect(found[0].message).not.toContain('{@link');
|
|
889
|
+
});
|
|
890
|
+
});
|
|
@@ -32,6 +32,55 @@ export type IntegrationDocFinding = {
|
|
|
32
32
|
coreTopic: string;
|
|
33
33
|
message: string;
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* A passage two topics repeat word for word: two of the package's own topics,
|
|
37
|
+
* or one of them and a Core topic (never the Core topic it replaces). Only
|
|
38
|
+
* prose counts, and only a run of 10 or more identical words, so each entry
|
|
39
|
+
* is a real copy. Each is also a `copied_passage` warning, so
|
|
40
|
+
* `integration check --strict` fails on it (architecture:cli-surface DEC-8).
|
|
41
|
+
*/
|
|
42
|
+
export type CopiedPassage = {
|
|
43
|
+
/**
|
|
44
|
+
* the package topic to change: it repeats the passage
|
|
45
|
+
*/
|
|
46
|
+
topic: string;
|
|
47
|
+
/**
|
|
48
|
+
* the title of the section the passage starts in
|
|
49
|
+
*/
|
|
50
|
+
section: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* the file line where the passage starts in `topic`, or null
|
|
53
|
+
*/
|
|
54
|
+
line: number | null;
|
|
55
|
+
/**
|
|
56
|
+
* the topic that also has it
|
|
57
|
+
*/
|
|
58
|
+
otherTopic: string;
|
|
59
|
+
/**
|
|
60
|
+
* the topic that should keep the text: a Core topic, or of two package topics the one it fits
|
|
61
|
+
*/
|
|
62
|
+
owner: string;
|
|
63
|
+
/**
|
|
64
|
+
* the passage as `topic` writes it: what to replace
|
|
65
|
+
*/
|
|
66
|
+
text: string;
|
|
67
|
+
/**
|
|
68
|
+
* whether that topic is the package's own or Core's
|
|
69
|
+
*/
|
|
70
|
+
otherOwner: "package" | "core";
|
|
71
|
+
/**
|
|
72
|
+
* the length of the longest shared run, in words
|
|
73
|
+
*/
|
|
74
|
+
words: number;
|
|
75
|
+
/**
|
|
76
|
+
* how many separate runs the two topics share
|
|
77
|
+
*/
|
|
78
|
+
passages: number;
|
|
79
|
+
/**
|
|
80
|
+
* what is repeated, and the exact fix: the passage in `topic` replaced by a link to `owner`
|
|
81
|
+
*/
|
|
82
|
+
message: string;
|
|
83
|
+
};
|
|
35
84
|
/**
|
|
36
85
|
* Each of the three authoring checks reports `validated`: false means no
|
|
37
86
|
* integration manifest was found, so nothing was inspected and the empty
|
|
@@ -73,6 +122,7 @@ export type IntegrationDocConflictResponse = {
|
|
|
73
122
|
name: string | null;
|
|
74
123
|
version: string | null;
|
|
75
124
|
findings: IntegrationDocFinding[];
|
|
125
|
+
copiedPassages: CopiedPassage[];
|
|
76
126
|
issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
|
|
77
127
|
};
|
|
78
128
|
};
|
|
@@ -48,6 +48,26 @@
|
|
|
48
48
|
* @property {string} message
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* A passage two topics repeat word for word: two of the package's own topics,
|
|
53
|
+
* or one of them and a Core topic (never the Core topic it replaces). Only
|
|
54
|
+
* prose counts, and only a run of 10 or more identical words, so each entry
|
|
55
|
+
* is a real copy. Each is also a `copied_passage` warning, so
|
|
56
|
+
* `integration check --strict` fails on it (architecture:cli-surface DEC-8).
|
|
57
|
+
*
|
|
58
|
+
* @typedef {object} CopiedPassage
|
|
59
|
+
* @property {string} topic the package topic to change: it repeats the passage
|
|
60
|
+
* @property {string | null} section the title of the section the passage starts in
|
|
61
|
+
* @property {number | null} line the file line where the passage starts in `topic`, or null
|
|
62
|
+
* @property {string} otherTopic the topic that also has it
|
|
63
|
+
* @property {string} owner the topic that should keep the text: a Core topic, or of two package topics the one it fits
|
|
64
|
+
* @property {string} text the passage as `topic` writes it: what to replace
|
|
65
|
+
* @property {'package' | 'core'} otherOwner whether that topic is the package's own or Core's
|
|
66
|
+
* @property {number} words the length of the longest shared run, in words
|
|
67
|
+
* @property {number} passages how many separate runs the two topics share
|
|
68
|
+
* @property {string} message what is repeated, and the exact fix: the passage in `topic` replaced by a link to `owner`
|
|
69
|
+
*/
|
|
70
|
+
|
|
51
71
|
/**
|
|
52
72
|
* Each of the three authoring checks reports `validated`: false means no
|
|
53
73
|
* integration manifest was found, so nothing was inspected and the empty
|
|
@@ -80,7 +100,7 @@
|
|
|
80
100
|
/**
|
|
81
101
|
* @typedef {object} IntegrationDocConflictResponse
|
|
82
102
|
* @property {'integration.doc-conflicts'} type
|
|
83
|
-
* @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
103
|
+
* @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], copiedPassages: CopiedPassage[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
84
104
|
*/
|
|
85
105
|
|
|
86
106
|
export {};
|
|
@@ -18,7 +18,9 @@ export const doc = {
|
|
|
18
18
|
'replaces is checked too: its findings are issues, errors for a package that ' +
|
|
19
19
|
'declares the CLI range that turns replacement on and warnings otherwise. ' +
|
|
20
20
|
"Each component doc's props are compared with the component's TypeScript props, " +
|
|
21
|
-
"read with the project's own `typescript
|
|
21
|
+
"read with the project's own `typescript` (or, where `typescript` is missing or has no " +
|
|
22
|
+
'JavaScript compiler API, as TypeScript 7 does, the `@typescript/typescript6` it ' +
|
|
23
|
+
'installs): a documented prop the code lacks, a ' +
|
|
22
24
|
'prop the package declares that the doc omits, a wrong `required`, or a type ' +
|
|
23
25
|
'that does not match. A type is judged only when it reads exactly: the same ' +
|
|
24
26
|
'text as the source, once whitespace, quotes and union order are set aside (exactly, if it contains `readonly`), ' +
|
|
@@ -50,14 +52,18 @@ export const doc = {
|
|
|
50
52
|
'drift',
|
|
51
53
|
],
|
|
52
54
|
params: [
|
|
53
|
-
{
|
|
55
|
+
{
|
|
56
|
+
name: 'pkg',
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Installed package; omit for the local package.',
|
|
59
|
+
},
|
|
54
60
|
{name: 'options.cwd', type: 'string', description: 'Resolution directory.'},
|
|
55
61
|
],
|
|
56
62
|
returns: [
|
|
57
63
|
{
|
|
58
64
|
type: 'integration.component-conflicts',
|
|
59
65
|
description:
|
|
60
|
-
|
|
66
|
+
"`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict. When the manifest loads and declares a components root, `propDrift` holds the props comparison: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `components` compared, `typesCompared` (documented prop types judged), `typesSkipped` (why none was, with a TypeScript older than 4.8), `findings` ({component, prop, kind: `not_in_code` | `not_in_doc` | `required_mismatch` | `type_mismatch`, severity: `warning`, message, doc, source, docType?, codeType?, docRequired?, codeRequired?}), `unchecked` ({component, doc, reason}), `typesNotCompared` ({component, doc, reason, props}: every other documented prop type, grouped by why it was not judged: not a form the check judges exactly (a doc type that does not parse, or a prop a mapped type builds from keys the check cannot trace, included), a field the prop's variants give different types, a standard prop such as `className`, or a prop declared outside the package), and `propsNotChecked` when a mapped type builds props from keys the check cannot trace to the package ({component, doc, reason, props}: no warning is drawn for those props).",
|
|
61
67
|
},
|
|
62
68
|
],
|
|
63
69
|
examples: [
|
|
@@ -9,28 +9,40 @@ export const doc = {
|
|
|
9
9
|
name: 'integrationDocConflicts',
|
|
10
10
|
namespace: 'cli/api',
|
|
11
11
|
displayName: 'integrationDocConflicts()',
|
|
12
|
-
summary:
|
|
12
|
+
summary:
|
|
13
|
+
"Check an integration's docs: the docs tree they add, every link, and overlaps with Core topics.",
|
|
13
14
|
description:
|
|
14
15
|
'Loads one local or installed integration and classifies Core doc overlaps as ' +
|
|
15
16
|
'intentional replacements, intentional extensions, or accidental same-name ' +
|
|
16
|
-
'conflicts that need an explicit relationship or a rename.'
|
|
17
|
+
'conflicts that need an explicit relationship or a rename. `copiedPassages` lists each ' +
|
|
18
|
+
'pair of topics that repeat 10 or more words of prose word for word: two of the ' +
|
|
19
|
+
"package's topics, or one of them and a Core topic other than the one it replaces. " +
|
|
20
|
+
'Code and examples are not compared. Each entry is also a `copied_passage` warning, so ' +
|
|
21
|
+
'`integration check --strict` fails on it; the check itself still fails only on errors.',
|
|
17
22
|
importPath: '@astryxdesign/cli/api',
|
|
18
23
|
signature:
|
|
19
24
|
'integrationDocConflicts(pkg?: string, options?: IntegrationAuthoringOptions): Promise<IntegrationDocConflictResponse>',
|
|
20
25
|
keywords: ['integration', 'docs', 'replace', 'extend', 'authoring', 'doctor'],
|
|
21
26
|
params: [
|
|
22
|
-
{
|
|
27
|
+
{
|
|
28
|
+
name: 'pkg',
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'Installed package; omit for the local package.',
|
|
31
|
+
},
|
|
23
32
|
{name: 'options.cwd', type: 'string', description: 'Resolution directory.'},
|
|
24
33
|
],
|
|
25
34
|
returns: [
|
|
26
35
|
{
|
|
27
36
|
type: 'integration.doc-conflicts',
|
|
28
37
|
description:
|
|
29
|
-
'`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues,
|
|
38
|
+
'`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, classified Core doc relationships, and `copiedPassages`.',
|
|
30
39
|
},
|
|
31
40
|
],
|
|
32
41
|
examples: [
|
|
33
|
-
{
|
|
42
|
+
{
|
|
43
|
+
label: 'Check the local integration',
|
|
44
|
+
code: 'await integrationDocConflicts();',
|
|
45
|
+
},
|
|
34
46
|
],
|
|
35
47
|
command: 'doctor integration docs',
|
|
36
48
|
related: ['validateIntegration', 'docs'],
|