Skip to content

Commit 0c65093

Browse files
committed
✨refactor(core): 更新文档&精简命令
1 parent a613d5a commit 0c65093

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ npm i -g code-genius
1818

1919
## 终端命令
2020

21-
| 命令 | 参数 | 默认值 | 功能描述 |
22-
| -------- | --------------------- | --------- | --------------------------------------------------- |
23-
| commit | --no-emoji | true | 生成 angualr 规范的提交信息 |
24-
| verify | -- | -- | 校验 COMMIT_EDITMSG 中的信息是否符合 Angualr 规范 |
25-
| clear | --pattern \<pattern\> | './dist/' | 运行 rimraf 删除不再需要的文件或文件夹 |
26-
| hooks | -- | -- | 新增或修改 simple-git-hooks 配置后需要重新初始化 |
27-
| run | -- | -- | 列出可以运行的全部脚本 |
28-
| fix | --pattern \<pattern\> | './src' | 运行 eslint 静态扫描和修复代码中存在的问题 |
29-
| format | --pattern \<pattern\> | ./src' | 运行 prettier 格式化代码风格 |
30-
| depcheck | -- | -- | 运行 npm-check 检查过时的、不正确的和未使用的依赖项 |
31-
| registry | -- | -- | 切换 NPM 镜像地址 |
21+
| 命令 | 参数 | 默认值 | 功能描述 |
22+
| -------- | ------------------------------------------------------------------- | --------- | --------------------------------------------------- |
23+
| commit | --no-emoji | true | 生成 angualr 规范的提交信息 |
24+
| verify | -- | -- | 校验 COMMIT_EDITMSG 中的信息是否符合 Angualr 规范 |
25+
| clear | --pattern \<pattern\> | './dist/' | 运行 rimraf 删除不再需要的文件或文件夹 |
26+
| hooks | -- | -- | 新增或修改 simple-git-hooks 配置后需要重新初始化 |
27+
| depcheck | -- | -- | 运行 npm-check 检查过时的、不正确的和未使用的依赖项 |
28+
| run | -- | -- | 列出可以运行的全部脚本 |
29+
| registry | -- | -- | 切换 NPM 镜像地址 |
30+
| fix | --pattern \<pattern\> | './src' | 运行 eslint 静态扫描和修复代码中存在的问题 |
31+
| format | --pattern \<pattern\> | ./src' | 运行 prettier 格式化代码风格 |
32+
| create | -- | -- | 运行 npm create 快速创建基础项目 |
33+
| template | -n, --project-name \<project-name\>, -f, --framework \<framework\>, | -- | 快速创建 CodeGenius 基础项目 |
3234

3335
## 执照
3436

src/command/create-project.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export const createProject = async (sources: ProjectSource[]) => {
1616
console.table(sources);
1717
}
1818

19-
const sourceChoices = sources.map(({ name, description }) => {
20-
const formatName = `${name}:`.padEnd(15);
19+
const sourceChoices = sources.map(({ name, display, description }) => {
20+
const formatDisplay = `${display}:`.padEnd(20);
2121
return {
2222
name: name,
23-
message: `${formatName}${description}`,
23+
message: `${formatDisplay}${description}`,
2424
};
2525
});
2626

@@ -32,8 +32,9 @@ export const createProject = async (sources: ProjectSource[]) => {
3232
choices: sourceChoices,
3333
},
3434
]);
35+
const commands = result.command.split(" ");
3536

36-
await execCommand("npm", ["create", result.command], {
37+
await execCommand(commands[0], [...commands.slice(1)], {
3738
stdio: "inherit",
3839
});
3940
};

src/setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export function cmdInstaller(cli: CAC) {
2222
npmRegistryInstaller(cli).setup();
2323
eslintFixInstaller(cli).setup();
2424
prettierFormatInstaller(cli).setup();
25-
clearInstaller(cli).setup();
2625
createProjectInstaller(cli).setup();
2726
templateInstaller(cli).setup();
2827
}

src/shared/config.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,23 @@ export const npmRegisters: Array<KeyValue> = [
133133

134134
export const projectSources: Array<ProjectSource> = [
135135
{
136-
name: "vite@latest",
136+
name: "npx code-genius template",
137+
display: "code-genius",
138+
description: "创建由 CodeGenius 内置的新的项目",
139+
},
140+
{
141+
name: "npm create vite@latest",
142+
display: "vite@latest",
137143
description: "创建由 Vite 驱动的新的项目",
138144
},
139145
{
140-
name: "vue@latest",
146+
name: "npm create vue@latest",
147+
display: "vue@latest",
141148
description: "创建由 Vite 驱动的 Vue3 项目",
142149
},
143150
{
144-
name: "vue@legacy",
151+
name: "npm create vue@legacy",
152+
display: "vue@legacy",
145153
description: "创建由 Vite 驱动的 Vue2 项目(支持 IE11)",
146154
},
147155
];

src/shared/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface KeyValue {
2222

2323
export interface ProjectSource {
2424
name: string;
25+
display: string;
2526
description: string;
2627
}
2728

0 commit comments

Comments
 (0)