Skip to content

Commit faf6b51

Browse files
authored
feature: add ability to provide user tip message for failure from GCP (#43)
1 parent 2f04719 commit faf6b51

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mondaycom/apps-cli",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
55
"author": "monday.com Apps Team",
66
"type": "module",

src/services/push-service.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,26 @@ const STATUS_TO_PROGRESS_VALUE: Record<keyof typeof DeploymentStatusTypesSchema,
169169
[DeploymentStatusTypesSchema.successful]: PROGRESS_STEP * 100,
170170
};
171171

172+
const setCustomTip = (tip?: string, color = 'green') => {
173+
let chalkColor = chalk.green;
174+
switch (color) {
175+
case 'yellow': {
176+
chalkColor = chalk.yellow;
177+
break;
178+
}
179+
}
180+
181+
return tip ? `\n ${chalk.italic(chalkColor(tip))}` : '';
182+
};
183+
172184
const finalizeDeployment = (
173185
deploymentStatus: AppVersionDeploymentStatus,
174186
task: ListrTaskWrapper<PushCommandTasksContext, any>,
175187
) => {
176188
switch (deploymentStatus.status) {
177189
case DeploymentStatusTypesSchema.failed: {
178-
task.title = deploymentStatus.error?.message || 'Deployment process has failed';
190+
const customTip = setCustomTip(deploymentStatus.tip, 'yellow');
191+
task.title = (deploymentStatus.error?.message.trimStart() || 'Deployment process has failed') + customTip;
179192
throw new Error(task.title);
180193
}
181194

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

0 commit comments

Comments
 (0)