@astryxdesign/cli 0.7.3-canary.b74cf21 → 0.7.3-canary.ca48bb7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -68
- package/api/build/blocks/blocks.d.mts +6 -4
- package/api/build/blocks/blocks.mjs +103 -20
- package/api/build/blocks/blocks.test.mjs +126 -13
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/kit/answer.d.mts +5 -4
- package/api/build/kit/answer.mjs +114 -12
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +8 -0
- package/api/build/kit/signals.mjs +10 -0
- package/api/build/tree.test.mjs +19 -11
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +17 -3
- package/api/component/component.test.mjs +15 -0
- package/api/component/doc-links.test.mjs +2 -2
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +61 -18
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.test.mjs +28 -18
- package/api/docs/integration-tree.test.mjs +20 -20
- package/api/docs/integrationDocs.test.mjs +1 -1
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +2 -2
- package/api/doctor/doctor.mjs +16 -12
- package/api/doctor/doctor.test.mjs +37 -12
- package/api/hook/hook.mjs +1 -1
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +21 -1
- package/api/integration/authoring-checks.test.mjs +220 -0
- package/api/integration/pack-check.mjs +110 -4
- package/api/integration/pack-check.test.mjs +69 -0
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +304 -1
- package/api/integration/validate-integration.d.mts +6 -1
- package/api/integration/validate-integration.mjs +82 -13
- package/api/integration/validate-integration.type.d.mts +37 -4
- package/api/integration/validate-integration.type.mjs +28 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.mjs +1 -1
- package/api/search/_entries.d.mts +11 -0
- package/api/search/_entries.mjs +77 -3
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/is-my-code-good.doc.mjs +287 -0
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
- package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
- package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +3 -3
- package/assets/docs/tree/cli-command.doc.mjs +1 -1
- package/assets/docs/tree/cli.doc.mjs +1 -1
- package/assets/docs/tree/codemods.doc.mjs +1 -1
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +1 -1
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/configuration.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +1 -1
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +2 -2
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +1 -1
- package/assets/docs/tree/start-a-template.doc.mjs +1 -1
- package/assets/docs/tree/subcomponent.doc.mjs +1 -1
- package/assets/docs/tree/template-assets.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-grading-rubric.doc.mjs +17 -38
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +5 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +2 -2
- package/clients/cli/commands/docs.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +14 -14
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/integration-check.test.mjs +48 -0
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/clients/cli/index.mjs +10 -85
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +56 -0
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +16 -4
- package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
- package/foundation/discovery/authoring-surface.d.mts +1 -1
- package/foundation/discovery/authoring-surface.mjs +2 -2
- package/foundation/discovery/authoring-surface.test.mjs +1 -1
- package/foundation/discovery/cli-self-docs.d.mts +2 -1
- package/foundation/discovery/cli-self-docs.mjs +4 -3
- package/foundation/discovery/cli-self-docs.test.mjs +2 -2
- package/foundation/discovery/runner-allowlist.d.mts +2 -4
- package/foundation/discovery/runner-allowlist.mjs +2 -4
- package/foundation/discovery/runner-commands.d.mts +77 -0
- package/foundation/discovery/runner-commands.mjs +294 -0
- package/foundation/discovery/runner-commands.test.mjs +128 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +18 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/discovery/theme-discovery.mjs +147 -3
- package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
- package/foundation/doc-compiler/read.mjs +59 -1
- package/foundation/doc-compiler/read.test.mjs +11 -2
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
- package/foundation/doc-compiler/tree.d.mts +32 -6
- package/foundation/doc-compiler/tree.mjs +77 -43
- package/foundation/doc-compiler/tree.test.mjs +7 -7
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- package/foundation/integrations/cli-peer-version.d.mts +36 -0
- package/foundation/integrations/cli-peer-version.mjs +132 -0
- package/foundation/integrations/cli-peer-version.test.mjs +354 -0
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/integrations.d.mts +20 -1
- package/foundation/integrations/integrations.mjs +59 -2
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- package/foundation/integrations/validate-contributions.d.mts +19 -0
- package/foundation/integrations/validate-contributions.mjs +172 -3
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
summarizeCheck,
|
|
29
29
|
} from './check/check.mjs';
|
|
30
30
|
import {componentDocNamesCheck} from '../../foundation/integrations/validate-contributions.mjs';
|
|
31
|
+
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
31
32
|
|
|
32
33
|
let tmpDir;
|
|
33
34
|
let copies = 0;
|
|
@@ -168,6 +169,7 @@ const writeNamed = files =>
|
|
|
168
169
|
version: '1.0.0',
|
|
169
170
|
exports: {
|
|
170
171
|
'./components/*': './components/*.tsx',
|
|
172
|
+
'./templates/*': './templates/*.tsx',
|
|
171
173
|
'.': './index.ts',
|
|
172
174
|
},
|
|
173
175
|
});
|
|
@@ -533,7 +535,14 @@ describe('block component names', () => {
|
|
|
533
535
|
'export function Panel() { return null; }\nexport const UI = {};\nexport const Lib = {};\nexport function pick() { return null; }\n',
|
|
534
536
|
...files,
|
|
535
537
|
},
|
|
536
|
-
{
|
|
538
|
+
{
|
|
539
|
+
name: '@acme/kit',
|
|
540
|
+
version: '1.0.0',
|
|
541
|
+
exports: {
|
|
542
|
+
'.': './index.tsx',
|
|
543
|
+
'./templates/*': './templates/*.tsx',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
537
546
|
);
|
|
538
547
|
/** @param {string} extra */
|
|
539
548
|
const block = extra =>
|
|
@@ -571,6 +580,9 @@ describe('block component names', () => {
|
|
|
571
580
|
),
|
|
572
581
|
'templates/account-card.tsx':
|
|
573
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",
|
|
574
586
|
});
|
|
575
587
|
|
|
576
588
|
expect(await allOf(dir)).toEqual([]);
|
|
@@ -1023,6 +1035,219 @@ describe('component doc files', () => {
|
|
|
1023
1035
|
});
|
|
1024
1036
|
expect(await issuesOf(fixed)).toEqual([]);
|
|
1025
1037
|
});
|
|
1038
|
+
|
|
1039
|
+
it('names a .jsx source beside a component doc and says to rename it', async () => {
|
|
1040
|
+
const dir = writePackage({
|
|
1041
|
+
[MANIFEST]: manifest({components: './components'}),
|
|
1042
|
+
'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
|
|
1043
|
+
'components/AcmeWidget.jsx': componentSource('AcmeWidget'),
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
const message = only(await issuesOf(dir), 'invalid_component');
|
|
1047
|
+
expect(message).toBe(
|
|
1048
|
+
'Component "AcmeWidget" is missing its same-stem source file AcmeWidget.tsx: found AcmeWidget.jsx, but a component source must be a .tsx file. Fix: rename AcmeWidget.jsx to AcmeWidget.tsx (and point its package export at the new file).',
|
|
1049
|
+
);
|
|
1050
|
+
|
|
1051
|
+
const fixed = follow(dir, {
|
|
1052
|
+
move: [['components/AcmeWidget.jsx', 'components/AcmeWidget.tsx']],
|
|
1053
|
+
});
|
|
1054
|
+
expect(await issuesOf(fixed)).toEqual([]);
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
it('says what an empty doc and a doc with no default export are missing', async () => {
|
|
1058
|
+
const dir = writePackage({
|
|
1059
|
+
[MANIFEST]: manifest({components: './components'}),
|
|
1060
|
+
'components/Empty.doc.mjs': '',
|
|
1061
|
+
'components/Empty.tsx': componentSource('Empty'),
|
|
1062
|
+
'components/Named.doc.mjs': componentDoc('Named').replace(
|
|
1063
|
+
'export default',
|
|
1064
|
+
'export const doc =',
|
|
1065
|
+
),
|
|
1066
|
+
'components/Named.tsx': componentSource('Named'),
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1069
|
+
const messages = (await issuesOf(dir)).map(issue => issue.message);
|
|
1070
|
+
const fix =
|
|
1071
|
+
'Fix: export the doc object as the default export: `export default {type: ..., name: ..., ...}`.';
|
|
1072
|
+
expect(messages).toEqual([
|
|
1073
|
+
`Component "Empty" has invalid metadata: ${path.join(dir, 'components', 'Empty.doc.mjs')} is empty, so it documents nothing. ${fix}`,
|
|
1074
|
+
`Component "Named" has invalid metadata: ${path.join(dir, 'components', 'Named.doc.mjs')} has no default export or \`docs\` export (it exports \`doc\`), so it documents nothing. ${fix}`,
|
|
1075
|
+
]);
|
|
1076
|
+
expect(messages.join('\n')).not.toContain('Invalid input');
|
|
1077
|
+
});
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
describe('template and theme pairing', () => {
|
|
1081
|
+
it('gives a template doc with no source a fix', async () => {
|
|
1082
|
+
const dir = writePackage({
|
|
1083
|
+
[MANIFEST]: manifest({templates: './templates'}),
|
|
1084
|
+
'templates/account-card.doc.mjs': templateDoc('Account card'),
|
|
1085
|
+
});
|
|
1086
|
+
|
|
1087
|
+
const message = only(await issuesOf(dir), 'invalid_template');
|
|
1088
|
+
expect(message).toBe(
|
|
1089
|
+
'Template "account-card" is missing its same-stem source file account-card.tsx. Fix: add account-card.tsx beside account-card.doc.mjs, with the template as its default export.',
|
|
1090
|
+
);
|
|
1091
|
+
const fixed = follow(dir, {
|
|
1092
|
+
write: {'templates/account-card.tsx': templateSource},
|
|
1093
|
+
});
|
|
1094
|
+
expect(await issuesOf(fixed)).toEqual([]);
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
const themeDoc = `${THEME_TYPE}export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'A theme.', maintained: true};\n`;
|
|
1098
|
+
const themeSource =
|
|
1099
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nexport const oceanTheme = defineTheme({name: 'ocean'});\n";
|
|
1100
|
+
|
|
1101
|
+
it('gives a theme descriptor with no source a fix', async () => {
|
|
1102
|
+
const dir = writePackage({
|
|
1103
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1104
|
+
'themes/ocean/oceanTheme.doc.mjs': themeDoc,
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
expect(only(await issuesOf(dir), 'invalid_theme')).toBe(
|
|
1108
|
+
'Theme "ocean" for @acme/kit must contain exactly one same-stem source for oceanTheme.doc.mjs; found 0. Fix: add oceanTheme.ts beside oceanTheme.doc.mjs, exporting `oceanTheme` from defineTheme.',
|
|
1109
|
+
);
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
it('gives a theme source with no descriptor a fix', async () => {
|
|
1113
|
+
const dir = writePackage({
|
|
1114
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1115
|
+
'themes/ocean/oceanTheme.ts': themeSource,
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
const message = only(await issuesOf(dir), 'invalid_theme');
|
|
1119
|
+
expect(message).toBe(
|
|
1120
|
+
`Theme "ocean" for @acme/kit must contain exactly one same-stem .doc.mjs descriptor; found 0 beside "oceanTheme.ts". Fix: add oceanTheme.doc.mjs beside it with type: 'theme' and name: 'ocean'; \`${formatCliCommand('docs authoring theme-doc', path.join(dir, 'themes', 'ocean'))}\` lists its fields.`,
|
|
1121
|
+
);
|
|
1122
|
+
const fixed = follow(dir, {
|
|
1123
|
+
write: {'themes/ocean/oceanTheme.doc.mjs': themeDoc},
|
|
1124
|
+
});
|
|
1125
|
+
expect(
|
|
1126
|
+
(await issuesOf(fixed)).filter(issue => issue.code === 'invalid_theme'),
|
|
1127
|
+
).toEqual([]);
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
it('says to rename a source named for its theme when the build writes beside it, and the rename clears it', async () => {
|
|
1131
|
+
const brandDoc = `${THEME_TYPE}export default {type: 'theme', name: 'brand', displayName: 'Brand', description: 'A theme.', maintained: true};\n`;
|
|
1132
|
+
const dir = writePackage({
|
|
1133
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1134
|
+
'themes/brand/brand.doc.mjs': brandDoc,
|
|
1135
|
+
'themes/brand/brand.ts':
|
|
1136
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nexport const brand = defineTheme({name: 'brand'});\n",
|
|
1137
|
+
'themes/brand/brand.js':
|
|
1138
|
+
"/**\n * @generated by `astryx theme build` — do not edit manually.\n */\nimport './brand.css';\nexport const brandTheme = {};\n",
|
|
1139
|
+
'themes/brand/brand.css': '.astryx-theme-brand {}\n',
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
expect(only(await issuesOf(dir), 'invalid_theme')).toBe(
|
|
1143
|
+
`Theme "brand" for @acme/kit must contain exactly one same-stem source for brand.doc.mjs; found 2: "brand.js", "brand.ts". Fix: "brand.js" is the module \`${formatCliCommand('theme build', path.join(dir, 'themes', 'brand'))}\` writes, which takes the theme's name; rename brand.ts to brandTheme.ts and brand.doc.mjs to brandTheme.doc.mjs, export \`brandTheme\` from it, and build again.`,
|
|
1144
|
+
);
|
|
1145
|
+
|
|
1146
|
+
const fixed = follow(dir, {
|
|
1147
|
+
remove: ['themes/brand/brand.ts', 'themes/brand/brand.doc.mjs'],
|
|
1148
|
+
write: {
|
|
1149
|
+
'themes/brand/brandTheme.ts':
|
|
1150
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nexport const brandTheme = defineTheme({name: 'brand'});\n",
|
|
1151
|
+
'themes/brand/brandTheme.doc.mjs': brandDoc,
|
|
1152
|
+
},
|
|
1153
|
+
});
|
|
1154
|
+
expect(
|
|
1155
|
+
(await issuesOf(fixed)).filter(issue => issue.code === 'invalid_theme'),
|
|
1156
|
+
).toEqual([]);
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
const builtOcean = (/** @type {string} */ extra) =>
|
|
1160
|
+
`/**\n * @generated by \`astryx theme build\` — do not edit manually.\n${extra} */\nimport './ocean.css';\nexport const oceanTheme = {};\n`;
|
|
1161
|
+
|
|
1162
|
+
it("names the theme's source when its defineTheme gives the theme's name, for a descriptor named for the built module", async () => {
|
|
1163
|
+
const dir = writePackage({
|
|
1164
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1165
|
+
'themes/ocean/ocean.doc.mjs': themeDoc,
|
|
1166
|
+
'themes/ocean/oceanTheme.ts': themeSource,
|
|
1167
|
+
'themes/ocean/ocean.js': builtOcean(''),
|
|
1168
|
+
'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1171
|
+
const message = only(await issuesOf(dir), 'invalid_theme');
|
|
1172
|
+
expect(message).toContain(
|
|
1173
|
+
'shares its stem with the built module "ocean.js", which does not export "ocean": a descriptor must share its stem with the source that calls defineTheme. The theme\'s source is "oceanTheme.ts". Fix: rename ocean.doc.mjs to oceanTheme.doc.mjs.',
|
|
1174
|
+
);
|
|
1175
|
+
const fixed = follow(dir, {
|
|
1176
|
+
move: [['themes/ocean/ocean.doc.mjs', 'themes/ocean/oceanTheme.doc.mjs']],
|
|
1177
|
+
});
|
|
1178
|
+
expect(
|
|
1179
|
+
(await issuesOf(fixed)).filter(issue => issue.code === 'invalid_theme'),
|
|
1180
|
+
).toEqual([]);
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
it("names the source the built module's Source: line gives, over a <name>Theme helper", async () => {
|
|
1184
|
+
const dir = writePackage({
|
|
1185
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1186
|
+
'themes/ocean/ocean.doc.mjs': themeDoc,
|
|
1187
|
+
'themes/ocean/seaTheme.ts': themeSource.replace('oceanTheme', 'seaTheme'),
|
|
1188
|
+
'themes/ocean/baseTheme.ts':
|
|
1189
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nexport const baseTheme = defineTheme({name: 'base'});\n",
|
|
1190
|
+
'themes/ocean/ocean.js': builtOcean(
|
|
1191
|
+
' * Source: themes/ocean/seaTheme.ts\n',
|
|
1192
|
+
),
|
|
1193
|
+
'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
|
|
1194
|
+
});
|
|
1195
|
+
|
|
1196
|
+
expect(only(await issuesOf(dir), 'invalid_theme')).toContain(
|
|
1197
|
+
'The theme\'s source is "seaTheme.ts". Fix: rename ocean.doc.mjs to seaTheme.doc.mjs.',
|
|
1198
|
+
);
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
it('never names a lone <name>Theme helper as the source: the message stays generic', async () => {
|
|
1202
|
+
const dir = writePackage({
|
|
1203
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1204
|
+
'themes/ocean/ocean.doc.mjs': themeDoc,
|
|
1205
|
+
'themes/ocean/oceanTheme.ts':
|
|
1206
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nexport const oceanTheme = defineTheme({name: 'base'});\n",
|
|
1207
|
+
'themes/ocean/ocean.js': builtOcean(''),
|
|
1208
|
+
'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
const message = only(await issuesOf(dir), 'invalid_theme');
|
|
1212
|
+
expect(message).toContain(
|
|
1213
|
+
'shares its stem with the built module "ocean.js", which does not export "ocean": a descriptor must share its stem with the source that calls defineTheme. Fix: rename ocean.doc.mjs to share its stem with the theme\'s source (the module that calls defineTheme, such as oceanTheme.ts).',
|
|
1214
|
+
);
|
|
1215
|
+
expect(message).not.toContain("The theme's source is");
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1218
|
+
it('accepts a descriptor named for a built module that exports its stem, as 0.7.2 does', async () => {
|
|
1219
|
+
const dir = writePackage({
|
|
1220
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1221
|
+
'themes/ocean/ocean.doc.mjs': themeDoc,
|
|
1222
|
+
'themes/ocean/oceanTheme.ts': themeSource,
|
|
1223
|
+
'themes/ocean/ocean.js': builtOcean('').replace(
|
|
1224
|
+
'export const oceanTheme = {};',
|
|
1225
|
+
'export const oceanTheme = {};\nexport const ocean = oceanTheme;',
|
|
1226
|
+
),
|
|
1227
|
+
'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
expect(
|
|
1231
|
+
(await issuesOf(dir)).filter(issue => issue.code === 'invalid_theme'),
|
|
1232
|
+
).toEqual([]);
|
|
1233
|
+
});
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
describe('a theme folder with a helper', () => {
|
|
1237
|
+
it('reads a descriptor beside its own defineTheme source, with a <name>Theme helper beside them', async () => {
|
|
1238
|
+
const dir = writePackage({
|
|
1239
|
+
[MANIFEST]: manifest({themes: './themes'}),
|
|
1240
|
+
'themes/brand/brand.doc.mjs': `${THEME_TYPE}export default {type: 'theme', name: 'brand', displayName: 'Brand', description: 'A theme.', maintained: true};\n`,
|
|
1241
|
+
'themes/brand/brand.ts':
|
|
1242
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nimport {baseTheme} from './baseTheme';\nexport const brand = defineTheme({name: 'brand', extends: baseTheme});\n",
|
|
1243
|
+
'themes/brand/baseTheme.ts':
|
|
1244
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\nexport const baseTheme = defineTheme({name: 'base'});\n",
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
expect(
|
|
1248
|
+
(await issuesOf(dir)).filter(issue => issue.code === 'invalid_theme'),
|
|
1249
|
+
).toEqual([]);
|
|
1250
|
+
});
|
|
1026
1251
|
});
|
|
1027
1252
|
|
|
1028
1253
|
describe('a hidden doc beside a source whose name differs only in case', () => {
|
|
@@ -1404,6 +1629,84 @@ describe('package.json', () => {
|
|
|
1404
1629
|
});
|
|
1405
1630
|
});
|
|
1406
1631
|
|
|
1632
|
+
describe('the manifest', () => {
|
|
1633
|
+
it('asks about a key one letter from a known one before blaming the CLI version', async () => {
|
|
1634
|
+
const dir = writePackage({
|
|
1635
|
+
[MANIFEST]: manifest({component: './components'}),
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
const message = only(await issuesOf(dir), 'unknown_manifest_key');
|
|
1639
|
+
expect(message).toBe(
|
|
1640
|
+
'This CLI does not know the manifest key "component", so it is ignored. Did you mean `components`? Fix: rename "component" to "components" in astryx.integration.mjs. If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.',
|
|
1641
|
+
);
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
it('says to remove a near-miss key when the manifest already sets the key it suggests', async () => {
|
|
1645
|
+
const dir = writePackage({
|
|
1646
|
+
[MANIFEST]: manifest({components: './components', component: './x'}),
|
|
1647
|
+
'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
|
|
1648
|
+
'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
|
|
1649
|
+
});
|
|
1650
|
+
|
|
1651
|
+
expect(only(await issuesOf(dir), 'unknown_manifest_key')).toBe(
|
|
1652
|
+
'This CLI does not know the manifest key "component", so it is ignored. Did you mean `components`? Fix: remove "component" from astryx.integration.mjs; it already sets "components". If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.',
|
|
1653
|
+
);
|
|
1654
|
+
const fixed = follow(dir, {
|
|
1655
|
+
write: {[MANIFEST]: manifest({components: './components'})},
|
|
1656
|
+
});
|
|
1657
|
+
expect(await issuesOf(fixed)).toEqual([]);
|
|
1658
|
+
});
|
|
1659
|
+
|
|
1660
|
+
it.each([
|
|
1661
|
+
[
|
|
1662
|
+
'alone, though the package name gives a provider ID',
|
|
1663
|
+
{providerID: '@acme/kit', docs: './docs'},
|
|
1664
|
+
'Fix: rename "providerID" to "providerId" in astryx.integration.mjs.',
|
|
1665
|
+
],
|
|
1666
|
+
[
|
|
1667
|
+
'beside the key it suggests',
|
|
1668
|
+
{providerID: '@acme/kit', providerId: '@acme/kit', docs: './docs'},
|
|
1669
|
+
'Fix: remove "providerID" from astryx.integration.mjs; it already sets "providerId".',
|
|
1670
|
+
],
|
|
1671
|
+
])(
|
|
1672
|
+
'reads the keys the manifest declares: providerID %s',
|
|
1673
|
+
async (_label, keys, fix) => {
|
|
1674
|
+
const dir = writePackage({
|
|
1675
|
+
[MANIFEST]: manifest(keys),
|
|
1676
|
+
'docs/a.doc.mjs': topic('a'),
|
|
1677
|
+
});
|
|
1678
|
+
|
|
1679
|
+
expect(only(await issuesOf(dir), 'unknown_manifest_key')).toContain(fix);
|
|
1680
|
+
},
|
|
1681
|
+
);
|
|
1682
|
+
|
|
1683
|
+
it('keeps the newer-CLI explanation for a key that is no near miss', async () => {
|
|
1684
|
+
const dir = writePackage({[MANIFEST]: manifest({playgrounds: './x'})});
|
|
1685
|
+
|
|
1686
|
+
expect(only(await issuesOf(dir), 'unknown_manifest_key')).toContain(
|
|
1687
|
+
'published against a newer Astryx CLI',
|
|
1688
|
+
);
|
|
1689
|
+
});
|
|
1690
|
+
|
|
1691
|
+
it('says a manifest has no default export, and what it exports', async () => {
|
|
1692
|
+
const dir = writePackage({
|
|
1693
|
+
[MANIFEST]: "export const integration = {docs: './docs'};\n",
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
expect(only(await issuesOf(dir), 'invalid_manifest')).toBe(
|
|
1697
|
+
"Integration manifest (astryx.integration.mjs) has no default export (it exports `integration`). Fix: export the manifest object as the default export: `export default {components: './components'}`, naming the roots the package has.",
|
|
1698
|
+
);
|
|
1699
|
+
});
|
|
1700
|
+
|
|
1701
|
+
it('says a manifest is empty', async () => {
|
|
1702
|
+
const dir = writePackage({[MANIFEST]: ''});
|
|
1703
|
+
|
|
1704
|
+
expect(only(await issuesOf(dir), 'invalid_manifest')).toMatch(
|
|
1705
|
+
/^Integration manifest \(astryx\.integration\.mjs\) is empty\. Fix: /u,
|
|
1706
|
+
);
|
|
1707
|
+
});
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1407
1710
|
describe('unreadable files and theme names', () => {
|
|
1408
1711
|
const asRoot = process.getuid?.() === 0;
|
|
1409
1712
|
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export function validateLocalIntegration(cwd?: string): Promise<ValidateResult>;
|
|
12
12
|
/**
|
|
13
|
-
* Validate an INSTALLED integration package
|
|
13
|
+
* Validate an INSTALLED integration package: the nearest `node_modules/<spec>`
|
|
14
|
+
* at or above `cwd`, resolved the way the project loads it.
|
|
14
15
|
* @param {string} spec package name
|
|
15
16
|
* @param {string} [cwd]
|
|
16
17
|
* @returns {Promise<ValidateResult>}
|
|
@@ -82,6 +83,10 @@ export type ValidateResult = {
|
|
|
82
83
|
*/
|
|
83
84
|
listed?: import("../../foundation/integrations/issue").AstryxIntegrationIssue[] | undefined;
|
|
84
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;
|
|
85
90
|
};
|
|
86
91
|
import { validateLoadedIntegration } from '../../foundation/integrations/validate-contributions.mjs';
|
|
87
92
|
import { isListedIssue } from '../../foundation/integrations/validate-contributions.mjs';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - validateLocalIntegration(cwd) — the package rooted at `cwd` (nearest
|
|
13
13
|
* package.json + sibling astryx.integration.{ts,mjs,js}).
|
|
14
14
|
* - validateInstalledIntegration(spec, cwd) — an installed package resolved
|
|
15
|
-
* from `cwd
|
|
15
|
+
* from the node_modules chain at or above `cwd`.
|
|
16
16
|
*
|
|
17
17
|
* Both return a { found, name, version, manifestFile, issues } result. `found`
|
|
18
18
|
* is false only for the no-manifest local case, which is guidance (not an
|
|
@@ -37,6 +37,7 @@ 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 {integrationRunnerCommands} from './_adapter.mjs';
|
|
40
41
|
import {
|
|
41
42
|
THEME_SLUG_RE,
|
|
42
43
|
unreadThemeFolders,
|
|
@@ -52,7 +53,7 @@ import {
|
|
|
52
53
|
import {
|
|
53
54
|
findManifestPaths,
|
|
54
55
|
loadManifest,
|
|
55
|
-
|
|
56
|
+
resolveInstalledIntegrationDir,
|
|
56
57
|
} from '../../foundation/integrations/integrations.mjs';
|
|
57
58
|
// The on-disk contribution validators live in foundation: Project and
|
|
58
59
|
// integration-warnings need them too, and foundation must not depend on api.
|
|
@@ -69,6 +70,12 @@ import {
|
|
|
69
70
|
rootProblem,
|
|
70
71
|
} from '../../foundation/integrations/validate-contributions.mjs';
|
|
71
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';
|
|
72
79
|
|
|
73
80
|
export {validateLoadedIntegration, isListedIssue};
|
|
74
81
|
|
|
@@ -91,6 +98,8 @@ export {validateLoadedIntegration, isListedIssue};
|
|
|
91
98
|
* may not fail `--strict` until the next (architecture:cli-surface INV35);
|
|
92
99
|
* `integration verify` still fails on a package.json npm cannot pack.
|
|
93
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
|
|
94
103
|
*/
|
|
95
104
|
|
|
96
105
|
/**
|
|
@@ -277,13 +286,15 @@ async function findUnreachableContributionIssues(
|
|
|
277
286
|
* Shared core for the local and installed entry points.
|
|
278
287
|
* @param {string} packageDir
|
|
279
288
|
* @param {{name: string, version?: string}} identity
|
|
280
|
-
* @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
|
|
281
292
|
* @returns {Promise<ValidateResult>}
|
|
282
293
|
*/
|
|
283
294
|
async function validateAtPackageDir(
|
|
284
295
|
packageDir,
|
|
285
296
|
identity,
|
|
286
|
-
{scanUnreachable = false} = {},
|
|
297
|
+
{scanUnreachable = false, own = false, cwd = packageDir} = {},
|
|
287
298
|
) {
|
|
288
299
|
/** @type {Issue[]} */
|
|
289
300
|
const issues = [];
|
|
@@ -328,12 +339,14 @@ async function validateAtPackageDir(
|
|
|
328
339
|
let manifest;
|
|
329
340
|
/** @type {string[]} */
|
|
330
341
|
let unknownKeys;
|
|
342
|
+
/** @type {string[]} */
|
|
343
|
+
let declaredKeys;
|
|
331
344
|
/** @type {string | undefined} */
|
|
332
345
|
let agentDocsError;
|
|
333
346
|
/** @type {string | undefined} */
|
|
334
347
|
let cliCommandError;
|
|
335
348
|
try {
|
|
336
|
-
({manifest, unknownKeys, agentDocsError, cliCommandError} =
|
|
349
|
+
({manifest, unknownKeys, declaredKeys, agentDocsError, cliCommandError} =
|
|
337
350
|
await loadManifest(
|
|
338
351
|
manifestFile,
|
|
339
352
|
`Integration manifest (${path.basename(manifestFile)})`,
|
|
@@ -400,6 +413,7 @@ async function validateAtPackageDir(
|
|
|
400
413
|
__cliCommandError: cliCommandError,
|
|
401
414
|
__agentDocsError: agentDocsError,
|
|
402
415
|
__unknownKeys: unknownKeys,
|
|
416
|
+
__declaredKeys: declaredKeys,
|
|
403
417
|
__spec: identity.name,
|
|
404
418
|
__declaredProviderId: manifest.providerId,
|
|
405
419
|
__packageDir: packageDir,
|
|
@@ -422,6 +436,24 @@ async function validateAtPackageDir(
|
|
|
422
436
|
issues.push(issue);
|
|
423
437
|
}
|
|
424
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
|
+
}
|
|
425
457
|
if (loaded.themes && !rootProblem(loaded.themes))
|
|
426
458
|
issues.push(...unreadThemeFolderIssues(packageDir, loaded));
|
|
427
459
|
// What the docs say that no reader serves: a prop listed twice, an
|
|
@@ -440,6 +472,14 @@ async function validateAtPackageDir(
|
|
|
440
472
|
packageDir,
|
|
441
473
|
)),
|
|
442
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;
|
|
443
483
|
if (scanUnreachable) {
|
|
444
484
|
issues.push(
|
|
445
485
|
...(await findUnreachableContributionIssues(
|
|
@@ -503,7 +543,7 @@ export async function validateLocalIntegration(cwd = process.cwd()) {
|
|
|
503
543
|
const result = await validateAtPackageDir(
|
|
504
544
|
packageDir,
|
|
505
545
|
{name, version: pkg.version},
|
|
506
|
-
{scanUnreachable: true},
|
|
546
|
+
{scanUnreachable: true, own: true},
|
|
507
547
|
);
|
|
508
548
|
(result.listed ??= []).unshift(
|
|
509
549
|
...fields,
|
|
@@ -592,20 +632,21 @@ function packageJsonFieldIssues(pkg, pkgJsonPath) {
|
|
|
592
632
|
}
|
|
593
633
|
|
|
594
634
|
/**
|
|
595
|
-
* Validate an INSTALLED integration package
|
|
635
|
+
* Validate an INSTALLED integration package: the nearest `node_modules/<spec>`
|
|
636
|
+
* at or above `cwd`, resolved the way the project loads it.
|
|
596
637
|
* @param {string} spec package name
|
|
597
638
|
* @param {string} [cwd]
|
|
598
639
|
* @returns {Promise<ValidateResult>}
|
|
599
640
|
*/
|
|
600
641
|
export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
601
|
-
//
|
|
642
|
+
// The resolver throws (path-safety guard) on a spec with path segments,
|
|
602
643
|
// `..`, or an absolute path. Every other malformed input to this command
|
|
603
644
|
// degrades into a diagnostic — so catch it here and return an issue instead
|
|
604
645
|
// of letting the throw escape to a raw stack (human) / generic ERR_UNKNOWN
|
|
605
646
|
// (--json).
|
|
606
647
|
let packageDir;
|
|
607
648
|
try {
|
|
608
|
-
packageDir =
|
|
649
|
+
packageDir = resolveInstalledIntegrationDir(spec, cwd);
|
|
609
650
|
} catch (err) {
|
|
610
651
|
return {
|
|
611
652
|
found: true,
|
|
@@ -637,10 +678,29 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
|
637
678
|
};
|
|
638
679
|
}
|
|
639
680
|
|
|
640
|
-
return validateAtPackageDir(
|
|
641
|
-
|
|
642
|
-
version: pkg.version,
|
|
643
|
-
|
|
681
|
+
return validateAtPackageDir(
|
|
682
|
+
packageDir,
|
|
683
|
+
{name: pkg.name ?? spec, version: pkg.version},
|
|
684
|
+
{cwd},
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* The runner-command notes for a package's topics: each Astryx command a topic
|
|
690
|
+
* writes with a package runner, where the doc file is, and the bare command to
|
|
691
|
+
* write.
|
|
692
|
+
* @param {any} integration a loaded integration
|
|
693
|
+
* @returns {Promise<Array<{code: string, message: string}>>}
|
|
694
|
+
*/
|
|
695
|
+
async function runnerCommandNotes(integration) {
|
|
696
|
+
const packageDir = integration.__packageDir;
|
|
697
|
+
return (await integrationRunnerCommands(integration)).map(each => ({
|
|
698
|
+
code: 'runner_command',
|
|
699
|
+
message:
|
|
700
|
+
typeof packageDir === 'string'
|
|
701
|
+
? `${path.relative(packageDir, each.file).split(path.sep).join('/')}: ${each.message}`
|
|
702
|
+
: each.message,
|
|
703
|
+
}));
|
|
644
704
|
}
|
|
645
705
|
|
|
646
706
|
/**
|
|
@@ -693,6 +753,11 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
693
753
|
...(names ?? []).flatMap(each => each.notes),
|
|
694
754
|
]
|
|
695
755
|
: [];
|
|
756
|
+
// Each Astryx command a topic writes with a package runner, as a
|
|
757
|
+
// `runner_command` note with its fix, the same way.
|
|
758
|
+
if (integration?.docs) {
|
|
759
|
+
notes.push(...(await runnerCommandNotes(integration)));
|
|
760
|
+
}
|
|
696
761
|
return {
|
|
697
762
|
type: 'integration.validate',
|
|
698
763
|
data: {
|
|
@@ -716,6 +781,10 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
716
781
|
...(docTypes ? {docTypes} : {}),
|
|
717
782
|
...(docNames ? {docNames} : {}),
|
|
718
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
|
+
: {}),
|
|
719
788
|
},
|
|
720
789
|
};
|
|
721
790
|
}
|
|
@@ -14,6 +14,7 @@ export type LoadedIntegration = {
|
|
|
14
14
|
codemods?: string | undefined;
|
|
15
15
|
docs?: string | undefined;
|
|
16
16
|
issuesUrl?: string | undefined;
|
|
17
|
+
__declaredKeys?: string[] | undefined;
|
|
17
18
|
__unknownKeys?: string[] | undefined;
|
|
18
19
|
__spec: string;
|
|
19
20
|
__packageDir: string;
|
|
@@ -36,7 +37,9 @@ export type ValidateIntegrationResponse = {
|
|
|
36
37
|
type: "integration.validate";
|
|
37
38
|
/**
|
|
38
39
|
* `notes`: information beside the issues that fails nothing, such as
|
|
39
|
-
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed
|
|
40
|
+
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed;
|
|
41
|
+
* `cli_peer_version`, the running CLI outside the package's
|
|
42
|
+
* `@astryxdesign/cli` peer range; and
|
|
40
43
|
* the package layout findings added after the last minor release, each with
|
|
41
44
|
* its fix in the message: two docs for one component
|
|
42
45
|
* (`duplicate_component_doc`), a root reached through a symlink
|
|
@@ -44,9 +47,11 @@ export type ValidateIntegrationResponse = {
|
|
|
44
47
|
* (`unreadable_file`), a package.json without `name` or `version`
|
|
45
48
|
* (`invalid_package_json`), no provider ID (`no_provider_id`), and a doc
|
|
46
49
|
* whose file name differs from its source only in letter case where the two
|
|
47
|
-
* still pair (`source_without_component_doc`);
|
|
48
|
-
* `unknown_block_component` (see `docNames` and `blockComponents`);
|
|
49
|
-
* become warnings in the next
|
|
50
|
+
* still pair (`source_without_component_doc`); `doc_name_mismatch` and
|
|
51
|
+
* `unknown_block_component` (see `docNames` and `blockComponents`); and
|
|
52
|
+
* since 0.7.3 each public-import finding; they become warnings in the next
|
|
53
|
+
* minor release; and `runner_command`, an Astryx command a topic writes
|
|
54
|
+
* with a package runner
|
|
50
55
|
*/
|
|
51
56
|
data: {
|
|
52
57
|
validated: boolean;
|
|
@@ -60,6 +65,7 @@ export type ValidateIntegrationResponse = {
|
|
|
60
65
|
docTypes?: DocTypesReport;
|
|
61
66
|
docNames?: DocNamesReport;
|
|
62
67
|
blockComponents?: BlockComponentsReport;
|
|
68
|
+
publicImports?: PublicImportsReport;
|
|
63
69
|
};
|
|
64
70
|
};
|
|
65
71
|
/**
|
|
@@ -113,3 +119,30 @@ export type BlockComponentsReport = {
|
|
|
113
119
|
reason: string;
|
|
114
120
|
}>;
|
|
115
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* An import the public-import check could not judge.
|
|
124
|
+
*/
|
|
125
|
+
export type PublicImportUnchecked = {
|
|
126
|
+
/**
|
|
127
|
+
* package-relative file that names it
|
|
128
|
+
*/
|
|
129
|
+
file: string;
|
|
130
|
+
/**
|
|
131
|
+
* the import specifier
|
|
132
|
+
*/
|
|
133
|
+
specifier: string;
|
|
134
|
+
/**
|
|
135
|
+
* why it was not checked
|
|
136
|
+
*/
|
|
137
|
+
reason: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The public-import check's report on validate's result: `unchecked` lists
|
|
141
|
+
* what it could not judge, never counted or failed on. Its findings are
|
|
142
|
+
* notes on the result (`data.notes`), so `findings` stays empty.
|
|
143
|
+
*/
|
|
144
|
+
export type PublicImportsReport = {
|
|
145
|
+
status: "checked";
|
|
146
|
+
findings: never[];
|
|
147
|
+
unchecked: PublicImportUnchecked[];
|
|
148
|
+
};
|