@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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Layout command JSON responses.
|
|
5
|
+
*
|
|
6
|
+
* `astryx layout expand|check|grammar` turn compressed XLE/XLO expressions into
|
|
7
|
+
* validated XDS TSX (or echo canonical surfaces / a grammar cheatsheet).
|
|
8
|
+
*
|
|
9
|
+
* Invocation -> type discriminator
|
|
10
|
+
* -----------------------------------------------------------------
|
|
11
|
+
* astryx --json layout expand "<expr>" -> layout.expand
|
|
12
|
+
* astryx --json layout check "<expr>" -> layout.check
|
|
13
|
+
* astryx --json layout grammar -> layout.grammar
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** The input surface an expression was parsed as. */
|
|
17
|
+
export type LayoutForm = 'compact' | 'outline' | 'auto';
|
|
18
|
+
|
|
19
|
+
/** A validation issue with its formatted, human-readable rendering. */
|
|
20
|
+
export interface LayoutIssue {
|
|
21
|
+
line?: number;
|
|
22
|
+
col?: number;
|
|
23
|
+
message: string;
|
|
24
|
+
formatted: string;
|
|
25
|
+
suggestions?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A block referenced by a layout expression and how it was spliced in. */
|
|
29
|
+
export interface LayoutBlockReference {
|
|
30
|
+
name: string;
|
|
31
|
+
mode: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** astryx --json layout expand "<expr>" [path] */
|
|
35
|
+
export interface LayoutExpandResponse {
|
|
36
|
+
type: 'layout.expand';
|
|
37
|
+
data: {
|
|
38
|
+
form: LayoutForm;
|
|
39
|
+
code: string;
|
|
40
|
+
componentsUsed: string[];
|
|
41
|
+
/** Number of useState hooks the expansion scaffolded. */
|
|
42
|
+
states: number;
|
|
43
|
+
todos: string[];
|
|
44
|
+
blocksReferenced: LayoutBlockReference[];
|
|
45
|
+
warnings: string[];
|
|
46
|
+
written: string | null;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** astryx --json layout check "<expr>" */
|
|
51
|
+
export interface LayoutCheckResponse {
|
|
52
|
+
type: 'layout.check';
|
|
53
|
+
data: {
|
|
54
|
+
valid: boolean;
|
|
55
|
+
form: LayoutForm;
|
|
56
|
+
errors: LayoutIssue[];
|
|
57
|
+
warnings: string[];
|
|
58
|
+
compact: string;
|
|
59
|
+
outline: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** astryx --json layout grammar */
|
|
64
|
+
export interface LayoutGrammarResponse {
|
|
65
|
+
type: 'layout.grammar';
|
|
66
|
+
data: {
|
|
67
|
+
text: string;
|
|
68
|
+
/** Alias table (short name -> canonical component), from the registry. */
|
|
69
|
+
aliases: Record<string, string>;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type LayoutResponse =
|
|
74
|
+
LayoutExpandResponse | LayoutCheckResponse | LayoutGrammarResponse;
|
package/types/theme.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Theme build command JSON responses.
|
|
5
|
+
*
|
|
6
|
+
* Invocation -> type discriminator
|
|
7
|
+
* ------------------------------------------------------------------
|
|
8
|
+
* xds --json theme build <file> -> theme.build
|
|
9
|
+
* xds --json theme list -> theme.list
|
|
10
|
+
* xds --json theme add <slug> -> theme.add
|
|
11
|
+
* (file not found / parse error) -> CLIError
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** xds --json theme build <file> */
|
|
15
|
+
export interface ThemeBuildResponse {
|
|
16
|
+
type: 'theme.build';
|
|
17
|
+
data: {
|
|
18
|
+
name: string;
|
|
19
|
+
tokenCount: number;
|
|
20
|
+
componentCount: number;
|
|
21
|
+
sizeKB: number;
|
|
22
|
+
outputs: {css: string; js: string; dts: string; variantsDts?: string};
|
|
23
|
+
warnings: string[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A single theme entry as surfaced by `theme list`. */
|
|
28
|
+
export interface ThemeListEntry {
|
|
29
|
+
slug: string;
|
|
30
|
+
displayName: string;
|
|
31
|
+
description: string;
|
|
32
|
+
maintained: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** xds --json theme list */
|
|
36
|
+
export interface ThemeListResponse {
|
|
37
|
+
type: 'theme.list';
|
|
38
|
+
data: ThemeListEntry[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** xds --json theme add <slug> */
|
|
42
|
+
export interface ThemeAddResponse {
|
|
43
|
+
type: 'theme.add';
|
|
44
|
+
data: {
|
|
45
|
+
slug: string;
|
|
46
|
+
displayName: string;
|
|
47
|
+
maintained: boolean;
|
|
48
|
+
outputDir: string;
|
|
49
|
+
entry: string;
|
|
50
|
+
exportName: string;
|
|
51
|
+
files: string[];
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -55,9 +55,16 @@ export interface UpgradeRunResponse {
|
|
|
55
55
|
from: string;
|
|
56
56
|
to: string;
|
|
57
57
|
codemods: number;
|
|
58
|
-
|
|
58
|
+
/** Integration packages processed in this upgrade (by name/spec). */
|
|
59
|
+
integrations: string[];
|
|
59
60
|
agentDocsRefreshed: boolean;
|
|
60
61
|
agentDocs: AgentDocsSummary;
|
|
62
|
+
/** Total files changed across core + integration codemods (apply mode). */
|
|
63
|
+
filesChanged?: number;
|
|
64
|
+
/** Total transforms that reported a change. */
|
|
65
|
+
transformsApplied?: number;
|
|
66
|
+
/** Per-codemod errors, when any codemod failed. */
|
|
67
|
+
errors?: Array<{file: string; codemod: string; error: string}>;
|
|
61
68
|
};
|
|
62
69
|
}
|
|
63
70
|
|
|
@@ -13,7 +13,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
13
13
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
|
|
15
15
|
/** Root of the @astryxdesign/cli package */
|
|
16
|
-
export const CLI_ROOT = path.resolve(__dirname, '..'
|
|
16
|
+
export const CLI_ROOT = path.resolve(__dirname, '..');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Find packages/core directory by walking up from startDir.
|
|
@@ -78,6 +78,7 @@ export function findProjectRoot(startDir = process.cwd()) {
|
|
|
78
78
|
* Returns array of { name, category, docsDir, blocksDir }.
|
|
79
79
|
*/
|
|
80
80
|
export function discoverExternalPackages(startDir = process.cwd()) {
|
|
81
|
+
/** @type {Array<{name: string, category: string, docsDir: string, blocksDir: string | null}>} */
|
|
81
82
|
const externals = [];
|
|
82
83
|
let dir = startDir;
|
|
83
84
|
|
|
@@ -96,6 +97,7 @@ export function discoverExternalPackages(startDir = process.cwd()) {
|
|
|
96
97
|
|
|
97
98
|
if (!nodeModulesDir) return externals;
|
|
98
99
|
|
|
100
|
+
/** @param {string} searchDir */
|
|
99
101
|
const scanDir = (searchDir) => {
|
|
100
102
|
if (!fs.existsSync(searchDir)) return;
|
|
101
103
|
const entries = fs.readdirSync(searchDir, {withFileTypes: true});
|
|
@@ -141,6 +143,7 @@ export function discoverExternalPackages(startDir = process.cwd()) {
|
|
|
141
143
|
/**
|
|
142
144
|
* List available component directories in packages/core/src.
|
|
143
145
|
* Returns directory names that contain Astryx*.tsx files.
|
|
146
|
+
* @param {string} coreDir
|
|
144
147
|
*/
|
|
145
148
|
export function listComponents(coreDir) {
|
|
146
149
|
const srcDir = path.join(coreDir, 'src');
|
package/src/commands/swizzle.mjs
DELETED
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file swizzle command — Copy component source for customization
|
|
5
|
-
*
|
|
6
|
-
* Resolves a component's owning package (core or a configured integration),
|
|
7
|
-
* copies its non-test/non-doc source files to the output directory, and
|
|
8
|
-
* rewrites escaping relative imports to use the OWNER package's subpaths.
|
|
9
|
-
*
|
|
10
|
-
* After swizzling, prints a short maintainer feedback note pointing users at
|
|
11
|
-
* the owner's issue tracker so they can let the team know what gap led them to
|
|
12
|
-
* customize the component. The core feedback URL is routed through app config
|
|
13
|
-
* (`config.issuesUrl`); integration components use their manifest `issuesUrl`.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import * as fs from 'node:fs';
|
|
17
|
-
import * as path from 'node:path';
|
|
18
|
-
import {findCoreDir, listComponents} from '../utils/paths.mjs';
|
|
19
|
-
import {
|
|
20
|
-
assertWithin,
|
|
21
|
-
PathSafetyError,
|
|
22
|
-
} from '../utils/path-safety.mjs';
|
|
23
|
-
import {jsonOut, humanLog} from '../lib/json.mjs';
|
|
24
|
-
import {cliError} from '../lib/cli-error.mjs';
|
|
25
|
-
import {ERROR_CODES} from '../lib/error-codes.mjs';
|
|
26
|
-
import {checkGhCli} from '../utils/github.mjs';
|
|
27
|
-
import {getCliInvocation} from '../utils/package-manager.mjs';
|
|
28
|
-
import {Project} from '../lib/project.mjs';
|
|
29
|
-
import {
|
|
30
|
-
CORE_PACKAGE,
|
|
31
|
-
findIntegrationComponentDoc,
|
|
32
|
-
findIntegrationComponentSource,
|
|
33
|
-
} from '../lib/component-discovery.mjs';
|
|
34
|
-
|
|
35
|
-
/** Default issue tracker for maintainer feedback after swizzling. */
|
|
36
|
-
const DEFAULT_ISSUES_URL = 'https://github.com/facebook/astryx/issues/new';
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Rewrite relative imports that point outside the component directory to use
|
|
40
|
-
* the OWNER package's subpaths. Imports within the copied directory (./x) are
|
|
41
|
-
* left untouched.
|
|
42
|
-
*
|
|
43
|
-
* e.g. with ownerPackage '@astryxdesign/core':
|
|
44
|
-
* '../theme/tokens.stylex' -> '@astryxdesign/core/theme'
|
|
45
|
-
* '../utils/mergeProps' -> '@astryxdesign/core/utils'
|
|
46
|
-
*
|
|
47
|
-
* `ownerPackage` defaults to '@astryxdesign/core' so existing core behavior is
|
|
48
|
-
* unchanged; integration components pass their own owning package.
|
|
49
|
-
*
|
|
50
|
-
* @param {string} content
|
|
51
|
-
* @param {string} [ownerPackage]
|
|
52
|
-
*/
|
|
53
|
-
export function rewriteImports(content, ownerPackage = CORE_PACKAGE) {
|
|
54
|
-
// Match import/export from statements with relative paths going up
|
|
55
|
-
return content.replace(
|
|
56
|
-
/(from\s+['"])(\.\.\/.+?)(['"])/g,
|
|
57
|
-
(match, prefix, importPath, suffix) => {
|
|
58
|
-
// Extract the top-level directory from the relative path
|
|
59
|
-
// e.g. '../theme/tokens.stylex' -> 'theme'
|
|
60
|
-
// e.g. '../utils/mergeProps' -> 'utils'
|
|
61
|
-
const parts = importPath.replace(/^\.\.\//, '').split('/');
|
|
62
|
-
const topDir = parts[0];
|
|
63
|
-
|
|
64
|
-
// Map to the owner package subpath
|
|
65
|
-
return `${prefix}${ownerPackage}/${topDir}${suffix}`;
|
|
66
|
-
},
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Build the maintainer feedback note for a swizzled component.
|
|
72
|
-
*
|
|
73
|
-
* Returns { issuesUrl, ghCommand? } or null when no issues URL is available
|
|
74
|
-
* (an integration that ships no `issuesUrl`). When the issues URL is a GitHub
|
|
75
|
-
* issues URL and the `gh` CLI is available, a ready-to-run `gh issue create`
|
|
76
|
-
* command is included so the user can file feedback without leaving the
|
|
77
|
-
* terminal.
|
|
78
|
-
*
|
|
79
|
-
* @param {string} component bare component name (used in the issue title)
|
|
80
|
-
* @param {string|undefined} issuesUrl owner's issue tracker URL
|
|
81
|
-
* @returns {{issuesUrl: string, ghCommand?: string} | null}
|
|
82
|
-
*/
|
|
83
|
-
function buildFeedback(component, issuesUrl) {
|
|
84
|
-
if (!issuesUrl) return null;
|
|
85
|
-
|
|
86
|
-
const feedback = {issuesUrl};
|
|
87
|
-
|
|
88
|
-
// Accept any github.com/<owner>/<repo>/issues(/new)? form.
|
|
89
|
-
const match = issuesUrl.match(
|
|
90
|
-
/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/issues(?:\/new)?\/?$/,
|
|
91
|
-
);
|
|
92
|
-
if (match && checkGhCli()) {
|
|
93
|
-
const [, owner, repo] = match;
|
|
94
|
-
feedback.ghCommand = `gh issue create --repo ${owner}/${repo} --title "[${component}] Swizzle feedback"`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return feedback;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Load the configured integrations + core issues URL for `cwd`, swallowing any
|
|
102
|
-
* config errors so swizzle never hard-fails on a malformed/absent config. An
|
|
103
|
-
* empty list means "core only". The core issues URL is routed through the
|
|
104
|
-
* Project (config.issuesUrl, falling back to the default core tracker).
|
|
105
|
-
* @param {string} cwd
|
|
106
|
-
* @returns {Promise<{loadedIntegrations: Array<object>, issuesUrl: string|undefined, project: Project|null}>}
|
|
107
|
-
*/
|
|
108
|
-
async function loadConfigSafely(cwd) {
|
|
109
|
-
try {
|
|
110
|
-
const project = await Project.load(cwd);
|
|
111
|
-
return {
|
|
112
|
-
loadedIntegrations: project.loadedIntegrations,
|
|
113
|
-
issuesUrl: project.config.issuesUrl,
|
|
114
|
-
project,
|
|
115
|
-
};
|
|
116
|
-
} catch {
|
|
117
|
-
return {loadedIntegrations: [], issuesUrl: undefined, project: null};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Build the set of OWNER packages that provide a component with `name` across
|
|
123
|
-
* core + every loaded integration.
|
|
124
|
-
*
|
|
125
|
-
* Core ownership is determined by the source directory existing on disk
|
|
126
|
-
* (`coreDir/src/<name>`) so plain core components without a `.doc.mjs` still
|
|
127
|
-
* resolve as today. Integration ownership is determined by a same-stem doc file
|
|
128
|
-
* (`<name>.doc.{ts,mjs,js}`) via findIntegrationComponentDoc.
|
|
129
|
-
*
|
|
130
|
-
* @param {string} coreDir
|
|
131
|
-
* @param {Array<{name: string, components?: string, issuesUrl?: string}>} loadedIntegrations
|
|
132
|
-
* @param {string} name bare component name (no XDS/Astryx prefix)
|
|
133
|
-
* @param {string|undefined} coreIssuesUrl
|
|
134
|
-
* @returns {Array<{package: string, sourceDir: string|null, ownerPackage: string, issuesUrl: string|undefined}>}
|
|
135
|
-
*/
|
|
136
|
-
function resolveOwners(coreDir, loadedIntegrations, name, coreIssuesUrl) {
|
|
137
|
-
const owners = [];
|
|
138
|
-
|
|
139
|
-
const coreComponentDir = path.join(coreDir, 'src', name);
|
|
140
|
-
if (fs.existsSync(coreComponentDir)) {
|
|
141
|
-
owners.push({
|
|
142
|
-
package: CORE_PACKAGE,
|
|
143
|
-
sourceDir: coreComponentDir,
|
|
144
|
-
ownerPackage: CORE_PACKAGE,
|
|
145
|
-
issuesUrl: coreIssuesUrl || DEFAULT_ISSUES_URL,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
for (const integration of loadedIntegrations) {
|
|
150
|
-
const docPath = findIntegrationComponentDoc(integration, name);
|
|
151
|
-
if (!docPath) continue;
|
|
152
|
-
const sourcePath = findIntegrationComponentSource(integration, name);
|
|
153
|
-
owners.push({
|
|
154
|
-
package: integration.name,
|
|
155
|
-
// The component's own folder — the directory containing its source.
|
|
156
|
-
sourceDir: sourcePath ? path.dirname(sourcePath) : null,
|
|
157
|
-
ownerPackage: integration.name,
|
|
158
|
-
issuesUrl: integration.issuesUrl,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return owners;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** Whether a filename should be excluded from the swizzle copy. */
|
|
166
|
-
function isExcludedFromCopy(file) {
|
|
167
|
-
return (
|
|
168
|
-
file.includes('.test.') || file.includes('.doc.') || file === 'README.md'
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export function registerSwizzle(program) {
|
|
173
|
-
program
|
|
174
|
-
.command('swizzle [component]')
|
|
175
|
-
.description('Copy component source for customization')
|
|
176
|
-
.option('--output <dir>', 'Output directory', './components/astryx')
|
|
177
|
-
.option('--package <pkg>', 'Scope to a specific owning package')
|
|
178
|
-
.option('--list', 'List available components')
|
|
179
|
-
.option('-f, --overwrite', 'Overwrite existing files without prompting')
|
|
180
|
-
.action(async (component, options) => {
|
|
181
|
-
const coreDir = findCoreDir(process.cwd());
|
|
182
|
-
const json = program.opts().json || false;
|
|
183
|
-
const run = getCliInvocation();
|
|
184
|
-
|
|
185
|
-
if (!coreDir) {
|
|
186
|
-
cliError(
|
|
187
|
-
'Could not find @astryxdesign/core package. Make sure you are inside the design system monorepo or have @astryxdesign/core installed.',
|
|
188
|
-
{code: ERROR_CODES.ERR_CORE_NOT_FOUND},
|
|
189
|
-
);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const components = listComponents(coreDir);
|
|
194
|
-
|
|
195
|
-
if (options.list || !component) {
|
|
196
|
-
if (json) return jsonOut('swizzle.list', components);
|
|
197
|
-
humanLog('\nAvailable components:\n');
|
|
198
|
-
for (const name of components) {
|
|
199
|
-
humanLog(` ${name}`);
|
|
200
|
-
}
|
|
201
|
-
humanLog(`\nUsage: ${run} swizzle <component>\n`);
|
|
202
|
-
humanLog(`Example: ${run} swizzle Button`);
|
|
203
|
-
humanLog(
|
|
204
|
-
` ${run} swizzle XDSButton (XDS prefix also works)\n`,
|
|
205
|
-
);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const dirName = component.replace(/^XDS/, '');
|
|
210
|
-
|
|
211
|
-
// Resolve the component's owning package(s) across core + integrations.
|
|
212
|
-
const {loadedIntegrations, project} = await loadConfigSafely(
|
|
213
|
-
process.cwd(),
|
|
214
|
-
);
|
|
215
|
-
// Core feedback URL is routed through the Project (config.issuesUrl,
|
|
216
|
-
// falling back to the default core tracker). When config load failed,
|
|
217
|
-
// resolveOwners applies the same default fallback.
|
|
218
|
-
const coreIssuesUrl = project
|
|
219
|
-
? project.issuesUrl({package: CORE_PACKAGE})
|
|
220
|
-
: undefined;
|
|
221
|
-
const allOwners = resolveOwners(
|
|
222
|
-
coreDir,
|
|
223
|
-
loadedIntegrations,
|
|
224
|
-
dirName,
|
|
225
|
-
coreIssuesUrl,
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
if (allOwners.length === 0) {
|
|
229
|
-
cliError(`Component "${component}" not found.`, {
|
|
230
|
-
suggestions: components.slice(0, 10).map(n => ({name: n})),
|
|
231
|
-
code: ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
232
|
-
});
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
let owner;
|
|
237
|
-
if (options.package) {
|
|
238
|
-
owner = allOwners.find(o => o.package === options.package);
|
|
239
|
-
if (!owner) {
|
|
240
|
-
cliError(
|
|
241
|
-
`Component "${dirName}" is not provided by package "${options.package}".`,
|
|
242
|
-
{
|
|
243
|
-
suggestions: allOwners.map(o => ({
|
|
244
|
-
name: o.package,
|
|
245
|
-
reason: 'provides this component',
|
|
246
|
-
})),
|
|
247
|
-
code: ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
248
|
-
},
|
|
249
|
-
);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
} else if (allOwners.length > 1) {
|
|
253
|
-
cliError(
|
|
254
|
-
`Component "${dirName}" is provided by multiple packages. Re-run with --package <pkg> to choose one.`,
|
|
255
|
-
{
|
|
256
|
-
suggestions: allOwners.map(o => ({
|
|
257
|
-
name: o.package,
|
|
258
|
-
reason: 'provides this component',
|
|
259
|
-
})),
|
|
260
|
-
code: ERROR_CODES.ERR_AMBIGUOUS_COMPONENT,
|
|
261
|
-
},
|
|
262
|
-
);
|
|
263
|
-
return;
|
|
264
|
-
} else {
|
|
265
|
-
owner = allOwners[0];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (!owner.sourceDir || !fs.existsSync(owner.sourceDir)) {
|
|
269
|
-
cliError(
|
|
270
|
-
`No source found for "${dirName}" in package "${owner.package}".`,
|
|
271
|
-
{code: ERROR_CODES.ERR_NO_SOURCE},
|
|
272
|
-
);
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const componentDir = owner.sourceDir;
|
|
277
|
-
|
|
278
|
-
// Path-safety: --output must resolve inside cwd. Reject absolute
|
|
279
|
-
// paths and `..` traversal up front, before any directory is created.
|
|
280
|
-
let outputBase;
|
|
281
|
-
try {
|
|
282
|
-
outputBase = assertWithin(options.output, process.cwd(), {
|
|
283
|
-
label: 'output directory',
|
|
284
|
-
});
|
|
285
|
-
} catch (err) {
|
|
286
|
-
if (err instanceof PathSafetyError) {
|
|
287
|
-
cliError(err.message, {code: ERROR_CODES.ERR_PATH_TRAVERSAL});
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
throw err;
|
|
291
|
-
}
|
|
292
|
-
const outputDir = path.join(outputBase, dirName);
|
|
293
|
-
|
|
294
|
-
// Pre-flight overwrite check: collect files we'd write and detect
|
|
295
|
-
// collisions before mkdir/writeFile so we never half-clobber.
|
|
296
|
-
const sourceFiles = fs.readdirSync(componentDir).filter(file => {
|
|
297
|
-
if (isExcludedFromCopy(file)) return false;
|
|
298
|
-
const stat = fs.statSync(path.join(componentDir, file));
|
|
299
|
-
return stat.isFile();
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
const existingFiles = sourceFiles.filter(f =>
|
|
303
|
-
fs.existsSync(path.join(outputDir, f)),
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
if (existingFiles.length > 0 && !options.overwrite) {
|
|
307
|
-
const relOutputForMsg = path.relative(process.cwd(), outputDir) || '.';
|
|
308
|
-
const msg =
|
|
309
|
-
`Refusing to overwrite ${existingFiles.length} existing file(s) in ${relOutputForMsg}/. ` +
|
|
310
|
-
`Re-run with --overwrite (or -f) to replace them.`;
|
|
311
|
-
cliError(msg, {code: ERROR_CODES.ERR_FILE_EXISTS});
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
fs.mkdirSync(outputDir, {recursive: true});
|
|
316
|
-
|
|
317
|
-
// Copy all non-test, non-doc, non-README files
|
|
318
|
-
const files = fs.readdirSync(componentDir);
|
|
319
|
-
let copied = 0;
|
|
320
|
-
// Track whether any copied source uses StyleX. Swizzled StyleX source
|
|
321
|
-
// needs a build-time StyleX compiler in the consumer's app or it renders
|
|
322
|
-
// unstyled with no error — so we surface a setup note after copying.
|
|
323
|
-
let usesStyleX = false;
|
|
324
|
-
|
|
325
|
-
for (const file of files) {
|
|
326
|
-
// Skip test files, doc files, and README
|
|
327
|
-
if (isExcludedFromCopy(file)) continue;
|
|
328
|
-
|
|
329
|
-
const srcPath = path.join(componentDir, file);
|
|
330
|
-
const stat = fs.statSync(srcPath);
|
|
331
|
-
if (!stat.isFile()) continue;
|
|
332
|
-
|
|
333
|
-
let content = fs.readFileSync(srcPath, 'utf-8');
|
|
334
|
-
|
|
335
|
-
// Rewrite escaping imports for .ts/.tsx files to the owner package.
|
|
336
|
-
if (file.endsWith('.ts') || file.endsWith('.tsx')) {
|
|
337
|
-
content = rewriteImports(content, owner.ownerPackage);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (
|
|
341
|
-
(file.endsWith('.ts') || file.endsWith('.tsx')) &&
|
|
342
|
-
content.includes('@stylexjs/stylex')
|
|
343
|
-
) {
|
|
344
|
-
usesStyleX = true;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
fs.writeFileSync(path.join(outputDir, file), content);
|
|
348
|
-
copied++;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const relOutput = path.relative(process.cwd(), outputDir);
|
|
352
|
-
const copiedFiles = files.filter(
|
|
353
|
-
f =>
|
|
354
|
-
!isExcludedFromCopy(f) &&
|
|
355
|
-
fs.statSync(path.join(componentDir, f)).isFile(),
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
const feedback = buildFeedback(dirName, owner.issuesUrl);
|
|
359
|
-
|
|
360
|
-
if (json) {
|
|
361
|
-
/** @type {import('../types/swizzle').SwizzleCopyResponse['data']} */
|
|
362
|
-
const payload = {
|
|
363
|
-
component: dirName,
|
|
364
|
-
package: owner.package,
|
|
365
|
-
outputDir: relOutput,
|
|
366
|
-
filesCopied: copied,
|
|
367
|
-
files: copiedFiles.map(f => f),
|
|
368
|
-
usesStyleX,
|
|
369
|
-
};
|
|
370
|
-
if (feedback) payload.feedback = feedback;
|
|
371
|
-
return jsonOut('swizzle.copy', payload);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
humanLog(`\n✓ Copied ${copied} files to ${relOutput}/\n`);
|
|
375
|
-
humanLog(
|
|
376
|
-
`Relative imports have been rewritten to use ${owner.ownerPackage}.`,
|
|
377
|
-
);
|
|
378
|
-
humanLog('You can now customize the component source freely.\n');
|
|
379
|
-
|
|
380
|
-
// StyleX build requirement. Swizzled components ship raw StyleX source,
|
|
381
|
-
// which needs a build-time StyleX compiler in the consumer's app to
|
|
382
|
-
// produce atomic CSS. Without it the component compiles but renders
|
|
383
|
-
// unstyled, with no error — a confusing silent failure, so call it out.
|
|
384
|
-
if (usesStyleX) {
|
|
385
|
-
humanLog(
|
|
386
|
-
'⚠ These components use StyleX and require a StyleX compiler in your build.',
|
|
387
|
-
);
|
|
388
|
-
humanLog(
|
|
389
|
-
' Without one they render unstyled (no error). See setup per framework:',
|
|
390
|
-
);
|
|
391
|
-
humanLog(` ${run} docs styling`);
|
|
392
|
-
humanLog(
|
|
393
|
-
' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font —',
|
|
394
|
-
);
|
|
395
|
-
humanLog(
|
|
396
|
-
' use an SWC-based StyleX transform instead (covered in the guide).',
|
|
397
|
-
);
|
|
398
|
-
humanLog('');
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// Maintainer feedback note. If we couldn't swizzle cleanly, the team
|
|
402
|
-
// wants to know — point users at the issue tracker. Skipped when the
|
|
403
|
-
// owning package ships no issues URL.
|
|
404
|
-
if (feedback) {
|
|
405
|
-
humanLog(
|
|
406
|
-
'Customizing a component often signals a gap in the design system.',
|
|
407
|
-
);
|
|
408
|
-
humanLog('Let the maintainers know what you needed:');
|
|
409
|
-
if (feedback.ghCommand) {
|
|
410
|
-
humanLog(` ${feedback.ghCommand}`);
|
|
411
|
-
} else {
|
|
412
|
-
humanLog(` ${feedback.issuesUrl}`);
|
|
413
|
-
}
|
|
414
|
-
humanLog('');
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
package/src/types/build.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Build command JSON responses.
|
|
5
|
-
*
|
|
6
|
-
* `astryx build` is the "assemble a page" verb. With no query it emits the
|
|
7
|
-
* workflow playbook; with a query it delegates to the search pipeline and
|
|
8
|
-
* emits a `search` response (see search.d.ts).
|
|
9
|
-
*
|
|
10
|
-
* Invocation -> type discriminator
|
|
11
|
-
* ---------------------------------------------------
|
|
12
|
-
* xds --json build -> build.help
|
|
13
|
-
* xds --json build "<idea>" -> search
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** xds --json build (no query) — the "how to build a page" playbook signal. */
|
|
17
|
-
export interface BuildHelpResponse {
|
|
18
|
-
type: 'build.help';
|
|
19
|
-
data: {
|
|
20
|
-
/** Always true; marks this envelope as the playbook rather than a result set. */
|
|
21
|
-
playbook: true;
|
|
22
|
-
};
|
|
23
|
-
}
|