Skip to content

Use async/await instead of promise chains - #66

Merged
ashirman merged 3 commits into
mainfrom
feature/rev-136
Oct 15, 2026
Merged

ashirman merged 3 commits into
mainfrom
feature/rev-136

Conversation

@revopushbot

Copy link
Copy Markdown
Contributor

Brings REV-136 to main. It was reviewed as #65, but that PR was merged into feature/rev-134 after #64 had already landed, so its two commits never reached main. The commits are unchanged.

This only modernises the syntax. Behaviour, output, exit codes, the SDK API and server requests are unchanged. Most of the diff is re-indentation, so Hide whitespace makes it much smaller.

Changes

  • command-executor: every command handler, execute() and the four release flows use async/await instead of .then chains.
    • if (await confirm()) { … } replaces the nested confirm chains.
    • try/catch around releaseErrorHandler replaces .catch(...).
    • Promise.all is kept where requests ran in parallel (deployment metrics, deployment history).
    • The no-op .catch(async (err) => { throw err; }) blocks are removed.
  • management-sdk: the request methods are async and still resolve null where they did before, which the tests assert.
  • sign: jwt.sign is used in its synchronous form, and Promise.reject/Promise.resolve inside the async function become throw/return.
  • hash-utils, gradle-utils, binary-utils: the last small chains are converted.
  • Kept as new Promise: only wrappers around callback and event APIs (superagent, prompt, child_process, yazl/yauzl, streams), plus getSdk's generic error wrapper.
  • Review cleanups:
    • The release size result is typed as nullable again.
    • A buildNumber assignment that did nothing and a redundant source-map check are gone.
    • Comments that only repeated the code are removed.

Validation errors that used to be thrown synchronously now reject. Every caller already awaits these calls, and execute() already ran commands inside a promise, so the CLI prints the same [Error] … with the same exit code.

Verification

  • Build and lint: tsc and npm run lint are clean.
  • Tests: all 155 pass on macOS and on Linux (Docker, Node 20.19.0).
  • End to end: the real CLI binary from main and from this branch, run against a local fake server with 45 commands.
    • Coverage: access keys, apps, collaborators, deployments, history, promote, patch, rollback, sessions, release, login state, cancelled prompts, validation errors, server errors, and a duplicate release with and without --noDuplicateReleaseError.
    • Output and exit codes are identical, apart from Replace Q with native promises #64's intended error for unreadable release folders.
    • The server received identical requests and bodies.
  • Code signing: the content hash matches main, and a bad key path gives the same error.

Found during review, not changed here

  • Signing a folder twice fails: sign() removes an existing .codepushrelease with rmdir, which only works on folders. Fixed separately in REV-137.
  • Duplicated release flows: releaseReact and releaseExpo are near-duplicates and could share one implementation.

🤖 Generated with Claude Code

revopushbot and others added 2 commits October 15, 2026 14:03
No behaviour change: the same output, exit codes and server requests.

- Command handlers, execute() and the release flows await instead of
  chaining .then(); release error handling uses try/catch
- SDK request methods are async and still resolve null where they did
- sign() uses jwt.sign synchronously and throws instead of returning
  rejected promises
- new Promise(...) stays only around callback and event APIs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Type the release size result as nullable again
- Drop a no-op buildNumber assignment and a redundant source map check
- Remove a try/catch that only rethrew and comments that restate the code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ashirman
ashirman merged commit 6379fa9 into main Oct 15, 2026
2 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.

2 participants