feat(cli): using rslog (#12334)

This commit is contained in:
neverland
2023-10-02 21:34:03 +08:00
committed by GitHub
parent 53188a7093
commit 087ecda7b2
15 changed files with 48 additions and 60 deletions

View File

@@ -36,7 +36,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"consola": "^3.0.2",
"rslog": "^1.0.0",
"fast-glob": "^3.2.11",
"fs-extra": "^11.1.0",
"enquirer": "2.3.6",

View File

@@ -1,7 +1,7 @@
import fs from 'fs-extra';
import glob from 'fast-glob';
import color from 'picocolors';
import { consola } from 'consola';
import { logger } from 'rslog';
import { prompt } from 'enquirer';
import { sep, join } from 'node:path';
import { CWD, GENERATOR_DIR } from './constant';
@@ -64,7 +64,7 @@ export class VanGenerator {
writing() {
console.log();
consola.info(`Creating project in ${color.green(this.outputDir)}\n`);
logger.info(`Creating project in ${color.green(this.outputDir)}\n`);
// see https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
const templatePath = join(GENERATOR_DIR, this.inputs.vueVersion).replace(
@@ -99,15 +99,15 @@ export class VanGenerator {
fs.writeFileSync(to, content);
const name = to.replace(this.outputDir + sep, '');
consola.success(`${color.green('create')} ${name}`);
logger.success(`${color.green('create')} ${name}`);
}
end() {
const { name } = this.inputs;
console.log();
consola.success(`Successfully created ${color.yellow(name)}.`);
consola.success(
logger.success(`Successfully created ${color.yellow(name)}.`);
logger.success(
`Run ${color.yellow(
`cd ${name} && git init && yarn && yarn dev`,
)} to start development!`,

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { consola } from 'consola';
import { logger } from 'rslog';
import { prompt } from 'enquirer';
import { ensureDir } from 'fs-extra';
import { VanGenerator } from './generator';
@@ -17,7 +17,7 @@ async function run() {
const generator = new VanGenerator(name);
await generator.run();
} catch (e) {
consola.error(e);
logger.error(e);
}
}