Skip to content

feat(scaffold): ship generate.sh and advance-state.sh - #176

Merged
clabonte merged 1 commit into
mainfrom
feat/generate-and-advance-state-scripts
Oct 19, 2026
Merged

clabonte merged 1 commit into
mainfrom
feat/generate-and-advance-state-scripts

Conversation

@clabonte

Copy link
Copy Markdown
Collaborator

Closes #170.

Two scripts land in scripts/specfuse/ through init and upgrade. Both are generic versions of RestoManager's production scripts.

generate.sh

  • Bundles OpenAPI once, and AsyncAPI when asyncSpecifications is set. Then runs specfuse authoring generate generate --progress --group <g> once per group.
  • Groups are picked by name (case-insensitive), by --lang (repeatable; aliases cs/dotnet, py, flutter, ts, docs), or with an explicit all. Also supports --list, --dry-run, --skip-validation and --spec-version.
  • Safety: lists every group whose destination is in another git repo, with that repo's branch. Refuses to run if that repo has uncommitted changes, unless --allow-dirty is passed.
  • Hook: a project-owned scripts/post-generate.sh (outside scripts/specfuse/, so upgrades leave it alone) runs after each group with <group> <language> <destination> <basePackage>. The README has a Dart build_runner example.
  • At the end, names the repos that need a regen PR and warns not to commit the regen's stateDir changes.

advance-state.sh

  • Wraps the generator's baseline command.
  • Keeps a group's new baseline only when its destination repo is clean, on its default branch (origin/HEAD, else main, or --branch) and level with origin. Every other group's state file is restored, including groups that write into the spec repo itself.
  • Refuses to start if stateDir has uncommitted changes. Supports --dry-run, --repo and --no-fetch.
  • Reads stateDir from the project file.

Differences from RestoManager's scripts

  • Reads JSON with python3 instead of jq, so there's no CRLF guard to maintain.
  • Doesn't tolerate exit 1 from baseline. It exits 0 on success (checked).
  • Restores state files for groups that write into the spec repo itself, which RestoManager's script left modified.
  • No built-in Dart or verify-generated step; those go in the hook.

Tested locally with /bin/bash 3.2 on two repos: hello-orders as the spec repo, plus a sibling Backend repo with a bare origin.

  • generate.sh: --list; all --dry-run; refusal on a dirty repo; unknown group; a real all run with the hook getting the right arguments.
  • advance-state.sh:
    • refuses when stateDir is dirty
    • skips while the regen is uncommitted, and while it's committed but not pushed
    • after the push: --dry-run keeps nothing; the real run keeps only Domain.json and drops the in-repo Local group's file
    • a rerun after committing reports nothing to commit
    • --repo filters correctly
  • Shellcheck reports nothing at warning level. The new CI step passes locally against a project scaffolded from this branch.

Notes

🤖 Generated with Claude Code

generate.sh bundles the specs once and runs `specfuse authoring generate
generate --group` per selected group (the generator's --group takes one
name): groups by name, --lang (repeatable, with aliases), or an explicit
`all`; --list and --dry-run. It names every destination that lands in
another git repo with its branch, and refuses to regenerate into one with
uncommitted changes unless --allow-dirty. A project-owned, executable
scripts/post-generate.sh runs after each group for language steps the
generator does not run (e.g. Dart build_runner).

advance-state.sh wraps the generator's `baseline` command: it keeps a
group's new stateDir baseline only when its destination repo is clean,
on its default branch and level with origin, and restores every other
group's state file, so the changelog baseline only ever moves to merged
code.

Both read the project file with python3 (no jq) and run on macOS bash
3.2. CI covers the offline guards in a fresh scaffold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clabonte
clabonte merged commit c4054af into main Oct 19, 2026
8 checks passed
@clabonte
clabonte deleted the feat/generate-and-advance-state-scripts branch October 19, 2026 12:38
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.

init: ship a multi-group generate wrapper and an advance-state script

1 participant