@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
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 +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- 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 +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Where the exports of the doc files Astryx ships are stored, how a
|
|
5
5
|
* source file's text is keyed in a store written at publish, and how such a
|
|
6
|
-
* store is read.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* store is read. A stored doc's parse that the store does not hold is kept
|
|
7
|
+
* for the user, by the doc's text and the zod release the doc parsers load
|
|
8
|
+
* (keptParse). ./import.mjs reads the
|
|
9
|
+
* stored exports and foundation/discovery/template-adapter.mjs the stored
|
|
10
|
+
* template component lists; scripts/generate-stored-docs.mjs and
|
|
9
11
|
* scripts/generate-template-components.mjs write them. Also where the
|
|
10
12
|
* CLI's docs routes are stored (scripts/generate-docs-routes.mjs).
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
import {createHash} from 'node:crypto';
|
|
14
16
|
import * as fs from 'node:fs';
|
|
17
|
+
import {createRequire} from 'node:module';
|
|
15
18
|
import * as path from 'node:path';
|
|
16
19
|
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
20
|
+
import {persistedValue} from '../fs/gather-cache.mjs';
|
|
21
|
+
import {withoutRecording} from '../fs/read-record.mjs';
|
|
17
22
|
|
|
18
23
|
/**
|
|
19
24
|
* Where the exports of the doc files Astryx ships (the CLI's and Core's) are
|
|
@@ -158,3 +163,69 @@ export function storedParse(value) {
|
|
|
158
163
|
return undefined;
|
|
159
164
|
}
|
|
160
165
|
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* How a doc's parse is kept: as its JSON text, only when that text reads back
|
|
169
|
+
* as a value equal to the parse, the rule the stored parses above follow.
|
|
170
|
+
* The text keeps the parse's own key order, so a kept parse prints as the
|
|
171
|
+
* fresh one does.
|
|
172
|
+
*/
|
|
173
|
+
const KEPT_PARSE_CODEC = {
|
|
174
|
+
encode: (/** @type {unknown} */ value) => value,
|
|
175
|
+
decode: (/** @type {unknown} */ stored) => stored,
|
|
176
|
+
valid: (/** @type {unknown} */ value) =>
|
|
177
|
+
value != null && typeof value === 'object',
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/** @type {string | null | undefined} */
|
|
181
|
+
let parserZodVersion;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The version of the zod copy the doc parsers load, read once per run. The
|
|
185
|
+
* build id names the CLI's own code, not the packages it depends on, and a
|
|
186
|
+
* reinstall can put another zod beside the same build.
|
|
187
|
+
* @returns {string | null} null when it cannot be read
|
|
188
|
+
*/
|
|
189
|
+
function docParserZodVersion() {
|
|
190
|
+
if (parserZodVersion === undefined) {
|
|
191
|
+
parserZodVersion = withoutRecording(() => {
|
|
192
|
+
try {
|
|
193
|
+
const require = createRequire(
|
|
194
|
+
new URL('../../authoring/doctypes/_schema.mjs', import.meta.url),
|
|
195
|
+
);
|
|
196
|
+
const {version} = JSON.parse(
|
|
197
|
+
fs.readFileSync(require.resolve('zod/package.json'), 'utf8'),
|
|
198
|
+
);
|
|
199
|
+
return typeof version === 'string' ? version : null;
|
|
200
|
+
} catch {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return parserZodVersion;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The parse of `value` by `parse`. When `value` is a stored doc's export
|
|
210
|
+
* (./import.mjs), the parse is a function of the doc's text, the CLI build
|
|
211
|
+
* and the zod release the parsers load, so it is kept for the user by those
|
|
212
|
+
* (gather-cache's `persistedValue`): a later read of the same text, by the
|
|
213
|
+
* same build with the same zod, gets the kept parse and does not parse. Any
|
|
214
|
+
* other value is parsed as before, and so is every value when the zod
|
|
215
|
+
* release cannot be read.
|
|
216
|
+
* @param {unknown} value
|
|
217
|
+
* @param {() => any} parse
|
|
218
|
+
* @returns {any}
|
|
219
|
+
*/
|
|
220
|
+
export function keptParse(value, parse) {
|
|
221
|
+
if (!value || typeof value !== 'object') return parse();
|
|
222
|
+
const at = storedExports.get(value);
|
|
223
|
+
if (!at) return parse();
|
|
224
|
+
const zod = docParserZodVersion();
|
|
225
|
+
if (zod == null) return parse();
|
|
226
|
+
return persistedValue(
|
|
227
|
+
['doc-parse', at.key, at.name, zod],
|
|
228
|
+
parse,
|
|
229
|
+
KEPT_PARSE_CODEC,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
@@ -17,19 +17,38 @@ export function runWithCliDoor<T>(command: string, fn: () => T): T;
|
|
|
17
17
|
*/
|
|
18
18
|
export function cliDoor(): string | undefined;
|
|
19
19
|
/**
|
|
20
|
-
* The
|
|
21
|
-
* integration that failed to load, or was set aside for a provider
|
|
22
|
-
* contributes nothing, so it declares nothing either.
|
|
23
|
-
* @param {ReadonlyArray<{name?: string, __spec?: string, cliCommand?: string, __loadError?: string, __providerConflict?: unknown}>} integrations
|
|
24
|
-
* @
|
|
20
|
+
* The values a set of loaded integrations declares for `setting`, in load
|
|
21
|
+
* order. An integration that failed to load, or was set aside for a provider
|
|
22
|
+
* conflict, contributes nothing, so it declares nothing either.
|
|
23
|
+
* @param {ReadonlyArray<{name?: string, __spec?: string, cliCommand?: string, installGuidance?: string, __loadError?: string, __providerConflict?: unknown}>} integrations
|
|
24
|
+
* @param {DeclaredSetting} setting
|
|
25
|
+
* @returns {DeclaredValue[]}
|
|
25
26
|
*/
|
|
26
|
-
export function
|
|
27
|
+
export function declaredValuesOf(integrations: ReadonlyArray<{
|
|
27
28
|
name?: string;
|
|
28
29
|
__spec?: string;
|
|
29
30
|
cliCommand?: string;
|
|
31
|
+
installGuidance?: string;
|
|
30
32
|
__loadError?: string;
|
|
31
33
|
__providerConflict?: unknown;
|
|
32
|
-
}
|
|
34
|
+
}>, setting: DeclaredSetting): DeclaredValue[];
|
|
35
|
+
/**
|
|
36
|
+
* Choose among declarations: one value, declared by one or more
|
|
37
|
+
* integrations, is used; different values are a conflict.
|
|
38
|
+
* @param {DeclaredValue[]} declared
|
|
39
|
+
* @returns {{value?: string, conflict: boolean, declared: DeclaredValue[]}}
|
|
40
|
+
*/
|
|
41
|
+
export function chooseDeclaredValue(declared: DeclaredValue[]): {
|
|
42
|
+
value?: string;
|
|
43
|
+
conflict: boolean;
|
|
44
|
+
declared: DeclaredValue[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The commands a set of loaded integrations declares, in load order.
|
|
48
|
+
* @param {Parameters<typeof declaredValuesOf>[0]} integrations
|
|
49
|
+
* @returns {DeclaredCliCommand[]}
|
|
50
|
+
*/
|
|
51
|
+
export function declaredCliCommandsOf(integrations: Parameters<typeof declaredValuesOf>[0]): DeclaredCliCommand[];
|
|
33
52
|
/**
|
|
34
53
|
* Choose among declarations: one command, declared by one or more
|
|
35
54
|
* integrations, is used; different commands are a conflict.
|
|
@@ -42,20 +61,44 @@ export function chooseDeclaredCliCommand(declared: DeclaredCliCommand[]): {
|
|
|
42
61
|
declared: DeclaredCliCommand[];
|
|
43
62
|
};
|
|
44
63
|
/**
|
|
45
|
-
* Record the
|
|
64
|
+
* Record the settings a project's loaded integrations declare. Called by
|
|
46
65
|
* `Project.load` each time it resolves the integration set; the latest load
|
|
47
66
|
* wins.
|
|
48
67
|
* @param {string} projectDir
|
|
49
|
-
* @param {Parameters<typeof
|
|
68
|
+
* @param {Parameters<typeof declaredValuesOf>[0]} integrations
|
|
50
69
|
* @returns {void}
|
|
51
70
|
*/
|
|
52
|
-
export function
|
|
71
|
+
export function recordDeclaredSettings(projectDir: string, integrations: Parameters<typeof declaredValuesOf>[0]): void;
|
|
53
72
|
/**
|
|
54
73
|
* Whether this process has loaded the project at `targetDir`.
|
|
55
74
|
* @param {string} [targetDir=process.cwd()]
|
|
56
75
|
* @returns {boolean}
|
|
57
76
|
*/
|
|
58
77
|
export function hasRecordedProject(targetDir?: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* What the integrations of the project at `targetDir` declare for `setting`,
|
|
80
|
+
* as recorded by its last `Project.load` in this process; see
|
|
81
|
+
* {@link chooseDeclaredValue}.
|
|
82
|
+
* @param {DeclaredSetting} setting
|
|
83
|
+
* @param {string} [targetDir=process.cwd()]
|
|
84
|
+
* @returns {{value?: string, conflict: boolean, declared: DeclaredValue[]}}
|
|
85
|
+
*/
|
|
86
|
+
export function declaredSetting(setting: DeclaredSetting, targetDir?: string): {
|
|
87
|
+
value?: string;
|
|
88
|
+
conflict: boolean;
|
|
89
|
+
declared: DeclaredValue[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* How an app in the project at `targetDir` adds `packages`, when its
|
|
93
|
+
* integrations say the package manager's add command is the wrong step there
|
|
94
|
+
* (`installGuidance`): their one line with `{packages}` filled in. Undefined
|
|
95
|
+
* when no loaded integration gives one, when two give different lines, or
|
|
96
|
+
* when this process has not loaded the project.
|
|
97
|
+
* @param {string[]} packages the packages to add, each as the step names it
|
|
98
|
+
* @param {string} [targetDir=process.cwd()]
|
|
99
|
+
* @returns {string | undefined}
|
|
100
|
+
*/
|
|
101
|
+
export function installGuidanceFor(packages: string[], targetDir?: string): string | undefined;
|
|
59
102
|
/**
|
|
60
103
|
* What the integrations of the project at `targetDir` declare, as recorded by
|
|
61
104
|
* its last `Project.load` in this process; see
|
|
@@ -81,3 +124,18 @@ export type DeclaredCliCommand = {
|
|
|
81
124
|
*/
|
|
82
125
|
command: string;
|
|
83
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* A setting an integration's manifest declares for the projects that load
|
|
129
|
+
* it: the command that runs the CLI, or how an app adds a dependency.
|
|
130
|
+
*/
|
|
131
|
+
export type DeclaredSetting = "cliCommand" | "installGuidance";
|
|
132
|
+
/**
|
|
133
|
+
* One integration's value for one setting.
|
|
134
|
+
*/
|
|
135
|
+
export type DeclaredValue = {
|
|
136
|
+
/**
|
|
137
|
+
* the integration package that declared it
|
|
138
|
+
*/
|
|
139
|
+
package: string;
|
|
140
|
+
value: string;
|
|
141
|
+
};
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* 1. **The integrations** — the `cliCommand` field of each loaded
|
|
11
11
|
* integration's manifest. `Project.load` records them per project with
|
|
12
|
-
* {@link
|
|
13
|
-
*
|
|
12
|
+
* {@link recordDeclaredSettings}, which also records each integration's
|
|
13
|
+
* `installGuidance` (read by {@link installGuidanceFor}). One command,
|
|
14
|
+
* declared by one or more integrations, is used. Two different commands cancel each other out: the
|
|
14
15
|
* picker falls back to its guess, even when a host set a door, and
|
|
15
16
|
* `astryx doctor` warns.
|
|
16
17
|
* 2. **The door** — the command a host ran this call through. A host sets it
|
|
@@ -58,7 +59,25 @@ export function cliDoor() {
|
|
|
58
59
|
return doorScope.getStore()?.command;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* A setting an integration's manifest declares for the projects that load
|
|
64
|
+
* it: the command that runs the CLI, or how an app adds a dependency.
|
|
65
|
+
* @typedef {'cliCommand' | 'installGuidance'} DeclaredSetting
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* One integration's value for one setting.
|
|
70
|
+
* @typedef {object} DeclaredValue
|
|
71
|
+
* @property {string} package the integration package that declared it
|
|
72
|
+
* @property {string} value
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* What a project's loaded integrations declare, per project: each one's
|
|
77
|
+
* name and settings. One record for every setting, so each is read from the
|
|
78
|
+
* same load.
|
|
79
|
+
* @type {Map<string, Array<{name: string, cliCommand?: string, installGuidance?: string}>>}
|
|
80
|
+
*/
|
|
62
81
|
const declaredByProject = new Map();
|
|
63
82
|
|
|
64
83
|
/**
|
|
@@ -79,27 +98,55 @@ function projectKey(dir) {
|
|
|
79
98
|
}
|
|
80
99
|
|
|
81
100
|
/**
|
|
82
|
-
* The
|
|
83
|
-
* integration that failed to load, or was set aside for a provider
|
|
84
|
-
* contributes nothing, so it declares nothing either.
|
|
85
|
-
* @param {ReadonlyArray<{name?: string, __spec?: string, cliCommand?: string, __loadError?: string, __providerConflict?: unknown}>} integrations
|
|
86
|
-
* @
|
|
101
|
+
* The values a set of loaded integrations declares for `setting`, in load
|
|
102
|
+
* order. An integration that failed to load, or was set aside for a provider
|
|
103
|
+
* conflict, contributes nothing, so it declares nothing either.
|
|
104
|
+
* @param {ReadonlyArray<{name?: string, __spec?: string, cliCommand?: string, installGuidance?: string, __loadError?: string, __providerConflict?: unknown}>} integrations
|
|
105
|
+
* @param {DeclaredSetting} setting
|
|
106
|
+
* @returns {DeclaredValue[]}
|
|
87
107
|
*/
|
|
88
|
-
export function
|
|
89
|
-
/** @type {
|
|
108
|
+
export function declaredValuesOf(integrations, setting) {
|
|
109
|
+
/** @type {DeclaredValue[]} */
|
|
90
110
|
const declared = [];
|
|
91
111
|
for (const integration of integrations) {
|
|
92
112
|
if (integration.__loadError != null) continue;
|
|
93
113
|
if (integration.__providerConflict != null) continue;
|
|
94
|
-
|
|
114
|
+
const value = integration[setting];
|
|
115
|
+
if (typeof value !== 'string') continue;
|
|
95
116
|
declared.push({
|
|
96
117
|
package: integration.name ?? integration.__spec ?? '(unnamed)',
|
|
97
|
-
|
|
118
|
+
value,
|
|
98
119
|
});
|
|
99
120
|
}
|
|
100
121
|
return declared;
|
|
101
122
|
}
|
|
102
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Choose among declarations: one value, declared by one or more
|
|
126
|
+
* integrations, is used; different values are a conflict.
|
|
127
|
+
* @param {DeclaredValue[]} declared
|
|
128
|
+
* @returns {{value?: string, conflict: boolean, declared: DeclaredValue[]}}
|
|
129
|
+
*/
|
|
130
|
+
export function chooseDeclaredValue(declared) {
|
|
131
|
+
const values = new Set(declared.map(entry => entry.value));
|
|
132
|
+
if (values.size === 1) {
|
|
133
|
+
return {value: declared[0].value, conflict: false, declared};
|
|
134
|
+
}
|
|
135
|
+
return {conflict: values.size > 1, declared};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The commands a set of loaded integrations declares, in load order.
|
|
140
|
+
* @param {Parameters<typeof declaredValuesOf>[0]} integrations
|
|
141
|
+
* @returns {DeclaredCliCommand[]}
|
|
142
|
+
*/
|
|
143
|
+
export function declaredCliCommandsOf(integrations) {
|
|
144
|
+
return declaredValuesOf(integrations, 'cliCommand').map(entry => ({
|
|
145
|
+
package: entry.package,
|
|
146
|
+
command: entry.value,
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
|
|
103
150
|
/**
|
|
104
151
|
* Choose among declarations: one command, declared by one or more
|
|
105
152
|
* integrations, is used; different commands are a conflict.
|
|
@@ -107,25 +154,38 @@ export function declaredCliCommandsOf(integrations) {
|
|
|
107
154
|
* @returns {{command?: string, conflict: boolean, declared: DeclaredCliCommand[]}}
|
|
108
155
|
*/
|
|
109
156
|
export function chooseDeclaredCliCommand(declared) {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
157
|
+
const {value, conflict} = chooseDeclaredValue(
|
|
158
|
+
declared.map(entry => ({package: entry.package, value: entry.command})),
|
|
159
|
+
);
|
|
160
|
+
return value == null
|
|
161
|
+
? {conflict, declared}
|
|
162
|
+
: {command: value, conflict, declared};
|
|
115
163
|
}
|
|
116
164
|
|
|
117
165
|
/**
|
|
118
|
-
* Record the
|
|
166
|
+
* Record the settings a project's loaded integrations declare. Called by
|
|
119
167
|
* `Project.load` each time it resolves the integration set; the latest load
|
|
120
168
|
* wins.
|
|
121
169
|
* @param {string} projectDir
|
|
122
|
-
* @param {Parameters<typeof
|
|
170
|
+
* @param {Parameters<typeof declaredValuesOf>[0]} integrations
|
|
123
171
|
* @returns {void}
|
|
124
172
|
*/
|
|
125
|
-
export function
|
|
173
|
+
export function recordDeclaredSettings(projectDir, integrations) {
|
|
126
174
|
declaredByProject.set(
|
|
127
175
|
projectKey(projectDir),
|
|
128
|
-
|
|
176
|
+
integrations
|
|
177
|
+
.filter(
|
|
178
|
+
each => each.__loadError == null && each.__providerConflict == null,
|
|
179
|
+
)
|
|
180
|
+
.map(each => ({
|
|
181
|
+
name: each.name ?? each.__spec ?? '(unnamed)',
|
|
182
|
+
...(typeof each.cliCommand === 'string'
|
|
183
|
+
? {cliCommand: each.cliCommand}
|
|
184
|
+
: {}),
|
|
185
|
+
...(typeof each.installGuidance === 'string'
|
|
186
|
+
? {installGuidance: each.installGuidance}
|
|
187
|
+
: {}),
|
|
188
|
+
})),
|
|
129
189
|
);
|
|
130
190
|
}
|
|
131
191
|
|
|
@@ -138,6 +198,40 @@ export function hasRecordedProject(targetDir = process.cwd()) {
|
|
|
138
198
|
return declaredByProject.has(projectKey(targetDir));
|
|
139
199
|
}
|
|
140
200
|
|
|
201
|
+
/**
|
|
202
|
+
* What the integrations of the project at `targetDir` declare for `setting`,
|
|
203
|
+
* as recorded by its last `Project.load` in this process; see
|
|
204
|
+
* {@link chooseDeclaredValue}.
|
|
205
|
+
* @param {DeclaredSetting} setting
|
|
206
|
+
* @param {string} [targetDir=process.cwd()]
|
|
207
|
+
* @returns {{value?: string, conflict: boolean, declared: DeclaredValue[]}}
|
|
208
|
+
*/
|
|
209
|
+
export function declaredSetting(setting, targetDir = process.cwd()) {
|
|
210
|
+
return chooseDeclaredValue(
|
|
211
|
+
declaredValuesOf(
|
|
212
|
+
declaredByProject.get(projectKey(targetDir)) ?? [],
|
|
213
|
+
setting,
|
|
214
|
+
),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* How an app in the project at `targetDir` adds `packages`, when its
|
|
220
|
+
* integrations say the package manager's add command is the wrong step there
|
|
221
|
+
* (`installGuidance`): their one line with `{packages}` filled in. Undefined
|
|
222
|
+
* when no loaded integration gives one, when two give different lines, or
|
|
223
|
+
* when this process has not loaded the project.
|
|
224
|
+
* @param {string[]} packages the packages to add, each as the step names it
|
|
225
|
+
* @param {string} [targetDir=process.cwd()]
|
|
226
|
+
* @returns {string | undefined}
|
|
227
|
+
*/
|
|
228
|
+
export function installGuidanceFor(packages, targetDir = process.cwd()) {
|
|
229
|
+
return declaredSetting('installGuidance', targetDir).value?.replaceAll(
|
|
230
|
+
'{packages}',
|
|
231
|
+
packages.join(' '),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
141
235
|
/**
|
|
142
236
|
* What the integrations of the project at `targetDir` declare, as recorded by
|
|
143
237
|
* its last `Project.load` in this process; see
|
|
@@ -147,6 +241,6 @@ export function hasRecordedProject(targetDir = process.cwd()) {
|
|
|
147
241
|
*/
|
|
148
242
|
export function declaredCliCommand(targetDir = process.cwd()) {
|
|
149
243
|
return chooseDeclaredCliCommand(
|
|
150
|
-
declaredByProject.get(projectKey(targetDir)) ?? [],
|
|
244
|
+
declaredCliCommandsOf(declaredByProject.get(projectKey(targetDir)) ?? []),
|
|
151
245
|
);
|
|
152
246
|
}
|
|
@@ -7,3 +7,12 @@
|
|
|
7
7
|
* @returns {boolean}
|
|
8
8
|
*/
|
|
9
9
|
export function isOutsideProject(cwd?: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* True when `cwd` is outside any project and no package.json is at or above
|
|
12
|
+
* it: where a command that writes to a project or package refuses to run. A
|
|
13
|
+
* folder with a package.json at or above it is a package being authored,
|
|
14
|
+
* even before it declares Astryx.
|
|
15
|
+
* @param {string} [cwd]
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
export function isOutsideAnyPackage(cwd?: string): boolean;
|
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
* to an app; each surface that prints such a step asks here first.
|
|
12
12
|
*
|
|
13
13
|
* @input a folder
|
|
14
|
-
* @output whether it is outside a project
|
|
14
|
+
* @output whether it is outside a project, or outside any package
|
|
15
15
|
* @position foundation/env — read by the setup reminder, init, doctor, upgrade,
|
|
16
|
-
*
|
|
16
|
+
* the theme, search, discover, and integration-check surfaces, and the
|
|
17
|
+
* commands that refuse to run outside a project.
|
|
17
18
|
*/
|
|
18
19
|
|
|
20
|
+
import * as fs from 'node:fs';
|
|
21
|
+
import * as path from 'node:path';
|
|
19
22
|
import {runChoice} from '../release/run-context.mjs';
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -31,3 +34,26 @@ export function isOutsideProject(cwd = process.cwd()) {
|
|
|
31
34
|
return false;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* True when `cwd` is outside any project and no package.json is at or above
|
|
40
|
+
* it: where a command that writes to a project or package refuses to run. A
|
|
41
|
+
* folder with a package.json at or above it is a package being authored,
|
|
42
|
+
* even before it declares Astryx.
|
|
43
|
+
* @param {string} [cwd]
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
export function isOutsideAnyPackage(cwd = process.cwd()) {
|
|
47
|
+
return isOutsideProject(cwd) && !hasPackageJsonAbove(cwd);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Is there a package.json in `dir` or a folder above it?
|
|
52
|
+
* @param {string} dir
|
|
53
|
+
*/
|
|
54
|
+
function hasPackageJsonAbove(dir) {
|
|
55
|
+
for (let at = path.resolve(dir); ; at = path.dirname(at)) {
|
|
56
|
+
if (fs.existsSync(path.join(at, 'package.json'))) return true;
|
|
57
|
+
if (path.dirname(at) === at) return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -113,6 +113,29 @@ export function persistedDerived<T, E>(key: unknown[], compute: () => T, codec:
|
|
|
113
113
|
decode: (stored: E) => T;
|
|
114
114
|
valid?: (value: T) => boolean;
|
|
115
115
|
}, inputs?: string[]): T;
|
|
116
|
+
/**
|
|
117
|
+
* A value that is a function of `key` and of this CLI build alone, kept in
|
|
118
|
+
* the catalogs folder: the parse of a doc the CLI reads from the stored docs,
|
|
119
|
+
* by the doc's text. The build and the folder it runs from stand for the
|
|
120
|
+
* CLI's own code, as in every kept entry, so nothing else is stamped. Kept
|
|
121
|
+
* only in a run that keeps catalogs (recordRunFor), by an installed CLI whose
|
|
122
|
+
* cache folder exists, and only when `codec` stores the value as text that
|
|
123
|
+
* reads back exactly. The entry holds a digest of that text, so a value that
|
|
124
|
+
* was changed after it was written is a miss. Anywhere else, or on any read
|
|
125
|
+
* or write error, `compute` runs as before. A `compute` that throws keeps
|
|
126
|
+
* nothing, so it throws the same way on every run.
|
|
127
|
+
* @template T, E
|
|
128
|
+
* @param {unknown[]} key - Everything the value is a function of, besides
|
|
129
|
+
* the CLI build; its first item names the kind of value.
|
|
130
|
+
* @param {() => T} compute
|
|
131
|
+
* @param {{encode: (value: T) => E, decode: (stored: E) => T, valid?: (value: T) => boolean}} codec
|
|
132
|
+
* @returns {T}
|
|
133
|
+
*/
|
|
134
|
+
export function persistedValue<T, E>(key: unknown[], compute: () => T, codec: {
|
|
135
|
+
encode: (value: T) => E;
|
|
136
|
+
decode: (stored: E) => T;
|
|
137
|
+
valid?: (value: T) => boolean;
|
|
138
|
+
}): T;
|
|
116
139
|
/**
|
|
117
140
|
* A summary of files and folders, made at once, kept as an entry beside the
|
|
118
141
|
* gathers, in or out of a recorded run: the stored value while every path
|
|
@@ -26,7 +26,11 @@
|
|
|
26
26
|
* against in Core's component docs,
|
|
27
27
|
* by `doctor` (api/doctor/_adapter.mjs) for its file-only docs checks and
|
|
28
28
|
* its theme-wiring scan, by the docs adapter (api/docs/_adapter.mjs) for
|
|
29
|
-
* the CLI's own docs tree, which `docs` and `search` read,
|
|
29
|
+
* the CLI's own docs tree, which `docs` and `search` read, by the discover
|
|
30
|
+
* adapter (api/discover/_adapter.mjs) for the integrations a project loads
|
|
31
|
+
* and what each adds, which `discover` lists, and for what discover
|
|
32
|
+
* searches in its sources' saved copies, which `search` reads for its
|
|
33
|
+
* discover line,
|
|
30
34
|
* in a run that records modules and variables to its end, and, through
|
|
31
35
|
* `persistedSummary`, by kept-tree.mjs for summaries of folder trees, the
|
|
32
36
|
* lookup commands' not-found hint's name index among them
|
|
@@ -37,7 +41,11 @@
|
|
|
37
41
|
* modules (api/theme/build/self-contained.mjs), each kept while every
|
|
38
42
|
* path it stamped but the CLI's own files (which its build id and the
|
|
39
43
|
* folder it runs from, both in every entry's key, stand for) is
|
|
40
|
-
* unchanged, in any command.
|
|
44
|
+
* unchanged, in any command. Through `persistedValue`, the stored docs
|
|
45
|
+
* (foundation/doc-compiler/stored-docs.mjs keptParse) keep each stored
|
|
46
|
+
* doc's parse by the doc's text and the zod release the parsers load,
|
|
47
|
+
* which with the build id are all the parse depends on, in a run that
|
|
48
|
+
* keeps catalogs. The commands whose runs keep the other
|
|
41
49
|
* entries are `search`, `build`, `component`, `template`, `theme`,
|
|
42
50
|
* `discover`, `docs` and `doctor`. The first such run on a machine makes the
|
|
43
51
|
* folder and keeps its gathers at once, so the next run (most often the same
|
|
@@ -1119,6 +1127,90 @@ export function persistedDerived(key, compute, codec, inputs = []) {
|
|
|
1119
1127
|
return value;
|
|
1120
1128
|
}
|
|
1121
1129
|
|
|
1130
|
+
/**
|
|
1131
|
+
* A value that is a function of `key` and of this CLI build alone, kept in
|
|
1132
|
+
* the catalogs folder: the parse of a doc the CLI reads from the stored docs,
|
|
1133
|
+
* by the doc's text. The build and the folder it runs from stand for the
|
|
1134
|
+
* CLI's own code, as in every kept entry, so nothing else is stamped. Kept
|
|
1135
|
+
* only in a run that keeps catalogs (recordRunFor), by an installed CLI whose
|
|
1136
|
+
* cache folder exists, and only when `codec` stores the value as text that
|
|
1137
|
+
* reads back exactly. The entry holds a digest of that text, so a value that
|
|
1138
|
+
* was changed after it was written is a miss. Anywhere else, or on any read
|
|
1139
|
+
* or write error, `compute` runs as before. A `compute` that throws keeps
|
|
1140
|
+
* nothing, so it throws the same way on every run.
|
|
1141
|
+
* @template T, E
|
|
1142
|
+
* @param {unknown[]} key - Everything the value is a function of, besides
|
|
1143
|
+
* the CLI build; its first item names the kind of value.
|
|
1144
|
+
* @param {() => T} compute
|
|
1145
|
+
* @param {{encode: (value: T) => E, decode: (stored: E) => T, valid?: (value: T) => boolean}} codec
|
|
1146
|
+
* @returns {T}
|
|
1147
|
+
*/
|
|
1148
|
+
export function persistedValue(key, compute, codec) {
|
|
1149
|
+
if (!run) return compute();
|
|
1150
|
+
const id = withoutRecording(buildId);
|
|
1151
|
+
const dir = id == null ? null : withoutRecording(gatherCacheDir);
|
|
1152
|
+
if (id == null || dir == null) return compute();
|
|
1153
|
+
const file = entryFile(dir, key, id);
|
|
1154
|
+
const entry = entryKey(key, id);
|
|
1155
|
+
try {
|
|
1156
|
+
const stored = JSON.parse(
|
|
1157
|
+
withoutRecording(() => fs.readFileSync(file, 'utf-8')),
|
|
1158
|
+
);
|
|
1159
|
+
const value =
|
|
1160
|
+
stored?.format === FORMAT &&
|
|
1161
|
+
stored.pure === true &&
|
|
1162
|
+
stored.key === entry &&
|
|
1163
|
+
stored.sum === textSum(JSON.stringify(stored.value))
|
|
1164
|
+
? readBack(() => stored.value, codec)
|
|
1165
|
+
: undefined;
|
|
1166
|
+
if (value !== undefined) {
|
|
1167
|
+
try {
|
|
1168
|
+
const now = new Date();
|
|
1169
|
+
withoutRecording(() => fs.utimesSync(file, now, now));
|
|
1170
|
+
} catch {
|
|
1171
|
+
// An entry that cannot be touched is evicted sooner; nothing more.
|
|
1172
|
+
}
|
|
1173
|
+
return value;
|
|
1174
|
+
}
|
|
1175
|
+
} catch {
|
|
1176
|
+
// No usable entry: computed below.
|
|
1177
|
+
}
|
|
1178
|
+
const value = compute();
|
|
1179
|
+
withoutRecording(() => {
|
|
1180
|
+
try {
|
|
1181
|
+
const body = storedText(codec, value);
|
|
1182
|
+
if (body === undefined) return;
|
|
1183
|
+
const head = JSON.stringify({
|
|
1184
|
+
format: FORMAT,
|
|
1185
|
+
pure: true,
|
|
1186
|
+
key: entry,
|
|
1187
|
+
sum: textSum(body),
|
|
1188
|
+
});
|
|
1189
|
+
// The value's text goes in as checked, as the head's last field.
|
|
1190
|
+
const text = `${head.slice(0, -1)},"value":${body}}`;
|
|
1191
|
+
const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
1192
|
+
fs.writeFileSync(temp, text, {mode: 0o600, flag: 'wx'});
|
|
1193
|
+
fs.renameSync(temp, file);
|
|
1194
|
+
evictOldest(dir, isEntry);
|
|
1195
|
+
} catch {
|
|
1196
|
+
// A value that cannot be stored is computed again next time.
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
return value;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* The digest a value kept by persistedValue is checked against: its JSON
|
|
1204
|
+
* text, as written and as the value read back writes it again.
|
|
1205
|
+
* @param {string | undefined} text
|
|
1206
|
+
* @returns {string | null}
|
|
1207
|
+
*/
|
|
1208
|
+
function textSum(text) {
|
|
1209
|
+
return text === undefined
|
|
1210
|
+
? null
|
|
1211
|
+
: createHash('sha256').update(text).digest('hex').slice(0, 32);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1122
1214
|
/**
|
|
1123
1215
|
* How old every stamped time must be before a summary is stored. A file
|
|
1124
1216
|
* system can store times as coarsely as 2 s, so a change within one tick of
|
|
@@ -34,7 +34,9 @@ export function importUserModule(file: string, { fresh }?: {
|
|
|
34
34
|
* there, so the caller can say what its outputs do not carry. Module loads
|
|
35
35
|
* outside this call's async context do not change. The module hook is
|
|
36
36
|
* installed for the first overlapping load and removed after the last. A
|
|
37
|
-
* Node without module hooks (before 22.15) runs the load
|
|
37
|
+
* Node without module hooks (before 22.15, or 23.0 to 23.4) runs the load
|
|
38
|
+
* unchanged, and a stylesheet or asset it meets refuses the load, naming
|
|
39
|
+
* that Node.
|
|
38
40
|
* @template T
|
|
39
41
|
* @param {() => Promise<T>} load
|
|
40
42
|
* @param {{unbuilt?: Set<string>, imported?: Set<string>}} [options]
|