forked from payloadcms/payload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-generated-templates.ts
36 lines (30 loc) · 1.13 KB
/
build-generated-templates.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as fs from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import path from 'path'
import { execSync } from 'child_process'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
main().catch((error) => {
console.error(error)
process.exit(1)
})
async function main() {
// Get all directories in `templates` directory
const repoRoot = path.resolve(dirname, '..')
const templatesDir = path.resolve(repoRoot, 'templates')
const rawTemplateDirs = await fs.readdir(templatesDir, { withFileTypes: true })
const templateDirnames = rawTemplateDirs
.filter(
(dirent) =>
dirent.isDirectory() && (dirent.name.startsWith('with') || dirent.name == 'blank'),
)
.map((dirent) => dirent.name)
console.log(`Found generated templates: ${templateDirnames}`)
// Build each template
for (const template of templateDirnames) {
const cmd = `cd ${templatesDir}/${template} && pnpm install --ignore-workspace --no-frozen-lockfile && pnpm build`
console.log(`🔧 Building ${template}...`)
console.log(` cmd: ${cmd}\n\n`)
execSync(cmd, { stdio: 'inherit' })
}
}