Skip to content

feat: add --android-flavor option for build commands#543

Merged
riderx merged 15 commits intomainfrom
feat/android-flavor-support
Mar 16, 2026
Merged

feat: add --android-flavor option for build commands#543
riderx merged 15 commits intomainfrom
feat/android-flavor-support

Conversation

@WcaleNieWolny
Copy link
Contributor

@WcaleNieWolny WcaleNieWolny commented Mar 13, 2026

Summary

  • Add --android-flavor <flavor> option to build request, build credentials save, and build credentials update commands
  • Wire through the full pipeline: CLI args → env vars → NON_CREDENTIAL_KEYSsplitPayloadbuildOptions.androidFlavor
  • During credentials save, inform the user when no flavor is specified (defaulting to Release without flavor)

Companion builder PR: Cap-go/capgo_builder — feat/android-flavor-support

Usage

# Save flavor in credentials
npx @capgo/cli build credentials save --platform android \
  --keystore ./release.keystore --android-flavor production

# Pass flavor per-build
npx @capgo/cli build request --platform android --android-flavor production

# Via env var
CAPGO_ANDROID_FLAVOR=production npx @capgo/cli build request --platform android

Test plan

  • build request --android-flavor production passes flavor through to buildOptions payload
  • build credentials save --android-flavor production persists and shows confirmation
  • build credentials save without flavor shows default info message
  • CAPGO_ANDROID_FLAVOR=production env var is picked up correctly

Summary by CodeRabbit

  • New Features

    • Added --android-flavor CLI option to build request and credential commands to specify Android product flavor.
    • Added --no-playstore-upload option to skip Play Store upload for a build.
  • Behavior Changes

    • Android flavor is trimmed; empty/whitespace values are ignored and removed from saved settings to avoid carryover.
  • Tests

    • Expanded tests to cover android-flavor handling and playstore-upload behavior.

- Add androidFlavor to BuildRequestOptions and BuildOptionsPayload schemas
- Add CAPGO_ANDROID_FLAVOR to env var loading and NON_CREDENTIAL_KEYS
- Wire --android-flavor through CLI args → credentials → splitPayload
- Add option to build request, credentials save, and credentials update commands
- Inform user during credentials save when defaulting without a flavor
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 073afc52-bb8c-48e2-8efc-cd6d583d5534

📥 Commits

Reviewing files that changed from the base of the PR and between 2056c63 and 47c802a.

📒 Files selected for processing (7)
  • src/build/credentials-command.ts
  • src/build/credentials.ts
  • src/build/request.ts
  • src/index.ts
  • src/schemas/build.ts
  • test/test-credentials.mjs
  • test/test-payload-split.mjs

📝 Walkthrough

Walkthrough

Adds an optional Android product flavor and a playstore-upload toggle to CLI, schema, credential storage, environment loading, and build request payloads; wires a new CAPGO_ANDROID_FLAVOR env/credential field end-to-end and removes saved play config when upload is skipped.

Changes

Cohort / File(s) Summary
CLI options
src/index.ts
Add --android-flavor <flavor> to build request, build credentials save, and build credentials update; add --no-playstore-upload to build request.
Schemas
src/schemas/build.ts
Add androidFlavor: z.string().trim().min(1).optional() and playstoreUpload: z.boolean().optional() to request/payload schemas.
Credential save/update UI & types
src/build/credentials-command.ts
Add androidFlavor?: string to SaveCredentialsOptions; trim, validate, save/clear CAPGO_ANDROID_FLAVOR; add logs for omitted/whitespace values; consider flavor in partial updates.
Credential loading & apply
src/build/credentials.ts
Load CAPGO_ANDROID_FLAVOR from runtime env (trimmed) and include it when applying/updating Android credentials.
Build request & payload split
src/build/request.ts
Include CAPGO_ANDROID_FLAVOR in NON_CREDENTIAL_KEYS; expose androidFlavor on split payload and set CLI/merged credential handling; when --no-playstore-upload is used, remove PLAY_CONFIG_JSON from merged credentials and log.
Tests
test/test-credentials.mjs, test/test-payload-split.mjs
Add tests for loading/trimming/precedence/isolation of CAPGO_ANDROID_FLAVOR; update non-credential keys expectations and add scenario verifying --no-playstore-upload removes play config.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI (user)
  participant Env as Runtime Env
  participant CredStore as Local Credential Store
  participant Merge as Merge Logic
  participant Builder as Remote Build API

  CLI->>Merge: provide flags (--android-flavor, --no-playstore-upload, other creds)
  Env->>Merge: provide `CAPGO_ANDROID_FLAVOR` (if set)
  CredStore->>Merge: provide saved credentials (including CAPGO_ANDROID_FLAVOR)
  Merge->>Merge: determine precedence (CLI > Env > Saved), trim flavor, remove PLAY_CONFIG_JSON if no-playstore-upload
  Merge->>Builder: send BuildOptionsPayload (includes androidFlavor) and merged credentials
  Builder-->>CLI: build queued/response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A tiny rabbit hops with delight,
