react-nest-cli 1.0.4 → 1.0.5
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/apps/components/Button/index.css +9 -0
- package/apps/components/Button/index.jsx +12 -0
- package/apps/components/Button/index.less +10 -0
- package/apps/components/Button/index.tsx +21 -0
- package/apps/components/Card/index.css +10 -0
- package/apps/components/Card/index.jsx +11 -0
- package/apps/components/Card/index.less +9 -0
- package/apps/components/Card/index.tsx +20 -0
- package/cspell.config.ts +1 -1
- package/package.json +7 -3
- package/packages/cli/dist/chunk-2LOTRMC6.js +24 -0
- package/packages/cli/dist/chunk-2LOTRMC6.js.map +1 -0
- package/packages/cli/dist/chunk-6IS4OKS7.js +69 -0
- package/packages/cli/dist/chunk-6IS4OKS7.js.map +1 -0
- package/packages/cli/dist/chunk-B7N5IJK6.js +120 -0
- package/packages/cli/dist/chunk-B7N5IJK6.js.map +1 -0
- package/packages/cli/dist/chunk-K5MQOF6Z.js +12 -0
- package/packages/cli/dist/chunk-K5MQOF6Z.js.map +1 -0
- package/packages/cli/dist/chunk-NCNZGYLV.js +13 -0
- package/packages/cli/dist/chunk-NCNZGYLV.js.map +1 -0
- package/packages/cli/dist/chunk-PMB2T2TP.js +13 -0
- package/packages/cli/dist/chunk-PMB2T2TP.js.map +1 -0
- package/packages/cli/dist/chunk-YUGLQSSS.js +19 -0
- package/packages/cli/dist/chunk-YUGLQSSS.js.map +1 -0
- package/packages/cli/dist/commands/base/info.d.ts +6 -0
- package/packages/cli/dist/commands/base/info.js +10 -0
- package/packages/cli/dist/commands/base/info.js.map +1 -0
- package/packages/cli/dist/commands/base/init.d.ts +5 -0
- package/packages/cli/dist/commands/base/init.js +8 -0
- package/packages/cli/dist/commands/base/init.js.map +1 -0
- package/packages/cli/dist/commands/base/initComponent.d.ts +5 -0
- package/packages/cli/dist/commands/base/initComponent.js +7 -0
- package/packages/cli/dist/commands/base/initComponent.js.map +1 -0
- package/packages/cli/dist/commands/base/version.d.ts +5 -0
- package/packages/cli/dist/commands/base/version.js +8 -0
- package/packages/cli/dist/commands/base/version.js.map +1 -0
- package/packages/cli/dist/commands/baseRegisterCommands.d.ts +7 -0
- package/packages/cli/dist/commands/baseRegisterCommands.js +7 -0
- package/packages/cli/dist/commands/baseRegisterCommands.js.map +1 -0
- package/packages/cli/dist/configs/prompts.config.d.ts +10 -0
- package/packages/cli/dist/configs/prompts.config.js +7 -0
- package/packages/cli/dist/configs/prompts.config.js.map +1 -0
- package/packages/cli/dist/configs/text.config.d.ts +5 -0
- package/packages/cli/dist/configs/text.config.js +7 -0
- package/packages/cli/dist/configs/text.config.js.map +1 -0
- package/packages/cli/dist/index.js +21 -118
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/commands/base/init.ts +0 -1
- package/packages/cli/src/commands/base/initComponent.ts +174 -0
- package/packages/cli/src/configs/prompts.config.ts +21 -6
- package/packages/cli/src/index.ts +4 -1
- package/packages/templates/react-nest/index.css +7 -0
- package/packages/templates/vue-template/vue +0 -0
- package/pnpm-workspace.yaml +2 -2
- package/stylelint.config.mjs +17 -0
- package/tsconfig.json +40 -39
- package/tsup.config.ts +4 -3
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
baseRegisterCommands_default
|
|
4
|
+
} from "./chunk-K5MQOF6Z.js";
|
|
5
|
+
import {
|
|
6
|
+
info,
|
|
7
|
+
logInfo
|
|
8
|
+
} from "./chunk-2LOTRMC6.js";
|
|
9
|
+
import {
|
|
10
|
+
init
|
|
11
|
+
} from "./chunk-6IS4OKS7.js";
|
|
12
|
+
import "./chunk-PMB2T2TP.js";
|
|
13
|
+
import {
|
|
14
|
+
initComponent_default
|
|
15
|
+
} from "./chunk-B7N5IJK6.js";
|
|
16
|
+
import {
|
|
17
|
+
version
|
|
18
|
+
} from "./chunk-YUGLQSSS.js";
|
|
19
|
+
import "./chunk-NCNZGYLV.js";
|
|
2
20
|
|
|
3
21
|
// packages/cli/src/index.ts
|
|
4
22
|
import { program } from "commander";
|
|
@@ -6,7 +24,7 @@ import { program } from "commander";
|
|
|
6
24
|
// packages/cli/package.json
|
|
7
25
|
var package_default = {
|
|
8
26
|
name: "@react-nest/cli",
|
|
9
|
-
version: "1.0.
|
|
27
|
+
version: "1.0.5",
|
|
10
28
|
description: "\u4E00\u4E2A\u811A\u624B\u67B6\u5DE5\u5177\uFF0C\u7528\u4E8E\u5FEB\u901F\u751F\u6210 react+nest \u9879\u76EE",
|
|
11
29
|
main: "index.js",
|
|
12
30
|
type: "module",
|
|
@@ -18,127 +36,12 @@ var package_default = {
|
|
|
18
36
|
license: "ISC"
|
|
19
37
|
};
|
|
20
38
|
|
|
21
|
-
// packages/cli/src/commands/baseRegisterCommands.ts
|
|
22
|
-
function baseRegisterCommands(program2) {
|
|
23
|
-
return function registerCommand2(fn) {
|
|
24
|
-
fn(program2);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
var baseRegisterCommands_default = baseRegisterCommands;
|
|
28
|
-
|
|
29
|
-
// packages/cli/src/commands/base/info.ts
|
|
30
|
-
import consola from "consola";
|
|
31
|
-
import figlet from "figlet";
|
|
32
|
-
import picocolors from "picocolors";
|
|
33
|
-
|
|
34
|
-
// packages/cli/src/configs/text.config.ts
|
|
35
|
-
var text_config_default = {
|
|
36
|
-
font: "Ghost",
|
|
37
|
-
horizontalLayout: "default",
|
|
38
|
-
verticalLayout: "default",
|
|
39
|
-
width: 200,
|
|
40
|
-
whitespaceBreak: true
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// packages/cli/src/commands/base/info.ts
|
|
44
|
-
var logInfo = (program2) => {
|
|
45
|
-
console.log(
|
|
46
|
-
picocolors.yellow(figlet.textSync("React Nest CLI", text_config_default))
|
|
47
|
-
);
|
|
48
|
-
consola.start(picocolors.yellow(program2.description()));
|
|
49
|
-
consola.info(picocolors.yellow(program2.version()));
|
|
50
|
-
};
|
|
51
|
-
function info(program2) {
|
|
52
|
-
program2.command("info").description("\u8F93\u51FA\u9879\u76EE\u4FE1\u606F").action(() => logInfo(program2));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// packages/cli/src/commands/base/version.ts
|
|
56
|
-
import consola2 from "consola";
|
|
57
|
-
import figlet2 from "figlet";
|
|
58
|
-
function version(program2) {
|
|
59
|
-
program2.command("version").description("\u8F93\u51FA\u7248\u672C\u53F7").action(() => {
|
|
60
|
-
consola2.info(
|
|
61
|
-
figlet2.textSync(`version ==> ${program2.version()}`, text_config_default)
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// packages/cli/src/commands/base/init.ts
|
|
67
|
-
import prompts from "prompts";
|
|
68
|
-
|
|
69
|
-
// packages/cli/src/configs/prompts.config.ts
|
|
70
|
-
var prompts_config_default = {
|
|
71
|
-
templates: [
|
|
72
|
-
{ 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 },
|
|
73
|
-
{ 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 }
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// packages/cli/src/commands/base/init.ts
|
|
78
|
-
import consola3 from "consola";
|
|
79
|
-
import fsExtra from "fs-extra";
|
|
80
|
-
import path from "path";
|
|
81
|
-
import { cwd } from "process";
|
|
82
|
-
import { downloadTemplate } from "giget";
|
|
83
|
-
import ora from "ora";
|
|
84
|
-
function init(program2) {
|
|
85
|
-
program2.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) => {
|
|
86
|
-
let { template } = rest || {};
|
|
87
|
-
if (!projectName) {
|
|
88
|
-
const response = await prompts({
|
|
89
|
-
type: "text",
|
|
90
|
-
initial: "my-project",
|
|
91
|
-
// 默认值
|
|
92
|
-
name: "projectName",
|
|
93
|
-
message: "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0"
|
|
94
|
-
// validate: value => value.length ? true : '请输入项目名称'
|
|
95
|
-
});
|
|
96
|
-
projectName = response.projectName;
|
|
97
|
-
}
|
|
98
|
-
const noTemplate = template && !prompts_config_default.templates.find((item) => item.value === template);
|
|
99
|
-
if (!template || noTemplate) {
|
|
100
|
-
if (noTemplate) {
|
|
101
|
-
consola3.error(`\u9879\u76EE\u6A21\u677F ${template} \u4E0D\u5B58\u5728, \u8BF7\u9009\u62E9\u5176\u4ED6\u6A21\u677F`);
|
|
102
|
-
}
|
|
103
|
-
const response = await prompts({
|
|
104
|
-
type: "select",
|
|
105
|
-
name: "template",
|
|
106
|
-
message: "\u8BF7\u9009\u62E9\u9879\u76EE\u6A21\u677F",
|
|
107
|
-
choices: prompts_config_default.templates,
|
|
108
|
-
initial: 0
|
|
109
|
-
// 默认选择第一个
|
|
110
|
-
});
|
|
111
|
-
template = response.template;
|
|
112
|
-
}
|
|
113
|
-
const tip = `\u521D\u59CB\u5316\u9879\u76EE ${projectName}\uFF0C\u6A21\u677F ${template}`;
|
|
114
|
-
const spinner = ora({
|
|
115
|
-
text: tip,
|
|
116
|
-
color: "blue"
|
|
117
|
-
// spinner: 'growVertical',
|
|
118
|
-
// isEnabled: false
|
|
119
|
-
});
|
|
120
|
-
spinner.start();
|
|
121
|
-
const projectDir = path.resolve(cwd(), projectName);
|
|
122
|
-
if (fsExtra.existsSync(projectDir)) {
|
|
123
|
-
spinner.fail(`\u{1F4A5}\u521D\u59CB\u5316\u5931\u8D25: \u9879\u76EE\u76EE\u5F55 ${projectName} \u5DF2\u5B58\u5728`);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const res = await downloadTemplate(
|
|
127
|
-
`github:liaolonghui/react-nest-cli/packages/templates/${template}#main`,
|
|
128
|
-
{
|
|
129
|
-
dir: projectDir
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
const { dir } = res;
|
|
133
|
-
spinner.succeed(`\u9879\u76EE\u521D\u59CB\u5316\u6210\u529F\uFF0C\u9879\u76EE\u76EE\u5F55\uFF1A${dir}`);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
39
|
// packages/cli/src/index.ts
|
|
138
40
|
program.version(package_default.version, "-V, --version", "\u8F93\u51FA\u7248\u672C\u53F7").helpOption("-h, --help", "\u8F93\u51FA\u5E2E\u52A9\u4FE1\u606F").description(package_default.description).action(() => logInfo(program));
|
|
139
41
|
var registerCommand = baseRegisterCommands_default(program);
|
|
140
42
|
registerCommand(info);
|
|
141
43
|
registerCommand(init);
|
|
44
|
+
registerCommand(initComponent_default);
|
|
142
45
|
registerCommand(version);
|
|
143
|
-
program.parse();
|
|
46
|
+
program.parse(process.argv);
|
|
144
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\nimport { program } from 'commander'\nimport packageJson from '../package.json' with { type: 'json' }\nimport baseRegisterCommands from './commands/baseRegisterCommands.ts'\nimport info, { logInfo } from './commands/base/info.ts'\nimport version from './commands/base/version.ts'\nimport init from './commands/base/init.ts'\nimport initComponent from './commands/base/initComponent.ts'\n\n// import.meta.dirname 指向当前文件所在目录\n// process.cwd() 指向当前工作目录 (实际运行时目录,不是当前文件所在目录)\n// const cwd = process.cwd();\n// const dirname = import.meta.dirname;\n\nprogram\n .version(packageJson.version, '-V, --version', '输出版本号')\n .helpOption('-h, --help', '输出帮助信息')\n // .help((str) => '帮助信息:\\n' + str)\n .description(packageJson.description)\n .action(() => logInfo(program))\n\nconst registerCommand = baseRegisterCommands(program)\n// 注册info命令\nregisterCommand(info)\n// 初始化项目命令\nregisterCommand(init)\n// 初始化组件命令\nregisterCommand(initComponent)\n// 输出版本号命令\nregisterCommand(version)\n\nprogram.parse(process.argv)\n","{\n \"name\": \"@react-nest/cli\",\n \"version\": \"1.0.5\",\n \"description\": \"一个脚手架工具,用于快速生成 react+nest 项目\",\n \"main\": \"index.js\",\n \"type\": \"module\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\"\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,SAAS,eAAe;;;ACDxB;AAAA,EACI,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,SAAW;AAAA,IACP,MAAQ;AAAA,EACZ;AAAA,EACA,UAAY,CAAC;AAAA,EACb,QAAU;AAAA,EACV,SAAW;AACf;;;ADEA,QACK,QAAQ,gBAAY,SAAS,iBAAiB,gCAAO,EACrD,WAAW,cAAc,sCAAQ,EAEjC,YAAY,gBAAY,WAAW,EACnC,OAAO,MAAM,QAAQ,OAAO,CAAC;AAElC,IAAM,kBAAkB,6BAAqB,OAAO;AAEpD,gBAAgB,IAAI;AAEpB,gBAAgB,IAAI;AAEpB,gBAAgB,qBAAa;AAE7B,gBAAgB,OAAO;AAEvB,QAAQ,MAAM,QAAQ,IAAI;","names":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { type Command } from 'commander'
|
|
2
|
+
import consola from 'consola'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { cwd } from 'node:process'
|
|
6
|
+
import ora from 'ora'
|
|
7
|
+
import prompts from 'prompts'
|
|
8
|
+
|
|
9
|
+
const firstCharUpperCase = (str: string) => {
|
|
10
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// 确保目录存在
|
|
14
|
+
const ensureDir = (dir: string) => {
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
fs.mkdir(dir, { recursive: true }, (err) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
consola.error(`创建目录 ${dir} 失败`)
|
|
19
|
+
resolve(false)
|
|
20
|
+
} else {
|
|
21
|
+
resolve(true)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 检查路径是否存在
|
|
28
|
+
const existsPath = (path: string) => {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
fs.stat(path, (err) => {
|
|
31
|
+
// consola.log(err)
|
|
32
|
+
if (err) {
|
|
33
|
+
resolve(false)
|
|
34
|
+
} else {
|
|
35
|
+
resolve(true)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const safeSaveFile = async (
|
|
42
|
+
path: string,
|
|
43
|
+
content: string,
|
|
44
|
+
force: boolean = false
|
|
45
|
+
) => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
existsPath(path)
|
|
48
|
+
.then((exists) => {
|
|
49
|
+
if (exists) {
|
|
50
|
+
if (!force) {
|
|
51
|
+
consola.error(`文件${path} 已存在`)
|
|
52
|
+
reject(false)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
fs.writeFile(path, content, 'utf-8', (err) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
consola.error(`文件${path} 写入失败`)
|
|
59
|
+
reject(false)
|
|
60
|
+
} else {
|
|
61
|
+
resolve(true)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch(() => {
|
|
67
|
+
reject(false)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const initComponent = (program: Command) => {
|
|
73
|
+
program
|
|
74
|
+
.command('init:component')
|
|
75
|
+
.alias('init:c')
|
|
76
|
+
.alias('init:comp')
|
|
77
|
+
.argument('[component-name]', '组件名称(如Button、Text、Card)')
|
|
78
|
+
.description('初始化React组件 TSX + CSS')
|
|
79
|
+
.option(
|
|
80
|
+
'-d, --dir <dir>',
|
|
81
|
+
'生成组件目录,默认src/components',
|
|
82
|
+
'src/components'
|
|
83
|
+
)
|
|
84
|
+
.option('-s, --style <style>', '使用哪种样式方案,默认css', 'css')
|
|
85
|
+
.option('-j, --jsx', '是否使用JSX文件,默认TSX', false)
|
|
86
|
+
.option('-f, --force', '是否强制覆盖已存在组件', false)
|
|
87
|
+
.action(async (componentName, rest) => {
|
|
88
|
+
const { dir, style, jsx, force } = rest || {}
|
|
89
|
+
if (!componentName) {
|
|
90
|
+
const response = await prompts({
|
|
91
|
+
type: 'text',
|
|
92
|
+
initial: 'Button', // 默认值
|
|
93
|
+
name: 'componentName',
|
|
94
|
+
message: '请输入组件名称',
|
|
95
|
+
})
|
|
96
|
+
componentName = response.componentName
|
|
97
|
+
}
|
|
98
|
+
if (!componentName || !componentName.trim()) {
|
|
99
|
+
process.stderr.write('组件名称不能为空\n')
|
|
100
|
+
process.exit(1)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
componentName = firstCharUpperCase(componentName)
|
|
104
|
+
|
|
105
|
+
// 组件目录
|
|
106
|
+
const inputComponentDir = path.join(
|
|
107
|
+
'apps/components',
|
|
108
|
+
componentName
|
|
109
|
+
)
|
|
110
|
+
const outputComponentDir = path.resolve(cwd(), dir, componentName)
|
|
111
|
+
|
|
112
|
+
const inputExists = await existsPath(inputComponentDir)
|
|
113
|
+
// consola.log(inputExists)
|
|
114
|
+
if (!inputExists) {
|
|
115
|
+
consola.error(`组件 ${componentName} 不存在`)
|
|
116
|
+
process.exit(1)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const tip = `初始化组件 ${componentName}`
|
|
120
|
+
const spinner = ora(tip).start()
|
|
121
|
+
|
|
122
|
+
// 初始化组件 确保输出组件目录存在
|
|
123
|
+
const dirExists = await ensureDir(outputComponentDir)
|
|
124
|
+
if (!dirExists) {
|
|
125
|
+
spinner.fail(
|
|
126
|
+
`组件 ${componentName} 初始化失败, 目录 ${outputComponentDir} 创建失败`
|
|
127
|
+
)
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let esFileExt = 'tsx'
|
|
132
|
+
let styleFileExt = 'css'
|
|
133
|
+
if (jsx) {
|
|
134
|
+
esFileExt = 'jsx'
|
|
135
|
+
}
|
|
136
|
+
if (style === 'less') {
|
|
137
|
+
styleFileExt = 'less'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const esPath = path.resolve(
|
|
141
|
+
outputComponentDir,
|
|
142
|
+
`index.${esFileExt}`
|
|
143
|
+
)
|
|
144
|
+
const stylePath = path.resolve(
|
|
145
|
+
outputComponentDir,
|
|
146
|
+
`index.${styleFileExt}`
|
|
147
|
+
)
|
|
148
|
+
let esContent = fs.readFileSync(
|
|
149
|
+
path.resolve(inputComponentDir, `index.${esFileExt}`),
|
|
150
|
+
'utf-8'
|
|
151
|
+
)
|
|
152
|
+
const styleContent = fs.readFileSync(
|
|
153
|
+
path.resolve(inputComponentDir, `index.${styleFileExt}`),
|
|
154
|
+
'utf-8'
|
|
155
|
+
)
|
|
156
|
+
// 需要手动给esContent导入对应的style文件
|
|
157
|
+
esContent = `import './index.${styleFileExt}';\n${esContent}`
|
|
158
|
+
|
|
159
|
+
Promise.all([
|
|
160
|
+
safeSaveFile(esPath, esContent, force),
|
|
161
|
+
safeSaveFile(stylePath, styleContent, force),
|
|
162
|
+
])
|
|
163
|
+
.then(() => {
|
|
164
|
+
spinner.succeed(
|
|
165
|
+
`组件 ${componentName} 初始化成功, 目录 ${outputComponentDir}`
|
|
166
|
+
)
|
|
167
|
+
})
|
|
168
|
+
.catch(() => {
|
|
169
|
+
spinner.fail(`组件 ${componentName} 初始化失败`)
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export default initComponent
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export default {
|
|
4
2
|
templates: [
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
{
|
|
4
|
+
title: 'React + Nest',
|
|
5
|
+
value: 'react-nest',
|
|
6
|
+
description: '这个模板包含了 React + Nest 项目的基本配置',
|
|
7
|
+
disabled: false,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
title: 'React + Nest + TypeScript',
|
|
11
|
+
value: 'react-nest-ts',
|
|
12
|
+
description:
|
|
13
|
+
'这个模板包含了 React + Nest + TypeScript 项目的基本配置',
|
|
14
|
+
disabled: false,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'Vue',
|
|
18
|
+
value: 'vue-template',
|
|
19
|
+
description: '这个模板包含了 Vue 项目的基本配置',
|
|
20
|
+
disabled: false,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
}
|
|
@@ -5,6 +5,7 @@ import baseRegisterCommands from './commands/baseRegisterCommands.ts'
|
|
|
5
5
|
import info, { logInfo } from './commands/base/info.ts'
|
|
6
6
|
import version from './commands/base/version.ts'
|
|
7
7
|
import init from './commands/base/init.ts'
|
|
8
|
+
import initComponent from './commands/base/initComponent.ts'
|
|
8
9
|
|
|
9
10
|
// import.meta.dirname 指向当前文件所在目录
|
|
10
11
|
// process.cwd() 指向当前工作目录 (实际运行时目录,不是当前文件所在目录)
|
|
@@ -23,7 +24,9 @@ const registerCommand = baseRegisterCommands(program)
|
|
|
23
24
|
registerCommand(info)
|
|
24
25
|
// 初始化项目命令
|
|
25
26
|
registerCommand(init)
|
|
27
|
+
// 初始化组件命令
|
|
28
|
+
registerCommand(initComponent)
|
|
26
29
|
// 输出版本号命令
|
|
27
30
|
registerCommand(version)
|
|
28
31
|
|
|
29
|
-
program.parse()
|
|
32
|
+
program.parse(process.argv)
|
|
File without changes
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
packages:
|
|
2
|
-
- '
|
|
3
|
-
- '
|
|
2
|
+
- 'packages/*'
|
|
3
|
+
- 'apps/*'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @type {import("stylelint").Config} */
|
|
2
|
+
export default {
|
|
3
|
+
"customSyntax" : "postcss-styled-syntax",
|
|
4
|
+
"extends": ["stylelint-config-standard"],
|
|
5
|
+
"rules": {
|
|
6
|
+
"unit-allowed-list": [
|
|
7
|
+
"px",
|
|
8
|
+
"em",
|
|
9
|
+
"rem"
|
|
10
|
+
],
|
|
11
|
+
"block-no-empty": true,
|
|
12
|
+
"declaration-property-value-keyword-no-deprecated": true,
|
|
13
|
+
"comment-no-empty": true,
|
|
14
|
+
"comment-empty-line-before": null,
|
|
15
|
+
"selector-not-notation": null
|
|
16
|
+
}
|
|
17
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
// "rootDir": "./src",
|
|
6
|
+
// "outDir": "./dist",
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
// For nodejs:
|
|
13
|
+
"lib": ["esnext", "dom", "DOM.Iterable"],
|
|
14
|
+
"types": ["node"],
|
|
15
|
+
// and npm install -D @types/node
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// "noEmit": true,
|
|
18
|
+
"emitDeclarationOnly": true,
|
|
19
|
+
"allowImportingTsExtensions": true,
|
|
19
20
|
|
|
21
|
+
// Other Outputs
|
|
22
|
+
"sourceMap": true,
|
|
23
|
+
"declaration": true,
|
|
24
|
+
"declarationMap": true,
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"declarationMap": true,
|
|
26
|
+
// Stricter Typechecking Options
|
|
27
|
+
"noUncheckedIndexedAccess": true,
|
|
28
|
+
"exactOptionalPropertyTypes": true,
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
// Style Options
|
|
31
|
+
// "noImplicitReturns": true,
|
|
32
|
+
// "noImplicitOverride": true,
|
|
33
|
+
// "noUnusedLocals": true,
|
|
34
|
+
// "noUnusedParameters": true,
|
|
35
|
+
// "noFallthroughCasesInSwitch": true,
|
|
36
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"jsx": "react-jsx",
|
|
41
|
-
"verbatimModuleSyntax": true,
|
|
42
|
-
"isolatedModules": true,
|
|
43
|
-
"noUncheckedSideEffectImports": true,
|
|
44
|
-
"moduleDetection": "force",
|
|
45
|
-
"skipLibCheck": true,
|
|
46
|
-
}
|
|
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
|
+
"exclude": ["node_modules", "apps/**/*"]
|
|
47
48
|
}
|
package/tsup.config.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineConfig } from 'tsup'
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
entry: ['packages/cli/src
|
|
4
|
+
entry: ['packages/cli/src'],
|
|
5
5
|
outDir: 'packages/cli/dist',
|
|
6
|
-
format: ['esm'], // ['cjs']
|
|
6
|
+
format: ['esm'], // ['esm', 'cjs', 'iife'],
|
|
7
|
+
bundle: true,
|
|
7
8
|
dts: true,
|
|
8
9
|
sourcemap: true,
|
|
9
10
|
clean: true,
|
|
@@ -11,7 +12,7 @@ export default defineConfig({
|
|
|
11
12
|
minify: false,
|
|
12
13
|
outExtension() {
|
|
13
14
|
return {
|
|
14
|
-
js:
|
|
15
|
+
js: `.js`,
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
})
|