@astryxdesign/cli 0.7.17-canary.g4ea41ce → 0.7.17-canary.g5a3fd39
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 +7 -2
- package/api/build/_adapter.d.mts +7 -6
- package/api/build/_adapter.mjs +18 -11
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/kind.d.mts +6 -0
- package/api/build/kit/kind.mjs +1 -1
- package/api/build/kit/rank.d.mts +7 -1
- package/api/build/kit/rank.mjs +15 -5
- package/api/build/kit/signals.mjs +58 -57
- package/api/build/kit/start.d.mts +2 -1
- package/api/build/kit/start.mjs +62 -9
- package/api/build/kit/words.d.mts +6 -2
- package/api/build/kit/words.mjs +7 -3
- package/api/component/__fixtures__/resolutions/modules.txt +2 -2
- package/api/component/_adapter.d.mts +30 -24
- package/api/component/_adapter.mjs +72 -31
- package/api/component/component.mjs +4 -4
- package/api/component/detail/detail.d.mts +2 -2
- package/api/component/detail/detail.mjs +1 -1
- package/api/component/list/list.d.mts +2 -2
- package/api/component/list/list.mjs +4 -4
- package/api/discover/_adapter.mjs +15 -15
- package/api/docs/_adapter.d.mts +13 -5
- package/api/docs/_adapter.mjs +37 -10
- package/api/doctor/_adapter.d.mts +32 -0
- package/api/doctor/_adapter.mjs +56 -1
- package/api/doctor/doctor.mjs +28 -5
- package/api/doctor/theme-checks.mjs +165 -83
- package/api/error.d.mts +4 -3
- package/api/error.mjs +3 -2
- package/api/hook/_adapter.d.mts +5 -4
- package/api/hook/_adapter.mjs +6 -5
- package/api/icon/_options.d.mts +17 -0
- package/api/icon/_options.mjs +54 -0
- package/api/icon/exportIconIndex.doc.d.mts +10 -0
- package/api/icon/exportIconIndex.doc.mjs +59 -0
- package/api/icon/icon.mjs +11 -34
- package/api/icon/icon.type.d.mts +49 -0
- package/api/icon/icon.type.mjs +24 -0
- package/api/icon/rankIconIndex.doc.d.mts +10 -0
- package/api/icon/rankIconIndex.doc.mjs +79 -0
- package/api/icon/search/icon-index.d.mts +41 -0
- package/api/icon/search/icon-index.mjs +139 -0
- package/api/icon/search/search.d.mts +18 -0
- package/api/icon/search/search.mjs +13 -0
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/search/_adapter.d.mts +8 -5
- package/api/search/_adapter.mjs +14 -10
- package/api/search/_gather-components.d.mts +4 -4
- package/api/search/_gather-components.mjs +4 -3
- package/api/search/_gather-hooks.d.mts +2 -2
- package/api/search/_gather-hooks.mjs +1 -1
- package/api/search/_lexical.mjs +12 -2
- package/api/search/_priority.d.mts +10 -2
- package/api/search/_priority.mjs +37 -7
- package/api/search/_score.d.mts +12 -3
- package/api/search/_score.mjs +6 -3
- package/api/search/_words.mjs +12 -3
- package/api/search/search.d.mts +7 -1
- package/api/search/search.mjs +37 -4
- package/api/swizzle/_adapter.d.mts +7 -5
- package/api/swizzle/_adapter.mjs +7 -3
- package/api/swizzle/copy/copy.mjs +5 -4
- package/api/theme/build/build.d.mts +5 -0
- package/api/theme/build/build.mjs +400 -21
- package/api/theme/build/family.mjs +18 -7
- package/api/theme/build/font-warning.mjs +5 -4
- package/api/theme/build/input-fields.d.mts +21 -6
- package/api/theme/build/input-fields.mjs +104 -13
- package/api/theme/build/typography-values.d.mts +22 -0
- package/api/theme/build/typography-values.mjs +172 -22
- package/api/theme/build/written-values.d.mts +7 -0
- package/api/theme/build/written-values.mjs +57 -8
- package/api/theme/generateTonalPalette.doc.mjs +1 -1
- package/api/theme/palette/generate/generator.d.mts +14 -2
- package/api/theme/palette/generate/generator.mjs +94 -8
- package/api/theme/theme.type.d.mts +21 -4
- package/api/theme/theme.type.mjs +14 -5
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +18 -3
- package/api/theme-edit/_adapter.d.mts +1 -1
- package/api/theme-edit/_adapter.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +10 -4
- package/api/theme-edit/_catalog.mjs +81 -22
- package/api/theme-edit/_check.mjs +402 -88
- package/api/theme-edit/_color.d.mts +11 -2
- package/api/theme-edit/_color.mjs +23 -7
- package/api/theme-edit/_compiler.mjs +11 -3
- package/api/theme-edit/_context.d.mts +87 -6
- package/api/theme-edit/_context.mjs +224 -17
- package/api/theme-edit/_css.mjs +4 -0
- package/api/theme-edit/_edit.mjs +331 -58
- package/api/theme-edit/_how-question.d.mts +11 -0
- package/api/theme-edit/_how-question.mjs +2514 -234
- package/api/theme-edit/_how.mjs +79 -14
- package/api/theme-edit/_missed.mjs +294 -32
- package/api/theme-edit/_normal.d.mts +3 -1
- package/api/theme-edit/_normal.mjs +4 -1
- package/api/theme-edit/_palette.mjs +36 -5
- package/api/theme-edit/_part-words.mjs +20 -2
- package/api/theme-edit/_parts.d.mts +12 -1
- package/api/theme-edit/_parts.mjs +116 -11
- package/api/theme-edit/_preview-app.mjs +40 -2
- package/api/theme-edit/_preview.d.mts +45 -5
- package/api/theme-edit/_preview.mjs +173 -21
- package/api/theme-edit/_settings.d.mts +20 -0
- package/api/theme-edit/_settings.mjs +1033 -94
- package/api/theme-edit/_tables.mjs +2 -2
- package/api/theme-edit/theme-edit.type.d.mts +6 -5
- package/api/theme-edit/theme-edit.type.mjs +8 -8
- package/api/upgrade/_adapter.mjs +13 -2
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/authoring.doc.mjs +1 -0
- package/assets/docs/tree/cli.doc.mjs +1 -0
- package/assets/docs/tree/computer-agent-guide.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
- package/assets/docs/tree/global.doc.mjs +1 -0
- package/assets/docs/tree/single-component.doc.mjs +40 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/who-answers.doc.mjs +2 -2
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Blockquote/BlockquoteShowcase.tsx +1 -1
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +4 -4
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx +1 -0
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsSupportingVariant.tsx +2 -2
- package/assets/templates/blocks/components/Card/CardElevations.tsx +1 -1
- package/assets/templates/blocks/components/Card/CardWithInnerLayout.tsx +19 -3
- package/assets/templates/blocks/components/Card/ClickableCardWithNestedButton.tsx +11 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardMulti.tsx +1 -1
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +1 -1
- package/assets/templates/blocks/components/Center/CenterInsideACard.tsx +1 -1
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx +8 -0
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerWithProgress.tsx +8 -2
- package/assets/templates/blocks/components/ChatLayout/ChatLayoutPanelChat.tsx +1 -0
- package/assets/templates/blocks/components/ChatLayout/ChatLayoutShowcase.tsx +1 -1
- package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleCustomContent.tsx +9 -1
- package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleMetadata.tsx +12 -2
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataFooter.tsx +28 -7
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataShowcase.tsx +35 -7
- package/assets/templates/blocks/components/Collapsible/CollapsibleShowcase.tsx +1 -1
- package/assets/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupBasic.tsx +20 -4
- package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +15 -3
- package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +29 -6
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBasic.tsx +2 -2
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBottomSheet.tsx +1 -1
- package/assets/templates/blocks/components/ContextMenu/ContextMenuShowcase.tsx +2 -2
- package/assets/templates/blocks/components/Divider/DividerFullBleed.tsx +1 -1
- package/assets/templates/blocks/components/Divider/DividerShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Divider/DividerVariants.tsx +1 -1
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +23 -4
- package/assets/templates/blocks/components/EmptyState/EmptyStateActions.tsx +18 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateCompact.tsx +20 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateContainer.tsx +16 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateShowcase.tsx +11 -1
- package/assets/templates/blocks/components/Heading/HeadingTruncation.tsx +12 -2
- package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/LayoutContent/LayoutContentBasic.tsx +1 -1
- package/assets/templates/blocks/components/LayoutContent/LayoutContentShowcase.tsx +1 -1
- package/assets/templates/blocks/components/LayoutFooter/LayoutFooterActions.tsx +17 -3
- package/assets/templates/blocks/components/LayoutFooter/LayoutFooterShowcase.tsx +17 -3
- package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderShowcase.tsx +15 -3
- package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderWithActions.tsx +9 -2
- package/assets/templates/blocks/components/LayoutPanel/LayoutPanelNavigation.tsx +1 -1
- package/assets/templates/blocks/components/LayoutPanel/LayoutPanelShowcase.tsx +1 -1
- package/assets/templates/blocks/components/MoreMenu/MoreMenuBottomSheet.tsx +1 -1
- package/assets/templates/blocks/components/MultiSelector/MultiSelectorGhostToolbar.tsx +14 -2
- package/assets/templates/blocks/components/Outline/OutlineDensity.tsx +2 -0
- package/assets/templates/blocks/components/OverflowList/OverflowListShowcase.tsx +6 -1
- package/assets/templates/blocks/components/Pagination/PaginationVariants.tsx +4 -0
- package/assets/templates/blocks/components/Popover/PopoverHookUsage.tsx +17 -2
- package/assets/templates/blocks/components/SegmentedControl/SegmentedControlFillLayout.tsx +1 -1
- package/assets/templates/blocks/components/Selector/SelectorGhostToolbar.tsx +14 -2
- package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +8 -1
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +2 -2
- package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -0
- package/assets/templates/blocks/components/Switch/SwitchWithStatus.tsx +1 -1
- package/assets/templates/blocks/components/TabList/TabListTabsFillLayout.tsx +1 -1
- package/assets/templates/blocks/components/TabList/TabListTabsWithActions.tsx +12 -1
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +11 -1
- package/assets/templates/blocks/components/Table/TableInCard.tsx +2 -2
- package/assets/templates/blocks/components/Text/TextTruncation.tsx +1 -1
- package/assets/templates/blocks/components/Text/TextWordBreak.tsx +12 -2
- package/assets/templates/blocks/components/Text/TextWrap.tsx +19 -4
- package/assets/templates/blocks/components/TextArea/TextAreaCharacterCount.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaShowcase.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaStates.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaValidation.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaWithIcon.tsx +1 -1
- package/assets/templates/blocks/components/TextInput/TextInputStatusVariant.tsx +2 -2
- package/assets/templates/blocks/components/Timestamp/TimestampAutoFormat.tsx +15 -1
- package/assets/templates/blocks/components/Timestamp/TimestampRelativeFormat.tsx +15 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.tsx +8 -0
- package/assets/templates/blocks/components/Toolbar/ToolbarSizes.tsx +12 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.tsx +18 -3
- package/assets/templates/blocks/components/TopNav/TopNavCenteredNavigation.tsx +6 -0
- package/assets/templates/blocks/components/TopNav/TopNavEnterpriseDashboard.tsx +7 -1
- package/assets/templates/blocks/components/TopNav/TopNavMegaMenu.tsx +2 -2
- package/assets/templates/blocks/components/TopNav/TopNavShowcase.tsx +9 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +102 -6
- package/assets/templates/pages/canvas-editor/page.tsx +73 -2
- package/assets/templates/pages/centered-hero/page.tsx +10 -4
- package/assets/templates/pages/course-detail/page.tsx +46 -2
- package/assets/templates/pages/dashboard/page.tsx +45 -16
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +31 -20
- package/assets/templates/pages/dashboard-comparison/page.tsx +9 -0
- package/assets/templates/pages/dashboard-composition/page.tsx +22 -9
- package/assets/templates/pages/dashboard-progress/page.tsx +27 -15
- package/assets/templates/pages/dashboard-scorecard/page.tsx +9 -0
- package/assets/templates/pages/detail-page/page.tsx +105 -77
- package/assets/templates/pages/documentation/page.tsx +15 -2
- package/assets/templates/pages/documentation-design/page.tsx +7 -34
- package/assets/templates/pages/documentation-technical/page.tsx +76 -12
- package/assets/templates/pages/editor/page.tsx +26 -21
- package/assets/templates/pages/file-explorer/page.tsx +35 -1
- package/assets/templates/pages/form-two-column/page.tsx +2 -3
- package/assets/templates/pages/form-wizard/page.tsx +31 -3
- package/assets/templates/pages/form-wizard-vertical/page.tsx +32 -3
- package/assets/templates/pages/gallery-hero/page.tsx +2 -1
- package/assets/templates/pages/ide/page.tsx +15 -1
- package/assets/templates/pages/incident-console/page.tsx +2 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +1 -1
- package/assets/templates/pages/kanban-board/page.tsx +39 -2
- package/assets/templates/pages/payment-form/page.tsx +77 -39
- package/assets/templates/pages/product-gallery/page.tsx +16 -14
- package/assets/templates/pages/settings/page.tsx +35 -3
- package/assets/templates/pages/settings-dialog/page.tsx +34 -5
- package/assets/templates/pages/settings-sidebar/page.tsx +23 -3
- package/assets/templates/pages/shell-nav/page.tsx +28 -12
- package/assets/templates/pages/shell-side-nav/page.tsx +16 -1
- package/assets/templates/pages/shell-top-nav/page.tsx +27 -1
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -1
- package/assets/templates/pages/table/template.doc.mjs +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/page.tsx +1 -1
- package/assets/templates/pages/table-filter/page.tsx +9 -2
- package/assets/templates/pages/table-grouped/page.tsx +16 -6
- package/assets/templates/pages/table-inbox/page.tsx +60 -1
- package/assets/templates/pages/table-page/page.tsx +10 -2
- package/assets/templates/pages/table-tree/page.tsx +95 -13
- package/assets/templates/pages/theme-showcase/page.tsx +107 -11
- package/assets/templates/pages/work-item-detail/page.tsx +88 -74
- package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -1
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/gothic/gothicTheme.ts +5 -0
- package/assets/templates/themes/neutral/neutralTheme.ts +1 -1
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +22 -8
- package/authoring/doctypes/_schema.mjs +31 -0
- package/authoring/doctypes/command/command.doc.mjs +24 -0
- package/authoring/doctypes/command/type.ts +31 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -5
- package/authoring/doctypes/namespace/namespace.doc.mjs +6 -0
- package/authoring/doctypes/namespace/type.ts +4 -0
- package/authoring/doctypes/template/type.ts +0 -7
- package/authoring/index.d.ts +6 -1
- package/authoring/integration/integration.doc.mjs +7 -0
- package/authoring/integration/schema.d.mts +6 -0
- package/authoring/integration/schema.mjs +3 -0
- package/authoring/integration/type.ts +34 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/component.mjs +5 -1
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/experimental/index.mjs +4 -1
- package/clients/cli/commands/experimental/theme.mjs +139 -64
- package/clients/cli/commands/experimental-render.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-add.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-template.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-use.doc.mjs +2 -0
- package/clients/cli/commands/gap-report.doc.mjs +1 -0
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +1 -1
- package/clients/cli/commands/integration-add.doc.mjs +1 -0
- package/clients/cli/commands/manifest.mjs +10 -3
- package/clients/cli/commands/swizzle.doc.mjs +8 -1
- package/clients/cli/commands/swizzle.mjs +13 -6
- package/clients/cli/commands/template.doc.mjs +3 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +2 -1
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
- package/clients/cli/commands/theme-remove.doc.mjs +2 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -0
- package/clients/cli/commands/theme-use.doc.mjs +2 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +21 -5
- package/clients/cli/index.mjs +167 -59
- package/clients/cli/lib/base-gate.mjs +522 -0
- package/clients/cli/lib/command-path.mjs +26 -0
- package/clients/cli/lib/define-command.mjs +161 -12
- package/clients/cli/lib/json-shim.mjs +34 -31
- package/clients/cli/lib/manifest.d.ts +14 -0
- package/clients/cli/lib/manifest.mjs +78 -22
- package/clients/cli/lib/root-args.mjs +79 -0
- package/clients/cli/lib/stray-option.mjs +21 -8
- package/clients/cli/lib/unknown-command.mjs +27 -6
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +13 -1
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core-docs.d.mts +10 -0
- package/foundation/bases/core-docs.mjs +42 -0
- package/foundation/bases/core.d.mts +11 -0
- package/foundation/bases/core.mjs +32 -0
- package/foundation/bases/requirements.d.mts +128 -0
- package/foundation/bases/requirements.mjs +193 -0
- package/foundation/bases/resolve.d.mts +134 -0
- package/foundation/bases/resolve.mjs +295 -0
- package/foundation/bases/state.d.mts +24 -0
- package/foundation/bases/state.mjs +46 -0
- package/foundation/bases/steps.d.mts +49 -0
- package/foundation/bases/steps.mjs +88 -0
- package/foundation/config/project.d.mts +14 -0
- package/foundation/config/project.mjs +68 -1
- package/foundation/discovery/cli-self-docs.mjs +9 -1
- package/foundation/discovery/command-pointers.d.mts +28 -0
- package/foundation/discovery/command-pointers.mjs +31 -0
- package/foundation/discovery/component-discovery.d.mts +9 -8
- package/foundation/discovery/component-discovery.mjs +9 -4
- package/foundation/discovery/docs-discovery.d.mts +13 -5
- package/foundation/discovery/docs-discovery.mjs +25 -6
- package/foundation/discovery/hook-discovery.d.mts +6 -6
- package/foundation/discovery/hook-discovery.mjs +6 -4
- package/foundation/discovery/template-adapter.mjs +5 -0
- package/foundation/discovery/template-ids.d.mts +1 -1
- package/foundation/discovery/template-ids.mjs +5 -1
- package/foundation/discovery/theme-discovery.mjs +3 -0
- package/foundation/discovery/theme-imports.mjs +19 -1
- package/foundation/doc-compiler/tree.d.mts +4 -2
- package/foundation/doc-compiler/tree.mjs +46 -1
- package/foundation/env/package-manager.d.mts +7 -0
- package/foundation/env/package-manager.mjs +21 -0
- package/foundation/fonts/font-stylesheet.d.mts +8 -0
- package/foundation/fonts/font-stylesheet.mjs +26 -2
- package/foundation/fs/gather-cache.mjs +44 -13
- package/foundation/fs/own-modules.d.mts +29 -0
- package/foundation/fs/own-modules.mjs +57 -0
- package/foundation/fs/paths.d.mts +30 -2
- package/foundation/fs/paths.mjs +49 -2
- package/foundation/integrations/integrations.d.mts +4 -0
- package/foundation/integrations/integrations.mjs +6 -1
- package/foundation/release/choose.d.mts +7 -0
- package/foundation/release/choose.mjs +16 -2
- package/foundation/release/notices.d.mts +26 -0
- package/foundation/release/notices.mjs +48 -19
- package/foundation/release/project.d.mts +3 -2
- package/foundation/release/project.mjs +4 -5
- package/foundation/release/run-context.d.mts +7 -2
- package/foundation/release/run-context.mjs +6 -2
- package/foundation/render/css-cut.mjs +86 -6
- package/foundation/render/cut-short.d.mts +35 -0
- package/foundation/render/cut-short.mjs +124 -0
- package/foundation/render/font-probe.d.mts +27 -0
- package/foundation/render/font-probe.mjs +77 -0
- package/foundation/render/layers.d.mts +1 -9
- package/foundation/render/layers.mjs +2 -111
- package/foundation/render/page-worker.mjs +83 -6
- package/foundation/render/picture-chrome.mjs +24 -2
- package/foundation/render/picture-playwright.mjs +22 -2
- package/foundation/render/picture-window.d.mts +20 -4
- package/foundation/render/picture-window.mjs +137 -4
- package/foundation/response/base.d.ts +25 -0
- package/foundation/response/error-codes.d.mts +4 -1
- package/foundation/response/error-codes.d.ts +4 -1
- package/foundation/response/error-codes.doc.mjs +17 -0
- package/foundation/response/error-codes.mjs +21 -0
- package/foundation/response/json.d.mts +3 -1
- package/foundation/response/json.mjs +7 -2
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/suggest/name-index.d.mts +2 -1
- package/foundation/suggest/name-index.mjs +1 -1
- package/foundation/suggest/other-command.d.mts +4 -1
- package/foundation/suggest/other-command.mjs +23 -6
- package/foundation/text/string-utils.d.mts +7 -2
- package/foundation/text/string-utils.mjs +24 -10
- package/package.json +6 -6
- package/assets/templates/pages/access-denied/page.tsx +0 -101
- package/assets/templates/pages/access-denied/template.doc.mjs +0 -24
- package/assets/templates/pages/error-page/page.tsx +0 -130
- package/assets/templates/pages/error-page/template.doc.mjs +0 -22
- package/assets/templates/pages/not-found/page.tsx +0 -124
- package/assets/templates/pages/not-found/template.doc.mjs +0 -30
- package/assets/templates/pages/review-workspace/page.tsx +0 -551
- package/assets/templates/pages/review-workspace/template.doc.mjs +0 -31
- package/assets/templates/pages/run-console/page.tsx +0 -945
- package/assets/templates/pages/run-console/template.doc.mjs +0 -27
- package/assets/templates/pages/welcome-portal/page.tsx +0 -538
- package/assets/templates/pages/welcome-portal/template.doc.mjs +0 -38
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The run's base on the Commander side: which commands and options
|
|
5
|
+
* help lists, the line that counts the hidden ones, and the one requirement
|
|
6
|
+
* check that runs before any command body.
|
|
7
|
+
* @input the program and the run's base resolution
|
|
8
|
+
* @output help filters, help text, and the preAction check
|
|
9
|
+
* @position clients/cli/lib — the CLI side of foundation/bases
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {Help} from 'commander';
|
|
13
|
+
import {requestedBase, runBase} from '../../../foundation/bases/resolve.mjs';
|
|
14
|
+
import {
|
|
15
|
+
formatCliCommand,
|
|
16
|
+
quoteCommandArgument,
|
|
17
|
+
} from '../../../foundation/env/package-manager.mjs';
|
|
18
|
+
import {
|
|
19
|
+
checkRequirements,
|
|
20
|
+
isAvailable,
|
|
21
|
+
longFlag,
|
|
22
|
+
missingSteps,
|
|
23
|
+
refusalLine,
|
|
24
|
+
} from '../../../foundation/bases/requirements.mjs';
|
|
25
|
+
import {isJsonMode, jsonError} from '../../../foundation/response/json.mjs';
|
|
26
|
+
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
27
|
+
import {setOutcome} from '../../../foundation/debug/index.mjs';
|
|
28
|
+
import {cliError} from './cli-error.mjs';
|
|
29
|
+
import {isOutsideProject} from '../../../foundation/env/project-scope.mjs';
|
|
30
|
+
import {
|
|
31
|
+
commandDocsOf,
|
|
32
|
+
servedDescription,
|
|
33
|
+
servedOptionDescription,
|
|
34
|
+
setHelpExampleFilter,
|
|
35
|
+
} from './define-command.mjs';
|
|
36
|
+
import {commandPath} from './command-path.mjs';
|
|
37
|
+
|
|
38
|
+
/** @typedef {import('commander').Command} Command */
|
|
39
|
+
/** @typedef {import('../../../foundation/bases/resolve.mjs').ActiveBase} ActiveBase */
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The base help and the manifest read: the run's base, or null when it does
|
|
43
|
+
* not resolve. The run then fails before any work, and help lists
|
|
44
|
+
* everything.
|
|
45
|
+
* @returns {ActiveBase | null}
|
|
46
|
+
*/
|
|
47
|
+
export function helpBase() {
|
|
48
|
+
try {
|
|
49
|
+
const resolution = runBase();
|
|
50
|
+
return resolution.ok ? resolution.base : null;
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Subcommands that are commands, without Commander's own `help`.
|
|
58
|
+
* @param {Command} cmd
|
|
59
|
+
* @returns {Command[]}
|
|
60
|
+
*/
|
|
61
|
+
function childCommands(cmd) {
|
|
62
|
+
return (cmd.commands ?? []).filter(child => child.name() !== 'help');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Is a command available on `base`? A command that only groups subcommands
|
|
67
|
+
* is available when any of its subcommands is.
|
|
68
|
+
* @param {Command} cmd
|
|
69
|
+
* @param {ActiveBase | null} base
|
|
70
|
+
* @returns {boolean}
|
|
71
|
+
*/
|
|
72
|
+
export function commandAvailable(cmd, base) {
|
|
73
|
+
if (base == null || base.core) return true;
|
|
74
|
+
return isAvailable(
|
|
75
|
+
base,
|
|
76
|
+
commandDocsOf(cmd)?.doc.requires,
|
|
77
|
+
childCommands(cmd).map(child => commandAvailable(child, base)),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Is an option available on `base`?
|
|
83
|
+
* @param {Command} cmd
|
|
84
|
+
* @param {import('commander').Option} option
|
|
85
|
+
* @param {ActiveBase | null} base
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/
|
|
88
|
+
export function optionAvailable(cmd, option, base) {
|
|
89
|
+
if (base == null || base.core) return true;
|
|
90
|
+
const declared = (commandDocsOf(cmd)?.doc.options ?? []).find(
|
|
91
|
+
o => longFlag(o.flag) === option.long,
|
|
92
|
+
);
|
|
93
|
+
return isAvailable(base, declared?.requires);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A command's description as help prints it: a pointer to a command the
|
|
98
|
+
* run's base does not serve is left out.
|
|
99
|
+
* @param {Command} cmd
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
export function servedHelpDescription(cmd) {
|
|
103
|
+
return servedText(cmd, served => servedDescription(cmd, served), cmd.description());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* An option's description as help prints it: a pointer to a command the
|
|
108
|
+
* run's base does not serve is left out.
|
|
109
|
+
* @param {Command} cmd the command that holds the option
|
|
110
|
+
* @param {import('commander').Option} option
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
export function servedHelpOptionDescription(cmd, option) {
|
|
114
|
+
return servedText(
|
|
115
|
+
cmd,
|
|
116
|
+
served => servedOptionDescription(option, served),
|
|
117
|
+
option.description ?? '',
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Text with the parts that name a command the run's base does not serve left
|
|
123
|
+
* out; the whole text on Core.
|
|
124
|
+
* @param {Command} cmd the command the text belongs to
|
|
125
|
+
* @param {(served: (path: string) => boolean) => string} read
|
|
126
|
+
* @param {string} whole
|
|
127
|
+
* @returns {string}
|
|
128
|
+
*/
|
|
129
|
+
function servedText(cmd, read, whole) {
|
|
130
|
+
const base = helpBase();
|
|
131
|
+
if (base == null || base.core) return whole;
|
|
132
|
+
/** @type {Command} */
|
|
133
|
+
let root = cmd;
|
|
134
|
+
while (root.parent) root = root.parent;
|
|
135
|
+
return read(path => exampleAvailable(root, path, base));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The subcommands of `cmd` that people and agents see, `help` aside: listed,
|
|
140
|
+
* and served by the run's base. Every list a suggestion names reads this.
|
|
141
|
+
* @param {{commands?: readonly any[]}} cmd
|
|
142
|
+
* @returns {any[]}
|
|
143
|
+
*/
|
|
144
|
+
export function servedSubcommands(cmd) {
|
|
145
|
+
const base = helpBase();
|
|
146
|
+
return (cmd.commands ?? []).filter(
|
|
147
|
+
c => !c._hidden && c.name() !== 'help' && commandAvailable(c, base),
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Help settings that list only what the run's base serves. Passed to the
|
|
153
|
+
* root's `configureHelp`, so every subcommand inherits them.
|
|
154
|
+
* @returns {Partial<import('commander').Help>}
|
|
155
|
+
*/
|
|
156
|
+
export function baseHelpSettings() {
|
|
157
|
+
return {
|
|
158
|
+
commandDescription(cmd) {
|
|
159
|
+
return servedHelpDescription(cmd);
|
|
160
|
+
},
|
|
161
|
+
subcommandDescription(cmd) {
|
|
162
|
+
return cmd.summary() || servedHelpDescription(cmd);
|
|
163
|
+
},
|
|
164
|
+
visibleCommands(cmd) {
|
|
165
|
+
const visible = Help.prototype.visibleCommands.call(this, cmd);
|
|
166
|
+
const base = helpBase();
|
|
167
|
+
return visible.filter(child => commandAvailable(child, base));
|
|
168
|
+
},
|
|
169
|
+
visibleOptions(cmd) {
|
|
170
|
+
const visible = Help.prototype.visibleOptions.call(this, cmd);
|
|
171
|
+
const base = helpBase();
|
|
172
|
+
return visible
|
|
173
|
+
.filter(option => optionAvailable(cmd, option, base))
|
|
174
|
+
.map(option => {
|
|
175
|
+
const shown = servedHelpOptionDescription(cmd, option);
|
|
176
|
+
// Help reads the description, choices, and default from the option.
|
|
177
|
+
return shown === option.description
|
|
178
|
+
? option
|
|
179
|
+
: Object.assign(Object.create(option), {description: shown});
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* What help leaves out under one command: the commands at any depth below
|
|
187
|
+
* it, and its own options.
|
|
188
|
+
* @param {Command} cmd
|
|
189
|
+
* @param {ActiveBase} base
|
|
190
|
+
* @returns {{commands: number, options: number}}
|
|
191
|
+
*/
|
|
192
|
+
function hiddenIn(cmd, base) {
|
|
193
|
+
/** @param {Command} group @returns {number} hidden commands at any depth */
|
|
194
|
+
const hiddenBelow = group =>
|
|
195
|
+
childCommands(group)
|
|
196
|
+
.filter(child => !(/** @type {any} */ (child)._hidden))
|
|
197
|
+
.reduce((total, child) => {
|
|
198
|
+
const children = childCommands(child);
|
|
199
|
+
if (children.length > 0) return total + hiddenBelow(child);
|
|
200
|
+
return total + (commandAvailable(child, base) ? 0 : 1);
|
|
201
|
+
}, 0);
|
|
202
|
+
const commands = hiddenBelow(cmd);
|
|
203
|
+
const options = (cmd.options ?? []).filter(
|
|
204
|
+
option => !option.hidden && !optionAvailable(cmd, option, base),
|
|
205
|
+
).length;
|
|
206
|
+
return {commands, options};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param {number} n
|
|
211
|
+
* @param {string} noun
|
|
212
|
+
* @returns {string}
|
|
213
|
+
*/
|
|
214
|
+
function count(n, noun) {
|
|
215
|
+
return `${n} ${noun}${n === 1 ? '' : 's'}`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Add the help text the base decides: a first line on a hidden command's own
|
|
220
|
+
* help that names the step it needs, and a last line that counts what help
|
|
221
|
+
* left out.
|
|
222
|
+
* @param {Command} program
|
|
223
|
+
*/
|
|
224
|
+
export function addBaseHelpText(program) {
|
|
225
|
+
program.addHelpText('beforeAll', ({command}) => {
|
|
226
|
+
const base = helpBase();
|
|
227
|
+
if (
|
|
228
|
+
base == null ||
|
|
229
|
+
command === program ||
|
|
230
|
+
commandAvailable(command, base)
|
|
231
|
+
) {
|
|
232
|
+
return '';
|
|
233
|
+
}
|
|
234
|
+
const requires = commandDocsOf(command)?.doc.requires ?? [];
|
|
235
|
+
const missing = missingSteps(base, requires);
|
|
236
|
+
if (missing.length === 0) {
|
|
237
|
+
return `astryx ${commandPath(command)} needs steps the active base ${base.name} does not provide.\n`;
|
|
238
|
+
}
|
|
239
|
+
return `${refusalLine({
|
|
240
|
+
command: commandPath(command),
|
|
241
|
+
option: null,
|
|
242
|
+
argument: null,
|
|
243
|
+
requires,
|
|
244
|
+
missing,
|
|
245
|
+
reason: 'not-declared',
|
|
246
|
+
module: null,
|
|
247
|
+
base: {name: base.name, version: base.version},
|
|
248
|
+
})}\n`;
|
|
249
|
+
});
|
|
250
|
+
program.addHelpText('afterAll', ({command}) => {
|
|
251
|
+
const base = helpBase();
|
|
252
|
+
if (base == null || base.core) return '';
|
|
253
|
+
const hidden = hiddenIn(command, base);
|
|
254
|
+
if (hidden.commands + hidden.options === 0) return '';
|
|
255
|
+
const what = [
|
|
256
|
+
hidden.commands > 0 ? count(hidden.commands, 'command') : null,
|
|
257
|
+
hidden.options > 0 ? count(hidden.options, 'option') : null,
|
|
258
|
+
]
|
|
259
|
+
.filter(Boolean)
|
|
260
|
+
.join(' and ');
|
|
261
|
+
return `\n${what} hidden: the active base ${base.name} does not provide the steps they need.`;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The long flags a run gave a command on its command line.
|
|
267
|
+
* @param {Command} cmd
|
|
268
|
+
* @returns {Set<string>}
|
|
269
|
+
*/
|
|
270
|
+
function givenOptions(cmd) {
|
|
271
|
+
/** @type {Set<string>} */
|
|
272
|
+
const given = new Set();
|
|
273
|
+
for (const option of cmd.options ?? []) {
|
|
274
|
+
const source = cmd.getOptionValueSource?.(option.attributeName());
|
|
275
|
+
if (source === 'cli' && option.long) given.add(option.long);
|
|
276
|
+
}
|
|
277
|
+
return given;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Refuse a run whose base resolution failed, before any work.
|
|
282
|
+
* @param {{code: string, message: string}} failure
|
|
283
|
+
* @param {Command} [cmd] the command that runs, for a suggestion
|
|
284
|
+
* @returns {never}
|
|
285
|
+
*/
|
|
286
|
+
function refuseResolution(failure, cmd) {
|
|
287
|
+
const suggestions =
|
|
288
|
+
failure.code === ERROR_CODES.ERR_BASE_NOT_FOUND && cmd != null
|
|
289
|
+
? baseAsOption(cmd)
|
|
290
|
+
: undefined;
|
|
291
|
+
return cliError(failure.message, {code: failure.code, suggestions});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The run as meant when `--base` names no installed package and the command
|
|
296
|
+
* has an option whose value names an item, such as the theme editor's
|
|
297
|
+
* `--like <theme>`: the same words, with the `--base` value given to that
|
|
298
|
+
* option.
|
|
299
|
+
* @param {Command} cmd the command that runs
|
|
300
|
+
* @returns {Array<{name: string, reason: string}> | undefined}
|
|
301
|
+
*/
|
|
302
|
+
function baseAsOption(cmd) {
|
|
303
|
+
const value = requestedBase();
|
|
304
|
+
const option = (commandDocsOf(cmd)?.doc.options ?? []).find(o => o.names);
|
|
305
|
+
if (value == null || option == null) return undefined;
|
|
306
|
+
const long = longFlag(option.flag);
|
|
307
|
+
if (long == null) return undefined;
|
|
308
|
+
const words = process.argv.slice(2);
|
|
309
|
+
const at = words.findIndex(w => w === '--base' || w.startsWith('--base='));
|
|
310
|
+
if (at < 0) return undefined;
|
|
311
|
+
const width = words[at] === '--base' ? 2 : 1;
|
|
312
|
+
const rest = [...words.slice(0, at), ...words.slice(at + width)];
|
|
313
|
+
// The option goes where --base was, unless that is before the command's
|
|
314
|
+
// own words: the command reads its options after them.
|
|
315
|
+
const path = commandPath(cmd).split(' ');
|
|
316
|
+
let matched = 0;
|
|
317
|
+
let commandEnd = 0;
|
|
318
|
+
for (let i = 0; i < rest.length && matched < path.length; i += 1) {
|
|
319
|
+
if (rest[i] === path[matched]) {
|
|
320
|
+
matched += 1;
|
|
321
|
+
commandEnd = i + 1;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const after = Math.max(at, commandEnd);
|
|
325
|
+
// A suggested run is printed without the output mode, as every refusal's
|
|
326
|
+
// lines are.
|
|
327
|
+
const meant = [...rest.slice(0, after), long, value, ...rest.slice(after)].filter(
|
|
328
|
+
w => w !== '--json',
|
|
329
|
+
);
|
|
330
|
+
return [
|
|
331
|
+
{
|
|
332
|
+
name: formatCliCommand(
|
|
333
|
+
['astryx', ...meant.map(w => quoteCommandArgument(w))].join(' '),
|
|
334
|
+
),
|
|
335
|
+
reason: `if ${value} is a ${option.names}, ${long} takes it`,
|
|
336
|
+
},
|
|
337
|
+
];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Refuse a run the base cannot serve: one line in text, the error envelope
|
|
342
|
+
* with `requirement` in JSON, exit 1, nothing written.
|
|
343
|
+
* @param {import('../../../foundation/bases/requirements.mjs').Requirement} requirement
|
|
344
|
+
* @returns {never}
|
|
345
|
+
*/
|
|
346
|
+
function refuseRequirement(requirement) {
|
|
347
|
+
const line = refusalLine(requirement);
|
|
348
|
+
setOutcome('rejected', {
|
|
349
|
+
exitCode: 1,
|
|
350
|
+
code: ERROR_CODES.ERR_BASE_CAPABILITY,
|
|
351
|
+
});
|
|
352
|
+
if (isJsonMode()) {
|
|
353
|
+
const {module, ...published} = requirement;
|
|
354
|
+
jsonError(line, undefined, ERROR_CODES.ERR_BASE_CAPABILITY, undefined, {
|
|
355
|
+
requirement: module == null ? published : {...published, module},
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
console.error(`Error: ${line}`);
|
|
359
|
+
process.exit(1);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Does the command's own refusal outside a project come before the check?
|
|
364
|
+
* A command that declares `refuse` refuses in a folder no project encloses,
|
|
365
|
+
* and that refusal wins over every base check.
|
|
366
|
+
* @param {import('@astryxdesign/cli/authoring').CommandDoc | undefined} doc
|
|
367
|
+
* @param {string} cwd
|
|
368
|
+
* @returns {boolean}
|
|
369
|
+
*/
|
|
370
|
+
export function refusesHereFirst(doc, cwd) {
|
|
371
|
+
return doc?.outsideProject === 'refuse' && isOutsideProject(cwd);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Every step the commands below a group declare.
|
|
376
|
+
* @param {Command} group
|
|
377
|
+
* @returns {string[]}
|
|
378
|
+
*/
|
|
379
|
+
function stepsBelow(group) {
|
|
380
|
+
return childCommands(group).flatMap(child => [
|
|
381
|
+
...(commandDocsOf(child)?.doc.requires ?? []),
|
|
382
|
+
...stepsBelow(child),
|
|
383
|
+
]);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** The adapters the check loaded for the running command. */
|
|
387
|
+
let checkedAdapters =
|
|
388
|
+
/** @type {Record<string, Record<string, unknown>>} */ ({});
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The adapters of the run's base that the check loaded, by capability. A
|
|
392
|
+
* command calls the active base's steps through this, never through a
|
|
393
|
+
* lookup of its own.
|
|
394
|
+
* @returns {Record<string, Record<string, unknown>>}
|
|
395
|
+
*/
|
|
396
|
+
export function runAdapters() {
|
|
397
|
+
return checkedAdapters;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* The check, as a preAction hook: resolve the run's base, then check the
|
|
402
|
+
* command, each given option, and each given argument value against it.
|
|
403
|
+
* The first failure ends the run.
|
|
404
|
+
* @param {Command} program
|
|
405
|
+
* @param {Command} actionCommand
|
|
406
|
+
* @returns {Promise<void>}
|
|
407
|
+
*/
|
|
408
|
+
export async function checkRun(program, actionCommand) {
|
|
409
|
+
checkedAdapters = {};
|
|
410
|
+
if (actionCommand === program) {
|
|
411
|
+
// A bare run declares no step, but it answers from the run's base.
|
|
412
|
+
const resolution = runBase();
|
|
413
|
+
if (!resolution.ok) refuseResolution(resolution);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const doc = commandDocsOf(actionCommand)?.doc;
|
|
417
|
+
if (refusesHereFirst(doc, process.cwd())) return;
|
|
418
|
+
const resolution = runBase();
|
|
419
|
+
if (!resolution.ok) refuseResolution(resolution, actionCommand);
|
|
420
|
+
const base = /** @type {ActiveBase} */ (resolution.base);
|
|
421
|
+
if (base.core) return;
|
|
422
|
+
// A group none of whose commands the base serves is a hidden name too.
|
|
423
|
+
if (!commandAvailable(actionCommand, base) && !doc?.requires?.length) {
|
|
424
|
+
const requires = [
|
|
425
|
+
...new Set(stepsBelow(actionCommand).filter(step => !base.steps.includes(step))),
|
|
426
|
+
];
|
|
427
|
+
refuseRequirement({
|
|
428
|
+
command: commandPath(actionCommand),
|
|
429
|
+
option: null,
|
|
430
|
+
argument: null,
|
|
431
|
+
requires,
|
|
432
|
+
missing: requires,
|
|
433
|
+
reason: 'not-declared',
|
|
434
|
+
module: null,
|
|
435
|
+
base: {name: base.name, version: base.version},
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const name = commandPath(actionCommand);
|
|
439
|
+
const verdict = await checkRequirements(
|
|
440
|
+
name,
|
|
441
|
+
doc,
|
|
442
|
+
{
|
|
443
|
+
options: givenOptions(actionCommand),
|
|
444
|
+
args: /** @type {Array<string | undefined>} */ (
|
|
445
|
+
(actionCommand.processedArgs ?? actionCommand.args ?? []).map(value =>
|
|
446
|
+
typeof value === 'string' ? value : undefined,
|
|
447
|
+
)
|
|
448
|
+
),
|
|
449
|
+
},
|
|
450
|
+
base,
|
|
451
|
+
);
|
|
452
|
+
if (!verdict.ok) refuseRequirement(verdict.requirement);
|
|
453
|
+
else checkedAdapters = verdict.adapters;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The argument a positional value fills: the one at its position, else a
|
|
458
|
+
* last variadic argument, which takes every value after it.
|
|
459
|
+
* @param {import('@astryxdesign/cli/authoring').CommandArgDoc[]} args
|
|
460
|
+
* @param {number} position
|
|
461
|
+
* @returns {import('@astryxdesign/cli/authoring').CommandArgDoc | undefined}
|
|
462
|
+
*/
|
|
463
|
+
function argumentAt(args, position) {
|
|
464
|
+
const last = args.at(-1);
|
|
465
|
+
return args[position] ?? (last?.variadic ? last : undefined);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Is an example value a placeholder in usage syntax, such as `<Name>` or
|
|
470
|
+
* `[path]`, rather than a value?
|
|
471
|
+
* @param {string} token
|
|
472
|
+
* @returns {boolean}
|
|
473
|
+
*/
|
|
474
|
+
function isPlaceholder(token) {
|
|
475
|
+
return token.startsWith('<') || token.startsWith('[');
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Does an example invocation name only commands, options, and argument
|
|
480
|
+
* values `base` serves?
|
|
481
|
+
* @param {Command} root the program
|
|
482
|
+
* @param {string} cli the example, such as `astryx template --cdn`
|
|
483
|
+
* @param {ActiveBase | null} base
|
|
484
|
+
* @returns {boolean}
|
|
485
|
+
*/
|
|
486
|
+
export function exampleAvailable(root, cli, base) {
|
|
487
|
+
if (base == null || base.core) return true;
|
|
488
|
+
const tokens = cli.trim().split(/\s+/);
|
|
489
|
+
if (tokens[0] === 'astryx') tokens.shift();
|
|
490
|
+
let cmd = root;
|
|
491
|
+
let positional = 0;
|
|
492
|
+
for (const token of tokens) {
|
|
493
|
+
if (token.startsWith('-')) {
|
|
494
|
+
const flag = token.split('=')[0];
|
|
495
|
+
const option = (cmd.options ?? []).find(
|
|
496
|
+
o => o.long === flag || o.short === flag,
|
|
497
|
+
);
|
|
498
|
+
if (option && !optionAvailable(cmd, option, base)) return false;
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
const child = childCommands(cmd).find(c => c.name() === token);
|
|
502
|
+
if (child && positional === 0) {
|
|
503
|
+
if (!commandAvailable(child, base)) return false;
|
|
504
|
+
cmd = child;
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
const arg = argumentAt(commandDocsOf(cmd)?.doc.args ?? [], positional);
|
|
508
|
+
if (!isAvailable(base, arg?.requires?.[token])) return false;
|
|
509
|
+
// A value of an argument that names an item names one of Core's items,
|
|
510
|
+
// which this base does not have.
|
|
511
|
+
if (arg?.names != null && !isPlaceholder(token)) return false;
|
|
512
|
+
positional += 1;
|
|
513
|
+
}
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
setHelpExampleFilter((cmd, cli) => {
|
|
518
|
+
/** @type {Command} */
|
|
519
|
+
let root = cmd;
|
|
520
|
+
while (root.parent) root = root.parent;
|
|
521
|
+
return exampleAvailable(root, cli, helpBase());
|
|
522
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The full path of a command after `astryx`, such as `theme build`.
|
|
5
|
+
* @input a Commander command
|
|
6
|
+
* @output commandPath()
|
|
7
|
+
* @position clients/cli/lib — the one walk from a command up to the root
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The full path of a command after `astryx`, such as `theme build`. The root
|
|
12
|
+
* program's path is ''.
|
|
13
|
+
* @param {import('commander').Command} cmd
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function commandPath(cmd) {
|
|
17
|
+
/** @type {string[]} */
|
|
18
|
+
const parts = [];
|
|
19
|
+
/** @type {import('commander').Command | null} */
|
|
20
|
+
let node = cmd;
|
|
21
|
+
while (node?.parent) {
|
|
22
|
+
parts.unshift(node.name());
|
|
23
|
+
node = node.parent;
|
|
24
|
+
}
|
|
25
|
+
return parts.join(' ');
|
|
26
|
+
}
|