@astryxdesign/cli 0.7.6-canary.f73623d → 0.7.6-canary.f77aaf2
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/assets/docs/motion.doc.mjs +1 -1
- package/package.json +24 -10
- package/api/api-docs-parse.test.mjs +0 -47
- package/api/blog/_adapter.test.mjs +0 -183
- package/api/blog/blog.test.mjs +0 -144
- package/api/blog/detail/detail.test.mjs +0 -118
- package/api/blog/list/list.test.mjs +0 -81
- package/api/build/blocks/blocks.test.mjs +0 -238
- package/api/build/build.test.mjs +0 -569
- package/api/build/kit/answer.test.mjs +0 -108
- package/api/build/kit/rank.test.mjs +0 -380
- package/api/build/kit/weights.test.mjs +0 -286
- package/api/build/tree.test.mjs +0 -185
- package/api/component/component-replacement.test.mjs +0 -616
- package/api/component/component.test.mjs +0 -532
- package/api/component/doc-links.test.mjs +0 -419
- package/api/component/integration-export-name.test.mjs +0 -644
- package/api/component/integration-import-agreement.test.mjs +0 -474
- package/api/discover/_adapter.test.mjs +0 -839
- package/api/discover/_catalog-view.test.mjs +0 -129
- package/api/discover/_package-scanner.test.mjs +0 -117
- package/api/discover/detail/detail.test.mjs +0 -145
- package/api/discover/detail/doc/doc.test.mjs +0 -93
- package/api/discover/detail/item/item.test.mjs +0 -75
- package/api/discover/discover.test.mjs +0 -100
- package/api/discover/list/list.test.mjs +0 -107
- package/api/discover/search/search.test.mjs +0 -319
- package/api/docs/compiled-topics.test.mjs +0 -94
- package/api/docs/detail/section/section.test.mjs +0 -92
- package/api/docs/docOverlays.test.mjs +0 -189
- package/api/docs/docs-homes.test.mjs +0 -127
- package/api/docs/docs.depth.test.mjs +0 -134
- package/api/docs/docs.test.mjs +0 -315
- package/api/docs/guide-route-targets.test.mjs +0 -1002
- package/api/docs/index/index.test.mjs +0 -67
- package/api/docs/integration-tree.test.mjs +0 -616
- package/api/docs/integrationDocs.test.mjs +0 -546
- package/api/docs/namespace-section.test.mjs +0 -260
- package/api/docs/react-version-sync.test.mjs +0 -79
- package/api/docs/reference-blocks.test.mjs +0 -404
- package/api/docs/token-tables.test.mjs +0 -93
- package/api/doctor/built-checks.test.mjs +0 -537
- package/api/doctor/doctor.test.mjs +0 -1651
- package/api/doctor/icon-sets.test.mjs +0 -111
- package/api/doctor/release-checks.test.mjs +0 -156
- package/api/doctor/theme-checks.test.mjs +0 -884
- package/api/gap-report/gap-report.test.mjs +0 -1549
- package/api/hook/detail/detail.test.mjs +0 -53
- package/api/hook/detail/params/params.test.mjs +0 -39
- package/api/hook/hook.test.mjs +0 -75
- package/api/icon/all-or-nothing.test.mjs +0 -283
- package/api/icon/error-codes.test.mjs +0 -341
- package/api/icon/experimental-markers.test.mjs +0 -93
- package/api/icon/icon.test.mjs +0 -506
- package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
- package/api/icon/new-set/new-set.test.mjs +0 -398
- package/api/icon/option-pairs.test.mjs +0 -368
- package/api/init/init.test.mjs +0 -319
- package/api/init/remove/remove.test.mjs +0 -124
- package/api/init/user/user.test.mjs +0 -232
- package/api/integration/add-contribution.component-names.test.mjs +0 -186
- package/api/integration/add-contribution.test.mjs +0 -990
- package/api/integration/add-helpers.test.mjs +0 -161
- package/api/integration/add-theme.test.mjs +0 -676
- package/api/integration/authoring-checks.test.mjs +0 -1691
- package/api/integration/check/check.test.mjs +0 -538
- package/api/integration/doc-stability.test.mjs +0 -216
- package/api/integration/example-checks.no-npm.test.mjs +0 -140
- package/api/integration/example-checks.test.mjs +0 -776
- package/api/integration/integration-block-exports.test.mjs +0 -248
- package/api/integration/pack-check.component-replaces.test.mjs +0 -126
- package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
- package/api/integration/pack-check.test.mjs +0 -2512
- package/api/integration/public-api.test.mjs +0 -21
- package/api/integration/template-conflict-compatibility.test.mjs +0 -73
- package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
- package/api/integration/validate-integration-case-disk.test.mjs +0 -123
- package/api/integration/validate-integration-fixes.test.mjs +0 -1457
- package/api/integration/validate-integration-gaps.test.mjs +0 -2007
- package/api/integration/validate-integration.test.mjs +0 -835
- package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
- package/api/json/envelope-types.test.mjs +0 -76
- package/api/json/parse.test.mjs +0 -76
- package/api/render/render.test.mjs +0 -1155
- package/api/search/_adapter.test.mjs +0 -192
- package/api/search/_doc-searcher.test.mjs +0 -36
- package/api/search/_entries.test.mjs +0 -48
- package/api/search/_main-searcher.test.mjs +0 -106
- package/api/search/_order.test.mjs +0 -72
- package/api/search/_template-searcher.test.mjs +0 -40
- package/api/search/search-return-type.test.mjs +0 -54
- package/api/search/search.domain-priority.test.mjs +0 -351
- package/api/search/search.family-members.test.mjs +0 -124
- package/api/search/search.family-word.test.mjs +0 -146
- package/api/search/search.integration-block.test.mjs +0 -100
- package/api/search/search.integration-check.test.mjs +0 -24
- package/api/search/search.test.mjs +0 -1007
- package/api/search/search.tie-order.test.mjs +0 -39
- package/api/search/tree.test.mjs +0 -66
- package/api/swizzle/_github.test.mjs +0 -53
- package/api/swizzle/copy/copy.test.mjs +0 -60
- package/api/swizzle/swizzle.test.mjs +0 -157
- package/api/template/cdn/cdn.test.mjs +0 -108
- package/api/template/checkout-wizard.test.mjs +0 -87
- package/api/template/copy/copy.receipt.test.mjs +0 -77
- package/api/template/copy/copy.test.mjs +0 -77
- package/api/template/data-token-fallbacks.test.mjs +0 -85
- package/api/template/discover-integration-templates.test.mjs +0 -56
- package/api/template/form-wizard-dialog.test.mjs +0 -47
- package/api/template/inline-wizard-template.test.mjs +0 -24
- package/api/template/list/list.test.mjs +0 -52
- package/api/template/show/show.test.mjs +0 -76
- package/api/template/table-filter-view-tabs.test.mjs +0 -45
- package/api/template/table-floating-bulk-actions.test.mjs +0 -66
- package/api/template/template-integration.test.mjs +0 -1274
- package/api/template/template-suffix.test.mjs +0 -286
- package/api/template/template.test.mjs +0 -222
- package/api/template/tokenizer-showcase.test.mjs +0 -47
- package/api/template/unknown-name.test.mjs +0 -63
- package/api/theme/add/add.test.mjs +0 -363
- package/api/theme/add/add.types.test.mjs +0 -150
- package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
- package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
- package/api/theme/build/build.core-on-demand.test.mjs +0 -113
- package/api/theme/build/build.family.test.mjs +0 -503
- package/api/theme/build/build.font-warning.test.mjs +0 -170
- package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
- package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
- package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
- package/api/theme/build/build.icon-lineage.test.mjs +0 -117
- package/api/theme/build/build.icon-preservation.test.mjs +0 -639
- package/api/theme/build/build.icon-variants.test.mjs +0 -105
- package/api/theme/build/build.icons-specifier.test.mjs +0 -149
- package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
- package/api/theme/build/build.project-core.test.mjs +0 -220
- package/api/theme/build/build.public-component-vars.test.mjs +0 -151
- package/api/theme/build/build.receipt-doc.test.mjs +0 -111
- package/api/theme/build/build.rollback.test.mjs +0 -148
- package/api/theme/build/build.test.mjs +0 -1258
- package/api/theme/build/font-warning.test.mjs +0 -268
- package/api/theme/eject/eject.binary.test.mjs +0 -90
- package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
- package/api/theme/eject/eject.rollback.test.mjs +0 -158
- package/api/theme/eject/eject.staging.test.mjs +0 -83
- package/api/theme/eject/eject.test.mjs +0 -160
- package/api/theme/integration-themes.test.mjs +0 -218
- package/api/theme/list/list.test.mjs +0 -271
- package/api/theme/palette/generate/generate.test.mjs +0 -445
- package/api/theme/palette/generate/generator.test.mjs +0 -385
- package/api/theme/palette/generate/preview.test.mjs +0 -55
- package/api/theme/remove/remove.test.mjs +0 -94
- package/api/theme/targets/targets.test.mjs +0 -91
- package/api/theme/template/template.test.mjs +0 -102
- package/api/theme/use/use.test.mjs +0 -98
- package/api/upgrade/list/list.test.mjs +0 -73
- package/api/upgrade/project-context.test.mjs +0 -272
- package/api/upgrade/provider-agreement.test.mjs +0 -152
- package/api/upgrade/registry/registry.test.mjs +0 -911
- package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
- package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
- package/api/upgrade/run/failure-receipt.test.mjs +0 -212
- package/api/upgrade/run/files-changed.test.mjs +0 -111
- package/api/upgrade/run/outcomes.test.mjs +0 -646
- package/api/upgrade/run/run.test.mjs +0 -511
- package/api/upgrade/upgrade.test.mjs +0 -594
- package/assets/codemods/__tests__/registry.test.mjs +0 -77
- package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
- package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
- package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
- package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
- package/assets/codemods/__tests__/runner.test.mjs +0 -559
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
- package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
- package/assets/codemods/__tests__/validation.test.mjs +0 -108
- package/assets/codemods/file-count.test.mjs +0 -163
- package/assets/codemods/integration-discovery.test.mjs +0 -360
- package/assets/codemods/integration-runner.protection.test.mjs +0 -206
- package/assets/codemods/outcome.test.mjs +0 -40
- package/assets/codemods/term-log.test.mjs +0 -80
- package/assets/codemods/transform-prop.test.mjs +0 -130
- package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
- package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
- package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
- package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
- package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
- package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
- package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
- package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
- package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
- package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
- package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
- package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
- package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
- package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
- package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
- package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
- package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
- package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
- package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
- package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
- package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
- package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
- package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
- package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
- package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
- package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
- package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
- package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
- package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
- package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
- package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
- package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
- package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
- package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
- package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
- package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
- package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
- package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
- package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
- package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
- package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
- package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
- package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
- package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
- package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
- package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
- package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
- package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
- package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
- package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
- package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
- package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
- package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
- package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
- package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
- package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
- package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
- package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
- package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
- package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
- package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
- package/authoring/_shared/errors.test.mjs +0 -49
- package/authoring/codemod/parse.test.mjs +0 -99
- package/authoring/config/debug-composition.test.mjs +0 -92
- package/authoring/config/parse.test.mjs +0 -121
- package/authoring/debug/parse.test.mjs +0 -187
- package/authoring/discover/parse.test.mjs +0 -158
- package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
- package/authoring/doctypes/doctypes-new.test.mjs +0 -162
- package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
- package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
- package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
- package/authoring/doctypes/load-contract.test.mjs +0 -246
- package/authoring/doctypes/namespace/parse.test.mjs +0 -163
- package/authoring/doctypes/parse.test.mjs +0 -422
- package/authoring/doctypes/template/parse.test.mjs +0 -198
- package/authoring/gap-report/parse.test.mjs +0 -172
- package/authoring/integration/parse.test.mjs +0 -184
- package/authoring/shadcn/receipt.test.mjs +0 -187
- package/authoring/shadcn/source-variants.test.mjs +0 -120
- package/clients/cli/__tests__/cliManifest.test.ts +0 -37
- package/clients/cli/cli-command.test.mjs +0 -166
- package/clients/cli/cli-exit-codes.test.mjs +0 -163
- package/clients/cli/command-load-failure.test.mjs +0 -83
- package/clients/cli/command-result-coverage.test.mjs +0 -136
- package/clients/cli/commands/blog.test.mjs +0 -138
- package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
- package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
- package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
- package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
- package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
- package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
- package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
- package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
- package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
- package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
- package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
- package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
- package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
- package/clients/cli/commands/build.error-codes.test.mjs +0 -50
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
- package/clients/cli/commands/build.playbook.test.mjs +0 -75
- package/clients/cli/commands/build.text-fields.test.mjs +0 -81
- package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
- package/clients/cli/commands/component-batch.test.mjs +0 -341
- package/clients/cli/commands/component-ownership.test.mjs +0 -384
- package/clients/cli/commands/component-package.test.mjs +0 -169
- package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
- package/clients/cli/commands/component-resolution.test.mjs +0 -204
- package/clients/cli/commands/component.test.mjs +0 -612
- package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
- package/clients/cli/commands/detail-levels.test.mjs +0 -145
- package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
- package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
- package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
- package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
- package/clients/cli/commands/discover.no-source.test.mjs +0 -490
- package/clients/cli/commands/discover.sources.test.mjs +0 -292
- package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
- package/clients/cli/commands/docs.depth.test.mjs +0 -219
- package/clients/cli/commands/docs.test.mjs +0 -385
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
- package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
- package/clients/cli/commands/doctor.test.mjs +0 -509
- package/clients/cli/commands/empty-argument.test.mjs +0 -16
- package/clients/cli/commands/external-showcase.test.mjs +0 -121
- package/clients/cli/commands/gap-report.test.mjs +0 -412
- package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
- package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
- package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
- package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
- package/clients/cli/commands/icon.test.mjs +0 -96
- package/clients/cli/commands/import-hint-correctness.test.mjs +0 -293
- package/clients/cli/commands/init.behavior.test.mjs +0 -434
- package/clients/cli/commands/init.flag-help.test.mjs +0 -151
- package/clients/cli/commands/init.next-steps.test.mjs +0 -41
- package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
- package/clients/cli/commands/integration-authoring.test.mjs +0 -288
- package/clients/cli/commands/integration-check.test.mjs +0 -522
- package/clients/cli/commands/integration-real-world.test.mjs +0 -661
- package/clients/cli/commands/interactive-guard.test.mjs +0 -143
- package/clients/cli/commands/json-contract.test.mjs +0 -216
- package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
- package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
- package/clients/cli/commands/outside-project.test.mjs +0 -874
- package/clients/cli/commands/search.test.mjs +0 -514
- package/clients/cli/commands/setup-nudge.test.mjs +0 -280
- package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
- package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
- package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
- package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
- package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
- package/clients/cli/commands/template.flag-help.test.mjs +0 -124
- package/clients/cli/commands/template.icons.test.mjs +0 -132
- package/clients/cli/commands/template.path-help.test.mjs +0 -40
- package/clients/cli/commands/template.path-safety.test.mjs +0 -82
- package/clients/cli/commands/template.show-media.test.mjs +0 -62
- package/clients/cli/commands/template.test.mjs +0 -62
- package/clients/cli/commands/text-json-parity.test.mjs +0 -850
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
- package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
- package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
- package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
- package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
- package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
- package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
- package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
- package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
- package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
- package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
- package/clients/cli/commands/upgrade.test.mjs +0 -361
- package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
- package/clients/cli/commands/write-failure.test.mjs +0 -175
- package/clients/cli/e2e-smoke.test.mjs +0 -162
- package/clients/cli/error-envelope-code.test.mjs +0 -38
- package/clients/cli/formatters/index.test.mjs +0 -262
- package/clients/cli/latest-version-env.test.mjs +0 -50
- package/clients/cli/lib/cli-error.test.mjs +0 -206
- package/clients/cli/lib/component-format.test.mjs +0 -246
- package/clients/cli/lib/define-command.test.mjs +0 -103
- package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
- package/clients/cli/lib/exit-codes.test.mjs +0 -111
- package/clients/cli/lib/hook-format.test.mjs +0 -35
- package/clients/cli/lib/json-shim.test.mjs +0 -268
- package/clients/cli/lib/manifest.test.mjs +0 -346
- package/clients/cli/lib/parse-error-format.test.mjs +0 -81
- package/clients/cli/lib/resolve-theme.test.mjs +0 -543
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
- package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
- package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
- package/foundation/config/config-cache.test.mjs +0 -83
- package/foundation/config/config-writer.test.mjs +0 -84
- package/foundation/config/integration-debug.test.mjs +0 -218
- package/foundation/config/project-themes.test.mjs +0 -119
- package/foundation/config/project.test.mjs +0 -931
- package/foundation/config/theme-private-vars.test.mjs +0 -76
- package/foundation/config/theme-state.test.mjs +0 -182
- package/foundation/debug/debug-fields.test.mjs +0 -327
- package/foundation/debug/integration-handlers.test.mjs +0 -267
- package/foundation/debug/on-event.test.mjs +0 -643
- package/foundation/debug/privacy-contract.test.mjs +0 -195
- package/foundation/debug/redact.test.mjs +0 -534
- package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
- package/foundation/discovery/authoring-surface.test.mjs +0 -392
- package/foundation/discovery/cli-self-docs.test.mjs +0 -396
- package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
- package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
- package/foundation/discovery/component-discovery.test.mjs +0 -336
- package/foundation/discovery/component-loader.test.mjs +0 -190
- package/foundation/discovery/component-replacement.test.mjs +0 -520
- package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
- package/foundation/discovery/copied-passages.test.mjs +0 -124
- package/foundation/discovery/doc-consistency.test.mjs +0 -347
- package/foundation/discovery/doc-fluff.test.mjs +0 -142
- package/foundation/discovery/doc-types.test.mjs +0 -774
- package/foundation/discovery/docs-discovery.test.mjs +0 -707
- package/foundation/discovery/docs-section-key.test.mjs +0 -246
- package/foundation/discovery/hook-discovery.test.mjs +0 -216
- package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
- package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
- package/foundation/discovery/icon-set-writer.test.mjs +0 -26
- package/foundation/discovery/integration-doc-files.test.mjs +0 -275
- package/foundation/discovery/module-exports.test.mjs +0 -209
- package/foundation/discovery/package-tsconfig.test.mjs +0 -210
- package/foundation/discovery/prop-drift.test.mjs +0 -2337
- package/foundation/discovery/runner-commands.test.mjs +0 -131
- package/foundation/discovery/stray-pointers.test.mjs +0 -92
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
- package/foundation/discovery/template-adapter.test.mjs +0 -223
- package/foundation/discovery/template-conflict-release.test.mjs +0 -40
- package/foundation/discovery/template-icons.test.mjs +0 -560
- package/foundation/discovery/template-needs.test.mjs +0 -306
- package/foundation/discovery/theme-discovery.test.mjs +0 -775
- package/foundation/discovery/theme-imports.test.mjs +0 -173
- package/foundation/discovery/theming-targets.test.mjs +0 -328
- package/foundation/discovery/type-match.test.mjs +0 -169
- package/foundation/discovery/type-text.test.mjs +0 -196
- package/foundation/discovery/unresolved-references.test.mjs +0 -567
- package/foundation/doc-compiler/bundle.test.mjs +0 -266
- package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
- package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
- package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
- package/foundation/doc-compiler/inputs.test.mjs +0 -298
- package/foundation/doc-compiler/links.test.mjs +0 -285
- package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
- package/foundation/doc-compiler/read.test.mjs +0 -380
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
- package/foundation/doc-compiler/tree.test.mjs +0 -691
- package/foundation/env/cli-command.test.mjs +0 -129
- package/foundation/env/node-version.test.mjs +0 -103
- package/foundation/env/package-manager.global.test.mjs +0 -66
- package/foundation/env/package-manager.test.mjs +0 -910
- package/foundation/env/search-path.test.mjs +0 -122
- package/foundation/env/semver.test.mjs +0 -111
- package/foundation/env/user-dirs.test.mjs +0 -72
- package/foundation/env/user-settings.test.mjs +0 -64
- package/foundation/fs/file-protection.test.mjs +0 -250
- package/foundation/fs/listing-cache.test.mjs +0 -88
- package/foundation/fs/module-loader.stdout.test.mjs +0 -333
- package/foundation/fs/module-loader.test.mjs +0 -410
- package/foundation/fs/path-safety.test.mjs +0 -222
- package/foundation/fs/paths.test.mjs +0 -725
- package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
- package/foundation/fs/publish-file.test.mjs +0 -136
- package/foundation/fs/read-record.test.mjs +0 -164
- package/foundation/identity/provider-identity.test.mjs +0 -254
- package/foundation/integrations/autolink.test.mjs +0 -430
- package/foundation/integrations/cli-peer-version.test.mjs +0 -354
- package/foundation/integrations/cli-requirement.test.mjs +0 -383
- package/foundation/integrations/computer-integrations.test.mjs +0 -292
- package/foundation/integrations/contribution-inventory.test.mjs +0 -420
- package/foundation/integrations/integration-warnings.test.mjs +0 -191
- package/foundation/integrations/integrations.test.mjs +0 -818
- package/foundation/integrations/manifest-writer.test.mjs +0 -271
- package/foundation/integrations/provider-conflicts.test.mjs +0 -125
- package/foundation/integrations/provider-ledger.test.mjs +0 -275
- package/foundation/integrations/provider-resolution.test.mjs +0 -369
- package/foundation/integrations/public-imports.test.mjs +0 -1818
- package/foundation/release/cache.test.mjs +0 -923
- package/foundation/release/choose.test.mjs +0 -427
- package/foundation/release/global-state.test.mjs +0 -381
- package/foundation/release/handoff.e2e.test.mjs +0 -278
- package/foundation/release/notices.test.mjs +0 -586
- package/foundation/release/project.test.mjs +0 -288
- package/foundation/render/render.test.mjs +0 -117
- package/foundation/response/error-codes.test.mjs +0 -297
- package/foundation/response/json-contract.test.mjs +0 -235
- package/foundation/response/json-serialize.test.mjs +0 -66
- package/foundation/response/response-types.doc.test.mjs +0 -278
- package/foundation/route/route.test.mjs +0 -153
- package/foundation/runtime/hosted-runtime.test.mjs +0 -403
- package/foundation/runtime/package-set.test.mjs +0 -432
- package/foundation/text/copyright-header.test.mjs +0 -58
- package/foundation/text/levenshtein.test.mjs +0 -53
- package/foundation/text/string-utils.test.mjs +0 -175
- package/foundation/text/suggest-order.test.mjs +0 -312
- package/foundation/xle/browser-imports.test.mjs +0 -74
- package/foundation/xle/expand.test.mjs +0 -54
- package/foundation/xle/print.test.mjs +0 -50
- package/foundation/xle/registry.test.mjs +0 -28
- package/foundation/xle/xle.test.mjs +0 -382
- package/host/door-conformance.test.mjs +0 -274
- package/host/index.test.mjs +0 -302
|
@@ -1,1274 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Integration-provided template discovery (same-stem + type-driven).
|
|
5
|
-
*
|
|
6
|
-
* These tests stand up a temp consumer project with an astryx.config and an
|
|
7
|
-
* installed integration package that contributes templates, then exercise the
|
|
8
|
-
* public `template()` API to verify discovery, package/type scoping, ambiguity
|
|
9
|
-
* errors, and copy-to-dir naming.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
13
|
-
import * as fs from 'node:fs';
|
|
14
|
-
import * as path from 'node:path';
|
|
15
|
-
import {
|
|
16
|
-
discoverAllWithErrors,
|
|
17
|
-
discoverCoreTemplates,
|
|
18
|
-
template,
|
|
19
|
-
} from './template.mjs';
|
|
20
|
-
import {search} from '../search/search.mjs';
|
|
21
|
-
import {build} from '../build/build.mjs';
|
|
22
|
-
import {runCli} from '../../test-utils/run-cli.mjs';
|
|
23
|
-
|
|
24
|
-
let tmpDir;
|
|
25
|
-
let originalCwd;
|
|
26
|
-
|
|
27
|
-
function makeConsumer() {
|
|
28
|
-
const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-template-it-'));
|
|
29
|
-
fs.writeFileSync(
|
|
30
|
-
path.join(dir, 'package.json'),
|
|
31
|
-
JSON.stringify({name: 'consumer'}),
|
|
32
|
-
);
|
|
33
|
-
fs.writeFileSync(
|
|
34
|
-
path.join(dir, 'astryx.config.mjs'),
|
|
35
|
-
`export default { integrations: ['@acme/widgets'] };\n`,
|
|
36
|
-
);
|
|
37
|
-
return dir;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Install an @acme/widgets integration package that declares a templates root.
|
|
42
|
-
* @returns the package dir.
|
|
43
|
-
*/
|
|
44
|
-
function installWidgets(consumerDir) {
|
|
45
|
-
const pkgDir = path.join(consumerDir, 'node_modules', '@acme', 'widgets');
|
|
46
|
-
fs.mkdirSync(pkgDir, {recursive: true});
|
|
47
|
-
fs.writeFileSync(
|
|
48
|
-
path.join(pkgDir, 'package.json'),
|
|
49
|
-
JSON.stringify({name: '@acme/widgets', version: '2.0.0'}),
|
|
50
|
-
);
|
|
51
|
-
fs.writeFileSync(
|
|
52
|
-
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
53
|
-
`export default { templates: './templates' };\n`,
|
|
54
|
-
);
|
|
55
|
-
fs.mkdirSync(path.join(pkgDir, 'templates'));
|
|
56
|
-
return pkgDir;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Write a template doc + same-stem source under the templates root. */
|
|
60
|
-
function writeTemplate(pkgDir, id, {kind, body, source, withSource = true}) {
|
|
61
|
-
const docPath = path.join(pkgDir, 'templates', `${id}.doc.mjs`);
|
|
62
|
-
fs.mkdirSync(path.dirname(docPath), {recursive: true});
|
|
63
|
-
fs.writeFileSync(
|
|
64
|
-
docPath,
|
|
65
|
-
body ??
|
|
66
|
-
`export default {type: '${kind}', name: '${id} name', description: '${id} desc'};\n`,
|
|
67
|
-
);
|
|
68
|
-
if (withSource) {
|
|
69
|
-
fs.writeFileSync(
|
|
70
|
-
path.join(pkgDir, 'templates', `${id}.tsx`),
|
|
71
|
-
source ??
|
|
72
|
-
`export default function ${id.replace(/[^a-zA-Z0-9]/g, '')}() { return null; }\n`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Set `replaces` on each named template's own doc, declaring the templates
|
|
79
|
-
* root first when the package has no manifest yet.
|
|
80
|
-
*/
|
|
81
|
-
function declareReplaces(pkgDir, replacements) {
|
|
82
|
-
const manifest = path.join(pkgDir, 'astryx.integration.mjs');
|
|
83
|
-
if (!fs.existsSync(manifest)) {
|
|
84
|
-
fs.writeFileSync(manifest, `export default {templates: './templates'};\n`);
|
|
85
|
-
}
|
|
86
|
-
for (const [id, target] of Object.entries(replacements)) {
|
|
87
|
-
const docPath = path.join(pkgDir, 'templates', `${id}.doc.mjs`);
|
|
88
|
-
const doc = fs.readFileSync(docPath, 'utf-8');
|
|
89
|
-
if (!doc.includes('export default {'))
|
|
90
|
-
throw new Error(`${id}: no doc object`);
|
|
91
|
-
fs.writeFileSync(
|
|
92
|
-
docPath,
|
|
93
|
-
doc.replace(
|
|
94
|
-
'export default {',
|
|
95
|
-
`export default {replaces: ${JSON.stringify(target)}, `,
|
|
96
|
-
),
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
beforeEach(() => {
|
|
102
|
-
originalCwd = process.cwd();
|
|
103
|
-
tmpDir = makeConsumer();
|
|
104
|
-
process.chdir(tmpDir);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
afterEach(() => {
|
|
108
|
-
process.chdir(originalCwd);
|
|
109
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe('integration template discovery', () => {
|
|
113
|
-
it('discovers and lists an integration template with package + type', async () => {
|
|
114
|
-
const pkgDir = installWidgets(tmpDir);
|
|
115
|
-
writeTemplate(pkgDir, 'pricing', {kind: 'page'});
|
|
116
|
-
|
|
117
|
-
const result = await template(undefined, {list: true, cwd: tmpDir});
|
|
118
|
-
expect(result.type).toBe('template.list');
|
|
119
|
-
const entry = result.data.find(t => t.id === 'pricing');
|
|
120
|
-
expect(entry).toBeTruthy();
|
|
121
|
-
expect(entry.type).toBe('page');
|
|
122
|
-
expect(entry.package).toBe('@acme/widgets');
|
|
123
|
-
expect(entry.name).toBe('pricing name');
|
|
124
|
-
expect(entry.description).toBe('pricing desc');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("reads an integration template's keywords in search and build", async () => {
|
|
128
|
-
const pkgDir = installWidgets(tmpDir);
|
|
129
|
-
writeTemplate(pkgDir, 'observatory', {
|
|
130
|
-
kind: 'page',
|
|
131
|
-
body: "export default {type: 'page', name: 'Observatory', description: 'Live tiles over a sky view.', category: 'Dashboard - Observatory', keywords: ['telescope', 'star map']};\n",
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const found = await search('telescope', {cwd: tmpDir, type: 'template'});
|
|
135
|
-
expect(found.data.results.map(r => r.name)).toContain('observatory');
|
|
136
|
-
const kit = await build('telescope star map page', {cwd: tmpDir});
|
|
137
|
-
if (kit.type !== 'build.kit') throw new Error(kit.type);
|
|
138
|
-
expect(kit.data.start?.name).toBe('observatory');
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('preserves integration block showcase metadata in list output', async () => {
|
|
142
|
-
const pkgDir = installWidgets(tmpDir);
|
|
143
|
-
writeTemplate(pkgDir, 'chart-showcase', {
|
|
144
|
-
kind: 'block',
|
|
145
|
-
body: `export default {
|
|
146
|
-
type: 'block',
|
|
147
|
-
name: 'Chart',
|
|
148
|
-
displayName: 'Chart',
|
|
149
|
-
description: 'A chart.',
|
|
150
|
-
category: 'components/Chart',
|
|
151
|
-
exampleFor: 'Chart',
|
|
152
|
-
aspectRatio: 16 / 10,
|
|
153
|
-
isShowcase: true,
|
|
154
|
-
alsoExampleFor: ['ChartBar'],
|
|
155
|
-
alsoShowcaseFor: ['ChartSwatch'],
|
|
156
|
-
componentsUsed: ['Chart'],
|
|
157
|
-
};\n`,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const result = await template(undefined, {
|
|
161
|
-
list: true,
|
|
162
|
-
type: 'block',
|
|
163
|
-
package: '@acme/widgets',
|
|
164
|
-
cwd: tmpDir,
|
|
165
|
-
});
|
|
166
|
-
expect(result.data[0]).toMatchObject({
|
|
167
|
-
id: 'chart-showcase',
|
|
168
|
-
displayName: 'Chart',
|
|
169
|
-
exampleFor: 'Chart',
|
|
170
|
-
aspectRatio: 1.6,
|
|
171
|
-
isShowcase: true,
|
|
172
|
-
alsoExampleFor: ['ChartBar'],
|
|
173
|
-
alsoShowcaseFor: ['ChartSwatch'],
|
|
174
|
-
componentsUsed: ['Chart'],
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('lists nested-id templates (kebab path under root)', async () => {
|
|
179
|
-
const pkgDir = installWidgets(tmpDir);
|
|
180
|
-
writeTemplate(pkgDir, 'marketing/hero', {kind: 'block'});
|
|
181
|
-
|
|
182
|
-
const result = await template(undefined, {list: true, cwd: tmpDir});
|
|
183
|
-
const entry = result.data.find(t => t.id === 'marketing/hero');
|
|
184
|
-
expect(entry).toBeTruthy();
|
|
185
|
-
expect(entry.type).toBe('block');
|
|
186
|
-
expect(entry.package).toBe('@acme/widgets');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('always reports core templates under @astryxdesign/core', async () => {
|
|
190
|
-
const result = await template(undefined, {list: true, cwd: tmpDir});
|
|
191
|
-
const core = result.data.filter(t => t.package === '@astryxdesign/core');
|
|
192
|
-
expect(core.length).toBeGreaterThan(0);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('--package narrows the listing', async () => {
|
|
196
|
-
const pkgDir = installWidgets(tmpDir);
|
|
197
|
-
writeTemplate(pkgDir, 'pricing', {kind: 'page'});
|
|
198
|
-
|
|
199
|
-
const result = await template(undefined, {
|
|
200
|
-
list: true,
|
|
201
|
-
package: '@acme/widgets',
|
|
202
|
-
cwd: tmpDir,
|
|
203
|
-
});
|
|
204
|
-
expect(result.data.length).toBe(1);
|
|
205
|
-
expect(result.data[0].id).toBe('pricing');
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('skips a template whose same-stem source is missing', async () => {
|
|
209
|
-
const pkgDir = installWidgets(tmpDir);
|
|
210
|
-
writeTemplate(pkgDir, 'orphan', {kind: 'page', withSource: false});
|
|
211
|
-
|
|
212
|
-
const result = await template(undefined, {list: true, cwd: tmpDir});
|
|
213
|
-
expect(result.data.find(t => t.id === 'orphan')).toBeUndefined();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('skips a raw doc that is missing a type', async () => {
|
|
217
|
-
const pkgDir = installWidgets(tmpDir);
|
|
218
|
-
writeTemplate(pkgDir, 'untyped', {
|
|
219
|
-
kind: 'page',
|
|
220
|
-
body: `export default {name: 'Untyped', description: 'no type'};\n`,
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const result = await template(undefined, {list: true, cwd: tmpDir});
|
|
224
|
-
expect(result.data.find(t => t.id === 'untyped')).toBeUndefined();
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('does not read Object prototype keys as replacements', async () => {
|
|
228
|
-
const pkgDir = installWidgets(tmpDir);
|
|
229
|
-
for (const id of ['constructor', 'toString', '__proto__']) {
|
|
230
|
-
writeTemplate(pkgDir, id, {kind: 'page'});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
234
|
-
expect(
|
|
235
|
-
discovered.errors.filter(error => error.replacementTarget != null),
|
|
236
|
-
).toEqual([]);
|
|
237
|
-
for (const id of ['constructor', 'toString', '__proto__']) {
|
|
238
|
-
const entry = discovered.templates.find(
|
|
239
|
-
template =>
|
|
240
|
-
template.dirName === id && template.package === '@acme/widgets',
|
|
241
|
-
);
|
|
242
|
-
expect(entry).toBeDefined();
|
|
243
|
-
expect(entry?.replaces).toBeUndefined();
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('errors with candidates when an id is ambiguous across type/package', async () => {
|
|
248
|
-
const pkgDir = installWidgets(tmpDir);
|
|
249
|
-
// Same id "hero" as both a page and a block within the integration.
|
|
250
|
-
writeTemplate(pkgDir, 'hero', {kind: 'page'});
|
|
251
|
-
// Add a sibling block doc with the same stem in a different file is not
|
|
252
|
-
// possible (same file). Instead install a second package with a "hero".
|
|
253
|
-
const pkg2 = path.join(tmpDir, 'node_modules', '@acme', 'extra');
|
|
254
|
-
fs.mkdirSync(path.join(pkg2, 'templates'), {recursive: true});
|
|
255
|
-
fs.writeFileSync(
|
|
256
|
-
path.join(pkg2, 'package.json'),
|
|
257
|
-
JSON.stringify({name: '@acme/extra', version: '1.0.0'}),
|
|
258
|
-
);
|
|
259
|
-
fs.writeFileSync(
|
|
260
|
-
path.join(pkg2, 'astryx.integration.mjs'),
|
|
261
|
-
`export default { templates: './templates' };\n`,
|
|
262
|
-
);
|
|
263
|
-
fs.writeFileSync(
|
|
264
|
-
path.join(pkg2, 'templates', 'hero.doc.mjs'),
|
|
265
|
-
`export default {type: 'block', name: 'Hero block', description: 'b'};\n`,
|
|
266
|
-
);
|
|
267
|
-
fs.writeFileSync(
|
|
268
|
-
path.join(pkg2, 'templates', 'hero.tsx'),
|
|
269
|
-
`export default function Hero() { return null; }\n`,
|
|
270
|
-
);
|
|
271
|
-
fs.writeFileSync(
|
|
272
|
-
path.join(tmpDir, 'astryx.config.mjs'),
|
|
273
|
-
`export default { integrations: ['@acme/widgets', '@acme/extra'] };\n`,
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
await expect(
|
|
277
|
-
template('hero', {targetPath: './out', cwd: tmpDir}),
|
|
278
|
-
).rejects.toMatchObject({code: 'ERR_AMBIGUOUS_TEMPLATE'});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('--type and --package narrow an ambiguous id to a single match', async () => {
|
|
282
|
-
const pkgDir = installWidgets(tmpDir);
|
|
283
|
-
writeTemplate(pkgDir, 'pricing', {kind: 'page'});
|
|
284
|
-
|
|
285
|
-
const result = await template('pricing', {
|
|
286
|
-
type: 'page',
|
|
287
|
-
package: '@acme/widgets',
|
|
288
|
-
show: true,
|
|
289
|
-
cwd: tmpDir,
|
|
290
|
-
});
|
|
291
|
-
expect(result.type).toBe('template.show');
|
|
292
|
-
expect(result.data.type).toBe('page');
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('copies a page template into a directory as page.tsx', async () => {
|
|
296
|
-
const pkgDir = installWidgets(tmpDir);
|
|
297
|
-
writeTemplate(pkgDir, 'pricing', {kind: 'page'});
|
|
298
|
-
|
|
299
|
-
const result = await template('pricing', {
|
|
300
|
-
targetPath: './dest',
|
|
301
|
-
cwd: tmpDir,
|
|
302
|
-
});
|
|
303
|
-
expect(result.type).toBe('template.copy');
|
|
304
|
-
expect(result.data.fileName).toBe('page.tsx');
|
|
305
|
-
expect(fs.existsSync(path.join(tmpDir, 'dest', 'page.tsx'))).toBe(true);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('uses a declared integration replacement by default and keeps the Core original addressable', async () => {
|
|
309
|
-
const pkgDir = installWidgets(tmpDir);
|
|
310
|
-
writeTemplate(pkgDir, 'acme-app-shell', {
|
|
311
|
-
kind: 'page',
|
|
312
|
-
source:
|
|
313
|
-
'export default function AcmeAppShell() { return <nav>AcmeSideNav + AcmeTopNav</nav>; }\n',
|
|
314
|
-
});
|
|
315
|
-
declareReplaces(pkgDir, {
|
|
316
|
-
'acme-app-shell': 'shell-side-nav',
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
const listed = await template(undefined, {list: true, cwd: tmpDir});
|
|
320
|
-
expect(
|
|
321
|
-
listed.data.find(entry => entry.id === 'acme-app-shell'),
|
|
322
|
-
).toMatchObject({
|
|
323
|
-
package: '@acme/widgets',
|
|
324
|
-
replaces: 'shell-side-nav',
|
|
325
|
-
});
|
|
326
|
-
expect(
|
|
327
|
-
listed.data.find(
|
|
328
|
-
entry =>
|
|
329
|
-
entry.id === 'shell-side-nav' &&
|
|
330
|
-
entry.package === '@astryxdesign/core',
|
|
331
|
-
),
|
|
332
|
-
).toBeUndefined();
|
|
333
|
-
|
|
334
|
-
const selected = await template('shell-side-nav', {
|
|
335
|
-
show: true,
|
|
336
|
-
cwd: tmpDir,
|
|
337
|
-
});
|
|
338
|
-
expect(selected.data.template).toBe('acme-app-shell');
|
|
339
|
-
expect(selected.data.source).toContain('AcmeSideNav + AcmeTopNav');
|
|
340
|
-
|
|
341
|
-
const searched = await search('shell-side-nav', {
|
|
342
|
-
type: 'template',
|
|
343
|
-
cwd: tmpDir,
|
|
344
|
-
});
|
|
345
|
-
expect(searched.data.results).toEqual(
|
|
346
|
-
expect.arrayContaining([
|
|
347
|
-
expect.objectContaining({name: 'acme-app-shell'}),
|
|
348
|
-
]),
|
|
349
|
-
);
|
|
350
|
-
|
|
351
|
-
const original = await template('shell-side-nav', {
|
|
352
|
-
package: '@astryxdesign/core',
|
|
353
|
-
show: true,
|
|
354
|
-
cwd: tmpDir,
|
|
355
|
-
});
|
|
356
|
-
expect(original.data.template).toBe('shell-side-nav');
|
|
357
|
-
expect(original.data.source).toContain('@astryxdesign/core/SideNav');
|
|
358
|
-
expect(original.data.source).not.toContain('AcmeSideNav + AcmeTopNav');
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('uses canonical replacement resolution for copy collisions', async () => {
|
|
362
|
-
const pkgDir = installWidgets(tmpDir);
|
|
363
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'page'});
|
|
364
|
-
declareReplaces(pkgDir, {
|
|
365
|
-
'acme-app-shell': 'shell-side-nav',
|
|
366
|
-
});
|
|
367
|
-
const target = path.join(tmpDir, 'existing');
|
|
368
|
-
fs.mkdirSync(target);
|
|
369
|
-
fs.writeFileSync(path.join(target, 'page.tsx'), '// keep me\n');
|
|
370
|
-
|
|
371
|
-
const result = await runCli(
|
|
372
|
-
['template', 'shell-side-nav', 'existing'],
|
|
373
|
-
tmpDir,
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
expect(result.status).toBe(1);
|
|
377
|
-
expect(`${result.stdout}\n${result.stderr}`).toContain(
|
|
378
|
-
'Refusing to overwrite existing file',
|
|
379
|
-
);
|
|
380
|
-
expect(fs.readFileSync(path.join(target, 'page.tsx'), 'utf-8')).toBe(
|
|
381
|
-
'// keep me\n',
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it('keeps package-scoped lookup exact when one package also owns the Core id', async () => {
|
|
386
|
-
const pkgDir = installWidgets(tmpDir);
|
|
387
|
-
writeTemplate(pkgDir, 'acme-app-shell', {
|
|
388
|
-
kind: 'page',
|
|
389
|
-
source:
|
|
390
|
-
"export default function AcmeAppShell() { return 'active replacement'; }\n",
|
|
391
|
-
});
|
|
392
|
-
writeTemplate(pkgDir, 'shell-side-nav', {
|
|
393
|
-
kind: 'page',
|
|
394
|
-
source:
|
|
395
|
-
"export default function PackageShellSideNav() { return 'package exact id'; }\n",
|
|
396
|
-
});
|
|
397
|
-
declareReplaces(pkgDir, {
|
|
398
|
-
'acme-app-shell': 'shell-side-nav',
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
const unqualified = await template('shell-side-nav', {
|
|
402
|
-
show: true,
|
|
403
|
-
cwd: tmpDir,
|
|
404
|
-
});
|
|
405
|
-
expect(unqualified.data.template).toBe('acme-app-shell');
|
|
406
|
-
expect(unqualified.data.source).toContain('active replacement');
|
|
407
|
-
|
|
408
|
-
const packageExact = await template('shell-side-nav', {
|
|
409
|
-
package: '@acme/widgets',
|
|
410
|
-
show: true,
|
|
411
|
-
cwd: tmpDir,
|
|
412
|
-
});
|
|
413
|
-
expect(packageExact.data.template).toBe('shell-side-nav');
|
|
414
|
-
expect(packageExact.data.source).toContain('package exact id');
|
|
415
|
-
|
|
416
|
-
const packageOwnId = await template('acme-app-shell', {
|
|
417
|
-
package: '@acme/widgets',
|
|
418
|
-
show: true,
|
|
419
|
-
cwd: tmpDir,
|
|
420
|
-
});
|
|
421
|
-
expect(packageOwnId.data.template).toBe('acme-app-shell');
|
|
422
|
-
expect(packageOwnId.data.source).toContain('active replacement');
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
it('preserves an active replacement whose own id is another active target', async () => {
|
|
426
|
-
const pkgDir = installWidgets(tmpDir);
|
|
427
|
-
writeTemplate(pkgDir, 'shell-top-nav', {
|
|
428
|
-
kind: 'page',
|
|
429
|
-
source:
|
|
430
|
-
"export default function FirstReplacement() { return 'first replacement'; }\n",
|
|
431
|
-
});
|
|
432
|
-
writeTemplate(pkgDir, 'acme-second-shell', {
|
|
433
|
-
kind: 'page',
|
|
434
|
-
source:
|
|
435
|
-
"export default function SecondReplacement() { return 'second replacement'; }\n",
|
|
436
|
-
});
|
|
437
|
-
declareReplaces(pkgDir, {
|
|
438
|
-
'shell-top-nav': 'shell-side-nav',
|
|
439
|
-
'acme-second-shell': 'shell-top-nav',
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
const first = await template('shell-side-nav', {show: true, cwd: tmpDir});
|
|
443
|
-
expect(first.data.template).toBe('shell-top-nav');
|
|
444
|
-
expect(first.data.source).toContain('first replacement');
|
|
445
|
-
|
|
446
|
-
const second = await template('shell-top-nav', {show: true, cwd: tmpDir});
|
|
447
|
-
expect(second.data.template).toBe('acme-second-shell');
|
|
448
|
-
expect(second.data.source).toContain('second replacement');
|
|
449
|
-
|
|
450
|
-
const firstSearch = await search('shell-side-nav', {
|
|
451
|
-
type: 'template',
|
|
452
|
-
cwd: tmpDir,
|
|
453
|
-
});
|
|
454
|
-
expect(firstSearch.data.results[0]).toMatchObject({
|
|
455
|
-
name: 'shell-top-nav',
|
|
456
|
-
command: 'astryx template shell-side-nav --type page',
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
const secondSearch = await search('shell-top-nav', {
|
|
460
|
-
type: 'template',
|
|
461
|
-
cwd: tmpDir,
|
|
462
|
-
});
|
|
463
|
-
expect(secondSearch.data.results[0]).toMatchObject({
|
|
464
|
-
name: 'acme-second-shell',
|
|
465
|
-
command: 'astryx template shell-top-nav --type page',
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
const renderedBuild = await runCli(['build', 'shell-side-nav'], tmpDir);
|
|
469
|
-
expect(renderedBuild.status).toBe(0);
|
|
470
|
-
expect(renderedBuild.stdout).toContain(
|
|
471
|
-
'template shell-side-nav --type page <path>',
|
|
472
|
-
);
|
|
473
|
-
expect(renderedBuild.stdout).not.toContain('template shell-top-nav <path>');
|
|
474
|
-
|
|
475
|
-
const listed = await template(undefined, {list: true, cwd: tmpDir});
|
|
476
|
-
expect(listed.data).toEqual(
|
|
477
|
-
expect.arrayContaining([
|
|
478
|
-
expect.objectContaining({
|
|
479
|
-
id: 'shell-top-nav',
|
|
480
|
-
replaces: 'shell-side-nav',
|
|
481
|
-
package: '@acme/widgets',
|
|
482
|
-
}),
|
|
483
|
-
expect.objectContaining({
|
|
484
|
-
id: 'acme-second-shell',
|
|
485
|
-
replaces: 'shell-top-nav',
|
|
486
|
-
package: '@acme/widgets',
|
|
487
|
-
}),
|
|
488
|
-
]),
|
|
489
|
-
);
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
it('keeps an active replacement ahead of an undeclared exact-id template in search', async () => {
|
|
493
|
-
const active = installWidgets(tmpDir);
|
|
494
|
-
writeTemplate(active, 'active-shell', {
|
|
495
|
-
kind: 'page',
|
|
496
|
-
body: `export default {type: 'page', name: 'ZZZ active shell', description: 'replacement'};\n`,
|
|
497
|
-
});
|
|
498
|
-
declareReplaces(active, {'active-shell': 'shell-side-nav'});
|
|
499
|
-
|
|
500
|
-
const accidental = path.join(tmpDir, 'node_modules', '@acme', 'extra');
|
|
501
|
-
fs.mkdirSync(path.join(accidental, 'templates'), {recursive: true});
|
|
502
|
-
fs.writeFileSync(
|
|
503
|
-
path.join(accidental, 'package.json'),
|
|
504
|
-
JSON.stringify({name: '@acme/extra', version: '1.0.0'}),
|
|
505
|
-
);
|
|
506
|
-
fs.writeFileSync(
|
|
507
|
-
path.join(accidental, 'astryx.integration.mjs'),
|
|
508
|
-
`export default {templates: './templates'};\n`,
|
|
509
|
-
);
|
|
510
|
-
writeTemplate(accidental, 'shell-side-nav', {
|
|
511
|
-
kind: 'page',
|
|
512
|
-
body: `export default {type: 'page', name: 'AAA accidental shell', description: 'collision'};\n`,
|
|
513
|
-
});
|
|
514
|
-
fs.writeFileSync(
|
|
515
|
-
path.join(tmpDir, 'astryx.config.mjs'),
|
|
516
|
-
`export default { integrations: ['@acme/widgets', '@acme/extra'] };\n`,
|
|
517
|
-
);
|
|
518
|
-
|
|
519
|
-
const selected = await template('shell-side-nav', {
|
|
520
|
-
show: true,
|
|
521
|
-
cwd: tmpDir,
|
|
522
|
-
});
|
|
523
|
-
expect(selected.data.template).toBe('active-shell');
|
|
524
|
-
const searched = await search('shell-side-nav', {
|
|
525
|
-
type: 'template',
|
|
526
|
-
cwd: tmpDir,
|
|
527
|
-
});
|
|
528
|
-
expect(searched.data.results[0]).toMatchObject({
|
|
529
|
-
name: 'active-shell',
|
|
530
|
-
command: 'astryx template shell-side-nav --type page',
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
it('keeps the old discovery behavior when no replacement is declared', async () => {
|
|
535
|
-
const pkgDir = installWidgets(tmpDir);
|
|
536
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'page'});
|
|
537
|
-
|
|
538
|
-
const core = await template('shell-side-nav', {show: true, cwd: tmpDir});
|
|
539
|
-
expect(core.data.template).toBe('shell-side-nav');
|
|
540
|
-
const integration = await template('acme-app-shell', {
|
|
541
|
-
show: true,
|
|
542
|
-
cwd: tmpDir,
|
|
543
|
-
});
|
|
544
|
-
expect(integration.data.template).toBe('acme-app-shell');
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
it('fails an ambiguous replacement closed and reports every declaration', async () => {
|
|
548
|
-
const pkgDir = installWidgets(tmpDir);
|
|
549
|
-
writeTemplate(pkgDir, 'acme-app-shell-a', {kind: 'page'});
|
|
550
|
-
writeTemplate(pkgDir, 'acme-app-shell-b', {kind: 'page'});
|
|
551
|
-
declareReplaces(pkgDir, {
|
|
552
|
-
'acme-app-shell-a': 'shell-side-nav',
|
|
553
|
-
'acme-app-shell-b': 'shell-side-nav',
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
557
|
-
expect(
|
|
558
|
-
discovered.errors.filter(
|
|
559
|
-
error => error.code === 'ambiguous_template_replacement',
|
|
560
|
-
),
|
|
561
|
-
).toHaveLength(2);
|
|
562
|
-
const selected = await template('shell-side-nav', {
|
|
563
|
-
show: true,
|
|
564
|
-
cwd: tmpDir,
|
|
565
|
-
});
|
|
566
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
567
|
-
expect(
|
|
568
|
-
discovered.templates.filter(template =>
|
|
569
|
-
template.dirName.startsWith('acme-app-shell-'),
|
|
570
|
-
),
|
|
571
|
-
).toHaveLength(2);
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
it('does not activate a replacement when the same package also declares a missing template', async () => {
|
|
575
|
-
const pkgDir = installWidgets(tmpDir);
|
|
576
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'page'});
|
|
577
|
-
writeTemplate(pkgDir, 'missing-app-shell', {
|
|
578
|
-
kind: 'page',
|
|
579
|
-
withSource: false,
|
|
580
|
-
});
|
|
581
|
-
declareReplaces(pkgDir, {
|
|
582
|
-
'acme-app-shell': 'shell-side-nav',
|
|
583
|
-
'missing-app-shell': 'shell-side-nav',
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
587
|
-
expect(discovered.errors).toEqual(
|
|
588
|
-
expect.arrayContaining([
|
|
589
|
-
expect.objectContaining({
|
|
590
|
-
code: 'invalid_template_replacement',
|
|
591
|
-
template: 'missing-app-shell',
|
|
592
|
-
}),
|
|
593
|
-
]),
|
|
594
|
-
);
|
|
595
|
-
const selected = await template('shell-side-nav', {
|
|
596
|
-
show: true,
|
|
597
|
-
cwd: tmpDir,
|
|
598
|
-
});
|
|
599
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
600
|
-
const own = await template('acme-app-shell', {show: true, cwd: tmpDir});
|
|
601
|
-
expect(own.data.template).toBe('acme-app-shell');
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
it('keeps Core when a template whose metadata does not load declares the same replacement', async () => {
|
|
605
|
-
const pkgDir = installWidgets(tmpDir);
|
|
606
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'page'});
|
|
607
|
-
writeTemplate(pkgDir, 'broken-app-shell', {
|
|
608
|
-
kind: 'page',
|
|
609
|
-
body: "export default {type: 'page', name: 'broken', description: 'b', bogusField: 1};\n",
|
|
610
|
-
});
|
|
611
|
-
writeTemplate(pkgDir, 'unparsable-app-shell', {
|
|
612
|
-
kind: 'page',
|
|
613
|
-
body: "export default {replaces: 'shell-side-nav', type: 'page' name: 'x'};\n",
|
|
614
|
-
});
|
|
615
|
-
declareReplaces(pkgDir, {
|
|
616
|
-
'acme-app-shell': 'shell-side-nav',
|
|
617
|
-
'broken-app-shell': 'shell-side-nav',
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
621
|
-
for (const id of ['broken-app-shell', 'unparsable-app-shell']) {
|
|
622
|
-
expect(discovered.errors).toEqual(
|
|
623
|
-
expect.arrayContaining([
|
|
624
|
-
expect.objectContaining({
|
|
625
|
-
code: 'invalid_template_replacement',
|
|
626
|
-
template: id,
|
|
627
|
-
replacementTarget: 'shell-side-nav',
|
|
628
|
-
}),
|
|
629
|
-
]),
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
const selected = await template('shell-side-nav', {show: true, cwd: tmpDir});
|
|
633
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
it('keeps Core when an installed .doc.ts template with invalid metadata computes its replacement', async () => {
|
|
637
|
-
const pkgDir = installWidgets(tmpDir);
|
|
638
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'page'});
|
|
639
|
-
declareReplaces(pkgDir, {'acme-app-shell': 'shell-side-nav'});
|
|
640
|
-
fs.writeFileSync(
|
|
641
|
-
path.join(pkgDir, 'templates', 'ts-app-shell.doc.ts'),
|
|
642
|
-
"const target: string = 'shell-side-nav';\nexport default {replaces: target, type: 'page', name: 'ts', description: 'd', bogusField: 1};\n",
|
|
643
|
-
);
|
|
644
|
-
fs.writeFileSync(
|
|
645
|
-
path.join(pkgDir, 'templates', 'ts-app-shell.tsx'),
|
|
646
|
-
'export default function TsAppShell() { return null; }\n',
|
|
647
|
-
);
|
|
648
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
649
|
-
expect(discovered.errors).toEqual(
|
|
650
|
-
expect.arrayContaining([
|
|
651
|
-
expect.objectContaining({
|
|
652
|
-
code: 'invalid_template_replacement',
|
|
653
|
-
template: 'ts-app-shell',
|
|
654
|
-
replacementTarget: 'shell-side-nav',
|
|
655
|
-
}),
|
|
656
|
-
]),
|
|
657
|
-
);
|
|
658
|
-
const selected = await template('shell-side-nav', {show: true, cwd: tmpDir});
|
|
659
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
it('keeps --json stdout clean when an unusable template doc writes as it loads', async () => {
|
|
663
|
-
fs.writeFileSync(
|
|
664
|
-
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
665
|
-
"export default {templates: './local-templates'};\n",
|
|
666
|
-
);
|
|
667
|
-
fs.mkdirSync(path.join(tmpDir, 'local-templates'), {recursive: true});
|
|
668
|
-
fs.writeFileSync(
|
|
669
|
-
path.join(tmpDir, 'local-templates', 'acme-shell.doc.ts'),
|
|
670
|
-
"process.stdout.write('HELLO-FROM-DOC\\n');\nexport default {name: 'acme-shell', description: 'Acme shell.', replaces: 'dashboard'};\n",
|
|
671
|
-
);
|
|
672
|
-
fs.writeFileSync(
|
|
673
|
-
path.join(tmpDir, 'local-templates', 'acme-shell.tsx'),
|
|
674
|
-
'export default function AcmeShell() { return null; }\n',
|
|
675
|
-
);
|
|
676
|
-
const result = await runCli(['--json', 'template', '--list'], tmpDir);
|
|
677
|
-
expect(result.stdout).not.toContain('HELLO-FROM-DOC');
|
|
678
|
-
// One clean JSON envelope, and the doc was read: its replacement shows.
|
|
679
|
-
const envelope = JSON.parse(result.stdout);
|
|
680
|
-
expect(envelope.type).toBe('template.list');
|
|
681
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
682
|
-
expect(discovered.errors).toEqual(
|
|
683
|
-
expect.arrayContaining([
|
|
684
|
-
expect.objectContaining({template: 'acme-shell', replacementTarget: 'dashboard'}),
|
|
685
|
-
]),
|
|
686
|
-
);
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
it('lets the later configured package win a shared replacement target with a warning', async () => {
|
|
690
|
-
const first = installWidgets(tmpDir);
|
|
691
|
-
writeTemplate(first, 'acme-app-shell-a', {
|
|
692
|
-
kind: 'page',
|
|
693
|
-
source:
|
|
694
|
-
"export default function AcmeAppShellA() { return 'first replacement'; }\n",
|
|
695
|
-
});
|
|
696
|
-
declareReplaces(first, {
|
|
697
|
-
'acme-app-shell-a': 'shell-side-nav',
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
const second = path.join(tmpDir, 'node_modules', '@acme', 'extra');
|
|
701
|
-
fs.mkdirSync(path.join(second, 'templates'), {recursive: true});
|
|
702
|
-
fs.writeFileSync(
|
|
703
|
-
path.join(second, 'package.json'),
|
|
704
|
-
JSON.stringify({name: '@acme/extra', version: '1.0.0'}),
|
|
705
|
-
);
|
|
706
|
-
writeTemplate(second, 'acme-app-shell-b', {
|
|
707
|
-
kind: 'page',
|
|
708
|
-
source:
|
|
709
|
-
"export default function AcmeAppShellB() { return 'later replacement'; }\n",
|
|
710
|
-
});
|
|
711
|
-
declareReplaces(second, {
|
|
712
|
-
'acme-app-shell-b': 'shell-side-nav',
|
|
713
|
-
});
|
|
714
|
-
fs.writeFileSync(
|
|
715
|
-
path.join(tmpDir, 'astryx.config.mjs'),
|
|
716
|
-
`export default { integrations: ['@acme/widgets', '@acme/extra'] };\n`,
|
|
717
|
-
);
|
|
718
|
-
|
|
719
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
720
|
-
expect(discovered.errors).toEqual(
|
|
721
|
-
expect.arrayContaining([
|
|
722
|
-
expect.objectContaining({
|
|
723
|
-
code: 'ambiguous_template_replacement',
|
|
724
|
-
severity: 'warning',
|
|
725
|
-
package: '@acme/extra',
|
|
726
|
-
}),
|
|
727
|
-
]),
|
|
728
|
-
);
|
|
729
|
-
const selected = await template('shell-side-nav', {
|
|
730
|
-
show: true,
|
|
731
|
-
cwd: tmpDir,
|
|
732
|
-
});
|
|
733
|
-
expect(selected.data.template).toBe('acme-app-shell-b');
|
|
734
|
-
expect(selected.data.source).toContain('later replacement');
|
|
735
|
-
|
|
736
|
-
const command = await runCli(['template', 'shell-side-nav'], tmpDir);
|
|
737
|
-
expect(command.status).toBe(0);
|
|
738
|
-
expect(command.stderr).toContain('@acme/extra has 1 integration issue');
|
|
739
|
-
expect(command.stderr).toMatch(/Run: .+ doctor/);
|
|
740
|
-
|
|
741
|
-
const doctor = await runCli(['doctor'], tmpDir);
|
|
742
|
-
expect(doctor.status).toBe(0);
|
|
743
|
-
expect(doctor.stdout).toContain('configured later');
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
it('keeps an explicitly configured replacement ahead of an autolinked one', async () => {
|
|
747
|
-
const explicit = installWidgets(tmpDir);
|
|
748
|
-
writeTemplate(explicit, 'explicit-shell', {
|
|
749
|
-
kind: 'page',
|
|
750
|
-
source:
|
|
751
|
-
"export default function ExplicitShell() { return 'explicit replacement'; }\n",
|
|
752
|
-
});
|
|
753
|
-
declareReplaces(explicit, {
|
|
754
|
-
'explicit-shell': 'shell-side-nav',
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
const implicit = path.join(tmpDir, 'node_modules', '@acme', 'implicit');
|
|
758
|
-
fs.mkdirSync(path.join(implicit, 'templates'), {recursive: true});
|
|
759
|
-
fs.writeFileSync(
|
|
760
|
-
path.join(implicit, 'package.json'),
|
|
761
|
-
JSON.stringify({name: '@acme/implicit', version: '1.0.0'}),
|
|
762
|
-
);
|
|
763
|
-
writeTemplate(implicit, 'implicit-shell', {
|
|
764
|
-
kind: 'page',
|
|
765
|
-
source:
|
|
766
|
-
"export default function ImplicitShell() { return 'implicit replacement'; }\n",
|
|
767
|
-
});
|
|
768
|
-
declareReplaces(implicit, {
|
|
769
|
-
'implicit-shell': 'shell-side-nav',
|
|
770
|
-
});
|
|
771
|
-
fs.writeFileSync(
|
|
772
|
-
path.join(tmpDir, 'package.json'),
|
|
773
|
-
JSON.stringify({
|
|
774
|
-
name: 'consumer',
|
|
775
|
-
dependencies: {
|
|
776
|
-
'@acme/widgets': '1.0.0',
|
|
777
|
-
'@acme/implicit': '1.0.0',
|
|
778
|
-
},
|
|
779
|
-
}),
|
|
780
|
-
);
|
|
781
|
-
|
|
782
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
783
|
-
expect(discovered.errors).toEqual(
|
|
784
|
-
expect.arrayContaining([
|
|
785
|
-
expect.objectContaining({
|
|
786
|
-
code: 'ambiguous_template_replacement',
|
|
787
|
-
severity: 'warning',
|
|
788
|
-
package: '@acme/widgets',
|
|
789
|
-
message: expect.stringContaining('explicitly configured'),
|
|
790
|
-
}),
|
|
791
|
-
]),
|
|
792
|
-
);
|
|
793
|
-
const selected = await template('shell-side-nav', {
|
|
794
|
-
show: true,
|
|
795
|
-
cwd: tmpDir,
|
|
796
|
-
});
|
|
797
|
-
expect(selected.data.template).toBe('explicit-shell');
|
|
798
|
-
expect(selected.data.source).toContain('explicit replacement');
|
|
799
|
-
});
|
|
800
|
-
|
|
801
|
-
it('describes precedence truthfully when only autolinked packages conflict', async () => {
|
|
802
|
-
const first = installWidgets(tmpDir);
|
|
803
|
-
writeTemplate(first, 'first-shell', {kind: 'page'});
|
|
804
|
-
declareReplaces(first, {
|
|
805
|
-
'first-shell': 'shell-side-nav',
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
const second = path.join(tmpDir, 'node_modules', '@acme', 'implicit');
|
|
809
|
-
fs.mkdirSync(path.join(second, 'templates'), {recursive: true});
|
|
810
|
-
fs.writeFileSync(
|
|
811
|
-
path.join(second, 'package.json'),
|
|
812
|
-
JSON.stringify({name: '@acme/implicit', version: '1.0.0'}),
|
|
813
|
-
);
|
|
814
|
-
writeTemplate(second, 'second-shell', {kind: 'page'});
|
|
815
|
-
declareReplaces(second, {
|
|
816
|
-
'second-shell': 'shell-side-nav',
|
|
817
|
-
});
|
|
818
|
-
fs.writeFileSync(
|
|
819
|
-
path.join(tmpDir, 'astryx.config.mjs'),
|
|
820
|
-
'export default {};\n',
|
|
821
|
-
);
|
|
822
|
-
fs.writeFileSync(
|
|
823
|
-
path.join(tmpDir, 'package.json'),
|
|
824
|
-
JSON.stringify({
|
|
825
|
-
name: 'consumer',
|
|
826
|
-
dependencies: {
|
|
827
|
-
'@acme/widgets': '1.0.0',
|
|
828
|
-
'@acme/implicit': '1.0.0',
|
|
829
|
-
},
|
|
830
|
-
}),
|
|
831
|
-
);
|
|
832
|
-
|
|
833
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
834
|
-
const warning = discovered.errors.find(
|
|
835
|
-
error => error.code === 'ambiguous_template_replacement',
|
|
836
|
-
);
|
|
837
|
-
|
|
838
|
-
expect(warning?.package).toBe('@acme/implicit');
|
|
839
|
-
expect(warning?.message).toContain(
|
|
840
|
-
'listed later in package.json dependencies',
|
|
841
|
-
);
|
|
842
|
-
expect(warning?.message).toContain('astryx.config');
|
|
843
|
-
expect(warning?.message).not.toContain('configured later');
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
it('does not let an invalid autolinked declaration disable an explicit replacement', async () => {
|
|
847
|
-
const explicit = installWidgets(tmpDir);
|
|
848
|
-
writeTemplate(explicit, 'explicit-shell', {
|
|
849
|
-
kind: 'page',
|
|
850
|
-
source:
|
|
851
|
-
"export default function ExplicitShell() { return 'explicit replacement'; }\n",
|
|
852
|
-
});
|
|
853
|
-
declareReplaces(explicit, {
|
|
854
|
-
'explicit-shell': 'shell-side-nav',
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
const implicit = path.join(tmpDir, 'node_modules', '@acme', 'implicit');
|
|
858
|
-
fs.mkdirSync(path.join(implicit, 'templates'), {recursive: true});
|
|
859
|
-
fs.writeFileSync(
|
|
860
|
-
path.join(implicit, 'package.json'),
|
|
861
|
-
JSON.stringify({name: '@acme/implicit', version: '1.0.0'}),
|
|
862
|
-
);
|
|
863
|
-
writeTemplate(implicit, 'wrong-kind-shell', {kind: 'block'});
|
|
864
|
-
declareReplaces(implicit, {
|
|
865
|
-
'wrong-kind-shell': 'shell-side-nav',
|
|
866
|
-
});
|
|
867
|
-
fs.writeFileSync(
|
|
868
|
-
path.join(tmpDir, 'package.json'),
|
|
869
|
-
JSON.stringify({
|
|
870
|
-
name: 'consumer',
|
|
871
|
-
dependencies: {
|
|
872
|
-
'@acme/widgets': '1.0.0',
|
|
873
|
-
'@acme/implicit': '1.0.0',
|
|
874
|
-
},
|
|
875
|
-
}),
|
|
876
|
-
);
|
|
877
|
-
|
|
878
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
879
|
-
expect(discovered.errors).toEqual(
|
|
880
|
-
expect.arrayContaining([
|
|
881
|
-
expect.objectContaining({
|
|
882
|
-
code: 'invalid_template_replacement',
|
|
883
|
-
package: '@acme/implicit',
|
|
884
|
-
}),
|
|
885
|
-
]),
|
|
886
|
-
);
|
|
887
|
-
const selected = await template('shell-side-nav', {
|
|
888
|
-
show: true,
|
|
889
|
-
cwd: tmpDir,
|
|
890
|
-
});
|
|
891
|
-
expect(selected.data.template).toBe('explicit-shell');
|
|
892
|
-
});
|
|
893
|
-
|
|
894
|
-
it('fails closed when an earlier package has an invalid replacement for the winning target', async () => {
|
|
895
|
-
const first = installWidgets(tmpDir);
|
|
896
|
-
writeTemplate(first, 'wrong-kind-shell', {kind: 'block'});
|
|
897
|
-
declareReplaces(first, {
|
|
898
|
-
'wrong-kind-shell': 'shell-side-nav',
|
|
899
|
-
});
|
|
900
|
-
|
|
901
|
-
const second = path.join(tmpDir, 'node_modules', '@acme', 'extra');
|
|
902
|
-
fs.mkdirSync(path.join(second, 'templates'), {recursive: true});
|
|
903
|
-
fs.writeFileSync(
|
|
904
|
-
path.join(second, 'package.json'),
|
|
905
|
-
JSON.stringify({name: '@acme/extra', version: '1.0.0'}),
|
|
906
|
-
);
|
|
907
|
-
writeTemplate(second, 'valid-shell', {kind: 'page'});
|
|
908
|
-
declareReplaces(second, {
|
|
909
|
-
'valid-shell': 'shell-side-nav',
|
|
910
|
-
});
|
|
911
|
-
fs.writeFileSync(
|
|
912
|
-
path.join(tmpDir, 'astryx.config.mjs'),
|
|
913
|
-
`export default { integrations: ['@acme/widgets', '@acme/extra'] };\n`,
|
|
914
|
-
);
|
|
915
|
-
|
|
916
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
917
|
-
expect(discovered.errors).toEqual(
|
|
918
|
-
expect.arrayContaining([
|
|
919
|
-
expect.objectContaining({
|
|
920
|
-
code: 'invalid_template_replacement',
|
|
921
|
-
package: '@acme/widgets',
|
|
922
|
-
}),
|
|
923
|
-
]),
|
|
924
|
-
);
|
|
925
|
-
const selected = await template('shell-side-nav', {
|
|
926
|
-
show: true,
|
|
927
|
-
cwd: tmpDir,
|
|
928
|
-
});
|
|
929
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
it('reports a missing Core target and leaves the integration template available by its own id', async () => {
|
|
933
|
-
const pkgDir = installWidgets(tmpDir);
|
|
934
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'page'});
|
|
935
|
-
declareReplaces(pkgDir, {
|
|
936
|
-
'acme-app-shell': 'missing-core-shell',
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
940
|
-
expect(discovered.errors).toEqual(
|
|
941
|
-
expect.arrayContaining([
|
|
942
|
-
expect.objectContaining({
|
|
943
|
-
code: 'missing_template_replacement_target',
|
|
944
|
-
template: 'acme-app-shell',
|
|
945
|
-
}),
|
|
946
|
-
]),
|
|
947
|
-
);
|
|
948
|
-
const integration = await template('acme-app-shell', {
|
|
949
|
-
show: true,
|
|
950
|
-
cwd: tmpDir,
|
|
951
|
-
});
|
|
952
|
-
expect(integration.data.template).toBe('acme-app-shell');
|
|
953
|
-
const listed = await template(undefined, {
|
|
954
|
-
list: true,
|
|
955
|
-
package: '@acme/widgets',
|
|
956
|
-
cwd: tmpDir,
|
|
957
|
-
});
|
|
958
|
-
expect(
|
|
959
|
-
listed.data.find(entry => entry.id === 'acme-app-shell')?.replaces,
|
|
960
|
-
).toBeUndefined();
|
|
961
|
-
});
|
|
962
|
-
|
|
963
|
-
it('reports a missing self-id target without hiding the integration template', async () => {
|
|
964
|
-
const pkgDir = installWidgets(tmpDir);
|
|
965
|
-
writeTemplate(pkgDir, 'ghost-shell', {kind: 'page'});
|
|
966
|
-
declareReplaces(pkgDir, {
|
|
967
|
-
'ghost-shell': 'ghost-shell',
|
|
968
|
-
});
|
|
969
|
-
|
|
970
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
971
|
-
expect(discovered.errors).toEqual(
|
|
972
|
-
expect.arrayContaining([
|
|
973
|
-
expect.objectContaining({
|
|
974
|
-
code: 'missing_template_replacement_target',
|
|
975
|
-
template: 'ghost-shell',
|
|
976
|
-
replacementTarget: 'ghost-shell',
|
|
977
|
-
}),
|
|
978
|
-
]),
|
|
979
|
-
);
|
|
980
|
-
expect(
|
|
981
|
-
discovered.templates.find(
|
|
982
|
-
candidate =>
|
|
983
|
-
candidate.dirName === 'ghost-shell' &&
|
|
984
|
-
candidate.package === '@acme/widgets',
|
|
985
|
-
),
|
|
986
|
-
).toBeDefined();
|
|
987
|
-
|
|
988
|
-
const selected = await template('ghost-shell', {
|
|
989
|
-
show: true,
|
|
990
|
-
cwd: tmpDir,
|
|
991
|
-
});
|
|
992
|
-
expect(selected.data.template).toBe('ghost-shell');
|
|
993
|
-
expect(selected.data.source).toContain('ghostshell');
|
|
994
|
-
});
|
|
995
|
-
|
|
996
|
-
it('reports a replacement whose kind does not match Core', async () => {
|
|
997
|
-
const pkgDir = installWidgets(tmpDir);
|
|
998
|
-
writeTemplate(pkgDir, 'acme-app-shell', {kind: 'block'});
|
|
999
|
-
declareReplaces(pkgDir, {
|
|
1000
|
-
'acme-app-shell': 'shell-side-nav',
|
|
1001
|
-
});
|
|
1002
|
-
|
|
1003
|
-
const discovered = await discoverAllWithErrors(tmpDir);
|
|
1004
|
-
expect(discovered.errors).toEqual(
|
|
1005
|
-
expect.arrayContaining([
|
|
1006
|
-
expect.objectContaining({
|
|
1007
|
-
code: 'invalid_template_replacement',
|
|
1008
|
-
template: 'acme-app-shell',
|
|
1009
|
-
}),
|
|
1010
|
-
]),
|
|
1011
|
-
);
|
|
1012
|
-
const selected = await template('shell-side-nav', {
|
|
1013
|
-
show: true,
|
|
1014
|
-
cwd: tmpDir,
|
|
1015
|
-
});
|
|
1016
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
1017
|
-
});
|
|
1018
|
-
|
|
1019
|
-
it('falls back to Core for a rejected same-id replacement while package lookup keeps the integration template', async () => {
|
|
1020
|
-
const pkgDir = installWidgets(tmpDir);
|
|
1021
|
-
writeTemplate(pkgDir, 'shell-side-nav', {kind: 'block'});
|
|
1022
|
-
declareReplaces(pkgDir, {
|
|
1023
|
-
'shell-side-nav': 'shell-side-nav',
|
|
1024
|
-
});
|
|
1025
|
-
|
|
1026
|
-
const selected = await template('shell-side-nav', {
|
|
1027
|
-
show: true,
|
|
1028
|
-
cwd: tmpDir,
|
|
1029
|
-
});
|
|
1030
|
-
expect(selected.data.template).toBe('shell-side-nav');
|
|
1031
|
-
expect(selected.data.type).toBe('page');
|
|
1032
|
-
|
|
1033
|
-
const integration = await template('shell-side-nav', {
|
|
1034
|
-
package: '@acme/widgets',
|
|
1035
|
-
show: true,
|
|
1036
|
-
cwd: tmpDir,
|
|
1037
|
-
});
|
|
1038
|
-
expect(integration.data.template).toBe('shell-side-nav');
|
|
1039
|
-
expect(integration.data.type).toBe('block');
|
|
1040
|
-
|
|
1041
|
-
const block = await template('shell-side-nav', {
|
|
1042
|
-
type: 'block',
|
|
1043
|
-
show: true,
|
|
1044
|
-
cwd: tmpDir,
|
|
1045
|
-
});
|
|
1046
|
-
expect(block.data.template).toBe('shell-side-nav');
|
|
1047
|
-
expect(block.data.type).toBe('block');
|
|
1048
|
-
|
|
1049
|
-
const listedBlocks = await template(undefined, {
|
|
1050
|
-
list: true,
|
|
1051
|
-
type: 'block',
|
|
1052
|
-
cwd: tmpDir,
|
|
1053
|
-
});
|
|
1054
|
-
expect(listedBlocks.data).toEqual(
|
|
1055
|
-
expect.arrayContaining([
|
|
1056
|
-
expect.objectContaining({
|
|
1057
|
-
id: 'shell-side-nav',
|
|
1058
|
-
type: 'block',
|
|
1059
|
-
package: '@acme/widgets',
|
|
1060
|
-
}),
|
|
1061
|
-
]),
|
|
1062
|
-
);
|
|
1063
|
-
|
|
1064
|
-
const searched = await search('shell-side-nav', {
|
|
1065
|
-
type: 'template',
|
|
1066
|
-
limit: 100,
|
|
1067
|
-
cwd: tmpDir,
|
|
1068
|
-
});
|
|
1069
|
-
const sameId = searched.data.results.filter(
|
|
1070
|
-
result => result.name === 'shell-side-nav',
|
|
1071
|
-
);
|
|
1072
|
-
expect(sameId).toEqual(
|
|
1073
|
-
expect.arrayContaining([
|
|
1074
|
-
expect.objectContaining({
|
|
1075
|
-
kind: 'page',
|
|
1076
|
-
command: 'astryx template shell-side-nav --type page',
|
|
1077
|
-
}),
|
|
1078
|
-
expect.objectContaining({
|
|
1079
|
-
kind: 'block',
|
|
1080
|
-
command: 'astryx template shell-side-nav --type block',
|
|
1081
|
-
}),
|
|
1082
|
-
]),
|
|
1083
|
-
);
|
|
1084
|
-
|
|
1085
|
-
const kit = await build('shell-side-nav', {
|
|
1086
|
-
type: 'template',
|
|
1087
|
-
limit: 100,
|
|
1088
|
-
cwd: tmpDir,
|
|
1089
|
-
});
|
|
1090
|
-
expect(kit.type).toBe('build.kit');
|
|
1091
|
-
if (kit.type !== 'build.kit') throw new Error('expected build.kit');
|
|
1092
|
-
expect(kit.data.blocks).toEqual(
|
|
1093
|
-
expect.arrayContaining([
|
|
1094
|
-
expect.objectContaining({
|
|
1095
|
-
name: 'shell-side-nav',
|
|
1096
|
-
command: 'astryx template shell-side-nav --type block',
|
|
1097
|
-
}),
|
|
1098
|
-
]),
|
|
1099
|
-
);
|
|
1100
|
-
});
|
|
1101
|
-
|
|
1102
|
-
it('round-trips both kinds when a block replacement shadows a page with the same id', async () => {
|
|
1103
|
-
const pkgDir = installWidgets(tmpDir);
|
|
1104
|
-
writeTemplate(pkgDir, 'acme-callout', {
|
|
1105
|
-
kind: 'block',
|
|
1106
|
-
source:
|
|
1107
|
-
"export default function AcmeCallout() { return 'replacement block'; }\n",
|
|
1108
|
-
});
|
|
1109
|
-
writeTemplate(pkgDir, 'CardCallout', {
|
|
1110
|
-
kind: 'page',
|
|
1111
|
-
source:
|
|
1112
|
-
"export default function CardCalloutPage() { return 'ordinary page'; }\n",
|
|
1113
|
-
});
|
|
1114
|
-
declareReplaces(pkgDir, {
|
|
1115
|
-
'acme-callout': 'CardCallout',
|
|
1116
|
-
});
|
|
1117
|
-
|
|
1118
|
-
const bare = await template('CardCallout', {show: true, cwd: tmpDir});
|
|
1119
|
-
expect(bare.data.template).toBe('acme-callout');
|
|
1120
|
-
expect(bare.data.type).toBe('block');
|
|
1121
|
-
|
|
1122
|
-
const page = await template('CardCallout', {
|
|
1123
|
-
type: 'page',
|
|
1124
|
-
show: true,
|
|
1125
|
-
cwd: tmpDir,
|
|
1126
|
-
});
|
|
1127
|
-
expect(page.data.template).toBe('CardCallout');
|
|
1128
|
-
expect(page.data.type).toBe('page');
|
|
1129
|
-
|
|
1130
|
-
const searched = await search('CardCallout', {
|
|
1131
|
-
type: 'template',
|
|
1132
|
-
limit: 100,
|
|
1133
|
-
cwd: tmpDir,
|
|
1134
|
-
});
|
|
1135
|
-
expect(searched.data.results).toEqual(
|
|
1136
|
-
expect.arrayContaining([
|
|
1137
|
-
expect.objectContaining({
|
|
1138
|
-
name: 'CardCallout',
|
|
1139
|
-
kind: 'page',
|
|
1140
|
-
command: 'astryx template CardCallout --type page',
|
|
1141
|
-
}),
|
|
1142
|
-
expect.objectContaining({
|
|
1143
|
-
name: 'acme-callout',
|
|
1144
|
-
kind: 'block',
|
|
1145
|
-
command: 'astryx template CardCallout --type block',
|
|
1146
|
-
}),
|
|
1147
|
-
]),
|
|
1148
|
-
);
|
|
1149
|
-
|
|
1150
|
-
const kit = await build('CardCallout', {
|
|
1151
|
-
type: 'template',
|
|
1152
|
-
limit: 100,
|
|
1153
|
-
cwd: tmpDir,
|
|
1154
|
-
});
|
|
1155
|
-
expect(kit.type).toBe('build.kit');
|
|
1156
|
-
if (kit.type !== 'build.kit') throw new Error('expected build.kit');
|
|
1157
|
-
expect(kit.data.pages).toEqual(
|
|
1158
|
-
expect.arrayContaining([
|
|
1159
|
-
expect.objectContaining({
|
|
1160
|
-
name: 'CardCallout',
|
|
1161
|
-
command: 'astryx template CardCallout --type page',
|
|
1162
|
-
}),
|
|
1163
|
-
]),
|
|
1164
|
-
);
|
|
1165
|
-
expect(kit.data.blocks).toEqual(
|
|
1166
|
-
expect.arrayContaining([
|
|
1167
|
-
expect.objectContaining({
|
|
1168
|
-
name: 'acme-callout',
|
|
1169
|
-
command: 'astryx template CardCallout --type block',
|
|
1170
|
-
}),
|
|
1171
|
-
]),
|
|
1172
|
-
);
|
|
1173
|
-
});
|
|
1174
|
-
|
|
1175
|
-
it('copies a block template into a directory as <id-basename>.tsx', async () => {
|
|
1176
|
-
const pkgDir = installWidgets(tmpDir);
|
|
1177
|
-
writeTemplate(pkgDir, 'marketing/hero', {kind: 'block'});
|
|
1178
|
-
|
|
1179
|
-
const result = await template('marketing/hero', {
|
|
1180
|
-
targetPath: './dest',
|
|
1181
|
-
cwd: tmpDir,
|
|
1182
|
-
});
|
|
1183
|
-
expect(result.type).toBe('template.copy');
|
|
1184
|
-
expect(result.data.fileName).toBe('hero.tsx');
|
|
1185
|
-
expect(fs.existsSync(path.join(tmpDir, 'dest', 'hero.tsx'))).toBe(true);
|
|
1186
|
-
});
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
describe('build names a start its command selects', () => {
|
|
1190
|
-
it('scaffolds an integration replacement through the Core id it replaces', async () => {
|
|
1191
|
-
const pkgDir = installWidgets(tmpDir);
|
|
1192
|
-
writeTemplate(pkgDir, 'acme-app-shell', {
|
|
1193
|
-
kind: 'page',
|
|
1194
|
-
body: "export default {type: 'page', name: 'Acme App Shell', category: 'Shell - Acme Sidebar', description: 'Acme application frame with a left sidebar navigation. Shell, frame, or sidebar navigation.'};\n",
|
|
1195
|
-
});
|
|
1196
|
-
declareReplaces(pkgDir, {'acme-app-shell': 'shell-side-nav'});
|
|
1197
|
-
|
|
1198
|
-
const kit = await build('acme application frame with sidebar navigation', {
|
|
1199
|
-
cwd: tmpDir,
|
|
1200
|
-
});
|
|
1201
|
-
expect(kit.type).toBe('build.kit');
|
|
1202
|
-
if (kit.type !== 'build.kit') throw new Error('expected build.kit');
|
|
1203
|
-
expect(kit.data.start).toMatchObject({
|
|
1204
|
-
name: 'acme-app-shell',
|
|
1205
|
-
command: 'astryx template shell-side-nav --type page <path>',
|
|
1206
|
-
});
|
|
1207
|
-
const selected = await template('shell-side-nav', {
|
|
1208
|
-
type: 'page',
|
|
1209
|
-
show: true,
|
|
1210
|
-
cwd: tmpDir,
|
|
1211
|
-
});
|
|
1212
|
-
expect(selected.data.template).toBe('acme-app-shell');
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
it('keeps the start command unambiguous when a block shares the id', async () => {
|
|
1216
|
-
const pkgDir = installWidgets(tmpDir);
|
|
1217
|
-
writeTemplate(pkgDir, 'contact-form', {kind: 'block'});
|
|
1218
|
-
|
|
1219
|
-
const kit = await build('contact form', {cwd: tmpDir});
|
|
1220
|
-
expect(kit.type).toBe('build.kit');
|
|
1221
|
-
if (kit.type !== 'build.kit') throw new Error('expected build.kit');
|
|
1222
|
-
expect(kit.data.start).toMatchObject({
|
|
1223
|
-
name: 'contact-form',
|
|
1224
|
-
command: 'astryx template contact-form --type page <path>',
|
|
1225
|
-
});
|
|
1226
|
-
const selected = await template('contact-form', {
|
|
1227
|
-
type: 'page',
|
|
1228
|
-
show: true,
|
|
1229
|
-
cwd: tmpDir,
|
|
1230
|
-
});
|
|
1231
|
-
expect(selected.data.template).toBe('contact-form');
|
|
1232
|
-
// The bare id is ambiguous here, which is why the command carries --type.
|
|
1233
|
-
await expect(
|
|
1234
|
-
template('contact-form', {show: true, cwd: tmpDir}),
|
|
1235
|
-
).rejects.toMatchObject({code: 'ERR_AMBIGUOUS_TEMPLATE'});
|
|
1236
|
-
});
|
|
1237
|
-
|
|
1238
|
-
it('resolves chained template aliases without the layout command', async () => {
|
|
1239
|
-
const [firstTarget, secondTarget] = (await discoverCoreTemplates()).filter(
|
|
1240
|
-
candidate => candidate.type === 'block',
|
|
1241
|
-
);
|
|
1242
|
-
expect(firstTarget).toBeDefined();
|
|
1243
|
-
expect(secondTarget).toBeDefined();
|
|
1244
|
-
|
|
1245
|
-
const pkgDir = installWidgets(tmpDir);
|
|
1246
|
-
writeTemplate(pkgDir, secondTarget.dirName, {
|
|
1247
|
-
kind: 'block',
|
|
1248
|
-
source:
|
|
1249
|
-
'export default function FirstReplacement() { return <span>First chain replacement</span>; }\n',
|
|
1250
|
-
});
|
|
1251
|
-
writeTemplate(pkgDir, 'acme-final-block', {
|
|
1252
|
-
kind: 'block',
|
|
1253
|
-
source:
|
|
1254
|
-
'export default function FinalReplacement() { return <span>Final chain replacement</span>; }\n',
|
|
1255
|
-
});
|
|
1256
|
-
declareReplaces(pkgDir, {
|
|
1257
|
-
[secondTarget.dirName]: firstTarget.dirName,
|
|
1258
|
-
'acme-final-block': secondTarget.dirName,
|
|
1259
|
-
});
|
|
1260
|
-
|
|
1261
|
-
const firstTemplate = await template(firstTarget.dirName, {
|
|
1262
|
-
show: true,
|
|
1263
|
-
cwd: tmpDir,
|
|
1264
|
-
});
|
|
1265
|
-
expect(firstTemplate.data.source).toContain('First chain replacement');
|
|
1266
|
-
|
|
1267
|
-
const secondTemplate = await template(secondTarget.dirName, {
|
|
1268
|
-
show: true,
|
|
1269
|
-
cwd: tmpDir,
|
|
1270
|
-
});
|
|
1271
|
-
expect(secondTemplate.data.source).toContain('Final chain replacement');
|
|
1272
|
-
}, 30_000);
|
|
1273
|
-
|
|
1274
|
-
});
|