@astryxdesign/cli 0.6.3-canary.ebaebc4 → 0.6.3-canary.ee13359
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 +114 -77
- 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 +35 -1
- package/api/build/build.type.mjs +24 -3
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/_adapter.d.mts +6 -12
- package/api/component/_adapter.mjs +20 -10
- package/api/component/component.doc.mjs +13 -3
- package/api/component/component.mjs +91 -14
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +16 -5
- package/api/component/component.type.mjs +13 -5
- 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 +40 -11
- package/api/discover/discover.doc.mjs +2 -1
- package/api/docs/_adapter.d.mts +210 -34
- package/api/docs/_adapter.mjs +674 -134
- package/api/docs/detail/detail.mjs +11 -3
- package/api/docs/detail/section/section.mjs +24 -13
- package/api/docs/detail/section/section.test.mjs +15 -6
- package/api/docs/docs.d.mts +5 -3
- package/api/docs/docs.doc.mjs +36 -15
- package/api/docs/docs.mjs +44 -8
- package/api/docs/docs.test.mjs +158 -4
- package/api/docs/docs.type.d.mts +165 -2
- package/api/docs/docs.type.mjs +101 -3
- package/api/docs/index/index.mjs +11 -3
- package/api/docs/index/index.test.mjs +1 -1
- package/api/docs/integration-tree.test.mjs +547 -0
- package/api/docs/integrationDocs.test.mjs +14 -14
- package/api/docs/list/list.mjs +28 -12
- package/api/docs/node/node.d.mts +43 -0
- package/api/docs/node/node.mjs +192 -0
- package/api/doctor/doctor.d.mts +54 -4
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +327 -16
- package/api/doctor/doctor.test.mjs +420 -7
- 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/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +69 -17
- package/api/index.d.mts +1 -1
- package/api/index.mjs +1 -0
- package/api/init/init.doc.mjs +6 -1
- 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.d.mts +2 -1
- package/api/integration/add-contribution.mjs +125 -12
- package/api/integration/add-contribution.test.mjs +254 -3
- package/api/integration/add-theme.mjs +34 -64
- package/api/integration/add-theme.test.mjs +105 -21
- package/api/integration/authoring-checks.mjs +108 -31
- package/api/integration/authoring-checks.test.mjs +171 -6
- package/api/integration/authoring-checks.type.d.mts +3 -1
- package/api/integration/authoring-checks.type.mjs +3 -1
- package/api/integration/integration-authoring.type.d.mts +2 -0
- package/api/integration/integration-authoring.type.mjs +2 -0
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +14 -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 +8 -1
- 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 +2 -1
- package/api/integration/integrationPackCheck.doc.mjs +2 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +7 -5
- package/api/integration/pack-check.mjs +34 -0
- package/api/integration/pack-check.test.mjs +138 -47
- package/api/integration/pack-check.type.d.mts +26 -2
- package/api/integration/pack-check.type.mjs +14 -1
- 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 +179 -26
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +3 -2
- package/api/json/assertResponse.doc.mjs +1 -0
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/index.ts +2 -0
- package/api/json/isError.doc.mjs +1 -0
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/_adapter.mjs +20 -5
- 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 +28 -10
- package/api/search/search.doc.mjs +8 -2
- package/api/search/search.mjs +334 -38
- package/api/search/search.test.mjs +124 -1
- package/api/search/search.type.d.mts +13 -1
- package/api/search/search.type.mjs +4 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/list/list.mjs +1 -0
- package/api/template/template-integration.test.mjs +1022 -3
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.doc.mjs +30 -8
- package/api/template/template.mjs +45 -8
- package/api/template/template.type.d.mts +6 -8
- package/api/template/template.type.mjs +3 -2
- 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 +114 -37
- 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/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 +7 -2
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.mjs +8 -1
- 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 +20 -0
- 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 +6 -2
- package/api/upgrade/_adapter.d.mts +32 -5
- package/api/upgrade/_adapter.mjs +124 -73
- 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 +356 -59
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +8 -2
- package/api/upgrade/upgrade.type.d.mts +38 -0
- package/api/upgrade/upgrade.type.mjs +16 -0
- package/assets/codemods/__tests__/runner.test.mjs +330 -8
- package/assets/codemods/integration-discovery.mjs +8 -2
- package/assets/codemods/integration-discovery.test.mjs +15 -0
- package/assets/codemods/integration-runner.mjs +56 -4
- package/assets/codemods/integration-runner.protection.test.mjs +153 -0
- package/assets/codemods/run-codemod.mjs +177 -34
- package/assets/codemods/runner.mjs +350 -102
- 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-native-picker-to-presentation.test.mjs +63 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +220 -0
- package/assets/codemods/transforms/next/index.mjs +19 -1
- package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
- 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.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/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/styling-libraries.doc.mjs +2 -2
- package/assets/docs/styling.doc.mjs +4 -4
- package/assets/docs/theme.doc.mjs +4 -4
- package/assets/docs/tokens.doc.mjs +1 -1
- package/assets/docs/tree/api.doc.mjs +30 -0
- package/assets/docs/tree/cli.doc.mjs +23 -0
- package/assets/docs/tree/commands.doc.mjs +25 -0
- package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +66 -38
- package/assets/docs/tree/integrations.test.mjs +62 -0
- package/assets/docs/tree/writing-docs.doc.mjs +286 -0
- package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
- 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/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -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/codemod/codemod.doc.mjs +1 -1
- package/authoring/codemod/type.ts +12 -0
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/type.ts +15 -3
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +71 -141
- package/authoring/doctypes/_schema.mjs +29 -2
- package/authoring/doctypes/base/graph-fields.doc.mjs +8 -6
- package/authoring/doctypes/base/type.ts +6 -5
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/component/type.ts +2 -2
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +3 -2
- package/authoring/doctypes/function/type.ts +3 -2
- package/authoring/doctypes/hook/type.ts +2 -2
- package/authoring/doctypes/load-contract.test.mjs +3 -2
- package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
- package/authoring/doctypes/namespace/parse.test.mjs +23 -25
- package/authoring/doctypes/namespace/type.ts +5 -2
- package/authoring/doctypes/parse.d.mts +4 -2
- package/authoring/doctypes/parse.mjs +10 -5
- package/authoring/doctypes/reference/reference.doc.mjs +7 -5
- package/authoring/doctypes/reference/type.ts +12 -10
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +1 -2
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +4 -0
- package/authoring/doctypes/template/parse.test.mjs +18 -0
- package/authoring/doctypes/template/template.doc.mjs +9 -3
- package/authoring/doctypes/template/type.ts +8 -0
- 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 +2 -1
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/identity/identity.doc.mjs +2 -2
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +7 -4
- package/authoring/index.mjs +2 -1
- package/authoring/integration/integration.doc.mjs +2 -2
- 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.adaptations.test.mjs +100 -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 +16 -50
- 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 +37 -49
- 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 +3 -8
- package/clients/cli/commands/component-ownership.test.mjs +3 -3
- 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 +52 -5
- 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 +4 -4
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +21 -9
- package/clients/cli/commands/docs.mjs +182 -68
- package/clients/cli/commands/docs.test.mjs +120 -16
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -3
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +15 -8
- 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 +83 -8
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +30 -25
- 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 +32 -6
- 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/integration.mjs +1 -0
- 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 +28 -9
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/setup-nudge.test.mjs +6 -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 +52 -13
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.mjs +4 -91
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/text-json-parity.test.mjs +719 -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.behavior.test.mjs +4 -3
- 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 +20 -8
- package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
- 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/commands/upgrade.mjs +29 -7
- package/clients/cli/formatters/index.mjs +2 -0
- package/clients/cli/formatters/index.test.mjs +6 -0
- package/clients/cli/index.mjs +21 -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 +31 -2
- 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 +70 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/agent-docs/agent-docs.test.mjs +10 -1
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project-themes.test.mjs +11 -19
- package/foundation/config/project.d.mts +20 -11
- package/foundation/config/project.mjs +246 -89
- package/foundation/config/project.test.mjs +270 -21
- 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 +20 -9
- 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 +119 -0
- package/foundation/discovery/cli-self-docs.mjs +490 -0
- package/foundation/discovery/cli-self-docs.test.mjs +375 -0
- package/foundation/discovery/component-discovery.d.mts +38 -0
- package/foundation/discovery/component-discovery.mjs +48 -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 +108 -10
- package/foundation/discovery/docs-discovery.mjs +191 -30
- package/foundation/discovery/docs-discovery.test.mjs +71 -32
- package/foundation/discovery/docs-output-budget.d.mts +2 -2
- package/foundation/discovery/docs-output-budget.mjs +1 -1
- package/foundation/discovery/docs-section-key.d.mts +28 -10
- package/foundation/discovery/docs-section-key.mjs +134 -33
- package/foundation/discovery/docs-section-key.test.mjs +41 -19
- package/foundation/discovery/template-adapter.d.mts +113 -11
- 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 +772 -82
- package/foundation/discovery/template-adapter.test.mjs +57 -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/doc-compiler/bundle.d.mts +47 -0
- package/foundation/doc-compiler/bundle.mjs +278 -0
- package/foundation/doc-compiler/bundle.test.mjs +266 -0
- package/foundation/doc-compiler/compile.d.mts +220 -39
- package/foundation/doc-compiler/compile.mjs +311 -15
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +305 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +28 -1
- 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 +291 -0
- package/foundation/doc-compiler/inputs.test.mjs +299 -0
- package/foundation/doc-compiler/ir.d.mts +13 -0
- package/foundation/doc-compiler/ir.mjs +196 -12
- package/foundation/doc-compiler/lenses.d.mts +3 -2
- package/foundation/doc-compiler/lenses.mjs +2 -1
- package/foundation/doc-compiler/links.d.mts +135 -0
- package/foundation/doc-compiler/links.mjs +253 -0
- package/foundation/doc-compiler/links.test.mjs +139 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +495 -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 +127 -0
- package/foundation/doc-compiler/read.mjs +325 -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/doc-compiler/tree.d.mts +288 -0
- package/foundation/doc-compiler/tree.mjs +876 -0
- package/foundation/doc-compiler/tree.test.mjs +598 -0
- package/foundation/fs/file-protection.d.mts +33 -0
- package/foundation/fs/file-protection.mjs +825 -0
- package/foundation/fs/file-protection.test.mjs +250 -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/autolink.test.mjs +1 -1
- package/foundation/integrations/cli-requirement.d.mts +45 -0
- package/foundation/integrations/cli-requirement.mjs +154 -0
- package/foundation/integrations/cli-requirement.test.mjs +109 -0
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +3 -2
- package/foundation/integrations/contribution-inventory.mjs +27 -24
- package/foundation/integrations/contribution-inventory.test.mjs +86 -27
- package/foundation/integrations/integration-warnings.d.mts +9 -2
- package/foundation/integrations/integration-warnings.mjs +51 -26
- package/foundation/integrations/integration-warnings.test.mjs +74 -1
- 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 +121 -29
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +2 -0
- package/foundation/response/error-codes.doc.mjs +13 -4
- package/foundation/response/error-codes.mjs +8 -2
- package/foundation/response/error-codes.test.mjs +137 -10
- 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 +22 -17
- 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 +4 -3
- package/foundation/xle/expand.test.mjs +54 -0
- package/foundation/xle/xle.test.mjs +13 -0
- package/package.json +10 -9
- 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
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import * as path from 'node:path';
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
|
+
import {ERROR_CODES} from '../response/error-codes.mjs';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Error thrown by path-safety guards. Carries a stable `code`
|
|
@@ -38,7 +39,7 @@ export class PathSafetyError extends Error {
|
|
|
38
39
|
*
|
|
39
40
|
* - Absolute paths (e.g. `/tmp/x`) — re-rooted by `path.join` is silent;
|
|
40
41
|
* better to fail loudly. Pass `{allowAbsolute: true}` to opt in.
|
|
41
|
-
* - Paths that escape via `..` segments.
|
|
42
|
+
* - Paths that escape via `..` segments or a symlink, dangling or not.
|
|
42
43
|
*
|
|
43
44
|
* Returns the resolved absolute path on success.
|
|
44
45
|
*
|
|
@@ -50,7 +51,8 @@ export class PathSafetyError extends Error {
|
|
|
50
51
|
* @param {string} [options.label='path'] - Human-readable name of the arg
|
|
51
52
|
* being checked (used in error messages, e.g. 'output directory').
|
|
52
53
|
* @returns {string} Absolute resolved path inside `rootDir`.
|
|
53
|
-
* @throws {PathSafetyError}
|
|
54
|
+
* @throws {PathSafetyError} An escape carries the registered
|
|
55
|
+
* `ERR_PATH_TRAVERSAL`, so it reaches an envelope correctly even uncaught.
|
|
54
56
|
*/
|
|
55
57
|
export function assertWithin(targetPath, rootDir, options = {}) {
|
|
56
58
|
const {allowAbsolute = false, label = 'path'} = options;
|
|
@@ -83,42 +85,70 @@ export function assertWithin(targetPath, rootDir, options = {}) {
|
|
|
83
85
|
throw new PathSafetyError(
|
|
84
86
|
`Invalid ${label} "${targetPath}": resolves outside the project root ` +
|
|
85
87
|
`(${absRoot}). Path traversal is not allowed.`,
|
|
86
|
-
|
|
88
|
+
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
87
89
|
);
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
// path.resolve is purely lexical — it does NOT follow symlinks, so a symlink
|
|
91
93
|
// INSIDE the root that points outside would pass the check above while the
|
|
92
|
-
// real write lands outside root. Canonicalize
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
// writes through this guard.
|
|
94
|
+
// real write lands outside root. Canonicalize both paths through every
|
|
95
|
+
// symlink, dangling ones included (a write through a dangling link creates
|
|
96
|
+
// its target), and re-check.
|
|
96
97
|
try {
|
|
97
|
-
const realRoot =
|
|
98
|
-
|
|
99
|
-
while (!fs.existsSync(existing)) {
|
|
100
|
-
const parent = path.dirname(existing);
|
|
101
|
-
if (parent === existing) break;
|
|
102
|
-
existing = parent;
|
|
103
|
-
}
|
|
104
|
-
const realExisting = fs.realpathSync(existing);
|
|
98
|
+
const realRoot = canonicalPath(absRoot);
|
|
99
|
+
const realTarget = canonicalPath(resolved);
|
|
105
100
|
const realRootWithSep = realRoot.endsWith(path.sep) ? realRoot : realRoot + path.sep;
|
|
106
|
-
if (
|
|
101
|
+
if (realTarget !== realRoot && !realTarget.startsWith(realRootWithSep)) {
|
|
107
102
|
throw new PathSafetyError(
|
|
108
103
|
`Invalid ${label} "${targetPath}": resolves outside the project root ` +
|
|
109
104
|
`(${absRoot}) via a symlink. Path traversal is not allowed.`,
|
|
110
|
-
|
|
105
|
+
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
111
106
|
);
|
|
112
107
|
}
|
|
113
108
|
} catch (err) {
|
|
114
109
|
if (err instanceof PathSafetyError) throw err;
|
|
115
|
-
//
|
|
116
|
-
//
|
|
110
|
+
// A symlink loop, a permission error, or a race; fall back to the lexical
|
|
111
|
+
// result already validated above rather than crash.
|
|
117
112
|
}
|
|
118
113
|
|
|
119
114
|
return resolved;
|
|
120
115
|
}
|
|
121
116
|
|
|
117
|
+
/** Linux's MAXSYMLINKS; a longer chain is treated as a loop. */
|
|
118
|
+
const MAX_SYMLINK_HOPS = 40;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* `target` with every symlink resolved, including a dangling one, which
|
|
122
|
+
* `fs.realpathSync` refuses. Components below the deepest existing entry are
|
|
123
|
+
* appended as given.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} target absolute path
|
|
126
|
+
* @param {number} [hops] symlinks followed so far
|
|
127
|
+
* @returns {string}
|
|
128
|
+
* @throws when the chain exceeds {@link MAX_SYMLINK_HOPS} or `lstat` fails
|
|
129
|
+
* for a reason other than a missing entry
|
|
130
|
+
*/
|
|
131
|
+
function canonicalPath(target, hops = 0) {
|
|
132
|
+
if (hops > MAX_SYMLINK_HOPS) throw new Error(`Too many symlinks: ${target}`);
|
|
133
|
+
let stat;
|
|
134
|
+
try {
|
|
135
|
+
stat = fs.lstatSync(target);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
const code = /** @type {NodeJS.ErrnoException} */ (err).code;
|
|
138
|
+
if (code !== 'ENOENT' && code !== 'ENOTDIR') throw err;
|
|
139
|
+
const parent = path.dirname(target);
|
|
140
|
+
if (parent === target) return target;
|
|
141
|
+
return path.join(canonicalPath(parent, hops), path.basename(target));
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
return fs.realpathSync(target);
|
|
145
|
+
} catch (err) {
|
|
146
|
+
if (!stat.isSymbolicLink()) throw err;
|
|
147
|
+
}
|
|
148
|
+
const link = fs.readlinkSync(target);
|
|
149
|
+
return canonicalPath(path.resolve(fs.realpathSync(path.dirname(target)), link), hops + 1);
|
|
150
|
+
}
|
|
151
|
+
|
|
122
152
|
/**
|
|
123
153
|
* Validate a "name" argument (e.g. theme name, component name) that will
|
|
124
154
|
* be embedded in a generated filename. Rejects names containing path
|
|
@@ -19,6 +19,19 @@ afterEach(() => {
|
|
|
19
19
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The code a guard rejected with, or 'accepted'.
|
|
24
|
+
* @param {() => unknown} fn
|
|
25
|
+
*/
|
|
26
|
+
function rejectionCode(fn) {
|
|
27
|
+
try {
|
|
28
|
+
fn();
|
|
29
|
+
} catch (err) {
|
|
30
|
+
return err instanceof PathSafetyError ? err.code : err;
|
|
31
|
+
}
|
|
32
|
+
return 'accepted';
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
describe('assertWithin', () => {
|
|
23
36
|
it('accepts a relative path that stays inside root', () => {
|
|
24
37
|
const result = assertWithin('subdir/file.txt', tmpDir);
|
|
@@ -38,6 +51,14 @@ describe('assertWithin', () => {
|
|
|
38
51
|
expect(() => assertWithin('a/b/../../../c', tmpDir)).toThrow(PathSafetyError);
|
|
39
52
|
});
|
|
40
53
|
|
|
54
|
+
it('reports an escape with the registered ERR_PATH_TRAVERSAL code', () => {
|
|
55
|
+
// An uncaught guard error reaches the JSON envelope with this code as-is.
|
|
56
|
+
expect(rejectionCode(() => assertWithin('../escaped', tmpDir))).toBe('ERR_PATH_TRAVERSAL');
|
|
57
|
+
expect(
|
|
58
|
+
rejectionCode(() => assertWithin('/etc/passwd', tmpDir, {allowAbsolute: true})),
|
|
59
|
+
).toBe('ERR_PATH_TRAVERSAL');
|
|
60
|
+
});
|
|
61
|
+
|
|
41
62
|
it('rejects absolute paths by default', () => {
|
|
42
63
|
expect(() => assertWithin('/tmp/elsewhere', tmpDir)).toThrow(/absolute paths are not allowed/i);
|
|
43
64
|
});
|
|
@@ -160,6 +181,7 @@ describe('assertWithin — symlink escape (realpath guard)', () => {
|
|
|
160
181
|
// path.resolve is lexical and would pass this; the realpath check must catch it.
|
|
161
182
|
expect(() => assertWithin('link/evil.txt', root)).toThrow(PathSafetyError);
|
|
162
183
|
expect(() => assertWithin('link/evil.txt', root)).toThrow(/outside|symlink|traversal/i);
|
|
184
|
+
expect(rejectionCode(() => assertWithin('link/evil.txt', root))).toBe('ERR_PATH_TRAVERSAL');
|
|
163
185
|
});
|
|
164
186
|
|
|
165
187
|
it('still accepts a legit non-existent nested path inside root', () => {
|
|
@@ -169,4 +191,32 @@ describe('assertWithin — symlink escape (realpath guard)', () => {
|
|
|
169
191
|
it('rejects a NUL byte in the path', () => {
|
|
170
192
|
expect(() => assertWithin('a\u0000b', root)).toThrow(PathSafetyError);
|
|
171
193
|
});
|
|
194
|
+
|
|
195
|
+
it('rejects a dangling symlink whose target is outside root', () => {
|
|
196
|
+
// A write through the link would create the missing target outside root.
|
|
197
|
+
fs.symlinkSync(path.join(outside, 'created.txt'), path.join(root, 'leaf'));
|
|
198
|
+
expect(rejectionCode(() => assertWithin('leaf', root))).toBe('ERR_PATH_TRAVERSAL');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('rejects a path through a dangling directory symlink that points outside root', () => {
|
|
202
|
+
fs.symlinkSync(path.join(outside, 'missing-dir'), path.join(root, 'dir'));
|
|
203
|
+
expect(rejectionCode(() => assertWithin('dir/evil.txt', root))).toBe('ERR_PATH_TRAVERSAL');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('follows a chain of links that ends in a dangling target outside root', () => {
|
|
207
|
+
fs.symlinkSync(path.join(outside, 'missing.txt'), path.join(root, 'second'));
|
|
208
|
+
fs.symlinkSync('second', path.join(root, 'first'));
|
|
209
|
+
expect(rejectionCode(() => assertWithin('first', root))).toBe('ERR_PATH_TRAVERSAL');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('accepts a dangling symlink whose target stays inside root', () => {
|
|
213
|
+
fs.symlinkSync(path.join('sub', 'new.txt'), path.join(root, 'leaf'));
|
|
214
|
+
expect(assertWithin('leaf', root)).toBe(path.join(root, 'leaf'));
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('terminates on a symlink loop', () => {
|
|
218
|
+
fs.symlinkSync('loop', path.join(root, 'loop'));
|
|
219
|
+
const result = rejectionCode(() => assertWithin('loop', root));
|
|
220
|
+
expect(['accepted', 'ERR_PATH_TRAVERSAL']).toContain(result);
|
|
221
|
+
});
|
|
172
222
|
});
|
|
@@ -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
|
+
};
|