@moluoxixi/create-app 2.0.419 → 2.0.420
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/dist/commands/create.js
CHANGED
|
@@ -60,14 +60,14 @@ export async function createProject(projectName) {
|
|
|
60
60
|
gitSpinner.warn('Git 初始化跳过');
|
|
61
61
|
}
|
|
62
62
|
// 安装依赖
|
|
63
|
-
|
|
63
|
+
console.log(chalk.blue('\n📦 开始安装依赖...\n'));
|
|
64
64
|
try {
|
|
65
65
|
await installDependencies(config.packageManager, config.targetDir, 1);
|
|
66
|
-
|
|
66
|
+
console.log(chalk.green('\n✅ 依赖安装成功!\n'));
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
|
|
70
|
-
console.log(chalk.yellow('
|
|
69
|
+
console.log(chalk.red('\n❌ 依赖安装失败\n'));
|
|
70
|
+
console.log(chalk.yellow('⚠️ 项目已创建,但依赖安装失败。'));
|
|
71
71
|
console.log(chalk.yellow(` 请手动运行 "${config.packageManager} install"\n`));
|
|
72
72
|
if (error instanceof Error) {
|
|
73
73
|
console.log(chalk.gray(` 错误详情: ${error.message}`));
|
package/dist/utils/install.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* 依赖安装工具
|
|
3
3
|
* 执行包管理器安装依赖
|
|
4
4
|
*/
|
|
5
|
-
import { exec } from 'node:child_process';
|
|
5
|
+
import { exec, spawn } from 'node:child_process';
|
|
6
6
|
import { promisify } from 'node:util';
|
|
7
7
|
import { validatePath } from "./file.js";
|
|
8
|
-
const execAsync = promisify(exec);
|
|
8
|
+
const execAsync = promisify(exec); // exec 用于 initGit 函数
|
|
9
9
|
/** 重试延迟基数(毫秒) */
|
|
10
10
|
const RETRY_DELAY_BASE_MS = 1000;
|
|
11
11
|
/**
|
|
@@ -43,8 +43,25 @@ export async function installDependencies(packageManager, cwd, retries = 0) {
|
|
|
43
43
|
let lastError;
|
|
44
44
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
45
45
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// 使用 spawn 以支持实时输出
|
|
47
|
+
await new Promise((resolve, reject) => {
|
|
48
|
+
const [cmd, ...args] = command.split(' ');
|
|
49
|
+
const child = spawn(cmd, args, {
|
|
50
|
+
cwd,
|
|
51
|
+
stdio: 'inherit', // 直接输出到终端
|
|
52
|
+
shell: true, // Windows 需要 shell
|
|
53
|
+
});
|
|
54
|
+
child.on('close', (code) => {
|
|
55
|
+
if (code === 0) {
|
|
56
|
+
resolve();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
reject(new Error(`命令退出,退出码: ${code}`));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
child.on('error', (error) => {
|
|
63
|
+
reject(error);
|
|
64
|
+
});
|
|
48
65
|
});
|
|
49
66
|
return; // 成功则返回
|
|
50
67
|
}
|
|
@@ -72,6 +89,8 @@ export async function initGit(cwd, projectName) {
|
|
|
72
89
|
// 验证路径安全性
|
|
73
90
|
validatePath(cwd);
|
|
74
91
|
await execAsync('git init', { cwd });
|
|
92
|
+
// 添加 AIRules 子模块
|
|
93
|
+
await execAsync('git submodule add -b main https://github.com/moluoxixi/AIRules.git .cursor', { cwd });
|
|
75
94
|
await execAsync('git add .', { cwd });
|
|
76
95
|
await execAsync(`git commit -m "feat: initialize ${projectName}"`, { cwd });
|
|
77
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moluoxixi/create-app",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.420",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create Vue/React projects with atomic layered architecture",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"type-check": "tsc --noEmit",
|
|
72
72
|
"lint:eslint": "eslint . --fix",
|
|
73
73
|
"submodule:update": "git submodule update --init --recursive --remote",
|
|
74
|
+
"postinstall": "pnpm submodule:update",
|
|
74
75
|
"lint-staged": "lint-staged",
|
|
75
76
|
"commit": "git add . && git-cz",
|
|
76
77
|
"version:patch": "pnpm version patch --no-git-tag-version",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"packageManager": "pnpm@10.8.0",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "vite",
|
|
12
|
-
"submodule:update": "git submodule update --init --recursive",
|
|
13
|
-
"
|
|
12
|
+
"submodule:update": "git submodule update --init --recursive --remote",
|
|
13
|
+
"postinstall": "pnpm submodule:update",
|
|
14
14
|
"build": "vite build --mode production",
|
|
15
15
|
"build:zip": "vite build --mode production && tsx scripts/build.mts",
|
|
16
16
|
"preview": "vite preview",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"scripts": {
|
|
3
|
-
"prepare": "
|
|
3
|
+
"prepare": "node .husky/install.mjs",
|
|
4
|
+
"postinstall": "pnpm submodule:update",
|
|
5
|
+
"submodule:update": "git submodule update --init --recursive --remote",
|
|
4
6
|
"lint-staged": "lint-staged",
|
|
5
7
|
"commit": "git add . && git-cz"
|
|
6
8
|
},
|