@astryxdesign/cli 0.7.3-canary.b74cf21 → 0.7.3-canary.ca48bb7
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 +68 -68
- package/api/build/blocks/blocks.d.mts +6 -4
- package/api/build/blocks/blocks.mjs +103 -20
- package/api/build/blocks/blocks.test.mjs +126 -13
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/kit/answer.d.mts +5 -4
- package/api/build/kit/answer.mjs +114 -12
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +8 -0
- package/api/build/kit/signals.mjs +10 -0
- package/api/build/tree.test.mjs +19 -11
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +17 -3
- package/api/component/component.test.mjs +15 -0
- package/api/component/doc-links.test.mjs +2 -2
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +61 -18
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.test.mjs +28 -18
- package/api/docs/integration-tree.test.mjs +20 -20
- package/api/docs/integrationDocs.test.mjs +1 -1
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +2 -2
- package/api/doctor/doctor.mjs +16 -12
- package/api/doctor/doctor.test.mjs +37 -12
- package/api/hook/hook.mjs +1 -1
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +21 -1
- package/api/integration/authoring-checks.test.mjs +220 -0
- package/api/integration/pack-check.mjs +110 -4
- package/api/integration/pack-check.test.mjs +69 -0
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +304 -1
- package/api/integration/validate-integration.d.mts +6 -1
- package/api/integration/validate-integration.mjs +82 -13
- package/api/integration/validate-integration.type.d.mts +37 -4
- package/api/integration/validate-integration.type.mjs +28 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.mjs +1 -1
- package/api/search/_entries.d.mts +11 -0
- package/api/search/_entries.mjs +77 -3
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/is-my-code-good.doc.mjs +287 -0
- 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 +2 -2
- package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
- package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +3 -3
- package/assets/docs/tree/cli-command.doc.mjs +1 -1
- package/assets/docs/tree/cli.doc.mjs +1 -1
- package/assets/docs/tree/codemods.doc.mjs +1 -1
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +1 -1
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/configuration.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +1 -1
- 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 +1 -1
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +2 -2
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +1 -1
- package/assets/docs/tree/start-a-template.doc.mjs +1 -1
- package/assets/docs/tree/subcomponent.doc.mjs +1 -1
- package/assets/docs/tree/template-assets.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-grading-rubric.doc.mjs +17 -38
- 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 +1 -1
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +5 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +2 -2
- package/clients/cli/commands/docs.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +14 -14
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/integration-check.test.mjs +48 -0
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/clients/cli/index.mjs +10 -85
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +56 -0
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +16 -4
- package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
- package/foundation/discovery/authoring-surface.d.mts +1 -1
- package/foundation/discovery/authoring-surface.mjs +2 -2
- package/foundation/discovery/authoring-surface.test.mjs +1 -1
- package/foundation/discovery/cli-self-docs.d.mts +2 -1
- package/foundation/discovery/cli-self-docs.mjs +4 -3
- package/foundation/discovery/cli-self-docs.test.mjs +2 -2
- package/foundation/discovery/runner-allowlist.d.mts +2 -4
- package/foundation/discovery/runner-allowlist.mjs +2 -4
- package/foundation/discovery/runner-commands.d.mts +77 -0
- package/foundation/discovery/runner-commands.mjs +294 -0
- package/foundation/discovery/runner-commands.test.mjs +128 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +18 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/discovery/theme-discovery.mjs +147 -3
- package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
- package/foundation/doc-compiler/read.mjs +59 -1
- package/foundation/doc-compiler/read.test.mjs +11 -2
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
- package/foundation/doc-compiler/tree.d.mts +32 -6
- package/foundation/doc-compiler/tree.mjs +77 -43
- package/foundation/doc-compiler/tree.test.mjs +7 -7
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- package/foundation/integrations/cli-peer-version.d.mts +36 -0
- package/foundation/integrations/cli-peer-version.mjs +132 -0
- package/foundation/integrations/cli-peer-version.test.mjs +354 -0
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/integrations.d.mts +20 -1
- package/foundation/integrations/integrations.mjs +59 -2
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- package/foundation/integrations/validate-contributions.d.mts +19 -0
- package/foundation/integrations/validate-contributions.mjs +172 -3
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -20,6 +20,14 @@ export function issueListed(code: string, message: string): Issue;
|
|
|
20
20
|
* @param {Issue} issue
|
|
21
21
|
*/
|
|
22
22
|
export function isListedIssue(issue: Issue): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The known manifest key `key` is a near miss of: a different letter case, or
|
|
25
|
+
* at most two letters added, dropped or changed (`component`, `doc`,
|
|
26
|
+
* `tempaltes`). Null when no known key is that close, or two are.
|
|
27
|
+
* @param {string} key
|
|
28
|
+
* @returns {string | null}
|
|
29
|
+
*/
|
|
30
|
+
export function nearestKnownKey(key: string): string | null;
|
|
23
31
|
/**
|
|
24
32
|
* Why a declared root cannot be read as a folder, or null when it can.
|
|
25
33
|
* A missing root keeps its own issue; a root that is a file or that the
|
|
@@ -98,6 +106,17 @@ export function componentDocNamesCheck(integration: LoadedIntegration): Promise<
|
|
|
98
106
|
};
|
|
99
107
|
notes: Note[];
|
|
100
108
|
}>;
|
|
109
|
+
/**
|
|
110
|
+
* The `name` a theme source passes to defineTheme for its exported theme,
|
|
111
|
+
* when the file says it as a string literal: `export const oceanTheme =
|
|
112
|
+
* defineTheme({name: 'ocean', ...})`. Null whenever only running the module
|
|
113
|
+
* could tell (a variable, a factory, a spread after the name, `extends`
|
|
114
|
+
* alone), so nothing is judged that a build would decide.
|
|
115
|
+
* @param {string} file
|
|
116
|
+
* @param {string} exportName
|
|
117
|
+
* @returns {string | null}
|
|
118
|
+
*/
|
|
119
|
+
export function literalThemeName(file: string, exportName: string): string | null;
|
|
101
120
|
/**
|
|
102
121
|
* Validate an already-LOADED integration (as produced by `loadIntegrations` —
|
|
103
122
|
* absolute contribution roots plus identity) and return its issues. This is the
|
|
@@ -26,6 +26,7 @@ import * as path from 'node:path';
|
|
|
26
26
|
import {parse as parseModule} from '@babel/parser';
|
|
27
27
|
import {isValidSemver} from '../env/semver.mjs';
|
|
28
28
|
import {findProjectCoreDir} from '../fs/paths.mjs';
|
|
29
|
+
import {KNOWN_INTEGRATION_KEYS} from '../../authoring/integration/schema.mjs';
|
|
29
30
|
import {
|
|
30
31
|
contributionFiles,
|
|
31
32
|
findSourceOnlyCandidates,
|
|
@@ -127,11 +128,36 @@ export function isListedIssue(issue) {
|
|
|
127
128
|
function checkUnknownKeys(integration, issues) {
|
|
128
129
|
const keys = integration.__unknownKeys ?? [];
|
|
129
130
|
if (keys.length === 0) return;
|
|
131
|
+
// A key one edit away from a known one is almost always a typo: say so
|
|
132
|
+
// first, since "a newer CLI" sends the author to upgrade for nothing.
|
|
133
|
+
const typos = keys
|
|
134
|
+
.map(key => ({key, known: nearestKnownKey(key)}))
|
|
135
|
+
.filter(each => each.known != null);
|
|
136
|
+
for (const {key, known} of typos) {
|
|
137
|
+
// The manifest object already declares the key it is a near miss of:
|
|
138
|
+
// renaming would give it twice, so the stray key goes. Read from what
|
|
139
|
+
// the manifest says, not the loaded integration, which fills some keys
|
|
140
|
+
// in (providerId from the package name).
|
|
141
|
+
const alreadySet = (integration.__declaredKeys ?? []).includes(
|
|
142
|
+
/** @type {string} */ (known),
|
|
143
|
+
);
|
|
144
|
+
const fix = alreadySet
|
|
145
|
+
? `Fix: remove "${key}" from ${manifestName(integration)}; it already sets "${known}".`
|
|
146
|
+
: `Fix: rename "${key}" to "${known}" in ${manifestName(integration)}.`;
|
|
147
|
+
issues.push(
|
|
148
|
+
issueWarning(
|
|
149
|
+
'unknown_manifest_key',
|
|
150
|
+
`This CLI does not know the manifest key "${key}", so it is ignored. Did you mean \`${known}\`? ${fix} If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.`,
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const rest = keys.filter(key => !typos.some(each => each.key === key));
|
|
155
|
+
if (rest.length === 0) return;
|
|
130
156
|
issues.push(
|
|
131
157
|
issueWarning(
|
|
132
158
|
'unknown_manifest_key',
|
|
133
|
-
`This CLI does not know the manifest ${
|
|
134
|
-
`${
|
|
159
|
+
`This CLI does not know the manifest ${rest.length === 1 ? 'key' : 'keys'} ` +
|
|
160
|
+
`${rest.map(key => `"${key}"`).join(', ')}, so ${rest.length === 1 ? 'it is' : 'they are'} ` +
|
|
135
161
|
`ignored — everything else in the manifest still applies. This usually ` +
|
|
136
162
|
`means the integration was published against a newer Astryx CLI than ` +
|
|
137
163
|
`this project resolves; upgrading @astryxdesign/cli picks it up.`,
|
|
@@ -146,6 +172,53 @@ function manifestName(integration) {
|
|
|
146
172
|
: 'the integration manifest';
|
|
147
173
|
}
|
|
148
174
|
|
|
175
|
+
/**
|
|
176
|
+
* The known manifest key `key` is a near miss of: a different letter case, or
|
|
177
|
+
* at most two letters added, dropped or changed (`component`, `doc`,
|
|
178
|
+
* `tempaltes`). Null when no known key is that close, or two are.
|
|
179
|
+
* @param {string} key
|
|
180
|
+
* @returns {string | null}
|
|
181
|
+
*/
|
|
182
|
+
export function nearestKnownKey(key) {
|
|
183
|
+
const lower = key.toLowerCase();
|
|
184
|
+
const limit = lower.length <= 4 ? 1 : 2;
|
|
185
|
+
/** @type {string[]} */
|
|
186
|
+
const close = [];
|
|
187
|
+
for (const known of KNOWN_INTEGRATION_KEYS) {
|
|
188
|
+
const distance = editDistance(lower, known.toLowerCase());
|
|
189
|
+
if (distance <= limit) close.push(known);
|
|
190
|
+
}
|
|
191
|
+
return close.length === 1 ? close[0] : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Levenshtein distance, with a swap of two neighbours counted as one edit.
|
|
196
|
+
* @param {string} a
|
|
197
|
+
* @param {string} b
|
|
198
|
+
*/
|
|
199
|
+
function editDistance(a, b) {
|
|
200
|
+
/** @type {number[][]} */
|
|
201
|
+
const d = Array.from({length: a.length + 1}, (_, i) =>
|
|
202
|
+
Array.from({length: b.length + 1}, (_, j) =>
|
|
203
|
+
i === 0 ? j : j === 0 ? i : 0,
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
for (let i = 1; i <= a.length; i++) {
|
|
207
|
+
for (let j = 1; j <= b.length; j++) {
|
|
208
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
209
|
+
d[i][j] = Math.min(
|
|
210
|
+
d[i - 1][j] + 1,
|
|
211
|
+
d[i][j - 1] + 1,
|
|
212
|
+
d[i - 1][j - 1] + cost,
|
|
213
|
+
);
|
|
214
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
215
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return d[a.length][b.length];
|
|
220
|
+
}
|
|
221
|
+
|
|
149
222
|
/**
|
|
150
223
|
* Why a declared root cannot be read as a folder, or null when it can.
|
|
151
224
|
* A missing root keeps its own issue; a root that is a file or that the
|
|
@@ -1005,13 +1078,20 @@ async function checkComponents(integration, issues) {
|
|
|
1005
1078
|
const docName = docPath
|
|
1006
1079
|
? path.basename(docPath)
|
|
1007
1080
|
: `${record.name}.doc.mjs`;
|
|
1081
|
+
let message = error.message;
|
|
1008
1082
|
let fix = `Fix: add ${record.name}.tsx beside ${docName}.`;
|
|
1009
1083
|
const stamp = docPath ? readContributionStamp(docPath, false) : null;
|
|
1010
1084
|
if (stamp && stamp.type !== 'component' && integration.__packageDir) {
|
|
1011
1085
|
context ??= createFixContext(integration.__packageDir, integration);
|
|
1012
1086
|
fix = notAComponentFix(context, docPath, stamp);
|
|
1087
|
+
} else {
|
|
1088
|
+
const other = docPath ? otherSourceFor(docPath) : null;
|
|
1089
|
+
if (other) {
|
|
1090
|
+
message = `${message.replace(/\.$/u, '')}: found ${other}, but a component source must be a .tsx file.`;
|
|
1091
|
+
fix = `Fix: rename ${other} to ${record.name}.tsx (and point its package export at the new file).`;
|
|
1092
|
+
}
|
|
1013
1093
|
}
|
|
1014
|
-
issues.push(issueError('invalid_component', `${
|
|
1094
|
+
issues.push(issueError('invalid_component', `${message} ${fix}`));
|
|
1015
1095
|
}
|
|
1016
1096
|
/** @type {Set<string>} sources a case-only rename is reported for */
|
|
1017
1097
|
const reportedSources = new Set();
|
|
@@ -1104,6 +1184,21 @@ function docStemOf(file) {
|
|
|
1104
1184
|
return suffix ? file.slice(0, -suffix.length) : file;
|
|
1105
1185
|
}
|
|
1106
1186
|
|
|
1187
|
+
/**
|
|
1188
|
+
* A same-stem source discovery does not read: `.jsx`, `.js`, `.ts` or `.mjs`.
|
|
1189
|
+
* @param {string} docPath
|
|
1190
|
+
* @returns {string | null} its file name
|
|
1191
|
+
*/
|
|
1192
|
+
function otherSourceFor(docPath) {
|
|
1193
|
+
const stem = docStemOf(path.basename(docPath));
|
|
1194
|
+
const dir = path.dirname(docPath);
|
|
1195
|
+
return (
|
|
1196
|
+
['.jsx', '.js', '.ts', '.mjs']
|
|
1197
|
+
.map(extension => `${stem}${extension}`)
|
|
1198
|
+
.find(file => fs.existsSync(path.join(dir, file))) ?? null
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1107
1202
|
/**
|
|
1108
1203
|
* The component docs under a root, read from the real directory listings:
|
|
1109
1204
|
* those beside a source whose name differs only in letter case (which an
|
|
@@ -1370,6 +1465,80 @@ async function checkThemes(integration, issues) {
|
|
|
1370
1465
|
}
|
|
1371
1466
|
}
|
|
1372
1467
|
|
|
1468
|
+
/**
|
|
1469
|
+
* The `name` a theme source passes to defineTheme for its exported theme,
|
|
1470
|
+
* when the file says it as a string literal: `export const oceanTheme =
|
|
1471
|
+
* defineTheme({name: 'ocean', ...})`. Null whenever only running the module
|
|
1472
|
+
* could tell (a variable, a factory, a spread after the name, `extends`
|
|
1473
|
+
* alone), so nothing is judged that a build would decide.
|
|
1474
|
+
* @param {string} file
|
|
1475
|
+
* @param {string} exportName
|
|
1476
|
+
* @returns {string | null}
|
|
1477
|
+
*/
|
|
1478
|
+
export function literalThemeName(file, exportName) {
|
|
1479
|
+
let ast;
|
|
1480
|
+
try {
|
|
1481
|
+
ast = parseModule(fs.readFileSync(file, 'utf8'), {
|
|
1482
|
+
sourceType: 'module',
|
|
1483
|
+
plugins: ['typescript', 'jsx'],
|
|
1484
|
+
errorRecovery: true,
|
|
1485
|
+
});
|
|
1486
|
+
} catch {
|
|
1487
|
+
return null;
|
|
1488
|
+
}
|
|
1489
|
+
/** @type {any} */
|
|
1490
|
+
let init = null;
|
|
1491
|
+
for (const node of ast.program.body) {
|
|
1492
|
+
const declaration =
|
|
1493
|
+
node.type === 'ExportNamedDeclaration' ? node.declaration : node;
|
|
1494
|
+
if (declaration?.type !== 'VariableDeclaration') continue;
|
|
1495
|
+
for (const declarator of declaration.declarations) {
|
|
1496
|
+
if (
|
|
1497
|
+
declarator.id.type === 'Identifier' &&
|
|
1498
|
+
declarator.id.name === exportName
|
|
1499
|
+
) {
|
|
1500
|
+
init = declarator.init;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
while (
|
|
1505
|
+
init?.type === 'TSAsExpression' ||
|
|
1506
|
+
init?.type === 'TSSatisfiesExpression'
|
|
1507
|
+
) {
|
|
1508
|
+
init = init.expression;
|
|
1509
|
+
}
|
|
1510
|
+
if (init?.type !== 'CallExpression') return null;
|
|
1511
|
+
const callee =
|
|
1512
|
+
init.callee.type === 'Identifier'
|
|
1513
|
+
? init.callee.name
|
|
1514
|
+
: init.callee.type === 'MemberExpression' &&
|
|
1515
|
+
init.callee.property.type === 'Identifier'
|
|
1516
|
+
? init.callee.property.name
|
|
1517
|
+
: null;
|
|
1518
|
+
if (callee !== 'defineTheme') return null;
|
|
1519
|
+
const [config] = init.arguments;
|
|
1520
|
+
if (config?.type !== 'ObjectExpression') return null;
|
|
1521
|
+
/** @type {string | null} */
|
|
1522
|
+
let name = null;
|
|
1523
|
+
for (const property of config.properties) {
|
|
1524
|
+
if (property.type === 'SpreadElement') {
|
|
1525
|
+
name = null;
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
1529
|
+
const key =
|
|
1530
|
+
property.key.type === 'Identifier'
|
|
1531
|
+
? property.key.name
|
|
1532
|
+
: property.key.type === 'StringLiteral'
|
|
1533
|
+
? property.key.value
|
|
1534
|
+
: null;
|
|
1535
|
+
if (key !== 'name') continue;
|
|
1536
|
+
name =
|
|
1537
|
+
property.value.type === 'StringLiteral' ? property.value.value : null;
|
|
1538
|
+
}
|
|
1539
|
+
return name;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1373
1542
|
/**
|
|
1374
1543
|
* A warning for each contribution file a reader reads (the docs and sources
|
|
1375
1544
|
* `integration verify` expects in the tarball) that the user running astryx
|
|
@@ -338,7 +338,7 @@ export const doc = {
|
|
|
338
338
|
{
|
|
339
339
|
value: 'integration.validate',
|
|
340
340
|
description:
|
|
341
|
-
'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message} information that fails nothing, such as invalid_cli_command for a malformed cliCommand, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed).',
|
|
341
|
+
'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message} information that fails nothing, such as invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. A runner_command note lists each Astryx command a topic writes with a package runner (its file, line and the bare command to write). When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on.',
|
|
342
342
|
},
|
|
343
343
|
{
|
|
344
344
|
value: 'integration.template-conflicts',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.3-canary.
|
|
3
|
+
"version": "0.7.3-canary.ca48bb7",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"zod": "^4.4.3"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@astryxdesign/charts": "0.7.3-canary.
|
|
110
|
-
"@astryxdesign/core": "0.7.3-canary.
|
|
111
|
-
"@astryxdesign/lab": "0.7.3-canary.
|
|
112
|
-
"@astryxdesign/theme-neutral": "0.7.3-canary.
|
|
109
|
+
"@astryxdesign/charts": "0.7.3-canary.ca48bb7",
|
|
110
|
+
"@astryxdesign/core": "0.7.3-canary.ca48bb7",
|
|
111
|
+
"@astryxdesign/lab": "0.7.3-canary.ca48bb7",
|
|
112
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.ca48bb7"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
115
115
|
"@astryxdesign/charts": {
|
|
@@ -126,10 +126,10 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@astryxdesign/charts": "0.7.3-canary.
|
|
130
|
-
"@astryxdesign/core": "0.7.3-canary.
|
|
131
|
-
"@astryxdesign/lab": "0.7.3-canary.
|
|
132
|
-
"@astryxdesign/theme-neutral": "0.7.3-canary.
|
|
129
|
+
"@astryxdesign/charts": "0.7.3-canary.ca48bb7",
|
|
130
|
+
"@astryxdesign/core": "0.7.3-canary.ca48bb7",
|
|
131
|
+
"@astryxdesign/lab": "0.7.3-canary.ca48bb7",
|
|
132
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.ca48bb7",
|
|
133
133
|
"@heroicons/react": "^2.2.0",
|
|
134
134
|
"@stylexjs/stylex": "^0.19.0",
|
|
135
135
|
"@types/babel__core": "^7.20.5",
|