@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
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
|
|
32
32
|
import * as fs from 'node:fs';
|
|
33
33
|
import * as path from 'node:path';
|
|
34
|
+
import {
|
|
35
|
+
fontKey,
|
|
36
|
+
stylesheetFontFamilies,
|
|
37
|
+
} from '../../../foundation/fonts/font-stylesheet.mjs';
|
|
34
38
|
import {fileURLToPath} from 'node:url';
|
|
35
39
|
import {spawn} from 'node:child_process';
|
|
36
40
|
import {
|
|
@@ -63,6 +67,7 @@ import {
|
|
|
63
67
|
themeTemplate,
|
|
64
68
|
} from '../../../api/theme/template/template.mjs';
|
|
65
69
|
import {findPackageRoot} from '../../../foundation/fs/paths.mjs';
|
|
70
|
+
import {expandGlob} from '../../../foundation/fs/glob.mjs';
|
|
66
71
|
import {
|
|
67
72
|
themeListAvailable,
|
|
68
73
|
themeListCopySources,
|
|
@@ -76,6 +81,7 @@ import {
|
|
|
76
81
|
themePaletteGenerate,
|
|
77
82
|
} from '../../../api/theme/palette/generate/generate.mjs';
|
|
78
83
|
import {
|
|
84
|
+
GENERATED_MARKER,
|
|
79
85
|
printBatchTrailer,
|
|
80
86
|
printCompactTrailer,
|
|
81
87
|
setEditorFolderListener,
|
|
@@ -85,6 +91,7 @@ import {
|
|
|
85
91
|
themeSourceFiles,
|
|
86
92
|
themeSourceGuesses,
|
|
87
93
|
buildSuggestion,
|
|
94
|
+
generatedSourceCommand,
|
|
88
95
|
writeDeferredBuildOutputs,
|
|
89
96
|
} from '../../../api/theme/build/build.mjs';
|
|
90
97
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
@@ -119,13 +126,46 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
|
|
|
119
126
|
* @property {string} build - The build subcommand's name: `build` or `compile`.
|
|
120
127
|
* @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => import('../../../api/error.mjs').AstryxError | null} [explain] - A clearer refusal for this group, or null.
|
|
121
128
|
* @property {(files: string[], options: {cwd: string, check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}) => Promise<import('../../../api/error.mjs').AstryxError | null>} [preflight] - A refusal before a build starts, or null.
|
|
122
|
-
* @property {(
|
|
129
|
+
* @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => Promise<import('../../../api/error.mjs').AstryxError>} [follow] - The refusal with its first suggested build checked and repaired as the build would check it.
|
|
130
|
+
* @property {(file: string, cwd: string) => import('../../../api/theme/build/build.mjs').FontHelp | null} [fontHelp] - How a group says to load a theme's fonts when it loads them itself (the editor's app copy).
|
|
131
|
+
* @property {(file: string, cwd: string) => string | null} [install] - How the app takes a theme a group wires another way than importing the build's outputs (the editor's app copy), for the full report.
|
|
132
|
+
* @property {(file: string, cwd: string) => string | null} [sourcePath] - The path a source builds under, when not the typed one; null to keep it.
|
|
133
|
+
* @property {(files: string[], cwd: string) => Promise<Record<string, Record<string, unknown>>>} [afterBuild] - Writes a group makes once a build's outputs are written (the editor's app copy), with what each did, by file, for its result.
|
|
134
|
+
* @property {(files: string[], options: {cwd: string, check?: boolean, out?: string}) => Promise<() => Promise<void>>} [hold] - Locks held while a build or check runs; resolves to their release.
|
|
135
|
+
* @property {(file: string, cwd: string, opts: {check: boolean, upToDate?: boolean, out?: string, iconsSpecifier?: string}) => Record<string, unknown> | null | Promise<Record<string, unknown> | null>} [extraData] - Fields a group adds to a build's result data (the editor's `appCopyStale`); in a check, `upToDate: false` fails it.
|
|
136
|
+
* @property {(file: string, cwd: string) => (['light'] | ['dark'] | null)} [colorModes] - The one color mode a theme file has that the file itself cannot say, for the build to write into the built module.
|
|
137
|
+
* @property {(file: string, cwd: string) => ((family: string) => boolean) | null | Promise<((family: string) => boolean) | null>} [loadedFonts] - Font families the app loads for a theme file that the file itself cannot say, so the build does not name them as unloaded.
|
|
123
138
|
* @property {(file: string, cwd: string) => {name: string, reason: string} | null} [missingSource] - For a source file that is not there, this group's way to write it again, or null.
|
|
124
139
|
* @property {(options: {targetPath?: string, overwrite?: boolean, cwd?: string}) => import('../../../api/theme/theme.type.mjs').ThemeTemplateResponse} [template] - This group's template write, in place of `themeTemplate`.
|
|
125
140
|
*/
|
|
126
141
|
|
|
127
142
|
/** @type {ThemeCommandWords} */
|
|
128
|
-
const THEME_WORDS = {
|
|
143
|
+
const THEME_WORDS = {
|
|
144
|
+
group: 'theme',
|
|
145
|
+
build: 'build',
|
|
146
|
+
loadedFonts: fontsLoadedBeside,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The font families a local theme's font stylesheet loads: the
|
|
151
|
+
* `<slug>.fonts.css` beside its source, where the theme's folder is named
|
|
152
|
+
* for its slug (the one font stylesheet `theme add` imports for it), read
|
|
153
|
+
* with its imports (an @fontsource package by its name, a stylesheet by its
|
|
154
|
+
* @font-face rules or the `family=` it requests). A build of that source
|
|
155
|
+
* does not name those families as unloaded. Another stylesheet in the
|
|
156
|
+
* folder loads nothing for the app, so it counts for nothing. Null when the
|
|
157
|
+
* theme has no font stylesheet.
|
|
158
|
+
* @param {string} file the theme source, as given
|
|
159
|
+
* @param {string} cwd
|
|
160
|
+
* @returns {((family: string) => boolean) | null}
|
|
161
|
+
*/
|
|
162
|
+
function fontsLoadedBeside(file, cwd) {
|
|
163
|
+
const dir = path.dirname(path.resolve(cwd, file));
|
|
164
|
+
const sheet = path.join(dir, `${path.basename(dir)}.fonts.css`);
|
|
165
|
+
if (!fs.existsSync(sheet)) return null;
|
|
166
|
+
const loaded = stylesheetFontFamilies(sheet);
|
|
167
|
+
return loaded.size ? family => loaded.has(fontKey(family)) : null;
|
|
168
|
+
}
|
|
129
169
|
|
|
130
170
|
/**
|
|
131
171
|
* Text as the group that ran the command words it: under `experimental
|
|
@@ -193,13 +233,16 @@ function inGroupNotes(result, words) {
|
|
|
193
233
|
* group that works whatever went wrong.
|
|
194
234
|
* @param {import('../../../api/error.mjs').AstryxError} err
|
|
195
235
|
* @param {ThemeCommandWords} [words]
|
|
196
|
-
* @param {Array<{name: string, reason
|
|
236
|
+
* @param {Array<{name: string, reason?: string}>} [fallback]
|
|
197
237
|
*/
|
|
198
238
|
function themeError(err, words = THEME_WORDS, fallback = []) {
|
|
199
239
|
err = words.explain?.(err, process.cwd()) ?? err;
|
|
200
240
|
/** @param {string} text */
|
|
201
241
|
const local = text => inGroupWords(text, words);
|
|
202
242
|
const given = err.suggestions || [];
|
|
243
|
+
// Suggested commands stay bare (`astryx …`): the JSON envelope carries
|
|
244
|
+
// them so, and the text output starts them the way this project runs the
|
|
245
|
+
// CLI.
|
|
203
246
|
return cliError(local(err.message), {
|
|
204
247
|
suggestions: (given.length > 0 ? given : fallback).map(x => ({
|
|
205
248
|
...x,
|
|
@@ -210,6 +253,122 @@ function themeError(err, words = THEME_WORDS, fallback = []) {
|
|
|
210
253
|
});
|
|
211
254
|
}
|
|
212
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Add a group's fields to a build's result data. Its warnings and notices
|
|
258
|
+
* join the build's own, and are printed as the build's are (`--json`
|
|
259
|
+
* prints none).
|
|
260
|
+
* @param {Record<string, any>} data
|
|
261
|
+
* @param {Record<string, unknown>} extra
|
|
262
|
+
*/
|
|
263
|
+
function mergeResultData(data, extra) {
|
|
264
|
+
const {warnings, notices, ...rest} = /** @type {any} */ (extra);
|
|
265
|
+
Object.assign(data, rest);
|
|
266
|
+
if (Array.isArray(warnings) && warnings.length > 0) {
|
|
267
|
+
data.warnings = [...(data.warnings ?? []), ...warnings];
|
|
268
|
+
for (const w of warnings) logger.warn(`Warning: ${w}`);
|
|
269
|
+
}
|
|
270
|
+
if (Array.isArray(notices) && notices.length > 0) {
|
|
271
|
+
data.notices = [...(data.notices ?? []), ...notices];
|
|
272
|
+
for (const n of notices) logger.log(`[note] ${n}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The builds a quoted glob means: each theme source it matches, or for a
|
|
278
|
+
* family run the one family of them, in the caller's mode, each marked for
|
|
279
|
+
* the group's checks.
|
|
280
|
+
* @param {string} pattern
|
|
281
|
+
* @param {{out?: string, check?: boolean, iconsSpecifier?: string, family?: boolean, familyKey?: string}} options
|
|
282
|
+
* @param {ThemeCommandWords} words
|
|
283
|
+
*/
|
|
284
|
+
function globSuggestions(pattern, options, words) {
|
|
285
|
+
const sources = globSources(pattern);
|
|
286
|
+
const reason = `${sources.length > 1 ? 'theme sources' : 'a theme source'} ${pattern} matches (globs are expanded by your shell, not in quotes)`;
|
|
287
|
+
const mode = {
|
|
288
|
+
check: Boolean(options.check),
|
|
289
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
290
|
+
};
|
|
291
|
+
if (options.family)
|
|
292
|
+
return sources.length
|
|
293
|
+
? [
|
|
294
|
+
buildRun(
|
|
295
|
+
{
|
|
296
|
+
name: buildSuggestion(sources, options, process.cwd(), words, {
|
|
297
|
+
family: true,
|
|
298
|
+
...(options.familyKey
|
|
299
|
+
? {familyKey: String(options.familyKey)}
|
|
300
|
+
: {}),
|
|
301
|
+
}),
|
|
302
|
+
reason,
|
|
303
|
+
},
|
|
304
|
+
sources,
|
|
305
|
+
{...mode, family: true},
|
|
306
|
+
),
|
|
307
|
+
]
|
|
308
|
+
: [];
|
|
309
|
+
return sources.map(source =>
|
|
310
|
+
buildRun(
|
|
311
|
+
{name: buildSuggestion(source, options, process.cwd(), words), reason},
|
|
312
|
+
[source],
|
|
313
|
+
{...mode, family: false, out: options.out},
|
|
314
|
+
),
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The theme sources a glob pattern matches, read from the working folder:
|
|
320
|
+
* the files of a theme module's kind that no build wrote (an output names
|
|
321
|
+
* its source in its header) and that are no type stub.
|
|
322
|
+
* @param {string} pattern
|
|
323
|
+
* @returns {string[]}
|
|
324
|
+
*/
|
|
325
|
+
function globSources(pattern) {
|
|
326
|
+
return expandGlob(pattern, process.cwd())
|
|
327
|
+
.filter(
|
|
328
|
+
file =>
|
|
329
|
+
/\.(?:[cm]?[jt]sx?)$/.test(file) &&
|
|
330
|
+
!/\.d\.[cm]?ts$/.test(file) &&
|
|
331
|
+
!fileStartsWith(path.resolve(process.cwd(), file), GENERATED_MARKER),
|
|
332
|
+
)
|
|
333
|
+
.slice(0, 8);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** @param {string} file @param {string} text */
|
|
337
|
+
function fileStartsWith(file, text) {
|
|
338
|
+
try {
|
|
339
|
+
const fd = fs.openSync(file, 'r');
|
|
340
|
+
try {
|
|
341
|
+
const head = Buffer.alloc(600);
|
|
342
|
+
const n = fs.readSync(fd, head, 0, head.length, 0);
|
|
343
|
+
return head.subarray(0, n).toString('utf8').includes(text);
|
|
344
|
+
} finally {
|
|
345
|
+
fs.closeSync(fd);
|
|
346
|
+
}
|
|
347
|
+
} catch {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Marks a suggested build with what it builds, for the group's checks. */
|
|
353
|
+
const BUILD_RUN = Symbol('build run');
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* A suggested build, marked with the files and mode it builds so the
|
|
357
|
+
* group's own checks can vet it before it is shown (the mark is not part of
|
|
358
|
+
* what is printed).
|
|
359
|
+
* @template {{name: string, reason: string}} S
|
|
360
|
+
* @param {S} suggestion
|
|
361
|
+
* @param {string[]} files
|
|
362
|
+
* @param {{check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}} mode
|
|
363
|
+
* @returns {S}
|
|
364
|
+
*/
|
|
365
|
+
function buildRun(suggestion, files, mode) {
|
|
366
|
+
return Object.defineProperty(suggestion, BUILD_RUN, {
|
|
367
|
+
value: {files, mode},
|
|
368
|
+
enumerable: false,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
213
372
|
/**
|
|
214
373
|
* A command of this CLI as this project runs it, each argument quoted for the
|
|
215
374
|
* shell.
|
|
@@ -539,6 +698,19 @@ function themeNextSteps(run, words = THEME_WORDS) {
|
|
|
539
698
|
: `Import one: ${run} ${words.group} add <slug> [--package <package>]\n${fork}`;
|
|
540
699
|
}
|
|
541
700
|
|
|
701
|
+
/**
|
|
702
|
+
* The list's `wiredBy` line: the provider a theme's package wires it with.
|
|
703
|
+
* The list reads no app source; doctor checks where the app renders it.
|
|
704
|
+
* @param {import('../../../api/theme/theme.type.mjs').ThemeListEntry} theme
|
|
705
|
+
*/
|
|
706
|
+
function wiredByLine(theme) {
|
|
707
|
+
if (!theme.wiredBy) return theme;
|
|
708
|
+
return {
|
|
709
|
+
...theme,
|
|
710
|
+
wiredBy: `wired by ${theme.wiredBy.export} from ${theme.wiredBy.from} when the app renders it; \`${getCliInvocation()} doctor\` checks where`,
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
542
714
|
/**
|
|
543
715
|
* Print every field in the `theme.list` entries. Duplicate slugs stay separate
|
|
544
716
|
* because each record names its owner.
|
|
@@ -562,7 +734,7 @@ function printThemeList(
|
|
|
562
734
|
} else {
|
|
563
735
|
emit(
|
|
564
736
|
section('Themes', `${themes.length} available`),
|
|
565
|
-
records(themes, {
|
|
737
|
+
records(themes.map(wiredByLine), {
|
|
566
738
|
fields: [
|
|
567
739
|
'slug',
|
|
568
740
|
'displayName',
|
|
@@ -570,12 +742,16 @@ function printThemeList(
|
|
|
570
742
|
'maintained',
|
|
571
743
|
'package',
|
|
572
744
|
'source',
|
|
745
|
+
'owner',
|
|
746
|
+
'installed',
|
|
747
|
+
'wiredBy',
|
|
573
748
|
'added',
|
|
574
749
|
'default',
|
|
575
750
|
],
|
|
576
751
|
layout: 'stacked',
|
|
577
752
|
format: {
|
|
578
753
|
maintained: (/** @type {boolean} */ value) => (value ? 'yes' : 'no'),
|
|
754
|
+
installed: (/** @type {boolean} */ value) => (value ? 'yes' : 'no'),
|
|
579
755
|
added: (/** @type {boolean} */ value) => (value ? 'yes' : 'no'),
|
|
580
756
|
default: (/** @type {boolean} */ value) => (value ? 'yes' : 'no'),
|
|
581
757
|
},
|
|
@@ -612,8 +788,8 @@ function printThemeList(
|
|
|
612
788
|
}
|
|
613
789
|
|
|
614
790
|
/**
|
|
615
|
-
* Print every `theme.app` receipt field
|
|
616
|
-
* add.
|
|
791
|
+
* Print every `theme.app` receipt field, the one-time app wiring on the first
|
|
792
|
+
* add, and the wiring to drop when the last theme's module is deleted.
|
|
617
793
|
* @param {import('../../../api/theme/theme.type.mjs').ThemeAppResponse} result
|
|
618
794
|
*/
|
|
619
795
|
function printThemeApp(result) {
|
|
@@ -629,6 +805,7 @@ function printThemeApp(result) {
|
|
|
629
805
|
'stylesheet',
|
|
630
806
|
'fontStylesheet',
|
|
631
807
|
'source',
|
|
808
|
+
'mode',
|
|
632
809
|
],
|
|
633
810
|
layout: 'stacked',
|
|
634
811
|
}),
|
|
@@ -641,6 +818,9 @@ function printThemeApp(result) {
|
|
|
641
818
|
slug: change.slug,
|
|
642
819
|
changed: change.changed,
|
|
643
820
|
firstAdd: change.firstAdd,
|
|
821
|
+
...(change.wireModes ? {wireModes: true} : {}),
|
|
822
|
+
...(change.moduleRemoved ? {moduleRemoved: true} : {}),
|
|
823
|
+
...(change.themeModes ? {themeModes: true} : {}),
|
|
644
824
|
},
|
|
645
825
|
],
|
|
646
826
|
{
|
|
@@ -651,20 +831,88 @@ function printThemeApp(result) {
|
|
|
651
831
|
'slug',
|
|
652
832
|
'changed',
|
|
653
833
|
'firstAdd',
|
|
834
|
+
'wireModes',
|
|
835
|
+
'moduleRemoved',
|
|
836
|
+
'themeModes',
|
|
654
837
|
],
|
|
655
838
|
layout: 'stacked',
|
|
656
839
|
},
|
|
657
840
|
),
|
|
658
841
|
);
|
|
659
842
|
for (const note of result.data.notes ?? []) emit(text(`[note] ${note}`));
|
|
660
|
-
if (!change.firstAdd) return;
|
|
661
843
|
const stem = path.basename(modulePath, path.extname(modulePath));
|
|
844
|
+
const appProvider = result.data.appProvider;
|
|
845
|
+
// The one provider that takes the theme (its manifest's themeProp) is the
|
|
846
|
+
// app's wiring: each receipt shows that provider, with the module's theme
|
|
847
|
+
// passed to it, in place of a Theme wrap the app does not render.
|
|
848
|
+
const provider =
|
|
849
|
+
appProvider?.line && appProvider.wiredBy.length === 1
|
|
850
|
+
? appProvider.wiredBy[0]
|
|
851
|
+
: null;
|
|
852
|
+
const providerCode = () =>
|
|
853
|
+
code(
|
|
854
|
+
`import {${provider?.export}} from '${provider?.from}';\n` +
|
|
855
|
+
`import {themes, defaultThemeSlug${/\bthemeModes\[/.test(String(appProvider?.line)) ? ', themeModes' : ''}} from './${stem}';\n\n` +
|
|
856
|
+
`${appProvider?.line}\n <App />\n</${provider?.export}>`,
|
|
857
|
+
);
|
|
858
|
+
if (change.moduleRemoved) {
|
|
859
|
+
if (appProvider && provider) {
|
|
860
|
+
emit(
|
|
861
|
+
text(
|
|
862
|
+
`Removed ${change.slug}, the only added theme, and deleted ${modulePath}. ${appProvider.wire}`,
|
|
863
|
+
),
|
|
864
|
+
providerCode(),
|
|
865
|
+
);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
emit(
|
|
869
|
+
text(
|
|
870
|
+
`Removed ${change.slug}, the only added theme, and deleted ${modulePath}. Undo its wiring in the app root: delete the module's import (and the Theme import when nothing else uses Theme), and keep only the children of the Theme wrapper:`,
|
|
871
|
+
),
|
|
872
|
+
code(
|
|
873
|
+
"import {Theme} from '@astryxdesign/core/theme';\n" +
|
|
874
|
+
`import {themes, defaultThemeSlug${change.themeModes ? ', themeModes' : ''}} from './${stem}';\n\n` +
|
|
875
|
+
`<Theme theme={themes[defaultThemeSlug]}${change.themeModes ? " mode={themeModes[defaultThemeSlug] ?? 'system'}" : ''}>\n <App />\n</Theme>`,
|
|
876
|
+
),
|
|
877
|
+
);
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
if (!change.firstAdd) {
|
|
881
|
+
// The module now lists one-mode themes' modes: the app's wiring, made
|
|
882
|
+
// without them, passes the selected theme's mode from now on.
|
|
883
|
+
if (change.wireModes) {
|
|
884
|
+
if (appProvider) {
|
|
885
|
+
emit(text(appProvider.wire), ...(provider ? [providerCode()] : []));
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
emit(
|
|
889
|
+
text(
|
|
890
|
+
"The theme module now exports themeModes. Pass the selected theme's mode to Theme in the app root:",
|
|
891
|
+
),
|
|
892
|
+
code(
|
|
893
|
+
"import {Theme} from '@astryxdesign/core/theme';\n" +
|
|
894
|
+
`import {themes, defaultThemeSlug, themeModes} from './${stem}';\n\n` +
|
|
895
|
+
"<Theme theme={themes[defaultThemeSlug]} mode={themeModes[defaultThemeSlug] ?? 'system'}>\n <App />\n</Theme>",
|
|
896
|
+
),
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
// With a theme of one color mode added, the generated module lists each
|
|
902
|
+
// such theme's mode in `themeModes`, and the wiring passes the selected
|
|
903
|
+
// theme's (none for a two-mode theme, which follows the system).
|
|
904
|
+
const modes = result.data.themes.some(t => t.mode);
|
|
905
|
+
if (appProvider && provider) {
|
|
906
|
+
emit(text(appProvider.wire), providerCode());
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
662
909
|
emit(
|
|
910
|
+
...(appProvider ? [text(appProvider.wire)] : []),
|
|
663
911
|
text('Wire the generated module once in the app root:'),
|
|
664
912
|
code(
|
|
665
913
|
"import {Theme} from '@astryxdesign/core/theme';\n" +
|
|
666
|
-
`import {themes, defaultThemeSlug} from './${stem}';\n\n` +
|
|
667
|
-
|
|
914
|
+
`import {themes, defaultThemeSlug${modes ? ', themeModes' : ''}} from './${stem}';\n\n` +
|
|
915
|
+
`<Theme theme={themes[defaultThemeSlug]}${modes ? " mode={themeModes[defaultThemeSlug] ?? 'system'}" : ''}>\n <App />\n</Theme>`,
|
|
668
916
|
),
|
|
669
917
|
);
|
|
670
918
|
}
|
|
@@ -964,90 +1212,154 @@ function registerPaletteCommands(
|
|
|
964
1212
|
* @param {ThemeCommandWords} words
|
|
965
1213
|
*/
|
|
966
1214
|
function registerThemeCommands(theme, program, docs, words) {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1215
|
+
/** The locks the group holds for one build run (see words.hold below). */
|
|
1216
|
+
/** @type {(() => Promise<void>) | undefined} */
|
|
1217
|
+
let release;
|
|
1218
|
+
const buildAction = async (
|
|
1219
|
+
/** @type {string[]} */ typedFiles,
|
|
1220
|
+
/** @type {{out?: string, watch?: boolean, check?: boolean, iconsSpecifier?: string, family?: boolean, familyKey?: string}} */ options,
|
|
1221
|
+
) => {
|
|
1222
|
+
// A group may name the path a source builds under (an editor theme
|
|
1223
|
+
// reached through a link builds under its own path, which its
|
|
1224
|
+
// outputs' headers name).
|
|
1225
|
+
const files = typedFiles.map(
|
|
1226
|
+
file => words.sourcePath?.(file, process.cwd()) ?? file,
|
|
1227
|
+
);
|
|
1228
|
+
// Every suggested build passes the group's own checks before it is
|
|
1229
|
+
// shown (from a subfolder an editor theme compiles from the app
|
|
1230
|
+
// root): a suggestion the group refuses gives way to the group's own
|
|
1231
|
+
// suggestion, which does.
|
|
1232
|
+
/** @param {Array<{name: string, reason?: string}> | undefined} list */
|
|
1233
|
+
const vet = async list => {
|
|
1234
|
+
/** @type {Array<{name: string, reason?: string}>} */
|
|
1235
|
+
const out = [];
|
|
1236
|
+
for (const s of list ?? []) {
|
|
1237
|
+
const run = /** @type {any} */ (s)[BUILD_RUN];
|
|
1238
|
+
const refused = run
|
|
1239
|
+
? await words.preflight?.(run.files, {
|
|
1240
|
+
cwd: process.cwd(),
|
|
1241
|
+
...run.mode,
|
|
1242
|
+
})
|
|
1243
|
+
: null;
|
|
1244
|
+
out.push(...(refused ? (refused.suggestions ?? []) : [s]));
|
|
1245
|
+
}
|
|
1246
|
+
return out;
|
|
1247
|
+
};
|
|
1248
|
+
/** @param {string} message @param {Parameters<typeof cliError>[1]} [opts] */
|
|
1249
|
+
const refuse = async (message, opts = {}) =>
|
|
1250
|
+
cliError(message, {
|
|
1251
|
+
...opts,
|
|
1252
|
+
suggestions: await vet(opts.suggestions),
|
|
1253
|
+
});
|
|
1254
|
+
/**
|
|
1255
|
+
* @param {import('../../../api/error.mjs').AstryxError} err
|
|
1256
|
+
* @param {ThemeCommandWords} [w]
|
|
1257
|
+
* @param {Array<{name: string, reason?: string}>} [fallback]
|
|
1258
|
+
*/
|
|
1259
|
+
const refuseTheme = async (err, w = words, fallback = []) => {
|
|
1260
|
+
err.suggestions = await vet(err.suggestions);
|
|
1261
|
+
return themeError(err, w, await vet(fallback));
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
const json = program.opts().json || false;
|
|
1265
|
+
// The report is one line per theme unless the user asks for
|
|
1266
|
+
// `--detail full`, which prints the install example and the font
|
|
1267
|
+
// guidance: once for one theme, as it always has, and once for the whole
|
|
1268
|
+
// batch rather than per theme.
|
|
1269
|
+
const detailChosen = program.getOptionValueSource('detail') !== 'default';
|
|
1270
|
+
const detail = detailChosen ? program.opts().detail : undefined;
|
|
1271
|
+
const compact = detail !== 'full';
|
|
1272
|
+
const entries = files.map(file => ({
|
|
1273
|
+
file,
|
|
1274
|
+
filePath: path.resolve(process.cwd(), file),
|
|
1275
|
+
}));
|
|
1276
|
+
|
|
1277
|
+
for (const entry of entries) {
|
|
1278
|
+
if (fs.existsSync(entry.filePath)) continue;
|
|
1279
|
+
// A quoted glob reaches us unexpanded: say so rather than reporting a
|
|
1280
|
+
// literal `themes/*.ts` as a missing file.
|
|
1281
|
+
const looksGlobby = /[*?[\]{}]/.test(entry.file);
|
|
1282
|
+
const guesses = looksGlobby
|
|
1283
|
+
? []
|
|
1284
|
+
: themeSourceGuesses(entry.file, process.cwd());
|
|
1285
|
+
// An editor theme's own source, deleted by hand: the editor writes
|
|
1286
|
+
// it again.
|
|
1287
|
+
const rewrite = looksGlobby
|
|
1288
|
+
? null
|
|
1289
|
+
: (words.missingSource?.(entry.file, process.cwd()) ?? null);
|
|
1290
|
+
// A file another command generates, gone from a folder whose other
|
|
1291
|
+
// files carry that command's mark: that command writes it again; a
|
|
1292
|
+
// blank theme template is no way back.
|
|
1293
|
+
const by =
|
|
1294
|
+
rewrite || looksGlobby ? null : generatedSourceCommand(entry.filePath);
|
|
1295
|
+
if (by)
|
|
1296
|
+
return await refuse(
|
|
1297
|
+
`File not found: ${entry.filePath}. It is a generated file: the files beside it are written by ${by}, so rebuild it with the command that made it.`,
|
|
1298
|
+
{
|
|
1299
|
+
code: ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1300
|
+
suggestions: /^astryx(\s|$)/.test(by)
|
|
1004
1301
|
? [
|
|
1005
1302
|
{
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
// run stays one.
|
|
1009
|
-
name: buildSuggestion(
|
|
1010
|
-
entry.file,
|
|
1011
|
-
options,
|
|
1012
|
-
process.cwd(),
|
|
1013
|
-
words,
|
|
1014
|
-
{
|
|
1015
|
-
glob: true,
|
|
1016
|
-
family: Boolean(options.family),
|
|
1017
|
-
...(options.family && options.familyKey
|
|
1018
|
-
? {familyKey: String(options.familyKey)}
|
|
1019
|
-
: {}),
|
|
1020
|
-
},
|
|
1021
|
-
),
|
|
1022
|
-
reason:
|
|
1023
|
-
'globs are expanded by your shell; pass the pattern unquoted, or list the files',
|
|
1303
|
+
name: `${getCliInvocation(process.cwd())} ${by.replace(/^astryx\s*/, '')}`.trim(),
|
|
1304
|
+
reason: 'the command that writes these files',
|
|
1024
1305
|
},
|
|
1025
1306
|
]
|
|
1026
|
-
:
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1307
|
+
: [],
|
|
1308
|
+
},
|
|
1309
|
+
);
|
|
1310
|
+
return await refuse(`File not found: ${entry.filePath}`, {
|
|
1311
|
+
code: ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1312
|
+
suggestions: rewrite
|
|
1313
|
+
? [rewrite]
|
|
1314
|
+
: looksGlobby
|
|
1315
|
+
? // The pattern, expanded as the shell would: the theme
|
|
1316
|
+
// sources it matches, each a build the checks then vet (an
|
|
1317
|
+
// editor theme's own files give way to its source); a
|
|
1318
|
+
// family run, the one family of them.
|
|
1319
|
+
globSuggestions(entry.file, options, words)
|
|
1320
|
+
: guesses.length > 0
|
|
1321
|
+
? guesses.map(guess =>
|
|
1322
|
+
buildRun(
|
|
1323
|
+
{
|
|
1324
|
+
// The same build of that source: a --check stays a
|
|
1325
|
+
// check.
|
|
1326
|
+
name: buildSuggestion(
|
|
1327
|
+
guess,
|
|
1328
|
+
options,
|
|
1329
|
+
process.cwd(),
|
|
1330
|
+
words,
|
|
1331
|
+
),
|
|
1332
|
+
reason: 'a theme source that exists',
|
|
1333
|
+
},
|
|
1334
|
+
[guess],
|
|
1335
|
+
{
|
|
1336
|
+
check: Boolean(options.check),
|
|
1337
|
+
family: Boolean(options.family),
|
|
1338
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1339
|
+
out: options.out,
|
|
1340
|
+
},
|
|
1341
|
+
),
|
|
1342
|
+
)
|
|
1343
|
+
: [
|
|
1344
|
+
themeCommand(
|
|
1345
|
+
words,
|
|
1346
|
+
'template',
|
|
1347
|
+
['theme.template.ts'],
|
|
1348
|
+
'start a theme source from the annotated template',
|
|
1349
|
+
),
|
|
1350
|
+
],
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1042
1353
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1354
|
+
/**
|
|
1355
|
+
* This build again without some of its options, as the way out of a
|
|
1356
|
+
* refusal about how they combine.
|
|
1357
|
+
* @param {Array<'out' | 'watch' | 'check' | 'family'>} drop
|
|
1358
|
+
* @param {string} reason
|
|
1359
|
+
* @param {string[]} [only] the files to build, when not all of them
|
|
1360
|
+
*/
|
|
1361
|
+
const buildWithout = (drop, reason, only = files) =>
|
|
1362
|
+
buildRun(
|
|
1051
1363
|
themeCommand(
|
|
1052
1364
|
words,
|
|
1053
1365
|
words.build,
|
|
@@ -1065,407 +1377,503 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1065
1377
|
: []),
|
|
1066
1378
|
],
|
|
1067
1379
|
reason,
|
|
1068
|
-
)
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
words,
|
|
1078
|
-
'template',
|
|
1079
|
-
['theme.template.ts'],
|
|
1080
|
-
'an annotated theme source that builds, to compare with',
|
|
1081
|
-
),
|
|
1082
|
-
];
|
|
1083
|
-
|
|
1084
|
-
// One file passed twice would build twice and report two themes.
|
|
1085
|
-
const seenFiles = new Set();
|
|
1086
|
-
for (const entry of entries) {
|
|
1087
|
-
const key = fs.realpathSync(entry.filePath);
|
|
1088
|
-
if (seenFiles.has(key)) {
|
|
1089
|
-
const once = entries
|
|
1090
|
-
.filter(
|
|
1091
|
-
(other, index) =>
|
|
1092
|
-
entries.findIndex(
|
|
1093
|
-
first =>
|
|
1094
|
-
fs.realpathSync(first.filePath) ===
|
|
1095
|
-
fs.realpathSync(other.filePath),
|
|
1096
|
-
) === index,
|
|
1097
|
-
)
|
|
1098
|
-
.map(other => other.file);
|
|
1099
|
-
return cliError(
|
|
1100
|
-
`${entry.file} is given more than once. Select each theme file once.`,
|
|
1101
|
-
{
|
|
1102
|
-
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1103
|
-
suggestions: [buildWithout([], 'each file once', once)],
|
|
1104
|
-
},
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
seenFiles.add(key);
|
|
1108
|
-
}
|
|
1380
|
+
),
|
|
1381
|
+
only,
|
|
1382
|
+
{
|
|
1383
|
+
check: Boolean(options.check) && !drop.includes('check'),
|
|
1384
|
+
family: Boolean(options.family) && !drop.includes('family'),
|
|
1385
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1386
|
+
out: drop.includes('out') ? undefined : options.out,
|
|
1387
|
+
},
|
|
1388
|
+
);
|
|
1109
1389
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1390
|
+
// A refusal from the build that names no command: without --out the
|
|
1391
|
+
// outputs go beside the source; otherwise the annotated template shows
|
|
1392
|
+
// a theme source that builds.
|
|
1393
|
+
const buildFallback = options.out
|
|
1394
|
+
? [buildWithout(['out'], 'write the outputs beside the source')]
|
|
1395
|
+
: [
|
|
1396
|
+
themeCommand(
|
|
1397
|
+
words,
|
|
1398
|
+
'template',
|
|
1399
|
+
['theme.template.ts'],
|
|
1400
|
+
'an annotated theme source that builds, to compare with',
|
|
1401
|
+
),
|
|
1402
|
+
];
|
|
1403
|
+
|
|
1404
|
+
// One file passed twice would build twice and report two themes.
|
|
1405
|
+
const seenFiles = new Set();
|
|
1406
|
+
for (const entry of entries) {
|
|
1407
|
+
const key = fs.realpathSync(entry.filePath);
|
|
1408
|
+
if (seenFiles.has(key)) {
|
|
1409
|
+
const once = entries
|
|
1410
|
+
.filter(
|
|
1411
|
+
(other, index) =>
|
|
1412
|
+
entries.findIndex(
|
|
1413
|
+
first =>
|
|
1414
|
+
fs.realpathSync(first.filePath) ===
|
|
1415
|
+
fs.realpathSync(other.filePath),
|
|
1416
|
+
) === index,
|
|
1417
|
+
)
|
|
1418
|
+
.map(other => other.file);
|
|
1419
|
+
return await refuse(
|
|
1420
|
+
`${entry.file} is given more than once. Select each theme file once.`,
|
|
1118
1421
|
{
|
|
1119
1422
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1120
|
-
suggestions: [
|
|
1121
|
-
{
|
|
1122
|
-
...themeCommand(
|
|
1123
|
-
words,
|
|
1124
|
-
words.build,
|
|
1125
|
-
[
|
|
1126
|
-
...files,
|
|
1127
|
-
// --out names one output, so it goes with one file only.
|
|
1128
|
-
...(options.out && files.length === 1
|
|
1129
|
-
? ['--out', options.out]
|
|
1130
|
-
: []),
|
|
1131
|
-
...(options.iconsSpecifier
|
|
1132
|
-
? ['--icons-specifier', options.iconsSpecifier]
|
|
1133
|
-
: []),
|
|
1134
|
-
...(options.check ? ['--check'] : []),
|
|
1135
|
-
],
|
|
1136
|
-
'build each theme on its own',
|
|
1137
|
-
),
|
|
1138
|
-
},
|
|
1139
|
-
],
|
|
1423
|
+
suggestions: [buildWithout([], 'each file once', once)],
|
|
1140
1424
|
},
|
|
1141
1425
|
);
|
|
1142
1426
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1427
|
+
seenFiles.add(key);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
// Family mode is a thin orchestration branch over the existing build API.
|
|
1431
|
+
// Its key is required exactly with --family, and options that describe one
|
|
1432
|
+
// standalone output or a long-running loop remain intentionally separate.
|
|
1433
|
+
if (Boolean(options.family) !== Boolean(options.familyKey)) {
|
|
1434
|
+
return await refuse(
|
|
1435
|
+
options.family
|
|
1436
|
+
? '--family requires --family-key <key>'
|
|
1437
|
+
: '--family-key requires --family',
|
|
1438
|
+
{
|
|
1145
1439
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1146
1440
|
suggestions: [
|
|
1147
|
-
|
|
1441
|
+
buildRun(
|
|
1442
|
+
themeCommand(
|
|
1443
|
+
words,
|
|
1444
|
+
words.build,
|
|
1445
|
+
[
|
|
1446
|
+
...files,
|
|
1447
|
+
// --out names one output, so it goes with one file only.
|
|
1448
|
+
...(options.out && files.length === 1
|
|
1449
|
+
? ['--out', options.out]
|
|
1450
|
+
: []),
|
|
1451
|
+
...(options.iconsSpecifier
|
|
1452
|
+
? ['--icons-specifier', options.iconsSpecifier]
|
|
1453
|
+
: []),
|
|
1454
|
+
...(options.check ? ['--check'] : []),
|
|
1455
|
+
],
|
|
1456
|
+
'build each theme on its own',
|
|
1457
|
+
),
|
|
1458
|
+
files,
|
|
1459
|
+
{
|
|
1460
|
+
check: Boolean(options.check),
|
|
1461
|
+
family: false,
|
|
1462
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1463
|
+
out: files.length === 1 ? options.out : undefined,
|
|
1464
|
+
},
|
|
1465
|
+
),
|
|
1148
1466
|
],
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1467
|
+
},
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1470
|
+
if (options.family && options.out) {
|
|
1471
|
+
return await refuse('--family cannot be combined with --out', {
|
|
1472
|
+
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1473
|
+
suggestions: [
|
|
1474
|
+
buildWithout(['out'], 'family outputs go beside the family root'),
|
|
1475
|
+
],
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
if (options.family && options.watch) {
|
|
1479
|
+
return await refuse('--family cannot be combined with --watch', {
|
|
1480
|
+
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1481
|
+
suggestions: [buildWithout(['watch'], 'build the family once')],
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
// --check and --watch are mutually exclusive: check is a one-shot,
|
|
1486
|
+
// exit-coded verification; watch is a long-running rebuild loop.
|
|
1487
|
+
if (options.check && options.watch) {
|
|
1488
|
+
return await refuse('--check cannot be combined with --watch', {
|
|
1489
|
+
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1490
|
+
suggestions: [buildWithout(['watch'], 'check once')],
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// --out names one output file, so it cannot describe N themes. Without
|
|
1495
|
+
// it each theme writes `<theme name>.css` beside its source, which is
|
|
1496
|
+
// what a multi-theme build wants anyway.
|
|
1497
|
+
if (options.out && entries.length > 1) {
|
|
1498
|
+
return await refuse(
|
|
1499
|
+
`--out takes a single output path and ${entries.length} theme files were given. ` +
|
|
1500
|
+
'Build them without --out (each theme writes <name>.css next to its source), ' +
|
|
1501
|
+
'or run one invocation per theme.',
|
|
1502
|
+
{
|
|
1153
1503
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1154
|
-
suggestions: [
|
|
1155
|
-
|
|
1156
|
-
|
|
1504
|
+
suggestions: [
|
|
1505
|
+
buildWithout(
|
|
1506
|
+
['out'],
|
|
1507
|
+
'each theme writes <name>.css next to its source',
|
|
1508
|
+
),
|
|
1509
|
+
],
|
|
1510
|
+
},
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1157
1513
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1514
|
+
// Watch mode: run an initial build, then rebuild on every change to the
|
|
1515
|
+
// theme file. Watch is a human-interactive, long-running mode — it is not
|
|
1516
|
+
// supported in --json (machine) mode, which expects a single envelope.
|
|
1517
|
+
if (options.watch) {
|
|
1518
|
+
if (json) {
|
|
1519
|
+
return await refuse('--watch is not supported with --json', {
|
|
1162
1520
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1163
|
-
suggestions: [
|
|
1521
|
+
suggestions: [
|
|
1522
|
+
buildWithout(['watch'], 'build once, with a JSON result'),
|
|
1523
|
+
],
|
|
1164
1524
|
});
|
|
1165
1525
|
}
|
|
1526
|
+
await runThemeBuildWatch(entries, {...options, detail}, words);
|
|
1527
|
+
return NO_RESULT_SET;
|
|
1528
|
+
}
|
|
1166
1529
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1530
|
+
// Non-watch: delegate to the API compiler, once per theme, in argument
|
|
1531
|
+
// order. Enable human output unless in --json mode (log → stdout via
|
|
1532
|
+
// humanLog, warn/error → stderr). The "Building theme from" line, the
|
|
1533
|
+
// [ok]/[warn] lines, and the install instructions are all emitted from
|
|
1534
|
+
// inside themeBuild via the shared logger.
|
|
1535
|
+
logger.setSilent(json);
|
|
1536
|
+
// Started by a watcher (runThemeBuildWatch): hand the editor-folder
|
|
1537
|
+
// warning to it, and let the channel not keep this build alive.
|
|
1538
|
+
const watchChild =
|
|
1539
|
+
typeof process.send === 'function' && process.argv0 === WATCH_CHILD_ARGV0;
|
|
1540
|
+
if (watchChild) {
|
|
1541
|
+
process.channel?.unref();
|
|
1542
|
+
setEditorFolderListener(warning => {
|
|
1543
|
+
// Held open until the message is out, then let go again.
|
|
1544
|
+
process.channel?.ref();
|
|
1545
|
+
process.send?.({type: WATCH_WARNING, text: warning}, () =>
|
|
1546
|
+
process.channel?.unref(),
|
|
1547
|
+
);
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
const refused = await words.preflight?.(files, {
|
|
1552
|
+
cwd: process.cwd(),
|
|
1553
|
+
check: options.check,
|
|
1554
|
+
family: Boolean(options.family),
|
|
1555
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1556
|
+
out: options.out,
|
|
1557
|
+
});
|
|
1558
|
+
if (refused)
|
|
1559
|
+
return await refuseTheme(
|
|
1560
|
+
(await words.follow?.(refused, process.cwd())) ?? refused,
|
|
1561
|
+
words,
|
|
1562
|
+
buildFallback,
|
|
1563
|
+
);
|
|
1564
|
+
|
|
1565
|
+
if (options.family) {
|
|
1566
|
+
try {
|
|
1567
|
+
const result = await themeBuildFamily(
|
|
1568
|
+
files,
|
|
1175
1569
|
{
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
['out'],
|
|
1180
|
-
'each theme writes <name>.css next to its source',
|
|
1181
|
-
),
|
|
1182
|
-
],
|
|
1570
|
+
familyKey: /** @type {string} */ (options.familyKey),
|
|
1571
|
+
check: options.check,
|
|
1572
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1183
1573
|
},
|
|
1574
|
+
{cwd: process.cwd()},
|
|
1575
|
+
{commandWords: words},
|
|
1184
1576
|
);
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
buildWithout(['watch'], 'build once, with a JSON result'),
|
|
1196
|
-
],
|
|
1197
|
-
});
|
|
1577
|
+
if (json) jsonOut(result);
|
|
1578
|
+
if (
|
|
1579
|
+
result.type === 'theme.build.check' &&
|
|
1580
|
+
!(
|
|
1581
|
+
/** @type {import('../../../api/theme/theme.type.mjs').ThemeBuildCheckResponse} */ (
|
|
1582
|
+
result
|
|
1583
|
+
).data.upToDate
|
|
1584
|
+
)
|
|
1585
|
+
) {
|
|
1586
|
+
process.exitCode = 1;
|
|
1198
1587
|
}
|
|
1199
|
-
await runThemeBuildWatch(entries, {...options, detail}, words);
|
|
1200
1588
|
return NO_RESULT_SET;
|
|
1589
|
+
} catch (e) {
|
|
1590
|
+
const err =
|
|
1591
|
+
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
1592
|
+
return await refuseTheme(err, words, [
|
|
1593
|
+
buildWithout(['family'], 'build each theme on its own'),
|
|
1594
|
+
]);
|
|
1201
1595
|
}
|
|
1596
|
+
}
|
|
1202
1597
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1598
|
+
// --json and --check keep their own output at every detail level.
|
|
1599
|
+
const report = !json && !options.check && (entries.length > 1 || compact);
|
|
1600
|
+
/** @type {import('../../../api/theme/build/build.mjs').ThemeBuildTrailer[]} */
|
|
1601
|
+
const trailers = [];
|
|
1602
|
+
|
|
1603
|
+
/** @type {Array<{file: string, receipt: import('../../../api/theme/theme.type.mjs').ThemeBuildResponse | import('../../../api/theme/theme.type.mjs').ThemeBuildCheckResponse | null}>} */
|
|
1604
|
+
const results = [];
|
|
1605
|
+
let stale = false;
|
|
1606
|
+
// A batch builds every theme first and then writes them in order, so
|
|
1607
|
+
// two themes that build the same files are refused before either
|
|
1608
|
+
// writes. Any other failure writes the themes built before it, as a
|
|
1609
|
+
// shell loop under `set -e` would have, and stops.
|
|
1610
|
+
const deferred = !options.check && entries.length > 1;
|
|
1611
|
+
// Each built theme keeps its writes and what it prints together; what
|
|
1612
|
+
// it prints waits until its outputs are written, so no `[ok]` line
|
|
1613
|
+
// names a file that is never written.
|
|
1614
|
+
/** @type {Array<{writes: Array<Array<{dest: string, content: string}>>, lines: Array<() => void>}>} */
|
|
1615
|
+
const built = [];
|
|
1616
|
+
const publish = () => {
|
|
1617
|
+
for (const theme of built.splice(0)) {
|
|
1618
|
+
writeDeferredBuildOutputs(theme.writes);
|
|
1619
|
+
for (const show of theme.lines) show();
|
|
1223
1620
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1621
|
+
};
|
|
1622
|
+
const writeFailed = async (/** @type {unknown} */ error) =>
|
|
1623
|
+
refuseTheme(
|
|
1624
|
+
/** @type {import('../../../api/error.mjs').AstryxError} */ (error),
|
|
1625
|
+
words,
|
|
1626
|
+
[
|
|
1627
|
+
buildWithout(
|
|
1628
|
+
[],
|
|
1629
|
+
'run the same build again once the files can be written',
|
|
1630
|
+
),
|
|
1631
|
+
],
|
|
1632
|
+
);
|
|
1633
|
+
/** @type {Map<string, string>} */
|
|
1634
|
+
const claimedOutputs = new Map();
|
|
1635
|
+
for (const entry of entries) {
|
|
1636
|
+
/** @type {Array<() => void>} */
|
|
1637
|
+
const lines = [];
|
|
1638
|
+
/** @type {Array<Array<{dest: string, content: string}>>} */
|
|
1639
|
+
const writes = [];
|
|
1640
|
+
const log = logger.log;
|
|
1641
|
+
const warn = logger.warn;
|
|
1642
|
+
// A group may know fonts the app loads that the theme file cannot
|
|
1643
|
+
// say (the editor's app copy stylesheet): the build leaves them out
|
|
1644
|
+
// of every "not loaded" note, family by family.
|
|
1645
|
+
const loads =
|
|
1646
|
+
(await words.loadedFonts?.(entry.file, process.cwd())) ?? null;
|
|
1647
|
+
// A check whose result a group may still fail holds its lines
|
|
1648
|
+
// until the group has looked.
|
|
1649
|
+
/** @type {Array<string | undefined> | null} */
|
|
1650
|
+
let held = null;
|
|
1651
|
+
if (options.check && words.extraData && !deferred) {
|
|
1652
|
+
held = [];
|
|
1653
|
+
logger.log = (/** @type {string | undefined} */ message) => {
|
|
1654
|
+
held?.push(message);
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
if (deferred) {
|
|
1658
|
+
logger.log = (/** @type {string | undefined} */ message) => {
|
|
1659
|
+
lines.push(() => log.call(logger, message));
|
|
1660
|
+
};
|
|
1661
|
+
logger.warn = (/** @type {string | undefined} */ message) => {
|
|
1662
|
+
lines.push(() => warn.call(logger, message));
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
try {
|
|
1666
|
+
const buildOptions = {
|
|
1667
|
+
out: options.out,
|
|
1668
|
+
check: options.check,
|
|
1669
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1670
|
+
};
|
|
1671
|
+
/** @type {import('../../../api/theme/build/build.mjs').ThemeBuildHandOff} */
|
|
1672
|
+
const handOff = {
|
|
1673
|
+
claimedOutputs,
|
|
1674
|
+
deferredWrites: deferred ? writes : undefined,
|
|
1675
|
+
commandWords: words,
|
|
1676
|
+
colorModes: words.colorModes?.(entry.file, process.cwd()) ?? null,
|
|
1677
|
+
fontHelp: words.fontHelp?.(entry.file, process.cwd()) ?? null,
|
|
1678
|
+
install: words.install?.(entry.file, process.cwd()) ?? null,
|
|
1679
|
+
loadedFonts: loads,
|
|
1680
|
+
};
|
|
1681
|
+
let result;
|
|
1682
|
+
if (report) {
|
|
1683
|
+
const built = await themeBuildForReport(
|
|
1684
|
+
entry.file,
|
|
1685
|
+
buildOptions,
|
|
1243
1686
|
{cwd: process.cwd()},
|
|
1244
|
-
{
|
|
1687
|
+
{compact},
|
|
1688
|
+
handOff,
|
|
1245
1689
|
);
|
|
1246
|
-
|
|
1247
|
-
if (
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1690
|
+
result = built.receipt;
|
|
1691
|
+
if (built.trailer) trailers.push(built.trailer);
|
|
1692
|
+
if (compact && result?.type === 'theme.build') {
|
|
1693
|
+
const {outputs, sizeKB, tokenCount, componentCount} = result.data;
|
|
1694
|
+
const show = () =>
|
|
1695
|
+
emit(
|
|
1696
|
+
text(
|
|
1697
|
+
`[ok] ${outputs.css} (${sizeKB} KB, ${tokenCount} token overrides, ${componentCount} component overrides)`,
|
|
1698
|
+
),
|
|
1699
|
+
);
|
|
1700
|
+
if (deferred) lines.push(show);
|
|
1701
|
+
else show();
|
|
1256
1702
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1703
|
+
} else {
|
|
1704
|
+
result = await themeBuildWithHandOff(
|
|
1705
|
+
entry.file,
|
|
1706
|
+
buildOptions,
|
|
1707
|
+
{cwd: process.cwd()},
|
|
1708
|
+
handOff,
|
|
1709
|
+
);
|
|
1264
1710
|
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1711
|
+
logger.log = log;
|
|
1712
|
+
logger.warn = warn;
|
|
1713
|
+
// A group may add to a build's result (the editor's app copy:
|
|
1714
|
+
// what keeps it behind, and in a check whether it is current).
|
|
1715
|
+
const extra = await words.extraData?.(entry.file, process.cwd(), {
|
|
1716
|
+
check: Boolean(options.check),
|
|
1717
|
+
upToDate: /** @type {any} */ (result)?.data?.upToDate,
|
|
1718
|
+
out: options.out,
|
|
1719
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1720
|
+
});
|
|
1721
|
+
if (extra && result?.data) mergeResultData(result.data, extra);
|
|
1722
|
+
// A check the group failed says so where the check said ok.
|
|
1723
|
+
if (held) {
|
|
1724
|
+
logger.log = log;
|
|
1725
|
+
for (const line of held)
|
|
1726
|
+
log.call(
|
|
1727
|
+
logger,
|
|
1728
|
+
extra?.upToDate === false &&
|
|
1729
|
+
typeof line === 'string' &&
|
|
1730
|
+
/^\s*\[ok\]/.test(line)
|
|
1731
|
+
? `[fail] ${String(extra.appCopyStale ?? 'not up to date')}`
|
|
1732
|
+
: line,
|
|
1733
|
+
);
|
|
1734
|
+
held = null;
|
|
1289
1735
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
),
|
|
1300
|
-
],
|
|
1301
|
-
);
|
|
1302
|
-
/** @type {Map<string, string>} */
|
|
1303
|
-
const claimedOutputs = new Map();
|
|
1304
|
-
for (const entry of entries) {
|
|
1305
|
-
/** @type {Array<() => void>} */
|
|
1306
|
-
const lines = [];
|
|
1307
|
-
/** @type {Array<Array<{dest: string, content: string}>>} */
|
|
1308
|
-
const writes = [];
|
|
1309
|
-
const log = logger.log;
|
|
1310
|
-
const warn = logger.warn;
|
|
1311
|
-
if (deferred) {
|
|
1312
|
-
logger.log = (/** @type {string | undefined} */ message) => {
|
|
1313
|
-
lines.push(() => log.call(logger, message));
|
|
1314
|
-
};
|
|
1315
|
-
logger.warn = (/** @type {string | undefined} */ message) => {
|
|
1316
|
-
lines.push(() => warn.call(logger, message));
|
|
1317
|
-
};
|
|
1736
|
+
results.push({file: entry.file, receipt: result ?? null});
|
|
1737
|
+
if (deferred) built.push({writes, lines});
|
|
1738
|
+
if (
|
|
1739
|
+
options.check &&
|
|
1740
|
+
result &&
|
|
1741
|
+
result.type === 'theme.build.check' &&
|
|
1742
|
+
!result.data.upToDate
|
|
1743
|
+
) {
|
|
1744
|
+
stale = true;
|
|
1318
1745
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
/** @type {import('../../../api/
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
const show = () =>
|
|
1345
|
-
emit(
|
|
1346
|
-
text(
|
|
1347
|
-
`[ok] ${outputs.css} (${sizeKB} KB, ${tokenCount} token overrides, ${componentCount} component overrides)`,
|
|
1348
|
-
),
|
|
1349
|
-
);
|
|
1350
|
-
if (deferred) lines.push(show);
|
|
1351
|
-
else show();
|
|
1352
|
-
}
|
|
1353
|
-
} else {
|
|
1354
|
-
result = await themeBuildWithHandOff(
|
|
1355
|
-
entry.file,
|
|
1356
|
-
buildOptions,
|
|
1357
|
-
{cwd: process.cwd()},
|
|
1358
|
-
handOff,
|
|
1359
|
-
);
|
|
1360
|
-
}
|
|
1361
|
-
logger.log = log;
|
|
1362
|
-
logger.warn = warn;
|
|
1363
|
-
results.push({file: entry.file, receipt: result ?? null});
|
|
1364
|
-
if (deferred) built.push({writes, lines});
|
|
1365
|
-
if (
|
|
1366
|
-
options.check &&
|
|
1367
|
-
result &&
|
|
1368
|
-
result.type === 'theme.build.check' &&
|
|
1369
|
-
!result.data.upToDate
|
|
1370
|
-
) {
|
|
1371
|
-
stale = true;
|
|
1372
|
-
}
|
|
1373
|
-
} catch (e) {
|
|
1374
|
-
logger.log = log;
|
|
1375
|
-
logger.warn = warn;
|
|
1376
|
-
const err =
|
|
1377
|
-
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
1378
|
-
// Stop at the first failure, as a shell loop under `set -e` does.
|
|
1379
|
-
// With several themes in flight the message alone rarely says which
|
|
1380
|
-
// one broke, so name it. Themes already written keep their install
|
|
1381
|
-
// and font guidance.
|
|
1382
|
-
if (/** @type {any} */ (err).outputCollision) {
|
|
1383
|
-
// Nothing is written, so only this theme's warnings are shown.
|
|
1384
|
-
for (const show of lines) show();
|
|
1385
|
-
return themeError(err, words, [
|
|
1386
|
-
buildWithout([], 'build the first theme on its own', [
|
|
1387
|
-
entries[0].file,
|
|
1388
|
-
]),
|
|
1389
|
-
]);
|
|
1390
|
-
}
|
|
1391
|
-
if (deferred) {
|
|
1392
|
-
try {
|
|
1393
|
-
publish();
|
|
1394
|
-
} catch (writeError) {
|
|
1395
|
-
return writeFailed(writeError);
|
|
1396
|
-
}
|
|
1397
|
-
// The failing theme's warnings, such as a missing package, say
|
|
1398
|
-
// why it failed.
|
|
1399
|
-
for (const show of lines) show();
|
|
1746
|
+
} catch (e) {
|
|
1747
|
+
logger.log = log;
|
|
1748
|
+
logger.warn = warn;
|
|
1749
|
+
for (const line of held ?? []) log.call(logger, line);
|
|
1750
|
+
held = null;
|
|
1751
|
+
const err =
|
|
1752
|
+
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
1753
|
+
// Stop at the first failure, as a shell loop under `set -e` does.
|
|
1754
|
+
// With several themes in flight the message alone rarely says which
|
|
1755
|
+
// one broke, so name it. Themes already written keep their install
|
|
1756
|
+
// and font guidance.
|
|
1757
|
+
if (/** @type {any} */ (err).outputCollision) {
|
|
1758
|
+
// Nothing is written, so only this theme's warnings are shown.
|
|
1759
|
+
for (const show of lines) show();
|
|
1760
|
+
return await refuseTheme(err, words, [
|
|
1761
|
+
buildWithout([], 'build the first theme on its own', [
|
|
1762
|
+
entries[0].file,
|
|
1763
|
+
]),
|
|
1764
|
+
]);
|
|
1765
|
+
}
|
|
1766
|
+
if (deferred) {
|
|
1767
|
+
try {
|
|
1768
|
+
publish();
|
|
1769
|
+
} catch (writeError) {
|
|
1770
|
+
return writeFailed(writeError);
|
|
1400
1771
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
return themeError(err, words, buildFallback);
|
|
1772
|
+
// The failing theme's warnings, such as a missing package, say
|
|
1773
|
+
// why it failed.
|
|
1774
|
+
for (const show of lines) show();
|
|
1405
1775
|
}
|
|
1776
|
+
if (report && compact) printCompactTrailer(trailers);
|
|
1777
|
+
else if (report) printBatchTrailer(trailers);
|
|
1778
|
+
if (entries.length > 1) err.message = `${entry.file}: ${err.message}`;
|
|
1779
|
+
return await refuseTheme(
|
|
1780
|
+
entries.length === 1
|
|
1781
|
+
? ((await words.follow?.(err, process.cwd())) ?? err)
|
|
1782
|
+
: err,
|
|
1783
|
+
words,
|
|
1784
|
+
buildFallback,
|
|
1785
|
+
);
|
|
1406
1786
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1787
|
+
}
|
|
1788
|
+
if (deferred) {
|
|
1789
|
+
try {
|
|
1790
|
+
publish();
|
|
1791
|
+
} catch (e) {
|
|
1792
|
+
return writeFailed(e);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
// A group follows the written outputs with writes of its own (the
|
|
1796
|
+
// editor's app copy), and each result says what they did.
|
|
1797
|
+
if (words.afterBuild && !options.check) {
|
|
1798
|
+
const more = await words.afterBuild(
|
|
1799
|
+
results.map(r => r.file),
|
|
1800
|
+
process.cwd(),
|
|
1801
|
+
);
|
|
1802
|
+
for (const r of results) {
|
|
1803
|
+
const data = /** @type {any} */ (r.receipt)?.data;
|
|
1804
|
+
if (data && more[r.file]) mergeResultData(data, more[r.file]);
|
|
1413
1805
|
}
|
|
1806
|
+
}
|
|
1414
1807
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
} else {
|
|
1421
|
-
/** @type {import('../../../api/theme/theme.type.mjs').ThemeBuildBatchResponse} */
|
|
1422
|
-
const batch = {
|
|
1423
|
-
type: 'theme.build.batch',
|
|
1424
|
-
data: {count: results.length, results},
|
|
1425
|
-
};
|
|
1426
|
-
jsonOut(batch);
|
|
1427
|
-
}
|
|
1808
|
+
if (json) {
|
|
1809
|
+
// One theme keeps the single-envelope contract it has always had; a
|
|
1810
|
+
// batch gets its own discriminant rather than N envelopes on stdout.
|
|
1811
|
+
if (entries.length === 1) {
|
|
1812
|
+
if (results[0].receipt) jsonOut(results[0].receipt);
|
|
1428
1813
|
} else {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
}
|
|
1814
|
+
/** @type {import('../../../api/theme/theme.type.mjs').ThemeBuildBatchResponse} */
|
|
1815
|
+
const batch = {
|
|
1816
|
+
type: 'theme.build.batch',
|
|
1817
|
+
data: {count: results.length, results},
|
|
1818
|
+
};
|
|
1819
|
+
jsonOut(batch);
|
|
1434
1820
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
: `\n[ok] Built ${entries.length} themes.`,
|
|
1441
|
-
),
|
|
1442
|
-
);
|
|
1821
|
+
} else {
|
|
1822
|
+
if (report && compact) {
|
|
1823
|
+
printCompactTrailer(trailers, {hint: !detailChosen});
|
|
1824
|
+
} else if (report) {
|
|
1825
|
+
printBatchTrailer(trailers);
|
|
1443
1826
|
}
|
|
1827
|
+
}
|
|
1828
|
+
if (!json && entries.length > 1) {
|
|
1829
|
+
emit(
|
|
1830
|
+
text(
|
|
1831
|
+
options.check
|
|
1832
|
+
? `\n${stale ? '[fail]' : '[ok]'} Checked ${entries.length} themes.`
|
|
1833
|
+
: `\n[ok] Built ${entries.length} themes.`,
|
|
1834
|
+
),
|
|
1835
|
+
);
|
|
1836
|
+
}
|
|
1444
1837
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1838
|
+
// Stale --check output is a failure after its receipt has been emitted.
|
|
1839
|
+
if (options.check && stale) {
|
|
1840
|
+
process.exitCode = 1;
|
|
1841
|
+
}
|
|
1449
1842
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1843
|
+
// Compiling a theme writes CSS; `--check` compares what is on disk. Both
|
|
1844
|
+
// are effects — the receipt (and the exit code) carry the outcome.
|
|
1845
|
+
return NO_RESULT_SET;
|
|
1846
|
+
};
|
|
1847
|
+
const buildCli = defineCommand(theme, docs.build, {
|
|
1848
|
+
fn: themeBuildFn,
|
|
1849
|
+
// The locks taken for the run go when the action ends, however it ends:
|
|
1850
|
+
// a refusal that exits releases them on exit, and a run in process
|
|
1851
|
+
// (which has no exit) here.
|
|
1852
|
+
action: async (
|
|
1853
|
+
/** @type {string[]} */ typedFiles,
|
|
1854
|
+
/** @type {any} */ options,
|
|
1855
|
+
) => {
|
|
1856
|
+
try {
|
|
1857
|
+
return await buildAction(typedFiles, options);
|
|
1858
|
+
} finally {
|
|
1859
|
+
await release?.();
|
|
1860
|
+
release = undefined;
|
|
1861
|
+
}
|
|
1453
1862
|
},
|
|
1454
1863
|
});
|
|
1455
1864
|
// A group may hold locks while a build or check runs (the editor's theme
|
|
1456
1865
|
// lock), so it never reads a change half written.
|
|
1457
1866
|
if (words.hold) {
|
|
1458
|
-
/** @type {(() => Promise<void>) | undefined} */
|
|
1459
|
-
let release;
|
|
1460
1867
|
buildCli.hook('preAction', async (_, cmd) => {
|
|
1461
1868
|
// Under --watch each rebuild runs on its own and takes the locks
|
|
1462
1869
|
// itself; holding them for the whole watch would block every one.
|
|
1463
1870
|
if (cmd.opts().watch) return;
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1871
|
+
const o = cmd.opts();
|
|
1872
|
+
release = await words.hold?.(cmd.args, {
|
|
1873
|
+
cwd: process.cwd(),
|
|
1874
|
+
check: Boolean(o.check),
|
|
1875
|
+
out: o.out,
|
|
1876
|
+
});
|
|
1469
1877
|
});
|
|
1470
1878
|
}
|
|
1471
1879
|
|