-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add build generated templates job
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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' }) | ||
} | ||
} |