Skip to content

feat: use sdk for reviewapps enable and disable commands - #3897

Open
jdodson wants to merge 1 commit into
v12.0.0from
jbd_add_review_apps
Open

feat: use sdk for reviewapps enable and disable commands#3897
jdodson wants to merge 1 commit into
v12.0.0from
jbd_add_review_apps

Conversation

@jdodson

@jdodson jdodson commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Why:

reviewapps:enable and reviewapps:disable duplicated the logic for looking up a pipeline's GitHub repository across the Platform API, Repositories API, and Kolkrabbi.

That logic also had a correctness issue: when the dashboard-repositories-api account feature returned {enabled: false}, the commands continued without a repository name instead of falling back to the pipeline repository service.

Moving repository resolution into @heroku/sdk gives both commands one consistent implementation while preserving existing command behavior, including flags, output, warnings, and the request body sent when disabling Review Apps.

How:

  • Update the CLI lockfile to use @heroku/sdk@0.6.1.
  • Replace direct Platform API and Kolkrabbi calls in reviewapps:enable and reviewapps:disable with the SDK.
  • Resolve the pipeline through platform.pipeline.info().
  • Resolve its repository through platform.reviewAppConfig.resolveRepoName().
  • Share authentication across SDK services while applying the CLI's Platform API URL only to the Platform and Repositories API clients.
  • Continue using the Kolkrabbi-backed repositories service as the fallback when the account feature is disabled or the Repositories API lookup fails.
  • Preserve the existing enable and settings-update behavior.
  • Preserve the complete request body for reviewapps:disable by applying it through platform.withOptions() before calling the generated DELETE method.
  • Preserve the hidden positive aliases accepted by reviewapps:disable.
  • Replace command-level Nock tests with SDK fakes so the CLI tests focus on flag parsing, request construction, routing, output, and error propagation.
  • Document the corrected disabled-feature fallback in V12-CHANGES.md.

Type of Change

Breaking Changes (major semver update)

  • Add a ! after your change type to denote a change that breaks current behavior

Feature Additions (minor semver update)

  • feat: Introduces a new feature to the codebase

Patch Updates (patch semver update)

  • fix: Bug fix
  • deps: Dependency upgrade
  • revert: Revert a previous commit
  • chore: Change that does not affect production code
  • refactor: Refactoring existing code without changing behavior
  • test: Add/update/remove tests

Testing

These commands change Review App configuration. Use a disposable app and pipeline rather than production resources.

Prerequisites

  • Node.js and npm installed
  • Heroku CLI authenticated (heroku auth:whoami)
  • Permission to create and destroy a disposable Heroku app and pipeline
  • A GitHub repository that can be connected to a Heroku pipeline and used for Review Apps
  • Run the commands below from the root of this CLI checkout

Set unique test values, replacing the repository placeholder:

export TEST_ID="reviewapps-sdk-$(date +%s)"
export TEST_APP="$TEST_ID-app"
export TEST_PIPELINE="$TEST_ID-pipeline"
export TEST_REPO="<github-owner>/<github-repository>"

Setup

  1. Install dependencies and build the CLI:

    npm install
    npm run build
  2. Confirm authentication:

    heroku auth:whoami
  3. Create a disposable app and pipeline:

    ./bin/run apps:create "$TEST_APP"
    ./bin/run pipelines:create "$TEST_PIPELINE" --app "$TEST_APP" --stage staging
  4. Connect the test GitHub repository:

    ./bin/run pipelines:connect "$TEST_PIPELINE" --repo "$TEST_REPO"

Test Commands

