Robin Malfait 4e5e0a3e1b
Bump prettier-plugin-tailwindcss to latest version during upgrade (#14808)
This PR adds a migration to bump the `prettier-plugin-tailwindcss`
version to the latest version when upgrading your project. This is to
ensure that the plugin is compatible with the latest version of Tailwind
CSS.

Note: we will only do this _if_ you already used the
`prettier-plugin-tailwindcss` plugin in your project.
2024-10-28 23:46:24 +00:00

16 lines
548 B
TypeScript

import fs from 'node:fs/promises'
import path from 'node:path'
import { pkg } from './utils/packages'
import { success } from './utils/renderer'
export async function migratePrettierPlugin(base: string) {
let packageJsonPath = path.resolve(base, 'package.json')
try {
let packageJson = await fs.readFile(packageJsonPath, 'utf-8')
if (packageJson.includes('prettier-plugin-tailwindcss')) {
await pkg('add prettier-plugin-tailwindcss@latest', base)
success(`Prettier plugin migrated to latest version.`)
}
} catch {}
}