create-patties 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +3 -2
- package/src/index.ts +39 -5
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-patties",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Scaffolder for new Patties projects.",
|
|
6
|
+
"license": "MIT",
|
|
6
7
|
"bin": {
|
|
7
8
|
"create-patties": "./bin/create-patties.ts"
|
|
8
9
|
},
|
|
@@ -22,6 +23,6 @@
|
|
|
22
23
|
"lint": "biome check ."
|
|
23
24
|
},
|
|
24
25
|
"engines": {
|
|
25
|
-
"bun": ">=1.
|
|
26
|
+
"bun": ">=1.3.0"
|
|
26
27
|
}
|
|
27
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
1
|
+
import { existsSync, readdirSync, realpathSync } from "node:fs";
|
|
2
2
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
3
|
import { hasGit, probeTools } from "./probes.ts";
|
|
4
4
|
import {
|
|
@@ -175,13 +175,43 @@ export async function run(argv: string[]): Promise<number> {
|
|
|
175
175
|
let gitSkippedReason: string | undefined;
|
|
176
176
|
if (args.git) {
|
|
177
177
|
if (hasGit()) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
// Strip git hook env vars so these commands resolve relative to targetDir
|
|
179
|
+
// rather than inheriting GIT_DIR/GIT_INDEX_FILE from a running commit hook.
|
|
180
|
+
const gitEnv: NodeJS.ProcessEnv = { ...process.env };
|
|
181
|
+
for (const key of ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE"]) {
|
|
182
|
+
delete gitEnv[key];
|
|
183
|
+
}
|
|
184
|
+
const init = await Bun.$`git init`
|
|
185
|
+
.cwd(targetDir)
|
|
186
|
+
.env(gitEnv)
|
|
187
|
+
.quiet()
|
|
188
|
+
.nothrow();
|
|
189
|
+
// Only stage/commit once `targetDir` is itself the git top-level. If
|
|
190
|
+
// `git init` failed, or the scaffold landed inside an existing repo (e.g.
|
|
191
|
+
// a git worktree), git resolves `.git` to a parent and `git add`/`commit`
|
|
192
|
+
// would clobber that outer repo. Compare the resolved top-level to be sure.
|
|
193
|
+
const top = await Bun.$`git rev-parse --show-toplevel`
|
|
181
194
|
.cwd(targetDir)
|
|
195
|
+
.env(gitEnv)
|
|
182
196
|
.quiet()
|
|
183
197
|
.nothrow();
|
|
184
|
-
|
|
198
|
+
// `git rev-parse` reports a symlink-resolved path; resolve `targetDir` the
|
|
199
|
+
// same way so the comparison holds on macOS (/var → /private/var).
|
|
200
|
+
const ownsRepo =
|
|
201
|
+
init.exitCode === 0 &&
|
|
202
|
+
top.exitCode === 0 &&
|
|
203
|
+
top.stdout.toString().trim() === realpathSync(targetDir);
|
|
204
|
+
if (ownsRepo) {
|
|
205
|
+
await Bun.$`git add -A`.cwd(targetDir).env(gitEnv).quiet().nothrow();
|
|
206
|
+
await Bun.$`git commit -m ${"chore: initial commit from create-patties"}`
|
|
207
|
+
.cwd(targetDir)
|
|
208
|
+
.env(gitEnv)
|
|
209
|
+
.quiet()
|
|
210
|
+
.nothrow();
|
|
211
|
+
step("initialized git and committed");
|
|
212
|
+
} else {
|
|
213
|
+
gitSkippedReason = "git-init-failed";
|
|
214
|
+
}
|
|
185
215
|
} else {
|
|
186
216
|
gitSkippedReason = "git-missing";
|
|
187
217
|
}
|
|
@@ -194,6 +224,9 @@ export async function run(argv: string[]): Promise<number> {
|
|
|
194
224
|
if (gitSkippedReason === "git-missing") {
|
|
195
225
|
stderr("create-patties: `git` not found — skipping `git init`.");
|
|
196
226
|
}
|
|
227
|
+
if (gitSkippedReason === "git-init-failed") {
|
|
228
|
+
stderr("create-patties: `git init` failed — skipping the initial commit.");
|
|
229
|
+
}
|
|
197
230
|
if (args.template === "claude") {
|
|
198
231
|
process.stdout.write(
|
|
199
232
|
"\nClaude Code is configured (CLAUDE.md). Run `claude` in the project to start a session.\n",
|
|
@@ -337,6 +370,7 @@ async function writePackageJson(dir: string, name: string): Promise<void> {
|
|
|
337
370
|
"bun-types": "latest",
|
|
338
371
|
typescript: "^5.5.0",
|
|
339
372
|
}),
|
|
373
|
+
engines: { bun: ">=1.3.0" },
|
|
340
374
|
};
|
|
341
375
|
await Bun.write(`${dir}/package.json`, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
342
376
|
}
|