From 9361f09c2b360f21180257cd8023457b4f875d61 Mon Sep 17 00:00:00 2001 From: Eugene Formanenko Date: Mon, 9 Sep 2024 15:57:31 +0400 Subject: [PATCH] feat: print full ref as bold --- src/command.ts | 1 - src/commands/deploy.ts | 28 +++++++++++++++++++--------- src/commands/restart.ts | 4 ++-- src/commands/rm.ts | 6 +++--- src/commands/tags/add.ts | 8 ++++---- src/commands/tags/remove.ts | 6 +++--- src/utils.ts | 4 ++++ 7 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/command.ts b/src/command.ts index 52f135e..8bcf16a 100644 --- a/src/command.ts +++ b/src/command.ts @@ -6,7 +6,6 @@ import { isNil, uniqBy } from 'lodash'; import { ApiError, getOrganization, getSquid, listOrganizations, listUserSquids, SquidRequest } from './api'; import { getTTY } from './tty'; -import { parseSquidFullname } from './utils'; export const SUCCESS_CHECK_MARK = chalk.green('✓'); diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index b7eda51..c7933ca 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -17,7 +17,7 @@ import { deploySquid, OrganizationRequest, Squid, uploadFile } from '../api'; import { SqdFlags, SUCCESS_CHECK_MARK } from '../command'; import { DeployCommand } from '../deploy-command'; import { loadManifestFile } from '../manifest'; -import { formatSquidFullname, ParsedSquidFullname, parseSquidFullname } from '../utils'; +import { formatSquidFullname, ParsedSquidFullname, parseSquidFullname, printSquidFullname } from '../utils'; const compressAsync = promisify(targz.compress); @@ -188,10 +188,6 @@ export default class Deploy extends DeployCommand { const { buildDir, squidDir, manifest } = res; - this.log(chalk.dim(`Squid directory: ${squidDir}`)); - this.log(chalk.dim(`Build directory: ${buildDir}`)); - this.log(chalk.dim(`Manifest: ${manifestPath}`)); - const overrides = fullname ? fullname : flags; // some hack to add slot name in case if version is used @@ -210,6 +206,20 @@ export default class Deploy extends DeployCommand { name = await this.promptSquidName(name); + this.log(chalk.dim(`Squid directory: ${squidDir}`)); + this.log(chalk.dim(`Build directory: ${buildDir}`)); + this.log(chalk.dim(`Manifest: ${manifestPath}`)); + this.log(chalk.cyan(`-----------------------------`)); + this.log(chalk.cyan(`Organization: ${organization.code}`)); + this.log(chalk.cyan(`Squid name: ${name}`)); + if (slot) { + this.log(chalk.cyan(`Squid slot: ${slot}`)); + } + if (tag) { + this.log(chalk.cyan(`Squid tag: ${tag}`)); + } + this.log(chalk.cyan(`-----------------------------`)); + let target: Squid | null = null; if (slot || tag) { target = await this.findSquid({ @@ -266,7 +276,7 @@ export default class Deploy extends DeployCommand { if (target) { this.logDeployResult( UPDATE_COLOR, - `The squid ${formatSquidFullname({ + `The squid ${printSquidFullname({ org: deployment.organization.code, name: deployment.squid.name, slot: deployment.squid.slot, @@ -275,7 +285,7 @@ export default class Deploy extends DeployCommand { } else { this.logDeployResult( CREATE_COLOR, - `A new squid ${formatSquidFullname({ + `A new squid ${printSquidFullname({ org: deployment.organization.code, name: deployment.squid.name, slot: deployment.squid.slot, @@ -295,7 +305,7 @@ export default class Deploy extends DeployCommand { type: 'confirm', message: [ chalk.reset( - `A squid "${formatSquidFullname({ + `A squid "${printSquidFullname({ org: target.organization.code, name: target.name, slot: target.slot, @@ -323,7 +333,7 @@ export default class Deploy extends DeployCommand { type: 'confirm', message: [ chalk.reset( - `A squid tag "${tag}" has already been assigned to ${formatSquidFullname({ name: oldSquid.name, slot: oldSquid.slot })}.`, + `A squid tag "${tag}" has already been assigned to ${printSquidFullname({ name: oldSquid.name, slot: oldSquid.slot })}.`, ), chalk.reset(`The tag will be assigned to the newly created squid. ${chalk.bold('Are you sure?')}`), ].join('\n'), diff --git a/src/commands/restart.ts b/src/commands/restart.ts index a8f950b..d954853 100644 --- a/src/commands/restart.ts +++ b/src/commands/restart.ts @@ -4,7 +4,7 @@ import { isNil, omitBy } from 'lodash'; import { restartSquid } from '../api'; import { SqdFlags } from '../command'; import { DeployCommand } from '../deploy-command'; -import { formatSquidFullname } from '../utils'; +import { formatSquidFullname, printSquidFullname } from '../utils'; import { UPDATE_COLOR } from './deploy'; @@ -66,7 +66,7 @@ export default class Restart extends DeployCommand { this.logDeployResult( UPDATE_COLOR, - `The squid ${formatSquidFullname({ + `The squid ${printSquidFullname({ org: deployment.organization.code, name: deployment.squid.name, slot: deployment.squid.slot, diff --git a/src/commands/rm.ts b/src/commands/rm.ts index 1a81f6d..245cba9 100644 --- a/src/commands/rm.ts +++ b/src/commands/rm.ts @@ -4,7 +4,7 @@ import inquirer from 'inquirer'; import { deleteSquid } from '../api'; import { SqdFlags, SquidReferenceArg } from '../command'; import { DeployCommand } from '../deploy-command'; -import { formatSquidFullname } from '../utils'; +import { formatSquidFullname, printSquidFullname } from '../utils'; import { DELETE_COLOR } from './deploy'; @@ -74,7 +74,7 @@ export default class Rm extends DeployCommand { { name: 'confirm', type: 'confirm', - message: `Your squid ${formatSquidFullname({ org, name, slot: squid.slot })} will be completely removed. This action can not be undone. Are you sure?`, + message: `Your squid ${printSquidFullname({ org, name, slot: squid.slot })} will be completely removed. This action can not be undone. Are you sure?`, }, ]); if (!confirm) return; @@ -86,7 +86,7 @@ export default class Rm extends DeployCommand { this.logDeployResult( DELETE_COLOR, - `A squid deployment ${formatSquidFullname({ + `A squid deployment ${printSquidFullname({ org: deployment.organization.code, name: deployment.squid.name, slot: deployment.squid.slot, diff --git a/src/commands/tags/add.ts b/src/commands/tags/add.ts index f6cf5c4..4e50d42 100644 --- a/src/commands/tags/add.ts +++ b/src/commands/tags/add.ts @@ -5,7 +5,7 @@ import inquirer from 'inquirer'; import { addSquidTag } from '../../api'; import { SqdFlags } from '../../command'; import { DeployCommand } from '../../deploy-command'; -import { formatSquidFullname } from '../../utils'; +import { formatSquidFullname, printSquidFullname } from '../../utils'; import { UPDATE_COLOR } from '../deploy'; export default class Add extends DeployCommand { @@ -70,7 +70,7 @@ export default class Add extends DeployCommand { if (squid.tags.find((t) => t.name === tagName)) { return this.log( - `Tag "${tagName}" is already assigned to the squid ${formatSquidFullname({ org, name, tag, slot })}`, + `Tag "${tagName}" is already assigned to the squid ${printSquidFullname({ org, name, tag, slot })}`, ); } @@ -82,7 +82,7 @@ export default class Add extends DeployCommand { type: 'confirm', message: [ chalk.reset( - `A squid tag "${tagName}" has already been assigned to the previous squid deployment ${formatSquidFullname({ org, name, slot: oldSquid.slot })}.`, + `A squid tag "${tagName}" has already been assigned to the previous squid deployment ${printSquidFullname({ org, name, slot: oldSquid.slot })}.`, ), chalk.reset(`The tag URL will be assigned to the newly created deployment. ${chalk.bold(`Are you sure?`)}`), ].join('\n'), @@ -101,7 +101,7 @@ export default class Add extends DeployCommand { this.logDeployResult( UPDATE_COLOR, - `The squid ${formatSquidFullname({ + `The squid ${printSquidFullname({ org: deployment.organization.code, name: deployment.squid.name, slot: deployment.squid.slot, diff --git a/src/commands/tags/remove.ts b/src/commands/tags/remove.ts index 230ca6d..a267985 100644 --- a/src/commands/tags/remove.ts +++ b/src/commands/tags/remove.ts @@ -3,7 +3,7 @@ import { Args } from '@oclif/core'; import { removeSquidTag } from '../../api'; import { SqdFlags } from '../../command'; import { DeployCommand } from '../../deploy-command'; -import { formatSquidFullname } from '../../utils'; +import { formatSquidFullname, printSquidFullname } from '../../utils'; import { UPDATE_COLOR } from '../deploy'; export default class Remove extends DeployCommand { @@ -74,7 +74,7 @@ export default class Remove extends DeployCommand { const squid = await this.findOrThrowSquid({ organization, reference }); if (!squid.tags.some((t) => t.name === tagName)) { - return this.log(`Tag "${tagName}" is not assigned to the squid ${formatSquidFullname({ org, name, tag, slot })}`); + return this.log(`Tag "${tagName}" is not assigned to the squid ${printSquidFullname({ org, name, tag, slot })}`); } const deployment = await removeSquidTag({ @@ -87,7 +87,7 @@ export default class Remove extends DeployCommand { this.logDeployResult( UPDATE_COLOR, - `The squid ${formatSquidFullname({ + `The squid ${printSquidFullname({ org: deployment.organization.code, name: deployment.squid.name, slot: deployment.squid.slot, diff --git a/src/utils.ts b/src/utils.ts index 3018395..daf2805 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -36,6 +36,10 @@ export function formatSquidFullname({ org, name, slot, tag }: ParsedSquidFullnam return res; } +export function printSquidFullname(args: ParsedSquidFullname) { + return chalk.bold(formatSquidFullname(args)); +} + export const SQUID_FULLNAME_REGEXP = /^(([a-z0-9\-]+)\/)?([a-z0-9\-]+)([:@])([a-z0-9\-]+)$/; export function parseSquidFullname(fullname: string): ParsedSquidFullname {