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}`);