@astryxdesign/cli 0.7.3-canary.f94e962 → 0.7.3
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/CHANGELOG.md +115 -0
- package/README.md +68 -68
- package/api/build/_adapter.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -18
- package/api/build/blocks/blocks.mjs +475 -116
- package/api/build/blocks/blocks.test.mjs +191 -61
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +9 -5
- package/api/build/kit/answer.mjs +123 -13
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +19 -0
- package/api/build/kit/signals.mjs +18 -7
- package/api/build/kit/weights.d.mts +8 -22
- package/api/build/kit/weights.mjs +87 -8
- package/api/build/kit/weights.test.mjs +96 -0
- package/api/build/tree.mjs +2 -1
- package/api/build/tree.test.mjs +37 -29
- package/api/component/_adapter.mjs +39 -5
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +1 -1
- package/api/component/doc-links.test.mjs +2 -2
- package/api/discover/_adapter.d.mts +1 -2
- package/api/discover/_adapter.mjs +6 -8
- package/api/discover/discover.mjs +0 -1
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +65 -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/_adapter.d.mts +33 -13
- package/api/doctor/_adapter.mjs +55 -25
- package/api/doctor/doctor.d.mts +23 -5
- package/api/doctor/doctor.mjs +97 -28
- package/api/doctor/doctor.test.mjs +67 -9
- package/api/hook/hook.mjs +1 -1
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +12 -1
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +48 -7
- package/api/integration/validate-integration.type.d.mts +36 -5
- package/api/integration/validate-integration.type.mjs +27 -6
- 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 +35 -17
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/_gather-templates.d.mts +0 -1
- package/api/search/_gather-templates.mjs +25 -0
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.integration-block.test.mjs +100 -0
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/template/template.mjs +5 -1
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- 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 +1 -1
- 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 +2 -2
- package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
- 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 +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +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/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.doc.mjs +1 -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.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/outside-project.test.mjs +99 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/index.mjs +35 -93
- 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-doc-state.d.mts +12 -0
- package/foundation/agent-docs/agent-doc-state.mjs +24 -2
- package/foundation/agent-docs/agent-docs.mjs +7 -6
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
- package/foundation/agent-docs/computer-agent-text.mjs +135 -8
- package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
- 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-commands.mjs +1 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +21 -9
- 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/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/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/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/release/cache.test.mjs +24 -21
- package/foundation/release/global-state.d.mts +8 -4
- package/foundation/release/global-state.mjs +4 -2
- package/foundation/release/notices.d.mts +62 -8
- package/foundation/release/notices.mjs +136 -25
- package/foundation/release/notices.test.mjs +21 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/package.json +9 -9
package/api/doctor/doctor.mjs
CHANGED
|
@@ -65,8 +65,9 @@ import {typedEdges} from '../docs/node/node.mjs';
|
|
|
65
65
|
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
66
66
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
67
67
|
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
68
|
-
import {availableLine, upgradeLine} from '../../foundation/release/notices.mjs';
|
|
69
|
-
import {
|
|
68
|
+
import {availableLine, RUN_FROM_PROJECT, upgradeLine} from '../../foundation/release/notices.mjs';
|
|
69
|
+
import {COMPUTER_COMMAND, COMPUTER_INSTALL_STEP} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
70
|
+
import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, insideProjectElsewhere, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts} from './_adapter.mjs';
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
73
|
* @typedef {'pass'|'warn'|'fail'|'info'} DoctorStatus
|
|
@@ -286,15 +287,25 @@ export function checkVersionAlignment(ctx) {
|
|
|
286
287
|
// the run (spec AST-081 FR2): say so, and how to add the CLI at Core's
|
|
287
288
|
// version.
|
|
288
289
|
if (ctx.ownCli === false) {
|
|
290
|
+
// The same comparison as the daily hint: the CLI against the Core the
|
|
291
|
+
// run reads (spec AST-081 FR2). The command adds the CLI in the project
|
|
292
|
+
// spec:AST-040 FR9 defines; from a folder inside it whose package.json
|
|
293
|
+
// is not the project's, or in no project, the fix says how to reach one.
|
|
294
|
+
const add = addCliCommandFor(ctx.cwd, coreVersion);
|
|
295
|
+
const matches = coreVersion === cliVersion;
|
|
296
|
+
const fix = add
|
|
297
|
+
? `${matches ? 'To pin it for the team and CI' : 'To match'}, run: ${add.command}.`
|
|
298
|
+
: matches
|
|
299
|
+
? null
|
|
300
|
+
: NO_PROJECT_FIX;
|
|
289
301
|
return {
|
|
290
302
|
id: 'version-alignment',
|
|
291
303
|
label: '@astryxdesign/core <-> @astryxdesign/cli alignment',
|
|
292
|
-
status:
|
|
293
|
-
message:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
fix: `${coreVersion === cliVersion ? 'To pin it for the team and CI' : 'To match'}, run: ${addCliCommandFor(ctx.cwd, coreVersion)}.`,
|
|
304
|
+
status: matches ? 'info' : 'warn',
|
|
305
|
+
message: matches
|
|
306
|
+
? `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered and matches its Core.`
|
|
307
|
+
: `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered while its Core is ${coreVersion}.`,
|
|
308
|
+
...(fix ? {fix} : {}),
|
|
298
309
|
};
|
|
299
310
|
}
|
|
300
311
|
// The project's own CLI answers this project whatever its version
|
|
@@ -308,10 +319,31 @@ export function checkVersionAlignment(ctx) {
|
|
|
308
319
|
message: drift
|
|
309
320
|
? `This project's CLI ${cliVersion} answers it, but its Core is ${coreVersion}: templates, docs, and agent text come from CLI ${cliVersion}, components from Core ${coreVersion}.`
|
|
310
321
|
: `@astryxdesign/core v${coreVersion} is in step with @astryxdesign/cli v${cliVersion}.`,
|
|
311
|
-
...(drift ?
|
|
322
|
+
...(drift ? alignFix(ctx.cwd, cliVersion, coreVersion) : {}),
|
|
312
323
|
};
|
|
313
324
|
}
|
|
314
325
|
|
|
326
|
+
/**
|
|
327
|
+
* The fix for a CLI and Core on different releases, when a command fits.
|
|
328
|
+
* @param {string} cwd
|
|
329
|
+
* @param {string} cli
|
|
330
|
+
* @param {string} core
|
|
331
|
+
* @returns {{fix?: string}}
|
|
332
|
+
*/
|
|
333
|
+
function alignFix(cwd, cli, core) {
|
|
334
|
+
// From a folder inside a project whose package.json is not the project's,
|
|
335
|
+
// aligning the project would leave this warning in place, so no command
|
|
336
|
+
// fits there (alignCommand returns none): point at the project instead.
|
|
337
|
+
const command = alignCommand(cwd, cli, core);
|
|
338
|
+
return {fix: command ? `To align them, run: ${command}.` : NO_PROJECT_FIX};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* The fix where no install command fits: the folder's package.json is not an
|
|
343
|
+
* Astryx project's (spec AST-040 FR9), and adding there would make it one.
|
|
344
|
+
*/
|
|
345
|
+
const NO_PROJECT_FIX = RUN_FROM_PROJECT;
|
|
346
|
+
|
|
315
347
|
/**
|
|
316
348
|
* Check 5 — astryx.config.mjs (if present) loads and has a valid shape.
|
|
317
349
|
* @param {DoctorContext} ctx
|
|
@@ -1048,16 +1080,20 @@ function nameTypes(names) {
|
|
|
1048
1080
|
}
|
|
1049
1081
|
|
|
1050
1082
|
/**
|
|
1051
|
-
* The section keys
|
|
1052
|
-
* command reads them.
|
|
1083
|
+
* The section keys the field reference lists (`astryx docs
|
|
1084
|
+
* authoring/field-reference --index`), read the way that command reads them.
|
|
1053
1085
|
* @returns {Promise<{keys: Set<string>} | {keys: null, error: string}>}
|
|
1054
1086
|
*/
|
|
1055
1087
|
async function authoringTopicKeys() {
|
|
1056
1088
|
try {
|
|
1089
|
+
const {AUTHORING_REFERENCE_ROUTE} =
|
|
1090
|
+
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
1057
1091
|
const catalog = DocsCatalog.fromBuiltins();
|
|
1058
|
-
const
|
|
1059
|
-
if (!
|
|
1060
|
-
|
|
1092
|
+
const node = (await projectTree(catalog)).get(AUTHORING_REFERENCE_ROUTE);
|
|
1093
|
+
if (!node?.ref?.topicFile) {
|
|
1094
|
+
return {keys: null, error: 'the docs tree has no field reference'};
|
|
1095
|
+
}
|
|
1096
|
+
const index = indexView(await lowerTopic(catalog, guideEntry(node)));
|
|
1061
1097
|
return {keys: new Set(index.sections.map(section => section.id))};
|
|
1062
1098
|
} catch (err) {
|
|
1063
1099
|
return {
|
|
@@ -1076,7 +1112,7 @@ function surfaceProblems(surface) {
|
|
|
1076
1112
|
const problems = [];
|
|
1077
1113
|
if (surface.types === 0 && surface.untraced.length === 0) {
|
|
1078
1114
|
problems.push(
|
|
1079
|
-
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring')}\``,
|
|
1115
|
+
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring/field-reference')}\``,
|
|
1080
1116
|
);
|
|
1081
1117
|
}
|
|
1082
1118
|
for (const {module, names, reason, source, key} of surface.unreadable) {
|
|
@@ -1089,7 +1125,7 @@ function surfaceProblems(surface) {
|
|
|
1089
1125
|
? `${source} does not load`
|
|
1090
1126
|
: `${source} renders section "${key}", which the topic's index does not list`;
|
|
1091
1127
|
problems.push(
|
|
1092
|
-
`${nameTypes(names)} from ${module} ${names.length === 1 ? 'has' : 'have'} no doc in \`${formatCliCommand('docs authoring')}\`: ${why}`,
|
|
1128
|
+
`${nameTypes(names)} from ${module} ${names.length === 1 ? 'has' : 'have'} no doc in \`${formatCliCommand('docs authoring/field-reference')}\`: ${why}`,
|
|
1093
1129
|
);
|
|
1094
1130
|
}
|
|
1095
1131
|
for (const {name, reason} of surface.untraced) {
|
|
@@ -1130,7 +1166,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1130
1166
|
const audit = await auditAuthoringSelfDocs({root, sources});
|
|
1131
1167
|
const problems = [
|
|
1132
1168
|
...audit.unreachable.map(
|
|
1133
|
-
source => `${source} is not in \`${formatCliCommand('docs authoring')}\``,
|
|
1169
|
+
source => `${source} is not in \`${formatCliCommand('docs authoring/field-reference')}\``,
|
|
1134
1170
|
),
|
|
1135
1171
|
...audit.failed.map(
|
|
1136
1172
|
({source, error}) => `${source} failed to load: ${error}`,
|
|
@@ -1146,7 +1182,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1146
1182
|
: {keys: options.topicKeys};
|
|
1147
1183
|
const surface = [
|
|
1148
1184
|
...('error' in topic
|
|
1149
|
-
? [`\`${formatCliCommand('docs authoring')}\` could not be read: ${topic.error}`]
|
|
1185
|
+
? [`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: ${topic.error}`]
|
|
1150
1186
|
: []),
|
|
1151
1187
|
...surfaceProblems(
|
|
1152
1188
|
await auditAuthoringSurface({root, sources, topicKeys: topic.keys}),
|
|
@@ -1170,7 +1206,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1170
1206
|
id,
|
|
1171
1207
|
label,
|
|
1172
1208
|
status: 'pass',
|
|
1173
|
-
message: `All ${audit.sections} authoring schemas are readable in \`${formatCliCommand('docs authoring')}\`.`,
|
|
1209
|
+
message: `All ${audit.sections} authoring schemas are readable in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
1174
1210
|
};
|
|
1175
1211
|
} catch (err) {
|
|
1176
1212
|
return {
|
|
@@ -1238,7 +1274,7 @@ export async function checkCliDocs(_ctx, options = {}) {
|
|
|
1238
1274
|
id,
|
|
1239
1275
|
label,
|
|
1240
1276
|
status: 'pass',
|
|
1241
|
-
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring')}\`.`,
|
|
1277
|
+
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
1242
1278
|
};
|
|
1243
1279
|
} catch (err) {
|
|
1244
1280
|
return {
|
|
@@ -1355,7 +1391,7 @@ export async function checkDocsProgressiveDisclosure(ctx) {
|
|
|
1355
1391
|
// A guide the docs tree places is a topic read by its route; it is held
|
|
1356
1392
|
// to the same budget as every flat topic.
|
|
1357
1393
|
const guides = [...(await projectTree(catalog)).nodes.values()]
|
|
1358
|
-
// A flat topic in
|
|
1394
|
+
// A flat topic in a topic level is checked above, as a topic.
|
|
1359
1395
|
.filter(node => node.kind === 'generic' && !node.ref?.flatTopic)
|
|
1360
1396
|
.map(guideEntry);
|
|
1361
1397
|
for (const entry of [...catalog.entries(), ...guides]) {
|
|
@@ -1456,6 +1492,10 @@ export function checkCliCommand(ctx) {
|
|
|
1456
1492
|
* each file of the computer-level agent text against this release's rendering
|
|
1457
1493
|
* @property {import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings} [agentTextSettings]
|
|
1458
1494
|
* the person's choices about the computer-level agent text
|
|
1495
|
+
* @property {string | null} [agentTextCommand] the command the skill file
|
|
1496
|
+
* tells agents to run, or null
|
|
1497
|
+
* @property {string | null} [agentTextInstall] the install step the skill
|
|
1498
|
+
* file records for when that command is not found, or null
|
|
1459
1499
|
* @property {string} [cwd] the folder doctor runs in, for the printed fix
|
|
1460
1500
|
* @property {import('../../foundation/release/notices.mjs').GlobalBehind | null} [globalBehind]
|
|
1461
1501
|
* the CLI installed for the computer, when it is older than the newest
|
|
@@ -1468,7 +1508,7 @@ export function checkCliCommand(ctx) {
|
|
|
1468
1508
|
* the newest update notice that did not print, and why (diagnostic only)
|
|
1469
1509
|
* @property {{pid: number | null, host: string | null, since: number} | null} [stateLock]
|
|
1470
1510
|
* who holds the state file's lock now (diagnostic only)
|
|
1471
|
-
* @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null}>} [searchPathCommands]
|
|
1511
|
+
* @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null, runner?: boolean}>} [searchPathCommands]
|
|
1472
1512
|
* every `astryx` on the search path, with the command that upgrades it
|
|
1473
1513
|
* the `astryx` commands on the search path, in order
|
|
1474
1514
|
* @property {import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]} [computerIntegrations]
|
|
@@ -1555,6 +1595,7 @@ function checkFailureNote(failed) {
|
|
|
1555
1595
|
const SKIP_REASONS = {
|
|
1556
1596
|
'already-shown': 'it had already printed that day',
|
|
1557
1597
|
'no-newer': 'no newer release was known',
|
|
1598
|
+
'no-project': 'the folder belongs to no Astryx project, so no install command fits',
|
|
1558
1599
|
};
|
|
1559
1600
|
|
|
1560
1601
|
/**
|
|
@@ -1678,6 +1719,8 @@ export function checkComputerAgentText(ctx) {
|
|
|
1678
1719
|
};
|
|
1679
1720
|
}
|
|
1680
1721
|
const entries = ctx.agentText ?? /** @type {NonNullable<typeof state>} */ (state).entries;
|
|
1722
|
+
const command = ctx.agentText ? (ctx.agentTextCommand ?? null) : /** @type {NonNullable<typeof state>} */ (state).command;
|
|
1723
|
+
const recorded = (ctx.agentText ? ctx.agentTextInstall : /** @type {NonNullable<typeof state>} */ (state).install) ?? null;
|
|
1681
1724
|
const fix = `Run \`${formatCliCommand('astryx init --user', ctx.cwd)}\`.`;
|
|
1682
1725
|
const [file, ...links] = entries;
|
|
1683
1726
|
const home = (/** @type {{path: string}} */ e) => displayHomePath(e.path);
|
|
@@ -1706,9 +1749,29 @@ export function checkComputerAgentText(ctx) {
|
|
|
1706
1749
|
};
|
|
1707
1750
|
}
|
|
1708
1751
|
const current = file.state === 'current';
|
|
1752
|
+
const status = `${current ? 'The computer-level agent text matches this release' : "The computer-level agent text differs from this release's"}: ${home(file)}.`;
|
|
1753
|
+
// The skill outlives the CLI it names when the home folder outlasts the
|
|
1754
|
+
// folder the CLI is installed in, as on a machine whose system folders
|
|
1755
|
+
// reset on restart. Reported only when no `astryx` command is on the search
|
|
1756
|
+
// path at all, apart from a package runner's own copy, which it puts first
|
|
1757
|
+
// only for the run it starts (the way back when the global CLI is gone).
|
|
1758
|
+
// Any other `astryx`, even one the scan cannot trace to the package, such
|
|
1759
|
+
// as the shim of Volta, asdf or mise, may well run the CLI, so doctor stays
|
|
1760
|
+
// quiet here and cli-on-path reports what it can; never a false "gone".
|
|
1761
|
+
// The reinstalled copy refreshes the text too.
|
|
1762
|
+
const rows = ctx.searchPathCommands;
|
|
1763
|
+
if (command === COMPUTER_COMMAND && rows && !rows.some(r => !r.runner)) {
|
|
1764
|
+
return {
|
|
1765
|
+
...base,
|
|
1766
|
+
message: `${status} It tells agents to run \`${COMPUTER_COMMAND}\`, but no \`${COMPUTER_COMMAND}\` command is on the search path, so agents that read it find no CLI to run (as when a restart removes the CLI installed for the computer and keeps the home folder).${linkNote}`,
|
|
1767
|
+
fix: recorded
|
|
1768
|
+
? `Run \`${recorded}\`, the step the skill names for when \`${COMPUTER_COMMAND}\` is not found.`
|
|
1769
|
+
: `Install it for the computer: \`${COMPUTER_INSTALL_STEP}\`.`,
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1709
1772
|
return {
|
|
1710
1773
|
...base,
|
|
1711
|
-
message: `${
|
|
1774
|
+
message: `${status}${linkNote}`,
|
|
1712
1775
|
...(!current || missing.length > 0 || dangling.length > 0 ? {fix} : {}),
|
|
1713
1776
|
};
|
|
1714
1777
|
}
|
|
@@ -1760,12 +1823,14 @@ export function checkComputerIntegrations(ctx) {
|
|
|
1760
1823
|
* Inside a project, the integrations installed for the computer that the
|
|
1761
1824
|
* project does not install: available, never used (spec AST-081 FR12).
|
|
1762
1825
|
* Always info.
|
|
1763
|
-
* @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: (name: string) => string}} input
|
|
1826
|
+
* @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: ((name: string) => string) | null, elsewhere?: boolean}} input
|
|
1764
1827
|
* `install`: the command that adds a package with the project's package
|
|
1765
|
-
* manager (read by the adapter)
|
|
1828
|
+
* manager (read by the adapter); null when the folder belongs to no
|
|
1829
|
+
* project, or `elsewhere`: its package.json is not the project's, where the
|
|
1830
|
+
* fix points at the project's folder
|
|
1766
1831
|
* @returns {DoctorCheck}
|
|
1767
1832
|
*/
|
|
1768
|
-
export function checkComputerIntegrationsAvailable({installed, candidates, install}) {
|
|
1833
|
+
export function checkComputerIntegrationsAvailable({installed, candidates, install, elsewhere = false}) {
|
|
1769
1834
|
const available = candidates.filter(c => !installed.has(c.name));
|
|
1770
1835
|
const base = {id: 'computer-integrations', label: 'Integrations installed for this computer', status: /** @type {const} */ ('info')};
|
|
1771
1836
|
if (available.length === 0) {
|
|
@@ -1775,7 +1840,11 @@ export function checkComputerIntegrationsAvailable({installed, candidates, insta
|
|
|
1775
1840
|
return {
|
|
1776
1841
|
...base,
|
|
1777
1842
|
message: `Installed for this computer but not in this project, so not used here: ${available.map(c => c.name).join(', ')}.`,
|
|
1778
|
-
|
|
1843
|
+
...(add
|
|
1844
|
+
? {fix: `To use one in this project, run ${available.map(c => `\`${add(c.name)}\``).join(' or ')}.`}
|
|
1845
|
+
: elsewhere
|
|
1846
|
+
? {fix: NO_PROJECT_FIX}
|
|
1847
|
+
: {}),
|
|
1779
1848
|
};
|
|
1780
1849
|
}
|
|
1781
1850
|
|
|
@@ -2034,7 +2103,7 @@ export async function runChecks(options = {}) {
|
|
|
2034
2103
|
{
|
|
2035
2104
|
const loadedNames = (project?.loadedIntegrations ?? []).map((/** @type {{name: string}} */ i) => i.name);
|
|
2036
2105
|
const candidates = await computerIntegrationsToAdd(cwd, loadedNames);
|
|
2037
|
-
checks.push(checkComputerIntegrationsAvailable({installed: new Set(loadedNames), candidates, install: installCommandFor(cwd)}));
|
|
2106
|
+
checks.push(checkComputerIntegrationsAvailable({installed: new Set(loadedNames), candidates, install: installCommandFor(cwd), elsewhere: insideProjectElsewhere(cwd)}));
|
|
2038
2107
|
}
|
|
2039
2108
|
checks.push(await checkAuthoringDocs(ctx));
|
|
2040
2109
|
checks.push(await checkCliDocs(ctx));
|
|
@@ -31,7 +31,9 @@ import {
|
|
|
31
31
|
checkIntegrationIssues,
|
|
32
32
|
checkVersionAlignment,
|
|
33
33
|
checkPackageManager,
|
|
34
|
+
checkComputerIntegrationsAvailable,
|
|
34
35
|
} from './doctor.mjs';
|
|
36
|
+
import {installCommandFor} from './_adapter.mjs';
|
|
35
37
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
36
38
|
import {Project} from '../../foundation/config/project.mjs';
|
|
37
39
|
|
|
@@ -223,7 +225,13 @@ describe("doctor — the project's own CLI and Core on different releases", () =
|
|
|
223
225
|
).version;
|
|
224
226
|
/** @param {string} core */
|
|
225
227
|
const at = core => {
|
|
228
|
+
// A project as spec:AST-040 FR9 defines it: its package.json declares
|
|
229
|
+
// an Astryx package.
|
|
226
230
|
const dir = mkProject({
|
|
231
|
+
'package.json': JSON.stringify({
|
|
232
|
+
name: 'app',
|
|
233
|
+
dependencies: {'@astryxdesign/core': core},
|
|
234
|
+
}),
|
|
227
235
|
'package-lock.json': '{}',
|
|
228
236
|
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
229
237
|
name: '@astryxdesign/core',
|
|
@@ -257,6 +265,10 @@ describe("doctor — the project's own CLI and Core on different releases", () =
|
|
|
257
265
|
|
|
258
266
|
it('in a project with no CLI of its own, warns that the started copy answered and names the command that adds the CLI at Core', () => {
|
|
259
267
|
const dir = mkProject({
|
|
268
|
+
'package.json': JSON.stringify({
|
|
269
|
+
name: 'app',
|
|
270
|
+
dependencies: {'@astryxdesign/core': '0.0.1'},
|
|
271
|
+
}),
|
|
260
272
|
'package-lock.json': '{}',
|
|
261
273
|
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
262
274
|
name: '@astryxdesign/core',
|
|
@@ -279,6 +291,52 @@ describe("doctor — the project's own CLI and Core on different releases", () =
|
|
|
279
291
|
});
|
|
280
292
|
});
|
|
281
293
|
|
|
294
|
+
describe('the command that adds an integration installed for the computer', () => {
|
|
295
|
+
const app = () =>
|
|
296
|
+
mkProject({
|
|
297
|
+
'package.json': JSON.stringify({
|
|
298
|
+
name: 'app',
|
|
299
|
+
dependencies: {'@astryxdesign/core': '0.7.0'},
|
|
300
|
+
}),
|
|
301
|
+
'pnpm-lock.yaml': '',
|
|
302
|
+
'tools/codegen/package.json': JSON.stringify({name: 'codegen'}),
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('adds it in the project, with its package manager', () => {
|
|
306
|
+
const dir = app();
|
|
307
|
+
expect(installCommandFor(dir)?.('@acme/a')).toBe('pnpm add @acme/a');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// A package.json that is not the project's (spec AST-040 FR9): a run
|
|
311
|
+
// there loads integrations from it, so a package added to the project
|
|
312
|
+
// stays unused there. No command; the fix points at the project.
|
|
313
|
+
it("from a tool folder inside the project, names no command and points at the project's folder", () => {
|
|
314
|
+
const dir = app();
|
|
315
|
+
expect(installCommandFor(path.join(dir, 'tools', 'codegen'))).toBeNull();
|
|
316
|
+
const c = checkComputerIntegrationsAvailable({
|
|
317
|
+
installed: new Set(),
|
|
318
|
+
candidates: [/** @type {any} */ ({name: '@acme/a'})],
|
|
319
|
+
install: null,
|
|
320
|
+
elsewhere: true,
|
|
321
|
+
});
|
|
322
|
+
expect(c.fix).toBe(
|
|
323
|
+
"Run this from the Astryx project's folder, or declare an Astryx package in this folder's package.json to make it a project of its own.",
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('in a folder that belongs to no project, names no command', () => {
|
|
328
|
+
const dir = mkProject({'package.json': JSON.stringify({name: 'tool'})});
|
|
329
|
+
expect(installCommandFor(dir)).toBeNull();
|
|
330
|
+
const c = checkComputerIntegrationsAvailable({
|
|
331
|
+
installed: new Set(),
|
|
332
|
+
candidates: [/** @type {any} */ ({name: '@acme/a'})],
|
|
333
|
+
install: null,
|
|
334
|
+
});
|
|
335
|
+
expect(c.status).toBe('info');
|
|
336
|
+
expect(c).not.toHaveProperty('fix');
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
282
340
|
describe('checkCliCommand', () => {
|
|
283
341
|
it('is informational when no integration declares a command', () => {
|
|
284
342
|
const dir = mkProject({'pnpm-lock.yaml': ''});
|
|
@@ -652,7 +710,7 @@ describe('checkAuthoringDocs', () => {
|
|
|
652
710
|
it('passes when every authoring self-doc is reachable and fits one read', async () => {
|
|
653
711
|
const c = await checkAuthoringDocs();
|
|
654
712
|
expect(c).toMatchObject({id: 'authoring-docs', status: 'pass'});
|
|
655
|
-
expect(c.message).toContain(formatCliCommand('docs authoring'));
|
|
713
|
+
expect(c.message).toContain(formatCliCommand('docs authoring/field-reference'));
|
|
656
714
|
}, SLOW);
|
|
657
715
|
});
|
|
658
716
|
|
|
@@ -680,7 +738,7 @@ describe('checkCliDocs', () => {
|
|
|
680
738
|
id: 'cli-docs',
|
|
681
739
|
label: 'CLI docs',
|
|
682
740
|
status: 'pass',
|
|
683
|
-
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring')}\`.`,
|
|
741
|
+
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
684
742
|
});
|
|
685
743
|
},
|
|
686
744
|
SLOW,
|
|
@@ -790,7 +848,7 @@ describe('checkDocsTree', () => {
|
|
|
790
848
|
describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
791
849
|
const NAMESPACE = 'doctypes/namespace/namespace.doc.mjs';
|
|
792
850
|
const NAMESPACE_TYPES =
|
|
793
|
-
`NamespaceDoc, NamespaceProviderScope, NamespaceSlotAcceptance, NamespaceSlot, NamespaceAdoptionSource, NamespaceAdoptionRule from doctypes/namespace/type.ts have no doc in \`${formatCliCommand('docs authoring')}\``;
|
|
851
|
+
`NamespaceDoc, NamespaceProviderScope, NamespaceSlotAcceptance, NamespaceSlot, NamespaceAdoptionSource, NamespaceAdoptionRule from doctypes/namespace/type.ts have no doc in \`${formatCliCommand('docs authoring/field-reference')}\``;
|
|
794
852
|
const SURFACE_FIX =
|
|
795
853
|
'Put a self-doc beside each module whose types @astryxdesign/cli/authoring exports and list it in AUTHORING_SELF_DOCS; export what each listed self-doc documents, or remove that self-doc.';
|
|
796
854
|
|
|
@@ -820,7 +878,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
820
878
|
id: 'authoring-docs',
|
|
821
879
|
label: 'Authoring docs',
|
|
822
880
|
status: 'pass',
|
|
823
|
-
message: `All ${AUTHORING_SELF_DOCS.length} authoring schemas are readable in \`${formatCliCommand('docs authoring')}\`.`,
|
|
881
|
+
message: `All ${AUTHORING_SELF_DOCS.length} authoring schemas are readable in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
824
882
|
});
|
|
825
883
|
},
|
|
826
884
|
SLOW,
|
|
@@ -849,7 +907,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
849
907
|
});
|
|
850
908
|
expect(c.status).toBe('fail');
|
|
851
909
|
expect(c.message).toBe(
|
|
852
|
-
`2 problems: ${NAMESPACE} is not in \`${formatCliCommand('docs authoring')}\`; ${NAMESPACE_TYPES}: ${NAMESPACE} is not listed in AUTHORING_SELF_DOCS`,
|
|
910
|
+
`2 problems: ${NAMESPACE} is not in \`${formatCliCommand('docs authoring/field-reference')}\`; ${NAMESPACE_TYPES}: ${NAMESPACE} is not listed in AUTHORING_SELF_DOCS`,
|
|
853
911
|
);
|
|
854
912
|
},
|
|
855
913
|
SLOW,
|
|
@@ -858,7 +916,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
858
916
|
it(
|
|
859
917
|
"fails when the topic's index no longer exposes the NamespaceDoc section",
|
|
860
918
|
async () => {
|
|
861
|
-
const index = await docs('authoring', undefined, {index: true});
|
|
919
|
+
const index = await docs('authoring/field-reference', undefined, {index: true});
|
|
862
920
|
const topicKeys = new Set(
|
|
863
921
|
index.data.sections
|
|
864
922
|
.map((/** @type {any} */ s) => s.id)
|
|
@@ -947,7 +1005,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
947
1005
|
expect(c.fix).toBe(SURFACE_FIX);
|
|
948
1006
|
expect(c.message).toMatch(
|
|
949
1007
|
new RegExp(
|
|
950
|
-
`^[A-Za-z, ]+ from ${escape(module)} have no doc in \`${escape(formatCliCommand('docs authoring'))}\`: no self-doc sits beside ${escape(module)}$`,
|
|
1008
|
+
`^[A-Za-z, ]+ from ${escape(module)} have no doc in \`${escape(formatCliCommand('docs authoring/field-reference'))}\`: no self-doc sits beside ${escape(module)}$`,
|
|
951
1009
|
),
|
|
952
1010
|
);
|
|
953
1011
|
for (const name of names) {
|
|
@@ -990,7 +1048,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
990
1048
|
expect(await checkAuthoringDocs()).toMatchObject({
|
|
991
1049
|
status: 'fail',
|
|
992
1050
|
message:
|
|
993
|
-
`\`${formatCliCommand('docs authoring')}\` could not be read: no built-in docs`,
|
|
1051
|
+
`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: no built-in docs`,
|
|
994
1052
|
fix: SURFACE_FIX,
|
|
995
1053
|
});
|
|
996
1054
|
} finally {
|
|
@@ -1011,7 +1069,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
1011
1069
|
const c = await checkAuthoringDocs(undefined, {root});
|
|
1012
1070
|
expect(c.status).toBe('fail');
|
|
1013
1071
|
expect(c.message).toContain(
|
|
1014
|
-
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring')}\``,
|
|
1072
|
+
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring/field-reference')}\``,
|
|
1015
1073
|
);
|
|
1016
1074
|
},
|
|
1017
1075
|
SLOW,
|
package/api/hook/hook.mjs
CHANGED
|
@@ -43,7 +43,7 @@ export async function hook(name, options = {}) {
|
|
|
43
43
|
zh = false,
|
|
44
44
|
} = options;
|
|
45
45
|
|
|
46
|
-
// Default detail level mirrors the CLI (see commands/hook
|
|
46
|
+
// Default detail level mirrors the CLI (see commands/hook.mjs):
|
|
47
47
|
// single-hook views default to 'full', list-style views (--list,
|
|
48
48
|
// --category, or no name) default to 'brief' (scannable name lists).
|
|
49
49
|
// Keeping this in sync with the CLI is what the API↔CLI parity test checks.
|
|
@@ -37,6 +37,7 @@ const componentDoc = name =>
|
|
|
37
37
|
`export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
|
|
38
38
|
/** @param {string} name */
|
|
39
39
|
const componentSource = name => `export function ${name}() { return null; }\n`;
|
|
40
|
+
/** @param {string} name */
|
|
40
41
|
const templateSource = name =>
|
|
41
42
|
`export default function ${name}() { return null; }\n`;
|
|
42
43
|
/** @param {string} name */
|
|
@@ -398,9 +399,9 @@ describe('unreachable_contribution fixes hold when followed', () => {
|
|
|
398
399
|
const dir = writePackage({
|
|
399
400
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
400
401
|
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
401
|
-
'templates/hero.tsx':
|
|
402
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
402
403
|
'src/blocks/Carousel.doc.mjs': `export default {type: 'block', name: 'Carousel', displayName: 'Carousel', aspectRatio: 1};\n`,
|
|
403
|
-
'src/blocks/Carousel.tsx':
|
|
404
|
+
'src/blocks/Carousel.tsx': templateSource('Carousel'),
|
|
404
405
|
});
|
|
405
406
|
|
|
406
407
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -423,7 +424,7 @@ describe('unreachable_contribution fixes hold when followed', () => {
|
|
|
423
424
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
424
425
|
'templates/.keep': '',
|
|
425
426
|
'src/blocks/Carousel.doc.mjs': `export default {type: 'block', name: 'Carousel', displayName: 'Carousel', aspectRatio: 1};\n`,
|
|
426
|
-
'src/blocks/Carousel.tsx':
|
|
427
|
+
'src/blocks/Carousel.tsx': templateSource('Carousel'),
|
|
427
428
|
});
|
|
428
429
|
|
|
429
430
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -687,9 +688,9 @@ describe('fixes never move a contribution onto a name its root already has', ()
|
|
|
687
688
|
const dir = writePackage({
|
|
688
689
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
689
690
|
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
690
|
-
'templates/hero.tsx':
|
|
691
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
691
692
|
'extra/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
692
|
-
'extra/hero.tsx':
|
|
693
|
+
'extra/hero.tsx': templateSource('Hero'),
|
|
693
694
|
});
|
|
694
695
|
|
|
695
696
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -169,6 +169,7 @@ const writeNamed = files =>
|
|
|
169
169
|
version: '1.0.0',
|
|
170
170
|
exports: {
|
|
171
171
|
'./components/*': './components/*.tsx',
|
|
172
|
+
'./templates/*': './templates/*.tsx',
|
|
172
173
|
'.': './index.ts',
|
|
173
174
|
},
|
|
174
175
|
});
|
|
@@ -534,7 +535,14 @@ describe('block component names', () => {
|
|
|
534
535
|
'export function Panel() { return null; }\nexport const UI = {};\nexport const Lib = {};\nexport function pick() { return null; }\n',
|
|
535
536
|
...files,
|
|
536
537
|
},
|
|
537
|
-
{
|
|
538
|
+
{
|
|
539
|
+
name: '@acme/kit',
|
|
540
|
+
version: '1.0.0',
|
|
541
|
+
exports: {
|
|
542
|
+
'.': './index.tsx',
|
|
543
|
+
'./templates/*': './templates/*.tsx',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
538
546
|
);
|
|
539
547
|
/** @param {string} extra */
|
|
540
548
|
const block = extra =>
|
|
@@ -572,6 +580,9 @@ describe('block component names', () => {
|
|
|
572
580
|
),
|
|
573
581
|
'templates/account-card.tsx':
|
|
574
582
|
"import {Helper} from 'some-lib';\nexport default function A() {\n return <Helper />;\n}\n",
|
|
583
|
+
// The package root the doc's derived import names exports the component.
|
|
584
|
+
'index.tsx':
|
|
585
|
+
"export function Panel() { return null; }\nexport {AcmeWidget} from './components/AcmeWidget';\n",
|
|
575
586
|
});
|
|
576
587
|
|
|
577
588
|
expect(await allOf(dir)).toEqual([]);
|
|
@@ -83,6 +83,10 @@ export type ValidateResult = {
|
|
|
83
83
|
*/
|
|
84
84
|
listed?: import("../../foundation/integrations/issue").AstryxIntegrationIssue[] | undefined;
|
|
85
85
|
integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* what the public-import check could not judge
|
|
88
|
+
*/
|
|
89
|
+
publicImports?: import("./validate-integration.type.mjs").PublicImportsReport | undefined;
|
|
86
90
|
};
|
|
87
91
|
import { validateLoadedIntegration } from '../../foundation/integrations/validate-contributions.mjs';
|
|
88
92
|
import { isListedIssue } from '../../foundation/integrations/validate-contributions.mjs';
|
|
@@ -70,6 +70,12 @@ import {
|
|
|
70
70
|
rootProblem,
|
|
71
71
|
} from '../../foundation/integrations/validate-contributions.mjs';
|
|
72
72
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
73
|
+
import {cliPeerVersionProblem} from '../../foundation/integrations/cli-peer-version.mjs';
|
|
74
|
+
import {publicImportIssues} from '../../foundation/integrations/public-imports.mjs';
|
|
75
|
+
import {runChoice} from '../../foundation/release/run-context.mjs';
|
|
76
|
+
|
|
77
|
+
/** The running CLI is outside the package's `@astryxdesign/cli` peer range. */
|
|
78
|
+
const CLI_PEER_VERSION = 'cli_peer_version';
|
|
73
79
|
|
|
74
80
|
export {validateLoadedIntegration, isListedIssue};
|
|
75
81
|
|
|
@@ -92,6 +98,8 @@ export {validateLoadedIntegration, isListedIssue};
|
|
|
92
98
|
* may not fail `--strict` until the next (architecture:cli-surface INV35);
|
|
93
99
|
* `integration verify` still fails on a package.json npm cannot pack.
|
|
94
100
|
* @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} [integration]
|
|
101
|
+
* @property {import('./validate-integration.type.mjs').PublicImportsReport} [publicImports]
|
|
102
|
+
* what the public-import check could not judge
|
|
95
103
|
*/
|
|
96
104
|
|
|
97
105
|
/**
|
|
@@ -278,13 +286,15 @@ async function findUnreachableContributionIssues(
|
|
|
278
286
|
* Shared core for the local and installed entry points.
|
|
279
287
|
* @param {string} packageDir
|
|
280
288
|
* @param {{name: string, version?: string}} identity
|
|
281
|
-
* @param {{scanUnreachable?: boolean}} [options]
|
|
289
|
+
* @param {{scanUnreachable?: boolean, own?: boolean, cwd?: string}} [options]
|
|
290
|
+
* `own`: the package is the one being authored in the current folder;
|
|
291
|
+
* `cwd`: the folder whose package manager an install command names
|
|
282
292
|
* @returns {Promise<ValidateResult>}
|
|
283
293
|
*/
|
|
284
294
|
async function validateAtPackageDir(
|
|
285
295
|
packageDir,
|
|
286
296
|
identity,
|
|
287
|
-
{scanUnreachable = false} = {},
|
|
297
|
+
{scanUnreachable = false, own = false, cwd = packageDir} = {},
|
|
288
298
|
) {
|
|
289
299
|
/** @type {Issue[]} */
|
|
290
300
|
const issues = [];
|
|
@@ -426,6 +436,24 @@ async function validateAtPackageDir(
|
|
|
426
436
|
issues.push(issue);
|
|
427
437
|
}
|
|
428
438
|
}
|
|
439
|
+
// The running CLI outside the package's `@astryxdesign/cli` peer range is a
|
|
440
|
+
// note for the same reason. It is built here, not among the contribution
|
|
441
|
+
// checks, so `integration verify` (which reports their layout findings)
|
|
442
|
+
// does not see it.
|
|
443
|
+
// The version an upgrade starts from is the project's: its own CLI's, or,
|
|
444
|
+
// with none, its Core's, as the project-upgrade notice takes it.
|
|
445
|
+
const choice = runChoice(cwd);
|
|
446
|
+
const from =
|
|
447
|
+
choice.inProject && choice.copy === 'starting' && choice.coreVersion
|
|
448
|
+
? choice.coreVersion
|
|
449
|
+
: undefined;
|
|
450
|
+
const peerProblem = cliPeerVersionProblem(loaded, undefined, cwd, {
|
|
451
|
+
own,
|
|
452
|
+
from,
|
|
453
|
+
});
|
|
454
|
+
if (peerProblem) {
|
|
455
|
+
(result.notes ??= []).push({code: CLI_PEER_VERSION, message: peerProblem});
|
|
456
|
+
}
|
|
429
457
|
if (loaded.themes && !rootProblem(loaded.themes))
|
|
430
458
|
issues.push(...unreadThemeFolderIssues(packageDir, loaded));
|
|
431
459
|
// What the docs say that no reader serves: a prop listed twice, an
|
|
@@ -444,6 +472,14 @@ async function validateAtPackageDir(
|
|
|
444
472
|
packageDir,
|
|
445
473
|
)),
|
|
446
474
|
);
|
|
475
|
+
// What the package tells apps to import, read from source: package.json
|
|
476
|
+
// `exports`, docs, examples and template imports.
|
|
477
|
+
const publicImports = await publicImportIssues(packageDir, loaded);
|
|
478
|
+
issues.push(...publicImports.issues);
|
|
479
|
+
// Each finding is a note until the next minor makes it a warning.
|
|
480
|
+
if (publicImports.notes.length > 0)
|
|
481
|
+
(result.notes ??= []).push(...publicImports.notes);
|
|
482
|
+
result.publicImports = publicImports.report;
|
|
447
483
|
if (scanUnreachable) {
|
|
448
484
|
issues.push(
|
|
449
485
|
...(await findUnreachableContributionIssues(
|
|
@@ -507,7 +543,7 @@ export async function validateLocalIntegration(cwd = process.cwd()) {
|
|
|
507
543
|
const result = await validateAtPackageDir(
|
|
508
544
|
packageDir,
|
|
509
545
|
{name, version: pkg.version},
|
|
510
|
-
{scanUnreachable: true},
|
|
546
|
+
{scanUnreachable: true, own: true},
|
|
511
547
|
);
|
|
512
548
|
(result.listed ??= []).unshift(
|
|
513
549
|
...fields,
|
|
@@ -642,10 +678,11 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
|
642
678
|
};
|
|
643
679
|
}
|
|
644
680
|
|
|
645
|
-
return validateAtPackageDir(
|
|
646
|
-
|
|
647
|
-
version: pkg.version,
|
|
648
|
-
|
|
681
|
+
return validateAtPackageDir(
|
|
682
|
+
packageDir,
|
|
683
|
+
{name: pkg.name ?? spec, version: pkg.version},
|
|
684
|
+
{cwd},
|
|
685
|
+
);
|
|
649
686
|
}
|
|
650
687
|
|
|
651
688
|
/**
|
|
@@ -744,6 +781,10 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
744
781
|
...(docTypes ? {docTypes} : {}),
|
|
745
782
|
...(docNames ? {docNames} : {}),
|
|
746
783
|
...(blockComponents ? {blockComponents} : {}),
|
|
784
|
+
// What the public-import check could not judge: listed, never failed on.
|
|
785
|
+
...(result.found && result.publicImports
|
|
786
|
+
? {publicImports: result.publicImports}
|
|
787
|
+
: {}),
|
|
747
788
|
},
|
|
748
789
|
};
|
|
749
790
|
}
|