From a6552141ecdce6e4a37effeb72c8068bac3a28fa Mon Sep 17 00:00:00 2001 From: Ole Kristian Losvik Date: Sat, 25 Jul 2026 21:01:58 +0200 Subject: [PATCH] feat(cli): self-ignore generated .lectio/ and dist/ dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `lectio` now writes a `.gitignore` (`*`) inside each generated directory, so `.lectio/` and `dist/` stay out of the consumer's `git status` without the CLI ever touching their root `.gitignore`. Delete the dir and its ignore goes with it — no stale root entry. Co-Authored-By: Claude Opus 4.8 --- .changeset/self-ignore-generated.md | 7 +++++++ apps/site-builder/bin/lectio.mjs | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/self-ignore-generated.md diff --git a/.changeset/self-ignore-generated.md b/.changeset/self-ignore-generated.md new file mode 100644 index 0000000..d25e5a2 --- /dev/null +++ b/.changeset/self-ignore-generated.md @@ -0,0 +1,7 @@ +--- +"lectio-docs": patch +--- + +Generated `.lectio/` and `dist/` directories now self-ignore: `lectio` writes a +`.gitignore` inside each, so they stay out of the consumer's `git status` +without the CLI ever modifying the repo's root `.gitignore`. diff --git a/apps/site-builder/bin/lectio.mjs b/apps/site-builder/bin/lectio.mjs index c2046ad..7a12374 100644 --- a/apps/site-builder/bin/lectio.mjs +++ b/apps/site-builder/bin/lectio.mjs @@ -101,6 +101,12 @@ const { buildSearchIndex } = await import('@eventuras/lectio-docs/build-index'); await collect({ rootDir, config, configDir: cwd }); const contentDir = resolve(cwd, config.output); +// A self-ignoring .gitignore in each generated dir keeps them out of the +// consumer's git without ever touching their root .gitignore. `*` ignores the +// whole dir (including this file), so nothing here shows up in `git status`. +const selfIgnore = '# Generated by lectio — safe to delete\n*\n'; +writeFileSync(join(contentDir, '.gitignore'), selfIgnore); + // --- 3. materialize this package's site app -------------------------------- // Copy app/ + wiring out of the package. Once installed, the package lives // under node_modules, where RR won't apply its app-source transforms — copying @@ -220,4 +226,5 @@ if (build.status !== 0) process.exit(build.status ?? 1); const outDir = resolve(cwd, 'dist'); rmSync(outDir, { recursive: true, force: true }); cpSync(join(siteDir, 'build', 'client'), outDir, { recursive: true }); +writeFileSync(join(outDir, '.gitignore'), selfIgnore); console.log(`\nDocs site built → ${outDir}`);