Repository navigation
refactor: add options through slots instead of exact-line edits - #4
Merged
Merged
Conversation
Slots are marker lines such as "// @slot middleware" in template files. An option adds its code there, and projects without it lose the line. This is to replace find-and-replace on exact lines, which breaks as soon as two options edit the same file. Nothing uses these yet.
Gatekeeper is now described in src/features/gatekeeper.ts and added at two slots in app.ts, instead of by matching exact lines. New options follow the same pattern: one file each, extra files in features/<id>/, and no changes to template files outside slots. Generated projects are byte-for-byte the same for npm and pnpm, with and without Gatekeeper. New tests check every registered option: its slots exist exactly once, it doesn't replace template files, and it changes nothing it doesn't declare. The features folder is in the published package, with a test so it stays there.
SibilSoren
force-pushed
the
refactor/feature-composition
branch
from
November 13, 2026 07:13
59f4e5e to
60301d5
Compare
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Options are now added through named slots in the template, with one file describing each option, instead of find-and-replace on exact lines. Nothing changes for users. This comes before the database options, because Gatekeeper, Drizzle and Prisma would all have edited the same files the old way.
Stacked on #3. Merge that first, and I'll rebase this onto main.
Type of Change
Changes Made
// @slot middleware(# @slotin YAML and Dockerfiles,<!-- @slot -->in Markdown). An option adds its code there, and projects without it lose the line.src/features/gatekeeper.tslists Gatekeeper's dependency and what it adds at theimportsandmiddlewareslots inapp.ts. Files that are new to the project go infeatures/<id>/and can't replace an existing file.tests/features.test.tschecks every registered option: its slots appear exactly once, it doesn't ship a template file, and it changes nothing outside package.json, the files it adds to and its own files. There are unit tests for slots, the package.json merge and composing.featuresis in the package'sfiles, with a test, so option files reach npm users.Testing
npx tsx src/index.ts test-project)npm run dev)npm test)npm run lintwith no errorsAt every commit, I generated all four combinations (npm and pnpm, with and without Gatekeeper) and compared them with the output from #3. All 150 files were byte-for-byte the same. Every commit also passes the CLI checks, and both generated variants pass typecheck, build, tests, lint, the format check and the boot checks from ci.yml.
When I deleted the
middlewareslot from the template, 8 tests failed and named it.Checklist