@sanity/ui-codemod 1.0.0-alpha.4 → 1.0.0-alpha.6
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/dist/_chunks-es/addAttribute.js +1 -1
- package/dist/_chunks-es/box.mods.js +1 -1
- package/dist/_chunks-es/layout-mods.js +4 -0
- package/dist/_chunks-es/layout-mods.js.map +1 -1
- package/dist/_chunks-es/{transformComponent.js → transformStyledComponents.js} +150 -2
- package/dist/_chunks-es/transformStyledComponents.js.map +1 -0
- package/dist/transforms/latest/box/box.js +1 -147
- package/dist/transforms/latest/box/box.js.map +1 -1
- package/dist/transforms/latest/card/card.js +24 -9
- package/dist/transforms/latest/card/card.js.map +1 -1
- package/dist/transforms/latest/code/code.js +18 -7
- package/dist/transforms/latest/code/code.js.map +1 -1
- package/dist/transforms/latest/container/container.js +15 -7
- package/dist/transforms/latest/container/container.js.map +1 -1
- package/dist/transforms/latest/flex/flex.js +15 -7
- package/dist/transforms/latest/flex/flex.js.map +1 -1
- package/dist/transforms/latest/grid/grid.js +15 -7
- package/dist/transforms/latest/grid/grid.js.map +1 -1
- package/dist/transforms/latest/heading/heading.js +18 -7
- package/dist/transforms/latest/heading/heading.js.map +1 -1
- package/dist/transforms/latest/text/text.js +18 -7
- package/dist/transforms/latest/text/text.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/latest/layout-mods.ts +4 -0
- package/src/transforms/latest/box/box.test.ts +86 -151
- package/src/transforms/latest/card/card.test.ts +100 -1
- package/src/transforms/latest/card/card.ts +42 -19
- package/src/transforms/latest/code/code.test.ts +84 -1
- package/src/transforms/latest/code/code.ts +47 -16
- package/src/transforms/latest/container/container.test.ts +78 -1
- package/src/transforms/latest/container/container.ts +29 -9
- package/src/transforms/latest/flex/flex.test.ts +78 -1
- package/src/transforms/latest/flex/flex.ts +29 -9
- package/src/transforms/latest/grid/grid.test.ts +78 -1
- package/src/transforms/latest/grid/grid.ts +29 -9
- package/src/transforms/latest/heading/heading.test.ts +84 -1
- package/src/transforms/latest/heading/heading.ts +47 -16
- package/src/transforms/latest/inline/inline.test.ts +78 -1
- package/src/transforms/latest/inline/inline.ts +29 -9
- package/src/transforms/latest/label/label.test.ts +84 -1
- package/src/transforms/latest/label/label.ts +36 -1
- package/src/transforms/latest/stack/stack.test.ts +100 -1
- package/src/transforms/latest/stack/stack.ts +29 -7
- package/src/transforms/latest/text/text.test.ts +84 -1
- package/src/transforms/latest/text/text.ts +58 -19
- package/src/utils/testUtils.ts +45 -0
- package/dist/_chunks-es/transformComponent.js.map +0 -1
|
@@ -3,10 +3,12 @@ import {type API, type FileInfo} from 'jscodeshift'
|
|
|
3
3
|
import type {BaseOptions} from '../../../types/BaseOptions'
|
|
4
4
|
import {addAttribute} from '../../../utils/addAttribute'
|
|
5
5
|
import {getComponentLocalNames} from '../../../utils/getComponentLocalNames'
|
|
6
|
+
import {getStyledComponentAliases} from '../../../utils/getStyledComponentAliases'
|
|
6
7
|
import {shouldTransformComponent} from '../../../utils/shouldTransformComponent'
|
|
7
8
|
import {transformAttributes} from '../../../utils/transformAttributes'
|
|
8
9
|
import {transformComponent} from '../../../utils/transformComponent'
|
|
9
10
|
import {transformImport} from '../../../utils/transformImport'
|
|
11
|
+
import {transformStyledComponents} from '../../../utils/transformStyledComponents'
|
|
10
12
|
import {TEXT_MODS} from './text.mods'
|
|
11
13
|
|
|
12
14
|
const TODO_WARNING = 'Please double check the Text migration below'
|
|
@@ -21,8 +23,16 @@ export default function transform(
|
|
|
21
23
|
|
|
22
24
|
return transformComponent(fileInfo, api, ({j, root, markChanged}) => {
|
|
23
25
|
const localNames = getComponentLocalNames(j, root, 'Text', options)
|
|
26
|
+
const styledAliases = getStyledComponentAliases(
|
|
27
|
+
j,
|
|
28
|
+
root,
|
|
29
|
+
'Text',
|
|
30
|
+
fileInfo.path,
|
|
31
|
+
localNames,
|
|
32
|
+
options,
|
|
33
|
+
)
|
|
24
34
|
|
|
25
|
-
if (!shouldTransformComponent(j, root, 'Text', localNames, options)) {
|
|
35
|
+
if (!shouldTransformComponent(j, root, 'Text', localNames, options, styledAliases)) {
|
|
26
36
|
return
|
|
27
37
|
}
|
|
28
38
|
|
|
@@ -30,28 +40,57 @@ export default function transform(
|
|
|
30
40
|
markChanged()
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
root
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
43
|
+
root.find(j.JSXOpeningElement).forEach((path) => {
|
|
44
|
+
let changed = false
|
|
45
|
+
const name = path.node.name
|
|
46
|
+
|
|
47
|
+
if (name.type !== 'JSXIdentifier' || !localNames.has(name.name)) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (transformAttributes(j, path, TEXT_MODS, TODO_WARNING)) {
|
|
52
|
+
changed = true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (addAttribute(j, path.node, 'as', 'div')) {
|
|
56
|
+
changed = true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (addAttribute(j, path.node, 'trim', true)) {
|
|
60
|
+
changed = true
|
|
61
|
+
}
|
|
39
62
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
if (changed) {
|
|
64
|
+
markChanged()
|
|
65
|
+
}
|
|
66
|
+
})
|
|
43
67
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
68
|
+
if (
|
|
69
|
+
transformStyledComponents(j, root, styledAliases, () => true, {
|
|
70
|
+
callback: (path) => {
|
|
71
|
+
let changed = false
|
|
47
72
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
if (transformAttributes(j, path, TEXT_MODS, TODO_WARNING)) {
|
|
74
|
+
changed = true
|
|
75
|
+
}
|
|
51
76
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
if (addAttribute(j, path.node, 'as', 'div')) {
|
|
78
|
+
changed = true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (addAttribute(j, path.node, 'trim', true)) {
|
|
82
|
+
changed = true
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (changed) {
|
|
86
|
+
markChanged()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return changed
|
|
90
|
+
},
|
|
55
91
|
})
|
|
92
|
+
) {
|
|
93
|
+
markChanged()
|
|
94
|
+
}
|
|
56
95
|
})
|
|
57
96
|
}
|
package/src/utils/testUtils.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import {mkdtempSync, readFileSync, rmSync, writeFileSync} from 'node:fs'
|
|
2
|
+
import {tmpdir} from 'node:os'
|
|
3
|
+
import {join} from 'node:path'
|
|
4
|
+
|
|
1
5
|
import {type FileInfo, type Options, type Transform} from 'jscodeshift'
|
|
2
6
|
import {expect, it} from 'vitest'
|
|
3
7
|
|
|
8
|
+
import {clearModuleParseCache} from './parseModule'
|
|
9
|
+
|
|
4
10
|
const applyTransform = require('jscodeshift/dist/testUtils').applyTransform
|
|
5
11
|
|
|
6
12
|
export function defineInlineTest(
|
|
@@ -52,3 +58,42 @@ function runInlineTest(
|
|
|
52
58
|
expectation(output)
|
|
53
59
|
return output
|
|
54
60
|
}
|
|
61
|
+
|
|
62
|
+
export function defineCrossFileTest(
|
|
63
|
+
module: Transform,
|
|
64
|
+
options: Options,
|
|
65
|
+
styledInput: string,
|
|
66
|
+
importerInput: string,
|
|
67
|
+
assert: (output: string) => void,
|
|
68
|
+
testName?: string,
|
|
69
|
+
crossFileOptions?: {
|
|
70
|
+
extraFiles?: Record<string, string>
|
|
71
|
+
},
|
|
72
|
+
) {
|
|
73
|
+
it(testName || 'transforms cross-file styled component correctly', async () => {
|
|
74
|
+
const dir = mkdtempSync(join(tmpdir(), 'ui-codemod-crossfile-'))
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
writeFileSync(join(dir, 'Component.styled.tsx'), styledInput.trim())
|
|
78
|
+
writeFileSync(join(dir, 'Component.tsx'), importerInput.trim())
|
|
79
|
+
|
|
80
|
+
for (const [filePath, source] of Object.entries(crossFileOptions?.extraFiles ?? {})) {
|
|
81
|
+
writeFileSync(join(dir, filePath), source.trim())
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const importerPath = join(dir, 'Component.tsx')
|
|
85
|
+
const source = readFileSync(importerPath, 'utf8')
|
|
86
|
+
const output = await applyTransform(
|
|
87
|
+
module,
|
|
88
|
+
options,
|
|
89
|
+
{source, path: importerPath},
|
|
90
|
+
{parser: 'tsx'},
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
assert(typeof output === 'string' ? output : '')
|
|
94
|
+
} finally {
|
|
95
|
+
clearModuleParseCache()
|
|
96
|
+
rmSync(dir, {recursive: true, force: true})
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformComponent.js","sources":["../../src/utils/getClonedImportSpecifiers.ts","../../src/utils/getSplitImportSpecifiers.ts","../../src/utils/transformImport.ts","../../src/utils/getComponentLocalNames.ts","../../src/utils/getAttribute.ts","../../src/utils/getAttributeExpression.ts","../../src/utils/getStaticAttributeExpression.ts","../../src/utils/insertTodoWarning.ts","../../src/utils/shouldTransformComponent.ts","../../src/utils/getCompositeAttrValue.ts","../../src/utils/getMappingExpression.ts","../../src/utils/getMappingValue.ts","../../src/utils/getMappingArray.ts","../../src/utils/getShorthandAttributes.ts","../../src/utils/getStyleExpression.ts","../../src/utils/isValidStyleType.ts","../../src/utils/mergeStyle.ts","../../src/utils/transformAttributes.ts","../../src/utils/transformComponent.ts"],"sourcesContent":["import type {API, ImportDefaultSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getClonedImportSpecifiers(\n j: API['jscodeshift'],\n specifiers: (ImportSpecifier | ImportDefaultSpecifier)[] = [],\n) {\n return specifiers.map((spec) => {\n if (spec.type === 'ImportSpecifier') {\n if (spec.imported.type !== 'Identifier' || spec.local?.type !== 'Identifier') {\n return spec\n }\n\n const clone = j.importSpecifier(\n j.identifier(spec.imported.name),\n j.identifier(spec.local.name),\n )\n\n if ('importKind' in spec && spec.importKind === 'type') {\n Object.assign(clone, {importKind: 'type'})\n }\n\n return clone\n } else {\n return j.importDefaultSpecifier(\n j.identifier((spec as ImportDefaultSpecifier).local?.name as string),\n )\n }\n })\n}\n","import type {ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getSplitImportSpecifiers(\n specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] = [],\n componentName: string,\n) {\n const componentNames = new Set([componentName, `${componentName}Props`])\n const specs = {\n componentSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier)[],\n restSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\n }\n\n for (const spec of specifiers) {\n if (spec.type === 'ImportNamespaceSpecifier') {\n specs.restSpecs.push(spec)\n continue\n }\n\n if (spec.type === 'ImportSpecifier' || spec.type === 'ImportDefaultSpecifier') {\n let local\n\n if (spec.type === 'ImportSpecifier') {\n const loc = spec.local ?? spec.imported\n local = loc.type === 'Identifier' ? loc.name : null\n }\n\n if (spec.type === 'ImportDefaultSpecifier') {\n local = spec.local?.type === 'Identifier' ? spec.local.name : null\n }\n\n if (local && componentNames.has(local)) {\n specs.componentSpecs.push(spec)\n } else {\n specs.restSpecs.push(spec)\n }\n }\n }\n\n return specs\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport {getClonedImportSpecifiers} from './getClonedImportSpecifiers'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\n\nexport const DEFAULT_UI_PACKAGE = '@sanity/ui'\n\n/**\n * Rewrites imports from `fromPackage` to `toPackage`, splitting imports if needed.\n * Returns whether the AST was updated.\n */\nexport function transformImport(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n fromPackage: string = DEFAULT_UI_PACKAGE,\n toPackage: string = DEFAULT_UI_PACKAGE,\n): boolean {\n if (fromPackage === toPackage) {\n return false\n }\n\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return\n }\n\n const {componentSpecs, restSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n if (componentSpecs.length === 0) {\n return\n }\n\n if (restSpecs.length === 0) {\n if (node.source && typeof node.source === 'object' && 'value' in node.source) {\n const sourceLiteral = node.source as {value: string}\n sourceLiteral.value = toPackage\n }\n\n hasChanges = true\n return\n }\n\n path.node.specifiers = restSpecs\n const clonedImportSpecifiers = getClonedImportSpecifiers(j, componentSpecs)\n path.insertAfter(j.importDeclaration(clonedImportSpecifiers, j.stringLiteral(toPackage)))\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\nexport function getComponentLocalNames(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n options?: BaseOptions,\n): Set<string> {\n const importedNames = new Set<string>()\n const packages = new Set([\n options?.fromPackage ?? DEFAULT_UI_PACKAGE,\n options?.toPackage ?? DEFAULT_UI_PACKAGE,\n ])\n let hasOtherPackageImport = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if ('importKind' in node && node.importKind === 'type') {\n return\n }\n\n const matchesPackage = packages.has(node.source.value as string)\n\n for (const spec of node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier' || spec.imported.name !== componentName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (!matchesPackage) {\n hasOtherPackageImport = true\n continue\n }\n\n importedNames.add(local)\n }\n })\n\n if (importedNames.size > 0) {\n return importedNames\n }\n\n if (hasOtherPackageImport) {\n return new Set()\n }\n\n const usesComponentInJsx = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === componentName\n })\n\n if (usesComponentInJsx) {\n return new Set([componentName])\n }\n\n return new Set()\n}\n","import type {JSXAttribute, JSXElement} from 'jscodeshift'\n\nexport function getAttribute(\n attrs: JSXElement['openingElement']['attributes'],\n name: string,\n): JSXAttribute | undefined {\n if (!attrs) {\n return undefined\n }\n\n for (const attr of attrs) {\n if (\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === name\n ) {\n return attr\n }\n }\n\n return undefined\n}\n","import {type API, type JSXAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getAttributeExpression(\n attr: JSXAttribute,\n j: API['jscodeshift'],\n): AnyExpression | null {\n if (!attr.value) {\n return j.booleanLiteral(true)\n }\n\n if (attr.value.type === 'StringLiteral' || attr.value.type === 'Literal') {\n return attr.value\n }\n\n if (attr.value.type === 'JSXExpressionContainer') {\n return attr.value.expression\n }\n\n return null\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\n\nexport type CompositePrimitive = string | number | boolean\n\nexport type StaticAttributeValue = CompositePrimitive | (CompositePrimitive | null | undefined)[]\n\nfunction getStaticPrimitive(expr: AnyExpression): CompositePrimitive | undefined {\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'Literal'\n ) {\n const {value} = expr\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return value\n }\n }\n\n return undefined\n}\n\nexport function getStaticAttributeExpression(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n name: string,\n): StaticAttributeValue | null {\n const attr = getAttribute(attrs, name)\n\n if (!attr) {\n return null\n }\n\n const expr = getAttributeExpression(attr, j)\n\n if (!expr) {\n return null\n }\n\n const primitive = getStaticPrimitive(expr as AnyExpression)\n\n if (primitive !== undefined) {\n return primitive\n }\n\n if (expr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = expr.elements as ((AnyExpression & {name?: string}) | null)[]\n const values: (CompositePrimitive | null | undefined)[] = []\n\n for (const element of elements) {\n if (element === null || element.type === 'NullLiteral') {\n values.push(null)\n continue\n }\n\n if (element.type === 'SpreadElement') {\n return null\n }\n\n if (element.type === 'Literal' && element.value === null) {\n values.push(null)\n continue\n }\n\n if (element.type === 'Identifier' && element.name === 'undefined') {\n values.push(undefined)\n continue\n }\n\n const elementValue = getStaticPrimitive(element)\n\n if (elementValue === undefined) {\n return null\n }\n\n values.push(elementValue)\n }\n\n return values\n}\n","import {type API, type ASTPath, type ImportDeclaration, type JSXOpeningElement} from 'jscodeshift'\n\ntype CommentableNode = {\n comments?: {type: string; value: string; leading?: boolean}[] | null\n}\n\n/**\n * Inserts a `UI-CODEMOD TODO` comment.\n * Returns whether the AST was updated.\n */\nexport function insertTodoWarning(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement | ImportDeclaration>,\n warning: string,\n): boolean {\n let target: CommentableNode | null = null\n\n if (path.node.type === 'ImportDeclaration') {\n target = path.node\n } else if (path.parent?.node.type === 'JSXElement') {\n target = path.parent.node\n }\n\n if (!target) {\n return false\n }\n\n target.comments ??= []\n\n if (target.comments.some((comment) => comment.value.includes(warning))) {\n return false\n }\n\n target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, true))\n return true\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\n/**\n * Returns whether a component transform should run on this file, based on local\n * usage or a pending import rewrite.\n */\nexport function shouldTransformComponent(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n localNames: Set<string>,\n options?: BaseOptions,\n styledAliases?: Set<string>,\n): boolean {\n if (localNames.size > 0) {\n return true\n }\n\n if (styledAliases && styledAliases.size > 0) {\n return true\n }\n\n const fromPackage = options?.fromPackage ?? DEFAULT_UI_PACKAGE\n const toPackage = options?.toPackage ?? DEFAULT_UI_PACKAGE\n\n if (fromPackage === toPackage) {\n return false\n }\n\n return root.find(j.ImportDeclaration).some((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return false\n }\n\n const {componentSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n return componentSpecs.length > 0\n })\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {CompositeAttributeMapping} from '../types/AttributeMods'\nimport {getStaticAttributeExpression} from './getStaticAttributeExpression'\n\nexport function getCompositeAttrValue(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n mapping: CompositeAttributeMapping,\n) {\n let compositeAttrValue: string | null = null\n\n for (const compositeKey of Object.keys(mapping)) {\n const compositeMapping = mapping[compositeKey]\n\n if (!compositeMapping) {\n continue\n }\n\n let hasMatchingValues = true\n\n for (const propName of Object.keys(compositeMapping)) {\n const mappingValue = compositeMapping[propName]\n const attrValue = getStaticAttributeExpression(j, attrs, propName)\n\n if (mappingValue === undefined || attrValue !== mappingValue) {\n hasMatchingValues = false\n break\n }\n }\n\n if (hasMatchingValues) {\n compositeAttrValue = compositeKey\n break\n }\n }\n\n return compositeAttrValue\n}\n","import {type API} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\n\nexport function getMappingExpression(\n j: API['jscodeshift'],\n val: string | boolean | number | undefined,\n): AnyExpression {\n if (val === undefined) {\n return j.identifier('undefined')\n }\n\n if (typeof val === 'boolean') {\n return j.booleanLiteral(val)\n }\n\n if (typeof val === 'number') {\n return j.numericLiteral(val)\n }\n\n return j.stringLiteral(val)\n}\n","import type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\n\nexport function getMappingValue(mapping: AttributeMapping, expr: AnyExpression) {\n let key\n\n if (\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal'\n ) {\n key = String(expr.value)\n }\n\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n\n if (expressions.length === 0 && quasis.length === 1) {\n key = quasis[0]?.value.cooked ?? null\n }\n }\n\n if (key) {\n if (Object.prototype.hasOwnProperty.call(mapping, key)) {\n return mapping[key]\n }\n\n const number = Number(key)\n\n if (!Number.isNaN(number) && Object.prototype.hasOwnProperty.call(mapping, number)) {\n return mapping[number]\n }\n }\n\n if (\n expr.type === 'BooleanLiteral' ||\n (expr.type === 'Literal' && typeof expr.value === 'boolean')\n ) {\n for (const val in mapping) {\n if (expr.value === mapping[val]) {\n return mapping[val]\n }\n }\n }\n\n return\n}\n","import {type API, type ArrayExpression} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getMappingArray(\n j: API['jscodeshift'],\n arr: AnyExpression,\n mapping: AttributeMapping,\n allowUndefined?: boolean,\n): ArrayExpression | null {\n if (arr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = arr.elements as (AnyExpression | null)[]\n const output: AnyExpression[] = []\n\n for (const el of elements) {\n if (el == null || el.type === 'SpreadElement') {\n return null\n }\n\n const mappingValue = getMappingValue(mapping, el)\n\n if (!mappingValue && !allowUndefined) {\n return null\n }\n\n output.push(getMappingExpression(j, mappingValue))\n }\n\n return j.arrayExpression(output as never[])\n}\n","import type {API, JSXAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMod} from '../types/AttributeMods'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getShorthandAttributes(\n j: API['jscodeshift'],\n expr: AnyExpression,\n mod: AttributeMod,\n) {\n const attributes: JSXAttribute[] = []\n\n if (!('props' in mod)) {\n return []\n }\n\n if (expr.type === 'ArrayExpression') {\n for (const prop of mod.props) {\n const styleArray = getMappingArray(j, expr, prop.mapping, true)\n\n if (!styleArray) {\n continue\n }\n\n attributes.push(\n j.jsxAttribute(j.jsxIdentifier(prop.name), j.jsxExpressionContainer(styleArray)),\n )\n }\n }\n\n for (const prop of mod.props) {\n const styleValue = getMappingValue(prop.mapping, expr)\n\n if (styleValue === undefined) {\n continue\n }\n\n if (typeof styleValue === 'string') {\n attributes.push(j.jsxAttribute(j.jsxIdentifier(prop.name), j.stringLiteral(styleValue)))\n } else {\n attributes.push(\n j.jsxAttribute(\n j.jsxIdentifier(prop.name),\n j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never),\n ),\n )\n }\n }\n\n return attributes\n}\n","import {type API} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getStyleExpression(j: API['jscodeshift'], expr: AnyExpression): AnyExpression {\n if (expr.type === 'Literal') {\n if (expr.value === null) {\n return j.literal(null)\n }\n\n if (typeof expr.value === 'boolean') {\n return j.booleanLiteral(expr.value)\n }\n\n if (typeof expr.value === 'number') {\n return j.numericLiteral(expr.value)\n }\n\n if (typeof expr.value === 'string') {\n return j.stringLiteral(expr.value)\n }\n }\n\n if (expr.type === 'BooleanLiteral') {\n return j.booleanLiteral(expr.value as boolean)\n }\n\n if (expr.type === 'NumericLiteral') {\n return j.numericLiteral(expr.value as number)\n }\n\n if (expr.type === 'StringLiteral') {\n return j.stringLiteral(expr.value as string)\n }\n\n return expr\n}\n","import {type AnyExpression} from '../types/AnyExpression'\n\nexport function isValidStyleType(expr: AnyExpression) {\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n return expressions.length === 0 && quasis.length === 1\n }\n\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'NullLiteral'\n ) {\n return true\n }\n\n return false\n}\n","import {type API, type JSXAttribute, type JSXSpreadAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function mergeStyle(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n styleKey: string,\n styleExpression: AnyExpression,\n) {\n const styleProp = j.objectProperty(j.identifier(styleKey), styleExpression as never)\n\n const styleIndex = attrs.findIndex(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'style',\n )\n\n if (styleIndex === -1) {\n attrs.push(\n j.jsxAttribute(\n j.jsxIdentifier('style'),\n j.jsxExpressionContainer(j.objectExpression([styleProp])),\n ),\n )\n\n return true\n }\n\n const styleAttr = attrs[styleIndex] as JSXAttribute\n\n if (styleAttr.value?.type !== 'JSXExpressionContainer') {\n return false\n }\n\n const expr = styleAttr.value.expression\n\n if (expr.type === 'ObjectExpression') {\n expr.properties = expr.properties.filter((prop) => {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n return true\n }\n\n const key = prop.key\n\n const name =\n key.type === 'Identifier'\n ? key.name\n : key.type === 'StringLiteral' || key.type === 'Literal'\n ? String(key.value)\n : null\n\n return name !== styleKey\n })\n\n expr.properties.push(styleProp)\n return true\n }\n\n styleAttr.value = j.jsxExpressionContainer(\n j.objectExpression([j.spreadElement(expr as never), styleProp]),\n )\n\n return true\n}\n","import {type API, type ASTPath, type JSXOpeningElement} from 'jscodeshift'\n\nimport {type AttributeMods} from '../types/AttributeMods'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\nimport {getCompositeAttrValue} from './getCompositeAttrValue'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\nimport {getShorthandAttributes} from './getShorthandAttributes'\nimport {getStyleExpression} from './getStyleExpression'\nimport {insertTodoWarning} from './insertTodoWarning'\nimport {isValidStyleType} from './isValidStyleType'\nimport {mergeStyle} from './mergeStyle'\n\n/**\n * Applies attribute migration rules to a JSX opening element.\n * Returns whether the AST was updated.\n */\nexport function transformAttributes(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement>,\n mods: AttributeMods,\n todoWarning: string,\n): boolean {\n if (!path.node.attributes) {\n return false\n }\n\n let hasChanges = false\n const attrs = path.node.attributes\n const removeIdxs: number[] = []\n\n for (const [attrName, mod] of Object.entries(mods)) {\n if (mod?.type !== 'warn-missing') {\n continue\n }\n\n if (getAttribute(attrs, attrName)) {\n continue\n }\n\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i]\n\n if (!attr || attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') {\n continue\n }\n\n const mod = mods[attr.name.name]\n const expr = getAttributeExpression(attr, j)\n\n if (!mod || !expr) {\n continue\n }\n\n if (mod.type === 'remove') {\n removeIdxs.push(i)\n }\n\n if (mod.type === 'warn-only') {\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'rename-only') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-only') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getStyleExpression(j, expr))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-mapped') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getMappingExpression(j, styleValue))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'shorthand-mapped') {\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const shorthandAttrs = getShorthandAttributes(j, expr, mod)\n\n if (shorthandAttrs.length) {\n attrs.splice(i + 1, 0, ...shorthandAttrs)\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'composite') {\n const triggerName = attr.name.name\n const compositeValue = getCompositeAttrValue(j, attrs, mod.mapping)\n\n if (!compositeValue) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n\n attr.value = j.stringLiteral(compositeValue)\n\n for (const attrName of Object.keys(mod.mapping[compositeValue] || {})) {\n if (attrName === triggerName) {\n continue\n }\n\n const otherAttr = getAttribute(attrs, attrName)\n\n if (otherAttr) {\n const k = attrs.indexOf(otherAttr)\n\n if (k !== -1) {\n removeIdxs.push(k)\n }\n }\n }\n\n hasChanges = true\n }\n\n if (mod.type === 'mapped-only' || mod.type === 'rename-mapped') {\n if (mod.type === 'rename-mapped') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n }\n\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (expr.type === 'ArrayExpression') {\n const styleArray = getMappingArray(j, expr, mod.mapping)\n\n if (!styleArray) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.value?.type === 'JSXExpressionContainer') {\n attr.value.expression = styleArray\n } else {\n attr.value = j.jsxExpressionContainer(styleArray)\n }\n\n hasChanges = true\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (typeof styleValue === 'string') {\n attr.value = j.stringLiteral(styleValue)\n } else {\n attr.value = j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never)\n }\n\n hasChanges = true\n }\n }\n\n const idxsToRemove = [...new Set(removeIdxs)].sort((a, b) => b - a)\n\n if (idxsToRemove.length > 0) {\n hasChanges = true\n\n for (const i of idxsToRemove) {\n attrs.splice(i, 1)\n }\n }\n\n return hasChanges\n}\n","import type {API, Collection, FileInfo} from 'jscodeshift'\n\nexport type TransformContext = {\n j: API['jscodeshift']\n root: Collection\n markChanged: () => void\n}\n\n/**\n * Runs a component transform on a file and only calls `toSource()` when\n * `markChanged()` was invoked. Returns `undefined` for no-op files.\n */\nexport function transformComponent(\n fileInfo: FileInfo,\n api: API,\n fn: (ctx: TransformContext) => void,\n): string | undefined {\n const j = api.jscodeshift\n const root = j(fileInfo.source)\n let hasChanges = false\n\n fn({\n j,\n root,\n markChanged: () => {\n hasChanges = true\n },\n })\n\n return hasChanges ? root.toSource() : undefined\n}\n"],"names":[],"mappings":";AAEO,SAAS,0BACd,GACA,aAA2D,IAC3D;AACA,SAAO,WAAW,IAAI,CAAC,SAAS;AAC9B,QAAI,KAAK,SAAS,mBAAmB;AACnC,UAAI,KAAK,SAAS,SAAS,gBAAgB,KAAK,OAAO,SAAS;AAC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