@astryxdesign/cli 0.7.4 → 0.7.5-canary.04434e7
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 +19 -19
- 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/unknown-name.test.mjs +63 -0
- package/api/upgrade/run/failure-receipt.test.mjs +155 -0
- package/api/upgrade/run/run.mjs +170 -8
- package/api/upgrade/upgrade.doc.mjs +4 -4
- package/api/upgrade/upgrade.mjs +19 -4
- package/api/upgrade/upgrade.type.d.mts +12 -1
- package/api/upgrade/upgrade.type.mjs +16 -3
- package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
- package/assets/codemods/integration-runner.mjs +1 -1
- package/assets/codemods/run-codemod.mjs +17 -3
- package/assets/codemods/runner.mjs +81 -8
- package/assets/codemods/transform-prop.mjs +99 -49
- package/assets/codemods/transform-prop.test.mjs +36 -1
- 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 +123 -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 +200 -32
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +19 -77
- package/assets/discover/official-packages.json +4 -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/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/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 +9 -8
- 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/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -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/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 +17 -0
- package/clients/cli/commands/upgrade.file-protection.test.mjs +29 -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/index.mjs +1 -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 +20 -5
- 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 +38 -1
- 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 +14 -9
|
@@ -61,22 +61,85 @@ const IGNORED_DIRS = new Set([
|
|
|
61
61
|
]);
|
|
62
62
|
export {IGNORED_DIRS};
|
|
63
63
|
|
|
64
|
+
/** Yarn's install and cache folders, a hard boundary under `.yarn`. */
|
|
65
|
+
const YARN_STORE_DIRS = new Set(['__virtual__', 'cache', 'sdks', 'unplugged']);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The number of path segments a hard boundary starting at `parts[index]`
|
|
69
|
+
* spans: 1 for a name in {@link IGNORED_DIRS}, 2 for `.yarn` followed by one
|
|
70
|
+
* of its store folders, 0 when none starts there.
|
|
71
|
+
* @param {string[]} parts
|
|
72
|
+
* @param {number} index
|
|
73
|
+
*/
|
|
74
|
+
function boundaryLength(parts, index) {
|
|
75
|
+
if (IGNORED_DIRS.has(parts[index])) return 1;
|
|
76
|
+
if (parts[index] === '.yarn' && YARN_STORE_DIRS.has(parts[index + 1])) {
|
|
77
|
+
return 2;
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
/** @param {string} root @param {string} fullPath @param {string} name */
|
|
65
83
|
export function isIgnoredDirectory(root, fullPath, name) {
|
|
66
84
|
if (IGNORED_DIRS.has(name)) return true;
|
|
67
85
|
const parts = path.relative(root, fullPath).split(path.sep);
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
return boundaryLength(parts, 0) === 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether a symbolic link to a directory leads into a tree the scan never
|
|
91
|
+
* descends. The link is checked like a directory by {@link isIgnoredDirectory},
|
|
92
|
+
* and its resolved target's absolute path is searched for the same hard
|
|
93
|
+
* boundaries, wherever the target lives: a symlinked `node_modules`, or a link
|
|
94
|
+
* into a dependency, package-store or version-control tree such as another
|
|
95
|
+
* project's `.yarn/cache`, is not walked. Only a target that stays inside the
|
|
96
|
+
* operation root may sit below a boundary that also contains that root, so a
|
|
97
|
+
* project that itself lives below a `node_modules` folder is still scanned; a
|
|
98
|
+
* link from it to a sibling package under that same folder is not.
|
|
99
|
+
* @param {string} root scan root
|
|
100
|
+
* @param {string} fullPath the link's path
|
|
101
|
+
* @param {string} name the link's name
|
|
102
|
+
* @param {string} realTarget the link's resolved real path
|
|
103
|
+
* @param {string} [operationRoot] the project root of the operation (default: the scan root)
|
|
104
|
+
* @returns {boolean}
|
|
105
|
+
*/
|
|
106
|
+
export function isIgnoredLinkedDirectory(
|
|
107
|
+
root,
|
|
108
|
+
fullPath,
|
|
109
|
+
name,
|
|
110
|
+
realTarget,
|
|
111
|
+
operationRoot = root,
|
|
112
|
+
) {
|
|
113
|
+
if (isIgnoredDirectory(root, fullPath, name)) return true;
|
|
114
|
+
let realRoot = operationRoot;
|
|
115
|
+
try {
|
|
116
|
+
realRoot = fs.realpathSync(operationRoot);
|
|
117
|
+
} catch {
|
|
118
|
+
// An unreadable root has no descendants to compare against.
|
|
119
|
+
}
|
|
120
|
+
const relative = path.relative(realRoot, realTarget);
|
|
121
|
+
const inside =
|
|
122
|
+
relative === '' ||
|
|
123
|
+
(relative !== '..' &&
|
|
124
|
+
!relative.startsWith(`..${path.sep}`) &&
|
|
125
|
+
!path.isAbsolute(relative));
|
|
126
|
+
// Inside the root, only a boundary that ends below the root counts.
|
|
127
|
+
const floor = inside ? realRoot.split(path.sep).length : 0;
|
|
128
|
+
const targetParts = realTarget.split(path.sep);
|
|
129
|
+
for (let index = 0; index < targetParts.length; index++) {
|
|
130
|
+
const length = boundaryLength(targetParts, index);
|
|
131
|
+
if (length > 0 && index + length > floor) return true;
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
72
134
|
}
|
|
73
135
|
|
|
74
136
|
/**
|
|
75
137
|
* Recursively find all source files in a directory.
|
|
76
138
|
* @param {string} dir
|
|
139
|
+
* @param {string} [root] the operation's project root (default: `dir`)
|
|
77
140
|
* @returns {string[]}
|
|
78
141
|
*/
|
|
79
|
-
function findSourceFiles(dir) {
|
|
142
|
+
function findSourceFiles(dir, root = dir) {
|
|
80
143
|
/** @type {string[]} */
|
|
81
144
|
const results = [];
|
|
82
145
|
const extensions = new Set([
|
|
@@ -112,13 +175,23 @@ function findSourceFiles(dir) {
|
|
|
112
175
|
for (const entry of entries) {
|
|
113
176
|
const fullPath = path.join(currentDir, entry.name);
|
|
114
177
|
// Symlinked files and descendants remain read-only candidates so a
|
|
115
|
-
// required change can be reported. Real-path ancestors prevent cycles
|
|
178
|
+
// required change can be reported. Real-path ancestors prevent cycles,
|
|
179
|
+
// and a link into a dependency or VCS tree is not descended.
|
|
116
180
|
if (entry.isSymbolicLink()) {
|
|
117
181
|
try {
|
|
118
182
|
const target = fs.statSync(fullPath);
|
|
119
183
|
if (target.isFile() && extensions.has(path.extname(entry.name))) {
|
|
120
184
|
results.push(fullPath);
|
|
121
|
-
} else if (
|
|
185
|
+
} else if (
|
|
186
|
+
target.isDirectory() &&
|
|
187
|
+
!isIgnoredLinkedDirectory(
|
|
188
|
+
dir,
|
|
189
|
+
fullPath,
|
|
190
|
+
entry.name,
|
|
191
|
+
fs.realpathSync(fullPath),
|
|
192
|
+
root,
|
|
193
|
+
)
|
|
194
|
+
) {
|
|
122
195
|
walk(fullPath, nextAncestors);
|
|
123
196
|
}
|
|
124
197
|
} catch {
|
|
@@ -472,7 +545,7 @@ export async function runCodemods(
|
|
|
472
545
|
let files = [];
|
|
473
546
|
if (sourcePathExists) {
|
|
474
547
|
log.step(`Scanning ${resolvedPath} for source files...`);
|
|
475
|
-
files = findSourceFiles(resolvedPath);
|
|
548
|
+
files = findSourceFiles(resolvedPath, path.resolve(root));
|
|
476
549
|
if (files.length === 0) {
|
|
477
550
|
log.warn('No source files found.');
|
|
478
551
|
} else {
|
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Find imported components, resolve their local
|
|
5
|
-
* and yield matching JSX prop paths to a
|
|
4
|
+
* Find imported components, resolve their local names (including aliases and
|
|
5
|
+
* namespace members) at a use site, and yield matching JSX prop paths to a
|
|
6
|
+
* visitor.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* variables, helper calls, object spreads, wrapper components, or types.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
* `transformProp` intentionally stops at the JSX boundary. It does not follow
|
|
9
|
+
* variables, helper calls, object spreads, wrapper components, or types. The
|
|
10
|
+
* resolver it is built on (`importedComponents`, `resolveImportedComponent`,
|
|
11
|
+
* `isModuleBinding`) is exported for transforms that prove other use sites.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{
|
|
13
16
|
* matchesImport: (source: string) => boolean,
|
|
14
17
|
* components: ReadonlyMap<string, ReadonlySet<string>>,
|
|
15
18
|
* normalizeComponentName?: (name: string) => string,
|
|
16
|
-
* }}
|
|
17
|
-
* @param {(propPath: any, context: {component: string, localName: string}) => void} visit
|
|
19
|
+
* }} ImportOptions
|
|
18
20
|
*/
|
|
19
|
-
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* direct: Map<string, {component: string, props: ReadonlySet<string>}>,
|
|
25
|
+
* namespaces: Set<string>,
|
|
26
|
+
* normalize: (name: string) => string,
|
|
27
|
+
* components: ReadonlyMap<string, ReadonlySet<string>>,
|
|
28
|
+
* }} ImportedComponents
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Local names bound by accepted runtime imports: named, aliased and default
|
|
33
|
+
* component imports, and namespace imports.
|
|
34
|
+
* @param {any} root jscodeshift collection for one source file
|
|
35
|
+
* @param {any} j configured jscodeshift instance
|
|
36
|
+
* @param {ImportOptions} options
|
|
37
|
+
* @returns {ImportedComponents}
|
|
38
|
+
*/
|
|
39
|
+
export function importedComponents(root, j, options) {
|
|
20
40
|
const normalize = options.normalizeComponentName ?? (name => name);
|
|
21
|
-
/** @type {
|
|
22
|
-
const
|
|
41
|
+
/** @type {ImportedComponents['direct']} */
|
|
42
|
+
const direct = new Map();
|
|
23
43
|
/** @type {Set<string>} */
|
|
24
|
-
const
|
|
44
|
+
const namespaces = new Set();
|
|
25
45
|
|
|
26
46
|
root.find(j.ImportDeclaration).forEach((/** @type {any} */ importPath) => {
|
|
27
47
|
const source = importPath.node.source.value;
|
|
@@ -46,53 +66,83 @@ export function transformProp(root, j, options, visit) {
|
|
|
46
66
|
const component = normalize(importedName);
|
|
47
67
|
const props = options.components.get(component);
|
|
48
68
|
if (!props) continue;
|
|
49
|
-
|
|
50
|
-
component,
|
|
51
|
-
props,
|
|
52
|
-
});
|
|
69
|
+
direct.set(specifier.local?.name ?? importedName, {component, props});
|
|
53
70
|
} else if (specifier.type === 'ImportDefaultSpecifier' && subpathProps) {
|
|
54
|
-
|
|
71
|
+
direct.set(specifier.local.name, {
|
|
55
72
|
component: subpathName,
|
|
56
73
|
props: subpathProps,
|
|
57
74
|
});
|
|
58
75
|
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
59
|
-
|
|
76
|
+
namespaces.add(specifier.local.name);
|
|
60
77
|
}
|
|
61
78
|
}
|
|
62
79
|
});
|
|
63
80
|
|
|
64
|
-
|
|
81
|
+
return {direct, namespaces, normalize, components: options.components};
|
|
82
|
+
}
|
|
65
83
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
/**
|
|
85
|
+
* True when `localName` at `path` resolves to a module-scope binding. A
|
|
86
|
+
* parameter or local declaration with the same name shadows the import.
|
|
87
|
+
* @param {any} path any node path inside the file
|
|
88
|
+
* @param {string} localName
|
|
89
|
+
*/
|
|
90
|
+
export function isModuleBinding(path, localName) {
|
|
91
|
+
return path.scope?.lookup(localName)?.path.node.type === 'Program';
|
|
92
|
+
}
|
|
71
93
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Resolve a component reference (`Card`, `Lib.Card`, or their JSX forms) to
|
|
96
|
+
* the imported component it names at `scopePath`, or null.
|
|
97
|
+
* @param {any} nameNode Identifier, JSXIdentifier, MemberExpression, or JSXMemberExpression
|
|
98
|
+
* @param {any} scopePath the path whose scope the reference is evaluated in
|
|
99
|
+
* @param {ImportedComponents} imports
|
|
100
|
+
* @returns {{component: string, props: ReadonlySet<string>, localName: string} | null}
|
|
101
|
+
*/
|
|
102
|
+
export function resolveImportedComponent(nameNode, scopePath, imports) {
|
|
103
|
+
let localName;
|
|
104
|
+
let binding;
|
|
105
|
+
if (nameNode?.type === 'JSXIdentifier' || nameNode?.type === 'Identifier') {
|
|
106
|
+
localName = nameNode.name;
|
|
107
|
+
binding = imports.direct.get(localName);
|
|
108
|
+
} else if (
|
|
109
|
+
(nameNode?.type === 'JSXMemberExpression' ||
|
|
110
|
+
(nameNode?.type === 'MemberExpression' && !nameNode.computed)) &&
|
|
111
|
+
(nameNode.object?.type === 'JSXIdentifier' ||
|
|
112
|
+
nameNode.object?.type === 'Identifier') &&
|
|
113
|
+
(nameNode.property?.type === 'JSXIdentifier' ||
|
|
114
|
+
nameNode.property?.type === 'Identifier') &&
|
|
115
|
+
imports.namespaces.has(nameNode.object.name)
|
|
116
|
+
) {
|
|
117
|
+
localName = nameNode.object.name;
|
|
118
|
+
const component = imports.normalize(nameNode.property.name);
|
|
119
|
+
const props = imports.components.get(component);
|
|
120
|
+
if (props) binding = {component, props};
|
|
121
|
+
}
|
|
122
|
+
if (!binding || !isModuleBinding(scopePath, localName)) return null;
|
|
123
|
+
return {...binding, localName};
|
|
124
|
+
}
|
|
90
125
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
126
|
+
/**
|
|
127
|
+
* @param {any} root jscodeshift collection for one source file
|
|
128
|
+
* @param {any} j configured jscodeshift instance
|
|
129
|
+
* @param {ImportOptions} options
|
|
130
|
+
* @param {(propPath: any, context: {component: string, localName: string}) => void} visit
|
|
131
|
+
*/
|
|
132
|
+
export function transformProp(root, j, options, visit) {
|
|
133
|
+
const imports = importedComponents(root, j, options);
|
|
134
|
+
if (imports.direct.size === 0 && imports.namespaces.size === 0) return;
|
|
135
|
+
|
|
136
|
+
root.find(j.JSXOpeningElement).forEach((/** @type {any} */ jsxPath) => {
|
|
137
|
+
// Only JSX tags whose root binding resolves to Program are usages of the
|
|
138
|
+
// import discovered above.
|
|
139
|
+
const resolved = resolveImportedComponent(
|
|
140
|
+
jsxPath.node.name,
|
|
141
|
+
jsxPath,
|
|
142
|
+
imports,
|
|
143
|
+
);
|
|
144
|
+
if (!resolved) return;
|
|
145
|
+
const {component, props, localName} = resolved;
|
|
96
146
|
|
|
97
147
|
for (let index = 0; index < jsxPath.node.attributes.length; index++) {
|
|
98
148
|
const attribute = jsxPath.node.attributes[index];
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import {describe, expect, it} from 'vitest';
|
|
4
4
|
import jscodeshift from 'jscodeshift';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
importedComponents,
|
|
7
|
+
resolveImportedComponent,
|
|
8
|
+
transformProp,
|
|
9
|
+
} from './transform-prop.mjs';
|
|
6
10
|
|
|
7
11
|
const j = jscodeshift.withParser('tsx');
|
|
8
12
|
const components = new Map([
|
|
@@ -92,4 +96,35 @@ const b = <Group tone="old" size="old" />;`);
|
|
|
92
96
|
expect(output).toContain('<Widget size="old" migratedtone="old"');
|
|
93
97
|
expect(output).toContain('<Group tone="old" migratedsize="old"');
|
|
94
98
|
});
|
|
99
|
+
|
|
100
|
+
it('resolves non-JSX references through the same import and shadow rules', () => {
|
|
101
|
+
const root = j(`import {Widget as Card} from '@example/core';
|
|
102
|
+
import * as Lib from '@example/core';
|
|
103
|
+
const a = Card;
|
|
104
|
+
const b = Lib.Group;
|
|
105
|
+
function shadow(Card, Lib) {
|
|
106
|
+
return [Card, Lib.Group];
|
|
107
|
+
}`);
|
|
108
|
+
const imports = importedComponents(root, j, {
|
|
109
|
+
matchesImport: value => /^@example\/core(?:\/|$)/.test(value),
|
|
110
|
+
components,
|
|
111
|
+
});
|
|
112
|
+
const resolved = root
|
|
113
|
+
.find(j.VariableDeclarator)
|
|
114
|
+
.paths()
|
|
115
|
+
.map(
|
|
116
|
+
path =>
|
|
117
|
+
resolveImportedComponent(path.node.init, path, imports)?.component,
|
|
118
|
+
);
|
|
119
|
+
expect(resolved).toEqual(['Widget', 'Group']);
|
|
120
|
+
const shadowed = root
|
|
121
|
+
.find(j.ArrayExpression)
|
|
122
|
+
.paths()
|
|
123
|
+
.flatMap(path =>
|
|
124
|
+
path.node.elements.map(element =>
|
|
125
|
+
resolveImportedComponent(element, path, imports),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
expect(shadowed).toEqual([null, null]);
|
|
129
|
+
});
|
|
95
130
|
});
|
package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as os from 'node:os';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
4
7
|
import jscodeshift from 'jscodeshift';
|
|
5
8
|
import manifest from '../index.mjs';
|
|
6
9
|
import transform, {
|
|
@@ -16,6 +19,38 @@ function apply(source, filePath = 'theme.ts') {
|
|
|
16
19
|
return transform({source, path: filePath}, api) ?? source;
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
/** A proven theme: an object passed to Astryx's imported defineTheme(). */
|
|
23
|
+
function defined(components) {
|
|
24
|
+
return `${IMPORT}export default defineTheme({name: 'brand', components: ${components}});`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const THEME_DOC = `/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
|
|
28
|
+
export default {
|
|
29
|
+
type: 'theme',
|
|
30
|
+
name: 'brand',
|
|
31
|
+
displayName: 'Brand',
|
|
32
|
+
description: 'A brand theme.',
|
|
33
|
+
maintained: false,
|
|
34
|
+
};
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const tempDirs = [];
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
for (const dir of tempDirs.splice(0)) {
|
|
40
|
+
fs.rmSync(dir, {recursive: true, force: true});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/** Write `files` into a fresh directory and return its path. */
|
|
45
|
+
function folder(files) {
|
|
46
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-surface-'));
|
|
47
|
+
tempDirs.push(dir);
|
|
48
|
+
for (const [name, content] of Object.entries(files)) {
|
|
49
|
+
fs.writeFileSync(path.join(dir, name), content);
|
|
50
|
+
}
|
|
51
|
+
return dir;
|
|
52
|
+
}
|
|
53
|
+
|
|
19
54
|
const EXPECTED_TARGETS = {
|
|
20
55
|
'base-table': 'table',
|
|
21
56
|
checkbox: 'checkbox-indicator',
|
|
@@ -60,7 +95,7 @@ describe('migrate-deprecated-theme-surface', () => {
|
|
|
60
95
|
'renames static target key %s to %s inside a components map',
|
|
61
96
|
(oldKey, newKey) => {
|
|
62
97
|
const output = apply(
|
|
63
|
-
`
|
|
98
|
+
defined(`{${JSON.stringify(oldKey)}: {base: {color: 'red'}}}`),
|
|
64
99
|
);
|
|
65
100
|
|
|
66
101
|
expect(output).not.toContain(`${JSON.stringify(oldKey)}:`);
|
|
@@ -103,12 +138,114 @@ export const theme = defineTheme({name: 'brand', components});`);
|
|
|
103
138
|
}
|
|
104
139
|
});
|
|
105
140
|
|
|
141
|
+
it('does not rewrite a look-alike theme object from another library', () => {
|
|
142
|
+
const input = `export const muiTheme = {
|
|
143
|
+
name: 'brand',
|
|
144
|
+
components: {checkbox: {root: {color: 'red'}}, radio: {root: {}}, textarea: {root: {}}},
|
|
145
|
+
};`;
|
|
146
|
+
expect(apply(input, 'src/muiTheme.ts')).toBe(input);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('does not take a file-level Astryx import as proof for a look-alike object', () => {
|
|
150
|
+
const input = `import {Button} from '@astryxdesign/core';
|
|
151
|
+
export const editorTheme = {name: 'editor', components: {textarea: {root: {}}}};`;
|
|
152
|
+
expect(apply(input, 'src/editorTheme.ts')).toBe(input);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('renames a direct theme object in a source its theme descriptor declares', () => {
|
|
156
|
+
const dir = folder({'brandTheme.doc.mjs': THEME_DOC});
|
|
157
|
+
const output = apply(
|
|
158
|
+
`export const brandTheme = {name: 'brand', components: {navicon: {base: {}}}};`,
|
|
159
|
+
path.join(dir, 'brandTheme.ts'),
|
|
160
|
+
);
|
|
161
|
+
expect(output).toContain("'nav-icon':");
|
|
162
|
+
expect(output).not.toMatch(/navicon\s*:/);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('renames only the declared theme binding in a described theme source', () => {
|
|
166
|
+
const dir = folder({'brandTheme.doc.mjs': THEME_DOC});
|
|
167
|
+
const output = apply(
|
|
168
|
+
`export const brandTheme = {name: 'brand', components: {navicon: {base: {}}}};
|
|
169
|
+
export const otherLibraryTheme = {
|
|
170
|
+
name: 'other',
|
|
171
|
+
components: {checkbox: {root: {}}, textarea: {root: {}}},
|
|
172
|
+
};`,
|
|
173
|
+
path.join(dir, 'brandTheme.ts'),
|
|
174
|
+
);
|
|
175
|
+
expect(output).toContain("'nav-icon':");
|
|
176
|
+
expect(output).toContain(
|
|
177
|
+
'components: {checkbox: {root: {}}, textarea: {root: {}}}',
|
|
178
|
+
);
|
|
179
|
+
expect(output).not.toContain('checkbox-indicator');
|
|
180
|
+
expect(output).not.toContain('text-area');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('follows a local binding exported under the descriptor name', () => {
|
|
184
|
+
const dir = folder({'brandTheme.doc.mjs': THEME_DOC});
|
|
185
|
+
const output = apply(
|
|
186
|
+
`const theme = {name: 'brand', components: {navicon: {base: {}}}} as const;
|
|
187
|
+
export {theme as brandTheme};`,
|
|
188
|
+
path.join(dir, 'brandTheme.ts'),
|
|
189
|
+
);
|
|
190
|
+
expect(output).toContain("'nav-icon':");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('does not treat an unexported or nested same-named object as the declared theme', () => {
|
|
194
|
+
const dir = folder({'brandTheme.doc.mjs': THEME_DOC});
|
|
195
|
+
for (const input of [
|
|
196
|
+
`const brandTheme = {name: 'brand', components: {navicon: {base: {}}}};`,
|
|
197
|
+
`export function make() {
|
|
198
|
+
const brandTheme = {name: 'brand', components: {navicon: {base: {}}}};
|
|
199
|
+
return brandTheme;
|
|
200
|
+
}`,
|
|
201
|
+
]) {
|
|
202
|
+
expect(apply(input, path.join(dir, 'brandTheme.ts'))).toBe(input);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('does not treat a descriptor for another stem or kind as theme proof', () => {
|
|
207
|
+
const input = `export const brandTheme = {name: 'brand', components: {navicon: {base: {}}}};`;
|
|
208
|
+
const otherStem = folder({'otherTheme.doc.mjs': THEME_DOC});
|
|
209
|
+
expect(apply(input, path.join(otherStem, 'brandTheme.ts'))).toBe(input);
|
|
210
|
+
const otherKind = folder({
|
|
211
|
+
'brandTheme.doc.mjs': 'export default {name: "brand", props: []};\n',
|
|
212
|
+
});
|
|
213
|
+
expect(apply(input, path.join(otherKind, 'brandTheme.ts'))).toBe(input);
|
|
214
|
+
});
|
|
215
|
+
|
|
106
216
|
it('does not treat a defineTheme from another library as an Astryx theme', () => {
|
|
107
217
|
const input = `import {defineTheme} from 'other-ui';
|
|
108
218
|
export default defineTheme({components: {checkbox: {base: {color: 'red'}}}});`;
|
|
109
219
|
expect(apply(input)).toBe(input);
|
|
110
220
|
});
|
|
111
221
|
|
|
222
|
+
it.each([
|
|
223
|
+
[
|
|
224
|
+
'named defineTheme',
|
|
225
|
+
`import {defineTheme} from '@astryxdesign/core';
|
|
226
|
+
function unrelated(defineTheme) {
|
|
227
|
+
return defineTheme({name: 'fake', components: {checkbox: {root: {}}}});
|
|
228
|
+
}`,
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
'aliased defineTheme',
|
|
232
|
+
`import {defineTheme as makeTheme} from '@astryxdesign/core';
|
|
233
|
+
function unrelated() {
|
|
234
|
+
const makeTheme = otherLibrary.createTheme;
|
|
235
|
+
return makeTheme({name: 'fake', components: {checkbox: {root: {}}}});
|
|
236
|
+
}`,
|
|
237
|
+
],
|
|
238
|
+
[
|
|
239
|
+
'namespace defineTheme',
|
|
240
|
+
`import * as Astryx from '@astryxdesign/core';
|
|
241
|
+
function unrelated(Astryx) {
|
|
242
|
+
return Astryx.defineTheme({name: 'fake', components: {checkbox: {root: {}}}});
|
|
243
|
+
}`,
|
|
244
|
+
],
|
|
245
|
+
])('does not treat a shadowed %s as an Astryx call', (_name, input) => {
|
|
246
|
+
expect(apply(input)).toBe(input);
|
|
247
|
+
});
|
|
248
|
+
|
|
112
249
|
it.each([
|
|
113
250
|
[
|
|
114
251
|
'an aliased defineTheme import',
|
|
@@ -141,9 +278,54 @@ const brand: DefineThemeInput = {name: 'brand', components: {navicon: {base: {}}
|
|
|
141
278
|
expect(output).not.toMatch(/navicon\s*:/);
|
|
142
279
|
});
|
|
143
280
|
|
|
281
|
+
it.each([
|
|
282
|
+
[
|
|
283
|
+
'a locally redeclared named type',
|
|
284
|
+
`import type {DefineThemeInput} from '@astryxdesign/core';
|
|
285
|
+
function unrelated() {
|
|
286
|
+
type DefineThemeInput = OtherTheme;
|
|
287
|
+
return {name: 'fake', components: {checkbox: {root: {}}}} satisfies DefineThemeInput;
|
|
288
|
+
}`,
|
|
289
|
+
],
|
|
290
|
+
[
|
|
291
|
+
'an aliased type shadowed by a type parameter',
|
|
292
|
+
`import type {DefineThemeInput as Theme} from '@astryxdesign/core';
|
|
293
|
+
function unrelated<Theme>(value: unknown) {
|
|
294
|
+
const theme: Theme = {name: 'fake', components: {checkbox: {root: {}}}};
|
|
295
|
+
return theme;
|
|
296
|
+
}`,
|
|
297
|
+
],
|
|
298
|
+
[
|
|
299
|
+
'a namespace shadowed by a type parameter',
|
|
300
|
+
`import type * as Astryx from '@astryxdesign/core';
|
|
301
|
+
function unrelated<Astryx>() {
|
|
302
|
+
return {name: 'fake', components: {checkbox: {root: {}}}} satisfies Astryx.DefineThemeInput;
|
|
303
|
+
}`,
|
|
304
|
+
],
|
|
305
|
+
[
|
|
306
|
+
'a namespace shadowed by a local namespace',
|
|
307
|
+
`import * as Astryx from '@astryxdesign/core';
|
|
308
|
+
function unrelated() {
|
|
309
|
+
namespace Astryx { export type DefineThemeInput = OtherTheme; }
|
|
310
|
+
return ({name: 'fake', components: {checkbox: {root: {}}}}) as Astryx.DefineThemeInput;
|
|
311
|
+
}`,
|
|
312
|
+
],
|
|
313
|
+
])('does not treat %s as an Astryx theme type', (_name, input) => {
|
|
314
|
+
expect(apply(input)).toBe(input);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('still recognizes an unshadowed theme type inside a function', () => {
|
|
318
|
+
const output =
|
|
319
|
+
apply(`import type {DefineThemeInput} from '@astryxdesign/core';
|
|
320
|
+
function makeTheme<T>() {
|
|
321
|
+
return {components: {navicon: {base: {}}}} satisfies DefineThemeInput;
|
|
322
|
+
}`);
|
|
323
|
+
expect(output).toContain("'nav-icon':");
|
|
324
|
+
});
|
|
325
|
+
|
|
144
326
|
it('renames a clear-icon alias with a TODO naming the owner scope it loses', () => {
|
|
145
327
|
const output = apply(
|
|
146
|
-
`
|
|
328
|
+
defined(`{'selector-clear-icon': {base: {color: 'red'}}}`),
|
|
147
329
|
);
|
|
148
330
|
expect(output).toContain("'input-clear-icon':");
|
|
149
331
|
expect(output).toContain(
|
|
@@ -155,10 +337,12 @@ const brand: DefineThemeInput = {name: 'brand', components: {navicon: {base: {}}
|
|
|
155
337
|
});
|
|
156
338
|
|
|
157
339
|
it('flags two clear-icon aliases that collapse onto the shared target', () => {
|
|
158
|
-
const output = apply(
|
|
340
|
+
const output = apply(
|
|
341
|
+
defined(`{
|
|
159
342
|
'selector-clear-icon': {base: {color: 'red'}},
|
|
160
343
|
'date-input-clear-icon': {base: {color: 'blue'}},
|
|
161
|
-
}
|
|
344
|
+
}`),
|
|
345
|
+
);
|
|
162
346
|
expect(output).toContain("'input-clear-icon':");
|
|
163
347
|
expect(output).toContain(
|
|
164
348
|
'merge deprecated theme target `date-input-clear-icon` into `input-clear-icon`',
|
|
@@ -291,6 +475,21 @@ const theme = {name: 'brand', components: {[oldTarget]: {base: {color: 'red'}}}}
|
|
|
291
475
|
expect(apply(output, 'theme.css')).toBe(output);
|
|
292
476
|
});
|
|
293
477
|
|
|
478
|
+
it('maps only the column values MetadataList emitted, not app classes', () => {
|
|
479
|
+
const output = apply(
|
|
480
|
+
`.astryx-metadata-list.app-compact-list { gap: 4px; }
|
|
481
|
+
.astryx-metadata-list.columns-3, .astryx-metadata-list.multi { gap: 8px; }`,
|
|
482
|
+
'theme.css',
|
|
483
|
+
);
|
|
484
|
+
expect(output).toContain('.astryx-metadata-list.app-compact-list');
|
|
485
|
+
expect(output).not.toContain('data-columns="app-compact-list"');
|
|
486
|
+
expect(output).toContain('.astryx-metadata-list:is([data-columns="3"])');
|
|
487
|
+
expect(output).not.toContain('data-columns="columns-3"');
|
|
488
|
+
expect(output).toContain(
|
|
489
|
+
'.astryx-metadata-list:is([data-columns="multi"])',
|
|
490
|
+
);
|
|
491
|
+
});
|
|
492
|
+
|
|
294
493
|
it('leaves unqualified and unknown consumer classes unchanged', () => {
|
|
295
494
|
const input = `.primary { color: red; }
|
|
296
495
|
.astryx-button.brand { color: blue; }`;
|
|
@@ -312,7 +511,9 @@ const theme = {name: 'brand', components: {[oldTarget]: {base: {color: 'red'}}}}
|
|
|
312
511
|
});
|
|
313
512
|
|
|
314
513
|
it('is byte-idempotent after JavaScript and CSS migration', () => {
|
|
315
|
-
const js =
|
|
514
|
+
const js = defined(
|
|
515
|
+
`{statusdot: {base: {color: 'red'}}, 'selector-clear-icon': {base: {color: 'red'}}}`,
|
|
516
|
+
);
|
|
316
517
|
const css = '.astryx-textarea.sm {}';
|
|
317
518
|
const jsOnce = apply(js);
|
|
318
519
|
const cssOnce = apply(css, 'theme.css');
|