@shark-pepper/create-app 1.0.0 → 1.0.2
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 +12 -2
- package/package.json +6 -4
package/bin/create-app-cli.js
CHANGED
|
@@ -31,6 +31,16 @@ function hasPnpm() {
|
|
|
31
31
|
}
|
|
32
32
|
const installCmd = hasPnpm() ? "pnpm install" : "npm install";
|
|
33
33
|
|
|
34
|
+
// 获取模板路径(全局安装后可用)
|
|
35
|
+
function getTemplatePath(templateName) {
|
|
36
|
+
const templatePath = path.resolve(__dirname, "../templates", templateName);
|
|
37
|
+
if (!fs.existsSync(templatePath)) {
|
|
38
|
+
console.error(symbols.error, chalk.red(`模板不存在: ${templatePath}`));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
return templatePath;
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
// 异步复制模板
|
|
35
45
|
async function copyTemplate(src, dest) {
|
|
36
46
|
try {
|
|
@@ -194,7 +204,7 @@ async function run() {
|
|
|
194
204
|
console.log(symbols.info, chalk.blue("📁 创建项目目录中..."));
|
|
195
205
|
|
|
196
206
|
// 复制模板
|
|
197
|
-
const templatePath =
|
|
207
|
+
const templatePath = getTemplatePath(template);
|
|
198
208
|
await copyTemplate(templatePath, projectPath);
|
|
199
209
|
|
|
200
210
|
// 处理 package.base.json → package.json
|
|
@@ -216,7 +226,7 @@ async function run() {
|
|
|
216
226
|
);
|
|
217
227
|
execSync(installCmd, { cwd: projectPath, stdio: "inherit" });
|
|
218
228
|
|
|
219
|
-
//
|
|
229
|
+
// Husky + lint-staged
|
|
220
230
|
setupHusky(projectPath);
|
|
221
231
|
|
|
222
232
|
// 可选 Jest
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shark-pepper/create-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"bin": {
|
|
11
11
|
"create-app": "bin/create-app-cli.js"
|
|
12
12
|
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"templates"
|
|
16
|
+
],
|
|
13
17
|
"keywords": [],
|
|
14
18
|
"author": "",
|
|
15
19
|
"license": "ISC",
|
|
@@ -17,9 +21,7 @@
|
|
|
17
21
|
"dependencies": {
|
|
18
22
|
"chalk": "^5.6.2",
|
|
19
23
|
"inquirer": "^12.10.0",
|
|
20
|
-
"log-symbols": "^7.0.1"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
24
|
+
"log-symbols": "^7.0.1",
|
|
23
25
|
"fs-extra": "^11.3.2"
|
|
24
26
|
}
|
|
25
27
|
}
|