Skip to content

Commit

Permalink
feature(eas-cli): add worker --alias flag
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Sep 12, 2024
1 parent feaa8cb commit 5af88b4
Showing 1 changed file with 23 additions and 0 deletions.
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`);
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 5af88b4

Please sign in to comment.