Skip to content

Commit 5a8a646

Browse files
committed
chore: update architecture.md and add test helper guards
- Document execFile usage in cloneRepo and installPackages operations - Add null guards to getLastJsonOutput and getWrittenPackageJson test helpers so failures produce clear messages instead of JSON parse errors
1 parent f1f9890 commit 5a8a646

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ Plain async functions with no UI dependencies. Each operation receives explicit
8282

8383
| Function | What it does |
8484
|---|---|
85-
| `cloneRepo(projectName)` | Shallow clone, checkout latest tag, rm .git, git init |
85+
| `cloneRepo(projectName)` | Shallow clone, checkout latest tag, rm .git, git init. Uses `execFile` (no shell) for all commands except `git checkout $(...)` which needs shell substitution. |
8686
| `createEnvFile(projectFolder)` | Copy .env.example to .env.local |
87-
| `installPackages(projectFolder, mode, features)` | Full: `pnpm i`. Custom: `pnpm remove` deselected packages + postinstall |
87+
| `installPackages(projectFolder, mode, features)` | Full: `pnpm i`. Custom: `pnpm remove` deselected packages + postinstall. Uses `execFile` exclusively (no shell). |
8888
| `cleanupFiles(projectFolder, mode, features)` | Remove files/folders for deselected features, patch package.json scripts, remove .install-files |
8989

9090
### Shell Execution (`source/operations/exec.ts`)

source/__tests__/nonInteractive.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ const { projectDirectoryExists } = await import('../utils/utils.js')
2929

3030
function getLastJsonOutput(): Record<string, unknown> {
3131
const lastCall = mockLog.mock.calls.at(-1)
32-
return JSON.parse(lastCall?.[0] as string)
32+
if (!lastCall) {
33+
throw new Error('console.log was never called — no JSON output to read')
34+
}
35+
return JSON.parse(lastCall[0] as string)
3336
}
3437

3538
describe('nonInteractive — validation', () => {

source/__tests__/operations/cleanupFiles.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ function getExecCommands(): string[] {
3434

3535
function getWrittenPackageJson(): Record<string, unknown> {
3636
const lastCall = vi.mocked(writeFileSync).mock.calls.at(-1)
37-
const content = lastCall?.[1] as string
38-
return JSON.parse(content)
37+
if (!lastCall) {
38+
throw new Error('writeFileSync was never called — no package.json to read')
39+
}
40+
return JSON.parse(lastCall[1] as string)
3941
}
4042

4143
describe('cleanupFiles', () => {

0 commit comments

Comments
 (0)