Files
payloadcms/scripts/remove-template-lock-files.ts
Elliot DeNolf 8658945d7b chore(templates): remove unneeded lock files, add hook (#9508)
- Update lock files for blank, website
- Delete unneeded lock files
- Adds git hook to ensure no new lockfiles are added for _other than_
blank and website.
2024-11-25 10:04:41 -05:00

25 lines
833 B
TypeScript

/**
* In order for Payload Cloud to detect the package manager used in a template, it looks for lock files in the root of the template directory.
*
* Lock files should remain for blank and website templates, but should be removed for all others.
*/
import { existsSync, readdirSync, rmSync } from 'fs'
import { join } from 'path'
const baseDir = join(process.cwd(), 'templates')
// These directories MUST contain a lock file for Payload Cloud to detect the package manager
const excluded = ['website', 'blank']
const directories = readdirSync(baseDir, { withFileTypes: true })
.filter((dir) => dir.isDirectory() && !excluded.includes(dir.name))
.map((dir) => join(baseDir, dir.name, 'pnpm-lock.yaml'))
directories.forEach((file) => {
if (existsSync(file)) {
rmSync(file)
console.log(`Removed: ${file}`)
}
})