Skip to content

Commit

Permalink
feature: add support for multi region param
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayElkana committed May 27, 2024
1 parent f5bd864 commit 89d2e2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/commands/app/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,20 @@ export default class AppDeploy extends AuthenticatedCommand {
public async run(): Promise<void> {
try {
const { flags } = await this.parse(AppDeploy);
const { directoryPath, appId, appVersionId, force } = flags;
const { directoryPath, force, appId } = flags;
const region = getRegionFromString(flags?.region);
const manifestFileDir = directoryPath || getCurrentWorkingDirectory();
const manifestFileData = readManifestFile(manifestFileDir);
flags.appId = appId || manifestFileData.app.id;

flags.appVersionId = await this.getAppVersionId(appVersionId, appId, force);

this.preparePrintCommand(this, { appVersionId: appVersionId, directoryPath: manifestFileData });
flags.appVersionId = await this.getAppVersionId(flags.appVersionId, flags.appId, force);

Check failure on line 69 in src/commands/app/deploy.ts

View workflow job for this annotation

GitHub Actions / Run validations

Use destructured variables over properties

Check failure on line 69 in src/commands/app/deploy.ts

View workflow job for this annotation

GitHub Actions / Run validations

Use destructured variables over properties
this.preparePrintCommand(this, { appVersionId: flags.appVersionId, directoryPath: manifestFileData });

Check failure on line 70 in src/commands/app/deploy.ts

View workflow job for this annotation

GitHub Actions / Run validations

Use destructured variables over properties

const { cdn, server } = manifestFileData.app?.hosting || {};
if (cdn && cdn.type === ManifestHostingType.Upload) {
logger.info('Deploying files to cdn...');
await getTasksForClientSide(
Number(appVersionId),
Number(flags.appVersionId),

Check failure on line 76 in src/commands/app/deploy.ts

View workflow job for this annotation

GitHub Actions / Run validations

Use destructured variables over properties
getManifestAssetPath(manifestFileDir, cdn.path),
region,
).run();
Expand All @@ -83,7 +82,7 @@ export default class AppDeploy extends AuthenticatedCommand {
if (server && server.type === ManifestHostingType.Upload) {
logger.info('Deploying server side files...');
await getTasksForServerSide(
Number(appVersionId),
Number(flags.appVersionId),

Check failure on line 85 in src/commands/app/deploy.ts

View workflow job for this annotation

GitHub Actions / Run validations

Use destructured variables over properties
getManifestAssetPath(manifestFileDir, server.path),
region,
).run();
Expand Down
6 changes: 4 additions & 2 deletions src/services/share/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PushCommandTasksContext } from 'types/commands/push';
import { Region } from 'types/general/region';

export const getTasksForClientSide = (appVersionId: number, directoryPath?: string, region?: Region) => {
const ctx = { appVersionId, directoryPath, region };
return new Listr<PushCommandTasksContext>(
[
{ title: 'Build asset to deploy', task: buildClientZip },
Expand All @@ -21,12 +22,13 @@ export const getTasksForClientSide = (appVersionId: number, directoryPath?: stri
},
],
{
ctx: { appVersionId, directoryPath, region },
ctx,
},
);
};

export const getTasksForServerSide = (appVersionId: number, directoryPath?: string, region?: Region) => {
const ctx = { appVersionId, directoryPath, region };
return new Listr<PushCommandTasksContext>(
[
{ title: 'Build asset to deploy', task: buildAssetToDeployTask },
Expand All @@ -46,6 +48,6 @@ export const getTasksForServerSide = (appVersionId: number, directoryPath?: stri
enabled: ctx => Boolean(ctx.showHandleDeploymentTask),
},
],
{ ctx: { appVersionId, directoryPath, region } },
{ ctx },
);
};

0 comments on commit 89d2e2d

Please sign in to comment.