INSTUI-5173: Document the new codemods in the upgrade guide; allow both Prettier 2 and 3 to run in the codemods - #2705
INSTUI-5173: Document the new codemods in the upgrade guide; allow both Prettier 2 and 3 to run in the codemods#2705matyasf wants to merge 2 commits into
Conversation
|
Visual regression reportCypress suite: ✅ Passing Visual diff:
Accessibility (axe): ✅ No violations. 📊 View full report — click a screenshot's ⚠ badge to see each violation boxed on the image, with the offending element named and contrast failures shown as color swatches. Baselines come from the |
|
|
||
| ## Codemods | ||
|
|
||
| ### updateInstUIImportVersions |
There was a problem hiding this comment.
this section was just moved up
| * @returns a promise resolving to the modified file as `string` or to `null` | ||
| */ | ||
| const myCodemod: Transform = (file, api, | ||
| const myCodemod: Transform = async (file, api, |
There was a problem hiding this comment.
async is needed because Prettier 3 as async, thus everything needs to be async
| - `fileName`: write parse errors and transform failures to this file. | ||
| - `usePrettier`: run output through Prettier (default `true`). | ||
|
|
||
| ### migrateToNewIcons |
| removed: { | ||
| iconColor: {}, | ||
| iconHoverColor: {} | ||
| iconHoverColor: {}, |
There was a problem hiding this comment.
changes in this file are because these were late additiong and were missing from the codemod
| const importModule = new Function('specifier', 'return import(specifier)') as ( | ||
| specifier: string | ||
| ) => Promise<Record<string, unknown>> | ||
|
|
||
| async function importPrettier(): Promise<Record<string, unknown>> { | ||
| try { | ||
| return await importModule(PRETTIER) | ||
| } catch { | ||
| // Test runners that evaluate modules in their own context (Vitest) give | ||
| // `new Function` no dynamic import callback, but do handle a plain import. | ||
| return await import(PRETTIER) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Prettier is an optional peer dependency, so it is resolved from the | ||
| * consumer's `node_modules` and its version is whatever they installed. | ||
| */ | ||
| function loadPrettier() { | ||
| if (!prettierPromise) { | ||
| prettierPromise = importPrettier() | ||
| .then((namespace) => { | ||
| const asDefault = namespace.default as PrettierModule | undefined | ||
| return typeof asDefault?.format === 'function' | ||
| ? asDefault | ||
| : (namespace as unknown as PrettierModule) | ||
| }) | ||
| .catch(() => undefined) | ||
| } | ||
| return prettierPromise | ||
| } |
There was a problem hiding this comment.
this whole thing is super ugly, but needed while ppl are using Prettier v2..
a0d79de to
c598399
Compare
| @@ -1,10 +1,10 @@ | |||
| --- | |||
| title: Upgrade guide for v11.7 | |||
| title: Upgrade guide for new theming | |||
There was a problem hiding this comment.
I was really debating the best title for this (cannot be much longer than now), still not 100% sure that this is the best
| --- | ||
|
|
||
| # Upgrade guide for v10 -> v11 | ||
| # Upgrade guide for v10 -> 11 |
There was a problem hiding this comment.
Why did you remove v from v11 here?
There was a problem hiding this comment.
Wanted to keep the title as short at possible
| npx jscodeshift@latest -t node_modules/@instructure/ui-codemods/lib/[codemod name].ts <path> \ | ||
| --extensions=ts,tsx \ | ||
| --ignore-pattern="**/node_modules/**" \ | ||
| --ignore-pattern="**/*.d.ts" \ |
There was a problem hiding this comment.
Remove the trailing slash after the last line
There was a problem hiding this comment.
I tried loading the upgrade-guide in a local environment and it loads extremely slowly for me. Please check it
There was a problem hiding this comment.
Thats because this page is huge and because you are using a debug build. Even in the prod build its 2 secs on my M3 Max. I guess if we'd optimize V12ChangelogTable to e.g. use native HTML instead of InstUI it would be much faster. maybe worth a shot in a different PR.
Is it a bad UX in your machine here too? https://instructure.design/pr-preview/pr-2705/upgrade-guide
c598399 to
95d5acd
Compare
Move the codemod docs to the top of the v11.7 upgrade guide and add migrateToNewIcons and multiVersionThemeVariablesCodemod sections. Note which InstUI version introduced each change in the codemod JSDoc, and group the exports by target version. Also add the missing Billboard iconHoverColorInverse and messageColorInverse removals and a DataPermissionLevels entry to the theme variable mappings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ettier 3 Prettier is now an optional peer dependency instead of a bundled Prettier 2. The codemods import it lazily from the consumer's node_modules, accept both the v2 sync and v3 async API, and fall back to unformatted output with a warning when it is not installed. This makes instUICodemodExecutor and every transform async, so the tests await them and the codemod fixtures are excluded from the repo's own Prettier run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
95d5acd to
e480a2a
Compare
| let warnedAboutMissingPrettier = false | ||
|
|
||
| /** | ||
| * jscodeshift registers `@babel/register` for `.mjs` and `.cjs` files too and |
There was a problem hiding this comment.
A bit too verbose comment here


Summary
migrateToNewIconsandmultiVersionThemeVariablesCodemoddocsiconHoverColorInverse/messageColorInverseremovals and aDataPermissionLevelsentry to the theme variable mappingsTest Plan
multiVersionThemeVariablesCodemodagainst a file using BillboardiconHoverColorInverse/messageColorInverseandDataPermissionLevelsoverrides to confirm they're removed.Fixes INSTUI-5173
🤖 Generated with Claude Code