webapps/scripts/bootstrap.mjs
Dominik Milacher 0dc24c4db7
Some checks failed
Build and deploy updated apps / Build & deploy (push) Failing after 50s
Extend ux layer and overhaul panoramablick-saalbach.at
2025-11-21 21:17:52 +01:00

38 lines
980 B
JavaScript

import { run } from './auxilary.mjs'
import { select, input } from '@inquirer/prompts'
import { existsSync } from 'node:fs'
const type = await select({
message: 'What do you want to bootstrap?',
choices: [
{
name: 'A layer',
value: 'layer',
description: 'Bootstrap a new layer to extend tooling',
},
{
name: 'An app',
value: 'app',
description: 'Bootstrap a new webapp',
},
],
})
const name = (await input({ message: `Name your new ${type}:` })).trim()
if (type === 'layer') {
const template = 'packages/layers/template'
const layer = `packages/layers/${name}`
if (existsSync(layer)) {
console.error(`Path ${layer} already exists`)
process.exit(2)
}
run(`cp -r ${template} ${layer}`)
run(`cd ${layer} && rm -rf node_modules`)
run(`cd ${layer}/.playground && rm -rf .nuxt && rm -rf node_modules`)
run(`find ${layer} -type f -name '*' -print0 | xargs -0 sed -i 's/__LAYER_NAME__/${name}/g'`)
}