@astryxdesign/cli 0.7.4-canary.626f01e → 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/integration/example-checks.no-npm.test.mjs +140 -0
- package/api/integration/example-checks.test.mjs +776 -0
- package/api/integration/validate-integration-case-disk.test.mjs +12 -2
- package/api/integration/validate-integration-gaps.test.mjs +36 -15
- package/api/integration/validate-integration.mjs +16 -0
- package/api/integration/validate-integration.type.d.mts +13 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/template/template-suffix.test.mjs +26 -0
- package/clients/cli/commands/doctor.mjs +10 -0
- package/foundation/discovery/template-adapter.mjs +11 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +4 -0
- package/foundation/integrations/validate-contributions.d.mts +53 -0
- package/foundation/integrations/validate-contributions.mjs +788 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -70,7 +70,12 @@ 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',
|
|
76
81
|
next: true,
|
|
@@ -101,7 +106,12 @@ describe('a doc whose name differs from its source only in case, on a case-insen
|
|
|
101
106
|
|
|
102
107
|
const {data} = await validateIntegration(undefined, {cwd: tmpDir});
|
|
103
108
|
expect(data.issues).toEqual([]);
|
|
104
|
-
|
|
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([
|
|
105
115
|
{
|
|
106
116
|
code: 'source_without_component_doc',
|
|
107
117
|
next: true,
|
|
@@ -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
|
/**
|
|
@@ -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,7 +1387,7 @@ 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',
|
|
1372
1393
|
next: true,
|
|
@@ -1891,8 +1912,8 @@ describe('layout findings 0.7.2 did not fail on', () => {
|
|
|
1891
1912
|
const validate = /** @type {any} */ (
|
|
1892
1913
|
result.data.checks[0].response.data
|
|
1893
1914
|
);
|
|
1894
|
-
expect(validate.notes.length).toBeGreaterThan(0);
|
|
1895
|
-
for (const note of validate.notes) {
|
|
1915
|
+
expect(others(validate.notes).length).toBeGreaterThan(0);
|
|
1916
|
+
for (const note of others(validate.notes)) {
|
|
1896
1917
|
// Listed now, a warning from the next minor release: `next`.
|
|
1897
1918
|
expect(Object.keys(note).sort()).toEqual(['code', 'message', 'next']);
|
|
1898
1919
|
expect(note.next).toBe(true);
|
|
@@ -1953,8 +1974,8 @@ describe('name findings listed until the next minor release', () => {
|
|
|
1953
1974
|
const {data} = await validateIntegration(undefined, {cwd: dir});
|
|
1954
1975
|
expect(data.issues).toEqual([]);
|
|
1955
1976
|
expect(/** @type {any} */ (data)[report].findings).toEqual([]);
|
|
1956
|
-
expect(data.notes
|
|
1957
|
-
expect(data.notes
|
|
1977
|
+
expect(others(data.notes).map(note => note.code)).toEqual([code]);
|
|
1978
|
+
expect(others(data.notes)[0].message).toContain('Fix: ');
|
|
1958
1979
|
|
|
1959
1980
|
const result = await integrationCheck({cwd: dir, strict: true});
|
|
1960
1981
|
expect(result.data.failures).toEqual([]);
|
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
// integration-warnings need them too, and foundation must not depend on api.
|
|
63
63
|
import {
|
|
64
64
|
blockComponentsCheck,
|
|
65
|
+
componentExamplesCheck,
|
|
65
66
|
componentDocNamesCheck,
|
|
66
67
|
INVALID_CLI_COMMAND,
|
|
67
68
|
isListedIssue,
|
|
@@ -807,6 +808,10 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
807
808
|
await blockComponentsCheck(integration),
|
|
808
809
|
]
|
|
809
810
|
: undefined;
|
|
811
|
+
// Components no block template shows.
|
|
812
|
+
const examples = integration
|
|
813
|
+
? await componentExamplesCheck(integration)
|
|
814
|
+
: undefined;
|
|
810
815
|
const docNames = names?.[0].report;
|
|
811
816
|
const blockComponents = names?.[1].report;
|
|
812
817
|
// Notes fail nothing: a malformed `cliCommand`, and the findings added
|
|
@@ -830,6 +835,7 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
830
835
|
...(names ?? []).flatMap(each =>
|
|
831
836
|
each.notes.map(note => ({...note, next: true})),
|
|
832
837
|
),
|
|
838
|
+
...(examples?.notes ?? []).map(note => ({...note, next: true})),
|
|
833
839
|
]
|
|
834
840
|
: [];
|
|
835
841
|
// The doc-syntax findings in the package's topics, as `next` notes with
|
|
@@ -863,6 +869,16 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
863
869
|
...(docTypes ? {docTypes} : {}),
|
|
864
870
|
...(docNames ? {docNames} : {}),
|
|
865
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
|
+
: {}),
|
|
866
882
|
// What the public-import check could not judge: listed, never failed on.
|
|
867
883
|
...(result.found && result.publicImports
|
|
868
884
|
? {publicImports: result.publicImports}
|
|
@@ -41,6 +41,10 @@ export type ValidateIntegrationResponse = {
|
|
|
41
41
|
* --next`, fails `integration check --strict --next`, and fails `--strict`
|
|
42
42
|
* from the next minor release. Notes include `invalid_cli_command`, a
|
|
43
43
|
* `cliCommand` that was ignored as malformed;
|
|
44
|
+
* `component_without_example`, `template_category`,
|
|
45
|
+
* `showcase_not_standalone` and `template_asset_not_packed`, what a
|
|
46
|
+
* package's examples need (next minor; a block's `alsoShowcaseFor` names
|
|
47
|
+
* count as shown);
|
|
44
48
|
* `cli_peer_version`, the running CLI outside the package's
|
|
45
49
|
* `@astryxdesign/cli` peer range; and
|
|
46
50
|
* the package layout findings added after the last minor release, each with
|
|
@@ -71,6 +75,15 @@ export type ValidateIntegrationResponse = {
|
|
|
71
75
|
docTypes?: DocTypesReport;
|
|
72
76
|
docNames?: DocNamesReport;
|
|
73
77
|
blockComponents?: BlockComponentsReport;
|
|
78
|
+
exampleAssets?: {
|
|
79
|
+
status: "checked";
|
|
80
|
+
findings: [];
|
|
81
|
+
unchecked: Array<{
|
|
82
|
+
file: string;
|
|
83
|
+
asset: string;
|
|
84
|
+
reason: string;
|
|
85
|
+
}>;
|
|
86
|
+
};
|
|
74
87
|
publicImports?: PublicImportsReport;
|
|
75
88
|
};
|
|
76
89
|
};
|
|
@@ -39,12 +39,16 @@
|
|
|
39
39
|
* "healthy" — the two are otherwise byte-identical.
|
|
40
40
|
* @typedef {object} ValidateIntegrationResponse
|
|
41
41
|
* @property {'integration.validate'} type
|
|
42
|
-
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string, next?: boolean}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, publicImports?: PublicImportsReport}} data
|
|
42
|
+
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string, next?: boolean}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, exampleAssets?: {status: 'checked', findings: [], unchecked: Array<{file: string, asset: string, reason: string}>}, publicImports?: PublicImportsReport}} data
|
|
43
43
|
* `notes`: information beside the issues. A note fails nothing by default;
|
|
44
44
|
* one with `next: true` counts as a warning under `integration check
|
|
45
45
|
* --next`, fails `integration check --strict --next`, and fails `--strict`
|
|
46
46
|
* from the next minor release. Notes include `invalid_cli_command`, a
|
|
47
47
|
* `cliCommand` that was ignored as malformed;
|
|
48
|
+
* `component_without_example`, `template_category`,
|
|
49
|
+
* `showcase_not_standalone` and `template_asset_not_packed`, what a
|
|
50
|
+
* package's examples need (next minor; a block's `alsoShowcaseFor` names
|
|
51
|
+
* count as shown);
|
|
48
52
|
* `cli_peer_version`, the running CLI outside the package's
|
|
49
53
|
* `@astryxdesign/cli` peer range; and
|
|
50
54
|
* the package layout findings added after the last minor release, each with
|
|
@@ -62,7 +62,7 @@ export const doc = {
|
|
|
62
62
|
{
|
|
63
63
|
type: 'integration.validate',
|
|
64
64
|
description:
|
|
65
|
-
"The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means \"not looked at\", not \"healthy\"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message, next?} information beside the issues; a note fails nothing by default, and one with `next: true` counts as a warning under `integration check --next`, fails `integration check --strict --next`, and fails `--strict` from the next minor release. Notes include `invalid_cli_command` for a `cliCommand` that was ignored as malformed and `cli_peer_version` when the running CLI is outside the `@astryxdesign/cli` peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. For the commands a topic writes, `runner_command` (written with a package runner), `plain_command` (written bare), `package_manager_command` (written for one package manager) and `doc_token` (a token that does not parse) notes each give the file, line and the token to write. A `doc_target_not_found` note names a doc whose `replaces` or `extends` names no topic and no guide of the CLI's docs or the package's own (such as a namespace, with the guides below it), so it changes nothing unless an app also installs a package that provides it, and a `doc_section_unplaced` note a section whose `before` or `after` names no section of the topic or guide it extends, so it is added at the end, and a `duplicate_guide_replacement` note two docs of the package that replace one guide, of which only the last is read; they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `component_import_missing_name`, `example_import_not_exported`, `example_import_missing_name`, `template_import_not_exported`, `template_import_outside_root`, `template_private_import`, `template_import_missing_name` and `template_no_default_export`. When the manifest loads, `data.publicImports` is `{status: 'checked', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: an `exports` target not built yet; a module whose export list cannot be read in full (CommonJS, or a declaration file it cannot read); a root import in a package with no `exports` (the root module `main` names is not read); every name an import (other than a component doc's own component) names that its module does not export, while a TypeScript file in the package has a `declare module` block for a relative path or the package's own name or a subpath of it, which can add names to that module (a `declare module` in a comment, `declare global`, a wildcard such as `'*.css'`, and another package's name do not count; a file whose text has `declare module` but that cannot be parsed counts); the same for every such name when the package has more than 5,000 files to search for that block; a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package's own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.",
|
|
65
|
+
"The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means \"not looked at\", not \"healthy\"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message, next?} information beside the issues; a note fails nothing by default, and one with `next: true` counts as a warning under `integration check --next`, fails `integration check --strict --next`, and fails `--strict` from the next minor release. Notes include `invalid_cli_command` for a `cliCommand` that was ignored as malformed and `cli_peer_version` when the running CLI is outside the `@astryxdesign/cli` peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. For the commands a topic writes, `runner_command` (written with a package runner), `plain_command` (written bare), `package_manager_command` (written for one package manager) and `doc_token` (a token that does not parse) notes each give the file, line and the token to write. A `doc_target_not_found` note names a doc whose `replaces` or `extends` names no topic and no guide of the CLI's docs or the package's own (such as a namespace, with the guides below it), so it changes nothing unless an app also installs a package that provides it, and a `doc_section_unplaced` note a section whose `before` or `after` names no section of the topic or guide it extends, so it is added at the end, and a `duplicate_guide_replacement` note two docs of the package that replace one guide, of which only the last is read; they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `component_import_missing_name`, `example_import_not_exported`, `example_import_missing_name`, `template_import_not_exported`, `template_import_outside_root`, `template_private_import`, `template_import_missing_name` and `template_no_default_export`. Since 0.7.4 the examples a package ships are checked the same way: `component_without_example` (a published component no block template shows with `exampleFor` and `isShowcase: true`, or names in `alsoShowcaseFor`), `template_category` (a template category written as a path, such as `components/X`), `showcase_not_standalone` (a showcase that imports server-only code or reads `process.env` past `NODE_ENV`) and `template_asset_not_packed` (a `new URL(…, import.meta.url)` asset that is missing, or that `npm pack --dry-run` leaves out of the package). When npm cannot list the package's files, an asset no `files` entry can reach is still a note, and any other is listed in `data.exampleAssets` (`{status: 'checked', findings: [], unchecked}`, present only when it lists any) as {file, asset, reason}; `integration check` counts them as not compared. When the manifest loads, `data.publicImports` is `{status: 'checked', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: an `exports` target not built yet; a module whose export list cannot be read in full (CommonJS, or a declaration file it cannot read); a root import in a package with no `exports` (the root module `main` names is not read); every name an import (other than a component doc's own component) names that its module does not export, while a TypeScript file in the package has a `declare module` block for a relative path or the package's own name or a subpath of it, which can add names to that module (a `declare module` in a comment, `declare global`, a wildcard such as `'*.css'`, and another package's name do not count; a file whose text has `declare module` but that cannot be parsed counts); the same for every such name when the package has more than 5,000 files to search for that block; a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package's own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.",
|
|
66
66
|
},
|
|
67
67
|
],
|
|
68
68
|
examples: [
|
|
@@ -250,6 +250,32 @@ describe('external showcase blocks: canonical .doc.* plus released .template.* c
|
|
|
250
250
|
expect(result.name).toBe('Bar — Showcase');
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
+
it('findShowcase prefers the showcase that names the component in exampleFor', async () => {
|
|
254
|
+
makeShowcaseFixture();
|
|
255
|
+
// Bar's showcase also uses Chip; Chip's own showcase sits in a folder
|
|
256
|
+
// that does not carry its name and says so only through exampleFor.
|
|
257
|
+
const dir = path.join(
|
|
258
|
+
tmpDir,
|
|
259
|
+
'node_modules',
|
|
260
|
+
'@test',
|
|
261
|
+
'ext',
|
|
262
|
+
'blocks',
|
|
263
|
+
'components',
|
|
264
|
+
'Gallery',
|
|
265
|
+
);
|
|
266
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
267
|
+
fs.writeFileSync(
|
|
268
|
+
path.join(dir, 'ChipCard.doc.mjs'),
|
|
269
|
+
"export default {type: 'block', name: 'Chip — Card', description: 'Chip showcase.', category: 'Test - Showcases', exampleFor: 'Chip', isShowcase: true, componentsUsed: ['Chip']};\n",
|
|
270
|
+
);
|
|
271
|
+
fs.writeFileSync(
|
|
272
|
+
path.join(dir, 'ChipCard.tsx'),
|
|
273
|
+
"'use client';\nexport default function ChipCard() { return <div>Chip</div>; }",
|
|
274
|
+
);
|
|
275
|
+
const result = await findShowcase('Chip', tmpDir);
|
|
276
|
+
expect(result?.name).toBe('Chip — Card');
|
|
277
|
+
});
|
|
278
|
+
|
|
253
279
|
it('findRelatedBlocks finds both suffix families', async () => {
|
|
254
280
|
makeShowcaseFixture();
|
|
255
281
|
const foo = await findRelatedBlocks('Foo', tmpDir);
|
|
@@ -235,6 +235,16 @@ function printIntegrationValidation(data) {
|
|
|
235
235
|
...docTypesBlocks(data.docTypes, errors > 0),
|
|
236
236
|
...docNamesBlocks(data.docNames),
|
|
237
237
|
...blockComponentsBlocks(data.blockComponents),
|
|
238
|
+
...(data.exampleAssets && data.exampleAssets.unchecked.length > 0
|
|
239
|
+
? [
|
|
240
|
+
text(
|
|
241
|
+
`[info] Template assets not checked: ${data.exampleAssets.unchecked.length}:`,
|
|
242
|
+
),
|
|
243
|
+
records(data.exampleAssets.unchecked, {
|
|
244
|
+
fields: ['file', 'asset', 'reason'],
|
|
245
|
+
}),
|
|
246
|
+
]
|
|
247
|
+
: []),
|
|
238
248
|
...(data.publicImports && data.publicImports.unchecked.length > 0
|
|
239
249
|
? [
|
|
240
250
|
text(
|
|
@@ -696,6 +696,9 @@ async function discoverBlocks() {
|
|
|
696
696
|
aspectRatio: doc?.aspectRatio ?? 1,
|
|
697
697
|
componentsUsed: doc?.componentsUsed ?? [],
|
|
698
698
|
isShowcase: doc?.isShowcase ?? false,
|
|
699
|
+
...(typeof doc?.exampleFor === 'string'
|
|
700
|
+
? {exampleFor: doc.exampleFor}
|
|
701
|
+
: {}),
|
|
699
702
|
filePath: tsxPath,
|
|
700
703
|
docPath,
|
|
701
704
|
category: relPath,
|
|
@@ -738,6 +741,9 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
|
|
|
738
741
|
aspectRatio: doc?.aspectRatio ?? 1,
|
|
739
742
|
componentsUsed: doc?.componentsUsed ?? [],
|
|
740
743
|
isShowcase: doc?.isShowcase ?? false,
|
|
744
|
+
...(typeof doc?.exampleFor === 'string'
|
|
745
|
+
? {exampleFor: doc.exampleFor}
|
|
746
|
+
: {}),
|
|
741
747
|
filePath: tsxPath,
|
|
742
748
|
docPath,
|
|
743
749
|
category: relPath,
|
|
@@ -1427,6 +1433,11 @@ export async function findShowcase(componentName, cwd, options) {
|
|
|
1427
1433
|
docPath: b.docPath,
|
|
1428
1434
|
});
|
|
1429
1435
|
|
|
1436
|
+
// Priority 0: the showcase that names the component (`exampleFor`), the
|
|
1437
|
+
// way packages declare it; a category no longer has to carry the name.
|
|
1438
|
+
const named = showcases.find(b => (b.exampleFor ?? '').toLowerCase() === lc);
|
|
1439
|
+
if (named) return toResult(named);
|
|
1440
|
+
|
|
1430
1441
|
// Priority 1: own directory (components/Badge/ for "Badge")
|
|
1431
1442
|
const dirMatch = showcases.find(b => {
|
|
1432
1443
|
const catDir = path.basename(b.category ?? '').toLowerCase();
|
|
@@ -343,6 +343,10 @@ const RUNNERS = {
|
|
|
343
343
|
runs: "each installed integration's manifest",
|
|
344
344
|
sites: ['importUserModule'],
|
|
345
345
|
},
|
|
346
|
+
'foundation/integrations/validate-contributions.mjs': {
|
|
347
|
+
runs: "`npm pack --dry-run --json --ignore-scripts`, to read which files an integration's package holds when a template loads an asset (no lifecycle script runs, nothing is written)",
|
|
348
|
+
sites: ['child_process.spawnSync'],
|
|
349
|
+
},
|
|
346
350
|
'foundation/release/cache.mjs': {
|
|
347
351
|
runs: 'npm (under npm-guard.mjs), to install and look up CLI releases in the per-user cache; each installed release once, to check it starts and reports its version; and ps (tasklist on Windows), to confirm the process a stale lock records is node or npm before ending it',
|
|
348
352
|
sites: ['child_process.spawnSync ×5'],
|
|
@@ -82,6 +82,59 @@ export function blockComponentsCheck(integration: LoadedIntegration): Promise<{
|
|
|
82
82
|
};
|
|
83
83
|
notes: Note[];
|
|
84
84
|
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Whether no `files` entry can reach a path, read case-insensitively and
|
|
87
|
+
* generously (`{a,b}` braces, globs, a no-slash entry at any depth, an entry
|
|
88
|
+
* for the path or any folder above it), for when npm cannot say what it
|
|
89
|
+
* packs: a path this misses is out of the package however npm reads the list.
|
|
90
|
+
* @param {string} rel POSIX, relative to the package root
|
|
91
|
+
* @param {unknown} files
|
|
92
|
+
*/
|
|
93
|
+
export function outsideFiles(rel: string, files: unknown): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* The `!` entry of a `files` field that leaves out `rel` or a folder above
|
|
96
|
+
* it, as written; null when none does.
|
|
97
|
+
* @param {string} rel package-relative path
|
|
98
|
+
* @param {unknown} files the `files` field
|
|
99
|
+
* @returns {string | null}
|
|
100
|
+
*/
|
|
101
|
+
export function negatedFilesEntry(rel: string, files: unknown): string | null;
|
|
102
|
+
/**
|
|
103
|
+
* What a package's examples need to work everywhere they are shown: template
|
|
104
|
+
* lists, docs pages and catalog cards, which render each block alone from
|
|
105
|
+
* the packed package. Four `next` notes, each with a fix to paste
|
|
106
|
+
* (architecture:cli-surface INV35, DEC-11):
|
|
107
|
+
* - `component_without_example`: a published component no block template
|
|
108
|
+
* shows, as its `exampleFor` with `isShowcase: true` (or in
|
|
109
|
+
* `alsoShowcaseFor`). A block named like a showcase that sets neither is a
|
|
110
|
+
* standalone block and does not count. Exempt, because an example cannot
|
|
111
|
+
* fix them: a hidden doc (`hidden: true`), a member of a family (its
|
|
112
|
+
* family's example covers it), a doc kept off the overview
|
|
113
|
+
* (`isHiddenFromOverview: true`, for parts that only make sense inside a
|
|
114
|
+
* parent), and a `Utility` component (providers and context).
|
|
115
|
+
* - `template_category`: a template `category` written as a path, such as
|
|
116
|
+
* `components/X`, with a `"<Group> - <Variant>"` one to write.
|
|
117
|
+
* - `showcase_not_standalone`: a showcase that imports what a browser cannot
|
|
118
|
+
* load (`server-only`, `next/headers`, `next/server`, `next/cache`, a Node
|
|
119
|
+
* built-in) or reads `process.env` past `NODE_ENV`. Type-only imports and
|
|
120
|
+
* comments don't count, and live data is fine: a showcase may fetch
|
|
121
|
+
* through the app. Only the showcase's own file is read.
|
|
122
|
+
* - `template_asset_not_packed`: a file a template loads with `new URL(…,
|
|
123
|
+
* import.meta.url)` that does not exist, or that npm leaves out of the
|
|
124
|
+
* package (`npm pack --dry-run`). When npm cannot answer, an asset no
|
|
125
|
+
* `files` entry can reach is still a note, and any other is returned in
|
|
126
|
+
* `unchecked`.
|
|
127
|
+
* @param {LoadedIntegration} integration
|
|
128
|
+
* @returns {Promise<{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>}>}
|
|
129
|
+
*/
|
|
130
|
+
export function componentExamplesCheck(integration: LoadedIntegration): Promise<{
|
|
131
|
+
notes: Note[];
|
|
132
|
+
unchecked: Array<{
|
|
133
|
+
file: string;
|
|
134
|
+
asset: string;
|
|
135
|
+
reason: string;
|
|
136
|
+
}>;
|
|
137
|
+
}>;
|
|
85
138
|
/**
|
|
86
139
|
* The component doc names the check could not judge, shaped like the doc type
|
|
87
140
|
* report so `integration check` counts them as not compared: each doc whose
|