Skip to content

feat(apps:liveupdates): add apps:liveupdates:create command#133

Open
robingenz wants to merge 2 commits intomainfrom
feat/live-updates-create
Open

feat(apps:liveupdates): add apps:liveupdates:create command#133
robingenz wants to merge 2 commits intomainfrom
feat/live-updates-create

Conversation

@robingenz
Copy link
Member

Summary

  • Add new apps:liveupdates:create command that creates a web build, waits for completion, optionally sets version constraints (Android/iOS), and deploys to a channel
  • Extract waitForBuildCompletion utility to src/utils/build.ts for reuse across apps:builds:create and apps:liveupdates:create
  • Add rolloutPercentage support to CreateAppDeploymentDto

Copilot AI review requested due to automatic review settings March 24, 2026 09:47
@robingenz
Copy link
Member Author

npm i @capawesome/cli@4.6.0-dev.bda9e9d.1774345600

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 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:create command and registered it in the CLI command map.
  • Extracted build polling/log streaming into waitForBuildCompletion and reused it in apps:builds:create.
  • Extended CreateAppDeploymentDto to include rolloutPercentage.

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.

Comment on lines +32 to +36
if (jobStatus === 'queued' || jobStatus === 'pending') {
if (isWaitingForStart) {
consola.start(`Waiting for build to start (status: ${jobStatus})...`);
}
await wait(3000);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +46
rolloutPercentage: z
.number()
.int()
.min(0)
.max(100)
.optional()
.describe('The rollout percentage for the deployment (0-100). Default: 100.'),
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +137 to +188
// 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,
});
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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