@astryxdesign/cli 0.7.6-canary.f73623d → 0.7.6-canary.f899313
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/package.json +23 -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,2845 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Icon-set authoring commands end to end (AST-084): `experimental icon
|
|
5
|
-
* new-set --from`, `experimental icon new-definition`, `experimental icon add`, `icon
|
|
6
|
-
* map`, and `experimental icon use`, driving the real program over an icon-set package
|
|
7
|
-
* that wraps a small component library and an app that installs it.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import * as fs from 'node:fs';
|
|
11
|
-
import * as os from 'node:os';
|
|
12
|
-
import * as path from 'node:path';
|
|
13
|
-
import {createRequire} from 'node:module';
|
|
14
|
-
import {pathToFileURL} from 'node:url';
|
|
15
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
16
|
-
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
17
|
-
import {writeIconSetProject} from '../../../test-utils/icon-set-fixture.mjs';
|
|
18
|
-
|
|
19
|
-
/** @type {string} */
|
|
20
|
-
let tmp;
|
|
21
|
-
/** @type {string} */
|
|
22
|
-
let pkg;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A component library under node_modules: two components (one also exported
|
|
26
|
-
* under an `…Icon` alias), a data export, and a default-export file.
|
|
27
|
-
* @param {string} dir
|
|
28
|
-
*/
|
|
29
|
-
function writeLibrary(dir) {
|
|
30
|
-
const lib = path.join(dir, 'node_modules', '@acme', 'glyph-library');
|
|
31
|
-
fs.mkdirSync(path.join(lib, 'icons'), {recursive: true});
|
|
32
|
-
fs.writeFileSync(
|
|
33
|
-
path.join(lib, 'package.json'),
|
|
34
|
-
JSON.stringify({
|
|
35
|
-
name: '@acme/glyph-library',
|
|
36
|
-
version: '2.0.0',
|
|
37
|
-
type: 'module',
|
|
38
|
-
exports: {'.': './index.js', './rocket': './icons/rocket.js'},
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
fs.writeFileSync(
|
|
42
|
-
path.join(lib, 'index.js'),
|
|
43
|
-
[
|
|
44
|
-
"export {Bin, Bin as BinIcon} from './icons/bin.js';",
|
|
45
|
-
"export {Cross} from './icons/cross.js';",
|
|
46
|
-
"export const glyphData = {path: 'M0 0'};",
|
|
47
|
-
"export const version = '2.0.0';",
|
|
48
|
-
'',
|
|
49
|
-
].join('\n'),
|
|
50
|
-
);
|
|
51
|
-
fs.writeFileSync(
|
|
52
|
-
path.join(lib, 'icons', 'bin.js'),
|
|
53
|
-
'export function Bin(props) { return null; }\n',
|
|
54
|
-
);
|
|
55
|
-
fs.writeFileSync(
|
|
56
|
-
path.join(lib, 'icons', 'cross.js'),
|
|
57
|
-
'export const Cross = props => null;\n',
|
|
58
|
-
);
|
|
59
|
-
fs.writeFileSync(
|
|
60
|
-
path.join(lib, 'icons', 'rocket.js'),
|
|
61
|
-
'export default function Rocket(props) { return null; }\n',
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
beforeEach(() => {
|
|
66
|
-
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-icon-authoring-'));
|
|
67
|
-
pkg = path.join(tmp, 'icons');
|
|
68
|
-
fs.mkdirSync(pkg, {recursive: true});
|
|
69
|
-
fs.writeFileSync(
|
|
70
|
-
path.join(pkg, 'package.json'),
|
|
71
|
-
JSON.stringify(
|
|
72
|
-
{
|
|
73
|
-
name: '@acme/icons',
|
|
74
|
-
version: '1.0.0',
|
|
75
|
-
license: 'MIT',
|
|
76
|
-
type: 'module',
|
|
77
|
-
exports: {'.': './index.js'},
|
|
78
|
-
dependencies: {'@acme/glyph-library': '^2.0.0'},
|
|
79
|
-
},
|
|
80
|
-
null,
|
|
81
|
-
2,
|
|
82
|
-
),
|
|
83
|
-
);
|
|
84
|
-
fs.writeFileSync(path.join(pkg, 'index.js'), 'export {};\n');
|
|
85
|
-
writeLibrary(pkg);
|
|
86
|
-
});
|
|
87
|
-
afterEach(() => {
|
|
88
|
-
fs.rmSync(tmp, {recursive: true, force: true});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
/** @param {string[]} args @param {string} [cwd] */
|
|
92
|
-
async function json(args, cwd = pkg) {
|
|
93
|
-
const res = await runCli([...args, '--json'], cwd);
|
|
94
|
-
return {code: res.code, body: JSON.parse(res.stdout)};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** @param {string} set */
|
|
98
|
-
const dataOf = set =>
|
|
99
|
-
JSON.parse(
|
|
100
|
-
fs.readFileSync(
|
|
101
|
-
path.join(pkg, 'icon-sets', set, `${set}.icons.json`),
|
|
102
|
-
'utf-8',
|
|
103
|
-
),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
describe('experimental icon new-set --from', () => {
|
|
107
|
-
it('wraps every component of a library once, names each <Name>Icon, pre-fills exact map hits, and says what to export', async () => {
|
|
108
|
-
const {code, body} = await json([
|
|
109
|
-
'experimental',
|
|
110
|
-
'icon',
|
|
111
|
-
'new-set',
|
|
112
|
-
'outline',
|
|
113
|
-
'--from',
|
|
114
|
-
'@acme/glyph-library',
|
|
115
|
-
]);
|
|
116
|
-
expect(code).toBe(0);
|
|
117
|
-
expect(body.data).toMatchObject({kind: 'icon-set', icons: 2});
|
|
118
|
-
// The package's entry is the author's: the receipt names the exact line
|
|
119
|
-
// and the entry stays as it was (architecture:cli-surface INV16).
|
|
120
|
-
expect(body.data.files).not.toContain('index.js');
|
|
121
|
-
expect(fs.readFileSync(path.join(pkg, 'index.js'), 'utf-8')).toBe(
|
|
122
|
-
'export {};\n',
|
|
123
|
-
);
|
|
124
|
-
expect(body.data.notes).toContain(
|
|
125
|
-
"Add `export * from './icon-sets/outline/outline.generated.js';` to index.js, so the icons import from @acme/icons.",
|
|
126
|
-
);
|
|
127
|
-
const data = dataOf('outline');
|
|
128
|
-
expect(data.generated).toBe('./icon-sets/outline/outline.generated.js');
|
|
129
|
-
expect(data.icons).toEqual([
|
|
130
|
-
{id: 'bin', export: 'BinIcon', words: ['bin']},
|
|
131
|
-
{id: 'cross', export: 'CrossIcon', words: ['cross']},
|
|
132
|
-
]);
|
|
133
|
-
// `delete` has the word bin, but a word alone is only a suggestion: a
|
|
134
|
-
// library's bin may not mean delete. Nothing is written for it.
|
|
135
|
-
expect(data.map).toEqual({});
|
|
136
|
-
expect(body.data.suggestions).toContainEqual({
|
|
137
|
-
definition: 'delete',
|
|
138
|
-
icon: 'bin',
|
|
139
|
-
word: 'bin',
|
|
140
|
-
});
|
|
141
|
-
// The installed library and version are the set's source.
|
|
142
|
-
expect(data.source).toEqual({
|
|
143
|
-
package: '@acme/glyph-library',
|
|
144
|
-
version: '2.0.0',
|
|
145
|
-
});
|
|
146
|
-
const generated = fs.readFileSync(
|
|
147
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
148
|
-
'utf-8',
|
|
149
|
-
);
|
|
150
|
-
expect(generated).toContain("export {BinIcon} from '@acme/glyph-library';");
|
|
151
|
-
expect(generated).toContain(
|
|
152
|
-
"export {Cross as CrossIcon} from '@acme/glyph-library';",
|
|
153
|
-
);
|
|
154
|
-
expect(generated).not.toContain('glyphData');
|
|
155
|
-
|
|
156
|
-
// Running it again refreshes in place and keeps the map.
|
|
157
|
-
const again = await json([
|
|
158
|
-
'experimental',
|
|
159
|
-
'icon',
|
|
160
|
-
'new-set',
|
|
161
|
-
'outline',
|
|
162
|
-
'--from',
|
|
163
|
-
'@acme/glyph-library',
|
|
164
|
-
]);
|
|
165
|
-
expect(again.code).toBe(0);
|
|
166
|
-
expect(dataOf('outline').map).toEqual({});
|
|
167
|
-
expect(again.body.data.suggestions).toContainEqual({
|
|
168
|
-
definition: 'delete',
|
|
169
|
-
icon: 'bin',
|
|
170
|
-
word: 'bin',
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('maps a definition only by its exact name, and prints the rest as suggestions', async () => {
|
|
175
|
-
// A library icon named after a definition (`close`) maps; a word (`bin`)
|
|
176
|
-
// does not.
|
|
177
|
-
fs.writeFileSync(
|
|
178
|
-
path.join(
|
|
179
|
-
pkg,
|
|
180
|
-
'node_modules',
|
|
181
|
-
'@acme',
|
|
182
|
-
'glyph-library',
|
|
183
|
-
'icons',
|
|
184
|
-
'close.js',
|
|
185
|
-
),
|
|
186
|
-
'export const Close = props => null;\n',
|
|
187
|
-
);
|
|
188
|
-
fs.appendFileSync(
|
|
189
|
-
path.join(pkg, 'node_modules', '@acme', 'glyph-library', 'index.js'),
|
|
190
|
-
"export {Close} from './icons/close.js';\n",
|
|
191
|
-
);
|
|
192
|
-
const res = await runCli(
|
|
193
|
-
[
|
|
194
|
-
'experimental',
|
|
195
|
-
'icon',
|
|
196
|
-
'new-set',
|
|
197
|
-
'outline',
|
|
198
|
-
'--from',
|
|
199
|
-
'@acme/glyph-library',
|
|
200
|
-
],
|
|
201
|
-
pkg,
|
|
202
|
-
);
|
|
203
|
-
expect(res.code).toBe(0);
|
|
204
|
-
expect(dataOf('outline').map).toEqual({close: 'close'});
|
|
205
|
-
expect(res.stdout).toContain('Suggestions');
|
|
206
|
-
expect(res.stdout).toContain('experimental icon map delete bin');
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('--variants and --default-variant declare the variants; the library license notice is copied', async () => {
|
|
210
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
211
|
-
fs.writeFileSync(path.join(lib, 'LICENSE'), 'MIT License\n');
|
|
212
|
-
const pkgJson = JSON.parse(
|
|
213
|
-
fs.readFileSync(path.join(lib, 'package.json'), 'utf-8'),
|
|
214
|
-
);
|
|
215
|
-
fs.writeFileSync(
|
|
216
|
-
path.join(lib, 'package.json'),
|
|
217
|
-
JSON.stringify({...pkgJson, license: 'ISC'}),
|
|
218
|
-
);
|
|
219
|
-
const {code, body} = await json([
|
|
220
|
-
'experimental',
|
|
221
|
-
'icon',
|
|
222
|
-
'new-set',
|
|
223
|
-
'glyphs',
|
|
224
|
-
'--from',
|
|
225
|
-
'@acme/glyph-library',
|
|
226
|
-
'--variants',
|
|
227
|
-
'outline,solid',
|
|
228
|
-
'--default-variant',
|
|
229
|
-
'outline',
|
|
230
|
-
]);
|
|
231
|
-
expect(code).toBe(0);
|
|
232
|
-
const data = dataOf('glyphs');
|
|
233
|
-
expect(data.variants).toEqual(['outline', 'solid']);
|
|
234
|
-
expect(data.default).toEqual({variant: 'outline'});
|
|
235
|
-
expect(body.data.files).toContain('icon-sets/glyphs/LICENSE');
|
|
236
|
-
// No TypeScript here: the receipt says the strict check needs one.
|
|
237
|
-
expect(body.data.notes.join(' ')).toContain('npm install -D typescript@6');
|
|
238
|
-
expect(
|
|
239
|
-
fs.readFileSync(
|
|
240
|
-
path.join(pkg, 'icon-sets', 'glyphs', 'LICENSE'),
|
|
241
|
-
'utf-8',
|
|
242
|
-
),
|
|
243
|
-
).toBe('MIT License\n');
|
|
244
|
-
expect(
|
|
245
|
-
fs.readFileSync(
|
|
246
|
-
path.join(pkg, 'icon-sets', 'glyphs', 'glyphs.doc.mjs'),
|
|
247
|
-
'utf-8',
|
|
248
|
-
),
|
|
249
|
-
).toContain("license: 'ISC'");
|
|
250
|
-
const check = JSON.stringify(
|
|
251
|
-
JSON.parse(
|
|
252
|
-
(await runCli(['integration', 'check', '--json'], pkg)).stdout,
|
|
253
|
-
),
|
|
254
|
-
);
|
|
255
|
-
expect(check).not.toContain('icon_license_notice_missing');
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('refuses a --default-variant that is not a variant, and --default-variant without --variants', async () => {
|
|
259
|
-
const bad = await json([
|
|
260
|
-
'experimental',
|
|
261
|
-
'icon',
|
|
262
|
-
'new-set',
|
|
263
|
-
'glyphs',
|
|
264
|
-
'--variants',
|
|
265
|
-
'outline,solid',
|
|
266
|
-
'--default-variant',
|
|
267
|
-
'mini',
|
|
268
|
-
]);
|
|
269
|
-
expect(bad.code).toBe(1);
|
|
270
|
-
expect(bad.body.error).toContain('not one of --variants');
|
|
271
|
-
const lone = await json([
|
|
272
|
-
'experimental',
|
|
273
|
-
'icon',
|
|
274
|
-
'new-set',
|
|
275
|
-
'glyphs',
|
|
276
|
-
'--default-variant',
|
|
277
|
-
'outline',
|
|
278
|
-
]);
|
|
279
|
-
expect(lone.code).toBe(1);
|
|
280
|
-
expect(lone.body.error).toContain('needs --variants');
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('the theme map reads each re-exported icon through an import, so the generated module loads', async () => {
|
|
284
|
-
await json([
|
|
285
|
-
'experimental',
|
|
286
|
-
'icon',
|
|
287
|
-
'new-set',
|
|
288
|
-
'outline',
|
|
289
|
-
'--from',
|
|
290
|
-
'@acme/glyph-library',
|
|
291
|
-
]);
|
|
292
|
-
// `close` is built in, so it lands in the theme map.
|
|
293
|
-
expect(
|
|
294
|
-
(await json(['experimental', 'icon', 'map', 'close', 'cross'])).code,
|
|
295
|
-
).toBe(0);
|
|
296
|
-
const file = path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js');
|
|
297
|
-
const text = fs.readFileSync(file, 'utf-8');
|
|
298
|
-
// A re-export binds no local name: the theme map's import does.
|
|
299
|
-
expect(text).toContain(
|
|
300
|
-
"import {Cross as CrossIcon} from '@acme/glyph-library';",
|
|
301
|
-
);
|
|
302
|
-
expect(text).toContain(
|
|
303
|
-
"export {Cross as CrossIcon} from '@acme/glyph-library';",
|
|
304
|
-
);
|
|
305
|
-
expect(text).toContain('close: createElement(CrossIcon,');
|
|
306
|
-
const check = JSON.stringify(
|
|
307
|
-
JSON.parse(
|
|
308
|
-
(await runCli(['integration', 'check', '--json'], pkg)).stdout,
|
|
309
|
-
),
|
|
310
|
-
);
|
|
311
|
-
expect(check).not.toContain('icon_theme_map_mismatch');
|
|
312
|
-
expect(check).not.toContain('icon_module_invalid');
|
|
313
|
-
|
|
314
|
-
// The module loads and the theme map draws the exported component.
|
|
315
|
-
const react = path.dirname(
|
|
316
|
-
createRequire(import.meta.url).resolve('react/package.json'),
|
|
317
|
-
);
|
|
318
|
-
fs.symlinkSync(react, path.join(pkg, 'node_modules', 'react'), 'dir');
|
|
319
|
-
const mod = await import(pathToFileURL(file).href);
|
|
320
|
-
expect(mod.themeIcons.close.type).toBe(mod.CrossIcon);
|
|
321
|
-
|
|
322
|
-
// Remapping drops the import the theme map no longer reads.
|
|
323
|
-
await json(['experimental', 'icon', 'map', 'close', 'bin']);
|
|
324
|
-
const remapped = fs.readFileSync(file, 'utf-8');
|
|
325
|
-
expect(remapped).not.toContain('import {Cross as CrossIcon}');
|
|
326
|
-
expect(remapped).toContain("import {BinIcon} from '@acme/glyph-library';");
|
|
327
|
-
}, 60_000);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
describe('icon add', () => {
|
|
331
|
-
beforeEach(async () => {
|
|
332
|
-
await runCli(['experimental', 'icon', 'new-set', 'outline'], pkg);
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('lists the definitions that fit an export, and writes nothing', async () => {
|
|
336
|
-
const {code, body} = await json([
|
|
337
|
-
'experimental',
|
|
338
|
-
'icon',
|
|
339
|
-
'add',
|
|
340
|
-
'Bin',
|
|
341
|
-
'--from',
|
|
342
|
-
'@acme/glyph-library',
|
|
343
|
-
]);
|
|
344
|
-
expect(code).toBe(0);
|
|
345
|
-
expect(body.type).toBe('icon.definitionMatches');
|
|
346
|
-
expect(body.data.matches[0]).toMatchObject({
|
|
347
|
-
name: 'delete',
|
|
348
|
-
source: 'astryx',
|
|
349
|
-
command:
|
|
350
|
-
'astryx experimental icon add Bin --from @acme/glyph-library --definition delete',
|
|
351
|
-
});
|
|
352
|
-
expect(dataOf('outline').icons).toEqual([]);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('adds the icon as <Name>Icon through the generated module, maps it, and is idempotent', async () => {
|
|
356
|
-
const args = [
|
|
357
|
-
'experimental',
|
|
358
|
-
'icon',
|
|
359
|
-
'add',
|
|
360
|
-
'Bin',
|
|
361
|
-
'--from',
|
|
362
|
-
'@acme/glyph-library',
|
|
363
|
-
'--definition',
|
|
364
|
-
'delete',
|
|
365
|
-
];
|
|
366
|
-
const first = await json(args);
|
|
367
|
-
expect(first.code).toBe(0);
|
|
368
|
-
expect(first.body.data).toMatchObject({
|
|
369
|
-
icon: {id: 'bin', export: 'BinIcon', module: '@acme/icons'},
|
|
370
|
-
definition: 'delete',
|
|
371
|
-
changed: true,
|
|
372
|
-
});
|
|
373
|
-
// The entry is not wired yet: the note names the line, and the entry
|
|
374
|
-
// stays the author's.
|
|
375
|
-
expect(first.body.data.note).toBe(
|
|
376
|
-
"Add `export * from './icon-sets/outline/outline.generated.js';` to index.js, so the icons import from @acme/icons.",
|
|
377
|
-
);
|
|
378
|
-
expect(fs.readFileSync(path.join(pkg, 'index.js'), 'utf-8')).toBe(
|
|
379
|
-
'export {};\n',
|
|
380
|
-
);
|
|
381
|
-
const data = dataOf('outline');
|
|
382
|
-
expect(data.map).toEqual({delete: 'bin'});
|
|
383
|
-
expect(data.icons[0]).toMatchObject({id: 'bin', export: 'BinIcon'});
|
|
384
|
-
// Only its own words: the definition's words are matched, not copied.
|
|
385
|
-
expect(data.icons[0].words).toEqual(['bin']);
|
|
386
|
-
expect(data.icons[0]).not.toHaveProperty('module');
|
|
387
|
-
const again = await json(args);
|
|
388
|
-
expect(again.body.data.changed).toBe(false);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
it('adds a declared variant of an existing icon with --variant, refusing one the set does not declare', async () => {
|
|
392
|
-
await json([
|
|
393
|
-
'experimental',
|
|
394
|
-
'icon',
|
|
395
|
-
'add',
|
|
396
|
-
'Bin',
|
|
397
|
-
'--from',
|
|
398
|
-
'@acme/glyph-library',
|
|
399
|
-
'--definition',
|
|
400
|
-
'delete',
|
|
401
|
-
]);
|
|
402
|
-
const args = [
|
|
403
|
-
'experimental',
|
|
404
|
-
'icon',
|
|
405
|
-
'add',
|
|
406
|
-
'Cross',
|
|
407
|
-
'--from',
|
|
408
|
-
'@acme/glyph-library',
|
|
409
|
-
'--id',
|
|
410
|
-
'bin',
|
|
411
|
-
'--variant',
|
|
412
|
-
'solid',
|
|
413
|
-
];
|
|
414
|
-
const before = dataOf('outline');
|
|
415
|
-
const refused = await json(args);
|
|
416
|
-
expect(refused.code).toBe(1);
|
|
417
|
-
expect(refused.body.code).toBe('ERR_INVALID_ARGUMENT');
|
|
418
|
-
expect(refused.body.error).toContain('variant "solid" is not in variants');
|
|
419
|
-
expect(refused.body.error).toContain('Declare it in "variants"');
|
|
420
|
-
expect(dataOf('outline')).toEqual(before);
|
|
421
|
-
|
|
422
|
-
const dataPath = path.join(
|
|
423
|
-
pkg,
|
|
424
|
-
'icon-sets',
|
|
425
|
-
'outline',
|
|
426
|
-
'outline.icons.json',
|
|
427
|
-
);
|
|
428
|
-
fs.writeFileSync(
|
|
429
|
-
dataPath,
|
|
430
|
-
JSON.stringify({
|
|
431
|
-
...before,
|
|
432
|
-
variants: ['outline', 'solid'],
|
|
433
|
-
default: {variant: 'outline'},
|
|
434
|
-
}),
|
|
435
|
-
);
|
|
436
|
-
const added = await json(args);
|
|
437
|
-
expect(added.code).toBe(0);
|
|
438
|
-
expect(added.body.data).toMatchObject({
|
|
439
|
-
icon: {id: 'bin', export: 'BinSolidIcon'},
|
|
440
|
-
variant: 'solid',
|
|
441
|
-
changed: true,
|
|
442
|
-
});
|
|
443
|
-
const data = dataOf('outline');
|
|
444
|
-
expect(Object.keys(data)).toContain('variants');
|
|
445
|
-
expect(data.icons[0].variants).toEqual([
|
|
446
|
-
{variant: 'solid', export: 'BinSolidIcon'},
|
|
447
|
-
]);
|
|
448
|
-
expect(
|
|
449
|
-
fs.readFileSync(
|
|
450
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
451
|
-
'utf-8',
|
|
452
|
-
),
|
|
453
|
-
).toContain("export {Cross as BinSolidIcon} from '@acme/glyph-library';");
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
it("adds the set's own definition with --new-definition, refusing one Astryx has", async () => {
|
|
457
|
-
const added = await json([
|
|
458
|
-
'experimental',
|
|
459
|
-
'icon',
|
|
460
|
-
'add',
|
|
461
|
-
'Cross',
|
|
462
|
-
'--from',
|
|
463
|
-
'@acme/glyph-library',
|
|
464
|
-
'--new-definition',
|
|
465
|
-
'crossOut',
|
|
466
|
-
'--description',
|
|
467
|
-
'Cross something out.',
|
|
468
|
-
'--words',
|
|
469
|
-
'strike,cross',
|
|
470
|
-
]);
|
|
471
|
-
expect(added.code).toBe(0);
|
|
472
|
-
expect(
|
|
473
|
-
fs.existsSync(
|
|
474
|
-
path.join(
|
|
475
|
-
pkg,
|
|
476
|
-
'icon-sets',
|
|
477
|
-
'outline',
|
|
478
|
-
'definitions',
|
|
479
|
-
'crossOut.doc.mjs',
|
|
480
|
-
),
|
|
481
|
-
),
|
|
482
|
-
).toBe(true);
|
|
483
|
-
expect(dataOf('outline').map).toEqual({crossOut: 'cross'});
|
|
484
|
-
expect(
|
|
485
|
-
fs.readFileSync(
|
|
486
|
-
path.join(
|
|
487
|
-
pkg,
|
|
488
|
-
'icon-sets',
|
|
489
|
-
'outline',
|
|
490
|
-
'definitions',
|
|
491
|
-
'crossOut.doc.mjs',
|
|
492
|
-
),
|
|
493
|
-
'utf-8',
|
|
494
|
-
),
|
|
495
|
-
).toContain("words: ['strike', 'cross']");
|
|
496
|
-
const refused = await json([
|
|
497
|
-
'experimental',
|
|
498
|
-
'icon',
|
|
499
|
-
'add',
|
|
500
|
-
'Cross',
|
|
501
|
-
'--from',
|
|
502
|
-
'@acme/glyph-library',
|
|
503
|
-
'--new-definition',
|
|
504
|
-
'close',
|
|
505
|
-
'--description',
|
|
506
|
-
'x',
|
|
507
|
-
'--words',
|
|
508
|
-
'x',
|
|
509
|
-
]);
|
|
510
|
-
expect(refused.code).toBe(1);
|
|
511
|
-
expect(refused.body.suggestions).toContainEqual(
|
|
512
|
-
expect.objectContaining({name: '--definition close'}),
|
|
513
|
-
);
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it('--new-definition that cannot write its definition leaves the generated module, its types, and the set data unchanged', async () => {
|
|
517
|
-
const set = path.join(pkg, 'icon-sets', 'outline');
|
|
518
|
-
const first = await json([
|
|
519
|
-
'experimental',
|
|
520
|
-
'icon',
|
|
521
|
-
'add',
|
|
522
|
-
'Bin',
|
|
523
|
-
'--from',
|
|
524
|
-
'@acme/glyph-library',
|
|
525
|
-
'--definition',
|
|
526
|
-
'delete',
|
|
527
|
-
]);
|
|
528
|
-
expect(first.code).toBe(0);
|
|
529
|
-
const files = ['outline.generated.js', 'outline.generated.d.ts'].map(name =>
|
|
530
|
-
path.join(set, name),
|
|
531
|
-
);
|
|
532
|
-
files.push(path.join(set, 'outline.icons.json'));
|
|
533
|
-
const before = files.map(file => fs.readFileSync(file, 'utf-8'));
|
|
534
|
-
// A file where the definitions folder belongs: the definition write fails.
|
|
535
|
-
fs.rmSync(path.join(set, 'definitions'), {recursive: true, force: true});
|
|
536
|
-
fs.writeFileSync(path.join(set, 'definitions'), 'not a folder\n');
|
|
537
|
-
const failed = await json([
|
|
538
|
-
'experimental',
|
|
539
|
-
'icon',
|
|
540
|
-
'add',
|
|
541
|
-
'Cross',
|
|
542
|
-
'--from',
|
|
543
|
-
'@acme/glyph-library',
|
|
544
|
-
'--new-definition',
|
|
545
|
-
'crossOut',
|
|
546
|
-
'--description',
|
|
547
|
-
'Cross something out.',
|
|
548
|
-
'--words',
|
|
549
|
-
'strike,cross',
|
|
550
|
-
]);
|
|
551
|
-
expect(failed.code).toBe(1);
|
|
552
|
-
expect(files.map(file => fs.readFileSync(file, 'utf-8'))).toEqual(before);
|
|
553
|
-
expect(fs.readFileSync(path.join(set, 'definitions'), 'utf-8')).toBe(
|
|
554
|
-
'not a folder\n',
|
|
555
|
-
);
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
it('refuses an export the module lacks, with close names, and an unknown definition', async () => {
|
|
559
|
-
const missing = await json([
|
|
560
|
-
'experimental',
|
|
561
|
-
'icon',
|
|
562
|
-
'add',
|
|
563
|
-
'Bim',
|
|
564
|
-
'--from',
|
|
565
|
-
'@acme/glyph-library',
|
|
566
|
-
'--definition',
|
|
567
|
-
'delete',
|
|
568
|
-
]);
|
|
569
|
-
expect(missing.code).toBe(1);
|
|
570
|
-
expect(
|
|
571
|
-
missing.body.suggestions.map((/** @type {any} */ s) => s.name),
|
|
572
|
-
).toContain('Bin');
|
|
573
|
-
const unknown = await json([
|
|
574
|
-
'experimental',
|
|
575
|
-
'icon',
|
|
576
|
-
'add',
|
|
577
|
-
'Bin',
|
|
578
|
-
'--from',
|
|
579
|
-
'@acme/glyph-library',
|
|
580
|
-
'--definition',
|
|
581
|
-
'trashCan',
|
|
582
|
-
]);
|
|
583
|
-
expect(unknown.code).toBe(1);
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
it('a default export, or a value through the declared adapter', async () => {
|
|
587
|
-
const rocket = await json([
|
|
588
|
-
'experimental',
|
|
589
|
-
'icon',
|
|
590
|
-
'add',
|
|
591
|
-
'Rocket',
|
|
592
|
-
'--from',
|
|
593
|
-
'@acme/glyph-library/rocket',
|
|
594
|
-
'--default',
|
|
595
|
-
'--definition',
|
|
596
|
-
'rocket',
|
|
597
|
-
]);
|
|
598
|
-
expect(rocket.code).toBe(0);
|
|
599
|
-
const refused = await json([
|
|
600
|
-
'experimental',
|
|
601
|
-
'icon',
|
|
602
|
-
'add',
|
|
603
|
-
'glyphData',
|
|
604
|
-
'--from',
|
|
605
|
-
'@acme/glyph-library',
|
|
606
|
-
'--definition',
|
|
607
|
-
'activity',
|
|
608
|
-
]);
|
|
609
|
-
expect(refused.code).toBe(1);
|
|
610
|
-
expect(refused.body.error).toContain('adapter');
|
|
611
|
-
|
|
612
|
-
const dataFile = path.join(
|
|
613
|
-
pkg,
|
|
614
|
-
'icon-sets',
|
|
615
|
-
'outline',
|
|
616
|
-
'outline.icons.json',
|
|
617
|
-
);
|
|
618
|
-
const data = JSON.parse(fs.readFileSync(dataFile, 'utf-8'));
|
|
619
|
-
data.adapter = {module: './src/adapt.js', export: 'adapt'};
|
|
620
|
-
fs.writeFileSync(dataFile, JSON.stringify(data, null, 2));
|
|
621
|
-
fs.mkdirSync(path.join(pkg, 'src'));
|
|
622
|
-
fs.writeFileSync(
|
|
623
|
-
path.join(pkg, 'src', 'adapt.js'),
|
|
624
|
-
'export function adapt(data) { return () => null; }\n',
|
|
625
|
-
);
|
|
626
|
-
const adapted = await json([
|
|
627
|
-
'experimental',
|
|
628
|
-
'icon',
|
|
629
|
-
'add',
|
|
630
|
-
'glyphData',
|
|
631
|
-
'--from',
|
|
632
|
-
'@acme/glyph-library',
|
|
633
|
-
'--definition',
|
|
634
|
-
'activity',
|
|
635
|
-
]);
|
|
636
|
-
expect(adapted.code).toBe(0);
|
|
637
|
-
expect(adapted.body.data.icon.export).toBe('GlyphDataIcon');
|
|
638
|
-
const generated = fs.readFileSync(
|
|
639
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
640
|
-
'utf-8',
|
|
641
|
-
);
|
|
642
|
-
expect(generated).toContain(
|
|
643
|
-
"import {adapt as adaptIcon} from '../../src/adapt.js';",
|
|
644
|
-
);
|
|
645
|
-
expect(generated).toContain(
|
|
646
|
-
'export const GlyphDataIcon = adaptIcon(GlyphDataIconSource);',
|
|
647
|
-
);
|
|
648
|
-
expect(generated).toContain(
|
|
649
|
-
"export {default as RocketIcon} from '@acme/glyph-library/rocket';",
|
|
650
|
-
);
|
|
651
|
-
});
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
describe('experimental icon map and new-definition', () => {
|
|
655
|
-
beforeEach(async () => {
|
|
656
|
-
await runCli(
|
|
657
|
-
[
|
|
658
|
-
'experimental',
|
|
659
|
-
'icon',
|
|
660
|
-
'new-set',
|
|
661
|
-
'outline',
|
|
662
|
-
'--from',
|
|
663
|
-
'@acme/glyph-library',
|
|
664
|
-
],
|
|
665
|
-
pkg,
|
|
666
|
-
);
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
it('maps, remaps, and removes an entry; refuses an unknown definition or icon', async () => {
|
|
670
|
-
const mapped = await json([
|
|
671
|
-
'experimental',
|
|
672
|
-
'icon',
|
|
673
|
-
'map',
|
|
674
|
-
'close',
|
|
675
|
-
'cross',
|
|
676
|
-
]);
|
|
677
|
-
expect(mapped.body.data).toMatchObject({
|
|
678
|
-
definition: 'close',
|
|
679
|
-
icon: 'cross',
|
|
680
|
-
changed: true,
|
|
681
|
-
});
|
|
682
|
-
expect(dataOf('outline').map.close).toBe('cross');
|
|
683
|
-
const removed = await json([
|
|
684
|
-
'experimental',
|
|
685
|
-
'icon',
|
|
686
|
-
'map',
|
|
687
|
-
'close',
|
|
688
|
-
'--remove',
|
|
689
|
-
]);
|
|
690
|
-
expect(removed.body.data).toMatchObject({icon: null, previous: 'cross'});
|
|
691
|
-
expect(dataOf('outline').map).not.toHaveProperty('close');
|
|
692
|
-
const unknown = await json([
|
|
693
|
-
'experimental',
|
|
694
|
-
'icon',
|
|
695
|
-
'map',
|
|
696
|
-
'orbit',
|
|
697
|
-
'cross',
|
|
698
|
-
]);
|
|
699
|
-
expect(unknown.code).toBe(1);
|
|
700
|
-
expect(unknown.body.suggestions).toContainEqual(
|
|
701
|
-
expect.objectContaining({
|
|
702
|
-
name: 'astryx experimental icon new-definition orbit --set outline',
|
|
703
|
-
}),
|
|
704
|
-
);
|
|
705
|
-
const noIcon = await json([
|
|
706
|
-
'experimental',
|
|
707
|
-
'icon',
|
|
708
|
-
'map',
|
|
709
|
-
'close',
|
|
710
|
-
'crosss',
|
|
711
|
-
]);
|
|
712
|
-
expect(noIcon.code).toBe(1);
|
|
713
|
-
expect(noIcon.body.suggestions).toContainEqual(
|
|
714
|
-
expect.objectContaining({name: 'cross'}),
|
|
715
|
-
);
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
it("adds the set's own definition, mapped with --icon", async () => {
|
|
719
|
-
const {code, body} = await json([
|
|
720
|
-
'experimental',
|
|
721
|
-
'icon',
|
|
722
|
-
'new-definition',
|
|
723
|
-
'crossOut',
|
|
724
|
-
'--description',
|
|
725
|
-
'Cross something out.',
|
|
726
|
-
'--words',
|
|
727
|
-
'strike,cross',
|
|
728
|
-
'--icon',
|
|
729
|
-
'cross',
|
|
730
|
-
]);
|
|
731
|
-
expect(code).toBe(0);
|
|
732
|
-
expect(body.data).toMatchObject({
|
|
733
|
-
kind: 'icon-definition',
|
|
734
|
-
name: 'crossOut',
|
|
735
|
-
});
|
|
736
|
-
expect(dataOf('outline').map.crossOut).toBe('cross');
|
|
737
|
-
const again = await json([
|
|
738
|
-
'experimental',
|
|
739
|
-
'icon',
|
|
740
|
-
'new-definition',
|
|
741
|
-
'crossOut',
|
|
742
|
-
'--description',
|
|
743
|
-
'x',
|
|
744
|
-
'--words',
|
|
745
|
-
'x',
|
|
746
|
-
]);
|
|
747
|
-
expect(again.code).toBe(1);
|
|
748
|
-
expect(again.body.code).toBe('ERR_FILE_EXISTS');
|
|
749
|
-
});
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
describe('experimental icon use', () => {
|
|
753
|
-
it("writes the project's experimental.iconSet, creating astryx.config.mjs, and refuses a set that is not installed", async () => {
|
|
754
|
-
const app = writeIconSetProject(tmp);
|
|
755
|
-
const used = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
756
|
-
expect(used.code).toBe(0);
|
|
757
|
-
expect(used.body.data).toMatchObject({
|
|
758
|
-
iconSet: 'glyphs',
|
|
759
|
-
set: '@acme/glyphs/glyphs',
|
|
760
|
-
created: true,
|
|
761
|
-
changed: true,
|
|
762
|
-
});
|
|
763
|
-
expect(
|
|
764
|
-
fs.readFileSync(path.join(app, 'astryx.config.mjs'), 'utf-8'),
|
|
765
|
-
).toMatch(/experimental: \{\s*iconSet: 'glyphs',?\s*\}/);
|
|
766
|
-
const again = await json(
|
|
767
|
-
['experimental', 'icon', 'use', '@acme/glyphs/glyphs'],
|
|
768
|
-
app,
|
|
769
|
-
);
|
|
770
|
-
expect(again.body.data).toMatchObject({
|
|
771
|
-
previous: 'glyphs',
|
|
772
|
-
changed: true,
|
|
773
|
-
created: false,
|
|
774
|
-
});
|
|
775
|
-
const missing = await json(['experimental', 'icon', 'use', 'glyps'], app);
|
|
776
|
-
expect(missing.code).toBe(1);
|
|
777
|
-
expect(missing.body.suggestions).toContainEqual(
|
|
778
|
-
expect.objectContaining({name: 'glyphs'}),
|
|
779
|
-
);
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
it('warns in the receipt when the project may run a CLI that refuses experimental.iconSet', async () => {
|
|
783
|
-
const app = writeIconSetProject(tmp);
|
|
784
|
-
const pkgFile = path.join(app, 'package.json');
|
|
785
|
-
const pkgJson = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
|
|
786
|
-
// No CLI range declared: nothing says which CLI it runs.
|
|
787
|
-
const none = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
788
|
-
expect(none.body.data).not.toHaveProperty('warning');
|
|
789
|
-
pkgJson.devDependencies = {'@astryxdesign/cli': '^0.7.0'};
|
|
790
|
-
fs.writeFileSync(pkgFile, JSON.stringify(pkgJson));
|
|
791
|
-
const old = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
792
|
-
expect(old.code).toBe(0);
|
|
793
|
-
expect(old.body.data.warning).toContain(
|
|
794
|
-
'range "^0.7.0" (devDependencies) admits a release before 0.7.4',
|
|
795
|
-
);
|
|
796
|
-
expect(old.body.data.warning).toContain('"Unrecognized key"');
|
|
797
|
-
expect(old.body.data.warning).toContain(
|
|
798
|
-
'commands that load the project configuration, such as `doctor` and `discover`, fail there',
|
|
799
|
-
);
|
|
800
|
-
expect(old.body.data.warning).not.toContain('every command');
|
|
801
|
-
const text = await runCli(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
802
|
-
expect(text.stdout).toContain(
|
|
803
|
-
"[warn] The project's @astryxdesign/cli range",
|
|
804
|
-
);
|
|
805
|
-
// Published 0.7.3 still refuses the key.
|
|
806
|
-
pkgJson.devDependencies = {'@astryxdesign/cli': '^0.7.3'};
|
|
807
|
-
fs.writeFileSync(pkgFile, JSON.stringify(pkgJson));
|
|
808
|
-
const previous = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
809
|
-
expect(previous.body.data.warning).toContain(
|
|
810
|
-
'range "^0.7.3" (devDependencies) admits a release before 0.7.4',
|
|
811
|
-
);
|
|
812
|
-
pkgJson.devDependencies = {'@astryxdesign/cli': '^0.7.4'};
|
|
813
|
-
fs.writeFileSync(pkgFile, JSON.stringify(pkgJson));
|
|
814
|
-
const current = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
815
|
-
expect(current.body.data).not.toHaveProperty('warning');
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
it('writes a plain existing config, keeping its other fields', async () => {
|
|
819
|
-
const app = writeIconSetProject(tmp);
|
|
820
|
-
const config = path.join(app, 'astryx.config.mjs');
|
|
821
|
-
fs.writeFileSync(config, 'export default {\n integrations: [],\n};\n');
|
|
822
|
-
const used = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
823
|
-
expect(used.code).toBe(0);
|
|
824
|
-
expect(used.body.data).toMatchObject({created: false, changed: true});
|
|
825
|
-
const written = fs.readFileSync(config, 'utf-8');
|
|
826
|
-
expect(written).toContain('integrations: []');
|
|
827
|
-
expect(written).toMatch(/iconSet: 'glyphs'/);
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
it('refuses a config reached through a symbolic link, leaving its target untouched', async () => {
|
|
831
|
-
const app = writeIconSetProject(tmp);
|
|
832
|
-
const target = path.join(tmp, 'shared.config.mjs');
|
|
833
|
-
const before = 'export default {\n integrations: [],\n};\n';
|
|
834
|
-
fs.writeFileSync(target, before);
|
|
835
|
-
fs.symlinkSync(target, path.join(app, 'astryx.config.mjs'));
|
|
836
|
-
const refused = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
837
|
-
expect(refused.code).toBe(1);
|
|
838
|
-
expect(refused.body.code).toBe('ERR_CODEMOD_PROTECTED');
|
|
839
|
-
expect(refused.body.error).toContain('symbolic link at astryx.config.mjs');
|
|
840
|
-
expect(fs.readFileSync(target, 'utf-8')).toBe(before);
|
|
841
|
-
expect(
|
|
842
|
-
fs.lstatSync(path.join(app, 'astryx.config.mjs')).isSymbolicLink(),
|
|
843
|
-
).toBe(true);
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
it('refuses a generated config, naming the marker that protects it', async () => {
|
|
847
|
-
const app = writeIconSetProject(tmp);
|
|
848
|
-
const config = path.join(app, 'astryx.config.mjs');
|
|
849
|
-
const before = '// @generated\nexport default {\n integrations: [],\n};\n';
|
|
850
|
-
fs.writeFileSync(config, before);
|
|
851
|
-
const refused = await json(['experimental', 'icon', 'use', 'glyphs'], app);
|
|
852
|
-
expect(refused.code).toBe(1);
|
|
853
|
-
expect(refused.body.code).toBe('ERR_CODEMOD_PROTECTED');
|
|
854
|
-
expect(refused.body.error).toContain(
|
|
855
|
-
'@generated in the leading comment block',
|
|
856
|
-
);
|
|
857
|
-
expect(fs.readFileSync(config, 'utf-8')).toBe(before);
|
|
858
|
-
});
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
describe('a library of icon data, through the adapter', () => {
|
|
862
|
-
beforeEach(() => {
|
|
863
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-data');
|
|
864
|
-
fs.mkdirSync(lib, {recursive: true});
|
|
865
|
-
fs.writeFileSync(
|
|
866
|
-
path.join(lib, 'package.json'),
|
|
867
|
-
JSON.stringify({
|
|
868
|
-
name: '@acme/glyph-data',
|
|
869
|
-
version: '1.0.0',
|
|
870
|
-
type: 'module',
|
|
871
|
-
exports: {'.': './index.js'},
|
|
872
|
-
}),
|
|
873
|
-
);
|
|
874
|
-
fs.writeFileSync(
|
|
875
|
-
path.join(lib, 'index.js'),
|
|
876
|
-
[
|
|
877
|
-
"export const glyphEye = {path: 'M1 1'};",
|
|
878
|
-
"export const glyphEyeOff = {path: 'M1 2'};",
|
|
879
|
-
"export const glyphTrash = {path: 'M2 2'};",
|
|
880
|
-
"export const glyphX = {path: 'M3 3'};",
|
|
881
|
-
'',
|
|
882
|
-
].join('\n'),
|
|
883
|
-
);
|
|
884
|
-
fs.mkdirSync(path.join(pkg, 'src'));
|
|
885
|
-
fs.writeFileSync(
|
|
886
|
-
path.join(pkg, 'src', 'adapt.js'),
|
|
887
|
-
'export function adapt(data) { return () => null; }\n',
|
|
888
|
-
);
|
|
889
|
-
fs.writeFileSync(
|
|
890
|
-
path.join(pkg, 'index.js'),
|
|
891
|
-
"export * from './icon-sets/outline/outline.generated.js';\n",
|
|
892
|
-
);
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
/** Declare the adapter in the set's data file. */
|
|
896
|
-
const declareAdapter = () => {
|
|
897
|
-
const file = path.join(pkg, 'icon-sets', 'outline', 'outline.icons.json');
|
|
898
|
-
const data = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
899
|
-
data.adapter = {module: './src/adapt.js', export: 'adapt'};
|
|
900
|
-
fs.writeFileSync(file, JSON.stringify(data, null, 2));
|
|
901
|
-
};
|
|
902
|
-
const generated = () =>
|
|
903
|
-
fs.readFileSync(
|
|
904
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
905
|
-
'utf-8',
|
|
906
|
-
);
|
|
907
|
-
|
|
908
|
-
it('the bulk wrap finds nothing until the adapter is declared, then wraps every data export without the shared prefix', async () => {
|
|
909
|
-
const before = await json([
|
|
910
|
-
'experimental',
|
|
911
|
-
'icon',
|
|
912
|
-
'new-set',
|
|
913
|
-
'outline',
|
|
914
|
-
'--from',
|
|
915
|
-
'@acme/glyph-data',
|
|
916
|
-
]);
|
|
917
|
-
expect(before.code).toBe(1);
|
|
918
|
-
expect(before.body.error).toContain('adapter');
|
|
919
|
-
await runCli(['experimental', 'icon', 'new-set', 'outline'], pkg);
|
|
920
|
-
declareAdapter();
|
|
921
|
-
const wrapped = await json([
|
|
922
|
-
'experimental',
|
|
923
|
-
'icon',
|
|
924
|
-
'new-set',
|
|
925
|
-
'outline',
|
|
926
|
-
'--from',
|
|
927
|
-
'@acme/glyph-data',
|
|
928
|
-
]);
|
|
929
|
-
expect(wrapped.code).toBe(0);
|
|
930
|
-
expect(
|
|
931
|
-
dataOf('outline').icons.map((/** @type {any} */ i) => [i.id, i.export]),
|
|
932
|
-
).toEqual([
|
|
933
|
-
['eye', 'EyeIcon'],
|
|
934
|
-
['eye-off', 'EyeOffIcon'],
|
|
935
|
-
['trash', 'TrashIcon'],
|
|
936
|
-
['x', 'XIcon'],
|
|
937
|
-
]);
|
|
938
|
-
expect(generated()).toContain(
|
|
939
|
-
'export const EyeIcon = adaptIcon(EyeIconSource);',
|
|
940
|
-
);
|
|
941
|
-
expect(generated()).toContain(
|
|
942
|
-
"import {glyphEye as EyeIconSource} from '@acme/glyph-data';",
|
|
943
|
-
);
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
it('icon add appended twice writes the adapter import once, and the module still parses', async () => {
|
|
947
|
-
await runCli(['experimental', 'icon', 'new-set', 'outline'], pkg);
|
|
948
|
-
declareAdapter();
|
|
949
|
-
for (const [name, definition] of [
|
|
950
|
-
['glyphTrash', 'delete'],
|
|
951
|
-
['glyphEye', 'view'],
|
|
952
|
-
['glyphX', 'close'],
|
|
953
|
-
]) {
|
|
954
|
-
const added = await json([
|
|
955
|
-
'experimental',
|
|
956
|
-
'icon',
|
|
957
|
-
'add',
|
|
958
|
-
name,
|
|
959
|
-
'--from',
|
|
960
|
-
'@acme/glyph-data',
|
|
961
|
-
...(definition === 'view'
|
|
962
|
-
? [
|
|
963
|
-
'--new-definition',
|
|
964
|
-
'peek',
|
|
965
|
-
'--description',
|
|
966
|
-
'Peek.',
|
|
967
|
-
'--words',
|
|
968
|
-
'peek',
|
|
969
|
-
]
|
|
970
|
-
: ['--definition', definition]),
|
|
971
|
-
]);
|
|
972
|
-
expect(added.code, name).toBe(0);
|
|
973
|
-
}
|
|
974
|
-
const text = generated();
|
|
975
|
-
expect(text.match(/as adaptIcon/gu)).toHaveLength(1);
|
|
976
|
-
// The library prefix is left out of the id and the export name.
|
|
977
|
-
expect(dataOf('outline').map).toMatchObject({delete: 'trash', close: 'x'});
|
|
978
|
-
expect(text).toContain(
|
|
979
|
-
'export const TrashIcon = adaptIcon(TrashIconSource);',
|
|
980
|
-
);
|
|
981
|
-
// A built-in mapping lands in the theme map, and the types follow.
|
|
982
|
-
expect(text).toContain(
|
|
983
|
-
"close: createElement(XIcon, {'aria-hidden': true, 'width': '1em', 'height': '1em'}),",
|
|
984
|
-
);
|
|
985
|
-
const types = fs.readFileSync(
|
|
986
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.d.ts'),
|
|
987
|
-
'utf-8',
|
|
988
|
-
);
|
|
989
|
-
expect(types).toContain(
|
|
990
|
-
'export declare const TrashIcon: ComponentType<SVGProps<SVGSVGElement>>;',
|
|
991
|
-
);
|
|
992
|
-
expect(types).toContain(
|
|
993
|
-
'export declare const themeIcons: {readonly close: ReactElement};',
|
|
994
|
-
);
|
|
995
|
-
// icon map rewrites the theme map.
|
|
996
|
-
await json(['experimental', 'icon', 'map', 'close', 'trash']);
|
|
997
|
-
expect(generated()).toContain('close: createElement(TrashIcon,');
|
|
998
|
-
// Integration check reads it all: no parse error, no missing export, no
|
|
999
|
-
// theme-map or types mismatch.
|
|
1000
|
-
const check = await runCli(['integration', 'check', '--json'], pkg);
|
|
1001
|
-
const codes = JSON.stringify(JSON.parse(check.stdout));
|
|
1002
|
-
for (const code of [
|
|
1003
|
-
'icon_module_invalid',
|
|
1004
|
-
'icon_export_missing',
|
|
1005
|
-
'icon_theme_map_mismatch',
|
|
1006
|
-
'icon_generated_types_mismatch',
|
|
1007
|
-
]) {
|
|
1008
|
-
expect(codes, code).not.toContain(code);
|
|
1009
|
-
}
|
|
1010
|
-
// The optional definitions left unmapped are listed, never issues.
|
|
1011
|
-
expect(codes).not.toContain('"severity":"info"');
|
|
1012
|
-
const printed = await runCli(['integration', 'check'], pkg);
|
|
1013
|
-
expect(printed.stdout).toContain('Unmapped icon definitions (optional)');
|
|
1014
|
-
expect(printed.stdout).toContain(
|
|
1015
|
-
'Mapping these is optional and never fails',
|
|
1016
|
-
);
|
|
1017
|
-
}, 60_000);
|
|
1018
|
-
});
|
|
1019
|
-
|
|
1020
|
-
describe('the library prefix ignores constants', () => {
|
|
1021
|
-
beforeEach(() => {
|
|
1022
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-data');
|
|
1023
|
-
fs.mkdirSync(lib, {recursive: true});
|
|
1024
|
-
fs.writeFileSync(
|
|
1025
|
-
path.join(lib, 'package.json'),
|
|
1026
|
-
JSON.stringify({
|
|
1027
|
-
name: '@acme/glyph-data',
|
|
1028
|
-
version: '1.0.0',
|
|
1029
|
-
type: 'module',
|
|
1030
|
-
exports: {'.': './index.js'},
|
|
1031
|
-
}),
|
|
1032
|
-
);
|
|
1033
|
-
fs.writeFileSync(
|
|
1034
|
-
path.join(lib, 'index.js'),
|
|
1035
|
-
[
|
|
1036
|
-
"export const glyphEye = {path: 'M1 1'};",
|
|
1037
|
-
"export const glyphTrash = {path: 'M2 2'};",
|
|
1038
|
-
"export const glyphX = {path: 'M3 3'};",
|
|
1039
|
-
"export const README = 'See the docs.';",
|
|
1040
|
-
"export const notes = 'Some notes.';",
|
|
1041
|
-
'export const count = 5;',
|
|
1042
|
-
"export const meta = {kind: 'meta'};",
|
|
1043
|
-
'',
|
|
1044
|
-
].join('\n'),
|
|
1045
|
-
);
|
|
1046
|
-
fs.mkdirSync(path.join(pkg, 'src'));
|
|
1047
|
-
fs.writeFileSync(
|
|
1048
|
-
path.join(pkg, 'src', 'adapt.js'),
|
|
1049
|
-
'export function adapt(data) { return () => null; }\n',
|
|
1050
|
-
);
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
/** Create the set with an adapter. */
|
|
1054
|
-
const setUp = async () => {
|
|
1055
|
-
await runCli(['experimental', 'icon', 'new-set', 'outline'], pkg);
|
|
1056
|
-
const file = path.join(pkg, 'icon-sets', 'outline', 'outline.icons.json');
|
|
1057
|
-
const data = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
1058
|
-
data.adapter = {module: './src/adapt.js', export: 'adapt'};
|
|
1059
|
-
fs.writeFileSync(file, JSON.stringify(data, null, 2));
|
|
1060
|
-
};
|
|
1061
|
-
const exportsOf = () =>
|
|
1062
|
-
dataOf('outline').icons.map((/** @type {any} */ i) => i.export);
|
|
1063
|
-
const wrap = (/** @type {string[]} */ extra = []) =>
|
|
1064
|
-
json([
|
|
1065
|
-
'experimental',
|
|
1066
|
-
'icon',
|
|
1067
|
-
'new-set',
|
|
1068
|
-
'outline',
|
|
1069
|
-
'--from',
|
|
1070
|
-
'@acme/glyph-data',
|
|
1071
|
-
...extra,
|
|
1072
|
-
]);
|
|
1073
|
-
|
|
1074
|
-
it('skips SCREAMING_CASE names, numbers, and stray strings; --exclude drops a non-icon object, and the refresh prunes the old exports', async () => {
|
|
1075
|
-
await setUp();
|
|
1076
|
-
// meta is shaped like an icon, so it keeps the prefix off.
|
|
1077
|
-
expect((await wrap()).code).toBe(0);
|
|
1078
|
-
expect(exportsOf()).toEqual([
|
|
1079
|
-
'GlyphEyeIcon',
|
|
1080
|
-
'GlyphTrashIcon',
|
|
1081
|
-
'GlyphXIcon',
|
|
1082
|
-
'MetaIcon',
|
|
1083
|
-
]);
|
|
1084
|
-
// Excluding meta lets the prefix come off the new ids; each existing icon
|
|
1085
|
-
// is the same icon (the same library export), so it keeps its public
|
|
1086
|
-
// export, and only meta leaves the module.
|
|
1087
|
-
const excluded = await wrap(['--exclude', 'meta']);
|
|
1088
|
-
expect(excluded.code).toBe(0);
|
|
1089
|
-
expect(exportsOf()).toEqual([
|
|
1090
|
-
'GlyphEyeIcon',
|
|
1091
|
-
'GlyphTrashIcon',
|
|
1092
|
-
'GlyphXIcon',
|
|
1093
|
-
]);
|
|
1094
|
-
expect(dataOf('outline').icons.map((/** @type {any} */ i) => i.id)).toEqual(
|
|
1095
|
-
['eye', 'trash', 'x'],
|
|
1096
|
-
);
|
|
1097
|
-
expect(excluded.body.data.renamed).toEqual([
|
|
1098
|
-
{from: 'glyph-eye', to: 'eye'},
|
|
1099
|
-
{from: 'glyph-trash', to: 'trash'},
|
|
1100
|
-
{from: 'glyph-x', to: 'x'},
|
|
1101
|
-
]);
|
|
1102
|
-
const generated = fs.readFileSync(
|
|
1103
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
1104
|
-
'utf-8',
|
|
1105
|
-
);
|
|
1106
|
-
expect(generated).not.toContain('MetaIcon');
|
|
1107
|
-
expect(generated).not.toContain('README');
|
|
1108
|
-
expect(generated).not.toContain('notes');
|
|
1109
|
-
// icon add reuses the icon the wrap already made for an export, even
|
|
1110
|
-
// though meta keeps its own prefix off.
|
|
1111
|
-
const added = await json([
|
|
1112
|
-
'experimental',
|
|
1113
|
-
'icon',
|
|
1114
|
-
'add',
|
|
1115
|
-
'glyphTrash',
|
|
1116
|
-
'--from',
|
|
1117
|
-
'@acme/glyph-data',
|
|
1118
|
-
'--definition',
|
|
1119
|
-
'delete',
|
|
1120
|
-
]);
|
|
1121
|
-
expect(added.code).toBe(0);
|
|
1122
|
-
expect(added.body.data.icon).toMatchObject({
|
|
1123
|
-
id: 'trash',
|
|
1124
|
-
export: 'GlyphTrashIcon',
|
|
1125
|
-
});
|
|
1126
|
-
expect(exportsOf()).toEqual([
|
|
1127
|
-
'GlyphEyeIcon',
|
|
1128
|
-
'GlyphTrashIcon',
|
|
1129
|
-
'GlyphXIcon',
|
|
1130
|
-
]);
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
it('--exclude needs --from', async () => {
|
|
1134
|
-
const res = await json([
|
|
1135
|
-
'experimental',
|
|
1136
|
-
'icon',
|
|
1137
|
-
'new-set',
|
|
1138
|
-
'outline',
|
|
1139
|
-
'--exclude',
|
|
1140
|
-
'README',
|
|
1141
|
-
]);
|
|
1142
|
-
expect(res.code).toBe(1);
|
|
1143
|
-
expect(res.body.error).toContain('--from');
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
it('a library of SVG strings keeps its strings as icons', async () => {
|
|
1147
|
-
fs.writeFileSync(
|
|
1148
|
-
path.join(pkg, 'node_modules', '@acme', 'glyph-data', 'index.js'),
|
|
1149
|
-
[
|
|
1150
|
-
"export const glyphEye = '<svg/>';",
|
|
1151
|
-
"export const glyphSun = '<svg/>';",
|
|
1152
|
-
"export const VERSION = '1.0.0';",
|
|
1153
|
-
'',
|
|
1154
|
-
].join('\n'),
|
|
1155
|
-
);
|
|
1156
|
-
await setUp();
|
|
1157
|
-
expect((await wrap()).code).toBe(0);
|
|
1158
|
-
expect(exportsOf()).toEqual(['EyeIcon', 'SunIcon']);
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
|
|
1162
|
-
describe('module resolution', () => {
|
|
1163
|
-
it('resolves the library from a set package nested deeper than six folders below node_modules', async () => {
|
|
1164
|
-
const deep = path.join(tmp, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'icons');
|
|
1165
|
-
fs.mkdirSync(path.dirname(deep), {recursive: true});
|
|
1166
|
-
fs.renameSync(pkg, deep);
|
|
1167
|
-
// The library is installed at the top, as a hoisting package manager does.
|
|
1168
|
-
fs.mkdirSync(path.join(tmp, 'node_modules', '@acme'), {recursive: true});
|
|
1169
|
-
fs.renameSync(
|
|
1170
|
-
path.join(deep, 'node_modules', '@acme', 'glyph-library'),
|
|
1171
|
-
path.join(tmp, 'node_modules', '@acme', 'glyph-library'),
|
|
1172
|
-
);
|
|
1173
|
-
pkg = deep;
|
|
1174
|
-
await runCli(['experimental', 'icon', 'new-set', 'outline'], pkg);
|
|
1175
|
-
const added = await json([
|
|
1176
|
-
'experimental',
|
|
1177
|
-
'icon',
|
|
1178
|
-
'add',
|
|
1179
|
-
'Bin',
|
|
1180
|
-
'--from',
|
|
1181
|
-
'@acme/glyph-library',
|
|
1182
|
-
'--definition',
|
|
1183
|
-
'delete',
|
|
1184
|
-
]);
|
|
1185
|
-
expect(added.code).toBe(0);
|
|
1186
|
-
fs.writeFileSync(
|
|
1187
|
-
path.join(pkg, 'index.js'),
|
|
1188
|
-
"export * from './icon-sets/outline/outline.generated.js';\n",
|
|
1189
|
-
);
|
|
1190
|
-
const check = await runCli(['integration', 'check', '--json'], pkg);
|
|
1191
|
-
expect(check.stdout).not.toContain('icon_export_missing');
|
|
1192
|
-
}, 60_000);
|
|
1193
|
-
});
|
|
1194
|
-
|
|
1195
|
-
describe('experimental icon add --variant --all', () => {
|
|
1196
|
-
beforeEach(() => {
|
|
1197
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1198
|
-
const pkgJson = JSON.parse(
|
|
1199
|
-
fs.readFileSync(path.join(lib, 'package.json'), 'utf-8'),
|
|
1200
|
-
);
|
|
1201
|
-
fs.writeFileSync(
|
|
1202
|
-
path.join(lib, 'package.json'),
|
|
1203
|
-
JSON.stringify({
|
|
1204
|
-
...pkgJson,
|
|
1205
|
-
exports: {...pkgJson.exports, './solid': './solid.js'},
|
|
1206
|
-
}),
|
|
1207
|
-
);
|
|
1208
|
-
// The solid module exports the same names; it has no Cross.
|
|
1209
|
-
fs.writeFileSync(
|
|
1210
|
-
path.join(lib, 'solid.js'),
|
|
1211
|
-
'export function BinIcon(props) { return null; }\n',
|
|
1212
|
-
);
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
it('adds the variant for every icon the module exports by the same id, in one run', async () => {
|
|
1216
|
-
expect(
|
|
1217
|
-
(
|
|
1218
|
-
await json([
|
|
1219
|
-
'experimental',
|
|
1220
|
-
'icon',
|
|
1221
|
-
'new-set',
|
|
1222
|
-
'glyphs',
|
|
1223
|
-
'--from',
|
|
1224
|
-
'@acme/glyph-library',
|
|
1225
|
-
'--variants',
|
|
1226
|
-
'outline,solid',
|
|
1227
|
-
])
|
|
1228
|
-
).code,
|
|
1229
|
-
).toBe(0);
|
|
1230
|
-
const {code, body} = await json([
|
|
1231
|
-
'experimental',
|
|
1232
|
-
'icon',
|
|
1233
|
-
'add',
|
|
1234
|
-
'--variant',
|
|
1235
|
-
'solid',
|
|
1236
|
-
'--from',
|
|
1237
|
-
'@acme/glyph-library/solid',
|
|
1238
|
-
'--all',
|
|
1239
|
-
]);
|
|
1240
|
-
expect(code).toBe(0);
|
|
1241
|
-
expect(body.type).toBe('icon.addVariants');
|
|
1242
|
-
expect(body.data).toMatchObject({added: 1, already: 0, missing: ['cross']});
|
|
1243
|
-
const bin = dataOf('glyphs').icons.find(
|
|
1244
|
-
(/** @type {{id: string}} */ each) => each.id === 'bin',
|
|
1245
|
-
);
|
|
1246
|
-
expect(bin.variants).toEqual([{variant: 'solid', export: 'BinSolidIcon'}]);
|
|
1247
|
-
const generated = fs.readFileSync(
|
|
1248
|
-
path.join(pkg, 'icon-sets', 'glyphs', 'glyphs.generated.js'),
|
|
1249
|
-
'utf-8',
|
|
1250
|
-
);
|
|
1251
|
-
expect(generated).toContain(
|
|
1252
|
-
"export {BinIcon as BinSolidIcon} from '@acme/glyph-library/solid';",
|
|
1253
|
-
);
|
|
1254
|
-
// Again: nothing changes.
|
|
1255
|
-
const again = await json([
|
|
1256
|
-
'experimental',
|
|
1257
|
-
'icon',
|
|
1258
|
-
'add',
|
|
1259
|
-
'--variant',
|
|
1260
|
-
'solid',
|
|
1261
|
-
'--from',
|
|
1262
|
-
'@acme/glyph-library/solid',
|
|
1263
|
-
'--all',
|
|
1264
|
-
]);
|
|
1265
|
-
expect(again.body.data).toMatchObject({
|
|
1266
|
-
added: 0,
|
|
1267
|
-
already: 1,
|
|
1268
|
-
changed: false,
|
|
1269
|
-
});
|
|
1270
|
-
});
|
|
1271
|
-
|
|
1272
|
-
it('refuses an undeclared variant, and an export name with --all', async () => {
|
|
1273
|
-
await json([
|
|
1274
|
-
'experimental',
|
|
1275
|
-
'icon',
|
|
1276
|
-
'new-set',
|
|
1277
|
-
'glyphs',
|
|
1278
|
-
'--from',
|
|
1279
|
-
'@acme/glyph-library',
|
|
1280
|
-
]);
|
|
1281
|
-
const undeclared = await json([
|
|
1282
|
-
'experimental',
|
|
1283
|
-
'icon',
|
|
1284
|
-
'add',
|
|
1285
|
-
'--variant',
|
|
1286
|
-
'solid',
|
|
1287
|
-
'--from',
|
|
1288
|
-
'@acme/glyph-library/solid',
|
|
1289
|
-
'--all',
|
|
1290
|
-
]);
|
|
1291
|
-
expect(undeclared.code).toBe(1);
|
|
1292
|
-
expect(undeclared.body.error).toContain('declares no variant "solid"');
|
|
1293
|
-
const named = await json([
|
|
1294
|
-
'experimental',
|
|
1295
|
-
'icon',
|
|
1296
|
-
'add',
|
|
1297
|
-
'BinIcon',
|
|
1298
|
-
'--variant',
|
|
1299
|
-
'solid',
|
|
1300
|
-
'--from',
|
|
1301
|
-
'@acme/glyph-library/solid',
|
|
1302
|
-
'--all',
|
|
1303
|
-
]);
|
|
1304
|
-
expect(named.code).toBe(1);
|
|
1305
|
-
expect(named.body.error).toBe(
|
|
1306
|
-
'--all and an export name cannot be used together',
|
|
1307
|
-
);
|
|
1308
|
-
expect(named.body.code).toBe('ERR_INVALID_OPTION');
|
|
1309
|
-
});
|
|
1310
|
-
});
|
|
1311
|
-
|
|
1312
|
-
describe('experimental icon map --pairs', () => {
|
|
1313
|
-
it('writes many entries in one write, all or none', async () => {
|
|
1314
|
-
await json([
|
|
1315
|
-
'experimental',
|
|
1316
|
-
'icon',
|
|
1317
|
-
'new-set',
|
|
1318
|
-
'outline',
|
|
1319
|
-
'--from',
|
|
1320
|
-
'@acme/glyph-library',
|
|
1321
|
-
]);
|
|
1322
|
-
const bad = await json([
|
|
1323
|
-
'experimental',
|
|
1324
|
-
'icon',
|
|
1325
|
-
'map',
|
|
1326
|
-
'--pairs',
|
|
1327
|
-
'close=cross,delete=nope',
|
|
1328
|
-
]);
|
|
1329
|
-
expect(bad.code).toBe(1);
|
|
1330
|
-
expect(bad.body.error).toContain('no icon "nope"');
|
|
1331
|
-
expect(dataOf('outline').map).toEqual({});
|
|
1332
|
-
const {code, body} = await json([
|
|
1333
|
-
'experimental',
|
|
1334
|
-
'icon',
|
|
1335
|
-
'map',
|
|
1336
|
-
'--pairs',
|
|
1337
|
-
'close=cross,delete=bin',
|
|
1338
|
-
]);
|
|
1339
|
-
expect(code).toBe(0);
|
|
1340
|
-
expect(body.type).toBe('icon.mapMany');
|
|
1341
|
-
expect(body.data.entries).toEqual([
|
|
1342
|
-
{definition: 'close', icon: 'cross', previous: null, changed: true},
|
|
1343
|
-
{definition: 'delete', icon: 'bin', previous: null, changed: true},
|
|
1344
|
-
]);
|
|
1345
|
-
expect(dataOf('outline').map).toEqual({close: 'cross', delete: 'bin'});
|
|
1346
|
-
// The theme map follows: close is built in.
|
|
1347
|
-
expect(
|
|
1348
|
-
fs.readFileSync(
|
|
1349
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
1350
|
-
'utf-8',
|
|
1351
|
-
),
|
|
1352
|
-
).toContain('close: createElement(CrossIcon,');
|
|
1353
|
-
});
|
|
1354
|
-
});
|
|
1355
|
-
|
|
1356
|
-
describe('experimental icon new-set receipt', () => {
|
|
1357
|
-
it('takes --display-name and --description, and suggests icons by name words, never one map already names', async () => {
|
|
1358
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1359
|
-
fs.writeFileSync(
|
|
1360
|
-
path.join(lib, 'icons', 'video.js'),
|
|
1361
|
-
'export const VideoCamera = props => null;\nexport const Camera = props => null;\nexport const Clipboard = props => null;\n',
|
|
1362
|
-
);
|
|
1363
|
-
fs.appendFileSync(
|
|
1364
|
-
path.join(lib, 'index.js'),
|
|
1365
|
-
"export {VideoCamera, Camera, Clipboard} from './icons/video.js';\n",
|
|
1366
|
-
);
|
|
1367
|
-
const {code, body} = await json([
|
|
1368
|
-
'experimental',
|
|
1369
|
-
'icon',
|
|
1370
|
-
'new-set',
|
|
1371
|
-
'outline',
|
|
1372
|
-
'--from',
|
|
1373
|
-
'@acme/glyph-library',
|
|
1374
|
-
'--display-name',
|
|
1375
|
-
'Acme Outline',
|
|
1376
|
-
'--description',
|
|
1377
|
-
'Outline icons from the Acme glyph library.',
|
|
1378
|
-
]);
|
|
1379
|
-
expect(code).toBe(0);
|
|
1380
|
-
const doc = fs.readFileSync(
|
|
1381
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.doc.mjs'),
|
|
1382
|
-
'utf-8',
|
|
1383
|
-
);
|
|
1384
|
-
expect(doc).toContain("displayName: 'Acme Outline'");
|
|
1385
|
-
expect(doc).toContain(
|
|
1386
|
-
"description: 'Outline icons from the Acme glyph library.'",
|
|
1387
|
-
);
|
|
1388
|
-
// `video` gets video-camera (its name's words) before camera (a word);
|
|
1389
|
-
// clipboard is mapped to the clipboard definition, so copy never gets it.
|
|
1390
|
-
const video = body.data.suggestions.filter(
|
|
1391
|
-
(/** @type {{definition: string}} */ each) => each.definition === 'video',
|
|
1392
|
-
);
|
|
1393
|
-
expect(
|
|
1394
|
-
video.map((/** @type {{icon: string}} */ each) => each.icon),
|
|
1395
|
-
).toEqual(['video-camera', 'camera']);
|
|
1396
|
-
expect(dataOf('outline').map).toMatchObject({clipboard: 'clipboard'});
|
|
1397
|
-
expect(
|
|
1398
|
-
body.data.suggestions.some(
|
|
1399
|
-
(/** @type {{icon: string}} */ each) => each.icon === 'clipboard',
|
|
1400
|
-
),
|
|
1401
|
-
).toBe(false);
|
|
1402
|
-
});
|
|
1403
|
-
});
|
|
1404
|
-
|
|
1405
|
-
describe('experimental icon new-set: aliases, providers, exclude, peers', () => {
|
|
1406
|
-
beforeEach(() => {
|
|
1407
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1408
|
-
fs.writeFileSync(
|
|
1409
|
-
path.join(lib, 'icons', 'extra.js'),
|
|
1410
|
-
[
|
|
1411
|
-
'export const Trash = props => null;',
|
|
1412
|
-
'export const PanelLeftClose = props => null;',
|
|
1413
|
-
'export function GlyphProvider(props) { return props.children; }',
|
|
1414
|
-
'export const Meta = props => null;',
|
|
1415
|
-
'',
|
|
1416
|
-
].join('\n'),
|
|
1417
|
-
);
|
|
1418
|
-
fs.appendFileSync(
|
|
1419
|
-
path.join(lib, 'index.js'),
|
|
1420
|
-
"export {Trash, Trash as Trash2, PanelLeftClose, GlyphProvider, Meta} from './icons/extra.js';\n",
|
|
1421
|
-
);
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
it('records other names as words, skips providers, keeps --exclude, and declares peers', async () => {
|
|
1425
|
-
fs.writeFileSync(
|
|
1426
|
-
path.join(pkg, 'package.json'),
|
|
1427
|
-
JSON.stringify({
|
|
1428
|
-
...JSON.parse(fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8')),
|
|
1429
|
-
dependencies: {'@acme/glyph-library': '^2.0.0', react: '^19.0.0'},
|
|
1430
|
-
}),
|
|
1431
|
-
);
|
|
1432
|
-
const first = await json([
|
|
1433
|
-
'experimental',
|
|
1434
|
-
'icon',
|
|
1435
|
-
'new-set',
|
|
1436
|
-
'outline',
|
|
1437
|
-
'--from',
|
|
1438
|
-
'@acme/glyph-library',
|
|
1439
|
-
'--exclude',
|
|
1440
|
-
'Meta',
|
|
1441
|
-
]);
|
|
1442
|
-
expect(first.code).toBe(0);
|
|
1443
|
-
let data = dataOf('outline');
|
|
1444
|
-
const ids = data.icons.map((/** @type {{id: string}} */ each) => each.id);
|
|
1445
|
-
expect(ids).toContain('trash');
|
|
1446
|
-
expect(ids).not.toContain('trash-2');
|
|
1447
|
-
expect(ids).not.toContain('glyph-provider');
|
|
1448
|
-
expect(ids).not.toContain('meta');
|
|
1449
|
-
expect(data.exclude).toEqual(['Meta']);
|
|
1450
|
-
// The receipt names the exports it left out.
|
|
1451
|
-
expect(first.body.data.notes.join(' ')).toMatch(
|
|
1452
|
-
/Left out \d+ exports that are not icons: .*GlyphProvider/u,
|
|
1453
|
-
);
|
|
1454
|
-
expect(
|
|
1455
|
-
data.icons.find((/** @type {{id: string}} */ each) => each.id === 'trash')
|
|
1456
|
-
.words,
|
|
1457
|
-
).toContain('trash-2');
|
|
1458
|
-
// close is never suggested panel-left-close: a suggestion starts with
|
|
1459
|
-
// the definition's name.
|
|
1460
|
-
expect(
|
|
1461
|
-
first.body.data.suggestions.some(
|
|
1462
|
-
(/** @type {{definition: string, icon: string}} */ each) =>
|
|
1463
|
-
each.definition === 'close' && each.icon === 'panel-left-close',
|
|
1464
|
-
),
|
|
1465
|
-
).toBe(false);
|
|
1466
|
-
// Peers: the receipt names the exact JSON to add; package.json keeps its
|
|
1467
|
-
// dependencies as they were (architecture:cli-surface INV16).
|
|
1468
|
-
const manifest = JSON.parse(
|
|
1469
|
-
fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8'),
|
|
1470
|
-
);
|
|
1471
|
-
expect(manifest).not.toHaveProperty('peerDependencies');
|
|
1472
|
-
expect(manifest.dependencies).toEqual({
|
|
1473
|
-
'@acme/glyph-library': '^2.0.0',
|
|
1474
|
-
react: '^19.0.0',
|
|
1475
|
-
});
|
|
1476
|
-
expect(first.body.data.notes).toContainEqual(
|
|
1477
|
-
expect.stringMatching(
|
|
1478
|
-
/^Declare the peers your set needs; add to package\.json "peerDependencies": `\{"react": ">=18", "@types\/react": ">=18", "@astryxdesign\/cli": ">=[^"]+"\}` and to "peerDependenciesMeta": `\{"@types\/react": \{"optional": true\}, "@astryxdesign\/cli": \{"optional": true\}\}`\.$/u,
|
|
1479
|
-
),
|
|
1480
|
-
);
|
|
1481
|
-
|
|
1482
|
-
// A refresh without --exclude still leaves Meta out, and says it refreshed.
|
|
1483
|
-
const again = await runCli(
|
|
1484
|
-
[
|
|
1485
|
-
'experimental',
|
|
1486
|
-
'icon',
|
|
1487
|
-
'new-set',
|
|
1488
|
-
'outline',
|
|
1489
|
-
'--from',
|
|
1490
|
-
'@acme/glyph-library',
|
|
1491
|
-
],
|
|
1492
|
-
pkg,
|
|
1493
|
-
);
|
|
1494
|
-
expect(again.code).toBe(0);
|
|
1495
|
-
expect(again.stdout).toContain('Icon set refreshed');
|
|
1496
|
-
expect(again.stdout).not.toContain('New icon set added');
|
|
1497
|
-
data = dataOf('outline');
|
|
1498
|
-
expect(
|
|
1499
|
-
data.icons.some((/** @type {{id: string}} */ each) => each.id === 'meta'),
|
|
1500
|
-
).toBe(false);
|
|
1501
|
-
|
|
1502
|
-
// map takes the kebab id of a definition and another name of an icon.
|
|
1503
|
-
const mapped = await json([
|
|
1504
|
-
'experimental',
|
|
1505
|
-
'icon',
|
|
1506
|
-
'map',
|
|
1507
|
-
'eye-slash',
|
|
1508
|
-
'cross',
|
|
1509
|
-
]);
|
|
1510
|
-
expect(mapped.code).toBe(0);
|
|
1511
|
-
expect(mapped.body.data).toMatchObject({
|
|
1512
|
-
definition: 'eyeSlash',
|
|
1513
|
-
icon: 'cross',
|
|
1514
|
-
});
|
|
1515
|
-
const alias = await json([
|
|
1516
|
-
'experimental',
|
|
1517
|
-
'icon',
|
|
1518
|
-
'map',
|
|
1519
|
-
'delete',
|
|
1520
|
-
'trash-2',
|
|
1521
|
-
]);
|
|
1522
|
-
expect(alias.code).toBe(0);
|
|
1523
|
-
expect(alias.body.data.icon).toBe('trash');
|
|
1524
|
-
// The same other name as the library exports it.
|
|
1525
|
-
const libraryName = await json([
|
|
1526
|
-
'experimental',
|
|
1527
|
-
'icon',
|
|
1528
|
-
'map',
|
|
1529
|
-
'delete',
|
|
1530
|
-
'Trash2',
|
|
1531
|
-
]);
|
|
1532
|
-
expect(libraryName.code, JSON.stringify(libraryName.body)).toBe(0);
|
|
1533
|
-
expect(libraryName.body.data.icon).toBe('trash');
|
|
1534
|
-
const pairs = await json([
|
|
1535
|
-
'experimental',
|
|
1536
|
-
'icon',
|
|
1537
|
-
'map',
|
|
1538
|
-
'--pairs',
|
|
1539
|
-
'more-horizontal=bin,delete=trash-2',
|
|
1540
|
-
]);
|
|
1541
|
-
expect(pairs.code).toBe(0);
|
|
1542
|
-
expect(dataOf('outline').map).toMatchObject({
|
|
1543
|
-
moreHorizontal: 'bin',
|
|
1544
|
-
delete: 'trash',
|
|
1545
|
-
});
|
|
1546
|
-
});
|
|
1547
|
-
});
|
|
1548
|
-
|
|
1549
|
-
describe('blind run 3 fixes', () => {
|
|
1550
|
-
it('refreshes a set whose icons have variants', async () => {
|
|
1551
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1552
|
-
const pkgJson = JSON.parse(
|
|
1553
|
-
fs.readFileSync(path.join(lib, 'package.json'), 'utf-8'),
|
|
1554
|
-
);
|
|
1555
|
-
fs.writeFileSync(
|
|
1556
|
-
path.join(lib, 'package.json'),
|
|
1557
|
-
JSON.stringify({
|
|
1558
|
-
...pkgJson,
|
|
1559
|
-
exports: {...pkgJson.exports, './solid': './solid.js'},
|
|
1560
|
-
}),
|
|
1561
|
-
);
|
|
1562
|
-
fs.writeFileSync(
|
|
1563
|
-
path.join(lib, 'solid.js'),
|
|
1564
|
-
'export function BinIcon(props) { return null; }\n',
|
|
1565
|
-
);
|
|
1566
|
-
const create = [
|
|
1567
|
-
'experimental',
|
|
1568
|
-
'icon',
|
|
1569
|
-
'new-set',
|
|
1570
|
-
'glyphs',
|
|
1571
|
-
'--from',
|
|
1572
|
-
'@acme/glyph-library',
|
|
1573
|
-
'--variants',
|
|
1574
|
-
'outline,solid',
|
|
1575
|
-
];
|
|
1576
|
-
expect((await json(create)).code).toBe(0);
|
|
1577
|
-
expect(
|
|
1578
|
-
(
|
|
1579
|
-
await json([
|
|
1580
|
-
'experimental',
|
|
1581
|
-
'icon',
|
|
1582
|
-
'add',
|
|
1583
|
-
'--variant',
|
|
1584
|
-
'solid',
|
|
1585
|
-
'--from',
|
|
1586
|
-
'@acme/glyph-library/solid',
|
|
1587
|
-
'--all',
|
|
1588
|
-
])
|
|
1589
|
-
).code,
|
|
1590
|
-
).toBe(0);
|
|
1591
|
-
const again = await json(create);
|
|
1592
|
-
expect(again.code).toBe(0);
|
|
1593
|
-
expect(again.body.data.refreshed).toBe(true);
|
|
1594
|
-
const bin = dataOf('glyphs').icons.find(
|
|
1595
|
-
(/** @type {{id: string}} */ each) => each.id === 'bin',
|
|
1596
|
-
);
|
|
1597
|
-
expect(bin.variants).toEqual([{variant: 'solid', export: 'BinSolidIcon'}]);
|
|
1598
|
-
});
|
|
1599
|
-
|
|
1600
|
-
it('suggests the export with its Icon suffix, lists a set by id, and says what new-set did', async () => {
|
|
1601
|
-
const created = await runCli(
|
|
1602
|
-
[
|
|
1603
|
-
'experimental',
|
|
1604
|
-
'icon',
|
|
1605
|
-
'new-set',
|
|
1606
|
-
'outline',
|
|
1607
|
-
'--from',
|
|
1608
|
-
'@acme/glyph-library',
|
|
1609
|
-
],
|
|
1610
|
-
pkg,
|
|
1611
|
-
);
|
|
1612
|
-
expect(created.stdout).toContain(
|
|
1613
|
-
'Declared the experimental.iconSets root ./icon-sets in astryx.integration.mjs.',
|
|
1614
|
-
);
|
|
1615
|
-
expect(created.stdout).toContain(
|
|
1616
|
-
"Add `export * from './icon-sets/outline/outline.generated.js';` to index.js, so the icons import from @acme/icons.",
|
|
1617
|
-
);
|
|
1618
|
-
const missing = await json([
|
|
1619
|
-
'experimental',
|
|
1620
|
-
'icon',
|
|
1621
|
-
'add',
|
|
1622
|
-
'Rocket',
|
|
1623
|
-
'--from',
|
|
1624
|
-
'@acme/glyph-library',
|
|
1625
|
-
]);
|
|
1626
|
-
expect(missing.code).toBe(1);
|
|
1627
|
-
const bin = await json([
|
|
1628
|
-
'experimental',
|
|
1629
|
-
'icon',
|
|
1630
|
-
'add',
|
|
1631
|
-
'Bi',
|
|
1632
|
-
'--from',
|
|
1633
|
-
'@acme/glyph-library',
|
|
1634
|
-
]);
|
|
1635
|
-
expect(bin.code).toBe(1);
|
|
1636
|
-
fs.appendFileSync(
|
|
1637
|
-
path.join(pkg, 'node_modules', '@acme', 'glyph-library', 'index.js'),
|
|
1638
|
-
"export {Bin as XMarkIcon} from './icons/bin.js';\n",
|
|
1639
|
-
);
|
|
1640
|
-
const suffix = await json([
|
|
1641
|
-
'experimental',
|
|
1642
|
-
'icon',
|
|
1643
|
-
'add',
|
|
1644
|
-
'XMark',
|
|
1645
|
-
'--from',
|
|
1646
|
-
'@acme/glyph-library',
|
|
1647
|
-
]);
|
|
1648
|
-
expect(suffix.code).toBe(1);
|
|
1649
|
-
expect(suffix.body.suggestions[0]).toMatchObject({name: 'XMarkIcon'});
|
|
1650
|
-
const listed = await json([
|
|
1651
|
-
'experimental',
|
|
1652
|
-
'icon',
|
|
1653
|
-
'--set',
|
|
1654
|
-
'outline',
|
|
1655
|
-
'--all-icons',
|
|
1656
|
-
]);
|
|
1657
|
-
expect(listed.code).toBe(0);
|
|
1658
|
-
expect(listed.body.type).toBe('icon.setIcons');
|
|
1659
|
-
expect(
|
|
1660
|
-
listed.body.data.icons.map((/** @type {{id: string}} */ each) => each.id),
|
|
1661
|
-
).toEqual(['bin', 'cross']);
|
|
1662
|
-
const text = await runCli(
|
|
1663
|
-
['experimental', 'icon', '--set', 'outline', '--all-icons'],
|
|
1664
|
-
pkg,
|
|
1665
|
-
);
|
|
1666
|
-
expect(text.stdout).toContain('Icons in outline (2)');
|
|
1667
|
-
expect(text.stdout).toMatch(/^- bin: bin$/mu);
|
|
1668
|
-
});
|
|
1669
|
-
});
|
|
1670
|
-
|
|
1671
|
-
describe('blind run 4 fixes', () => {
|
|
1672
|
-
it('names a ./ file icon as written', async () => {
|
|
1673
|
-
await json(['experimental', 'icon', 'new-set', 'outline']);
|
|
1674
|
-
fs.mkdirSync(path.join(pkg, 'src', 'icons'), {recursive: true});
|
|
1675
|
-
fs.writeFileSync(
|
|
1676
|
-
path.join(pkg, 'src', 'icons', 'check-double.js'),
|
|
1677
|
-
'export const CheckDouble = props => null;\nexport const CheckDoubleSolid = props => null;\n',
|
|
1678
|
-
);
|
|
1679
|
-
const added = await json([
|
|
1680
|
-
'experimental',
|
|
1681
|
-
'icon',
|
|
1682
|
-
'add',
|
|
1683
|
-
'CheckDouble',
|
|
1684
|
-
'--from',
|
|
1685
|
-
'./src/icons/check-double.js',
|
|
1686
|
-
'--definition',
|
|
1687
|
-
'checkDouble',
|
|
1688
|
-
]);
|
|
1689
|
-
expect(added.code).toBe(0);
|
|
1690
|
-
expect(added.body.data.icon).toMatchObject({
|
|
1691
|
-
id: 'check-double',
|
|
1692
|
-
export: 'CheckDoubleIcon',
|
|
1693
|
-
});
|
|
1694
|
-
});
|
|
1695
|
-
|
|
1696
|
-
it('--definitions lists every definition, marking built-ins', async () => {
|
|
1697
|
-
const {code, body} = await json(['experimental', 'icon', '--definitions']);
|
|
1698
|
-
expect(code).toBe(0);
|
|
1699
|
-
expect(body.type).toBe('icon.definitions');
|
|
1700
|
-
const close = body.data.definitions.find(
|
|
1701
|
-
(/** @type {{name: string}} */ each) => each.name === 'close',
|
|
1702
|
-
);
|
|
1703
|
-
expect(close).toMatchObject({builtIn: true});
|
|
1704
|
-
expect(close.words).toContain('x');
|
|
1705
|
-
const text = await runCli(['experimental', 'icon', '--definitions'], pkg);
|
|
1706
|
-
expect(text.stdout).toMatch(/^- close \[built-in\]: /mu);
|
|
1707
|
-
});
|
|
1708
|
-
|
|
1709
|
-
it('suggests an icon by another name its library gives it, and new-set names the typecheck script and a description note', async () => {
|
|
1710
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1711
|
-
fs.writeFileSync(
|
|
1712
|
-
path.join(lib, 'icons', 'face.js'),
|
|
1713
|
-
'export const FaceSlightlySmiling = props => null;\n',
|
|
1714
|
-
);
|
|
1715
|
-
fs.appendFileSync(
|
|
1716
|
-
path.join(lib, 'index.js'),
|
|
1717
|
-
"export {FaceSlightlySmiling, FaceSlightlySmiling as Smile} from './icons/face.js';\n",
|
|
1718
|
-
);
|
|
1719
|
-
const {code, body} = await json([
|
|
1720
|
-
'experimental',
|
|
1721
|
-
'icon',
|
|
1722
|
-
'new-set',
|
|
1723
|
-
'outline',
|
|
1724
|
-
'--from',
|
|
1725
|
-
'@acme/glyph-library',
|
|
1726
|
-
]);
|
|
1727
|
-
expect(code).toBe(0);
|
|
1728
|
-
expect(body.data.suggestions).toContainEqual({
|
|
1729
|
-
definition: 'emoji',
|
|
1730
|
-
icon: 'face-slightly-smiling',
|
|
1731
|
-
word: 'smile',
|
|
1732
|
-
});
|
|
1733
|
-
expect(body.data.notes.join(' ')).toContain('description is a placeholder');
|
|
1734
|
-
const manifest = JSON.parse(
|
|
1735
|
-
fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8'),
|
|
1736
|
-
);
|
|
1737
|
-
// The script is the author's to add: the receipt names the exact line.
|
|
1738
|
-
expect(manifest).not.toHaveProperty('scripts');
|
|
1739
|
-
expect(body.data.notes).toContain(
|
|
1740
|
-
'Run `integration check --strict` in your build; add to package.json "scripts": `"typecheck": "astryx integration check --strict"`.',
|
|
1741
|
-
);
|
|
1742
|
-
});
|
|
1743
|
-
});
|
|
1744
|
-
|
|
1745
|
-
describe('blind run 5 fixes', () => {
|
|
1746
|
-
it('names the ./ source folder files needs, maps by export name, and suggests by spelling and stem', async () => {
|
|
1747
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1748
|
-
fs.writeFileSync(
|
|
1749
|
-
path.join(lib, 'icons', 'more.js'),
|
|
1750
|
-
[
|
|
1751
|
-
'export const LightBulb = props => null;',
|
|
1752
|
-
'export const TrendingUp = props => null;',
|
|
1753
|
-
'export const LockOpen = props => null;',
|
|
1754
|
-
'',
|
|
1755
|
-
].join('\n'),
|
|
1756
|
-
);
|
|
1757
|
-
fs.appendFileSync(
|
|
1758
|
-
path.join(lib, 'index.js'),
|
|
1759
|
-
"export {LightBulb, TrendingUp, LockOpen, LockOpen as Unlock} from './icons/more.js';\n",
|
|
1760
|
-
);
|
|
1761
|
-
fs.writeFileSync(
|
|
1762
|
-
path.join(pkg, 'package.json'),
|
|
1763
|
-
JSON.stringify({
|
|
1764
|
-
...JSON.parse(fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8')),
|
|
1765
|
-
files: ['index.js', 'icon-sets', 'astryx.integration.mjs'],
|
|
1766
|
-
}),
|
|
1767
|
-
);
|
|
1768
|
-
const {body} = await json([
|
|
1769
|
-
'experimental',
|
|
1770
|
-
'icon',
|
|
1771
|
-
'new-set',
|
|
1772
|
-
'outline',
|
|
1773
|
-
'--from',
|
|
1774
|
-
'@acme/glyph-library',
|
|
1775
|
-
]);
|
|
1776
|
-
const pairs = body.data.suggestions.map(
|
|
1777
|
-
(/** @type {{definition: string, icon: string}} */ each) =>
|
|
1778
|
-
`${each.definition}>${each.icon}`,
|
|
1779
|
-
);
|
|
1780
|
-
expect(pairs).toContain('lightbulb>light-bulb');
|
|
1781
|
-
expect(pairs).toContain('trendUp>trending-up');
|
|
1782
|
-
expect(pairs).toContain('unlock>lock-open');
|
|
1783
|
-
// map takes the export name, in any case.
|
|
1784
|
-
const byExport = await json([
|
|
1785
|
-
'experimental',
|
|
1786
|
-
'icon',
|
|
1787
|
-
'map',
|
|
1788
|
-
'close',
|
|
1789
|
-
'CrossIcon',
|
|
1790
|
-
]);
|
|
1791
|
-
expect(byExport.body.data).toMatchObject({
|
|
1792
|
-
definition: 'close',
|
|
1793
|
-
icon: 'cross',
|
|
1794
|
-
});
|
|
1795
|
-
// A ./ file's folder is named for files, so the icon ships; files stays
|
|
1796
|
-
// the author's (architecture:cli-surface INV16).
|
|
1797
|
-
fs.mkdirSync(path.join(pkg, 'art'), {recursive: true});
|
|
1798
|
-
fs.writeFileSync(
|
|
1799
|
-
path.join(pkg, 'art', 'check-double.js'),
|
|
1800
|
-
'export const CheckDouble = props => null;\n',
|
|
1801
|
-
);
|
|
1802
|
-
const added = await json([
|
|
1803
|
-
'experimental',
|
|
1804
|
-
'icon',
|
|
1805
|
-
'add',
|
|
1806
|
-
'CheckDouble',
|
|
1807
|
-
'--from',
|
|
1808
|
-
'./art/check-double.js',
|
|
1809
|
-
'--definition',
|
|
1810
|
-
'checkDouble',
|
|
1811
|
-
]);
|
|
1812
|
-
expect(added.code).toBe(0);
|
|
1813
|
-
expect(added.body.data.files).not.toContain('package.json');
|
|
1814
|
-
expect(
|
|
1815
|
-
JSON.parse(fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8'))
|
|
1816
|
-
.files,
|
|
1817
|
-
).toEqual(['index.js', 'icon-sets', 'astryx.integration.mjs']);
|
|
1818
|
-
expect(added.body.data.note).toContain(
|
|
1819
|
-
'./art/check-double.js is not in package.json "files", so it would not be published; set "files" to `["index.js","icon-sets","astryx.integration.mjs","art"]`.',
|
|
1820
|
-
);
|
|
1821
|
-
const text = await runCli(['experimental', 'icon', '--definitions'], pkg);
|
|
1822
|
-
expect(text.stdout).toMatch(/^- activity \[optional\]: /mu);
|
|
1823
|
-
});
|
|
1824
|
-
});
|
|
1825
|
-
|
|
1826
|
-
describe('blind run 6 fixes', () => {
|
|
1827
|
-
it('never suggests the opposite direction, and names only a ./ file folder for files', async () => {
|
|
1828
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1829
|
-
fs.writeFileSync(
|
|
1830
|
-
path.join(lib, 'icons', 'dots.js'),
|
|
1831
|
-
'export const EllipsisHorizontal = props => null;\nexport const EllipsisVertical = props => null;\n',
|
|
1832
|
-
);
|
|
1833
|
-
fs.appendFileSync(
|
|
1834
|
-
path.join(lib, 'index.js'),
|
|
1835
|
-
"export {EllipsisHorizontal, EllipsisVertical} from './icons/dots.js';\n",
|
|
1836
|
-
);
|
|
1837
|
-
const {body} = await json([
|
|
1838
|
-
'experimental',
|
|
1839
|
-
'icon',
|
|
1840
|
-
'new-set',
|
|
1841
|
-
'outline',
|
|
1842
|
-
'--from',
|
|
1843
|
-
'@acme/glyph-library',
|
|
1844
|
-
]);
|
|
1845
|
-
const more = body.data.suggestions
|
|
1846
|
-
.filter(
|
|
1847
|
-
(/** @type {{definition: string}} */ each) =>
|
|
1848
|
-
each.definition === 'moreHorizontal',
|
|
1849
|
-
)
|
|
1850
|
-
.map((/** @type {{icon: string}} */ each) => each.icon);
|
|
1851
|
-
expect(more).toEqual(['ellipsis-horizontal']);
|
|
1852
|
-
const manifestFile = path.join(pkg, 'package.json');
|
|
1853
|
-
fs.writeFileSync(
|
|
1854
|
-
manifestFile,
|
|
1855
|
-
JSON.stringify({
|
|
1856
|
-
...JSON.parse(fs.readFileSync(manifestFile, 'utf-8')),
|
|
1857
|
-
files: ['index.js', 'icon-sets'],
|
|
1858
|
-
}),
|
|
1859
|
-
);
|
|
1860
|
-
fs.mkdirSync(path.join(pkg, 'src', 'icons'), {recursive: true});
|
|
1861
|
-
fs.writeFileSync(
|
|
1862
|
-
path.join(pkg, 'src', 'icons', 'check-double.js'),
|
|
1863
|
-
'export const CheckDouble = props => null;\n',
|
|
1864
|
-
);
|
|
1865
|
-
const added = await json([
|
|
1866
|
-
'experimental',
|
|
1867
|
-
'icon',
|
|
1868
|
-
'add',
|
|
1869
|
-
'CheckDouble',
|
|
1870
|
-
'--from',
|
|
1871
|
-
'./src/icons/check-double.js',
|
|
1872
|
-
'--definition',
|
|
1873
|
-
'checkDouble',
|
|
1874
|
-
]);
|
|
1875
|
-
expect(added.body.data.note).toContain(
|
|
1876
|
-
'set "files" to `["index.js","icon-sets","src/icons"]`.',
|
|
1877
|
-
);
|
|
1878
|
-
});
|
|
1879
|
-
});
|
|
1880
|
-
|
|
1881
|
-
describe('blind run 7 fixes', () => {
|
|
1882
|
-
it('a refresh rewrites the description, lists only files it changes, and words leave out bare numbers', async () => {
|
|
1883
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1884
|
-
fs.writeFileSync(
|
|
1885
|
-
path.join(lib, 'icons', 'volume.js'),
|
|
1886
|
-
'export const Volume2 = props => null;\n',
|
|
1887
|
-
);
|
|
1888
|
-
fs.appendFileSync(
|
|
1889
|
-
path.join(lib, 'index.js'),
|
|
1890
|
-
"export {Volume2} from './icons/volume.js';\n",
|
|
1891
|
-
);
|
|
1892
|
-
const args = [
|
|
1893
|
-
'experimental',
|
|
1894
|
-
'icon',
|
|
1895
|
-
'new-set',
|
|
1896
|
-
'outline',
|
|
1897
|
-
'--from',
|
|
1898
|
-
'@acme/glyph-library',
|
|
1899
|
-
];
|
|
1900
|
-
await json(args);
|
|
1901
|
-
const volume = dataOf('outline').icons.find(
|
|
1902
|
-
(/** @type {{id: string}} */ each) => each.id === 'volume-2',
|
|
1903
|
-
);
|
|
1904
|
-
expect(volume.words).toEqual(['volume']);
|
|
1905
|
-
const dry = await json([...args, '--dry-run']);
|
|
1906
|
-
expect(dry.body.data.files).toEqual([]);
|
|
1907
|
-
const described = await json([
|
|
1908
|
-
...args,
|
|
1909
|
-
'--description',
|
|
1910
|
-
"Acme's outline icons.",
|
|
1911
|
-
]);
|
|
1912
|
-
expect(described.body.data.files).toEqual([
|
|
1913
|
-
'icon-sets/outline/outline.doc.mjs',
|
|
1914
|
-
]);
|
|
1915
|
-
expect(
|
|
1916
|
-
fs.readFileSync(
|
|
1917
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.doc.mjs'),
|
|
1918
|
-
'utf-8',
|
|
1919
|
-
),
|
|
1920
|
-
).toContain("description: 'Acme\\'s outline icons.',");
|
|
1921
|
-
});
|
|
1922
|
-
});
|
|
1923
|
-
|
|
1924
|
-
describe('blind run 8 fixes', () => {
|
|
1925
|
-
it('a refresh lists every exact-name entry for review again', async () => {
|
|
1926
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
1927
|
-
fs.writeFileSync(
|
|
1928
|
-
path.join(lib, 'icons', 'close.js'),
|
|
1929
|
-
'export const Close = props => null;\n',
|
|
1930
|
-
);
|
|
1931
|
-
fs.appendFileSync(
|
|
1932
|
-
path.join(lib, 'index.js'),
|
|
1933
|
-
"export {Close} from './icons/close.js';\n",
|
|
1934
|
-
);
|
|
1935
|
-
const args = [
|
|
1936
|
-
'experimental',
|
|
1937
|
-
'icon',
|
|
1938
|
-
'new-set',
|
|
1939
|
-
'outline',
|
|
1940
|
-
'--from',
|
|
1941
|
-
'@acme/glyph-library',
|
|
1942
|
-
];
|
|
1943
|
-
expect((await json(args)).body.data.mapped).toEqual([
|
|
1944
|
-
{definition: 'close', icon: 'close'},
|
|
1945
|
-
]);
|
|
1946
|
-
const again = await json([...args, '--dry-run']);
|
|
1947
|
-
expect(again.body.data.mapped).toEqual([
|
|
1948
|
-
{definition: 'close', icon: 'close'},
|
|
1949
|
-
]);
|
|
1950
|
-
});
|
|
1951
|
-
});
|
|
1952
|
-
|
|
1953
|
-
describe('package wiring stays the author’s', () => {
|
|
1954
|
-
/**
|
|
1955
|
-
* Every issue the check reports, by code and message.
|
|
1956
|
-
* @returns {Promise<Array<{code: string, message: string}>>}
|
|
1957
|
-
*/
|
|
1958
|
-
async function checkIssues() {
|
|
1959
|
-
const body = JSON.parse(
|
|
1960
|
-
(await runCli(['integration', 'check', '--json'], pkg)).stdout,
|
|
1961
|
-
);
|
|
1962
|
-
/** @type {Array<{code: string, message: string}>} */
|
|
1963
|
-
const found = [];
|
|
1964
|
-
/** @param {unknown} node */
|
|
1965
|
-
const walk = node => {
|
|
1966
|
-
if (Array.isArray(node)) node.forEach(walk);
|
|
1967
|
-
else if (node && typeof node === 'object') {
|
|
1968
|
-
const each = /** @type {Record<string, unknown>} */ (node);
|
|
1969
|
-
if (typeof each.code === 'string' && typeof each.message === 'string') {
|
|
1970
|
-
found.push({code: each.code, message: each.message});
|
|
1971
|
-
}
|
|
1972
|
-
Object.values(each).forEach(walk);
|
|
1973
|
-
}
|
|
1974
|
-
};
|
|
1975
|
-
walk(body.data);
|
|
1976
|
-
return found;
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
it('integration check names the same entry change as the new-set receipt, once, until the author makes it', async () => {
|
|
1980
|
-
const {body} = await json([
|
|
1981
|
-
'experimental',
|
|
1982
|
-
'icon',
|
|
1983
|
-
'new-set',
|
|
1984
|
-
'outline',
|
|
1985
|
-
'--from',
|
|
1986
|
-
'@acme/glyph-library',
|
|
1987
|
-
]);
|
|
1988
|
-
const note =
|
|
1989
|
-
"Add `export * from './icon-sets/outline/outline.generated.js';` to index.js, so the icons import from @acme/icons.";
|
|
1990
|
-
expect(body.data.notes).toContain(note);
|
|
1991
|
-
const missing = (await checkIssues()).filter(
|
|
1992
|
-
each => each.code === 'icon_export_missing',
|
|
1993
|
-
);
|
|
1994
|
-
expect([...new Set(missing.map(each => each.message))]).toEqual([
|
|
1995
|
-
`Icon set "outline": its icons are not exported from "@acme/icons" yet. ${note}`,
|
|
1996
|
-
]);
|
|
1997
|
-
// The author adds the line; the finding is gone.
|
|
1998
|
-
fs.appendFileSync(
|
|
1999
|
-
path.join(pkg, 'index.js'),
|
|
2000
|
-
"export * from './icon-sets/outline/outline.generated.js';\n",
|
|
2001
|
-
);
|
|
2002
|
-
expect(
|
|
2003
|
-
(await checkIssues()).filter(each => each.code === 'icon_export_missing'),
|
|
2004
|
-
).toEqual([]);
|
|
2005
|
-
});
|
|
2006
|
-
|
|
2007
|
-
it('integration check never fails a built or CommonJS entry over the wiring it cannot read', async () => {
|
|
2008
|
-
fs.writeFileSync(
|
|
2009
|
-
path.join(pkg, 'package.json'),
|
|
2010
|
-
JSON.stringify({
|
|
2011
|
-
...JSON.parse(fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8')),
|
|
2012
|
-
exports: {'.': './dist/index.cjs'},
|
|
2013
|
-
}),
|
|
2014
|
-
);
|
|
2015
|
-
fs.mkdirSync(path.join(pkg, 'dist'));
|
|
2016
|
-
fs.writeFileSync(
|
|
2017
|
-
path.join(pkg, 'dist', 'index.cjs'),
|
|
2018
|
-
'module.exports = {};\n',
|
|
2019
|
-
);
|
|
2020
|
-
await json([
|
|
2021
|
-
'experimental',
|
|
2022
|
-
'icon',
|
|
2023
|
-
'new-set',
|
|
2024
|
-
'outline',
|
|
2025
|
-
'--from',
|
|
2026
|
-
'@acme/glyph-library',
|
|
2027
|
-
]);
|
|
2028
|
-
expect(fs.readFileSync(path.join(pkg, 'dist', 'index.cjs'), 'utf-8')).toBe(
|
|
2029
|
-
'module.exports = {};\n',
|
|
2030
|
-
);
|
|
2031
|
-
expect(
|
|
2032
|
-
(await checkIssues()).filter(each =>
|
|
2033
|
-
each.message.includes('are not exported from'),
|
|
2034
|
-
),
|
|
2035
|
-
).toEqual([]);
|
|
2036
|
-
});
|
|
2037
|
-
});
|
|
2038
|
-
|
|
2039
|
-
describe('a refresh that first records the source', () => {
|
|
2040
|
-
it('copies the library notices and takes its license, as new-set --from does', async () => {
|
|
2041
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
2042
|
-
fs.writeFileSync(path.join(lib, 'LICENSE'), 'ISC License\n');
|
|
2043
|
-
fs.writeFileSync(
|
|
2044
|
-
path.join(lib, 'package.json'),
|
|
2045
|
-
JSON.stringify({
|
|
2046
|
-
...JSON.parse(fs.readFileSync(path.join(lib, 'package.json'), 'utf-8')),
|
|
2047
|
-
license: 'ISC',
|
|
2048
|
-
}),
|
|
2049
|
-
);
|
|
2050
|
-
expect(
|
|
2051
|
-
(await json(['experimental', 'icon', 'new-set', 'glyphs'])).code,
|
|
2052
|
-
).toBe(0);
|
|
2053
|
-
const doc = path.join(pkg, 'icon-sets', 'glyphs', 'glyphs.doc.mjs');
|
|
2054
|
-
expect(fs.readFileSync(doc, 'utf-8')).toContain("license: 'MIT'");
|
|
2055
|
-
const pkgBefore = fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8');
|
|
2056
|
-
|
|
2057
|
-
const refreshed = await json([
|
|
2058
|
-
'experimental',
|
|
2059
|
-
'icon',
|
|
2060
|
-
'new-set',
|
|
2061
|
-
'glyphs',
|
|
2062
|
-
'--from',
|
|
2063
|
-
'@acme/glyph-library',
|
|
2064
|
-
]);
|
|
2065
|
-
expect(refreshed.code).toBe(0);
|
|
2066
|
-
expect(refreshed.body.data.refreshed).toBe(true);
|
|
2067
|
-
expect(refreshed.body.data.files).toEqual(
|
|
2068
|
-
expect.arrayContaining([
|
|
2069
|
-
'icon-sets/glyphs/glyphs.doc.mjs',
|
|
2070
|
-
'icon-sets/glyphs/LICENSE',
|
|
2071
|
-
]),
|
|
2072
|
-
);
|
|
2073
|
-
expect(dataOf('glyphs').source).toEqual({
|
|
2074
|
-
package: '@acme/glyph-library',
|
|
2075
|
-
version: '2.0.0',
|
|
2076
|
-
});
|
|
2077
|
-
expect(
|
|
2078
|
-
fs.readFileSync(
|
|
2079
|
-
path.join(pkg, 'icon-sets', 'glyphs', 'LICENSE'),
|
|
2080
|
-
'utf-8',
|
|
2081
|
-
),
|
|
2082
|
-
).toBe('ISC License\n');
|
|
2083
|
-
expect(fs.readFileSync(doc, 'utf-8')).toContain("license: 'ISC'");
|
|
2084
|
-
expect(refreshed.body.data.notes).toContain(
|
|
2085
|
-
'The set\'s license in icon-sets/glyphs/glyphs.doc.mjs changed from "MIT" to "ISC", the license of @acme/glyph-library, whose artwork it now wraps. Edit it if the artwork\'s license differs.',
|
|
2086
|
-
);
|
|
2087
|
-
// The package's own license is the author's (INV16).
|
|
2088
|
-
expect(fs.readFileSync(path.join(pkg, 'package.json'), 'utf-8')).toBe(
|
|
2089
|
-
pkgBefore,
|
|
2090
|
-
);
|
|
2091
|
-
const strict = await runCli(
|
|
2092
|
-
['integration', 'check', '--strict', '--json'],
|
|
2093
|
-
pkg,
|
|
2094
|
-
);
|
|
2095
|
-
expect(strict.stdout).not.toContain('icon_license_notice_missing');
|
|
2096
|
-
|
|
2097
|
-
// A later refresh keeps the author's license.
|
|
2098
|
-
fs.writeFileSync(
|
|
2099
|
-
doc,
|
|
2100
|
-
fs
|
|
2101
|
-
.readFileSync(doc, 'utf-8')
|
|
2102
|
-
.replace("license: 'ISC'", "license: 'ISC AND CC-BY-4.0'"),
|
|
2103
|
-
);
|
|
2104
|
-
await json([
|
|
2105
|
-
'experimental',
|
|
2106
|
-
'icon',
|
|
2107
|
-
'new-set',
|
|
2108
|
-
'glyphs',
|
|
2109
|
-
'--from',
|
|
2110
|
-
'@acme/glyph-library',
|
|
2111
|
-
]);
|
|
2112
|
-
expect(fs.readFileSync(doc, 'utf-8')).toContain(
|
|
2113
|
-
"license: 'ISC AND CC-BY-4.0'",
|
|
2114
|
-
);
|
|
2115
|
-
});
|
|
2116
|
-
});
|
|
2117
|
-
|
|
2118
|
-
describe('a first-source refresh over a license the author chose', () => {
|
|
2119
|
-
it('keeps it, and the receipt names both licenses', async () => {
|
|
2120
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
2121
|
-
fs.writeFileSync(
|
|
2122
|
-
path.join(lib, 'package.json'),
|
|
2123
|
-
JSON.stringify({
|
|
2124
|
-
...JSON.parse(fs.readFileSync(path.join(lib, 'package.json'), 'utf-8')),
|
|
2125
|
-
license: 'ISC',
|
|
2126
|
-
}),
|
|
2127
|
-
);
|
|
2128
|
-
await json(['experimental', 'icon', 'new-set', 'glyphs']);
|
|
2129
|
-
const doc = path.join(pkg, 'icon-sets', 'glyphs', 'glyphs.doc.mjs');
|
|
2130
|
-
fs.writeFileSync(
|
|
2131
|
-
doc,
|
|
2132
|
-
fs
|
|
2133
|
-
.readFileSync(doc, 'utf-8')
|
|
2134
|
-
.replace("license: 'MIT'", "license: 'CC-BY-4.0'"),
|
|
2135
|
-
);
|
|
2136
|
-
const refreshed = await json([
|
|
2137
|
-
'experimental',
|
|
2138
|
-
'icon',
|
|
2139
|
-
'new-set',
|
|
2140
|
-
'glyphs',
|
|
2141
|
-
'--from',
|
|
2142
|
-
'@acme/glyph-library',
|
|
2143
|
-
]);
|
|
2144
|
-
expect(refreshed.code).toBe(0);
|
|
2145
|
-
expect(fs.readFileSync(doc, 'utf-8')).toContain("license: 'CC-BY-4.0'");
|
|
2146
|
-
expect(refreshed.body.data.notes).toContain(
|
|
2147
|
-
'The set\'s license in icon-sets/glyphs/glyphs.doc.mjs stays "CC-BY-4.0", which you set; @acme/glyph-library is licensed "ISC". Change it if the artwork is the library\'s.',
|
|
2148
|
-
);
|
|
2149
|
-
});
|
|
2150
|
-
});
|
|
2151
|
-
|
|
2152
|
-
describe('map names an icon only by its id, export name, or another library name', () => {
|
|
2153
|
-
beforeEach(() => {
|
|
2154
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
2155
|
-
fs.writeFileSync(
|
|
2156
|
-
path.join(lib, 'icons', 'glass.js'),
|
|
2157
|
-
'export const MagnifyingGlass = props => null;\n',
|
|
2158
|
-
);
|
|
2159
|
-
fs.appendFileSync(
|
|
2160
|
-
path.join(lib, 'index.js'),
|
|
2161
|
-
"export {MagnifyingGlass, MagnifyingGlass as Search} from './icons/glass.js';\n",
|
|
2162
|
-
);
|
|
2163
|
-
});
|
|
2164
|
-
|
|
2165
|
-
it('refuses a word an icon carries, with the icons that carry it, and writes nothing', async () => {
|
|
2166
|
-
await json([
|
|
2167
|
-
'experimental',
|
|
2168
|
-
'icon',
|
|
2169
|
-
'new-set',
|
|
2170
|
-
'outline',
|
|
2171
|
-
'--from',
|
|
2172
|
-
'@acme/glyph-library',
|
|
2173
|
-
]);
|
|
2174
|
-
const dataFile = path.join(
|
|
2175
|
-
pkg,
|
|
2176
|
-
'icon-sets',
|
|
2177
|
-
'outline',
|
|
2178
|
-
'outline.icons.json',
|
|
2179
|
-
);
|
|
2180
|
-
const before = fs.readFileSync(dataFile, 'utf-8');
|
|
2181
|
-
|
|
2182
|
-
const word = await json([
|
|
2183
|
-
'experimental',
|
|
2184
|
-
'icon',
|
|
2185
|
-
'map',
|
|
2186
|
-
'moreHorizontal',
|
|
2187
|
-
'glass',
|
|
2188
|
-
]);
|
|
2189
|
-
expect(word.code).toBe(1);
|
|
2190
|
-
expect(word.body.error).toContain('has no icon "glass"');
|
|
2191
|
-
expect(word.body.error).toContain('a word it carries is not its name');
|
|
2192
|
-
expect(
|
|
2193
|
-
word.body.suggestions.map(
|
|
2194
|
-
(/** @type {{name: string}} */ each) => each.name,
|
|
2195
|
-
),
|
|
2196
|
-
).toContain('magnifying-glass');
|
|
2197
|
-
|
|
2198
|
-
const pairs = await json([
|
|
2199
|
-
'experimental',
|
|
2200
|
-
'icon',
|
|
2201
|
-
'map',
|
|
2202
|
-
'--pairs',
|
|
2203
|
-
'close=cross,moreHorizontal=glass',
|
|
2204
|
-
]);
|
|
2205
|
-
expect(pairs.code).toBe(1);
|
|
2206
|
-
expect(pairs.body.error).toContain('Nothing was written');
|
|
2207
|
-
expect(fs.readFileSync(dataFile, 'utf-8')).toBe(before);
|
|
2208
|
-
|
|
2209
|
-
// The id, the export name in any case, and another library name map.
|
|
2210
|
-
for (const [given, id] of [
|
|
2211
|
-
['magnifying-glass', 'magnifying-glass'],
|
|
2212
|
-
['magnifyingglassicon', 'magnifying-glass'],
|
|
2213
|
-
['MagnifyingGlass', 'magnifying-glass'],
|
|
2214
|
-
['search', 'magnifying-glass'],
|
|
2215
|
-
['Search', 'magnifying-glass'],
|
|
2216
|
-
]) {
|
|
2217
|
-
const ok = await json(['experimental', 'icon', 'map', 'search', given]);
|
|
2218
|
-
expect(ok.code, given).toBe(0);
|
|
2219
|
-
expect(ok.body.data.icon, given).toBe(id);
|
|
2220
|
-
}
|
|
2221
|
-
});
|
|
2222
|
-
});
|
|
2223
|
-
|
|
2224
|
-
describe('a refresh after the id rule changes', () => {
|
|
2225
|
-
it('carries a renamed icon’s map entries, variants, and words, matched by its export, and reports the rename', async () => {
|
|
2226
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
2227
|
-
fs.writeFileSync(
|
|
2228
|
-
path.join(lib, 'icons', 'squares.js'),
|
|
2229
|
-
'export const Squares2X2Icon = props => null;\n',
|
|
2230
|
-
);
|
|
2231
|
-
fs.appendFileSync(
|
|
2232
|
-
path.join(lib, 'index.js'),
|
|
2233
|
-
"export {Squares2X2Icon} from './icons/squares.js';\n",
|
|
2234
|
-
);
|
|
2235
|
-
const args = [
|
|
2236
|
-
'experimental',
|
|
2237
|
-
'icon',
|
|
2238
|
-
'new-set',
|
|
2239
|
-
'outline',
|
|
2240
|
-
'--from',
|
|
2241
|
-
'@acme/glyph-library',
|
|
2242
|
-
'--variants',
|
|
2243
|
-
'outline,solid',
|
|
2244
|
-
];
|
|
2245
|
-
expect((await json(args)).code).toBe(0);
|
|
2246
|
-
// Rewrite the data file as the old id rule wrote it: `squares-2-x2`,
|
|
2247
|
-
// with that rule's words, a word the author added, a variant, and a map
|
|
2248
|
-
// entry.
|
|
2249
|
-
const dataFile = path.join(
|
|
2250
|
-
pkg,
|
|
2251
|
-
'icon-sets',
|
|
2252
|
-
'outline',
|
|
2253
|
-
'outline.icons.json',
|
|
2254
|
-
);
|
|
2255
|
-
const data = dataOf('outline');
|
|
2256
|
-
const icon = data.icons.find(
|
|
2257
|
-
(/** @type {{export: string}} */ each) =>
|
|
2258
|
-
each.export === 'Squares2X2Icon',
|
|
2259
|
-
);
|
|
2260
|
-
Object.assign(icon, {
|
|
2261
|
-
id: 'squares-2-x2',
|
|
2262
|
-
words: ['squares', 'x2', 'tiles'],
|
|
2263
|
-
variants: [{variant: 'solid', export: 'Squares2X2SolidIcon'}],
|
|
2264
|
-
});
|
|
2265
|
-
data.map = {...data.map, moreHorizontal: 'squares-2-x2'};
|
|
2266
|
-
fs.writeFileSync(dataFile, `${JSON.stringify(data, null, 2)}\n`);
|
|
2267
|
-
|
|
2268
|
-
const refreshed = await json(args);
|
|
2269
|
-
expect(refreshed.code).toBe(0);
|
|
2270
|
-
expect(refreshed.body.data.renamed).toEqual([
|
|
2271
|
-
{from: 'squares-2-x2', to: 'squares-2x2'},
|
|
2272
|
-
]);
|
|
2273
|
-
const notes = refreshed.body.data.notes.join(' ');
|
|
2274
|
-
expect(notes).toContain('squares-2-x2 -> squares-2x2');
|
|
2275
|
-
expect(notes).not.toContain('no longer exports');
|
|
2276
|
-
const after = dataOf('outline');
|
|
2277
|
-
expect(after.map.moreHorizontal).toBe('squares-2x2');
|
|
2278
|
-
const renamed = after.icons.find(
|
|
2279
|
-
(/** @type {{export: string}} */ each) =>
|
|
2280
|
-
each.export === 'Squares2X2Icon',
|
|
2281
|
-
);
|
|
2282
|
-
expect(renamed).toMatchObject({
|
|
2283
|
-
id: 'squares-2x2',
|
|
2284
|
-
variants: [{variant: 'solid', export: 'Squares2X2SolidIcon'}],
|
|
2285
|
-
});
|
|
2286
|
-
expect(renamed.words).toContain('tiles');
|
|
2287
|
-
expect(renamed.words).not.toContain('x2');
|
|
2288
|
-
expect(
|
|
2289
|
-
after.icons.some(
|
|
2290
|
-
(/** @type {{id: string}} */ each) => each.id === 'squares-2-x2',
|
|
2291
|
-
),
|
|
2292
|
-
).toBe(false);
|
|
2293
|
-
// The export stays in the generated module.
|
|
2294
|
-
expect(
|
|
2295
|
-
fs.readFileSync(
|
|
2296
|
-
path.join(pkg, 'icon-sets', 'outline', 'outline.generated.js'),
|
|
2297
|
-
'utf-8',
|
|
2298
|
-
),
|
|
2299
|
-
).toContain('Squares2X2Icon');
|
|
2300
|
-
});
|
|
2301
|
-
});
|
|
2302
|
-
|
|
2303
|
-
describe('add --variant --all after the id rule changes', () => {
|
|
2304
|
-
it('meets an icon whose id an older rule wrote by its export name', async () => {
|
|
2305
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
2306
|
-
fs.writeFileSync(
|
|
2307
|
-
path.join(lib, 'package.json'),
|
|
2308
|
-
JSON.stringify({
|
|
2309
|
-
...JSON.parse(fs.readFileSync(path.join(lib, 'package.json'), 'utf-8')),
|
|
2310
|
-
exports: {'.': './index.js', './solid': './solid.js'},
|
|
2311
|
-
}),
|
|
2312
|
-
);
|
|
2313
|
-
fs.writeFileSync(
|
|
2314
|
-
path.join(lib, 'icons', 'squares.js'),
|
|
2315
|
-
'export const Squares2X2Icon = props => null;\n',
|
|
2316
|
-
);
|
|
2317
|
-
fs.appendFileSync(
|
|
2318
|
-
path.join(lib, 'index.js'),
|
|
2319
|
-
"export {Squares2X2Icon} from './icons/squares.js';\n",
|
|
2320
|
-
);
|
|
2321
|
-
fs.writeFileSync(
|
|
2322
|
-
path.join(lib, 'solid.js'),
|
|
2323
|
-
'export const Squares2X2Icon = props => null;\n',
|
|
2324
|
-
);
|
|
2325
|
-
await json([
|
|
2326
|
-
'experimental',
|
|
2327
|
-
'icon',
|
|
2328
|
-
'new-set',
|
|
2329
|
-
'outline',
|
|
2330
|
-
'--from',
|
|
2331
|
-
'@acme/glyph-library',
|
|
2332
|
-
'--variants',
|
|
2333
|
-
'outline,solid',
|
|
2334
|
-
]);
|
|
2335
|
-
const dataFile = path.join(
|
|
2336
|
-
pkg,
|
|
2337
|
-
'icon-sets',
|
|
2338
|
-
'outline',
|
|
2339
|
-
'outline.icons.json',
|
|
2340
|
-
);
|
|
2341
|
-
const data = dataOf('outline');
|
|
2342
|
-
data.icons.find(
|
|
2343
|
-
(/** @type {{export: string}} */ each) =>
|
|
2344
|
-
each.export === 'Squares2X2Icon',
|
|
2345
|
-
).id = 'squares-2-x2';
|
|
2346
|
-
fs.writeFileSync(dataFile, `${JSON.stringify(data, null, 2)}\n`);
|
|
2347
|
-
const added = await json([
|
|
2348
|
-
'experimental',
|
|
2349
|
-
'icon',
|
|
2350
|
-
'add',
|
|
2351
|
-
'--variant',
|
|
2352
|
-
'solid',
|
|
2353
|
-
'--from',
|
|
2354
|
-
'@acme/glyph-library/solid',
|
|
2355
|
-
'--all',
|
|
2356
|
-
]);
|
|
2357
|
-
expect(added.code).toBe(0);
|
|
2358
|
-
expect(added.body.data.missing).not.toContain('squares-2-x2');
|
|
2359
|
-
expect(
|
|
2360
|
-
dataOf('outline').icons.find(
|
|
2361
|
-
(/** @type {{id: string}} */ each) => each.id === 'squares-2-x2',
|
|
2362
|
-
).variants,
|
|
2363
|
-
).toEqual([{variant: 'solid', export: 'Squares2X2SolidIcon'}]);
|
|
2364
|
-
});
|
|
2365
|
-
});
|
|
2366
|
-
|
|
2367
|
-
describe('--set through the CLI selects the set add, map, and new-definition edit', () => {
|
|
2368
|
-
beforeEach(async () => {
|
|
2369
|
-
for (const set of ['one', 'two']) {
|
|
2370
|
-
await json([
|
|
2371
|
-
'experimental',
|
|
2372
|
-
'icon',
|
|
2373
|
-
'new-set',
|
|
2374
|
-
set,
|
|
2375
|
-
'--from',
|
|
2376
|
-
'@acme/glyph-library',
|
|
2377
|
-
]);
|
|
2378
|
-
}
|
|
2379
|
-
// A third set that is withdrawn: its data file is not JSON.
|
|
2380
|
-
const broken = path.join(pkg, 'icon-sets', 'lines');
|
|
2381
|
-
fs.mkdirSync(broken, {recursive: true});
|
|
2382
|
-
fs.writeFileSync(
|
|
2383
|
-
path.join(broken, 'lines.doc.mjs'),
|
|
2384
|
-
fs
|
|
2385
|
-
.readFileSync(path.join(pkg, 'icon-sets', 'one', 'one.doc.mjs'), 'utf8')
|
|
2386
|
-
.replace("name: 'one'", "name: 'lines'"),
|
|
2387
|
-
);
|
|
2388
|
-
fs.writeFileSync(path.join(broken, 'lines.icons.json'), '{nope');
|
|
2389
|
-
});
|
|
2390
|
-
|
|
2391
|
-
/** @type {Array<[string, (set: string) => string[], string]>} the command, its words, the icon it maps */
|
|
2392
|
-
const COMMANDS = [
|
|
2393
|
-
[
|
|
2394
|
-
'map',
|
|
2395
|
-
set => ['experimental', 'icon', 'map', 'delete', 'bin', '--set', set],
|
|
2396
|
-
'bin',
|
|
2397
|
-
],
|
|
2398
|
-
[
|
|
2399
|
-
'add',
|
|
2400
|
-
set => [
|
|
2401
|
-
'experimental',
|
|
2402
|
-
'icon',
|
|
2403
|
-
'add',
|
|
2404
|
-
'Rocket',
|
|
2405
|
-
'--from',
|
|
2406
|
-
'@acme/glyph-library/rocket',
|
|
2407
|
-
'--default',
|
|
2408
|
-
'--definition',
|
|
2409
|
-
'delete',
|
|
2410
|
-
'--set',
|
|
2411
|
-
set,
|
|
2412
|
-
],
|
|
2413
|
-
'rocket',
|
|
2414
|
-
],
|
|
2415
|
-
[
|
|
2416
|
-
'new-definition',
|
|
2417
|
-
set => [
|
|
2418
|
-
'experimental',
|
|
2419
|
-
'icon',
|
|
2420
|
-
'new-definition',
|
|
2421
|
-
'binIt',
|
|
2422
|
-
'--description',
|
|
2423
|
-
'Put something in the bin.',
|
|
2424
|
-
'--words',
|
|
2425
|
-
'bin',
|
|
2426
|
-
'--icon',
|
|
2427
|
-
'bin',
|
|
2428
|
-
'--set',
|
|
2429
|
-
set,
|
|
2430
|
-
],
|
|
2431
|
-
'bin',
|
|
2432
|
-
],
|
|
2433
|
-
];
|
|
2434
|
-
|
|
2435
|
-
it.each(COMMANDS)(
|
|
2436
|
-
'%s --set edits that set and leaves the other',
|
|
2437
|
-
async (_name, args, id) => {
|
|
2438
|
-
const before = fs.readFileSync(
|
|
2439
|
-
path.join(pkg, 'icon-sets', 'one', 'one.icons.json'),
|
|
2440
|
-
'utf-8',
|
|
2441
|
-
);
|
|
2442
|
-
const res = await json(args('two'));
|
|
2443
|
-
expect(res.code, JSON.stringify(res.body)).toBe(0);
|
|
2444
|
-
expect(
|
|
2445
|
-
fs.readFileSync(
|
|
2446
|
-
path.join(pkg, 'icon-sets', 'one', 'one.icons.json'),
|
|
2447
|
-
'utf-8',
|
|
2448
|
-
),
|
|
2449
|
-
).toBe(before);
|
|
2450
|
-
expect(Object.values(dataOf('two').map)).toContain(id);
|
|
2451
|
-
},
|
|
2452
|
-
);
|
|
2453
|
-
|
|
2454
|
-
it.each(COMMANDS)('%s --set with a missing set', async (_name, args) => {
|
|
2455
|
-
const res = await json(args('nope'));
|
|
2456
|
-
expect(res.code).toBe(1);
|
|
2457
|
-
expect(res.body).toMatchObject({
|
|
2458
|
-
code: 'ERR_NOT_FOUND',
|
|
2459
|
-
error: 'No icon set named "nope" in this package',
|
|
2460
|
-
});
|
|
2461
|
-
});
|
|
2462
|
-
|
|
2463
|
-
it.each(COMMANDS)('%s --set with a withdrawn set', async (_name, args) => {
|
|
2464
|
-
const res = await json(args('lines'));
|
|
2465
|
-
expect(res.code).toBe(1);
|
|
2466
|
-
expect(res.body.code).toBe('ERR_NOT_FOUND');
|
|
2467
|
-
expect(res.body.error).toMatch(
|
|
2468
|
-
/^Icon set "lines" is in this package but withdrawn: .*not valid JSON/u,
|
|
2469
|
-
);
|
|
2470
|
-
});
|
|
2471
|
-
});
|
|
2472
|
-
|
|
2473
|
-
describe('a refresh of a set wrapped from a prefixed library by an older id rule', () => {
|
|
2474
|
-
it('matches each icon by the library export it re-exports, and keeps its public export byte for byte', async () => {
|
|
2475
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'hero');
|
|
2476
|
-
fs.mkdirSync(lib, {recursive: true});
|
|
2477
|
-
fs.writeFileSync(
|
|
2478
|
-
path.join(lib, 'package.json'),
|
|
2479
|
-
JSON.stringify({
|
|
2480
|
-
name: '@acme/hero',
|
|
2481
|
-
version: '1.0.0',
|
|
2482
|
-
type: 'module',
|
|
2483
|
-
exports: {'.': './index.js'},
|
|
2484
|
-
}),
|
|
2485
|
-
);
|
|
2486
|
-
fs.writeFileSync(
|
|
2487
|
-
path.join(lib, 'index.js'),
|
|
2488
|
-
[
|
|
2489
|
-
'export const HiSquares2X2Icon = props => null;',
|
|
2490
|
-
'export const HiTrashIcon = props => null;',
|
|
2491
|
-
'export const HiXMarkIcon = props => null;',
|
|
2492
|
-
'',
|
|
2493
|
-
].join('\n'),
|
|
2494
|
-
);
|
|
2495
|
-
const args = [
|
|
2496
|
-
'experimental',
|
|
2497
|
-
'icon',
|
|
2498
|
-
'new-set',
|
|
2499
|
-
'hero',
|
|
2500
|
-
'--from',
|
|
2501
|
-
'@acme/hero',
|
|
2502
|
-
];
|
|
2503
|
-
expect((await json(args)).code).toBe(0);
|
|
2504
|
-
const setDir = path.join(pkg, 'icon-sets', 'hero');
|
|
2505
|
-
const generatedFile = path.join(setDir, 'hero.generated.js');
|
|
2506
|
-
const typesFile = path.join(setDir, 'hero.generated.d.ts');
|
|
2507
|
-
// Rewrite the set as an older id rule wrote it: id `squares-2-x2`,
|
|
2508
|
-
// public export `Squares2X2Icon`, re-exporting `HiSquares2X2Icon`, with
|
|
2509
|
-
// a map entry and an author's word.
|
|
2510
|
-
const data = dataOf('hero');
|
|
2511
|
-
const squares = data.icons.find(
|
|
2512
|
-
(/** @type {{id: string}} */ each) => each.id === 'squares-2x2',
|
|
2513
|
-
);
|
|
2514
|
-
const newName = squares.export;
|
|
2515
|
-
Object.assign(squares, {
|
|
2516
|
-
id: 'squares-2-x2',
|
|
2517
|
-
export: 'Squares2X2Icon',
|
|
2518
|
-
words: ['squares', 'x2', 'grid-view'],
|
|
2519
|
-
});
|
|
2520
|
-
data.map = {...data.map, moreHorizontal: 'squares-2-x2'};
|
|
2521
|
-
fs.writeFileSync(
|
|
2522
|
-
path.join(setDir, 'hero.icons.json'),
|
|
2523
|
-
`${JSON.stringify(data, null, 2)}\n`,
|
|
2524
|
-
);
|
|
2525
|
-
for (const file of [generatedFile, typesFile]) {
|
|
2526
|
-
fs.writeFileSync(
|
|
2527
|
-
file,
|
|
2528
|
-
fs.readFileSync(file, 'utf-8').replaceAll(newName, 'Squares2X2Icon'),
|
|
2529
|
-
);
|
|
2530
|
-
}
|
|
2531
|
-
expect(fs.readFileSync(generatedFile, 'utf-8')).toContain(
|
|
2532
|
-
"export {HiSquares2X2Icon as Squares2X2Icon} from '@acme/hero';",
|
|
2533
|
-
);
|
|
2534
|
-
|
|
2535
|
-
const refreshed = await json(args);
|
|
2536
|
-
expect(refreshed.code).toBe(0);
|
|
2537
|
-
expect(refreshed.body.data.renamed).toEqual([
|
|
2538
|
-
{from: 'squares-2-x2', to: 'squares-2x2'},
|
|
2539
|
-
]);
|
|
2540
|
-
expect(refreshed.body.data.notes.join(' ')).not.toContain(
|
|
2541
|
-
'no longer exports',
|
|
2542
|
-
);
|
|
2543
|
-
const after = dataOf('hero');
|
|
2544
|
-
expect(after.map.moreHorizontal).toBe('squares-2x2');
|
|
2545
|
-
const kept = after.icons.find(
|
|
2546
|
-
(/** @type {{id: string}} */ each) => each.id === 'squares-2x2',
|
|
2547
|
-
);
|
|
2548
|
-
expect(kept.export).toBe('Squares2X2Icon');
|
|
2549
|
-
expect(kept.words).toContain('grid-view');
|
|
2550
|
-
const generated = fs.readFileSync(generatedFile, 'utf-8');
|
|
2551
|
-
expect(generated).toContain(
|
|
2552
|
-
"export {HiSquares2X2Icon as Squares2X2Icon} from '@acme/hero';",
|
|
2553
|
-
);
|
|
2554
|
-
expect(generated).not.toContain(
|
|
2555
|
-
newName === 'Squares2X2Icon' ? '\0' : newName,
|
|
2556
|
-
);
|
|
2557
|
-
// The set still checks: its types match its module, and, once the entry
|
|
2558
|
-
// re-exports it, every icon export resolves.
|
|
2559
|
-
fs.appendFileSync(
|
|
2560
|
-
path.join(pkg, 'index.js'),
|
|
2561
|
-
"export * from './icon-sets/hero/hero.generated.js';\n",
|
|
2562
|
-
);
|
|
2563
|
-
const check = await runCli(['integration', 'check', '--json'], pkg);
|
|
2564
|
-
expect(check.stdout).not.toContain('icon_generated_types_mismatch');
|
|
2565
|
-
expect(check.stdout).not.toContain('icon_export_missing');
|
|
2566
|
-
});
|
|
2567
|
-
});
|
|
2568
|
-
|
|
2569
|
-
describe('add --variant --all on a set an older id rule wrote from a prefixed library', () => {
|
|
2570
|
-
it('meets each icon by the library export it re-exports', async () => {
|
|
2571
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'hero');
|
|
2572
|
-
fs.mkdirSync(lib, {recursive: true});
|
|
2573
|
-
fs.writeFileSync(
|
|
2574
|
-
path.join(lib, 'package.json'),
|
|
2575
|
-
JSON.stringify({
|
|
2576
|
-
name: '@acme/hero',
|
|
2577
|
-
version: '1.0.0',
|
|
2578
|
-
type: 'module',
|
|
2579
|
-
exports: {'.': './index.js', './solid': './solid.js'},
|
|
2580
|
-
}),
|
|
2581
|
-
);
|
|
2582
|
-
const source =
|
|
2583
|
-
'export const HiSquares2X2Icon = props => null;\nexport const HiTrashIcon = props => null;\n';
|
|
2584
|
-
fs.writeFileSync(path.join(lib, 'index.js'), source);
|
|
2585
|
-
fs.writeFileSync(path.join(lib, 'solid.js'), source);
|
|
2586
|
-
await json([
|
|
2587
|
-
'experimental',
|
|
2588
|
-
'icon',
|
|
2589
|
-
'new-set',
|
|
2590
|
-
'hero',
|
|
2591
|
-
'--from',
|
|
2592
|
-
'@acme/hero',
|
|
2593
|
-
'--variants',
|
|
2594
|
-
'outline,solid',
|
|
2595
|
-
]);
|
|
2596
|
-
const setDir = path.join(pkg, 'icon-sets', 'hero');
|
|
2597
|
-
const data = dataOf('hero');
|
|
2598
|
-
const squares = data.icons.find(
|
|
2599
|
-
(/** @type {{id: string}} */ each) => each.id === 'squares-2x2',
|
|
2600
|
-
);
|
|
2601
|
-
const newName = squares.export;
|
|
2602
|
-
Object.assign(squares, {id: 'squares-2-x2', export: 'Squares2X2Icon'});
|
|
2603
|
-
fs.writeFileSync(
|
|
2604
|
-
path.join(setDir, 'hero.icons.json'),
|
|
2605
|
-
`${JSON.stringify(data, null, 2)}\n`,
|
|
2606
|
-
);
|
|
2607
|
-
for (const file of ['hero.generated.js', 'hero.generated.d.ts']) {
|
|
2608
|
-
const full = path.join(setDir, file);
|
|
2609
|
-
fs.writeFileSync(
|
|
2610
|
-
full,
|
|
2611
|
-
fs.readFileSync(full, 'utf-8').replaceAll(newName, 'Squares2X2Icon'),
|
|
2612
|
-
);
|
|
2613
|
-
}
|
|
2614
|
-
const added = await json([
|
|
2615
|
-
'experimental',
|
|
2616
|
-
'icon',
|
|
2617
|
-
'add',
|
|
2618
|
-
'--variant',
|
|
2619
|
-
'solid',
|
|
2620
|
-
'--from',
|
|
2621
|
-
'@acme/hero/solid',
|
|
2622
|
-
'--all',
|
|
2623
|
-
]);
|
|
2624
|
-
expect(added.code, JSON.stringify(added.body)).toBe(0);
|
|
2625
|
-
expect(added.body.data.missing).toEqual([]);
|
|
2626
|
-
expect(
|
|
2627
|
-
dataOf('hero').icons.find(
|
|
2628
|
-
(/** @type {{id: string}} */ each) => each.id === 'squares-2-x2',
|
|
2629
|
-
).variants,
|
|
2630
|
-
).toEqual([{variant: 'solid', export: 'Squares2X2SolidIcon'}]);
|
|
2631
|
-
});
|
|
2632
|
-
});
|
|
2633
|
-
|
|
2634
|
-
describe('a refresh after the library drops an icon', () => {
|
|
2635
|
-
it('names the icon it removed and the map entry that lost it', async () => {
|
|
2636
|
-
const args = [
|
|
2637
|
-
'experimental',
|
|
2638
|
-
'icon',
|
|
2639
|
-
'new-set',
|
|
2640
|
-
'outline',
|
|
2641
|
-
'--from',
|
|
2642
|
-
'@acme/glyph-library',
|
|
2643
|
-
];
|
|
2644
|
-
await json(args);
|
|
2645
|
-
await json(['experimental', 'icon', 'map', 'close', 'cross']);
|
|
2646
|
-
const index = path.join(
|
|
2647
|
-
pkg,
|
|
2648
|
-
'node_modules',
|
|
2649
|
-
'@acme',
|
|
2650
|
-
'glyph-library',
|
|
2651
|
-
'index.js',
|
|
2652
|
-
);
|
|
2653
|
-
fs.writeFileSync(
|
|
2654
|
-
index,
|
|
2655
|
-
fs
|
|
2656
|
-
.readFileSync(index, 'utf-8')
|
|
2657
|
-
.replace("export {Cross} from './icons/cross.js';\n", ''),
|
|
2658
|
-
);
|
|
2659
|
-
const refreshed = await json(args);
|
|
2660
|
-
expect(refreshed.code).toBe(0);
|
|
2661
|
-
expect(refreshed.body.data.notes).toEqual(
|
|
2662
|
-
expect.arrayContaining([
|
|
2663
|
-
'These map entries named those icons and were removed: close -> "cross".',
|
|
2664
|
-
'1 icons the library no longer exports were removed from the set: cross.',
|
|
2665
|
-
]),
|
|
2666
|
-
);
|
|
2667
|
-
});
|
|
2668
|
-
});
|
|
2669
|
-
|
|
2670
|
-
describe('a refresh changes only the icons the refreshed module supplies', () => {
|
|
2671
|
-
beforeEach(() => {
|
|
2672
|
-
// A second library, and your own artwork.
|
|
2673
|
-
const other = path.join(pkg, 'node_modules', '@acme', 'other-library');
|
|
2674
|
-
fs.mkdirSync(other, {recursive: true});
|
|
2675
|
-
fs.writeFileSync(
|
|
2676
|
-
path.join(other, 'package.json'),
|
|
2677
|
-
JSON.stringify({
|
|
2678
|
-
name: '@acme/other-library',
|
|
2679
|
-
version: '1.0.0',
|
|
2680
|
-
type: 'module',
|
|
2681
|
-
exports: {'.': './index.js'},
|
|
2682
|
-
}),
|
|
2683
|
-
);
|
|
2684
|
-
fs.writeFileSync(
|
|
2685
|
-
path.join(other, 'index.js'),
|
|
2686
|
-
'export const Rocket = props => null;\n',
|
|
2687
|
-
);
|
|
2688
|
-
fs.mkdirSync(path.join(pkg, 'art'), {recursive: true});
|
|
2689
|
-
fs.writeFileSync(
|
|
2690
|
-
path.join(pkg, 'art', 'spark.js'),
|
|
2691
|
-
'export const Spark = props => null;\n',
|
|
2692
|
-
);
|
|
2693
|
-
fs.writeFileSync(
|
|
2694
|
-
path.join(pkg, 'art', 'spark.d.ts'),
|
|
2695
|
-
'export declare const Spark: (props: object) => null;\n',
|
|
2696
|
-
);
|
|
2697
|
-
});
|
|
2698
|
-
|
|
2699
|
-
it('keeps your ./ artwork and another library’s icon, with their map entries and module lines, and still removes a library icon that went away', async () => {
|
|
2700
|
-
const args = [
|
|
2701
|
-
'experimental',
|
|
2702
|
-
'icon',
|
|
2703
|
-
'new-set',
|
|
2704
|
-
'outline',
|
|
2705
|
-
'--from',
|
|
2706
|
-
'@acme/glyph-library',
|
|
2707
|
-
];
|
|
2708
|
-
expect((await json(args)).code).toBe(0);
|
|
2709
|
-
for (const add of [
|
|
2710
|
-
['Spark', '--from', './art/spark.js', '--definition', 'sparkles'],
|
|
2711
|
-
['Rocket', '--from', '@acme/other-library', '--definition', 'rocket'],
|
|
2712
|
-
]) {
|
|
2713
|
-
const added = await json(['experimental', 'icon', 'add', ...add]);
|
|
2714
|
-
expect(added.code, JSON.stringify(added.body)).toBe(0);
|
|
2715
|
-
}
|
|
2716
|
-
await json(['experimental', 'icon', 'map', 'close', 'cross']);
|
|
2717
|
-
const generatedFile = path.join(
|
|
2718
|
-
pkg,
|
|
2719
|
-
'icon-sets',
|
|
2720
|
-
'outline',
|
|
2721
|
-
'outline.generated.js',
|
|
2722
|
-
);
|
|
2723
|
-
const before = fs.readFileSync(generatedFile, 'utf-8');
|
|
2724
|
-
const sparkLine = before
|
|
2725
|
-
.split('\n')
|
|
2726
|
-
.find(line => line.includes('SparkIcon') && line.includes('art/spark'));
|
|
2727
|
-
const rocketLine = before
|
|
2728
|
-
.split('\n')
|
|
2729
|
-
.find(
|
|
2730
|
-
line => line.includes('RocketIcon') && line.includes('other-library'),
|
|
2731
|
-
);
|
|
2732
|
-
expect(sparkLine).toBeTruthy();
|
|
2733
|
-
expect(rocketLine).toBeTruthy();
|
|
2734
|
-
// The library drops Cross.
|
|
2735
|
-
const index = path.join(
|
|
2736
|
-
pkg,
|
|
2737
|
-
'node_modules',
|
|
2738
|
-
'@acme',
|
|
2739
|
-
'glyph-library',
|
|
2740
|
-
'index.js',
|
|
2741
|
-
);
|
|
2742
|
-
fs.writeFileSync(
|
|
2743
|
-
index,
|
|
2744
|
-
fs
|
|
2745
|
-
.readFileSync(index, 'utf-8')
|
|
2746
|
-
.replace("export {Cross} from './icons/cross.js';\n", ''),
|
|
2747
|
-
);
|
|
2748
|
-
|
|
2749
|
-
const refreshed = await json(args);
|
|
2750
|
-
expect(refreshed.code).toBe(0);
|
|
2751
|
-
const data = dataOf('outline');
|
|
2752
|
-
const ids = data.icons.map((/** @type {{id: string}} */ each) => each.id);
|
|
2753
|
-
expect(ids).toEqual(expect.arrayContaining(['bin', 'spark', 'rocket']));
|
|
2754
|
-
expect(ids).not.toContain('cross');
|
|
2755
|
-
expect(data.map).toMatchObject({sparkles: 'spark', rocket: 'rocket'});
|
|
2756
|
-
expect(data.map).not.toHaveProperty('close');
|
|
2757
|
-
const after = fs.readFileSync(generatedFile, 'utf-8');
|
|
2758
|
-
expect(after).toContain(/** @type {string} */ (sparkLine));
|
|
2759
|
-
expect(after).toContain(/** @type {string} */ (rocketLine));
|
|
2760
|
-
const notes = refreshed.body.data.notes.join('\n');
|
|
2761
|
-
expect(notes).toContain(
|
|
2762
|
-
'1 icons the library no longer exports were removed from the set: cross.',
|
|
2763
|
-
);
|
|
2764
|
-
expect(notes).toContain('close -> "cross"');
|
|
2765
|
-
expect(notes).not.toMatch(/spark|rocket/u);
|
|
2766
|
-
});
|
|
2767
|
-
|
|
2768
|
-
it('add --variant --all leaves icons from other modules alone and never lists them as missing', async () => {
|
|
2769
|
-
const lib = path.join(pkg, 'node_modules', '@acme', 'glyph-library');
|
|
2770
|
-
fs.writeFileSync(
|
|
2771
|
-
path.join(lib, 'package.json'),
|
|
2772
|
-
JSON.stringify({
|
|
2773
|
-
...JSON.parse(fs.readFileSync(path.join(lib, 'package.json'), 'utf-8')),
|
|
2774
|
-
exports: {'.': './index.js', './solid': './solid.js'},
|
|
2775
|
-
}),
|
|
2776
|
-
);
|
|
2777
|
-
// The solid module also exports a Spark: it is not your Spark.
|
|
2778
|
-
fs.writeFileSync(
|
|
2779
|
-
path.join(lib, 'solid.js'),
|
|
2780
|
-
'export const Bin = props => null;\nexport const Spark = props => null;\n',
|
|
2781
|
-
);
|
|
2782
|
-
await json([
|
|
2783
|
-
'experimental',
|
|
2784
|
-
'icon',
|
|
2785
|
-
'new-set',
|
|
2786
|
-
'outline',
|
|
2787
|
-
'--from',
|
|
2788
|
-
'@acme/glyph-library',
|
|
2789
|
-
'--variants',
|
|
2790
|
-
'outline,solid',
|
|
2791
|
-
]);
|
|
2792
|
-
await json([
|
|
2793
|
-
'experimental',
|
|
2794
|
-
'icon',
|
|
2795
|
-
'add',
|
|
2796
|
-
'Spark',
|
|
2797
|
-
'--from',
|
|
2798
|
-
'./art/spark.js',
|
|
2799
|
-
'--definition',
|
|
2800
|
-
'sparkles',
|
|
2801
|
-
]);
|
|
2802
|
-
const added = await json([
|
|
2803
|
-
'experimental',
|
|
2804
|
-
'icon',
|
|
2805
|
-
'add',
|
|
2806
|
-
'--variant',
|
|
2807
|
-
'solid',
|
|
2808
|
-
'--from',
|
|
2809
|
-
'@acme/glyph-library/solid',
|
|
2810
|
-
'--all',
|
|
2811
|
-
]);
|
|
2812
|
-
expect(added.code, JSON.stringify(added.body)).toBe(0);
|
|
2813
|
-
expect(added.body.data.missing).toEqual(['cross']);
|
|
2814
|
-
const spark = dataOf('outline').icons.find(
|
|
2815
|
-
(/** @type {{id: string}} */ each) => each.id === 'spark',
|
|
2816
|
-
);
|
|
2817
|
-
expect(spark.variants).toBeUndefined();
|
|
2818
|
-
});
|
|
2819
|
-
});
|
|
2820
|
-
|
|
2821
|
-
describe('a refresh with --exclude', () => {
|
|
2822
|
-
it('names the icons --exclude left out, never as ones the library no longer exports', async () => {
|
|
2823
|
-
const args = [
|
|
2824
|
-
'experimental',
|
|
2825
|
-
'icon',
|
|
2826
|
-
'new-set',
|
|
2827
|
-
'outline',
|
|
2828
|
-
'--from',
|
|
2829
|
-
'@acme/glyph-library',
|
|
2830
|
-
];
|
|
2831
|
-
await json(args);
|
|
2832
|
-
await json(['experimental', 'icon', 'map', 'close', 'cross']);
|
|
2833
|
-
const refreshed = await json([...args, '--exclude', 'Cross']);
|
|
2834
|
-
expect(refreshed.code).toBe(0);
|
|
2835
|
-
const notes = refreshed.body.data.notes;
|
|
2836
|
-
expect(notes).toEqual(
|
|
2837
|
-
expect.arrayContaining([
|
|
2838
|
-
'Left out by --exclude, and removed from the set: cross.',
|
|
2839
|
-
'These map entries named icons --exclude left out and were removed: close -> "cross".',
|
|
2840
|
-
]),
|
|
2841
|
-
);
|
|
2842
|
-
expect(notes.join('\n')).not.toContain('no longer exports');
|
|
2843
|
-
expect(dataOf('outline').exclude).toEqual(['Cross']);
|
|
2844
|
-
});
|
|
2845
|
-
});
|