Skip to content

Commit

Permalink
feature(eas-cli): add worker --alias flag (#2551)
Browse files Browse the repository at this point in the history
* feature(eas-cli): add `worker --alias` flag

* docs: add changelog entry

* fix(eas-cli): add missing `ora.start`

Co-authored-by: Szymon Dziedzic <szymon.dziedzic@swmansion.com>

---------

Co-authored-by: Szymon Dziedzic <szymon.dziedzic@swmansion.com>
  • Loading branch information
byCedric and szdziedzic committed Sep 12, 2024
1 parent feaa8cb commit a404bb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is the log of notable changes to EAS CLI and related packages.

- Add `worker:alias` command to assign aliases from the CLI. ([#2548](https://github.com/expo/eas-cli/pull/2548) by [@byCedric](https://github.com/byCedric))
- Add `worker --prod` flag to deploy to production from the CLI. ([#2550](https://github.com/expo/eas-cli/pull/2550) by [@byCedric](https://github.com/byCedric))
- Add `worker --alias` flag to assign custom aliases when deploying. ([#2551](https://github.com/expo/eas-cli/pull/2551) by [@byCedric](https://github.com/byCedric)))

### 🐛 Bug fixes

Expand Down
23 changes: 23 additions & 0 deletions packages/eas-cli/src/commands/worker/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ora } from '../../ora';
import { createProgressTracker } from '../../utils/progress';
import * as WorkerAssets from '../../worker/assets';
import {
assignWorkerDeploymentAliasAsync,
assignWorkerDeploymentProductionAsync,
getSignedDeploymentUrlAsync,
} from '../../worker/deployment';
Expand All @@ -25,12 +26,14 @@ interface DeployFlags {
nonInteractive: boolean;
json: boolean;
prod: boolean;
aliasName?: string;
}

interface RawDeployFlags {
'non-interactive': boolean;
json: boolean;
prod: boolean;
alias?: string;
}

export default class WorkerDeploy extends EasCommand {
Expand All @@ -42,6 +45,9 @@ export default class WorkerDeploy extends EasCommand {
static override state = 'beta';

static override flags = {
alias: Flags.string({
description: 'Custom alias for the deployment',
}),
prod: Flags.boolean({
description: 'Deploy to production',
default: false,
Expand Down Expand Up @@ -227,6 +233,22 @@ export default class WorkerDeploy extends EasCommand {

await uploadAssetsAsync(assetMap, deployResult.uploads);

if (flags.aliasName) {
progress = ora(chalk`Assigning alias {bold ${flags.aliasName}} to worker deployment`).start();
try {
await assignWorkerDeploymentAliasAsync({
graphqlClient,
appId: projectId,
deploymentId: deployResult.id,
aliasName: flags.aliasName,
});
progress.succeed(chalk`Assigned alias {bold ${flags.aliasName}} to worker deployment`);
} catch (error: any) {
progress.fail(chalk`Failed to assign {bold ${flags.aliasName}} alias to worker deployment`);
throw error;
}
}

const expoBaseDomain = process.env.EXPO_STAGING ? 'staging.expo' : 'expo';
const dashboardUrl = `https://${expoBaseDomain}.dev/projects/${projectId}/serverless/deployments`;

Expand Down Expand Up @@ -265,6 +287,7 @@ export default class WorkerDeploy extends EasCommand {
nonInteractive: flags['non-interactive'],
json: flags['json'],
prod: !!flags.prod,
aliasName: flags.alias?.trim().toLowerCase(),
};
}
}
Expand Down

0 comments on commit a404bb3

Please sign in to comment.