@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0404a74
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 +76 -86
- package/api/build/_adapter.d.mts +17 -0
- package/api/build/_adapter.mjs +53 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +6 -4
- package/api/build/kit/rank.mjs +132 -28
- package/api/build/kit/signals.d.mts +7 -1
- package/api/build/kit/signals.mjs +21 -10
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +14 -9
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +351 -46
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +86 -0
- package/api/build/kit/words.mjs +241 -1
- package/api/build/tree.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +5 -6
- package/api/component/_adapter.d.mts +26 -2
- package/api/component/_adapter.mjs +135 -8
- package/api/component/component.mjs +14 -1
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +11 -1
- package/api/discover/_adapter.mjs +95 -1
- package/api/discover/detail/item/item.mjs +5 -0
- package/api/discover/discover.mjs +12 -3
- package/api/discover/discover.type.d.mts +16 -3
- package/api/discover/discover.type.mjs +13 -3
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +57 -2
- package/api/docs/_adapter.mjs +266 -33
- package/api/docs/_entry-names-lazily.d.mts +22 -0
- package/api/docs/_entry-names-lazily.mjs +25 -0
- package/api/docs/_entry-names.d.mts +23 -0
- package/api/docs/_entry-names.mjs +105 -0
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +54 -5
- package/api/doctor/_adapter.mjs +162 -11
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +15 -3
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +31 -7
- package/api/doctor/theme-checks.d.mts +35 -3
- package/api/doctor/theme-checks.mjs +377 -29
- package/api/hook/_adapter.d.mts +10 -4
- package/api/hook/_adapter.mjs +41 -5
- package/api/hook/detail/detail.mjs +5 -2
- package/api/hook/detail/params/params.mjs +10 -3
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/add-helpers.mjs +10 -0
- package/api/integration/authoring-checks.mjs +11 -8
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/pack-check.mjs +16 -1
- package/api/integration/validate-integration.d.mts +18 -6
- package/api/integration/validate-integration.mjs +129 -15
- package/api/integration/validate-integration.type.d.mts +22 -0
- package/api/integration/validate-integration.type.mjs +2 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +53 -1
- package/api/render/render.type.mjs +32 -2
- package/api/search/ORDERING.md +2 -2
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.d.mts +9 -4
- package/api/search/_candidate-score.mjs +133 -46
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +14 -0
- package/api/search/_lexical.mjs +93 -11
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/template/_adapter.d.mts +16 -0
- package/api/template/_adapter.mjs +39 -2
- package/api/template/cdn/cdn.mjs +37 -8
- package/api/template/copy/copy.d.mts +6 -3
- package/api/template/copy/copy.mjs +40 -8
- package/api/template/template.doc.mjs +3 -3
- package/api/template/template.mjs +63 -11
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +1 -0
- package/api/theme/_adapter.d.mts +12 -1
- package/api/theme/_adapter.mjs +132 -13
- package/api/theme/_app-provider.d.mts +31 -0
- package/api/theme/_app-provider.mjs +135 -0
- package/api/theme/add/add.mjs +3 -1
- package/api/theme/build/build.d.mts +142 -1
- package/api/theme/build/build.mjs +692 -284
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +80 -5
- package/api/theme/build/font-warning.mjs +323 -55
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/build/null-values.d.mts +28 -0
- package/api/theme/build/null-values.mjs +191 -0
- package/api/theme/list/list.mjs +17 -1
- package/api/theme/remove/remove.d.mts +2 -1
- package/api/theme/remove/remove.mjs +7 -3
- package/api/theme/theme.type.d.mts +78 -1
- package/api/theme/theme.type.mjs +38 -2
- package/api/theme/themeAdd.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +8 -5
- package/api/theme-edit/_adapter.d.mts +116 -4
- package/api/theme-edit/_adapter.mjs +1058 -93
- package/api/theme-edit/_catalog.d.mts +46 -2
- package/api/theme-edit/_catalog.mjs +115 -14
- package/api/theme-edit/_check.d.mts +133 -24
- package/api/theme-edit/_check.mjs +3392 -531
- package/api/theme-edit/_color.d.mts +26 -0
- package/api/theme-edit/_color.mjs +92 -2
- package/api/theme-edit/_compiler.d.mts +5 -1
- package/api/theme-edit/_compiler.mjs +141 -17
- package/api/theme-edit/_context.d.mts +74 -6
- package/api/theme-edit/_context.mjs +468 -76
- package/api/theme-edit/_css.d.mts +21 -0
- package/api/theme-edit/_css.mjs +87 -14
- package/api/theme-edit/_edit.d.mts +74 -7
- package/api/theme-edit/_edit.mjs +4426 -319
- package/api/theme-edit/_how-commands.d.mts +76 -1
- package/api/theme-edit/_how-commands.mjs +793 -9
- package/api/theme-edit/_how-question.d.mts +97 -6
- package/api/theme-edit/_how-question.mjs +9184 -747
- package/api/theme-edit/_how.d.mts +5 -2
- package/api/theme-edit/_how.mjs +255 -46
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +322 -0
- package/api/theme-edit/_normal.mjs +1630 -0
- package/api/theme-edit/_palette.d.mts +49 -0
- package/api/theme-edit/_palette.mjs +180 -38
- package/api/theme-edit/_part-words.d.mts +39 -0
- package/api/theme-edit/_part-words.mjs +152 -0
- package/api/theme-edit/_parts.d.mts +55 -3
- package/api/theme-edit/_parts.mjs +421 -36
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +1108 -599
- package/api/theme-edit/_preview.d.mts +156 -19
- package/api/theme-edit/_preview.mjs +809 -180
- package/api/theme-edit/_project.d.mts +61 -1
- package/api/theme-edit/_project.mjs +177 -6
- package/api/theme-edit/_settings.d.mts +619 -48
- package/api/theme-edit/_settings.mjs +4910 -617
- package/api/theme-edit/_tables.d.mts +41 -0
- package/api/theme-edit/_tables.mjs +261 -41
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +34 -2
- package/api/theme-edit/theme-edit.type.mjs +18 -3
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/api/upgrade/upgrade.mjs +16 -1
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/integration-runner.mjs +1 -1
- package/assets/codemods/jscodeshift.d.ts +1 -1
- package/assets/codemods/run-codemod.mjs +151 -18
- package/assets/codemods/runner.mjs +1 -4
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -0
- package/assets/docs/theme.doc.dense.mjs +76 -7
- package/assets/docs/theme.doc.mjs +66 -2
- package/assets/docs/theme.doc.zh.mjs +51 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/render-pages.doc.mjs +46 -5
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs-routes.generated.json +1 -0
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/page.tsx +31 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +1 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +1 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-comparison/page.tsx +2 -2
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/page.tsx +1 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/page.tsx +60 -7
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/page.tsx +13 -13
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/page.tsx +14 -2
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/page.tsx +9 -0
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/form-wizard-vertical/page.tsx +23 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +33 -2
- package/assets/templates/pages/kanban-board/page.tsx +12 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/page.tsx +16 -0
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/page.tsx +19 -6
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/messaging-shell/template.doc.mjs +6 -0
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/payment-form/page.tsx +30 -4
- package/assets/templates/pages/product-detail/page.tsx +26 -2
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/page.tsx +162 -12
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/page.tsx +11 -3
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/page.tsx +9 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/page.tsx +161 -133
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/page.tsx +14 -1
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/page.tsx +47 -7
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +9 -2
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +9 -9
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +24 -1
- package/authoring/integration/schema.mjs +126 -4
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/discover.mjs +70 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +44 -6
- package/clients/cli/commands/doctor.mjs +84 -16
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +1032 -134
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +4 -4
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.doc.mjs +1 -1
- package/clients/cli/commands/template.mjs +15 -2
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-remove.doc.mjs +13 -5
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +849 -441
- package/clients/cli/commands/upgrade.mjs +46 -8
- package/clients/cli/index.mjs +9 -19
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +265 -29
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/lib/stray-option.mjs +478 -0
- package/clients/cli/lib/unknown-command.mjs +353 -0
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +26 -29
- package/foundation/config/theme-state.d.mts +31 -2
- package/foundation/config/theme-state.mjs +140 -8
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/cli-self-doc-names.d.mts +13 -0
- package/foundation/discovery/cli-self-doc-names.mjs +51 -0
- package/foundation/discovery/cli-self-docs.d.mts +0 -2
- package/foundation/discovery/cli-self-docs.mjs +2 -15
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +59 -10
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/core-theme-facts.d.mts +70 -0
- package/foundation/discovery/core-theme-facts.mjs +384 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/docs-discovery.d.mts +66 -9
- package/foundation/discovery/docs-discovery.mjs +126 -60
- package/foundation/discovery/entry-name-files.d.mts +106 -0
- package/foundation/discovery/entry-name-files.mjs +354 -0
- package/foundation/discovery/hook-discovery.d.mts +18 -2
- package/foundation/discovery/hook-discovery.mjs +93 -42
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-component-views.d.mts +15 -0
- package/foundation/discovery/integration-component-views.mjs +91 -0
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/module-exports.d.mts +26 -1
- package/foundation/discovery/module-exports.mjs +114 -40
- package/foundation/discovery/name-roots.d.mts +38 -0
- package/foundation/discovery/name-roots.mjs +108 -0
- package/foundation/discovery/next-routes.d.mts +48 -0
- package/foundation/discovery/next-routes.mjs +181 -0
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +40 -18
- package/foundation/discovery/template-adapter.d.mts +49 -29
- package/foundation/discovery/template-adapter.mjs +89 -99
- package/foundation/discovery/template-destination.d.mts +28 -0
- package/foundation/discovery/template-destination.mjs +104 -0
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/template-ids.d.mts +69 -0
- package/foundation/discovery/template-ids.mjs +199 -0
- package/foundation/discovery/theme-discovery.d.mts +12 -0
- package/foundation/discovery/theme-discovery.mjs +34 -4
- package/foundation/discovery/theme-imports.d.mts +24 -0
- package/foundation/discovery/theme-imports.mjs +61 -4
- package/foundation/discovery/theming-targets.d.mts +13 -5
- package/foundation/discovery/theming-targets.mjs +41 -47
- package/foundation/doc-compiler/generated-levels.d.mts +43 -0
- package/foundation/doc-compiler/generated-levels.mjs +72 -0
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/literal-doc.d.mts +12 -0
- package/foundation/doc-compiler/literal-doc.mjs +322 -0
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +29 -0
- package/foundation/doc-compiler/stored-docs.mjs +63 -1
- package/foundation/doc-compiler/tree.d.mts +4 -84
- package/foundation/doc-compiler/tree.mjs +4 -62
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +46 -0
- package/foundation/fonts/font-stylesheet.mjs +173 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +16 -5
- package/foundation/fs/gather-cache.d.mts +94 -4
- package/foundation/fs/gather-cache.mjs +671 -106
- package/foundation/fs/glob.d.mts +16 -0
- package/foundation/fs/glob.mjs +105 -0
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +80 -0
- package/foundation/fs/kept-tree.mjs +240 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/path-safety.d.mts +11 -2
- package/foundation/fs/path-safety.mjs +108 -18
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +56 -7
- package/foundation/fs/read-record.mjs +280 -56
- package/foundation/fs/regular-file.d.mts +29 -0
- package/foundation/fs/regular-file.mjs +77 -0
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/integrations.d.mts +23 -1
- package/foundation/integrations/integrations.mjs +18 -1
- package/foundation/integrations/pack-state.d.mts +75 -0
- package/foundation/integrations/pack-state.mjs +314 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/shipped-imports.d.mts +122 -0
- package/foundation/integrations/shipped-imports.mjs +497 -0
- package/foundation/integrations/validate-contributions.d.mts +0 -17
- package/foundation/integrations/validate-contributions.mjs +59 -333
- package/foundation/render/assets.mjs +52 -7
- package/foundation/render/charts.d.mts +78 -27
- package/foundation/render/charts.mjs +266 -90
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +70 -7
- package/foundation/render/embedded-imports.mjs +132 -41
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/layers.d.mts +30 -0
- package/foundation/render/layers.mjs +158 -0
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/offline.d.mts +32 -0
- package/foundation/render/offline.mjs +56 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +354 -21
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +192 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +46 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +79 -5
- package/foundation/render/render-page.mjs +735 -109
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +6 -6
- package/foundation/suggest/name-index.d.mts +148 -0
- package/foundation/suggest/name-index.mjs +317 -0
- package/foundation/suggest/other-command.d.mts +140 -0
- package/foundation/suggest/other-command.mjs +756 -0
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/entry-names.d.mts +14 -0
- package/foundation/text/entry-names.mjs +14 -0
- package/foundation/text/string-utils.d.mts +46 -6
- package/foundation/text/string-utils.mjs +118 -20
- package/foundation/text/suggest-order.d.mts +47 -4
- package/foundation/text/suggest-order.mjs +174 -5
- package/foundation/xle/browser.d.mts +2 -2
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
findHookDoc,
|
|
15
15
|
} from '../../../foundation/discovery/hook-discovery.mjs';
|
|
16
16
|
import {loadDocs} from '../../../foundation/discovery/component-loader.mjs';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
formatAccessibility,
|
|
19
|
+
formatBestPractices,
|
|
20
|
+
mdCell,
|
|
21
|
+
} from './component-format.mjs';
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Build a signature string from hook docs.
|
|
@@ -60,7 +64,7 @@ function formatParamsTable(params) {
|
|
|
60
64
|
/** @type {string[]} */
|
|
61
65
|
const lines = [];
|
|
62
66
|
lines.push('| Param | Type | Default | Description |');
|
|
63
|
-
lines.push('
|
|
67
|
+
lines.push('|---|---|---|---|');
|
|
64
68
|
for (const p of params) {
|
|
65
69
|
const def = p.default ? `\`${mdCell(p.default)}\`` : '-';
|
|
66
70
|
const req = p.required ? ' **(required)**' : '';
|
|
@@ -81,7 +85,7 @@ function formatReturnsTable(returns) {
|
|
|
81
85
|
/** @type {string[]} */
|
|
82
86
|
const lines = [];
|
|
83
87
|
lines.push('| Field | Type | Description |');
|
|
84
|
-
lines.push('
|
|
88
|
+
lines.push('|---|---|---|');
|
|
85
89
|
for (const r of returns) {
|
|
86
90
|
lines.push(
|
|
87
91
|
`| \`${mdCell(r.name)}\` | \`${mdCell(r.type)}\` | ${mdCell(r.description)} |`,
|
|
@@ -107,14 +111,7 @@ export function formatHookFull(docs) {
|
|
|
107
111
|
if (desc) sections.push(desc + '\n');
|
|
108
112
|
|
|
109
113
|
// Best Practices (same position as component format)
|
|
110
|
-
|
|
111
|
-
sections.push('## Best Practices\n');
|
|
112
|
-
for (const bp of docs.usage.bestPractices) {
|
|
113
|
-
const badge = bp.guidance ? '**Do:**' : "**Don't:**";
|
|
114
|
-
sections.push(`- ${badge} ${bp.description}`);
|
|
115
|
-
}
|
|
116
|
-
sections.push('');
|
|
117
|
-
}
|
|
114
|
+
sections.push(...formatBestPractices(docs.usage?.bestPractices));
|
|
118
115
|
|
|
119
116
|
sections.push(...formatAccessibility(docs.usage?.accessibility));
|
|
120
117
|
|
|
@@ -161,14 +158,7 @@ export function formatHookCompact(docs, importPath) {
|
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
// Best Practices (matches component compact)
|
|
164
|
-
|
|
165
|
-
sections.push('## Best Practices\n');
|
|
166
|
-
for (const bp of docs.usage.bestPractices) {
|
|
167
|
-
const badge = bp.guidance ? '**Do:**' : "**Don't:**";
|
|
168
|
-
sections.push(`- ${badge} ${bp.description}`);
|
|
169
|
-
}
|
|
170
|
-
sections.push('');
|
|
171
|
-
}
|
|
161
|
+
sections.push(...formatBestPractices(docs.usage?.bestPractices));
|
|
172
162
|
|
|
173
163
|
sections.push(...formatAccessibility(docs.usage?.accessibility));
|
|
174
164
|
|
|
@@ -41,11 +41,22 @@
|
|
|
41
41
|
* such as help printed as the failure report, still passes through.
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
API_VERSION,
|
|
46
|
+
isJsonMode,
|
|
47
|
+
toErrorEnvelope,
|
|
48
|
+
} from '../../../foundation/response/json.mjs';
|
|
45
49
|
import {answeredBy} from '../../../foundation/release/run-context.mjs';
|
|
46
50
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
47
|
-
import {
|
|
48
|
-
|
|
51
|
+
import {
|
|
52
|
+
setCommand,
|
|
53
|
+
setOutcome,
|
|
54
|
+
recordHelp,
|
|
55
|
+
} from '../../../foundation/debug/index.mjs';
|
|
56
|
+
import {
|
|
57
|
+
formatCliCommand,
|
|
58
|
+
getCliInvocation,
|
|
59
|
+
} from '../../../foundation/env/package-manager.mjs';
|
|
49
60
|
|
|
50
61
|
/**
|
|
51
62
|
* Fully-qualified name of a command relative to the root program, e.g.
|
|
@@ -99,17 +110,18 @@ export function buildHelpEnvelope(cmd) {
|
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
/** @type {Array<{flags: string, description: string, defaultValue?: unknown, choices?: string[]}>} */
|
|
102
|
-
const options = cmd.options.map(
|
|
113
|
+
const options = cmd.options.map(o => {
|
|
103
114
|
/** @type {any} */
|
|
104
115
|
const opt = {flags: o.flags, description: o.description || ''};
|
|
105
116
|
if (o.defaultValue !== undefined) opt.defaultValue = o.defaultValue;
|
|
106
|
-
if (Array.isArray(o.argChoices) && o.argChoices.length)
|
|
117
|
+
if (Array.isArray(o.argChoices) && o.argChoices.length)
|
|
118
|
+
opt.choices = o.argChoices;
|
|
107
119
|
return opt;
|
|
108
120
|
});
|
|
109
121
|
|
|
110
122
|
const subcommands = cmd.commands
|
|
111
|
-
.filter(
|
|
112
|
-
.map(
|
|
123
|
+
.filter(s => !(/** @type {any} */ (s)._hidden))
|
|
124
|
+
.map(s => ({name: s.name(), description: s.description() || ''}));
|
|
113
125
|
|
|
114
126
|
return {
|
|
115
127
|
apiVersion: API_VERSION,
|
|
@@ -135,7 +147,7 @@ export function buildHelpEnvelope(cmd) {
|
|
|
135
147
|
*/
|
|
136
148
|
export function buildHelpErrorEnvelope(cmd) {
|
|
137
149
|
const available = cmd.commands
|
|
138
|
-
.filter(s => !(/** @type {any} */ (s)
|
|
150
|
+
.filter(s => !(/** @type {any} */ (s)._hidden) && s.name() !== 'help')
|
|
139
151
|
.map(s => s.name());
|
|
140
152
|
if (!cmd.parent) {
|
|
141
153
|
// Commander dispatches `help <name>` with ['help', <name>, ...] in args.
|
|
@@ -149,7 +161,10 @@ export function buildHelpErrorEnvelope(cmd) {
|
|
|
149
161
|
const group = fullNameOf(cmd);
|
|
150
162
|
return toErrorEnvelope(
|
|
151
163
|
`'${group}' needs a subcommand`,
|
|
152
|
-
available.map(name => ({
|
|
164
|
+
available.map(name => ({
|
|
165
|
+
name: `${group} ${name}`,
|
|
166
|
+
reason: 'available subcommand',
|
|
167
|
+
})),
|
|
153
168
|
ERROR_CODES.ERR_MISSING_ARGUMENT,
|
|
154
169
|
);
|
|
155
170
|
}
|
|
@@ -205,13 +220,22 @@ function commanderCodeToErrorCode(commanderCode, message) {
|
|
|
205
220
|
}
|
|
206
221
|
}
|
|
207
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Whether a command, by its words (`theme build`), answers `--json`. The
|
|
225
|
+
* answer to an option a command does not take offers `--json` only then.
|
|
226
|
+
* @type {(path: string) => boolean}
|
|
227
|
+
*/
|
|
228
|
+
let jsonSupported = () => true;
|
|
229
|
+
|
|
208
230
|
/**
|
|
209
231
|
* Install the shim on a Commander program. Idempotent — safe to call
|
|
210
232
|
* once at program-construction time.
|
|
211
233
|
*
|
|
212
234
|
* @param {import('commander').Command} program
|
|
235
|
+
* @param {{jsonSupported?: (path: string) => boolean}} [options]
|
|
213
236
|
*/
|
|
214
|
-
export function installJsonShim(program) {
|
|
237
|
+
export function installJsonShim(program, options = {}) {
|
|
238
|
+
if (options.jsonSupported) jsonSupported = options.jsonSupported;
|
|
215
239
|
// exitOverride() and configureOutput() do NOT auto-cascade to
|
|
216
240
|
// subcommands that were registered BEFORE the shim runs (Commander
|
|
217
241
|
// copies these settings from parent at command-creation time, not
|
|
@@ -256,7 +280,7 @@ function applyShimRecursively(cmd) {
|
|
|
256
280
|
throw err;
|
|
257
281
|
});
|
|
258
282
|
cmd.configureOutput({
|
|
259
|
-
writeOut:
|
|
283
|
+
writeOut: str => process.stdout.write(str),
|
|
260
284
|
// Commander's own "error: ..." line never reaches the user. Under --json a
|
|
261
285
|
// consumer parsing both streams must not see it alongside the envelope;
|
|
262
286
|
// in text mode it is Commander's format, not Astryx's, so an invalid
|
|
@@ -268,7 +292,7 @@ function applyShimRecursively(cmd) {
|
|
|
268
292
|
// ONLY that line. Commander also writes HELP through this channel when it
|
|
269
293
|
// shows help because the invocation failed (a command group with no
|
|
270
294
|
// subcommand), and that output is still wanted in text mode.
|
|
271
|
-
writeErr:
|
|
295
|
+
writeErr: str => {
|
|
272
296
|
if (jsonActive()) return;
|
|
273
297
|
if (/^error:\s/i.test(str)) return;
|
|
274
298
|
process.stderr.write(str);
|
|
@@ -303,7 +327,18 @@ function usageSuggestion(err, code) {
|
|
|
303
327
|
)
|
|
304
328
|
return editorMissingSuggestions(cmd);
|
|
305
329
|
if (code !== 'commander.optionMissingArgument') return undefined;
|
|
306
|
-
|
|
330
|
+
// The command's usage with the option in it, as it takes its value
|
|
331
|
+
// (`astryx theme build --out <path> <files...>`).
|
|
332
|
+
const flags = /option '([^']+)' argument missing/.exec(
|
|
333
|
+
/** @type {any} */ (err)?.message ?? '',
|
|
334
|
+
)?.[1];
|
|
335
|
+
const option = flags
|
|
336
|
+
? /--[\w-]+(?:\s+[<[][^>\]]*[>\]])?/.exec(flags)?.[0]
|
|
337
|
+
: undefined;
|
|
338
|
+
const usage = option
|
|
339
|
+
? cmd.usage().replace('[options]', `${option} [options]`)
|
|
340
|
+
: cmd.usage();
|
|
341
|
+
return [{name: `${parts.join(' ')} ${usage}`.trim(), reason: 'usage'}];
|
|
307
342
|
}
|
|
308
343
|
|
|
309
344
|
/**
|
|
@@ -317,11 +352,57 @@ function editorMissingMessage(err, message) {
|
|
|
317
352
|
const wants = (cmd?.registeredArguments ?? [])
|
|
318
353
|
.filter((/** @type {any} */ a) => a.required)
|
|
319
354
|
.map((/** @type {any} */ a) => a.name());
|
|
320
|
-
return editorMissingArgument(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
355
|
+
return editorMissingArgument(cmd, wants, /'([^']+)'/.exec(message)?.[1])
|
|
356
|
+
.message;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* The editor themes of the app a command runs in, as the theme editor
|
|
361
|
+
* lists them; the editor registers it, so this module reads no theme files.
|
|
362
|
+
* @type {(cwd: string) => string[]}
|
|
363
|
+
*/
|
|
364
|
+
let editorThemesHere = () => [];
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* How the theme commands read an option commander does not know, or one
|
|
368
|
+
* given no value (commander's code says which), which the editor
|
|
369
|
+
* registers: the message and the commands that work, or undefined for a
|
|
370
|
+
* command it does not read.
|
|
371
|
+
* @type {(cmd: any, code: string) => {message: string, suggestions: Array<{name: string, reason: string}>} | undefined | Promise<{message: string, suggestions: Array<{name: string, reason: string}>} | undefined>}
|
|
372
|
+
*/
|
|
373
|
+
let unknownOptionReader = () => undefined;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Register how the theme commands read an option they do not take.
|
|
377
|
+
* @param {(cmd: any, code: string) => {message: string, suggestions: Array<{name: string, reason: string}>} | undefined | Promise<{message: string, suggestions: Array<{name: string, reason: string}>} | undefined>} read
|
|
378
|
+
*/
|
|
379
|
+
export function setUnknownOptionReader(read) {
|
|
380
|
+
unknownOptionReader = read;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* The theme name the editor offers `new` here, the one its own refusals
|
|
385
|
+
* offer: the name asked for when its folder is free, else name-2, name-3…
|
|
386
|
+
* The editor registers it, so this module reads no theme files.
|
|
387
|
+
* @type {(cwd: string, name: string) => string}
|
|
388
|
+
*/
|
|
389
|
+
let editorFreeName = (_cwd, name) => name;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Register the theme name the editor offers `new` here.
|
|
393
|
+
* @param {(cwd: string, name: string) => string} free
|
|
394
|
+
*/
|
|
395
|
+
export function setEditorFreeName(free) {
|
|
396
|
+
editorFreeName = free;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Register how the theme editor lists the themes of the app a command runs
|
|
401
|
+
* in, for the missing-theme suggestions.
|
|
402
|
+
* @param {(cwd: string) => string[]} list
|
|
403
|
+
*/
|
|
404
|
+
export function setEditorThemeList(list) {
|
|
405
|
+
editorThemesHere = list;
|
|
325
406
|
}
|
|
326
407
|
|
|
327
408
|
/**
|
|
@@ -335,6 +416,42 @@ function editorMissingSuggestions(cmd) {
|
|
|
335
416
|
for (let node = cmd; node; node = node.parent) parts.unshift(node.name());
|
|
336
417
|
const words = parts.slice(1).join(' ');
|
|
337
418
|
const invocation = getCliInvocation(process.cwd());
|
|
419
|
+
// No theme named, and the app has exactly one editor theme: the command
|
|
420
|
+
// on that theme, when the theme is all it takes.
|
|
421
|
+
const wants = (cmd?.registeredArguments ?? []).filter(
|
|
422
|
+
(/** @type {any} */ a) => a.required,
|
|
423
|
+
);
|
|
424
|
+
// (`new` names a theme that does not exist yet: never the one here.)
|
|
425
|
+
if (
|
|
426
|
+
!(cmd?.args ?? []).length &&
|
|
427
|
+
wants.length === 1 &&
|
|
428
|
+
wants[0].name() === 'theme' &&
|
|
429
|
+
cmd.name() !== 'new'
|
|
430
|
+
) {
|
|
431
|
+
const themes = editorThemesHere(process.cwd());
|
|
432
|
+
if (themes.length === 1)
|
|
433
|
+
return [
|
|
434
|
+
{
|
|
435
|
+
name: `${invocation} ${words} ${themes[0]}`,
|
|
436
|
+
reason: `do this instead: ${themes[0]} is the theme here`,
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: `${invocation} ${words} --help`,
|
|
440
|
+
reason: 'what each argument is',
|
|
441
|
+
},
|
|
442
|
+
];
|
|
443
|
+
}
|
|
444
|
+
// `new` with no name: a name no theme here has.
|
|
445
|
+
if (!(cmd?.args ?? []).length && cmd.name() === 'new') {
|
|
446
|
+
const free = editorFreeName(process.cwd(), 'my-theme');
|
|
447
|
+
return [
|
|
448
|
+
{
|
|
449
|
+
name: `${invocation} ${words} ${free}`,
|
|
450
|
+
reason: 'do this instead: a name for the new theme',
|
|
451
|
+
},
|
|
452
|
+
{name: `${invocation} ${words} --help`, reason: 'what each argument is'},
|
|
453
|
+
];
|
|
454
|
+
}
|
|
338
455
|
return [
|
|
339
456
|
{name: `${invocation} ${words} ${cmd.usage()}`.trim(), reason: 'usage'},
|
|
340
457
|
{name: `${invocation} ${words} --help`, reason: 'what each argument is'},
|
|
@@ -435,7 +552,9 @@ function patchOutputHelp(cmd) {
|
|
|
435
552
|
if (anyCmd.__xdsHelpPatched) return;
|
|
436
553
|
anyCmd.__xdsHelpPatched = true;
|
|
437
554
|
const original = cmd.outputHelp.bind(cmd);
|
|
438
|
-
anyCmd.outputHelp = function patchedOutputHelp(
|
|
555
|
+
anyCmd.outputHelp = function patchedOutputHelp(
|
|
556
|
+
/** @type {any} */ contextOptions,
|
|
557
|
+
) {
|
|
439
558
|
if (jsonActive()) {
|
|
440
559
|
if (!process.__xdsJsonHandled) {
|
|
441
560
|
process.__xdsJsonHandled = true;
|
|
@@ -461,7 +580,9 @@ function patchPrototype(CommandCtor) {
|
|
|
461
580
|
if (proto.__xdsHelpPatched) return;
|
|
462
581
|
proto.__xdsHelpPatched = true;
|
|
463
582
|
const original = proto.outputHelp;
|
|
464
|
-
proto.outputHelp = function patchedProtoOutputHelp(
|
|
583
|
+
proto.outputHelp = function patchedProtoOutputHelp(
|
|
584
|
+
/** @type {any} */ contextOptions,
|
|
585
|
+
) {
|
|
465
586
|
if (jsonActive()) {
|
|
466
587
|
if (!process.__xdsJsonHandled) {
|
|
467
588
|
process.__xdsJsonHandled = true;
|
|
@@ -493,11 +614,15 @@ function patchPrototype(CommandCtor) {
|
|
|
493
614
|
* commander.excessArguments
|
|
494
615
|
*
|
|
495
616
|
* @param {unknown} err
|
|
496
|
-
* @returns {boolean} true if handled (caller should not
|
|
617
|
+
* @returns {boolean | Promise<boolean>} true if handled (caller should not
|
|
618
|
+
* re-throw); a promise when the answer is written once its suggestions
|
|
619
|
+
* are checked
|
|
497
620
|
*/
|
|
498
621
|
export function handleCommanderError(err) {
|
|
499
622
|
if (!err || typeof err !== 'object' || !('code' in err)) return false;
|
|
500
|
-
const code =
|
|
623
|
+
const code =
|
|
624
|
+
/** @type {{code?: string, exitCode?: number, message?: string}} */ (err)
|
|
625
|
+
.code;
|
|
501
626
|
if (typeof code !== 'string' || !code.startsWith('commander.')) return false;
|
|
502
627
|
|
|
503
628
|
const exitCode = /** @type {{exitCode?: number}} */ (err).exitCode ?? 1;
|
|
@@ -529,29 +654,140 @@ export function handleCommanderError(err) {
|
|
|
529
654
|
code: commanderCodeToErrorCode(code, message),
|
|
530
655
|
});
|
|
531
656
|
|
|
657
|
+
// An option a command does not take: the editor's own reader reads its
|
|
658
|
+
// commands' options; every other command gets the generic answer.
|
|
659
|
+
const rejected = /** @type {any} */ (err)?.[REJECTED_COMMAND];
|
|
660
|
+
if (code === 'commander.unknownOption' && rejected)
|
|
661
|
+
return answerStrayOption(err, rejected, message, exitCode);
|
|
662
|
+
|
|
532
663
|
// Real error paths. Strip Commander's "error: " prefix once: in the envelope
|
|
533
664
|
// the key is already `error`, and in text mode the Astryx prefix replaces it.
|
|
534
|
-
|
|
665
|
+
// The editor's reader also reads an option given without its value and
|
|
666
|
+
// words a theme command does not take.
|
|
667
|
+
const read =
|
|
668
|
+
code === 'commander.optionMissingArgument' ||
|
|
669
|
+
code === 'commander.excessArguments'
|
|
670
|
+
? unknownOptionReader(rejected, code)
|
|
671
|
+
: undefined;
|
|
672
|
+
// The reader checks the commands it offers as the command itself would
|
|
673
|
+
// (which may take a moment): the answer is written once it has them.
|
|
674
|
+
if (read instanceof Promise)
|
|
675
|
+
return read.then(r => finishParseError(err, code, message, exitCode, r));
|
|
676
|
+
return finishParseError(err, code, message, exitCode, read);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* The answer to an option a command does not take, loaded only for this
|
|
681
|
+
* error. On the program itself, before a word that names no command
|
|
682
|
+
* (`astryx describe Table --format json`), the unknown command is the fault
|
|
683
|
+
* to report, and its answer names the command meant. Otherwise the editor's
|
|
684
|
+
* reader reads the option for its own commands, and every other command
|
|
685
|
+
* gets the options it takes and the run as meant (./stray-option.mjs).
|
|
686
|
+
* @param {unknown} err
|
|
687
|
+
* @param {any} rejected the command that refused the option
|
|
688
|
+
* @param {string} message Commander's message
|
|
689
|
+
* @param {number} exitCode
|
|
690
|
+
* @returns {Promise<boolean>}
|
|
691
|
+
*/
|
|
692
|
+
async function answerStrayOption(err, rejected, message, exitCode) {
|
|
693
|
+
const code = 'commander.unknownOption';
|
|
694
|
+
const words = process.argv.slice(2);
|
|
695
|
+
const stray = /unknown option '([^']+)'/.exec(message)?.[1] ?? '';
|
|
696
|
+
const {strayOptionAnswer, withoutStray} = await import('./stray-option.mjs');
|
|
697
|
+
if (!rejected.parent) {
|
|
698
|
+
const {findEntry, firstWord, unknownCommandAnswer} =
|
|
699
|
+
await import('./unknown-command.mjs');
|
|
700
|
+
// Only a word before the stray option is read as the command: after it,
|
|
701
|
+
// the word may be the option's value (`astryx --format text component
|
|
702
|
+
// Table`), and the unknown option stays the fault.
|
|
703
|
+
const at = words.indexOf(stray);
|
|
704
|
+
const first = firstWord(at < 0 ? words : words.slice(0, at), rejected);
|
|
705
|
+
const cleaned = withoutStray(words, stray, rejected.options);
|
|
706
|
+
if (
|
|
707
|
+
first &&
|
|
708
|
+
!rejected.commands.some((/** @type {any} */ c) => c.name() === first.word)
|
|
709
|
+
) {
|
|
710
|
+
const answer = await unknownCommandAnswer(rejected, cleaned, {
|
|
711
|
+
findEntry,
|
|
712
|
+
});
|
|
713
|
+
setOutcome('parse-error', {
|
|
714
|
+
exitCode: exitCode || 1,
|
|
715
|
+
error: new Error(answer?.message ?? message),
|
|
716
|
+
code: ERROR_CODES.ERR_UNKNOWN_COMMAND,
|
|
717
|
+
});
|
|
718
|
+
return finishParseError(
|
|
719
|
+
err,
|
|
720
|
+
code,
|
|
721
|
+
message,
|
|
722
|
+
exitCode,
|
|
723
|
+
answer && {
|
|
724
|
+
message: answer.message,
|
|
725
|
+
// Only the runs: a near or listed command name is no run to print
|
|
726
|
+
// after `Run:`, so the program's help stands in for those.
|
|
727
|
+
suggestions: answer.suggestions.some(s =>
|
|
728
|
+
s.name.startsWith('astryx '),
|
|
729
|
+
)
|
|
730
|
+
? answer.suggestions
|
|
731
|
+
.filter(s => s.name.startsWith('astryx '))
|
|
732
|
+
.map(s => ({name: formatCliCommand(s.name), reason: s.reason}))
|
|
733
|
+
: [{name: formatCliCommand('--help'), reason: 'every command'}],
|
|
734
|
+
},
|
|
735
|
+
ERROR_CODES.ERR_UNKNOWN_COMMAND,
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const read = await unknownOptionReader(rejected, code);
|
|
740
|
+
return finishParseError(
|
|
741
|
+
err,
|
|
742
|
+
code,
|
|
743
|
+
message,
|
|
744
|
+
exitCode,
|
|
745
|
+
read ??
|
|
746
|
+
strayOptionAnswer(rejected, message.replace(/^error:\s*/i, ''), words, {
|
|
747
|
+
jsonSupported,
|
|
748
|
+
}),
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* The rest of {@link handleCommanderError} for a parse failure: the message
|
|
754
|
+
* and suggestions written (the theme reader's answer when it read the
|
|
755
|
+
* option), and the exit.
|
|
756
|
+
* @param {unknown} err
|
|
757
|
+
* @param {string} code
|
|
758
|
+
* @param {string} message
|
|
759
|
+
* @param {number} exitCode
|
|
760
|
+
* @param {{message: string, suggestions: Array<{name: string, reason: string}>} | undefined | null} read
|
|
761
|
+
* @param {string} [errorCode] the code the answer reports, when it is not
|
|
762
|
+
* the one Commander's code maps to
|
|
763
|
+
* @returns {boolean}
|
|
764
|
+
*/
|
|
765
|
+
function finishParseError(err, code, message, exitCode, read, errorCode) {
|
|
766
|
+
const answer = read ?? undefined;
|
|
767
|
+
const suggestions = answer?.suggestions ?? usageSuggestion(err, code);
|
|
535
768
|
// In the theme editor a missing argument names what was given: in
|
|
536
769
|
// `set corners small` the first word is read as the theme, so "value" alone
|
|
537
770
|
// would name the wrong thing.
|
|
538
|
-
const cleaned =
|
|
539
|
-
|
|
771
|
+
const cleaned = answer
|
|
772
|
+
? answer.message
|
|
773
|
+
: code === 'commander.missingArgument' && suggestions?.length === 2
|
|
540
774
|
? editorMissingMessage(err, message)
|
|
541
775
|
: message.replace(/^error:\s*/i, '');
|
|
542
776
|
if (jsonActive()) {
|
|
543
777
|
emitJsonError(
|
|
544
778
|
cleaned,
|
|
545
779
|
suggestions,
|
|
546
|
-
commanderCodeToErrorCode(code, cleaned),
|
|
780
|
+
errorCode ?? commanderCodeToErrorCode(code, cleaned),
|
|
547
781
|
);
|
|
548
782
|
} else {
|
|
549
783
|
// Commander's own line was suppressed above, so a parse failure reads the
|
|
550
784
|
// same as every other CLI error — the `Error: …` line cliError prints.
|
|
551
785
|
process.stderr.write(`Error: ${cleaned}\n`);
|
|
552
|
-
if (suggestions)
|
|
553
|
-
|
|
554
|
-
|
|
786
|
+
if (suggestions)
|
|
787
|
+
process.stderr.write(
|
|
788
|
+
`${suggestions[0].reason === 'usage' ? 'Usage' : 'Run'}: ${suggestions[0].name}\n`,
|
|
789
|
+
);
|
|
790
|
+
if (suggestions?.[1]) process.stderr.write(`Run: ${suggestions[1].name}\n`);
|
|
555
791
|
}
|
|
556
792
|
process.exit(exitCode || 1);
|
|
557
793
|
}
|
|
@@ -42,6 +42,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
42
42
|
import {API_VERSION} from '../../../foundation/response/json.mjs';
|
|
43
43
|
import {commandDocsOf} from './define-command.mjs';
|
|
44
44
|
import {doc as manifestDoc} from '../commands/manifest.doc.mjs';
|
|
45
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* What a run may do beyond the command it was asked for (spec AST-081;
|
|
@@ -222,7 +223,7 @@ function describeCommand(cmd, root, jsonSupported) {
|
|
|
222
223
|
// `.command()` calls silently changes the output.
|
|
223
224
|
if (subcommands.length > 0) {
|
|
224
225
|
entry.subcommands = subcommands.sort((a, b) =>
|
|
225
|
-
/** @type {any} */ (a).name
|
|
226
|
+
compareText(/** @type {any} */ (a).name, /** @type {any} */ (b).name),
|
|
226
227
|
);
|
|
227
228
|
}
|
|
228
229
|
|
|
@@ -307,7 +308,7 @@ export function buildManifest(program, opts = {}) {
|
|
|
307
308
|
(program.commands || [])
|
|
308
309
|
.map(cmd => describeCommand(cmd, program, jsonSupported))
|
|
309
310
|
.filter(Boolean)
|
|
310
|
-
).sort((a, b) => a.name
|
|
311
|
+
).sort((a, b) => compareText(a.name, b.name));
|
|
311
312
|
|
|
312
313
|
return {
|
|
313
314
|
name: 'astryx',
|