@shark-pepper/create-app 1.0.5 → 1.0.6
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/bin/create-app-cli.js +4 -35
- package/package.json +1 -1
- package/templates/react-app/.commitlintrc.js +3 -0
- package/templates/react-app/.eslintrc.js +44 -0
- package/templates/react-app/.husky/commit-msg +4 -0
- package/templates/react-app/.husky/pre-commit +4 -0
- package/templates/react-app/package.base.json +12 -7
- package/templates/react-app/pnpm-lock.yaml +1969 -388
- package/templates/react-app/postcss.config.js +5 -0
- package/templates/react-app/webpack/webpack.dev.js +0 -2
- package/templates/react-app/webpack/webpack.prod.js +0 -2
- package/templates/react-app/eslint.config.js +0 -108
package/bin/create-app-cli.js
CHANGED
|
@@ -12,7 +12,6 @@ import chalk from "chalk";
|
|
|
12
12
|
import symbols from "log-symbols";
|
|
13
13
|
import fse from "fs-extra";
|
|
14
14
|
|
|
15
|
-
// __dirname for ESM
|
|
16
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
16
|
const __dirname = path.dirname(__filename);
|
|
18
17
|
|
|
@@ -54,7 +53,8 @@ async function copyTemplate(src, dest) {
|
|
|
54
53
|
if (!relPath) return true; // 根目录
|
|
55
54
|
// 忽略 node_modules 目录和某些隐藏文件
|
|
56
55
|
if (relPath.split(path.sep).includes("node_modules")) return false;
|
|
57
|
-
if (relPath.startsWith(".git")
|
|
56
|
+
if (relPath.startsWith(".git") && relPath !== ".gitignore")
|
|
57
|
+
return false;
|
|
58
58
|
if (relPath.startsWith(".DS_Store")) return false;
|
|
59
59
|
|
|
60
60
|
return true;
|
|
@@ -70,36 +70,6 @@ async function copyTemplate(src, dest) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
// Husky + lint-staged 配置
|
|
74
|
-
function setupHusky(projectPath) {
|
|
75
|
-
console.log(chalk.blue("⚙️ Configure Husky + lint-staged ..."));
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
// 执行 husky install
|
|
79
|
-
execSync("npx husky install", { cwd: projectPath, stdio: "inherit" });
|
|
80
|
-
|
|
81
|
-
// 创建 pre-commit 钩子
|
|
82
|
-
const huskyDir = path.join(projectPath, ".husky");
|
|
83
|
-
if (!fs.existsSync(huskyDir)) fs.mkdirSync(huskyDir, { recursive: true });
|
|
84
|
-
|
|
85
|
-
const preCommitFile = path.join(huskyDir, "pre-commit");
|
|
86
|
-
if (!fs.existsSync(preCommitFile)) {
|
|
87
|
-
fs.writeFileSync(
|
|
88
|
-
preCommitFile,
|
|
89
|
-
'#!/bin/sh\n. "$(dirname "$0")/_/husky.sh"\nnpx lint-staged\n',
|
|
90
|
-
{ mode: 0o755 }
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
console.log(
|
|
95
|
-
symbols.success,
|
|
96
|
-
chalk.green("✅ Husky + lint-staged is configured.")
|
|
97
|
-
);
|
|
98
|
-
} catch (err) {
|
|
99
|
-
console.error(symbols.error, chalk.red("Husky configuration failed."), err);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
73
|
// Jest 配置
|
|
104
74
|
function setupJest(projectPath) {
|
|
105
75
|
console.log(chalk.blue("⚙️ Configuring the Jest testing environment..."));
|
|
@@ -247,6 +217,8 @@ async function run() {
|
|
|
247
217
|
);
|
|
248
218
|
}
|
|
249
219
|
|
|
220
|
+
execSync("git init", { cwd: projectPath, stdio: "inherit" });
|
|
221
|
+
|
|
250
222
|
// 安装依赖
|
|
251
223
|
console.log(
|
|
252
224
|
chalk.yellow(
|
|
@@ -257,9 +229,6 @@ async function run() {
|
|
|
257
229
|
);
|
|
258
230
|
execSync(installCmd, { cwd: projectPath, stdio: "inherit" });
|
|
259
231
|
|
|
260
|
-
// Husky + lint-staged
|
|
261
|
-
setupHusky(projectPath);
|
|
262
|
-
|
|
263
232
|
// 可选 Jest
|
|
264
233
|
if (useJest) setupJest(projectPath);
|
|
265
234
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
|
|
4
|
+
parser: '@typescript-eslint/parser',
|
|
5
|
+
parserOptions: {
|
|
6
|
+
ecmaVersion: 'latest',
|
|
7
|
+
sourceType: 'module',
|
|
8
|
+
ecmaFeatures: { jsx: true },
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
env: {
|
|
12
|
+
browser: true,
|
|
13
|
+
node: true,
|
|
14
|
+
es2022: true,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
|
|
18
|
+
|
|
19
|
+
extends: [
|
|
20
|
+
'eslint:recommended',
|
|
21
|
+
'plugin:@typescript-eslint/recommended',
|
|
22
|
+
'plugin:react/recommended',
|
|
23
|
+
'plugin:react-hooks/recommended',
|
|
24
|
+
'prettier',
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
settings: {
|
|
28
|
+
react: {
|
|
29
|
+
version: 'detect',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
rules: {
|
|
34
|
+
'react/react-in-jsx-scope': 'off',
|
|
35
|
+
'react/prop-types': 'off',
|
|
36
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
37
|
+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
38
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
39
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
40
|
+
'prefer-const': 'warn',
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
ignorePatterns: ['dist', 'build', 'node_modules'],
|
|
44
|
+
};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "webpack serve --open --mode development --config webpack/webpack.dev.js",
|
|
8
8
|
"build": "webpack --mode production --config webpack/webpack.prod.js",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"prepare": "husky"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "",
|
|
@@ -23,21 +23,26 @@
|
|
|
23
23
|
"@babel/preset-env": "^7.28.5",
|
|
24
24
|
"@babel/preset-react": "^7.28.5",
|
|
25
25
|
"@babel/preset-typescript": "^7.28.5",
|
|
26
|
+
"@commitlint/cli": "^20.2.0",
|
|
27
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
26
28
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
|
27
29
|
"@types/css-modules": "^1.0.5",
|
|
28
30
|
"@types/react": "^19.2.2",
|
|
29
31
|
"@types/react-dom": "^19.2.2",
|
|
30
32
|
"@types/react-router-dom": "^5.3.3",
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
32
|
-
"@typescript-eslint/parser": "^
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
34
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
35
|
+
"autoprefixer": "^10.4.22",
|
|
33
36
|
"babel-loader": "^10.0.0",
|
|
34
37
|
"core-js": "^3.47.0",
|
|
35
38
|
"cspell": "^9.2.2",
|
|
36
39
|
"css-loader": "^7.1.2",
|
|
37
40
|
"esbuild": "^0.27.0",
|
|
38
41
|
"esbuild-loader": "^4.4.0",
|
|
39
|
-
"eslint": "
|
|
40
|
-
"eslint-
|
|
42
|
+
"eslint": "8.57.1",
|
|
43
|
+
"eslint-config-prettier": "^9.1.2",
|
|
44
|
+
"eslint-plugin-react": "^7.37.5",
|
|
45
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
41
46
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
42
47
|
"html-webpack-plugin": "^5.6.4",
|
|
43
48
|
"husky": "^9.1.7",
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
"sass": "^1.93.3",
|
|
50
55
|
"sass-loader": "^16.0.6",
|
|
51
56
|
"style-loader": "^4.0.0",
|
|
52
|
-
"typescript": "
|
|
57
|
+
"typescript": "~5.3.3",
|
|
53
58
|
"webpack": "^5.102.1",
|
|
54
59
|
"webpack-cli": "^6.0.1",
|
|
55
60
|
"webpack-dev-server": "^5.2.2",
|