Trims flavors and stores them snugly at night,
CAPGO_ANDROID_FLAVOR tucked neat in a pack,
Play uploads silenced — no config to track,
Hooray for builds that now know their knack! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding a new --android-flavor option to build commands. It is concise, specific, and clearly summarizes the primary feature being introduced.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/android-flavor-support
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2056c6368b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +342 to +344
else {
log.info('Android flavor not specified (defaulting to Release build without flavor)')
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Unset CAPGO_ANDROID_FLAVOR when save omits flavor

When --android-flavor is not provided, this branch only logs a default message and does not clear CAPGO_ANDROID_FLAVOR; because saved credentials are merged (updateSavedCredentials keeps existing keys), re-running build credentials save --platform android ... after previously setting a flavor will silently retain the old flavor and future builds still use it. This is especially confusing because the CLI tells the user it is defaulting to a build without flavor.

Useful? React with 👍 / 👎.

@WcaleNieWolny WcaleNieWolny marked this pull request as draft March 13, 2026 12:25
Use z.string().trim().min(1) on both buildRequestOptionsSchema and
buildOptionsPayloadSchema so whitespace-only values are treated as
missing instead of passing through as an empty flavor name.
Add ℹ️ default message for --build-mode matching the pattern of all
other default-value messages in the build request flow.

Also fix misleading Android flavor default message that conflated
flavor with build type.
…tted

updateSavedCredentials uses a shallow merge, so re-running
`build credentials save --platform android` without --android-flavor
silently preserves the previously saved flavor. This is confusing
because the CLI tells the user "no product flavor will be used" while
the old flavor persists in saved credentials and gets used on the
next build.

Call removeSavedCredentialKeys after save to explicitly remove the
stale flavor key. The update command intentionally preserves existing
values since it's designed for partial updates.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for specifying an Android Gradle product flavor for Capgo Cloud builds, propagating it through CLI flags, env vars, saved credentials, and the build request payload.

Changes:

  • Add androidFlavor to build request/options schemas and build options payload.
  • Add --android-flavor to build request and build credentials save/update CLI commands.
  • Thread CAPGO_ANDROID_FLAVOR through env loading, credentials merging, and payload splitting.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/schemas/build.ts Extends request/options payload schemas to include androidFlavor.
src/index.ts Adds --android-flavor CLI option to relevant build/credentials commands.
src/build/request.ts Includes CAPGO_ANDROID_FLAVOR in non-secret key splitting and build options payload; wires CLI option into merged creds.
src/build/credentials.ts Loads CAPGO_ANDROID_FLAVOR from environment variables.
src/build/credentials-command.ts Saves/updates CAPGO_ANDROID_FLAVOR in local credentials storage and logs the choice.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 871 to 875
'CAPGO_ANDROID_APP_DIR',
'CAPGO_ANDROID_PROJECT_DIR',
'ANDROID_PROJECT_DIR',
'CAPGO_ANDROID_FLAVOR',
])
Copy link
Contributor

@ToriChanIntegration ToriChanIntegration left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — feat: add --android-flavor option for build commands

Clean, well-scoped PR. The pipeline wiring is correct and consistent with how other non-secret keys are handled. One test fix is required before merge.


🔴 Failing test — test/test-payload-split.mjs

❌ FAILED: NON_CREDENTIAL_KEYS covers all non-secret fields
   Error: Expected 14 non-credential keys, got 15

