Skip to content

4.4.0 - setup: one command for the whole first run

Choose a tag to compare

@ankurhalder ankurhalder released this 04 Nov 17:22
· 26 commits to main since this release

4.4.0 — one command for the whole first run

npx @ankurhalder/codebase-snapshot setup

That is now the whole first run, with defaults and no prompts: detect the project, write the
commented config, add the npm scripts and the devDependency, install them, and generate the
snapshot.

🚀 Setup for: /path/to/repo
✅ Created snapshot.config.ts (preset: nextjs)
   Added npm scripts: snapshot, snapshot:validate
   Added devDependency: @ankurhalder/codebase-snapshot ^4.4.0
   Added to .gitignore: snapshot/, snapshot.tmp/
⏳ Installing dependencies…
✅ Installed dependencies (npm install, 2.1s)
✅ Snapshot generated in 0.16s:
   - Tracked files: 128
   …
   Next:  npm run snapshot

What it does, precisely

Step Detail
Config written only when the repository has none — an existing file is kept byte for byte and the output says ♻ Keeping snapshot.config.ts
Scripts snapshot and snapshot:validate, only when those keys are absent
Dependency added to devDependencies unless it is already declared, with your own pin left alone
Ignore snapshot/ and snapshot.tmp/, appended once
Install with the package manager your lockfile names — bun.lockb, pnpm-lock.yaml, yarn.lock, otherwise npm
Generate through the real generate command, so every guard, warning and JSON field is identical to a plain run
  • --no-install skips the install: CI, an offline machine, or a lockfile you would rather no
    package manager touched. A failed install is a warning, not a dead end — the scripts resolve
    the package through npx, so the snapshot is generated either way.
  • --dry-run prints the plan and the config it would write, and writes nothing.
  • --format json emits one document: { "setup": { configPath, configReused, preset, scripts, dependency, gitignoreEntries, install, notes }, "manifest": { … } }.
  • The ownership guard is untouched. An outDir holding files this tool did not write is still
    refused (exit 1, naming the entries) — after the config is written, so nothing is lost.
  • init is unchanged. It still refuses when a config exists and needs --force; setup is the
    merge-friendly path.

Also in this release: a dead end removed

generate refused with "it holds no .codebase-snapshot marker (found parts, reports) — remove the
directory yourself"
for a directory that held no files at all — just parts/ and reports/
from an interrupted run. Replacing a tree with no files destroys nothing, so it is treated as empty
now. The walk is iterative, a symlink counts as content, and a directory holding even one file is
still refused without a marker.

Verified

  • npm run verify green: lint 105 files, 505 tests / 501 pass / 0 fail / 4 host-dependent skips, tarball 23 files.
  • The same suite on Node 18.20.4 and 20.19.4: 500 pass, 0 fail.
  • The full flow run for real against a fixture, including npm install (2.1 s) and a generated snapshot.
  • This release runs the 18 / 20 / 22 verify matrix before the publish job is allowed to start.

Full details: CHANGELOG.md