Skip to content

Release v1.4.0 — plugin lifecycle hooks, config validation, addon overwrite fixes - #8

Merged
Kidkender merged 6 commits into
mainfrom
release/1.4.0
Jul 3, 2026
Merged

Release v1.4.0 — plugin lifecycle hooks, config validation, addon overwrite fixes#8
Kidkender merged 6 commits into
mainfrom
release/1.4.0

Conversation

@Kidkender

Copy link
Copy Markdown
Owner

Summary

  • Added: Zod-based GenerateOptions validation (fail-fast on invalid database/language combos, wrong flag types) and BasePlugin lifecycle hooks (beforeGenerate/afterGenerate/beforeApplyAddon/afterApplyAddon) replacing monolithic generate()/applyAddon() overrides.
  • Fixed: --oauth + --api-docs (Node) used to silently overwrite each other's src/app.ts wiring — now patched incrementally against anchor markers instead of full-file overwrite.
  • Fixed: same overwrite-conflict class in .env.example across --database postgresql/--oauth/--email/--s3 — now patched incrementally, with variable substitution applied to the spliced text.
  • Fixed: malformed .archgenrc.json was silently ignored — now warns with the parse error instead.
  • Fixed: Python add observability --sentry wasn't injecting sentry-sdk (dependency map had drifted between generate()/applyAddon()); consolidated into one source of truth for Node and Python.
  • Fixed: tsup.config.ts never cleaned dist/plugins before re-copying templates, so deleted/renamed template files could silently leak into published releases.

Full details in CHANGELOG.md under [1.4.0].

Test plan

  • pnpm test — 225/225 unit tests pass
  • pnpm exec tsc --noEmit — clean
  • vitest 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
  • Manual verification: --oauth --api-docs together, sequential archgen add, and idempotent re-run all produce correct output against a clean dist/ rebuild

Kidkender added 6 commits July 2, 2026 13:36
- 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).
@Kidkender
Kidkender merged commit 9485738 into main Jul 3, 2026
7 checks passed
@Kidkender
Kidkender deleted the release/1.4.0 branch July 3, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant