@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.78641f8
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 +63 -63
- package/api/component/_adapter.mjs +4 -3
- package/api/component/component.mjs +13 -6
- package/api/component/doc-links.test.mjs +33 -0
- package/api/docs/_adapter.d.mts +80 -0
- package/api/docs/_adapter.mjs +261 -11
- package/api/docs/detail/detail.mjs +8 -0
- package/api/docs/docOverlays.test.mjs +2 -1
- package/api/docs/docs.d.mts +16 -6
- package/api/docs/docs.doc.mjs +1 -1
- package/api/docs/docs.mjs +55 -6
- package/api/docs/docs.type.d.mts +28 -2
- package/api/docs/docs.type.mjs +13 -3
- package/api/docs/guide-route-targets.test.mjs +1002 -0
- package/api/docs/index/index.mjs +9 -0
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +85 -0
- package/api/docs/list/list.mjs +7 -1
- package/api/docs/node/node.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +1 -1
- package/api/doctor/built-checks.mjs +43 -13
- package/api/doctor/built-checks.test.mjs +29 -0
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/_adapter.d.mts +11 -2
- package/api/integration/_adapter.mjs +30 -4
- package/api/integration/authoring-checks.mjs +29 -2
- package/api/integration/authoring-checks.test.mjs +131 -1
- package/api/integration/check/check.d.mts +4 -1
- package/api/integration/check/check.mjs +34 -4
- package/api/integration/check/check.test.mjs +49 -0
- package/api/integration/example-checks.no-npm.test.mjs +140 -0
- package/api/integration/example-checks.test.mjs +776 -0
- package/api/integration/integration-check.type.d.mts +8 -0
- package/api/integration/integration-check.type.mjs +4 -1
- package/api/integration/integrationCheck.doc.mjs +8 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +65 -1
- package/api/integration/pack-check.test.mjs +63 -0
- package/api/integration/validate-integration-case-disk.test.mjs +14 -2
- package/api/integration/validate-integration-gaps.test.mjs +43 -19
- package/api/integration/validate-integration.mjs +112 -14
- package/api/integration/validate-integration.type.d.mts +23 -4
- package/api/integration/validate-integration.type.mjs +14 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_candidate-score.d.mts +9 -3
- package/api/search/_candidate-score.mjs +90 -3
- package/api/search/_gather-components.mjs +48 -1
- package/api/search/_gather-docs.mjs +12 -2
- package/api/search/_lexical.d.mts +12 -0
- package/api/search/_lexical.mjs +3 -0
- package/api/search/_priority.mjs +5 -2
- package/api/search/_score.d.mts +2 -1
- package/api/search/_score.mjs +4 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.family-members.test.mjs +124 -0
- package/api/search/search.family-word.test.mjs +146 -0
- package/api/search/search.mjs +28 -0
- package/api/template/template-suffix.test.mjs +26 -0
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/assets/discover/official-packages.json +16 -0
- package/assets/docs/author-a-theme.doc.mjs +15 -15
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +16 -16
- package/assets/docs/is-my-code-good.doc.mjs +6 -6
- package/assets/docs/styling-overview.doc.mjs +5 -5
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
- package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
- package/assets/docs/tree/authoring.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +3 -3
- package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
- package/assets/docs/tree/checks.doc.mjs +11 -11
- package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +6 -6
- package/assets/docs/tree/codemods.doc.mjs +7 -7
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +2 -2
- package/assets/docs/tree/component-lookups.doc.mjs +6 -5
- package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
- package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
- 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/doc-syntax.doc.mjs +219 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +11 -11
- package/assets/docs/tree/global.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +1 -1
- package/assets/docs/tree/install-once.doc.mjs +4 -4
- package/assets/docs/tree/layout.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/migration-setup.doc.mjs +15 -15
- package/assets/docs/tree/migration.doc.mjs +2 -1
- package/assets/docs/tree/other-libraries.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +2 -2
- package/assets/docs/tree/problems.doc.mjs +8 -8
- package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +7 -7
- package/assets/docs/tree/quick-start.doc.mjs +9 -9
- package/assets/docs/tree/reference.doc.mjs +2 -2
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -4
- package/assets/docs/tree/start-a-template.doc.mjs +5 -5
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
- package/assets/docs/tree/styling.doc.mjs +1 -1
- package/assets/docs/tree/tailwind.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
- package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
- package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
- package/assets/docs/tree/uninstall.doc.mjs +2 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +4 -4
- package/assets/docs/tree/who-answers.doc.mjs +4 -4
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
- package/assets/docs/use-a-theme.doc.mjs +10 -10
- package/assets/docs/use-integrations.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +15 -15
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/authoring/codemod/codemod.doc.mjs +1 -1
- package/authoring/config/config.doc.mjs +4 -4
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/_schema.d.mts +4 -0
- package/authoring/doctypes/_schema.mjs +4 -0
- package/authoring/doctypes/reference/type.ts +14 -2
- package/authoring/gap-report/gap-report.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +27 -2
- package/clients/cli/commands/docs.test.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +12 -1
- package/clients/cli/commands/integration-check.doc.mjs +11 -0
- package/clients/cli/commands/integration-check.test.mjs +36 -3
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-verify.doc.mjs +1 -1
- package/clients/cli/commands/integration.mjs +15 -3
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +2 -2
- package/clients/cli/lib/define-command.mjs +5 -3
- package/foundation/agent-docs/agent-docs.d.mts +14 -2
- package/foundation/agent-docs/agent-docs.mjs +65 -4
- package/foundation/agent-docs/agent-docs.test.mjs +107 -0
- package/foundation/discovery/docs-discovery.d.mts +93 -2
- package/foundation/discovery/docs-discovery.mjs +237 -8
- package/foundation/discovery/runner-allowlist.d.mts +2 -0
- package/foundation/discovery/runner-allowlist.mjs +4 -0
- package/foundation/discovery/runner-commands.d.mts +29 -13
- package/foundation/discovery/runner-commands.mjs +253 -17
- package/foundation/discovery/stray-pointers.mjs +11 -5
- package/foundation/discovery/stray-pointers.test.mjs +6 -0
- package/foundation/discovery/template-adapter.mjs +11 -0
- package/foundation/doc-compiler/compile.mjs +8 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +7 -0
- package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
- package/foundation/doc-compiler/doc-syntax.mjs +739 -0
- package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
- package/foundation/doc-compiler/links.d.mts +13 -16
- package/foundation/doc-compiler/links.mjs +40 -7
- package/foundation/doc-compiler/tree.d.mts +5 -0
- package/foundation/doc-compiler/tree.mjs +9 -0
- package/foundation/env/package-manager.d.mts +18 -0
- package/foundation/env/package-manager.mjs +40 -0
- package/foundation/integrations/cli-requirement.d.mts +29 -0
- package/foundation/integrations/cli-requirement.mjs +47 -0
- package/foundation/integrations/cli-requirement.test.mjs +23 -2
- package/foundation/integrations/validate-contributions.d.mts +53 -0
- package/foundation/integrations/validate-contributions.mjs +788 -0
- package/foundation/response/response-types.doc.mjs +6 -6
- package/package.json +9 -9
|
@@ -15,6 +15,12 @@ export type IntegrationCheckOptions = {
|
|
|
15
15
|
* did not run, not only on errors.
|
|
16
16
|
*/
|
|
17
17
|
strict?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Also count each finding the next minor release
|
|
20
|
+
* turns into a warning (a note marked `next`) as a warning now, so `strict`
|
|
21
|
+
* fails on it.
|
|
22
|
+
*/
|
|
23
|
+
next?: boolean | undefined;
|
|
18
24
|
};
|
|
19
25
|
/**
|
|
20
26
|
* The checks `integrationCheck()` runs, in the order it runs them.
|
|
@@ -107,11 +113,13 @@ export type IntegrationCheckCommandResponse = {
|
|
|
107
113
|
name: string | null;
|
|
108
114
|
version: string | null;
|
|
109
115
|
strict: boolean;
|
|
116
|
+
next: boolean;
|
|
110
117
|
checks: IntegrationCheckResult[];
|
|
111
118
|
errors: number;
|
|
112
119
|
warnings: number;
|
|
113
120
|
skipped: string[];
|
|
114
121
|
unchecked: number;
|
|
122
|
+
upcoming: number;
|
|
115
123
|
failures: IntegrationCheckFailure[];
|
|
116
124
|
failed: boolean;
|
|
117
125
|
};
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* current directory by default.
|
|
12
12
|
* @property {boolean} [strict] Also fail on any warning and on any check that
|
|
13
13
|
* did not run, not only on errors.
|
|
14
|
+
* @property {boolean} [next] Also count each finding the next minor release
|
|
15
|
+
* turns into a warning (a note marked `next`) as a warning now, so `strict`
|
|
16
|
+
* fails on it.
|
|
14
17
|
*/
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -78,7 +81,7 @@
|
|
|
78
81
|
* @property {'integration.check'} type
|
|
79
82
|
* `unchecked` counts the items the checks list as not compared, which never
|
|
80
83
|
* fail it.
|
|
81
|
-
* @property {{validated: boolean, name: string | null, version: string | null, strict: boolean, checks: IntegrationCheckResult[], errors: number, warnings: number, skipped: string[], unchecked: number, failures: IntegrationCheckFailure[], failed: boolean}} data
|
|
84
|
+
* @property {{validated: boolean, name: string | null, version: string | null, strict: boolean, next: boolean, checks: IntegrationCheckResult[], errors: number, warnings: number, skipped: string[], unchecked: number, upcoming: number, failures: IntegrationCheckFailure[], failed: boolean}} data
|
|
82
85
|
*/
|
|
83
86
|
|
|
84
87
|
export {};
|
|
@@ -44,12 +44,19 @@ export const doc = {
|
|
|
44
44
|
description:
|
|
45
45
|
'Also fail on any warning and on any check that did not run, not only on errors. A malformed `cliCommand` is reported as a note (`invalid_cli_command`) in `data.notes` of the validate check, which fails nothing until a minor release names it.',
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
name: 'options.next',
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
default: 'false',
|
|
51
|
+
description:
|
|
52
|
+
"Also count the findings the next minor release turns into warnings, validate's notes marked `next`, as warnings now, so `strict` fails on them.",
|
|
53
|
+
},
|
|
47
54
|
],
|
|
48
55
|
returns: [
|
|
49
56
|
{
|
|
50
57
|
type: 'integration.check',
|
|
51
58
|
description:
|
|
52
|
-
"`data.validated` (false when no integration manifest was found, so nothing was checked), `data.name` and `data.version` of the package, `data.strict`, and `data.checks`, one entry per check in the order they run (`validate`, `components`, `templates`, `docs`), each with `check`, `errors` (what makes that check's own subcommand exit 1), `warnings`, `skipped` (why work did not run), `failed` (whether that subcommand exits 1), and `response`, the envelope the check returns on its own. The totals are `data.errors`, `data.warnings`, and `data.skipped` (each reason prefixed with its check); an issue every check starts from, such as one about the manifest, counts once, and every other finding counts on its own. `data.unchecked` counts the items the checks list as not compared, which never fail it. With `strict`, `data.failures` lists each warning and each piece of skipped work once again as an error in the checks' own issue format ({check, severity: `error`, code, message, component, prop, fix, file, line}, each where it applies); it is empty without `strict`. `data.failed` decides the exit code.",
|
|
59
|
+
"`data.validated` (false when no integration manifest was found, so nothing was checked), `data.name` and `data.version` of the package, `data.strict`, `data.next`, and `data.checks`, one entry per check in the order they run (`validate`, `components`, `templates`, `docs`), each with `check`, `errors` (what makes that check's own subcommand exit 1), `warnings`, `skipped` (why work did not run), `failed` (whether that subcommand exits 1), and `response`, the envelope the check returns on its own. The totals are `data.errors`, `data.warnings`, and `data.skipped` (each reason prefixed with its check); an issue every check starts from, such as one about the manifest, counts once, and every other finding counts on its own. `data.unchecked` counts the items the checks list as not compared, which never fail it. `data.upcoming` counts the findings the next minor release turns into warnings (validate's notes marked `next`), and `data.next` says whether this run counted them as warnings now. With `strict`, `data.failures` lists each warning and each piece of skipped work once again as an error in the checks' own issue format ({check, severity: `error`, code, message, component, prop, fix, file, line}, each where it applies); it is empty without `strict`. `data.failed` decides the exit code.",
|
|
53
60
|
},
|
|
54
61
|
],
|
|
55
62
|
examples: [
|
|
@@ -19,7 +19,7 @@ export const doc = {
|
|
|
19
19
|
"package's topics, or one of them and a Core topic other than the one it replaces. " +
|
|
20
20
|
'Code and examples are not compared. `fluff` lists each padding phrase, with its file ' +
|
|
21
21
|
'line, and each topic of 80 or more prose words in which fewer than half carry content. ' +
|
|
22
|
-
'`strayPointers` lists each code span that is exactly `
|
|
22
|
+
'`strayPointers` lists each code span that is exactly `{@command docs <name>}` for a doc that ' +
|
|
23
23
|
"exists, in a topic's prose, description or summary or a component doc's text fields, " +
|
|
24
24
|
'with the `{@link}` that replaces it. ' +
|
|
25
25
|
'Each entry of these lists is also a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`), so ' +
|
|
@@ -25,6 +25,7 @@ import * as os from 'node:os';
|
|
|
25
25
|
import {fileURLToPath} from 'node:url';
|
|
26
26
|
import {spawnSync} from 'node:child_process';
|
|
27
27
|
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
28
|
+
import {commandTokensIn} from '../../foundation/doc-compiler/doc-syntax.mjs';
|
|
28
29
|
import {resolvePackageDir} from '../../foundation/integrations/integrations.mjs';
|
|
29
30
|
import {
|
|
30
31
|
literalThemeName,
|
|
@@ -37,6 +38,8 @@ import {
|
|
|
37
38
|
keywordsCliProblem,
|
|
38
39
|
replacesCliProblem,
|
|
39
40
|
sectionIdsCliProblem,
|
|
41
|
+
docTokensCliProblem,
|
|
42
|
+
sectionPositionCliProblem,
|
|
40
43
|
themesCliProblem,
|
|
41
44
|
} from '../../foundation/integrations/cli-requirement.mjs';
|
|
42
45
|
import {
|
|
@@ -322,19 +325,50 @@ function extractTarball(tgzPath, extractDir) {
|
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Whether any of these doc files writes a doc token (`{@command …}`, `{@pm …}`
|
|
330
|
+
* or `{@pm-only …}`; an escaped `{@@…}` is not one).
|
|
331
|
+
* @param {unknown[]} files
|
|
332
|
+
* @returns {boolean}
|
|
333
|
+
*/
|
|
334
|
+
function writesDocTokens(files) {
|
|
335
|
+
return files.some(file => {
|
|
336
|
+
if (typeof file !== 'string') return false;
|
|
337
|
+
try {
|
|
338
|
+
return commandTokensIn(fs.readFileSync(file, 'utf8')).length > 0;
|
|
339
|
+
} catch {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
325
345
|
/**
|
|
326
346
|
* Whether any of these doc files has a section that sets `id`.
|
|
327
347
|
* @param {string[]} files
|
|
328
348
|
* @returns {Promise<boolean>}
|
|
329
349
|
*/
|
|
330
350
|
async function setsSectionIds(files) {
|
|
351
|
+
return setsSectionField(files, ['id']);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Whether any of these doc files has a section that sets one of `fields`.
|
|
356
|
+
* @param {string[]} files
|
|
357
|
+
* @param {string[]} fields
|
|
358
|
+
* @returns {Promise<boolean>}
|
|
359
|
+
*/
|
|
360
|
+
async function setsSectionField(files, fields) {
|
|
331
361
|
for (const file of files) {
|
|
332
362
|
if (typeof file !== 'string') continue;
|
|
333
363
|
const doc = /** @type {any} */ (
|
|
334
364
|
await loadTopicModule(file).catch(() => null)
|
|
335
365
|
);
|
|
336
366
|
const sections = Array.isArray(doc?.sections) ? doc.sections : [];
|
|
337
|
-
if (
|
|
367
|
+
if (
|
|
368
|
+
sections.some((/** @type {any} */ section) =>
|
|
369
|
+
fields.some(field => section?.[field] != null),
|
|
370
|
+
)
|
|
371
|
+
) {
|
|
338
372
|
return true;
|
|
339
373
|
}
|
|
340
374
|
}
|
|
@@ -1383,6 +1417,36 @@ export async function integrationPackCheck(options = {}) {
|
|
|
1383
1417
|
issues.push(error('section_ids_need_cli', idProblem));
|
|
1384
1418
|
}
|
|
1385
1419
|
}
|
|
1420
|
+
// `before` and `after` need a newer CLI than any field above. Added in a
|
|
1421
|
+
// patch release, it warns and never fails the check (INV35).
|
|
1422
|
+
if (
|
|
1423
|
+
await setsSectionField(
|
|
1424
|
+
[
|
|
1425
|
+
...records.map(record => record.path),
|
|
1426
|
+
...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),
|
|
1427
|
+
],
|
|
1428
|
+
['before', 'after'],
|
|
1429
|
+
)
|
|
1430
|
+
) {
|
|
1431
|
+
const positionProblem = sectionPositionCliProblem(pkg);
|
|
1432
|
+
if (positionProblem != null) {
|
|
1433
|
+
issues.push(warning('section_position_needs_cli', positionProblem));
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
// A doc token shows as written on a CLI before the one that renders
|
|
1437
|
+
// them. Added in a patch release, it warns and never fails (INV35).
|
|
1438
|
+
if (
|
|
1439
|
+
problem == null &&
|
|
1440
|
+
writesDocTokens([
|
|
1441
|
+
...records.map(record => record.path),
|
|
1442
|
+
...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),
|
|
1443
|
+
])
|
|
1444
|
+
) {
|
|
1445
|
+
const tokenProblem = docTokensCliProblem(pkg);
|
|
1446
|
+
if (tokenProblem != null) {
|
|
1447
|
+
issues.push(warning('doc_tokens_need_cli', tokenProblem));
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1386
1450
|
}
|
|
1387
1451
|
// A template that sets `replaces` (spec:AST-035) or `keywords` needs a CLI
|
|
1388
1452
|
// that reads the field: an older CLI drops that template and can hide the
|
|
@@ -1724,6 +1724,69 @@ describe('integrationPackCheck', () => {
|
|
|
1724
1724
|
expect(await codes()).not.toContain('section_ids_need_cli');
|
|
1725
1725
|
}, 120_000);
|
|
1726
1726
|
|
|
1727
|
+
it('warns, without failing, when a doc section sets before or after on a CLI range that rejects them', async () => {
|
|
1728
|
+
writePackage({
|
|
1729
|
+
manifest: "export default {docs: './docs'};\n",
|
|
1730
|
+
themes: false,
|
|
1731
|
+
});
|
|
1732
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
1733
|
+
const pkgFile = path.join(tmpDir, 'package.json');
|
|
1734
|
+
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
|
|
1735
|
+
pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
|
|
1736
|
+
fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
1737
|
+
const issues = async () =>
|
|
1738
|
+
(await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
|
|
1739
|
+
(/** @type {{code: string}} */ issue) =>
|
|
1740
|
+
issue.code === 'section_position_needs_cli',
|
|
1741
|
+
);
|
|
1742
|
+
// A placed guide's section counts too: an older CLI rejects the field in
|
|
1743
|
+
// any doc and hides the package's topics.
|
|
1744
|
+
fs.writeFileSync(
|
|
1745
|
+
path.join(tmpDir, 'docs', 'acme.doc.mjs'),
|
|
1746
|
+
"export default {type: 'namespace', name: 'acme', title: 'Acme', summary: 'Acme.', slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}}};\n",
|
|
1747
|
+
);
|
|
1748
|
+
fs.writeFileSync(
|
|
1749
|
+
path.join(tmpDir, 'docs', 'setup.doc.mjs'),
|
|
1750
|
+
"export default {type: 'generic', name: 'setup', title: 'Setup', description: 'Set up.', placement: {parent: 'namespace:acme', slot: 'guides'}, sections: [{id: 'overview', title: 'Overview', after: 'nothing', content: [{type: 'prose', text: 'Set up.'}]}]};\n",
|
|
1751
|
+
);
|
|
1752
|
+
expect(await issues()).toEqual([
|
|
1753
|
+
expect.objectContaining({severity: 'warning'}),
|
|
1754
|
+
]);
|
|
1755
|
+
pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
|
|
1756
|
+
fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
1757
|
+
expect(await issues()).toEqual([]);
|
|
1758
|
+
}, 120_000);
|
|
1759
|
+
|
|
1760
|
+
it('warns when a package whose docs write doc tokens has a CLI range that prints them raw', async () => {
|
|
1761
|
+
writePackage({
|
|
1762
|
+
manifest: "export default {docs: './docs'};\n",
|
|
1763
|
+
themes: false,
|
|
1764
|
+
});
|
|
1765
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
1766
|
+
const write = (/** @type {string} */ name, /** @type {string} */ text) =>
|
|
1767
|
+
fs.writeFileSync(
|
|
1768
|
+
path.join(tmpDir, 'docs', `${name}.doc.mjs`),
|
|
1769
|
+
`export default {type: 'generic', name: '${name}', title: 'Notes', description: 'Notes.', sections: [{title: 'Run', content: [{type: 'prose', text: ${JSON.stringify(text)}}]}]};\n`,
|
|
1770
|
+
);
|
|
1771
|
+
const found = async () =>
|
|
1772
|
+
(await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
|
|
1773
|
+
(/** @type {{code: string}} */ issue) => issue.code === 'doc_tokens_need_cli',
|
|
1774
|
+
);
|
|
1775
|
+
// An escaped token is shown as written by every release.
|
|
1776
|
+
write('escaped', 'Write {@@pm install x} for an install.');
|
|
1777
|
+
expect(await found()).toEqual([]);
|
|
1778
|
+
write('tokens', 'Run {@command doctor} first.');
|
|
1779
|
+
expect((await found()).map((/** @type {any} */ issue) => issue.severity)).toEqual(['warning']);
|
|
1780
|
+
const pkgFile = path.join(tmpDir, 'package.json');
|
|
1781
|
+
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
|
|
1782
|
+
pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.3'};
|
|
1783
|
+
fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
1784
|
+
expect(await found()).toHaveLength(1);
|
|
1785
|
+
pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
|
|
1786
|
+
fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
1787
|
+
expect(await found()).toEqual([]);
|
|
1788
|
+
}, 120_000);
|
|
1789
|
+
|
|
1727
1790
|
it('fails a package with a template that sets replaces on a CLI range that rejects the field', async () => {
|
|
1728
1791
|
writePackage({
|
|
1729
1792
|
manifest: "export default {templates: './templates'};\n",
|
|
@@ -70,9 +70,15 @@ describe('a doc whose name differs from its source only in case, on a case-insen
|
|
|
70
70
|
|
|
71
71
|
const {data} = await validateIntegration(undefined, {cwd: tmpDir});
|
|
72
72
|
expect(data.issues).toEqual([]);
|
|
73
|
-
|
|
73
|
+
// The component has no example template; that note is tested elsewhere.
|
|
74
|
+
expect(
|
|
75
|
+
(data.notes ?? []).filter(
|
|
76
|
+
note => note.code !== 'component_without_example',
|
|
77
|
+
),
|
|
78
|
+
).toEqual([
|
|
74
79
|
{
|
|
75
80
|
code: 'source_without_component_doc',
|
|
81
|
+
next: true,
|
|
76
82
|
message:
|
|
77
83
|
'Component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run, so there the component is missing. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',
|
|
78
84
|
},
|
|
@@ -100,9 +106,15 @@ describe('a doc whose name differs from its source only in case, on a case-insen
|
|
|
100
106
|
|
|
101
107
|
const {data} = await validateIntegration(undefined, {cwd: tmpDir});
|
|
102
108
|
expect(data.issues).toEqual([]);
|
|
103
|
-
|
|
109
|
+
// The component has no example template; that note is tested elsewhere.
|
|
110
|
+
expect(
|
|
111
|
+
(data.notes ?? []).filter(
|
|
112
|
+
note => note.code !== 'component_without_example',
|
|
113
|
+
),
|
|
114
|
+
).toEqual([
|
|
104
115
|
{
|
|
105
116
|
code: 'source_without_component_doc',
|
|
117
|
+
next: true,
|
|
106
118
|
message:
|
|
107
119
|
'Hidden component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',
|
|
108
120
|
},
|
|
@@ -127,7 +127,28 @@ async function issuesOf(dir) {
|
|
|
127
127
|
* @returns {Promise<Array<{code: string, message: string}>>}
|
|
128
128
|
*/
|
|
129
129
|
async function listedOf(dir) {
|
|
130
|
-
return (
|
|
130
|
+
return (
|
|
131
|
+
(await validateIntegration(undefined, {cwd: dir})).data.notes ?? []
|
|
132
|
+
).filter(note => !EXAMPLE_CODES.has(note.code));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The example notes, which nearly every fixture here draws (a component with
|
|
137
|
+
* no example template); authoring-checks.test.mjs covers them.
|
|
138
|
+
*/
|
|
139
|
+
const EXAMPLE_CODES = new Set([
|
|
140
|
+
'component_without_example',
|
|
141
|
+
'template_category',
|
|
142
|
+
'showcase_not_standalone',
|
|
143
|
+
'template_asset_not_packed',
|
|
144
|
+
]);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Notes without the example notes.
|
|
148
|
+
* @param {Array<{code: string, message: string, next?: boolean}> | undefined} notes
|
|
149
|
+
*/
|
|
150
|
+
function others(notes) {
|
|
151
|
+
return (notes ?? []).filter(note => !EXAMPLE_CODES.has(note.code));
|
|
131
152
|
}
|
|
132
153
|
|
|
133
154
|
/**
|
|
@@ -185,7 +206,7 @@ describe('a name that differs from its file name', () => {
|
|
|
185
206
|
expect(await issuesOf(dir)).toEqual([]);
|
|
186
207
|
const issues = await allOf(dir);
|
|
187
208
|
expect(issues.map(issue => issue.code)).toEqual(['doc_name_mismatch']);
|
|
188
|
-
expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message']);
|
|
209
|
+
expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message', 'next']);
|
|
189
210
|
expect(issues[0].message).toBe(
|
|
190
211
|
'Component doc "AcmeWidget.doc.mjs" sets name: \'AcmeWidgets\', but components/AcmeWidget.tsx, the module its import names, does not export AcmeWidgets, so Astryx lists the component as "AcmeWidget" (its file name), and `astryx component AcmeWidget` prints `import {AcmeWidgets}`. Fix: set name: \'AcmeWidget\' in AcmeWidget.doc.mjs.',
|
|
191
212
|
);
|
|
@@ -239,7 +260,7 @@ describe('a name that differs from its file name', () => {
|
|
|
239
260
|
});
|
|
240
261
|
|
|
241
262
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
242
|
-
expect(data.notes
|
|
263
|
+
expect(others(data.notes)).toEqual([]);
|
|
243
264
|
expect(data.docNames).toEqual({
|
|
244
265
|
status: 'checked',
|
|
245
266
|
findings: [],
|
|
@@ -657,7 +678,7 @@ describe('block component names', () => {
|
|
|
657
678
|
});
|
|
658
679
|
|
|
659
680
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
660
|
-
expect((data.notes
|
|
681
|
+
expect(others(data.notes).map(note => note.message)).toEqual([
|
|
661
682
|
expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
|
|
662
683
|
]);
|
|
663
684
|
expect(data.blockComponents?.unchecked).toEqual([]);
|
|
@@ -682,7 +703,7 @@ describe('block component names', () => {
|
|
|
682
703
|
});
|
|
683
704
|
|
|
684
705
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
685
|
-
expect((data.notes
|
|
706
|
+
expect(others(data.notes).map(note => note.message)).toEqual([
|
|
686
707
|
expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
|
|
687
708
|
]);
|
|
688
709
|
expect(data.blockComponents?.unchecked).toEqual([]);
|
|
@@ -838,7 +859,7 @@ describe('block component names', () => {
|
|
|
838
859
|
});
|
|
839
860
|
|
|
840
861
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
841
|
-
expect((data.notes
|
|
862
|
+
expect(others(data.notes).map(note => note.message)).toEqual([
|
|
842
863
|
expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
|
|
843
864
|
]);
|
|
844
865
|
});
|
|
@@ -857,7 +878,7 @@ describe('block component names', () => {
|
|
|
857
878
|
});
|
|
858
879
|
|
|
859
880
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
860
|
-
expect(data.notes
|
|
881
|
+
expect(others(data.notes)).toEqual([]);
|
|
861
882
|
expect(data.blockComponents?.unchecked).toEqual([
|
|
862
883
|
{
|
|
863
884
|
file: 'templates/account-card.doc.mjs',
|
|
@@ -882,7 +903,7 @@ describe('block component names', () => {
|
|
|
882
903
|
});
|
|
883
904
|
|
|
884
905
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
885
|
-
expect((data.notes
|
|
906
|
+
expect(others(data.notes).map(note => note.message)).toEqual([
|
|
886
907
|
expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
|
|
887
908
|
]);
|
|
888
909
|
expect(data.blockComponents?.unchecked).toEqual([]);
|
|
@@ -897,7 +918,7 @@ describe('block component names', () => {
|
|
|
897
918
|
});
|
|
898
919
|
|
|
899
920
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
900
|
-
expect(data.notes
|
|
921
|
+
expect(others(data.notes)).toEqual([]);
|
|
901
922
|
expect(data.blockComponents?.unchecked).toEqual([
|
|
902
923
|
{
|
|
903
924
|
file: 'templates/account-card.doc.mjs',
|
|
@@ -917,7 +938,7 @@ describe('block component names', () => {
|
|
|
917
938
|
});
|
|
918
939
|
|
|
919
940
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
920
|
-
expect((data.notes
|
|
941
|
+
expect(others(data.notes).map(note => note.message)).toEqual([
|
|
921
942
|
expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
|
|
922
943
|
]);
|
|
923
944
|
expect(data.blockComponents?.unchecked).toEqual([]);
|
|
@@ -960,7 +981,7 @@ describe('block component names', () => {
|
|
|
960
981
|
);
|
|
961
982
|
|
|
962
983
|
const {data} = await validateIntegration(undefined, {cwd: outside});
|
|
963
|
-
expect(data.notes
|
|
984
|
+
expect(others(data.notes)).toEqual([]);
|
|
964
985
|
const reason =
|
|
965
986
|
'Core is not installed, so its component names cannot be checked.';
|
|
966
987
|
expect(data.blockComponents).toEqual({
|
|
@@ -1366,9 +1387,10 @@ describe('package.json', () => {
|
|
|
1366
1387
|
).toEqual([['invalid_component', 'error']]);
|
|
1367
1388
|
}
|
|
1368
1389
|
const validate = result.data.checks[0].response.data;
|
|
1369
|
-
expect('notes' in validate ? validate.notes : undefined).toEqual([
|
|
1390
|
+
expect('notes' in validate ? others(validate.notes) : undefined).toEqual([
|
|
1370
1391
|
{
|
|
1371
1392
|
code: 'invalid_package_json',
|
|
1393
|
+
next: true,
|
|
1372
1394
|
message:
|
|
1373
1395
|
'package.json has no "name", so npm cannot pack or publish the package, and a project that installs it has no name to select it by. Fix: add "name": "@your-scope/your-package" to package.json.',
|
|
1374
1396
|
},
|
|
@@ -1890,9 +1912,11 @@ describe('layout findings 0.7.2 did not fail on', () => {
|
|
|
1890
1912
|
const validate = /** @type {any} */ (
|
|
1891
1913
|
result.data.checks[0].response.data
|
|
1892
1914
|
);
|
|
1893
|
-
expect(validate.notes.length).toBeGreaterThan(0);
|
|
1894
|
-
for (const note of validate.notes) {
|
|
1895
|
-
|
|
1915
|
+
expect(others(validate.notes).length).toBeGreaterThan(0);
|
|
1916
|
+
for (const note of others(validate.notes)) {
|
|
1917
|
+
// Listed now, a warning from the next minor release: `next`.
|
|
1918
|
+
expect(Object.keys(note).sort()).toEqual(['code', 'message', 'next']);
|
|
1919
|
+
expect(note.next).toBe(true);
|
|
1896
1920
|
expect(note.message).toContain('Fix: ');
|
|
1897
1921
|
}
|
|
1898
1922
|
} finally {
|
|
@@ -1917,7 +1941,7 @@ describe('layout findings 0.7.2 did not fail on', () => {
|
|
|
1917
1941
|
);
|
|
1918
1942
|
expect(run.status, run.stderr).toBe(0);
|
|
1919
1943
|
expect(run.stdout).toContain(
|
|
1920
|
-
'note (duplicate_component_doc): Component "AcmeWidget" has 2 docs:',
|
|
1944
|
+
'note (duplicate_component_doc): [next minor] Component "AcmeWidget" has 2 docs:',
|
|
1921
1945
|
);
|
|
1922
1946
|
expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');
|
|
1923
1947
|
});
|
|
@@ -1950,8 +1974,8 @@ describe('name findings listed until the next minor release', () => {
|
|
|
1950
1974
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
1951
1975
|
expect(data.issues).toEqual([]);
|
|
1952
1976
|
expect(/** @type {any} */ (data)[report].findings).toEqual([]);
|
|
1953
|
-
expect(data.notes
|
|
1954
|
-
expect(data.notes
|
|
1977
|
+
expect(others(data.notes).map(note => note.code)).toEqual([code]);
|
|
1978
|
+
expect(others(data.notes)[0].message).toContain('Fix: ');
|
|
1955
1979
|
|
|
1956
1980
|
const result = await integrationCheck({cwd: dir, strict: true});
|
|
1957
1981
|
expect(result.data.failures).toEqual([]);
|
|
@@ -1968,7 +1992,7 @@ describe('name findings listed until the next minor release', () => {
|
|
|
1968
1992
|
);
|
|
1969
1993
|
expect(run.status, run.stderr).toBe(0);
|
|
1970
1994
|
expect(run.stdout).toContain(
|
|
1971
|
-
'note (unknown_block_component): Template "account-card" names "AcmeGizmo" in componentsUsed',
|
|
1995
|
+
'note (unknown_block_component): [next minor] Template "account-card" names "AcmeGizmo" in componentsUsed',
|
|
1972
1996
|
);
|
|
1973
1997
|
expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');
|
|
1974
1998
|
});
|
|
@@ -37,7 +37,10 @@ import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
|
37
37
|
import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
|
|
38
38
|
import {integrationDocTypes} from '../docs/_adapter.mjs';
|
|
39
39
|
import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
integrationDocCommands,
|
|
42
|
+
integrationDocTargets,
|
|
43
|
+
} from './_adapter.mjs';
|
|
41
44
|
import {
|
|
42
45
|
THEME_SLUG_RE,
|
|
43
46
|
unreadThemeFolders,
|
|
@@ -59,6 +62,7 @@ import {
|
|
|
59
62
|
// integration-warnings need them too, and foundation must not depend on api.
|
|
60
63
|
import {
|
|
61
64
|
blockComponentsCheck,
|
|
65
|
+
componentExamplesCheck,
|
|
62
66
|
componentDocNamesCheck,
|
|
63
67
|
INVALID_CLI_COMMAND,
|
|
64
68
|
isListedIssue,
|
|
@@ -77,6 +81,15 @@ import {runChoice} from '../../foundation/release/run-context.mjs';
|
|
|
77
81
|
/** The running CLI is outside the package's `@astryxdesign/cli` peer range. */
|
|
78
82
|
const CLI_PEER_VERSION = 'cli_peer_version';
|
|
79
83
|
|
|
84
|
+
/** A doc replaces or extends a name that holds no topic and no guide. */
|
|
85
|
+
const DOC_TARGET_NOT_FOUND = 'doc_target_not_found';
|
|
86
|
+
|
|
87
|
+
/** An extension section's `before` or `after` names no section of the base. */
|
|
88
|
+
const DOC_SECTION_UNPLACED = 'doc_section_unplaced';
|
|
89
|
+
|
|
90
|
+
/** Two docs of one package replace one guide; only the last one is read. */
|
|
91
|
+
const DUPLICATE_GUIDE_REPLACEMENT = 'duplicate_guide_replacement';
|
|
92
|
+
|
|
80
93
|
export {validateLoadedIntegration, isListedIssue};
|
|
81
94
|
|
|
82
95
|
/**
|
|
@@ -477,8 +490,11 @@ async function validateAtPackageDir(
|
|
|
477
490
|
const publicImports = await publicImportIssues(packageDir, loaded);
|
|
478
491
|
issues.push(...publicImports.issues);
|
|
479
492
|
// Each finding is a note until the next minor makes it a warning.
|
|
493
|
+
// Listed now, a warning from the next minor release: `next`.
|
|
480
494
|
if (publicImports.notes.length > 0)
|
|
481
|
-
(result.notes ??= []).push(
|
|
495
|
+
(result.notes ??= []).push(
|
|
496
|
+
...publicImports.notes.map(note => ({...note, next: true})),
|
|
497
|
+
);
|
|
482
498
|
result.publicImports = publicImports.report;
|
|
483
499
|
if (scanUnreachable) {
|
|
484
500
|
issues.push(
|
|
@@ -686,23 +702,78 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
|
686
702
|
}
|
|
687
703
|
|
|
688
704
|
/**
|
|
689
|
-
* The
|
|
690
|
-
*
|
|
691
|
-
*
|
|
705
|
+
* The doc-syntax notes for a package's topics: each command a topic writes
|
|
706
|
+
* with a runner (`runner_command`), for one package manager
|
|
707
|
+
* (`package_manager_command`), or bare (`plain_command`), and each token that
|
|
708
|
+
* does not parse (`doc_token`), with the file, line and what to write
|
|
709
|
+
* instead. The next minor release turns them into warnings: `next`.
|
|
692
710
|
* @param {any} integration a loaded integration
|
|
693
|
-
* @returns {Promise<Array<{code: string, message: string}>>}
|
|
711
|
+
* @returns {Promise<Array<{code: string, message: string, next: true}>>}
|
|
694
712
|
*/
|
|
695
|
-
async function
|
|
713
|
+
async function docCommandNotes(integration) {
|
|
696
714
|
const packageDir = integration.__packageDir;
|
|
697
|
-
return (await
|
|
698
|
-
code:
|
|
715
|
+
return (await integrationDocCommands(integration)).map(each => ({
|
|
716
|
+
code: each.code,
|
|
699
717
|
message:
|
|
700
718
|
typeof packageDir === 'string'
|
|
701
719
|
? `${path.relative(packageDir, each.file).split(path.sep).join('/')}: ${each.message}`
|
|
702
720
|
: each.message,
|
|
721
|
+
next: true,
|
|
703
722
|
}));
|
|
704
723
|
}
|
|
705
724
|
|
|
725
|
+
/**
|
|
726
|
+
* The notes for docs that replace or extend a topic or a guide the docs tree
|
|
727
|
+
* places, or place an extension's section with `before` or `after`: a name
|
|
728
|
+
* that holds neither (such as a namespace) applies nothing, and a key that
|
|
729
|
+
* names no section adds the section at the end. Each is listed, failing nothing, until
|
|
730
|
+
* the next minor release (architecture:cli-surface INV35).
|
|
731
|
+
* @param {any} integration a loaded integration
|
|
732
|
+
* @returns {Promise<Array<{code: string, message: string}>>}
|
|
733
|
+
*/
|
|
734
|
+
async function docTargetNotes(integration) {
|
|
735
|
+
/** @type {Array<{code: string, message: string}>} */
|
|
736
|
+
const notes = [];
|
|
737
|
+
const targets = await integrationDocTargets(integration);
|
|
738
|
+
/** @type {Map<string, string[]>} lowercased route → the docs replacing it */
|
|
739
|
+
const replacers = new Map();
|
|
740
|
+
for (const each of targets) {
|
|
741
|
+
if (each.kind !== 'guide' || each.relationship !== 'replaces') continue;
|
|
742
|
+
// An old route and the new one name one guide.
|
|
743
|
+
const key = each.guide ?? each.target.toLowerCase();
|
|
744
|
+
replacers.set(key, [...(replacers.get(key) ?? []), each.topic]);
|
|
745
|
+
}
|
|
746
|
+
for (const [route, topics] of replacers) {
|
|
747
|
+
if (topics.length < 2) continue;
|
|
748
|
+
notes.push({
|
|
749
|
+
code: DUPLICATE_GUIDE_REPLACEMENT,
|
|
750
|
+
message: `"${topics.join('", "')}" all replace the guide "${route}", and only the last, "${topics.at(-1)}", is read. Fix: keep one replacement, or make the others extend it.`,
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
for (const each of targets) {
|
|
754
|
+
if (each.kind === 'namespace') {
|
|
755
|
+
const shown = each.guidesBelow.slice(0, 8);
|
|
756
|
+
const more = each.guidesBelow.length - shown.length;
|
|
757
|
+
notes.push({
|
|
758
|
+
code: DOC_TARGET_NOT_FOUND,
|
|
759
|
+
message: `"${each.topic}" ${each.relationship} "${each.target}", which is a namespace of the docs tree: it holds no sections to ${each.relationship === 'replaces' ? 'replace' : 'extend'}, so this changes nothing. Fix: name the route of a guide below it${shown.length > 0 ? `: ${shown.join(', ')}${more > 0 ? `, and ${more} more` : ''}` : ''}.`,
|
|
760
|
+
});
|
|
761
|
+
} else if (each.kind == null) {
|
|
762
|
+
notes.push({
|
|
763
|
+
code: DOC_TARGET_NOT_FOUND,
|
|
764
|
+
message: `"${each.topic}" ${each.relationship} "${each.target}", which is neither a topic nor a guide of the CLI's docs or this package's own: it changes nothing unless an app also installs a package that provides it. Fix: if it should name one of those, name a topic as \`${formatCliCommand('docs')}\` lists it, or a guide's route as \`${formatCliCommand('docs authoring --depth all')}\` or \`${formatCliCommand('docs cli --depth all')}\` lists it.`,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
for (const {section, field, key} of each.unplaced) {
|
|
768
|
+
notes.push({
|
|
769
|
+
code: DOC_SECTION_UNPLACED,
|
|
770
|
+
message: `Section "${section}" of "${each.topic}" goes ${field} "${key}", which is no section of "${each.guide ?? each.target}", so it is added at the end. Fix: use a key \`${formatCliCommand(`docs ${each.guide ?? each.target} --index`)}\` lists.`,
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return notes;
|
|
775
|
+
}
|
|
776
|
+
|
|
706
777
|
/**
|
|
707
778
|
* Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
|
|
708
779
|
* (`pkg` given) and return the `integration.validate` envelope. The no-manifest
|
|
@@ -737,26 +808,43 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
737
808
|
await blockComponentsCheck(integration),
|
|
738
809
|
]
|
|
739
810
|
: undefined;
|
|
811
|
+
// Components no block template shows.
|
|
812
|
+
const examples = integration
|
|
813
|
+
? await componentExamplesCheck(integration)
|
|
814
|
+
: undefined;
|
|
740
815
|
const docNames = names?.[0].report;
|
|
741
816
|
const blockComponents = names?.[1].report;
|
|
742
817
|
// Notes fail nothing: a malformed `cliCommand`, and the findings added
|
|
743
818
|
// after the last minor release, each with its fix in the message, which
|
|
744
819
|
// may not fail `--strict` until the next (architecture:cli-surface INV35):
|
|
745
820
|
// the layout findings and the component names judged wrong.
|
|
821
|
+
// A finding the next minor release turns into a warning is marked `next`:
|
|
822
|
+
// `integration check --strict --next` fails on it today.
|
|
746
823
|
const notes = result.found
|
|
747
824
|
? [
|
|
748
|
-
|
|
825
|
+
// A malformed cliCommand fails --strict from the next minor
|
|
826
|
+
// (spec:AST-081 FR5).
|
|
827
|
+
...(result.notes ?? []).map(note =>
|
|
828
|
+
note.code === INVALID_CLI_COMMAND ? {...note, next: true} : note,
|
|
829
|
+
),
|
|
749
830
|
...(result.listed ?? []).map(issue => ({
|
|
750
831
|
code: issue.code,
|
|
751
832
|
message: issue.message,
|
|
833
|
+
next: true,
|
|
752
834
|
})),
|
|
753
|
-
...(names ?? []).flatMap(each =>
|
|
835
|
+
...(names ?? []).flatMap(each =>
|
|
836
|
+
each.notes.map(note => ({...note, next: true})),
|
|
837
|
+
),
|
|
838
|
+
...(examples?.notes ?? []).map(note => ({...note, next: true})),
|
|
754
839
|
]
|
|
755
840
|
: [];
|
|
756
|
-
//
|
|
757
|
-
//
|
|
841
|
+
// The doc-syntax findings in the package's topics, as `next` notes with
|
|
842
|
+
// their fixes, the same way.
|
|
758
843
|
if (integration?.docs) {
|
|
759
|
-
notes.push(...(await
|
|
844
|
+
notes.push(...(await docCommandNotes(integration)));
|
|
845
|
+
notes.push(
|
|
846
|
+
...(await docTargetNotes(integration)).map(note => ({...note, next: true})),
|
|
847
|
+
);
|
|
760
848
|
}
|
|
761
849
|
return {
|
|
762
850
|
type: 'integration.validate',
|
|
@@ -781,6 +869,16 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
781
869
|
...(docTypes ? {docTypes} : {}),
|
|
782
870
|
...(docNames ? {docNames} : {}),
|
|
783
871
|
...(blockComponents ? {blockComponents} : {}),
|
|
872
|
+
// Template assets npm could not place, when there are any.
|
|
873
|
+
...(examples && examples.unchecked.length > 0
|
|
874
|
+
? {
|
|
875
|
+
exampleAssets: {
|
|
876
|
+
status: 'checked',
|
|
877
|
+
findings: [],
|
|
878
|
+
unchecked: examples.unchecked,
|
|
879
|
+
},
|
|
880
|
+
}
|
|
881
|
+
: {}),
|
|
784
882
|
// What the public-import check could not judge: listed, never failed on.
|
|
785
883
|
...(result.found && result.publicImports
|
|
786
884
|
? {publicImports: result.publicImports}
|