@astryxdesign/cli 0.7.2-canary.405bb94 → 0.7.2-canary.40b21e5
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 +21 -20
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +41 -1
- package/api/component/_adapter.mjs +93 -7
- package/api/component/component.mjs +22 -5
- package/api/component/integration-export-name.test.mjs +644 -0
- 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/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +244 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.mjs +1 -1
- 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 +219 -52
- 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/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +22 -0
- package/api/integration/_adapter.mjs +67 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +24 -4
- package/api/integration/authoring-checks.test.mjs +365 -0
- package/api/integration/authoring-checks.type.d.mts +59 -0
- package/api/integration/authoring-checks.type.mjs +35 -2
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
- package/api/integration/integrationDocConflicts.doc.mjs +17 -5
- package/api/integration/pack-check.mjs +343 -104
- package/api/integration/pack-check.test.mjs +700 -0
- package/api/integration/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.test.mjs +11 -0
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +12 -1
- package/api/integration/validateIntegration.doc.mjs +19 -3
- package/api/search/search.d.mts +81 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +601 -50
- package/api/search/search.test.mjs +139 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +114 -17
- 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/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -3
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +11 -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 +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +196 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +57 -7
- package/assets/docs/tree/checks.doc.mjs +26 -18
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +10 -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 +2 -2
- 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 +6 -5
- 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 +4 -8
- package/assets/docs/tree/publishing.doc.mjs +2 -2
- package/assets/docs/tree/quick-start.doc.mjs +38 -22
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
- 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 +15 -6
- 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 +16 -8
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- 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 +7 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/theme.template.ts +1 -1
- 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 +30 -27
- package/authoring/doctypes/component/type.ts +13 -8
- 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/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- 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/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +12 -4
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- 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 +17 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +17 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +837 -0
- package/clients/cli/commands/doctor.mjs +224 -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.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +332 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +106 -1
- 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/text-json-parity.test.mjs +5 -0
- 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 +30 -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/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.d.mts +178 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +659 -62
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- 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 +157 -0
- package/foundation/discovery/doc-types.mjs +1224 -0
- package/foundation/discovery/doc-types.test.mjs +700 -0
- package/foundation/discovery/docs-discovery.d.mts +88 -0
- package/foundation/discovery/docs-discovery.mjs +83 -2
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +278 -0
- package/foundation/discovery/prop-drift.mjs +2263 -0
- package/foundation/discovery/prop-drift.test.mjs +2272 -0
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +14 -0
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -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/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +14 -8
- package/package.json +9 -9
- package/scripts/postinstall.mjs +3 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
PASSAGE_WORDS,
|
|
7
|
+
contentWords,
|
|
8
|
+
passageWords,
|
|
9
|
+
wordSpans,
|
|
10
|
+
proseWords,
|
|
11
|
+
sharedPassages,
|
|
12
|
+
} from './copied-passages.mjs';
|
|
13
|
+
|
|
14
|
+
const words = (/** @type {string} */ text) =>
|
|
15
|
+
passageWords(text).map(word => ({word, section: null, block: 1}));
|
|
16
|
+
|
|
17
|
+
describe('passageWords', () => {
|
|
18
|
+
it('sets aside case, links, and Markdown emphasis', () => {
|
|
19
|
+
expect(
|
|
20
|
+
passageWords('Use **`Button`** for {@link component:Button} actions.'),
|
|
21
|
+
).toEqual(['use', 'button', 'for', 'actions.']);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('proseWords', () => {
|
|
26
|
+
it('reads prose with its section, and skips code, references, and names', () => {
|
|
27
|
+
const doc = {
|
|
28
|
+
type: 'generic',
|
|
29
|
+
name: 'acme-guide',
|
|
30
|
+
title: 'Acme guide',
|
|
31
|
+
description: 'Intro words.',
|
|
32
|
+
sections: [
|
|
33
|
+
{
|
|
34
|
+
title: 'Setup',
|
|
35
|
+
content: [
|
|
36
|
+
{type: 'prose', text: 'Install it.'},
|
|
37
|
+
{type: 'code', lang: 'sh', code: 'npm install acme'},
|
|
38
|
+
{type: 'reference', ref: 'generic:other'},
|
|
39
|
+
{type: 'list', items: ['First step.']},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
expect(proseWords(doc)).toEqual([
|
|
45
|
+
{word: 'intro', section: null, block: 1},
|
|
46
|
+
{word: 'words.', section: null, block: 1},
|
|
47
|
+
{word: 'install', section: 'Setup', block: 2},
|
|
48
|
+
{word: 'it.', section: 'Setup', block: 2},
|
|
49
|
+
{word: 'first', section: 'Setup', block: 3},
|
|
50
|
+
{word: 'step.', section: 'Setup', block: 3},
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('sharedPassages', () => {
|
|
56
|
+
const passage = Array.from(
|
|
57
|
+
{length: PASSAGE_WORDS + 5},
|
|
58
|
+
(_, i) => `w${i}`,
|
|
59
|
+
).join(' ');
|
|
60
|
+
|
|
61
|
+
it('finds the longest shared run', () => {
|
|
62
|
+
expect(
|
|
63
|
+
sharedPassages(words(`a b ${passage} c`), words(`x ${passage} y`)),
|
|
64
|
+
).toEqual([{start: 2, length: PASSAGE_WORDS + 5}]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('never runs a passage from one string into the next', () => {
|
|
68
|
+
const half = Math.ceil(PASSAGE_WORDS / 2);
|
|
69
|
+
const first = passage.split(' ').slice(0, half).join(' ');
|
|
70
|
+
const second = passage.split(' ').slice(half, PASSAGE_WORDS).join(' ');
|
|
71
|
+
const split = [
|
|
72
|
+
...passageWords(first).map(word => ({word, section: null, block: 1})),
|
|
73
|
+
...passageWords(second).map(word => ({word, section: null, block: 2})),
|
|
74
|
+
];
|
|
75
|
+
expect(sharedPassages(split, words(`${first} ${second}`))).toEqual([]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('ignores a run shorter than the passage size', () => {
|
|
79
|
+
const short = passage
|
|
80
|
+
.split(' ')
|
|
81
|
+
.slice(0, PASSAGE_WORDS - 1)
|
|
82
|
+
.join(' ');
|
|
83
|
+
expect(
|
|
84
|
+
sharedPassages(words(`a ${short} b`), words(`c ${short} d`)),
|
|
85
|
+
).toEqual([]);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('contentWords', () => {
|
|
90
|
+
it('counts distinct words that are not function words', () => {
|
|
91
|
+
const run = words('and it is in the way that you can do it for them');
|
|
92
|
+
expect(contentWords(run, 0, run.length)).toBe(1);
|
|
93
|
+
const fact = words('Name each codemod folder after the Core version.');
|
|
94
|
+
expect(contentWords(fact, 0, fact.length)).toBe(5);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('wordSpans', () => {
|
|
99
|
+
it('reads the words passageWords reads, with where each sits as written', () => {
|
|
100
|
+
const text = 'Run `astryx docs`, then {@link generic:theme} *now*.';
|
|
101
|
+
const spans = wordSpans(text);
|
|
102
|
+
expect(spans.map(span => span.word)).toEqual(passageWords(text));
|
|
103
|
+
expect(text.slice(spans[1].start, spans[2].end)).toBe('`astryx docs`');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('passageWords and pointers', () => {
|
|
108
|
+
it('reads a link and a written docs command as no words', () => {
|
|
109
|
+
expect(
|
|
110
|
+
passageWords(
|
|
111
|
+
'See {@link generic:theme} or `astryx docs theme` (Share it).',
|
|
112
|
+
),
|
|
113
|
+
).toEqual(['see', 'or', 'share', 'it']);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('counts no punctuation-only token as a word', () => {
|
|
117
|
+
expect(
|
|
118
|
+
passageWords('Set the theme first, see {@link generic:theme}.'),
|
|
119
|
+
).toEqual(['set', 'the', 'theme', 'first', 'see']);
|
|
120
|
+
expect(
|
|
121
|
+
wordSpans('Read it - then {@link generic:theme}.').map(s => s.word),
|
|
122
|
+
).toEqual(['read', 'it', 'then']);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Check each doc file's values against the published authoring types.
|
|
6
|
+
* @param {DocFile[]} files
|
|
7
|
+
* @param {{packageDir: string, resolveFrom: Array<string | null | undefined>, core?: boolean}} options
|
|
8
|
+
* `core`: the docs are Core's own, so templates are held to TemplateDoc
|
|
9
|
+
* @returns {Promise<DocTypesReport>}
|
|
10
|
+
*/
|
|
11
|
+
export function checkDocTypes(files: DocFile[], options: {
|
|
12
|
+
packageDir: string;
|
|
13
|
+
resolveFrom: Array<string | null | undefined>;
|
|
14
|
+
core?: boolean;
|
|
15
|
+
}): Promise<DocTypesReport>;
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {'components' | 'hooks' | 'templates' | 'docs' | 'docs-overlay' | 'themes'} DocRoot
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} DocFile
|
|
21
|
+
* @property {string} path absolute path to the doc file
|
|
22
|
+
* @property {DocRoot} root the contribution root it was found in
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {'unknown_field' | 'missing_field' | 'wrong_type'} DocTypeProblem
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {object} DocTypeFinding
|
|
29
|
+
* @property {string} doc the doc file, relative to the package root
|
|
30
|
+
* @property {number} line 1-based line of the field (or of the doc value)
|
|
31
|
+
* @property {string} export the export checked (`default`, `docs`, `docsZh`, …)
|
|
32
|
+
* @property {string} type the authoring type it was checked against
|
|
33
|
+
* @property {string} field the field's path in the doc, such as
|
|
34
|
+
* `usage.bestPractices[2].guidance`; empty for the doc value as a whole
|
|
35
|
+
* @property {DocTypeProblem} problem
|
|
36
|
+
* @property {'warning'} severity
|
|
37
|
+
* @property {string} message what TypeScript reports, shortened
|
|
38
|
+
* @property {string} fix what to change
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {object} DocTypesUnchecked
|
|
42
|
+
* @property {string} doc the doc file, relative to the package root
|
|
43
|
+
* @property {string} reason why it was not checked
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {object} DocTypesReport
|
|
47
|
+
* @property {'checked' | 'skipped'} status `skipped` means nothing was checked,
|
|
48
|
+
* and `reason` says why
|
|
49
|
+
* @property {string} [reason]
|
|
50
|
+
* @property {string} [typescript] the version of the compiler that checked
|
|
51
|
+
* @property {number} docs how many doc values were checked
|
|
52
|
+
* @property {DocTypeFinding[]} findings
|
|
53
|
+
* @property {DocTypesUnchecked[]} unchecked doc files with nothing to check,
|
|
54
|
+
* or not fully checked
|
|
55
|
+
*/
|
|
56
|
+
/** The line both surfaces print when the compiler is missing. */
|
|
57
|
+
export const DOC_TYPES_TYPESCRIPT_MISSING_REASON: "TypeScript is not installed in this project, so docs were not checked against the authoring types. On TypeScript 7, add its TypeScript 6 API package (`npm install -D @typescript/typescript6`); otherwise install TypeScript 5.0 through 6 (`npm install -D typescript@6`). Then run this check again.";
|
|
58
|
+
export type DocRoot = "components" | "hooks" | "templates" | "docs" | "docs-overlay" | "themes";
|
|
59
|
+
export type DocFile = {
|
|
60
|
+
/**
|
|
61
|
+
* absolute path to the doc file
|
|
62
|
+
*/
|
|
63
|
+
path: string;
|
|
64
|
+
/**
|
|
65
|
+
* the contribution root it was found in
|
|
66
|
+
*/
|
|
67
|
+
root: DocRoot;
|
|
68
|
+
};
|
|
69
|
+
export type DocTypeProblem = "unknown_field" | "missing_field" | "wrong_type";
|
|
70
|
+
export type DocTypeFinding = {
|
|
71
|
+
/**
|
|
72
|
+
* the doc file, relative to the package root
|
|
73
|
+
*/
|
|
74
|
+
doc: string;
|
|
75
|
+
/**
|
|
76
|
+
* 1-based line of the field (or of the doc value)
|
|
77
|
+
*/
|
|
78
|
+
line: number;
|
|
79
|
+
/**
|
|
80
|
+
* the export checked (`default`, `docs`, `docsZh`, …)
|
|
81
|
+
*/
|
|
82
|
+
export: string;
|
|
83
|
+
/**
|
|
84
|
+
* the authoring type it was checked against
|
|
85
|
+
*/
|
|
86
|
+
type: string;
|
|
87
|
+
/**
|
|
88
|
+
* the field's path in the doc, such as
|
|
89
|
+
* `usage.bestPractices[2].guidance`; empty for the doc value as a whole
|
|
90
|
+
*/
|
|
91
|
+
field: string;
|
|
92
|
+
problem: DocTypeProblem;
|
|
93
|
+
severity: "warning";
|
|
94
|
+
/**
|
|
95
|
+
* what TypeScript reports, shortened
|
|
96
|
+
*/
|
|
97
|
+
message: string;
|
|
98
|
+
/**
|
|
99
|
+
* what to change
|
|
100
|
+
*/
|
|
101
|
+
fix: string;
|
|
102
|
+
};
|
|
103
|
+
export type DocTypesUnchecked = {
|
|
104
|
+
/**
|
|
105
|
+
* the doc file, relative to the package root
|
|
106
|
+
*/
|
|
107
|
+
doc: string;
|
|
108
|
+
/**
|
|
109
|
+
* why it was not checked
|
|
110
|
+
*/
|
|
111
|
+
reason: string;
|
|
112
|
+
};
|
|
113
|
+
export type DocTypesReport = {
|
|
114
|
+
/**
|
|
115
|
+
* `skipped` means nothing was checked,
|
|
116
|
+
* and `reason` says why
|
|
117
|
+
*/
|
|
118
|
+
status: "checked" | "skipped";
|
|
119
|
+
reason?: string | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* the version of the compiler that checked
|
|
122
|
+
*/
|
|
123
|
+
typescript?: string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* how many doc values were checked
|
|
126
|
+
*/
|
|
127
|
+
docs: number;
|
|
128
|
+
findings: DocTypeFinding[];
|
|
129
|
+
/**
|
|
130
|
+
* doc files with nothing to check,
|
|
131
|
+
* or not fully checked
|
|
132
|
+
*/
|
|
133
|
+
unchecked: DocTypesUnchecked[];
|
|
134
|
+
};
|
|
135
|
+
export type Target = {
|
|
136
|
+
exportName: string;
|
|
137
|
+
/**
|
|
138
|
+
* the doc value's expression
|
|
139
|
+
*/
|
|
140
|
+
node: any;
|
|
141
|
+
/**
|
|
142
|
+
* the authoring type, as a type expression
|
|
143
|
+
*/
|
|
144
|
+
typeExpr: string;
|
|
145
|
+
/**
|
|
146
|
+
* how findings name that type
|
|
147
|
+
*/
|
|
148
|
+
typeName: string;
|
|
149
|
+
/**
|
|
150
|
+
* nodes whose leading JSDoc annotations are blanked
|
|
151
|
+
*/
|
|
152
|
+
blank: any[];
|
|
153
|
+
/**
|
|
154
|
+
* source ranges to blank
|
|
155
|
+
*/
|
|
156
|
+
blankRanges: Array<[number, number]>;
|
|
157
|
+
};
|