These manual steps exercise all three migrated live Platform API operations using the SDK's 3.sdk media type: enabling without flags validates POST, changing settings validates PATCH, and disabling without flags validates DELETE with the preserved request body. A successful Configuring pipeline... done confirms that the deployed endpoint accepted the SDK request.

  1. Enable Review Apps without changing individual settings:

    ./bin/run reviewapps:enable --pipeline "$TEST_PIPELINE"

    Expect Configuring pipeline... done.

  2. Enable all supported settings:

    ./bin/run reviewapps:enable \
      --pipeline "$TEST_PIPELINE" \
      --autodeploy \
      --autodestroy \
      --wait-for-ci

    Expect messages for enabling auto deployment, auto destroy, and waiting for CI, followed by Configuring pipeline... done.

  3. Disable each setting through the visible flags:

    ./bin/run reviewapps:disable \
      --pipeline "$TEST_PIPELINE" \
      --no-autodeploy \
      --no-autodestroy \
      --no-wait-for-ci

    Expect messages for disabling all three settings, followed by Configuring pipeline... done.

  4. Verify a hidden positive alias remains backward compatible:

    ./bin/run reviewapps:disable --pipeline "$TEST_PIPELINE" --autodeploy

    Expect Disabling auto deployment... followed by Configuring pipeline... done.

  5. Verify the deprecated app warning remains unchanged:

    ./bin/run reviewapps:enable --pipeline "$TEST_PIPELINE" --app "$TEST_APP"

    Expect a warning containing Specifying an app via --app or --remote is no longer needed with Review Apps and a successful configuration result.

  6. Disable Review Apps entirely:

    ./bin/run reviewapps:disable --pipeline "$TEST_PIPELINE"

    Expect Configuring pipeline... done. Run this last among the manual command checks so the pipeline is left with Review Apps disabled.

  7. Run the automated Review Apps tests:

    npx mocha 'test/unit/commands/reviewapps/*.unit.test.ts' --reporter min

    Expect all Review Apps tests to pass.

  8. Run the focused lint, type, and build checks:

    npx eslint \
      src/commands/reviewapps/enable.ts \
      src/commands/reviewapps/disable.ts \
      test/unit/commands/reviewapps/enable.unit.test.ts \
      test/unit/commands/reviewapps/disable.unit.test.ts
    
    bash scripts/codemods/sdk-migration/tsc-delta.sh
    npm run build

    Expect each command to exit successfully without new diagnostics.

Tear Down

Run these steps even if a manual test fails:

  1. Disable Review Apps if they are still enabled:

    ./bin/run reviewapps:disable --pipeline "$TEST_PIPELINE" || true
  2. Destroy the disposable pipeline and app:

    ./bin/run pipelines:destroy "$TEST_PIPELINE"
    ./bin/run apps:destroy --app "$TEST_APP" --confirm "$TEST_APP"
  3. Clear the test variables:

    unset TEST_ID TEST_APP TEST_PIPELINE TEST_REPO

The disabled-account-feature fallback is covered by the SDK resolver tests because that account feature cannot be safely toggled as part of manual CLI testing.

Screenshots (if applicable)

Related Issues

GUS work item: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002eLUGnYAO/view

@jdodson
jdodson requested a review from a team as a code owner September 1, 2026 22:48
@jdodson jdodson changed the title fix: use @heroku/sdk for reviewapps enable and disable commands feat: use @heroku/sdk for reviewapps enable and disable commands Sep 1, 2026
@jdodson jdodson changed the title feat: use @heroku/sdk for reviewapps enable and disable commands feat: use sdk for reviewapps enable and disable commands Sep 1, 2026
@jdodson
jdodson changed the base branch from main to v12.0.0 September 1, 2026 22:50
@jdodson
jdodson changed the base branch from v12.0.0 to main September 1, 2026 23:16
@jdodson
jdodson changed the base branch from main to v12.0.0 September 1, 2026 23:16
@jdodson jdodson closed this Sep 1, 2026
@jdodson jdodson reopened this Sep 1, 2026
@jdodson
jdodson deployed to AcceptanceTests September 1, 2026 23:17 — with GitHub Actions Active
@jdodson
jdodson deployed to AcceptanceTests September 1, 2026 23:17 — with GitHub Actions Active
@jdodson
jdodson deployed to AcceptanceTests September 1, 2026 23:17 — with GitHub Actions Active
@jdodson
jdodson deployed to AcceptanceTests September 1, 2026 23:17 — with GitHub Actions Active
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