@shark-pepper/create-app 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/README.md +30 -2
- package/bin/create-app-cli.js +45 -23
- package/package.json +1 -1
- package/templates/react-app/.babelrc +17 -0
- package/templates/react-app/package.base.json +27 -14
- package/templates/react-app/pnpm-lock.yaml +4640 -2067
- package/templates/react-app/src/App.tsx +18 -1
- package/templates/react-app/src/index.tsx +15 -4
- package/templates/react-app/src/routes/index.tsx +11 -0
- package/templates/react-app/src/styles/App.module.scss +16 -0
- package/templates/react-app/webpack/webpack.common.js +53 -0
- package/templates/react-app/webpack/webpack.dev.js +81 -0
- package/templates/react-app/webpack/webpack.prod.js +84 -0
- package/templates/react-app/webpack.config.js +0 -123
package/README.md
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
|
-
# create-app
|
|
2
|
-
|
|
1
|
+
# 🦈 @shark-pepper/create-app
|
|
2
|
+
|
|
3
|
+
> 🚀 A scaffolding tool for creating modern front-end projects.
|
|
4
|
+
> It supports mainstream configurations such as React, TypeScript, Webpack, ESLint, Prettier, and Jest.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ✨ Characteristic
|
|
9
|
+
|
|
10
|
+
- ⚙️ By default, it integrates specification tools such as ESLint, Prettier, Husky, and Commitlint.
|
|
11
|
+
- 🧪 Supports Jest unit testing
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 📦 Quick Start
|
|
16
|
+
|
|
17
|
+
### Use npx (recommended)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @shark-pepper/create-app my-project
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Or install globally
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g @shark-pepper/create-app
|
|
28
|
+
create-app my-project
|
|
29
|
+
|
|
30
|
+
```
|
package/bin/create-app-cli.js
CHANGED
|
@@ -35,7 +35,10 @@ const installCmd = hasPnpm() ? "pnpm install" : "npm install";
|
|
|
35
35
|
function getTemplatePath(templateName) {
|
|
36
36
|
const templatePath = path.resolve(__dirname, "../templates", templateName);
|
|
37
37
|
if (!fs.existsSync(templatePath)) {
|
|
38
|
-
console.error(
|
|
38
|
+
console.error(
|
|
39
|
+
symbols.error,
|
|
40
|
+
chalk.red(`Template does not exist: ${templatePath}`)
|
|
41
|
+
);
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
return templatePath;
|
|
@@ -57,16 +60,19 @@ async function copyTemplate(src, dest) {
|
|
|
57
60
|
return true;
|
|
58
61
|
},
|
|
59
62
|
});
|
|
60
|
-
console.log(
|
|
63
|
+
console.log(
|
|
64
|
+
symbols.success,
|
|
65
|
+
chalk.green("✅ Template file copy completed")
|
|
66
|
+
);
|
|
61
67
|
} catch (err) {
|
|
62
|
-
console.error(symbols.error, chalk.red("
|
|
68
|
+
console.error(symbols.error, chalk.red("Template copy failed"), err);
|
|
63
69
|
process.exit(1);
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
// Husky + lint-staged 配置
|
|
68
74
|
function setupHusky(projectPath) {
|
|
69
|
-
console.log(chalk.blue("⚙️
|
|
75
|
+
console.log(chalk.blue("⚙️ Configure Husky + lint-staged ..."));
|
|
70
76
|
|
|
71
77
|
try {
|
|
72
78
|
// 执行 husky install
|
|
@@ -85,15 +91,18 @@ function setupHusky(projectPath) {
|
|
|
85
91
|
);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
console.log(
|
|
94
|
+
console.log(
|
|
95
|
+
symbols.success,
|
|
96
|
+
chalk.green("✅ Husky + lint-staged is configured.")
|
|
97
|
+
);
|
|
89
98
|
} catch (err) {
|
|
90
|
-
console.error(symbols.error, chalk.red("Husky
|
|
99
|
+
console.error(symbols.error, chalk.red("Husky configuration failed."), err);
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
// Jest 配置
|
|
95
104
|
function setupJest(projectPath) {
|
|
96
|
-
console.log(chalk.blue("⚙️
|
|
105
|
+
console.log(chalk.blue("⚙️ Configuring the Jest testing environment..."));
|
|
97
106
|
|
|
98
107
|
try {
|
|
99
108
|
// 安装依赖
|
|
@@ -156,9 +165,12 @@ module.exports = {
|
|
|
156
165
|
const fileMock = `module.exports = 'test-file-stub';\n`;
|
|
157
166
|
fs.writeFileSync(path.join(mocksDir, "fileMock.js"), fileMock, "utf-8");
|
|
158
167
|
|
|
159
|
-
console.log(
|
|
168
|
+
console.log(
|
|
169
|
+
symbols.success,
|
|
170
|
+
chalk.green("✅ Jest configuration complete")
|
|
171
|
+
);
|
|
160
172
|
} catch (err) {
|
|
161
|
-
console.error(symbols.error, chalk.red("Jest
|
|
173
|
+
console.error(symbols.error, chalk.red("Jest configuration failed."), err);
|
|
162
174
|
}
|
|
163
175
|
}
|
|
164
176
|
|
|
@@ -170,32 +182,32 @@ async function run() {
|
|
|
170
182
|
{
|
|
171
183
|
type: "input",
|
|
172
184
|
name: "projectName",
|
|
173
|
-
message: "
|
|
185
|
+
message: "Project Name: ",
|
|
174
186
|
default: "my-app",
|
|
175
187
|
when: () => !projectNameArg,
|
|
176
188
|
},
|
|
177
189
|
{
|
|
178
190
|
type: "input",
|
|
179
191
|
name: "version",
|
|
180
|
-
message: "
|
|
192
|
+
message: "Version: ",
|
|
181
193
|
default: "1.0.0",
|
|
182
194
|
},
|
|
183
195
|
{
|
|
184
196
|
type: "input",
|
|
185
197
|
name: "description",
|
|
186
|
-
message: "
|
|
187
|
-
default: "A project created by create-app
|
|
198
|
+
message: "Description: ",
|
|
199
|
+
default: "A project created by @shark-pepper/create-app",
|
|
188
200
|
},
|
|
189
201
|
{
|
|
190
202
|
type: "list",
|
|
191
203
|
name: "template",
|
|
192
|
-
message: "
|
|
193
|
-
choices: ["react-app"
|
|
204
|
+
message: "Select a project template: ",
|
|
205
|
+
choices: ["react-app"],
|
|
194
206
|
},
|
|
195
207
|
{
|
|
196
208
|
type: "confirm",
|
|
197
209
|
name: "useJest",
|
|
198
|
-
message: "
|
|
210
|
+
message: "Need to generate a Jest-based unit test configuration",
|
|
199
211
|
default: true,
|
|
200
212
|
},
|
|
201
213
|
]);
|
|
@@ -205,12 +217,15 @@ async function run() {
|
|
|
205
217
|
|
|
206
218
|
const projectPath = path.join(process.cwd(), projectName);
|
|
207
219
|
if (fs.existsSync(projectPath)) {
|
|
208
|
-
console.log(
|
|
220
|
+
console.log(
|
|
221
|
+
symbols.error,
|
|
222
|
+
chalk.red(`The directory ${projectName} already exists!`)
|
|
223
|
+
);
|
|
209
224
|
process.exit(1);
|
|
210
225
|
}
|
|
211
226
|
|
|
212
227
|
fs.mkdirSync(projectPath);
|
|
213
|
-
console.log(symbols.info, chalk.blue("📁
|
|
228
|
+
console.log(symbols.info, chalk.blue("📁 Create a project directory..."));
|
|
214
229
|
|
|
215
230
|
// 复制模板
|
|
216
231
|
const templatePath = getTemplatePath(template);
|
|
@@ -226,12 +241,19 @@ async function run() {
|
|
|
226
241
|
pkgData.description = description;
|
|
227
242
|
fs.writeFileSync(pkgPath, JSON.stringify(pkgData, null, 2), "utf-8");
|
|
228
243
|
fs.unlinkSync(basePkgPath);
|
|
229
|
-
console.log(
|
|
244
|
+
console.log(
|
|
245
|
+
symbols.success,
|
|
246
|
+
chalk.green("✅ package.json has been generated")
|
|
247
|
+
);
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
// 安装依赖
|
|
233
251
|
console.log(
|
|
234
|
-
chalk.yellow(
|
|
252
|
+
chalk.yellow(
|
|
253
|
+
`📦 Dependencies are being installed using ${
|
|
254
|
+
installCmd.split(" ")[0]
|
|
255
|
+
}...`
|
|
256
|
+
)
|
|
235
257
|
);
|
|
236
258
|
execSync(installCmd, { cwd: projectPath, stdio: "inherit" });
|
|
237
259
|
|
|
@@ -243,13 +265,13 @@ async function run() {
|
|
|
243
265
|
|
|
244
266
|
console.log(
|
|
245
267
|
symbols.success,
|
|
246
|
-
chalk.green(`🎉
|
|
268
|
+
chalk.green(`🎉 Project ${projectName} created successfully!`)
|
|
247
269
|
);
|
|
248
|
-
console.log(chalk.cyan(`👉
|
|
270
|
+
console.log(chalk.cyan(`👉 Run the project:`));
|
|
249
271
|
console.log(chalk.white(` cd ${projectName}`));
|
|
250
272
|
console.log(chalk.white(` npm start`));
|
|
251
273
|
} catch (err) {
|
|
252
|
-
console.error(symbols.error, chalk.red("
|
|
274
|
+
console.error(symbols.error, chalk.red("Project creation failed!"), err);
|
|
253
275
|
}
|
|
254
276
|
}
|
|
255
277
|
|
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"start": "webpack serve --open --mode development",
|
|
8
|
-
"build": "webpack --mode production",
|
|
7
|
+
"start": "webpack serve --open --mode development --config webpack/webpack.dev.js",
|
|
8
|
+
"build": "webpack --mode production --config webpack/webpack.prod.js",
|
|
9
9
|
"prepare": "husky install",
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
11
|
},
|
|
@@ -15,35 +15,48 @@
|
|
|
15
15
|
"packageManager": "pnpm@10.18.1",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"react": "^19.2.0",
|
|
18
|
-
"react-dom": "^19.2.0"
|
|
18
|
+
"react-dom": "^19.2.0",
|
|
19
|
+
"react-router-dom": "^7.9.5"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
22
|
+
"@babel/core": "^7.28.5",
|
|
23
|
+
"@babel/preset-env": "^7.28.5",
|
|
24
|
+
"@babel/preset-react": "^7.28.5",
|
|
25
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
26
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
|
27
|
+
"@types/css-modules": "^1.0.5",
|
|
21
28
|
"@types/react": "^19.2.2",
|
|
22
29
|
"@types/react-dom": "^19.2.2",
|
|
30
|
+
"@types/react-router-dom": "^5.3.3",
|
|
23
31
|
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
24
32
|
"@typescript-eslint/parser": "^8.46.2",
|
|
33
|
+
"babel-loader": "^10.0.0",
|
|
34
|
+
"core-js": "^3.47.0",
|
|
25
35
|
"cspell": "^9.2.2",
|
|
36
|
+
"css-loader": "^7.1.2",
|
|
37
|
+
"esbuild": "^0.27.0",
|
|
38
|
+
"esbuild-loader": "^4.4.0",
|
|
26
39
|
"eslint": "^9.38.0",
|
|
40
|
+
"eslint-webpack-plugin": "^5.0.2",
|
|
41
|
+
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
27
42
|
"html-webpack-plugin": "^5.6.4",
|
|
28
43
|
"husky": "^9.1.7",
|
|
29
44
|
"lint-staged": "^16.2.6",
|
|
45
|
+
"mini-css-extract-plugin": "^2.9.4",
|
|
46
|
+
"postcss-loader": "^8.2.0",
|
|
30
47
|
"prettier": "^3.6.2",
|
|
31
|
-
"
|
|
48
|
+
"react-refresh": "^0.18.0",
|
|
49
|
+
"sass": "^1.93.3",
|
|
50
|
+
"sass-loader": "^16.0.6",
|
|
51
|
+
"style-loader": "^4.0.0",
|
|
32
52
|
"typescript": "^5.9.3",
|
|
33
53
|
"webpack": "^5.102.1",
|
|
34
54
|
"webpack-cli": "^6.0.1",
|
|
35
55
|
"webpack-dev-server": "^5.2.2",
|
|
36
|
-
"
|
|
37
|
-
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
38
|
-
"mini-css-extract-plugin": "^2.9.4"
|
|
56
|
+
"webpack-merge": "^6.0.1"
|
|
39
57
|
},
|
|
40
58
|
"lint-staged": {
|
|
41
|
-
"*.{ts,tsx,js,jsx}": [
|
|
42
|
-
|
|
43
|
-
"prettier --write"
|
|
44
|
-
],
|
|
45
|
-
"*.{css,scss,less,json,md}": [
|
|
46
|
-
"prettier --write"
|
|
47
|
-
]
|
|
59
|
+
"*.{ts,tsx,js,jsx}": ["eslint --fix", "prettier --write"],
|
|
60
|
+
"*.{css,scss,less,json,md}": ["prettier --write"]
|
|
48
61
|
}
|
|
49
62
|
}
|