@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03
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 +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- 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 +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- 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 +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +219 -6
- 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 +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- 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/authoring-checks.mjs +6 -6
- 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/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -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 +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.mjs +51 -32
- 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 +5 -0
- package/api/search/_lexical.mjs +8 -2
- 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/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +122 -1
- package/api/theme/build/build.mjs +412 -84
- 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 +23 -3
- package/api/theme/build/font-warning.mjs +54 -5
- package/api/theme/build/icon-imports.mjs +25 -2
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +103 -3
- package/api/theme-edit/_adapter.mjs +961 -82
- package/api/theme-edit/_catalog.mjs +19 -4
- package/api/theme-edit/_check.d.mts +63 -24
- package/api/theme-edit/_check.mjs +2467 -362
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +89 -6
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +165 -54
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +31 -4
- package/api/theme-edit/_edit.mjs +2433 -204
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +759 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6473 -553
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- 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 +292 -0
- package/api/theme-edit/_normal.mjs +1454 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +18 -1
- package/api/theme-edit/_parts.mjs +246 -23
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +776 -187
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +582 -139
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +3 -1
- package/api/theme-edit/_settings.d.mts +417 -42
- package/api/theme-edit/_settings.mjs +3262 -424
- package/api/theme-edit/_tables.d.mts +15 -0
- package/api/theme-edit/_tables.mjs +63 -1
- package/api/theme-edit/_vet.d.mts +20 -0
- package/api/theme-edit/_vet.mjs +47 -2
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- 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/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- 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 +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- 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/use-a-theme.doc.mjs +1 -1
- 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/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/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/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- 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/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- 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/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -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/template.doc.mjs +2 -1
- 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/mixed-gallery/template.doc.mjs +2 -1
- 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/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/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/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- 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/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- 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/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/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +358 -63
- 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 +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- 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 +1 -1
- 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.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.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +317 -47
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- 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 +92 -21
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- 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-doc-files.mjs +2 -1
- 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 +38 -18
- package/foundation/discovery/template-adapter.d.mts +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.mjs +3 -2
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -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 +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +512 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -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/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- 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/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- 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/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- 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 +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- 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 {
|
|
@@ -85,6 +89,7 @@ import {
|
|
|
85
89
|
themeSourceFiles,
|
|
86
90
|
themeSourceGuesses,
|
|
87
91
|
buildSuggestion,
|
|
92
|
+
generatedSourceCommand,
|
|
88
93
|
writeDeferredBuildOutputs,
|
|
89
94
|
} from '../../../api/theme/build/build.mjs';
|
|
90
95
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
@@ -119,13 +124,45 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
|
|
|
119
124
|
* @property {string} build - The build subcommand's name: `build` or `compile`.
|
|
120
125
|
* @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
126
|
* @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 {(
|
|
127
|
+
* @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.
|
|
128
|
+
* @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).
|
|
129
|
+
* @property {(file: string, cwd: string) => string | null} [sourcePath] - The path a source builds under, when not the typed one; null to keep it.
|
|
130
|
+
* @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.
|
|
131
|
+
* @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.
|
|
132
|
+
* @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.
|
|
133
|
+
* @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.
|
|
134
|
+
* @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
135
|
* @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
136
|
* @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
137
|
*/
|
|
126
138
|
|
|
127
139
|
/** @type {ThemeCommandWords} */
|
|
128
|
-
const THEME_WORDS = {
|
|
140
|
+
const THEME_WORDS = {
|
|
141
|
+
group: 'theme',
|
|
142
|
+
build: 'build',
|
|
143
|
+
loadedFonts: fontsLoadedBeside,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The font families a local theme's font stylesheet loads: the
|
|
148
|
+
* `<slug>.fonts.css` beside its source, where the theme's folder is named
|
|
149
|
+
* for its slug (the one font stylesheet `theme add` imports for it), read
|
|
150
|
+
* with its imports (an @fontsource package by its name, a stylesheet by its
|
|
151
|
+
* @font-face rules or the `family=` it requests). A build of that source
|
|
152
|
+
* does not name those families as unloaded. Another stylesheet in the
|
|
153
|
+
* folder loads nothing for the app, so it counts for nothing. Null when the
|
|
154
|
+
* theme has no font stylesheet.
|
|
155
|
+
* @param {string} file the theme source, as given
|
|
156
|
+
* @param {string} cwd
|
|
157
|
+
* @returns {((family: string) => boolean) | null}
|
|
158
|
+
*/
|
|
159
|
+
function fontsLoadedBeside(file, cwd) {
|
|
160
|
+
const dir = path.dirname(path.resolve(cwd, file));
|
|
161
|
+
const sheet = path.join(dir, `${path.basename(dir)}.fonts.css`);
|
|
162
|
+
if (!fs.existsSync(sheet)) return null;
|
|
163
|
+
const loaded = stylesheetFontFamilies(sheet);
|
|
164
|
+
return loaded.size ? family => loaded.has(fontKey(family)) : null;
|
|
165
|
+
}
|
|
129
166
|
|
|
130
167
|
/**
|
|
131
168
|
* Text as the group that ran the command words it: under `experimental
|
|
@@ -193,13 +230,16 @@ function inGroupNotes(result, words) {
|
|
|
193
230
|
* group that works whatever went wrong.
|
|
194
231
|
* @param {import('../../../api/error.mjs').AstryxError} err
|
|
195
232
|
* @param {ThemeCommandWords} [words]
|
|
196
|
-
* @param {Array<{name: string, reason
|
|
233
|
+
* @param {Array<{name: string, reason?: string}>} [fallback]
|
|
197
234
|
*/
|
|
198
235
|
function themeError(err, words = THEME_WORDS, fallback = []) {
|
|
199
236
|
err = words.explain?.(err, process.cwd()) ?? err;
|
|
200
237
|
/** @param {string} text */
|
|
201
238
|
const local = text => inGroupWords(text, words);
|
|
202
239
|
const given = err.suggestions || [];
|
|
240
|
+
// Suggested commands stay bare (`astryx …`): the JSON envelope carries
|
|
241
|
+
// them so, and the text output starts them the way this project runs the
|
|
242
|
+
// CLI.
|
|
203
243
|
return cliError(local(err.message), {
|
|
204
244
|
suggestions: (given.length > 0 ? given : fallback).map(x => ({
|
|
205
245
|
...x,
|
|
@@ -210,6 +250,41 @@ function themeError(err, words = THEME_WORDS, fallback = []) {
|
|
|
210
250
|
});
|
|
211
251
|
}
|
|
212
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Add a group's fields to a build's result data. Its warnings join the
|
|
255
|
+
* build's own, and are printed as the build's are (`--json` prints none).
|
|
256
|
+
* @param {Record<string, any>} data
|
|
257
|
+
* @param {Record<string, unknown>} extra
|
|
258
|
+
*/
|
|
259
|
+
function mergeResultData(data, extra) {
|
|
260
|
+
const {warnings, ...rest} = /** @type {any} */ (extra);
|
|
261
|
+
Object.assign(data, rest);
|
|
262
|
+
if (Array.isArray(warnings) && warnings.length > 0) {
|
|
263
|
+
data.warnings = [...(data.warnings ?? []), ...warnings];
|
|
264
|
+
for (const w of warnings) logger.warn(`Warning: ${w}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Marks a suggested build with what it builds, for the group's checks. */
|
|
269
|
+
const BUILD_RUN = Symbol('build run');
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* A suggested build, marked with the files and mode it builds so the
|
|
273
|
+
* group's own checks can vet it before it is shown (the mark is not part of
|
|
274
|
+
* what is printed).
|
|
275
|
+
* @template {{name: string, reason: string}} S
|
|
276
|
+
* @param {S} suggestion
|
|
277
|
+
* @param {string[]} files
|
|
278
|
+
* @param {{check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}} mode
|
|
279
|
+
* @returns {S}
|
|
280
|
+
*/
|
|
281
|
+
function buildRun(suggestion, files, mode) {
|
|
282
|
+
return Object.defineProperty(suggestion, BUILD_RUN, {
|
|
283
|
+
value: {files, mode},
|
|
284
|
+
enumerable: false,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
213
288
|
/**
|
|
214
289
|
* A command of this CLI as this project runs it, each argument quoted for the
|
|
215
290
|
* shell.
|
|
@@ -629,6 +704,7 @@ function printThemeApp(result) {
|
|
|
629
704
|
'stylesheet',
|
|
630
705
|
'fontStylesheet',
|
|
631
706
|
'source',
|
|
707
|
+
'mode',
|
|
632
708
|
],
|
|
633
709
|
layout: 'stacked',
|
|
634
710
|
}),
|
|
@@ -641,6 +717,7 @@ function printThemeApp(result) {
|
|
|
641
717
|
slug: change.slug,
|
|
642
718
|
changed: change.changed,
|
|
643
719
|
firstAdd: change.firstAdd,
|
|
720
|
+
...(change.wireModes ? {wireModes: true} : {}),
|
|
644
721
|
},
|
|
645
722
|
],
|
|
646
723
|
{
|
|
@@ -651,20 +728,40 @@ function printThemeApp(result) {
|
|
|
651
728
|
'slug',
|
|
652
729
|
'changed',
|
|
653
730
|
'firstAdd',
|
|
731
|
+
'wireModes',
|
|
654
732
|
],
|
|
655
733
|
layout: 'stacked',
|
|
656
734
|
},
|
|
657
735
|
),
|
|
658
736
|
);
|
|
659
737
|
for (const note of result.data.notes ?? []) emit(text(`[note] ${note}`));
|
|
660
|
-
if (!change.firstAdd) return;
|
|
661
738
|
const stem = path.basename(modulePath, path.extname(modulePath));
|
|
739
|
+
if (!change.firstAdd) {
|
|
740
|
+
// The module now lists one-mode themes' modes: the app's wiring, made
|
|
741
|
+
// without them, passes the selected theme's mode from now on.
|
|
742
|
+
if (change.wireModes)
|
|
743
|
+
emit(
|
|
744
|
+
text(
|
|
745
|
+
"The theme module now exports themeModes. Pass the selected theme's mode to Theme in the app root:",
|
|
746
|
+
),
|
|
747
|
+
code(
|
|
748
|
+
"import {Theme} from '@astryxdesign/core/theme';\n" +
|
|
749
|
+
`import {themes, defaultThemeSlug, themeModes} from './${stem}';\n\n` +
|
|
750
|
+
"<Theme theme={themes[defaultThemeSlug]} mode={themeModes[defaultThemeSlug] ?? 'system'}>\n <App />\n</Theme>",
|
|
751
|
+
),
|
|
752
|
+
);
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
// With a theme of one color mode added, the generated module lists each
|
|
756
|
+
// such theme's mode in `themeModes`, and the wiring passes the selected
|
|
757
|
+
// theme's (none for a two-mode theme, which follows the system).
|
|
758
|
+
const modes = result.data.themes.some(t => t.mode);
|
|
662
759
|
emit(
|
|
663
760
|
text('Wire the generated module once in the app root:'),
|
|
664
761
|
code(
|
|
665
762
|
"import {Theme} from '@astryxdesign/core/theme';\n" +
|
|
666
|
-
`import {themes, defaultThemeSlug} from './${stem}';\n\n` +
|
|
667
|
-
|
|
763
|
+
`import {themes, defaultThemeSlug${modes ? ', themeModes' : ''}} from './${stem}';\n\n` +
|
|
764
|
+
`<Theme theme={themes[defaultThemeSlug]}${modes ? " mode={themeModes[defaultThemeSlug] ?? 'system'}" : ''}>\n <App />\n</Theme>`,
|
|
668
765
|
),
|
|
669
766
|
);
|
|
670
767
|
}
|
|
@@ -967,9 +1064,51 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
967
1064
|
const buildCli = defineCommand(theme, docs.build, {
|
|
968
1065
|
fn: themeBuildFn,
|
|
969
1066
|
action: async (
|
|
970
|
-
/** @type {string[]} */
|
|
1067
|
+
/** @type {string[]} */ typedFiles,
|
|
971
1068
|
/** @type {{out?: string, watch?: boolean, check?: boolean, iconsSpecifier?: string, family?: boolean, familyKey?: string}} */ options,
|
|
972
1069
|
) => {
|
|
1070
|
+
// A group may name the path a source builds under (an editor theme
|
|
1071
|
+
// reached through a link builds under its own path, which its
|
|
1072
|
+
// outputs' headers name).
|
|
1073
|
+
const files = typedFiles.map(
|
|
1074
|
+
file => words.sourcePath?.(file, process.cwd()) ?? file,
|
|
1075
|
+
);
|
|
1076
|
+
// Every suggested build passes the group's own checks before it is
|
|
1077
|
+
// shown (from a subfolder an editor theme compiles from the app
|
|
1078
|
+
// root): a suggestion the group refuses gives way to the group's own
|
|
1079
|
+
// suggestion, which does.
|
|
1080
|
+
/** @param {Array<{name: string, reason?: string}> | undefined} list */
|
|
1081
|
+
const vet = async list => {
|
|
1082
|
+
/** @type {Array<{name: string, reason?: string}>} */
|
|
1083
|
+
const out = [];
|
|
1084
|
+
for (const s of list ?? []) {
|
|
1085
|
+
const run = /** @type {any} */ (s)[BUILD_RUN];
|
|
1086
|
+
const refused = run
|
|
1087
|
+
? await words.preflight?.(run.files, {
|
|
1088
|
+
cwd: process.cwd(),
|
|
1089
|
+
...run.mode,
|
|
1090
|
+
})
|
|
1091
|
+
: null;
|
|
1092
|
+
out.push(...(refused ? (refused.suggestions ?? []) : [s]));
|
|
1093
|
+
}
|
|
1094
|
+
return out;
|
|
1095
|
+
};
|
|
1096
|
+
/** @param {string} message @param {Parameters<typeof cliError>[1]} [opts] */
|
|
1097
|
+
const refuse = async (message, opts = {}) =>
|
|
1098
|
+
cliError(message, {
|
|
1099
|
+
...opts,
|
|
1100
|
+
suggestions: await vet(opts.suggestions),
|
|
1101
|
+
});
|
|
1102
|
+
/**
|
|
1103
|
+
* @param {import('../../../api/error.mjs').AstryxError} err
|
|
1104
|
+
* @param {ThemeCommandWords} [w]
|
|
1105
|
+
* @param {Array<{name: string, reason?: string}>} [fallback]
|
|
1106
|
+
*/
|
|
1107
|
+
const refuseTheme = async (err, w = words, fallback = []) => {
|
|
1108
|
+
err.suggestions = await vet(err.suggestions);
|
|
1109
|
+
return themeError(err, w, await vet(fallback));
|
|
1110
|
+
};
|
|
1111
|
+
|
|
973
1112
|
const json = program.opts().json || false;
|
|
974
1113
|
// The report is one line per theme unless the user asks for
|
|
975
1114
|
// `--detail full`, which prints the install example and the font
|
|
@@ -996,7 +1135,29 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
996
1135
|
const rewrite = looksGlobby
|
|
997
1136
|
? null
|
|
998
1137
|
: (words.missingSource?.(entry.file, process.cwd()) ?? null);
|
|
999
|
-
|
|
1138
|
+
// A file another command generates, gone from a folder whose other
|
|
1139
|
+
// files carry that command's mark: that command writes it again; a
|
|
1140
|
+
// blank theme template is no way back.
|
|
1141
|
+
const by =
|
|
1142
|
+
rewrite || looksGlobby
|
|
1143
|
+
? null
|
|
1144
|
+
: generatedSourceCommand(entry.filePath);
|
|
1145
|
+
if (by)
|
|
1146
|
+
return await refuse(
|
|
1147
|
+
`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.`,
|
|
1148
|
+
{
|
|
1149
|
+
code: ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1150
|
+
suggestions: /^astryx(\s|$)/.test(by)
|
|
1151
|
+
? [
|
|
1152
|
+
{
|
|
1153
|
+
name: `${getCliInvocation(process.cwd())} ${by.replace(/^astryx\s*/, '')}`.trim(),
|
|
1154
|
+
reason: 'the command that writes these files',
|
|
1155
|
+
},
|
|
1156
|
+
]
|
|
1157
|
+
: [],
|
|
1158
|
+
},
|
|
1159
|
+
);
|
|
1160
|
+
return await refuse(`File not found: ${entry.filePath}`, {
|
|
1000
1161
|
code: ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
1001
1162
|
suggestions: rewrite
|
|
1002
1163
|
? [rewrite]
|
|
@@ -1024,11 +1185,28 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1024
1185
|
},
|
|
1025
1186
|
]
|
|
1026
1187
|
: guesses.length > 0
|
|
1027
|
-
? guesses.map(guess =>
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1188
|
+
? guesses.map(guess =>
|
|
1189
|
+
buildRun(
|
|
1190
|
+
{
|
|
1191
|
+
// The same build of that source: a --check stays a
|
|
1192
|
+
// check.
|
|
1193
|
+
name: buildSuggestion(
|
|
1194
|
+
guess,
|
|
1195
|
+
options,
|
|
1196
|
+
process.cwd(),
|
|
1197
|
+
words,
|
|
1198
|
+
),
|
|
1199
|
+
reason: 'a theme source that exists',
|
|
1200
|
+
},
|
|
1201
|
+
[guess],
|
|
1202
|
+
{
|
|
1203
|
+
check: Boolean(options.check),
|
|
1204
|
+
family: Boolean(options.family),
|
|
1205
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1206
|
+
out: options.out,
|
|
1207
|
+
},
|
|
1208
|
+
),
|
|
1209
|
+
)
|
|
1032
1210
|
: [
|
|
1033
1211
|
themeCommand(
|
|
1034
1212
|
words,
|
|
@@ -1048,23 +1226,37 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1048
1226
|
* @param {string[]} [only] the files to build, when not all of them
|
|
1049
1227
|
*/
|
|
1050
1228
|
const buildWithout = (drop, reason, only = files) =>
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1229
|
+
buildRun(
|
|
1230
|
+
themeCommand(
|
|
1231
|
+
words,
|
|
1232
|
+
words.build,
|
|
1233
|
+
[
|
|
1234
|
+
...(options.family && !drop.includes('family')
|
|
1235
|
+
? [
|
|
1236
|
+
'--family',
|
|
1237
|
+
...only,
|
|
1238
|
+
'--family-key',
|
|
1239
|
+
String(options.familyKey),
|
|
1240
|
+
]
|
|
1241
|
+
: only),
|
|
1242
|
+
...(options.out && !drop.includes('out')
|
|
1243
|
+
? ['--out', options.out]
|
|
1244
|
+
: []),
|
|
1245
|
+
...(options.check && !drop.includes('check') ? ['--check'] : []),
|
|
1246
|
+
...(options.watch && !drop.includes('watch') ? ['--watch'] : []),
|
|
1247
|
+
...(options.iconsSpecifier
|
|
1248
|
+
? ['--icons-specifier', options.iconsSpecifier]
|
|
1249
|
+
: []),
|
|
1250
|
+
],
|
|
1251
|
+
reason,
|
|
1252
|
+
),
|
|
1253
|
+
only,
|
|
1254
|
+
{
|
|
1255
|
+
check: Boolean(options.check) && !drop.includes('check'),
|
|
1256
|
+
family: Boolean(options.family) && !drop.includes('family'),
|
|
1257
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1258
|
+
out: drop.includes('out') ? undefined : options.out,
|
|
1259
|
+
},
|
|
1068
1260
|
);
|
|
1069
1261
|
|
|
1070
1262
|
// A refusal from the build that names no command: without --out the
|
|
@@ -1096,7 +1288,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1096
1288
|
) === index,
|
|
1097
1289
|
)
|
|
1098
1290
|
.map(other => other.file);
|
|
1099
|
-
return
|
|
1291
|
+
return await refuse(
|
|
1100
1292
|
`${entry.file} is given more than once. Select each theme file once.`,
|
|
1101
1293
|
{
|
|
1102
1294
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
@@ -1111,15 +1303,15 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1111
1303
|
// Its key is required exactly with --family, and options that describe one
|
|
1112
1304
|
// standalone output or a long-running loop remain intentionally separate.
|
|
1113
1305
|
if (Boolean(options.family) !== Boolean(options.familyKey)) {
|
|
1114
|
-
return
|
|
1306
|
+
return await refuse(
|
|
1115
1307
|
options.family
|
|
1116
1308
|
? '--family requires --family-key <key>'
|
|
1117
1309
|
: '--family-key requires --family',
|
|
1118
1310
|
{
|
|
1119
1311
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1120
1312
|
suggestions: [
|
|
1121
|
-
|
|
1122
|
-
|
|
1313
|
+
buildRun(
|
|
1314
|
+
themeCommand(
|
|
1123
1315
|
words,
|
|
1124
1316
|
words.build,
|
|
1125
1317
|
[
|
|
@@ -1135,13 +1327,20 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1135
1327
|
],
|
|
1136
1328
|
'build each theme on its own',
|
|
1137
1329
|
),
|
|
1138
|
-
|
|
1330
|
+
files,
|
|
1331
|
+
{
|
|
1332
|
+
check: Boolean(options.check),
|
|
1333
|
+
family: false,
|
|
1334
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1335
|
+
out: files.length === 1 ? options.out : undefined,
|
|
1336
|
+
},
|
|
1337
|
+
),
|
|
1139
1338
|
],
|
|
1140
1339
|
},
|
|
1141
1340
|
);
|
|
1142
1341
|
}
|
|
1143
1342
|
if (options.family && options.out) {
|
|
1144
|
-
return
|
|
1343
|
+
return await refuse('--family cannot be combined with --out', {
|
|
1145
1344
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1146
1345
|
suggestions: [
|
|
1147
1346
|
buildWithout(['out'], 'family outputs go beside the family root'),
|
|
@@ -1149,7 +1348,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1149
1348
|
});
|
|
1150
1349
|
}
|
|
1151
1350
|
if (options.family && options.watch) {
|
|
1152
|
-
return
|
|
1351
|
+
return await refuse('--family cannot be combined with --watch', {
|
|
1153
1352
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1154
1353
|
suggestions: [buildWithout(['watch'], 'build the family once')],
|
|
1155
1354
|
});
|
|
@@ -1158,7 +1357,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1158
1357
|
// --check and --watch are mutually exclusive: check is a one-shot,
|
|
1159
1358
|
// exit-coded verification; watch is a long-running rebuild loop.
|
|
1160
1359
|
if (options.check && options.watch) {
|
|
1161
|
-
return
|
|
1360
|
+
return await refuse('--check cannot be combined with --watch', {
|
|
1162
1361
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1163
1362
|
suggestions: [buildWithout(['watch'], 'check once')],
|
|
1164
1363
|
});
|
|
@@ -1168,7 +1367,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1168
1367
|
// it each theme writes `<theme name>.css` beside its source, which is
|
|
1169
1368
|
// what a multi-theme build wants anyway.
|
|
1170
1369
|
if (options.out && entries.length > 1) {
|
|
1171
|
-
return
|
|
1370
|
+
return await refuse(
|
|
1172
1371
|
`--out takes a single output path and ${entries.length} theme files were given. ` +
|
|
1173
1372
|
'Build them without --out (each theme writes <name>.css next to its source), ' +
|
|
1174
1373
|
'or run one invocation per theme.',
|
|
@@ -1189,7 +1388,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1189
1388
|
// supported in --json (machine) mode, which expects a single envelope.
|
|
1190
1389
|
if (options.watch) {
|
|
1191
1390
|
if (json) {
|
|
1192
|
-
return
|
|
1391
|
+
return await refuse('--watch is not supported with --json', {
|
|
1193
1392
|
code: ERROR_CODES.ERR_THEME_INVALID,
|
|
1194
1393
|
suggestions: [
|
|
1195
1394
|
buildWithout(['watch'], 'build once, with a JSON result'),
|
|
@@ -1229,7 +1428,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1229
1428
|
iconsSpecifier: options.iconsSpecifier,
|
|
1230
1429
|
out: options.out,
|
|
1231
1430
|
});
|
|
1232
|
-
if (refused)
|
|
1431
|
+
if (refused)
|
|
1432
|
+
return await refuseTheme(
|
|
1433
|
+
(await words.follow?.(refused, process.cwd())) ?? refused,
|
|
1434
|
+
words,
|
|
1435
|
+
buildFallback,
|
|
1436
|
+
);
|
|
1233
1437
|
|
|
1234
1438
|
if (options.family) {
|
|
1235
1439
|
try {
|
|
@@ -1258,7 +1462,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1258
1462
|
} catch (e) {
|
|
1259
1463
|
const err =
|
|
1260
1464
|
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
1261
|
-
return
|
|
1465
|
+
return await refuseTheme(err, words, [
|
|
1262
1466
|
buildWithout(['family'], 'build each theme on its own'),
|
|
1263
1467
|
]);
|
|
1264
1468
|
}
|
|
@@ -1288,8 +1492,8 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1288
1492
|
for (const show of theme.lines) show();
|
|
1289
1493
|
}
|
|
1290
1494
|
};
|
|
1291
|
-
const writeFailed = (/** @type {unknown} */ error) =>
|
|
1292
|
-
|
|
1495
|
+
const writeFailed = async (/** @type {unknown} */ error) =>
|
|
1496
|
+
refuseTheme(
|
|
1293
1497
|
/** @type {import('../../../api/error.mjs').AstryxError} */ (error),
|
|
1294
1498
|
words,
|
|
1295
1499
|
[
|
|
@@ -1308,6 +1512,21 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1308
1512
|
const writes = [];
|
|
1309
1513
|
const log = logger.log;
|
|
1310
1514
|
const warn = logger.warn;
|
|
1515
|
+
// A group may know fonts the app loads that the theme file cannot
|
|
1516
|
+
// say (the editor's app copy stylesheet): the build leaves them out
|
|
1517
|
+
// of every "not loaded" note, family by family.
|
|
1518
|
+
const loads =
|
|
1519
|
+
(await words.loadedFonts?.(entry.file, process.cwd())) ?? null;
|
|
1520
|
+
// A check whose result a group may still fail holds its lines
|
|
1521
|
+
// until the group has looked.
|
|
1522
|
+
/** @type {Array<string | undefined> | null} */
|
|
1523
|
+
let held = null;
|
|
1524
|
+
if (options.check && words.extraData && !deferred) {
|
|
1525
|
+
held = [];
|
|
1526
|
+
logger.log = (/** @type {string | undefined} */ message) => {
|
|
1527
|
+
held?.push(message);
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1311
1530
|
if (deferred) {
|
|
1312
1531
|
logger.log = (/** @type {string | undefined} */ message) => {
|
|
1313
1532
|
lines.push(() => log.call(logger, message));
|
|
@@ -1327,6 +1546,9 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1327
1546
|
claimedOutputs,
|
|
1328
1547
|
deferredWrites: deferred ? writes : undefined,
|
|
1329
1548
|
commandWords: words,
|
|
1549
|
+
colorModes: words.colorModes?.(entry.file, process.cwd()) ?? null,
|
|
1550
|
+
fontHelp: words.fontHelp?.(entry.file, process.cwd()) ?? null,
|
|
1551
|
+
loadedFonts: loads,
|
|
1330
1552
|
};
|
|
1331
1553
|
let result;
|
|
1332
1554
|
if (report) {
|
|
@@ -1360,6 +1582,29 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1360
1582
|
}
|
|
1361
1583
|
logger.log = log;
|
|
1362
1584
|
logger.warn = warn;
|
|
1585
|
+
// A group may add to a build's result (the editor's app copy:
|
|
1586
|
+
// what keeps it behind, and in a check whether it is current).
|
|
1587
|
+
const extra = await words.extraData?.(entry.file, process.cwd(), {
|
|
1588
|
+
check: Boolean(options.check),
|
|
1589
|
+
upToDate: /** @type {any} */ (result)?.data?.upToDate,
|
|
1590
|
+
out: options.out,
|
|
1591
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1592
|
+
});
|
|
1593
|
+
if (extra && result?.data) mergeResultData(result.data, extra);
|
|
1594
|
+
// A check the group failed says so where the check said ok.
|
|
1595
|
+
if (held) {
|
|
1596
|
+
logger.log = log;
|
|
1597
|
+
for (const line of held)
|
|
1598
|
+
log.call(
|
|
1599
|
+
logger,
|
|
1600
|
+
extra?.upToDate === false &&
|
|
1601
|
+
typeof line === 'string' &&
|
|
1602
|
+
/^\s*\[ok\]/.test(line)
|
|
1603
|
+
? `[fail] ${String(extra.appCopyStale ?? 'not up to date')}`
|
|
1604
|
+
: line,
|
|
1605
|
+
);
|
|
1606
|
+
held = null;
|
|
1607
|
+
}
|
|
1363
1608
|
results.push({file: entry.file, receipt: result ?? null});
|
|
1364
1609
|
if (deferred) built.push({writes, lines});
|
|
1365
1610
|
if (
|
|
@@ -1373,6 +1618,8 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1373
1618
|
} catch (e) {
|
|
1374
1619
|
logger.log = log;
|
|
1375
1620
|
logger.warn = warn;
|
|
1621
|
+
for (const line of held ?? []) log.call(logger, line);
|
|
1622
|
+
held = null;
|
|
1376
1623
|
const err =
|
|
1377
1624
|
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
1378
1625
|
// Stop at the first failure, as a shell loop under `set -e` does.
|
|
@@ -1382,7 +1629,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1382
1629
|
if (/** @type {any} */ (err).outputCollision) {
|
|
1383
1630
|
// Nothing is written, so only this theme's warnings are shown.
|
|
1384
1631
|
for (const show of lines) show();
|
|
1385
|
-
return
|
|
1632
|
+
return await refuseTheme(err, words, [
|
|
1386
1633
|
buildWithout([], 'build the first theme on its own', [
|
|
1387
1634
|
entries[0].file,
|
|
1388
1635
|
]),
|
|
@@ -1401,7 +1648,13 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1401
1648
|
if (report && compact) printCompactTrailer(trailers);
|
|
1402
1649
|
else if (report) printBatchTrailer(trailers);
|
|
1403
1650
|
if (entries.length > 1) err.message = `${entry.file}: ${err.message}`;
|
|
1404
|
-
return
|
|
1651
|
+
return await refuseTheme(
|
|
1652
|
+
entries.length === 1
|
|
1653
|
+
? ((await words.follow?.(err, process.cwd())) ?? err)
|
|
1654
|
+
: err,
|
|
1655
|
+
words,
|
|
1656
|
+
buildFallback,
|
|
1657
|
+
);
|
|
1405
1658
|
}
|
|
1406
1659
|
}
|
|
1407
1660
|
if (deferred) {
|
|
@@ -1411,6 +1664,18 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1411
1664
|
return writeFailed(e);
|
|
1412
1665
|
}
|
|
1413
1666
|
}
|
|
1667
|
+
// A group follows the written outputs with writes of its own (the
|
|
1668
|
+
// editor's app copy), and each result says what they did.
|
|
1669
|
+
if (words.afterBuild && !options.check) {
|
|
1670
|
+
const more = await words.afterBuild(
|
|
1671
|
+
results.map(r => r.file),
|
|
1672
|
+
process.cwd(),
|
|
1673
|
+
);
|
|
1674
|
+
for (const r of results) {
|
|
1675
|
+
const data = /** @type {any} */ (r.receipt)?.data;
|
|
1676
|
+
if (data && more[r.file]) mergeResultData(data, more[r.file]);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1414
1679
|
|
|
1415
1680
|
if (json) {
|
|
1416
1681
|
// One theme keeps the single-envelope contract it has always had; a
|
|
@@ -1461,7 +1726,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1461
1726
|
// Under --watch each rebuild runs on its own and takes the locks
|
|
1462
1727
|
// itself; holding them for the whole watch would block every one.
|
|
1463
1728
|
if (cmd.opts().watch) return;
|
|
1464
|
-
|
|
1729
|
+
const o = cmd.opts();
|
|
1730
|
+
release = await words.hold?.(cmd.args, {
|
|
1731
|
+
cwd: process.cwd(),
|
|
1732
|
+
check: Boolean(o.check),
|
|
1733
|
+
out: o.out,
|
|
1734
|
+
});
|
|
1465
1735
|
});
|
|
1466
1736
|
buildCli.hook('postAction', async () => {
|
|
1467
1737
|
await release?.();
|
|
@@ -22,6 +22,44 @@ import {doc as upgradeCommand} from './upgrade.doc.mjs';
|
|
|
22
22
|
import {doc as upgradeFn} from '../../../api/upgrade/upgrade.doc.mjs';
|
|
23
23
|
import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* The codemod list as text: a heading that says how many codemods there are
|
|
27
|
+
* and names their package when they share one, then each version with one
|
|
28
|
+
* line per codemod, its name and title, and `(optional)` on a codemod that
|
|
29
|
+
* runs only on request. When codemods come from more than one package, every
|
|
30
|
+
* line names its package.
|
|
31
|
+
* @param {import('../../../api/upgrade/upgrade.type.mjs').UpgradeListResponse['data']} codemods
|
|
32
|
+
* @returns {import('../formatters/index.mjs').Block[]}
|
|
33
|
+
*/
|
|
34
|
+
function codemodListBlocks(codemods) {
|
|
35
|
+
const packages = new Set(codemods.map(c => c.package));
|
|
36
|
+
const shared = packages.size === 1 ? [...packages][0] : null;
|
|
37
|
+
/** @type {Map<string, typeof codemods>} */
|
|
38
|
+
const byVersion = new Map();
|
|
39
|
+
for (const c of codemods) {
|
|
40
|
+
byVersion.set(c.version, [...(byVersion.get(c.version) ?? []), c]);
|
|
41
|
+
}
|
|
42
|
+
const count = `${codemods.length} codemod${codemods.length === 1 ? '' : 's'}`;
|
|
43
|
+
return [
|
|
44
|
+
section(
|
|
45
|
+
'Available codemods',
|
|
46
|
+
`${count}${shared ? ` from ${shared}` : ''}, oldest first`,
|
|
47
|
+
),
|
|
48
|
+
...[...byVersion].flatMap(([version, group]) => [
|
|
49
|
+
section(version),
|
|
50
|
+
records(
|
|
51
|
+
group.map(c => ({
|
|
52
|
+
name: c.name,
|
|
53
|
+
title: c.title,
|
|
54
|
+
optional: c.optional ? '(optional)' : undefined,
|
|
55
|
+
package: shared ? undefined : c.package,
|
|
56
|
+
})),
|
|
57
|
+
{fields: ['name', 'title', 'optional', 'package'], layout: 'inline'},
|
|
58
|
+
),
|
|
59
|
+
]),
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
|
|
25
63
|
/**
|
|
26
64
|
* @param {import('commander').Command} program
|
|
27
65
|
*/
|
|
@@ -79,13 +117,10 @@ export function registerUpgrade(program) {
|
|
|
79
117
|
if (json) jsonOut(result);
|
|
80
118
|
else if (result.type === 'upgrade.list') {
|
|
81
119
|
// Render the list from the result, not the API logger, so the text
|
|
82
|
-
// carries the same fields the JSON does
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fields: ['name', 'package', 'title', 'version', 'optional'],
|
|
87
|
-
}),
|
|
88
|
-
);
|
|
120
|
+
// carries the same fields the JSON does. One line per codemod under
|
|
121
|
+
// its version: the list gains a line per codemod each release, not a
|
|
122
|
+
// five-line record.
|
|
123
|
+
emit(...codemodListBlocks(result.data));
|
|
89
124
|
}
|
|
90
125
|
|
|
91
126
|
const registrySummary =
|
package/clients/cli/index.mjs
CHANGED
|
@@ -595,7 +595,7 @@ export async function createProgram({argv} = {}) {
|
|
|
595
595
|
|
|
596
596
|
program
|
|
597
597
|
.name('astryx')
|
|
598
|
-
.description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (
|
|
598
|
+
.description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (takes pictures of real components): a theme change is not done until you have looked. No app yet: astryx experimental theme preview app <dir>.')
|
|
599
599
|
.version(pkg.version)
|
|
600
600
|
// These four change only the reads named in their text; every other
|
|
601
601
|
// command ignores them.
|