@astryxdesign/cli 0.7.4 → 0.7.5-canary.031a639
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -20
- package/api/component/_adapter.mjs +16 -1
- package/api/component/component.test.mjs +31 -0
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +5 -2
- package/api/docs/_adapter.mjs +24 -16
- package/api/docs/docs.test.mjs +18 -0
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/experimental.d.mts +5 -0
- package/api/experimental.mjs +15 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +16 -3
- package/api/icon/_authoring.d.mts +5 -1
- package/api/icon/_authoring.mjs +478 -63
- package/api/icon/_options.d.mts +11 -0
- package/api/icon/_options.mjs +39 -4
- package/api/icon/_records.d.mts +19 -0
- package/api/icon/_records.mjs +25 -0
- package/api/icon/add/add.d.mts +3 -3
- package/api/icon/add/add.mjs +227 -14
- package/api/icon/all-or-nothing.test.mjs +283 -0
- package/api/icon/detail/detail.mjs +2 -13
- package/api/icon/error-codes.test.mjs +14 -7
- package/api/icon/icon.d.mts +2 -2
- package/api/icon/icon.doc.mjs +30 -2
- package/api/icon/icon.mjs +57 -8
- package/api/icon/icon.test.mjs +133 -1
- package/api/icon/icon.type.d.mts +126 -1
- package/api/icon/icon.type.mjs +67 -3
- package/api/icon/iconAdd.doc.mjs +22 -6
- package/api/icon/iconMap.doc.mjs +24 -8
- package/api/icon/iconNewDefinition.doc.mjs +2 -2
- package/api/icon/iconNewSet.doc.mjs +30 -2
- package/api/icon/iconUse.doc.mjs +4 -1
- package/api/icon/map/map.d.mts +4 -4
- package/api/icon/map/map.mjs +134 -9
- package/api/icon/new-definition/new-definition.mjs +6 -2
- package/api/icon/new-set/new-set.mjs +2 -2
- package/api/icon/new-set/new-set.test.mjs +60 -10
- package/api/icon/option-pairs.test.mjs +368 -0
- package/api/icon/search/search.d.mts +10 -0
- package/api/icon/search/search.mjs +55 -14
- package/api/icon/use/use.mjs +2 -13
- package/api/integration/add-helpers.d.mts +15 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
- package/api/integration/pack-check.mjs +10 -4
- package/api/integration/pack-check.test.mjs +5 -1
- package/api/integration/validate-integration.type.d.mts +3 -2
- package/api/integration/validate-integration.type.mjs +3 -2
- package/api/render/_adapter.d.mts +28 -0
- package/api/render/_adapter.mjs +540 -0
- package/api/render/render.d.mts +15 -0
- package/api/render/render.doc.d.mts +9 -0
- package/api/render/render.doc.mjs +112 -0
- package/api/render/render.mjs +113 -0
- package/api/render/render.test.mjs +1155 -0
- package/api/render/render.type.d.mts +74 -0
- package/api/render/render.type.mjs +64 -0
- package/api/search/_adapter.test.mjs +21 -2
- package/api/search/_result.d.mts +5 -5
- package/api/search/search.d.mts +1 -1
- package/api/template/template.mjs +3 -1
- package/api/template/template.type.d.mts +2 -1
- package/api/template/template.type.mjs +1 -1
- package/api/template/tokenizer-showcase.test.mjs +47 -0
- package/api/template/unknown-name.test.mjs +63 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +134 -75
- package/api/theme/build/build.test.mjs +77 -0
- package/api/upgrade/_adapter.d.mts +47 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/failure-receipt.test.mjs +212 -0
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +670 -44
- package/api/upgrade/upgrade.doc.mjs +4 -4
- package/api/upgrade/upgrade.mjs +19 -4
- package/api/upgrade/upgrade.type.d.mts +36 -1
- package/api/upgrade/upgrade.type.mjs +29 -4
- package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
- package/assets/codemods/integration-runner.mjs +8 -2
- package/assets/codemods/integration-runner.protection.test.mjs +53 -0
- package/assets/codemods/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/parse.mjs +94 -0
- package/assets/codemods/run-codemod.mjs +109 -5
- package/assets/codemods/runner.mjs +119 -13
- package/assets/codemods/transform-prop.mjs +99 -49
- package/assets/codemods/transform-prop.test.mjs +36 -1
- package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
- package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +143 -70
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +23 -78
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -1
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
- package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +50 -20
- package/assets/docs/tree/render-pages.doc.mjs +94 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +145 -1
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/icons/definitions/activity.doc.mjs +1 -1
- package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
- package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
- package/assets/icons/definitions/alignStart.doc.mjs +10 -0
- package/assets/icons/definitions/archive.doc.mjs +1 -1
- package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
- package/assets/icons/definitions/attach.doc.mjs +1 -1
- package/assets/icons/definitions/audio.doc.mjs +1 -1
- package/assets/icons/definitions/cart.doc.mjs +1 -1
- package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
- package/assets/icons/definitions/close.doc.mjs +1 -1
- package/assets/icons/definitions/collapse.doc.mjs +1 -1
- package/assets/icons/definitions/compose.doc.mjs +1 -1
- package/assets/icons/definitions/conversation.doc.mjs +1 -1
- package/assets/icons/definitions/copy.doc.mjs +1 -1
- package/assets/icons/definitions/cpu.doc.mjs +9 -0
- package/assets/icons/definitions/database.doc.mjs +1 -1
- package/assets/icons/definitions/desktop.doc.mjs +1 -1
- package/assets/icons/definitions/discount.doc.mjs +1 -1
- package/assets/icons/definitions/download.doc.mjs +1 -1
- package/assets/icons/definitions/emoji.doc.mjs +1 -1
- package/assets/icons/definitions/error.doc.mjs +1 -1
- package/assets/icons/definitions/expand.doc.mjs +1 -1
- package/assets/icons/definitions/experiment.doc.mjs +1 -1
- package/assets/icons/definitions/externalLink.doc.mjs +7 -1
- package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
- package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
- package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
- package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
- package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
- package/assets/icons/definitions/gitFork.doc.mjs +9 -0
- package/assets/icons/definitions/info.doc.mjs +1 -1
- package/assets/icons/definitions/location.doc.mjs +1 -1
- package/assets/icons/definitions/mention.doc.mjs +1 -1
- package/assets/icons/definitions/menu.doc.mjs +1 -1
- package/assets/icons/definitions/microphone.doc.mjs +1 -1
- package/assets/icons/definitions/mobile.doc.mjs +1 -1
- package/assets/icons/definitions/money.doc.mjs +1 -1
- package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
- package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
- package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
- package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
- package/assets/icons/definitions/panelRight.doc.mjs +10 -0
- package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
- package/assets/icons/definitions/redo.doc.mjs +1 -1
- package/assets/icons/definitions/refresh.doc.mjs +1 -1
- package/assets/icons/definitions/rotate.doc.mjs +9 -0
- package/assets/icons/definitions/scale.doc.mjs +10 -0
- package/assets/icons/definitions/search.doc.mjs +1 -1
- package/assets/icons/definitions/send.doc.mjs +1 -1
- package/assets/icons/definitions/settings.doc.mjs +1 -1
- package/assets/icons/definitions/star.doc.mjs +1 -1
- package/assets/icons/definitions/stop.doc.mjs +1 -1
- package/assets/icons/definitions/success.doc.mjs +1 -1
- package/assets/icons/definitions/textCase.doc.mjs +9 -0
- package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
- package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
- package/assets/icons/definitions/trendDown.doc.mjs +7 -1
- package/assets/icons/definitions/trendUp.doc.mjs +1 -1
- package/assets/icons/definitions/undo.doc.mjs +1 -1
- package/assets/icons/definitions/upload.doc.mjs +1 -1
- package/assets/icons/definitions/userAdd.doc.mjs +1 -1
- package/assets/icons/definitions/warning.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +22 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/library/page.tsx +1 -2
- package/assets/templates/pages/table-comparison/page.tsx +12 -3
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
- package/assets/templates/themes/butter/butterTheme.ts +47 -44
- package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
- package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
- package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
- package/assets/templates/themes/stone/stoneTheme.ts +46 -21
- package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
- package/assets/theme.template.ts +18 -5
- package/authoring/codemod/type.ts +10 -0
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
- package/authoring/doctypes/icon-set/parse.d.mts +1 -0
- package/authoring/doctypes/icon-set/parse.mjs +1 -0
- package/authoring/doctypes/icon-set/type.ts +5 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/clients/cli/commands/doctor.mjs +16 -17
- package/clients/cli/commands/experimental/icon.mjs +167 -35
- package/clients/cli/commands/experimental/index.mjs +2 -0
- package/clients/cli/commands/experimental/render.mjs +113 -0
- package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
- package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
- package/clients/cli/commands/experimental-render.doc.mjs +60 -0
- package/clients/cli/commands/experimental.doc.mjs +4 -2
- package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
- package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
- package/clients/cli/commands/icon.test.mjs +1 -1
- package/clients/cli/commands/template.mjs +4 -1
- package/clients/cli/commands/text-json-parity.test.mjs +46 -0
- package/clients/cli/commands/upgrade.doc.mjs +47 -2
- package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
- package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
- package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/clients/cli/index.mjs +1 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/discovery/component-discovery.d.mts +2 -1
- package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
- package/foundation/discovery/component-discovery.mjs +13 -7
- package/foundation/discovery/icon-set-checks.d.mts +43 -9
- package/foundation/discovery/icon-set-checks.mjs +296 -21
- package/foundation/discovery/icon-set-checks.test.mjs +125 -12
- package/foundation/discovery/icon-set-writer.d.mts +192 -3
- package/foundation/discovery/icon-set-writer.mjs +608 -34
- package/foundation/discovery/icon-set-writer.test.mjs +26 -0
- package/foundation/discovery/module-exports.mjs +82 -25
- package/foundation/discovery/module-exports.test.mjs +38 -1
- package/foundation/discovery/package-exports.d.mts +13 -0
- package/foundation/discovery/package-exports.mjs +40 -1
- package/foundation/discovery/template-icons.d.mts +6 -0
- package/foundation/discovery/template-icons.mjs +98 -10
- package/foundation/discovery/template-icons.test.mjs +103 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +22 -11
- package/foundation/doc-compiler/import.mjs +81 -8
- package/foundation/doc-compiler/read.d.mts +4 -3
- package/foundation/doc-compiler/read.mjs +15 -10
- package/foundation/doc-compiler/read.test.mjs +59 -1
- package/foundation/doc-compiler/tree.mjs +3 -1
- package/foundation/fs/module-loader.d.mts +3 -2
- package/foundation/fs/module-loader.mjs +3 -2
- package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
- package/foundation/fs/read-record.d.mts +27 -0
- package/foundation/fs/read-record.mjs +83 -15
- package/foundation/fs/read-record.test.mjs +88 -1
- package/foundation/render/assets.d.mts +31 -0
- package/foundation/render/assets.mjs +102 -0
- package/foundation/render/component-map.d.mts +52 -0
- package/foundation/render/component-map.mjs +141 -0
- package/foundation/render/css-cut.d.mts +29 -0
- package/foundation/render/css-cut.mjs +144 -0
- package/foundation/render/embedded-files.d.mts +28 -0
- package/foundation/render/embedded-files.mjs +108 -0
- package/foundation/render/embedded-imports.d.mts +61 -0
- package/foundation/render/embedded-imports.mjs +315 -0
- package/foundation/render/html-reader.d.mts +37 -0
- package/foundation/render/html-reader.mjs +121 -0
- package/foundation/render/page-worker.d.mts +7 -0
- package/foundation/render/page-worker.mjs +519 -0
- package/foundation/render/rebuild.d.mts +19 -0
- package/foundation/render/rebuild.mjs +269 -0
- package/foundation/render/render-page.d.mts +85 -0
- package/foundation/render/render-page.mjs +612 -0
- package/foundation/render/render.test.mjs +117 -0
- package/foundation/render/source-block.d.mts +52 -0
- package/foundation/render/source-block.mjs +106 -0
- package/foundation/response/base.d.ts +7 -0
- package/foundation/response/error-codes.d.mts +10 -1
- package/foundation/response/error-codes.doc.mjs +59 -2
- package/foundation/response/error-codes.mjs +62 -1
- package/foundation/response/json.d.mts +10 -3
- package/foundation/response/json.mjs +16 -4
- package/foundation/response/response-types.doc.mjs +39 -2
- package/foundation/text/string-utils.mjs +33 -0
- package/foundation/text/string-utils.test.mjs +17 -0
- package/foundation/text/suggest-order.d.mts +17 -3
- package/foundation/text/suggest-order.mjs +58 -13
- package/foundation/text/suggest-order.test.mjs +53 -0
- package/package.json +15 -9
|
@@ -57,8 +57,15 @@ export function registerUpgrade(program) {
|
|
|
57
57
|
// already printed the error before throwing.
|
|
58
58
|
logger.setSilent(json);
|
|
59
59
|
if (e instanceof AstryxError) {
|
|
60
|
-
if (json)
|
|
61
|
-
|
|
60
|
+
if (json) {
|
|
61
|
+
// A failed migration still names the files it already changed.
|
|
62
|
+
jsonError(
|
|
63
|
+
e.message,
|
|
64
|
+
undefined,
|
|
65
|
+
e.code,
|
|
66
|
+
/** @type {any} */ (e).receipt,
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
62
69
|
// The logger was silent only for --list; replay the error there.
|
|
63
70
|
// Non-list failures were already printed by the API.
|
|
64
71
|
if (isList) logger.error(e.message);
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx upgrade` end to end: generated files to rebuild are listed in
|
|
5
|
+
* `regenerate` with their commands. A file the project protects keeps the run
|
|
6
|
+
* incomplete (ERR_CODEMOD_PROTECTED, as for any protected file); one nothing
|
|
7
|
+
* protects stays a codemod error (ERR_CODEMOD_FAILED). A declared
|
|
8
|
+
* regeneration clears them, and a real codemod failure keeps its
|
|
9
|
+
* ERR_CODEMOD_FAILED error.
|
|
10
|
+
* Manual migrations are covered at the API level in
|
|
11
|
+
* `api/upgrade/run/outcomes.test.mjs`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
15
|
+
import {spawnSync} from 'node:child_process';
|
|
16
|
+
import * as fs from 'node:fs';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import {fileURLToPath} from 'node:url';
|
|
20
|
+
import {CLI_VERSION} from '../../../test-utils/release-fixtures.mjs';
|
|
21
|
+
|
|
22
|
+
const CLI = path.resolve(
|
|
23
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
24
|
+
'..',
|
|
25
|
+
'bin',
|
|
26
|
+
'astryx.mjs',
|
|
27
|
+
);
|
|
28
|
+
const CODEMOD = 'core:validate-data-token-ownership';
|
|
29
|
+
const STALE_THEME =
|
|
30
|
+
'/* @generated by `astryx theme build` */\n' +
|
|
31
|
+
'@layer astryx-base {\n :root { --color-data-categorical-green: #008000; }\n}\n';
|
|
32
|
+
const FRESH_THEME = '/* @generated by `astryx theme build` */\n.theme {}\n';
|
|
33
|
+
// The generated block below authored rules: the marker is not in the leading
|
|
34
|
+
// comment block, so nothing protects this file (spec:AST-040 FR3).
|
|
35
|
+
const UNPROTECTED_STALE_THEME = `.app { color: red; }\n${STALE_THEME}`;
|
|
36
|
+
|
|
37
|
+
let root;
|
|
38
|
+
|
|
39
|
+
function write(relative, contents) {
|
|
40
|
+
const file = path.join(root, relative);
|
|
41
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
42
|
+
fs.writeFileSync(file, contents);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function read(relative) {
|
|
46
|
+
return fs.readFileSync(path.join(root, relative), 'utf8');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function run(args, {json = true, cwd = root} = {}) {
|
|
50
|
+
const result = spawnSync(
|
|
51
|
+
process.execPath,
|
|
52
|
+
[CLI, ...(json ? ['--json'] : []), 'upgrade', ...args],
|
|
53
|
+
{
|
|
54
|
+
cwd,
|
|
55
|
+
encoding: 'utf8',
|
|
56
|
+
timeout: 60_000,
|
|
57
|
+
env: {...process.env, FORCE_COLOR: '0', CI: ''},
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
return {...result, envelope: json ? JSON.parse(result.stdout) : null};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @param {{config?: string}} [options] */
|
|
64
|
+
function seed({config = 'export default {};\n'} = {}) {
|
|
65
|
+
write(
|
|
66
|
+
'package.json',
|
|
67
|
+
JSON.stringify({
|
|
68
|
+
name: 'consumer',
|
|
69
|
+
private: true,
|
|
70
|
+
dependencies: {'@astryxdesign/core': CLI_VERSION},
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
write(
|
|
74
|
+
'node_modules/@astryxdesign/core/package.json',
|
|
75
|
+
JSON.stringify({name: '@astryxdesign/core', version: CLI_VERSION}),
|
|
76
|
+
);
|
|
77
|
+
write('astryx.config.mjs', config);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const ONLY = ['--from', '0.6.0', '--codemod', 'validate-data-token-ownership'];
|
|
81
|
+
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-upgrade-outcomes-'));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
afterEach(() => {
|
|
87
|
+
fs.rmSync(root, {recursive: true, force: true});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('generated files to regenerate', () => {
|
|
91
|
+
it('are listed with the rebuild command, and in protectedFiles with the declaration that protects them', () => {
|
|
92
|
+
seed();
|
|
93
|
+
write('app/theme.css', STALE_THEME);
|
|
94
|
+
|
|
95
|
+
const applied = run([...ONLY, '--path', '.', '--apply']);
|
|
96
|
+
|
|
97
|
+
expect(applied.status).toBe(1);
|
|
98
|
+
expect(applied.envelope).toMatchObject({
|
|
99
|
+
type: 'upgrade.run',
|
|
100
|
+
data: {
|
|
101
|
+
complete: false,
|
|
102
|
+
errorCode: 'ERR_CODEMOD_PROTECTED',
|
|
103
|
+
errors: [],
|
|
104
|
+
declinedCandidates: [],
|
|
105
|
+
// The stale theme carries an @generated header, so it is a protected
|
|
106
|
+
// file that still requires a change, with its declaration.
|
|
107
|
+
protectedFiles: [
|
|
108
|
+
{
|
|
109
|
+
file: 'app/theme.css',
|
|
110
|
+
codemods: [CODEMOD],
|
|
111
|
+
reasons: ['generated'],
|
|
112
|
+
declarations: [expect.stringContaining('@generated')],
|
|
113
|
+
commands: ['astryx theme build'],
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
regenerate: [
|
|
117
|
+
{
|
|
118
|
+
file: 'app/theme.css',
|
|
119
|
+
codemods: [CODEMOD],
|
|
120
|
+
commands: ['astryx theme build'],
|
|
121
|
+
messages: [expect.stringContaining('Rebuild it')],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
expect(read('app/theme.css')).toBe(STALE_THEME);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('read as incomplete in text, never as up to date', () => {
|
|
130
|
+
seed();
|
|
131
|
+
write('app/theme.css', STALE_THEME);
|
|
132
|
+
|
|
133
|
+
const text = run([...ONLY, '--path', '.', '--apply'], {json: false});
|
|
134
|
+
|
|
135
|
+
expect(text.status).toBe(1);
|
|
136
|
+
expect(text.stderr).toMatch(
|
|
137
|
+
/ERR_CODEMOD_PROTECTED: 1 protected file still requires a codemod change:\n\s+app\/theme\.css — .*@generated/,
|
|
138
|
+
);
|
|
139
|
+
expect(text.stdout).toMatch(/Regenerate with: astryx theme build/);
|
|
140
|
+
expect(text.stdout).toMatch(/Upgrade incomplete/);
|
|
141
|
+
expect(`${text.stdout}\n${text.stderr}`).not.toMatch(/No changes needed/);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('keep the incomplete result, not a config error, when astryx.config fails validation too', () => {
|
|
145
|
+
seed({config: "export default {theme: 'neutral'};\n"});
|
|
146
|
+
write('app/theme.css', STALE_THEME);
|
|
147
|
+
|
|
148
|
+
const applied = run([...ONLY, '--path', '.', '--apply']);
|
|
149
|
+
|
|
150
|
+
expect(applied.status).toBe(1);
|
|
151
|
+
expect(applied.envelope).toMatchObject({
|
|
152
|
+
type: 'upgrade.run',
|
|
153
|
+
data: {
|
|
154
|
+
complete: false,
|
|
155
|
+
errorCode: 'ERR_CODEMOD_PROTECTED',
|
|
156
|
+
protectedFiles: [expect.objectContaining({file: 'app/theme.css'})],
|
|
157
|
+
regenerate: [
|
|
158
|
+
expect.objectContaining({
|
|
159
|
+
file: 'app/theme.css',
|
|
160
|
+
commands: ['astryx theme build'],
|
|
161
|
+
}),
|
|
162
|
+
],
|
|
163
|
+
// The config's own error is still listed, as main reports it.
|
|
164
|
+
errors: [
|
|
165
|
+
{
|
|
166
|
+
file: '.',
|
|
167
|
+
codemod: 'config',
|
|
168
|
+
error: expect.stringContaining('astryx.config'),
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const configError = applied.envelope.data.errors[0].error;
|
|
175
|
+
const text = run([...ONLY, '--path', '.', '--apply'], {json: false});
|
|
176
|
+
expect(text.status).toBe(1);
|
|
177
|
+
expect(text.stderr).toContain(configError);
|
|
178
|
+
expect(text.stdout).toMatch(/Upgrade incomplete: protected changes remain/);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('include protected generated files with their header command, alongside protectedFiles', () => {
|
|
182
|
+
seed();
|
|
183
|
+
write('.gitattributes', 'generated/** linguist-generated=true\n');
|
|
184
|
+
write(
|
|
185
|
+
'generated/panel.tsx',
|
|
186
|
+
'// @generated\n// Command: pnpm run gen:panel\n' +
|
|
187
|
+
"import {useResizable} from '@astryxdesign/core';\n" +
|
|
188
|
+
'export const usePanel = () => useResizable({minSizePx: 200});\n',
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
const applied = run([
|
|
192
|
+
'--from',
|
|
193
|
+
'0.5.0',
|
|
194
|
+
'--codemod',
|
|
195
|
+
'rename-resizable-pixel-bounds',
|
|
196
|
+
'--path',
|
|
197
|
+
'.',
|
|
198
|
+
'--apply',
|
|
199
|
+
]);
|
|
200
|
+
|
|
201
|
+
expect(applied.status).toBe(1);
|
|
202
|
+
expect(applied.envelope.data).toMatchObject({
|
|
203
|
+
complete: false,
|
|
204
|
+
errorCode: 'ERR_CODEMOD_PROTECTED',
|
|
205
|
+
protectedFiles: [expect.objectContaining({file: 'generated/panel.tsx'})],
|
|
206
|
+
regenerate: [
|
|
207
|
+
{
|
|
208
|
+
file: 'generated/panel.tsx',
|
|
209
|
+
codemods: ['core:rename-resizable-pixel-bounds'],
|
|
210
|
+
commands: ['pnpm run gen:panel'],
|
|
211
|
+
messages: [],
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('clear once the declared regeneration rebuilds the file', () => {
|
|
218
|
+
const rebuild = `require('node:fs').writeFileSync('app/theme.css', ${JSON.stringify(FRESH_THEME)})`;
|
|
219
|
+
seed({
|
|
220
|
+
config: `export default {hooks: {postCodemod: [{name: 'theme', buildCommand: () => ({command: process.execPath, args: ['-e', ${JSON.stringify(rebuild)}]})}]}};\n`,
|
|
221
|
+
});
|
|
222
|
+
write('app/theme.css', STALE_THEME);
|
|
223
|
+
|
|
224
|
+
const applied = run([...ONLY, '--path', '.', '--apply']);
|
|
225
|
+
|
|
226
|
+
expect(applied.status, applied.stderr).toBe(0);
|
|
227
|
+
expect(applied.envelope.data).toMatchObject({
|
|
228
|
+
complete: true,
|
|
229
|
+
regenerate: [],
|
|
230
|
+
modifiedFiles: ['app/theme.css'],
|
|
231
|
+
});
|
|
232
|
+
expect(read('app/theme.css')).toBe(FRESH_THEME);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('report one nothing protects as a codemod error, not ERR_CODEMOD_PROTECTED', () => {
|
|
236
|
+
seed();
|
|
237
|
+
write('app/theme.css', UNPROTECTED_STALE_THEME);
|
|
238
|
+
|
|
239
|
+
const applied = run([...ONLY, '--path', '.', '--apply']);
|
|
240
|
+
|
|
241
|
+
expect(applied.status).toBe(1);
|
|
242
|
+
expect(applied.envelope).not.toHaveProperty('type');
|
|
243
|
+
expect(applied.envelope).toMatchObject({
|
|
244
|
+
code: 'ERR_CODEMOD_FAILED',
|
|
245
|
+
receipt: {
|
|
246
|
+
complete: false,
|
|
247
|
+
errorCode: 'ERR_CODEMOD_FAILED',
|
|
248
|
+
protectedFiles: [],
|
|
249
|
+
errors: [
|
|
250
|
+
expect.objectContaining({
|
|
251
|
+
file: 'app/theme.css',
|
|
252
|
+
codemod: CODEMOD,
|
|
253
|
+
error: expect.stringContaining('Rebuild it'),
|
|
254
|
+
}),
|
|
255
|
+
],
|
|
256
|
+
regenerate: [
|
|
257
|
+
expect.objectContaining({
|
|
258
|
+
file: 'app/theme.css',
|
|
259
|
+
commands: ['astryx theme build'],
|
|
260
|
+
}),
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const text = run([...ONLY, '--path', '.', '--apply'], {json: false});
|
|
266
|
+
expect(text.status).toBe(1);
|
|
267
|
+
expect(text.stderr).toMatch(
|
|
268
|
+
/1 generated file must be regenerated:\n\s+app\/theme\.css — /,
|
|
269
|
+
);
|
|
270
|
+
expect(text.stderr).not.toMatch(/ERR_CODEMOD_PROTECTED/);
|
|
271
|
+
expect(text.stdout).toMatch(/Regenerate with: astryx theme build/);
|
|
272
|
+
expect(text.stdout).toMatch(/Upgrade failed/);
|
|
273
|
+
expect(`${text.stdout}\n${text.stderr}`).not.toMatch(
|
|
274
|
+
/No changes needed|Done!/,
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('name files from the folder the command runs in', () => {
|
|
279
|
+
seed();
|
|
280
|
+
write('app/theme.css', STALE_THEME);
|
|
281
|
+
|
|
282
|
+
const applied = run([...ONLY, '--path', '.', '--apply'], {
|
|
283
|
+
cwd: path.join(root, 'app'),
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
expect(applied.envelope.data).toMatchObject({
|
|
287
|
+
regenerate: [expect.objectContaining({file: 'theme.css'})],
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe('a real failure beside them', () => {
|
|
293
|
+
function seedFailing() {
|
|
294
|
+
seed({config: "export default {integrations: ['@acme/widgets']};\n"});
|
|
295
|
+
write(
|
|
296
|
+
'node_modules/@acme/widgets/package.json',
|
|
297
|
+
JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
298
|
+
);
|
|
299
|
+
write(
|
|
300
|
+
'node_modules/@acme/widgets/astryx.integration.mjs',
|
|
301
|
+
"export default {codemods: './codemods'};\n",
|
|
302
|
+
);
|
|
303
|
+
write(
|
|
304
|
+
'node_modules/@acme/widgets/codemods/0.7.0/fail.mjs',
|
|
305
|
+
"export default {type: 'code', title: 'Fail on boom', transform: file => { if (file.source.includes('boom')) throw new Error('codemod boom'); return undefined; }};\n",
|
|
306
|
+
);
|
|
307
|
+
write('src/broken.ts', 'export const boom = 1;\n');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
it('keeps the ERR_CODEMOD_FAILED error, whose receipt carries both lists', () => {
|
|
311
|
+
seedFailing();
|
|
312
|
+
|
|
313
|
+
const applied = run(['--from', '0.6.0', '--path', 'src', '--apply']);
|
|
314
|
+
|
|
315
|
+
expect(applied.status).toBe(1);
|
|
316
|
+
expect(applied.envelope).toMatchObject({
|
|
317
|
+
code: 'ERR_CODEMOD_FAILED',
|
|
318
|
+
receipt: {
|
|
319
|
+
complete: false,
|
|
320
|
+
errorCode: 'ERR_CODEMOD_FAILED',
|
|
321
|
+
errors: [
|
|
322
|
+
expect.objectContaining({
|
|
323
|
+
file: 'src/broken.ts',
|
|
324
|
+
codemod: '@acme/widgets:fail',
|
|
325
|
+
}),
|
|
326
|
+
],
|
|
327
|
+
declinedCandidates: [],
|
|
328
|
+
regenerate: [],
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('with a protected file to regenerate, returns the incomplete receipt as for a protected file', () => {
|
|
334
|
+
seedFailing();
|
|
335
|
+
write('src/theme.css', STALE_THEME);
|
|
336
|
+
|
|
337
|
+
const applied = run(['--from', '0.6.0', '--path', 'src', '--apply']);
|
|
338
|
+
|
|
339
|
+
expect(applied.status).toBe(1);
|
|
340
|
+
expect(applied.envelope).toMatchObject({
|
|
341
|
+
type: 'upgrade.run',
|
|
342
|
+
data: {
|
|
343
|
+
complete: false,
|
|
344
|
+
errorCode: 'ERR_CODEMOD_PROTECTED',
|
|
345
|
+
errors: [expect.objectContaining({file: 'src/broken.ts'})],
|
|
346
|
+
regenerate: [expect.objectContaining({file: 'src/theme.css'})],
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
});
|
package/clients/cli/index.mjs
CHANGED
|
@@ -552,6 +552,11 @@ describe('detectStylingSystem', () => {
|
|
|
552
552
|
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
553
553
|
});
|
|
554
554
|
|
|
555
|
+
it('detects the official unplugin (the standard Vite path)', () => {
|
|
556
|
+
writePkg({'@stylexjs/unplugin': '0.10.0'});
|
|
557
|
+
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
558
|
+
});
|
|
559
|
+
|
|
555
560
|
it('detects tailwind when tailwindcss is present', () => {
|
|
556
561
|
writePkg({tailwindcss: '4.0.0'});
|
|
557
562
|
expect(detectStylingSystem(tmpDir)).toBe('tailwind');
|
|
@@ -127,7 +127,8 @@ export function docStem(docPath: string): string;
|
|
|
127
127
|
/**
|
|
128
128
|
* The local module a doc's import names: the doc's own `import`, else the
|
|
129
129
|
* subpath its directory publishes, read through the package's `exports` (its
|
|
130
|
-
* `main` when it has none).
|
|
130
|
+
* `main` when it has none). A subpath's `source` condition wins when its file
|
|
131
|
+
* is in the package, so the answer does not depend on a build. Undefined when the package directory is unknown;
|
|
131
132
|
* null when the import names another package or resolves to no file.
|
|
132
133
|
*
|
|
133
134
|
* @param {{name?: string, __packageDir?: string, __packageExports?: Record<string, unknown>|null}} integration
|
|
@@ -705,6 +705,47 @@ describe('integration components a family doc lists in components', () => {
|
|
|
705
705
|
expect(namesIn(loaded)).toEqual(['AcmeList']);
|
|
706
706
|
});
|
|
707
707
|
|
|
708
|
+
it('reads members through the source condition, the same with or without built output', () => {
|
|
709
|
+
// The family's member is exported only from the root entry, as Lab's
|
|
710
|
+
// TourStep is.
|
|
711
|
+
const loaded = writePackage(
|
|
712
|
+
{
|
|
713
|
+
exports: {
|
|
714
|
+
'.': {
|
|
715
|
+
source: './src/index.ts',
|
|
716
|
+
types: './dist/index.d.ts',
|
|
717
|
+
default: './dist/index.js',
|
|
718
|
+
},
|
|
719
|
+
},
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
'src/index.ts':
|
|
723
|
+
"export {AcmeList} from './list/AcmeList';\nexport {AcmeListRow} from './list/row';\n",
|
|
724
|
+
'src/list/AcmeList.doc.mjs': family(
|
|
725
|
+
'AcmeList',
|
|
726
|
+
"{name: 'AcmeList', description: 'x'}, {name: 'AcmeListRow', description: 'x'}",
|
|
727
|
+
),
|
|
728
|
+
'src/list/AcmeList.tsx':
|
|
729
|
+
'export function AcmeList() { return null; }\n',
|
|
730
|
+
'src/list/row.tsx': 'export function AcmeListRow() { return null; }\n',
|
|
731
|
+
},
|
|
732
|
+
);
|
|
733
|
+
expect(namesIn(loaded)).toEqual(['AcmeList', 'AcmeListRow']);
|
|
734
|
+
expect(findIntegrationComponentSource(loaded, 'AcmeListRow')).toBe(
|
|
735
|
+
path.join(root, 'src', 'list', 'row.tsx'),
|
|
736
|
+
);
|
|
737
|
+
// Built output, even a stale one without the member, changes nothing.
|
|
738
|
+
fs.mkdirSync(path.join(root, 'dist'), {recursive: true});
|
|
739
|
+
fs.writeFileSync(
|
|
740
|
+
path.join(root, 'dist', 'index.js'),
|
|
741
|
+
'export function AcmeList() { return null; }\n',
|
|
742
|
+
);
|
|
743
|
+
expect(namesIn(loaded)).toEqual(['AcmeList', 'AcmeListRow']);
|
|
744
|
+
// A package that does not ship its source reads the built output.
|
|
745
|
+
fs.rmSync(path.join(root, 'src', 'index.ts'));
|
|
746
|
+
expect(namesIn(loaded)).toEqual(['AcmeList']);
|
|
747
|
+
});
|
|
748
|
+
|
|
708
749
|
it('lists a member another folder declares, with no source', async () => {
|
|
709
750
|
const loaded = writePackage(
|
|
710
751
|
{exports: {'./menu': './src/menu/index.ts'}},
|
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
moduleExportsName,
|
|
19
19
|
staticExportObject,
|
|
20
20
|
} from './module-exports.mjs';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
inspectPackageExport,
|
|
23
|
+
sourceExportTarget,
|
|
24
|
+
} from './package-exports.mjs';
|
|
22
25
|
|
|
23
26
|
const require = createRequire(import.meta.url);
|
|
24
27
|
|
|
@@ -996,7 +999,8 @@ function packageMain(packageDir) {
|
|
|
996
999
|
/**
|
|
997
1000
|
* The local module a doc's import names: the doc's own `import`, else the
|
|
998
1001
|
* subpath its directory publishes, read through the package's `exports` (its
|
|
999
|
-
* `main` when it has none).
|
|
1002
|
+
* `main` when it has none). A subpath's `source` condition wins when its file
|
|
1003
|
+
* is in the package, so the answer does not depend on a build. Undefined when the package directory is unknown;
|
|
1000
1004
|
* null when the import names another package or resolves to no file.
|
|
1001
1005
|
*
|
|
1002
1006
|
* @param {{name?: string, __packageDir?: string, __packageExports?: Record<string, unknown>|null}} integration
|
|
@@ -1027,11 +1031,13 @@ export function importedModule(integration, docPath, doc) {
|
|
|
1027
1031
|
specifier === packageName
|
|
1028
1032
|
? '.'
|
|
1029
1033
|
: `./${specifier.slice(packageName.length + 1)}`;
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1034
|
+
const pkg = {name: packageName, exports: exportsMap ?? undefined};
|
|
1035
|
+
// The `source` condition first, when its file is there, so a family lists
|
|
1036
|
+
// the same members whether or not the package has been built.
|
|
1037
|
+
return (
|
|
1038
|
+
sourceExportTarget(pkg, packageDir, subpath) ??
|
|
1039
|
+
inspectPackageExport(pkg, packageDir, subpath).target
|
|
1040
|
+
);
|
|
1035
1041
|
}
|
|
1036
1042
|
|
|
1037
1043
|
/**
|
|
@@ -28,9 +28,8 @@ export function iconSetIssues(packageDir: string, loaded: {
|
|
|
28
28
|
* Astryx's optional (not built-in) definitions the set's `map` does not
|
|
29
29
|
* name. Mapping them is optional, so they never fail a check.
|
|
30
30
|
* @property {Array<{definition: string, icon: string}>} suggestions for every
|
|
31
|
-
* unmapped definition, built-in, optional, or the set's own, the icon
|
|
32
|
-
*
|
|
33
|
-
* beyond that
|
|
31
|
+
* unmapped definition, built-in, optional, or the set's own, the best icon
|
|
32
|
+
* {@link suggestedIcons} gives, if any
|
|
34
33
|
* @property {IconSetUnchecked[]} unchecked what the checks could not judge:
|
|
35
34
|
* never counted, never failing, even under `--strict`
|
|
36
35
|
*/
|
|
@@ -48,9 +47,8 @@ export function iconSetCoverage(loaded: {
|
|
|
48
47
|
iconSets?: string;
|
|
49
48
|
}, unchecked?: Map<string, IconSetUnchecked[]>): IconSetCoverage[];
|
|
50
49
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
53
|
-
* when none is: a suggestion is never a guess from parts of words.
|
|
50
|
+
* The best icon {@link suggestedIcons} gives for a definition, or null when
|
|
51
|
+
* it gives none.
|
|
54
52
|
* @param {DiscoveredIconSet} set
|
|
55
53
|
* @param {import('../../authoring/doctypes/icon-definition/type').IconDefinitionDoc} doc
|
|
56
54
|
* @returns {{map: string, icon: string} | null}
|
|
@@ -59,6 +57,41 @@ export function suggestIcon(set: DiscoveredIconSet, doc: import("../../authoring
|
|
|
59
57
|
map: string;
|
|
60
58
|
icon: string;
|
|
61
59
|
} | null;
|
|
60
|
+
/**
|
|
61
|
+
* The icons a definition might map to, best first, at most three, in the
|
|
62
|
+
* order AST-084 FR13 gives: the name in another spelling, an icon the library
|
|
63
|
+
* gives the name as another name, ids that start with the name (`video` →
|
|
64
|
+
* `video-camera`, never `close` → `panel-left-close`), an id that is one of
|
|
65
|
+
* its words (`delete` → `trash`), another name that is one of its words, and
|
|
66
|
+
* two-word ids that are a one-word word sized, shaped, or numbered
|
|
67
|
+
* (`grid-2x2`). An icon `map` already names
|
|
68
|
+
* for another definition, or whose id is another definition's name, is left
|
|
69
|
+
* out: it has a meaning of its own. Never a negated form or the opposite
|
|
70
|
+
* direction, and never a guess from parts of words.
|
|
71
|
+
* @param {{data: {icons: Array<{id: string, words?: string[]}>, map?: Record<string, string>}, definitions?: Array<{doc: {name: string}}>}} set
|
|
72
|
+
* @param {{name: string, words: string[]}} doc
|
|
73
|
+
* @returns {Array<{icon: string, word: string}>}
|
|
74
|
+
*/
|
|
75
|
+
export function suggestedIcons(set: {
|
|
76
|
+
data: {
|
|
77
|
+
icons: Array<{
|
|
78
|
+
id: string;
|
|
79
|
+
words?: string[];
|
|
80
|
+
}>;
|
|
81
|
+
map?: Record<string, string>;
|
|
82
|
+
};
|
|
83
|
+
definitions?: Array<{
|
|
84
|
+
doc: {
|
|
85
|
+
name: string;
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
}, doc: {
|
|
89
|
+
name: string;
|
|
90
|
+
words: string[];
|
|
91
|
+
}): Array<{
|
|
92
|
+
icon: string;
|
|
93
|
+
word: string;
|
|
94
|
+
}>;
|
|
62
95
|
/** @typedef {import('../integrations/issue').AstryxIntegrationIssue} Issue */
|
|
63
96
|
/** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
|
|
64
97
|
/** An invalid descriptor or data file. */
|
|
@@ -87,6 +120,8 @@ export const ICON_DEFINITION_UNUSED: "icon_definition_unused";
|
|
|
87
120
|
export const ICON_SOURCE_VERSION_DRIFT: "icon_source_version_drift";
|
|
88
121
|
/** A set with an upstream and no license notice. */
|
|
89
122
|
export const ICON_LICENSE_NOTICE_MISSING: "icon_license_notice_missing";
|
|
123
|
+
/** How many icons one definition is suggested at most. */
|
|
124
|
+
export const SUGGESTIONS_PER_DEFINITION: 3;
|
|
90
125
|
/**
|
|
91
126
|
* One item a check could not judge: listed, never counted, never failing.
|
|
92
127
|
*/
|
|
@@ -124,9 +159,8 @@ export type IconSetCoverage = {
|
|
|
124
159
|
}>;
|
|
125
160
|
/**
|
|
126
161
|
* for every
|
|
127
|
-
* unmapped definition, built-in, optional, or the set's own, the icon
|
|
128
|
-
*
|
|
129
|
-
* beyond that
|
|
162
|
+
* unmapped definition, built-in, optional, or the set's own, the best icon
|
|
163
|
+
* {@link suggestedIcons} gives, if any
|
|
130
164
|
*/
|
|
131
165
|
suggestions: Array<{
|
|
132
166
|
definition: string;
|