zero-ai 1.0.69 → 1.0.70
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/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
const Ec = require("../epic");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
2
4
|
const child = require('child_process');
|
|
3
5
|
const Ut = require("../commander-shared");
|
|
4
6
|
|
|
7
|
+
const REPO_URL = "https://gitee.com/silentbalanceyh/scaffold-ui.git";
|
|
8
|
+
const REPO_NAME = "scaffold-ui";
|
|
9
|
+
|
|
5
10
|
const COMMANDS = [
|
|
6
11
|
"run-default.sh",
|
|
7
12
|
"run-doc.sh",
|
|
@@ -60,24 +65,21 @@ const COMMANDS = [
|
|
|
60
65
|
]
|
|
61
66
|
|
|
62
67
|
const executeRemote = (actual = {}, options = {}) => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
const outputBase = "."; // 仓库与 .gitignore 使用项目根目录
|
|
69
|
+
const repoCache = path.resolve(outputBase, ".r2mo", "repo", REPO_NAME);
|
|
70
|
+
const repoCacheDir = path.dirname(repoCache);
|
|
71
|
+
// 确保 .r2mo/repo 目录存在
|
|
72
|
+
if (!fs.existsSync(repoCacheDir)) {
|
|
73
|
+
fs.mkdirSync(repoCacheDir, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
// 若已有克隆则先删除,再拉取
|
|
76
|
+
if (Ec.isExist(repoCache)) {
|
|
77
|
+
Ec.info(`发现存在旧仓库,正在删除:${repoCache}`);
|
|
78
|
+
child.execSync(`rm -rf ${repoCache}`, options);
|
|
73
79
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
child.execSync(cmdGit, options);
|
|
78
|
-
const cmdRm = `rm -rf ${pathSource}/.git`;
|
|
79
|
-
child.execSync(cmdRm, options);
|
|
80
|
-
return pathSource;
|
|
80
|
+
Ec.info(`拉取最新代码到:${repoCache}`);
|
|
81
|
+
child.execSync(`git clone ${REPO_URL} ${repoCache}`, options);
|
|
82
|
+
return repoCache;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
const executeLocal = (actual = {}, options = {}) => {
|
|
@@ -121,26 +123,45 @@ module.exports = (options) => {
|
|
|
121
123
|
pathSource = executeRemote(parsed, optionsWait);
|
|
122
124
|
}
|
|
123
125
|
if (pathSource) {
|
|
124
|
-
|
|
126
|
+
const outputBase = ".";
|
|
127
|
+
// 确保 .r2mo/repo 在 .gitignore 中
|
|
128
|
+
const gitignorePath = path.resolve(outputBase, ".gitignore");
|
|
129
|
+
const ignoreEntry = ".r2mo/repo/";
|
|
130
|
+
if (fs.existsSync(gitignorePath)) {
|
|
131
|
+
const gitignoreContent = fs.readFileSync(gitignorePath, "utf-8");
|
|
132
|
+
const hasIgnoreEntry = gitignoreContent.split("\n").some((line) => {
|
|
133
|
+
const t = line.trim();
|
|
134
|
+
return t === ".r2mo/repo" || t === ".r2mo/repo/";
|
|
135
|
+
});
|
|
136
|
+
if (!hasIgnoreEntry) {
|
|
137
|
+
const newContent = gitignoreContent.endsWith("\n")
|
|
138
|
+
? `${gitignoreContent}${ignoreEntry}\n`
|
|
139
|
+
: `${gitignoreContent}\n${ignoreEntry}\n`;
|
|
140
|
+
fs.writeFileSync(gitignorePath, newContent, "utf-8");
|
|
141
|
+
Ec.info(`已将 ${ignoreEntry} 添加到 .gitignore`);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
fs.writeFileSync(gitignorePath, `${ignoreEntry}\n`, "utf-8");
|
|
145
|
+
Ec.info(`已创建 .gitignore 并添加 ${ignoreEntry}`);
|
|
146
|
+
}
|
|
147
|
+
// 拷贝框架文件
|
|
125
148
|
Ec.info(`开始更新主框架:......`.yellow);
|
|
126
149
|
COMMANDS.forEach(command => {
|
|
127
150
|
Ec.info(`处理目录:${command.green}`);
|
|
128
|
-
let cmd;
|
|
129
151
|
if (command.endsWith("/")) {
|
|
130
|
-
// 目录拷贝
|
|
131
152
|
if (!Ec.isExist(command)) {
|
|
132
|
-
|
|
133
|
-
child.execSync(cmdDir, optionsWait);
|
|
153
|
+
child.execSync(`mkdir -p ${command}`, optionsWait);
|
|
134
154
|
}
|
|
135
|
-
|
|
136
|
-
child.execSync(cmd, optionsWait);
|
|
155
|
+
child.execSync(`cp -rf ${pathSource}/${command}* ./${command}`, optionsWait);
|
|
137
156
|
} else {
|
|
138
|
-
|
|
139
|
-
cmd = `cp -rf ${pathSource}/${command} ./${command}`;
|
|
140
|
-
child.execSync(cmd, optionsWait);
|
|
157
|
+
child.execSync(`cp -rf ${pathSource}/${command} ./${command}`, optionsWait);
|
|
141
158
|
}
|
|
142
|
-
})
|
|
159
|
+
});
|
|
143
160
|
Ec.info(`主框架更新完成:${pathSource}!`.help);
|
|
161
|
+
// 拷贝完成后移除临时仓库
|
|
162
|
+
Ec.info(`正在移除临时仓库:${pathSource}`);
|
|
163
|
+
child.execSync(`rm -rf ${pathSource}`, optionsWait);
|
|
164
|
+
Ec.info(`临时仓库已移除。`);
|
|
144
165
|
}
|
|
145
166
|
}
|
|
146
167
|
/**
|