@instructure/ui-codemods 8.17.1-snapshot.35 → 8.17.1-snapshot.80
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 +8 -0
- package/lib/helpers/replaceDeprecatedImports.ts +144 -3
- package/lib/helpers/replaceDeprecatedProps.ts +75 -7
- package/lib/helpers/v7PropsUpdateHelpers.ts +551 -0
- package/lib/updateImports.ts +1 -1
- package/lib/updatePropNames.ts +7 -2
- package/lib/updateV7Props.ts +101 -0
- package/lib/updateV8Props.ts +74 -0
- package/lib/utils/UpdateV7ButtonsLink.ts +139 -0
- package/lib/utils/updateV7ButtonsClose.ts +104 -0
- package/lib/utils/updateV7ButtonsIconCircle.ts +240 -0
- package/lib/utils/updateV7ButtonsMisc.ts +137 -0
- package/lib/utils/updateV7ButtonsWithText.ts +111 -0
- package/lib/utils/updateV7FocusableView.ts +105 -0
- package/lib/utils/updateV7Heading.ts +145 -0
- package/lib/utils/updateV7Lists.ts +113 -0
- package/lib/utils/updateV7Pill.ts +83 -0
- package/lib/utils/updateV7Popover.ts +137 -0
- package/lib/utils/updateV7Tabs.ts +129 -0
- package/lib/utils/warnV7ComponentDeprecations.ts +96 -0
- package/package.json +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/utils/createLiteral.ts +0 -48
- package/lib/utils/findDeprecatedProp.ts +0 -59
- package/lib/utils/findImportDeclaration.ts +0 -51
- package/lib/utils/findTransform.ts +0 -97
- package/lib/utils/parseImport.ts +0 -78
|
@@ -1,59 +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 { UpdatePropNamesOptions } from '../updatePropNames'
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Find the deprecated prop for a component
|
|
29
|
-
*
|
|
30
|
-
* @param {object} config Deprecated property configuration
|
|
31
|
-
* @param {string} comp Component name
|
|
32
|
-
* @param {string} prop Property name
|
|
33
|
-
* @return {object} Object if a match is found, otherwise null
|
|
34
|
-
*/
|
|
35
|
-
export default function findDeprecatedProp(
|
|
36
|
-
config: UpdatePropNamesOptions,
|
|
37
|
-
comp: string,
|
|
38
|
-
prop: string
|
|
39
|
-
) {
|
|
40
|
-
if (config && comp && prop && config[comp]) {
|
|
41
|
-
const component = config[comp]
|
|
42
|
-
|
|
43
|
-
// Iterate versions
|
|
44
|
-
const versions = Object.keys(component)
|
|
45
|
-
for (let i = 0; i < versions.length; i++) {
|
|
46
|
-
const props = component[versions[i]]
|
|
47
|
-
|
|
48
|
-
// Iterate properties
|
|
49
|
-
for (let j = 0; j < props.length; j++) {
|
|
50
|
-
const match = props[j]
|
|
51
|
-
|
|
52
|
-
if (prop === match.old) {
|
|
53
|
-
return match
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
@@ -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
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Finds an import statement with the given path in the given collection, e.g.
|
|
29
|
-
* "findImportDeclaration(j, root, 'myPath')" finds
|
|
30
|
-
* "import otherModule from 'myPath'"
|
|
31
|
-
* @param j JSCodeshift
|
|
32
|
-
* @param root the collection (AST tree) to search
|
|
33
|
-
* @param importPath the import path to look for
|
|
34
|
-
*/
|
|
35
|
-
export default function findImportDeclaration(
|
|
36
|
-
j: JSCodeshift,
|
|
37
|
-
root: Collection,
|
|
38
|
-
importPath: string
|
|
39
|
-
) {
|
|
40
|
-
let importDeclaration
|
|
41
|
-
const declarationQueryResult = root.find(j.ImportDeclaration, {
|
|
42
|
-
source: {
|
|
43
|
-
type: 'StringLiteral',
|
|
44
|
-
value: importPath
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
if (declarationQueryResult.length > 0) {
|
|
48
|
-
importDeclaration = declarationQueryResult.get()
|
|
49
|
-
}
|
|
50
|
-
return importDeclaration
|
|
51
|
-
}
|
|
@@ -1,97 +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 { Transform } from '../updateImports'
|
|
26
|
-
import { ParsedImport } from './parseImport'
|
|
27
|
-
|
|
28
|
-
export default function findTransform(
|
|
29
|
-
transforms: Transform[],
|
|
30
|
-
importPath: string,
|
|
31
|
-
parsedImport: ParsedImport,
|
|
32
|
-
moduleName?: string
|
|
33
|
-
) {
|
|
34
|
-
return (
|
|
35
|
-
transforms.find(({ where = {} }) => {
|
|
36
|
-
// If `where` has no entries, there are no matching transforms
|
|
37
|
-
if (Object.keys(where).length === 0) return false
|
|
38
|
-
|
|
39
|
-
let performedTest = false
|
|
40
|
-
let foundTransform = true
|
|
41
|
-
|
|
42
|
-
if (where.moduleName) {
|
|
43
|
-
performedTest = true
|
|
44
|
-
|
|
45
|
-
if (moduleName) {
|
|
46
|
-
// Give preference to the module name parsed from the AST vs. the import path string
|
|
47
|
-
foundTransform = foundTransform && where.moduleName === moduleName
|
|
48
|
-
} else {
|
|
49
|
-
foundTransform =
|
|
50
|
-
foundTransform && where.moduleName === parsedImport.moduleName
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (where.moduleNames) {
|
|
55
|
-
performedTest = true
|
|
56
|
-
|
|
57
|
-
if (moduleName) {
|
|
58
|
-
foundTransform =
|
|
59
|
-
foundTransform && where.moduleNames.includes(moduleName)
|
|
60
|
-
} else {
|
|
61
|
-
foundTransform =
|
|
62
|
-
foundTransform &&
|
|
63
|
-
where.moduleNames.includes(parsedImport.moduleName!)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (where.packageName) {
|
|
68
|
-
performedTest = true
|
|
69
|
-
|
|
70
|
-
foundTransform =
|
|
71
|
-
foundTransform && where.packageName === parsedImport.fullName
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (where.packageNames) {
|
|
75
|
-
performedTest = true
|
|
76
|
-
|
|
77
|
-
foundTransform =
|
|
78
|
-
foundTransform && where.packageNames.includes(parsedImport.fullName!)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (where.importPath) {
|
|
82
|
-
performedTest = true
|
|
83
|
-
|
|
84
|
-
foundTransform = foundTransform && where.importPath === importPath
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (where.importPattern) {
|
|
88
|
-
performedTest = true
|
|
89
|
-
|
|
90
|
-
foundTransform =
|
|
91
|
-
foundTransform && new RegExp(where.importPattern).test(importPath)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return performedTest && foundTransform
|
|
95
|
-
}) || {}
|
|
96
|
-
).transform
|
|
97
|
-
}
|
package/lib/utils/parseImport.ts
DELETED
|
@@ -1,78 +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 path from 'path'
|
|
26
|
-
|
|
27
|
-
export default function parseImport(importPath: string): ParsedImport {
|
|
28
|
-
let parsedImport = {}
|
|
29
|
-
|
|
30
|
-
if (!importPath) return {}
|
|
31
|
-
|
|
32
|
-
const splitPath = importPath.split('/')
|
|
33
|
-
|
|
34
|
-
const parseSourceAndModule = (entries: string[] = []) => {
|
|
35
|
-
if (entries.length === 0) return {}
|
|
36
|
-
|
|
37
|
-
const lastEntry = entries[entries.length - 1]
|
|
38
|
-
|
|
39
|
-
const moduleOffset = path.parse(lastEntry).name === 'index' ? 2 : 1
|
|
40
|
-
|
|
41
|
-
const moduleName = entries[entries.length - moduleOffset]
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
moduleName: moduleName ? path.parse(moduleName).name : undefined,
|
|
45
|
-
sourcePath: entries.slice(0, entries.length - moduleOffset).join('/')
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (importPath[0] === '@') {
|
|
50
|
-
const [scope, name, ...rest] = splitPath
|
|
51
|
-
|
|
52
|
-
parsedImport = {
|
|
53
|
-
scope,
|
|
54
|
-
name,
|
|
55
|
-
fullName: `${scope}/${name}`,
|
|
56
|
-
moduleName: `${scope}/${name}`,
|
|
57
|
-
...parseSourceAndModule(rest)
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
const [name, ...rest] = splitPath
|
|
61
|
-
|
|
62
|
-
parsedImport = {
|
|
63
|
-
name,
|
|
64
|
-
fullName: name,
|
|
65
|
-
moduleName: name,
|
|
66
|
-
...parseSourceAndModule(rest)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return parsedImport
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export type ParsedImport = {
|
|
73
|
-
scope?: string
|
|
74
|
-
name?: string
|
|
75
|
-
fullName?: string
|
|
76
|
-
moduleName?: string
|
|
77
|
-
sourcePath?: string
|
|
78
|
-
}
|