@icebreakers/monorepo 3.2.13 → 3.2.15
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/cli.cjs +6 -10
- package/dist/cli.mjs +6 -10
- package/dist/index.cjs +42 -29
- package/dist/index.d.cts +26 -5
- package/dist/index.d.mts +27 -6
- package/dist/index.mjs +2 -3
- package/dist/{upgrade-DiPTZW6J.mjs → upgrade-BTlzE81C.mjs} +240 -419
- package/dist/{upgrade-DjOZstRC.cjs → upgrade-a6Bh03Pw.cjs} +575 -649
- package/package.json +7 -12
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
|
-
var __defProp
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
20
15
|
}
|
|
21
16
|
return to;
|
|
22
17
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
19
|
value: mod,
|
|
25
20
|
enumerable: true
|
|
26
21
|
}) : target, mod));
|
|
27
|
-
|
|
28
22
|
//#endregion
|
|
29
23
|
let git_url_parse = require("git-url-parse");
|
|
30
24
|
git_url_parse = __toESM(git_url_parse);
|
|
@@ -36,10 +30,13 @@ let pathe = require("pathe");
|
|
|
36
30
|
pathe = __toESM(pathe);
|
|
37
31
|
let node_process = require("node:process");
|
|
38
32
|
node_process = __toESM(node_process);
|
|
39
|
-
let
|
|
40
|
-
fs_extra = __toESM(fs_extra);
|
|
33
|
+
let node_fs_promises = require("node:fs/promises");
|
|
41
34
|
let consola = require("consola");
|
|
42
35
|
let _icebreakers_monorepo_templates = require("@icebreakers/monorepo-templates");
|
|
36
|
+
let yaml = require("yaml");
|
|
37
|
+
yaml = __toESM(yaml);
|
|
38
|
+
let node_crypto = require("node:crypto");
|
|
39
|
+
node_crypto = __toESM(node_crypto);
|
|
43
40
|
let c12 = require("c12");
|
|
44
41
|
let node_os = require("node:os");
|
|
45
42
|
node_os = __toESM(node_os);
|
|
@@ -49,10 +46,6 @@ let node_url = require("node:url");
|
|
|
49
46
|
let picocolors = require("picocolors");
|
|
50
47
|
picocolors = __toESM(picocolors);
|
|
51
48
|
require("@pnpm/types");
|
|
52
|
-
let yaml = require("yaml");
|
|
53
|
-
yaml = __toESM(yaml);
|
|
54
|
-
let node_crypto = require("node:crypto");
|
|
55
|
-
node_crypto = __toESM(node_crypto);
|
|
56
49
|
let comment_json = require("comment-json");
|
|
57
50
|
let p_queue = require("p-queue");
|
|
58
51
|
p_queue = __toESM(p_queue);
|
|
@@ -60,75 +53,6 @@ let klaw = require("klaw");
|
|
|
60
53
|
klaw = __toESM(klaw);
|
|
61
54
|
let node_buffer = require("node:buffer");
|
|
62
55
|
let semver = require("semver");
|
|
63
|
-
|
|
64
|
-
//#region ../../node_modules/.pnpm/get-value@4.0.1/node_modules/get-value/dist/index.mjs
|
|
65
|
-
var __defProp = Object.defineProperty;
|
|
66
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
67
|
-
value,
|
|
68
|
-
configurable: true
|
|
69
|
-
});
|
|
70
|
-
var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
|
|
71
|
-
var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
72
|
-
if (typeof options.join === "function") return options.join(segs);
|
|
73
|
-
return segs[0] + joinChar + segs[1];
|
|
74
|
-
}, "join");
|
|
75
|
-
var split = /* @__PURE__ */ __name((path, splitChar, options) => {
|
|
76
|
-
if (typeof options.split === "function") return options.split(path);
|
|
77
|
-
return path.split(splitChar);
|
|
78
|
-
}, "split");
|
|
79
|
-
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
80
|
-
if (typeof options?.isValid === "function") return options.isValid(key, target);
|
|
81
|
-
return true;
|
|
82
|
-
}, "isValid");
|
|
83
|
-
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
84
|
-
return isObject(v) || typeof v === "function";
|
|
85
|
-
}, "isValidObject");
|
|
86
|
-
var index_default = /* @__PURE__ */ __name((target, path, options = {}) => {
|
|
87
|
-
if (!isObject(options)) options = { default: options };
|
|
88
|
-
if (!isValidObject(target)) return typeof options.default !== "undefined" ? options.default : target;
|
|
89
|
-
if (typeof path === "number") path = String(path);
|
|
90
|
-
const pathIsArray = Array.isArray(path);
|
|
91
|
-
const pathIsString = typeof path === "string";
|
|
92
|
-
const splitChar = options.separator || ".";
|
|
93
|
-
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
94
|
-
if (!pathIsString && !pathIsArray) return target;
|
|
95
|
-
if (target[path] !== void 0) return isValid(path, target, options) ? target[path] : options.default;
|
|
96
|
-
const segs = pathIsArray ? path : split(path, splitChar, options);
|
|
97
|
-
const len = segs.length;
|
|
98
|
-
let idx = 0;
|
|
99
|
-
do {
|
|
100
|
-
let prop = segs[idx];
|
|
101
|
-
if (typeof prop !== "string") prop = String(prop);
|
|
102
|
-
while (prop && prop.slice(-1) === "\\") prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
103
|
-
if (target[prop] !== void 0) {
|
|
104
|
-
if (!isValid(prop, target, options)) return options.default;
|
|
105
|
-
target = target[prop];
|
|
106
|
-
} else {
|
|
107
|
-
let hasProp = false;
|
|
108
|
-
let n = idx + 1;
|
|
109
|
-
while (n < len) {
|
|
110
|
-
prop = join([prop, segs[n++]], joinChar, options);
|
|
111
|
-
if (hasProp = target[prop] !== void 0) {
|
|
112
|
-
if (!isValid(prop, target, options)) return options.default;
|
|
113
|
-
target = target[prop];
|
|
114
|
-
idx = n - 1;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (!hasProp) return options.default;
|
|
119
|
-
}
|
|
120
|
-
} while (++idx < len && isValidObject(target));
|
|
121
|
-
if (idx === len) return target;
|
|
122
|
-
return options.default;
|
|
123
|
-
}, "getValue");
|
|
124
|
-
/*!
|
|
125
|
-
* get-value <https://github.com/jonschlinkert/get-value>
|
|
126
|
-
*
|
|
127
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
128
|
-
* Released under the MIT License.
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
56
|
//#region src/core/git.ts
|
|
133
57
|
/**
|
|
134
58
|
* 对 simple-git 的轻量封装,集中处理配置缓存与常用查询。
|
|
@@ -163,8 +87,8 @@ var GitClient = class {
|
|
|
163
87
|
* 解析 remote.origin.url,返回 git-url-parse 的结构,便于获取仓库元信息。
|
|
164
88
|
*/
|
|
165
89
|
async getGitUrl() {
|
|
166
|
-
const x =
|
|
167
|
-
if (x) return (0, git_url_parse.default)(x);
|
|
90
|
+
const x = (await this.getConfig())["remote.origin.url"];
|
|
91
|
+
if (typeof x === "string") return (0, git_url_parse.default)(x);
|
|
168
92
|
}
|
|
169
93
|
/**
|
|
170
94
|
* 组合 owner/name,生成常用的仓库名表达。
|
|
@@ -179,8 +103,8 @@ var GitClient = class {
|
|
|
179
103
|
async getUser() {
|
|
180
104
|
const config = await this.getConfig();
|
|
181
105
|
return {
|
|
182
|
-
name:
|
|
183
|
-
email:
|
|
106
|
+
name: config["user.name"],
|
|
107
|
+
email: config["user.email"]
|
|
184
108
|
};
|
|
185
109
|
}
|
|
186
110
|
/**
|
|
@@ -195,7 +119,6 @@ var GitClient = class {
|
|
|
195
119
|
}
|
|
196
120
|
}
|
|
197
121
|
};
|
|
198
|
-
|
|
199
122
|
//#endregion
|
|
200
123
|
//#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
201
124
|
function isPlainObject$1(value) {
|
|
@@ -224,19 +147,18 @@ function createDefu(merger) {
|
|
|
224
147
|
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
225
148
|
}
|
|
226
149
|
const defu = createDefu();
|
|
227
|
-
|
|
150
|
+
createDefu((object, key, currentValue) => {
|
|
228
151
|
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
229
152
|
object[key] = currentValue(object[key]);
|
|
230
153
|
return true;
|
|
231
154
|
}
|
|
232
155
|
});
|
|
233
|
-
|
|
156
|
+
createDefu((object, key, currentValue) => {
|
|
234
157
|
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
235
158
|
object[key] = currentValue(object[key]);
|
|
236
159
|
return true;
|
|
237
160
|
}
|
|
238
161
|
});
|
|
239
|
-
|
|
240
162
|
//#endregion
|
|
241
163
|
//#region src/core/workspace.ts
|
|
242
164
|
/**
|
|
@@ -275,14 +197,96 @@ async function getWorkspaceData(cwd, options) {
|
|
|
275
197
|
packages: await getWorkspacePackages(workspaceDir, options)
|
|
276
198
|
};
|
|
277
199
|
}
|
|
278
|
-
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/utils/fs.ts
|
|
202
|
+
function stringifyJson(data, options) {
|
|
203
|
+
return JSON.stringify(data, void 0, options?.spaces);
|
|
204
|
+
}
|
|
205
|
+
async function ensureParentDir(targetPath) {
|
|
206
|
+
await (0, node_fs_promises.mkdir)(pathe.default.dirname(targetPath), { recursive: true });
|
|
207
|
+
}
|
|
208
|
+
async function pathExists(targetPath) {
|
|
209
|
+
try {
|
|
210
|
+
await (0, node_fs_promises.access)(targetPath);
|
|
211
|
+
return true;
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const exists = pathExists;
|
|
217
|
+
async function ensureDir(targetPath) {
|
|
218
|
+
await (0, node_fs_promises.mkdir)(targetPath, { recursive: true });
|
|
219
|
+
}
|
|
220
|
+
async function ensureFile(targetPath) {
|
|
221
|
+
await ensureParentDir(targetPath);
|
|
222
|
+
await (await (0, node_fs_promises.open)(targetPath, "a")).close();
|
|
223
|
+
}
|
|
224
|
+
async function remove(targetPath) {
|
|
225
|
+
await (0, node_fs_promises.rm)(targetPath, {
|
|
226
|
+
recursive: true,
|
|
227
|
+
force: true,
|
|
228
|
+
maxRetries: 3,
|
|
229
|
+
retryDelay: 100
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
async function copy(sourcePath, targetPath) {
|
|
233
|
+
await (0, node_fs_promises.cp)(sourcePath, targetPath, {
|
|
234
|
+
recursive: true,
|
|
235
|
+
force: true
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async function outputFile(targetPath, data, options) {
|
|
239
|
+
await ensureParentDir(targetPath);
|
|
240
|
+
await (0, node_fs_promises.writeFile)(targetPath, data, options);
|
|
241
|
+
}
|
|
242
|
+
async function readJson(targetPath) {
|
|
243
|
+
return JSON.parse(await (0, node_fs_promises.readFile)(targetPath, "utf8"));
|
|
244
|
+
}
|
|
245
|
+
const readJSON = readJson;
|
|
246
|
+
async function writeJson(targetPath, data, options) {
|
|
247
|
+
await (0, node_fs_promises.writeFile)(targetPath, stringifyJson(data, options), "utf8");
|
|
248
|
+
}
|
|
249
|
+
const writeJSON = writeJson;
|
|
250
|
+
async function outputJson(targetPath, data, options) {
|
|
251
|
+
await ensureParentDir(targetPath);
|
|
252
|
+
await writeJson(targetPath, data, options);
|
|
253
|
+
}
|
|
254
|
+
const outputJSON = outputJson;
|
|
255
|
+
/**
|
|
256
|
+
* 判断是否为可忽略的文件系统错误。
|
|
257
|
+
* - ENOENT: 文件已被删除
|
|
258
|
+
* - EBUSY: Windows 中资源被系统占用
|
|
259
|
+
*/
|
|
260
|
+
function isIgnorableFsError(error) {
|
|
261
|
+
if (!error) return false;
|
|
262
|
+
const code = error.code;
|
|
263
|
+
return code === "ENOENT" || code === "EBUSY" || code === "EEXIST";
|
|
264
|
+
}
|
|
265
|
+
const fs = {
|
|
266
|
+
copy,
|
|
267
|
+
ensureDir,
|
|
268
|
+
ensureFile,
|
|
269
|
+
exists,
|
|
270
|
+
mkdtemp: node_fs_promises.mkdtemp,
|
|
271
|
+
outputFile,
|
|
272
|
+
outputJSON,
|
|
273
|
+
outputJson,
|
|
274
|
+
pathExists,
|
|
275
|
+
readFile: node_fs_promises.readFile,
|
|
276
|
+
readJSON,
|
|
277
|
+
readJson,
|
|
278
|
+
remove,
|
|
279
|
+
stat: node_fs_promises.stat,
|
|
280
|
+
writeFile: node_fs_promises.writeFile,
|
|
281
|
+
writeJSON,
|
|
282
|
+
writeJson
|
|
283
|
+
};
|
|
279
284
|
//#endregion
|
|
280
285
|
//#region src/core/logger.ts
|
|
281
286
|
/**
|
|
282
287
|
* 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
|
|
283
288
|
*/
|
|
284
289
|
const logger = (0, consola.createConsola)();
|
|
285
|
-
|
|
286
290
|
//#endregion
|
|
287
291
|
//#region src/commands/ai.ts
|
|
288
292
|
const agenticSections = [
|
|
@@ -313,7 +317,7 @@ function createTimestampFolderName(date = /* @__PURE__ */ new Date()) {
|
|
|
313
317
|
async function generateAgenticTemplate(options = {}) {
|
|
314
318
|
const cwd = options.cwd ?? node_process.default.cwd();
|
|
315
319
|
const format = options.format ?? "md";
|
|
316
|
-
const baseDir = options.baseDir ??
|
|
320
|
+
const baseDir = options.baseDir ?? "agentic/prompts";
|
|
317
321
|
if (format !== "md" && format !== "json") throw new Error(`不支持的模板格式:${format}`);
|
|
318
322
|
const template = format === "md" ? renderMarkdownTemplate() : renderJsonTemplate();
|
|
319
323
|
const ext = format === "json" ? "json" : "md";
|
|
@@ -325,17 +329,17 @@ async function generateAgenticTemplate(options = {}) {
|
|
|
325
329
|
}
|
|
326
330
|
const targetPath = pathe.default.resolve(cwd, outputPath);
|
|
327
331
|
const targetDir = pathe.default.dirname(targetPath);
|
|
328
|
-
await
|
|
329
|
-
const exists = await
|
|
332
|
+
await fs.ensureDir(targetDir);
|
|
333
|
+
const exists = await fs.pathExists(targetPath);
|
|
330
334
|
if (exists && !options.force) throw new Error(`目标文件已存在:${pathe.default.relative(cwd, targetPath)}`);
|
|
331
|
-
await
|
|
335
|
+
await fs.outputFile(targetPath, template, "utf8");
|
|
332
336
|
const actionLabel = exists ? "已覆盖模板" : "已生成模板";
|
|
333
337
|
logger.success(`${actionLabel}:${pathe.default.relative(cwd, targetPath)}`);
|
|
334
338
|
return template;
|
|
335
339
|
}
|
|
336
340
|
async function loadAgenticTasks(filePath, cwd) {
|
|
337
341
|
const fullPath = pathe.default.resolve(cwd, filePath);
|
|
338
|
-
const tasks = await
|
|
342
|
+
const tasks = await fs.readJson(fullPath);
|
|
339
343
|
if (!Array.isArray(tasks)) throw new TypeError("任务清单需要是数组");
|
|
340
344
|
return tasks;
|
|
341
345
|
}
|
|
@@ -353,175 +357,127 @@ async function generateAgenticTemplates(tasks, defaults = {}) {
|
|
|
353
357
|
}
|
|
354
358
|
return results;
|
|
355
359
|
}
|
|
356
|
-
|
|
357
360
|
//#endregion
|
|
358
|
-
//#region
|
|
359
|
-
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
363
|
-
* Released under the MIT License.
|
|
361
|
+
//#region src/utils/github.ts
|
|
362
|
+
/**
|
|
363
|
+
* 将 Issue 模版里的 discussions 链接同步为当前仓库的 discussions 地址。
|
|
364
364
|
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
|
|
365
|
+
function updateIssueTemplateConfig(source, repoName) {
|
|
366
|
+
if (!repoName) return source;
|
|
367
|
+
let doc;
|
|
368
|
+
try {
|
|
369
|
+
doc = (0, yaml.parseDocument)(source);
|
|
370
|
+
} catch {
|
|
371
|
+
return source;
|
|
372
|
+
}
|
|
373
|
+
const contactLinks = doc.get("contact_links");
|
|
374
|
+
if (!(0, yaml.isSeq)(contactLinks)) return source;
|
|
375
|
+
const nextUrl = `https://github.com/${repoName}/discussions`;
|
|
376
|
+
let changed = false;
|
|
377
|
+
contactLinks.items.forEach((_, index) => {
|
|
378
|
+
const url = doc.getIn([
|
|
379
|
+
"contact_links",
|
|
380
|
+
index,
|
|
381
|
+
"url"
|
|
382
|
+
]);
|
|
383
|
+
if (typeof url !== "string") return;
|
|
384
|
+
if (!url.includes("/discussions")) return;
|
|
385
|
+
if (url === nextUrl) return;
|
|
386
|
+
doc.setIn([
|
|
387
|
+
"contact_links",
|
|
388
|
+
index,
|
|
389
|
+
"url"
|
|
390
|
+
], nextUrl);
|
|
391
|
+
changed = true;
|
|
392
|
+
});
|
|
393
|
+
if (!changed) return source;
|
|
394
|
+
return doc.toString();
|
|
395
|
+
}
|
|
372
396
|
//#endregion
|
|
373
|
-
//#region
|
|
374
|
-
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
378
|
-
* Released under the MIT License.
|
|
397
|
+
//#region src/utils/hash.ts
|
|
398
|
+
/**
|
|
399
|
+
* 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
|
|
379
400
|
*/
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
//#region ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
|
|
388
|
-
/*!
|
|
389
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
390
|
-
*
|
|
391
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
392
|
-
* Released under the MIT License.
|
|
401
|
+
function getFileHash(data) {
|
|
402
|
+
const hashSum = node_crypto.default.createHash("md5");
|
|
403
|
+
hashSum.update(data);
|
|
404
|
+
return hashSum.digest("hex");
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* 对比两个文件的 md5,如果不一致则认为内容有变化。
|
|
393
408
|
*/
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
ctor = o.constructor;
|
|
403
|
-
if (typeof ctor !== "function") return false;
|
|
404
|
-
prot = ctor.prototype;
|
|
405
|
-
if (isObjectObject(prot) === false) return false;
|
|
406
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
|
|
407
|
-
return true;
|
|
408
|
-
};
|
|
409
|
-
}));
|
|
410
|
-
|
|
409
|
+
function isFileChanged(src, dest) {
|
|
410
|
+
try {
|
|
411
|
+
return getFileHash(src) !== getFileHash(dest);
|
|
412
|
+
} catch (err) {
|
|
413
|
+
logger.error("Error calculating file hash:", err);
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
411
417
|
//#endregion
|
|
412
|
-
//#region
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const isUnsafeKey = (key) => {
|
|
427
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
428
|
-
};
|
|
429
|
-
const validateKey = (key) => {
|
|
430
|
-
if (!isPrimitive(key)) throw new TypeError("Object keys must be strings or symbols");
|
|
431
|
-
if (isUnsafeKey(key)) throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
432
|
-
};
|
|
433
|
-
const toStringKey = (input) => {
|
|
434
|
-
return Array.isArray(input) ? input.flat().map(String).join(",") : input;
|
|
435
|
-
};
|
|
436
|
-
const createMemoKey = (input, options) => {
|
|
437
|
-
if (typeof input !== "string" || !options) return input;
|
|
438
|
-
let key = input + ";";
|
|
439
|
-
if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
|
|
440
|
-
if (options.separator !== void 0) key += `separator=${options.separator};`;
|
|
441
|
-
if (options.split !== void 0) key += `split=${options.split};`;
|
|
442
|
-
if (options.merge !== void 0) key += `merge=${options.merge};`;
|
|
443
|
-
if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
|
|
444
|
-
return key;
|
|
445
|
-
};
|
|
446
|
-
const memoize = (input, options, fn) => {
|
|
447
|
-
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
|
448
|
-
validateKey(key);
|
|
449
|
-
const value = setValue.cache.get(key) || fn();
|
|
450
|
-
setValue.cache.set(key, value);
|
|
451
|
-
return value;
|
|
452
|
-
};
|
|
453
|
-
const splitString = (input, options = {}) => {
|
|
454
|
-
const sep = options.separator || ".";
|
|
455
|
-
const preserve = sep === "/" ? false : options.preservePaths;
|
|
456
|
-
if (typeof input === "string" && preserve !== false && /\//.test(input)) return [input];
|
|
457
|
-
const parts = [];
|
|
458
|
-
let part = "";
|
|
459
|
-
const push = (part) => {
|
|
460
|
-
let number;
|
|
461
|
-
if (part.trim() !== "" && Number.isInteger(number = Number(part))) parts.push(number);
|
|
462
|
-
else parts.push(part);
|
|
463
|
-
};
|
|
464
|
-
for (let i = 0; i < input.length; i++) {
|
|
465
|
-
const value = input[i];
|
|
466
|
-
if (value === "\\") {
|
|
467
|
-
part += input[++i];
|
|
468
|
-
continue;
|
|
469
|
-
}
|
|
470
|
-
if (value === sep) {
|
|
471
|
-
push(part);
|
|
472
|
-
part = "";
|
|
473
|
-
continue;
|
|
474
|
-
}
|
|
475
|
-
part += value;
|
|
418
|
+
//#region src/utils/object.ts
|
|
419
|
+
const arrayIndexPattern = /^\d+$/;
|
|
420
|
+
function isArrayIndex(value) {
|
|
421
|
+
return arrayIndexPattern.test(value);
|
|
422
|
+
}
|
|
423
|
+
function parsePath(input) {
|
|
424
|
+
const segments = [];
|
|
425
|
+
let current = "";
|
|
426
|
+
let escaped = false;
|
|
427
|
+
for (const char of input) {
|
|
428
|
+
if (escaped) {
|
|
429
|
+
current += char;
|
|
430
|
+
escaped = false;
|
|
431
|
+
continue;
|
|
476
432
|
}
|
|
477
|
-
if (
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const split = (input, options) => {
|
|
481
|
-
if (options && typeof options.split === "function") return options.split(input);
|
|
482
|
-
if (typeof input === "symbol") return [input];
|
|
483
|
-
if (Array.isArray(input)) return input;
|
|
484
|
-
return memoize(input, options, () => splitString(input, options));
|
|
485
|
-
};
|
|
486
|
-
const assignProp = (obj, prop, value, options) => {
|
|
487
|
-
validateKey(prop);
|
|
488
|
-
if (value === void 0) deleteProperty(obj, prop);
|
|
489
|
-
else if (options && options.merge) {
|
|
490
|
-
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
491
|
-
if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) obj[prop] = merge(obj[prop], value);
|
|
492
|
-
else obj[prop] = value;
|
|
493
|
-
} else obj[prop] = value;
|
|
494
|
-
return obj;
|
|
495
|
-
};
|
|
496
|
-
const setValue = (target, path, value, options) => {
|
|
497
|
-
if (!path || !isObject(target)) return target;
|
|
498
|
-
const keys = split(path, options);
|
|
499
|
-
let obj = target;
|
|
500
|
-
for (let i = 0; i < keys.length; i++) {
|
|
501
|
-
const key = keys[i];
|
|
502
|
-
const next = keys[i + 1];
|
|
503
|
-
validateKey(key);
|
|
504
|
-
if (next === void 0) {
|
|
505
|
-
assignProp(obj, key, value, options);
|
|
506
|
-
break;
|
|
507
|
-
}
|
|
508
|
-
if (typeof next === "number" && !Array.isArray(obj[key])) {
|
|
509
|
-
obj = obj[key] = [];
|
|
510
|
-
continue;
|
|
511
|
-
}
|
|
512
|
-
if (!isObject(obj[key])) obj[key] = {};
|
|
513
|
-
obj = obj[key];
|
|
433
|
+
if (char === "\\") {
|
|
434
|
+
escaped = true;
|
|
435
|
+
continue;
|
|
514
436
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
437
|
+
if (char === ".") {
|
|
438
|
+
segments.push(current);
|
|
439
|
+
current = "";
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
current += char;
|
|
443
|
+
}
|
|
444
|
+
segments.push(current);
|
|
445
|
+
return segments;
|
|
446
|
+
}
|
|
447
|
+
function setByPath(target, path, value) {
|
|
448
|
+
const segments = typeof path === "string" ? parsePath(path) : [...path];
|
|
449
|
+
if (!segments.length) return target;
|
|
450
|
+
let current = target;
|
|
451
|
+
for (let index = 0; index < segments.length - 1; index++) {
|
|
452
|
+
const segment = segments[index];
|
|
453
|
+
const nextSegment = segments[index + 1];
|
|
454
|
+
const key = Array.isArray(current) && isArrayIndex(segment) ? Number(segment) : segment;
|
|
455
|
+
const existing = current[key];
|
|
456
|
+
if (typeof existing !== "object" || existing === null) current[key] = isArrayIndex(nextSegment) ? [] : {};
|
|
457
|
+
current = current[key];
|
|
458
|
+
}
|
|
459
|
+
const lastSegment = segments.at(-1);
|
|
460
|
+
const lastKey = Array.isArray(current) && isArrayIndex(lastSegment) ? Number(lastSegment) : lastSegment;
|
|
461
|
+
current[lastKey] = value;
|
|
462
|
+
return target;
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/utils/regexp.ts
|
|
466
|
+
const regexpSpecialCharacterPattern = /[|\\{}()[\]^$+*?.]/g;
|
|
467
|
+
const hyphenPattern = /-/g;
|
|
468
|
+
/**
|
|
469
|
+
* 逃逸正则表达式中所有特殊字符,避免被当做模式解析。
|
|
470
|
+
*/
|
|
471
|
+
function escapeStringRegexp(str) {
|
|
472
|
+
return str.replace(regexpSpecialCharacterPattern, "\\$&").replace(hyphenPattern, "\\x2d");
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* 判断字符串是否命中任意一个正则,用于过滤要同步的资产文件。
|
|
476
|
+
*/
|
|
477
|
+
function isMatch(str, arr) {
|
|
478
|
+
for (const reg of arr) if (reg.test(str)) return true;
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
525
481
|
//#endregion
|
|
526
482
|
//#region src/core/config.ts
|
|
527
483
|
/**
|
|
@@ -566,12 +522,10 @@ async function loadMonorepoConfig(cwd) {
|
|
|
566
522
|
async function resolveCommandConfig(name, cwd) {
|
|
567
523
|
return ((await loadMonorepoConfig(cwd)).commands ?? {})[name] ?? {};
|
|
568
524
|
}
|
|
569
|
-
|
|
570
525
|
//#endregion
|
|
571
526
|
//#region package.json
|
|
572
527
|
var name = "@icebreakers/monorepo";
|
|
573
|
-
var version = "3.2.
|
|
574
|
-
|
|
528
|
+
var version = "3.2.15";
|
|
575
529
|
//#endregion
|
|
576
530
|
//#region src/constants.ts
|
|
577
531
|
/**
|
|
@@ -586,7 +540,6 @@ const packageDir = node_path.dirname(packageJsonPath);
|
|
|
586
540
|
* monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
|
|
587
541
|
*/
|
|
588
542
|
const rootDir = node_path.resolve(packageDir, "..", "..");
|
|
589
|
-
|
|
590
543
|
//#endregion
|
|
591
544
|
//#region src/commands/skills.ts
|
|
592
545
|
const skillName = "icebreakers-monorepo-cli";
|
|
@@ -600,11 +553,11 @@ function getSkillTargetPaths(homeDir = node_os.default.homedir()) {
|
|
|
600
553
|
}
|
|
601
554
|
function normalizeTargets(values) {
|
|
602
555
|
if (!values?.length) return;
|
|
603
|
-
return
|
|
556
|
+
return [...new Set(values)];
|
|
604
557
|
}
|
|
605
558
|
async function syncSkills(options = {}) {
|
|
606
559
|
const cwd = options.cwd ?? node_process.default.cwd();
|
|
607
|
-
if (!await
|
|
560
|
+
if (!await fs.pathExists(skillSourceDir)) {
|
|
608
561
|
const relative = pathe.default.relative(cwd, skillSourceDir);
|
|
609
562
|
throw new Error(`未找到技能目录:${relative || skillSourceDir}`);
|
|
610
563
|
}
|
|
@@ -622,9 +575,9 @@ async function syncSkills(options = {}) {
|
|
|
622
575
|
const results = [];
|
|
623
576
|
for (const target of targets) {
|
|
624
577
|
const dest = targetPaths[target];
|
|
625
|
-
await
|
|
626
|
-
await
|
|
627
|
-
await
|
|
578
|
+
await fs.remove(dest);
|
|
579
|
+
await fs.ensureDir(pathe.default.dirname(dest));
|
|
580
|
+
await fs.copy(skillSourceDir, dest);
|
|
628
581
|
results.push({
|
|
629
582
|
target,
|
|
630
583
|
dest
|
|
@@ -632,10 +585,8 @@ async function syncSkills(options = {}) {
|
|
|
632
585
|
}
|
|
633
586
|
return results;
|
|
634
587
|
}
|
|
635
|
-
|
|
636
588
|
//#endregion
|
|
637
589
|
//#region src/commands/clean.ts
|
|
638
|
-
var import_set_value = /* @__PURE__ */ __toESM(require_set_value(), 1);
|
|
639
590
|
function mergeCleanConfig(base, overrides) {
|
|
640
591
|
const normalizedBase = base ?? {};
|
|
641
592
|
if (!overrides) return normalizedBase;
|
|
@@ -677,22 +628,21 @@ async function cleanProjects(cwd, overrides) {
|
|
|
677
628
|
const qoderDir = pathe.default.resolve(workspaceDir, ".qoder");
|
|
678
629
|
const docsPlansDir = pathe.default.resolve(workspaceDir, "docs/plans");
|
|
679
630
|
const skillTargets = Object.values(getSkillTargetPaths());
|
|
680
|
-
const candidates =
|
|
631
|
+
const candidates = [...new Set([
|
|
681
632
|
...cleanDirs.filter(Boolean),
|
|
682
633
|
readmeZh,
|
|
683
634
|
qoderDir,
|
|
684
635
|
docsPlansDir,
|
|
685
636
|
...skillTargets
|
|
686
|
-
])
|
|
637
|
+
])];
|
|
687
638
|
await Promise.all(candidates.map(async (dir) => {
|
|
688
|
-
if (await
|
|
639
|
+
if (await fs.pathExists(dir)) await fs.remove(dir);
|
|
689
640
|
}));
|
|
690
641
|
const name = pathe.default.resolve(workspaceDir, "package.json");
|
|
691
|
-
const pkgJson = await
|
|
692
|
-
(
|
|
693
|
-
await
|
|
642
|
+
const pkgJson = await fs.readJson(name);
|
|
643
|
+
setByPath(pkgJson, "devDependencies.@icebreakers/monorepo", cleanConfig?.pinnedVersion ?? "latest");
|
|
644
|
+
await fs.outputJson(name, pkgJson, { spaces: 2 });
|
|
694
645
|
}
|
|
695
|
-
|
|
696
646
|
//#endregion
|
|
697
647
|
//#region src/commands/create.ts
|
|
698
648
|
/**
|
|
@@ -797,7 +747,7 @@ async function applyGitMetadata(pkgJson, repoDir, targetDir) {
|
|
|
797
747
|
const git = new GitClient({ baseDir: repoDir });
|
|
798
748
|
const repoName = await git.getRepoName();
|
|
799
749
|
if (!repoName) return;
|
|
800
|
-
(
|
|
750
|
+
setByPath(pkgJson, ["bugs", "url"], `https://github.com/${repoName}/issues`);
|
|
801
751
|
const repository = {
|
|
802
752
|
type: "git",
|
|
803
753
|
url: `git+https://github.com/${repoName}.git`
|
|
@@ -805,9 +755,9 @@ async function applyGitMetadata(pkgJson, repoDir, targetDir) {
|
|
|
805
755
|
const directoryBase = await git.getRepoRoot() ?? repoDir;
|
|
806
756
|
const relative = pathe.default.relative(directoryBase, targetDir);
|
|
807
757
|
if (relative && relative !== ".") repository.directory = relative.split(pathe.default.sep).join("/");
|
|
808
|
-
(
|
|
758
|
+
setByPath(pkgJson, "repository", repository);
|
|
809
759
|
const gitUser = await git.getUser();
|
|
810
|
-
if (gitUser?.name && gitUser?.email) (
|
|
760
|
+
if (gitUser?.name && gitUser?.email) setByPath(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
811
761
|
} catch {}
|
|
812
762
|
}
|
|
813
763
|
/**
|
|
@@ -819,35 +769,34 @@ async function createNewProject(options) {
|
|
|
819
769
|
const renameJson = options?.renameJson ?? createConfig?.renameJson ?? false;
|
|
820
770
|
const rawName = options?.name ?? createConfig?.name;
|
|
821
771
|
const name = typeof rawName === "string" ? rawName.trim() : void 0;
|
|
822
|
-
const requestedTemplate = options?.type ?? createConfig?.type ?? createConfig?.defaultTemplate ??
|
|
772
|
+
const requestedTemplate = options?.type ?? createConfig?.type ?? createConfig?.defaultTemplate ?? "unbuild";
|
|
823
773
|
const templateDefinitions = getTemplateMap(createConfig?.templateMap);
|
|
824
774
|
const templatesRoot = createConfig?.templatesDir ? pathe.default.resolve(cwd, createConfig.templatesDir) : _icebreakers_monorepo_templates.templatesDir;
|
|
825
|
-
const fallbackTemplate = createConfig?.defaultTemplate ??
|
|
775
|
+
const fallbackTemplate = createConfig?.defaultTemplate ?? "unbuild";
|
|
826
776
|
const bundlerName = typeof requestedTemplate === "string" && templateDefinitions[requestedTemplate] ? requestedTemplate : fallbackTemplate;
|
|
827
777
|
const templateDefinition = templateDefinitions[bundlerName];
|
|
828
778
|
if (!templateDefinition) throw new Error(`未找到名为 ${bundlerName} 的模板,请检查 monorepo.config.ts`);
|
|
829
779
|
const from = pathe.default.join(templatesRoot, templateDefinition.source);
|
|
830
780
|
const targetName = name && name.length > 0 ? name : templateDefinition.target;
|
|
831
781
|
const to = pathe.default.join(cwd, targetName);
|
|
832
|
-
if (await
|
|
833
|
-
await
|
|
782
|
+
if (await fs.pathExists(to)) throw new Error(`${picocolors.default.red("目标目录已存在")}: ${pathe.default.relative(cwd, to)}`);
|
|
783
|
+
await fs.ensureDir(to);
|
|
834
784
|
const sourceJsonPath = pathe.default.resolve(from, "package.json");
|
|
835
|
-
const hasPackageJson = await
|
|
785
|
+
const hasPackageJson = await fs.pathExists(sourceJsonPath);
|
|
836
786
|
await (0, _icebreakers_monorepo_templates.scaffoldTemplate)({
|
|
837
787
|
sourceDir: from,
|
|
838
788
|
targetDir: to,
|
|
839
789
|
skipRootBasenames: ["package.json"]
|
|
840
790
|
});
|
|
841
791
|
if (hasPackageJson) {
|
|
842
|
-
const sourceJson = await
|
|
843
|
-
(
|
|
844
|
-
(
|
|
792
|
+
const sourceJson = await fs.readJson(sourceJsonPath);
|
|
793
|
+
setByPath(sourceJson, "version", "0.0.0");
|
|
794
|
+
setByPath(sourceJson, "name", name?.startsWith("@") ? name : pathe.default.basename(targetName));
|
|
845
795
|
await applyGitMetadata(sourceJson, cwd, to);
|
|
846
|
-
await
|
|
796
|
+
await fs.outputJson(pathe.default.resolve(to, renameJson ? "package.mock.json" : "package.json"), sourceJson, { spaces: 2 });
|
|
847
797
|
}
|
|
848
798
|
logger.success(`${picocolors.default.bgGreenBright(picocolors.default.white(`[${bundlerName}]`))} ${targetName} 项目创建成功!`);
|
|
849
799
|
}
|
|
850
|
-
|
|
851
800
|
//#endregion
|
|
852
801
|
//#region src/core/context.ts
|
|
853
802
|
/**
|
|
@@ -868,7 +817,6 @@ async function createContext(cwd) {
|
|
|
868
817
|
config: await loadMonorepoConfig(workspaceDir)
|
|
869
818
|
};
|
|
870
819
|
}
|
|
871
|
-
|
|
872
820
|
//#endregion
|
|
873
821
|
//#region src/commands/init/setChangeset.ts
|
|
874
822
|
/**
|
|
@@ -876,106 +824,17 @@ async function createContext(cwd) {
|
|
|
876
824
|
*/
|
|
877
825
|
async function setChangeset_default(ctx) {
|
|
878
826
|
const { gitUrl, workspaceFilepath } = ctx;
|
|
879
|
-
if (gitUrl && await
|
|
827
|
+
if (gitUrl && await fs.exists(workspaceFilepath)) {
|
|
880
828
|
const changesetConfigPath = pathe.default.resolve(pathe.default.dirname(workspaceFilepath), ".changeset/config.json");
|
|
881
|
-
if (await
|
|
882
|
-
const changesetConfig = await
|
|
829
|
+
if (await fs.exists(changesetConfigPath)) {
|
|
830
|
+
const changesetConfig = await fs.readJson(changesetConfigPath);
|
|
883
831
|
if (gitUrl.full_name) {
|
|
884
|
-
(
|
|
885
|
-
await
|
|
832
|
+
setByPath(changesetConfig, "changelog.1.repo", gitUrl.full_name);
|
|
833
|
+
await fs.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
|
|
886
834
|
}
|
|
887
835
|
}
|
|
888
836
|
}
|
|
889
837
|
}
|
|
890
|
-
|
|
891
|
-
//#endregion
|
|
892
|
-
//#region src/utils/fs.ts
|
|
893
|
-
/**
|
|
894
|
-
* 判断是否为可忽略的文件系统错误。
|
|
895
|
-
* - ENOENT: 文件已被删除
|
|
896
|
-
* - EBUSY: Windows 中资源被系统占用
|
|
897
|
-
*/
|
|
898
|
-
function isIgnorableFsError(error) {
|
|
899
|
-
if (!error) return false;
|
|
900
|
-
const code = error.code;
|
|
901
|
-
return code === "ENOENT" || code === "EBUSY" || code === "EEXIST";
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
//#endregion
|
|
905
|
-
//#region src/utils/github.ts
|
|
906
|
-
/**
|
|
907
|
-
* 将 Issue 模版里的 discussions 链接同步为当前仓库的 discussions 地址。
|
|
908
|
-
*/
|
|
909
|
-
function updateIssueTemplateConfig(source, repoName) {
|
|
910
|
-
if (!repoName) return source;
|
|
911
|
-
let doc;
|
|
912
|
-
try {
|
|
913
|
-
doc = (0, yaml.parseDocument)(source);
|
|
914
|
-
} catch {
|
|
915
|
-
return source;
|
|
916
|
-
}
|
|
917
|
-
const contactLinks = doc.get("contact_links");
|
|
918
|
-
if (!(0, yaml.isSeq)(contactLinks)) return source;
|
|
919
|
-
const nextUrl = `https://github.com/${repoName}/discussions`;
|
|
920
|
-
let changed = false;
|
|
921
|
-
contactLinks.items.forEach((_, index) => {
|
|
922
|
-
const url = doc.getIn([
|
|
923
|
-
"contact_links",
|
|
924
|
-
index,
|
|
925
|
-
"url"
|
|
926
|
-
]);
|
|
927
|
-
if (typeof url !== "string") return;
|
|
928
|
-
if (!url.includes("/discussions")) return;
|
|
929
|
-
if (url === nextUrl) return;
|
|
930
|
-
doc.setIn([
|
|
931
|
-
"contact_links",
|
|
932
|
-
index,
|
|
933
|
-
"url"
|
|
934
|
-
], nextUrl);
|
|
935
|
-
changed = true;
|
|
936
|
-
});
|
|
937
|
-
if (!changed) return source;
|
|
938
|
-
return doc.toString();
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
//#endregion
|
|
942
|
-
//#region src/utils/hash.ts
|
|
943
|
-
/**
|
|
944
|
-
* 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
|
|
945
|
-
*/
|
|
946
|
-
function getFileHash(data) {
|
|
947
|
-
const hashSum = node_crypto.default.createHash("md5");
|
|
948
|
-
hashSum.update(data);
|
|
949
|
-
return hashSum.digest("hex");
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* 对比两个文件的 md5,如果不一致则认为内容有变化。
|
|
953
|
-
*/
|
|
954
|
-
function isFileChanged(src, dest) {
|
|
955
|
-
try {
|
|
956
|
-
return getFileHash(src) !== getFileHash(dest);
|
|
957
|
-
} catch (err) {
|
|
958
|
-
logger.error("Error calculating file hash:", err);
|
|
959
|
-
return false;
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
//#endregion
|
|
964
|
-
//#region src/utils/regexp.ts
|
|
965
|
-
/**
|
|
966
|
-
* 逃逸正则表达式中所有特殊字符,避免被当做模式解析。
|
|
967
|
-
*/
|
|
968
|
-
function escapeStringRegexp(str) {
|
|
969
|
-
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* 判断字符串是否命中任意一个正则,用于过滤要同步的资产文件。
|
|
973
|
-
*/
|
|
974
|
-
function isMatch(str, arr) {
|
|
975
|
-
for (const reg of arr) if (reg.test(str)) return true;
|
|
976
|
-
return false;
|
|
977
|
-
}
|
|
978
|
-
|
|
979
838
|
//#endregion
|
|
980
839
|
//#region src/commands/init/setIssueTemplateConfig.ts
|
|
981
840
|
/**
|
|
@@ -985,12 +844,11 @@ async function setIssueTemplateConfig_default(ctx) {
|
|
|
985
844
|
const repoName = ctx.gitUrl?.full_name;
|
|
986
845
|
if (!repoName) return;
|
|
987
846
|
const configPath = pathe.default.resolve(ctx.cwd, ".github/ISSUE_TEMPLATE/config.yml");
|
|
988
|
-
if (!await
|
|
989
|
-
const source = await
|
|
847
|
+
if (!await fs.pathExists(configPath)) return;
|
|
848
|
+
const source = await fs.readFile(configPath, "utf8");
|
|
990
849
|
const next = updateIssueTemplateConfig(source, repoName);
|
|
991
|
-
if (next !== source) await
|
|
850
|
+
if (next !== source) await fs.writeFile(configPath, next, "utf8");
|
|
992
851
|
}
|
|
993
|
-
|
|
994
852
|
//#endregion
|
|
995
853
|
//#region src/commands/init/setPkgJson.ts
|
|
996
854
|
/**
|
|
@@ -998,24 +856,23 @@ async function setIssueTemplateConfig_default(ctx) {
|
|
|
998
856
|
*/
|
|
999
857
|
async function setPkgJson_default(ctx) {
|
|
1000
858
|
const { gitUrl, gitUser, packages, cwd, workspaceFilepath } = ctx;
|
|
1001
|
-
const workspaceExists = await
|
|
859
|
+
const workspaceExists = await fs.pathExists(workspaceFilepath);
|
|
1002
860
|
if (gitUrl && workspaceExists) await Promise.all(packages.map(async (pkg) => {
|
|
1003
|
-
if (!await
|
|
861
|
+
if (!await fs.pathExists(pkg.pkgJsonPath)) return;
|
|
1004
862
|
const pkgJson = JSON.parse(JSON.stringify(pkg.manifest));
|
|
1005
863
|
const directory = pathe.default.relative(cwd, pkg.rootDir);
|
|
1006
|
-
(
|
|
864
|
+
setByPath(pkgJson, ["bugs", "url"], `https://github.com/${gitUrl.full_name}/issues`);
|
|
1007
865
|
const repository = {
|
|
1008
866
|
type: "git",
|
|
1009
867
|
url: `git+https://github.com/${gitUrl.full_name}.git`
|
|
1010
868
|
};
|
|
1011
869
|
if (directory) repository.directory = directory;
|
|
1012
|
-
(
|
|
1013
|
-
if (gitUser?.name && gitUser?.email) (
|
|
870
|
+
setByPath(pkgJson, "repository", repository);
|
|
871
|
+
if (gitUser?.name && gitUser?.email) setByPath(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
1014
872
|
const nextContent = `${JSON.stringify(pkgJson, void 0, 2)}\n`;
|
|
1015
|
-
if (await
|
|
873
|
+
if (await fs.readFile(pkg.pkgJsonPath, "utf8") !== nextContent) await fs.writeFile(pkg.pkgJsonPath, nextContent, "utf8");
|
|
1016
874
|
}));
|
|
1017
875
|
}
|
|
1018
|
-
|
|
1019
876
|
//#endregion
|
|
1020
877
|
//#region src/commands/init/setReadme.ts
|
|
1021
878
|
async function getRows(ctx) {
|
|
@@ -1023,7 +880,7 @@ async function getRows(ctx) {
|
|
|
1023
880
|
const rows = [];
|
|
1024
881
|
if (gitUrl) rows.push(`# ${gitUrl.name}\n`);
|
|
1025
882
|
rows.push("## Packages\n");
|
|
1026
|
-
const sortedPackages =
|
|
883
|
+
const sortedPackages = packages.toSorted((a, b) => {
|
|
1027
884
|
const left = a.manifest.name ?? "";
|
|
1028
885
|
const right = b.manifest.name ?? "";
|
|
1029
886
|
return left.localeCompare(right);
|
|
@@ -1060,9 +917,8 @@ async function getRows(ctx) {
|
|
|
1060
917
|
*/
|
|
1061
918
|
async function setReadme_default(ctx) {
|
|
1062
919
|
const rows = await getRows(ctx);
|
|
1063
|
-
await
|
|
920
|
+
await fs.writeFile(pathe.default.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}\n`);
|
|
1064
921
|
}
|
|
1065
|
-
|
|
1066
922
|
//#endregion
|
|
1067
923
|
//#region src/commands/init/index.ts
|
|
1068
924
|
/**
|
|
@@ -1076,7 +932,6 @@ async function init(cwd) {
|
|
|
1076
932
|
if (!initConfig.skipReadme) await setReadme_default(ctx);
|
|
1077
933
|
if (!initConfig.skipIssueTemplateConfig) await setIssueTemplateConfig_default(ctx);
|
|
1078
934
|
}
|
|
1079
|
-
|
|
1080
935
|
//#endregion
|
|
1081
936
|
//#region src/commands/mirror/sources.ts
|
|
1082
937
|
const chinaMirrorsEnvs = {
|
|
@@ -1107,7 +962,6 @@ const chinaMirrorsEnvs = {
|
|
|
1107
962
|
npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
|
|
1108
963
|
npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
|
|
1109
964
|
};
|
|
1110
|
-
|
|
1111
965
|
//#endregion
|
|
1112
966
|
//#region src/commands/mirror/utils.ts
|
|
1113
967
|
/**
|
|
@@ -1120,9 +974,8 @@ function setMirror(obj, envs = chinaMirrorsEnvs) {
|
|
|
1120
974
|
"osx"
|
|
1121
975
|
];
|
|
1122
976
|
const prefix = "terminal.integrated.env";
|
|
1123
|
-
if (typeof obj === "object" && obj) for (const platform of platforms) (
|
|
977
|
+
if (typeof obj === "object" && obj) for (const platform of platforms) setByPath(obj, [prefix, platform].join(".").replaceAll(".", "\\."), envs);
|
|
1124
978
|
}
|
|
1125
|
-
|
|
1126
979
|
//#endregion
|
|
1127
980
|
//#region src/commands/mirror/binaryMirror.ts
|
|
1128
981
|
/**
|
|
@@ -1131,16 +984,15 @@ function setMirror(obj, envs = chinaMirrorsEnvs) {
|
|
|
1131
984
|
async function setVscodeBinaryMirror(cwd) {
|
|
1132
985
|
const mirrorConfig = await resolveCommandConfig("mirror", cwd);
|
|
1133
986
|
const targetJsonPath = pathe.default.resolve(cwd, ".vscode/settings.json");
|
|
1134
|
-
await
|
|
1135
|
-
const json = (0, comment_json.parse)(await
|
|
987
|
+
await fs.ensureFile(targetJsonPath);
|
|
988
|
+
const json = (0, comment_json.parse)(await fs.readFile(targetJsonPath, "utf8"), void 0, false);
|
|
1136
989
|
const env = mirrorConfig?.env ? {
|
|
1137
990
|
...chinaMirrorsEnvs,
|
|
1138
991
|
...mirrorConfig.env
|
|
1139
992
|
} : chinaMirrorsEnvs;
|
|
1140
993
|
json && typeof json === "object" && setMirror(json, env);
|
|
1141
|
-
await
|
|
994
|
+
await fs.writeFile(targetJsonPath, `${(0, comment_json.stringify)(json, void 0, 2)}\n`, "utf8");
|
|
1142
995
|
}
|
|
1143
|
-
|
|
1144
996
|
//#endregion
|
|
1145
997
|
//#region src/commands/sync.ts
|
|
1146
998
|
function renderCommand(template, pkgName) {
|
|
@@ -1158,9 +1010,9 @@ async function syncNpmMirror(cwd, options) {
|
|
|
1158
1010
|
logger.info(`[当前工作区Repo]:\n${packages.map((x) => `- ${picocolors.default.green(x.manifest.name)} : ${pathe.default.relative(workspaceDir, x.rootDir)}`).join("\n")}\n`);
|
|
1159
1011
|
const set = new Set(packages.map((x) => x.manifest.name));
|
|
1160
1012
|
if (packageFilter?.length) {
|
|
1161
|
-
for (const name of
|
|
1013
|
+
for (const name of [...set]) if (!name || !packageFilter.includes(name)) set.delete(name);
|
|
1162
1014
|
}
|
|
1163
|
-
logger.info(`[即将同步的包]:\n${Array.from(set
|
|
1015
|
+
logger.info(`[即将同步的包]:\n${Array.from(set, (x) => `- ${picocolors.default.green(x ?? "")}`).join("\n")}\n`);
|
|
1164
1016
|
const queue = new p_queue.default({ concurrency: configConcurrency ?? Math.max(node_os.default.cpus().length, 1) });
|
|
1165
1017
|
const template = configCommand ?? "cnpm sync {name}";
|
|
1166
1018
|
const tasks = [];
|
|
@@ -1172,17 +1024,18 @@ async function syncNpmMirror(cwd, options) {
|
|
|
1172
1024
|
}
|
|
1173
1025
|
await Promise.all(tasks);
|
|
1174
1026
|
}
|
|
1175
|
-
|
|
1176
1027
|
//#endregion
|
|
1177
1028
|
//#region src/commands/upgrade/agents.ts
|
|
1029
|
+
const crlfPattern$1 = /\r\n/g;
|
|
1030
|
+
const h2HeadingPrefixPattern = /^##\s+/;
|
|
1178
1031
|
function normalizeEol$1(input) {
|
|
1179
|
-
return input.replace(
|
|
1032
|
+
return input.replace(crlfPattern$1, "\n");
|
|
1180
1033
|
}
|
|
1181
1034
|
function normalizeComparableContent(input) {
|
|
1182
1035
|
return normalizeEol$1(input).trimEnd();
|
|
1183
1036
|
}
|
|
1184
1037
|
function normalizeHeadingKey(line) {
|
|
1185
|
-
return line.replace(
|
|
1038
|
+
return line.replace(h2HeadingPrefixPattern, "").trim().toLowerCase();
|
|
1186
1039
|
}
|
|
1187
1040
|
function trimEdgeEmptyLines(lines) {
|
|
1188
1041
|
const next = [...lines];
|
|
@@ -1204,7 +1057,7 @@ function parseMarkdownByH2(content) {
|
|
|
1204
1057
|
const sections = [];
|
|
1205
1058
|
let current;
|
|
1206
1059
|
for (const line of lines) {
|
|
1207
|
-
if (
|
|
1060
|
+
if (h2HeadingPrefixPattern.test(line)) {
|
|
1208
1061
|
if (current) sections.push(current);
|
|
1209
1062
|
current = {
|
|
1210
1063
|
key: normalizeHeadingKey(line),
|
|
@@ -1270,7 +1123,6 @@ function mergeAgentsMarkdown(source, target) {
|
|
|
1270
1123
|
function isAgentsMarkdownEquivalent(left, right) {
|
|
1271
1124
|
return normalizeComparableContent(left) === normalizeComparableContent(right);
|
|
1272
1125
|
}
|
|
1273
|
-
|
|
1274
1126
|
//#endregion
|
|
1275
1127
|
//#region src/commands/upgrade/overwrite.ts
|
|
1276
1128
|
function asBuffer(data) {
|
|
@@ -1278,7 +1130,7 @@ function asBuffer(data) {
|
|
|
1278
1130
|
}
|
|
1279
1131
|
async function evaluateWriteIntent(targetPath, options) {
|
|
1280
1132
|
const { skipOverwrite, source } = options;
|
|
1281
|
-
if (!await
|
|
1133
|
+
if (!await fs.pathExists(targetPath)) return {
|
|
1282
1134
|
type: "write",
|
|
1283
1135
|
reason: "missing"
|
|
1284
1136
|
};
|
|
@@ -1289,7 +1141,7 @@ async function evaluateWriteIntent(targetPath, options) {
|
|
|
1289
1141
|
const src = asBuffer(source);
|
|
1290
1142
|
let destSize = 0;
|
|
1291
1143
|
try {
|
|
1292
|
-
destSize = (await
|
|
1144
|
+
destSize = (await fs.stat(targetPath)).size;
|
|
1293
1145
|
} catch {
|
|
1294
1146
|
return {
|
|
1295
1147
|
type: "write",
|
|
@@ -1300,7 +1152,7 @@ async function evaluateWriteIntent(targetPath, options) {
|
|
|
1300
1152
|
type: "prompt",
|
|
1301
1153
|
reason: "changed"
|
|
1302
1154
|
};
|
|
1303
|
-
if (!isFileChanged(src, await
|
|
1155
|
+
if (!isFileChanged(src, await fs.readFile(targetPath))) return {
|
|
1304
1156
|
type: "skip",
|
|
1305
1157
|
reason: "identical"
|
|
1306
1158
|
};
|
|
@@ -1335,21 +1187,13 @@ async function flushPendingOverwrites(pending) {
|
|
|
1335
1187
|
const selectedSet = new Set(selected);
|
|
1336
1188
|
for (const item of pending) if (selectedSet.has(item.targetPath)) await item.action();
|
|
1337
1189
|
}
|
|
1338
|
-
|
|
1339
|
-
//#endregion
|
|
1340
|
-
//#region src/commands/upgrade/scripts.ts
|
|
1341
|
-
/**
|
|
1342
|
-
* 升级时注入到 package.json 的脚本命令集合,保证常用脚本齐全。
|
|
1343
|
-
*/
|
|
1344
|
-
const scripts = {
|
|
1190
|
+
const scriptsEntries = Object.entries({
|
|
1345
1191
|
"script:init": "monorepo init",
|
|
1346
1192
|
"script:sync": "monorepo sync",
|
|
1347
1193
|
"script:clean": "monorepo clean",
|
|
1348
1194
|
"script:mirror": "monorepo mirror",
|
|
1349
1195
|
"commitlint": "commitlint --edit"
|
|
1350
|
-
};
|
|
1351
|
-
const scriptsEntries = Object.entries(scripts);
|
|
1352
|
-
|
|
1196
|
+
});
|
|
1353
1197
|
//#endregion
|
|
1354
1198
|
//#region src/commands/upgrade/pkg-json.ts
|
|
1355
1199
|
const NON_OVERRIDABLE_PREFIXES = ["workspace:", "catalog:"];
|
|
@@ -1413,7 +1257,6 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
1413
1257
|
targetPkgJson.scripts = scripts;
|
|
1414
1258
|
}
|
|
1415
1259
|
}
|
|
1416
|
-
|
|
1417
1260
|
//#endregion
|
|
1418
1261
|
//#region src/commands/upgrade/workspace.ts
|
|
1419
1262
|
function isPlainObject(value) {
|
|
@@ -1469,11 +1312,11 @@ function mergeWorkspaceManifest(source, target) {
|
|
|
1469
1312
|
}
|
|
1470
1313
|
return result;
|
|
1471
1314
|
}
|
|
1472
|
-
|
|
1473
1315
|
//#endregion
|
|
1474
1316
|
//#region src/commands/upgrade/index.ts
|
|
1317
|
+
const crlfPattern = /\r\n/g;
|
|
1475
1318
|
function normalizeEol(input) {
|
|
1476
|
-
return input.replace(
|
|
1319
|
+
return input.replace(crlfPattern, "\n");
|
|
1477
1320
|
}
|
|
1478
1321
|
function normalizeGitignoreLine(line) {
|
|
1479
1322
|
const trimmed = line.trim();
|
|
@@ -1522,7 +1365,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1522
1365
|
const baseTargets = (0, _icebreakers_monorepo_templates.getAssetTargets)(useCoreAssets);
|
|
1523
1366
|
const configTargets = upgradeConfig?.targets ?? [];
|
|
1524
1367
|
const mergeTargets = upgradeConfig?.mergeTargets;
|
|
1525
|
-
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] :
|
|
1368
|
+
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : [...new Set([...baseTargets, ...configTargets])] : baseTargets;
|
|
1526
1369
|
if (merged.interactive) targets = await (0, _icebreakers_monorepo_templates.checkbox)({
|
|
1527
1370
|
message: "选择你需要的文件",
|
|
1528
1371
|
choices: targets.map((x) => {
|
|
@@ -1554,14 +1397,14 @@ async function upgradeMonorepo(opts) {
|
|
|
1554
1397
|
const targetPath = pathe.default.resolve(absOutDir, relPath);
|
|
1555
1398
|
try {
|
|
1556
1399
|
if (relPath === "package.json") {
|
|
1557
|
-
if (!await
|
|
1558
|
-
const sourcePkgJson = await
|
|
1559
|
-
const targetPkgJson = await
|
|
1400
|
+
if (!await fs.pathExists(targetPath)) continue;
|
|
1401
|
+
const sourcePkgJson = await fs.readJson(file.path);
|
|
1402
|
+
const targetPkgJson = await fs.readJson(targetPath);
|
|
1560
1403
|
setPkgJson(sourcePkgJson, targetPkgJson, scriptOverrides ? { scripts: scriptOverrides } : void 0);
|
|
1561
1404
|
const data = `${JSON.stringify(targetPkgJson, void 0, 2)}\n`;
|
|
1562
1405
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1563
1406
|
const action = async () => {
|
|
1564
|
-
await
|
|
1407
|
+
await fs.outputFile(targetPath, data, "utf8");
|
|
1565
1408
|
logger.success(targetPath);
|
|
1566
1409
|
};
|
|
1567
1410
|
await scheduleOverwrite(intent, {
|
|
@@ -1573,14 +1416,14 @@ async function upgradeMonorepo(opts) {
|
|
|
1573
1416
|
continue;
|
|
1574
1417
|
}
|
|
1575
1418
|
if (relPath === "pnpm-workspace.yaml") {
|
|
1576
|
-
const sourceManifest = normalizeWorkspaceManifest(yaml.default.parse(await
|
|
1577
|
-
const exists = await
|
|
1578
|
-
const targetManifest = exists ? normalizeWorkspaceManifest(yaml.default.parse(await
|
|
1419
|
+
const sourceManifest = normalizeWorkspaceManifest(yaml.default.parse(await fs.readFile(file.path, "utf8")));
|
|
1420
|
+
const exists = await fs.pathExists(targetPath);
|
|
1421
|
+
const targetManifest = exists ? normalizeWorkspaceManifest(yaml.default.parse(await fs.readFile(targetPath, "utf8"))) : normalizeWorkspaceManifest({});
|
|
1579
1422
|
const mergedManifest = exists ? mergeWorkspaceManifest(sourceManifest, targetManifest) : sourceManifest;
|
|
1580
1423
|
const data = yaml.default.stringify(mergedManifest, { singleQuote: true });
|
|
1581
1424
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1582
1425
|
const action = async () => {
|
|
1583
|
-
await
|
|
1426
|
+
await fs.outputFile(targetPath, data, "utf8");
|
|
1584
1427
|
logger.success(targetPath);
|
|
1585
1428
|
};
|
|
1586
1429
|
await scheduleOverwrite(intent, {
|
|
@@ -1592,14 +1435,14 @@ async function upgradeMonorepo(opts) {
|
|
|
1592
1435
|
continue;
|
|
1593
1436
|
}
|
|
1594
1437
|
if (relPath === ".gitignore") {
|
|
1595
|
-
const source = await
|
|
1596
|
-
const exists = await
|
|
1597
|
-
const target = exists ? await
|
|
1438
|
+
const source = await fs.readFile(file.path, "utf8");
|
|
1439
|
+
const exists = await fs.pathExists(targetPath);
|
|
1440
|
+
const target = exists ? await fs.readFile(targetPath, "utf8") : "";
|
|
1598
1441
|
const data = exists ? mergeGitignore(source, target) : source;
|
|
1599
1442
|
if (exists && isTextEquivalent(target, data)) continue;
|
|
1600
1443
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1601
1444
|
const action = async () => {
|
|
1602
|
-
await
|
|
1445
|
+
await fs.outputFile(targetPath, data, "utf8");
|
|
1603
1446
|
logger.success(targetPath);
|
|
1604
1447
|
};
|
|
1605
1448
|
await scheduleOverwrite(intent, {
|
|
@@ -1611,14 +1454,14 @@ async function upgradeMonorepo(opts) {
|
|
|
1611
1454
|
continue;
|
|
1612
1455
|
}
|
|
1613
1456
|
if (relPath === "AGENTS.md") {
|
|
1614
|
-
const source = await
|
|
1615
|
-
const exists = await
|
|
1616
|
-
const target = exists ? await
|
|
1457
|
+
const source = await fs.readFile(file.path, "utf8");
|
|
1458
|
+
const exists = await fs.pathExists(targetPath);
|
|
1459
|
+
const target = exists ? await fs.readFile(targetPath, "utf8") : "";
|
|
1617
1460
|
const data = exists ? mergeAgentsMarkdown(source, target) : source;
|
|
1618
1461
|
if (exists && isAgentsMarkdownEquivalent(target, data)) continue;
|
|
1619
1462
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1620
1463
|
const action = async () => {
|
|
1621
|
-
await
|
|
1464
|
+
await fs.outputFile(targetPath, data, "utf8");
|
|
1622
1465
|
logger.success(targetPath);
|
|
1623
1466
|
};
|
|
1624
1467
|
await scheduleOverwrite(intent, {
|
|
@@ -1630,12 +1473,12 @@ async function upgradeMonorepo(opts) {
|
|
|
1630
1473
|
continue;
|
|
1631
1474
|
}
|
|
1632
1475
|
if (relPath === ".changeset/config.json" && repoName) {
|
|
1633
|
-
const changesetJson = await
|
|
1634
|
-
(
|
|
1476
|
+
const changesetJson = await fs.readJson(file.path);
|
|
1477
|
+
setByPath(changesetJson, "changelog.1.repo", repoName);
|
|
1635
1478
|
const data = `${JSON.stringify(changesetJson, void 0, 2)}\n`;
|
|
1636
1479
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1637
1480
|
const action = async () => {
|
|
1638
|
-
await
|
|
1481
|
+
await fs.outputFile(targetPath, data, "utf8");
|
|
1639
1482
|
logger.success(targetPath);
|
|
1640
1483
|
};
|
|
1641
1484
|
await scheduleOverwrite(intent, {
|
|
@@ -1647,13 +1490,13 @@ async function upgradeMonorepo(opts) {
|
|
|
1647
1490
|
continue;
|
|
1648
1491
|
}
|
|
1649
1492
|
if (relPath === "LICENSE") {
|
|
1650
|
-
const source = await
|
|
1493
|
+
const source = await fs.readFile(file.path);
|
|
1651
1494
|
const intent = await evaluateWriteIntent(targetPath, {
|
|
1652
1495
|
skipOverwrite: true,
|
|
1653
1496
|
source
|
|
1654
1497
|
});
|
|
1655
1498
|
const action = async () => {
|
|
1656
|
-
await
|
|
1499
|
+
await fs.outputFile(targetPath, source);
|
|
1657
1500
|
logger.success(targetPath);
|
|
1658
1501
|
};
|
|
1659
1502
|
await scheduleOverwrite(intent, {
|
|
@@ -1665,10 +1508,10 @@ async function upgradeMonorepo(opts) {
|
|
|
1665
1508
|
continue;
|
|
1666
1509
|
}
|
|
1667
1510
|
if (relPath === ".github/ISSUE_TEMPLATE/config.yml") {
|
|
1668
|
-
const data = updateIssueTemplateConfig(await
|
|
1511
|
+
const data = updateIssueTemplateConfig(await fs.readFile(file.path, "utf8"), repoName);
|
|
1669
1512
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1670
1513
|
const action = async () => {
|
|
1671
|
-
await
|
|
1514
|
+
await fs.outputFile(targetPath, data);
|
|
1672
1515
|
logger.success(targetPath);
|
|
1673
1516
|
};
|
|
1674
1517
|
await scheduleOverwrite(intent, {
|
|
@@ -1679,10 +1522,10 @@ async function upgradeMonorepo(opts) {
|
|
|
1679
1522
|
});
|
|
1680
1523
|
continue;
|
|
1681
1524
|
}
|
|
1682
|
-
const source = await
|
|
1525
|
+
const source = await fs.readFile(file.path);
|
|
1683
1526
|
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(source));
|
|
1684
1527
|
const action = async () => {
|
|
1685
|
-
await
|
|
1528
|
+
await fs.outputFile(targetPath, source);
|
|
1686
1529
|
logger.success(targetPath);
|
|
1687
1530
|
};
|
|
1688
1531
|
await scheduleOverwrite(intent, {
|
|
@@ -1698,227 +1541,310 @@ async function upgradeMonorepo(opts) {
|
|
|
1698
1541
|
}
|
|
1699
1542
|
await flushPendingOverwrites(pendingOverwrites);
|
|
1700
1543
|
}
|
|
1701
|
-
|
|
1702
1544
|
//#endregion
|
|
1703
|
-
Object.defineProperty(exports,
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1545
|
+
Object.defineProperty(exports, "GitClient", {
|
|
1546
|
+
enumerable: true,
|
|
1547
|
+
get: function() {
|
|
1548
|
+
return GitClient;
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
Object.defineProperty(exports, "__toESM", {
|
|
1552
|
+
enumerable: true,
|
|
1553
|
+
get: function() {
|
|
1554
|
+
return __toESM;
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
Object.defineProperty(exports, "cleanProjects", {
|
|
1558
|
+
enumerable: true,
|
|
1559
|
+
get: function() {
|
|
1560
|
+
return cleanProjects;
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
Object.defineProperty(exports, "copy", {
|
|
1564
|
+
enumerable: true,
|
|
1565
|
+
get: function() {
|
|
1566
|
+
return copy;
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
Object.defineProperty(exports, "createContext", {
|
|
1570
|
+
enumerable: true,
|
|
1571
|
+
get: function() {
|
|
1572
|
+
return createContext;
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
Object.defineProperty(exports, "createNewProject", {
|
|
1576
|
+
enumerable: true,
|
|
1577
|
+
get: function() {
|
|
1578
|
+
return createNewProject;
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
Object.defineProperty(exports, "createTimestampFolderName", {
|
|
1582
|
+
enumerable: true,
|
|
1583
|
+
get: function() {
|
|
1584
|
+
return createTimestampFolderName;
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
Object.defineProperty(exports, "defaultAgenticBaseDir", {
|
|
1588
|
+
enumerable: true,
|
|
1589
|
+
get: function() {
|
|
1590
|
+
return defaultAgenticBaseDir;
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
Object.defineProperty(exports, "defaultTemplate", {
|
|
1594
|
+
enumerable: true,
|
|
1595
|
+
get: function() {
|
|
1596
|
+
return defaultTemplate;
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
Object.defineProperty(exports, "defineMonorepoConfig", {
|
|
1600
|
+
enumerable: true,
|
|
1601
|
+
get: function() {
|
|
1602
|
+
return defineMonorepoConfig;
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
Object.defineProperty(exports, "ensureDir", {
|
|
1606
|
+
enumerable: true,
|
|
1607
|
+
get: function() {
|
|
1608
|
+
return ensureDir;
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
Object.defineProperty(exports, "ensureFile", {
|
|
1612
|
+
enumerable: true,
|
|
1613
|
+
get: function() {
|
|
1614
|
+
return ensureFile;
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
Object.defineProperty(exports, "escapeStringRegexp", {
|
|
1618
|
+
enumerable: true,
|
|
1619
|
+
get: function() {
|
|
1620
|
+
return escapeStringRegexp;
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
Object.defineProperty(exports, "exists", {
|
|
1624
|
+
enumerable: true,
|
|
1625
|
+
get: function() {
|
|
1626
|
+
return exists;
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
Object.defineProperty(exports, "generateAgenticTemplate", {
|
|
1630
|
+
enumerable: true,
|
|
1631
|
+
get: function() {
|
|
1632
|
+
return generateAgenticTemplate;
|
|
1633
|
+
}
|
|
1708
1634
|
});
|
|
1709
|
-
Object.defineProperty(exports,
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1635
|
+
Object.defineProperty(exports, "generateAgenticTemplates", {
|
|
1636
|
+
enumerable: true,
|
|
1637
|
+
get: function() {
|
|
1638
|
+
return generateAgenticTemplates;
|
|
1639
|
+
}
|
|
1714
1640
|
});
|
|
1715
|
-
Object.defineProperty(exports,
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1641
|
+
Object.defineProperty(exports, "getCreateChoices", {
|
|
1642
|
+
enumerable: true,
|
|
1643
|
+
get: function() {
|
|
1644
|
+
return getCreateChoices;
|
|
1645
|
+
}
|
|
1720
1646
|
});
|
|
1721
|
-
Object.defineProperty(exports,
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1647
|
+
Object.defineProperty(exports, "getFileHash", {
|
|
1648
|
+
enumerable: true,
|
|
1649
|
+
get: function() {
|
|
1650
|
+
return getFileHash;
|
|
1651
|
+
}
|
|
1726
1652
|
});
|
|
1727
|
-
Object.defineProperty(exports,
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1653
|
+
Object.defineProperty(exports, "getSkillTargetPaths", {
|
|
1654
|
+
enumerable: true,
|
|
1655
|
+
get: function() {
|
|
1656
|
+
return getSkillTargetPaths;
|
|
1657
|
+
}
|
|
1732
1658
|
});
|
|
1733
|
-
Object.defineProperty(exports,
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1659
|
+
Object.defineProperty(exports, "getTemplateMap", {
|
|
1660
|
+
enumerable: true,
|
|
1661
|
+
get: function() {
|
|
1662
|
+
return getTemplateMap;
|
|
1663
|
+
}
|
|
1738
1664
|
});
|
|
1739
|
-
Object.defineProperty(exports,
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1665
|
+
Object.defineProperty(exports, "getWorkspaceData", {
|
|
1666
|
+
enumerable: true,
|
|
1667
|
+
get: function() {
|
|
1668
|
+
return getWorkspaceData;
|
|
1669
|
+
}
|
|
1744
1670
|
});
|
|
1745
|
-
Object.defineProperty(exports,
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1671
|
+
Object.defineProperty(exports, "getWorkspacePackages", {
|
|
1672
|
+
enumerable: true,
|
|
1673
|
+
get: function() {
|
|
1674
|
+
return getWorkspacePackages;
|
|
1675
|
+
}
|
|
1750
1676
|
});
|
|
1751
|
-
Object.defineProperty(exports,
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1677
|
+
Object.defineProperty(exports, "init", {
|
|
1678
|
+
enumerable: true,
|
|
1679
|
+
get: function() {
|
|
1680
|
+
return init;
|
|
1681
|
+
}
|
|
1756
1682
|
});
|
|
1757
|
-
Object.defineProperty(exports,
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1683
|
+
Object.defineProperty(exports, "isFileChanged", {
|
|
1684
|
+
enumerable: true,
|
|
1685
|
+
get: function() {
|
|
1686
|
+
return isFileChanged;
|
|
1687
|
+
}
|
|
1762
1688
|
});
|
|
1763
|
-
Object.defineProperty(exports,
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1689
|
+
Object.defineProperty(exports, "isIgnorableFsError", {
|
|
1690
|
+
enumerable: true,
|
|
1691
|
+
get: function() {
|
|
1692
|
+
return isIgnorableFsError;
|
|
1693
|
+
}
|
|
1768
1694
|
});
|
|
1769
|
-
Object.defineProperty(exports,
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1695
|
+
Object.defineProperty(exports, "isMatch", {
|
|
1696
|
+
enumerable: true,
|
|
1697
|
+
get: function() {
|
|
1698
|
+
return isMatch;
|
|
1699
|
+
}
|
|
1774
1700
|
});
|
|
1775
|
-
Object.defineProperty(exports,
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1701
|
+
Object.defineProperty(exports, "loadAgenticTasks", {
|
|
1702
|
+
enumerable: true,
|
|
1703
|
+
get: function() {
|
|
1704
|
+
return loadAgenticTasks;
|
|
1705
|
+
}
|
|
1780
1706
|
});
|
|
1781
|
-
Object.defineProperty(exports,
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1707
|
+
Object.defineProperty(exports, "loadMonorepoConfig", {
|
|
1708
|
+
enumerable: true,
|
|
1709
|
+
get: function() {
|
|
1710
|
+
return loadMonorepoConfig;
|
|
1711
|
+
}
|
|
1786
1712
|
});
|
|
1787
|
-
Object.defineProperty(exports,
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1713
|
+
Object.defineProperty(exports, "logger", {
|
|
1714
|
+
enumerable: true,
|
|
1715
|
+
get: function() {
|
|
1716
|
+
return logger;
|
|
1717
|
+
}
|
|
1792
1718
|
});
|
|
1793
|
-
Object.defineProperty(exports,
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1719
|
+
Object.defineProperty(exports, "name", {
|
|
1720
|
+
enumerable: true,
|
|
1721
|
+
get: function() {
|
|
1722
|
+
return name;
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
Object.defineProperty(exports, "outputFile", {
|
|
1726
|
+
enumerable: true,
|
|
1727
|
+
get: function() {
|
|
1728
|
+
return outputFile;
|
|
1729
|
+
}
|
|
1798
1730
|
});
|
|
1799
|
-
Object.defineProperty(exports,
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1731
|
+
Object.defineProperty(exports, "outputJSON", {
|
|
1732
|
+
enumerable: true,
|
|
1733
|
+
get: function() {
|
|
1734
|
+
return outputJSON;
|
|
1735
|
+
}
|
|
1804
1736
|
});
|
|
1805
|
-
Object.defineProperty(exports,
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1737
|
+
Object.defineProperty(exports, "outputJson", {
|
|
1738
|
+
enumerable: true,
|
|
1739
|
+
get: function() {
|
|
1740
|
+
return outputJson;
|
|
1741
|
+
}
|
|
1810
1742
|
});
|
|
1811
|
-
Object.defineProperty(exports,
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1743
|
+
Object.defineProperty(exports, "packageDir", {
|
|
1744
|
+
enumerable: true,
|
|
1745
|
+
get: function() {
|
|
1746
|
+
return packageDir;
|
|
1747
|
+
}
|
|
1816
1748
|
});
|
|
1817
|
-
Object.defineProperty(exports,
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1749
|
+
Object.defineProperty(exports, "pathExists", {
|
|
1750
|
+
enumerable: true,
|
|
1751
|
+
get: function() {
|
|
1752
|
+
return pathExists;
|
|
1753
|
+
}
|
|
1822
1754
|
});
|
|
1823
|
-
Object.defineProperty(exports,
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1755
|
+
Object.defineProperty(exports, "readJSON", {
|
|
1756
|
+
enumerable: true,
|
|
1757
|
+
get: function() {
|
|
1758
|
+
return readJSON;
|
|
1759
|
+
}
|
|
1828
1760
|
});
|
|
1829
|
-
Object.defineProperty(exports,
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1761
|
+
Object.defineProperty(exports, "readJson", {
|
|
1762
|
+
enumerable: true,
|
|
1763
|
+
get: function() {
|
|
1764
|
+
return readJson;
|
|
1765
|
+
}
|
|
1834
1766
|
});
|
|
1835
|
-
Object.defineProperty(exports,
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1767
|
+
Object.defineProperty(exports, "remove", {
|
|
1768
|
+
enumerable: true,
|
|
1769
|
+
get: function() {
|
|
1770
|
+
return remove;
|
|
1771
|
+
}
|
|
1840
1772
|
});
|
|
1841
|
-
Object.defineProperty(exports,
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1773
|
+
Object.defineProperty(exports, "resolveCommandConfig", {
|
|
1774
|
+
enumerable: true,
|
|
1775
|
+
get: function() {
|
|
1776
|
+
return resolveCommandConfig;
|
|
1777
|
+
}
|
|
1846
1778
|
});
|
|
1847
|
-
Object.defineProperty(exports,
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1779
|
+
Object.defineProperty(exports, "rootDir", {
|
|
1780
|
+
enumerable: true,
|
|
1781
|
+
get: function() {
|
|
1782
|
+
return rootDir;
|
|
1783
|
+
}
|
|
1852
1784
|
});
|
|
1853
|
-
Object.defineProperty(exports,
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1785
|
+
Object.defineProperty(exports, "setByPath", {
|
|
1786
|
+
enumerable: true,
|
|
1787
|
+
get: function() {
|
|
1788
|
+
return setByPath;
|
|
1789
|
+
}
|
|
1858
1790
|
});
|
|
1859
|
-
Object.defineProperty(exports,
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1791
|
+
Object.defineProperty(exports, "setVscodeBinaryMirror", {
|
|
1792
|
+
enumerable: true,
|
|
1793
|
+
get: function() {
|
|
1794
|
+
return setVscodeBinaryMirror;
|
|
1795
|
+
}
|
|
1864
1796
|
});
|
|
1865
|
-
Object.defineProperty(exports,
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1797
|
+
Object.defineProperty(exports, "skillTargets", {
|
|
1798
|
+
enumerable: true,
|
|
1799
|
+
get: function() {
|
|
1800
|
+
return skillTargets;
|
|
1801
|
+
}
|
|
1870
1802
|
});
|
|
1871
|
-
Object.defineProperty(exports,
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1803
|
+
Object.defineProperty(exports, "syncNpmMirror", {
|
|
1804
|
+
enumerable: true,
|
|
1805
|
+
get: function() {
|
|
1806
|
+
return syncNpmMirror;
|
|
1807
|
+
}
|
|
1876
1808
|
});
|
|
1877
|
-
Object.defineProperty(exports,
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1809
|
+
Object.defineProperty(exports, "syncSkills", {
|
|
1810
|
+
enumerable: true,
|
|
1811
|
+
get: function() {
|
|
1812
|
+
return syncSkills;
|
|
1813
|
+
}
|
|
1882
1814
|
});
|
|
1883
|
-
Object.defineProperty(exports,
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1815
|
+
Object.defineProperty(exports, "templateMap", {
|
|
1816
|
+
enumerable: true,
|
|
1817
|
+
get: function() {
|
|
1818
|
+
return templateMap;
|
|
1819
|
+
}
|
|
1888
1820
|
});
|
|
1889
|
-
Object.defineProperty(exports,
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1821
|
+
Object.defineProperty(exports, "updateIssueTemplateConfig", {
|
|
1822
|
+
enumerable: true,
|
|
1823
|
+
get: function() {
|
|
1824
|
+
return updateIssueTemplateConfig;
|
|
1825
|
+
}
|
|
1894
1826
|
});
|
|
1895
|
-
Object.defineProperty(exports,
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1827
|
+
Object.defineProperty(exports, "upgradeMonorepo", {
|
|
1828
|
+
enumerable: true,
|
|
1829
|
+
get: function() {
|
|
1830
|
+
return upgradeMonorepo;
|
|
1831
|
+
}
|
|
1900
1832
|
});
|
|
1901
|
-
Object.defineProperty(exports,
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1833
|
+
Object.defineProperty(exports, "version", {
|
|
1834
|
+
enumerable: true,
|
|
1835
|
+
get: function() {
|
|
1836
|
+
return version;
|
|
1837
|
+
}
|
|
1906
1838
|
});
|
|
1907
|
-
Object.defineProperty(exports,
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1839
|
+
Object.defineProperty(exports, "writeJSON", {
|
|
1840
|
+
enumerable: true,
|
|
1841
|
+
get: function() {
|
|
1842
|
+
return writeJSON;
|
|
1843
|
+
}
|
|
1912
1844
|
});
|
|
1913
|
-
Object.defineProperty(exports,
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1845
|
+
Object.defineProperty(exports, "writeJson", {
|
|
1846
|
+
enumerable: true,
|
|
1847
|
+
get: function() {
|
|
1848
|
+
return writeJson;
|
|
1849
|
+
}
|
|
1918
1850
|
});
|
|
1919
|
-
Object.defineProperty(exports, 'version', {
|
|
1920
|
-
enumerable: true,
|
|
1921
|
-
get: function () {
|
|
1922
|
-
return version;
|
|
1923
|
-
}
|
|
1924
|
-
});
|