@@ -4,6 +4,7 @@ import * as p from "@clack/prompts";
|
||||
import { initRenderer } from '@gregorlohaus/tdir'
|
||||
import { z } from 'zod'
|
||||
import path from "node:path";
|
||||
import { readdir, rename } from "node:fs/promises";
|
||||
|
||||
p.intro(`create-glstack ${process.env.GLSTACK_DEV && 'isDev'}`);
|
||||
|
||||
@@ -89,6 +90,22 @@ const destDir = path.join("./", project.name);
|
||||
// `results` in the bundleid prompt makes group() infer it as unknown.
|
||||
render(destDir, { project: { ...project, bundleid: project.bundleid as string } }, { reverseMap: true })
|
||||
|
||||
// npm never publishes .gitignore/.npmrc, so the template stores them as _gitignore/_npmrc.
|
||||
const dotfiles: Record<string, string> = { _gitignore: ".gitignore", _npmrc: ".npmrc" }
|
||||
for (const file of await readdir(destDir, { recursive: true })) {
|
||||
const dotname = dotfiles[path.basename(file)]
|
||||
if (dotname) await rename(path.join(destDir, file), path.join(destDir, path.dirname(file), dotname))
|
||||
}
|
||||
const mapFile = Bun.file(path.join(destDir, ".tdir-map.json"))
|
||||
if (await mapFile.exists()) {
|
||||
const map = await mapFile.json()
|
||||
for (const entry of map.files) {
|
||||
const dotname = dotfiles[path.basename(entry.outputPath)]
|
||||
if (dotname) entry.outputPath = path.join(path.dirname(entry.outputPath), dotname)
|
||||
}
|
||||
await Bun.write(mapFile, JSON.stringify(map, null, 2))
|
||||
}
|
||||
|
||||
const s = p.spinner();
|
||||
if (project.installDeps) {
|
||||
s.start("Installing dependencies");
|
||||
|
||||
Reference in New Issue
Block a user