@astryxdesign/cli 0.6.3-canary.ea2f048 → 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 -76
- 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/_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 +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 +40 -11
- 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 +230 -41
- package/api/docs/_adapter.mjs +734 -108
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +22 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +54 -19
- package/api/docs/detail/section/section.test.mjs +50 -0
- package/api/docs/docs.d.mts +10 -3
- package/api/docs/docs.doc.mjs +54 -16
- package/api/docs/docs.mjs +53 -10
- package/api/docs/docs.test.mjs +164 -4
- package/api/docs/docs.type.d.mts +205 -5
- package/api/docs/docs.type.mjs +137 -11
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +40 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/integration-tree.test.mjs +547 -0
- package/api/docs/integrationDocs.test.mjs +114 -8
- 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 +99 -1
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +544 -1
- package/api/doctor/doctor.test.mjs +610 -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 +2 -2
- 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 +130 -15
- package/api/integration/add-contribution.test.mjs +258 -7
- 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 +3 -1
- 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 +83 -7
- package/api/integration/pack-check.test.mjs +387 -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 +29 -11
- package/api/search/search.doc.mjs +8 -2
- package/api/search/search.mjs +337 -41
- package/api/search/search.test.mjs +124 -1
- package/api/search/search.type.d.mts +15 -3
- package/api/search/search.type.mjs +5 -2
- 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/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.d.mts +1 -1
- package/api/template/template.doc.mjs +30 -8
- package/api/template/template.mjs +45 -8
- package/api/template/template.type.d.mts +12 -14
- package/api/template/template.type.mjs +15 -14
- 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 +20 -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 +6 -2
- package/api/upgrade/_adapter.d.mts +32 -5
- package/api/upgrade/_adapter.mjs +139 -22
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/project-context.test.mjs +272 -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 +12 -5
- package/api/upgrade/upgrade.type.d.mts +43 -5
- package/api/upgrade/upgrade.type.mjs +27 -11
- package/assets/codemods/__tests__/runner.test.mjs +330 -8
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -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.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/README.md +9 -0
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/styling-libraries.doc.mjs +3 -3
- 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} +124 -25
- package/assets/docs/tree/integrations.test.mjs +62 -0
- package/assets/docs/tree/writing-docs.doc.mjs +286 -0
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- 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/_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/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/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 +8 -8
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +718 -23
- package/authoring/doctypes/_schema.mjs +519 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +64 -0
- package/authoring/doctypes/base/type.ts +41 -0
- 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 +5 -4
- package/authoring/doctypes/component/component.doc.mjs +6 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +6 -5
- 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 +4 -2
- package/authoring/doctypes/function/function.doc.mjs +7 -2
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +9 -4
- 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 +5 -4
- package/authoring/doctypes/legacy.d.mts +8 -6
- package/authoring/doctypes/legacy.mjs +5 -4
- package/authoring/doctypes/load-contract.test.mjs +208 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +128 -0
- package/authoring/doctypes/namespace/parse.d.mts +12 -0
- package/authoring/doctypes/namespace/parse.mjs +25 -0
- package/authoring/doctypes/namespace/parse.test.mjs +163 -0
- package/authoring/doctypes/namespace/type.ts +74 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -11
- package/authoring/doctypes/parse.test.mjs +77 -3
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +8 -5
- package/authoring/doctypes/reference/reference.doc.mjs +20 -5
- package/authoring/doctypes/reference/type.ts +53 -5
- 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 +4 -4
- package/authoring/doctypes/template/parse.d.mts +94 -1
- package/authoring/doctypes/template/parse.mjs +40 -2
- package/authoring/doctypes/template/parse.test.mjs +26 -2
- package/authoring/doctypes/template/template.doc.mjs +13 -3
- package/authoring/doctypes/template/type.ts +13 -2
- 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 -10
- 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 +10 -10
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.d.mts +9 -0
- package/authoring/identity/identity.doc.mjs +61 -0
- package/authoring/identity/type.ts +132 -0
- package/authoring/index.d.mts +2 -0
- package/authoring/index.d.ts +52 -17
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +15 -8
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/parse.test.mjs +10 -1
- package/authoring/integration/schema.d.mts +6 -4
- package/authoring/integration/schema.mjs +9 -3
- package/authoring/integration/type.ts +19 -8
- package/authoring/shadcn/receipt.d.mts +6 -6
- 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 +28 -6
- package/clients/cli/commands/docs.mjs +238 -24
- package/clients/cli/commands/docs.test.mjs +193 -1
- 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-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/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 +9 -5
- 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 +22 -10
- 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 +164 -1
- package/clients/cli/formatters/index.test.mjs +97 -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 +36 -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 +263 -91
- package/foundation/config/project.test.mjs +270 -21
- package/foundation/discovery/authoring-self-docs.d.mts +75 -0
- package/foundation/discovery/authoring-self-docs.mjs +224 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +165 -0
- 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 +39 -1
- package/foundation/discovery/component-discovery.mjs +50 -1
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +116 -11
- package/foundation/discovery/docs-discovery.mjs +389 -108
- package/foundation/discovery/docs-discovery.test.mjs +325 -20
- package/foundation/discovery/docs-output-budget.d.mts +28 -0
- package/foundation/discovery/docs-output-budget.mjs +50 -0
- package/foundation/discovery/docs-section-key.d.mts +116 -0
- package/foundation/discovery/docs-section-key.mjs +322 -0
- package/foundation/discovery/docs-section-key.test.mjs +246 -0
- 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 +774 -83
- 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/discovery/theming-targets.test.mjs +4 -0
- 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 +343 -0
- package/foundation/doc-compiler/compile.mjs +558 -0
- 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 +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 +291 -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 +471 -0
- package/foundation/doc-compiler/lenses.d.mts +34 -0
- package/foundation/doc-compiler/lenses.mjs +128 -0
- 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/identity/provider-identity.d.mts +90 -0
- package/foundation/identity/provider-identity.mjs +320 -0
- package/foundation/identity/provider-identity.test.mjs +254 -0
- package/foundation/identity/providers.d.mts +7 -0
- package/foundation/identity/providers.mjs +16 -0
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -45
- 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 +52 -21
- package/foundation/integrations/integration-warnings.test.mjs +74 -1
- package/foundation/integrations/integrations.d.mts +49 -2
- package/foundation/integrations/integrations.mjs +81 -8
- package/foundation/integrations/integrations.test.mjs +384 -1
- package/foundation/integrations/provider-conflicts.test.mjs +125 -0
- 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.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +131 -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 +57 -17
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +26 -16
- 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 -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
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Normalize an npm package name into a ProviderId.
|
|
6
|
+
* @param {string} packageName
|
|
7
|
+
* @returns {ProviderId}
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeProviderId(packageName: string): ProviderId;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a SHA-256 digest.
|
|
12
|
+
* @param {string} digest
|
|
13
|
+
* @returns {ContentDigest}
|
|
14
|
+
*/
|
|
15
|
+
export function normalizeContentDigest(digest: string): ContentDigest;
|
|
16
|
+
/**
|
|
17
|
+
* Build a stable provider + contribution kind + artifact-name ID.
|
|
18
|
+
* @param {string} provider
|
|
19
|
+
* @param {ContributionKind} kind
|
|
20
|
+
* @param {string} name
|
|
21
|
+
* @returns {ArtifactId}
|
|
22
|
+
*/
|
|
23
|
+
export function createArtifactId(provider: string, kind: ContributionKind, name: string): ArtifactId;
|
|
24
|
+
/**
|
|
25
|
+
* Build a stable document ID from provider + authored kind + stable name.
|
|
26
|
+
* @param {string} provider
|
|
27
|
+
* @param {AuthoredDocKind} kind
|
|
28
|
+
* @param {string} name
|
|
29
|
+
* @returns {DocId}
|
|
30
|
+
*/
|
|
31
|
+
export function createDocId(provider: string, kind: AuthoredDocKind, name: string): DocId;
|
|
32
|
+
/**
|
|
33
|
+
* Build a normalized logical artifact record.
|
|
34
|
+
* @param {string} provider
|
|
35
|
+
* @param {ContributionKind} kind
|
|
36
|
+
* @param {string} name
|
|
37
|
+
* @returns {ArtifactIdentity}
|
|
38
|
+
*/
|
|
39
|
+
export function createArtifactIdentity(provider: string, kind: ContributionKind, name: string): ArtifactIdentity;
|
|
40
|
+
/**
|
|
41
|
+
* Parse and canonicalize an ArtifactId.
|
|
42
|
+
* @param {string} value
|
|
43
|
+
* @returns {ArtifactIdentity}
|
|
44
|
+
*/
|
|
45
|
+
export function parseArtifactId(value: string): ArtifactIdentity;
|
|
46
|
+
/**
|
|
47
|
+
* Build one immutable provider instance.
|
|
48
|
+
* @param {{providerId: string, packageName: string, packageVersion: string, sourceDigest: string}} input
|
|
49
|
+
* @returns {ProviderInstance}
|
|
50
|
+
*/
|
|
51
|
+
export function createProviderInstance(input: {
|
|
52
|
+
providerId: string;
|
|
53
|
+
packageName: string;
|
|
54
|
+
packageVersion: string;
|
|
55
|
+
sourceDigest: string;
|
|
56
|
+
}): ProviderInstance;
|
|
57
|
+
/**
|
|
58
|
+
* Bind one validated authored document to immutable provider and source
|
|
59
|
+
* provenance. Runtime lifecycle state is intentionally absent.
|
|
60
|
+
* @param {{
|
|
61
|
+
* provider: ProviderInstance,
|
|
62
|
+
* kind: AuthoredDocKind,
|
|
63
|
+
* stableName: string,
|
|
64
|
+
* source: {group: string, path: string, digest: string},
|
|
65
|
+
* authored: AuthoredDoc,
|
|
66
|
+
* }} input
|
|
67
|
+
* @returns {AuthoredDocEntry}
|
|
68
|
+
*/
|
|
69
|
+
export function createAuthoredDocEntry(input: {
|
|
70
|
+
provider: ProviderInstance;
|
|
71
|
+
kind: AuthoredDocKind;
|
|
72
|
+
stableName: string;
|
|
73
|
+
source: {
|
|
74
|
+
group: string;
|
|
75
|
+
path: string;
|
|
76
|
+
digest: string;
|
|
77
|
+
};
|
|
78
|
+
authored: AuthoredDoc;
|
|
79
|
+
}): AuthoredDocEntry;
|
|
80
|
+
export type ArtifactId = import("../../authoring/identity/type").ArtifactId;
|
|
81
|
+
export type ArtifactIdentity = import("../../authoring/identity/type").ArtifactIdentity;
|
|
82
|
+
export type AuthoredDoc = import("../../authoring/identity/type").AuthoredDoc;
|
|
83
|
+
export type AuthoredDocEntry = import("../../authoring/identity/type").AuthoredDocEntry;
|
|
84
|
+
export type AuthoredDocKind = import("../../authoring/doctypes/base/type").AuthoredDocKind;
|
|
85
|
+
export type ContentDigest = import("../../authoring/identity/type").ContentDigest;
|
|
86
|
+
export type ContributionKind = import("../../authoring/identity/type").ContributionKind;
|
|
87
|
+
export type DocId = import("../../authoring/identity/type").DocId;
|
|
88
|
+
export type ProviderId = import("../../authoring/identity/type").ProviderId;
|
|
89
|
+
export type ProviderInstance = import("../../authoring/identity/type").ProviderInstance;
|
|
90
|
+
export type ProviderInstanceId = import("../../authoring/identity/type").ProviderInstanceId;
|