@astryxdesign/cli 0.7.2-canary.fe2c655 → 0.7.3-canary.02f5fe4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +119 -0
- package/README.md +216 -162
- package/api/build/_adapter.d.mts +66 -0
- package/api/build/_adapter.mjs +139 -4
- package/api/build/blocks/blocks.d.mts +92 -0
- package/api/build/blocks/blocks.mjs +528 -0
- package/api/build/blocks/blocks.test.mjs +238 -0
- package/api/build/blocks/blocks.weights.json +1 -0
- package/api/build/build.doc.mjs +4 -0
- package/api/build/build.mjs +25 -6
- package/api/build/build.type.mjs +1 -1
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/answer.d.mts +18 -0
- package/api/build/kit/answer.mjs +195 -0
- package/api/build/kit/answer.test.mjs +108 -0
- package/api/build/kit/kind.d.mts +25 -0
- package/api/build/kit/kind.mjs +170 -0
- package/api/build/kit/kit.d.mts +2 -4
- package/api/build/kit/kit.mjs +8 -406
- package/api/build/kit/rank.d.mts +3 -32
- package/api/build/kit/rank.mjs +25 -342
- package/api/build/kit/rank.test.mjs +2 -1
- package/api/build/kit/signals.d.mts +79 -0
- package/api/build/kit/signals.mjs +295 -0
- package/api/build/kit/start.d.mts +32 -0
- package/api/build/kit/start.mjs +163 -0
- package/api/build/kit/words.d.mts +72 -0
- package/api/build/kit/words.mjs +202 -0
- package/api/build/tree.d.mts +20 -0
- package/api/build/tree.mjs +53 -0
- package/api/build/tree.test.mjs +185 -0
- package/api/build/tree.weights.json +1 -0
- package/api/component/_adapter.d.mts +72 -1
- package/api/component/_adapter.mjs +251 -23
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.doc.mjs +6 -1
- package/api/component/component.mjs +97 -16
- package/api/component/component.test.mjs +95 -0
- package/api/component/doc-links.test.mjs +386 -0
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/discover/_adapter.d.mts +131 -12
- package/api/discover/_adapter.mjs +520 -34
- package/api/discover/_adapter.test.mjs +641 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +9 -7
- package/api/discover/discover.mjs +120 -19
- package/api/discover/discover.type.d.mts +20 -7
- package/api/discover/discover.type.mjs +17 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/docs/_adapter.d.mts +76 -2
- package/api/docs/_adapter.mjs +630 -34
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +5 -4
- package/api/docs/docs.mjs +2 -1
- package/api/docs/docs.test.mjs +39 -20
- package/api/docs/integration-tree.test.mjs +42 -20
- package/api/docs/integrationDocs.test.mjs +125 -1
- package/api/docs/list/list.mjs +12 -2
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +3 -5
- package/api/doctor/_adapter.d.mts +128 -0
- package/api/doctor/_adapter.mjs +253 -4
- package/api/doctor/doctor.d.mts +217 -0
- package/api/doctor/doctor.doc.mjs +3 -2
- package/api/doctor/doctor.mjs +691 -52
- package/api/doctor/doctor.test.mjs +267 -18
- package/api/doctor/release-checks.test.mjs +156 -0
- package/api/doctor/theme-checks.mjs +17 -4
- package/api/doctor/theme-checks.test.mjs +223 -7
- package/api/error.d.mts +10 -0
- package/api/error.mjs +25 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +219 -52
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/hook/_adapter.mjs +3 -11
- package/api/hook/hook.doc.mjs +4 -0
- package/api/hook/hook.mjs +1 -1
- package/api/hook/list/list.d.mts +1 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/_adapter.d.mts +22 -0
- package/api/init/_adapter.mjs +59 -0
- package/api/init/init.d.mts +7 -5
- package/api/init/init.doc.mjs +45 -10
- package/api/init/init.mjs +28 -4
- package/api/init/init.test.mjs +18 -2
- package/api/init/init.type.d.mts +50 -5
- package/api/init/init.type.mjs +39 -5
- package/api/init/remove/remove.mjs +17 -4
- package/api/init/remove/remove.test.mjs +114 -2
- package/api/init/run/run.d.mts +1 -1
- package/api/init/run/run.mjs +86 -12
- package/api/init/user/user.d.mts +14 -0
- package/api/init/user/user.mjs +87 -0
- package/api/init/user/user.test.mjs +232 -0
- package/api/integration/_adapter.d.mts +53 -0
- package/api/integration/_adapter.mjs +132 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +192 -14
- package/api/integration/authoring-checks.test.mjs +1028 -0
- package/api/integration/authoring-checks.type.d.mts +143 -0
- package/api/integration/authoring-checks.type.mjs +74 -2
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +45 -6
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +486 -123
- package/api/integration/pack-check.test.mjs +817 -10
- package/api/integration/validate-integration-case-disk.test.mjs +111 -0
- package/api/integration/validate-integration-fixes.test.mjs +73 -5
- package/api/integration/validate-integration-gaps.test.mjs +1975 -0
- package/api/integration/validate-integration.d.mts +23 -2
- package/api/integration/validate-integration.mjs +358 -45
- package/api/integration/validate-integration.test.mjs +88 -8
- package/api/integration/validate-integration.type.d.mts +105 -0
- package/api/integration/validate-integration.type.mjs +79 -1
- package/api/integration/validate-unread-theme-folders.test.mjs +3 -2
- package/api/integration/validateIntegration.doc.mjs +19 -3
- package/api/search/ORDERING.md +28 -0
- package/api/search/_adapter.d.mts +91 -0
- package/api/search/_adapter.mjs +172 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.d.mts +40 -0
- package/api/search/_candidate-score.mjs +238 -0
- package/api/search/_cards.json +6098 -0
- package/api/search/_compound.d.mts +50 -0
- package/api/search/_compound.mjs +170 -0
- package/api/search/_doc-searcher.d.mts +4 -0
- package/api/search/_doc-searcher.mjs +23 -0
- package/api/search/_doc-searcher.test.mjs +36 -0
- package/api/search/_doc-searcher.weights.json +1 -0
- package/api/search/_doc-text.d.mts +30 -0
- package/api/search/_doc-text.mjs +87 -0
- package/api/search/_entries.d.mts +63 -0
- package/api/search/_entries.mjs +232 -0
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_features.d.mts +35 -0
- package/api/search/_features.mjs +155 -0
- package/api/search/_gather-components.d.mts +26 -0
- package/api/search/_gather-components.mjs +284 -0
- package/api/search/_gather-docs.d.mts +20 -0
- package/api/search/_gather-docs.mjs +254 -0
- package/api/search/_gather-hooks.d.mts +12 -0
- package/api/search/_gather-hooks.mjs +52 -0
- package/api/search/_gather-templates.d.mts +25 -0
- package/api/search/_gather-templates.mjs +107 -0
- package/api/search/_lexical.d.mts +135 -0
- package/api/search/_lexical.mjs +351 -0
- package/api/search/_main-searcher.d.mts +19 -0
- package/api/search/_main-searcher.mjs +115 -0
- package/api/search/_main-searcher.test.mjs +106 -0
- package/api/search/_main-searcher.weights.json +1 -0
- package/api/search/_module-doc.d.mts +32 -0
- package/api/search/_module-doc.mjs +78 -0
- package/api/search/_order.d.mts +32 -0
- package/api/search/_order.mjs +162 -0
- package/api/search/_order.test.mjs +72 -0
- package/api/search/_priority.d.mts +50 -0
- package/api/search/_priority.mjs +139 -0
- package/api/search/_query-words.d.mts +25 -0
- package/api/search/_query-words.mjs +92 -0
- package/api/search/_query.d.mts +65 -0
- package/api/search/_query.mjs +176 -0
- package/api/search/_result.d.mts +97 -0
- package/api/search/_result.mjs +150 -0
- package/api/search/_score.d.mts +60 -0
- package/api/search/_score.mjs +283 -0
- package/api/search/_synonyms.d.mts +21 -0
- package/api/search/_synonyms.mjs +67 -0
- package/api/search/_template-searcher.d.mts +4 -0
- package/api/search/_template-searcher.mjs +23 -0
- package/api/search/_template-searcher.test.mjs +40 -0
- package/api/search/_template-searcher.weights.json +1 -0
- package/api/search/_titles.d.mts +33 -0
- package/api/search/_titles.mjs +65 -0
- package/api/search/_words.d.mts +64 -0
- package/api/search/_words.mjs +157 -0
- package/api/search/search.d.mts +22 -236
- package/api/search/search.doc.mjs +14 -7
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +59 -1904
- package/api/search/search.test.mjs +193 -15
- package/api/search/search.type.d.mts +20 -2
- package/api/search/search.type.mjs +12 -2
- package/api/search/tree.d.mts +15 -0
- package/api/search/tree.mjs +40 -0
- package/api/search/tree.test.mjs +66 -0
- package/api/search/tree.weights.json +1 -0
- package/api/swizzle/_adapter.mjs +2 -2
- package/api/swizzle/copy/copy.mjs +29 -15
- package/api/template/template-integration.test.mjs +1 -1
- package/api/template/template.mjs +5 -1
- package/api/template/template.test.mjs +120 -3
- package/api/theme/_adapter.d.mts +16 -0
- package/api/theme/_adapter.mjs +32 -5
- package/api/theme/build/build.d.mts +2 -1
- package/api/theme/build/build.family.test.mjs +64 -0
- package/api/theme/build/build.mjs +250 -38
- package/api/theme/build/build.packed-old-core.test.mjs +21 -3
- package/api/theme/build/font-warning.mjs +5 -3
- package/api/theme/build/font-warning.test.mjs +2 -1
- package/api/theme/remove/remove.test.mjs +2 -2
- package/api/theme/targets/targets.mjs +3 -10
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/theme/themeTargets.doc.mjs +4 -0
- package/api/theme/use/use.test.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +97 -11
- package/api/upgrade/_adapter.mjs +315 -32
- 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/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +48 -4
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +16 -8
- package/api/upgrade/upgrade.mjs +18 -3
- package/api/upgrade/upgrade.test.mjs +194 -0
- package/api/upgrade/upgrade.type.d.mts +28 -3
- package/api/upgrade/upgrade.type.mjs +24 -7
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/runner.mjs +7 -1
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +11 -0
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +3 -3
- package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/v0.7.2/index.mjs +20 -0
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +5 -5
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +26 -6
- package/assets/docs/is-my-code-good.doc.mjs +287 -0
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +22 -2
- package/assets/docs/tree/add-a-theme.doc.mjs +14 -4
- package/assets/docs/tree/add-a-topic.doc.mjs +54 -9
- package/assets/docs/tree/agent-guidance.doc.mjs +19 -5
- package/assets/docs/tree/api.doc.mjs +6 -0
- package/assets/docs/tree/authoring.doc.mjs +61 -0
- package/assets/docs/tree/block-template.doc.mjs +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +6 -2
- package/assets/docs/tree/check-the-props.doc.mjs +201 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +69 -11
- package/assets/docs/tree/checks.doc.mjs +32 -24
- package/assets/docs/tree/ci-and-containers.doc.mjs +101 -0
- package/assets/docs/tree/cli-command.doc.mjs +142 -0
- package/assets/docs/tree/cli.doc.mjs +7 -1
- package/assets/docs/tree/codemods.doc.mjs +17 -7
- package/assets/docs/tree/commands.doc.mjs +7 -1
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +21 -3
- package/assets/docs/tree/components.doc.mjs +7 -1
- package/assets/docs/tree/computer-agent-guide.doc.mjs +160 -0
- package/assets/docs/tree/computer-integrations.doc.mjs +93 -0
- package/assets/docs/tree/configuration.doc.mjs +8 -4
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +41 -22
- package/assets/docs/tree/define-the-theme.doc.mjs +7 -6
- package/assets/docs/tree/describe-the-component.doc.mjs +3 -3
- package/assets/docs/tree/docs.doc.mjs +9 -3
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +19 -9
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
- package/assets/docs/tree/generate-a-palette.doc.mjs +8 -6
- package/assets/docs/tree/global-integrations.doc.mjs +124 -0
- package/assets/docs/tree/global.doc.mjs +131 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +5 -5
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +128 -0
- package/assets/docs/tree/install-once.doc.mjs +105 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/links.doc.mjs +7 -6
- package/assets/docs/tree/migration-setup.doc.mjs +3 -2
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- package/assets/docs/tree/monorepos.doc.mjs +84 -0
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +4 -8
- package/assets/docs/tree/problems.doc.mjs +205 -0
- package/assets/docs/tree/project-global-or-both.doc.mjs +131 -0
- package/assets/docs/tree/publishing.doc.mjs +6 -6
- package/assets/docs/tree/quick-start.doc.mjs +54 -28
- package/assets/docs/tree/reference.doc.mjs +192 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +15 -7
- package/assets/docs/tree/replace-a-core-template.doc.mjs +10 -12
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +9 -11
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +17 -5
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +9 -8
- package/assets/docs/tree/single-component.doc.mjs +15 -6
- package/assets/docs/tree/start-a-template.doc.mjs +18 -8
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +6 -17
- 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 +2 -2
- package/assets/docs/tree/templates.doc.mjs +7 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +7 -7
- package/assets/docs/tree/test-template-in-app.doc.mjs +5 -5
- package/assets/docs/tree/themes.doc.mjs +5 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +29 -13
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/uninstall.doc.mjs +109 -0
- package/assets/docs/tree/updates.doc.mjs +92 -0
- package/assets/docs/tree/upgrading.doc.mjs +6 -6
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +15 -3
- package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +14 -9
- package/assets/docs/tree/who-answers.doc.mjs +119 -0
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +7 -6
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/assets/docs/working-with-ai.doc.mjs +70 -13
- 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/assets/theme.template.ts +1 -1
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/discover/discover.doc.mjs +7 -1
- package/authoring/doctypes/_schema.d.mts +8 -3
- package/authoring/doctypes/_schema.mjs +1 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/command/command.doc.mjs +20 -12
- package/authoring/doctypes/command/type.ts +14 -0
- package/authoring/doctypes/component/component.doc.mjs +30 -27
- package/authoring/doctypes/component/type.ts +21 -8
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/hook/type.ts +4 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +12 -11
- package/authoring/doctypes/schema/schema.doc.mjs +10 -10
- package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/index.d.ts +2 -0
- package/authoring/integration/integration.doc.mjs +30 -6
- package/authoring/integration/parse.test.mjs +21 -0
- package/authoring/integration/schema.d.mts +16 -3
- package/authoring/integration/schema.mjs +34 -2
- package/authoring/integration/type.ts +13 -1
- package/clients/cli/bin/astryx.mjs +11 -65
- package/clients/cli/cli-command.test.mjs +166 -0
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/blog.doc.mjs +1 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +17 -3
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/build-theme.font-warning.test.mjs +3 -3
- package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/build.doc.mjs +1 -0
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +4 -0
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/discover.broken-integration.test.mjs +11 -7
- package/clients/cli/commands/discover.doc.mjs +9 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +448 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/docs.doc.mjs +3 -2
- package/clients/cli/commands/docs.mjs +50 -20
- package/clients/cli/commands/docs.test.mjs +16 -16
- package/clients/cli/commands/doctor-integration-components.doc.mjs +19 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +20 -5
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +22 -2
- package/clients/cli/commands/doctor-integration.test.mjs +936 -3
- package/clients/cli/commands/doctor.doc.mjs +12 -2
- package/clients/cli/commands/doctor.mjs +332 -7
- package/clients/cli/commands/doctor.test.mjs +75 -4
- package/clients/cli/commands/gap-report.doc.mjs +15 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/hook.doc.mjs +1 -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/init.behavior.test.mjs +235 -1
- package/clients/cli/commands/init.doc.mjs +55 -10
- package/clients/cli/commands/init.flag-help.test.mjs +1 -0
- package/clients/cli/commands/init.mjs +2 -2
- package/clients/cli/commands/integration-add.doc.mjs +7 -0
- package/clients/cli/commands/integration-authoring.test.mjs +49 -3
- package/clients/cli/commands/integration-check.doc.mjs +93 -0
- package/clients/cli/commands/integration-check.test.mjs +489 -0
- package/clients/cli/commands/integration-pack.doc.mjs +8 -1
- package/clients/cli/commands/integration-verify.doc.mjs +8 -1
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +119 -7
- package/clients/cli/commands/json-contract.test.mjs +11 -2
- package/clients/cli/commands/manifest.doc.mjs +2 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/outside-project.test.mjs +874 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/search.doc.mjs +1 -0
- package/clients/cli/commands/search.mjs +16 -11
- package/clients/cli/commands/search.test.mjs +429 -296
- package/clients/cli/commands/setup-nudge.test.mjs +180 -2
- package/clients/cli/commands/swizzle.doc.mjs +7 -0
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +19 -2
- package/clients/cli/commands/template.doc.mjs +1 -0
- package/clients/cli/commands/text-json-parity.test.mjs +5 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +3 -3
- package/clients/cli/commands/theme-add.doc.mjs +8 -1
- package/clients/cli/commands/theme-build.doc.mjs +3 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +6 -0
- package/clients/cli/commands/theme-list.doc.mjs +1 -0
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -0
- package/clients/cli/commands/theme-remove.doc.mjs +7 -0
- package/clients/cli/commands/theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -0
- package/clients/cli/commands/theme-use.doc.mjs +7 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +27 -14
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.doc.mjs +26 -3
- package/clients/cli/commands/upgrade.file-protection.test.mjs +3 -2
- package/clients/cli/commands/upgrade.hook-output.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/clients/cli/index.mjs +156 -100
- package/clients/cli/lib/cli-error.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +14 -9
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/json-shim.mjs +3 -1
- package/clients/cli/lib/manifest.d.ts +9 -0
- package/clients/cli/lib/manifest.mjs +17 -1
- package/clients/cli/lib/manifest.test.mjs +37 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/clients/cli/run.mjs +108 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +67 -13
- package/foundation/agent-docs/agent-doc-state.mjs +123 -14
- package/foundation/agent-docs/agent-docs.d.mts +104 -15
- package/foundation/agent-docs/agent-docs.mjs +1028 -114
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +1239 -17
- package/foundation/agent-docs/agent-docs.test.mjs +683 -39
- package/foundation/agent-docs/computer-agent-text.d.mts +170 -0
- package/foundation/agent-docs/computer-agent-text.mjs +750 -0
- package/foundation/agent-docs/computer-agent-text.test.mjs +699 -0
- package/foundation/config/project.d.mts +35 -3
- package/foundation/config/project.mjs +243 -26
- package/foundation/config/project.test.mjs +122 -0
- package/foundation/config/theme-state.mjs +5 -4
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +17 -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 +22 -4
- package/foundation/discovery/cli-self-docs.test.mjs +3 -2
- package/foundation/discovery/component-discovery.d.mts +227 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +940 -57
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/component-replacement.mjs +20 -1
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1231 -0
- package/foundation/discovery/doc-types.test.mjs +744 -0
- package/foundation/discovery/docs-discovery.d.mts +88 -0
- package/foundation/discovery/docs-discovery.mjs +97 -3
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/module-exports.d.mts +68 -0
- package/foundation/discovery/module-exports.mjs +609 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +297 -0
- package/foundation/discovery/prop-drift.mjs +2428 -0
- package/foundation/discovery/prop-drift.test.mjs +2337 -0
- package/foundation/discovery/runner-allowlist.d.mts +38 -0
- package/foundation/discovery/runner-allowlist.mjs +51 -0
- 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.d.mts +52 -0
- package/foundation/discovery/stray-pointers.mjs +293 -0
- package/foundation/discovery/stray-pointers.test.mjs +86 -0
- package/foundation/discovery/template-adapter.mjs +92 -6
- package/foundation/discovery/template-needs.mjs +6 -46
- package/foundation/discovery/theme-discovery.mjs +147 -3
- package/foundation/discovery/theme-imports.mjs +8 -4
- package/foundation/discovery/theme-imports.test.mjs +1 -1
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +84 -10
- package/foundation/doc-compiler/inputs.mjs +27 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +41 -5
- package/foundation/doc-compiler/links.mjs +167 -28
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/read.d.mts +1 -1
- 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 +107 -44
- package/foundation/doc-compiler/tree.test.mjs +14 -7
- package/foundation/env/cli-command.d.mts +83 -0
- package/foundation/env/cli-command.mjs +152 -0
- package/foundation/env/cli-command.test.mjs +129 -0
- package/foundation/env/node-version.test.mjs +15 -3
- package/foundation/env/package-manager.d.mts +93 -9
- package/foundation/env/package-manager.global.test.mjs +66 -0
- package/foundation/env/package-manager.mjs +184 -13
- package/foundation/env/package-manager.test.mjs +341 -15
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +33 -0
- package/foundation/env/search-path.d.mts +42 -0
- package/foundation/env/search-path.mjs +205 -0
- package/foundation/env/search-path.test.mjs +122 -0
- package/foundation/env/user-dirs.d.mts +39 -0
- package/foundation/env/user-dirs.mjs +93 -0
- package/foundation/env/user-dirs.test.mjs +72 -0
- package/foundation/env/user-settings.d.mts +46 -0
- package/foundation/env/user-settings.mjs +106 -0
- package/foundation/env/user-settings.test.mjs +64 -0
- package/foundation/fs/file-protection.mjs +15 -1
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.stdout.test.mjs +3 -2
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/fs/path-compare.d.mts +33 -0
- package/foundation/fs/path-compare.mjs +73 -0
- package/foundation/fs/paths.d.mts +122 -4
- package/foundation/fs/paths.mjs +675 -29
- package/foundation/fs/paths.test.mjs +439 -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/computer-integrations.d.mts +81 -0
- package/foundation/integrations/computer-integrations.mjs +345 -0
- package/foundation/integrations/computer-integrations.test.mjs +292 -0
- package/foundation/integrations/contribution-inventory.d.mts +26 -20
- package/foundation/integrations/contribution-inventory.mjs +97 -8
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/integration-warnings.mjs +3 -2
- package/foundation/integrations/integration-warnings.test.mjs +8 -9
- package/foundation/integrations/integrations.d.mts +51 -1
- package/foundation/integrations/integrations.mjs +106 -4
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- package/foundation/integrations/validate-contributions.d.mts +117 -0
- package/foundation/integrations/validate-contributions.mjs +1209 -14
- package/foundation/release/agent-text-worker.d.mts +4 -0
- package/foundation/release/agent-text-worker.mjs +52 -0
- package/foundation/release/cache.d.mts +310 -0
- package/foundation/release/cache.mjs +1216 -0
- package/foundation/release/cache.test.mjs +923 -0
- package/foundation/release/choose.d.mts +207 -0
- package/foundation/release/choose.mjs +677 -0
- package/foundation/release/choose.test.mjs +427 -0
- package/foundation/release/core-worker.d.mts +4 -0
- package/foundation/release/core-worker.mjs +38 -0
- package/foundation/release/global-state.d.mts +263 -0
- package/foundation/release/global-state.mjs +474 -0
- package/foundation/release/global-state.test.mjs +381 -0
- package/foundation/release/handoff.d.mts +79 -0
- package/foundation/release/handoff.e2e.test.mjs +278 -0
- package/foundation/release/handoff.mjs +524 -0
- package/foundation/release/lock-lease.d.mts +23 -0
- package/foundation/release/lock-lease.mjs +80 -0
- package/foundation/release/notices.d.mts +307 -0
- package/foundation/release/notices.mjs +707 -0
- package/foundation/release/notices.test.mjs +586 -0
- package/foundation/release/npm-guard.d.mts +4 -0
- package/foundation/release/npm-guard.mjs +126 -0
- package/foundation/release/project.d.mts +141 -0
- package/foundation/release/project.mjs +466 -0
- package/foundation/release/project.test.mjs +288 -0
- package/foundation/release/refresh-worker.d.mts +4 -0
- package/foundation/release/refresh-worker.mjs +27 -0
- package/foundation/release/run-context.d.mts +47 -0
- package/foundation/release/run-context.mjs +163 -0
- package/foundation/release/update-notice-env.d.mts +28 -0
- package/foundation/release/update-notice-env.mjs +39 -0
- package/foundation/response/base.d.ts +26 -3
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.doc.mjs +12 -0
- package/foundation/response/error-codes.mjs +17 -0
- package/foundation/response/error-codes.test.mjs +2 -0
- package/foundation/response/json-contract.test.mjs +7 -2
- package/foundation/response/json.mjs +4 -1
- package/foundation/response/response-types.doc.mjs +22 -11
- package/foundation/response/response-types.doc.test.mjs +46 -0
- package/foundation/response/response.doc.mjs +3 -3
- package/foundation/route/route.d.mts +285 -0
- package/foundation/route/route.mjs +324 -0
- package/foundation/route/route.test.mjs +153 -0
- package/foundation/runtime/hosted-runtime.test.mjs +403 -0
- package/foundation/runtime/locked-versions.d.mts +32 -0
- package/foundation/runtime/locked-versions.mjs +65 -0
- package/foundation/runtime/package-root.d.mts +91 -0
- package/foundation/runtime/package-root.mjs +174 -0
- package/foundation/runtime/package-set.d.mts +62 -0
- package/foundation/runtime/package-set.mjs +130 -0
- package/foundation/runtime/package-set.test.mjs +432 -0
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/foundation/xle/browser-imports.test.mjs +74 -0
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/host/door-conformance.test.mjs +274 -0
- package/host/index.d.ts +116 -0
- package/host/index.mjs +295 -0
- package/host/index.test.mjs +302 -0
- package/package.json +16 -11
- package/scripts/postinstall.mjs +24 -5
- package/assets/docs/tree/integrations.doc.mjs +0 -40
|
@@ -23,8 +23,15 @@
|
|
|
23
23
|
|
|
24
24
|
import * as fs from 'node:fs';
|
|
25
25
|
import * as path from 'node:path';
|
|
26
|
+
import {parse as parseModule} from '@babel/parser';
|
|
26
27
|
import {isValidSemver} from '../env/semver.mjs';
|
|
27
|
-
import {
|
|
28
|
+
import {findProjectCoreDir} from '../fs/paths.mjs';
|
|
29
|
+
import {KNOWN_INTEGRATION_KEYS} from '../../authoring/integration/schema.mjs';
|
|
30
|
+
import {
|
|
31
|
+
contributionFiles,
|
|
32
|
+
findSourceOnlyCandidates,
|
|
33
|
+
findTemplateSourceOnlyCandidates,
|
|
34
|
+
} from './contribution-inventory.mjs';
|
|
28
35
|
import {
|
|
29
36
|
CODEMOD_FILE_RE,
|
|
30
37
|
CODEMOD_SKIP_DIRS,
|
|
@@ -45,6 +52,12 @@ import {MANIFEST_BASENAMES} from './integrations.mjs';
|
|
|
45
52
|
import {discoverIntegrationCodemods} from '../../assets/codemods/integration-discovery.mjs';
|
|
46
53
|
import {discoverIntegrationTemplatesForOne} from '../discovery/template-adapter.mjs';
|
|
47
54
|
import * as componentDiscovery from '../discovery/component-discovery.mjs';
|
|
55
|
+
import {loadComponentDoc} from '../discovery/component-loader.mjs';
|
|
56
|
+
import {
|
|
57
|
+
moduleExportNames,
|
|
58
|
+
moduleExportsName,
|
|
59
|
+
moduleExportVerdict,
|
|
60
|
+
} from '../discovery/module-exports.mjs';
|
|
48
61
|
import {discoverIntegrationDocs} from '../discovery/docs-discovery.mjs';
|
|
49
62
|
import {discoverIntegrationThemes} from '../discovery/theme-discovery.mjs';
|
|
50
63
|
|
|
@@ -56,6 +69,9 @@ import {discoverIntegrationThemes} from '../discovery/theme-discovery.mjs';
|
|
|
56
69
|
/** Stable issue code for an invalid optional agent-doc contribution. */
|
|
57
70
|
export const INVALID_AGENT_DOCS = 'invalid_agent_docs';
|
|
58
71
|
|
|
72
|
+
/** Stable issue code for a `cliCommand` that was ignored as invalid. */
|
|
73
|
+
export const INVALID_CLI_COMMAND = 'invalid_cli_command';
|
|
74
|
+
|
|
59
75
|
/** Stable issue code for a package whose provider ID is already claimed. */
|
|
60
76
|
export const DUPLICATE_PROVIDER = 'duplicate_provider';
|
|
61
77
|
|
|
@@ -69,6 +85,32 @@ export function issueWarning(code, message) {
|
|
|
69
85
|
return {code, severity: 'warning', message};
|
|
70
86
|
}
|
|
71
87
|
|
|
88
|
+
/** Issues `issueListed` made: listed in validate's `layout` report only. */
|
|
89
|
+
const LISTED = new WeakSet();
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A layout finding added after the last minor release: validate lists it, in
|
|
93
|
+
* its `layout` report, but it is never an issue, so nothing counts it and
|
|
94
|
+
* `integration check --strict` does not fail on it. A new failing finding
|
|
95
|
+
* joins only in a minor release (architecture:cli-surface INV35).
|
|
96
|
+
* @param {string} code
|
|
97
|
+
* @param {string} message
|
|
98
|
+
* @returns {Issue}
|
|
99
|
+
*/
|
|
100
|
+
export function issueListed(code, message) {
|
|
101
|
+
const issue = issueWarning(code, message);
|
|
102
|
+
LISTED.add(issue);
|
|
103
|
+
return issue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Whether `issueListed` made this issue.
|
|
108
|
+
* @param {Issue} issue
|
|
109
|
+
*/
|
|
110
|
+
export function isListedIssue(issue) {
|
|
111
|
+
return LISTED.has(issue);
|
|
112
|
+
}
|
|
113
|
+
|
|
72
114
|
/**
|
|
73
115
|
* Report the manifest keys this CLI does not know.
|
|
74
116
|
*
|
|
@@ -86,11 +128,36 @@ export function issueWarning(code, message) {
|
|
|
86
128
|
function checkUnknownKeys(integration, issues) {
|
|
87
129
|
const keys = integration.__unknownKeys ?? [];
|
|
88
130
|
if (keys.length === 0) return;
|
|
131
|
+
// A key one edit away from a known one is almost always a typo: say so
|
|
132
|
+
// first, since "a newer CLI" sends the author to upgrade for nothing.
|
|
133
|
+
const typos = keys
|
|
134
|
+
.map(key => ({key, known: nearestKnownKey(key)}))
|
|
135
|
+
.filter(each => each.known != null);
|
|
136
|
+
for (const {key, known} of typos) {
|
|
137
|
+
// The manifest object already declares the key it is a near miss of:
|
|
138
|
+
// renaming would give it twice, so the stray key goes. Read from what
|
|
139
|
+
// the manifest says, not the loaded integration, which fills some keys
|
|
140
|
+
// in (providerId from the package name).
|
|
141
|
+
const alreadySet = (integration.__declaredKeys ?? []).includes(
|
|
142
|
+
/** @type {string} */ (known),
|
|
143
|
+
);
|
|
144
|
+
const fix = alreadySet
|
|
145
|
+
? `Fix: remove "${key}" from ${manifestName(integration)}; it already sets "${known}".`
|
|
146
|
+
: `Fix: rename "${key}" to "${known}" in ${manifestName(integration)}.`;
|
|
147
|
+
issues.push(
|
|
148
|
+
issueWarning(
|
|
149
|
+
'unknown_manifest_key',
|
|
150
|
+
`This CLI does not know the manifest key "${key}", so it is ignored. Did you mean \`${known}\`? ${fix} If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.`,
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const rest = keys.filter(key => !typos.some(each => each.key === key));
|
|
155
|
+
if (rest.length === 0) return;
|
|
89
156
|
issues.push(
|
|
90
157
|
issueWarning(
|
|
91
158
|
'unknown_manifest_key',
|
|
92
|
-
`This CLI does not know the manifest ${
|
|
93
|
-
`${
|
|
159
|
+
`This CLI does not know the manifest ${rest.length === 1 ? 'key' : 'keys'} ` +
|
|
160
|
+
`${rest.map(key => `"${key}"`).join(', ')}, so ${rest.length === 1 ? 'it is' : 'they are'} ` +
|
|
94
161
|
`ignored — everything else in the manifest still applies. This usually ` +
|
|
95
162
|
`means the integration was published against a newer Astryx CLI than ` +
|
|
96
163
|
`this project resolves; upgrading @astryxdesign/cli picks it up.`,
|
|
@@ -98,6 +165,60 @@ function checkUnknownKeys(integration, issues) {
|
|
|
98
165
|
);
|
|
99
166
|
}
|
|
100
167
|
|
|
168
|
+
/** @param {{__manifestFile?: string}} integration */
|
|
169
|
+
function manifestName(integration) {
|
|
170
|
+
return integration.__manifestFile
|
|
171
|
+
? path.basename(integration.__manifestFile)
|
|
172
|
+
: 'the integration manifest';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The known manifest key `key` is a near miss of: a different letter case, or
|
|
177
|
+
* at most two letters added, dropped or changed (`component`, `doc`,
|
|
178
|
+
* `tempaltes`). Null when no known key is that close, or two are.
|
|
179
|
+
* @param {string} key
|
|
180
|
+
* @returns {string | null}
|
|
181
|
+
*/
|
|
182
|
+
export function nearestKnownKey(key) {
|
|
183
|
+
const lower = key.toLowerCase();
|
|
184
|
+
const limit = lower.length <= 4 ? 1 : 2;
|
|
185
|
+
/** @type {string[]} */
|
|
186
|
+
const close = [];
|
|
187
|
+
for (const known of KNOWN_INTEGRATION_KEYS) {
|
|
188
|
+
const distance = editDistance(lower, known.toLowerCase());
|
|
189
|
+
if (distance <= limit) close.push(known);
|
|
190
|
+
}
|
|
191
|
+
return close.length === 1 ? close[0] : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Levenshtein distance, with a swap of two neighbours counted as one edit.
|
|
196
|
+
* @param {string} a
|
|
197
|
+
* @param {string} b
|
|
198
|
+
*/
|
|
199
|
+
function editDistance(a, b) {
|
|
200
|
+
/** @type {number[][]} */
|
|
201
|
+
const d = Array.from({length: a.length + 1}, (_, i) =>
|
|
202
|
+
Array.from({length: b.length + 1}, (_, j) =>
|
|
203
|
+
i === 0 ? j : j === 0 ? i : 0,
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
for (let i = 1; i <= a.length; i++) {
|
|
207
|
+
for (let j = 1; j <= b.length; j++) {
|
|
208
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
209
|
+
d[i][j] = Math.min(
|
|
210
|
+
d[i - 1][j] + 1,
|
|
211
|
+
d[i][j - 1] + 1,
|
|
212
|
+
d[i - 1][j - 1] + cost,
|
|
213
|
+
);
|
|
214
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
215
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return d[a.length][b.length];
|
|
220
|
+
}
|
|
221
|
+
|
|
101
222
|
/**
|
|
102
223
|
* Why a declared root cannot be read as a folder, or null when it can.
|
|
103
224
|
* A missing root keeps its own issue; a root that is a file or that the
|
|
@@ -133,11 +254,14 @@ export function rootProblem(root) {
|
|
|
133
254
|
* declared-but-missing root is a `missing_root` error, a file is an
|
|
134
255
|
* `invalid_root` error, and a folder that cannot be read is an
|
|
135
256
|
* `unreadable_root` error. The contribution checks skip all three.
|
|
136
|
-
*
|
|
257
|
+
* A readable root reached through a symlinked folder is a `symlinked_root`
|
|
258
|
+
* warning: npm pack does not follow it, so the published package loses it.
|
|
259
|
+
* @param {{components?: string, templates?: string, codemods?: string, docs?: string, themes?: string, __manifestFile?: string}} resolved
|
|
137
260
|
* absolute resolved roots (undefined when not declared)
|
|
138
261
|
* @param {Issue[]} issues
|
|
262
|
+
* @param {string} [packageDir] the package the roots belong to
|
|
139
263
|
*/
|
|
140
|
-
function checkRoots(resolved, issues) {
|
|
264
|
+
function checkRoots(resolved, issues, packageDir) {
|
|
141
265
|
const kinds = /** @type {const} */ ([
|
|
142
266
|
'components',
|
|
143
267
|
'templates',
|
|
@@ -149,7 +273,28 @@ function checkRoots(resolved, issues) {
|
|
|
149
273
|
const root = resolved[kind];
|
|
150
274
|
if (root == null) continue;
|
|
151
275
|
const problem = rootProblem(root);
|
|
152
|
-
if (problem == null)
|
|
276
|
+
if (problem == null) {
|
|
277
|
+
const link = packageDir ? symlinkedFolder(root, packageDir) : null;
|
|
278
|
+
if (link && packageDir) {
|
|
279
|
+
const shown = slash(path.relative(packageDir, link.path));
|
|
280
|
+
const realPackage = fs.realpathSync(packageDir);
|
|
281
|
+
const target = slash(path.relative(realPackage, link.target));
|
|
282
|
+
const realRoot = slash(
|
|
283
|
+
path.relative(realPackage, fs.realpathSync(root)),
|
|
284
|
+
);
|
|
285
|
+
const outside = target.startsWith('../') || path.isAbsolute(target);
|
|
286
|
+
const fix = outside
|
|
287
|
+
? 'replace the link with a real folder holding its files'
|
|
288
|
+
: `replace the link with the folder itself (move ${target}/ to ${shown}/), or set \`${kind}: './${realRoot}'\` in ${manifestName(resolved)}`;
|
|
289
|
+
issues.push(
|
|
290
|
+
issueListed(
|
|
291
|
+
'symlinked_root',
|
|
292
|
+
`Declared ${kind} root "${slash(path.relative(packageDir, root))}" is reached through the symlink "${shown}" (to "${target}"). Astryx follows it locally, but npm pack does not follow a symlinked folder, so the published package ships none of these files. Fix: ${fix}.`,
|
|
293
|
+
),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
153
298
|
if (problem.kind === 'missing') {
|
|
154
299
|
issues.push(
|
|
155
300
|
issueError(
|
|
@@ -175,6 +320,41 @@ function checkRoots(resolved, issues) {
|
|
|
175
320
|
}
|
|
176
321
|
}
|
|
177
322
|
|
|
323
|
+
/** @param {string} file */
|
|
324
|
+
function slash(file) {
|
|
325
|
+
return file.split(path.sep).join('/');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* The first folder on the way from the package to `root` (the root itself
|
|
330
|
+
* included) that is a symlink, with where it points, or null.
|
|
331
|
+
* @param {string} root absolute
|
|
332
|
+
* @param {string} packageDir absolute
|
|
333
|
+
* @returns {{path: string, target: string} | null}
|
|
334
|
+
*/
|
|
335
|
+
export function symlinkedFolder(root, packageDir) {
|
|
336
|
+
const relative = path.relative(packageDir, root);
|
|
337
|
+
if (
|
|
338
|
+
relative === '' ||
|
|
339
|
+
relative.startsWith('..') ||
|
|
340
|
+
path.isAbsolute(relative)
|
|
341
|
+
) {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
let current = packageDir;
|
|
345
|
+
for (const segment of relative.split(path.sep)) {
|
|
346
|
+
current = path.join(current, segment);
|
|
347
|
+
try {
|
|
348
|
+
if (fs.lstatSync(current).isSymbolicLink()) {
|
|
349
|
+
return {path: current, target: fs.realpathSync(current)};
|
|
350
|
+
}
|
|
351
|
+
} catch {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
|
|
178
358
|
/**
|
|
179
359
|
* Validate the integration's codemods via the landed discovery. Discovery is
|
|
180
360
|
* strict (throws on bad export / duplicate id); we convert any throw into an
|
|
@@ -295,6 +475,577 @@ async function checkTemplates(integration, issues) {
|
|
|
295
475
|
issueError('invalid_template', /** @type {any} */ (err).message),
|
|
296
476
|
);
|
|
297
477
|
}
|
|
478
|
+
checkTemplateSourcesWithoutDoc(integration, issues);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* The component names each of a package's templates gives in `exampleFor`
|
|
483
|
+
* and `componentsUsed`, judged against the components `astryx component`
|
|
484
|
+
* finds: the package's own, and every doc it resolves in Core. A name the
|
|
485
|
+
* template imports needs no doc of its own. A name neither has is an
|
|
486
|
+
* `unknown_block_component` finding, since the template list and the
|
|
487
|
+
* block's search keywords then give a name no one can look up. A name the
|
|
488
|
+
* template may reach through anything the walk does not model, and, without
|
|
489
|
+
* Core installed, a name the package does not have, cannot be judged and is
|
|
490
|
+
* listed in `unchecked` instead.
|
|
491
|
+
* @param {LoadedIntegration} integration
|
|
492
|
+
* @returns {Promise<{findings: Array<{docPath: string, name: string, message: string}>, unchecked: Array<{docPath: string, name: string, reason: string}>}>}
|
|
493
|
+
*/
|
|
494
|
+
async function judgeBlockComponents(integration) {
|
|
495
|
+
/** @type {Array<{docPath: string, name: string, message: string}>} */
|
|
496
|
+
const findings = [];
|
|
497
|
+
/** @type {Array<{docPath: string, name: string, reason: string}>} */
|
|
498
|
+
const unchecked = [];
|
|
499
|
+
const root = integration.templates;
|
|
500
|
+
if (!root || rootProblem(root)) return {findings, unchecked};
|
|
501
|
+
let templates;
|
|
502
|
+
try {
|
|
503
|
+
({templates} = await discoverIntegrationTemplatesForOne(integration));
|
|
504
|
+
} catch {
|
|
505
|
+
return {findings, unchecked};
|
|
506
|
+
}
|
|
507
|
+
/** @type {Set<string>} */
|
|
508
|
+
let own;
|
|
509
|
+
try {
|
|
510
|
+
own = new Set(
|
|
511
|
+
componentDiscovery
|
|
512
|
+
.discoverIntegrationComponents(integration)
|
|
513
|
+
.map(record => record.name),
|
|
514
|
+
);
|
|
515
|
+
} catch {
|
|
516
|
+
return {findings, unchecked};
|
|
517
|
+
}
|
|
518
|
+
// The Core installed beside the package, never the one the CLI carries:
|
|
519
|
+
// a name is judged against the Core the package's users install.
|
|
520
|
+
const coreDir = findProjectCoreDir(integration.__packageDir ?? root);
|
|
521
|
+
/** @type {Map<string, boolean>} */
|
|
522
|
+
const inCore = new Map();
|
|
523
|
+
/** @param {string} name */
|
|
524
|
+
const coreHas = name => {
|
|
525
|
+
if (!coreDir) return false;
|
|
526
|
+
if (!inCore.has(name)) {
|
|
527
|
+
let found;
|
|
528
|
+
try {
|
|
529
|
+
found = componentDiscovery.findComponentReadme(coreDir, name) != null;
|
|
530
|
+
} catch {
|
|
531
|
+
found = false;
|
|
532
|
+
}
|
|
533
|
+
inCore.set(name, found);
|
|
534
|
+
}
|
|
535
|
+
return /** @type {boolean} */ (inCore.get(name));
|
|
536
|
+
};
|
|
537
|
+
for (const template of templates) {
|
|
538
|
+
const fields = [
|
|
539
|
+
...(typeof template.exampleFor === 'string'
|
|
540
|
+
? [{field: 'exampleFor', name: template.exampleFor}]
|
|
541
|
+
: []),
|
|
542
|
+
...(Array.isArray(template.componentsUsed) ? template.componentsUsed : [])
|
|
543
|
+
.filter(name => typeof name === 'string')
|
|
544
|
+
.map(name => ({field: 'componentsUsed', name})),
|
|
545
|
+
];
|
|
546
|
+
if (fields.length === 0) continue;
|
|
547
|
+
const imported = importedNames(template.filePath, integration);
|
|
548
|
+
for (const {field, name} of fields) {
|
|
549
|
+
if (own.has(name) || imported.names.has(name)) continue;
|
|
550
|
+
if (coreHas(name)) continue;
|
|
551
|
+
// A name the template may reach through a namespace import, or
|
|
552
|
+
// through a local module this read could not follow, is not judged.
|
|
553
|
+
if (imported.unread.length > 0) {
|
|
554
|
+
unchecked.push({
|
|
555
|
+
docPath: template.docPath,
|
|
556
|
+
name,
|
|
557
|
+
reason: imported.unread[0],
|
|
558
|
+
});
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (!coreDir) {
|
|
562
|
+
unchecked.push({
|
|
563
|
+
docPath: template.docPath,
|
|
564
|
+
name,
|
|
565
|
+
reason:
|
|
566
|
+
'Core is not installed, so its component names cannot be checked.',
|
|
567
|
+
});
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
findings.push({
|
|
571
|
+
docPath: template.docPath,
|
|
572
|
+
name,
|
|
573
|
+
message: `Template "${template.dirName}" names "${name}" in ${field}, but neither this package nor Core has a component by that name and the template does not import it, so \`astryx template --list\` and the block's search keywords give a component name no one can look up. Fix: use the component's exact name, or remove "${name}" from ${field}.`,
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return {findings, unchecked};
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Visit every node under `node`, depth first.
|
|
582
|
+
* @param {any} node
|
|
583
|
+
* @param {(node: any) => void} visit
|
|
584
|
+
*/
|
|
585
|
+
function walkNodes(node, visit) {
|
|
586
|
+
if (node == null || typeof node !== 'object') return;
|
|
587
|
+
if (Array.isArray(node)) {
|
|
588
|
+
for (const each of node) walkNodes(each, visit);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (typeof node.type === 'string') visit(node);
|
|
592
|
+
for (const [key, value] of Object.entries(node)) {
|
|
593
|
+
if (
|
|
594
|
+
key === 'loc' ||
|
|
595
|
+
key === 'start' ||
|
|
596
|
+
key === 'end' ||
|
|
597
|
+
key === 'extra' ||
|
|
598
|
+
key === 'leadingComments' ||
|
|
599
|
+
key === 'trailingComments'
|
|
600
|
+
) {
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if (value && typeof value === 'object') walkNodes(value, visit);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** The extensions a local import may leave off, in the order tried. */
|
|
608
|
+
const LOCAL_MODULE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs'];
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Libraries that render no component of this package or of Core: React's
|
|
612
|
+
* own exports and StyleX. Importing them, even as a namespace
|
|
613
|
+
* (`import * as stylex`), leaves no name unjudged.
|
|
614
|
+
*/
|
|
615
|
+
const RENDERLESS_SOURCES = ['react', 'react-dom', '@stylexjs/stylex'];
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Packages a template may import from without leaving its names unjudged:
|
|
619
|
+
* Core and the renderless libraries. Any other package may render components
|
|
620
|
+
* this check does not see, such as a grid that renders its cards.
|
|
621
|
+
*/
|
|
622
|
+
const KNOWN_SOURCES = ['@astryxdesign/core', ...RENDERLESS_SOURCES];
|
|
623
|
+
|
|
624
|
+
/** @param {string} source */
|
|
625
|
+
function renderlessSource(source) {
|
|
626
|
+
return RENDERLESS_SOURCES.some(
|
|
627
|
+
known => source === known || source.startsWith(`${known}/`),
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Whether an import source is one whose components this check sees: Core, a
|
|
633
|
+
* library that renders none, or a relative helper (followed and read in full
|
|
634
|
+
* on its own). The package's own name is followed like a helper too.
|
|
635
|
+
* @param {string} source
|
|
636
|
+
*/
|
|
637
|
+
function knownSource(source) {
|
|
638
|
+
if (source.startsWith('.')) return true;
|
|
639
|
+
return KNOWN_SOURCES.some(
|
|
640
|
+
known => source === known || source.startsWith(`${known}/`),
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Every name a template imports, as imported and as bound locally, read
|
|
646
|
+
* without running it, with the names its local helper modules import (a
|
|
647
|
+
* relative import or re-export is followed, so a barrel such as
|
|
648
|
+
* `parts/index.ts` counts). A name is judged only where the template reaches
|
|
649
|
+
* components solely through named imports and re-exports this walk reads:
|
|
650
|
+
* `unread` gives the reason for anything else it meets, which leaves an
|
|
651
|
+
* unresolved name unjudged. That covers a default or namespace import, an
|
|
652
|
+
* alias of an imported binding, a member read off one (in JSX or not,
|
|
653
|
+
* optional or computed), a rendered component it cannot trace to an import,
|
|
654
|
+
* `require()`, a dynamic `import()`, an `export *` from another package, and
|
|
655
|
+
* a local module it cannot read. So does any `default` binding (`import X`,
|
|
656
|
+
* `{default as X}`, `export {default as X} from`) and any import from a
|
|
657
|
+
* package other than Core or a library that renders no component (see
|
|
658
|
+
* KNOWN_SOURCES). An import of the package's own name is followed like a
|
|
659
|
+
* relative helper, through its package.json `exports`. Type-only imports
|
|
660
|
+
* render nothing and are skipped, as is a namespace or default import of a
|
|
661
|
+
* library that renders no component.
|
|
662
|
+
* @param {string} file
|
|
663
|
+
* @param {LoadedIntegration} integration
|
|
664
|
+
* @returns {{names: Set<string>, unread: string[]}}
|
|
665
|
+
*/
|
|
666
|
+
function importedNames(file, integration) {
|
|
667
|
+
const packageName = integration.name;
|
|
668
|
+
/** @type {Set<string>} */
|
|
669
|
+
const names = new Set();
|
|
670
|
+
/** @type {string[]} */
|
|
671
|
+
const unread = [];
|
|
672
|
+
const top = path.dirname(file);
|
|
673
|
+
const shownTop = path.basename(file);
|
|
674
|
+
/** @type {Set<string>} */
|
|
675
|
+
const seen = new Set();
|
|
676
|
+
/** @param {string} current */
|
|
677
|
+
const visit = current => {
|
|
678
|
+
if (seen.has(current)) return;
|
|
679
|
+
seen.add(current);
|
|
680
|
+
const shown = slash(path.relative(top, current)) || shownTop;
|
|
681
|
+
let ast;
|
|
682
|
+
try {
|
|
683
|
+
ast = parseModule(fs.readFileSync(current, 'utf8'), {
|
|
684
|
+
sourceType: 'module',
|
|
685
|
+
plugins: ['typescript', 'jsx'],
|
|
686
|
+
errorRecovery: true,
|
|
687
|
+
});
|
|
688
|
+
} catch {
|
|
689
|
+
unread.push(
|
|
690
|
+
`${shown} could not be read, so the components it renders are not known.`,
|
|
691
|
+
);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
// A file that parses only with errors recovered may be missing parts.
|
|
695
|
+
if (/** @type {any} */ (ast).errors?.length > 0) {
|
|
696
|
+
unread.push(
|
|
697
|
+
`${shown} does not parse cleanly, so the components it renders are not known.`,
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
/** @type {Map<string, string>} local binding -> the module it came from */
|
|
701
|
+
const bindings = new Map();
|
|
702
|
+
for (const node of ast.program.body) {
|
|
703
|
+
const reexport =
|
|
704
|
+
(node.type === 'ExportNamedDeclaration' && node.source != null) ||
|
|
705
|
+
node.type === 'ExportAllDeclaration';
|
|
706
|
+
if (node.type !== 'ImportDeclaration' && !reexport) continue;
|
|
707
|
+
// A type-only import or re-export renders nothing.
|
|
708
|
+
if (
|
|
709
|
+
/** @type {any} */ (node).importKind === 'type' ||
|
|
710
|
+
/** @type {any} */ (node).exportKind === 'type'
|
|
711
|
+
) {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const source = String(/** @type {any} */ (node).source.value);
|
|
715
|
+
// The package's own name: read like a relative helper, below.
|
|
716
|
+
const own =
|
|
717
|
+
typeof packageName === 'string' &&
|
|
718
|
+
packageName !== '' &&
|
|
719
|
+
(source === packageName || source.startsWith(`${packageName}/`));
|
|
720
|
+
if (!own && !knownSource(source)) {
|
|
721
|
+
unread.push(
|
|
722
|
+
`${shown} imports from "${source}", another package whose components may render ones this check does not see.`,
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
if (node.type === 'ImportDeclaration') {
|
|
726
|
+
for (const specifier of node.specifiers) {
|
|
727
|
+
if (/** @type {any} */ (specifier).importKind === 'type') continue;
|
|
728
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
729
|
+
// `import * as stylex`: a library that renders no component.
|
|
730
|
+
if (renderlessSource(source)) continue;
|
|
731
|
+
unread.push(
|
|
732
|
+
`${shown} imports "${source}" as a namespace (${specifier.local.name}), whose component names this check does not read.`,
|
|
733
|
+
);
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
if (
|
|
737
|
+
specifier.type === 'ImportDefaultSpecifier' &&
|
|
738
|
+
!renderlessSource(source)
|
|
739
|
+
) {
|
|
740
|
+
// A default may be any component, under any name.
|
|
741
|
+
unread.push(
|
|
742
|
+
`${shown} imports the default of "${source}" as ${specifier.local.name}, which may be any component.`,
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
names.add(specifier.local.name);
|
|
746
|
+
bindings.set(specifier.local.name, source);
|
|
747
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
748
|
+
const imported = specifier.imported;
|
|
749
|
+
const importedName =
|
|
750
|
+
imported.type === 'Identifier' ? imported.name : imported.value;
|
|
751
|
+
if (importedName === 'default') {
|
|
752
|
+
unread.push(
|
|
753
|
+
`${shown} imports the default of "${source}" as ${specifier.local.name}, which may be any component.`,
|
|
754
|
+
);
|
|
755
|
+
} else {
|
|
756
|
+
names.add(importedName);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
} else if (node.type === 'ExportNamedDeclaration') {
|
|
761
|
+
// A barrel: `export {Body} from './Body'` passes Body on, and what
|
|
762
|
+
// Body renders comes from the module it names.
|
|
763
|
+
for (const each of node.specifiers) {
|
|
764
|
+
const specifier = /** @type {any} */ (each);
|
|
765
|
+
if (specifier.exportKind === 'type') continue;
|
|
766
|
+
if (specifier.type !== 'ExportSpecifier') {
|
|
767
|
+
// `export * as UI from`, `export UI from`.
|
|
768
|
+
unread.push(
|
|
769
|
+
`${shown} re-exports "${source}" as a whole (${specifier.exported.type === 'Identifier' ? specifier.exported.name : specifier.exported.value}), whose component names this check does not read.`,
|
|
770
|
+
);
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
const local =
|
|
774
|
+
specifier.local.type === 'Identifier'
|
|
775
|
+
? specifier.local.name
|
|
776
|
+
: specifier.local.value;
|
|
777
|
+
const exported =
|
|
778
|
+
specifier.exported.type === 'Identifier'
|
|
779
|
+
? specifier.exported.name
|
|
780
|
+
: specifier.exported.value;
|
|
781
|
+
if (local === 'default') {
|
|
782
|
+
unread.push(
|
|
783
|
+
`${shown} re-exports the default of "${source}" as ${exported}, which may be any component.`,
|
|
784
|
+
);
|
|
785
|
+
} else {
|
|
786
|
+
names.add(local);
|
|
787
|
+
}
|
|
788
|
+
names.add(exported);
|
|
789
|
+
}
|
|
790
|
+
} else if (!source.startsWith('.') && !own) {
|
|
791
|
+
// `export * from` another package passes on names this check
|
|
792
|
+
// does not list.
|
|
793
|
+
unread.push(
|
|
794
|
+
`${shown} re-exports everything from "${source}", whose component names this check does not read.`,
|
|
795
|
+
);
|
|
796
|
+
continue;
|
|
797
|
+
} else if (/** @type {any} */ (node).exported) {
|
|
798
|
+
// `export * as UI from './parts'`.
|
|
799
|
+
unread.push(
|
|
800
|
+
`${shown} re-exports "${source}" as a whole, whose component names this check does not read.`,
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
if (!source.startsWith('.') && !own) continue;
|
|
804
|
+
if (own) {
|
|
805
|
+
const resolved = componentDiscovery.ownPackageModule(
|
|
806
|
+
integration,
|
|
807
|
+
source,
|
|
808
|
+
);
|
|
809
|
+
/** @type {boolean} */
|
|
810
|
+
let isFile;
|
|
811
|
+
try {
|
|
812
|
+
isFile = resolved != null && fs.statSync(resolved).isFile();
|
|
813
|
+
} catch {
|
|
814
|
+
isFile = false;
|
|
815
|
+
}
|
|
816
|
+
if (
|
|
817
|
+
resolved &&
|
|
818
|
+
isFile &&
|
|
819
|
+
LOCAL_MODULE_EXTENSIONS.includes(path.extname(resolved))
|
|
820
|
+
) {
|
|
821
|
+
visit(resolved);
|
|
822
|
+
} else {
|
|
823
|
+
unread.push(
|
|
824
|
+
`${shown} imports "${source}", this package's own name, which resolves to no source this check can read.`,
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
const base = path.resolve(path.dirname(current), source);
|
|
830
|
+
const target = [
|
|
831
|
+
base,
|
|
832
|
+
...LOCAL_MODULE_EXTENSIONS.map(extension => `${base}${extension}`),
|
|
833
|
+
...LOCAL_MODULE_EXTENSIONS.map(extension =>
|
|
834
|
+
path.join(base, `index${extension}`),
|
|
835
|
+
),
|
|
836
|
+
].find(candidate => {
|
|
837
|
+
try {
|
|
838
|
+
return fs.statSync(candidate).isFile();
|
|
839
|
+
} catch {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
if (!target) {
|
|
844
|
+
unread.push(
|
|
845
|
+
`${shown} imports "${source}", which resolves to no file this check can read.`,
|
|
846
|
+
);
|
|
847
|
+
} else if (LOCAL_MODULE_EXTENSIONS.includes(path.extname(target))) {
|
|
848
|
+
visit(target);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
// Anything this check does not model leaves the names unjudged: what
|
|
852
|
+
// the module renders through a binding, an alias, a member read, a
|
|
853
|
+
// component held in a variable, or a module loaded at runtime.
|
|
854
|
+
/** @type {Set<string>} functions and classes the module declares */
|
|
855
|
+
const declared = new Set();
|
|
856
|
+
walkNodes(ast.program, node => {
|
|
857
|
+
if (
|
|
858
|
+
(node.type === 'FunctionDeclaration' ||
|
|
859
|
+
node.type === 'ClassDeclaration') &&
|
|
860
|
+
node.id?.name
|
|
861
|
+
) {
|
|
862
|
+
declared.add(node.id.name);
|
|
863
|
+
} else if (
|
|
864
|
+
node.type === 'VariableDeclarator' &&
|
|
865
|
+
node.id?.type === 'Identifier' &&
|
|
866
|
+
[
|
|
867
|
+
'ArrowFunctionExpression',
|
|
868
|
+
'FunctionExpression',
|
|
869
|
+
'ClassExpression',
|
|
870
|
+
].includes(node.init?.type)
|
|
871
|
+
) {
|
|
872
|
+
declared.add(node.id.name);
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
const from = (/** @type {string} */ name) =>
|
|
876
|
+
bindings.has(name) ? ` (imported from "${bindings.get(name)}")` : '';
|
|
877
|
+
walkNodes(ast.program, node => {
|
|
878
|
+
if (node.type === 'JSXMemberExpression') {
|
|
879
|
+
let object = node.object;
|
|
880
|
+
while (object?.type === 'JSXMemberExpression') object = object.object;
|
|
881
|
+
const name = object?.name ?? 'an object';
|
|
882
|
+
unread.push(
|
|
883
|
+
`${shown} renders members of ${name}${from(name)}, whose names this check does not read.`,
|
|
884
|
+
);
|
|
885
|
+
} else if (
|
|
886
|
+
node.type === 'JSXOpeningElement' &&
|
|
887
|
+
node.name?.type === 'JSXIdentifier' &&
|
|
888
|
+
/^[A-Z]/u.test(node.name.name) &&
|
|
889
|
+
!names.has(node.name.name) &&
|
|
890
|
+
!declared.has(node.name.name)
|
|
891
|
+
) {
|
|
892
|
+
unread.push(
|
|
893
|
+
`${shown} renders ${node.name.name}, a value this check does not trace to an import.`,
|
|
894
|
+
);
|
|
895
|
+
} else if (
|
|
896
|
+
node.type === 'VariableDeclarator' &&
|
|
897
|
+
node.init?.type === 'Identifier' &&
|
|
898
|
+
bindings.has(node.init.name)
|
|
899
|
+
) {
|
|
900
|
+
// `const UI = Lib`, `const {Panel} = Lib`: an alias of an import.
|
|
901
|
+
if (node.id?.type === 'Identifier') {
|
|
902
|
+
bindings.set(
|
|
903
|
+
node.id.name,
|
|
904
|
+
/** @type {string} */ (bindings.get(node.init.name)),
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
unread.push(
|
|
908
|
+
`${shown} reads ${node.init.name}${from(node.init.name)} into another name, which this check does not follow.`,
|
|
909
|
+
);
|
|
910
|
+
} else if (
|
|
911
|
+
(node.type === 'MemberExpression' ||
|
|
912
|
+
node.type === 'OptionalMemberExpression') &&
|
|
913
|
+
node.object?.type === 'Identifier' &&
|
|
914
|
+
bindings.has(node.object.name)
|
|
915
|
+
) {
|
|
916
|
+
// `UI.Panel`, `UI?.Panel`, `UI['Panel']`, `createElement(UI.Panel)`.
|
|
917
|
+
unread.push(
|
|
918
|
+
`${shown} reads members of ${node.object.name}${from(node.object.name)}, whose names this check does not read.`,
|
|
919
|
+
);
|
|
920
|
+
} else if (
|
|
921
|
+
node.type === 'CallExpression' &&
|
|
922
|
+
node.callee?.type === 'Identifier' &&
|
|
923
|
+
node.callee.name === 'require'
|
|
924
|
+
) {
|
|
925
|
+
const argument = node.arguments?.[0];
|
|
926
|
+
const spec =
|
|
927
|
+
argument?.type === 'StringLiteral'
|
|
928
|
+
? `"${argument.value}"`
|
|
929
|
+
: 'a module';
|
|
930
|
+
unread.push(
|
|
931
|
+
`${shown} loads ${spec} with require(), whose component names this check does not read.`,
|
|
932
|
+
);
|
|
933
|
+
} else if (
|
|
934
|
+
node.type === 'ImportExpression' ||
|
|
935
|
+
(node.type === 'CallExpression' && node.callee?.type === 'Import')
|
|
936
|
+
) {
|
|
937
|
+
const argument = node.source ?? node.arguments?.[0];
|
|
938
|
+
const spec =
|
|
939
|
+
argument?.type === 'StringLiteral'
|
|
940
|
+
? `"${argument.value}"`
|
|
941
|
+
: 'a module';
|
|
942
|
+
unread.push(
|
|
943
|
+
`${shown} loads ${spec} with a dynamic import(), whose component names this check does not read.`,
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
visit(file);
|
|
949
|
+
return {names, unread};
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* The local name a module's default export declares (`export default
|
|
954
|
+
* function AcmeWidget()`, `export default class AcmeWidget`), or of the
|
|
955
|
+
* binding it exports as default (`export default AcmeWidget`), or null.
|
|
956
|
+
* @param {string} file
|
|
957
|
+
* @returns {string | null}
|
|
958
|
+
*/
|
|
959
|
+
function defaultBinding(file) {
|
|
960
|
+
let ast;
|
|
961
|
+
try {
|
|
962
|
+
ast = parseModule(fs.readFileSync(file, 'utf8'), {
|
|
963
|
+
sourceType: 'module',
|
|
964
|
+
plugins: ['typescript', 'jsx'],
|
|
965
|
+
errorRecovery: true,
|
|
966
|
+
});
|
|
967
|
+
} catch {
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
for (const node of ast.program.body) {
|
|
971
|
+
if (node.type !== 'ExportDefaultDeclaration') continue;
|
|
972
|
+
const declaration = /** @type {any} */ (node.declaration);
|
|
973
|
+
if (typeof declaration?.id?.name === 'string') return declaration.id.name;
|
|
974
|
+
if (declaration?.type === 'Identifier') return declaration.name;
|
|
975
|
+
}
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* A note: information beside validate's issues that fails nothing, with the
|
|
981
|
+
* fix in its message.
|
|
982
|
+
* @typedef {{code: string, message: string}} Note
|
|
983
|
+
*/
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* @param {string} code
|
|
987
|
+
* @param {{message: string}} finding
|
|
988
|
+
* @returns {Note}
|
|
989
|
+
*/
|
|
990
|
+
function note(code, finding) {
|
|
991
|
+
return {code, message: finding.message};
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* The block component names this check could not judge, shaped like the
|
|
996
|
+
* doc type report so `integration check` counts them as not compared: each
|
|
997
|
+
* name a template gives in `exampleFor` or `componentsUsed` that neither the
|
|
998
|
+
* package nor Core has, when the template reaches components through
|
|
999
|
+
* anything but named imports and re-exports from the package, Core, or
|
|
1000
|
+
* helpers read in full (see importedNames), or when Core is not installed to
|
|
1001
|
+
* look it up in; its findings are always empty. A name judged unknown is an
|
|
1002
|
+
* `unknown_block_component` note, with its fix in the message: validate
|
|
1003
|
+
* lists notes beside its issues, and nothing counts them, so `--strict` does
|
|
1004
|
+
* not fail on it until the next minor release (architecture:cli-surface
|
|
1005
|
+
* INV35).
|
|
1006
|
+
* @param {LoadedIntegration} integration
|
|
1007
|
+
* @returns {Promise<{report: {status: 'checked', findings: [], unchecked: Array<{file: string, name: string, reason: string}>}, notes: Note[]}>}
|
|
1008
|
+
*/
|
|
1009
|
+
export async function blockComponentsCheck(integration) {
|
|
1010
|
+
const {findings, unchecked} = await judgeBlockComponents(integration);
|
|
1011
|
+
const base = integration.__packageDir ?? integration.templates ?? '';
|
|
1012
|
+
return {
|
|
1013
|
+
report: {
|
|
1014
|
+
status: 'checked',
|
|
1015
|
+
findings: [],
|
|
1016
|
+
unchecked: unchecked.map(entry => ({
|
|
1017
|
+
file: slash(path.relative(base, entry.docPath)),
|
|
1018
|
+
name: entry.name,
|
|
1019
|
+
reason: entry.reason,
|
|
1020
|
+
})),
|
|
1021
|
+
},
|
|
1022
|
+
notes: findings.map(entry => note('unknown_block_component', entry)),
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Warn about a `.tsx` directly in the templates root with no same-stem template
|
|
1028
|
+
* metadata: template discovery pairs sources with docs, so `astryx template`
|
|
1029
|
+
* never lists it. A PascalCase file directly in a shared components root is
|
|
1030
|
+
* left to the component check, which already warns about it.
|
|
1031
|
+
* @param {LoadedIntegration} integration loaded-integration-shaped object
|
|
1032
|
+
* @param {Issue[]} issues
|
|
1033
|
+
*/
|
|
1034
|
+
function checkTemplateSourcesWithoutDoc(integration, issues) {
|
|
1035
|
+
const root = /** @type {string} */ (integration.templates);
|
|
1036
|
+
const sharedComponents =
|
|
1037
|
+
integration.components != null &&
|
|
1038
|
+
path.resolve(integration.components) === path.resolve(root);
|
|
1039
|
+
for (const file of findTemplateSourceOnlyCandidates(root)) {
|
|
1040
|
+
if (sharedComponents && /^[A-Z]/u.test(file)) continue;
|
|
1041
|
+
const stem = file.slice(0, -'.tsx'.length);
|
|
1042
|
+
issues.push(
|
|
1043
|
+
issueWarning(
|
|
1044
|
+
'source_without_template_doc',
|
|
1045
|
+
`Template source "${file}" has no same-stem metadata file ${stem}.doc.mjs, so \`astryx template\` never lists it. Fix: add ${stem}.doc.mjs beside it with type: 'page' or 'block'; \`astryx docs authoring integration-template-doc\` lists its fields. If it is not a template, move it out of the templates root.`,
|
|
1046
|
+
),
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
298
1049
|
}
|
|
299
1050
|
|
|
300
1051
|
/**
|
|
@@ -308,6 +1059,8 @@ async function checkComponents(integration, issues) {
|
|
|
308
1059
|
if (!integration.components || rootProblem(integration.components)) return;
|
|
309
1060
|
const discover = componentDiscovery.discoverValidIntegrationComponents;
|
|
310
1061
|
if (typeof discover !== 'function') return; // feature not present yet
|
|
1062
|
+
const root = /** @type {string} */ (integration.components);
|
|
1063
|
+
const files = componentDocFiles(root);
|
|
311
1064
|
try {
|
|
312
1065
|
const {discovered, errors} = await discover(integration);
|
|
313
1066
|
/** @type {import('./contribution-fixes.mjs').FixContext | undefined} */
|
|
@@ -320,13 +1073,75 @@ async function checkComponents(integration, issues) {
|
|
|
320
1073
|
continue;
|
|
321
1074
|
}
|
|
322
1075
|
const docPath = record.docPath;
|
|
323
|
-
|
|
1076
|
+
// Reported once, below, as the case mismatch it is.
|
|
1077
|
+
if (docPath && files.caseMismatch.has(docPath)) continue;
|
|
1078
|
+
const docName = docPath
|
|
1079
|
+
? path.basename(docPath)
|
|
1080
|
+
: `${record.name}.doc.mjs`;
|
|
1081
|
+
let message = error.message;
|
|
1082
|
+
let fix = `Fix: add ${record.name}.tsx beside ${docName}.`;
|
|
324
1083
|
const stamp = docPath ? readContributionStamp(docPath, false) : null;
|
|
325
1084
|
if (stamp && stamp.type !== 'component' && integration.__packageDir) {
|
|
326
1085
|
context ??= createFixContext(integration.__packageDir, integration);
|
|
327
1086
|
fix = notAComponentFix(context, docPath, stamp);
|
|
1087
|
+
} else {
|
|
1088
|
+
const other = docPath ? otherSourceFor(docPath) : null;
|
|
1089
|
+
if (other) {
|
|
1090
|
+
message = `${message.replace(/\.$/u, '')}: found ${other}, but a component source must be a .tsx file.`;
|
|
1091
|
+
fix = `Fix: rename ${other} to ${record.name}.tsx (and point its package export at the new file).`;
|
|
1092
|
+
}
|
|
328
1093
|
}
|
|
329
|
-
issues.push(issueError('invalid_component', `${
|
|
1094
|
+
issues.push(issueError('invalid_component', `${message} ${fix}`));
|
|
1095
|
+
}
|
|
1096
|
+
/** @type {Set<string>} sources a case-only rename is reported for */
|
|
1097
|
+
const reportedSources = new Set();
|
|
1098
|
+
for (const [docPath, source] of files.caseMismatch) {
|
|
1099
|
+
const doc = path.basename(docPath);
|
|
1100
|
+
const renamed = `${source.slice(0, -'.tsx'.length)}${doc.slice(docStemOf(doc).length)}`;
|
|
1101
|
+
const shown = slash(path.relative(root, docPath));
|
|
1102
|
+
const linux = `They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run`;
|
|
1103
|
+
const fix = `Fix: rename ${doc} to ${renamed}.`;
|
|
1104
|
+
// Where discovery still pairs the doc with its source (a
|
|
1105
|
+
// case-insensitive disk), the component works here: listed, as
|
|
1106
|
+
// validate passed it before. A hidden doc that does not pair leaves its
|
|
1107
|
+
// source without a doc, which the source check below reports as it
|
|
1108
|
+
// always has (architecture:cli-surface INV37).
|
|
1109
|
+
const pairs = componentDiscovery.integrationSourceForDoc(docPath) != null;
|
|
1110
|
+
const hidden = componentDiscovery.isHiddenComponentDoc(docPath);
|
|
1111
|
+
if (hidden && !pairs) continue;
|
|
1112
|
+
reportedSources.add(path.join(path.dirname(docPath), source));
|
|
1113
|
+
if (hidden) {
|
|
1114
|
+
issues.push(
|
|
1115
|
+
issueListed(
|
|
1116
|
+
'source_without_component_doc',
|
|
1117
|
+
`Hidden component doc "${shown}" and its source "${source}" differ only in letter case. ${linux}. ${fix}`,
|
|
1118
|
+
),
|
|
1119
|
+
);
|
|
1120
|
+
} else if (pairs) {
|
|
1121
|
+
issues.push(
|
|
1122
|
+
issueListed(
|
|
1123
|
+
'source_without_component_doc',
|
|
1124
|
+
`Component doc "${shown}" and its source "${source}" differ only in letter case. ${linux}, so there the component is missing. ${fix}`,
|
|
1125
|
+
),
|
|
1126
|
+
);
|
|
1127
|
+
} else {
|
|
1128
|
+
issues.push(
|
|
1129
|
+
issueError(
|
|
1130
|
+
'invalid_component',
|
|
1131
|
+
`Component doc "${shown}" and its source "${source}" differ only in letter case. ${linux}, so here the component is missing. ${fix}`,
|
|
1132
|
+
),
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
for (const {read, ignored} of files.duplicates) {
|
|
1137
|
+
const readName = path.basename(read);
|
|
1138
|
+
const ignoredNames = ignored.map(file => path.basename(file));
|
|
1139
|
+
issues.push(
|
|
1140
|
+
issueListed(
|
|
1141
|
+
'duplicate_component_doc',
|
|
1142
|
+
`Component "${docStemOf(readName)}" has ${ignored.length + 1} docs: ${[readName, ...ignoredNames].join(', ')}. Astryx reads ${readName} and ignores ${ignoredNames.join(' and ')}. Fix: delete ${ignoredNames.join(' and ')}, moving anything only ${ignored.length === 1 ? 'it says' : 'they say'} into ${readName}.`,
|
|
1143
|
+
),
|
|
1144
|
+
);
|
|
330
1145
|
}
|
|
331
1146
|
const overlap = integration.__packageDir
|
|
332
1147
|
? newComponentDocNote(
|
|
@@ -340,16 +1155,13 @@ async function checkComponents(integration, issues) {
|
|
|
340
1155
|
// A hidden doc still pairs with its source; discovery just skips it.
|
|
341
1156
|
if (
|
|
342
1157
|
['.doc.ts', '.doc.mjs', '.doc.js'].some(suffix =>
|
|
343
|
-
fs.existsSync(
|
|
344
|
-
path.join(
|
|
345
|
-
/** @type {string} */ (integration.components),
|
|
346
|
-
`${name}${suffix}`,
|
|
347
|
-
),
|
|
348
|
-
),
|
|
1158
|
+
fs.existsSync(path.join(root, `${name}${suffix}`)),
|
|
349
1159
|
)
|
|
350
1160
|
) {
|
|
351
1161
|
continue;
|
|
352
1162
|
}
|
|
1163
|
+
// A doc whose name differs only in case is reported above.
|
|
1164
|
+
if (reportedSources.has(path.join(root, `${name}.tsx`))) continue;
|
|
353
1165
|
issues.push(
|
|
354
1166
|
issueWarning(
|
|
355
1167
|
'source_without_component_doc',
|
|
@@ -364,6 +1176,251 @@ async function checkComponents(integration, issues) {
|
|
|
364
1176
|
}
|
|
365
1177
|
}
|
|
366
1178
|
|
|
1179
|
+
const COMPONENT_DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
|
|
1180
|
+
|
|
1181
|
+
/** @param {string} file a doc file name */
|
|
1182
|
+
function docStemOf(file) {
|
|
1183
|
+
const suffix = COMPONENT_DOC_SUFFIXES.find(each => file.endsWith(each));
|
|
1184
|
+
return suffix ? file.slice(0, -suffix.length) : file;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* A same-stem source discovery does not read: `.jsx`, `.js`, `.ts` or `.mjs`.
|
|
1189
|
+
* @param {string} docPath
|
|
1190
|
+
* @returns {string | null} its file name
|
|
1191
|
+
*/
|
|
1192
|
+
function otherSourceFor(docPath) {
|
|
1193
|
+
const stem = docStemOf(path.basename(docPath));
|
|
1194
|
+
const dir = path.dirname(docPath);
|
|
1195
|
+
return (
|
|
1196
|
+
['.jsx', '.js', '.ts', '.mjs']
|
|
1197
|
+
.map(extension => `${stem}${extension}`)
|
|
1198
|
+
.find(file => fs.existsSync(path.join(dir, file))) ?? null
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* The component docs under a root, read from the real directory listings:
|
|
1204
|
+
* those beside a source whose name differs only in letter case (which an
|
|
1205
|
+
* existence check on a case-insensitive disk would call paired), and stems
|
|
1206
|
+
* with more than one doc, with the doc discovery reads.
|
|
1207
|
+
* @param {string} root
|
|
1208
|
+
*/
|
|
1209
|
+
function componentDocFiles(root) {
|
|
1210
|
+
/** @type {Map<string, string>} doc path -> the source's real file name */
|
|
1211
|
+
const caseMismatch = new Map();
|
|
1212
|
+
/** @type {Array<{read: string, ignored: string[]}>} */
|
|
1213
|
+
const duplicates = [];
|
|
1214
|
+
/** @param {string} dir */
|
|
1215
|
+
const walk = dir => {
|
|
1216
|
+
let entries;
|
|
1217
|
+
try {
|
|
1218
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
1219
|
+
} catch {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
const names = new Set(entries.map(entry => entry.name));
|
|
1223
|
+
/** @type {Map<string, string[]>} */
|
|
1224
|
+
const byStem = new Map();
|
|
1225
|
+
for (const entry of entries) {
|
|
1226
|
+
const full = path.join(dir, entry.name);
|
|
1227
|
+
if (entry.isDirectory()) {
|
|
1228
|
+
if (entry.name !== 'node_modules' && entry.name !== '__tests__') {
|
|
1229
|
+
walk(full);
|
|
1230
|
+
}
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1233
|
+
const stem = docStemOf(entry.name);
|
|
1234
|
+
if (stem === entry.name) continue;
|
|
1235
|
+
byStem.set(stem, [...(byStem.get(stem) ?? []), entry.name]);
|
|
1236
|
+
const source = `${stem}.tsx`;
|
|
1237
|
+
if (names.has(source)) continue;
|
|
1238
|
+
const other = [...names].find(
|
|
1239
|
+
name => name !== source && name.toLowerCase() === source.toLowerCase(),
|
|
1240
|
+
);
|
|
1241
|
+
// The source's own doc, if it has one, is its pair.
|
|
1242
|
+
if (
|
|
1243
|
+
other &&
|
|
1244
|
+
!COMPONENT_DOC_SUFFIXES.some(suffix =>
|
|
1245
|
+
names.has(`${other.slice(0, -'.tsx'.length)}${suffix}`),
|
|
1246
|
+
)
|
|
1247
|
+
) {
|
|
1248
|
+
caseMismatch.set(full, other);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
for (const docs of byStem.values()) {
|
|
1252
|
+
if (docs.length < 2) continue;
|
|
1253
|
+
const ordered = COMPONENT_DOC_SUFFIXES.map(suffix =>
|
|
1254
|
+
docs.find(doc => doc.endsWith(suffix)),
|
|
1255
|
+
).filter(doc => doc != null);
|
|
1256
|
+
duplicates.push({
|
|
1257
|
+
read: path.join(dir, /** @type {string} */ (ordered[0])),
|
|
1258
|
+
ignored: ordered
|
|
1259
|
+
.slice(1)
|
|
1260
|
+
.map(doc => path.join(dir, /** @type {string} */ (doc))),
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
walk(root);
|
|
1265
|
+
return {caseMismatch, duplicates};
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Judge each component doc's `name` against the module its printed import
|
|
1270
|
+
* names: a finding when that module provably does not export it, and an
|
|
1271
|
+
* entry in `unchecked` when it cannot be judged, so it is listed instead.
|
|
1272
|
+
* @param {LoadedIntegration} integration
|
|
1273
|
+
* @param {Array<{name: string, docPath: string, sourcePath: string|null}>} components
|
|
1274
|
+
* @param {string} root the components root
|
|
1275
|
+
* @param {Map<string, string>} skip docs already reported, by path
|
|
1276
|
+
* @param {Array<{docPath: string, name: string, message: string}>} findings
|
|
1277
|
+
* @param {Array<{docPath: string, name: string, reason: string}>} unchecked
|
|
1278
|
+
*/
|
|
1279
|
+
async function judgeComponentDocNames(
|
|
1280
|
+
integration,
|
|
1281
|
+
components,
|
|
1282
|
+
root,
|
|
1283
|
+
skip,
|
|
1284
|
+
findings,
|
|
1285
|
+
unchecked,
|
|
1286
|
+
) {
|
|
1287
|
+
const base = integration.__packageDir ?? root;
|
|
1288
|
+
for (const record of components) {
|
|
1289
|
+
if (componentDiscovery.isIntegrationMember(record)) continue;
|
|
1290
|
+
if (skip.has(record.docPath)) continue;
|
|
1291
|
+
// A doc with no source is its own error.
|
|
1292
|
+
if (record.sourcePath == null) continue;
|
|
1293
|
+
let doc;
|
|
1294
|
+
try {
|
|
1295
|
+
doc = await loadComponentDoc(record.docPath);
|
|
1296
|
+
} catch {
|
|
1297
|
+
continue;
|
|
1298
|
+
}
|
|
1299
|
+
const name = doc?.name;
|
|
1300
|
+
if (typeof name !== 'string' || name === record.name) continue;
|
|
1301
|
+
// The module the printed import names: the doc's import, the published
|
|
1302
|
+
// subpath, or the package root, resolved through package.json "exports".
|
|
1303
|
+
// Without a package to resolve it in, the same-stem source.
|
|
1304
|
+
const printed = componentDiscovery.importedModule(
|
|
1305
|
+
integration,
|
|
1306
|
+
record.docPath,
|
|
1307
|
+
doc,
|
|
1308
|
+
);
|
|
1309
|
+
if (printed === null) {
|
|
1310
|
+
unchecked.push({
|
|
1311
|
+
docPath: record.docPath,
|
|
1312
|
+
name,
|
|
1313
|
+
reason:
|
|
1314
|
+
'Its import names another package, or resolves to no file this check can read.',
|
|
1315
|
+
});
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
const module = printed ?? record.sourcePath;
|
|
1319
|
+
const shown = slash(path.relative(base, module));
|
|
1320
|
+
// Only what the code contradicts: the module must provably not export
|
|
1321
|
+
// the name the doc gives.
|
|
1322
|
+
const judged = moduleExportVerdict(module, name);
|
|
1323
|
+
if (judged.verdict === 'exports') continue;
|
|
1324
|
+
if (judged.verdict === 'unknown') {
|
|
1325
|
+
unchecked.push({docPath: record.docPath, name, reason: judged.reason});
|
|
1326
|
+
continue;
|
|
1327
|
+
}
|
|
1328
|
+
// A source whose only export is a default, read because no printed
|
|
1329
|
+
// import could be resolved: the package's entry may publish it under
|
|
1330
|
+
// any name, so the name is not judged. A printed import that names a
|
|
1331
|
+
// default-only module does not export the name, which is a mismatch.
|
|
1332
|
+
const exportedNames = moduleExportNames(module);
|
|
1333
|
+
const defaultOnly =
|
|
1334
|
+
exportedNames != null &&
|
|
1335
|
+
exportedNames.length === 1 &&
|
|
1336
|
+
exportedNames[0] === 'default';
|
|
1337
|
+
if (defaultOnly && printed === undefined) {
|
|
1338
|
+
unchecked.push({
|
|
1339
|
+
docPath: record.docPath,
|
|
1340
|
+
name,
|
|
1341
|
+
reason: `${shown} exports a default, which the package entry may publish under any name.`,
|
|
1342
|
+
});
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
const file = path.basename(record.docPath);
|
|
1346
|
+
// The name to propose: the file name when the module exports it, else
|
|
1347
|
+
// the one component the module exports.
|
|
1348
|
+
let fix;
|
|
1349
|
+
if (defaultOnly) {
|
|
1350
|
+
fix =
|
|
1351
|
+
defaultBinding(module) === name
|
|
1352
|
+
? `Fix: add \`export {${name}};\` to ${shown}, so it exports ${name} by name as well, or set the doc's import to the module that publishes it as ${name}.`
|
|
1353
|
+
: `Fix: bind the default to ${name} in ${shown} and export it by name too (\`const ${name} = …; export default ${name}; export {${name}};\`), or set the doc's import to the module that publishes it as ${name}.`;
|
|
1354
|
+
} else if (moduleExportsName(module, record.name)) {
|
|
1355
|
+
fix = `Fix: set name: '${record.name}' in ${file}.`;
|
|
1356
|
+
} else {
|
|
1357
|
+
const exported = (exportedNames ?? []).filter(each =>
|
|
1358
|
+
/^[A-Z][A-Za-z0-9]*$/u.test(each),
|
|
1359
|
+
);
|
|
1360
|
+
fix =
|
|
1361
|
+
exported.length === 1
|
|
1362
|
+
? `Fix: set name: '${exported[0]}' in ${file}, the component ${shown} exports.`
|
|
1363
|
+
: `Fix: set name in ${file} to the component ${shown} exports${exported.length > 1 ? ` (${exported.join(', ')})` : ''}.`;
|
|
1364
|
+
}
|
|
1365
|
+
findings.push({
|
|
1366
|
+
docPath: record.docPath,
|
|
1367
|
+
name,
|
|
1368
|
+
message: `Component doc "${slash(path.relative(root, record.docPath))}" sets name: '${name}', but ${shown}, the module its import names, does not export ${name}, so Astryx lists the component as "${record.name}" (its file name), and \`astryx component ${record.name}\` prints \`import {${name}}\`. ${fix}`,
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* The component doc names the check could not judge, shaped like the doc type
|
|
1375
|
+
* report so `integration check` counts them as not compared: each doc whose
|
|
1376
|
+
* `name` differs from the name it is listed under and whose source's exports
|
|
1377
|
+
* cannot all be read without running it; its findings are always empty. A
|
|
1378
|
+
* name the module its printed import names provably lacks is a
|
|
1379
|
+
* `doc_name_mismatch` note, with its fix in the message: validate lists
|
|
1380
|
+
* notes beside its issues, and nothing counts them, so `--strict` does not
|
|
1381
|
+
* fail on it until the next minor release (architecture:cli-surface INV35).
|
|
1382
|
+
* @param {LoadedIntegration} integration
|
|
1383
|
+
* @returns {Promise<{report: {status: 'checked', findings: [], unchecked: Array<{file: string, name: string, reason: string}>}, notes: Note[]}>}
|
|
1384
|
+
*/
|
|
1385
|
+
export async function componentDocNamesCheck(integration) {
|
|
1386
|
+
/** @type {Array<{docPath: string, name: string, message: string}>} */
|
|
1387
|
+
const findings = [];
|
|
1388
|
+
/** @type {Array<{docPath: string, name: string, reason: string}>} */
|
|
1389
|
+
const unchecked = [];
|
|
1390
|
+
const root = integration.components;
|
|
1391
|
+
if (root && !rootProblem(root)) {
|
|
1392
|
+
try {
|
|
1393
|
+
const {components} =
|
|
1394
|
+
await componentDiscovery.discoverValidIntegrationComponents(
|
|
1395
|
+
integration,
|
|
1396
|
+
);
|
|
1397
|
+
await judgeComponentDocNames(
|
|
1398
|
+
integration,
|
|
1399
|
+
components,
|
|
1400
|
+
root,
|
|
1401
|
+
componentDocFiles(root).caseMismatch,
|
|
1402
|
+
findings,
|
|
1403
|
+
unchecked,
|
|
1404
|
+
);
|
|
1405
|
+
} catch {
|
|
1406
|
+
// A components root discovery cannot read is reported as an issue.
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
const base = integration.__packageDir ?? root ?? '';
|
|
1410
|
+
return {
|
|
1411
|
+
report: {
|
|
1412
|
+
status: 'checked',
|
|
1413
|
+
findings: [],
|
|
1414
|
+
unchecked: unchecked.map(entry => ({
|
|
1415
|
+
file: slash(path.relative(base, entry.docPath)),
|
|
1416
|
+
name: entry.name,
|
|
1417
|
+
reason: entry.reason,
|
|
1418
|
+
})),
|
|
1419
|
+
},
|
|
1420
|
+
notes: findings.map(entry => note('doc_name_mismatch', entry)),
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
|
|
367
1424
|
/**
|
|
368
1425
|
* Validate the integration's doc topics via the landed discovery. A doc that
|
|
369
1426
|
* cannot be loaded, is not a usable topic, or collides with a sibling is
|
|
@@ -399,18 +1456,123 @@ async function checkDocs(integration, issues) {
|
|
|
399
1456
|
async function checkThemes(integration, issues) {
|
|
400
1457
|
if (!integration.themes || rootProblem(integration.themes)) return;
|
|
401
1458
|
try {
|
|
1459
|
+
// A theme may name itself differently from its folder (its built files
|
|
1460
|
+
// then carry that name), so a name that differs is no finding here:
|
|
1461
|
+
// verify judges it against the files the package exports.
|
|
402
1462
|
await discoverIntegrationThemes(integration);
|
|
403
1463
|
} catch (err) {
|
|
404
1464
|
issues.push(issueError('invalid_theme', /** @type {any} */ (err).message));
|
|
405
1465
|
}
|
|
406
1466
|
}
|
|
407
1467
|
|
|
1468
|
+
/**
|
|
1469
|
+
* The `name` a theme source passes to defineTheme for its exported theme,
|
|
1470
|
+
* when the file says it as a string literal: `export const oceanTheme =
|
|
1471
|
+
* defineTheme({name: 'ocean', ...})`. Null whenever only running the module
|
|
1472
|
+
* could tell (a variable, a factory, a spread after the name, `extends`
|
|
1473
|
+
* alone), so nothing is judged that a build would decide.
|
|
1474
|
+
* @param {string} file
|
|
1475
|
+
* @param {string} exportName
|
|
1476
|
+
* @returns {string | null}
|
|
1477
|
+
*/
|
|
1478
|
+
export function literalThemeName(file, exportName) {
|
|
1479
|
+
let ast;
|
|
1480
|
+
try {
|
|
1481
|
+
ast = parseModule(fs.readFileSync(file, 'utf8'), {
|
|
1482
|
+
sourceType: 'module',
|
|
1483
|
+
plugins: ['typescript', 'jsx'],
|
|
1484
|
+
errorRecovery: true,
|
|
1485
|
+
});
|
|
1486
|
+
} catch {
|
|
1487
|
+
return null;
|
|
1488
|
+
}
|
|
1489
|
+
/** @type {any} */
|
|
1490
|
+
let init = null;
|
|
1491
|
+
for (const node of ast.program.body) {
|
|
1492
|
+
const declaration =
|
|
1493
|
+
node.type === 'ExportNamedDeclaration' ? node.declaration : node;
|
|
1494
|
+
if (declaration?.type !== 'VariableDeclaration') continue;
|
|
1495
|
+
for (const declarator of declaration.declarations) {
|
|
1496
|
+
if (
|
|
1497
|
+
declarator.id.type === 'Identifier' &&
|
|
1498
|
+
declarator.id.name === exportName
|
|
1499
|
+
) {
|
|
1500
|
+
init = declarator.init;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
while (
|
|
1505
|
+
init?.type === 'TSAsExpression' ||
|
|
1506
|
+
init?.type === 'TSSatisfiesExpression'
|
|
1507
|
+
) {
|
|
1508
|
+
init = init.expression;
|
|
1509
|
+
}
|
|
1510
|
+
if (init?.type !== 'CallExpression') return null;
|
|
1511
|
+
const callee =
|
|
1512
|
+
init.callee.type === 'Identifier'
|
|
1513
|
+
? init.callee.name
|
|
1514
|
+
: init.callee.type === 'MemberExpression' &&
|
|
1515
|
+
init.callee.property.type === 'Identifier'
|
|
1516
|
+
? init.callee.property.name
|
|
1517
|
+
: null;
|
|
1518
|
+
if (callee !== 'defineTheme') return null;
|
|
1519
|
+
const [config] = init.arguments;
|
|
1520
|
+
if (config?.type !== 'ObjectExpression') return null;
|
|
1521
|
+
/** @type {string | null} */
|
|
1522
|
+
let name = null;
|
|
1523
|
+
for (const property of config.properties) {
|
|
1524
|
+
if (property.type === 'SpreadElement') {
|
|
1525
|
+
name = null;
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
1529
|
+
const key =
|
|
1530
|
+
property.key.type === 'Identifier'
|
|
1531
|
+
? property.key.name
|
|
1532
|
+
: property.key.type === 'StringLiteral'
|
|
1533
|
+
? property.key.value
|
|
1534
|
+
: null;
|
|
1535
|
+
if (key !== 'name') continue;
|
|
1536
|
+
name =
|
|
1537
|
+
property.value.type === 'StringLiteral' ? property.value.value : null;
|
|
1538
|
+
}
|
|
1539
|
+
return name;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* A warning for each contribution file a reader reads (the docs and sources
|
|
1544
|
+
* `integration verify` expects in the tarball) that the user running astryx
|
|
1545
|
+
* cannot read; files no reader takes, such as `.DS_Store`, are not looked at: Astryx cannot check it, and npm pack stops on it. A
|
|
1546
|
+
* warning, so validate keeps its exit code; `integration verify` fails on the
|
|
1547
|
+
* pack itself.
|
|
1548
|
+
* @param {LoadedIntegration} integration
|
|
1549
|
+
* @param {Issue[]} issues
|
|
1550
|
+
*/
|
|
1551
|
+
function checkUnreadableFiles(integration, issues) {
|
|
1552
|
+
const packageDir = integration.__packageDir;
|
|
1553
|
+
if (!packageDir) return;
|
|
1554
|
+
for (const shown of contributionFiles(integration, packageDir)) {
|
|
1555
|
+
try {
|
|
1556
|
+
fs.accessSync(path.join(packageDir, shown), fs.constants.R_OK);
|
|
1557
|
+
} catch (err) {
|
|
1558
|
+
const code = String(/** @type {any} */ (err)?.code ?? 'unknown error');
|
|
1559
|
+
issues.push(
|
|
1560
|
+
issueListed(
|
|
1561
|
+
'unreadable_file',
|
|
1562
|
+
`Could not read "${shown}" (${code}), so Astryx cannot check it and npm pack fails on it. Fix: make it readable (chmod a+r ${shown}), or delete it if it does not belong in the package.`,
|
|
1563
|
+
),
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
408
1569
|
/**
|
|
409
1570
|
* Run every contribution validator against a loaded-integration-shaped object.
|
|
410
1571
|
* @param {LoadedIntegration} integration
|
|
411
1572
|
* @param {Issue[]} issues
|
|
412
1573
|
*/
|
|
413
1574
|
async function runContributionChecks(integration, issues) {
|
|
1575
|
+
checkUnreadableFiles(integration, issues);
|
|
414
1576
|
await checkCodemods(integration, issues);
|
|
415
1577
|
await checkTemplates(integration, issues);
|
|
416
1578
|
await checkComponents(integration, issues);
|
|
@@ -429,6 +1591,29 @@ async function runContributionChecks(integration, issues) {
|
|
|
429
1591
|
* @returns {Promise<Issue[]>}
|
|
430
1592
|
*/
|
|
431
1593
|
export async function validateLoadedIntegration(loaded) {
|
|
1594
|
+
return (await validateLoadedIntegrationListed(loaded)).issues;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/**
|
|
1598
|
+
* Every contribution check, split: `issues` as validateLoadedIntegration
|
|
1599
|
+
* returns them, and `listed`, the layout findings validate lists in its
|
|
1600
|
+
* `layout` report without counting them.
|
|
1601
|
+
* @param {LoadedIntegration} loaded
|
|
1602
|
+
* @returns {Promise<{issues: Issue[], listed: Issue[]}>}
|
|
1603
|
+
*/
|
|
1604
|
+
export async function validateLoadedIntegrationListed(loaded) {
|
|
1605
|
+
const all = await allLoadedIntegrationIssues(loaded);
|
|
1606
|
+
return {
|
|
1607
|
+
issues: all.filter(issue => !LISTED.has(issue)),
|
|
1608
|
+
listed: all.filter(issue => LISTED.has(issue)),
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* @param {LoadedIntegration} loaded
|
|
1614
|
+
* @returns {Promise<Issue[]>}
|
|
1615
|
+
*/
|
|
1616
|
+
async function allLoadedIntegrationIssues(loaded) {
|
|
432
1617
|
/** @type {Issue[]} */
|
|
433
1618
|
const issues = [];
|
|
434
1619
|
if (!loaded || typeof loaded !== 'object') return issues;
|
|
@@ -450,6 +1635,14 @@ export async function validateLoadedIntegration(loaded) {
|
|
|
450
1635
|
if (loaded.__agentDocsError) {
|
|
451
1636
|
issues.push(issueError(INVALID_AGENT_DOCS, loaded.__agentDocsError));
|
|
452
1637
|
}
|
|
1638
|
+
if (loaded.__cliCommandError) {
|
|
1639
|
+
issues.push(
|
|
1640
|
+
issueWarning(
|
|
1641
|
+
INVALID_CLI_COMMAND,
|
|
1642
|
+
`${loaded.__cliCommandError}. The command is ignored; printed commands use the package-manager prefix.`,
|
|
1643
|
+
),
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
453
1646
|
checkRoots(
|
|
454
1647
|
{
|
|
455
1648
|
components: loaded.components,
|
|
@@ -457,8 +1650,10 @@ export async function validateLoadedIntegration(loaded) {
|
|
|
457
1650
|
codemods: loaded.codemods,
|
|
458
1651
|
docs: loaded.docs,
|
|
459
1652
|
themes: loaded.themes,
|
|
1653
|
+
__manifestFile: loaded.__manifestFile,
|
|
460
1654
|
},
|
|
461
1655
|
issues,
|
|
1656
|
+
loaded.__packageDir,
|
|
462
1657
|
);
|
|
463
1658
|
await runContributionChecks(loaded, issues);
|
|
464
1659
|
return issues;
|