Skip to content

[FEAT, TEMPLATE, DOCS] v2.0.0 stage 2: option catalog, generation API, dev dependency split - #95

Merged
bnbong merged 1 commit into
devfrom
feat/v2.0.0
Dec 2, 2026
Merged

bnbong merged 1 commit into
devfrom
feat/v2.0.0

Conversation

@bnbong

@bnbong bnbong commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Requesting Merging

Description

Second staged PR for v2.0.0. It adds the two pieces the later stages build on, and keeps the CLI's prompts, tables and messages unchanged apart from the points under "Visible changes":

  1. A catalog (src/fastapi_fastkit/catalog/catalog.toml with loader, rules, i18n overlay and JSON export) as the single source of levels, templates, options, their dependencies and compatibility rules. The existing settings constants are derived from it.
  2. A generation API, fastapi_fastkit.generation.generate(spec, target_dir), that does not prompt, run subprocesses, probe installed tools or print. The CLI now generates through it; environment creation and installation stay in the CLI layer.

Stage 3 (unified fastkit init) and stage 5 (web generator) use both.

Type of Change

  • BUG FIX
  • ADDING NEW TEMPLATE
  • FEATURE ADDED/UPDATED
  • HOTFIX
  • DELETING UNNECESSARY FEATURES
  • DOCUMENTATION & DEVOPS
  • Etc..

Test Environment

  • macOS (Apple Silicon), Python 3.12
  • Full suite: 4078 passed, 28 skipped
  • Full suite with EncodingWarning from fastapi_fastkit as errors: 4078 passed, 28 skipped
  • C locale (LC_ALL=C, PYTHONUTF8=0), -m "not extended": 3987 passed, 28 skipped
  • Simulated Windows (POSIX-only os / signal attributes removed): 4070 passed, 36 skipped
  • mypy src, black --check, isort --check: clean
  • mkdocs build --strict: passes
  • Diff coverage against dev: 99%
  • Before/after comparison of 65 CLI scenarios (every template, every stack, --interactive, five config files, four package managers, with --dry-run): terminal output and generated trees differ only in the points listed under "Visible changes" and in SECRET_KEY
  • Generated projects installed for real with pip, uv, PDM 2.29.8 and Poetry 2.0.1 / 2.1.4 / 2.2.1 / 2.5.2: runtime and dev tools importable, project tests pass
  • fastapi-sqlmodel Docker image built: no test or lint tools inside, /health answers
  • /openapi.json of seven generated projects identical before and after the Page[T] change
  • In-place startdemo checked by hand: success, forced failure (directory back to its original files, hashes and modes) and failed restore (backup kept, path printed)

Not verified on real Windows, including the junction check (its test skips elsewhere). The security-scan workflow change was run locally only up to dependency resolution.

Major Changes

Catalog

  • catalog.toml holds levels, presets, templates, package managers, option axes with runtime and dev dependencies, rules (requires, implies, adds, note) and a concept list with FastAPI docs URLs.
  • Loader validates the file at import (unknown references, conflicting rules, messages that cannot be formatted). An agreement test fails when the catalog and the code know different options, presets, templates or package managers; a golden test pins the derived settings constants to their previous values.
  • python -m fastapi_fastkit.catalog export writes the JSON the web generator will read. Translation overlays (i18n/<lang>.toml) are supported; none ship yet.

Generation API

  • GenerationSpec covers template, stack and feature projects; spec_from_config maps saved 1.x config files, keeping their pins, extras and version.
  • generate returns the files written, the dependencies, the metadata and the messages the CLI then prints. plan gives the same without writing; --dry-run uses it, and a test keeps its file list equal to what a real run writes.
  • Secrets come from an injectable factory, so two runs with the same seed produce identical trees.
  • Tests run generate for every template, preset and package manager with subprocess, shutil.which, click and rich output made to fail.

Visible changes

  • fastkit init projects: test and lint tools move from runtime dependencies to the dev group and a new requirements-dev.txt. Generated Dockerfiles install runtime dependencies only; the generated Makefile, GitHub Actions workflow and devcontainer install requirements-dev.txt. Every table that declares dev tools is kept equal, so pip install -e ".[dev]", uv sync, pdm install and poetry install give the same tools.
  • fastapi-sqlmodel, fastapi-auth-jwt, fastapi-llm-agent: requirements-dev.txt added; their images no longer contain test and lint tools.
  • startdemo dependency table and --dry-run list show runtime dependencies, without comment lines or test tools.
  • Shipped scripts/*.sh are executable after generation.
  • With --no-venv, output no longer depends on which package managers are installed. When the requested manager is missing and an environment is created, fastkit warns and sets the project up for an available one.
  • Generating into an existing directory:
    • fastkit refuses to write through a symbolic link or junction and lists the links before writing anything.
    • The overwrite confirmation lists every file the run may change.
    • A failed or interrupted run puts overwritten files back and removes what it created; if a file cannot be restored, its original stays in a backup directory whose path is printed.
    • An existing .env is never replaced; an existing .venv is not restored.
  • addroute sorts the imports it writes the way isort does for any route name, and wraps an over-long inserted import. Registrations and imports under if TYPE_CHECKING: or if False: no longer count as present.
  • Page and CRUDBase use the Python 3.12 type parameter syntax; projects created with the ruff option pass their own ruff check.

Fixes

  • Poetry: direct-reference requirements (pkg @ https://...) were written as invalid TOML.
  • Rollback removes only directories the run itself created.
  • fastapi-sqlmodel: mypy src tests is clean in a generated project; its lint script checks both.
  • Template security scan and the inspection freshness check also read requirements-dev.txt-tpl.

Docs

  • CHANGELOG and English docs updated (dev dependency split, startdemo output, overwrite behaviour, catalog step for new templates and options). Translations are not re-synced; reference/translation-status lists the pages.

Screenshots (optional)

N/A

Etc

  • addroute output needs no formatter for route names up to 19 and entity names up to 18 characters (pinned by a test). Longer names give working code with sorted imports that black may rewrap.
  • Known, planned for stage 3: startdemo copies each template's own requirements.txt, which still lists dev tools for templates other than the three above; the single-module preset's generated project fails isort and mypy src; templates fail a bare ruff check on several rules.

@bnbong bnbong self-assigned this Dec 2, 2026
@bnbong bnbong added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request fix Fix or improve source codes labels Dec 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T06:44:21.554830Z dd787ff PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the template Add or editing a FastAPI template label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

✅ Template Inspection Passed

All changed templates have been validated successfully.


Last updated: 2026-12-02T06:42:30.313Z

@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.70972% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fastapi_fastkit/backend/main.py 96.38% 3 Missing ⚠️
...tapi_fastkit/backend/package_managers/pyproject.py 98.36% 2 Missing ⚠️
src/fastapi_fastkit/backend/rollback.py 99.09% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@bnbong
bnbong merged commit e1fc395 into dev Dec 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request fix Fix or improve source codes template Add or editing a FastAPI template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant