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 for failure from GCP #43

Merged
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.2.0",
"version": "1.3.0",
"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
"author": "monday.com Apps Team",
"type": "module",
Expand Down
17 changes: 15 additions & 2 deletions src/services/push-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,26 @@ const STATUS_TO_PROGRESS_VALUE: Record<keyof typeof DeploymentStatusTypesSchema,
[DeploymentStatusTypesSchema.successful]: PROGRESS_STEP * 100,
};

const setCustomTip = (tip?: string, color = 'green') => {
let chalkColor = chalk.green;
switch (color) {
case 'yellow': {
chalkColor = chalk.yellow;
break;
}
}

return tip ? `\n ${chalk.italic(chalkColor(tip))}` : '';
};

const finalizeDeployment = (
deploymentStatus: AppVersionDeploymentStatus,
task: ListrTaskWrapper<PushCommandTasksContext, any>,
) => {
switch (deploymentStatus.status) {
case DeploymentStatusTypesSchema.failed: {
task.title = deploymentStatus.error?.message || 'Deployment process has failed';
const customTip = setCustomTip(deploymentStatus.tip, 'yellow');
task.title = (deploymentStatus.error?.message.trimStart() || 'Deployment process has failed') + customTip;
throw new Error(task.title);
}

Expand Down Expand Up @@ -206,7 +219,7 @@ export const handleDeploymentTask = async (
progressLogger: (message: keyof typeof DeploymentStatusTypesSchema, tip?: string) => {
const deltaInSeconds = (Date.now() - now) / TimeInMs.second;
task.title = `Deployment in progress: ${message}`;
const customTip = tip ? `\n ${chalk.italic(chalk.green(tip))}` : '';
const customTip = setCustomTip(tip);
task.output =
createProgressBarString(MAX_PROGRESS_VALUE, STATUS_TO_PROGRESS_VALUE[message], deltaInSeconds) + customTip;
},
Expand Down
Loading