jjb-cmd 2.5.7 → 2.5.8
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 +1 -1
- package/src/ai-pull.js +15 -11
package/package.json
CHANGED
package/src/ai-pull.js
CHANGED
|
@@ -241,19 +241,23 @@ module.exports = (branch) => {
|
|
|
241
241
|
});
|
|
242
242
|
console.log(`✓ 仓库代码拉取成功(分支: ${targetBranch})`);
|
|
243
243
|
|
|
244
|
-
// 步骤2: 将仓库 admin
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
// 步骤2: 将仓库 admin 下的 Cursor 配置同步到当前项目 .cursor/
|
|
245
|
+
// 优先使用 admin/.cursor 下的一级子目录(避免复制成 .cursor/.cursor);否则回退为 admin 下的一级子目录
|
|
246
|
+
console.log('步骤2: 正在复制 admin 内 Cursor 资源到 .cursor/...');
|
|
247
|
+
const adminRootPath = path.join(cloneDir, 'admin');
|
|
248
|
+
const adminCursorPath = path.join(adminRootPath, '.cursor');
|
|
249
|
+
const syncSourcePath = fs.existsSync(adminCursorPath) ? adminCursorPath : adminRootPath;
|
|
250
|
+
const syncSourceLabel = fs.existsSync(adminCursorPath) ? 'admin/.cursor' : 'admin';
|
|
247
251
|
const cursorDir = path.join(root_path, '.cursor');
|
|
248
252
|
|
|
249
|
-
if (!fs.existsSync(
|
|
253
|
+
if (!fs.existsSync(adminRootPath)) {
|
|
250
254
|
console.log('【Warning】:仓库中未找到 admin 文件夹');
|
|
251
255
|
step3();
|
|
252
256
|
} else {
|
|
253
257
|
let subdirs;
|
|
254
258
|
try {
|
|
255
|
-
subdirs = fs.readdirSync(
|
|
256
|
-
const p = path.join(
|
|
259
|
+
subdirs = fs.readdirSync(syncSourcePath).filter((name) => {
|
|
260
|
+
const p = path.join(syncSourcePath, name);
|
|
257
261
|
try {
|
|
258
262
|
return fs.statSync(p).isDirectory();
|
|
259
263
|
} catch (e) {
|
|
@@ -261,13 +265,13 @@ module.exports = (branch) => {
|
|
|
261
265
|
}
|
|
262
266
|
});
|
|
263
267
|
} catch (e) {
|
|
264
|
-
console.error(
|
|
268
|
+
console.error(`【Error】:读取 ${syncSourceLabel} 目录失败`, e.message);
|
|
265
269
|
cleanupAndExit(1);
|
|
266
270
|
return;
|
|
267
271
|
}
|
|
268
272
|
|
|
269
273
|
if (subdirs.length === 0) {
|
|
270
|
-
console.log(
|
|
274
|
+
console.log(`【Warning】:${syncSourceLabel} 下没有子文件夹可同步`);
|
|
271
275
|
step3();
|
|
272
276
|
} else {
|
|
273
277
|
try {
|
|
@@ -282,16 +286,16 @@ module.exports = (branch) => {
|
|
|
282
286
|
|
|
283
287
|
function copyAdminDirAt(i) {
|
|
284
288
|
if (i >= subdirs.length) {
|
|
285
|
-
console.log(`✓ 已将
|
|
289
|
+
console.log(`✓ 已将 ${syncSourceLabel} 下 ${subdirs.length} 个文件夹复制到 .cursor/(${subdirs.join(', ')})`);
|
|
286
290
|
step3();
|
|
287
291
|
return;
|
|
288
292
|
}
|
|
289
293
|
const name = subdirs[i];
|
|
290
|
-
const srcPath = path.join(
|
|
294
|
+
const srcPath = path.join(syncSourcePath, name);
|
|
291
295
|
const destPath = path.join(cursorDir, name);
|
|
292
296
|
const afterCopy = (err) => {
|
|
293
297
|
if (err) {
|
|
294
|
-
console.error(`【Error】:复制
|
|
298
|
+
console.error(`【Error】:复制 ${syncSourceLabel}/${name} 失败`, err.message);
|
|
295
299
|
cleanupAndExit(1);
|
|
296
300
|
return;
|
|
297
301
|
}
|