@instructure/ui-codemods 11.7.6-snapshot-16 → 11.7.6-snapshot-20
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 +7 -0
- package/lib/__node_tests__/codemods.test.ts +14 -14
- package/lib/__node_tests__/runTest.ts +10 -5
- package/lib/__node_tests__/updateInstUIImportVersions.test.ts +44 -44
- package/lib/index.ts +6 -3
- package/lib/instUIv11Codemods.ts +2 -2
- package/lib/migrateToNewIcons.ts +10 -3
- package/lib/multiVersionThemeVariablesCodemod/migrateComponentOverridesToThemeOverride.ts +3 -2
- package/lib/multiVersionThemeVariablesCodemod/multiVersionThemeVariablesCodemod.ts +4 -3
- package/lib/multiVersionThemeVariablesCodemod/themeVariableMappings/index.ts +11 -1
- package/lib/multiVersionThemeVariablesCodemod/transformThemeVariables.ts +3 -2
- package/lib/removeAsFromInstUISettingsProvider.ts +2 -2
- package/lib/renameCanvasThemesCodemod.ts +2 -2
- package/lib/renameGetComputedStyleToGetCSSStyleDeclaration.ts +2 -2
- package/lib/updateInstUIImportVersions.ts +2 -2
- package/lib/updateV10Breaking.ts +2 -2
- package/lib/utils/formatSource.ts +75 -5
- package/lib/utils/instUICodemodExecutor.ts +6 -5
- package/lib/warnCodeEditorRemoved.ts +7 -2
- package/lib/warnTableCaptionMissing.ts +2 -2
- package/package.json +12 -8
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [11.7.6-snapshot-
|
|
6
|
+
## [11.7.6-snapshot-20](https://github.com/instructure/instructure-ui/compare/v11.7.5...v11.7.6-snapshot-20) (2026-09-04)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-codemods
|
|
9
9
|
|
package/README.md
CHANGED
|
@@ -28,6 +28,13 @@ type: code
|
|
|
28
28
|
npx jscodeshift@latest -t node_modules/@instructure/ui-codemods/lib/updateV10Breaking.ts <path>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Formatting
|
|
32
|
+
|
|
33
|
+
Codemods run their output through [Prettier](https://prettier.io/) by default,
|
|
34
|
+
using your project's Prettier installation and [config
|
|
35
|
+
file](https://prettier.io/docs/configuration.html). Prettier is an optional peer
|
|
36
|
+
dependency, both Prettier 2 and Prettier 3 work.
|
|
37
|
+
|
|
31
38
|
For more information about what the codemods do, see the [major version upgrade guides](upgrade-guide)
|
|
32
39
|
|
|
33
40
|
[npm]: https://img.shields.io/npm/v/@instructure/ui-codemods.svg
|
|
@@ -60,38 +60,38 @@ describe('test codemods', () => {
|
|
|
60
60
|
consoleWarningMock.mockRestore()
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
it('test InstUI v10 color codemods', () => {
|
|
64
|
-
runTest(updateV10Breaking)
|
|
63
|
+
it('test InstUI v10 color codemods', async () => {
|
|
64
|
+
await runTest(updateV10Breaking)
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
it('test removing "as" prop from InstUISettingsProvider', () => {
|
|
68
|
-
runTest(removeAsFromInstUISettingsProvider)
|
|
67
|
+
it('test removing "as" prop from InstUISettingsProvider', async () => {
|
|
68
|
+
await runTest(removeAsFromInstUISettingsProvider)
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
it('test renaming Canvas themes', () => {
|
|
72
|
-
runTest(renameCanvasThemesCodemod)
|
|
71
|
+
it('test renaming Canvas themes', async () => {
|
|
72
|
+
await runTest(renameCanvasThemesCodemod)
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
it('test renaming "getComputedStyle" to getCSSStyleDeclaration', () => {
|
|
76
|
-
runTest(renameGetComputedStyleToGetCSSStyleDeclaration)
|
|
75
|
+
it('test renaming "getComputedStyle" to getCSSStyleDeclaration', async () => {
|
|
76
|
+
await runTest(renameGetComputedStyleToGetCSSStyleDeclaration)
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
it('test Table caption prop warning', async () => {
|
|
80
|
-
runTest(warnTableCaptionMissing)
|
|
80
|
+
await runTest(warnTableCaptionMissing)
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
it('test CodeEditor removed warning', async () => {
|
|
84
|
-
runTest(warnCodeEditorRemoved)
|
|
84
|
+
await runTest(warnCodeEditorRemoved)
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
-
it('test migrating legacy icons to lucide/custom icons', () => {
|
|
88
|
-
runTest(migrateToNewIcons)
|
|
87
|
+
it('test migrating legacy icons to lucide/custom icons', async () => {
|
|
88
|
+
await runTest(migrateToNewIcons)
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
// All fixtures run through the full `multiVersionThemeVariablesCodemod` (both
|
|
92
92
|
// legs: token renames + provider override relocation), so every `.output` is
|
|
93
93
|
// the real end-to-end result a user gets - no single-leg intermediate states.
|
|
94
|
-
it('test multi-version theme variables codemod (end-to-end)', () => {
|
|
95
|
-
runTest(multiVersionThemeVariablesCodemod)
|
|
94
|
+
it('test multi-version theme variables codemod (end-to-end)', async () => {
|
|
95
|
+
await runTest(multiVersionThemeVariablesCodemod)
|
|
96
96
|
})
|
|
97
97
|
})
|
|
@@ -36,13 +36,13 @@ import { expect, vi } from 'vitest'
|
|
|
36
36
|
* - Fixtures must be named `XY.input.[ts|tsx|js]` and `XY.output.[ts|tsx|js]`
|
|
37
37
|
* @param codemod The codemod to run
|
|
38
38
|
*/
|
|
39
|
-
export function runTest(codemod: Transform) {
|
|
39
|
+
export async function runTest(codemod: Transform) {
|
|
40
40
|
// Fixtures live in `./__testfixtures__/[codemod name]/`.
|
|
41
41
|
const fixturesDir = `${__dirname}/__testfixtures__/${codemod.name}`
|
|
42
42
|
const entries = fs.readdirSync(fixturesDir, { withFileTypes: true })
|
|
43
43
|
|
|
44
44
|
let fixturesRun = 0
|
|
45
|
-
|
|
45
|
+
for (const entry of entries) {
|
|
46
46
|
if (entry.isFile() && entry.name.includes('input')) {
|
|
47
47
|
const isWarningTest = entry.name.includes('.warning.input')
|
|
48
48
|
const inputPath = path.join(entry.parentPath, entry.name)
|
|
@@ -82,7 +82,7 @@ export function runTest(codemod: Transform) {
|
|
|
82
82
|
const options = {}
|
|
83
83
|
|
|
84
84
|
// Run codemod withouth comparison
|
|
85
|
-
codemod(fileInfo, api, options)
|
|
85
|
+
await codemod(fileInfo, api, options)
|
|
86
86
|
|
|
87
87
|
const expectedWarningContent = fs
|
|
88
88
|
.readFileSync(expectedPath, 'utf8')
|
|
@@ -123,11 +123,16 @@ export function runTest(codemod: Transform) {
|
|
|
123
123
|
warnSpy.mockRestore()
|
|
124
124
|
}
|
|
125
125
|
} else {
|
|
126
|
-
runInlineTest(
|
|
126
|
+
await runInlineTest(
|
|
127
|
+
codemod,
|
|
128
|
+
{},
|
|
129
|
+
{ path: inputPath, source: input },
|
|
130
|
+
expected
|
|
131
|
+
)
|
|
127
132
|
}
|
|
128
133
|
fixturesRun++
|
|
129
134
|
}
|
|
130
|
-
}
|
|
135
|
+
}
|
|
131
136
|
if (fixturesRun === 0) {
|
|
132
137
|
throw new Error(
|
|
133
138
|
`Test failed for codemod "${codemod.name}": No fixtures found.`
|
|
@@ -45,8 +45,8 @@ function makeFileInfo(source: string) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
describe('updateInstUIImportVersions', () => {
|
|
48
|
-
it('rewrites unversioned @instructure import to target version', () => {
|
|
49
|
-
runInlineTest(
|
|
48
|
+
it('rewrites unversioned @instructure import to target version', async () => {
|
|
49
|
+
await runInlineTest(
|
|
50
50
|
updateInstUIImportVersions,
|
|
51
51
|
{ versionTo: 'v11.7' },
|
|
52
52
|
makeFileInfo(`import { Button } from '@instructure/ui'`),
|
|
@@ -54,8 +54,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
54
54
|
)
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
-
it('rewrites an import that @instructure/ui re-exports under an alias', () => {
|
|
58
|
-
runInlineTest(
|
|
57
|
+
it('rewrites an import that @instructure/ui re-exports under an alias', async () => {
|
|
58
|
+
await runInlineTest(
|
|
59
59
|
updateInstUIImportVersions,
|
|
60
60
|
{ versionTo: 'v11.7' },
|
|
61
61
|
makeFileInfo(`import { TreeBrowserCollection } from '@instructure/ui'`),
|
|
@@ -63,8 +63,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
63
63
|
)
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
-
it('rewrites versioned import from versionFrom to versionTo', () => {
|
|
67
|
-
runInlineTest(
|
|
66
|
+
it('rewrites versioned import from versionFrom to versionTo', async () => {
|
|
67
|
+
await runInlineTest(
|
|
68
68
|
updateInstUIImportVersions,
|
|
69
69
|
{ versionTo: 'v11.7', versionFrom: 'v11.6' },
|
|
70
70
|
makeFileInfo(`import { Button } from '@instructure/ui/v11_6'`),
|
|
@@ -72,8 +72,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
72
72
|
)
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
it('returns null when versionFrom does not match', () => {
|
|
76
|
-
const result = updateInstUIImportVersions(
|
|
75
|
+
it('returns null when versionFrom does not match', async () => {
|
|
76
|
+
const result = await updateInstUIImportVersions(
|
|
77
77
|
makeFileInfo(`import { Button } from '@instructure/ui/v11_5'`),
|
|
78
78
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
79
79
|
{ versionTo: 'v11.7', versionFrom: 'v11.6' }
|
|
@@ -81,8 +81,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
81
81
|
expect(result).toBeNull()
|
|
82
82
|
})
|
|
83
83
|
|
|
84
|
-
it('rewrites only imports containing the specified component', () => {
|
|
85
|
-
runInlineTest(
|
|
84
|
+
it('rewrites only imports containing the specified component', async () => {
|
|
85
|
+
await runInlineTest(
|
|
86
86
|
updateInstUIImportVersions,
|
|
87
87
|
{ versionTo: 'v11.7', components: 'Button' },
|
|
88
88
|
makeFileInfo(
|
|
@@ -99,8 +99,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
99
99
|
)
|
|
100
100
|
})
|
|
101
101
|
|
|
102
|
-
it('returns null when no imports match the specified component', () => {
|
|
103
|
-
const result = updateInstUIImportVersions(
|
|
102
|
+
it('returns null when no imports match the specified component', async () => {
|
|
103
|
+
const result = await updateInstUIImportVersions(
|
|
104
104
|
makeFileInfo(`import { Alert } from '@instructure/ui'`),
|
|
105
105
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
106
106
|
{ versionTo: 'v11.7', components: 'Button' }
|
|
@@ -108,7 +108,7 @@ describe('updateInstUIImportVersions', () => {
|
|
|
108
108
|
expect(result).toBeNull()
|
|
109
109
|
})
|
|
110
110
|
|
|
111
|
-
it('returns null for non-@instructure imports', () => {
|
|
111
|
+
it('returns null for non-@instructure imports', async () => {
|
|
112
112
|
// Includes component names that are in versionedExports but come from other packages —
|
|
113
113
|
// the codemod must check the package, not just the import name.
|
|
114
114
|
const cases = [
|
|
@@ -118,7 +118,7 @@ describe('updateInstUIImportVersions', () => {
|
|
|
118
118
|
`import { Alert } from 'antd'`
|
|
119
119
|
]
|
|
120
120
|
for (const source of cases) {
|
|
121
|
-
const result = updateInstUIImportVersions(
|
|
121
|
+
const result = await updateInstUIImportVersions(
|
|
122
122
|
makeFileInfo(source),
|
|
123
123
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
124
124
|
{ versionTo: 'v11.7' }
|
|
@@ -127,9 +127,9 @@ describe('updateInstUIImportVersions', () => {
|
|
|
127
127
|
}
|
|
128
128
|
})
|
|
129
129
|
|
|
130
|
-
it('does not rewrite non-versioned components', () => {
|
|
130
|
+
it('does not rewrite non-versioned components', async () => {
|
|
131
131
|
// 'withStyleNew' is not in versionedExports, so it should be skipped
|
|
132
|
-
const result = updateInstUIImportVersions(
|
|
132
|
+
const result = await updateInstUIImportVersions(
|
|
133
133
|
makeFileInfo(`import { withStyleNew } from '@instructure/ui'`),
|
|
134
134
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
135
135
|
{ versionTo: 'v11.7' }
|
|
@@ -137,10 +137,10 @@ describe('updateInstUIImportVersions', () => {
|
|
|
137
137
|
expect(result).toBeNull()
|
|
138
138
|
})
|
|
139
139
|
|
|
140
|
-
it('does not split mixed @instructure/ui import: moves all specifiers to versioned path', () => {
|
|
140
|
+
it('does not split mixed @instructure/ui import: moves all specifiers to versioned path', async () => {
|
|
141
141
|
// @instructure/ui version files re-export everything including non-component
|
|
142
142
|
// symbols (e.g. canvas), so splitting is unnecessary — rewrite the whole import.
|
|
143
|
-
runInlineTest(
|
|
143
|
+
await runInlineTest(
|
|
144
144
|
updateInstUIImportVersions,
|
|
145
145
|
{ versionTo: 'v11.7' },
|
|
146
146
|
makeFileInfo(`import {canvas, Button} from "@instructure/ui"`),
|
|
@@ -148,9 +148,9 @@ describe('updateInstUIImportVersions', () => {
|
|
|
148
148
|
)
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
-
it('splits mixed import from an individual @instructure package: non-component stays, component moves', () => {
|
|
151
|
+
it('splits mixed import from an individual @instructure package: non-component stays, component moves', async () => {
|
|
152
152
|
// TestComponent is not in versionedExports, Button is → triggers a split
|
|
153
|
-
runInlineTest(
|
|
153
|
+
await runInlineTest(
|
|
154
154
|
updateInstUIImportVersions,
|
|
155
155
|
{ versionTo: 'v11.7' },
|
|
156
156
|
makeFileInfo(
|
|
@@ -161,8 +161,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
161
161
|
)
|
|
162
162
|
})
|
|
163
163
|
|
|
164
|
-
it('does not add semicolons to split imports when usePrettier=false and file has no semis', () => {
|
|
165
|
-
runInlineTest(
|
|
164
|
+
it('does not add semicolons to split imports when usePrettier=false and file has no semis', async () => {
|
|
165
|
+
await runInlineTest(
|
|
166
166
|
updateInstUIImportVersions,
|
|
167
167
|
{ versionTo: 'v11.7', usePrettier: false },
|
|
168
168
|
makeFileInfo(
|
|
@@ -172,8 +172,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
172
172
|
)
|
|
173
173
|
})
|
|
174
174
|
|
|
175
|
-
it('preserves semicolons in split imports when file uses semis and usePrettier=false', () => {
|
|
176
|
-
runInlineTest(
|
|
175
|
+
it('preserves semicolons in split imports when file uses semis and usePrettier=false', async () => {
|
|
176
|
+
await runInlineTest(
|
|
177
177
|
updateInstUIImportVersions,
|
|
178
178
|
{ versionTo: 'v11.7', usePrettier: false },
|
|
179
179
|
makeFileInfo(
|
|
@@ -183,9 +183,9 @@ describe('updateInstUIImportVersions', () => {
|
|
|
183
183
|
)
|
|
184
184
|
})
|
|
185
185
|
|
|
186
|
-
it('moves type specifier to versioned path when its name is a known component', () => {
|
|
186
|
+
it('moves type specifier to versioned path when its name is a known component', async () => {
|
|
187
187
|
// 'type Alert' — inline type modifier, Alert is in versionedExports
|
|
188
|
-
runInlineTest(
|
|
188
|
+
await runInlineTest(
|
|
189
189
|
updateInstUIImportVersions,
|
|
190
190
|
{ versionTo: 'v11.7', components: 'Button,Alert' },
|
|
191
191
|
makeFileInfo(`import { Button, type Alert } from '@instructure/ui'`),
|
|
@@ -193,10 +193,10 @@ describe('updateInstUIImportVersions', () => {
|
|
|
193
193
|
)
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
-
it('moves all specifiers to versioned path when source is @instructure/ui, even with --components filter', () => {
|
|
196
|
+
it('moves all specifiers to versioned path when source is @instructure/ui, even with --components filter', async () => {
|
|
197
197
|
// ButtonProps is not in the components filter, but @instructure/ui
|
|
198
198
|
// version files re-export everything — no split, whole import moves.
|
|
199
|
-
runInlineTest(
|
|
199
|
+
await runInlineTest(
|
|
200
200
|
updateInstUIImportVersions,
|
|
201
201
|
{ versionTo: 'v11.7', components: 'Button' },
|
|
202
202
|
makeFileInfo(
|
|
@@ -206,8 +206,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
206
206
|
)
|
|
207
207
|
})
|
|
208
208
|
|
|
209
|
-
it('leaves default imports and type-only named imports untouched when not in components', () => {
|
|
210
|
-
const result = updateInstUIImportVersions(
|
|
209
|
+
it('leaves default imports and type-only named imports untouched when not in components', async () => {
|
|
210
|
+
const result = await updateInstUIImportVersions(
|
|
211
211
|
makeFileInfo(`import Service, { type Config } from '@instructure/ui'`),
|
|
212
212
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
213
213
|
{ versionTo: 'v11.7' }
|
|
@@ -216,8 +216,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
216
216
|
expect(result).toBeNull()
|
|
217
217
|
})
|
|
218
218
|
|
|
219
|
-
it('returns null when versionTo is not provided', () => {
|
|
220
|
-
const result = updateInstUIImportVersions(
|
|
219
|
+
it('returns null when versionTo is not provided', async () => {
|
|
220
|
+
const result = await updateInstUIImportVersions(
|
|
221
221
|
makeFileInfo(`import { Button } from '@instructure/ui'`),
|
|
222
222
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
223
223
|
{}
|
|
@@ -225,11 +225,11 @@ describe('updateInstUIImportVersions', () => {
|
|
|
225
225
|
expect(result).toBeNull()
|
|
226
226
|
})
|
|
227
227
|
|
|
228
|
-
it('diagnose mode reports matching imports', () => {
|
|
228
|
+
it('diagnose mode reports matching imports', async () => {
|
|
229
229
|
const reported: string[] = []
|
|
230
230
|
const api = makeApi((msg: string) => reported.push(msg))
|
|
231
231
|
|
|
232
|
-
updateInstUIImportVersions(
|
|
232
|
+
await updateInstUIImportVersions(
|
|
233
233
|
makeFileInfo(`import { Button, Alert } from '@instructure/ui/v11_6'`),
|
|
234
234
|
api as Parameters<typeof updateInstUIImportVersions>[1],
|
|
235
235
|
{ diagnose: true }
|
|
@@ -241,11 +241,11 @@ describe('updateInstUIImportVersions', () => {
|
|
|
241
241
|
expect(reported[0]).toContain('v11_6')
|
|
242
242
|
})
|
|
243
243
|
|
|
244
|
-
it('diagnose mode filters by component name', () => {
|
|
244
|
+
it('diagnose mode filters by component name', async () => {
|
|
245
245
|
const reported: string[] = []
|
|
246
246
|
const api = makeApi((msg: string) => reported.push(msg))
|
|
247
247
|
|
|
248
|
-
updateInstUIImportVersions(
|
|
248
|
+
await updateInstUIImportVersions(
|
|
249
249
|
makeFileInfo(`import { Button, Alert } from '@instructure/ui/v11_6'`),
|
|
250
250
|
api as Parameters<typeof updateInstUIImportVersions>[1],
|
|
251
251
|
{ diagnose: true, components: 'Button' }
|
|
@@ -256,11 +256,11 @@ describe('updateInstUIImportVersions', () => {
|
|
|
256
256
|
expect(reported[0]).not.toContain('Alert')
|
|
257
257
|
})
|
|
258
258
|
|
|
259
|
-
it('diagnose mode shows "oldest" label for unversioned imports', () => {
|
|
259
|
+
it('diagnose mode shows "oldest" label for unversioned imports', async () => {
|
|
260
260
|
const reported: string[] = []
|
|
261
261
|
const api = makeApi((msg: string) => reported.push(msg))
|
|
262
262
|
|
|
263
|
-
updateInstUIImportVersions(
|
|
263
|
+
await updateInstUIImportVersions(
|
|
264
264
|
makeFileInfo(`import { Button } from '@instructure/ui'`),
|
|
265
265
|
api as Parameters<typeof updateInstUIImportVersions>[1],
|
|
266
266
|
{ diagnose: true }
|
|
@@ -270,7 +270,7 @@ describe('updateInstUIImportVersions', () => {
|
|
|
270
270
|
expect(reported[0]).toContain('oldest')
|
|
271
271
|
})
|
|
272
272
|
|
|
273
|
-
it('rewrites all matching imports in a file with 10+ @instructure imports', () => {
|
|
273
|
+
it('rewrites all matching imports in a file with 10+ @instructure imports', async () => {
|
|
274
274
|
const input = [
|
|
275
275
|
`import React from 'react'`,
|
|
276
276
|
`import { Alert } from '@instructure/ui'`,
|
|
@@ -305,7 +305,7 @@ describe('updateInstUIImportVersions', () => {
|
|
|
305
305
|
`import type { SomeType } from 'some-lib'`
|
|
306
306
|
].join('\n')
|
|
307
307
|
|
|
308
|
-
runInlineTest(
|
|
308
|
+
await runInlineTest(
|
|
309
309
|
updateInstUIImportVersions,
|
|
310
310
|
{ versionTo: 'v11.7' },
|
|
311
311
|
makeFileInfo(input),
|
|
@@ -313,8 +313,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
313
313
|
)
|
|
314
314
|
})
|
|
315
315
|
|
|
316
|
-
it('rewrites named imports from individual @instructure packages', () => {
|
|
317
|
-
runInlineTest(
|
|
316
|
+
it('rewrites named imports from individual @instructure packages', async () => {
|
|
317
|
+
await runInlineTest(
|
|
318
318
|
updateInstUIImportVersions,
|
|
319
319
|
{ versionTo: 'v11.7' },
|
|
320
320
|
makeFileInfo(
|
|
@@ -332,8 +332,8 @@ describe('updateInstUIImportVersions', () => {
|
|
|
332
332
|
)
|
|
333
333
|
})
|
|
334
334
|
|
|
335
|
-
it('does not rewrite default imports from @instructure packages', () => {
|
|
336
|
-
const result = updateInstUIImportVersions(
|
|
335
|
+
it('does not rewrite default imports from @instructure packages', async () => {
|
|
336
|
+
const result = await updateInstUIImportVersions(
|
|
337
337
|
makeFileInfo(`import Button from '@instructure/ui-button'`),
|
|
338
338
|
makeApi() as Parameters<typeof updateInstUIImportVersions>[1],
|
|
339
339
|
{ versionTo: 'v11.7' }
|
package/lib/index.ts
CHANGED
|
@@ -34,14 +34,17 @@ import updateInstUIImportVersions from './updateInstUIImportVersions'
|
|
|
34
34
|
import multiVersionThemeVariablesCodemod from './multiVersionThemeVariablesCodemod/multiVersionThemeVariablesCodemod'
|
|
35
35
|
|
|
36
36
|
export {
|
|
37
|
+
// Codemods for InstUI v9 -> v10
|
|
37
38
|
updateV10Breaking,
|
|
39
|
+
// Codemods for InstUI v10 -> v11
|
|
38
40
|
instUIv11Codemods,
|
|
39
41
|
removeAsFromInstUISettingsProvider,
|
|
40
42
|
renameCanvasThemes,
|
|
41
|
-
renameGetComputedStyleToGetCSSStyleDeclaration,
|
|
42
43
|
warnTableCaptionMissing,
|
|
44
|
+
renameGetComputedStyleToGetCSSStyleDeclaration,
|
|
43
45
|
warnCodeEditorRemoved,
|
|
46
|
+
// Codemods for new theming/multi version (used by InstUI v11.7.2 and above)
|
|
44
47
|
migrateToNewIcons,
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
multiVersionThemeVariablesCodemod,
|
|
49
|
+
updateInstUIImportVersions
|
|
47
50
|
}
|
package/lib/instUIv11Codemods.ts
CHANGED
|
@@ -32,12 +32,12 @@ import { warnCodeEditorRemovedCodemod } from './warnCodeEditorRemoved'
|
|
|
32
32
|
/**
|
|
33
33
|
* Runs all InstUI v10 -> v11 upgrade codemods
|
|
34
34
|
*/
|
|
35
|
-
const InstUIv11Codemods: Transform = (
|
|
35
|
+
const InstUIv11Codemods: Transform = async (
|
|
36
36
|
file,
|
|
37
37
|
api,
|
|
38
38
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
39
39
|
) => {
|
|
40
|
-
return instUICodemodExecutor(
|
|
40
|
+
return await instUICodemodExecutor(
|
|
41
41
|
[
|
|
42
42
|
removeAsProp,
|
|
43
43
|
renameCanvasThemes,
|
package/lib/migrateToNewIcons.ts
CHANGED
|
@@ -111,8 +111,10 @@ function migrateIcons(j: JSCodeshift, root: Collection): boolean {
|
|
|
111
111
|
/**
|
|
112
112
|
* Migrates legacy InstUI icons (`IconXxxLine` / `IconXxxSolid`) to new
|
|
113
113
|
* `XxxInstUIIcon` components.
|
|
114
|
+
* Warns about legacy icons that has no mappings and have to be migrated manually.
|
|
115
|
+
* New icons were introduced in InstUI v11.7.2
|
|
114
116
|
*
|
|
115
|
-
*
|
|
117
|
+
* This codemod will rename icons if they are imported from:
|
|
116
118
|
* - `@instructure/ui-icons`
|
|
117
119
|
* - `@instructure/ui-icons/es/svg`
|
|
118
120
|
* - `@instructure/ui`
|
|
@@ -122,8 +124,13 @@ const migrateToNewIconsCodemod: InstUICodemod = (j, root, filePath) => {
|
|
|
122
124
|
return migrateIcons(j, root)
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
const migrateToNewIcons: Transform = (file, api, options) => {
|
|
126
|
-
return instUICodemodExecutor(
|
|
127
|
+
const migrateToNewIcons: Transform = async (file, api, options) => {
|
|
128
|
+
return await instUICodemodExecutor(
|
|
129
|
+
migrateToNewIconsCodemod,
|
|
130
|
+
file,
|
|
131
|
+
api,
|
|
132
|
+
options
|
|
133
|
+
)
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
export default migrateToNewIcons
|
|
@@ -39,13 +39,14 @@ import { namedTypes } from 'ast-types'
|
|
|
39
39
|
* channel, so every component override must move - regardless of whether its
|
|
40
40
|
* tokens have changed. Token renames are handled separately by
|
|
41
41
|
* `transformThemeVariables`.
|
|
42
|
+
* This change was introduced in InstUI v11.7.2
|
|
42
43
|
*/
|
|
43
|
-
const migrateComponentOverridesToThemeOverride: Transform = (
|
|
44
|
+
const migrateComponentOverridesToThemeOverride: Transform = async (
|
|
44
45
|
file,
|
|
45
46
|
api,
|
|
46
47
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
47
48
|
) => {
|
|
48
|
-
return instUICodemodExecutor(
|
|
49
|
+
return await instUICodemodExecutor(
|
|
49
50
|
migrateComponentOverridesToThemeOverrideCodemod,
|
|
50
51
|
file,
|
|
51
52
|
api,
|
|
@@ -28,14 +28,15 @@ import { transformThemeVariablesCodemod } from './transformThemeVariables'
|
|
|
28
28
|
import { migrateComponentOverridesToThemeOverrideCodemod } from './migrateComponentOverridesToThemeOverride'
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Runs all InstUI multi-version upgrade codemods
|
|
31
|
+
* Runs all InstUI multi-version upgrade codemods.
|
|
32
|
+
* (used for multi-version introduced in InstUI v11.7.2)
|
|
32
33
|
*/
|
|
33
|
-
const multiVersionThemeVariablesCodemod: Transform = (
|
|
34
|
+
const multiVersionThemeVariablesCodemod: Transform = async (
|
|
34
35
|
file,
|
|
35
36
|
api,
|
|
36
37
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
37
38
|
) => {
|
|
38
|
-
return instUICodemodExecutor(
|
|
39
|
+
return await instUICodemodExecutor(
|
|
39
40
|
[
|
|
40
41
|
transformThemeVariablesCodemod,
|
|
41
42
|
migrateComponentOverridesToThemeOverrideCodemod
|
|
@@ -159,7 +159,9 @@ export const THEME_VARIABLE_MAPPINGS: Record<string, ComponentMapping> = {
|
|
|
159
159
|
import: '@instructure/ui-billboard',
|
|
160
160
|
removed: {
|
|
161
161
|
iconColor: {},
|
|
162
|
-
iconHoverColor: {}
|
|
162
|
+
iconHoverColor: {},
|
|
163
|
+
iconHoverColorInverse: {},
|
|
164
|
+
messageColorInverse: {}
|
|
163
165
|
}
|
|
164
166
|
},
|
|
165
167
|
Spinner: {
|
|
@@ -1191,6 +1193,14 @@ export const THEME_VARIABLE_MAPPINGS: Record<string, ComponentMapping> = {
|
|
|
1191
1193
|
cardBorderRadius: { to: 'borderRadius' }
|
|
1192
1194
|
}
|
|
1193
1195
|
},
|
|
1196
|
+
DataPermissionLevels: {
|
|
1197
|
+
import: '@instructure/ui-instructure',
|
|
1198
|
+
removed: {
|
|
1199
|
+
cardPadding: {},
|
|
1200
|
+
cardExplainerContainerBottomMargin: {},
|
|
1201
|
+
cardGap: {}
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1194
1204
|
Flex: {
|
|
1195
1205
|
import: '@instructure/ui-flex',
|
|
1196
1206
|
removed: {
|
|
@@ -32,13 +32,14 @@ import type { ComponentMapping } from './themeVariableMappings'
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Renames/removes component theme variables to their new (multi-version) names.
|
|
35
|
+
* This change was introduced in InstUI v11.7.2
|
|
35
36
|
*/
|
|
36
|
-
const transformThemeVariables: Transform = (
|
|
37
|
+
const transformThemeVariables: Transform = async (
|
|
37
38
|
file,
|
|
38
39
|
api,
|
|
39
40
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
40
41
|
) => {
|
|
41
|
-
return instUICodemodExecutor(
|
|
42
|
+
return await instUICodemodExecutor(
|
|
42
43
|
transformThemeVariablesCodemod,
|
|
43
44
|
file,
|
|
44
45
|
api,
|
|
@@ -30,12 +30,12 @@ import { isJSXAttribute } from './utils/codemodTypeCheckers'
|
|
|
30
30
|
/**
|
|
31
31
|
* removes the `as` prop from InstUISettingsProvider.
|
|
32
32
|
*/
|
|
33
|
-
const removeAsFromInstUISettingsProvider: Transform = (
|
|
33
|
+
const removeAsFromInstUISettingsProvider: Transform = async (
|
|
34
34
|
file,
|
|
35
35
|
api,
|
|
36
36
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
37
37
|
) => {
|
|
38
|
-
return instUICodemodExecutor(removeAsProp, file, api, options)
|
|
38
|
+
return await instUICodemodExecutor(removeAsProp, file, api, options)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const removeAsProp = (j: JSCodeshift, root: Collection, filePath: string) => {
|
|
@@ -32,12 +32,12 @@ import instUICodemodExecutor from './utils/instUICodemodExecutor'
|
|
|
32
32
|
* `canvasHighContrastTheme`, warns about deleted `ThemeRegistry` imports and
|
|
33
33
|
* the removed `canvas.use()`/`canvasHighContrast.use()` functions
|
|
34
34
|
*/
|
|
35
|
-
const renameCanvasThemesCodemod: Transform = (
|
|
35
|
+
const renameCanvasThemesCodemod: Transform = async (
|
|
36
36
|
file,
|
|
37
37
|
api,
|
|
38
38
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
39
39
|
) => {
|
|
40
|
-
return instUICodemodExecutor(renameCanvasThemes, file, api, options)
|
|
40
|
+
return await instUICodemodExecutor(renameCanvasThemes, file, api, options)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const renameCanvasThemes: InstUICodemod = (j, root, filePath) => {
|
|
@@ -28,12 +28,12 @@ import instUICodemodExecutor from './utils/instUICodemodExecutor'
|
|
|
28
28
|
/**
|
|
29
29
|
* renames the `getComputedStyle` utility function to `getCSSStyleDeclaration`
|
|
30
30
|
*/
|
|
31
|
-
const renameGetComputedStyleToGetCSSStyleDeclaration: Transform = (
|
|
31
|
+
const renameGetComputedStyleToGetCSSStyleDeclaration: Transform = async (
|
|
32
32
|
file,
|
|
33
33
|
api,
|
|
34
34
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
35
35
|
) => {
|
|
36
|
-
return instUICodemodExecutor(renameGetComputedStyle, file, api, options)
|
|
36
|
+
return await instUICodemodExecutor(renameGetComputedStyle, file, api, options)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const renameGetComputedStyle = (j: JSCodeshift, root: Collection) => {
|
|
@@ -211,7 +211,7 @@ const updateInstUIImportVersionsCodemod =
|
|
|
211
211
|
return hasChanges
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
const updateInstUIImportVersions: Transform = (file, api, options) => {
|
|
214
|
+
const updateInstUIImportVersions: Transform = async (file, api, options) => {
|
|
215
215
|
// When no --components filter is given, fall back to the full list of known
|
|
216
216
|
const components = parseComponents(options.components) ?? [
|
|
217
217
|
...versionedExports
|
|
@@ -245,7 +245,7 @@ const updateInstUIImportVersions: Transform = (file, api, options) => {
|
|
|
245
245
|
const hasSemi = detectSemi(file.source)
|
|
246
246
|
|
|
247
247
|
try {
|
|
248
|
-
const result = instUICodemodExecutor(
|
|
248
|
+
const result = await instUICodemodExecutor(
|
|
249
249
|
updateInstUIImportVersionsCodemod(
|
|
250
250
|
components,
|
|
251
251
|
versionTo,
|
package/lib/updateV10Breaking.ts
CHANGED
|
@@ -29,12 +29,12 @@ import instUICodemodExecutor from './utils/instUICodemodExecutor'
|
|
|
29
29
|
/**
|
|
30
30
|
* Updates theme color syntax from InstUI v9 to v10
|
|
31
31
|
*/
|
|
32
|
-
const updateV10Breaking: Transform = (
|
|
32
|
+
const updateV10Breaking: Transform = async (
|
|
33
33
|
file,
|
|
34
34
|
api,
|
|
35
35
|
options?: { fileName?: string; usePrettier?: boolean }
|
|
36
36
|
) => {
|
|
37
|
-
return instUICodemodExecutor(updateToV10Colors, file, api, options)
|
|
37
|
+
return await instUICodemodExecutor(updateToV10Colors, file, api, options)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export default updateV10Breaking
|