fix(codegen): skip the OpenAPI-client stage when codegen-tool-dir is absent - #33
Merged
Merged
Conversation
…absent
The codegen action's step 1 ("Generate OpenAPI client (Java CLI)") always
cd's into codegen-tool-dir and runs `dart pub get`, unconditionally — a
consumer with no generated OpenAPI client (e.g. one that deleted its api/
package and openapi_codegen toolchain entirely) hits a bare "No such file
or directory" with no way to opt out, since no skip input existed.
Add a `generate-openapi` input (auto/true/false, default auto) to the
codegen action and its android-setup/ios-setup wrappers. `auto` checks
whether codegen-tool-dir exists on disk and skips steps 1-3 (the whole
OpenAPI-client stage) when it doesn't, leaving just the app-level
`flutter pub get` + `build_runner build`. The planner (planCodegen) stays
pure/I/O-free for testability — the CLI command layer does the directory
check and passes an explicit bool through.
Bumps cli-version.txt (0.1.0 -> 0.2.0) since bin/ and lib/src/codegen.dart
changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
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
The
codegenaction (and itsandroid-setup/ios-setupwrappers) always ran the OpenAPI-client stage unconditionally — step 1 (dart pub getincodegen-tool-dir) hard-fails with a bare "No such file or directory" for any consumer that has no generated OpenAPI client, with no input to opt out.Why
Discovered fixing vaam-store/mobile's CI: vaam-store/mobile#16 deleted its
api/OpenAPI package and toolchain entirely, butanalyze · teststill calledvymalo/flutter-tools/actions/codegen@v0, which unconditionally trieddart pub getinside the now-deletedmobile/tool/openapi_codegendir and died. A hard-coded assumption in a shared action is a trap for any consumer without an OpenAPI client, not just this one.Change
generate-openapiinput (auto/true/false, defaultauto) oncodegen,android-setup,ios-setup.autochecks whethercodegen-tool-direxists on disk; when it doesn't, steps 1-3 (the whole OpenAPI-client stage) are skipped and only the app-levelflutter pub get+build_runner buildrun.planCodegen(lib/src/codegen.dart) stays pure/I/O-free — it takes an explicitgenerateOpenapibool. The directory-existence check lives in the CLI command layer (bin/flutter_tools.dart), matching this repo's plan-then-execute testability design.autoonly skips when the directory is genuinely absent; explicittrue/falsestill force it).cli-version.txt0.1.0 -> 0.2.0 (Dart code changed) per RELEASING.md Flow A. Needsrelease-clithenrelease-actions(withmove_major) run from the Actions tab once this merges, to movev0.Verification
dart format --output=none --set-exit-if-changed .— cleandart analyze --fatal-infos— no issuesdart test— 63 passed, including 3 newplanCodegencases forgenerateOpenapi: falseand the unchanged default--dry-runsanity check: a missingcodegen-tool-dirproduces a 2-step plan (app pub get + build_runner only); an existing one produces the original 9-step plan, unchangedanalyze · testgreen against it (linked once opened)🤖 Generated with Claude Code