@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.
Files changed (142) hide show
  1. package/README.md +7 -7
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +41 -1
  4. package/api/component/_adapter.mjs +93 -7
  5. package/api/component/component.mjs +22 -5
  6. package/api/component/component.test.mjs +420 -167
  7. package/api/component/integration-export-name.test.mjs +644 -0
  8. package/api/component/list/list.mjs +42 -4
  9. package/api/docs/_adapter.mjs +207 -1
  10. package/api/docs/integrationDocs.test.mjs +124 -0
  11. package/api/doctor/theme-checks.mjs +1 -1
  12. package/api/gap-report/gap-report.mjs +67 -4
  13. package/api/init/run/run.mjs +2 -2
  14. package/api/integration/_adapter.d.mts +12 -0
  15. package/api/integration/_adapter.mjs +54 -0
  16. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  17. package/api/integration/add-contribution.mjs +7 -3
  18. package/api/integration/authoring-checks.mjs +11 -2
  19. package/api/integration/authoring-checks.test.mjs +39 -0
  20. package/api/integration/authoring-checks.type.d.mts +9 -0
  21. package/api/integration/authoring-checks.type.mjs +14 -1
  22. package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
  23. package/api/integration/pack-check.mjs +61 -107
  24. package/api/integration/pack-check.test.mjs +359 -0
  25. package/api/integration/validate-integration.test.mjs +11 -0
  26. package/api/search/search.d.mts +9 -0
  27. package/api/search/search.mjs +108 -16
  28. package/api/search/search.test.mjs +36 -0
  29. package/api/swizzle/copy/copy.mjs +28 -14
  30. package/api/template/template.test.mjs +120 -3
  31. package/api/theme/build/build.family.test.mjs +16 -0
  32. package/api/theme/build/build.mjs +81 -22
  33. package/api/theme/themeBuild.doc.mjs +3 -3
  34. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  35. package/assets/codemods/transforms/next/index.mjs +11 -1
  36. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  37. package/assets/docs/README.md +10 -0
  38. package/assets/docs/author-a-theme.doc.mjs +1 -1
  39. package/assets/docs/getting-started.doc.mjs +3 -3
  40. package/assets/docs/theme.doc.dense.mjs +1 -1
  41. package/assets/docs/theme.doc.mjs +1 -1
  42. package/assets/docs/theme.doc.zh.mjs +1 -1
  43. package/assets/docs/tree/add-a-component.doc.mjs +10 -0
  44. package/assets/docs/tree/check-the-props.doc.mjs +145 -0
  45. package/assets/docs/tree/checks.doc.mjs +4 -4
  46. package/assets/docs/tree/component-family.doc.mjs +5 -1
  47. package/assets/docs/tree/component-imports.doc.mjs +8 -0
  48. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  49. package/assets/docs/tree/links.doc.mjs +2 -2
  50. package/assets/docs/tree/single-component.doc.mjs +3 -2
  51. package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
  52. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  53. package/assets/docs/tree/versioning.doc.mjs +1 -0
  54. package/assets/docs/tree/write-the-template-file.doc.mjs +2 -1
  55. package/assets/docs/use-a-theme.doc.mjs +2 -2
  56. package/assets/docs/working-with-ai.doc.mjs +43 -4
  57. package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
  58. package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
  59. package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
  60. package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
  61. package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
  62. package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
  63. package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
  64. package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
  65. package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
  66. package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
  67. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
  68. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
  69. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
  70. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
  71. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
  72. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
  73. package/assets/templates/pages/detail-page/page.tsx +3 -3
  74. package/assets/templates/pages/table-inbox/page.tsx +10 -8
  75. package/assets/theme.template.ts +1 -1
  76. package/authoring/doctypes/base/type.ts +6 -0
  77. package/authoring/doctypes/component/component.doc.mjs +4 -4
  78. package/authoring/doctypes/component/type.ts +6 -3
  79. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  80. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  81. package/authoring/doctypes/template/parse.d.mts +6 -2
  82. package/authoring/doctypes/template/parse.mjs +3 -1
  83. package/authoring/doctypes/template/type.ts +22 -0
  84. package/authoring/index.d.ts +1 -0
  85. package/authoring/integration/integration.doc.mjs +8 -1
  86. package/authoring/integration/parse.test.mjs +10 -0
  87. package/authoring/integration/schema.d.mts +2 -0
  88. package/authoring/integration/schema.mjs +1 -0
  89. package/authoring/integration/type.ts +4 -0
  90. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  91. package/clients/cli/commands/build-theme.mjs +1 -1
  92. package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
  93. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  94. package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
  95. package/clients/cli/commands/doctor-integration.test.mjs +392 -0
  96. package/clients/cli/commands/doctor.mjs +74 -0
  97. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  98. package/clients/cli/lib/component-format.mjs +5 -1
  99. package/foundation/config/project.mjs +82 -0
  100. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  101. package/foundation/discovery/component-discovery.d.mts +190 -10
  102. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  103. package/foundation/discovery/component-discovery.mjs +864 -56
  104. package/foundation/discovery/component-discovery.test.mjs +96 -0
  105. package/foundation/discovery/component-replacement.mjs +18 -0
  106. package/foundation/discovery/component-replacement.test.mjs +40 -0
  107. package/foundation/discovery/doc-types.d.mts +157 -0
  108. package/foundation/discovery/doc-types.mjs +1224 -0
  109. package/foundation/discovery/doc-types.test.mjs +652 -0
  110. package/foundation/discovery/docs-discovery.d.mts +81 -0
  111. package/foundation/discovery/docs-discovery.mjs +57 -0
  112. package/foundation/discovery/module-exports.d.mts +27 -0
  113. package/foundation/discovery/module-exports.mjs +356 -31
  114. package/foundation/discovery/module-exports.test.mjs +172 -0
  115. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  116. package/foundation/discovery/package-tsconfig.mjs +228 -0
  117. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  118. package/foundation/discovery/project-typescript.d.mts +23 -0
  119. package/foundation/discovery/project-typescript.mjs +61 -0
  120. package/foundation/discovery/prop-drift.d.mts +220 -0
  121. package/foundation/discovery/prop-drift.mjs +1765 -0
  122. package/foundation/discovery/prop-drift.test.mjs +1197 -0
  123. package/foundation/discovery/template-adapter.mjs +74 -5
  124. package/foundation/discovery/type-match.d.mts +53 -0
  125. package/foundation/discovery/type-match.mjs +660 -0
  126. package/foundation/discovery/type-match.test.mjs +169 -0
  127. package/foundation/discovery/type-text.d.mts +68 -0
  128. package/foundation/discovery/type-text.mjs +658 -0
  129. package/foundation/discovery/type-text.test.mjs +196 -0
  130. package/foundation/discovery/unresolved-references.d.mts +62 -0
  131. package/foundation/discovery/unresolved-references.mjs +790 -0
  132. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  133. package/foundation/doc-compiler/doc-loads.test.mjs +9 -1
  134. package/foundation/doc-compiler/inputs.mjs +23 -0
  135. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  136. package/foundation/doc-compiler/links.d.mts +9 -5
  137. package/foundation/doc-compiler/links.mjs +4 -2
  138. package/foundation/integrations/contribution-inventory.mjs +6 -1
  139. package/foundation/response/response-types.doc.mjs +1 -1
  140. package/foundation/xle/registry.mjs +4 -0
  141. package/foundation/xle/registry.test.mjs +28 -0
  142. 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
+ };