@astryxdesign/cli 0.1.8-canary.0c4d8d7 → 0.1.8-canary.0db5dfd
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/{src/api → api/blog}/blog.mjs +42 -6
- package/{src/api → api/blog}/blog.test.mjs +2 -2
- package/api/build/build.mjs +92 -0
- package/api/build/build.test.mjs +92 -0
- package/{src/api → api/component}/component.mjs +49 -26
- package/{src/api → api/discover}/discover.mjs +55 -18
- package/{src/api → api/docs}/docs.mjs +47 -21
- package/{src/api → api/doctor}/doctor.mjs +11 -8
- package/{src/api → api/hook}/hook.mjs +11 -11
- package/{src/api → api}/index.mjs +16 -9
- package/{src/api → api/integration}/validate-integration.mjs +48 -15
- package/{src/api → api/integration}/validate-integration.test.mjs +1 -1
- package/{src/api → api/layout}/layout.mjs +66 -17
- package/{src/api → api/layout}/layout.test.mjs +1 -1
- package/{src/api → api/search}/search.mjs +71 -12
- package/api/swizzle/swizzle.mjs +283 -0
- package/{src/commands → api/swizzle}/swizzle.test.mjs +26 -1
- package/{src/api → api/template}/template-integration.test.mjs +2 -2
- package/{src/api → api/template}/template-suffix.test.mjs +3 -3
- package/{src/api → api/template}/template.mjs +96 -19
- package/{src/api → api/theme}/theme-add.mjs +35 -7
- package/{src → authoring}/codemod.mjs +6 -6
- package/{src → authoring}/config.test.mjs +1 -1
- package/{src → authoring}/doc.mjs +1 -1
- package/{src → authoring}/doc.test.mjs +1 -1
- package/{src → authoring}/template.mjs +1 -1
- package/bin/astryx.mjs +12 -10
- package/{src → cli}/commands/blog.mjs +48 -7
- package/{src → cli}/commands/build-theme.mjs +125 -46
- package/{src → cli}/commands/build.mjs +33 -57
- package/{src → cli}/commands/component/index.mjs +49 -22
- package/{src → cli}/commands/component-ownership.test.mjs +3 -3
- package/{src → cli}/commands/component-package.test.mjs +1 -1
- package/{src → cli}/commands/component-resolution.test.mjs +2 -2
- package/{src → cli}/commands/discover.mjs +17 -8
- package/{src → cli}/commands/docs.mjs +39 -7
- package/{src → cli}/commands/docs.test.mjs +1 -1
- package/{src → cli}/commands/doctor.mjs +3 -3
- package/{src → cli}/commands/doctor.test.mjs +2 -2
- package/{src → cli}/commands/ensure-core-built.mjs +3 -2
- package/{src → cli}/commands/external-showcase.test.mjs +1 -1
- package/{src → cli}/commands/hook/index.mjs +37 -14
- package/{src → cli}/commands/import-hint-correctness.test.mjs +1 -1
- package/{src → cli}/commands/init.mjs +20 -9
- package/{src → cli}/commands/layout.mjs +58 -18
- package/{src → cli}/commands/search.mjs +19 -12
- package/{src → cli}/commands/search.test.mjs +1 -1
- package/{src → cli}/commands/setup-nudge.test.mjs +1 -1
- package/cli/commands/swizzle.mjs +103 -0
- package/{src → cli}/commands/template.mjs +73 -22
- package/{src → cli}/commands/template.path-safety.test.mjs +2 -2
- package/{src → cli}/commands/upgrade.integration-policy.test.mjs +1 -1
- package/{src → cli}/commands/upgrade.mjs +160 -52
- package/{src → cli}/commands/upgrade.test.mjs +1 -1
- package/{src → cli}/commands/validate-integration.mjs +17 -37
- package/{src → cli}/index.mjs +17 -15
- package/{src/codemods → codemods}/ensure-jscodeshift.mjs +1 -1
- package/{src/codemods → codemods}/integration-discovery.mjs +6 -3
- package/{src/codemods → codemods}/integration-discovery.test.mjs +1 -1
- package/{src/codemods → codemods}/integration-runner.mjs +8 -3
- package/{src/codemods → codemods}/registry.mjs +3 -1
- package/{src/codemods → codemods}/run-codemod.mjs +17 -10
- package/{src/codemods → codemods}/runner.mjs +22 -12
- package/{src/codemods → codemods}/transforms/v0.0.10/remove-size-props.mjs +9 -4
- package/{src/codemods → codemods}/transforms/v0.0.12/add-is-icon-only.mjs +27 -22
- package/{src/codemods → codemods}/transforms/v0.0.13/icon-name-deprecations.mjs +12 -5
- package/{src/codemods → codemods}/transforms/v0.0.13/rename-attachments-to-drawer.mjs +15 -8
- package/{src/codemods → codemods}/transforms/v0.0.13/toolbar-density-to-size.mjs +10 -4
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-action-props.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-section-wash-to-muted.mjs +11 -6
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-status-variants.mjs +15 -10
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-item-children-to-endcontent.mjs +13 -8
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs +18 -13
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-theme-selectors-to-data-attrs.mjs +8 -4
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-date-picker-to-input.mjs +11 -6
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-imperative-ref-to-handleRef.mjs +6 -1
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-isStreaming-to-isStopShown.mjs +6 -1
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-stack-element-to-as.mjs +8 -3
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-badge-dot-to-statusdot.mjs +17 -10
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-gap-to-numeric.mjs +7 -1
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-isFullBleed-to-padding.mjs +9 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-useXDSIcon-to-getIcon.mjs +12 -7
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-banner-endButton-to-endContent.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-form-tooltip-startIcon.mjs +8 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-isShown-to-isOpen.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-selector-items-to-options.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-sidenav-header-to-heading.mjs +11 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-topnav-title-to-heading.mjs +10 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/unify-uncontrolled-to-defaultX.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/unify-visibility-to-onOpenChange.mjs +10 -5
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-badge-children-to-label.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-collapse-to-collapsible.mjs +9 -3
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-radius-tokens.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-shadow-tokens.mjs +13 -6
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-skeleton-radius.mjs +7 -1
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-token-names.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.7/rename-banner-variant-to-container.mjs +8 -3
- package/{src/codemods → codemods}/transforms/v0.0.8/migrate-token-renames.mjs +15 -8
- package/{src/codemods → codemods}/transforms/v0.0.8/rename-endslot-to-endcontent.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.1.0/drop-xds-prefix-imports.mjs +19 -14
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +21 -17
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-declare-module.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +16 -11
- package/{src/codemods → codemods}/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +15 -9
- package/{src/codemods → codemods}/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +17 -12
- package/{src/codemods → codemods}/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +15 -9
- package/{src/codemods → codemods}/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +17 -10
- package/{src/codemods → codemods}/transforms/v0.1.7/rename-table-renderprops-styles-to-xstyle.mjs +18 -13
- package/{src/codemods → codemods}/transforms/v0.1.8/rename-avatar-size-scale.mjs +15 -10
- package/docs/internationalization.doc.mjs +92 -46
- package/{src/commands → lib/agent-docs}/agent-docs.mjs +30 -11
- package/{src/commands → lib/agent-docs}/agent-docs.path-safety.test.mjs +1 -1
- package/{src/lib → lib}/component-discovery.mjs +44 -2
- package/{src/lib → lib}/component-format.mjs +65 -24
- package/{src/lib → lib}/component-loader.mjs +27 -13
- package/{src/lib → lib}/componentDocOverlay.test.mjs +0 -1
- package/{src/lib → lib}/error-codes.test.mjs +1 -1
- package/{src/lib → lib}/hook-discovery.mjs +14 -1
- package/{src/lib → lib}/hook-format.mjs +29 -5
- package/{src/lib → lib}/integration-warnings.mjs +2 -2
- package/{src/lib → lib}/integrations.mjs +20 -0
- package/{src/lib → lib}/integrations.test.mjs +1 -1
- package/{src/lib → lib}/json-contract.test.mjs +1 -1
- package/{src/lib → lib}/json-shim.mjs +10 -5
- package/{src/lib → lib}/json-shim.test.mjs +1 -1
- package/{src/lib → lib}/levenshtein.mjs +6 -0
- package/{src/lib → lib}/manifest.mjs +7 -5
- package/{src/lib → lib}/manifest.test.mjs +2 -2
- package/{src/lib → lib}/module-loader.mjs +1 -0
- package/{src/lib → lib}/package-scanner.mjs +47 -0
- package/{src/lib → lib}/project.mjs +48 -18
- package/{src/lib → lib}/project.test.mjs +1 -1
- package/{src/lib → lib}/resolve-theme.mjs +5 -0
- package/{src/lib → lib}/string-utils.mjs +15 -0
- package/{src/lib → lib}/term-log.mjs +12 -3
- package/{src/lib → lib}/xle/browser.mjs +18 -8
- package/{src/lib → lib}/xle/expand.mjs +155 -22
- package/{src/lib → lib}/xle/parse.mjs +119 -13
- package/{src/lib → lib}/xle/print.mjs +54 -14
- package/{src/lib → lib}/xle/registry-core.mjs +28 -3
- package/{src/lib → lib}/xle/registry.mjs +9 -4
- package/{src/lib → lib}/xle/splice.mjs +13 -2
- package/{src/lib → lib}/xle/validate.mjs +95 -14
- package/lib/xle/xle-ast.d.ts +214 -0
- package/package.json +33 -26
- package/scripts/postinstall.mjs +4 -4
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +1 -1
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +19 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +46 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +14 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +33 -0
- package/{src/types → types}/api.contract.assert.ts +17 -8
- package/{src/types → types}/api.d.ts +106 -0
- package/{src/types → types}/base.d.ts +17 -2
- package/types/build.d.ts +53 -0
- package/types/codemod.d.ts +166 -0
- package/{src/types → types}/component.d.ts +1 -1
- package/{src/types → types}/discover.d.ts +1 -1
- package/{src/types → types}/docs.d.ts +1 -4
- package/{src/types → types}/hook.d.ts +1 -1
- package/types/jscodeshift.d.ts +19 -0
- package/types/layout.d.ts +74 -0
- package/types/theme.d.ts +53 -0
- package/{src/types → types}/upgrade.d.ts +8 -1
- package/{src/utils → utils}/paths.mjs +4 -1
- package/src/commands/swizzle.mjs +0 -417
- package/src/types/build.d.ts +0 -23
- package/src/types/codemod.d.ts +0 -81
- package/src/types/theme.d.ts +0 -23
- /package/{src/api → api/docs}/docOverlays.test.mjs +0 -0
- /package/{src/api → api}/error.mjs +0 -0
- /package/{src/api → api/integration}/integration-block-exports.test.mjs +0 -0
- /package/{src/api → api/template}/template.test.mjs +0 -0
- /package/{src → authoring}/codemod.test.mjs +0 -0
- /package/{src → authoring}/config.mjs +0 -0
- /package/{src → authoring}/integration.mjs +0 -0
- /package/{src → authoring}/template.test.mjs +0 -0
- /package/{src → cli}/cli-exit-codes.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.color-scheme.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.import-path.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.path-safety.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.prose.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.variants.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.watch.test.mjs +0 -0
- /package/{src → cli}/commands/cli-postinstall.test.mjs +0 -0
- /package/{src → cli}/commands/component.test.mjs +0 -0
- /package/{src → cli}/commands/detail-levels.test.mjs +0 -0
- /package/{src → cli}/commands/init.next-steps.test.mjs +0 -0
- /package/{src → cli}/commands/interactive-guard.test.mjs +0 -0
- /package/{src → cli}/commands/json-contract.test.mjs +0 -0
- /package/{src → cli}/commands/swizzle.path-safety.test.mjs +0 -0
- /package/{src → cli}/commands/swizzle.routing.test.mjs +0 -0
- /package/{src → cli}/commands/template.test.mjs +0 -0
- /package/{src → cli}/commands/upgrade.config-ordering.test.mjs +0 -0
- /package/{src → cli}/commands/validate-integration.test.mjs +0 -0
- /package/{src → cli}/update-hint-commands.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/registry.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-section-wash-to-muted.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/runner.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/toolbar-density-to-size.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/validation.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.10/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.12/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.7/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.2/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.3/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.5/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.8/index.mjs +0 -0
- /package/{src/commands → lib/agent-docs}/agent-docs.test.mjs +0 -0
- /package/{src/lib → lib}/cli-error.mjs +0 -0
- /package/{src/lib → lib}/cli-error.test.mjs +0 -0
- /package/{src/lib → lib}/component-discovery.importpath.test.mjs +0 -0
- /package/{src/lib → lib}/component-format.test.mjs +0 -0
- /package/{src/lib → lib}/component-loader.test.mjs +0 -0
- /package/{src/lib → lib}/config-cache.mjs +0 -0
- /package/{src/lib → lib}/config-cache.test.mjs +0 -0
- /package/{src/lib → lib}/config-schema.mjs +0 -0
- /package/{src/lib → lib}/error-codes.mjs +0 -0
- /package/{src/lib → lib}/integration-warnings.test.mjs +0 -0
- /package/{src/lib → lib}/json.mjs +0 -0
- /package/{src/lib → lib}/module-loader.test.mjs +0 -0
- /package/{src/lib → lib}/node-version.mjs +0 -0
- /package/{src/lib → lib}/node-version.test.mjs +0 -0
- /package/{src/lib → lib}/parse.mjs +0 -0
- /package/{src/lib → lib}/site.mjs +0 -0
- /package/{src/lib → lib}/xle/browser.d.ts +0 -0
- /package/{src/lib → lib}/xle/xle.test.mjs +0 -0
- /package/{src/schemas → schemas}/doc-schema.mjs +0 -0
- /package/{src/schemas → schemas}/template-schema.mjs +0 -0
- /package/{src/types → types}/config.d.ts +0 -0
- /package/{src/types → types}/doc.d.ts +0 -0
- /package/{src/types → types}/doctor.d.ts +0 -0
- /package/{src/types → types}/error-codes.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/integration.d.ts +0 -0
- /package/{src/types → types}/manifest.d.ts +0 -0
- /package/{src/types → types}/search.d.ts +0 -0
- /package/{src/types → types}/swizzle.d.ts +0 -0
- /package/{src/types → types}/template-api.d.ts +0 -0
- /package/{src/types → types}/template.d.ts +0 -0
- /package/{src/types → types}/validate-integration.d.ts +0 -0
- /package/{src/utils → utils}/github.mjs +0 -0
- /package/{src/utils → utils}/package-manager.mjs +0 -0
- /package/{src/utils → utils}/package-manager.test.mjs +0 -0
- /package/{src/utils → utils}/path-safety.mjs +0 -0
- /package/{src/utils → utils}/path-safety.test.mjs +0 -0
- /package/{src/utils → utils}/paths.test.mjs +0 -0
- /package/{src/utils → utils}/semver.mjs +0 -0
- /package/{src/utils → utils}/semver.test.mjs +0 -0
- /package/{src/utils → utils}/update-check.mjs +0 -0
- /package/{src/utils → utils}/update-check.test.mjs +0 -0
|
@@ -7,21 +7,54 @@
|
|
|
7
7
|
import * as fs from 'node:fs';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import {createJiti} from 'jiti';
|
|
10
|
-
import {loadModuleWithSchema} from '
|
|
11
|
-
import {TemplateEnvelopeSchema} from '
|
|
12
|
-
import {CLI_ROOT, discoverExternalPackages} from '
|
|
10
|
+
import {loadModuleWithSchema} from '../../lib/module-loader.mjs';
|
|
11
|
+
import {TemplateEnvelopeSchema} from '../../schemas/template-schema.mjs';
|
|
12
|
+
import {CLI_ROOT, discoverExternalPackages} from '../../utils/paths.mjs';
|
|
13
13
|
import {
|
|
14
14
|
assertWithin,
|
|
15
15
|
isFilePathArg,
|
|
16
16
|
PathSafetyError,
|
|
17
|
-
} from '
|
|
18
|
-
import {AstryxError} from '
|
|
19
|
-
import {ERROR_CODES} from '
|
|
20
|
-
import {Project} from '
|
|
17
|
+
} from '../../utils/path-safety.mjs';
|
|
18
|
+
import {AstryxError} from '../error.mjs';
|
|
19
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
20
|
+
import {Project} from '../../lib/project.mjs';
|
|
21
21
|
|
|
22
22
|
/** Identity used for core (built-in) templates in package-scoped listings. */
|
|
23
23
|
const CORE_PACKAGE = '@astryxdesign/core';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A discovered template (page or block), normalized across core, external, and
|
|
27
|
+
* integration sources. Not every source populates every field, so
|
|
28
|
+
* source-specific extras (`aspectRatio`, `isShowcase`, `package`) are optional.
|
|
29
|
+
* @typedef {object} DiscoveredTemplate
|
|
30
|
+
* @property {'page'|'block'} type
|
|
31
|
+
* @property {string} dirName
|
|
32
|
+
* @property {string} name
|
|
33
|
+
* @property {string} description
|
|
34
|
+
* @property {string} [category]
|
|
35
|
+
* @property {boolean} [isReady]
|
|
36
|
+
* @property {boolean} [scaffold]
|
|
37
|
+
* @property {number} [aspectRatio]
|
|
38
|
+
* @property {string[]} [componentsUsed]
|
|
39
|
+
* @property {boolean} [isShowcase]
|
|
40
|
+
* @property {string} filePath
|
|
41
|
+
* @property {string} docPath
|
|
42
|
+
* @property {string} [package]
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An integration-template discovery error.
|
|
47
|
+
* @typedef {object} TemplateDiscoveryError
|
|
48
|
+
* @property {string} package
|
|
49
|
+
* @property {string} [template]
|
|
50
|
+
* @property {string} message
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The loaded metadata object from a template spec (loose — authored shape).
|
|
55
|
+
* @typedef {Record<string, any> | undefined | null} TemplateDocModule
|
|
56
|
+
*/
|
|
57
|
+
|
|
25
58
|
/**
|
|
26
59
|
* Canonical basename suffixes for template-spec files, in precedence order.
|
|
27
60
|
* A template spec exports a `createBlockTemplate`/`createPageTemplate` result
|
|
@@ -60,6 +93,7 @@ function matchedTemplateSuffix(file) {
|
|
|
60
93
|
*/
|
|
61
94
|
const TEMPLATE_SUFFIX_RE = /\.(template|doc)\.(ts|mjs|js)$/;
|
|
62
95
|
|
|
96
|
+
/** @type {ReturnType<typeof createJiti> | undefined} */
|
|
63
97
|
let jitiInstance;
|
|
64
98
|
/** Lazily-created jiti for loading `.ts` template specs (JSX-capable). */
|
|
65
99
|
function getJiti() {
|
|
@@ -69,7 +103,6 @@ function getJiti() {
|
|
|
69
103
|
return jitiInstance;
|
|
70
104
|
}
|
|
71
105
|
|
|
72
|
-
|
|
73
106
|
/**
|
|
74
107
|
* Load an integration template doc module and validate it against the template
|
|
75
108
|
* envelope at the load boundary. Default export only — `.ts` via jiti,
|
|
@@ -145,7 +178,7 @@ export function stripTemplateAssetRefs(source) {
|
|
|
145
178
|
* native dynamic import. Returns null if the file does not exist.
|
|
146
179
|
*
|
|
147
180
|
* @param {string} docPath absolute path to the spec file
|
|
148
|
-
* @returns {Promise<
|
|
181
|
+
* @returns {Promise<TemplateDocModule>}
|
|
149
182
|
*/
|
|
150
183
|
async function loadDocModule(docPath) {
|
|
151
184
|
if (!fs.existsSync(docPath)) return null;
|
|
@@ -159,6 +192,7 @@ async function loadDocModule(docPath) {
|
|
|
159
192
|
export {discoverAll as discoverTemplates};
|
|
160
193
|
|
|
161
194
|
export function listTemplates() {
|
|
195
|
+
/** @type {string[]} */
|
|
162
196
|
const all = [];
|
|
163
197
|
if (fs.existsSync(PAGES_DIR)) {
|
|
164
198
|
all.push(
|
|
@@ -171,7 +205,13 @@ export function listTemplates() {
|
|
|
171
205
|
return all.sort();
|
|
172
206
|
}
|
|
173
207
|
|
|
208
|
+
/**
|
|
209
|
+
* @param {string} dir
|
|
210
|
+
* @param {RegExp} pattern
|
|
211
|
+
* @returns {string[]}
|
|
212
|
+
*/
|
|
174
213
|
function findDocFiles(dir, pattern) {
|
|
214
|
+
/** @type {string[]} */
|
|
175
215
|
const results = [];
|
|
176
216
|
if (!fs.existsSync(dir)) return results;
|
|
177
217
|
for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
|
|
@@ -205,6 +245,7 @@ async function discoverPages() {
|
|
|
205
245
|
.readdirSync(PAGES_DIR, {withFileTypes: true})
|
|
206
246
|
.filter(e => e.isDirectory());
|
|
207
247
|
|
|
248
|
+
/** @type {DiscoveredTemplate[]} */
|
|
208
249
|
const templates = [];
|
|
209
250
|
for (const dir of dirs) {
|
|
210
251
|
const dirPath = path.join(PAGES_DIR, dir.name);
|
|
@@ -228,9 +269,11 @@ async function discoverPages() {
|
|
|
228
269
|
|
|
229
270
|
async function discoverBlocks() {
|
|
230
271
|
const docFiles = findDocFiles(BLOCKS_DIR, TEMPLATE_SUFFIX_RE);
|
|
272
|
+
/** @type {DiscoveredTemplate[]} */
|
|
231
273
|
const blocks = [];
|
|
232
274
|
for (const docPath of docFiles) {
|
|
233
275
|
const suffix = matchedTemplateSuffix(docPath);
|
|
276
|
+
if (!suffix) continue;
|
|
234
277
|
const basename = path.basename(docPath, suffix);
|
|
235
278
|
const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
|
|
236
279
|
if (!fs.existsSync(tsxPath)) continue;
|
|
@@ -262,6 +305,7 @@ async function discoverBlocks() {
|
|
|
262
305
|
*/
|
|
263
306
|
async function discoverExternalBlocks(cwd = process.cwd()) {
|
|
264
307
|
const externals = discoverExternalPackages(cwd);
|
|
308
|
+
/** @type {DiscoveredTemplate[]} */
|
|
265
309
|
const blocks = [];
|
|
266
310
|
|
|
267
311
|
for (const ext of externals) {
|
|
@@ -269,6 +313,7 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
|
|
|
269
313
|
const docFiles = findDocFiles(ext.blocksDir, TEMPLATE_SUFFIX_RE);
|
|
270
314
|
for (const docPath of docFiles) {
|
|
271
315
|
const suffix = matchedTemplateSuffix(docPath);
|
|
316
|
+
if (!suffix) continue;
|
|
272
317
|
const basename = path.basename(docPath, suffix);
|
|
273
318
|
const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
|
|
274
319
|
if (!fs.existsSync(tsxPath)) continue;
|
|
@@ -297,6 +342,7 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
|
|
|
297
342
|
/**
|
|
298
343
|
* Discover all blocks — core + external packages.
|
|
299
344
|
* @param {string} [cwd]
|
|
345
|
+
* @returns {Promise<DiscoveredTemplate[]>}
|
|
300
346
|
*/
|
|
301
347
|
async function discoverAllBlocks(cwd = process.cwd()) {
|
|
302
348
|
const [core, external] = await Promise.all([
|
|
@@ -306,6 +352,10 @@ async function discoverAllBlocks(cwd = process.cwd()) {
|
|
|
306
352
|
return [...core, ...external];
|
|
307
353
|
}
|
|
308
354
|
|
|
355
|
+
/**
|
|
356
|
+
* @param {string} [cwd]
|
|
357
|
+
* @returns {Promise<DiscoveredTemplate[]>}
|
|
358
|
+
*/
|
|
309
359
|
async function discoverAll(cwd = process.cwd()) {
|
|
310
360
|
const [pages, blocks, integration] = await Promise.all([
|
|
311
361
|
discoverPages(),
|
|
@@ -323,7 +373,7 @@ async function discoverAll(cwd = process.cwd()) {
|
|
|
323
373
|
* when the caller wants to warn about malformed integration templates.
|
|
324
374
|
*
|
|
325
375
|
* @param {string} [cwd]
|
|
326
|
-
* @returns {Promise<{templates:
|
|
376
|
+
* @returns {Promise<{templates: DiscoveredTemplate[], errors: TemplateDiscoveryError[]}>}
|
|
327
377
|
*/
|
|
328
378
|
async function discoverAllWithErrors(cwd = process.cwd()) {
|
|
329
379
|
const [pages, blocks, integration] = await Promise.all([
|
|
@@ -348,8 +398,10 @@ export {discoverAllWithErrors};
|
|
|
348
398
|
* @returns {string[]}
|
|
349
399
|
*/
|
|
350
400
|
function findIntegrationDocFiles(root) {
|
|
401
|
+
/** @type {string[]} */
|
|
351
402
|
const results = [];
|
|
352
403
|
if (!fs.existsSync(root)) return results;
|
|
404
|
+
/** @param {string} dir */
|
|
353
405
|
const walk = dir => {
|
|
354
406
|
for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
|
|
355
407
|
const full = path.join(dir, entry.name);
|
|
@@ -377,16 +429,21 @@ function findIntegrationDocFiles(root) {
|
|
|
377
429
|
* template is skipped (recorded in `errors`).
|
|
378
430
|
*
|
|
379
431
|
* @param {string} [cwd]
|
|
380
|
-
* @returns {Promise<{templates:
|
|
432
|
+
* @returns {Promise<{templates: DiscoveredTemplate[], errors: TemplateDiscoveryError[]}>}
|
|
381
433
|
*/
|
|
382
434
|
async function discoverIntegrationTemplates(cwd = process.cwd()) {
|
|
435
|
+
/** @type {DiscoveredTemplate[]} */
|
|
383
436
|
const templates = [];
|
|
437
|
+
/** @type {TemplateDiscoveryError[]} */
|
|
384
438
|
const errors = [];
|
|
385
439
|
|
|
386
440
|
let loadedIntegrations;
|
|
387
441
|
try {
|
|
388
442
|
const project = await Project.load(cwd);
|
|
389
|
-
loadedIntegrations =
|
|
443
|
+
loadedIntegrations =
|
|
444
|
+
/** @type {import('../../lib/integrations.mjs').LoadedIntegration[]} */ (
|
|
445
|
+
project.loadedIntegrations
|
|
446
|
+
);
|
|
390
447
|
} catch {
|
|
391
448
|
// Config load failures are surfaced elsewhere (discover/doctor); here we
|
|
392
449
|
// simply contribute no integration templates.
|
|
@@ -409,10 +466,12 @@ async function discoverIntegrationTemplates(cwd = process.cwd()) {
|
|
|
409
466
|
* than thrown. Exposed for `validate-integration`.
|
|
410
467
|
*
|
|
411
468
|
* @param {{name?: string, __spec?: string, templates?: string}} integration
|
|
412
|
-
* @returns {Promise<{templates:
|
|
469
|
+
* @returns {Promise<{templates: DiscoveredTemplate[], errors: TemplateDiscoveryError[]}>}
|
|
413
470
|
*/
|
|
414
471
|
export async function discoverIntegrationTemplatesForOne(integration) {
|
|
472
|
+
/** @type {DiscoveredTemplate[]} */
|
|
415
473
|
const templates = [];
|
|
474
|
+
/** @type {TemplateDiscoveryError[]} */
|
|
416
475
|
const errors = [];
|
|
417
476
|
|
|
418
477
|
const root = integration?.templates;
|
|
@@ -421,6 +480,7 @@ export async function discoverIntegrationTemplatesForOne(integration) {
|
|
|
421
480
|
|
|
422
481
|
for (const docPath of findIntegrationDocFiles(root)) {
|
|
423
482
|
const suffix = matchedTemplateSuffix(docPath);
|
|
483
|
+
if (!suffix) continue;
|
|
424
484
|
const id = path
|
|
425
485
|
.relative(root, docPath)
|
|
426
486
|
.slice(0, -suffix.length)
|
|
@@ -444,7 +504,7 @@ export async function discoverIntegrationTemplatesForOne(integration) {
|
|
|
444
504
|
errors.push({
|
|
445
505
|
package: pkgLabel,
|
|
446
506
|
template: id,
|
|
447
|
-
message: `Template "${id}" failed to load: ${err.message}`,
|
|
507
|
+
message: `Template "${id}" failed to load: ${/** @type {any} */ (err).message}`,
|
|
448
508
|
});
|
|
449
509
|
continue;
|
|
450
510
|
}
|
|
@@ -480,10 +540,15 @@ export async function discoverIntegrationTemplatesForOne(integration) {
|
|
|
480
540
|
return {templates, errors};
|
|
481
541
|
}
|
|
482
542
|
|
|
543
|
+
/**
|
|
544
|
+
* @param {string} componentName
|
|
545
|
+
* @param {string} [cwd]
|
|
546
|
+
* @returns {Promise<DiscoveredTemplate[]>}
|
|
547
|
+
*/
|
|
483
548
|
export async function findRelatedBlocks(componentName, cwd) {
|
|
484
549
|
const blocks = await discoverAllBlocks(cwd);
|
|
485
550
|
return blocks.filter(b =>
|
|
486
|
-
b.componentsUsed.some(c => c.toLowerCase() === componentName.toLowerCase()),
|
|
551
|
+
(b.componentsUsed ?? []).some(c => c.toLowerCase() === componentName.toLowerCase()),
|
|
487
552
|
);
|
|
488
553
|
}
|
|
489
554
|
|
|
@@ -506,7 +571,7 @@ export async function findShowcase(componentName, cwd, options) {
|
|
|
506
571
|
return true;
|
|
507
572
|
});
|
|
508
573
|
|
|
509
|
-
const toResult = b => ({
|
|
574
|
+
const toResult = (/** @type {DiscoveredTemplate} */ b) => ({
|
|
510
575
|
name: b.name,
|
|
511
576
|
aspectRatio: b.aspectRatio,
|
|
512
577
|
filePath: b.filePath,
|
|
@@ -515,14 +580,14 @@ export async function findShowcase(componentName, cwd, options) {
|
|
|
515
580
|
|
|
516
581
|
// Priority 1: own directory (components/Badge/ for "Badge")
|
|
517
582
|
const dirMatch = showcases.find(b => {
|
|
518
|
-
const catDir = path.basename(b.category).toLowerCase();
|
|
583
|
+
const catDir = path.basename(b.category ?? '').toLowerCase();
|
|
519
584
|
return catDir === lc;
|
|
520
585
|
});
|
|
521
586
|
if (dirMatch) return toResult(dirMatch);
|
|
522
587
|
|
|
523
588
|
// Priority 2: componentsUsed in any directory (ClickableCard in Card/)
|
|
524
589
|
const usedMatch = showcases.find(b =>
|
|
525
|
-
b.componentsUsed.some(c => c.toLowerCase() === lc),
|
|
590
|
+
(b.componentsUsed ?? []).some(c => c.toLowerCase() === lc),
|
|
526
591
|
);
|
|
527
592
|
if (usedMatch) return toResult(usedMatch);
|
|
528
593
|
|
|
@@ -540,6 +605,10 @@ const UBIQUITOUS = new Set([
|
|
|
540
605
|
'Icon',
|
|
541
606
|
]);
|
|
542
607
|
|
|
608
|
+
/**
|
|
609
|
+
* @param {string} pagePath
|
|
610
|
+
* @returns {string[]}
|
|
611
|
+
*/
|
|
543
612
|
export function extractComponents(pagePath) {
|
|
544
613
|
const src = fs.readFileSync(pagePath, 'utf-8');
|
|
545
614
|
// Match JSX opening tags, e.g. `<Section` or the legacy `<XDSSection`.
|
|
@@ -548,6 +617,7 @@ export function extractComponents(pagePath) {
|
|
|
548
617
|
// JSX-tag boundary keeps this precise (avoids matching imports/comments/
|
|
549
618
|
// identifiers) while remaining prefix-agnostic.
|
|
550
619
|
const tagRegex = /<(XDS)?([A-Z]\w+)/g;
|
|
620
|
+
/** @type {string[]} */
|
|
551
621
|
const matches = [];
|
|
552
622
|
let m;
|
|
553
623
|
while ((m = tagRegex.exec(src)) !== null) {
|
|
@@ -617,10 +687,11 @@ const SPATIAL_PROPS = [
|
|
|
617
687
|
* @returns {string[]}
|
|
618
688
|
*/
|
|
619
689
|
function extractSpatialAttrs(tagText) {
|
|
690
|
+
/** @type {string[]} */
|
|
620
691
|
const attrs = [];
|
|
621
692
|
for (const name of SPATIAL_PROPS) {
|
|
622
693
|
const eqMatch = tagText.match(new RegExp(`\\b${name}\\s*=\\s*`));
|
|
623
|
-
if (eqMatch) {
|
|
694
|
+
if (eqMatch && eqMatch.index != null) {
|
|
624
695
|
const start = eqMatch.index;
|
|
625
696
|
let i = eqMatch.index + eqMatch[0].length;
|
|
626
697
|
const rest = tagText.slice(i);
|
|
@@ -662,13 +733,19 @@ function extractSpatialAttrs(tagText) {
|
|
|
662
733
|
return attrs;
|
|
663
734
|
}
|
|
664
735
|
|
|
736
|
+
/**
|
|
737
|
+
* @param {string} source
|
|
738
|
+
* @returns {string}
|
|
739
|
+
*/
|
|
665
740
|
function extractSkeleton(source) {
|
|
666
741
|
const lines = source.split('\n');
|
|
742
|
+
/** @type {string[]} */
|
|
667
743
|
const out = [];
|
|
668
744
|
let depth = 0;
|
|
669
745
|
let capturing = false;
|
|
670
746
|
let inDefaultExport = false;
|
|
671
747
|
const MAX_LINES = 35;
|
|
748
|
+
/** @type {string[]} */
|
|
672
749
|
const depthStack = [];
|
|
673
750
|
|
|
674
751
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
import * as fs from 'node:fs';
|
|
10
10
|
import * as path from 'node:path';
|
|
11
|
-
import {CLI_ROOT} from '
|
|
12
|
-
import {assertWithin, PathSafetyError} from '
|
|
13
|
-
import {AstryxError} from '
|
|
14
|
-
import {ERROR_CODES} from '
|
|
11
|
+
import {CLI_ROOT} from '../../utils/paths.mjs';
|
|
12
|
+
import {assertWithin, PathSafetyError} from '../../utils/path-safety.mjs';
|
|
13
|
+
import {AstryxError} from '../error.mjs';
|
|
14
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
15
15
|
|
|
16
16
|
const THEMES_DIR = path.join(CLI_ROOT, 'templates', 'themes');
|
|
17
17
|
const MANIFEST_PATH = path.join(THEMES_DIR, 'manifest.json');
|
|
@@ -21,19 +21,39 @@ const MANIFEST_PATH = path.join(THEMES_DIR, 'manifest.json');
|
|
|
21
21
|
const META_COPYRIGHT_HEADER_RE =
|
|
22
22
|
/^(\uFEFF?(?:#![^\r\n]*(?:\r?\n))?)\/\/ Copyright \(c\) Meta Platforms, Inc\. and affiliates\.\r?\n(?:\r?\n)*/;
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* A single bundled theme entry from `templates/themes/manifest.json`.
|
|
26
|
+
* @typedef {object} BundledTheme
|
|
27
|
+
* @property {string} slug
|
|
28
|
+
* @property {string} displayName
|
|
29
|
+
* @property {string} description
|
|
30
|
+
* @property {boolean} maintained
|
|
31
|
+
* @property {string} entry
|
|
32
|
+
* @property {string} exportName
|
|
33
|
+
* @property {string[]} files
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} source
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
24
40
|
function stripCopyrightHeader(source) {
|
|
25
41
|
return source.replace(META_COPYRIGHT_HEADER_RE, '$1');
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Parsed `themes` array from the bundle manifest (empty if not generated).
|
|
46
|
+
* @returns {BundledTheme[]}
|
|
47
|
+
*/
|
|
29
48
|
export function listThemes() {
|
|
30
49
|
if (!fs.existsSync(MANIFEST_PATH)) return [];
|
|
50
|
+
/** @type {{themes?: BundledTheme[]}} */
|
|
31
51
|
let manifest;
|
|
32
52
|
try {
|
|
33
53
|
manifest = JSON.parse(fs.readFileSync(MANIFEST_PATH, 'utf-8'));
|
|
34
54
|
} catch (err) {
|
|
35
55
|
throw new AstryxError(
|
|
36
|
-
`Theme bundle manifest is unreadable (${MANIFEST_PATH}): ${err.message}`,
|
|
56
|
+
`Theme bundle manifest is unreadable (${MANIFEST_PATH}): ${/** @type {any} */ (err).message}`,
|
|
37
57
|
undefined,
|
|
38
58
|
ERROR_CODES.ERR_NO_SOURCE,
|
|
39
59
|
);
|
|
@@ -41,12 +61,20 @@ export function listThemes() {
|
|
|
41
61
|
return Array.isArray(manifest.themes) ? manifest.themes : [];
|
|
42
62
|
}
|
|
43
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} [slug]
|
|
66
|
+
* @returns {BundledTheme | undefined}
|
|
67
|
+
*/
|
|
44
68
|
function findTheme(slug) {
|
|
45
69
|
if (!slug) return undefined;
|
|
46
70
|
const lc = String(slug).toLowerCase();
|
|
47
71
|
return listThemes().find(t => t.slug.toLowerCase() === lc);
|
|
48
72
|
}
|
|
49
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @param {string} slug
|
|
76
|
+
* @returns {string}
|
|
77
|
+
*/
|
|
50
78
|
function defaultTargetDir(slug) {
|
|
51
79
|
return path.join('src', 'themes', slug);
|
|
52
80
|
}
|
|
@@ -160,7 +188,7 @@ export async function themeAdd(slug, options = {}) {
|
|
|
160
188
|
}
|
|
161
189
|
}
|
|
162
190
|
throw new AstryxError(
|
|
163
|
-
`Failed to write theme files: ${err.message}`,
|
|
191
|
+
`Failed to write theme files: ${/** @type {any} */ (err).message}`,
|
|
164
192
|
undefined,
|
|
165
193
|
ERROR_CODES.ERR_WRITE_FAILED,
|
|
166
194
|
);
|
|
@@ -65,12 +65,12 @@ export const CodemodEnvelopeSchema = z.discriminatedUnion('type', [
|
|
|
65
65
|
* Define a file-transforming codemod. Stamp-only: returns the definition with
|
|
66
66
|
* `type: 'code'` injected. Validation happens at the load boundary.
|
|
67
67
|
*
|
|
68
|
-
* @template {import('
|
|
68
|
+
* @template {import('../types/codemod').AstryxCodemodDef} T
|
|
69
69
|
* @param {T} def
|
|
70
|
-
* @returns {import('
|
|
70
|
+
* @returns {import('../types/codemod').AstryxCodemod}
|
|
71
71
|
*/
|
|
72
72
|
export function createCodemod(def) {
|
|
73
|
-
return /** @type {import('
|
|
73
|
+
return /** @type {import('../types/codemod').AstryxCodemod} */ ({
|
|
74
74
|
...def,
|
|
75
75
|
type: 'code',
|
|
76
76
|
});
|
|
@@ -81,12 +81,12 @@ export function createCodemod(def) {
|
|
|
81
81
|
* returns the definition with `type: 'config'` injected. Validation happens at
|
|
82
82
|
* the load boundary.
|
|
83
83
|
*
|
|
84
|
-
* @template {import('
|
|
84
|
+
* @template {import('../types/codemod').AstryxConfigCodemodDef} T
|
|
85
85
|
* @param {T} def
|
|
86
|
-
* @returns {import('
|
|
86
|
+
* @returns {import('../types/codemod').AstryxConfigCodemod}
|
|
87
87
|
*/
|
|
88
88
|
export function createConfigCodemod(def) {
|
|
89
|
-
return /** @type {import('
|
|
89
|
+
return /** @type {import('../types/codemod').AstryxConfigCodemod} */ ({
|
|
90
90
|
...def,
|
|
91
91
|
type: 'config',
|
|
92
92
|
});
|
|
@@ -6,7 +6,7 @@ import {createIntegration} from './integration.mjs';
|
|
|
6
6
|
import {
|
|
7
7
|
AstryxConfigSchema,
|
|
8
8
|
AstryxIntegrationSchema,
|
|
9
|
-
} from '
|
|
9
|
+
} from '../lib/config-schema.mjs';
|
|
10
10
|
|
|
11
11
|
// createConfig/createIntegration are now pure typed-identity helpers: they
|
|
12
12
|
// return their argument unchanged and perform NO runtime validation. Validation
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
FunctionDocKindSchema,
|
|
13
13
|
GenericDocKindSchema,
|
|
14
14
|
} from './doc.mjs';
|
|
15
|
-
import {loadComponentDoc} from '
|
|
15
|
+
import {loadComponentDoc} from '../lib/component-loader.mjs';
|
|
16
16
|
|
|
17
17
|
// The factories are stamp-only (like createConfig / createBlockTemplate): they
|
|
18
18
|
// inject a `type` discriminant and are otherwise identity, performing NO
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export {createPageTemplate, createBlockTemplate} from '@astryxdesign/core/authoring';
|
|
15
|
-
export {BaseTemplateSchema, TemplateEnvelopeSchema} from '
|
|
15
|
+
export {BaseTemplateSchema, TemplateEnvelopeSchema} from '../schemas/template-schema.mjs';
|
package/bin/astryx.mjs
CHANGED
|
@@ -13,21 +13,22 @@
|
|
|
13
13
|
// `node-version.mjs` is intentionally dependency-free so it loads on the
|
|
14
14
|
// unsupported runtimes this guard protects against.
|
|
15
15
|
//
|
|
16
|
-
// Sibling `
|
|
17
|
-
// installed as a package, `npx astryx` runs this file
|
|
18
|
-
// `node_modules/.bin/astryx` symlink, and some Node versions resolve
|
|
19
|
-
// specifiers from the symlink's directory
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
16
|
+
// Sibling package modules (e.g. `cli/`, `lib/`) are resolved by this bin's REAL
|
|
17
|
+
// path. When the CLI is installed as a package, `npx astryx` runs this file
|
|
18
|
+
// through the `node_modules/.bin/astryx` symlink, and some Node versions resolve
|
|
19
|
+
// relative specifiers from the symlink's directory rather than the real package
|
|
20
|
+
// — breaking bare `../…` imports with a cryptic ERR_MODULE_NOT_FOUND.
|
|
21
|
+
// realpath-ing `import.meta.url` makes these imports resolve correctly however
|
|
22
|
+
// the bin is invoked (symlink, copy, or Windows shim). Uses only built-ins, so
|
|
23
|
+
// the version gate below still runs first.
|
|
24
24
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
25
25
|
import {realpathSync} from 'node:fs';
|
|
26
26
|
import {dirname, join} from 'node:path';
|
|
27
27
|
|
|
28
28
|
const binDir = dirname(realpathSync(fileURLToPath(import.meta.url)));
|
|
29
|
+
/** @param {string} rel */
|
|
29
30
|
const importSrc = rel =>
|
|
30
|
-
import(pathToFileURL(join(binDir, '..',
|
|
31
|
+
import(pathToFileURL(join(binDir, '..', rel)).href);
|
|
31
32
|
|
|
32
33
|
const {isNodeVersionSupported, unsupportedNodeMessage} =
|
|
33
34
|
await importSrc('lib/node-version.mjs');
|
|
@@ -54,7 +55,7 @@ if (!isNodeVersionSupported(process.versions.node)) {
|
|
|
54
55
|
|
|
55
56
|
// Imports that transitively load `styleText` must happen AFTER the gate above,
|
|
56
57
|
// so they are dynamically imported here rather than at the top of the module.
|
|
57
|
-
const {program} = await importSrc('index.mjs');
|
|
58
|
+
const {program} = await importSrc('cli/index.mjs');
|
|
58
59
|
const {isJsonMode, toErrorEnvelope} = await importSrc('lib/json.mjs');
|
|
59
60
|
const {handleCommanderError} = await importSrc('lib/json-shim.mjs');
|
|
60
61
|
|
|
@@ -72,6 +73,7 @@ function inJsonMode() {
|
|
|
72
73
|
return isJsonMode() || process.argv.slice(2).includes('--json');
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
/** @param {unknown} err */
|
|
75
77
|
function handleFatal(err) {
|
|
76
78
|
// CommanderError (parse errors, --help, unknown command) routes
|
|
77
79
|
// through the JSON shim so that a --json consumer always gets a
|
|
@@ -13,11 +13,44 @@
|
|
|
13
13
|
* astryx blog <slug> Print a post as plaintext
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {getRunPrefix} from '
|
|
17
|
-
import {humanLog} from '
|
|
18
|
-
import {cliError} from '
|
|
19
|
-
import {blog as blogApi} from '
|
|
16
|
+
import {getRunPrefix} from '../../utils/package-manager.mjs';
|
|
17
|
+
import {humanLog} from '../../lib/json.mjs';
|
|
18
|
+
import {cliError} from '../../lib/cli-error.mjs';
|
|
19
|
+
import {blog as blogApi} from '../../api/blog/blog.mjs';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} BlogPost
|
|
23
|
+
* @property {string} slug
|
|
24
|
+
* @property {string} title
|
|
25
|
+
* @property {string} [description]
|
|
26
|
+
* @property {string} [date]
|
|
27
|
+
* @property {string} [type]
|
|
28
|
+
* @property {string[]} [authors]
|
|
29
|
+
* @property {string} [link]
|
|
30
|
+
* @property {string | null} [textUrl]
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {object} BlogListData
|
|
35
|
+
* @property {string} feedUrl
|
|
36
|
+
* @property {BlogPost[]} posts
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {BlogPost & {feedUrl: string, text: string}} BlogDetailData
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {(
|
|
45
|
+
* | {type: 'blog.list', data: BlogListData}
|
|
46
|
+
* | {type: 'blog.detail', data: BlogDetailData}
|
|
47
|
+
* )} BlogResult
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {BlogListData} data
|
|
52
|
+
* @param {string} run
|
|
53
|
+
*/
|
|
21
54
|
function formatList({feedUrl, posts}, run) {
|
|
22
55
|
const lines = [`\nAstryx blog · feed: ${feedUrl}\n`];
|
|
23
56
|
if (posts.length === 0) {
|
|
@@ -35,17 +68,25 @@ function formatList({feedUrl, posts}, run) {
|
|
|
35
68
|
return lines.join('\n');
|
|
36
69
|
}
|
|
37
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @param {import('commander').Command} program
|
|
73
|
+
*/
|
|
38
74
|
export function registerBlog(program) {
|
|
39
75
|
program
|
|
40
76
|
.command('blog [slug]', {hidden: true})
|
|
41
77
|
.description('Read the Astryx blog from the published feed')
|
|
42
|
-
.action(async slug => {
|
|
78
|
+
.action(async (/** @type {string | undefined} */ slug) => {
|
|
43
79
|
const run = getRunPrefix();
|
|
80
|
+
/** @type {BlogResult} */
|
|
44
81
|
let result;
|
|
45
82
|
try {
|
|
46
|
-
result = await blogApi(slug);
|
|
83
|
+
result = /** @type {BlogResult} */ (await blogApi(slug));
|
|
47
84
|
} catch (e) {
|
|
48
|
-
|
|
85
|
+
const err = /** @type {import('../../api/error.mjs').AstryxError} */ (e);
|
|
86
|
+
cliError(err.message, {
|
|
87
|
+
suggestions: err.suggestions || [],
|
|
88
|
+
code: err.code,
|
|
89
|
+
});
|
|
49
90
|
return;
|
|
50
91
|
}
|
|
51
92
|
|