57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
import * as p from "@clack/prompts";
|
|
import { initRenderer } from '@gregorlohaus/tdir'
|
|
import { z } from 'zod'
|
|
import join from "node:path";
|
|
|
|
p.intro("create-glstack");
|
|
|
|
const project = await p.group(
|
|
{
|
|
name: () =>
|
|
p.text({
|
|
message: "What would you like to name your project?",
|
|
placeholder: "glstack-test",
|
|
defaultValue: "glstack-test",
|
|
validate: (value) => {
|
|
return undefined
|
|
},
|
|
}),
|
|
goprefix: () =>
|
|
p.text({
|
|
message: "What would you like to use as a go package prefix?",
|
|
placeholder: "github.com/glstack-test",
|
|
defaultValue: "github.com/glstack-test",
|
|
validate: (value) => {
|
|
return undefined
|
|
},
|
|
}),
|
|
},
|
|
{
|
|
onCancel: () => {
|
|
p.cancel("Operation cancelled.");
|
|
process.exit(0);
|
|
},
|
|
}
|
|
);
|
|
const createRenderer = initRenderer('./template')
|
|
const render = createRenderer(z.object({
|
|
project: z.object({
|
|
name: z.string(),
|
|
goprefix: z.string()
|
|
})
|
|
}))
|
|
const destDir = join.join("./",project.name);
|
|
render(destDir,{project})
|
|
// TODO: template rendering — copy/generate files into destDir
|
|
|
|
const s = p.spinner();
|
|
s.start("Installing dependencies");
|
|
await Bun.$`bun install`.cwd(join.join(destDir)).quiet();
|
|
await Bun.$`bun install`.cwd(join.join(destDir,'packages','rpc')).quiet();
|
|
await Bun.$`bun install`.cwd(join.join(destDir,'apps','web')).quiet();
|
|
s.stop("Dependencies installed.");
|
|
|
|
p.outro("You're all set!");
|