@instructure/ui-codemods 10.20.2-snapshot-11 → 10.20.2-snapshot-13
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/CHANGELOG.md +1 -1
- package/README.md +5 -87
- package/lib/__node_tests__/codemodHelpers.test.tsx +455 -0
- package/lib/__node_tests__/{updateV10Breaking.test.ts → codemods.test.ts} +3 -3
- package/lib/__node_tests__/{testHelpers.ts → runTest.ts} +1 -3
- package/lib/index.ts +1 -16
- package/lib/{utils → instui-codemods}/updateToV10Colors.ts +6 -7
- package/lib/updateV10Breaking.ts +12 -26
- package/lib/{helpers → utils}/codemodHelpers.ts +153 -164
- package/lib/utils/codemodTypeCheckers.ts +221 -0
- package/lib/utils/instUICodemodExecutor.ts +89 -0
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/helpers/replaceDeprecatedImports.ts +0 -546
- package/lib/helpers/replaceDeprecatedProps.ts +0 -230
- package/lib/updateImports.ts +0 -86
- package/lib/updatePropNames.ts +0 -66
- package/lib/updateV7Props.ts +0 -101
- package/lib/updateV8Breaking.ts +0 -49
- package/lib/updateV8ReactDOM.ts +0 -61
- package/lib/updateV9Breaking.ts +0 -54
- package/lib/utils/UpdateV7ButtonsLink.ts +0 -139
- package/lib/utils/requireUncached.ts +0 -28
- package/lib/utils/updateToV8Theming.ts +0 -84
- package/lib/utils/updateToV9Theming.ts +0 -70
- package/lib/utils/updateV7ButtonsClose.ts +0 -104
- package/lib/utils/updateV7ButtonsIconCircle.ts +0 -240
- package/lib/utils/updateV7ButtonsMisc.ts +0 -137
- package/lib/utils/updateV7ButtonsWithText.ts +0 -111
- package/lib/utils/updateV7FocusableView.ts +0 -105
- package/lib/utils/updateV7Heading.ts +0 -145
- package/lib/utils/updateV7Lists.ts +0 -113
- package/lib/utils/updateV7Pill.ts +0 -83
- package/lib/utils/updateV7Popover.ts +0 -133
- package/lib/utils/updateV7Tabs.ts +0 -129
- package/lib/utils/updateV8RenderProp.ts +0 -142
- package/lib/utils/updateV8ThemeProp.ts +0 -51
- package/lib/utils/warnV7ComponentDeprecations.ts +0 -96
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import type {
|
|
26
|
-
Collection,
|
|
27
|
-
JSCodeshift,
|
|
28
|
-
JSXExpressionContainer,
|
|
29
|
-
StringLiteral
|
|
30
|
-
} from 'jscodeshift'
|
|
31
|
-
import type { JSXChild } from '../helpers/codemodHelpers'
|
|
32
|
-
import {
|
|
33
|
-
findElements,
|
|
34
|
-
findImport,
|
|
35
|
-
getVisibleChildren,
|
|
36
|
-
isJSXElement,
|
|
37
|
-
isJSXIdentifier,
|
|
38
|
-
isJSXMemberExpression,
|
|
39
|
-
isJSXText,
|
|
40
|
-
printWarning
|
|
41
|
-
} from '../helpers/codemodHelpers'
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Does the following updates on a <Popover>:
|
|
45
|
-
* - `<Popover><Popover.Trigger>{t}</Popover.Trigger></Popover>` ->
|
|
46
|
-
* `<Popover renderTrigger={t} />`
|
|
47
|
-
* - `<Popover><Popover.Content>c</Popover.Content></Popover>` ->
|
|
48
|
-
* `<Popover>c</Popover>`
|
|
49
|
-
* - `<Popover onToggle=` -> Display warning that it needs to be done
|
|
50
|
-
* manually
|
|
51
|
-
**/
|
|
52
|
-
export default function updateV7Popover(
|
|
53
|
-
j: JSCodeshift,
|
|
54
|
-
root: Collection,
|
|
55
|
-
filePath: string
|
|
56
|
-
) {
|
|
57
|
-
const importName = findImport(j, root, 'Popover', [
|
|
58
|
-
'@instructure/ui-popover',
|
|
59
|
-
'@instructure/ui'
|
|
60
|
-
])
|
|
61
|
-
if (!importName) {
|
|
62
|
-
return false
|
|
63
|
-
}
|
|
64
|
-
let isUpdated = false
|
|
65
|
-
///// `<Popover><Popover.Trigger>{t}</Popover.Trigger></Popover>` ->
|
|
66
|
-
///// `<Popover renderTrigger={t} />`
|
|
67
|
-
findElements(filePath, j, root, 'Popover').forEach((path) => {
|
|
68
|
-
const trigger = getVisibleChildren(
|
|
69
|
-
getChildrenByName('Popover', 'Trigger', path.value.children)
|
|
70
|
-
)
|
|
71
|
-
if (trigger.length > 0) {
|
|
72
|
-
// should have 0 or 1 child
|
|
73
|
-
isUpdated = true
|
|
74
|
-
const theChild = trigger[0]
|
|
75
|
-
let toAdd = theChild as StringLiteral | JSXExpressionContainer
|
|
76
|
-
if (isJSXText(theChild)) {
|
|
77
|
-
toAdd = j.stringLiteral(theChild.value)
|
|
78
|
-
}
|
|
79
|
-
if (isJSXElement(theChild)) {
|
|
80
|
-
toAdd = j.jsxExpressionContainer(theChild)
|
|
81
|
-
} // hope these conversions are enough
|
|
82
|
-
path.value.openingElement.attributes!.push(
|
|
83
|
-
j.jsxAttribute(j.jsxIdentifier('renderTrigger'), toAdd)
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
///// `<Popover><Popover.Content>c</Popover.Content></Popover>` ->
|
|
88
|
-
///// `<Popover>c</Popover>`
|
|
89
|
-
findElements(filePath, j, root, 'Popover').forEach((path) => {
|
|
90
|
-
const trigger = getChildrenByName('Popover', 'Content', path.value.children)
|
|
91
|
-
if (trigger) {
|
|
92
|
-
// should have 0 or 1 child
|
|
93
|
-
isUpdated = true
|
|
94
|
-
path.value.children!.push(...trigger)
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
///// `<Popover onToggle=` -> Display warning that it needs to be done manually
|
|
98
|
-
findElements(filePath, j, root, 'Popover', { name: 'onToggle' }).forEach(
|
|
99
|
-
(path) => {
|
|
100
|
-
printWarning(
|
|
101
|
-
filePath,
|
|
102
|
-
path.value.loc?.start.line,
|
|
103
|
-
"Popover's onToggle needs to be converted manually " +
|
|
104
|
-
'to onShowContent and onHideContent'
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
return isUpdated
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Removes the child of the given array that is named like `Name1.Name2`
|
|
113
|
-
* It returns the first child of the child that has this name (if any)
|
|
114
|
-
*/
|
|
115
|
-
function getChildrenByName(name1: string, name2: string, array?: JSXChild[]) {
|
|
116
|
-
if (!array) {
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
for (const child of array) {
|
|
120
|
-
if (
|
|
121
|
-
isJSXElement(child) &&
|
|
122
|
-
child.children &&
|
|
123
|
-
isJSXMemberExpression(child.openingElement.name) &&
|
|
124
|
-
isJSXIdentifier(child.openingElement.name.object) &&
|
|
125
|
-
child.openingElement.name.object.name === name1 &&
|
|
126
|
-
child.openingElement.name.property.name === name2
|
|
127
|
-
) {
|
|
128
|
-
array.splice(array.indexOf(child), 1)
|
|
129
|
-
return child.children
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return
|
|
133
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import type { Collection, JSCodeshift, JSXAttribute } from 'jscodeshift'
|
|
26
|
-
import {
|
|
27
|
-
findElements,
|
|
28
|
-
findImport,
|
|
29
|
-
isJSXAttribue,
|
|
30
|
-
isLiteral,
|
|
31
|
-
printWarning
|
|
32
|
-
} from '../helpers/codemodHelpers'
|
|
33
|
-
|
|
34
|
-
type SizeValue = 'small' | 'medium' | 'large'
|
|
35
|
-
|
|
36
|
-
// default theme values for Tabs's size prop
|
|
37
|
-
const sizeConversions = {
|
|
38
|
-
small: '30em',
|
|
39
|
-
medium: '48em',
|
|
40
|
-
large: '62em'
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Does the following updates on a <Tabs>:
|
|
44
|
-
* - `Tabs size="" maxWidth=..` -> `Tabs maxWidth=..` (delete size)
|
|
45
|
-
* - `Tabs size=` -> `<Tabs maxWidth=` (convert size to maxWidth)
|
|
46
|
-
* - `Tabs selectedIndex=` -> display warning to use isSelected on Tabs.Panel
|
|
47
|
-
**/
|
|
48
|
-
export default function updateV7Tabs(
|
|
49
|
-
j: JSCodeshift,
|
|
50
|
-
root: Collection,
|
|
51
|
-
filePath: string
|
|
52
|
-
) {
|
|
53
|
-
const importName = findImport(j, root, 'Tabs', [
|
|
54
|
-
'@instructure/ui-tabs',
|
|
55
|
-
'@instructure/ui'
|
|
56
|
-
])
|
|
57
|
-
if (!importName) {
|
|
58
|
-
return false
|
|
59
|
-
}
|
|
60
|
-
let isUpdated = false
|
|
61
|
-
// `Tabs size="" maxWidth=..` -> delete size
|
|
62
|
-
// `Tabs size=` -> `<Tabs maxWidth=` (convert size to maxWidth)
|
|
63
|
-
findElements(filePath, j, root, importName, { name: 'size' }).forEach(
|
|
64
|
-
(path) => {
|
|
65
|
-
const attributes = path.value.openingElement.attributes
|
|
66
|
-
if (!attributes) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
// delete size is maxWidth exists
|
|
70
|
-
let hasMaxWidth = false
|
|
71
|
-
let sizeAttribute: JSXAttribute
|
|
72
|
-
for (const attr of attributes) {
|
|
73
|
-
if (isJSXAttribue(attr)) {
|
|
74
|
-
if (attr.name.name === 'maxWidth') {
|
|
75
|
-
hasMaxWidth = true
|
|
76
|
-
} else {
|
|
77
|
-
if (attr.name.name === 'size') {
|
|
78
|
-
sizeAttribute = attr
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (hasMaxWidth) {
|
|
84
|
-
isUpdated = true
|
|
85
|
-
attributes.splice(attributes.indexOf(sizeAttribute!), 1)
|
|
86
|
-
} else {
|
|
87
|
-
// `Tabs size=` -> `<Tabs maxWidth=` (convert size to maxWidth)
|
|
88
|
-
if (isLiteral(sizeAttribute!.value)) {
|
|
89
|
-
const sizeVal = sizeAttribute!.value.value as SizeValue
|
|
90
|
-
const sizeConverted = sizeConversions[sizeVal]
|
|
91
|
-
attributes.splice(attributes.indexOf(sizeAttribute!), 1)
|
|
92
|
-
attributes.push(
|
|
93
|
-
j.jsxAttribute(
|
|
94
|
-
j.jsxIdentifier('maxWidth'),
|
|
95
|
-
j.stringLiteral(sizeConverted)
|
|
96
|
-
)
|
|
97
|
-
)
|
|
98
|
-
printWarning(
|
|
99
|
-
filePath,
|
|
100
|
-
sizeAttribute!.loc?.start.line,
|
|
101
|
-
"Tabs 'size' attribute was converted to " +
|
|
102
|
-
"'maxWidth', please check the value, it's only valid if this " +
|
|
103
|
-
'was not overridden in the theme.'
|
|
104
|
-
)
|
|
105
|
-
isUpdated = true
|
|
106
|
-
} else {
|
|
107
|
-
printWarning(
|
|
108
|
-
filePath,
|
|
109
|
-
sizeAttribute!.loc?.start.line,
|
|
110
|
-
"Tabs 'size' attribute has non-literal value," +
|
|
111
|
-
'please update manually.'
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
// `Tabs selectedIndex=` -> display warning to use isSelected on Tabs.Panel
|
|
118
|
-
findElements(filePath, j, root, importName, {
|
|
119
|
-
name: 'selectedIndex'
|
|
120
|
-
}).forEach((path) => {
|
|
121
|
-
printWarning(
|
|
122
|
-
filePath,
|
|
123
|
-
path.value.loc?.start.line,
|
|
124
|
-
"Tabs 'selectedIndex' attribute needs to be updated " +
|
|
125
|
-
"manually, use 'isSelected' on 'Tabs.Panel'."
|
|
126
|
-
)
|
|
127
|
-
})
|
|
128
|
-
return isUpdated
|
|
129
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
Collection,
|
|
27
|
-
JSCodeshift,
|
|
28
|
-
JSXElement,
|
|
29
|
-
JSXExpressionContainer,
|
|
30
|
-
JSXFragment
|
|
31
|
-
} from 'jscodeshift'
|
|
32
|
-
import {
|
|
33
|
-
addImportIfNeeded,
|
|
34
|
-
findImport,
|
|
35
|
-
isCallExpression,
|
|
36
|
-
isIdentifier,
|
|
37
|
-
isJSXElement,
|
|
38
|
-
isJSXFragment,
|
|
39
|
-
isLiteral,
|
|
40
|
-
isMemberExpression,
|
|
41
|
-
isSpreadElement,
|
|
42
|
-
printWarning
|
|
43
|
-
} from '../helpers/codemodHelpers'
|
|
44
|
-
|
|
45
|
-
export type UpdateV8RenderPropOptions = {
|
|
46
|
-
wrapperPath: string
|
|
47
|
-
wrapperTag: string
|
|
48
|
-
isDefaultImport: boolean
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Updates ReactDOM.render calls with a given wrapper, for example:
|
|
53
|
-
* ReactDOM.render(<div />) -> ReactDOM.render(<Root><div /></Root>)
|
|
54
|
-
*/
|
|
55
|
-
export default function updateV8RenderProp(
|
|
56
|
-
j: JSCodeshift,
|
|
57
|
-
root: Collection,
|
|
58
|
-
filePath: string,
|
|
59
|
-
options: UpdateV8RenderPropOptions
|
|
60
|
-
) {
|
|
61
|
-
let functionImport: string | undefined
|
|
62
|
-
const defaultImport = findImport(j, root, 'ReactDOM', 'react-dom')
|
|
63
|
-
if (!defaultImport) {
|
|
64
|
-
functionImport = findImport(j, root, 'render', 'react-dom')
|
|
65
|
-
}
|
|
66
|
-
if (!functionImport && !defaultImport) {
|
|
67
|
-
return false
|
|
68
|
-
}
|
|
69
|
-
let hasModifications = false
|
|
70
|
-
root.find(j.CallExpression).forEach((path) => {
|
|
71
|
-
const astNode = path.value.callee
|
|
72
|
-
// it's a function import: import {render} from 'react-dom'; render()
|
|
73
|
-
const foundFunctionImport =
|
|
74
|
-
functionImport && isIdentifier(astNode) && astNode.name === functionImport
|
|
75
|
-
// it's a default import: import ReactDOM from 'react-dom'; ReactDOM.render()
|
|
76
|
-
const foundDefaultImport =
|
|
77
|
-
defaultImport &&
|
|
78
|
-
isMemberExpression(astNode) &&
|
|
79
|
-
isIdentifier(astNode.object) &&
|
|
80
|
-
astNode.object.name === defaultImport &&
|
|
81
|
-
isIdentifier(astNode.property) &&
|
|
82
|
-
astNode.property.name === 'render'
|
|
83
|
-
if (foundFunctionImport || foundDefaultImport) {
|
|
84
|
-
hasModifications = true
|
|
85
|
-
// add import
|
|
86
|
-
addImportIfNeeded(j, root, options.wrapperTag, options.wrapperPath, true)
|
|
87
|
-
// wrap in <Root>
|
|
88
|
-
const args = path.value.arguments
|
|
89
|
-
if (args.length === 0) {
|
|
90
|
-
printWarning(
|
|
91
|
-
filePath,
|
|
92
|
-
path.value.loc?.start.line,
|
|
93
|
-
'ReactDOM.render() seems to have 0 arguments, please check'
|
|
94
|
-
)
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
const firstArg = args[0]
|
|
98
|
-
if (isSpreadElement(firstArg)) {
|
|
99
|
-
printWarning(
|
|
100
|
-
filePath,
|
|
101
|
-
path.value.loc?.start.line,
|
|
102
|
-
'ReactDOM.render()-s first argument is spread element, please update manually.'
|
|
103
|
-
)
|
|
104
|
-
return
|
|
105
|
-
} else {
|
|
106
|
-
let argToAdd: (JSXElement | JSXExpressionContainer | JSXFragment)[]
|
|
107
|
-
if (
|
|
108
|
-
isJSXElement(firstArg) ||
|
|
109
|
-
(isJSXFragment(firstArg) &&
|
|
110
|
-
firstArg.children &&
|
|
111
|
-
firstArg.children.length > 0)
|
|
112
|
-
) {
|
|
113
|
-
argToAdd = [firstArg]
|
|
114
|
-
} else if (
|
|
115
|
-
isLiteral(firstArg) ||
|
|
116
|
-
isIdentifier(firstArg) ||
|
|
117
|
-
isCallExpression(firstArg)
|
|
118
|
-
) {
|
|
119
|
-
argToAdd = [j.jsxExpressionContainer(firstArg)]
|
|
120
|
-
} else if (
|
|
121
|
-
isJSXFragment(firstArg) &&
|
|
122
|
-
(!firstArg.children || firstArg.children.length == 0)
|
|
123
|
-
) {
|
|
124
|
-
return // no need to style empty tag
|
|
125
|
-
} else {
|
|
126
|
-
printWarning(
|
|
127
|
-
filePath,
|
|
128
|
-
path.value.loc?.start.line,
|
|
129
|
-
'ReactDOM.render()-s first argument is some strange type, please update manually.'
|
|
130
|
-
)
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
args[0] = j.jsxElement(
|
|
134
|
-
j.jsxOpeningElement(j.jsxIdentifier(options.wrapperTag)),
|
|
135
|
-
j.jsxClosingElement(j.jsxIdentifier(options.wrapperTag)),
|
|
136
|
-
argToAdd
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
return hasModifications
|
|
142
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { Collection, JSCodeshift } from 'jscodeshift'
|
|
26
|
-
import { findEveryImport } from '../helpers/codemodHelpers'
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Renames components theme={} prop to themeOverride={}
|
|
30
|
-
*/
|
|
31
|
-
export default function updateV8ThemeProp(j: JSCodeshift, root: Collection) {
|
|
32
|
-
const instUIImports = findEveryImport(j, root, '@instructure/ui', false)
|
|
33
|
-
let isChanged = false
|
|
34
|
-
instUIImports.forEach((instUIImport) => {
|
|
35
|
-
const elems = root
|
|
36
|
-
.find(j.JSXOpeningElement, {
|
|
37
|
-
name: {
|
|
38
|
-
type: 'JSXIdentifier',
|
|
39
|
-
name: instUIImport as string
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
.find(j.JSXIdentifier, {
|
|
43
|
-
name: 'theme'
|
|
44
|
-
})
|
|
45
|
-
elems.replaceWith('themeOverride')
|
|
46
|
-
if (elems.length > 0) {
|
|
47
|
-
isChanged = true
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
return isChanged
|
|
51
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import type { Collection, JSCodeshift } from 'jscodeshift'
|
|
26
|
-
import {
|
|
27
|
-
findElements,
|
|
28
|
-
findImport,
|
|
29
|
-
printWarning
|
|
30
|
-
} from '../helpers/codemodHelpers'
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Warns about the deprecation of DeprecatedButton, Media, MetricsList,
|
|
34
|
-
* Position.Content, Position.Target, Progress components.
|
|
35
|
-
*/
|
|
36
|
-
export default function warnV7ComponentDeprecations(
|
|
37
|
-
j: JSCodeshift,
|
|
38
|
-
root: Collection,
|
|
39
|
-
filePath: string
|
|
40
|
-
) {
|
|
41
|
-
warnDeprecation(j, root, filePath, 'DeprecatedButton', [
|
|
42
|
-
'@instructure/ui',
|
|
43
|
-
'@instructure/ui-buttons'
|
|
44
|
-
])
|
|
45
|
-
warnDeprecation(j, root, filePath, 'Media', [
|
|
46
|
-
'@instructure/ui',
|
|
47
|
-
'@instructure/ui-byline'
|
|
48
|
-
])
|
|
49
|
-
warnDeprecation(j, root, filePath, 'MetricsList', [
|
|
50
|
-
'@instructure/ui',
|
|
51
|
-
'@instructure/ui-metric'
|
|
52
|
-
])
|
|
53
|
-
const importName = findImport(j, root, 'Position', [
|
|
54
|
-
'@instructure/ui',
|
|
55
|
-
'@instructure/ui-position'
|
|
56
|
-
])
|
|
57
|
-
if (importName) {
|
|
58
|
-
findElements(filePath, j, root, importName + '.Content').forEach((path) => {
|
|
59
|
-
printWarning(
|
|
60
|
-
filePath,
|
|
61
|
-
path.value.loc?.start.line,
|
|
62
|
-
'Position.Content needs to be upgraded manually at line.'
|
|
63
|
-
)
|
|
64
|
-
})
|
|
65
|
-
findElements(filePath, j, root, importName + '.Target').forEach((path) => {
|
|
66
|
-
printWarning(
|
|
67
|
-
filePath,
|
|
68
|
-
path.value.loc?.start.line,
|
|
69
|
-
'Position.Target needs to be upgraded manually at line.'
|
|
70
|
-
)
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
warnDeprecation(j, root, filePath, 'Progress', [
|
|
74
|
-
'@instructure/ui',
|
|
75
|
-
'@instructure/ui-progress'
|
|
76
|
-
])
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function warnDeprecation(
|
|
80
|
-
j: JSCodeshift,
|
|
81
|
-
root: Collection,
|
|
82
|
-
filePath: string,
|
|
83
|
-
name: string,
|
|
84
|
-
importPath: string[]
|
|
85
|
-
) {
|
|
86
|
-
const importName = findImport(j, root, name, importPath)
|
|
87
|
-
if (importName) {
|
|
88
|
-
findElements(filePath, j, root, importName).forEach((path) => {
|
|
89
|
-
printWarning(
|
|
90
|
-
filePath,
|
|
91
|
-
path.value.loc?.start.line,
|
|
92
|
-
name + ' needs to be upgraded manually.'
|
|
93
|
-
)
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
}
|