@icebreakers/monorepo 3.2.18 → 4.0.0
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/README.md +181 -52
- package/bin/mo.js +2 -0
- package/bin/rc.js +2 -0
- package/bin/repo.js +2 -0
- package/bin/repoctl.js +2 -0
- package/dist/cli.mjs +1067 -76
- package/dist/commands-MPDw9wMy.mjs +2501 -0
- package/dist/config-BGCo7USv.mjs +120 -0
- package/dist/create-flow-BEHRojMs.mjs +179 -0
- package/dist/index-BBxViYZd.d.mts +1049 -0
- package/dist/index.d.mts +383 -713
- package/dist/index.mjs +6 -2
- package/dist/rolldown-runtime-twds-ZHy.mjs +14 -0
- package/dist/tooling-DyUe-eiv.mjs +427 -0
- package/dist/tooling-entry.d.mts +2 -0
- package/dist/tooling-entry.mjs +2 -0
- package/dist/types-CRtyTy2K.mjs +213 -0
- package/dist/workspace-DS6LAL71.mjs +118 -0
- package/package.json +43 -34
- package/resources/skills/icebreakers-monorepo-cli/SKILL.md +12 -10
- package/resources/skills/icebreakers-monorepo-cli/references/commands.md +166 -21
- package/resources/skills/icebreakers-monorepo-cli/references/config.md +13 -9
- package/resources/skills/icebreakers-monorepo-cli/references/templates.md +30 -5
- package/tsconfig.base.json +23 -0
- package/dist/cli.cjs +0 -116
- package/dist/cli.d.cts +0 -1
- package/dist/index.cjs +0 -82
- package/dist/index.d.cts +0 -918
- package/dist/upgrade-Beo3EoFO.cjs +0 -1850
- package/dist/upgrade-tD-PPMpL.mjs +0 -1513
|
@@ -1,1850 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
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
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
|
-
let git_url_parse = require("git-url-parse");
|
|
24
|
-
git_url_parse = __toESM(git_url_parse);
|
|
25
|
-
let simple_git = require("simple-git");
|
|
26
|
-
let _pnpm_find_workspace_dir = require("@pnpm/find-workspace-dir");
|
|
27
|
-
let _pnpm_workspace_find_packages = require("@pnpm/workspace.find-packages");
|
|
28
|
-
let _pnpm_workspace_read_manifest = require("@pnpm/workspace.read-manifest");
|
|
29
|
-
let pathe = require("pathe");
|
|
30
|
-
pathe = __toESM(pathe);
|
|
31
|
-
let node_process = require("node:process");
|
|
32
|
-
node_process = __toESM(node_process);
|
|
33
|
-
let node_fs_promises = require("node:fs/promises");
|
|
34
|
-
let consola = require("consola");
|
|
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);
|
|
40
|
-
let c12 = require("c12");
|
|
41
|
-
let node_os = require("node:os");
|
|
42
|
-
node_os = __toESM(node_os);
|
|
43
|
-
let node_path = require("node:path");
|
|
44
|
-
node_path = __toESM(node_path);
|
|
45
|
-
let node_url = require("node:url");
|
|
46
|
-
let picocolors = require("picocolors");
|
|
47
|
-
picocolors = __toESM(picocolors);
|
|
48
|
-
require("@pnpm/types");
|
|
49
|
-
let comment_json = require("comment-json");
|
|
50
|
-
let p_queue = require("p-queue");
|
|
51
|
-
p_queue = __toESM(p_queue);
|
|
52
|
-
let klaw = require("klaw");
|
|
53
|
-
klaw = __toESM(klaw);
|
|
54
|
-
let node_buffer = require("node:buffer");
|
|
55
|
-
let semver = require("semver");
|
|
56
|
-
//#region src/core/git.ts
|
|
57
|
-
/**
|
|
58
|
-
* 对 simple-git 的轻量封装,集中处理配置缓存与常用查询。
|
|
59
|
-
*/
|
|
60
|
-
var GitClient = class {
|
|
61
|
-
client;
|
|
62
|
-
#config;
|
|
63
|
-
constructor(options = {}) {
|
|
64
|
-
this.client = (0, simple_git.simpleGit)(options);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 读取 Git 的 config 列表,原样返回 simple-git 的结果。
|
|
68
|
-
*/
|
|
69
|
-
listConfig() {
|
|
70
|
-
return this.client.listConfig();
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 初始化配置缓存,避免多次访问 Git 产生的性能损耗。
|
|
74
|
-
*/
|
|
75
|
-
async init() {
|
|
76
|
-
this.#config = (await this.listConfig()).all;
|
|
77
|
-
return this.#config;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 获取缓存的配置,若未初始化则自动触发 init。
|
|
81
|
-
*/
|
|
82
|
-
async getConfig() {
|
|
83
|
-
if (this.#config) return this.#config;
|
|
84
|
-
else return await this.init();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 解析 remote.origin.url,返回 git-url-parse 的结构,便于获取仓库元信息。
|
|
88
|
-
*/
|
|
89
|
-
async getGitUrl() {
|
|
90
|
-
const x = (await this.getConfig())["remote.origin.url"];
|
|
91
|
-
if (typeof x === "string") return (0, git_url_parse.default)(x);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 组合 owner/name,生成常用的仓库名表达。
|
|
95
|
-
*/
|
|
96
|
-
async getRepoName() {
|
|
97
|
-
const url = await this.getGitUrl();
|
|
98
|
-
if (url) return `${url.owner}/${url.name}`;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 从 Git 配置中提取用户信息,用于填充 package.json author 字段。
|
|
102
|
-
*/
|
|
103
|
-
async getUser() {
|
|
104
|
-
const config = await this.getConfig();
|
|
105
|
-
return {
|
|
106
|
-
name: config["user.name"],
|
|
107
|
-
email: config["user.email"]
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 获取当前仓库的顶层目录路径。
|
|
112
|
-
*/
|
|
113
|
-
async getRepoRoot() {
|
|
114
|
-
try {
|
|
115
|
-
const root = await this.client.revparse(["--show-toplevel"]);
|
|
116
|
-
return typeof root === "string" ? root.trim() : void 0;
|
|
117
|
-
} catch {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
124
|
-
function isPlainObject$1(value) {
|
|
125
|
-
if (value === null || typeof value !== "object") return false;
|
|
126
|
-
const prototype = Object.getPrototypeOf(value);
|
|
127
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
128
|
-
if (Symbol.iterator in value) return false;
|
|
129
|
-
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
133
|
-
if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
|
|
134
|
-
const object = Object.assign({}, defaults);
|
|
135
|
-
for (const key in baseObject) {
|
|
136
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
137
|
-
const value = baseObject[key];
|
|
138
|
-
if (value === null || value === void 0) continue;
|
|
139
|
-
if (merger && merger(object, key, value, namespace)) continue;
|
|
140
|
-
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
141
|
-
else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
142
|
-
else object[key] = value;
|
|
143
|
-
}
|
|
144
|
-
return object;
|
|
145
|
-
}
|
|
146
|
-
function createDefu(merger) {
|
|
147
|
-
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
148
|
-
}
|
|
149
|
-
const defu = createDefu();
|
|
150
|
-
createDefu((object, key, currentValue) => {
|
|
151
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
152
|
-
object[key] = currentValue(object[key]);
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
createDefu((object, key, currentValue) => {
|
|
157
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
158
|
-
object[key] = currentValue(object[key]);
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/core/workspace.ts
|
|
164
|
-
/**
|
|
165
|
-
* 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
|
|
166
|
-
*/
|
|
167
|
-
async function getWorkspacePackages(workspaceDir, options) {
|
|
168
|
-
const { ignoreRootPackage, ignorePrivatePackage, patterns } = defu(options, {
|
|
169
|
-
ignoreRootPackage: true,
|
|
170
|
-
ignorePrivatePackage: true
|
|
171
|
-
});
|
|
172
|
-
const manifest = await (0, _pnpm_workspace_read_manifest.readWorkspaceManifest)(workspaceDir);
|
|
173
|
-
const workspacePatterns = patterns ?? manifest?.packages;
|
|
174
|
-
let pkgs = (await (0, _pnpm_workspace_find_packages.findWorkspacePackages)(workspaceDir, workspacePatterns ? { patterns: workspacePatterns } : {})).filter((x) => {
|
|
175
|
-
if (ignorePrivatePackage && x.manifest.private) return false;
|
|
176
|
-
return true;
|
|
177
|
-
}).map((project) => {
|
|
178
|
-
const pkgJsonPath = pathe.default.resolve(project.rootDir, "package.json");
|
|
179
|
-
return {
|
|
180
|
-
...project,
|
|
181
|
-
pkgJsonPath
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
if (ignoreRootPackage) pkgs = pkgs.filter((x) => {
|
|
185
|
-
return x.rootDir !== workspaceDir;
|
|
186
|
-
});
|
|
187
|
-
return pkgs;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
|
|
191
|
-
*/
|
|
192
|
-
async function getWorkspaceData(cwd, options) {
|
|
193
|
-
const workspaceDir = await (0, _pnpm_find_workspace_dir.findWorkspaceDir)(cwd) ?? cwd;
|
|
194
|
-
return {
|
|
195
|
-
cwd,
|
|
196
|
-
workspaceDir,
|
|
197
|
-
packages: await getWorkspacePackages(workspaceDir, options)
|
|
198
|
-
};
|
|
199
|
-
}
|
|
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
|
-
};
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/core/logger.ts
|
|
286
|
-
/**
|
|
287
|
-
* 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
|
|
288
|
-
*/
|
|
289
|
-
const logger = (0, consola.createConsola)();
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/commands/ai.ts
|
|
292
|
-
const agenticSections = [
|
|
293
|
-
"目标/产物",
|
|
294
|
-
"约束(性能/风格/兼容/不可改动范围)",
|
|
295
|
-
"验收标准(要跑的命令、预期输出/文件)",
|
|
296
|
-
"仓库路径",
|
|
297
|
-
"允许操作(可/不可写文件,可运行的命令清单,可否联网)",
|
|
298
|
-
"上下文线索(日志/文件/模块/相关 issue)",
|
|
299
|
-
"里程碑(根因→设计→实现→验证)"
|
|
300
|
-
];
|
|
301
|
-
const defaultAgenticBaseDir = "agentic/prompts";
|
|
302
|
-
function renderMarkdownTemplate() {
|
|
303
|
-
return `${agenticSections.map((title) => `## ${title}\n- `).join("\n\n")}\n`;
|
|
304
|
-
}
|
|
305
|
-
function renderJsonTemplate() {
|
|
306
|
-
const payload = {};
|
|
307
|
-
for (const title of agenticSections) payload[title] = "";
|
|
308
|
-
return `${JSON.stringify(payload, null, 2)}\n`;
|
|
309
|
-
}
|
|
310
|
-
function createTimestampFolderName(date = /* @__PURE__ */ new Date()) {
|
|
311
|
-
const pad = (value) => value.toString().padStart(2, "0");
|
|
312
|
-
return `${date.getUTCFullYear()}${pad(date.getUTCMonth() + 1)}${pad(date.getUTCDate())}-${pad(date.getUTCHours())}${pad(date.getUTCMinutes())}${pad(date.getUTCSeconds())}`;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* 生成 Agentic 任务提示词模板,默认写入 agentic/prompts/<timestamp>/prompt.md,可自定义输出路径。
|
|
316
|
-
*/
|
|
317
|
-
async function generateAgenticTemplate(options = {}) {
|
|
318
|
-
const cwd = options.cwd ?? node_process.default.cwd();
|
|
319
|
-
const format = options.format ?? "md";
|
|
320
|
-
const baseDir = options.baseDir ?? "agentic/prompts";
|
|
321
|
-
if (format !== "md" && format !== "json") throw new Error(`不支持的模板格式:${format}`);
|
|
322
|
-
const template = format === "md" ? renderMarkdownTemplate() : renderJsonTemplate();
|
|
323
|
-
const ext = format === "json" ? "json" : "md";
|
|
324
|
-
let outputPath = options.output;
|
|
325
|
-
if (!outputPath && options.name) outputPath = pathe.default.join(baseDir, `${options.name}.${ext}`);
|
|
326
|
-
if (!outputPath) {
|
|
327
|
-
const folderName = options.folderName ?? createTimestampFolderName();
|
|
328
|
-
outputPath = pathe.default.join(baseDir, folderName, `prompt.${ext}`);
|
|
329
|
-
}
|
|
330
|
-
const targetPath = pathe.default.resolve(cwd, outputPath);
|
|
331
|
-
const targetDir = pathe.default.dirname(targetPath);
|
|
332
|
-
await fs.ensureDir(targetDir);
|
|
333
|
-
const exists = await fs.pathExists(targetPath);
|
|
334
|
-
if (exists && !options.force) throw new Error(`目标文件已存在:${pathe.default.relative(cwd, targetPath)}`);
|
|
335
|
-
await fs.outputFile(targetPath, template, "utf8");
|
|
336
|
-
const actionLabel = exists ? "已覆盖模板" : "已生成模板";
|
|
337
|
-
logger.success(`${actionLabel}:${pathe.default.relative(cwd, targetPath)}`);
|
|
338
|
-
return template;
|
|
339
|
-
}
|
|
340
|
-
async function loadAgenticTasks(filePath, cwd) {
|
|
341
|
-
const fullPath = pathe.default.resolve(cwd, filePath);
|
|
342
|
-
const tasks = await fs.readJson(fullPath);
|
|
343
|
-
if (!Array.isArray(tasks)) throw new TypeError("任务清单需要是数组");
|
|
344
|
-
return tasks;
|
|
345
|
-
}
|
|
346
|
-
async function generateAgenticTemplates(tasks, defaults = {}) {
|
|
347
|
-
const results = [];
|
|
348
|
-
for (const task of tasks) {
|
|
349
|
-
const normalized = typeof task === "string" ? {
|
|
350
|
-
...defaults,
|
|
351
|
-
name: task
|
|
352
|
-
} : {
|
|
353
|
-
...defaults,
|
|
354
|
-
...task
|
|
355
|
-
};
|
|
356
|
-
results.push(await generateAgenticTemplate(normalized));
|
|
357
|
-
}
|
|
358
|
-
return results;
|
|
359
|
-
}
|
|
360
|
-
//#endregion
|
|
361
|
-
//#region src/utils/github.ts
|
|
362
|
-
/**
|
|
363
|
-
* 将 Issue 模版里的 discussions 链接同步为当前仓库的 discussions 地址。
|
|
364
|
-
*/
|
|
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
|
-
}
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/utils/hash.ts
|
|
398
|
-
/**
|
|
399
|
-
* 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
|
|
400
|
-
*/
|
|
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,如果不一致则认为内容有变化。
|
|
408
|
-
*/
|
|
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
|
-
}
|
|
417
|
-
//#endregion
|
|
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;
|
|
432
|
-
}
|
|
433
|
-
if (char === "\\") {
|
|
434
|
-
escaped = true;
|
|
435
|
-
continue;
|
|
436
|
-
}
|
|
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
|
-
}
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region src/core/config.ts
|
|
483
|
-
/**
|
|
484
|
-
* 简单的内存缓存,避免同一次命令中重复走磁盘加载配置。
|
|
485
|
-
*/
|
|
486
|
-
const cache = /* @__PURE__ */ new Map();
|
|
487
|
-
/**
|
|
488
|
-
* 基于 c12 的通用配置加载逻辑,支持多种配置文件格式。
|
|
489
|
-
*/
|
|
490
|
-
async function loadConfigInternal(cwd) {
|
|
491
|
-
const { config, configFile } = await (0, c12.loadConfig)({
|
|
492
|
-
name: "monorepo",
|
|
493
|
-
cwd,
|
|
494
|
-
rcFile: false,
|
|
495
|
-
defaults: {},
|
|
496
|
-
globalRc: false,
|
|
497
|
-
packageJson: false
|
|
498
|
-
});
|
|
499
|
-
return {
|
|
500
|
-
file: configFile ? pathe.default.resolve(configFile) : null,
|
|
501
|
-
config: config ?? {}
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* 提供类型提示的辅助函数,供外部定义配置时使用。
|
|
506
|
-
*/
|
|
507
|
-
function defineMonorepoConfig(config) {
|
|
508
|
-
return config;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
512
|
-
*/
|
|
513
|
-
async function loadMonorepoConfig(cwd) {
|
|
514
|
-
const key = pathe.default.resolve(cwd);
|
|
515
|
-
if (!cache.has(key)) cache.set(key, loadConfigInternal(key));
|
|
516
|
-
const { config } = await cache.get(key);
|
|
517
|
-
return config;
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
521
|
-
*/
|
|
522
|
-
async function resolveCommandConfig(name, cwd) {
|
|
523
|
-
return ((await loadMonorepoConfig(cwd)).commands ?? {})[name] ?? {};
|
|
524
|
-
}
|
|
525
|
-
//#endregion
|
|
526
|
-
//#region package.json
|
|
527
|
-
var name = "@icebreakers/monorepo";
|
|
528
|
-
var version = "3.2.18";
|
|
529
|
-
//#endregion
|
|
530
|
-
//#region src/constants.ts
|
|
531
|
-
/**
|
|
532
|
-
* 还原出 package.json 所在的绝对路径,方便后续按目录组织资源文件。
|
|
533
|
-
*/
|
|
534
|
-
const packageJsonPath = (0, node_url.fileURLToPath)(new URL("../package.json", require("url").pathToFileURL(__filename).href));
|
|
535
|
-
/**
|
|
536
|
-
* @icebreakers/monorepo 包的根目录。
|
|
537
|
-
*/
|
|
538
|
-
const packageDir = node_path.dirname(packageJsonPath);
|
|
539
|
-
/**
|
|
540
|
-
* monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
|
|
541
|
-
*/
|
|
542
|
-
const rootDir = node_path.resolve(packageDir, "..", "..");
|
|
543
|
-
//#endregion
|
|
544
|
-
//#region src/commands/skills.ts
|
|
545
|
-
const skillName = "icebreakers-monorepo-cli";
|
|
546
|
-
const skillTargets = ["codex", "claude"];
|
|
547
|
-
const skillSourceDir = pathe.default.join(packageDir, "resources", "skills", skillName);
|
|
548
|
-
function getSkillTargetPaths(homeDir = node_os.default.homedir()) {
|
|
549
|
-
return {
|
|
550
|
-
codex: pathe.default.join(homeDir, ".codex", "skills", skillName),
|
|
551
|
-
claude: pathe.default.join(homeDir, ".claude", "skills", skillName)
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
function normalizeTargets(values) {
|
|
555
|
-
if (!values?.length) return;
|
|
556
|
-
return [...new Set(values)];
|
|
557
|
-
}
|
|
558
|
-
async function syncSkills(options = {}) {
|
|
559
|
-
const cwd = options.cwd ?? node_process.default.cwd();
|
|
560
|
-
if (!await fs.pathExists(skillSourceDir)) {
|
|
561
|
-
const relative = pathe.default.relative(cwd, skillSourceDir);
|
|
562
|
-
throw new Error(`未找到技能目录:${relative || skillSourceDir}`);
|
|
563
|
-
}
|
|
564
|
-
let targets = normalizeTargets(options.targets);
|
|
565
|
-
if (!targets?.length) targets = normalizeTargets(await (0, _icebreakers_monorepo_templates.checkbox)({
|
|
566
|
-
message: "请选择需要同步的技能目标",
|
|
567
|
-
choices: skillTargets.map((target) => ({
|
|
568
|
-
name: target,
|
|
569
|
-
value: target,
|
|
570
|
-
checked: true
|
|
571
|
-
}))
|
|
572
|
-
}));
|
|
573
|
-
if (!targets?.length) return [];
|
|
574
|
-
const targetPaths = getSkillTargetPaths();
|
|
575
|
-
const results = [];
|
|
576
|
-
for (const target of targets) {
|
|
577
|
-
const dest = targetPaths[target];
|
|
578
|
-
await fs.remove(dest);
|
|
579
|
-
await fs.ensureDir(pathe.default.dirname(dest));
|
|
580
|
-
await fs.copy(skillSourceDir, dest);
|
|
581
|
-
results.push({
|
|
582
|
-
target,
|
|
583
|
-
dest
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
return results;
|
|
587
|
-
}
|
|
588
|
-
//#endregion
|
|
589
|
-
//#region src/commands/clean.ts
|
|
590
|
-
function mergeCleanConfig(base, overrides) {
|
|
591
|
-
const normalizedBase = base ?? {};
|
|
592
|
-
if (!overrides) return normalizedBase;
|
|
593
|
-
const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, value]) => value !== void 0));
|
|
594
|
-
return {
|
|
595
|
-
...normalizedBase,
|
|
596
|
-
...definedOverrides
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* 交互式清理被选中的包目录,同时重写根 package.json 中的 @icebreakers/monorepo 版本。
|
|
601
|
-
*/
|
|
602
|
-
async function cleanProjects(cwd, overrides) {
|
|
603
|
-
const cleanConfig = mergeCleanConfig(await resolveCommandConfig("clean", cwd), overrides);
|
|
604
|
-
const { packages, workspaceDir } = await getWorkspaceData(cwd, cleanConfig?.includePrivate ?? true ? { ignorePrivatePackage: false } : void 0);
|
|
605
|
-
const filteredPackages = packages.filter((pkg) => {
|
|
606
|
-
const name = pkg.manifest.name ?? "";
|
|
607
|
-
if (!name) return true;
|
|
608
|
-
if (!cleanConfig?.ignorePackages?.length) return true;
|
|
609
|
-
return !cleanConfig.ignorePackages.includes(name);
|
|
610
|
-
});
|
|
611
|
-
let cleanDirs = [];
|
|
612
|
-
if (cleanConfig?.autoConfirm) cleanDirs = filteredPackages.map((pkg) => pkg.rootDir);
|
|
613
|
-
else cleanDirs = await (0, _icebreakers_monorepo_templates.checkbox)({
|
|
614
|
-
message: "请选择需要清理的目录",
|
|
615
|
-
choices: filteredPackages.map((x) => {
|
|
616
|
-
const baseChoice = {
|
|
617
|
-
name: pathe.default.relative(workspaceDir, x.rootDir),
|
|
618
|
-
value: x.rootDir,
|
|
619
|
-
checked: true
|
|
620
|
-
};
|
|
621
|
-
return x.manifest.name ? {
|
|
622
|
-
...baseChoice,
|
|
623
|
-
description: x.manifest.name
|
|
624
|
-
} : baseChoice;
|
|
625
|
-
})
|
|
626
|
-
});
|
|
627
|
-
const readmeZh = pathe.default.resolve(workspaceDir, "README.zh-CN.md");
|
|
628
|
-
const qoderDir = pathe.default.resolve(workspaceDir, ".qoder");
|
|
629
|
-
const docsPlansDir = pathe.default.resolve(workspaceDir, "docs/plans");
|
|
630
|
-
const skillTargets = Object.values(getSkillTargetPaths());
|
|
631
|
-
const candidates = [...new Set([
|
|
632
|
-
...cleanDirs.filter(Boolean),
|
|
633
|
-
readmeZh,
|
|
634
|
-
qoderDir,
|
|
635
|
-
docsPlansDir,
|
|
636
|
-
...skillTargets
|
|
637
|
-
])];
|
|
638
|
-
await Promise.all(candidates.map(async (dir) => {
|
|
639
|
-
if (await fs.pathExists(dir)) await fs.remove(dir);
|
|
640
|
-
}));
|
|
641
|
-
const name = pathe.default.resolve(workspaceDir, "package.json");
|
|
642
|
-
const pkgJson = await fs.readJson(name);
|
|
643
|
-
setByPath(pkgJson, "devDependencies.@icebreakers/monorepo", cleanConfig?.pinnedVersion ?? "latest");
|
|
644
|
-
await fs.outputJson(name, pkgJson, { spaces: 2 });
|
|
645
|
-
}
|
|
646
|
-
//#endregion
|
|
647
|
-
//#region src/commands/create.ts
|
|
648
|
-
/**
|
|
649
|
-
* 内置模板映射表,source 指向 templates 根目录下的来源目录,target 为生成路径。
|
|
650
|
-
*/
|
|
651
|
-
const templateMap = {
|
|
652
|
-
"tsup": {
|
|
653
|
-
source: "tsup",
|
|
654
|
-
target: "packages/tsup"
|
|
655
|
-
},
|
|
656
|
-
"tsdown": {
|
|
657
|
-
source: "tsdown",
|
|
658
|
-
target: "packages/tsdown"
|
|
659
|
-
},
|
|
660
|
-
"unbuild": {
|
|
661
|
-
source: "unbuild",
|
|
662
|
-
target: "packages/unbuild"
|
|
663
|
-
},
|
|
664
|
-
"vue-lib": {
|
|
665
|
-
source: "vue-lib",
|
|
666
|
-
target: "packages/vue-lib"
|
|
667
|
-
},
|
|
668
|
-
"hono-server": {
|
|
669
|
-
source: "server",
|
|
670
|
-
target: "apps/server"
|
|
671
|
-
},
|
|
672
|
-
"vue-hono": {
|
|
673
|
-
source: "client",
|
|
674
|
-
target: "apps/client"
|
|
675
|
-
},
|
|
676
|
-
"vitepress": {
|
|
677
|
-
source: "vitepress",
|
|
678
|
-
target: "apps/website"
|
|
679
|
-
},
|
|
680
|
-
"cli": {
|
|
681
|
-
source: "cli",
|
|
682
|
-
target: "apps/cli"
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
function normalizeTemplateDefinition(value) {
|
|
686
|
-
if (typeof value === "string") return {
|
|
687
|
-
source: value,
|
|
688
|
-
target: value
|
|
689
|
-
};
|
|
690
|
-
return value;
|
|
691
|
-
}
|
|
692
|
-
const defaultTemplate = "unbuild";
|
|
693
|
-
/**
|
|
694
|
-
* 交互式选择模板时的默认选项列表。
|
|
695
|
-
*/
|
|
696
|
-
const baseChoices = [
|
|
697
|
-
{
|
|
698
|
-
name: "unbuild 打包",
|
|
699
|
-
value: "unbuild"
|
|
700
|
-
},
|
|
701
|
-
{
|
|
702
|
-
name: "tsup 打包",
|
|
703
|
-
value: "tsup"
|
|
704
|
-
},
|
|
705
|
-
{
|
|
706
|
-
name: "tsdown 打包",
|
|
707
|
-
value: "tsdown"
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
name: "vue 组件",
|
|
711
|
-
value: "vue-lib"
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
name: "vue hono 全栈",
|
|
715
|
-
value: "vue-hono"
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
name: "hono 模板",
|
|
719
|
-
value: "hono-server"
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
name: "vitepress 文档",
|
|
723
|
-
value: "vitepress"
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
name: "cli 模板",
|
|
727
|
-
value: "cli"
|
|
728
|
-
}
|
|
729
|
-
];
|
|
730
|
-
/**
|
|
731
|
-
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
732
|
-
*/
|
|
733
|
-
function getCreateChoices(choices) {
|
|
734
|
-
if (choices?.length) return choices;
|
|
735
|
-
return [...baseChoices];
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
739
|
-
*/
|
|
740
|
-
function getTemplateMap(extra) {
|
|
741
|
-
const base = Object.fromEntries(Object.entries(templateMap).map(([key, value]) => [key, normalizeTemplateDefinition(value)]));
|
|
742
|
-
if (extra && Object.keys(extra).length) for (const [key, value] of Object.entries(extra)) base[key] = normalizeTemplateDefinition(value);
|
|
743
|
-
return base;
|
|
744
|
-
}
|
|
745
|
-
async function applyGitMetadata(pkgJson, repoDir, targetDir) {
|
|
746
|
-
try {
|
|
747
|
-
const git = new GitClient({ baseDir: repoDir });
|
|
748
|
-
const repoName = await git.getRepoName();
|
|
749
|
-
if (!repoName) return;
|
|
750
|
-
setByPath(pkgJson, ["bugs", "url"], `https://github.com/${repoName}/issues`);
|
|
751
|
-
const repository = {
|
|
752
|
-
type: "git",
|
|
753
|
-
url: `git+https://github.com/${repoName}.git`
|
|
754
|
-
};
|
|
755
|
-
const directoryBase = await git.getRepoRoot() ?? repoDir;
|
|
756
|
-
const relative = pathe.default.relative(directoryBase, targetDir);
|
|
757
|
-
if (relative && relative !== ".") repository.directory = relative.split(pathe.default.sep).join("/");
|
|
758
|
-
setByPath(pkgJson, "repository", repository);
|
|
759
|
-
const gitUser = await git.getUser();
|
|
760
|
-
if (gitUser?.name && gitUser?.email) setByPath(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
761
|
-
} catch {}
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
765
|
-
*/
|
|
766
|
-
async function createNewProject(options) {
|
|
767
|
-
const cwd = options?.cwd ?? node_process.default.cwd();
|
|
768
|
-
const createConfig = await resolveCommandConfig("create", cwd);
|
|
769
|
-
const renameJson = options?.renameJson ?? createConfig?.renameJson ?? false;
|
|
770
|
-
const rawName = options?.name ?? createConfig?.name;
|
|
771
|
-
const name = typeof rawName === "string" ? rawName.trim() : void 0;
|
|
772
|
-
const requestedTemplate = options?.type ?? createConfig?.type ?? createConfig?.defaultTemplate ?? "unbuild";
|
|
773
|
-
const templateDefinitions = getTemplateMap(createConfig?.templateMap);
|
|
774
|
-
const templatesRoot = createConfig?.templatesDir ? pathe.default.resolve(cwd, createConfig.templatesDir) : _icebreakers_monorepo_templates.templatesDir;
|
|
775
|
-
const fallbackTemplate = createConfig?.defaultTemplate ?? "unbuild";
|
|
776
|
-
const bundlerName = typeof requestedTemplate === "string" && templateDefinitions[requestedTemplate] ? requestedTemplate : fallbackTemplate;
|
|
777
|
-
const templateDefinition = templateDefinitions[bundlerName];
|
|
778
|
-
if (!templateDefinition) throw new Error(`未找到名为 ${bundlerName} 的模板,请检查 monorepo.config.ts`);
|
|
779
|
-
const from = pathe.default.join(templatesRoot, templateDefinition.source);
|
|
780
|
-
const targetName = name && name.length > 0 ? name : templateDefinition.target;
|
|
781
|
-
const to = pathe.default.join(cwd, targetName);
|
|
782
|
-
if (await fs.pathExists(to)) throw new Error(`${picocolors.default.red("目标目录已存在")}: ${pathe.default.relative(cwd, to)}`);
|
|
783
|
-
await fs.ensureDir(to);
|
|
784
|
-
const sourceJsonPath = pathe.default.resolve(from, "package.json");
|
|
785
|
-
const hasPackageJson = await fs.pathExists(sourceJsonPath);
|
|
786
|
-
await (0, _icebreakers_monorepo_templates.scaffoldTemplate)({
|
|
787
|
-
sourceDir: from,
|
|
788
|
-
targetDir: to,
|
|
789
|
-
skipRootBasenames: ["package.json"]
|
|
790
|
-
});
|
|
791
|
-
if (hasPackageJson) {
|
|
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));
|
|
795
|
-
await applyGitMetadata(sourceJson, cwd, to);
|
|
796
|
-
await fs.outputJson(pathe.default.resolve(to, renameJson ? "package.mock.json" : "package.json"), sourceJson, { spaces: 2 });
|
|
797
|
-
}
|
|
798
|
-
logger.success(`${picocolors.default.bgGreenBright(picocolors.default.white(`[${bundlerName}]`))} ${targetName} 项目创建成功!`);
|
|
799
|
-
}
|
|
800
|
-
//#endregion
|
|
801
|
-
//#region src/core/context.ts
|
|
802
|
-
/**
|
|
803
|
-
* 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
|
|
804
|
-
*/
|
|
805
|
-
async function createContext(cwd) {
|
|
806
|
-
const { packages, workspaceDir } = await getWorkspaceData(cwd);
|
|
807
|
-
const git = new GitClient({ baseDir: workspaceDir });
|
|
808
|
-
const workspaceFilepath = pathe.default.resolve(workspaceDir, "pnpm-workspace.yaml");
|
|
809
|
-
return {
|
|
810
|
-
cwd,
|
|
811
|
-
git,
|
|
812
|
-
gitUrl: await git.getGitUrl(),
|
|
813
|
-
gitUser: await git.getUser(),
|
|
814
|
-
workspaceDir,
|
|
815
|
-
workspaceFilepath,
|
|
816
|
-
packages,
|
|
817
|
-
config: await loadMonorepoConfig(workspaceDir)
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
//#endregion
|
|
821
|
-
//#region src/commands/init/setChangeset.ts
|
|
822
|
-
/**
|
|
823
|
-
* 将 changeset 配置中的仓库地址指向当前项目,方便自动生成变更日志链接。
|
|
824
|
-
*/
|
|
825
|
-
async function setChangeset_default(ctx) {
|
|
826
|
-
const { gitUrl, workspaceFilepath } = ctx;
|
|
827
|
-
if (gitUrl && await fs.exists(workspaceFilepath)) {
|
|
828
|
-
const changesetConfigPath = pathe.default.resolve(pathe.default.dirname(workspaceFilepath), ".changeset/config.json");
|
|
829
|
-
if (await fs.exists(changesetConfigPath)) {
|
|
830
|
-
const changesetConfig = await fs.readJson(changesetConfigPath);
|
|
831
|
-
if (gitUrl.full_name) {
|
|
832
|
-
setByPath(changesetConfig, "changelog.1.repo", gitUrl.full_name);
|
|
833
|
-
await fs.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
//#endregion
|
|
839
|
-
//#region src/commands/init/setIssueTemplateConfig.ts
|
|
840
|
-
/**
|
|
841
|
-
* 同步 Issue 模版里的 discussions 链接到当前仓库。
|
|
842
|
-
*/
|
|
843
|
-
async function setIssueTemplateConfig_default(ctx) {
|
|
844
|
-
const repoName = ctx.gitUrl?.full_name;
|
|
845
|
-
if (!repoName) return;
|
|
846
|
-
const configPath = pathe.default.resolve(ctx.cwd, ".github/ISSUE_TEMPLATE/config.yml");
|
|
847
|
-
if (!await fs.pathExists(configPath)) return;
|
|
848
|
-
const source = await fs.readFile(configPath, "utf8");
|
|
849
|
-
const next = updateIssueTemplateConfig(source, repoName);
|
|
850
|
-
if (next !== source) await fs.writeFile(configPath, next, "utf8");
|
|
851
|
-
}
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region src/commands/init/setPkgJson.ts
|
|
854
|
-
/**
|
|
855
|
-
* 根据当前仓库信息同步 package.json 的仓库、作者等字段。
|
|
856
|
-
*/
|
|
857
|
-
async function setPkgJson_default(ctx) {
|
|
858
|
-
const { gitUrl, gitUser, packages, cwd, workspaceFilepath } = ctx;
|
|
859
|
-
const workspaceExists = await fs.pathExists(workspaceFilepath);
|
|
860
|
-
if (gitUrl && workspaceExists) await Promise.all(packages.map(async (pkg) => {
|
|
861
|
-
if (!await fs.pathExists(pkg.pkgJsonPath)) return;
|
|
862
|
-
const pkgJson = JSON.parse(JSON.stringify(pkg.manifest));
|
|
863
|
-
const directory = pathe.default.relative(cwd, pkg.rootDir);
|
|
864
|
-
setByPath(pkgJson, ["bugs", "url"], `https://github.com/${gitUrl.full_name}/issues`);
|
|
865
|
-
const repository = {
|
|
866
|
-
type: "git",
|
|
867
|
-
url: `git+https://github.com/${gitUrl.full_name}.git`
|
|
868
|
-
};
|
|
869
|
-
if (directory) repository.directory = directory;
|
|
870
|
-
setByPath(pkgJson, "repository", repository);
|
|
871
|
-
if (gitUser?.name && gitUser?.email) setByPath(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
872
|
-
const nextContent = `${JSON.stringify(pkgJson, void 0, 2)}\n`;
|
|
873
|
-
if (await fs.readFile(pkg.pkgJsonPath, "utf8") !== nextContent) await fs.writeFile(pkg.pkgJsonPath, nextContent, "utf8");
|
|
874
|
-
}));
|
|
875
|
-
}
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region src/commands/init/setReadme.ts
|
|
878
|
-
async function getRows(ctx) {
|
|
879
|
-
const { packages, gitUrl, gitUser, cwd } = ctx;
|
|
880
|
-
const rows = [];
|
|
881
|
-
if (gitUrl) rows.push(`# ${gitUrl.name}\n`);
|
|
882
|
-
rows.push("## Packages\n");
|
|
883
|
-
const sortedPackages = packages.toSorted((a, b) => {
|
|
884
|
-
const left = a.manifest.name ?? "";
|
|
885
|
-
const right = b.manifest.name ?? "";
|
|
886
|
-
return left.localeCompare(right);
|
|
887
|
-
});
|
|
888
|
-
for (const pkg of sortedPackages) {
|
|
889
|
-
const p = pathe.default.relative(cwd, pkg.rootDirRealPath);
|
|
890
|
-
if (p) {
|
|
891
|
-
const description = pkg.manifest.description ? `- ${pkg.manifest.description}` : "";
|
|
892
|
-
rows.push(`- [${pkg.manifest.name}](${p}) ${description}`);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
if (gitUrl) {
|
|
896
|
-
rows.push("\n## Contributing\n");
|
|
897
|
-
rows.push("Contributions Welcome! You can contribute in the following ways.");
|
|
898
|
-
rows.push("");
|
|
899
|
-
rows.push("- Create an Issue - Propose a new feature. Report a bug.");
|
|
900
|
-
rows.push("- Pull Request - Fix a bug and typo. Refactor the code.");
|
|
901
|
-
rows.push("- Create third-party middleware - Instruct below.");
|
|
902
|
-
rows.push("- Share - Share your thoughts on the Blog, X, and others.");
|
|
903
|
-
rows.push(`- Make your application - Please try to use ${gitUrl.name}.`);
|
|
904
|
-
rows.push("");
|
|
905
|
-
rows.push("For more details, see [CONTRIBUTING.md](CONTRIBUTING.md).");
|
|
906
|
-
rows.push("\n## Contributors\n");
|
|
907
|
-
rows.push(`Thanks to [all contributors](https://github.com/${gitUrl.full_name}/graphs/contributors)!`);
|
|
908
|
-
}
|
|
909
|
-
rows.push("\n## Authors\n");
|
|
910
|
-
if (gitUser?.name && gitUser?.email) rows.push(`${gitUser.name} <${gitUser.email}>`);
|
|
911
|
-
rows.push("\n## License\n");
|
|
912
|
-
rows.push("Distributed under the MIT License. See [LICENSE](LICENSE) for more information.");
|
|
913
|
-
return rows;
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* 生成标准化的 README 草稿,列出所有子包并补充贡献者、作者信息。
|
|
917
|
-
*/
|
|
918
|
-
async function setReadme_default(ctx) {
|
|
919
|
-
const rows = await getRows(ctx);
|
|
920
|
-
await fs.writeFile(pathe.default.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}\n`);
|
|
921
|
-
}
|
|
922
|
-
//#endregion
|
|
923
|
-
//#region src/commands/init/index.ts
|
|
924
|
-
/**
|
|
925
|
-
* 初始化命令入口,根据配置逐步生成基础文件。
|
|
926
|
-
*/
|
|
927
|
-
async function init(cwd) {
|
|
928
|
-
const ctx = await createContext(cwd);
|
|
929
|
-
const initConfig = ctx.config.commands?.init ?? {};
|
|
930
|
-
if (!initConfig.skipChangeset) await setChangeset_default(ctx);
|
|
931
|
-
if (!initConfig.skipPkgJson) await setPkgJson_default(ctx);
|
|
932
|
-
if (!initConfig.skipReadme) await setReadme_default(ctx);
|
|
933
|
-
if (!initConfig.skipIssueTemplateConfig) await setIssueTemplateConfig_default(ctx);
|
|
934
|
-
}
|
|
935
|
-
//#endregion
|
|
936
|
-
//#region src/commands/mirror/sources.ts
|
|
937
|
-
const chinaMirrorsEnvs = {
|
|
938
|
-
COREPACK_NPM_REGISTRY: "https://registry.npmmirror.com",
|
|
939
|
-
EDGEDRIVER_CDNURL: "https://npmmirror.com/mirrors/edgedriver",
|
|
940
|
-
NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
941
|
-
NVM_NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
942
|
-
PHANTOMJS_CDNURL: "https://cdn.npmmirror.com/binaries/phantomjs",
|
|
943
|
-
CHROMEDRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/chromedriver",
|
|
944
|
-
OPERADRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/operadriver",
|
|
945
|
-
CYPRESS_DOWNLOAD_PATH_TEMPLATE: "https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip",
|
|
946
|
-
ELECTRON_MIRROR: "https://cdn.npmmirror.com/binaries/electron/",
|
|
947
|
-
ELECTRON_BUILDER_BINARIES_MIRROR: "https://cdn.npmmirror.com/binaries/electron-builder-binaries/",
|
|
948
|
-
SASS_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-sass",
|
|
949
|
-
SWC_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-swc",
|
|
950
|
-
NWJS_URLBASE: "https://cdn.npmmirror.com/binaries/nwjs/v",
|
|
951
|
-
PUPPETEER_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
952
|
-
PUPPETEER_DOWNLOAD_BASE_URL: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
953
|
-
PLAYWRIGHT_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/playwright",
|
|
954
|
-
SENTRYCLI_CDNURL: "https://cdn.npmmirror.com/binaries/sentry-cli",
|
|
955
|
-
SAUCECTL_INSTALL_BINARY_MIRROR: "https://cdn.npmmirror.com/binaries/saucectl",
|
|
956
|
-
RE2_DOWNLOAD_MIRROR: "https://cdn.npmmirror.com/binaries/node-re2",
|
|
957
|
-
RE2_DOWNLOAD_SKIP_PATH: "true",
|
|
958
|
-
PRISMA_ENGINES_MIRROR: "https://cdn.npmmirror.com/binaries/prisma",
|
|
959
|
-
npm_config_better_sqlite3_binary_host: "https://cdn.npmmirror.com/binaries/better-sqlite3",
|
|
960
|
-
npm_config_keytar_binary_host: "https://cdn.npmmirror.com/binaries/keytar",
|
|
961
|
-
npm_config_sharp_binary_host: "https://cdn.npmmirror.com/binaries/sharp",
|
|
962
|
-
npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
|
|
963
|
-
npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
|
|
964
|
-
};
|
|
965
|
-
//#endregion
|
|
966
|
-
//#region src/commands/mirror/utils.ts
|
|
967
|
-
/**
|
|
968
|
-
* 在 vscode 里面设置镜像下载地址的环境变量,避免下载缓慢
|
|
969
|
-
*/
|
|
970
|
-
function setMirror(obj, envs = chinaMirrorsEnvs) {
|
|
971
|
-
const platforms = [
|
|
972
|
-
"linux",
|
|
973
|
-
"windows",
|
|
974
|
-
"osx"
|
|
975
|
-
];
|
|
976
|
-
const prefix = "terminal.integrated.env";
|
|
977
|
-
if (typeof obj === "object" && obj) for (const platform of platforms) setByPath(obj, [prefix, platform].join(".").replaceAll(".", "\\."), envs);
|
|
978
|
-
}
|
|
979
|
-
//#endregion
|
|
980
|
-
//#region src/commands/mirror/binaryMirror.ts
|
|
981
|
-
/**
|
|
982
|
-
* 根据中国大陆镜像源,自动向 VSCode settings.json 注入终端环境变量。
|
|
983
|
-
*/
|
|
984
|
-
async function setVscodeBinaryMirror(cwd) {
|
|
985
|
-
const mirrorConfig = await resolveCommandConfig("mirror", cwd);
|
|
986
|
-
const targetJsonPath = pathe.default.resolve(cwd, ".vscode/settings.json");
|
|
987
|
-
await fs.ensureFile(targetJsonPath);
|
|
988
|
-
const json = (0, comment_json.parse)(await fs.readFile(targetJsonPath, "utf8"), void 0, false);
|
|
989
|
-
const env = mirrorConfig?.env ? {
|
|
990
|
-
...chinaMirrorsEnvs,
|
|
991
|
-
...mirrorConfig.env
|
|
992
|
-
} : chinaMirrorsEnvs;
|
|
993
|
-
json && typeof json === "object" && setMirror(json, env);
|
|
994
|
-
await fs.writeFile(targetJsonPath, `${(0, comment_json.stringify)(json, void 0, 2)}\n`, "utf8");
|
|
995
|
-
}
|
|
996
|
-
//#endregion
|
|
997
|
-
//#region src/commands/sync.ts
|
|
998
|
-
function renderCommand(template, pkgName) {
|
|
999
|
-
return template.replaceAll("{name}", pkgName);
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* 批量执行 `cnpm sync`(或自定义命令),将所有包同步到 npmmirror。
|
|
1003
|
-
*/
|
|
1004
|
-
async function syncNpmMirror(cwd, options) {
|
|
1005
|
-
const { concurrency: configConcurrency, command: configCommand, packages: packageFilter, ...workspaceOverrides } = await resolveCommandConfig("sync", cwd) ?? {};
|
|
1006
|
-
const { packages, workspaceDir } = await getWorkspaceData(cwd, {
|
|
1007
|
-
...workspaceOverrides,
|
|
1008
|
-
...options ?? {}
|
|
1009
|
-
});
|
|
1010
|
-
logger.info(`[当前工作区Repo]:\n${packages.map((x) => `- ${picocolors.default.green(x.manifest.name)} : ${pathe.default.relative(workspaceDir, x.rootDir)}`).join("\n")}\n`);
|
|
1011
|
-
const set = new Set(packages.map((x) => x.manifest.name));
|
|
1012
|
-
if (packageFilter?.length) {
|
|
1013
|
-
for (const name of [...set]) if (!name || !packageFilter.includes(name)) set.delete(name);
|
|
1014
|
-
}
|
|
1015
|
-
logger.info(`[即将同步的包]:\n${Array.from(set, (x) => `- ${picocolors.default.green(x ?? "")}`).join("\n")}\n`);
|
|
1016
|
-
const queue = new p_queue.default({ concurrency: configConcurrency ?? Math.max(node_os.default.cpus().length, 1) });
|
|
1017
|
-
const template = configCommand ?? "cnpm sync {name}";
|
|
1018
|
-
const tasks = [];
|
|
1019
|
-
for (const pkgName of set) {
|
|
1020
|
-
if (!pkgName) continue;
|
|
1021
|
-
tasks.push(queue.add(async () => {
|
|
1022
|
-
return (0, _icebreakers_monorepo_templates.execaCommand)(renderCommand(template, pkgName), { stdio: "inherit" });
|
|
1023
|
-
}));
|
|
1024
|
-
}
|
|
1025
|
-
await Promise.all(tasks);
|
|
1026
|
-
}
|
|
1027
|
-
//#endregion
|
|
1028
|
-
//#region src/commands/upgrade/agents.ts
|
|
1029
|
-
const crlfPattern$1 = /\r\n/g;
|
|
1030
|
-
const h2HeadingPrefixPattern = /^##\s+/;
|
|
1031
|
-
function normalizeEol$1(input) {
|
|
1032
|
-
return input.replace(crlfPattern$1, "\n");
|
|
1033
|
-
}
|
|
1034
|
-
function normalizeComparableContent(input) {
|
|
1035
|
-
return normalizeEol$1(input).trimEnd();
|
|
1036
|
-
}
|
|
1037
|
-
function normalizeHeadingKey(line) {
|
|
1038
|
-
return line.replace(h2HeadingPrefixPattern, "").trim().toLowerCase();
|
|
1039
|
-
}
|
|
1040
|
-
function trimEdgeEmptyLines(lines) {
|
|
1041
|
-
const next = [...lines];
|
|
1042
|
-
while (next.length) {
|
|
1043
|
-
const first = next[0];
|
|
1044
|
-
if (first === void 0 || first.trim().length > 0) break;
|
|
1045
|
-
next.shift();
|
|
1046
|
-
}
|
|
1047
|
-
while (next.length) {
|
|
1048
|
-
const last = next.at(-1);
|
|
1049
|
-
if (last === void 0 || last.trim().length > 0) break;
|
|
1050
|
-
next.pop();
|
|
1051
|
-
}
|
|
1052
|
-
return next;
|
|
1053
|
-
}
|
|
1054
|
-
function parseMarkdownByH2(content) {
|
|
1055
|
-
const lines = normalizeEol$1(content).split("\n");
|
|
1056
|
-
const preamble = [];
|
|
1057
|
-
const sections = [];
|
|
1058
|
-
let current;
|
|
1059
|
-
for (const line of lines) {
|
|
1060
|
-
if (h2HeadingPrefixPattern.test(line)) {
|
|
1061
|
-
if (current) sections.push(current);
|
|
1062
|
-
current = {
|
|
1063
|
-
key: normalizeHeadingKey(line),
|
|
1064
|
-
lines: [line]
|
|
1065
|
-
};
|
|
1066
|
-
continue;
|
|
1067
|
-
}
|
|
1068
|
-
if (current) {
|
|
1069
|
-
current.lines.push(line);
|
|
1070
|
-
continue;
|
|
1071
|
-
}
|
|
1072
|
-
preamble.push(line);
|
|
1073
|
-
}
|
|
1074
|
-
if (current) sections.push(current);
|
|
1075
|
-
return {
|
|
1076
|
-
preamble,
|
|
1077
|
-
sections
|
|
1078
|
-
};
|
|
1079
|
-
}
|
|
1080
|
-
function mergePlainText(source, target) {
|
|
1081
|
-
const sourceLines = trimEdgeEmptyLines(normalizeEol$1(source).split("\n"));
|
|
1082
|
-
const result = trimEdgeEmptyLines(normalizeEol$1(target).split("\n"));
|
|
1083
|
-
const seen = new Set(result);
|
|
1084
|
-
for (const line of sourceLines) {
|
|
1085
|
-
if (!line.trim()) continue;
|
|
1086
|
-
if (seen.has(line)) continue;
|
|
1087
|
-
seen.add(line);
|
|
1088
|
-
result.push(line);
|
|
1089
|
-
}
|
|
1090
|
-
return `${result.join("\n")}\n`;
|
|
1091
|
-
}
|
|
1092
|
-
function getSectionSignature(section) {
|
|
1093
|
-
return `${section.key}\n${trimEdgeEmptyLines(section.lines).join("\n")}`;
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
* Merge AGENTS instructions by keeping existing sections and filling missing sections
|
|
1097
|
-
* from source defaults. This avoids destructive overwrite while still syncing updates.
|
|
1098
|
-
*/
|
|
1099
|
-
function mergeAgentsMarkdown(source, target) {
|
|
1100
|
-
const sourceParsed = parseMarkdownByH2(source);
|
|
1101
|
-
const targetParsed = parseMarkdownByH2(target);
|
|
1102
|
-
if (!sourceParsed.sections.length || !targetParsed.sections.length) return mergePlainText(source, target);
|
|
1103
|
-
const sourceSectionKeys = new Set(sourceParsed.sections.map((section) => section.key));
|
|
1104
|
-
const targetSectionMap = new Map(targetParsed.sections.map((section) => [section.key, section]));
|
|
1105
|
-
const mergedSections = [];
|
|
1106
|
-
for (const section of sourceParsed.sections) mergedSections.push(targetSectionMap.get(section.key) ?? section);
|
|
1107
|
-
const seenTargetOnlySectionSignatures = /* @__PURE__ */ new Set();
|
|
1108
|
-
for (const section of targetParsed.sections) if (!sourceSectionKeys.has(section.key)) {
|
|
1109
|
-
const signature = getSectionSignature(section);
|
|
1110
|
-
if (seenTargetOnlySectionSignatures.has(signature)) continue;
|
|
1111
|
-
seenTargetOnlySectionSignatures.add(signature);
|
|
1112
|
-
mergedSections.push(section);
|
|
1113
|
-
}
|
|
1114
|
-
const preamble = trimEdgeEmptyLines(targetParsed.preamble.length ? targetParsed.preamble : sourceParsed.preamble);
|
|
1115
|
-
const blocks = [];
|
|
1116
|
-
if (preamble.length) blocks.push(preamble.join("\n"));
|
|
1117
|
-
for (const section of mergedSections) blocks.push(trimEdgeEmptyLines(section.lines).join("\n"));
|
|
1118
|
-
return `${blocks.filter(Boolean).join("\n\n")}\n`;
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* Compare AGENTS markdown with normalized EOL and trailing newline differences ignored.
|
|
1122
|
-
*/
|
|
1123
|
-
function isAgentsMarkdownEquivalent(left, right) {
|
|
1124
|
-
return normalizeComparableContent(left) === normalizeComparableContent(right);
|
|
1125
|
-
}
|
|
1126
|
-
//#endregion
|
|
1127
|
-
//#region src/commands/upgrade/overwrite.ts
|
|
1128
|
-
function asBuffer(data) {
|
|
1129
|
-
return typeof data === "string" ? node_buffer.Buffer.from(data) : data;
|
|
1130
|
-
}
|
|
1131
|
-
async function evaluateWriteIntent(targetPath, options) {
|
|
1132
|
-
const { skipOverwrite, source } = options;
|
|
1133
|
-
if (!await fs.pathExists(targetPath)) return {
|
|
1134
|
-
type: "write",
|
|
1135
|
-
reason: "missing"
|
|
1136
|
-
};
|
|
1137
|
-
if (skipOverwrite) return {
|
|
1138
|
-
type: "skip",
|
|
1139
|
-
reason: "skipOverwrite"
|
|
1140
|
-
};
|
|
1141
|
-
const src = asBuffer(source);
|
|
1142
|
-
let destSize = 0;
|
|
1143
|
-
try {
|
|
1144
|
-
destSize = (await fs.stat(targetPath)).size;
|
|
1145
|
-
} catch {
|
|
1146
|
-
return {
|
|
1147
|
-
type: "write",
|
|
1148
|
-
reason: "missing"
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
if (destSize !== src.length) return {
|
|
1152
|
-
type: "prompt",
|
|
1153
|
-
reason: "changed"
|
|
1154
|
-
};
|
|
1155
|
-
if (!isFileChanged(src, await fs.readFile(targetPath))) return {
|
|
1156
|
-
type: "skip",
|
|
1157
|
-
reason: "identical"
|
|
1158
|
-
};
|
|
1159
|
-
return {
|
|
1160
|
-
type: "prompt",
|
|
1161
|
-
reason: "changed"
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
async function scheduleOverwrite(intent, options) {
|
|
1165
|
-
const { relPath, targetPath, action, pending } = options;
|
|
1166
|
-
if (intent.type === "write") {
|
|
1167
|
-
await action();
|
|
1168
|
-
return;
|
|
1169
|
-
}
|
|
1170
|
-
if (intent.type === "prompt") pending.push({
|
|
1171
|
-
relPath,
|
|
1172
|
-
targetPath,
|
|
1173
|
-
action
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
async function flushPendingOverwrites(pending) {
|
|
1177
|
-
if (!pending.length) return;
|
|
1178
|
-
const selected = await (0, _icebreakers_monorepo_templates.checkbox)({
|
|
1179
|
-
message: "检测到以下文件内容与当前仓库不同,选择需要覆盖的文件",
|
|
1180
|
-
choices: pending.map((item) => ({
|
|
1181
|
-
name: picocolors.default.greenBright(item.relPath),
|
|
1182
|
-
value: item.targetPath,
|
|
1183
|
-
checked: false
|
|
1184
|
-
})),
|
|
1185
|
-
loop: false
|
|
1186
|
-
});
|
|
1187
|
-
const selectedSet = new Set(selected);
|
|
1188
|
-
for (const item of pending) if (selectedSet.has(item.targetPath)) await item.action();
|
|
1189
|
-
}
|
|
1190
|
-
const scriptsEntries = Object.entries({
|
|
1191
|
-
"script:init": "monorepo init",
|
|
1192
|
-
"script:sync": "monorepo sync",
|
|
1193
|
-
"script:clean": "monorepo clean",
|
|
1194
|
-
"script:mirror": "monorepo mirror",
|
|
1195
|
-
"commitlint": "commitlint --edit"
|
|
1196
|
-
});
|
|
1197
|
-
//#endregion
|
|
1198
|
-
//#region src/commands/upgrade/pkg-json.ts
|
|
1199
|
-
const NON_OVERRIDABLE_PREFIXES = ["workspace:", "catalog:"];
|
|
1200
|
-
function parseVersion(input) {
|
|
1201
|
-
if (typeof input !== "string" || input.trim().length === 0) return null;
|
|
1202
|
-
try {
|
|
1203
|
-
return (0, semver.minVersion)(input) ?? (0, semver.coerce)(input);
|
|
1204
|
-
} catch {
|
|
1205
|
-
return null;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function hasNonOverridablePrefix(version) {
|
|
1209
|
-
if (typeof version !== "string") return false;
|
|
1210
|
-
return NON_OVERRIDABLE_PREFIXES.some((prefix) => version.startsWith(prefix));
|
|
1211
|
-
}
|
|
1212
|
-
function shouldAssignVersion(currentVersion, nextVersion) {
|
|
1213
|
-
if (typeof currentVersion !== "string" || currentVersion.trim().length === 0) return true;
|
|
1214
|
-
if (currentVersion === nextVersion) return false;
|
|
1215
|
-
const current = parseVersion(currentVersion);
|
|
1216
|
-
const next = parseVersion(nextVersion);
|
|
1217
|
-
if (!current || !next) return true;
|
|
1218
|
-
return !(0, semver.gte)(current, next);
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* 将内置 package.json 内容合并进目标工程:
|
|
1222
|
-
* - 同步依赖(保留 workspace: 前缀的版本)
|
|
1223
|
-
* - 确保 @icebreakers/monorepo 使用最新版本
|
|
1224
|
-
* - 写入预置脚本
|
|
1225
|
-
*/
|
|
1226
|
-
function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
1227
|
-
const packageManager = sourcePkgJson.packageManager ?? "";
|
|
1228
|
-
const sourceDeps = sourcePkgJson.dependencies ?? {};
|
|
1229
|
-
const sourceDevDeps = sourcePkgJson.devDependencies ?? {};
|
|
1230
|
-
const targetDeps = { ...targetPkgJson.dependencies ?? {} };
|
|
1231
|
-
const targetDevDeps = { ...targetPkgJson.devDependencies ?? {} };
|
|
1232
|
-
if (packageManager) targetPkgJson.packageManager = packageManager;
|
|
1233
|
-
for (const [depName, depVersion] of Object.entries(sourceDeps)) {
|
|
1234
|
-
if (typeof depVersion !== "string") continue;
|
|
1235
|
-
const targetVersion = targetDeps[depName];
|
|
1236
|
-
if (hasNonOverridablePrefix(targetVersion)) continue;
|
|
1237
|
-
if (shouldAssignVersion(targetVersion, depVersion)) targetDeps[depName] = depVersion;
|
|
1238
|
-
}
|
|
1239
|
-
if (Object.keys(targetDeps).length) targetPkgJson.dependencies = targetDeps;
|
|
1240
|
-
for (const [depName, depVersion] of Object.entries(sourceDevDeps)) {
|
|
1241
|
-
if (typeof depVersion !== "string") continue;
|
|
1242
|
-
if (depName === name) {
|
|
1243
|
-
const nextVersion = `^${version}`;
|
|
1244
|
-
const targetVersion = targetDevDeps[depName];
|
|
1245
|
-
if (!hasNonOverridablePrefix(targetVersion) && shouldAssignVersion(targetVersion, nextVersion)) targetDevDeps[depName] = nextVersion;
|
|
1246
|
-
} else {
|
|
1247
|
-
const targetVersion = targetDevDeps[depName];
|
|
1248
|
-
if (hasNonOverridablePrefix(targetVersion)) continue;
|
|
1249
|
-
if (shouldAssignVersion(targetVersion, depVersion)) targetDevDeps[depName] = depVersion;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
if (Object.keys(targetDevDeps).length) targetPkgJson.devDependencies = targetDevDeps;
|
|
1253
|
-
const scriptPairs = options?.scripts ? Object.entries(options.scripts) : scriptsEntries;
|
|
1254
|
-
if (scriptPairs.length) {
|
|
1255
|
-
const scripts = { ...targetPkgJson.scripts ?? {} };
|
|
1256
|
-
for (const [scriptName, scriptCmd] of scriptPairs) scripts[scriptName] = scriptCmd;
|
|
1257
|
-
targetPkgJson.scripts = scripts;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
//#endregion
|
|
1261
|
-
//#region src/commands/upgrade/workspace.ts
|
|
1262
|
-
function isPlainObject(value) {
|
|
1263
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1264
|
-
}
|
|
1265
|
-
function normalizeQuotedString(value) {
|
|
1266
|
-
const trimmed = value.trim();
|
|
1267
|
-
const first = trimmed[0];
|
|
1268
|
-
if ((first === "'" || first === "\"") && trimmed.endsWith(first)) return trimmed.slice(1, -1);
|
|
1269
|
-
return trimmed;
|
|
1270
|
-
}
|
|
1271
|
-
function normalizeWorkspaceManifest(manifest) {
|
|
1272
|
-
if (isPlainObject(manifest)) return { ...manifest };
|
|
1273
|
-
return {};
|
|
1274
|
-
}
|
|
1275
|
-
function mergeUniqueArray(target, source) {
|
|
1276
|
-
const seen = new Set(target.map((item) => {
|
|
1277
|
-
return typeof item === "string" ? normalizeQuotedString(item) : item;
|
|
1278
|
-
}));
|
|
1279
|
-
const result = [...target];
|
|
1280
|
-
for (const item of source) {
|
|
1281
|
-
const key = typeof item === "string" ? normalizeQuotedString(item) : item;
|
|
1282
|
-
if (!seen.has(key)) {
|
|
1283
|
-
seen.add(key);
|
|
1284
|
-
result.push(item);
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
return result;
|
|
1288
|
-
}
|
|
1289
|
-
/**
|
|
1290
|
-
* Merge pnpm workspace manifests by filling missing fields only.
|
|
1291
|
-
* Existing values take precedence; arrays are deduped while keeping target order.
|
|
1292
|
-
*/
|
|
1293
|
-
function mergeWorkspaceManifest(source, target) {
|
|
1294
|
-
const normalizedSource = normalizeWorkspaceManifest(source);
|
|
1295
|
-
const normalizedTarget = normalizeWorkspaceManifest(target);
|
|
1296
|
-
const result = { ...normalizedTarget };
|
|
1297
|
-
for (const [key, value] of Object.entries(normalizedSource)) {
|
|
1298
|
-
const current = normalizedTarget[key];
|
|
1299
|
-
if (current === void 0) {
|
|
1300
|
-
result[key] = value;
|
|
1301
|
-
continue;
|
|
1302
|
-
}
|
|
1303
|
-
if (Array.isArray(current) && Array.isArray(value)) {
|
|
1304
|
-
result[key] = mergeUniqueArray(current, value);
|
|
1305
|
-
continue;
|
|
1306
|
-
}
|
|
1307
|
-
if (isPlainObject(current) && isPlainObject(value)) {
|
|
1308
|
-
result[key] = mergeWorkspaceManifest(value, current);
|
|
1309
|
-
continue;
|
|
1310
|
-
}
|
|
1311
|
-
result[key] = current;
|
|
1312
|
-
}
|
|
1313
|
-
return result;
|
|
1314
|
-
}
|
|
1315
|
-
//#endregion
|
|
1316
|
-
//#region src/commands/upgrade/index.ts
|
|
1317
|
-
const crlfPattern = /\r\n/g;
|
|
1318
|
-
function normalizeEol(input) {
|
|
1319
|
-
return input.replace(crlfPattern, "\n");
|
|
1320
|
-
}
|
|
1321
|
-
function normalizeGitignoreLine(line) {
|
|
1322
|
-
const trimmed = line.trim();
|
|
1323
|
-
if (!trimmed) return "";
|
|
1324
|
-
if (trimmed.startsWith("#")) return `#${trimmed.slice(1).trim()}`;
|
|
1325
|
-
return trimmed;
|
|
1326
|
-
}
|
|
1327
|
-
function isTextEquivalent(left, right) {
|
|
1328
|
-
return normalizeEol(left).trimEnd() === normalizeEol(right).trimEnd();
|
|
1329
|
-
}
|
|
1330
|
-
function mergeGitignore(source, target) {
|
|
1331
|
-
const sourceLines = normalizeEol(source).split("\n");
|
|
1332
|
-
const result = normalizeEol(target).split("\n");
|
|
1333
|
-
const seen = new Set(result.map((line) => normalizeGitignoreLine(line)).filter(Boolean));
|
|
1334
|
-
for (const line of sourceLines) {
|
|
1335
|
-
const normalized = normalizeGitignoreLine(line);
|
|
1336
|
-
if (!normalized || seen.has(normalized)) continue;
|
|
1337
|
-
seen.add(normalized);
|
|
1338
|
-
result.push(line);
|
|
1339
|
-
}
|
|
1340
|
-
while (result.length) {
|
|
1341
|
-
const last = result.at(-1);
|
|
1342
|
-
if (last === void 0 || last.trim().length > 0) break;
|
|
1343
|
-
result.pop();
|
|
1344
|
-
}
|
|
1345
|
-
return `${result.join("\n")}\n`;
|
|
1346
|
-
}
|
|
1347
|
-
/**
|
|
1348
|
-
* 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
|
|
1349
|
-
*/
|
|
1350
|
-
async function upgradeMonorepo(opts) {
|
|
1351
|
-
await (0, _icebreakers_monorepo_templates.ensureTemplateAssetsPrepared)();
|
|
1352
|
-
const cwd = opts.cwd ?? node_process.default.cwd();
|
|
1353
|
-
const upgradeConfig = await resolveCommandConfig("upgrade", cwd);
|
|
1354
|
-
const merged = {
|
|
1355
|
-
cwd,
|
|
1356
|
-
outDir: "",
|
|
1357
|
-
...upgradeConfig ?? {},
|
|
1358
|
-
...opts
|
|
1359
|
-
};
|
|
1360
|
-
const outDir = merged.outDir ?? "";
|
|
1361
|
-
const absOutDir = pathe.default.isAbsolute(outDir) ? outDir : pathe.default.join(cwd, outDir);
|
|
1362
|
-
const repoName = await new GitClient({ baseDir: cwd }).getRepoName();
|
|
1363
|
-
const useCoreAssets = merged.core ?? false;
|
|
1364
|
-
merged.core = useCoreAssets;
|
|
1365
|
-
const baseTargets = (0, _icebreakers_monorepo_templates.getAssetTargets)(useCoreAssets);
|
|
1366
|
-
const configTargets = upgradeConfig?.targets ?? [];
|
|
1367
|
-
const mergeTargets = upgradeConfig?.mergeTargets;
|
|
1368
|
-
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : [...new Set([...baseTargets, ...configTargets])] : baseTargets;
|
|
1369
|
-
if (merged.interactive) targets = await (0, _icebreakers_monorepo_templates.checkbox)({
|
|
1370
|
-
message: "选择你需要的文件",
|
|
1371
|
-
choices: targets.map((x) => {
|
|
1372
|
-
return {
|
|
1373
|
-
value: x,
|
|
1374
|
-
checked: true
|
|
1375
|
-
};
|
|
1376
|
-
})
|
|
1377
|
-
});
|
|
1378
|
-
const regexpArr = targets.map((x) => {
|
|
1379
|
-
return new RegExp(`^${escapeStringRegexp(x)}`);
|
|
1380
|
-
});
|
|
1381
|
-
const skipChangesetMarkdown = upgradeConfig?.skipChangesetMarkdown ?? true;
|
|
1382
|
-
const scriptOverrides = upgradeConfig?.scripts;
|
|
1383
|
-
const skipOverwrite = merged.skipOverwrite;
|
|
1384
|
-
const buildWriteIntentOptions = (source) => {
|
|
1385
|
-
return skipOverwrite === void 0 ? { source } : {
|
|
1386
|
-
skipOverwrite,
|
|
1387
|
-
source
|
|
1388
|
-
};
|
|
1389
|
-
};
|
|
1390
|
-
const pendingOverwrites = [];
|
|
1391
|
-
for await (const file of (0, klaw.default)(_icebreakers_monorepo_templates.assetsDir, { filter(p) {
|
|
1392
|
-
return isMatch((0, _icebreakers_monorepo_templates.toWorkspaceGitignorePath)(pathe.default.relative(_icebreakers_monorepo_templates.assetsDir, p)), regexpArr);
|
|
1393
|
-
} })) {
|
|
1394
|
-
if (!file.stats.isFile()) continue;
|
|
1395
|
-
const relPath = (0, _icebreakers_monorepo_templates.toWorkspaceGitignorePath)(pathe.default.relative(_icebreakers_monorepo_templates.assetsDir, file.path));
|
|
1396
|
-
if (skipChangesetMarkdown && relPath.startsWith(".changeset/") && relPath.endsWith(".md")) continue;
|
|
1397
|
-
const targetPath = pathe.default.resolve(absOutDir, relPath);
|
|
1398
|
-
try {
|
|
1399
|
-
if (relPath === "package.json") {
|
|
1400
|
-
if (!await fs.pathExists(targetPath)) continue;
|
|
1401
|
-
const sourcePkgJson = await fs.readJson(file.path);
|
|
1402
|
-
const targetPkgJson = await fs.readJson(targetPath);
|
|
1403
|
-
setPkgJson(sourcePkgJson, targetPkgJson, scriptOverrides ? { scripts: scriptOverrides } : void 0);
|
|
1404
|
-
const data = `${JSON.stringify(targetPkgJson, void 0, 2)}\n`;
|
|
1405
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1406
|
-
const action = async () => {
|
|
1407
|
-
await fs.outputFile(targetPath, data, "utf8");
|
|
1408
|
-
logger.success(targetPath);
|
|
1409
|
-
};
|
|
1410
|
-
await scheduleOverwrite(intent, {
|
|
1411
|
-
relPath,
|
|
1412
|
-
targetPath,
|
|
1413
|
-
action,
|
|
1414
|
-
pending: pendingOverwrites
|
|
1415
|
-
});
|
|
1416
|
-
continue;
|
|
1417
|
-
}
|
|
1418
|
-
if (relPath === "pnpm-workspace.yaml") {
|
|
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({});
|
|
1422
|
-
const mergedManifest = exists ? mergeWorkspaceManifest(sourceManifest, targetManifest) : sourceManifest;
|
|
1423
|
-
const data = yaml.default.stringify(mergedManifest, { singleQuote: true });
|
|
1424
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1425
|
-
const action = async () => {
|
|
1426
|
-
await fs.outputFile(targetPath, data, "utf8");
|
|
1427
|
-
logger.success(targetPath);
|
|
1428
|
-
};
|
|
1429
|
-
await scheduleOverwrite(intent, {
|
|
1430
|
-
relPath,
|
|
1431
|
-
targetPath,
|
|
1432
|
-
action,
|
|
1433
|
-
pending: pendingOverwrites
|
|
1434
|
-
});
|
|
1435
|
-
continue;
|
|
1436
|
-
}
|
|
1437
|
-
if (relPath === ".gitignore") {
|
|
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") : "";
|
|
1441
|
-
const data = exists ? mergeGitignore(source, target) : source;
|
|
1442
|
-
if (exists && isTextEquivalent(target, data)) continue;
|
|
1443
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1444
|
-
const action = async () => {
|
|
1445
|
-
await fs.outputFile(targetPath, data, "utf8");
|
|
1446
|
-
logger.success(targetPath);
|
|
1447
|
-
};
|
|
1448
|
-
await scheduleOverwrite(intent, {
|
|
1449
|
-
relPath,
|
|
1450
|
-
targetPath,
|
|
1451
|
-
action,
|
|
1452
|
-
pending: pendingOverwrites
|
|
1453
|
-
});
|
|
1454
|
-
continue;
|
|
1455
|
-
}
|
|
1456
|
-
if (relPath === "AGENTS.md") {
|
|
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") : "";
|
|
1460
|
-
const data = exists ? mergeAgentsMarkdown(source, target) : source;
|
|
1461
|
-
if (exists && isAgentsMarkdownEquivalent(target, data)) continue;
|
|
1462
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1463
|
-
const action = async () => {
|
|
1464
|
-
await fs.outputFile(targetPath, data, "utf8");
|
|
1465
|
-
logger.success(targetPath);
|
|
1466
|
-
};
|
|
1467
|
-
await scheduleOverwrite(intent, {
|
|
1468
|
-
relPath,
|
|
1469
|
-
targetPath,
|
|
1470
|
-
action,
|
|
1471
|
-
pending: pendingOverwrites
|
|
1472
|
-
});
|
|
1473
|
-
continue;
|
|
1474
|
-
}
|
|
1475
|
-
if (relPath === ".changeset/config.json" && repoName) {
|
|
1476
|
-
const changesetJson = await fs.readJson(file.path);
|
|
1477
|
-
setByPath(changesetJson, "changelog.1.repo", repoName);
|
|
1478
|
-
const data = `${JSON.stringify(changesetJson, void 0, 2)}\n`;
|
|
1479
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1480
|
-
const action = async () => {
|
|
1481
|
-
await fs.outputFile(targetPath, data, "utf8");
|
|
1482
|
-
logger.success(targetPath);
|
|
1483
|
-
};
|
|
1484
|
-
await scheduleOverwrite(intent, {
|
|
1485
|
-
relPath,
|
|
1486
|
-
targetPath,
|
|
1487
|
-
action,
|
|
1488
|
-
pending: pendingOverwrites
|
|
1489
|
-
});
|
|
1490
|
-
continue;
|
|
1491
|
-
}
|
|
1492
|
-
if (relPath === "LICENSE") {
|
|
1493
|
-
const source = await fs.readFile(file.path);
|
|
1494
|
-
const intent = await evaluateWriteIntent(targetPath, {
|
|
1495
|
-
skipOverwrite: true,
|
|
1496
|
-
source
|
|
1497
|
-
});
|
|
1498
|
-
const action = async () => {
|
|
1499
|
-
await fs.outputFile(targetPath, source);
|
|
1500
|
-
logger.success(targetPath);
|
|
1501
|
-
};
|
|
1502
|
-
await scheduleOverwrite(intent, {
|
|
1503
|
-
relPath,
|
|
1504
|
-
targetPath,
|
|
1505
|
-
action,
|
|
1506
|
-
pending: pendingOverwrites
|
|
1507
|
-
});
|
|
1508
|
-
continue;
|
|
1509
|
-
}
|
|
1510
|
-
if (relPath === ".github/ISSUE_TEMPLATE/config.yml") {
|
|
1511
|
-
const data = updateIssueTemplateConfig(await fs.readFile(file.path, "utf8"), repoName);
|
|
1512
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1513
|
-
const action = async () => {
|
|
1514
|
-
await fs.outputFile(targetPath, data);
|
|
1515
|
-
logger.success(targetPath);
|
|
1516
|
-
};
|
|
1517
|
-
await scheduleOverwrite(intent, {
|
|
1518
|
-
relPath,
|
|
1519
|
-
targetPath,
|
|
1520
|
-
action,
|
|
1521
|
-
pending: pendingOverwrites
|
|
1522
|
-
});
|
|
1523
|
-
continue;
|
|
1524
|
-
}
|
|
1525
|
-
const source = await fs.readFile(file.path);
|
|
1526
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(source));
|
|
1527
|
-
const action = async () => {
|
|
1528
|
-
await fs.outputFile(targetPath, source);
|
|
1529
|
-
logger.success(targetPath);
|
|
1530
|
-
};
|
|
1531
|
-
await scheduleOverwrite(intent, {
|
|
1532
|
-
relPath,
|
|
1533
|
-
targetPath,
|
|
1534
|
-
action,
|
|
1535
|
-
pending: pendingOverwrites
|
|
1536
|
-
});
|
|
1537
|
-
} catch (error) {
|
|
1538
|
-
if (isIgnorableFsError(error)) continue;
|
|
1539
|
-
throw error;
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
await flushPendingOverwrites(pendingOverwrites);
|
|
1543
|
-
}
|
|
1544
|
-
//#endregion
|
|
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
|
-
}
|
|
1634
|
-
});
|
|
1635
|
-
Object.defineProperty(exports, "generateAgenticTemplates", {
|
|
1636
|
-
enumerable: true,
|
|
1637
|
-
get: function() {
|
|
1638
|
-
return generateAgenticTemplates;
|
|
1639
|
-
}
|
|
1640
|
-
});
|
|
1641
|
-
Object.defineProperty(exports, "getCreateChoices", {
|
|
1642
|
-
enumerable: true,
|
|
1643
|
-
get: function() {
|
|
1644
|
-
return getCreateChoices;
|
|
1645
|
-
}
|
|
1646
|
-
});
|
|
1647
|
-
Object.defineProperty(exports, "getFileHash", {
|
|
1648
|
-
enumerable: true,
|
|
1649
|
-
get: function() {
|
|
1650
|
-
return getFileHash;
|
|
1651
|
-
}
|
|
1652
|
-
});
|
|
1653
|
-
Object.defineProperty(exports, "getSkillTargetPaths", {
|
|
1654
|
-
enumerable: true,
|
|
1655
|
-
get: function() {
|
|
1656
|
-
return getSkillTargetPaths;
|
|
1657
|
-
}
|
|
1658
|
-
});
|
|
1659
|
-
Object.defineProperty(exports, "getTemplateMap", {
|
|
1660
|
-
enumerable: true,
|
|
1661
|
-
get: function() {
|
|
1662
|
-
return getTemplateMap;
|
|
1663
|
-
}
|
|
1664
|
-
});
|
|
1665
|
-
Object.defineProperty(exports, "getWorkspaceData", {
|
|
1666
|
-
enumerable: true,
|
|
1667
|
-
get: function() {
|
|
1668
|
-
return getWorkspaceData;
|
|
1669
|
-
}
|
|
1670
|
-
});
|
|
1671
|
-
Object.defineProperty(exports, "getWorkspacePackages", {
|
|
1672
|
-
enumerable: true,
|
|
1673
|
-
get: function() {
|
|
1674
|
-
return getWorkspacePackages;
|
|
1675
|
-
}
|
|
1676
|
-
});
|
|
1677
|
-
Object.defineProperty(exports, "init", {
|
|
1678
|
-
enumerable: true,
|
|
1679
|
-
get: function() {
|
|
1680
|
-
return init;
|
|
1681
|
-
}
|
|
1682
|
-
});
|
|
1683
|
-
Object.defineProperty(exports, "isFileChanged", {
|
|
1684
|
-
enumerable: true,
|
|
1685
|
-
get: function() {
|
|
1686
|
-
return isFileChanged;
|
|
1687
|
-
}
|
|
1688
|
-
});
|
|
1689
|
-
Object.defineProperty(exports, "isIgnorableFsError", {
|
|
1690
|
-
enumerable: true,
|
|
1691
|
-
get: function() {
|
|
1692
|
-
return isIgnorableFsError;
|
|
1693
|
-
}
|
|
1694
|
-
});
|
|
1695
|
-
Object.defineProperty(exports, "isMatch", {
|
|
1696
|
-
enumerable: true,
|
|
1697
|
-
get: function() {
|
|
1698
|
-
return isMatch;
|
|
1699
|
-
}
|
|
1700
|
-
});
|
|
1701
|
-
Object.defineProperty(exports, "loadAgenticTasks", {
|
|
1702
|
-
enumerable: true,
|
|
1703
|
-
get: function() {
|
|
1704
|
-
return loadAgenticTasks;
|
|
1705
|
-
}
|
|
1706
|
-
});
|
|
1707
|
-
Object.defineProperty(exports, "loadMonorepoConfig", {
|
|
1708
|
-
enumerable: true,
|
|
1709
|
-
get: function() {
|
|
1710
|
-
return loadMonorepoConfig;
|
|
1711
|
-
}
|
|
1712
|
-
});
|
|
1713
|
-
Object.defineProperty(exports, "logger", {
|
|
1714
|
-
enumerable: true,
|
|
1715
|
-
get: function() {
|
|
1716
|
-
return logger;
|
|
1717
|
-
}
|
|
1718
|
-
});
|
|
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
|
-
}
|
|
1730
|
-
});
|
|
1731
|
-
Object.defineProperty(exports, "outputJSON", {
|
|
1732
|
-
enumerable: true,
|
|
1733
|
-
get: function() {
|
|
1734
|
-
return outputJSON;
|
|
1735
|
-
}
|
|
1736
|
-
});
|
|
1737
|
-
Object.defineProperty(exports, "outputJson", {
|
|
1738
|
-
enumerable: true,
|
|
1739
|
-
get: function() {
|
|
1740
|
-
return outputJson;
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
Object.defineProperty(exports, "packageDir", {
|
|
1744
|
-
enumerable: true,
|
|
1745
|
-
get: function() {
|
|
1746
|
-
return packageDir;
|
|
1747
|
-
}
|
|
1748
|
-
});
|
|
1749
|
-
Object.defineProperty(exports, "pathExists", {
|
|
1750
|
-
enumerable: true,
|
|
1751
|
-
get: function() {
|
|
1752
|
-
return pathExists;
|
|
1753
|
-
}
|
|
1754
|
-
});
|
|
1755
|
-
Object.defineProperty(exports, "readJSON", {
|
|
1756
|
-
enumerable: true,
|
|
1757
|
-
get: function() {
|
|
1758
|
-
return readJSON;
|
|
1759
|
-
}
|
|
1760
|
-
});
|
|
1761
|
-
Object.defineProperty(exports, "readJson", {
|
|
1762
|
-
enumerable: true,
|
|
1763
|
-
get: function() {
|
|
1764
|
-
return readJson;
|
|
1765
|
-
}
|
|
1766
|
-
});
|
|
1767
|
-
Object.defineProperty(exports, "remove", {
|
|
1768
|
-
enumerable: true,
|
|
1769
|
-
get: function() {
|
|
1770
|
-
return remove;
|
|
1771
|
-
}
|
|
1772
|
-
});
|
|
1773
|
-
Object.defineProperty(exports, "resolveCommandConfig", {
|
|
1774
|
-
enumerable: true,
|
|
1775
|
-
get: function() {
|
|
1776
|
-
return resolveCommandConfig;
|
|
1777
|
-
}
|
|
1778
|
-
});
|
|
1779
|
-
Object.defineProperty(exports, "rootDir", {
|
|
1780
|
-
enumerable: true,
|
|
1781
|
-
get: function() {
|
|
1782
|
-
return rootDir;
|
|
1783
|
-
}
|
|
1784
|
-
});
|
|
1785
|
-
Object.defineProperty(exports, "setByPath", {
|
|
1786
|
-
enumerable: true,
|
|
1787
|
-
get: function() {
|
|
1788
|
-
return setByPath;
|
|
1789
|
-
}
|
|
1790
|
-
});
|
|
1791
|
-
Object.defineProperty(exports, "setVscodeBinaryMirror", {
|
|
1792
|
-
enumerable: true,
|
|
1793
|
-
get: function() {
|
|
1794
|
-
return setVscodeBinaryMirror;
|
|
1795
|
-
}
|
|
1796
|
-
});
|
|
1797
|
-
Object.defineProperty(exports, "skillTargets", {
|
|
1798
|
-
enumerable: true,
|
|
1799
|
-
get: function() {
|
|
1800
|
-
return skillTargets;
|
|
1801
|
-
}
|
|
1802
|
-
});
|
|
1803
|
-
Object.defineProperty(exports, "syncNpmMirror", {
|
|
1804
|
-
enumerable: true,
|
|
1805
|
-
get: function() {
|
|
1806
|
-
return syncNpmMirror;
|
|
1807
|
-
}
|
|
1808
|
-
});
|
|
1809
|
-
Object.defineProperty(exports, "syncSkills", {
|
|
1810
|
-
enumerable: true,
|
|
1811
|
-
get: function() {
|
|
1812
|
-
return syncSkills;
|
|
1813
|
-
}
|
|
1814
|
-
});
|
|
1815
|
-
Object.defineProperty(exports, "templateMap", {
|
|
1816
|
-
enumerable: true,
|
|
1817
|
-
get: function() {
|
|
1818
|
-
return templateMap;
|
|
1819
|
-
}
|
|
1820
|
-
});
|
|
1821
|
-
Object.defineProperty(exports, "updateIssueTemplateConfig", {
|
|
1822
|
-
enumerable: true,
|
|
1823
|
-
get: function() {
|
|
1824
|
-
return updateIssueTemplateConfig;
|
|
1825
|
-
}
|
|
1826
|
-
});
|
|
1827
|
-
Object.defineProperty(exports, "upgradeMonorepo", {
|
|
1828
|
-
enumerable: true,
|
|
1829
|
-
get: function() {
|
|
1830
|
-
return upgradeMonorepo;
|
|
1831
|
-
}
|
|
1832
|
-
});
|
|
1833
|
-
Object.defineProperty(exports, "version", {
|
|
1834
|
-
enumerable: true,
|
|
1835
|
-
get: function() {
|
|
1836
|
-
return version;
|
|
1837
|
-
}
|
|
1838
|
-
});
|
|
1839
|
-
Object.defineProperty(exports, "writeJSON", {
|
|
1840
|
-
enumerable: true,
|
|
1841
|
-
get: function() {
|
|
1842
|
-
return writeJSON;
|
|
1843
|
-
}
|
|
1844
|
-
});
|
|
1845
|
-
Object.defineProperty(exports, "writeJson", {
|
|
1846
|
-
enumerable: true,
|
|
1847
|
-
get: function() {
|
|
1848
|
-
return writeJson;
|
|
1849
|
-
}
|
|
1850
|
-
});
|