@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.9dbb6c1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -73
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +13 -3
- package/api/component/component.mjs +31 -2
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +22 -11
- package/api/component/component.type.mjs +32 -24
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +4 -3
- package/api/component/list/list.d.mts +0 -5
- package/api/component/list/list.mjs +37 -9
- package/api/discover/discover.doc.mjs +2 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +28 -30
- package/api/docs/_adapter.mjs +73 -135
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.d.mts +0 -15
- package/api/docs/detail/detail.mjs +14 -78
- package/api/docs/detail/section/section.mjs +22 -18
- package/api/docs/detail/section/section.test.mjs +4 -3
- package/api/docs/docs.doc.mjs +1 -0
- package/api/docs/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/docs/index/index.mjs +6 -5
- package/api/docs/list/list.mjs +3 -7
- package/api/doctor/doctor.d.mts +25 -3
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +186 -18
- package/api/doctor/doctor.test.mjs +326 -1
- package/api/gap-report/gap-report.doc.mjs +8 -4
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +1 -0
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +69 -17
- package/api/init/init.doc.mjs +5 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +23 -10
- package/api/integration/add-contribution.test.mjs +121 -7
- package/api/integration/add-theme.mjs +34 -64
- package/api/integration/add-theme.test.mjs +105 -21
- package/api/integration/authoring-checks.test.mjs +8 -4
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +8 -4
- package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
- package/api/integration/integrationAddCodemod.doc.mjs +1 -0
- package/api/integration/integrationAddComponent.doc.mjs +2 -1
- package/api/integration/integrationAddDoc.doc.mjs +1 -0
- package/api/integration/integrationAddTemplate.doc.mjs +1 -0
- package/api/integration/integrationAddTheme.doc.mjs +6 -5
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
- package/api/integration/integrationDocConflicts.doc.mjs +1 -0
- package/api/integration/integrationPackCheck.doc.mjs +1 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +266 -47
- package/api/integration/summarizeIssues.doc.mjs +1 -0
- package/api/integration/validate-integration-fixes.test.mjs +1389 -0
- package/api/integration/validate-integration.mjs +52 -102
- package/api/integration/validate-integration.test.mjs +176 -23
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +2 -1
- package/api/json/assertResponse.doc.mjs +1 -0
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/isError.doc.mjs +1 -0
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutCheck.doc.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +2 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -0
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +6 -1
- package/api/search/search.mjs +31 -14
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.doc.mjs +3 -1
- package/api/template/template.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- package/api/theme/_adapter.d.mts +2 -3
- package/api/theme/_adapter.mjs +4 -5
- package/api/theme/add/add.binary.test.mjs +84 -0
- package/api/theme/add/add.mjs +20 -3
- package/api/theme/add/add.staging.test.mjs +66 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/generateTonalPalette.doc.mjs +1 -0
- package/api/theme/integration-themes.test.mjs +39 -28
- package/api/theme/list/list.test.mjs +19 -20
- package/api/theme/listThemes.doc.mjs +6 -5
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeAdd.doc.mjs +4 -3
- package/api/theme/themeBuild.doc.mjs +8 -4
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +5 -3
- package/api/theme/themePaletteGenerate.doc.mjs +1 -0
- package/api/theme/themeTargets.doc.mjs +1 -0
- package/api/theme/themeTemplate.doc.mjs +5 -1
- package/api/upgrade/_adapter.d.mts +12 -3
- package/api/upgrade/_adapter.mjs +108 -70
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/provider-agreement.test.mjs +152 -0
- package/api/upgrade/run/run.mjs +1 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +3 -1
- package/api/upgrade/upgrade.type.d.mts +8 -4
- package/api/upgrade/upgrade.type.mjs +11 -10
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -0
- package/assets/codemods/runner.mjs +115 -5
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transform-prop.mjs +109 -0
- package/assets/codemods/transform-prop.test.mjs +95 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/cli-integrations.doc.mjs +26 -30
- package/assets/docs/cli.doc.mjs +15 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
- package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
- package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
- package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
- package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
- package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
- package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +7 -2
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- package/authoring/doctypes/command/command.doc.mjs +4 -3
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +3 -3
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +3 -3
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +2 -2
- package/authoring/doctypes/function/function.doc.mjs +5 -1
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +2 -2
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +3 -3
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +208 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +22 -20
- package/authoring/doctypes/parse.mjs +16 -12
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +7 -3
- package/authoring/doctypes/reference/type.ts +3 -3
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +3 -4
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +7 -3
- package/authoring/doctypes/template/type.ts +4 -1
- package/authoring/doctypes/theme/parse.d.mts +35 -0
- package/authoring/doctypes/theme/parse.mjs +76 -0
- package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
- package/authoring/doctypes/theme/theme.doc.mjs +79 -0
- package/authoring/doctypes/theme/type.ts +42 -0
- package/authoring/doctypes/types.ts +12 -11
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +21 -19
- package/authoring/index.mjs +2 -1
- package/authoring/integration/integration.doc.mjs +2 -2
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +4 -10
- package/clients/cli/__tests__/cliManifest.test.ts +27 -29
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +5 -2
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +46 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +5 -3
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor-integration.test.mjs +15 -7
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +17 -6
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +20 -9
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +22 -6
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +3 -9
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +15 -4
- package/clients/cli/commands/layout-expand.doc.mjs +22 -5
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
- package/clients/cli/commands/layout.doc.mjs +3 -3
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +7 -4
- package/clients/cli/commands/search.mjs +17 -7
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/swizzle.doc.mjs +3 -2
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +29 -7
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +4 -3
- package/clients/cli/commands/theme-build.doc.mjs +8 -7
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -3
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +1 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +18 -7
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project-themes.test.mjs +11 -19
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +173 -30
- package/foundation/config/project.test.mjs +129 -16
- package/foundation/discovery/authoring-self-docs.d.mts +6 -0
- package/foundation/discovery/authoring-self-docs.mjs +17 -7
- package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
- package/foundation/discovery/authoring-surface.d.mts +74 -0
- package/foundation/discovery/authoring-surface.mjs +525 -0
- package/foundation/discovery/authoring-surface.test.mjs +392 -0
- package/foundation/discovery/cli-self-docs.d.mts +113 -0
- package/foundation/discovery/cli-self-docs.mjs +514 -0
- package/foundation/discovery/cli-self-docs.test.mjs +437 -0
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +7 -2
- package/foundation/discovery/docs-discovery.mjs +24 -14
- package/foundation/discovery/docs-discovery.test.mjs +55 -16
- package/foundation/discovery/template-adapter.d.mts +21 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +319 -65
- package/foundation/discovery/template-adapter.test.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +67 -7
- package/foundation/discovery/theme-discovery.mjs +916 -186
- package/foundation/discovery/theme-discovery.test.mjs +613 -219
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/bundle.d.mts +47 -0
- package/foundation/doc-compiler/bundle.mjs +218 -0
- package/foundation/doc-compiler/bundle.test.mjs +255 -0
- package/foundation/doc-compiler/compile.d.mts +362 -0
- package/foundation/doc-compiler/compile.mjs +511 -0
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +277 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
- package/foundation/doc-compiler/import.d.mts +24 -0
- package/foundation/doc-compiler/import.mjs +59 -0
- package/foundation/doc-compiler/inputs.d.mts +102 -0
- package/foundation/doc-compiler/inputs.mjs +286 -0
- package/foundation/doc-compiler/inputs.test.mjs +299 -0
- package/foundation/doc-compiler/ir.d.mts +22 -0
- package/foundation/doc-compiler/ir.mjs +464 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
- package/foundation/doc-compiler/overlays.d.mts +37 -0
- package/foundation/doc-compiler/overlays.mjs +206 -0
- package/foundation/doc-compiler/parse-readable.d.mts +9 -0
- package/foundation/doc-compiler/parse-readable.mjs +29 -0
- package/foundation/doc-compiler/read.d.mts +126 -0
- package/foundation/doc-compiler/read.mjs +320 -0
- package/foundation/doc-compiler/read.test.mjs +313 -0
- package/foundation/doc-compiler/source.d.mts +33 -0
- package/foundation/doc-compiler/source.mjs +128 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -52
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +1 -1
- package/foundation/integrations/contribution-inventory.mjs +17 -20
- package/foundation/integrations/contribution-inventory.test.mjs +67 -27
- package/foundation/integrations/integrations.d.mts +3 -0
- package/foundation/integrations/integrations.mjs +11 -97
- package/foundation/integrations/provider-ledger.test.mjs +275 -0
- package/foundation/integrations/provider-resolution.d.mts +152 -0
- package/foundation/integrations/provider-resolution.mjs +576 -0
- package/foundation/integrations/provider-resolution.test.mjs +369 -0
- package/foundation/integrations/theme-descriptor.d.mts +8 -0
- package/foundation/integrations/theme-descriptor.mjs +44 -0
- package/foundation/integrations/validate-contributions.mjs +104 -10
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +3 -4
- package/foundation/response/error-codes.mjs +2 -2
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +11 -11
- package/foundation/response/response-types.doc.test.mjs +158 -0
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/text/string-utils.mjs +22 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/assets/templates/themes/manifest.json +0 -95
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -1,107 +1,142 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* @file Integration proof for filesystems that reject hard links.
|
|
5
|
+
*
|
|
6
|
+
* A module mock makes `fs.linkSync` fail the way those filesystems do (EPERM,
|
|
7
|
+
* or EXDEV across devices), so `applyWrites` publishes through the
|
|
8
|
+
* exclusive-copy fallback on every run. Private tests use injected seams, not
|
|
9
|
+
* environment variables (AST-017 FR14, DEC-5); the last case holds the
|
|
10
|
+
* publish-file module and its proofs to that.
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
10
|
-
import * as fs from 'node:fs';
|
|
13
|
+
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
11
14
|
import * as path from 'node:path';
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import {fileURLToPath} from 'node:url';
|
|
17
|
+
import jscodeshift from 'jscodeshift';
|
|
18
|
+
|
|
19
|
+
vi.mock('node:fs', async importOriginal => {
|
|
20
|
+
const actual = await importOriginal();
|
|
21
|
+
return {
|
|
22
|
+
...actual,
|
|
23
|
+
linkSync: vi.fn(() => {
|
|
24
|
+
throw Object.assign(new Error('EPERM: operation not permitted, link'), {code: 'EPERM'});
|
|
25
|
+
}),
|
|
26
|
+
copyFileSync: vi.fn(actual.copyFileSync),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const {applyWrites} = await import('../../api/integration/add-helpers.mjs');
|
|
31
|
+
const fs = await import('node:fs');
|
|
32
|
+
|
|
33
|
+
describe.each(['EPERM', 'EXDEV'])('hard links fail with %s', code => {
|
|
34
|
+
let testDir;
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
vi.clearAllMocks();
|
|
38
|
+
vi.mocked(fs.linkSync).mockImplementation(() => {
|
|
39
|
+
throw Object.assign(new Error(`${code}: cannot link`), {code});
|
|
23
40
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
testDir = fs.mkdtempSync(path.join(os.tmpdir(), '.astryx-publish-proof-'));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
fs.rmSync(testDir, {recursive: true, force: true});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('applyWrites creates files through the exclusive-copy fallback', () => {
|
|
49
|
+
const plans = [
|
|
50
|
+
{
|
|
51
|
+
path: path.join(testDir, 'MyComponent.tsx'),
|
|
52
|
+
contents: '// MyComponent\nexport default function MyComponent() {}\n',
|
|
53
|
+
createOnly: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
path: path.join(testDir, 'MyComponent.test.tsx'),
|
|
57
|
+
contents: '// test\nimport MyComponent from "./MyComponent";\n',
|
|
58
|
+
createOnly: true,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const rollback = applyWrites(plans);
|
|
63
|
+
expect(typeof rollback).toBe('function');
|
|
64
|
+
expect(fs.readFileSync(plans[0].path, 'utf-8')).toContain('MyComponent');
|
|
65
|
+
expect(fs.readFileSync(plans[1].path, 'utf-8')).toContain('test');
|
|
66
|
+
expect(fs.linkSync).toHaveBeenCalledTimes(plans.length);
|
|
67
|
+
for (const plan of plans) {
|
|
68
|
+
expect(fs.copyFileSync).toHaveBeenCalledWith(
|
|
69
|
+
expect.any(String),
|
|
70
|
+
plan.path,
|
|
71
|
+
fs.constants.COPYFILE_EXCL,
|
|
36
72
|
);
|
|
37
|
-
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
38
75
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
path: path.join(testDir, 'MyComponent.tsx'),
|
|
43
|
-
contents: '// MyComponent\nexport default function MyComponent() {}\n',
|
|
44
|
-
createOnly: true,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
path: path.join(testDir, 'MyComponent.test.tsx'),
|
|
48
|
-
contents: '// test\nimport MyComponent from "./MyComponent";\n',
|
|
49
|
-
createOnly: true,
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
const rollback = applyWrites(plans);
|
|
54
|
-
expect(typeof rollback).toBe('function');
|
|
55
|
-
expect(fs.readFileSync(plans[0].path, 'utf-8')).toContain('MyComponent');
|
|
56
|
-
expect(fs.readFileSync(plans[1].path, 'utf-8')).toContain('test');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('applyWrites preserves no-clobber behavior', () => {
|
|
60
|
-
const target = path.join(testDir, 'existing.tsx');
|
|
61
|
-
fs.writeFileSync(target, '// original\n');
|
|
62
|
-
|
|
63
|
-
expect(() =>
|
|
64
|
-
applyWrites([
|
|
65
|
-
{
|
|
66
|
-
path: target,
|
|
67
|
-
contents: '// replacement\n',
|
|
68
|
-
createOnly: true,
|
|
69
|
-
},
|
|
70
|
-
]),
|
|
71
|
-
).toThrow(/overwrite|exists/i);
|
|
72
|
-
expect(fs.readFileSync(target, 'utf-8')).toBe('// original\n');
|
|
73
|
-
});
|
|
76
|
+
it('applyWrites preserves no-clobber behavior', () => {
|
|
77
|
+
const target = path.join(testDir, 'existing.tsx');
|
|
78
|
+
fs.writeFileSync(target, '// original\n');
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const bad = path.join(testDir, 'bad.tsx');
|
|
78
|
-
fs.writeFileSync(bad, '// preexisting\n');
|
|
79
|
-
|
|
80
|
-
expect(() =>
|
|
81
|
-
applyWrites([
|
|
82
|
-
{path: good, contents: '// good file\n', createOnly: true},
|
|
83
|
-
{path: bad, contents: '// replacement\n', createOnly: true},
|
|
84
|
-
]),
|
|
85
|
-
).toThrow();
|
|
86
|
-
expect(fs.existsSync(good)).toBe(false);
|
|
87
|
-
expect(fs.readFileSync(bad, 'utf-8')).toBe('// preexisting\n');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('applyWrites keeps compare-and-swap replacement behavior', () => {
|
|
91
|
-
const target = path.join(testDir, 'config.json');
|
|
92
|
-
const original = '{"version": 1}\n';
|
|
93
|
-
fs.writeFileSync(target, original);
|
|
94
|
-
|
|
95
|
-
const rollback = applyWrites([
|
|
80
|
+
expect(() =>
|
|
81
|
+
applyWrites([
|
|
96
82
|
{
|
|
97
83
|
path: target,
|
|
98
|
-
contents: '
|
|
99
|
-
createOnly:
|
|
100
|
-
expectedOriginal: Buffer.from(original),
|
|
84
|
+
contents: '// replacement\n',
|
|
85
|
+
createOnly: true,
|
|
101
86
|
},
|
|
102
|
-
])
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
87
|
+
]),
|
|
88
|
+
).toThrow(/overwrite|exists/i);
|
|
89
|
+
expect(fs.readFileSync(target, 'utf-8')).toBe('// original\n');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('applyWrites rolls back partial publication', () => {
|
|
93
|
+
const good = path.join(testDir, 'good.tsx');
|
|
94
|
+
const bad = path.join(testDir, 'bad.tsx');
|
|
95
|
+
fs.writeFileSync(bad, '// preexisting\n');
|
|
96
|
+
|
|
97
|
+
expect(() =>
|
|
98
|
+
applyWrites([
|
|
99
|
+
{path: good, contents: '// good file\n', createOnly: true},
|
|
100
|
+
{path: bad, contents: '// replacement\n', createOnly: true},
|
|
101
|
+
]),
|
|
102
|
+
).toThrow();
|
|
103
|
+
expect(fs.existsSync(good)).toBe(false);
|
|
104
|
+
expect(fs.readFileSync(bad, 'utf-8')).toBe('// preexisting\n');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('applyWrites keeps compare-and-swap replacement behavior', () => {
|
|
108
|
+
const target = path.join(testDir, 'config.json');
|
|
109
|
+
const original = '{"version": 1}\n';
|
|
110
|
+
fs.writeFileSync(target, original);
|
|
111
|
+
|
|
112
|
+
const rollback = applyWrites([
|
|
113
|
+
{
|
|
114
|
+
path: target,
|
|
115
|
+
contents: '{"version": 2}\n',
|
|
116
|
+
createOnly: false,
|
|
117
|
+
expectedOriginal: Buffer.from(original),
|
|
118
|
+
},
|
|
119
|
+
]);
|
|
120
|
+
expect(typeof rollback).toBe('function');
|
|
121
|
+
expect(fs.readFileSync(target, 'utf-8')).toBe('{"version": 2}\n');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('private test seams', () => {
|
|
126
|
+
it('no publish-file module or proof reads process.env', () => {
|
|
127
|
+
const self = fileURLToPath(import.meta.url);
|
|
128
|
+
const dir = path.dirname(self);
|
|
129
|
+
const files = fs.readdirSync(dir).filter(name => /^publish-file.*\.mjs$/.test(name));
|
|
130
|
+
const j = jscodeshift.withParser('babylon');
|
|
131
|
+
const reads = files.flatMap(name =>
|
|
132
|
+
j(fs.readFileSync(path.join(dir, name), 'utf8'))
|
|
133
|
+
.find(j.MemberExpression, {object: {name: 'process'}})
|
|
134
|
+
.filter(p => (p.node.computed ? p.node.property.value : p.node.property.name) === 'env')
|
|
135
|
+
.nodes()
|
|
136
|
+
.map(node => `${name}:${node.loc?.start.line}`),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(files).toEqual(expect.arrayContaining(['publish-file.mjs', path.basename(self)]));
|
|
140
|
+
expect(reads).toEqual([]);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -35,6 +35,28 @@ export function resolveInstalledPackageDir(name: string, fromDir: string): {
|
|
|
35
35
|
packageDir: string;
|
|
36
36
|
hostDir: string;
|
|
37
37
|
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {object} AutolinkCandidate
|
|
40
|
+
* @property {string} spec
|
|
41
|
+
* @property {string} field
|
|
42
|
+
* @property {string} packageDir
|
|
43
|
+
* @property {string} hostDir
|
|
44
|
+
* @property {boolean} [repeat] the directory is already loaded or already a
|
|
45
|
+
* candidate under another dependency key; it is not loaded again
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Every declared dependency that ships exactly one root manifest, in
|
|
49
|
+
* declaration order, including the ones whose directory is already loaded or
|
|
50
|
+
* already a candidate (`repeat`), so a caller can account for each of them.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} projectDir directory holding the project's package.json
|
|
53
|
+
* @param {{exclude?: Iterable<string>}} [options] `exclude` — package
|
|
54
|
+
* directories already loaded (from config); matched through symlinks
|
|
55
|
+
* @returns {AutolinkCandidate[]}
|
|
56
|
+
*/
|
|
57
|
+
export function scanAutolinkCandidates(projectDir: string, { exclude }?: {
|
|
58
|
+
exclude?: Iterable<string>;
|
|
59
|
+
}): AutolinkCandidate[];
|
|
38
60
|
/**
|
|
39
61
|
* Declared dependencies that ship an integration manifest and are not already
|
|
40
62
|
* loaded, in declaration order.
|
|
@@ -50,7 +72,7 @@ export function resolveInstalledPackageDir(name: string, fromDir: string): {
|
|
|
50
72
|
* directories already loaded (from config); matched through symlinks
|
|
51
73
|
* @returns {Array<{spec: string, field: string, packageDir: string, hostDir: string}>}
|
|
52
74
|
*/
|
|
53
|
-
export function findAutolinkCandidates(projectDir: string,
|
|
75
|
+
export function findAutolinkCandidates(projectDir: string, options?: {
|
|
54
76
|
exclude?: Iterable<string>;
|
|
55
77
|
}): Array<{
|
|
56
78
|
spec: string;
|
|
@@ -58,6 +80,24 @@ export function findAutolinkCandidates(projectDir: string, { exclude }?: {
|
|
|
58
80
|
packageDir: string;
|
|
59
81
|
hostDir: string;
|
|
60
82
|
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Load every autolink candidate, each in isolation, as provider candidates for
|
|
85
|
+
* {@link resolveProviders}. Nothing is filtered here: a candidate whose load
|
|
86
|
+
* throws or whose manifest fails comes back with its error, and a repeated
|
|
87
|
+
* directory comes back unloaded, so the resolver records each one.
|
|
88
|
+
*
|
|
89
|
+
* @param {object} options
|
|
90
|
+
* @param {string} options.projectDir directory holding the project's package.json
|
|
91
|
+
* @param {import('./integrations.mjs').LoadedIntegration[]} [options.loaded]
|
|
92
|
+
* integrations already loaded from config
|
|
93
|
+
* @param {boolean} [options.fresh]
|
|
94
|
+
* @returns {Promise<import('./provider-resolution.mjs').ProviderCandidate[]>}
|
|
95
|
+
*/
|
|
96
|
+
export function loadAutolinkCandidates({ projectDir, loaded, fresh, }: {
|
|
97
|
+
projectDir: string;
|
|
98
|
+
loaded?: import("./integrations.mjs").LoadedIntegration[] | undefined;
|
|
99
|
+
fresh?: boolean | undefined;
|
|
100
|
+
}): Promise<import("./provider-resolution.mjs").ProviderCandidate[]>;
|
|
61
101
|
/**
|
|
62
102
|
* Load every declared dependency that ships an integration manifest and is not
|
|
63
103
|
* already loaded from config.
|
|
@@ -72,6 +112,12 @@ export function findAutolinkCandidates(projectDir: string, { exclude }?: {
|
|
|
72
112
|
* consuming project can neither fix nor silence, and which
|
|
73
113
|
* `astryx doctor integration validate <package>` reports on demand.
|
|
74
114
|
*
|
|
115
|
+
* One package reached twice (an alias beside the package it aliases, at the
|
|
116
|
+
* same version) loads once. The same name at another version is kept, so the
|
|
117
|
+
* provider pass reports it instead of dropping it. Project.load does not call
|
|
118
|
+
* this; it hands {@link loadAutolinkCandidates} to the resolver, whose ledger
|
|
119
|
+
* records every candidate dropped here.
|
|
120
|
+
*
|
|
75
121
|
* @param {object} options
|
|
76
122
|
* @param {string} options.projectDir directory holding the project's package.json
|
|
77
123
|
* @param {import('./integrations.mjs').LoadedIntegration[]} [options.loaded]
|
|
@@ -94,3 +140,14 @@ export function autolinkIntegrations({ projectDir, loaded, fresh, }: {
|
|
|
94
140
|
* @type {readonly string[]}
|
|
95
141
|
*/
|
|
96
142
|
export const DEPENDENCY_FIELDS: readonly string[];
|
|
143
|
+
export type AutolinkCandidate = {
|
|
144
|
+
spec: string;
|
|
145
|
+
field: string;
|
|
146
|
+
packageDir: string;
|
|
147
|
+
hostDir: string;
|
|
148
|
+
/**
|
|
149
|
+
* the directory is already loaded or already a
|
|
150
|
+
* candidate under another dependency key; it is not loaded again
|
|
151
|
+
*/
|
|
152
|
+
repeat?: boolean | undefined;
|
|
153
|
+
};
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
* package's own package.json `name` (see loadIntegrations), so an aliased
|
|
30
30
|
* dependency reports the package it actually is.
|
|
31
31
|
*
|
|
32
|
-
* An explicit config entry always wins:
|
|
33
|
-
*
|
|
32
|
+
* An explicit config entry always wins: a dependency whose directory is
|
|
33
|
+
* already loaded from config is never imported again, and comes back as a
|
|
34
|
+
* repeat so the provider ledger still records it.
|
|
34
35
|
*
|
|
35
36
|
* @position lib — sits between config/project (the caller) and
|
|
36
37
|
* integrations/integrations (the loader); contributes no discovery of its own.
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
import * as fs from 'node:fs';
|
|
40
41
|
import * as path from 'node:path';
|
|
41
42
|
import {findManifestPaths, loadIntegrations} from './integrations.mjs';
|
|
43
|
+
import {resolveProviders} from './provider-resolution.mjs';
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* package.json fields whose keys name a dependency this project installs.
|
|
@@ -164,36 +166,44 @@ function realPath(target) {
|
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
|
|
169
|
+
* @typedef {object} AutolinkCandidate
|
|
170
|
+
* @property {string} spec
|
|
171
|
+
* @property {string} field
|
|
172
|
+
* @property {string} packageDir
|
|
173
|
+
* @property {string} hostDir
|
|
174
|
+
* @property {boolean} [repeat] the directory is already loaded or already a
|
|
175
|
+
* candidate under another dependency key; it is not loaded again
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Every declared dependency that ships exactly one root manifest, in
|
|
180
|
+
* declaration order, including the ones whose directory is already loaded or
|
|
181
|
+
* already a candidate (`repeat`), so a caller can account for each of them.
|
|
175
182
|
*
|
|
176
183
|
* @param {string} projectDir directory holding the project's package.json
|
|
177
184
|
* @param {{exclude?: Iterable<string>}} [options] `exclude` — package
|
|
178
185
|
* directories already loaded (from config); matched through symlinks
|
|
179
|
-
* @returns {
|
|
186
|
+
* @returns {AutolinkCandidate[]}
|
|
180
187
|
*/
|
|
181
|
-
export function
|
|
188
|
+
export function scanAutolinkCandidates(projectDir, {exclude = []} = {}) {
|
|
182
189
|
const taken = new Set([...exclude].map(realPath));
|
|
183
|
-
/** @type {
|
|
190
|
+
/** @type {AutolinkCandidate[]} */
|
|
184
191
|
const candidates = [];
|
|
185
192
|
|
|
186
193
|
for (const {name, field} of readDeclaredDependencies(projectDir)) {
|
|
187
194
|
const resolved = resolveInstalledPackageDir(name, projectDir);
|
|
188
195
|
if (!resolved) continue;
|
|
189
196
|
|
|
197
|
+
if (findManifestPaths(resolved.packageDir).length !== 1) continue;
|
|
198
|
+
|
|
190
199
|
// Two dependency keys can name one installed package — an npm alias beside
|
|
191
200
|
// the package it aliases, or the two spellings of a package mid-rename
|
|
192
201
|
// resolving through one store entry. Load it once.
|
|
193
202
|
const identity = realPath(resolved.packageDir);
|
|
194
|
-
if (taken.has(identity))
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
if (taken.has(identity)) {
|
|
204
|
+
candidates.push({spec: name, field, ...resolved, repeat: true});
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
197
207
|
|
|
198
208
|
taken.add(identity);
|
|
199
209
|
candidates.push({spec: name, field, ...resolved});
|
|
@@ -202,6 +212,100 @@ export function findAutolinkCandidates(projectDir, {exclude = []} = {}) {
|
|
|
202
212
|
return candidates;
|
|
203
213
|
}
|
|
204
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Declared dependencies that ship an integration manifest and are not already
|
|
217
|
+
* loaded, in declaration order.
|
|
218
|
+
*
|
|
219
|
+
* A candidate must have EXACTLY ONE root manifest. Zero is the ordinary case
|
|
220
|
+
* (almost every dependency), and more than one is a packaging mistake the
|
|
221
|
+
* loader treats as a hard error — an error the project did not ask for and
|
|
222
|
+
* cannot fix, so an ambiguous package is passed over here rather than allowed
|
|
223
|
+
* to fail the load of a project that merely depends on it.
|
|
224
|
+
*
|
|
225
|
+
* @param {string} projectDir directory holding the project's package.json
|
|
226
|
+
* @param {{exclude?: Iterable<string>}} [options] `exclude` — package
|
|
227
|
+
* directories already loaded (from config); matched through symlinks
|
|
228
|
+
* @returns {Array<{spec: string, field: string, packageDir: string, hostDir: string}>}
|
|
229
|
+
*/
|
|
230
|
+
export function findAutolinkCandidates(projectDir, options) {
|
|
231
|
+
return scanAutolinkCandidates(projectDir, options)
|
|
232
|
+
.filter(candidate => !candidate.repeat)
|
|
233
|
+
.map(({spec, field, packageDir, hostDir}) => ({
|
|
234
|
+
spec,
|
|
235
|
+
field,
|
|
236
|
+
packageDir,
|
|
237
|
+
hostDir,
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Load every autolink candidate, each in isolation, as provider candidates for
|
|
243
|
+
* {@link resolveProviders}. Nothing is filtered here: a candidate whose load
|
|
244
|
+
* throws or whose manifest fails comes back with its error, and a repeated
|
|
245
|
+
* directory comes back unloaded, so the resolver records each one.
|
|
246
|
+
*
|
|
247
|
+
* @param {object} options
|
|
248
|
+
* @param {string} options.projectDir directory holding the project's package.json
|
|
249
|
+
* @param {import('./integrations.mjs').LoadedIntegration[]} [options.loaded]
|
|
250
|
+
* integrations already loaded from config
|
|
251
|
+
* @param {boolean} [options.fresh]
|
|
252
|
+
* @returns {Promise<import('./provider-resolution.mjs').ProviderCandidate[]>}
|
|
253
|
+
*/
|
|
254
|
+
export async function loadAutolinkCandidates({
|
|
255
|
+
projectDir,
|
|
256
|
+
loaded = [],
|
|
257
|
+
fresh = false,
|
|
258
|
+
}) {
|
|
259
|
+
const scanned = scanAutolinkCandidates(projectDir, {
|
|
260
|
+
// A configured entry that never resolved to a directory has none to exclude.
|
|
261
|
+
exclude: loaded.flatMap(integration =>
|
|
262
|
+
typeof integration.__packageDir === 'string'
|
|
263
|
+
? [integration.__packageDir]
|
|
264
|
+
: [],
|
|
265
|
+
),
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
/** @type {import('./provider-resolution.mjs').ProviderCandidate[]} */
|
|
269
|
+
const candidates = [];
|
|
270
|
+
for (const candidate of scanned) {
|
|
271
|
+
const {spec, packageDir} = candidate;
|
|
272
|
+
if (candidate.repeat) {
|
|
273
|
+
candidates.push({source: 'autolinked', spec, packageDir, repeat: true});
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
// Resolve from the directory whose node_modules actually holds the
|
|
278
|
+
// package, so a hoisted dependency resolves the same way Node found it.
|
|
279
|
+
const [integration] = await loadIntegrations([spec], {
|
|
280
|
+
cwd: candidate.hostDir,
|
|
281
|
+
fresh,
|
|
282
|
+
});
|
|
283
|
+
candidates.push({
|
|
284
|
+
source: 'autolinked',
|
|
285
|
+
spec,
|
|
286
|
+
packageDir,
|
|
287
|
+
...(integration == null
|
|
288
|
+
? {}
|
|
289
|
+
: {
|
|
290
|
+
integration: {
|
|
291
|
+
...integration,
|
|
292
|
+
__autolinked: true,
|
|
293
|
+
__dependencyField: candidate.field,
|
|
294
|
+
},
|
|
295
|
+
}),
|
|
296
|
+
});
|
|
297
|
+
} catch (error) {
|
|
298
|
+
candidates.push({
|
|
299
|
+
source: 'autolinked',
|
|
300
|
+
spec,
|
|
301
|
+
packageDir,
|
|
302
|
+
error: error instanceof Error ? error.message : String(error),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return candidates;
|
|
307
|
+
}
|
|
308
|
+
|
|
205
309
|
/**
|
|
206
310
|
* Load every declared dependency that ships an integration manifest and is not
|
|
207
311
|
* already loaded from config.
|
|
@@ -216,6 +320,12 @@ export function findAutolinkCandidates(projectDir, {exclude = []} = {}) {
|
|
|
216
320
|
* consuming project can neither fix nor silence, and which
|
|
217
321
|
* `astryx doctor integration validate <package>` reports on demand.
|
|
218
322
|
*
|
|
323
|
+
* One package reached twice (an alias beside the package it aliases, at the
|
|
324
|
+
* same version) loads once. The same name at another version is kept, so the
|
|
325
|
+
* provider pass reports it instead of dropping it. Project.load does not call
|
|
326
|
+
* this; it hands {@link loadAutolinkCandidates} to the resolver, whose ledger
|
|
327
|
+
* records every candidate dropped here.
|
|
328
|
+
*
|
|
219
329
|
* @param {object} options
|
|
220
330
|
* @param {string} options.projectDir directory holding the project's package.json
|
|
221
331
|
* @param {import('./integrations.mjs').LoadedIntegration[]} [options.loaded]
|
|
@@ -228,45 +338,26 @@ export async function autolinkIntegrations({
|
|
|
228
338
|
loaded = [],
|
|
229
339
|
fresh = false,
|
|
230
340
|
}) {
|
|
231
|
-
const candidates =
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
341
|
+
const candidates = await loadAutolinkCandidates({projectDir, loaded, fresh});
|
|
342
|
+
const {ledger} = resolveProviders([
|
|
343
|
+
...loaded.map(integration => ({
|
|
344
|
+
source: /** @type {const} */ ('configured'),
|
|
345
|
+
integration,
|
|
346
|
+
spec: integration.__spec,
|
|
347
|
+
})),
|
|
348
|
+
...candidates,
|
|
349
|
+
]);
|
|
235
350
|
/** @type {import('./integrations.mjs').LoadedIntegration[]} */
|
|
236
351
|
const autolinked = [];
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
for (const candidate of candidates) {
|
|
246
|
-
/** @type {import('./integrations.mjs').LoadedIntegration|undefined} */
|
|
247
|
-
let integration;
|
|
248
|
-
try {
|
|
249
|
-
// Resolve from the directory whose node_modules actually holds the
|
|
250
|
-
// package, so a hoisted dependency resolves the same way Node found it.
|
|
251
|
-
[integration] = await loadIntegrations([candidate.spec], {
|
|
252
|
-
cwd: candidate.hostDir,
|
|
253
|
-
fresh,
|
|
254
|
-
});
|
|
255
|
-
} catch {
|
|
256
|
-
continue;
|
|
352
|
+
for (const entry of ledger.values()) {
|
|
353
|
+
const {candidate} = entry;
|
|
354
|
+
if (
|
|
355
|
+
candidate.source === 'autolinked' &&
|
|
356
|
+
candidate.integration != null &&
|
|
357
|
+
(entry.outcome === 'contributes' || entry.outcome === 'set-aside')
|
|
358
|
+
) {
|
|
359
|
+
autolinked.push(candidate.integration);
|
|
257
360
|
}
|
|
258
|
-
if (!integration || integration.__loadError) continue;
|
|
259
|
-
// Identity is the resolved package's own name and version, so an alias and
|
|
260
|
-
// the package it aliases collapse here even when they are two directories
|
|
261
|
-
// on disk.
|
|
262
|
-
if (seen.has(identity(integration))) continue;
|
|
263
|
-
seen.add(identity(integration));
|
|
264
|
-
autolinked.push({
|
|
265
|
-
...integration,
|
|
266
|
-
__autolinked: true,
|
|
267
|
-
__dependencyField: candidate.field,
|
|
268
|
-
});
|
|
269
361
|
}
|
|
270
|
-
|
|
271
362
|
return autolinked;
|
|
272
363
|
}
|