Skip to content

Commit

Permalink
support cdn uploading for client side (#115)
Browse files Browse the repository at this point in the history
* support cdn uploading for client side

* fixing comments

* fix

* upgrade version

* fix
  • Loading branch information
Shaharshaki2 authored Feb 9, 2025
1 parent 4536123 commit 8f6221c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mondaycom/apps-cli",
"version": "4.4.1",
"version": "4.5.0",
"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
"author": "monday.com Apps Team",
"type": "module",
Expand Down
23 changes: 21 additions & 2 deletions src/commands/code/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { APP_ID_TO_ENTER, APP_VERSION_ID_TO_ENTER } from 'consts/messages';
import { DynamicChoicesService } from 'services/dynamic-choices-service';
import { getCurrentWorkingDirectory } from 'services/env-service';
import { validateIfCanBuild } from 'services/files-service';
import { getTasksForServerSide } from 'services/share/deploy';
import { getTasksForClientSide, getTasksForServerSide } from 'services/share/deploy';
import logger from 'utils/logger';
import { addRegionToFlags, chooseRegionIfNeeded, getRegionFromString } from 'utils/region';

Expand All @@ -14,6 +14,7 @@ const MESSAGES = {
appVersionId: APP_VERSION_ID_TO_ENTER,
appId: APP_ID_TO_ENTER,
force: 'Force push to live version',
cdn: 'Push files to CDN',
};

export default class Push extends AuthenticatedCommand {
Expand Down Expand Up @@ -43,17 +44,35 @@ export default class Push extends AuthenticatedCommand {
char: 'f',
description: MESSAGES.force,
}),
cdn: Flags.boolean({
char: 'c',
description: MESSAGES.cdn,
}),
}),
);

static args = {};
DEBUG_TAG = 'code_push';

public async handleCdnUpload(directoryPath?: string): Promise<void> {
const { appVersionId } = await DynamicChoicesService.chooseAppAndAppVersion(false, false, {
autoSelectVersion: true,
});
logger.info('Deploying build to CDN...');
await getTasksForClientSide(Number(appVersionId), directoryPath || getCurrentWorkingDirectory()).run();
}

public async run(): Promise<void> {
const { flags } = await this.parse(Push);
const { directoryPath, region: strRegion } = flags;
const { directoryPath, region: strRegion, cdn } = flags;
const region = getRegionFromString(strRegion);
let appVersionId = flags.appVersionId;

if (cdn) {
await this.handleCdnUpload(directoryPath);
process.exit(0);
}

validateIfCanBuild(directoryPath || getCurrentWorkingDirectory());

try {
Expand Down
2 changes: 1 addition & 1 deletion src/services/push-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const deployClientZip = async (
task.output = `Deploying client zip (${ctx.archivePath!}) to cdn`;
const buffer = readZipFileAsBuffer(ctx.archivePath!);
const data = await uploadClientZipFile(ctx.appVersionId, buffer);
task.title = `your project is live at: ${data.url}, use ${data.sourceUrl} for download your source`;
task.title = `Your project is live at: ${data.url}\n You can download your source code here: ${data.sourceUrl}`;
};

export const buildAssetToDeployTask = async (
Expand Down

0 comments on commit 8f6221c

Please sign in to comment.