react-nest-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
- package/packages/cli/src/configs/prompts.config.ts +8 -0
- package/packages/cli/src/configs/text.config.ts +9 -0
- package/packages/cli/src/index.ts +103 -0
- package/packages/templates/react-nest/package.json +20 -0
- package/packages/templates/react-nest-ts/package.json +12 -0
- package/pnpm-workspace.yaml +3 -0
- package/tsconfig.json +47 -0
- package/tsup.config.ts +10 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
## 项目介绍
|
|
2
|
+
|
|
3
|
+
一个脚手架工具,用于快速生成 react+nest 项目
|
|
4
|
+
|
|
5
|
+
使用脚手架 自动化生成项目、规范依赖管理、规范代码风格、代码质量控制、自动化测试、CI/CD 配置、提高开发效率。
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g react-nest-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 基本使用
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
react-nest init <project-name>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## 脚手架命令列表
|
|
22
|
+
init 初始化项目
|
|
23
|
+
version 展示版本信息
|
|
24
|
+
info 展示脚手架信息
|
|
25
|
+
help 展示帮助信息
|
|
26
|
+
|
|
27
|
+
## 项目命令列表
|
|
28
|
+
serve 启动项目
|
|
29
|
+
build 构建项目
|
|
30
|
+
preview 本地预览项目
|
|
31
|
+
lint 检查项目代码风格和质量
|
|
32
|
+
deploy 部署项目到指定环境,如测试环境、预发环境、生产环境等
|
|
33
|
+
test 运行测试用例
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// packages/cli/src/index.ts
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import picocolors from "picocolors";
|
|
4
|
+
import figlet from "figlet";
|
|
5
|
+
import prompts from "prompts";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
import ora from "ora";
|
|
8
|
+
import { downloadTemplate } from "giget";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import fsExtra from "fs-extra";
|
|
11
|
+
|
|
12
|
+
// packages/cli/src/configs/text.config.ts
|
|
13
|
+
var text_config_default = {
|
|
14
|
+
font: "Ghost",
|
|
15
|
+
horizontalLayout: "default",
|
|
16
|
+
verticalLayout: "default",
|
|
17
|
+
width: 200,
|
|
18
|
+
whitespaceBreak: true
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// packages/cli/src/configs/prompts.config.ts
|
|
22
|
+
var prompts_config_default = {
|
|
23
|
+
templates: [
|
|
24
|
+
{ title: "React + Nest", value: "react-nest", description: "\u8FD9\u4E2A\u6A21\u677F\u5305\u542B\u4E86 React + Nest \u9879\u76EE\u7684\u57FA\u672C\u914D\u7F6E", disabled: false },
|
|
25
|
+
{ title: "React + Nest + TypeScript", value: "react-nest-ts", description: "\u8FD9\u4E2A\u6A21\u677F\u5305\u542B\u4E86 React + Nest + TypeScript \u9879\u76EE\u7684\u57FA\u672C\u914D\u7F6E", disabled: false }
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// packages/cli/src/index.ts
|
|
30
|
+
var logInfo = () => {
|
|
31
|
+
console.info(picocolors.yellow(figlet.textSync("React Nest CLI", text_config_default)));
|
|
32
|
+
consola.start(picocolors.yellow(program.description()));
|
|
33
|
+
consola.info(picocolors.yellow(program.version()));
|
|
34
|
+
};
|
|
35
|
+
program.version("1.0.0", "-V, --version", "\u8F93\u51FA\u7248\u672C\u53F7").helpOption("-h, --help", "\u8F93\u51FA\u5E2E\u52A9\u4FE1\u606F").description("\u4E00\u4E2A\u811A\u624B\u67B6\u5DE5\u5177\uFF0C\u7528\u4E8E\u5FEB\u901F\u751F\u6210 React+Nest \u9879\u76EE").action(logInfo);
|
|
36
|
+
program.command("info").description("\u8F93\u51FA\u9879\u76EE\u4FE1\u606F").action(logInfo);
|
|
37
|
+
program.command("init").description("\u521D\u59CB\u5316\u9879\u76EE").argument("[project-name]", "\u9879\u76EE\u540D\u79F0").option("--template <template-name>", "\u9879\u76EE\u6A21\u677F\u540D\u79F0").action(async (projectName, rest) => {
|
|
38
|
+
let { template } = rest || {};
|
|
39
|
+
if (!projectName) {
|
|
40
|
+
const response = await prompts({
|
|
41
|
+
type: "text",
|
|
42
|
+
initial: "my-project",
|
|
43
|
+
// 默认值
|
|
44
|
+
name: "projectName",
|
|
45
|
+
message: "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0"
|
|
46
|
+
// validate: value => value.length ? true : '请输入项目名称'
|
|
47
|
+
});
|
|
48
|
+
projectName = response.projectName;
|
|
49
|
+
}
|
|
50
|
+
const noTemplate = template && !prompts_config_default.templates.find((item) => item.value === template);
|
|
51
|
+
if (!template || noTemplate) {
|
|
52
|
+
if (noTemplate) {
|
|
53
|
+
consola.error(`\u9879\u76EE\u6A21\u677F ${template} \u4E0D\u5B58\u5728, \u8BF7\u9009\u62E9\u5176\u4ED6\u6A21\u677F`);
|
|
54
|
+
}
|
|
55
|
+
const response = await prompts({
|
|
56
|
+
type: "select",
|
|
57
|
+
name: "template",
|
|
58
|
+
message: "\u8BF7\u9009\u62E9\u9879\u76EE\u6A21\u677F",
|
|
59
|
+
choices: prompts_config_default.templates,
|
|
60
|
+
initial: 0
|
|
61
|
+
// 默认选择第一个
|
|
62
|
+
});
|
|
63
|
+
template = response.template;
|
|
64
|
+
}
|
|
65
|
+
const tip = `\u521D\u59CB\u5316\u9879\u76EE ${projectName}\uFF0C\u6A21\u677F ${template}`;
|
|
66
|
+
const spinner = ora({
|
|
67
|
+
text: tip,
|
|
68
|
+
color: "blue"
|
|
69
|
+
// spinner: 'growVertical',
|
|
70
|
+
// isEnabled: false
|
|
71
|
+
});
|
|
72
|
+
spinner.start();
|
|
73
|
+
const projectDir = path.resolve(import.meta.dirname, projectName);
|
|
74
|
+
if (fsExtra.existsSync(projectDir)) {
|
|
75
|
+
spinner.fail(`\u{1F4A5}\u521D\u59CB\u5316\u5931\u8D25: \u9879\u76EE\u76EE\u5F55 ${projectName} \u5DF2\u5B58\u5728`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const res = await downloadTemplate(`github:liaolonghui/react-nest-cli/packages/templates/${template}#main`, {
|
|
79
|
+
dir: projectDir
|
|
80
|
+
});
|
|
81
|
+
const { dir } = res;
|
|
82
|
+
spinner.succeed(`\u9879\u76EE\u521D\u59CB\u5316\u6210\u529F\uFF0C\u9879\u76EE\u76EE\u5F55\uFF1A${dir}`);
|
|
83
|
+
});
|
|
84
|
+
program.command("version").description("\u8F93\u51FA\u7248\u672C\u53F7").action(() => {
|
|
85
|
+
consola.info(figlet.textSync(`version ==> ${program.version()}`, text_config_default));
|
|
86
|
+
});
|
|
87
|
+
program.parse();
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../packages/cli/src/index.ts","../packages/cli/src/configs/text.config.ts","../packages/cli/src/configs/prompts.config.ts"],"sourcesContent":["import { program } from \"commander\";\nimport picocolors from \"picocolors\"; // 也可用chalk\nimport figlet from 'figlet';\nimport prompts from 'prompts'; // 也可用inquirer、手动readline等\nimport consola from \"consola\";\nimport ora from 'ora';\nimport { downloadTemplate } from 'giget';\nimport path from 'node:path';\nimport fsExtra from 'fs-extra';\nimport textConfig from './configs/text.config.ts';\nimport promptsConfig from \"./configs/prompts.config.ts\";\n\n\n// 输出项目信息\nconst logInfo = () => {\n console.info(picocolors.yellow(figlet.textSync('React Nest CLI', textConfig)))\n consola.start(picocolors.yellow(program.description()))\n consola.info(picocolors.yellow(program.version()))\n}\n\n\nprogram\n .version(\"1.0.0\", '-V, --version', '输出版本号')\n .helpOption('-h, --help', '输出帮助信息')\n // .help((str) => '帮助信息:\\n' + str)\n .description(\"一个脚手架工具,用于快速生成 React+Nest 项目\")\n .action(logInfo);\n\n// 输出项目信息\nprogram\n .command('info')\n .description('输出项目信息')\n .action(logInfo);\n\n// 初始化项目\nprogram\n .command('init')\n .description('初始化项目')\n .argument('[project-name]', '项目名称')\n .option('--template <template-name>', '项目模板名称')\n .action(async (projectName, rest) => {\n let { template } = rest || {};\n // 如果projectName没有提供,让用户输入\n if (!projectName) {\n const response = await prompts({\n type: 'text',\n initial: 'my-project', // 默认值\n name: 'projectName',\n message: '请输入项目名称',\n // validate: value => value.length ? true : '请输入项目名称'\n });\n projectName = response.projectName;\n }\n\n // 如果template没有提供或者template不存在,让用户选择\n const noTemplate = (template && !promptsConfig.templates.find(item => item.value === template));\n if (!template || noTemplate) {\n if (noTemplate) {\n consola.error(`项目模板 ${template} 不存在, 请选择其他模板`);\n }\n const response = await prompts({\n type: 'select',\n name: 'template',\n message: '请选择项目模板',\n choices: promptsConfig.templates,\n initial: 0, // 默认选择第一个\n });\n template = response.template;\n }\n\n const tip = `初始化项目 ${projectName},模板 ${template}`;\n const spinner = ora({\n text: tip,\n color: 'blue',\n // spinner: 'growVertical',\n // isEnabled: false\n });\n spinner.start();\n\n const projectDir = path.resolve(import.meta.dirname, projectName);\n if (fsExtra.existsSync(projectDir)) {\n spinner.fail(`💥初始化失败: 项目目录 ${projectName} 已存在`);\n return;\n }\n\n const res = await downloadTemplate(`github:liaolonghui/react-nest-cli/packages/templates/${template}#main`, {\n dir: projectDir,\n });\n const { dir } = res;\n spinner.succeed(`项目初始化成功,项目目录:${dir}`);\n // console.log(res);\n\n });\n\n// 输出版本号\nprogram.command('version')\n .description('输出版本号')\n .action(() => {\n // 全局option -V, --version 已被注册,这里无需再注册version命令,只是为了演示\n consola.info(figlet.textSync(`version ==> ${program.version()}`, textConfig));\n });\n\nprogram.parse();","import type { FigletOptions } from \"figlet\";\n\nexport default {\n font: \"Ghost\",\n horizontalLayout: \"default\",\n verticalLayout: \"default\",\n width: 200,\n whitespaceBreak: true,\n} as FigletOptions","\n\nexport default {\n templates: [\n { title: 'React + Nest', value: 'react-nest', description: '这个模板包含了 React + Nest 项目的基本配置', disabled: false },\n { title: 'React + Nest + TypeScript', value: 'react-nest-ts', description: '这个模板包含了 React + Nest + TypeScript 项目的基本配置', disabled: false },\n ]\n}"],"mappings":";AAAA,SAAS,eAAe;AACxB,OAAO,gBAAgB;AACvB,OAAO,YAAY;AACnB,OAAO,aAAa;AACpB,OAAO,aAAa;AACpB,OAAO,SAAS;AAChB,SAAS,wBAAwB;AACjC,OAAO,UAAU;AACjB,OAAO,aAAa;;;ACNpB,IAAO,sBAAQ;AAAA,EACX,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,iBAAiB;AACrB;;;ACNA,IAAO,yBAAQ;AAAA,EACX,WAAW;AAAA,IACP,EAAE,OAAO,gBAAgB,OAAO,cAAc,aAAa,sGAAgC,UAAU,MAAM;AAAA,IAC3G,EAAE,OAAO,6BAA6B,OAAO,iBAAiB,aAAa,mHAA6C,UAAU,MAAM;AAAA,EAC5I;AACJ;;;AFOA,IAAM,UAAU,MAAM;AAClB,UAAQ,KAAK,WAAW,OAAO,OAAO,SAAS,kBAAkB,mBAAU,CAAC,CAAC;AAC7E,UAAQ,MAAM,WAAW,OAAO,QAAQ,YAAY,CAAC,CAAC;AACtD,UAAQ,KAAK,WAAW,OAAO,QAAQ,QAAQ,CAAC,CAAC;AACrD;AAGA,QACK,QAAQ,SAAS,iBAAiB,gCAAO,EACzC,WAAW,cAAc,sCAAQ,EAEjC,YAAY,8GAA8B,EAC1C,OAAO,OAAO;AAGnB,QACK,QAAQ,MAAM,EACd,YAAY,sCAAQ,EACpB,OAAO,OAAO;AAGnB,QACK,QAAQ,MAAM,EACd,YAAY,gCAAO,EACnB,SAAS,kBAAkB,0BAAM,EACjC,OAAO,8BAA8B,sCAAQ,EAC7C,OAAO,OAAO,aAAa,SAAS;AACjC,MAAI,EAAE,SAAS,IAAI,QAAQ,CAAC;AAE5B,MAAI,CAAC,aAAa;AACd,UAAM,WAAW,MAAM,QAAQ;AAAA,MAC3B,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEb,CAAC;AACD,kBAAc,SAAS;AAAA,EAC3B;AAGA,QAAM,aAAc,YAAY,CAAC,uBAAc,UAAU,KAAK,UAAQ,KAAK,UAAU,QAAQ;AAC7F,MAAI,CAAC,YAAY,YAAY;AACzB,QAAI,YAAY;AACZ,cAAQ,MAAM,4BAAQ,QAAQ,iEAAe;AAAA,IACjD;AACA,UAAM,WAAW,MAAM,QAAQ;AAAA,MAC3B,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,uBAAc;AAAA,MACvB,SAAS;AAAA;AAAA,IACb,CAAC;AACD,eAAW,SAAS;AAAA,EACxB;AAEA,QAAM,MAAM,kCAAS,WAAW,sBAAO,QAAQ;AAC/C,QAAM,UAAU,IAAI;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA,EAGX,CAAC;AACD,UAAQ,MAAM;AAEd,QAAM,aAAa,KAAK,QAAQ,YAAY,SAAS,WAAW;AAChE,MAAI,QAAQ,WAAW,UAAU,GAAG;AAChC,YAAQ,KAAK,qEAAiB,WAAW,qBAAM;AAC/C;AAAA,EACJ;AAEA,QAAM,MAAM,MAAM,iBAAiB,wDAAwD,QAAQ,SAAS;AAAA,IACxG,KAAK;AAAA,EACT,CAAC;AACD,QAAM,EAAE,IAAI,IAAI;AAChB,UAAQ,QAAQ,iFAAgB,GAAG,EAAE;AAGzC,CAAC;AAGL,QAAQ,QAAQ,SAAS,EACpB,YAAY,gCAAO,EACnB,OAAO,MAAM;AAEV,UAAQ,KAAK,OAAO,SAAS,eAAe,QAAQ,QAAQ,CAAC,IAAI,mBAAU,CAAC;AAChF,CAAC;AAEL,QAAQ,MAAM;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-nest-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "一个脚手架工具,用于快速生成 react+nest 项目",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"react-nest": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsup",
|
|
12
|
+
"start": "ts-node ./packages/cli/src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"nest",
|
|
17
|
+
"脚手架"
|
|
18
|
+
],
|
|
19
|
+
"author": "liaolonghui",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"commander": "^14.0.3",
|
|
23
|
+
"consola": "^3.4.2",
|
|
24
|
+
"figlet": "^1.10.0",
|
|
25
|
+
"fs-extra": "^11.3.3",
|
|
26
|
+
"giget": "^3.1.2",
|
|
27
|
+
"ora": "^9.3.0",
|
|
28
|
+
"picocolors": "^1.1.1",
|
|
29
|
+
"prompts": "^2.4.2",
|
|
30
|
+
"tsup": "^8.5.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/fs-extra": "^11.0.4",
|
|
34
|
+
"@types/node": "^25.2.1",
|
|
35
|
+
"@types/prompts": "^2.4.9",
|
|
36
|
+
"ts-node": "^10.9.2",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
templates: [
|
|
5
|
+
{ title: 'React + Nest', value: 'react-nest', description: '这个模板包含了 React + Nest 项目的基本配置', disabled: false },
|
|
6
|
+
{ title: 'React + Nest + TypeScript', value: 'react-nest-ts', description: '这个模板包含了 React + Nest + TypeScript 项目的基本配置', disabled: false },
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { program } from "commander";
|
|
2
|
+
import picocolors from "picocolors"; // 也可用chalk
|
|
3
|
+
import figlet from 'figlet';
|
|
4
|
+
import prompts from 'prompts'; // 也可用inquirer、手动readline等
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import { downloadTemplate } from 'giget';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import fsExtra from 'fs-extra';
|
|
10
|
+
import textConfig from './configs/text.config.ts';
|
|
11
|
+
import promptsConfig from "./configs/prompts.config.ts";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// 输出项目信息
|
|
15
|
+
const logInfo = () => {
|
|
16
|
+
console.info(picocolors.yellow(figlet.textSync('React Nest CLI', textConfig)))
|
|
17
|
+
consola.start(picocolors.yellow(program.description()))
|
|
18
|
+
consola.info(picocolors.yellow(program.version()))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.version("1.0.0", '-V, --version', '输出版本号')
|
|
24
|
+
.helpOption('-h, --help', '输出帮助信息')
|
|
25
|
+
// .help((str) => '帮助信息:\n' + str)
|
|
26
|
+
.description("一个脚手架工具,用于快速生成 React+Nest 项目")
|
|
27
|
+
.action(logInfo);
|
|
28
|
+
|
|
29
|
+
// 输出项目信息
|
|
30
|
+
program
|
|
31
|
+
.command('info')
|
|
32
|
+
.description('输出项目信息')
|
|
33
|
+
.action(logInfo);
|
|
34
|
+
|
|
35
|
+
// 初始化项目
|
|
36
|
+
program
|
|
37
|
+
.command('init')
|
|
38
|
+
.description('初始化项目')
|
|
39
|
+
.argument('[project-name]', '项目名称')
|
|
40
|
+
.option('--template <template-name>', '项目模板名称')
|
|
41
|
+
.action(async (projectName, rest) => {
|
|
42
|
+
let { template } = rest || {};
|
|
43
|
+
// 如果projectName没有提供,让用户输入
|
|
44
|
+
if (!projectName) {
|
|
45
|
+
const response = await prompts({
|
|
46
|
+
type: 'text',
|
|
47
|
+
initial: 'my-project', // 默认值
|
|
48
|
+
name: 'projectName',
|
|
49
|
+
message: '请输入项目名称',
|
|
50
|
+
// validate: value => value.length ? true : '请输入项目名称'
|
|
51
|
+
});
|
|
52
|
+
projectName = response.projectName;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 如果template没有提供或者template不存在,让用户选择
|
|
56
|
+
const noTemplate = (template && !promptsConfig.templates.find(item => item.value === template));
|
|
57
|
+
if (!template || noTemplate) {
|
|
58
|
+
if (noTemplate) {
|
|
59
|
+
consola.error(`项目模板 ${template} 不存在, 请选择其他模板`);
|
|
60
|
+
}
|
|
61
|
+
const response = await prompts({
|
|
62
|
+
type: 'select',
|
|
63
|
+
name: 'template',
|
|
64
|
+
message: '请选择项目模板',
|
|
65
|
+
choices: promptsConfig.templates,
|
|
66
|
+
initial: 0, // 默认选择第一个
|
|
67
|
+
});
|
|
68
|
+
template = response.template;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const tip = `初始化项目 ${projectName},模板 ${template}`;
|
|
72
|
+
const spinner = ora({
|
|
73
|
+
text: tip,
|
|
74
|
+
color: 'blue',
|
|
75
|
+
// spinner: 'growVertical',
|
|
76
|
+
// isEnabled: false
|
|
77
|
+
});
|
|
78
|
+
spinner.start();
|
|
79
|
+
|
|
80
|
+
const projectDir = path.resolve(import.meta.dirname, projectName);
|
|
81
|
+
if (fsExtra.existsSync(projectDir)) {
|
|
82
|
+
spinner.fail(`💥初始化失败: 项目目录 ${projectName} 已存在`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const res = await downloadTemplate(`github:liaolonghui/react-nest-cli/packages/templates/${template}#main`, {
|
|
87
|
+
dir: projectDir,
|
|
88
|
+
});
|
|
89
|
+
const { dir } = res;
|
|
90
|
+
spinner.succeed(`项目初始化成功,项目目录:${dir}`);
|
|
91
|
+
// console.log(res);
|
|
92
|
+
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// 输出版本号
|
|
96
|
+
program.command('version')
|
|
97
|
+
.description('输出版本号')
|
|
98
|
+
.action(() => {
|
|
99
|
+
// 全局option -V, --version 已被注册,这里无需再注册version命令,只是为了演示
|
|
100
|
+
consola.info(figlet.textSync(`version ==> ${program.version()}`, textConfig));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
program.parse();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-nest",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/liaolonghui/react-nest-cli.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/liaolonghui/react-nest-cli/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/liaolonghui/react-nest-cli#readme"
|
|
20
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
// "rootDir": "./src",
|
|
6
|
+
// "outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
// For nodejs:
|
|
13
|
+
"lib": ["esnext"],
|
|
14
|
+
"types": ["node"],
|
|
15
|
+
// and npm install -D @types/node
|
|
16
|
+
|
|
17
|
+
"emitDeclarationOnly": true,
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// Other Outputs
|
|
22
|
+
"sourceMap": true,
|
|
23
|
+
"declaration": true,
|
|
24
|
+
"declarationMap": true,
|
|
25
|
+
|
|
26
|
+
// Stricter Typechecking Options
|
|
27
|
+
"noUncheckedIndexedAccess": true,
|
|
28
|
+
"exactOptionalPropertyTypes": true,
|
|
29
|
+
|
|
30
|
+
// Style Options
|
|
31
|
+
// "noImplicitReturns": true,
|
|
32
|
+
// "noImplicitOverride": true,
|
|
33
|
+
// "noUnusedLocals": true,
|
|
34
|
+
// "noUnusedParameters": true,
|
|
35
|
+
// "noFallthroughCasesInSwitch": true,
|
|
36
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
37
|
+
|
|
38
|
+
// Recommended Options
|
|
39
|
+
"strict": true,
|
|
40
|
+
"jsx": "react-jsx",
|
|
41
|
+
"verbatimModuleSyntax": true,
|
|
42
|
+
"isolatedModules": true,
|
|
43
|
+
"noUncheckedSideEffectImports": true,
|
|
44
|
+
"moduleDetection": "force",
|
|
45
|
+
"skipLibCheck": true,
|
|
46
|
+
}
|
|
47
|
+
}
|