CAPGO_ANDROID_FLAVOR was added to NON_CREDENTIAL_KEYS but test/test-payload-split.mjs still has the hardcoded list of 14 keys. Fix:

  const expectedKeys = [
    'CAPGO_IOS_SCHEME',
    'CAPGO_IOS_TARGET',
    'CAPGO_IOS_DISTRIBUTION',
    'BUILD_OUTPUT_UPLOAD_ENABLED',
    'BUILD_OUTPUT_RETENTION_SECONDS',
    'SKIP_BUILD_NUMBER_BUMP',
    'CAPGO_IOS_SOURCE_DIR',
    'CAPGO_IOS_APP_DIR',
    'CAPGO_IOS_PROJECT_DIR',
    'IOS_PROJECT_DIR',
    'CAPGO_ANDROID_SOURCE_DIR',
    'CAPGO_ANDROID_APP_DIR',
    'CAPGO_ANDROID_PROJECT_DIR',
    'ANDROID_PROJECT_DIR',
+   'CAPGO_ANDROID_FLAVOR',
  ]

🟡 Minor — update doesn't clear saved flavor, save does

In saveCredentialsCommand, omitting --android-flavor actively removes any saved CAPGO_ANDROID_FLAVOR (good — prevents stale flavor carrying over). In updateCredentialsCommand, omitting it leaves any previously saved value in place. This is an intentional partial-update semantic, but it's worth a short code comment to prevent future confusion.


✅ What's done well

  • CAPGO_ANDROID_FLAVOR correctly placed in NON_CREDENTIAL_KEYS — it's not sensitive
  • splitPayload maps it to androidFlavor in buildOptions — consistent with all other non-credential keys
  • Schema uses z.string().trim().min(1).optional() in both buildRequestOptionsSchema and buildOptionsPayloadSchema — matches the builder PR
  • Env var loading (loadCredentialsFromEnv) is consistent with the existing pattern
  • --android-flavor option added to all three relevant commands (build request, credentials save, credentials update)

CI

Run tests fails due to the test count issue above. SonarCloud Code Analysis failure — check if it's related to the test or a coverage threshold drop. All other checks pass.

This is a draft — marking request-changes so the test fix is tracked.

…ormalize value

- Add options.androidFlavor to hasAndroidOptions so that
  `build credentials update --android-flavor <name>` auto-detects
  the android platform without requiring explicit --platform android.
- Trim the flavor value before persisting in both save and update
  commands, rejecting whitespace-only values with a warning.
- Test 9: flavor is loaded from environment
- Test 10: empty string is not loaded (truthiness guard)
- Test 11: flavor follows CLI > Env > Saved merge precedence
- Test 12: flavor is isolated to android platform credentials
loadCredentialsFromEnv() now trims the env var and ignores it when
empty after trimming, consistent with the trim+min(1) validation
applied in the save and update CLI paths.

Added tests for whitespace-only and padded env values.
The NON_CREDENTIAL_KEYS set already contained CAPGO_ANDROID_FLAVOR
but the test's expectedKeys list was missing it, causing a count
mismatch (expected 14, got 15).
Save clears CAPGO_ANDROID_FLAVOR when --android-flavor is omitted (full
replacement), while update intentionally leaves it untouched (partial
update). Added a code comment to prevent future confusion.
Copy link
Contributor

@ToriChanIntegration ToriChanIntegration left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved ✅

All issues from the previous review are resolved, and the PR is now substantially stronger.

Previous blocker — fixed:

  • test/test-payload-split.mjs updated to expect 15 NON_CREDENTIAL_KEYS with CAPGO_ANDROID_FLAVOR included

New additions since last review:

  • test/test-credentials.mjs: 6 new tests covering env loading, empty/whitespace rejection, trimming, merge precedence (CLI > Env > Saved), and platform isolation (flavor doesn't leak into iOS credentials) — thorough coverage
  • Whitespace-only --android-flavor values are trimmed and ignored with a user-facing warning — consistent with how the builder PR handles it
  • Comment in updateCredentialsCommand explaining the intentional asymmetry vs saveCredentialsCommand — good defensive documentation

CI:

  • Run tests: passing ✅
  • SonarCloud quality gate: passing ✅ (the SonarCloud Code Analysis job failure is the GitHub Actions step exiting non-zero, not the gate — this is a known draft-PR quirk; the gate itself is green)
  • All other checks: passing ✅

Ready to merge once the draft is marked ready.

riderx and others added 2 commits March 17, 2026 00:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@riderx riderx marked this pull request as ready for review March 16, 2026 23:57
@riderx riderx merged commit 4843296 into main Mar 16, 2026
18 of 19 checks passed
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.

4 participants