Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add ability to provide user tip message from GCP #42

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "1.1.0",
"version": "1.2.0",
"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
"author": "monday.com Apps Team",
"type": "module",
Expand Down
14 changes: 10 additions & 4 deletions src/services/push-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';
import chalk from 'chalk';
import { ListrTaskWrapper } from 'listr2';

import { getAppVersionDeploymentStatusUrl, getDeploymentSignedUrl } from 'consts/urls';
Expand Down Expand Up @@ -62,7 +63,10 @@ export const getAppVersionDeploymentStatus = async (appVersionId: number) => {
export const pollForDeploymentStatus = async (
appVersionId: number,
retryAfter: number,
options: { ttl?: number; progressLogger?: (message: keyof typeof DeploymentStatusTypesSchema) => void } = {},
options: {
ttl?: number;
progressLogger?: (message: keyof typeof DeploymentStatusTypesSchema, tip?: string) => void;
} = {},
): Promise<AppVersionDeploymentStatus> => {
const { ttl, progressLogger } = options;

Expand All @@ -79,7 +83,7 @@ export const pollForDeploymentStatus = async (
const response = await getAppVersionDeploymentStatus(appVersionId);
if (statusesToKeepPolling.includes(response.status)) {
if (progressLogger) {
progressLogger(response.status);
progressLogger(response.status, response.tip);
}

return false;
Expand Down Expand Up @@ -199,10 +203,12 @@ export const handleDeploymentTask = async (
const ttl = TimeInMs.minute * 30;
const deploymentStatus = await pollForDeploymentStatus(ctx.appVersionId, retryAfter, {
ttl,
progressLogger: (message: keyof typeof DeploymentStatusTypesSchema) => {
progressLogger: (message: keyof typeof DeploymentStatusTypesSchema, tip?: string) => {
const deltaInSeconds = (Date.now() - now) / TimeInMs.second;
task.title = `Deployment in progress: ${message}`;
task.output = createProgressBarString(MAX_PROGRESS_VALUE, STATUS_TO_PROGRESS_VALUE[message], deltaInSeconds);
const customTip = tip ? `\n ${chalk.italic(chalk.green(tip))}` : '';
task.output =
createProgressBarString(MAX_PROGRESS_VALUE, STATUS_TO_PROGRESS_VALUE[message], deltaInSeconds) + customTip;
},
});

Expand Down
1 change: 1 addition & 0 deletions src/services/schemas/push-service-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const deploymentStatusTypesSchema = z.enum(deploymentStatusTypesArray);
export const appVersionDeploymentStatusSchema = z
.object({
status: deploymentStatusTypesSchema,
tip: z.string().optional(),
deployment: z
.object({
url: z.string(),
Expand Down
Loading