Robin Malfait eb54dcdbfc
Install @tailwindcss/postcss next to tailwindcss (#14830)
This PR improves the PostCSS migrations to make sure that we install
`@tailwindcss/postcss` in the same bucket as `tailwindcss`.

If `tailwindcss` exists in the `dependencies` bucket, we install
`@tailwindcss/postcss` in the same bucket. If `tailwindcss` exists in
the `devDependencies` bucket, we install `@tailwindcss/postcss` in the
same bucket.

This also contains an internal refactor that normalizes the package
manager to make sure we can install a package to the correct bucket
depending on the package manager.

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2024-10-30 15:32:24 -04:00

16 lines
550 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(base).add(['prettier-plugin-tailwindcss@latest'])
success(`Prettier plugin migrated to latest version.`)
}
} catch {}
}