feat(cli): improve changelog logging

This commit is contained in:
陈嘉涵 2020-01-15 13:11:20 +08:00
parent 67e2a2759c
commit a98e9b29f9
3 changed files with 20 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import { join } from 'path';
import { ROOT } from '../common/constant';
import { logger, simplifyPath } from '../common/logger';
import { ora, slimPath } from '../common/logger';
import { createWriteStream, readFileSync } from 'fs-extra';
// @ts-ignore
import conventionalChangelog from 'conventional-changelog';
@ -47,7 +47,7 @@ function transform(item: any) {
}
export async function changelog() {
logger.start('Generating changelog...');
const spinner = ora('Generating changelog...').start();
return new Promise(resolve => {
conventionalChangelog(
@ -66,7 +66,7 @@ export async function changelog() {
)
.pipe(createWriteStream(DIST_FILE))
.on('close', () => {
logger.success(`Changelog generated successfully at ${simplifyPath(DIST_FILE)}`);
spinner.succeed(`Changelog generated at ${slimPath(DIST_FILE)}`);
resolve();
});
});

View File

@ -1,3 +1,4 @@
import ora from 'ora';
import chalk from 'chalk';
import logger from 'signale';
import { ROOT } from '../common/constant';
@ -35,8 +36,8 @@ export function getInteractiveLogger() {
return interactive;
}
export function simplifyPath(path: string) {
export function slimPath(path: string) {
return chalk.yellow(path.replace(ROOT, '.'));
}
export { logger };
export { ora, logger };

View File

@ -8279,6 +8279,20 @@ ora@4.0.2:
strip-ansi "^5.2.0"
wcwidth "^1.0.1"
ora@^4.0.3:
version "4.0.3"
resolved "https://registry.npm.taobao.org/ora/download/ora-4.0.3.tgz#752a1b7b4be4825546a7a3d59256fa523b6b6d05"
integrity sha1-dSobe0vkglVGp6PVklb6UjtrbQU=
dependencies:
chalk "^3.0.0"
cli-cursor "^3.1.0"
cli-spinners "^2.2.0"
is-interactive "^1.0.0"
log-symbols "^3.0.0"
mute-stream "0.0.8"
strip-ansi "^6.0.0"
wcwidth "^1.0.1"
original@^1.0.0:
version "1.0.2"
resolved "https://registry.npm.taobao.org/original/download/original-1.0.2.tgz#e442a61cffe1c5fd20a65f3261c26663b303f25f"