react-nest-cli 1.0.3 → 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/.cspell/project-words.txt +3 -0
- package/.editorconfig +5 -0
- package/.husky/commit-msg +3 -0
- package/.husky/pre-commit +3 -0
- package/.prettierignore +1 -0
- 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/commitlint.config.ts +113 -0
- package/cspell.config.ts +16 -0
- package/eslint.config.ts +52 -0
- package/package.json +86 -38
- 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 +38 -85
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/package.json +13 -0
- package/packages/cli/src/commands/base/info.ts +22 -0
- package/packages/cli/src/commands/base/init.ts +73 -0
- package/packages/cli/src/commands/base/initComponent.ts +174 -0
- package/packages/cli/src/commands/base/version.ts +16 -0
- package/packages/cli/src/commands/baseRegisterCommands.ts +9 -0
- package/packages/cli/src/configs/prompts.config.ts +21 -6
- package/packages/cli/src/index.ts +22 -102
- package/packages/templates/react-nest/index.css +7 -0
- package/packages/templates/react-nest/index.js +1 -0
- package/packages/templates/react-nest-ts/index.js +1 -0
- package/packages/templates/vue-template/vue +0 -0
- package/pnpm-workspace.yaml +2 -2
- package/prettier.config.js +6 -0
- package/stylelint.config.mjs +17 -0
- package/tsconfig.json +40 -39
- package/tsup.config.ts +12 -5
- package/turbo.json +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Command } from 'commander'
|
|
2
|
+
import prompts from 'prompts'
|
|
3
|
+
import promptsConfig from '../../configs/prompts.config.ts'
|
|
4
|
+
import consola from 'consola'
|
|
5
|
+
import fsExtra from 'fs-extra'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
import { cwd } from 'node:process'
|
|
8
|
+
import { downloadTemplate } from 'giget'
|
|
9
|
+
import ora from 'ora'
|
|
10
|
+
|
|
11
|
+
export default function init(program: Command) {
|
|
12
|
+
program
|
|
13
|
+
.command('init')
|
|
14
|
+
.description('初始化项目')
|
|
15
|
+
.argument('[project-name]', '项目名称')
|
|
16
|
+
.option('--template <template-name>', '项目模板名称')
|
|
17
|
+
.action(async (projectName, rest) => {
|
|
18
|
+
let { template } = rest || {}
|
|
19
|
+
// 如果projectName没有提供,让用户输入
|
|
20
|
+
if (!projectName) {
|
|
21
|
+
const response = await prompts({
|
|
22
|
+
type: 'text',
|
|
23
|
+
initial: 'my-project', // 默认值
|
|
24
|
+
name: 'projectName',
|
|
25
|
+
message: '请输入项目名称',
|
|
26
|
+
// validate: value => value.length ? true : '请输入项目名称'
|
|
27
|
+
})
|
|
28
|
+
projectName = response.projectName
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 如果template没有提供或者template不存在,让用户选择
|
|
32
|
+
const noTemplate =
|
|
33
|
+
template &&
|
|
34
|
+
!promptsConfig.templates.find((item) => item.value === template)
|
|
35
|
+
if (!template || noTemplate) {
|
|
36
|
+
if (noTemplate) {
|
|
37
|
+
consola.error(`项目模板 ${template} 不存在, 请选择其他模板`)
|
|
38
|
+
}
|
|
39
|
+
const response = await prompts({
|
|
40
|
+
type: 'select',
|
|
41
|
+
name: 'template',
|
|
42
|
+
message: '请选择项目模板',
|
|
43
|
+
choices: promptsConfig.templates,
|
|
44
|
+
initial: 0, // 默认选择第一个
|
|
45
|
+
})
|
|
46
|
+
template = response.template
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const tip = `初始化项目 ${projectName},模板 ${template}`
|
|
50
|
+
const spinner = ora({
|
|
51
|
+
text: tip,
|
|
52
|
+
color: 'blue',
|
|
53
|
+
// spinner: 'growVertical',
|
|
54
|
+
// isEnabled: false
|
|
55
|
+
})
|
|
56
|
+
spinner.start()
|
|
57
|
+
|
|
58
|
+
const projectDir = path.resolve(cwd(), projectName)
|
|
59
|
+
if (fsExtra.existsSync(projectDir)) {
|
|
60
|
+
spinner.fail(`💥初始化失败: 项目目录 ${projectName} 已存在`)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const res = await downloadTemplate(
|
|
65
|
+
`github:liaolonghui/react-nest-cli/packages/templates/${template}#main`,
|
|
66
|
+
{
|
|
67
|
+
dir: projectDir,
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
const { dir } = res
|
|
71
|
+
spinner.succeed(`项目初始化成功,项目目录:${dir}`)
|
|
72
|
+
})
|
|
73
|
+
}
|
|
@@ -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
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from 'commander'
|
|
2
|
+
import consola from 'consola'
|
|
3
|
+
import figlet from 'figlet'
|
|
4
|
+
import textConfig from '../../configs/text.config.ts'
|
|
5
|
+
|
|
6
|
+
export default function version(program: Command) {
|
|
7
|
+
// 输出版本号
|
|
8
|
+
program
|
|
9
|
+
.command('version')
|
|
10
|
+
.description('输出版本号')
|
|
11
|
+
.action(() => {
|
|
12
|
+
consola.info(
|
|
13
|
+
figlet.textSync(`version ==> ${program.version()}`, textConfig)
|
|
14
|
+
)
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,112 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { program } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import fsExtra from 'fs-extra';
|
|
11
|
-
import textConfig from './configs/text.config.ts';
|
|
12
|
-
import promptsConfig from "./configs/prompts.config.ts";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// 输出项目信息
|
|
16
|
-
const logInfo = () => {
|
|
17
|
-
console.info(picocolors.yellow(figlet.textSync('React Nest CLI', textConfig)))
|
|
18
|
-
consola.start(picocolors.yellow(program.description()))
|
|
19
|
-
consola.info(picocolors.yellow(program.version()))
|
|
20
|
-
}
|
|
2
|
+
import { program } from 'commander'
|
|
3
|
+
import packageJson from '../package.json' with { type: 'json' }
|
|
4
|
+
import baseRegisterCommands from './commands/baseRegisterCommands.ts'
|
|
5
|
+
import info, { logInfo } from './commands/base/info.ts'
|
|
6
|
+
import version from './commands/base/version.ts'
|
|
7
|
+
import init from './commands/base/init.ts'
|
|
8
|
+
import initComponent from './commands/base/initComponent.ts'
|
|
21
9
|
|
|
22
10
|
// import.meta.dirname 指向当前文件所在目录
|
|
23
11
|
// process.cwd() 指向当前工作目录 (实际运行时目录,不是当前文件所在目录)
|
|
24
|
-
const cwd = process.cwd();
|
|
25
|
-
const dirname = import.meta.dirname;
|
|
26
|
-
const packageJsonPath = path.resolve(dirname, '../../../package.json');
|
|
27
|
-
const packageJson = JSON.parse(fsExtra.readFileSync(packageJsonPath, 'utf-8'));
|
|
28
|
-
|
|
29
|
-
// console.log(packageJsonPath, packageJson);
|
|
12
|
+
// const cwd = process.cwd();
|
|
13
|
+
// const dirname = import.meta.dirname;
|
|
30
14
|
|
|
31
15
|
program
|
|
32
16
|
.version(packageJson.version, '-V, --version', '输出版本号')
|
|
33
17
|
.helpOption('-h, --help', '输出帮助信息')
|
|
34
18
|
// .help((str) => '帮助信息:\n' + str)
|
|
35
19
|
.description(packageJson.description)
|
|
36
|
-
.action(logInfo)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.option('--template <template-name>', '项目模板名称')
|
|
50
|
-
.action(async (projectName, rest) => {
|
|
51
|
-
let { template } = rest || {};
|
|
52
|
-
// 如果projectName没有提供,让用户输入
|
|
53
|
-
if (!projectName) {
|
|
54
|
-
const response = await prompts({
|
|
55
|
-
type: 'text',
|
|
56
|
-
initial: 'my-project', // 默认值
|
|
57
|
-
name: 'projectName',
|
|
58
|
-
message: '请输入项目名称',
|
|
59
|
-
// validate: value => value.length ? true : '请输入项目名称'
|
|
60
|
-
});
|
|
61
|
-
projectName = response.projectName;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 如果template没有提供或者template不存在,让用户选择
|
|
65
|
-
const noTemplate = (template && !promptsConfig.templates.find(item => item.value === template));
|
|
66
|
-
if (!template || noTemplate) {
|
|
67
|
-
if (noTemplate) {
|
|
68
|
-
consola.error(`项目模板 ${template} 不存在, 请选择其他模板`);
|
|
69
|
-
}
|
|
70
|
-
const response = await prompts({
|
|
71
|
-
type: 'select',
|
|
72
|
-
name: 'template',
|
|
73
|
-
message: '请选择项目模板',
|
|
74
|
-
choices: promptsConfig.templates,
|
|
75
|
-
initial: 0, // 默认选择第一个
|
|
76
|
-
});
|
|
77
|
-
template = response.template;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const tip = `初始化项目 ${projectName},模板 ${template}`;
|
|
81
|
-
const spinner = ora({
|
|
82
|
-
text: tip,
|
|
83
|
-
color: 'blue',
|
|
84
|
-
// spinner: 'growVertical',
|
|
85
|
-
// isEnabled: false
|
|
86
|
-
});
|
|
87
|
-
spinner.start();
|
|
88
|
-
|
|
89
|
-
const projectDir = path.resolve(cwd, projectName);
|
|
90
|
-
if (fsExtra.existsSync(projectDir)) {
|
|
91
|
-
spinner.fail(`💥初始化失败: 项目目录 ${projectName} 已存在`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const res = await downloadTemplate(`github:liaolonghui/react-nest-cli/packages/templates/${template}#main`, {
|
|
96
|
-
dir: projectDir,
|
|
97
|
-
});
|
|
98
|
-
const { dir } = res;
|
|
99
|
-
spinner.succeed(`项目初始化成功,项目目录:${dir}`);
|
|
100
|
-
// console.log(res);
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// 输出版本号
|
|
105
|
-
program.command('version')
|
|
106
|
-
.description('输出版本号')
|
|
107
|
-
.action(() => {
|
|
108
|
-
// 全局option -V, --version 已被注册,这里无需再注册version命令,只是为了演示
|
|
109
|
-
consola.info(figlet.textSync(`version ==> ${program.version()}`, textConfig));
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
program.parse();
|
|
20
|
+
.action(() => logInfo(program))
|
|
21
|
+
|
|
22
|
+
const registerCommand = baseRegisterCommands(program)
|
|
23
|
+
// 注册info命令
|
|
24
|
+
registerCommand(info)
|
|
25
|
+
// 初始化项目命令
|
|
26
|
+
registerCommand(init)
|
|
27
|
+
// 初始化组件命令
|
|
28
|
+
registerCommand(initComponent)
|
|
29
|
+
// 输出版本号命令
|
|
30
|
+
registerCommand(version)
|
|
31
|
+
|
|
32
|
+
program.parse(process.argv)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('react-nest template')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('react-nest-ts template')
|
|
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,11 +1,18 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
2
|
-
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
3
2
|
|
|
4
3
|
export default defineConfig({
|
|
5
|
-
entry: ['packages/cli/src
|
|
4
|
+
entry: ['packages/cli/src'],
|
|
6
5
|
outDir: 'packages/cli/dist',
|
|
7
|
-
format: ['esm'],
|
|
6
|
+
format: ['esm'], // ['esm', 'cjs', 'iife'],
|
|
7
|
+
bundle: true,
|
|
8
8
|
dts: true,
|
|
9
9
|
sourcemap: true,
|
|
10
10
|
clean: true,
|
|
11
|
-
|
|
11
|
+
splitting: true,
|
|
12
|
+
minify: false,
|
|
13
|
+
outExtension() {
|
|
14
|
+
return {
|
|
15
|
+
js: `.js`,
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
})
|
package/turbo.json
ADDED
|
File without changes
|