mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 03:19:18 +08:00
feat: 新增部署脚本
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import boxen from 'boxen';
|
||||
import chalk from 'chalk';
|
||||
import gradient from 'gradient-string';
|
||||
import ora, { type Ora } from 'ora';
|
||||
|
||||
export function printBanner() {
|
||||
const title = gradient.pastel('Ecom Deploy');
|
||||
console.log(
|
||||
boxen(`${title}\n${chalk.gray('部署管理工具 · Docker 编排')}`, {
|
||||
padding: 1,
|
||||
borderColor: 'cyan',
|
||||
borderStyle: 'round',
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function printSuccess(msg: string) {
|
||||
console.log(chalk.green('✔'), msg);
|
||||
}
|
||||
|
||||
export function printError(msg: string) {
|
||||
console.error(chalk.red('✖'), msg);
|
||||
}
|
||||
|
||||
export function printInfo(msg: string) {
|
||||
console.log(chalk.blue('ℹ'), msg);
|
||||
}
|
||||
|
||||
export function printBox(title: string, content: string, borderColor: 'green' | 'cyan' | 'yellow' = 'cyan') {
|
||||
console.log(
|
||||
boxen(content, {
|
||||
title: chalk.bold(title),
|
||||
padding: 1,
|
||||
borderColor,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
let activeSpinner: Ora | null = null;
|
||||
|
||||
export async function runSpinner<T>(fn: () => Promise<T>, text: string): Promise<T> {
|
||||
const spinner = ora(text).start();
|
||||
activeSpinner = spinner;
|
||||
try {
|
||||
const result = await fn();
|
||||
spinner.succeed();
|
||||
return result;
|
||||
} catch (e) {
|
||||
spinner.fail();
|
||||
throw e;
|
||||
} finally {
|
||||
activeSpinner = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user