@astryxdesign/cli 0.7.2 → 0.7.3-canary.b74cf21
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 +99 -66
- package/api/build/_adapter.d.mts +58 -0
- package/api/build/_adapter.mjs +115 -3
- package/api/build/blocks/blocks.d.mts +42 -0
- package/api/build/blocks/blocks.mjs +169 -0
- package/api/build/blocks/blocks.test.mjs +108 -0
- package/api/build/blocks/blocks.weights.json +1 -0
- package/api/build/build.mjs +25 -6
- package/api/build/kit/answer.d.mts +14 -0
- package/api/build/kit/answer.mjs +85 -0
- package/api/build/kit/answer.test.mjs +38 -0
- package/api/build/kit/kind.d.mts +25 -0
- package/api/build/kit/kind.mjs +170 -0
- package/api/build/kit/kit.d.mts +2 -4
- package/api/build/kit/kit.mjs +8 -398
- package/api/build/kit/rank.d.mts +3 -32
- package/api/build/kit/rank.mjs +25 -342
- package/api/build/kit/rank.test.mjs +2 -1
- package/api/build/kit/signals.d.mts +60 -0
- package/api/build/kit/signals.mjs +284 -0
- package/api/build/kit/start.d.mts +32 -0
- package/api/build/kit/start.mjs +163 -0
- package/api/build/kit/words.d.mts +72 -0
- package/api/build/kit/words.mjs +202 -0
- package/api/build/tree.d.mts +20 -0
- package/api/build/tree.mjs +52 -0
- package/api/build/tree.test.mjs +177 -0
- package/api/build/tree.weights.json +1 -0
- package/api/discover/_adapter.mjs +36 -9
- package/api/discover/_adapter.test.mjs +42 -0
- package/api/docs/_adapter.mjs +17 -5
- package/api/docs/docs.test.mjs +7 -1
- package/api/doctor/doctor.mjs +86 -12
- package/api/init/init.doc.mjs +20 -6
- package/api/init/init.test.mjs +18 -2
- package/api/init/init.type.d.mts +3 -3
- package/api/init/init.type.mjs +3 -3
- package/api/init/remove/remove.mjs +17 -4
- package/api/init/remove/remove.test.mjs +114 -2
- package/api/init/run/run.mjs +69 -6
- package/api/integration/authoring-checks.mjs +83 -9
- package/api/integration/pack-check.mjs +14 -1
- package/api/integration/pack-check.test.mjs +18 -0
- package/api/integration/validate-integration-case-disk.test.mjs +111 -0
- package/api/integration/validate-integration-gaps.test.mjs +1672 -0
- package/api/integration/validate-integration.d.mts +9 -1
- package/api/integration/validate-integration.mjs +216 -26
- package/api/integration/validate-integration.type.d.mts +57 -1
- package/api/integration/validate-integration.type.mjs +44 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/ORDERING.md +28 -0
- package/api/search/_adapter.d.mts +66 -2
- package/api/search/_adapter.mjs +118 -10
- package/api/search/_candidate-score.d.mts +40 -0
- package/api/search/_candidate-score.mjs +238 -0
- package/api/search/_cards.json +6098 -0
- package/api/search/_compound.d.mts +50 -0
- package/api/search/_compound.mjs +170 -0
- package/api/search/_doc-searcher.d.mts +4 -0
- package/api/search/_doc-searcher.mjs +23 -0
- package/api/search/_doc-searcher.test.mjs +36 -0
- package/api/search/_doc-searcher.weights.json +1 -0
- package/api/search/_doc-text.d.mts +30 -0
- package/api/search/_doc-text.mjs +87 -0
- package/api/search/_entries.d.mts +52 -0
- package/api/search/_entries.mjs +158 -0
- package/api/search/_features.d.mts +35 -0
- package/api/search/_features.mjs +155 -0
- package/api/search/_gather-components.d.mts +26 -0
- package/api/search/_gather-components.mjs +284 -0
- package/api/search/_gather-docs.d.mts +20 -0
- package/api/search/_gather-docs.mjs +254 -0
- package/api/search/_gather-hooks.d.mts +12 -0
- package/api/search/_gather-hooks.mjs +52 -0
- package/api/search/_gather-templates.d.mts +25 -0
- package/api/search/_gather-templates.mjs +107 -0
- package/api/search/_lexical.d.mts +135 -0
- package/api/search/_lexical.mjs +351 -0
- package/api/search/_main-searcher.d.mts +19 -0
- package/api/search/_main-searcher.mjs +115 -0
- package/api/search/_main-searcher.test.mjs +106 -0
- package/api/search/_main-searcher.weights.json +1 -0
- package/api/search/_module-doc.d.mts +32 -0
- package/api/search/_module-doc.mjs +78 -0
- package/api/search/_order.d.mts +32 -0
- package/api/search/_order.mjs +162 -0
- package/api/search/_order.test.mjs +72 -0
- package/api/search/_priority.d.mts +50 -0
- package/api/search/_priority.mjs +139 -0
- package/api/search/_query-words.d.mts +25 -0
- package/api/search/_query-words.mjs +92 -0
- package/api/search/_query.d.mts +65 -0
- package/api/search/_query.mjs +176 -0
- package/api/search/_result.d.mts +97 -0
- package/api/search/_result.mjs +150 -0
- package/api/search/_score.d.mts +60 -0
- package/api/search/_score.mjs +283 -0
- package/api/search/_synonyms.d.mts +21 -0
- package/api/search/_synonyms.mjs +67 -0
- package/api/search/_template-searcher.d.mts +4 -0
- package/api/search/_template-searcher.mjs +23 -0
- package/api/search/_template-searcher.test.mjs +40 -0
- package/api/search/_template-searcher.weights.json +1 -0
- package/api/search/_titles.d.mts +33 -0
- package/api/search/_titles.mjs +65 -0
- package/api/search/_words.d.mts +64 -0
- package/api/search/_words.mjs +157 -0
- package/api/search/search.d.mts +22 -305
- package/api/search/search.doc.mjs +7 -5
- package/api/search/search.mjs +53 -2483
- package/api/search/search.type.d.mts +6 -1
- package/api/search/search.type.mjs +6 -1
- package/api/search/tree.d.mts +15 -0
- package/api/search/tree.mjs +40 -0
- package/api/search/tree.test.mjs +66 -0
- package/api/search/tree.weights.json +1 -0
- package/api/theme/build/build.packed-old-core.test.mjs +1 -0
- package/api/upgrade/_adapter.d.mts +0 -6
- package/api/upgrade/_adapter.mjs +52 -4
- package/api/upgrade/upgrade.test.mjs +194 -0
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +11 -0
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +3 -3
- package/assets/docs/tree/api.doc.mjs +6 -0
- package/assets/docs/tree/host-entry.doc.mjs +128 -0
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +6 -2
- package/authoring/debug/parse.d.mts +1 -1
- package/clients/cli/bin/astryx.mjs +7 -78
- package/clients/cli/commands/doctor.mjs +30 -0
- package/clients/cli/commands/doctor.test.mjs +65 -0
- package/clients/cli/commands/init.behavior.test.mjs +230 -1
- package/clients/cli/commands/init.doc.mjs +28 -9
- package/clients/cli/commands/init.flag-help.test.mjs +1 -0
- package/clients/cli/commands/init.mjs +2 -2
- package/clients/cli/commands/outside-project.test.mjs +2 -1
- package/clients/cli/commands/setup-nudge.test.mjs +61 -0
- package/clients/cli/index.mjs +19 -1
- package/clients/cli/run.mjs +108 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +20 -7
- package/foundation/agent-docs/agent-doc-state.mjs +35 -8
- package/foundation/agent-docs/agent-docs.d.mts +100 -12
- package/foundation/agent-docs/agent-docs.mjs +1010 -99
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +1239 -17
- package/foundation/agent-docs/agent-docs.test.mjs +678 -35
- package/foundation/config/project.mjs +15 -2
- package/foundation/discovery/component-discovery.d.mts +37 -0
- package/foundation/discovery/component-discovery.mjs +80 -5
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/docs-discovery.mjs +14 -1
- package/foundation/discovery/module-exports.d.mts +41 -0
- package/foundation/discovery/module-exports.mjs +253 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +8 -0
- package/foundation/fs/paths.mjs +30 -3
- package/foundation/integrations/computer-integrations.d.mts +6 -3
- package/foundation/integrations/computer-integrations.mjs +38 -9
- package/foundation/integrations/contribution-inventory.d.mts +15 -20
- package/foundation/integrations/contribution-inventory.mjs +41 -5
- package/foundation/integrations/integrations.d.mts +7 -0
- package/foundation/integrations/integrations.mjs +2 -0
- package/foundation/integrations/validate-contributions.d.mts +96 -0
- package/foundation/integrations/validate-contributions.mjs +996 -10
- package/foundation/release/handoff.d.mts +23 -4
- package/foundation/release/handoff.mjs +175 -8
- package/foundation/release/run-context.mjs +14 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/route/route.d.mts +285 -0
- package/foundation/route/route.mjs +324 -0
- package/foundation/route/route.test.mjs +153 -0
- package/foundation/runtime/hosted-runtime.test.mjs +403 -0
- package/foundation/runtime/locked-versions.d.mts +32 -0
- package/foundation/runtime/locked-versions.mjs +65 -0
- package/foundation/runtime/package-root.d.mts +91 -0
- package/foundation/runtime/package-root.mjs +174 -0
- package/foundation/runtime/package-set.d.mts +62 -0
- package/foundation/runtime/package-set.mjs +130 -0
- package/foundation/runtime/package-set.test.mjs +432 -0
- package/host/door-conformance.test.mjs +274 -0
- package/host/index.d.ts +116 -0
- package/host/index.mjs +295 -0
- package/host/index.test.mjs +302 -0
- package/package.json +14 -9
|
@@ -23,8 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
import * as fs from 'node:fs';
|
|
25
25
|
import * as path from 'node:path';
|
|
26
|
+
import {parse as parseModule} from '@babel/parser';
|
|
26
27
|
import {isValidSemver} from '../env/semver.mjs';
|
|
28
|
+
import {findProjectCoreDir} from '../fs/paths.mjs';
|
|
27
29
|
import {
|
|
30
|
+
contributionFiles,
|
|
28
31
|
findSourceOnlyCandidates,
|
|
29
32
|
findTemplateSourceOnlyCandidates,
|
|
30
33
|
} from './contribution-inventory.mjs';
|
|
@@ -48,6 +51,12 @@ import {MANIFEST_BASENAMES} from './integrations.mjs';
|
|
|
48
51
|
import {discoverIntegrationCodemods} from '../../assets/codemods/integration-discovery.mjs';
|
|
49
52
|
import {discoverIntegrationTemplatesForOne} from '../discovery/template-adapter.mjs';
|
|
50
53
|
import * as componentDiscovery from '../discovery/component-discovery.mjs';
|
|
54
|
+
import {loadComponentDoc} from '../discovery/component-loader.mjs';
|
|
55
|
+
import {
|
|
56
|
+
moduleExportNames,
|
|
57
|
+
moduleExportsName,
|
|
58
|
+
moduleExportVerdict,
|
|
59
|
+
} from '../discovery/module-exports.mjs';
|
|
51
60
|
import {discoverIntegrationDocs} from '../discovery/docs-discovery.mjs';
|
|
52
61
|
import {discoverIntegrationThemes} from '../discovery/theme-discovery.mjs';
|
|
53
62
|
|
|
@@ -75,6 +84,32 @@ export function issueWarning(code, message) {
|
|
|
75
84
|
return {code, severity: 'warning', message};
|
|
76
85
|
}
|
|
77
86
|
|
|
87
|
+
/** Issues `issueListed` made: listed in validate's `layout` report only. */
|
|
88
|
+
const LISTED = new WeakSet();
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A layout finding added after the last minor release: validate lists it, in
|
|
92
|
+
* its `layout` report, but it is never an issue, so nothing counts it and
|
|
93
|
+
* `integration check --strict` does not fail on it. A new failing finding
|
|
94
|
+
* joins only in a minor release (architecture:cli-surface INV35).
|
|
95
|
+
* @param {string} code
|
|
96
|
+
* @param {string} message
|
|
97
|
+
* @returns {Issue}
|
|
98
|
+
*/
|
|
99
|
+
export function issueListed(code, message) {
|
|
100
|
+
const issue = issueWarning(code, message);
|
|
101
|
+
LISTED.add(issue);
|
|
102
|
+
return issue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Whether `issueListed` made this issue.
|
|
107
|
+
* @param {Issue} issue
|
|
108
|
+
*/
|
|
109
|
+
export function isListedIssue(issue) {
|
|
110
|
+
return LISTED.has(issue);
|
|
111
|
+
}
|
|
112
|
+
|
|
78
113
|
/**
|
|
79
114
|
* Report the manifest keys this CLI does not know.
|
|
80
115
|
*
|
|
@@ -104,6 +139,13 @@ function checkUnknownKeys(integration, issues) {
|
|
|
104
139
|
);
|
|
105
140
|
}
|
|
106
141
|
|
|
142
|
+
/** @param {{__manifestFile?: string}} integration */
|
|
143
|
+
function manifestName(integration) {
|
|
144
|
+
return integration.__manifestFile
|
|
145
|
+
? path.basename(integration.__manifestFile)
|
|
146
|
+
: 'the integration manifest';
|
|
147
|
+
}
|
|
148
|
+
|
|
107
149
|
/**
|
|
108
150
|
* Why a declared root cannot be read as a folder, or null when it can.
|
|
109
151
|
* A missing root keeps its own issue; a root that is a file or that the
|
|
@@ -139,11 +181,14 @@ export function rootProblem(root) {
|
|
|
139
181
|
* declared-but-missing root is a `missing_root` error, a file is an
|
|
140
182
|
* `invalid_root` error, and a folder that cannot be read is an
|
|
141
183
|
* `unreadable_root` error. The contribution checks skip all three.
|
|
142
|
-
*
|
|
184
|
+
* A readable root reached through a symlinked folder is a `symlinked_root`
|
|
185
|
+
* warning: npm pack does not follow it, so the published package loses it.
|
|
186
|
+
* @param {{components?: string, templates?: string, codemods?: string, docs?: string, themes?: string, __manifestFile?: string}} resolved
|
|
143
187
|
* absolute resolved roots (undefined when not declared)
|
|
144
188
|
* @param {Issue[]} issues
|
|
189
|
+
* @param {string} [packageDir] the package the roots belong to
|
|
145
190
|
*/
|
|
146
|
-
function checkRoots(resolved, issues) {
|
|
191
|
+
function checkRoots(resolved, issues, packageDir) {
|
|
147
192
|
const kinds = /** @type {const} */ ([
|
|
148
193
|
'components',
|
|
149
194
|
'templates',
|
|
@@ -155,7 +200,28 @@ function checkRoots(resolved, issues) {
|
|
|
155
200
|
const root = resolved[kind];
|
|
156
201
|
if (root == null) continue;
|
|
157
202
|
const problem = rootProblem(root);
|
|
158
|
-
if (problem == null)
|
|
203
|
+
if (problem == null) {
|
|
204
|
+
const link = packageDir ? symlinkedFolder(root, packageDir) : null;
|
|
205
|
+
if (link && packageDir) {
|
|
206
|
+
const shown = slash(path.relative(packageDir, link.path));
|
|
207
|
+
const realPackage = fs.realpathSync(packageDir);
|
|
208
|
+
const target = slash(path.relative(realPackage, link.target));
|
|
209
|
+
const realRoot = slash(
|
|
210
|
+
path.relative(realPackage, fs.realpathSync(root)),
|
|
211
|
+
);
|
|
212
|
+
const outside = target.startsWith('../') || path.isAbsolute(target);
|
|
213
|
+
const fix = outside
|
|
214
|
+
? 'replace the link with a real folder holding its files'
|
|
215
|
+
: `replace the link with the folder itself (move ${target}/ to ${shown}/), or set \`${kind}: './${realRoot}'\` in ${manifestName(resolved)}`;
|
|
216
|
+
issues.push(
|
|
217
|
+
issueListed(
|
|
218
|
+
'symlinked_root',
|
|
219
|
+
`Declared ${kind} root "${slash(path.relative(packageDir, root))}" is reached through the symlink "${shown}" (to "${target}"). Astryx follows it locally, but npm pack does not follow a symlinked folder, so the published package ships none of these files. Fix: ${fix}.`,
|
|
220
|
+
),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
159
225
|
if (problem.kind === 'missing') {
|
|
160
226
|
issues.push(
|
|
161
227
|
issueError(
|
|
@@ -181,6 +247,41 @@ function checkRoots(resolved, issues) {
|
|
|
181
247
|
}
|
|
182
248
|
}
|
|
183
249
|
|
|
250
|
+
/** @param {string} file */
|
|
251
|
+
function slash(file) {
|
|
252
|
+
return file.split(path.sep).join('/');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The first folder on the way from the package to `root` (the root itself
|
|
257
|
+
* included) that is a symlink, with where it points, or null.
|
|
258
|
+
* @param {string} root absolute
|
|
259
|
+
* @param {string} packageDir absolute
|
|
260
|
+
* @returns {{path: string, target: string} | null}
|
|
261
|
+
*/
|
|
262
|
+
export function symlinkedFolder(root, packageDir) {
|
|
263
|
+
const relative = path.relative(packageDir, root);
|
|
264
|
+
if (
|
|
265
|
+
relative === '' ||
|
|
266
|
+
relative.startsWith('..') ||
|
|
267
|
+
path.isAbsolute(relative)
|
|
268
|
+
) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
let current = packageDir;
|
|
272
|
+
for (const segment of relative.split(path.sep)) {
|
|
273
|
+
current = path.join(current, segment);
|
|
274
|
+
try {
|
|
275
|
+
if (fs.lstatSync(current).isSymbolicLink()) {
|
|
276
|
+
return {path: current, target: fs.realpathSync(current)};
|
|
277
|
+
}
|
|
278
|
+
} catch {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
184
285
|
/**
|
|
185
286
|
* Validate the integration's codemods via the landed discovery. Discovery is
|
|
186
287
|
* strict (throws on bad export / duplicate id); we convert any throw into an
|
|
@@ -304,6 +405,551 @@ async function checkTemplates(integration, issues) {
|
|
|
304
405
|
checkTemplateSourcesWithoutDoc(integration, issues);
|
|
305
406
|
}
|
|
306
407
|
|
|
408
|
+
/**
|
|
409
|
+
* The component names each of a package's templates gives in `exampleFor`
|
|
410
|
+
* and `componentsUsed`, judged against the components `astryx component`
|
|
411
|
+
* finds: the package's own, and every doc it resolves in Core. A name the
|
|
412
|
+
* template imports needs no doc of its own. A name neither has is an
|
|
413
|
+
* `unknown_block_component` finding, since the template list and the
|
|
414
|
+
* block's search keywords then give a name no one can look up. A name the
|
|
415
|
+
* template may reach through anything the walk does not model, and, without
|
|
416
|
+
* Core installed, a name the package does not have, cannot be judged and is
|
|
417
|
+
* listed in `unchecked` instead.
|
|
418
|
+
* @param {LoadedIntegration} integration
|
|
419
|
+
* @returns {Promise<{findings: Array<{docPath: string, name: string, message: string}>, unchecked: Array<{docPath: string, name: string, reason: string}>}>}
|
|
420
|
+
*/
|
|
421
|
+
async function judgeBlockComponents(integration) {
|
|
422
|
+
/** @type {Array<{docPath: string, name: string, message: string}>} */
|
|
423
|
+
const findings = [];
|
|
424
|
+
/** @type {Array<{docPath: string, name: string, reason: string}>} */
|
|
425
|
+
const unchecked = [];
|
|
426
|
+
const root = integration.templates;
|
|
427
|
+
if (!root || rootProblem(root)) return {findings, unchecked};
|
|
428
|
+
let templates;
|
|
429
|
+
try {
|
|
430
|
+
({templates} = await discoverIntegrationTemplatesForOne(integration));
|
|
431
|
+
} catch {
|
|
432
|
+
return {findings, unchecked};
|
|
433
|
+
}
|
|
434
|
+
/** @type {Set<string>} */
|
|
435
|
+
let own;
|
|
436
|
+
try {
|
|
437
|
+
own = new Set(
|
|
438
|
+
componentDiscovery
|
|
439
|
+
.discoverIntegrationComponents(integration)
|
|
440
|
+
.map(record => record.name),
|
|
441
|
+
);
|
|
442
|
+
} catch {
|
|
443
|
+
return {findings, unchecked};
|
|
444
|
+
}
|
|
445
|
+
// The Core installed beside the package, never the one the CLI carries:
|
|
446
|
+
// a name is judged against the Core the package's users install.
|
|
447
|
+
const coreDir = findProjectCoreDir(integration.__packageDir ?? root);
|
|
448
|
+
/** @type {Map<string, boolean>} */
|
|
449
|
+
const inCore = new Map();
|
|
450
|
+
/** @param {string} name */
|
|
451
|
+
const coreHas = name => {
|
|
452
|
+
if (!coreDir) return false;
|
|
453
|
+
if (!inCore.has(name)) {
|
|
454
|
+
let found;
|
|
455
|
+
try {
|
|
456
|
+
found = componentDiscovery.findComponentReadme(coreDir, name) != null;
|
|
457
|
+
} catch {
|
|
458
|
+
found = false;
|
|
459
|
+
}
|
|
460
|
+
inCore.set(name, found);
|
|
461
|
+
}
|
|
462
|
+
return /** @type {boolean} */ (inCore.get(name));
|
|
463
|
+
};
|
|
464
|
+
for (const template of templates) {
|
|
465
|
+
const fields = [
|
|
466
|
+
...(typeof template.exampleFor === 'string'
|
|
467
|
+
? [{field: 'exampleFor', name: template.exampleFor}]
|
|
468
|
+
: []),
|
|
469
|
+
...(Array.isArray(template.componentsUsed) ? template.componentsUsed : [])
|
|
470
|
+
.filter(name => typeof name === 'string')
|
|
471
|
+
.map(name => ({field: 'componentsUsed', name})),
|
|
472
|
+
];
|
|
473
|
+
if (fields.length === 0) continue;
|
|
474
|
+
const imported = importedNames(template.filePath, integration);
|
|
475
|
+
for (const {field, name} of fields) {
|
|
476
|
+
if (own.has(name) || imported.names.has(name)) continue;
|
|
477
|
+
if (coreHas(name)) continue;
|
|
478
|
+
// A name the template may reach through a namespace import, or
|
|
479
|
+
// through a local module this read could not follow, is not judged.
|
|
480
|
+
if (imported.unread.length > 0) {
|
|
481
|
+
unchecked.push({
|
|
482
|
+
docPath: template.docPath,
|
|
483
|
+
name,
|
|
484
|
+
reason: imported.unread[0],
|
|
485
|
+
});
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (!coreDir) {
|
|
489
|
+
unchecked.push({
|
|
490
|
+
docPath: template.docPath,
|
|
491
|
+
name,
|
|
492
|
+
reason:
|
|
493
|
+
'Core is not installed, so its component names cannot be checked.',
|
|
494
|
+
});
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
findings.push({
|
|
498
|
+
docPath: template.docPath,
|
|
499
|
+
name,
|
|
500
|
+
message: `Template "${template.dirName}" names "${name}" in ${field}, but neither this package nor Core has a component by that name and the template does not import it, so \`astryx template --list\` and the block's search keywords give a component name no one can look up. Fix: use the component's exact name, or remove "${name}" from ${field}.`,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return {findings, unchecked};
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Visit every node under `node`, depth first.
|
|
509
|
+
* @param {any} node
|
|
510
|
+
* @param {(node: any) => void} visit
|
|
511
|
+
*/
|
|
512
|
+
function walkNodes(node, visit) {
|
|
513
|
+
if (node == null || typeof node !== 'object') return;
|
|
514
|
+
if (Array.isArray(node)) {
|
|
515
|
+
for (const each of node) walkNodes(each, visit);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (typeof node.type === 'string') visit(node);
|
|
519
|
+
for (const [key, value] of Object.entries(node)) {
|
|
520
|
+
if (
|
|
521
|
+
key === 'loc' ||
|
|
522
|
+
key === 'start' ||
|
|
523
|
+
key === 'end' ||
|
|
524
|
+
key === 'extra' ||
|
|
525
|
+
key === 'leadingComments' ||
|
|
526
|
+
key === 'trailingComments'
|
|
527
|
+
) {
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
if (value && typeof value === 'object') walkNodes(value, visit);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/** The extensions a local import may leave off, in the order tried. */
|
|
535
|
+
const LOCAL_MODULE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs'];
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Libraries that render no component of this package or of Core: React's
|
|
539
|
+
* own exports and StyleX. Importing them, even as a namespace
|
|
540
|
+
* (`import * as stylex`), leaves no name unjudged.
|
|
541
|
+
*/
|
|
542
|
+
const RENDERLESS_SOURCES = ['react', 'react-dom', '@stylexjs/stylex'];
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Packages a template may import from without leaving its names unjudged:
|
|
546
|
+
* Core and the renderless libraries. Any other package may render components
|
|
547
|
+
* this check does not see, such as a grid that renders its cards.
|
|
548
|
+
*/
|
|
549
|
+
const KNOWN_SOURCES = ['@astryxdesign/core', ...RENDERLESS_SOURCES];
|
|
550
|
+
|
|
551
|
+
/** @param {string} source */
|
|
552
|
+
function renderlessSource(source) {
|
|
553
|
+
return RENDERLESS_SOURCES.some(
|
|
554
|
+
known => source === known || source.startsWith(`${known}/`),
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Whether an import source is one whose components this check sees: Core, a
|
|
560
|
+
* library that renders none, or a relative helper (followed and read in full
|
|
561
|
+
* on its own). The package's own name is followed like a helper too.
|
|
562
|
+
* @param {string} source
|
|
563
|
+
*/
|
|
564
|
+
function knownSource(source) {
|
|
565
|
+
if (source.startsWith('.')) return true;
|
|
566
|
+
return KNOWN_SOURCES.some(
|
|
567
|
+
known => source === known || source.startsWith(`${known}/`),
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Every name a template imports, as imported and as bound locally, read
|
|
573
|
+
* without running it, with the names its local helper modules import (a
|
|
574
|
+
* relative import or re-export is followed, so a barrel such as
|
|
575
|
+
* `parts/index.ts` counts). A name is judged only where the template reaches
|
|
576
|
+
* components solely through named imports and re-exports this walk reads:
|
|
577
|
+
* `unread` gives the reason for anything else it meets, which leaves an
|
|
578
|
+
* unresolved name unjudged. That covers a default or namespace import, an
|
|
579
|
+
* alias of an imported binding, a member read off one (in JSX or not,
|
|
580
|
+
* optional or computed), a rendered component it cannot trace to an import,
|
|
581
|
+
* `require()`, a dynamic `import()`, an `export *` from another package, and
|
|
582
|
+
* a local module it cannot read. So does any `default` binding (`import X`,
|
|
583
|
+
* `{default as X}`, `export {default as X} from`) and any import from a
|
|
584
|
+
* package other than Core or a library that renders no component (see
|
|
585
|
+
* KNOWN_SOURCES). An import of the package's own name is followed like a
|
|
586
|
+
* relative helper, through its package.json `exports`. Type-only imports
|
|
587
|
+
* render nothing and are skipped, as is a namespace or default import of a
|
|
588
|
+
* library that renders no component.
|
|
589
|
+
* @param {string} file
|
|
590
|
+
* @param {LoadedIntegration} integration
|
|
591
|
+
* @returns {{names: Set<string>, unread: string[]}}
|
|
592
|
+
*/
|
|
593
|
+
function importedNames(file, integration) {
|
|
594
|
+
const packageName = integration.name;
|
|
595
|
+
/** @type {Set<string>} */
|
|
596
|
+
const names = new Set();
|
|
597
|
+
/** @type {string[]} */
|
|
598
|
+
const unread = [];
|
|
599
|
+
const top = path.dirname(file);
|
|
600
|
+
const shownTop = path.basename(file);
|
|
601
|
+
/** @type {Set<string>} */
|
|
602
|
+
const seen = new Set();
|
|
603
|
+
/** @param {string} current */
|
|
604
|
+
const visit = current => {
|
|
605
|
+
if (seen.has(current)) return;
|
|
606
|
+
seen.add(current);
|
|
607
|
+
const shown = slash(path.relative(top, current)) || shownTop;
|
|
608
|
+
let ast;
|
|
609
|
+
try {
|
|
610
|
+
ast = parseModule(fs.readFileSync(current, 'utf8'), {
|
|
611
|
+
sourceType: 'module',
|
|
612
|
+
plugins: ['typescript', 'jsx'],
|
|
613
|
+
errorRecovery: true,
|
|
614
|
+
});
|
|
615
|
+
} catch {
|
|
616
|
+
unread.push(
|
|
617
|
+
`${shown} could not be read, so the components it renders are not known.`,
|
|
618
|
+
);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
// A file that parses only with errors recovered may be missing parts.
|
|
622
|
+
if (/** @type {any} */ (ast).errors?.length > 0) {
|
|
623
|
+
unread.push(
|
|
624
|
+
`${shown} does not parse cleanly, so the components it renders are not known.`,
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
/** @type {Map<string, string>} local binding -> the module it came from */
|
|
628
|
+
const bindings = new Map();
|
|
629
|
+
for (const node of ast.program.body) {
|
|
630
|
+
const reexport =
|
|
631
|
+
(node.type === 'ExportNamedDeclaration' && node.source != null) ||
|
|
632
|
+
node.type === 'ExportAllDeclaration';
|
|
633
|
+
if (node.type !== 'ImportDeclaration' && !reexport) continue;
|
|
634
|
+
// A type-only import or re-export renders nothing.
|
|
635
|
+
if (
|
|
636
|
+
/** @type {any} */ (node).importKind === 'type' ||
|
|
637
|
+
/** @type {any} */ (node).exportKind === 'type'
|
|
638
|
+
) {
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
const source = String(/** @type {any} */ (node).source.value);
|
|
642
|
+
// The package's own name: read like a relative helper, below.
|
|
643
|
+
const own =
|
|
644
|
+
typeof packageName === 'string' &&
|
|
645
|
+
packageName !== '' &&
|
|
646
|
+
(source === packageName || source.startsWith(`${packageName}/`));
|
|
647
|
+
if (!own && !knownSource(source)) {
|
|
648
|
+
unread.push(
|
|
649
|
+
`${shown} imports from "${source}", another package whose components may render ones this check does not see.`,
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
if (node.type === 'ImportDeclaration') {
|
|
653
|
+
for (const specifier of node.specifiers) {
|
|
654
|
+
if (/** @type {any} */ (specifier).importKind === 'type') continue;
|
|
655
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
656
|
+
// `import * as stylex`: a library that renders no component.
|
|
657
|
+
if (renderlessSource(source)) continue;
|
|
658
|
+
unread.push(
|
|
659
|
+
`${shown} imports "${source}" as a namespace (${specifier.local.name}), whose component names this check does not read.`,
|
|
660
|
+
);
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (
|
|
664
|
+
specifier.type === 'ImportDefaultSpecifier' &&
|
|
665
|
+
!renderlessSource(source)
|
|
666
|
+
) {
|
|
667
|
+
// A default may be any component, under any name.
|
|
668
|
+
unread.push(
|
|
669
|
+
`${shown} imports the default of "${source}" as ${specifier.local.name}, which may be any component.`,
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
names.add(specifier.local.name);
|
|
673
|
+
bindings.set(specifier.local.name, source);
|
|
674
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
675
|
+
const imported = specifier.imported;
|
|
676
|
+
const importedName =
|
|
677
|
+
imported.type === 'Identifier' ? imported.name : imported.value;
|
|
678
|
+
if (importedName === 'default') {
|
|
679
|
+
unread.push(
|
|
680
|
+
`${shown} imports the default of "${source}" as ${specifier.local.name}, which may be any component.`,
|
|
681
|
+
);
|
|
682
|
+
} else {
|
|
683
|
+
names.add(importedName);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
} else if (node.type === 'ExportNamedDeclaration') {
|
|
688
|
+
// A barrel: `export {Body} from './Body'` passes Body on, and what
|
|
689
|
+
// Body renders comes from the module it names.
|
|
690
|
+
for (const each of node.specifiers) {
|
|
691
|
+
const specifier = /** @type {any} */ (each);
|
|
692
|
+
if (specifier.exportKind === 'type') continue;
|
|
693
|
+
if (specifier.type !== 'ExportSpecifier') {
|
|
694
|
+
// `export * as UI from`, `export UI from`.
|
|
695
|
+
unread.push(
|
|
696
|
+
`${shown} re-exports "${source}" as a whole (${specifier.exported.type === 'Identifier' ? specifier.exported.name : specifier.exported.value}), whose component names this check does not read.`,
|
|
697
|
+
);
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
const local =
|
|
701
|
+
specifier.local.type === 'Identifier'
|
|
702
|
+
? specifier.local.name
|
|
703
|
+
: specifier.local.value;
|
|
704
|
+
const exported =
|
|
705
|
+
specifier.exported.type === 'Identifier'
|
|
706
|
+
? specifier.exported.name
|
|
707
|
+
: specifier.exported.value;
|
|
708
|
+
if (local === 'default') {
|
|
709
|
+
unread.push(
|
|
710
|
+
`${shown} re-exports the default of "${source}" as ${exported}, which may be any component.`,
|
|
711
|
+
);
|
|
712
|
+
} else {
|
|
713
|
+
names.add(local);
|
|
714
|
+
}
|
|
715
|
+
names.add(exported);
|
|
716
|
+
}
|
|
717
|
+
} else if (!source.startsWith('.') && !own) {
|
|
718
|
+
// `export * from` another package passes on names this check
|
|
719
|
+
// does not list.
|
|
720
|
+
unread.push(
|
|
721
|
+
`${shown} re-exports everything from "${source}", whose component names this check does not read.`,
|
|
722
|
+
);
|
|
723
|
+
continue;
|
|
724
|
+
} else if (/** @type {any} */ (node).exported) {
|
|
725
|
+
// `export * as UI from './parts'`.
|
|
726
|
+
unread.push(
|
|
727
|
+
`${shown} re-exports "${source}" as a whole, whose component names this check does not read.`,
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
if (!source.startsWith('.') && !own) continue;
|
|
731
|
+
if (own) {
|
|
732
|
+
const resolved = componentDiscovery.ownPackageModule(
|
|
733
|
+
integration,
|
|
734
|
+
source,
|
|
735
|
+
);
|
|
736
|
+
/** @type {boolean} */
|
|
737
|
+
let isFile;
|
|
738
|
+
try {
|
|
739
|
+
isFile = resolved != null && fs.statSync(resolved).isFile();
|
|
740
|
+
} catch {
|
|
741
|
+
isFile = false;
|
|
742
|
+
}
|
|
743
|
+
if (
|
|
744
|
+
resolved &&
|
|
745
|
+
isFile &&
|
|
746
|
+
LOCAL_MODULE_EXTENSIONS.includes(path.extname(resolved))
|
|
747
|
+
) {
|
|
748
|
+
visit(resolved);
|
|
749
|
+
} else {
|
|
750
|
+
unread.push(
|
|
751
|
+
`${shown} imports "${source}", this package's own name, which resolves to no source this check can read.`,
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
const base = path.resolve(path.dirname(current), source);
|
|
757
|
+
const target = [
|
|
758
|
+
base,
|
|
759
|
+
...LOCAL_MODULE_EXTENSIONS.map(extension => `${base}${extension}`),
|
|
760
|
+
...LOCAL_MODULE_EXTENSIONS.map(extension =>
|
|
761
|
+
path.join(base, `index${extension}`),
|
|
762
|
+
),
|
|
763
|
+
].find(candidate => {
|
|
764
|
+
try {
|
|
765
|
+
return fs.statSync(candidate).isFile();
|
|
766
|
+
} catch {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
if (!target) {
|
|
771
|
+
unread.push(
|
|
772
|
+
`${shown} imports "${source}", which resolves to no file this check can read.`,
|
|
773
|
+
);
|
|
774
|
+
} else if (LOCAL_MODULE_EXTENSIONS.includes(path.extname(target))) {
|
|
775
|
+
visit(target);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
// Anything this check does not model leaves the names unjudged: what
|
|
779
|
+
// the module renders through a binding, an alias, a member read, a
|
|
780
|
+
// component held in a variable, or a module loaded at runtime.
|
|
781
|
+
/** @type {Set<string>} functions and classes the module declares */
|
|
782
|
+
const declared = new Set();
|
|
783
|
+
walkNodes(ast.program, node => {
|
|
784
|
+
if (
|
|
785
|
+
(node.type === 'FunctionDeclaration' ||
|
|
786
|
+
node.type === 'ClassDeclaration') &&
|
|
787
|
+
node.id?.name
|
|
788
|
+
) {
|
|
789
|
+
declared.add(node.id.name);
|
|
790
|
+
} else if (
|
|
791
|
+
node.type === 'VariableDeclarator' &&
|
|
792
|
+
node.id?.type === 'Identifier' &&
|
|
793
|
+
[
|
|
794
|
+
'ArrowFunctionExpression',
|
|
795
|
+
'FunctionExpression',
|
|
796
|
+
'ClassExpression',
|
|
797
|
+
].includes(node.init?.type)
|
|
798
|
+
) {
|
|
799
|
+
declared.add(node.id.name);
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
const from = (/** @type {string} */ name) =>
|
|
803
|
+
bindings.has(name) ? ` (imported from "${bindings.get(name)}")` : '';
|
|
804
|
+
walkNodes(ast.program, node => {
|
|
805
|
+
if (node.type === 'JSXMemberExpression') {
|
|
806
|
+
let object = node.object;
|
|
807
|
+
while (object?.type === 'JSXMemberExpression') object = object.object;
|
|
808
|
+
const name = object?.name ?? 'an object';
|
|
809
|
+
unread.push(
|
|
810
|
+
`${shown} renders members of ${name}${from(name)}, whose names this check does not read.`,
|
|
811
|
+
);
|
|
812
|
+
} else if (
|
|
813
|
+
node.type === 'JSXOpeningElement' &&
|
|
814
|
+
node.name?.type === 'JSXIdentifier' &&
|
|
815
|
+
/^[A-Z]/u.test(node.name.name) &&
|
|
816
|
+
!names.has(node.name.name) &&
|
|
817
|
+
!declared.has(node.name.name)
|
|
818
|
+
) {
|
|
819
|
+
unread.push(
|
|
820
|
+
`${shown} renders ${node.name.name}, a value this check does not trace to an import.`,
|
|
821
|
+
);
|
|
822
|
+
} else if (
|
|
823
|
+
node.type === 'VariableDeclarator' &&
|
|
824
|
+
node.init?.type === 'Identifier' &&
|
|
825
|
+
bindings.has(node.init.name)
|
|
826
|
+
) {
|
|
827
|
+
// `const UI = Lib`, `const {Panel} = Lib`: an alias of an import.
|
|
828
|
+
if (node.id?.type === 'Identifier') {
|
|
829
|
+
bindings.set(
|
|
830
|
+
node.id.name,
|
|
831
|
+
/** @type {string} */ (bindings.get(node.init.name)),
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
unread.push(
|
|
835
|
+
`${shown} reads ${node.init.name}${from(node.init.name)} into another name, which this check does not follow.`,
|
|
836
|
+
);
|
|
837
|
+
} else if (
|
|
838
|
+
(node.type === 'MemberExpression' ||
|
|
839
|
+
node.type === 'OptionalMemberExpression') &&
|
|
840
|
+
node.object?.type === 'Identifier' &&
|
|
841
|
+
bindings.has(node.object.name)
|
|
842
|
+
) {
|
|
843
|
+
// `UI.Panel`, `UI?.Panel`, `UI['Panel']`, `createElement(UI.Panel)`.
|
|
844
|
+
unread.push(
|
|
845
|
+
`${shown} reads members of ${node.object.name}${from(node.object.name)}, whose names this check does not read.`,
|
|
846
|
+
);
|
|
847
|
+
} else if (
|
|
848
|
+
node.type === 'CallExpression' &&
|
|
849
|
+
node.callee?.type === 'Identifier' &&
|
|
850
|
+
node.callee.name === 'require'
|
|
851
|
+
) {
|
|
852
|
+
const argument = node.arguments?.[0];
|
|
853
|
+
const spec =
|
|
854
|
+
argument?.type === 'StringLiteral'
|
|
855
|
+
? `"${argument.value}"`
|
|
856
|
+
: 'a module';
|
|
857
|
+
unread.push(
|
|
858
|
+
`${shown} loads ${spec} with require(), whose component names this check does not read.`,
|
|
859
|
+
);
|
|
860
|
+
} else if (
|
|
861
|
+
node.type === 'ImportExpression' ||
|
|
862
|
+
(node.type === 'CallExpression' && node.callee?.type === 'Import')
|
|
863
|
+
) {
|
|
864
|
+
const argument = node.source ?? node.arguments?.[0];
|
|
865
|
+
const spec =
|
|
866
|
+
argument?.type === 'StringLiteral'
|
|
867
|
+
? `"${argument.value}"`
|
|
868
|
+
: 'a module';
|
|
869
|
+
unread.push(
|
|
870
|
+
`${shown} loads ${spec} with a dynamic import(), whose component names this check does not read.`,
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
};
|
|
875
|
+
visit(file);
|
|
876
|
+
return {names, unread};
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* The local name a module's default export declares (`export default
|
|
881
|
+
* function AcmeWidget()`, `export default class AcmeWidget`), or of the
|
|
882
|
+
* binding it exports as default (`export default AcmeWidget`), or null.
|
|
883
|
+
* @param {string} file
|
|
884
|
+
* @returns {string | null}
|
|
885
|
+
*/
|
|
886
|
+
function defaultBinding(file) {
|
|
887
|
+
let ast;
|
|
888
|
+
try {
|
|
889
|
+
ast = parseModule(fs.readFileSync(file, 'utf8'), {
|
|
890
|
+
sourceType: 'module',
|
|
891
|
+
plugins: ['typescript', 'jsx'],
|
|
892
|
+
errorRecovery: true,
|
|
893
|
+
});
|
|
894
|
+
} catch {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
for (const node of ast.program.body) {
|
|
898
|
+
if (node.type !== 'ExportDefaultDeclaration') continue;
|
|
899
|
+
const declaration = /** @type {any} */ (node.declaration);
|
|
900
|
+
if (typeof declaration?.id?.name === 'string') return declaration.id.name;
|
|
901
|
+
if (declaration?.type === 'Identifier') return declaration.name;
|
|
902
|
+
}
|
|
903
|
+
return null;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* A note: information beside validate's issues that fails nothing, with the
|
|
908
|
+
* fix in its message.
|
|
909
|
+
* @typedef {{code: string, message: string}} Note
|
|
910
|
+
*/
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* @param {string} code
|
|
914
|
+
* @param {{message: string}} finding
|
|
915
|
+
* @returns {Note}
|
|
916
|
+
*/
|
|
917
|
+
function note(code, finding) {
|
|
918
|
+
return {code, message: finding.message};
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* The block component names this check could not judge, shaped like the
|
|
923
|
+
* doc type report so `integration check` counts them as not compared: each
|
|
924
|
+
* name a template gives in `exampleFor` or `componentsUsed` that neither the
|
|
925
|
+
* package nor Core has, when the template reaches components through
|
|
926
|
+
* anything but named imports and re-exports from the package, Core, or
|
|
927
|
+
* helpers read in full (see importedNames), or when Core is not installed to
|
|
928
|
+
* look it up in; its findings are always empty. A name judged unknown is an
|
|
929
|
+
* `unknown_block_component` note, with its fix in the message: validate
|
|
930
|
+
* lists notes beside its issues, and nothing counts them, so `--strict` does
|
|
931
|
+
* not fail on it until the next minor release (architecture:cli-surface
|
|
932
|
+
* INV35).
|
|
933
|
+
* @param {LoadedIntegration} integration
|
|
934
|
+
* @returns {Promise<{report: {status: 'checked', findings: [], unchecked: Array<{file: string, name: string, reason: string}>}, notes: Note[]}>}
|
|
935
|
+
*/
|
|
936
|
+
export async function blockComponentsCheck(integration) {
|
|
937
|
+
const {findings, unchecked} = await judgeBlockComponents(integration);
|
|
938
|
+
const base = integration.__packageDir ?? integration.templates ?? '';
|
|
939
|
+
return {
|
|
940
|
+
report: {
|
|
941
|
+
status: 'checked',
|
|
942
|
+
findings: [],
|
|
943
|
+
unchecked: unchecked.map(entry => ({
|
|
944
|
+
file: slash(path.relative(base, entry.docPath)),
|
|
945
|
+
name: entry.name,
|
|
946
|
+
reason: entry.reason,
|
|
947
|
+
})),
|
|
948
|
+
},
|
|
949
|
+
notes: findings.map(entry => note('unknown_block_component', entry)),
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
|
|
307
953
|
/**
|
|
308
954
|
* Warn about a `.tsx` directly in the templates root with no same-stem template
|
|
309
955
|
* metadata: template discovery pairs sources with docs, so `astryx template`
|
|
@@ -340,6 +986,8 @@ async function checkComponents(integration, issues) {
|
|
|
340
986
|
if (!integration.components || rootProblem(integration.components)) return;
|
|
341
987
|
const discover = componentDiscovery.discoverValidIntegrationComponents;
|
|
342
988
|
if (typeof discover !== 'function') return; // feature not present yet
|
|
989
|
+
const root = /** @type {string} */ (integration.components);
|
|
990
|
+
const files = componentDocFiles(root);
|
|
343
991
|
try {
|
|
344
992
|
const {discovered, errors} = await discover(integration);
|
|
345
993
|
/** @type {import('./contribution-fixes.mjs').FixContext | undefined} */
|
|
@@ -352,7 +1000,12 @@ async function checkComponents(integration, issues) {
|
|
|
352
1000
|
continue;
|
|
353
1001
|
}
|
|
354
1002
|
const docPath = record.docPath;
|
|
355
|
-
|
|
1003
|
+
// Reported once, below, as the case mismatch it is.
|
|
1004
|
+
if (docPath && files.caseMismatch.has(docPath)) continue;
|
|
1005
|
+
const docName = docPath
|
|
1006
|
+
? path.basename(docPath)
|
|
1007
|
+
: `${record.name}.doc.mjs`;
|
|
1008
|
+
let fix = `Fix: add ${record.name}.tsx beside ${docName}.`;
|
|
356
1009
|
const stamp = docPath ? readContributionStamp(docPath, false) : null;
|
|
357
1010
|
if (stamp && stamp.type !== 'component' && integration.__packageDir) {
|
|
358
1011
|
context ??= createFixContext(integration.__packageDir, integration);
|
|
@@ -360,6 +1013,56 @@ async function checkComponents(integration, issues) {
|
|
|
360
1013
|
}
|
|
361
1014
|
issues.push(issueError('invalid_component', `${error.message} ${fix}`));
|
|
362
1015
|
}
|
|
1016
|
+
/** @type {Set<string>} sources a case-only rename is reported for */
|
|
1017
|
+
const reportedSources = new Set();
|
|
1018
|
+
for (const [docPath, source] of files.caseMismatch) {
|
|
1019
|
+
const doc = path.basename(docPath);
|
|
1020
|
+
const renamed = `${source.slice(0, -'.tsx'.length)}${doc.slice(docStemOf(doc).length)}`;
|
|
1021
|
+
const shown = slash(path.relative(root, docPath));
|
|
1022
|
+
const linux = `They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run`;
|
|
1023
|
+
const fix = `Fix: rename ${doc} to ${renamed}.`;
|
|
1024
|
+
// Where discovery still pairs the doc with its source (a
|
|
1025
|
+
// case-insensitive disk), the component works here: listed, as
|
|
1026
|
+
// validate passed it before. A hidden doc that does not pair leaves its
|
|
1027
|
+
// source without a doc, which the source check below reports as it
|
|
1028
|
+
// always has (architecture:cli-surface INV37).
|
|
1029
|
+
const pairs = componentDiscovery.integrationSourceForDoc(docPath) != null;
|
|
1030
|
+
const hidden = componentDiscovery.isHiddenComponentDoc(docPath);
|
|
1031
|
+
if (hidden && !pairs) continue;
|
|
1032
|
+
reportedSources.add(path.join(path.dirname(docPath), source));
|
|
1033
|
+
if (hidden) {
|
|
1034
|
+
issues.push(
|
|
1035
|
+
issueListed(
|
|
1036
|
+
'source_without_component_doc',
|
|
1037
|
+
`Hidden component doc "${shown}" and its source "${source}" differ only in letter case. ${linux}. ${fix}`,
|
|
1038
|
+
),
|
|
1039
|
+
);
|
|
1040
|
+
} else if (pairs) {
|
|
1041
|
+
issues.push(
|
|
1042
|
+
issueListed(
|
|
1043
|
+
'source_without_component_doc',
|
|
1044
|
+
`Component doc "${shown}" and its source "${source}" differ only in letter case. ${linux}, so there the component is missing. ${fix}`,
|
|
1045
|
+
),
|
|
1046
|
+
);
|
|
1047
|
+
} else {
|
|
1048
|
+
issues.push(
|
|
1049
|
+
issueError(
|
|
1050
|
+
'invalid_component',
|
|
1051
|
+
`Component doc "${shown}" and its source "${source}" differ only in letter case. ${linux}, so here the component is missing. ${fix}`,
|
|
1052
|
+
),
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
for (const {read, ignored} of files.duplicates) {
|
|
1057
|
+
const readName = path.basename(read);
|
|
1058
|
+
const ignoredNames = ignored.map(file => path.basename(file));
|
|
1059
|
+
issues.push(
|
|
1060
|
+
issueListed(
|
|
1061
|
+
'duplicate_component_doc',
|
|
1062
|
+
`Component "${docStemOf(readName)}" has ${ignored.length + 1} docs: ${[readName, ...ignoredNames].join(', ')}. Astryx reads ${readName} and ignores ${ignoredNames.join(' and ')}. Fix: delete ${ignoredNames.join(' and ')}, moving anything only ${ignored.length === 1 ? 'it says' : 'they say'} into ${readName}.`,
|
|
1063
|
+
),
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
363
1066
|
const overlap = integration.__packageDir
|
|
364
1067
|
? newComponentDocNote(
|
|
365
1068
|
(context ??= createFixContext(integration.__packageDir, integration)),
|
|
@@ -372,16 +1075,13 @@ async function checkComponents(integration, issues) {
|
|
|
372
1075
|
// A hidden doc still pairs with its source; discovery just skips it.
|
|
373
1076
|
if (
|
|
374
1077
|
['.doc.ts', '.doc.mjs', '.doc.js'].some(suffix =>
|
|
375
|
-
fs.existsSync(
|
|
376
|
-
path.join(
|
|
377
|
-
/** @type {string} */ (integration.components),
|
|
378
|
-
`${name}${suffix}`,
|
|
379
|
-
),
|
|
380
|
-
),
|
|
1078
|
+
fs.existsSync(path.join(root, `${name}${suffix}`)),
|
|
381
1079
|
)
|
|
382
1080
|
) {
|
|
383
1081
|
continue;
|
|
384
1082
|
}
|
|
1083
|
+
// A doc whose name differs only in case is reported above.
|
|
1084
|
+
if (reportedSources.has(path.join(root, `${name}.tsx`))) continue;
|
|
385
1085
|
issues.push(
|
|
386
1086
|
issueWarning(
|
|
387
1087
|
'source_without_component_doc',
|
|
@@ -396,6 +1096,236 @@ async function checkComponents(integration, issues) {
|
|
|
396
1096
|
}
|
|
397
1097
|
}
|
|
398
1098
|
|
|
1099
|
+
const COMPONENT_DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
|
|
1100
|
+
|
|
1101
|
+
/** @param {string} file a doc file name */
|
|
1102
|
+
function docStemOf(file) {
|
|
1103
|
+
const suffix = COMPONENT_DOC_SUFFIXES.find(each => file.endsWith(each));
|
|
1104
|
+
return suffix ? file.slice(0, -suffix.length) : file;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* The component docs under a root, read from the real directory listings:
|
|
1109
|
+
* those beside a source whose name differs only in letter case (which an
|
|
1110
|
+
* existence check on a case-insensitive disk would call paired), and stems
|
|
1111
|
+
* with more than one doc, with the doc discovery reads.
|
|
1112
|
+
* @param {string} root
|
|
1113
|
+
*/
|
|
1114
|
+
function componentDocFiles(root) {
|
|
1115
|
+
/** @type {Map<string, string>} doc path -> the source's real file name */
|
|
1116
|
+
const caseMismatch = new Map();
|
|
1117
|
+
/** @type {Array<{read: string, ignored: string[]}>} */
|
|
1118
|
+
const duplicates = [];
|
|
1119
|
+
/** @param {string} dir */
|
|
1120
|
+
const walk = dir => {
|
|
1121
|
+
let entries;
|
|
1122
|
+
try {
|
|
1123
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
1124
|
+
} catch {
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
const names = new Set(entries.map(entry => entry.name));
|
|
1128
|
+
/** @type {Map<string, string[]>} */
|
|
1129
|
+
const byStem = new Map();
|
|
1130
|
+
for (const entry of entries) {
|
|
1131
|
+
const full = path.join(dir, entry.name);
|
|
1132
|
+
if (entry.isDirectory()) {
|
|
1133
|
+
if (entry.name !== 'node_modules' && entry.name !== '__tests__') {
|
|
1134
|
+
walk(full);
|
|
1135
|
+
}
|
|
1136
|
+
continue;
|
|
1137
|
+
}
|
|
1138
|
+
const stem = docStemOf(entry.name);
|
|
1139
|
+
if (stem === entry.name) continue;
|
|
1140
|
+
byStem.set(stem, [...(byStem.get(stem) ?? []), entry.name]);
|
|
1141
|
+
const source = `${stem}.tsx`;
|
|
1142
|
+
if (names.has(source)) continue;
|
|
1143
|
+
const other = [...names].find(
|
|
1144
|
+
name => name !== source && name.toLowerCase() === source.toLowerCase(),
|
|
1145
|
+
);
|
|
1146
|
+
// The source's own doc, if it has one, is its pair.
|
|
1147
|
+
if (
|
|
1148
|
+
other &&
|
|
1149
|
+
!COMPONENT_DOC_SUFFIXES.some(suffix =>
|
|
1150
|
+
names.has(`${other.slice(0, -'.tsx'.length)}${suffix}`),
|
|
1151
|
+
)
|
|
1152
|
+
) {
|
|
1153
|
+
caseMismatch.set(full, other);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
for (const docs of byStem.values()) {
|
|
1157
|
+
if (docs.length < 2) continue;
|
|
1158
|
+
const ordered = COMPONENT_DOC_SUFFIXES.map(suffix =>
|
|
1159
|
+
docs.find(doc => doc.endsWith(suffix)),
|
|
1160
|
+
).filter(doc => doc != null);
|
|
1161
|
+
duplicates.push({
|
|
1162
|
+
read: path.join(dir, /** @type {string} */ (ordered[0])),
|
|
1163
|
+
ignored: ordered
|
|
1164
|
+
.slice(1)
|
|
1165
|
+
.map(doc => path.join(dir, /** @type {string} */ (doc))),
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
walk(root);
|
|
1170
|
+
return {caseMismatch, duplicates};
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Judge each component doc's `name` against the module its printed import
|
|
1175
|
+
* names: a finding when that module provably does not export it, and an
|
|
1176
|
+
* entry in `unchecked` when it cannot be judged, so it is listed instead.
|
|
1177
|
+
* @param {LoadedIntegration} integration
|
|
1178
|
+
* @param {Array<{name: string, docPath: string, sourcePath: string|null}>} components
|
|
1179
|
+
* @param {string} root the components root
|
|
1180
|
+
* @param {Map<string, string>} skip docs already reported, by path
|
|
1181
|
+
* @param {Array<{docPath: string, name: string, message: string}>} findings
|
|
1182
|
+
* @param {Array<{docPath: string, name: string, reason: string}>} unchecked
|
|
1183
|
+
*/
|
|
1184
|
+
async function judgeComponentDocNames(
|
|
1185
|
+
integration,
|
|
1186
|
+
components,
|
|
1187
|
+
root,
|
|
1188
|
+
skip,
|
|
1189
|
+
findings,
|
|
1190
|
+
unchecked,
|
|
1191
|
+
) {
|
|
1192
|
+
const base = integration.__packageDir ?? root;
|
|
1193
|
+
for (const record of components) {
|
|
1194
|
+
if (componentDiscovery.isIntegrationMember(record)) continue;
|
|
1195
|
+
if (skip.has(record.docPath)) continue;
|
|
1196
|
+
// A doc with no source is its own error.
|
|
1197
|
+
if (record.sourcePath == null) continue;
|
|
1198
|
+
let doc;
|
|
1199
|
+
try {
|
|
1200
|
+
doc = await loadComponentDoc(record.docPath);
|
|
1201
|
+
} catch {
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1204
|
+
const name = doc?.name;
|
|
1205
|
+
if (typeof name !== 'string' || name === record.name) continue;
|
|
1206
|
+
// The module the printed import names: the doc's import, the published
|
|
1207
|
+
// subpath, or the package root, resolved through package.json "exports".
|
|
1208
|
+
// Without a package to resolve it in, the same-stem source.
|
|
1209
|
+
const printed = componentDiscovery.importedModule(
|
|
1210
|
+
integration,
|
|
1211
|
+
record.docPath,
|
|
1212
|
+
doc,
|
|
1213
|
+
);
|
|
1214
|
+
if (printed === null) {
|
|
1215
|
+
unchecked.push({
|
|
1216
|
+
docPath: record.docPath,
|
|
1217
|
+
name,
|
|
1218
|
+
reason:
|
|
1219
|
+
'Its import names another package, or resolves to no file this check can read.',
|
|
1220
|
+
});
|
|
1221
|
+
continue;
|
|
1222
|
+
}
|
|
1223
|
+
const module = printed ?? record.sourcePath;
|
|
1224
|
+
const shown = slash(path.relative(base, module));
|
|
1225
|
+
// Only what the code contradicts: the module must provably not export
|
|
1226
|
+
// the name the doc gives.
|
|
1227
|
+
const judged = moduleExportVerdict(module, name);
|
|
1228
|
+
if (judged.verdict === 'exports') continue;
|
|
1229
|
+
if (judged.verdict === 'unknown') {
|
|
1230
|
+
unchecked.push({docPath: record.docPath, name, reason: judged.reason});
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1233
|
+
// A source whose only export is a default, read because no printed
|
|
1234
|
+
// import could be resolved: the package's entry may publish it under
|
|
1235
|
+
// any name, so the name is not judged. A printed import that names a
|
|
1236
|
+
// default-only module does not export the name, which is a mismatch.
|
|
1237
|
+
const exportedNames = moduleExportNames(module);
|
|
1238
|
+
const defaultOnly =
|
|
1239
|
+
exportedNames != null &&
|
|
1240
|
+
exportedNames.length === 1 &&
|
|
1241
|
+
exportedNames[0] === 'default';
|
|
1242
|
+
if (defaultOnly && printed === undefined) {
|
|
1243
|
+
unchecked.push({
|
|
1244
|
+
docPath: record.docPath,
|
|
1245
|
+
name,
|
|
1246
|
+
reason: `${shown} exports a default, which the package entry may publish under any name.`,
|
|
1247
|
+
});
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
const file = path.basename(record.docPath);
|
|
1251
|
+
// The name to propose: the file name when the module exports it, else
|
|
1252
|
+
// the one component the module exports.
|
|
1253
|
+
let fix;
|
|
1254
|
+
if (defaultOnly) {
|
|
1255
|
+
fix =
|
|
1256
|
+
defaultBinding(module) === name
|
|
1257
|
+
? `Fix: add \`export {${name}};\` to ${shown}, so it exports ${name} by name as well, or set the doc's import to the module that publishes it as ${name}.`
|
|
1258
|
+
: `Fix: bind the default to ${name} in ${shown} and export it by name too (\`const ${name} = …; export default ${name}; export {${name}};\`), or set the doc's import to the module that publishes it as ${name}.`;
|
|
1259
|
+
} else if (moduleExportsName(module, record.name)) {
|
|
1260
|
+
fix = `Fix: set name: '${record.name}' in ${file}.`;
|
|
1261
|
+
} else {
|
|
1262
|
+
const exported = (exportedNames ?? []).filter(each =>
|
|
1263
|
+
/^[A-Z][A-Za-z0-9]*$/u.test(each),
|
|
1264
|
+
);
|
|
1265
|
+
fix =
|
|
1266
|
+
exported.length === 1
|
|
1267
|
+
? `Fix: set name: '${exported[0]}' in ${file}, the component ${shown} exports.`
|
|
1268
|
+
: `Fix: set name in ${file} to the component ${shown} exports${exported.length > 1 ? ` (${exported.join(', ')})` : ''}.`;
|
|
1269
|
+
}
|
|
1270
|
+
findings.push({
|
|
1271
|
+
docPath: record.docPath,
|
|
1272
|
+
name,
|
|
1273
|
+
message: `Component doc "${slash(path.relative(root, record.docPath))}" sets name: '${name}', but ${shown}, the module its import names, does not export ${name}, so Astryx lists the component as "${record.name}" (its file name), and \`astryx component ${record.name}\` prints \`import {${name}}\`. ${fix}`,
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* The component doc names the check could not judge, shaped like the doc type
|
|
1280
|
+
* report so `integration check` counts them as not compared: each doc whose
|
|
1281
|
+
* `name` differs from the name it is listed under and whose source's exports
|
|
1282
|
+
* cannot all be read without running it; its findings are always empty. A
|
|
1283
|
+
* name the module its printed import names provably lacks is a
|
|
1284
|
+
* `doc_name_mismatch` note, with its fix in the message: validate lists
|
|
1285
|
+
* notes beside its issues, and nothing counts them, so `--strict` does not
|
|
1286
|
+
* fail on it until the next minor release (architecture:cli-surface INV35).
|
|
1287
|
+
* @param {LoadedIntegration} integration
|
|
1288
|
+
* @returns {Promise<{report: {status: 'checked', findings: [], unchecked: Array<{file: string, name: string, reason: string}>}, notes: Note[]}>}
|
|
1289
|
+
*/
|
|
1290
|
+
export async function componentDocNamesCheck(integration) {
|
|
1291
|
+
/** @type {Array<{docPath: string, name: string, message: string}>} */
|
|
1292
|
+
const findings = [];
|
|
1293
|
+
/** @type {Array<{docPath: string, name: string, reason: string}>} */
|
|
1294
|
+
const unchecked = [];
|
|
1295
|
+
const root = integration.components;
|
|
1296
|
+
if (root && !rootProblem(root)) {
|
|
1297
|
+
try {
|
|
1298
|
+
const {components} =
|
|
1299
|
+
await componentDiscovery.discoverValidIntegrationComponents(
|
|
1300
|
+
integration,
|
|
1301
|
+
);
|
|
1302
|
+
await judgeComponentDocNames(
|
|
1303
|
+
integration,
|
|
1304
|
+
components,
|
|
1305
|
+
root,
|
|
1306
|
+
componentDocFiles(root).caseMismatch,
|
|
1307
|
+
findings,
|
|
1308
|
+
unchecked,
|
|
1309
|
+
);
|
|
1310
|
+
} catch {
|
|
1311
|
+
// A components root discovery cannot read is reported as an issue.
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
const base = integration.__packageDir ?? root ?? '';
|
|
1315
|
+
return {
|
|
1316
|
+
report: {
|
|
1317
|
+
status: 'checked',
|
|
1318
|
+
findings: [],
|
|
1319
|
+
unchecked: unchecked.map(entry => ({
|
|
1320
|
+
file: slash(path.relative(base, entry.docPath)),
|
|
1321
|
+
name: entry.name,
|
|
1322
|
+
reason: entry.reason,
|
|
1323
|
+
})),
|
|
1324
|
+
},
|
|
1325
|
+
notes: findings.map(entry => note('doc_name_mismatch', entry)),
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
|
|
399
1329
|
/**
|
|
400
1330
|
* Validate the integration's doc topics via the landed discovery. A doc that
|
|
401
1331
|
* cannot be loaded, is not a usable topic, or collides with a sibling is
|
|
@@ -431,18 +1361,49 @@ async function checkDocs(integration, issues) {
|
|
|
431
1361
|
async function checkThemes(integration, issues) {
|
|
432
1362
|
if (!integration.themes || rootProblem(integration.themes)) return;
|
|
433
1363
|
try {
|
|
1364
|
+
// A theme may name itself differently from its folder (its built files
|
|
1365
|
+
// then carry that name), so a name that differs is no finding here:
|
|
1366
|
+
// verify judges it against the files the package exports.
|
|
434
1367
|
await discoverIntegrationThemes(integration);
|
|
435
1368
|
} catch (err) {
|
|
436
1369
|
issues.push(issueError('invalid_theme', /** @type {any} */ (err).message));
|
|
437
1370
|
}
|
|
438
1371
|
}
|
|
439
1372
|
|
|
1373
|
+
/**
|
|
1374
|
+
* A warning for each contribution file a reader reads (the docs and sources
|
|
1375
|
+
* `integration verify` expects in the tarball) that the user running astryx
|
|
1376
|
+
* cannot read; files no reader takes, such as `.DS_Store`, are not looked at: Astryx cannot check it, and npm pack stops on it. A
|
|
1377
|
+
* warning, so validate keeps its exit code; `integration verify` fails on the
|
|
1378
|
+
* pack itself.
|
|
1379
|
+
* @param {LoadedIntegration} integration
|
|
1380
|
+
* @param {Issue[]} issues
|
|
1381
|
+
*/
|
|
1382
|
+
function checkUnreadableFiles(integration, issues) {
|
|
1383
|
+
const packageDir = integration.__packageDir;
|
|
1384
|
+
if (!packageDir) return;
|
|
1385
|
+
for (const shown of contributionFiles(integration, packageDir)) {
|
|
1386
|
+
try {
|
|
1387
|
+
fs.accessSync(path.join(packageDir, shown), fs.constants.R_OK);
|
|
1388
|
+
} catch (err) {
|
|
1389
|
+
const code = String(/** @type {any} */ (err)?.code ?? 'unknown error');
|
|
1390
|
+
issues.push(
|
|
1391
|
+
issueListed(
|
|
1392
|
+
'unreadable_file',
|
|
1393
|
+
`Could not read "${shown}" (${code}), so Astryx cannot check it and npm pack fails on it. Fix: make it readable (chmod a+r ${shown}), or delete it if it does not belong in the package.`,
|
|
1394
|
+
),
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
|
|
440
1400
|
/**
|
|
441
1401
|
* Run every contribution validator against a loaded-integration-shaped object.
|
|
442
1402
|
* @param {LoadedIntegration} integration
|
|
443
1403
|
* @param {Issue[]} issues
|
|
444
1404
|
*/
|
|
445
1405
|
async function runContributionChecks(integration, issues) {
|
|
1406
|
+
checkUnreadableFiles(integration, issues);
|
|
446
1407
|
await checkCodemods(integration, issues);
|
|
447
1408
|
await checkTemplates(integration, issues);
|
|
448
1409
|
await checkComponents(integration, issues);
|
|
@@ -461,6 +1422,29 @@ async function runContributionChecks(integration, issues) {
|
|
|
461
1422
|
* @returns {Promise<Issue[]>}
|
|
462
1423
|
*/
|
|
463
1424
|
export async function validateLoadedIntegration(loaded) {
|
|
1425
|
+
return (await validateLoadedIntegrationListed(loaded)).issues;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Every contribution check, split: `issues` as validateLoadedIntegration
|
|
1430
|
+
* returns them, and `listed`, the layout findings validate lists in its
|
|
1431
|
+
* `layout` report without counting them.
|
|
1432
|
+
* @param {LoadedIntegration} loaded
|
|
1433
|
+
* @returns {Promise<{issues: Issue[], listed: Issue[]}>}
|
|
1434
|
+
*/
|
|
1435
|
+
export async function validateLoadedIntegrationListed(loaded) {
|
|
1436
|
+
const all = await allLoadedIntegrationIssues(loaded);
|
|
1437
|
+
return {
|
|
1438
|
+
issues: all.filter(issue => !LISTED.has(issue)),
|
|
1439
|
+
listed: all.filter(issue => LISTED.has(issue)),
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* @param {LoadedIntegration} loaded
|
|
1445
|
+
* @returns {Promise<Issue[]>}
|
|
1446
|
+
*/
|
|
1447
|
+
async function allLoadedIntegrationIssues(loaded) {
|
|
464
1448
|
/** @type {Issue[]} */
|
|
465
1449
|
const issues = [];
|
|
466
1450
|
if (!loaded || typeof loaded !== 'object') return issues;
|
|
@@ -497,8 +1481,10 @@ export async function validateLoadedIntegration(loaded) {
|
|
|
497
1481
|
codemods: loaded.codemods,
|
|
498
1482
|
docs: loaded.docs,
|
|
499
1483
|
themes: loaded.themes,
|
|
1484
|
+
__manifestFile: loaded.__manifestFile,
|
|
500
1485
|
},
|
|
501
1486
|
issues,
|
|
1487
|
+
loaded.__packageDir,
|
|
502
1488
|
);
|
|
503
1489
|
await runContributionChecks(loaded, issues);
|
|
504
1490
|
return issues;
|