@astryxdesign/cli 0.7.2-canary.db3a2e7 → 0.7.2-canary.e26723d
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 +7 -7
- 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/component.test.mjs +420 -167
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/docs/_adapter.mjs +207 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/gap-report/gap-report.mjs +67 -4
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
- package/api/integration/pack-check.mjs +61 -107
- package/api/integration/pack-check.test.mjs +359 -0
- package/api/integration/validate-integration.test.mjs +11 -0
- package/api/search/search.d.mts +9 -0
- package/api/search/search.mjs +108 -16
- package/api/search/search.test.mjs +36 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/template/template.test.mjs +120 -3
- package/api/theme/build/build.family.test.mjs +16 -0
- package/api/theme/build/build.mjs +81 -22
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +10 -0
- package/assets/docs/tree/check-the-props.doc.mjs +145 -0
- package/assets/docs/tree/checks.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +5 -1
- package/assets/docs/tree/component-imports.doc.mjs +8 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/single-component.doc.mjs +3 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +1 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +2 -1
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
- package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
- package/assets/templates/pages/detail-page/page.tsx +3 -3
- package/assets/templates/pages/table-inbox/page.tsx +10 -8
- package/assets/theme.template.ts +1 -1
- package/authoring/doctypes/base/type.ts +6 -0
- package/authoring/doctypes/component/component.doc.mjs +4 -4
- package/authoring/doctypes/component/type.ts +6 -3
- 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/type.ts +22 -0
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +8 -1
- 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 +84 -0
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
- package/clients/cli/commands/doctor-integration.test.mjs +392 -0
- package/clients/cli/commands/doctor.mjs +74 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/lib/component-format.mjs +5 -1
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -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 +652 -0
- package/foundation/discovery/docs-discovery.d.mts +81 -0
- package/foundation/discovery/docs-discovery.mjs +57 -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 +23 -0
- package/foundation/discovery/project-typescript.mjs +61 -0
- package/foundation/discovery/prop-drift.d.mts +220 -0
- package/foundation/discovery/prop-drift.mjs +1765 -0
- package/foundation/discovery/prop-drift.test.mjs +1197 -0
- package/foundation/discovery/template-adapter.mjs +74 -5
- 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 +9 -1
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- package/foundation/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +10 -10
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Find the project's own TypeScript compiler.
|
|
5
|
+
*
|
|
6
|
+
* @input Directories to resolve `typescript` from, in order.
|
|
7
|
+
* @output The compiler module and its version; or, when the only TypeScript
|
|
8
|
+
* installed has no JavaScript compiler API to read types with, its version
|
|
9
|
+
* alone; or null when none is installed.
|
|
10
|
+
* @position Shared by the author checks that read source with the project's
|
|
11
|
+
* compiler, so each finds it, and says why it cannot use it, the same way.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import {createRequire} from 'node:module';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the project's own `typescript`, trying each directory in order.
|
|
19
|
+
* @param {Array<string | null | undefined>} dirs
|
|
20
|
+
* @returns {{ts: any, version: string} | {ts: null, version: string} | null}
|
|
21
|
+
* `ts: null` when a TypeScript is installed but has no `createProgram`
|
|
22
|
+
*/
|
|
23
|
+
export function resolveProjectTypeScript(dirs) {
|
|
24
|
+
/** @type {string | null} */
|
|
25
|
+
let unusable = null;
|
|
26
|
+
for (const dir of dirs) {
|
|
27
|
+
if (!dir) continue;
|
|
28
|
+
const require = createRequire(path.join(path.resolve(dir), 'package.json'));
|
|
29
|
+
/** The version of the `typescript` package installed here, or null. */
|
|
30
|
+
const installed = () => {
|
|
31
|
+
try {
|
|
32
|
+
const {version} = require('typescript/package.json');
|
|
33
|
+
return typeof version === 'string' && version !== '' ? version : null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
const ts = require('typescript');
|
|
40
|
+
if (ts && typeof ts.createProgram === 'function') {
|
|
41
|
+
return {ts, version: String(ts.version)};
|
|
42
|
+
}
|
|
43
|
+
unusable ??= installed();
|
|
44
|
+
} catch {
|
|
45
|
+
// Not installed from here, or installed without an entry this CLI can
|
|
46
|
+
// load; try the next directory.
|
|
47
|
+
unusable ??= installed();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return unusable ? {ts: null, version: unusable} : null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Why a check that needs the compiler did not run, when the TypeScript
|
|
55
|
+
* installed has no JavaScript compiler API.
|
|
56
|
+
* @param {string} version
|
|
57
|
+
* @param {string} outcome what was not done, such as `docs were not checked`
|
|
58
|
+
*/
|
|
59
|
+
export function unusableTypeScriptReason(version, outcome) {
|
|
60
|
+
return `TypeScript ${version} is installed in this project, but it has no JavaScript compiler API (\`createProgram\`) to read types with, so ${outcome}.`;
|
|
61
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
* Compare each documented prop table with the TypeScript props of the export
|
|
6
|
+
* it describes.
|
|
7
|
+
* @param {PropDriftTable[]} tables
|
|
8
|
+
* @param {{packageDir: string, resolveFrom: Array<string | null | undefined>}} options
|
|
9
|
+
* @returns {PropDriftReport}
|
|
10
|
+
*/
|
|
11
|
+
export function comparePropTables(tables: PropDriftTable[], options: {
|
|
12
|
+
packageDir: string;
|
|
13
|
+
resolveFrom: Array<string | null | undefined>;
|
|
14
|
+
}): PropDriftReport;
|
|
15
|
+
/**
|
|
16
|
+
* Compare documented props with each component's TypeScript props: find each
|
|
17
|
+
* doc's prop tables, then compare them (`comparePropTables`).
|
|
18
|
+
* @param {PropDriftComponent[]} components
|
|
19
|
+
* @param {{packageDir: string, resolveFrom: Array<string | null | undefined>, loadDoc?: (docPath: string) => Promise<any>}} options
|
|
20
|
+
* @returns {Promise<PropDriftReport>}
|
|
21
|
+
*/
|
|
22
|
+
export function comparePropDocs(components: PropDriftComponent[], options: {
|
|
23
|
+
packageDir: string;
|
|
24
|
+
resolveFrom: Array<string | null | undefined>;
|
|
25
|
+
loadDoc?: (docPath: string) => Promise<any>;
|
|
26
|
+
}): Promise<PropDriftReport>;
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {'not_in_code' | 'not_in_doc' | 'required_mismatch'} PropDriftKind
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {object} PropDriftFinding
|
|
32
|
+
* @property {string} component the documented component (export) name
|
|
33
|
+
* @property {string} prop
|
|
34
|
+
* @property {PropDriftKind} kind
|
|
35
|
+
* @property {'warning'} severity
|
|
36
|
+
* @property {string} message
|
|
37
|
+
* @property {string} doc the doc file, relative to the package root
|
|
38
|
+
* @property {string} source the source file, relative to the package root
|
|
39
|
+
* @property {string} [docType] the documented type, as written
|
|
40
|
+
* @property {string} [codeType] the type as the source declares it
|
|
41
|
+
* @property {boolean} [docRequired]
|
|
42
|
+
* @property {boolean} [codeRequired]
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {object} PropDriftUnchecked
|
|
46
|
+
* @property {string} component
|
|
47
|
+
* @property {string} doc the doc file, relative to the package root
|
|
48
|
+
* @property {string} reason why its props could not be read
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {object} PropDriftReport
|
|
52
|
+
* @property {'checked' | 'skipped'} status `skipped` means nothing was
|
|
53
|
+
* compared, and `reason` says why
|
|
54
|
+
* @property {string} [reason]
|
|
55
|
+
* @property {string} [typescript] the version of the compiler that read the props
|
|
56
|
+
* @property {number} components how many documented prop tables were compared
|
|
57
|
+
* @property {PropDriftFinding[]} findings
|
|
58
|
+
* @property {PropDriftUnchecked[]} unchecked documented components whose props
|
|
59
|
+
* could not be read from the source
|
|
60
|
+
* @property {Array<PropDriftUnchecked & {props: string[]}>} [propsNotChecked]
|
|
61
|
+
* props a mapped type builds from keys the check can't trace, which a doc
|
|
62
|
+
* leaving out draws no warning for
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {object} PropDriftTable
|
|
66
|
+
* @property {string} doc the doc file, relative to the package root
|
|
67
|
+
* @property {string} name the export the table documents
|
|
68
|
+
* @property {any[]} props the table's entries
|
|
69
|
+
* @property {string[]} sources the files that may hold the export, in order
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {object} PropDriftComponent
|
|
73
|
+
* @property {string} name
|
|
74
|
+
* @property {string} docPath absolute path to the component's `.doc.*` file
|
|
75
|
+
* @property {string | null} sourcePath absolute path to its same-stem
|
|
76
|
+
* source, or null when no file in the package declares it (a family member
|
|
77
|
+
* only another folder or built output defines)
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Props a doc never needs to list: the internal and styling props the
|
|
81
|
+
* `ComponentPropDoc` authoring guidance says to skip, `ref`, which Core's
|
|
82
|
+
* docs also leave out, and `key`, which React keeps for itself.
|
|
83
|
+
*/
|
|
84
|
+
export const PROPS_NOT_DOCUMENTED: readonly string[];
|
|
85
|
+
/** The line both surfaces print when the compiler is missing. */
|
|
86
|
+
export const TYPESCRIPT_MISSING_REASON: "TypeScript is not installed in this project, so documented props were not compared with the code. Install typescript and run this check again.";
|
|
87
|
+
export type CodeProp = {
|
|
88
|
+
name: string;
|
|
89
|
+
/**
|
|
90
|
+
* whether every caller must pass it: false
|
|
91
|
+
* when a member of the props type, an overload, or the package's
|
|
92
|
+
* `defaultProps` lets a caller leave it out
|
|
93
|
+
*/
|
|
94
|
+
required: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* declared in the package's own source, or built
|
|
97
|
+
* from keys it writes
|
|
98
|
+
*/
|
|
99
|
+
own: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* built from keys the check can't trace
|
|
102
|
+
*/
|
|
103
|
+
untraced?: boolean | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* its declaration carries an internal JSDoc tag
|
|
106
|
+
*/
|
|
107
|
+
skipTagged: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* the type as written, per own declaration
|
|
110
|
+
*/
|
|
111
|
+
declared: string[];
|
|
112
|
+
/**
|
|
113
|
+
* the compiler's renderings, computed on demand
|
|
114
|
+
*/
|
|
115
|
+
renderings: () => string[];
|
|
116
|
+
/**
|
|
117
|
+
* the prop's type in each member of the props type
|
|
118
|
+
*/
|
|
119
|
+
types: () => any[];
|
|
120
|
+
};
|
|
121
|
+
export type PropDriftKind = "not_in_code" | "not_in_doc" | "required_mismatch";
|
|
122
|
+
export type PropDriftFinding = {
|
|
123
|
+
/**
|
|
124
|
+
* the documented component (export) name
|
|
125
|
+
*/
|
|
126
|
+
component: string;
|
|
127
|
+
prop: string;
|
|
128
|
+
kind: PropDriftKind;
|
|
129
|
+
severity: "warning";
|
|
130
|
+
message: string;
|
|
131
|
+
/**
|
|
132
|
+
* the doc file, relative to the package root
|
|
133
|
+
*/
|
|
134
|
+
doc: string;
|
|
135
|
+
/**
|
|
136
|
+
* the source file, relative to the package root
|
|
137
|
+
*/
|
|
138
|
+
source: string;
|
|
139
|
+
/**
|
|
140
|
+
* the documented type, as written
|
|
141
|
+
*/
|
|
142
|
+
docType?: string | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* the type as the source declares it
|
|
145
|
+
*/
|
|
146
|
+
codeType?: string | undefined;
|
|
147
|
+
docRequired?: boolean | undefined;
|
|
148
|
+
codeRequired?: boolean | undefined;
|
|
149
|
+
};
|
|
150
|
+
export type PropDriftUnchecked = {
|
|
151
|
+
component: string;
|
|
152
|
+
/**
|
|
153
|
+
* the doc file, relative to the package root
|
|
154
|
+
*/
|
|
155
|
+
doc: string;
|
|
156
|
+
/**
|
|
157
|
+
* why its props could not be read
|
|
158
|
+
*/
|
|
159
|
+
reason: string;
|
|
160
|
+
};
|
|
161
|
+
export type PropDriftReport = {
|
|
162
|
+
/**
|
|
163
|
+
* `skipped` means nothing was
|
|
164
|
+
* compared, and `reason` says why
|
|
165
|
+
*/
|
|
166
|
+
status: "checked" | "skipped";
|
|
167
|
+
reason?: string | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* the version of the compiler that read the props
|
|
170
|
+
*/
|
|
171
|
+
typescript?: string | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* how many documented prop tables were compared
|
|
174
|
+
*/
|
|
175
|
+
components: number;
|
|
176
|
+
findings: PropDriftFinding[];
|
|
177
|
+
/**
|
|
178
|
+
* documented components whose props
|
|
179
|
+
* could not be read from the source
|
|
180
|
+
*/
|
|
181
|
+
unchecked: PropDriftUnchecked[];
|
|
182
|
+
/**
|
|
183
|
+
* props a mapped type builds from keys the check can't trace, which a doc
|
|
184
|
+
* leaving out draws no warning for
|
|
185
|
+
*/
|
|
186
|
+
propsNotChecked?: (PropDriftUnchecked & {
|
|
187
|
+
props: string[];
|
|
188
|
+
})[] | undefined;
|
|
189
|
+
};
|
|
190
|
+
export type PropDriftTable = {
|
|
191
|
+
/**
|
|
192
|
+
* the doc file, relative to the package root
|
|
193
|
+
*/
|
|
194
|
+
doc: string;
|
|
195
|
+
/**
|
|
196
|
+
* the export the table documents
|
|
197
|
+
*/
|
|
198
|
+
name: string;
|
|
199
|
+
/**
|
|
200
|
+
* the table's entries
|
|
201
|
+
*/
|
|
202
|
+
props: any[];
|
|
203
|
+
/**
|
|
204
|
+
* the files that may hold the export, in order
|
|
205
|
+
*/
|
|
206
|
+
sources: string[];
|
|
207
|
+
};
|
|
208
|
+
export type PropDriftComponent = {
|
|
209
|
+
name: string;
|
|
210
|
+
/**
|
|
211
|
+
* absolute path to the component's `.doc.*` file
|
|
212
|
+
*/
|
|
213
|
+
docPath: string;
|
|
214
|
+
/**
|
|
215
|
+
* absolute path to its same-stem
|
|
216
|
+
* source, or null when no file in the package declares it (a family member
|
|
217
|
+
* only another folder or built output defines)
|
|
218
|
+
*/
|
|
219
|
+
sourcePath: string | null;
|
|
220
|
+
};
|