From 2a6e1c2ca15c3b3a1b252c17bb5c33ecb22be772 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 19 Jun 2026 17:24:52 -0400 Subject: [PATCH 1/2] fix(init): correct clone destination --- .changeset/fix-init-clone-dest.md | 9 +++++++++ src/commands/init.ts | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .changeset/fix-init-clone-dest.md diff --git a/.changeset/fix-init-clone-dest.md b/.changeset/fix-init-clone-dest.md new file mode 100644 index 0000000..886f37a --- /dev/null +++ b/.changeset/fix-init-clone-dest.md @@ -0,0 +1,9 @@ +--- +"@bomb.sh/tools": patch +--- + +fix(init): read postprocessed files from the actual clone target, scaffold `.` in-place + +`init ` cloned the template into `.//` but postprocessed `package.json`/`README.md` from a stale hardcoded `./.temp/` path, crashing with `ENOENT`. The destination now points at the directory the template was actually cloned into. + +`init` / `init .` now scaffolds into the current directory in-place (via giget `--force`) and derives the project name from the current directory's basename, instead of cloning into a mis-named subdirectory. diff --git a/src/commands/init.ts b/src/commands/init.ts index d183f9e..3ecbee6 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -1,4 +1,5 @@ import { readFile, writeFile } from 'node:fs/promises'; +import { basename } from 'node:path'; import { cwd } from 'node:process'; import { pathToFileURL } from 'node:url'; import { x } from 'tinyexec'; @@ -7,10 +8,15 @@ import type { CommandContext } from '../context.ts'; export async function init(ctx: CommandContext) { const [_name = '.'] = ctx.args; const cwdUrl = pathToFileURL(`${cwd()}/`); - const name = - _name === '.' ? new URL('../', cwdUrl).pathname.split('/').filter(Boolean).pop()! : _name; - const dest = new URL('./.temp/', cwdUrl); - for await (const line of x('pnpx', ['giget@latest', 'gh:bombshell-dev/template', name])) { + // `.` scaffolds into the current directory; otherwise clone into a new `.//`. + const inPlace = _name === '.'; + const name = inPlace ? basename(cwd()) : _name; + const target = inPlace ? '.' : name; + const dest = inPlace ? cwdUrl : new URL(`./${name}/`, cwdUrl); + const gigetArgs = ['giget@latest', 'gh:bombshell-dev/template', target]; + // `--force` lets the template extract into an existing (non-empty) directory. + if (inPlace) gigetArgs.push('--force'); + for await (const line of x('pnpx', gigetArgs)) { console.log(line); } From 29f9d81dbc9f46ce8bd9f82760a17d3a9bc534f2 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 19 Jun 2026 17:33:06 -0400 Subject: [PATCH 2/2] chore(changeset): update changeset --- .changeset/fix-init-clone-dest.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.changeset/fix-init-clone-dest.md b/.changeset/fix-init-clone-dest.md index 886f37a..2ad67fb 100644 --- a/.changeset/fix-init-clone-dest.md +++ b/.changeset/fix-init-clone-dest.md @@ -2,8 +2,6 @@ "@bomb.sh/tools": patch --- -fix(init): read postprocessed files from the actual clone target, scaffold `.` in-place +Fixes the `bsh init` command—it now points at the directory the template was actually cloned into. -`init ` cloned the template into `.//` but postprocessed `package.json`/`README.md` from a stale hardcoded `./.temp/` path, crashing with `ENOENT`. The destination now points at the directory the template was actually cloned into. - -`init` / `init .` now scaffolds into the current directory in-place (via giget `--force`) and derives the project name from the current directory's basename, instead of cloning into a mis-named subdirectory. +`init` / `init .` now scaffolds into the current directory in-place and uses the current directory's basename as the project name.