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.
This commit is contained in:
24
scripts/remove-template-lock-files.ts
Normal file
24
scripts/remove-template-lock-files.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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}`)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user