feat(apps:liveupdates): add apps:liveupdates:create command#133
feat(apps:liveupdates): add apps:liveupdates:create command#133
apps:liveupdates:create command#133Conversation
|
There was a problem hiding this comment.
Pull request overview
Adds a new CLI workflow to create and deploy Live Updates by creating a web build, waiting for completion, optionally applying native version constraints, and deploying to a channel. It also factors shared “wait for build completion” polling into a reusable utility and extends the deployment DTO to support rollout percentages.
Changes:
- Added
apps:liveupdates:createcommand and registered it in the CLI command map. - Extracted build polling/log streaming into
waitForBuildCompletionand reused it inapps:builds:create. - Extended
CreateAppDeploymentDtoto includerolloutPercentage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/build.ts | New reusable build polling utility (status + logs) used by multiple commands. |
| src/types/app-deployment.ts | Adds rolloutPercentage to deployment creation DTO. |
| src/index.ts | Registers the new apps:liveupdates:create command. |
| src/commands/apps/liveupdates/create.ts | Implements the new live update creation workflow (build → wait → constraints → deploy). |
| src/commands/apps/builds/create.ts | Replaces inline polling loop with the new shared utility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (jobStatus === 'queued' || jobStatus === 'pending') { | ||
| if (isWaitingForStart) { | ||
| consola.start(`Waiting for build to start (status: ${jobStatus})...`); | ||
| } | ||
| await wait(3000); |
There was a problem hiding this comment.
isWaitingForStart never changes in the queued/pending branch, so consola.start(...) will be invoked on every polling iteration while the job is waiting. Consider tracking the last printed status (or setting a separate flag after the first consola.start) so the start message/spinner is only triggered when the status changes, avoiding repeated output/flicker.
| rolloutPercentage: z | ||
| .number() | ||
| .int() | ||
| .min(0) | ||
| .max(100) | ||
| .optional() | ||
| .describe('The rollout percentage for the deployment (0-100). Default: 100.'), |
There was a problem hiding this comment.
rolloutPercentage is defined with z.number(), but CLI args are typically parsed as strings; elsewhere in the codebase numeric flags use z.coerce.number(). As-is, --rollout-percentage 50 may fail validation. Switch this option to z.coerce.number() (keeping the int/min/max constraints) for consistent CLI behavior.
| // Create the web build | ||
| consola.start('Creating build...'); | ||
| const response = await appBuildsService.create({ | ||
| appCertificateName: certificate, | ||
| appEnvironmentName: environment, | ||
| appId, | ||
| stack, | ||
| gitRef, | ||
| platform: 'web', | ||
| }); | ||
| consola.info(`Build ID: ${response.id}`); | ||
| consola.info(`Build Number: ${response.numberAsString}`); | ||
| consola.info(`Build URL: ${DEFAULT_CONSOLE_BASE_URL}/apps/${appId}/builds/${response.id}`); | ||
| consola.success('Build created successfully.'); | ||
|
|
||
| // Wait for build to complete | ||
| await waitForBuildCompletion({ appId, appBuildId: response.id }); | ||
| consola.success('Build completed successfully.'); | ||
| console.log(); | ||
|
|
||
| // Update build with version constraints if any are provided | ||
| const hasVersionConstraints = | ||
| options.androidMin || | ||
| options.androidMax || | ||
| options.androidEq || | ||
| options.iosMin || | ||
| options.iosMax || | ||
| options.iosEq; | ||
| if (hasVersionConstraints) { | ||
| consola.start('Updating version constraints...'); | ||
| await appBuildsService.update({ | ||
| appId, | ||
| appBuildId: response.id, | ||
| minAndroidAppVersionCode: options.androidMin, | ||
| maxAndroidAppVersionCode: options.androidMax, | ||
| eqAndroidAppVersionCode: options.androidEq, | ||
| minIosAppVersionCode: options.iosMin, | ||
| maxIosAppVersionCode: options.iosMax, | ||
| eqIosAppVersionCode: options.iosEq, | ||
| }); | ||
| consola.success('Version constraints updated successfully.'); | ||
| } | ||
|
|
||
| // Deploy to channel | ||
| consola.start('Creating deployment...'); | ||
| const rolloutPercentage = (options.rolloutPercentage ?? 100) / 100; | ||
| const deployment = await appDeploymentsService.create({ | ||
| appId, | ||
| appBuildId: response.id, | ||
| appChannelName: channel, | ||
| rolloutPercentage, | ||
| }); |
There was a problem hiding this comment.
This new command adds a multi-step workflow (create build → poll logs/status → optionally update version constraints → create deployment). Similar liveupdate commands in this repo have Vitest/Nock coverage; adding a create.test.ts would help lock in the expected API requests (including rollout conversion and version-constraint update) and prevent regressions.
Summary
apps:liveupdates:createcommand that creates a web build, waits for completion, optionally sets version constraints (Android/iOS), and deploys to a channelwaitForBuildCompletionutility tosrc/utils/build.tsfor reuse acrossapps:builds:createandapps:liveupdates:createrolloutPercentagesupport toCreateAppDeploymentDto