Release v1.4.0 — plugin lifecycle hooks, config validation, addon overwrite fixes - #8
Merged
Conversation
- Node/Python: collapse the addon->dependency map duplicated between generate() and applyAddon() into one source of truth. This also fixes a real bug: `archgen add observability --sentry` on Python silently skipped the sentry-sdk dependency (only generate() handled it). - Validate --sentry requires --observability for both create and add, on Node and Python. Previously the flag was silently ignored. - BasePlugin: add beforeGenerate/afterGenerate/beforeApplyAddon/ afterApplyAddon hooks. Node/Python/Go plugins now implement small hooks instead of overriding generate()/applyAddon() wholesale and re-deriving the dry-run guard themselves. - Add regression tests for GoPlugin (previously untested) and for the new BasePlugin hook contract.
Config was a plain object with no runtime validation, so bad input (wrong database for a language, wrong flag types) failed late inside a plugin instead of fast at the boundary. Adds core/schema.ts with a language-aware database check and wires it into ArchGen.create() before any disk work happens; removes the now-redundant hardcoded VALID_*_DATABASES checks from the CLI.
loadPreset() swallowed any read/parse error and returned {} with no
signal. A user with a typo'd preset file would see none of their
expected defaults applied and no indication why. Now logs a warning
with the file path and underlying error before falling back to {}.
Both addons shipped a full app.ts overwriting the base file, so combining --oauth and --api-docs (or add-ing one after the other) meant whichever ran last won and the other's Fastify plugin registration was silently dropped — the orphaned module files still existed on disk but were never wired up. e2e tests only checked file existence, not that app.ts actually referenced them, so this shipped unnoticed. Replaces the full-file overwrite with incremental patching against `// @addon-imports` / `// @addon-plugins` markers in the base template, mirroring the regex-based dependency injection already used for pyproject.toml. Idempotent (re-running an addon add doesn't duplicate the patch) and marker-preserving (repeated `archgen add` calls keep working).
…xample
Same overwrite-conflict pattern as the app.ts fix: database/postgresql,
oauth, email and s3 each shipped a full .env.example, so combining any
two silently dropped whichever ran first (confirmed: --oauth --email --s3
together left only s3's vars, and --database postgresql lost its
postgresql:// URL back to the mysql default).
Replaces the full-file overwrites with incremental patching against a
`# @addon-env` marker, mirroring the app.ts fix. Patch text runs through
variable substitution before splicing, since splicing happens after the
base file's own {{VAR}} substitution already ran (email's
MAIL_FROM_NAME={{PROJECT_NAME}} was silently left unsubstituted
otherwise).
Also fixes tsup.config.ts: the template-copy step never cleaned
dist/plugins before re-copying, so deleted/renamed template files (like
the ones removed here) would have silently lingered in dist/ across
builds — including published releases via prepublishOnly.
tests/unit/node-plugin-env-patch.test.ts was written and verified passing alongside the .env.example fix but was dropped from that commit by a git add scoping mistake (directory add missed this new file).
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.
Summary
GenerateOptionsvalidation (fail-fast on invalid database/language combos, wrong flag types) andBasePluginlifecycle hooks (beforeGenerate/afterGenerate/beforeApplyAddon/afterApplyAddon) replacing monolithicgenerate()/applyAddon()overrides.--oauth+--api-docs(Node) used to silently overwrite each other'ssrc/app.tswiring — now patched incrementally against anchor markers instead of full-file overwrite..env.exampleacross--database postgresql/--oauth/--email/--s3— now patched incrementally, with variable substitution applied to the spliced text..archgenrc.jsonwas silently ignored — now warns with the parse error instead.add observability --sentrywasn't injectingsentry-sdk(dependency map had drifted betweengenerate()/applyAddon()); consolidated into one source of truth for Node and Python.tsup.config.tsnever cleaneddist/pluginsbefore re-copying templates, so deleted/renamed template files could silently leak into published releases.Full details in
CHANGELOG.mdunder[1.4.0].Test plan
pnpm test— 225/225 unit tests passpnpm exec tsc --noEmit— cleanvitest run --config vitest.integration.config.ts tests/integration/create.test.ts— 21/21 pass, including new regression tests for the app.ts and .env.example overwrite fixes--oauth --api-docstogether, sequentialarchgen add, and idempotent re-run all produce correct output against a cleandist/rebuild