@icebreakers/monorepo 5.5.10 → 5.7.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 +2 -0
- package/dist/baseline-DPfotf4y.mjs +146 -0
- package/dist/bundle-B9vRch4R.mjs +49 -0
- package/dist/catalog-CDEyc1uA.mjs +299 -0
- package/dist/cli.mjs +1487 -156
- package/dist/commands-TS8ABFdP.mjs +13820 -0
- package/dist/config-C38c_Q8L.mjs +66 -0
- package/dist/{create-flow-C811m80z.mjs → create-flow-CCr2hfSY.mjs} +103 -40
- package/dist/deps-CUdI2DaB.mjs +47 -0
- package/dist/execute-PX1hT0qv.mjs +68 -0
- package/dist/execute-Vi4qHe-D.mjs +663 -0
- package/dist/format-DZ7L34rf.mjs +28 -0
- package/dist/index-CoCTFWZJ.d.mts +2150 -0
- package/dist/index.d.mts +1741 -111
- package/dist/index.mjs +60 -6
- package/dist/inputs-_xIVONmB.mjs +50 -0
- package/dist/npm-B25nrSyz.mjs +82 -0
- package/dist/plan-B5aE_WNF.mjs +75 -0
- package/dist/run-Lu7y1bNf.mjs +165 -0
- package/dist/save-CdCf630Z.mjs +79 -0
- package/dist/scan-4nboHNXP.mjs +293 -0
- package/dist/template-drift-BBhnrHY1.mjs +2740 -0
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +2 -1
- package/dist/transaction-DAhY8EpG.mjs +168 -0
- package/dist/tsconfig-CGntrzBM.mjs +1483 -0
- package/dist/{tooling-BfXlmCi-.mjs → vitest-DkGh4Ygo.mjs} +108 -167
- package/dist/workspace-tasks-CnB8kkS0.mjs +4435 -0
- package/package.json +25 -7
- package/resources/api-report/runner.cjs +76 -0
- package/resources/devcontainer/setup.mjs +36 -0
- package/resources/knip/reporter.mjs +46 -0
- package/resources/maintenance/migration-lanes.mjs +141 -0
- package/resources/maintenance/migration-lock.mjs +119 -0
- package/resources/maintenance/migrations.mjs +215 -0
- package/resources/maintenance/presets.mjs +130 -0
- package/resources/maintenance/validate.mjs +233 -0
- package/resources/maintenance/workflow.yml +151 -0
- package/resources/skills/repoctl/SKILL.md +4 -2
- package/resources/skills/repoctl/references/commands.md +224 -13
- package/resources/skills/repoctl/references/config.md +70 -6
- package/resources/skills/repoctl/references/dependencies.md +37 -0
- package/resources/skills/repoctl/references/knip.md +34 -0
- package/resources/skills/repoctl/references/templates.md +26 -2
- package/dist/commands-CIzCAxyY.mjs +0 -5672
- package/dist/config-p842Knhq.mjs +0 -114
- package/dist/index-DDQKKYet.d.mts +0 -1025
- package/dist/types-m8JLwKzl.mjs +0 -499
- package/dist/workspace-MCKewElu.mjs +0 -123
package/dist/types-m8JLwKzl.mjs
DELETED
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import path from "pathe";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import { access, cp, mkdir, mkdtemp, open, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
5
|
-
import { createConsola } from "consola";
|
|
6
|
-
import * as path$2 from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
//#region src/utils/fs.ts
|
|
9
|
-
function stringifyJson(data, options) {
|
|
10
|
-
const content = JSON.stringify(data, void 0, options?.spaces);
|
|
11
|
-
return options?.spaces ? `${content}\n` : content;
|
|
12
|
-
}
|
|
13
|
-
async function ensureParentDir(targetPath) {
|
|
14
|
-
await mkdir(path.dirname(targetPath), { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 判断文件或目录是否存在。
|
|
18
|
-
*
|
|
19
|
-
* @param targetPath 目标路径
|
|
20
|
-
* @returns 存在时返回 `true`
|
|
21
|
-
*/
|
|
22
|
-
async function pathExists(targetPath) {
|
|
23
|
-
try {
|
|
24
|
-
await access(targetPath);
|
|
25
|
-
return true;
|
|
26
|
-
} catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* `pathExists()` 的别名。
|
|
32
|
-
*/
|
|
33
|
-
const exists = pathExists;
|
|
34
|
-
/**
|
|
35
|
-
* 递归创建目录。
|
|
36
|
-
*/
|
|
37
|
-
async function ensureDir(targetPath) {
|
|
38
|
-
await mkdir(targetPath, { recursive: true });
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 确保文件存在;若父目录不存在会自动创建。
|
|
42
|
-
*/
|
|
43
|
-
async function ensureFile(targetPath) {
|
|
44
|
-
await ensureParentDir(targetPath);
|
|
45
|
-
await (await open(targetPath, "a")).close();
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* 递归删除文件或目录。
|
|
49
|
-
*
|
|
50
|
-
* 默认启用 `force: true`、`recursive: true`,并带少量重试。
|
|
51
|
-
*/
|
|
52
|
-
async function remove(targetPath) {
|
|
53
|
-
await rm(targetPath, {
|
|
54
|
-
recursive: true,
|
|
55
|
-
force: true,
|
|
56
|
-
maxRetries: 3,
|
|
57
|
-
retryDelay: 100
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* 递归复制文件或目录。
|
|
62
|
-
*/
|
|
63
|
-
async function copy(sourcePath, targetPath) {
|
|
64
|
-
await cp(sourcePath, targetPath, {
|
|
65
|
-
recursive: true,
|
|
66
|
-
force: true
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* 自动创建父目录后写入文件。
|
|
71
|
-
*/
|
|
72
|
-
async function outputFile(targetPath, data, options) {
|
|
73
|
-
await ensureParentDir(targetPath);
|
|
74
|
-
await writeFile(targetPath, data, options);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* 读取 JSON 文件并解析。
|
|
78
|
-
*/
|
|
79
|
-
async function readJson(targetPath) {
|
|
80
|
-
return JSON.parse(await readFile(targetPath, "utf8"));
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* `readJson()` 的别名。
|
|
84
|
-
*/
|
|
85
|
-
const readJSON = readJson;
|
|
86
|
-
/**
|
|
87
|
-
* 写入 JSON 文件,不会自动创建父目录。
|
|
88
|
-
*/
|
|
89
|
-
async function writeJson(targetPath, data, options) {
|
|
90
|
-
await writeFile(targetPath, stringifyJson(data, options), "utf8");
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* `writeJson()` 的别名。
|
|
94
|
-
*/
|
|
95
|
-
const writeJSON = writeJson;
|
|
96
|
-
/**
|
|
97
|
-
* 自动创建父目录后写入 JSON 文件。
|
|
98
|
-
*/
|
|
99
|
-
async function outputJson(targetPath, data, options) {
|
|
100
|
-
await ensureParentDir(targetPath);
|
|
101
|
-
await writeJson(targetPath, data, options);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* `outputJson()` 的别名。
|
|
105
|
-
*/
|
|
106
|
-
const outputJSON = outputJson;
|
|
107
|
-
/**
|
|
108
|
-
* 判断是否为可忽略的文件系统错误。
|
|
109
|
-
* - ENOENT: 文件已被删除
|
|
110
|
-
* - EBUSY: Windows 中资源被系统占用
|
|
111
|
-
*/
|
|
112
|
-
function isIgnorableFsError(error) {
|
|
113
|
-
if (!error) return false;
|
|
114
|
-
const code = error.code;
|
|
115
|
-
return code === "ENOENT" || code === "EBUSY" || code === "EEXIST";
|
|
116
|
-
}
|
|
117
|
-
const fs = {
|
|
118
|
-
copy,
|
|
119
|
-
ensureDir,
|
|
120
|
-
ensureFile,
|
|
121
|
-
exists,
|
|
122
|
-
mkdtemp,
|
|
123
|
-
outputFile,
|
|
124
|
-
outputJSON,
|
|
125
|
-
outputJson,
|
|
126
|
-
pathExists,
|
|
127
|
-
readFile,
|
|
128
|
-
readdir,
|
|
129
|
-
readJSON,
|
|
130
|
-
readJson,
|
|
131
|
-
remove,
|
|
132
|
-
stat,
|
|
133
|
-
writeFile,
|
|
134
|
-
writeJSON,
|
|
135
|
-
writeJson
|
|
136
|
-
};
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/core/logger.ts
|
|
139
|
-
/**
|
|
140
|
-
* 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
|
|
141
|
-
*/
|
|
142
|
-
const logger = createConsola();
|
|
143
|
-
//#endregion
|
|
144
|
-
//#region src/i18n/locales/en/error.ts
|
|
145
|
-
const errorMessages$1 = {
|
|
146
|
-
commanderAllowedChoices: "Allowed choices are",
|
|
147
|
-
commanderArgumentMissing: "argument missing",
|
|
148
|
-
commanderDidYouMean: "Did you mean",
|
|
149
|
-
commanderDidYouMeanOneOf: "Did you mean one of",
|
|
150
|
-
commanderErrorPrefix: "error:",
|
|
151
|
-
commanderMissingRequiredArgument: "missing required argument",
|
|
152
|
-
commanderNotSpecified: "not specified",
|
|
153
|
-
commanderRequiredOption: "required option",
|
|
154
|
-
commanderTooManyArguments: "too many arguments",
|
|
155
|
-
commanderUnknownCommand: "unknown command",
|
|
156
|
-
commanderUnknownOption: "unknown option",
|
|
157
|
-
tasksFileRequired: "A tasks file path is required when using tasks mode.",
|
|
158
|
-
unknownCreateIntent: "Unknown create intent: {intent}",
|
|
159
|
-
unknownInitTooling: "Unknown init tooling target: {targets}",
|
|
160
|
-
missingPackageJsonForTooling: "Cannot initialize tooling because package.json was not found: {path}",
|
|
161
|
-
missingDependencyVersion: "No version information was found for dependency {name}."
|
|
162
|
-
};
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/i18n/locales/en/help.ts
|
|
165
|
-
const helpMessages$1 = {
|
|
166
|
-
argumentsTitle: "Arguments:",
|
|
167
|
-
cliDescription: "Task-first repository initialization and maintenance for pnpm and Turborepo workspaces.",
|
|
168
|
-
commandsTitle: "Commands:",
|
|
169
|
-
choicesLabel: "choices:",
|
|
170
|
-
defaultLabel: "default:",
|
|
171
|
-
envLabel: "env:",
|
|
172
|
-
globalOptionsTitle: "Global Options:",
|
|
173
|
-
helpCommand: "Display help for command",
|
|
174
|
-
helpOption: "Display help for command",
|
|
175
|
-
languageOption: "Output language: en or zh-CN",
|
|
176
|
-
optionsTitle: "Options:",
|
|
177
|
-
presetLabel: "preset:",
|
|
178
|
-
quickStart: `
|
|
179
|
-
Quick start:
|
|
180
|
-
Existing repo:
|
|
181
|
-
$ {cliName} init
|
|
182
|
-
$ {cliName} doctor
|
|
183
|
-
$ {cliName} templates
|
|
184
|
-
$ {cliName} new my-package
|
|
185
|
-
$ {cliName} check
|
|
186
|
-
|
|
187
|
-
Faster in generated repos:
|
|
188
|
-
$ pnpm run repo:init
|
|
189
|
-
$ pnpm run repo:doctor
|
|
190
|
-
$ pnpm run repo:new -- my-package
|
|
191
|
-
$ pnpm run repo:check
|
|
192
|
-
|
|
193
|
-
Keep the repo current:
|
|
194
|
-
$ {cliName} upgrade
|
|
195
|
-
`,
|
|
196
|
-
usageTitle: "Usage:",
|
|
197
|
-
versionOption: "Output the version number"
|
|
198
|
-
};
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/i18n/locales/en/prompt.ts
|
|
201
|
-
const promptMessages$1 = {
|
|
202
|
-
createIntent: "What do you want to create?",
|
|
203
|
-
createName: "Enter a name",
|
|
204
|
-
libraryTemplate: "Select a library template",
|
|
205
|
-
packageName: "Enter the package name",
|
|
206
|
-
templateType: "Select a template type",
|
|
207
|
-
upgradeFiles: "Select the files you need",
|
|
208
|
-
overwriteFiles: "Select changed managed files to overwrite",
|
|
209
|
-
skillTargets: "Select skill synchronization targets"
|
|
210
|
-
};
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region src/i18n/locales/en/report.ts
|
|
213
|
-
const reportMessages$1 = {
|
|
214
|
-
wrote: "Wrote {path}",
|
|
215
|
-
dryRunOnly: "Dry run only; no files were written.",
|
|
216
|
-
nextInstallBuild: "Next: run `pnpm install` and `pnpm build`.",
|
|
217
|
-
nextInstallStart: "Next: run `pnpm install` and start the new workspace package.",
|
|
218
|
-
doctorBlocking: "Doctor found {count} blocking issue(s).",
|
|
219
|
-
doctorStrictWarnings: "Doctor found {count} warning(s) in strict mode.",
|
|
220
|
-
doctorSuggestions: "Doctor found {count} suggestion(s)."
|
|
221
|
-
};
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/i18n/locales/en/index.ts
|
|
224
|
-
const enMessages = {
|
|
225
|
-
...helpMessages$1,
|
|
226
|
-
...promptMessages$1,
|
|
227
|
-
...reportMessages$1,
|
|
228
|
-
...errorMessages$1
|
|
229
|
-
};
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/i18n/locales/zh-CN/error.ts
|
|
232
|
-
const errorMessages = {
|
|
233
|
-
commanderAllowedChoices: "可选值为",
|
|
234
|
-
commanderArgumentMissing: "缺少参数",
|
|
235
|
-
commanderDidYouMean: "你是否想输入",
|
|
236
|
-
commanderDidYouMeanOneOf: "你是否想输入以下之一",
|
|
237
|
-
commanderErrorPrefix: "错误:",
|
|
238
|
-
commanderMissingRequiredArgument: "缺少必填参数",
|
|
239
|
-
commanderNotSpecified: "未指定",
|
|
240
|
-
commanderRequiredOption: "必填选项",
|
|
241
|
-
commanderTooManyArguments: "参数过多",
|
|
242
|
-
commanderUnknownCommand: "未知命令",
|
|
243
|
-
commanderUnknownOption: "未知选项",
|
|
244
|
-
tasksFileRequired: "使用 tasks 模式时必须提供任务文件路径。",
|
|
245
|
-
unknownCreateIntent: "未找到创建意图:{intent}",
|
|
246
|
-
unknownInitTooling: "未知的 init tooling 目标:{targets}",
|
|
247
|
-
missingPackageJsonForTooling: "未找到 package.json,无法初始化 tooling:{path}",
|
|
248
|
-
missingDependencyVersion: "未找到依赖 {name} 的版本信息。"
|
|
249
|
-
};
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/i18n/locales/zh-CN/help.ts
|
|
252
|
-
const helpMessages = {
|
|
253
|
-
argumentsTitle: "参数:",
|
|
254
|
-
cliDescription: "面向 pnpm 与 Turborepo 工作区的任务型仓库初始化与维护工具。",
|
|
255
|
-
commandsTitle: "命令:",
|
|
256
|
-
choicesLabel: "可选值:",
|
|
257
|
-
defaultLabel: "默认值:",
|
|
258
|
-
envLabel: "环境变量:",
|
|
259
|
-
globalOptionsTitle: "全局选项:",
|
|
260
|
-
helpCommand: "显示指定命令的帮助",
|
|
261
|
-
helpOption: "显示命令帮助",
|
|
262
|
-
languageOption: "输出语言:en 或 zh-CN",
|
|
263
|
-
optionsTitle: "选项:",
|
|
264
|
-
presetLabel: "预设值:",
|
|
265
|
-
quickStart: `
|
|
266
|
-
快速开始:
|
|
267
|
-
已有仓库:
|
|
268
|
-
$ {cliName} init
|
|
269
|
-
$ {cliName} doctor
|
|
270
|
-
$ {cliName} templates
|
|
271
|
-
$ {cliName} new my-package
|
|
272
|
-
$ {cliName} check
|
|
273
|
-
|
|
274
|
-
生成仓库中的快捷脚本:
|
|
275
|
-
$ pnpm run repo:init
|
|
276
|
-
$ pnpm run repo:doctor
|
|
277
|
-
$ pnpm run repo:new -- my-package
|
|
278
|
-
$ pnpm run repo:check
|
|
279
|
-
|
|
280
|
-
保持仓库配置最新:
|
|
281
|
-
$ {cliName} upgrade
|
|
282
|
-
`,
|
|
283
|
-
usageTitle: "用法:",
|
|
284
|
-
versionOption: "输出版本号"
|
|
285
|
-
};
|
|
286
|
-
//#endregion
|
|
287
|
-
//#region src/i18n/locales/zh-CN/prompt.ts
|
|
288
|
-
const promptMessages = {
|
|
289
|
-
createIntent: "你要创建什么?",
|
|
290
|
-
createName: "请输入名称",
|
|
291
|
-
libraryTemplate: "请选择库模板",
|
|
292
|
-
packageName: "请输入包名",
|
|
293
|
-
templateType: "请选择模板类型",
|
|
294
|
-
upgradeFiles: "选择你需要的文件",
|
|
295
|
-
overwriteFiles: "检测到受管文件内容变化,请选择要覆盖的文件",
|
|
296
|
-
skillTargets: "请选择需要同步的技能目标"
|
|
297
|
-
};
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/i18n/locales/zh-CN/report.ts
|
|
300
|
-
const reportMessages = {
|
|
301
|
-
wrote: "已写入 {path}",
|
|
302
|
-
dryRunOnly: "仅执行预览;未写入任何文件。",
|
|
303
|
-
nextInstallBuild: "下一步:运行 `pnpm install` 和 `pnpm build`。",
|
|
304
|
-
nextInstallStart: "下一步:运行 `pnpm install`,然后启动新 workspace 包。",
|
|
305
|
-
doctorBlocking: "Doctor 发现 {count} 个阻断问题。",
|
|
306
|
-
doctorStrictWarnings: "严格模式下 doctor 发现 {count} 个警告。",
|
|
307
|
-
doctorSuggestions: "Doctor 提供了 {count} 条建议。"
|
|
308
|
-
};
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region src/i18n/locales/zh-CN/index.ts
|
|
311
|
-
const zhCNMessages = {
|
|
312
|
-
...helpMessages,
|
|
313
|
-
...promptMessages,
|
|
314
|
-
...reportMessages,
|
|
315
|
-
...errorMessages
|
|
316
|
-
};
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/i18n/index.ts
|
|
319
|
-
const supportedLocales = ["en", "zh-CN"];
|
|
320
|
-
function isRepoctlLocale(value) {
|
|
321
|
-
return supportedLocales.includes(value);
|
|
322
|
-
}
|
|
323
|
-
function readArgvLocale(argv) {
|
|
324
|
-
const equalsArg = argv.find((arg) => arg.startsWith("--lang="));
|
|
325
|
-
if (equalsArg) return equalsArg.slice(7);
|
|
326
|
-
const index = argv.indexOf("--lang");
|
|
327
|
-
return index >= 0 ? argv[index + 1] : void 0;
|
|
328
|
-
}
|
|
329
|
-
function resolveRepoctlLocale(options = {}) {
|
|
330
|
-
const argvLocale = readArgvLocale(options.argv ?? process.argv);
|
|
331
|
-
if (isRepoctlLocale(argvLocale)) return argvLocale;
|
|
332
|
-
const envLocale = options.env?.["REPOCTL_LANG"] ?? process.env["REPOCTL_LANG"];
|
|
333
|
-
return isRepoctlLocale(envLocale) ? envLocale : "en";
|
|
334
|
-
}
|
|
335
|
-
const repoctlLocale = resolveRepoctlLocale();
|
|
336
|
-
function localize(english, simplifiedChinese) {
|
|
337
|
-
return repoctlLocale === "zh-CN" ? simplifiedChinese : english;
|
|
338
|
-
}
|
|
339
|
-
function message(key, values = {}) {
|
|
340
|
-
const catalog = repoctlLocale === "zh-CN" ? zhCNMessages : enMessages;
|
|
341
|
-
return Object.entries(values).reduce((result, [name, value]) => result.replaceAll(`{${name}}`, value), catalog[key]);
|
|
342
|
-
}
|
|
343
|
-
//#endregion
|
|
344
|
-
//#region package.json
|
|
345
|
-
var name = "@icebreakers/monorepo";
|
|
346
|
-
var version = "5.5.10";
|
|
347
|
-
var package_default = {
|
|
348
|
-
name,
|
|
349
|
-
type: "module",
|
|
350
|
-
version,
|
|
351
|
-
description: "Core engine and programmatic APIs for repoctl",
|
|
352
|
-
author: "ice breaker <hi@sonofmagic.top>",
|
|
353
|
-
license: "MIT",
|
|
354
|
-
homepage: "https://repoctl.icebreaker.top",
|
|
355
|
-
repository: {
|
|
356
|
-
"type": "git",
|
|
357
|
-
"url": "git+https://github.com/icelib/repoctl.git",
|
|
358
|
-
"directory": "packages/monorepo"
|
|
359
|
-
},
|
|
360
|
-
bugs: { "url": "https://github.com/icelib/repoctl/issues" },
|
|
361
|
-
keywords: [
|
|
362
|
-
"monorepo",
|
|
363
|
-
"repoctl",
|
|
364
|
-
"tooling",
|
|
365
|
-
"icebreaker"
|
|
366
|
-
],
|
|
367
|
-
sideEffects: false,
|
|
368
|
-
exports: {
|
|
369
|
-
".": {
|
|
370
|
-
"types": "./dist/index.d.mts",
|
|
371
|
-
"default": "./dist/index.mjs"
|
|
372
|
-
},
|
|
373
|
-
"./cli": {
|
|
374
|
-
"types": "./dist/cli.d.mts",
|
|
375
|
-
"default": "./dist/cli.mjs"
|
|
376
|
-
},
|
|
377
|
-
"./tooling": {
|
|
378
|
-
"types": "./dist/tooling-entry.d.mts",
|
|
379
|
-
"default": "./dist/tooling-entry.mjs"
|
|
380
|
-
},
|
|
381
|
-
"./tsconfig": "./tsconfig.base.json",
|
|
382
|
-
"./tsconfig.json": "./tsconfig.base.json",
|
|
383
|
-
"./package.json": "./package.json"
|
|
384
|
-
},
|
|
385
|
-
main: "./dist/index.mjs",
|
|
386
|
-
module: "./dist/index.mjs",
|
|
387
|
-
types: "./dist/index.d.mts",
|
|
388
|
-
bin: {
|
|
389
|
-
"repo": "bin/repo.js",
|
|
390
|
-
"repoctl": "bin/repoctl.js"
|
|
391
|
-
},
|
|
392
|
-
files: [
|
|
393
|
-
"README.md",
|
|
394
|
-
"bin",
|
|
395
|
-
"dist",
|
|
396
|
-
"resources",
|
|
397
|
-
"tsconfig.base.json"
|
|
398
|
-
],
|
|
399
|
-
engines: { "node": ">=22.13.0" },
|
|
400
|
-
scripts: {
|
|
401
|
-
"dev": "tsdown --watch --sourcemap",
|
|
402
|
-
"build": "tsdown",
|
|
403
|
-
"test": "vitest run",
|
|
404
|
-
"test:dev": "vitest",
|
|
405
|
-
"typecheck": "pnpm --filter @icebreakers/monorepo-templates build && node ../../node_modules/typescript/bin/tsc -p tsconfig.json",
|
|
406
|
-
"tsd": "pnpm build && tsd --files test-d/**/*.test-d.ts",
|
|
407
|
-
"release": "pnpm publish",
|
|
408
|
-
"lint": "eslint .",
|
|
409
|
-
"lint:fix": "eslint . --fix"
|
|
410
|
-
},
|
|
411
|
-
peerDependencies: {
|
|
412
|
-
"@commitlint/cli": "catalog:",
|
|
413
|
-
"eslint": "^9.0.0 || ^10.0.0",
|
|
414
|
-
"stylelint": "catalog:",
|
|
415
|
-
"typescript": "^5.0.0 || ^6.0.0"
|
|
416
|
-
},
|
|
417
|
-
peerDependenciesMeta: {
|
|
418
|
-
"@commitlint/cli": { "optional": true },
|
|
419
|
-
"eslint": { "optional": true },
|
|
420
|
-
"stylelint": { "optional": true },
|
|
421
|
-
"typescript": { "optional": true }
|
|
422
|
-
},
|
|
423
|
-
dependencies: {
|
|
424
|
-
"@icebreakers/commitlint-config": "workspace:*",
|
|
425
|
-
"@icebreakers/eslint-config": "workspace:*",
|
|
426
|
-
"@icebreakers/monorepo-templates": "workspace:*",
|
|
427
|
-
"@icebreakers/stylelint-config": "workspace:*",
|
|
428
|
-
"@pnpm/find-workspace-dir": "^1000.1.5",
|
|
429
|
-
"@pnpm/logger": "^1100.0.0",
|
|
430
|
-
"@pnpm/types": "^1102.1.1",
|
|
431
|
-
"@pnpm/worker": "^1100.4.5",
|
|
432
|
-
"@pnpm/workspace.find-packages": "^1000.0.65",
|
|
433
|
-
"@pnpm/workspace.read-manifest": "^1000.3.1",
|
|
434
|
-
"c12": "^3.3.4",
|
|
435
|
-
"commander": "catalog:",
|
|
436
|
-
"comment-json": "catalog:",
|
|
437
|
-
"consola": "^3.4.2",
|
|
438
|
-
"git-url-parse": "^16.1.0",
|
|
439
|
-
"klaw": "^4.1.0",
|
|
440
|
-
"lint-staged": "^17.6.0",
|
|
441
|
-
"p-queue": "^9.3.3",
|
|
442
|
-
"pathe": "^2.0.3",
|
|
443
|
-
"picocolors": "^1.1.1",
|
|
444
|
-
"semver": "catalog:",
|
|
445
|
-
"simple-git": "^3.36.0",
|
|
446
|
-
"vitest": "catalog:",
|
|
447
|
-
"yaml": "catalog:"
|
|
448
|
-
},
|
|
449
|
-
devDependencies: {
|
|
450
|
-
"@types/klaw": "^3.0.8",
|
|
451
|
-
"@types/micromatch": "^4.0.10",
|
|
452
|
-
"@types/semver": "catalog:",
|
|
453
|
-
"ci-info": "^4.4.0",
|
|
454
|
-
"fdir": "^6.5.0",
|
|
455
|
-
"micromatch": "^4.0.8"
|
|
456
|
-
},
|
|
457
|
-
publishConfig: {
|
|
458
|
-
"access": "public",
|
|
459
|
-
"registry": "https://registry.npmjs.org"
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/constants.ts
|
|
464
|
-
const require = createRequire(import.meta.url);
|
|
465
|
-
/**
|
|
466
|
-
* 用户默认看到的 CLI 名称,帮助文案和生成脚本都统一引导到 repo。
|
|
467
|
-
*/
|
|
468
|
-
const cliName = "repo";
|
|
469
|
-
/**
|
|
470
|
-
* 还原出 package.json 所在的绝对路径,方便后续按目录组织资源文件。
|
|
471
|
-
*/
|
|
472
|
-
const packageJsonPath = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
473
|
-
/**
|
|
474
|
-
* @icebreakers/monorepo 包的根目录。
|
|
475
|
-
*/
|
|
476
|
-
const packageDir = path$2.dirname(packageJsonPath);
|
|
477
|
-
/**
|
|
478
|
-
* CLI 提供的模板/资产目录来源于 @icebreakers/monorepo-templates。
|
|
479
|
-
* 这里只解析 package.json 路径,避免 CLI 启动时加载模板包入口。
|
|
480
|
-
*/
|
|
481
|
-
const templatesPackageDir = path$2.dirname(require.resolve("@icebreakers/monorepo-templates/package.json"));
|
|
482
|
-
const assetsDir = path$2.join(templatesPackageDir, "assets");
|
|
483
|
-
const templatesDir = path$2.join(templatesPackageDir, "templates");
|
|
484
|
-
/**
|
|
485
|
-
* monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
|
|
486
|
-
*/
|
|
487
|
-
const rootDir = path$2.resolve(packageDir, "..", "..");
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/commands/init/tooling/types.ts
|
|
490
|
-
const initToolingTargets = [
|
|
491
|
-
"commitlint",
|
|
492
|
-
"eslint",
|
|
493
|
-
"stylelint",
|
|
494
|
-
"lint-staged",
|
|
495
|
-
"tsconfig",
|
|
496
|
-
"vitest"
|
|
497
|
-
];
|
|
498
|
-
//#endregion
|
|
499
|
-
export { outputJson as C, remove as D, readJson as E, writeJSON as O, outputJSON as S, readJSON as T, ensureFile as _, rootDir as a, isIgnorableFsError as b, package_default as c, message as d, resolveRepoctlLocale as f, ensureDir as g, copy as h, packageDir as i, writeJson as k, version as l, logger as m, assetsDir as n, templatesDir as o, supportedLocales as p, cliName as r, name as s, initToolingTargets as t, localize as u, exists as v, pathExists as w, outputFile as x, fs as y };
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
|
|
3
|
-
import { findWorkspacePackages } from "@pnpm/workspace.find-packages";
|
|
4
|
-
import { readWorkspaceManifest } from "@pnpm/workspace.read-manifest";
|
|
5
|
-
import path from "pathe";
|
|
6
|
-
//#region src/core/workspace.ts
|
|
7
|
-
var workspace_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
clearWorkspaceCache: () => clearWorkspaceCache,
|
|
9
|
-
getWorkspaceData: () => getWorkspaceData,
|
|
10
|
-
getWorkspacePackageSummaries: () => getWorkspacePackageSummaries,
|
|
11
|
-
getWorkspacePackages: () => getWorkspacePackages
|
|
12
|
-
});
|
|
13
|
-
const workspaceDirCache = /* @__PURE__ */ new Map();
|
|
14
|
-
const workspaceManifestCache = /* @__PURE__ */ new Map();
|
|
15
|
-
const workspacePackagesCache = /* @__PURE__ */ new Map();
|
|
16
|
-
function normalizeDir(dir) {
|
|
17
|
-
return path.resolve(dir);
|
|
18
|
-
}
|
|
19
|
-
function getPatternsCacheKey(patterns) {
|
|
20
|
-
return patterns === void 0 ? "<manifest>" : JSON.stringify(patterns);
|
|
21
|
-
}
|
|
22
|
-
function comparePackagePath(left, right) {
|
|
23
|
-
return left.relativeDir.localeCompare(right.relativeDir);
|
|
24
|
-
}
|
|
25
|
-
function getPackageRootDir(project) {
|
|
26
|
-
return normalizeDir(project.rootDirRealPath || project.rootDir);
|
|
27
|
-
}
|
|
28
|
-
async function findWorkspaceDirCached(cwd) {
|
|
29
|
-
const key = normalizeDir(cwd);
|
|
30
|
-
if (!workspaceDirCache.has(key)) workspaceDirCache.set(key, findWorkspaceDir(key));
|
|
31
|
-
return workspaceDirCache.get(key);
|
|
32
|
-
}
|
|
33
|
-
async function readWorkspaceManifestCached(workspaceDir) {
|
|
34
|
-
const key = normalizeDir(workspaceDir);
|
|
35
|
-
if (!workspaceManifestCache.has(key)) workspaceManifestCache.set(key, readWorkspaceManifest(key));
|
|
36
|
-
return workspaceManifestCache.get(key);
|
|
37
|
-
}
|
|
38
|
-
async function findWorkspacePackagesCached(workspaceDir, patterns) {
|
|
39
|
-
const normalizedWorkspaceDir = normalizeDir(workspaceDir);
|
|
40
|
-
const key = `${normalizedWorkspaceDir}:${getPatternsCacheKey(patterns)}`;
|
|
41
|
-
if (!workspacePackagesCache.has(key)) workspacePackagesCache.set(key, findWorkspacePackages(normalizedWorkspaceDir, patterns ? { patterns } : {}));
|
|
42
|
-
return workspacePackagesCache.get(key);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 清空当前进程内的 workspace 发现缓存。
|
|
46
|
-
*
|
|
47
|
-
* 普通 CLI 命令执行后进程会退出;长期运行的集成测试或程序化调用在修改
|
|
48
|
-
* `pnpm-workspace.yaml` / package 目录后,可以调用它让后续扫描重新读磁盘。
|
|
49
|
-
*/
|
|
50
|
-
function clearWorkspaceCache() {
|
|
51
|
-
workspaceDirCache.clear();
|
|
52
|
-
workspaceManifestCache.clear();
|
|
53
|
-
workspacePackagesCache.clear();
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 读取 pnpm workspace 下的所有包,并根据选项做过滤。
|
|
57
|
-
*
|
|
58
|
-
* 默认值:
|
|
59
|
-
* - `ignoreRootPackage`: `true`
|
|
60
|
-
* - `ignorePrivatePackage`: `true`
|
|
61
|
-
*
|
|
62
|
-
* @param workspaceDir workspace 根目录
|
|
63
|
-
* @param options 过滤选项
|
|
64
|
-
* @returns 带有 `pkgJsonPath` 字段的 workspace package 列表
|
|
65
|
-
*/
|
|
66
|
-
async function getWorkspacePackages(workspaceDir, options) {
|
|
67
|
-
const normalizedWorkspaceDir = normalizeDir(workspaceDir);
|
|
68
|
-
const ignoreRootPackage = options?.ignoreRootPackage ?? true;
|
|
69
|
-
const ignorePrivatePackage = options?.ignorePrivatePackage ?? true;
|
|
70
|
-
const manifest = options?.patterns === void 0 ? await readWorkspaceManifestCached(normalizedWorkspaceDir) : void 0;
|
|
71
|
-
let pkgs = (await findWorkspacePackagesCached(normalizedWorkspaceDir, options?.patterns ?? manifest?.packages)).filter((x) => {
|
|
72
|
-
if (ignorePrivatePackage && x.manifest.private) return false;
|
|
73
|
-
return true;
|
|
74
|
-
}).map((project) => {
|
|
75
|
-
const rootDir = getPackageRootDir(project);
|
|
76
|
-
const pkgJsonPath = path.resolve(rootDir, "package.json");
|
|
77
|
-
return {
|
|
78
|
-
...project,
|
|
79
|
-
rootDir,
|
|
80
|
-
pkgJsonPath
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
if (ignoreRootPackage) pkgs = pkgs.filter((x) => {
|
|
84
|
-
return x.rootDir !== normalizedWorkspaceDir;
|
|
85
|
-
});
|
|
86
|
-
return pkgs;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* 一次性返回 `cwd`、真实 `workspaceDir` 与过滤后的包列表。
|
|
90
|
-
*
|
|
91
|
-
* @param cwd 当前工作目录
|
|
92
|
-
* @param options 传给 `getWorkspacePackages()` 的过滤选项
|
|
93
|
-
*/
|
|
94
|
-
async function getWorkspaceData(cwd, options) {
|
|
95
|
-
const normalizedCwd = normalizeDir(cwd);
|
|
96
|
-
const workspaceDir = await findWorkspaceDirCached(normalizedCwd) ?? normalizedCwd;
|
|
97
|
-
return {
|
|
98
|
-
cwd: normalizedCwd,
|
|
99
|
-
workspaceDir,
|
|
100
|
-
packages: await getWorkspacePackages(workspaceDir, options)
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 返回适合展示和程序化消费的 workspace package 摘要。
|
|
105
|
-
*/
|
|
106
|
-
async function getWorkspacePackageSummaries(cwd, options) {
|
|
107
|
-
const { packages, workspaceDir } = await getWorkspaceData(cwd, options);
|
|
108
|
-
const summaries = packages.map((pkg) => ({
|
|
109
|
-
...pkg.manifest.name ? { name: pkg.manifest.name } : {},
|
|
110
|
-
...pkg.manifest.description ? { description: pkg.manifest.description } : {},
|
|
111
|
-
private: pkg.manifest.private === true,
|
|
112
|
-
rootDir: pkg.rootDir,
|
|
113
|
-
relativeDir: path.relative(workspaceDir, pkg.rootDir) || ".",
|
|
114
|
-
pkgJsonPath: pkg.pkgJsonPath
|
|
115
|
-
})).sort(comparePackagePath);
|
|
116
|
-
return {
|
|
117
|
-
cwd: normalizeDir(cwd),
|
|
118
|
-
workspaceDir,
|
|
119
|
-
packages: summaries
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
export { workspace_exports as a, getWorkspacePackages as i, getWorkspaceData as n, getWorkspacePackageSummaries as r, clearWorkspaceCache as t };
|