✨ 更新cli
- 更改注释 - 去除对api的依赖 - 增加可见性控制 - 更改为初始化时赋值
This commit is contained in:
parent
d1ef50c3c2
commit
c5298edeaf
@ -1,31 +1,31 @@
|
||||
import { Command } from "./api";
|
||||
import prompts from "prompts";
|
||||
import { file as fs } from "./file";
|
||||
import ejs from "ejs";
|
||||
import { join, resolve, sep } from "path";
|
||||
|
||||
abstract class Cli {
|
||||
|
||||
|
||||
abstract class Cli implements Command{
|
||||
protected RUN: string = join(resolve(process.cwd()), sep);
|
||||
protected answers: {} | null = null;
|
||||
private dir = join(resolve(__dirname));
|
||||
protected PATH: string = this.dir.substring(0, this.dir.lastIndexOf("extend"));
|
||||
protected TPL: string = join(this.PATH, "template/");
|
||||
protected RUN: string; // RUN: 项目初始化目录
|
||||
private dir: string; // dir: 项目运行目录
|
||||
protected PATH: string; // PATH: 项目根目录
|
||||
protected TPL: string; // TPL: 模板目录
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @protected
|
||||
*/
|
||||
protected constructor() {
|
||||
this.run().then().catch(err => console.log(err));
|
||||
this.RUN = join(resolve(process.cwd()), sep);
|
||||
let dir = this.dir = join(resolve(__dirname));
|
||||
let path = this.PATH = this.dir.substring(0, dir.lastIndexOf("extend"));
|
||||
this.TPL = join(path, "template/");
|
||||
|
||||
this.run().catch(err => console.log(err));
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* 自动指令中枢:
|
||||
* @description 自动调用 CLI 过程中的5大阶段
|
||||
*/
|
||||
async run() {
|
||||
private async run() {
|
||||
await this.Initialize();
|
||||
await this.Prompting();
|
||||
await this.Writing();
|
||||
@ -33,23 +33,22 @@ abstract class Cli implements Command{
|
||||
await this.Ending();
|
||||
}
|
||||
|
||||
Initialize() {
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
// 5 大阶段
|
||||
protected Initialize() {}
|
||||
|
||||
Prompting() {
|
||||
}
|
||||
protected Prompting() {}
|
||||
|
||||
Writing() {
|
||||
}
|
||||
protected Writing() {}
|
||||
|
||||
Installing() {
|
||||
}
|
||||
protected Installing() {}
|
||||
|
||||
protected Ending() {}
|
||||
|
||||
// 5 大阶段
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Ending() {
|
||||
}
|
||||
|
||||
// TODO: Copy Files
|
||||
// PATH: 当前项目绝对路径
|
||||
protected easyCopy(file: string) {
|
||||
// @ts-ignore
|
||||
return fs.copy(join(this.TPL, file), join(this.RUN, this.answers.appName, file));
|
||||
|
Loading…
Reference in New Issue
Block a user