@icebreakers/monorepo 5.1.1 → 5.3.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.
@@ -0,0 +1,416 @@
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.3.0";
347
+ var dependencies = {
348
+ "@icebreakers/commitlint-config": "^4.0.4",
349
+ "@icebreakers/eslint-config": "^7.0.4",
350
+ "@icebreakers/monorepo-templates": "workspace:*",
351
+ "@icebreakers/stylelint-config": "^5.0.5",
352
+ "@pnpm/find-workspace-dir": "^1000.1.5",
353
+ "@pnpm/logger": "^1100.0.0",
354
+ "@pnpm/types": "^1101.9.0",
355
+ "@pnpm/worker": "^1100.2.11",
356
+ "@pnpm/workspace.find-packages": "^1000.0.65",
357
+ "@pnpm/workspace.read-manifest": "^1000.3.1",
358
+ "c12": "^3.3.4",
359
+ "commander": "^15.0.0",
360
+ "comment-json": "^5.0.0",
361
+ "consola": "^3.4.2",
362
+ "git-url-parse": "^16.1.0",
363
+ "klaw": "^4.1.0",
364
+ "lint-staged": "^17.3.0",
365
+ "p-queue": "^9.3.3",
366
+ "pathe": "^2.0.3",
367
+ "picocolors": "^1.1.1",
368
+ "semver": "^7.8.5",
369
+ "simple-git": "^3.36.0",
370
+ "vitest": "^4.1.10",
371
+ "yaml": "^2.9.0"
372
+ };
373
+ var devDependencies = {
374
+ "@types/klaw": "^3.0.7",
375
+ "@types/micromatch": "^4.0.10",
376
+ "fdir": "^6.5.0",
377
+ "micromatch": "^4.0.8"
378
+ };
379
+ //#endregion
380
+ //#region src/constants.ts
381
+ const require = createRequire(import.meta.url);
382
+ /**
383
+ * 用户默认看到的 CLI 名称,帮助文案和生成脚本都统一引导到 repo。
384
+ */
385
+ const cliName = "repo";
386
+ /**
387
+ * 还原出 package.json 所在的绝对路径,方便后续按目录组织资源文件。
388
+ */
389
+ const packageJsonPath = fileURLToPath(new URL("../package.json", import.meta.url));
390
+ /**
391
+ * @icebreakers/monorepo 包的根目录。
392
+ */
393
+ const packageDir = path$2.dirname(packageJsonPath);
394
+ /**
395
+ * CLI 提供的模板/资产目录来源于 @icebreakers/monorepo-templates。
396
+ * 这里只解析 package.json 路径,避免 CLI 启动时加载模板包入口。
397
+ */
398
+ const templatesPackageDir = path$2.dirname(require.resolve("@icebreakers/monorepo-templates/package.json"));
399
+ const assetsDir = path$2.join(templatesPackageDir, "assets");
400
+ const templatesDir = path$2.join(templatesPackageDir, "templates");
401
+ /**
402
+ * monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
403
+ */
404
+ const rootDir = path$2.resolve(packageDir, "..", "..");
405
+ //#endregion
406
+ //#region src/commands/init/tooling/types.ts
407
+ const initToolingTargets = [
408
+ "commitlint",
409
+ "eslint",
410
+ "stylelint",
411
+ "lint-staged",
412
+ "tsconfig",
413
+ "vitest"
414
+ ];
415
+ //#endregion
416
+ export { writeJson as A, outputJSON as C, readJson as D, readJSON as E, remove as O, outputFile as S, pathExists as T, ensureDir as _, rootDir as a, fs as b, devDependencies as c, localize as d, message as f, copy as g, logger as h, packageDir as i, writeJSON as k, name as l, supportedLocales as m, assetsDir as n, templatesDir as o, resolveRepoctlLocale as p, cliName as r, dependencies as s, initToolingTargets as t, version as u, ensureFile as v, outputJson as w, isIgnorableFsError as x, exists as y };
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "5.1.1",
5
- "description": "Core engine behind the repoctl monorepo CLI",
4
+ "version": "5.3.0",
5
+ "description": "Core engine and programmatic APIs for repoctl",
6
6
  "author": "ice breaker <hi@sonofmagic.top>",
7
7
  "license": "MIT",
8
8
  "homepage": "https://repo.icebreaker.top",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/sonofmagic/monorepo-template.git",
11
+ "url": "git+https://github.com/sonofmagic/repoctl.git",
12
12
  "directory": "packages/monorepo"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/sonofmagic/monorepo-template/issues"
15
+ "url": "https://github.com/sonofmagic/repoctl/issues"
16
16
  },
17
17
  "keywords": [
18
18
  "monorepo",
@@ -79,13 +79,13 @@
79
79
  }
80
80
  },
81
81
  "dependencies": {
82
- "@icebreakers/commitlint-config": "^4.0.3",
83
- "@icebreakers/eslint-config": "^7.0.3",
84
- "@icebreakers/stylelint-config": "^5.0.4",
82
+ "@icebreakers/commitlint-config": "^4.0.4",
83
+ "@icebreakers/eslint-config": "^7.0.4",
84
+ "@icebreakers/stylelint-config": "^5.0.5",
85
85
  "@pnpm/find-workspace-dir": "^1000.1.5",
86
86
  "@pnpm/logger": "^1100.0.0",
87
87
  "@pnpm/types": "^1101.9.0",
88
- "@pnpm/worker": "^1100.2.10",
88
+ "@pnpm/worker": "^1100.2.11",
89
89
  "@pnpm/workspace.find-packages": "^1000.0.65",
90
90
  "@pnpm/workspace.read-manifest": "^1000.3.1",
91
91
  "c12": "^3.3.4",
@@ -102,7 +102,7 @@
102
102
  "simple-git": "^3.36.0",
103
103
  "vitest": "^4.1.10",
104
104
  "yaml": "^2.9.0",
105
- "@icebreakers/monorepo-templates": "1.1.0"
105
+ "@icebreakers/monorepo-templates": "1.2.1"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@types/klaw": "^3.0.7",
@@ -1,215 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import path from "pathe";
3
- import { access, cp, mkdir, mkdtemp, open, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
4
- import { createConsola } from "consola";
5
- import * as path$2 from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- //#region src/utils/fs.ts
8
- function stringifyJson(data, options) {
9
- const content = JSON.stringify(data, void 0, options?.spaces);
10
- return options?.spaces ? `${content}\n` : content;
11
- }
12
- async function ensureParentDir(targetPath) {
13
- await mkdir(path.dirname(targetPath), { recursive: true });
14
- }
15
- /**
16
- * 判断文件或目录是否存在。
17
- *
18
- * @param targetPath 目标路径
19
- * @returns 存在时返回 `true`
20
- */
21
- async function pathExists(targetPath) {
22
- try {
23
- await access(targetPath);
24
- return true;
25
- } catch {
26
- return false;
27
- }
28
- }
29
- /**
30
- * `pathExists()` 的别名。
31
- */
32
- const exists = pathExists;
33
- /**
34
- * 递归创建目录。
35
- */
36
- async function ensureDir(targetPath) {
37
- await mkdir(targetPath, { recursive: true });
38
- }
39
- /**
40
- * 确保文件存在;若父目录不存在会自动创建。
41
- */
42
- async function ensureFile(targetPath) {
43
- await ensureParentDir(targetPath);
44
- await (await open(targetPath, "a")).close();
45
- }
46
- /**
47
- * 递归删除文件或目录。
48
- *
49
- * 默认启用 `force: true`、`recursive: true`,并带少量重试。
50
- */
51
- async function remove(targetPath) {
52
- await rm(targetPath, {
53
- recursive: true,
54
- force: true,
55
- maxRetries: 3,
56
- retryDelay: 100
57
- });
58
- }
59
- /**
60
- * 递归复制文件或目录。
61
- */
62
- async function copy(sourcePath, targetPath) {
63
- await cp(sourcePath, targetPath, {
64
- recursive: true,
65
- force: true
66
- });
67
- }
68
- /**
69
- * 自动创建父目录后写入文件。
70
- */
71
- async function outputFile(targetPath, data, options) {
72
- await ensureParentDir(targetPath);
73
- await writeFile(targetPath, data, options);
74
- }
75
- /**
76
- * 读取 JSON 文件并解析。
77
- */
78
- async function readJson(targetPath) {
79
- return JSON.parse(await readFile(targetPath, "utf8"));
80
- }
81
- /**
82
- * `readJson()` 的别名。
83
- */
84
- const readJSON = readJson;
85
- /**
86
- * 写入 JSON 文件,不会自动创建父目录。
87
- */
88
- async function writeJson(targetPath, data, options) {
89
- await writeFile(targetPath, stringifyJson(data, options), "utf8");
90
- }
91
- /**
92
- * `writeJson()` 的别名。
93
- */
94
- const writeJSON = writeJson;
95
- /**
96
- * 自动创建父目录后写入 JSON 文件。
97
- */
98
- async function outputJson(targetPath, data, options) {
99
- await ensureParentDir(targetPath);
100
- await writeJson(targetPath, data, options);
101
- }
102
- /**
103
- * `outputJson()` 的别名。
104
- */
105
- const outputJSON = outputJson;
106
- /**
107
- * 判断是否为可忽略的文件系统错误。
108
- * - ENOENT: 文件已被删除
109
- * - EBUSY: Windows 中资源被系统占用
110
- */
111
- function isIgnorableFsError(error) {
112
- if (!error) return false;
113
- const code = error.code;
114
- return code === "ENOENT" || code === "EBUSY" || code === "EEXIST";
115
- }
116
- const fs = {
117
- copy,
118
- ensureDir,
119
- ensureFile,
120
- exists,
121
- mkdtemp,
122
- outputFile,
123
- outputJSON,
124
- outputJson,
125
- pathExists,
126
- readFile,
127
- readdir,
128
- readJSON,
129
- readJson,
130
- remove,
131
- stat,
132
- writeFile,
133
- writeJSON,
134
- writeJson
135
- };
136
- //#endregion
137
- //#region src/core/logger.ts
138
- /**
139
- * 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
140
- */
141
- const logger = createConsola();
142
- //#endregion
143
- //#region package.json
144
- var name = "@icebreakers/monorepo";
145
- var version = "5.1.1";
146
- var dependencies = {
147
- "@icebreakers/commitlint-config": "^4.0.3",
148
- "@icebreakers/eslint-config": "^7.0.3",
149
- "@icebreakers/monorepo-templates": "workspace:*",
150
- "@icebreakers/stylelint-config": "^5.0.4",
151
- "@pnpm/find-workspace-dir": "^1000.1.5",
152
- "@pnpm/logger": "^1100.0.0",
153
- "@pnpm/types": "^1101.9.0",
154
- "@pnpm/worker": "^1100.2.10",
155
- "@pnpm/workspace.find-packages": "^1000.0.65",
156
- "@pnpm/workspace.read-manifest": "^1000.3.1",
157
- "c12": "^3.3.4",
158
- "commander": "^15.0.0",
159
- "comment-json": "^5.0.0",
160
- "consola": "^3.4.2",
161
- "git-url-parse": "^16.1.0",
162
- "klaw": "^4.1.0",
163
- "lint-staged": "^17.3.0",
164
- "p-queue": "^9.3.3",
165
- "pathe": "^2.0.3",
166
- "picocolors": "^1.1.1",
167
- "semver": "^7.8.5",
168
- "simple-git": "^3.36.0",
169
- "vitest": "^4.1.10",
170
- "yaml": "^2.9.0"
171
- };
172
- var devDependencies = {
173
- "@types/klaw": "^3.0.7",
174
- "@types/micromatch": "^4.0.10",
175
- "fdir": "^6.5.0",
176
- "micromatch": "^4.0.8"
177
- };
178
- //#endregion
179
- //#region src/constants.ts
180
- const require = createRequire(import.meta.url);
181
- /**
182
- * 用户默认看到的 CLI 名称,帮助文案和生成脚本都统一引导到 repo。
183
- */
184
- const cliName = "repo";
185
- /**
186
- * 还原出 package.json 所在的绝对路径,方便后续按目录组织资源文件。
187
- */
188
- const packageJsonPath = fileURLToPath(new URL("../package.json", import.meta.url));
189
- /**
190
- * @icebreakers/monorepo 包的根目录。
191
- */
192
- const packageDir = path$2.dirname(packageJsonPath);
193
- /**
194
- * CLI 提供的模板/资产目录来源于 @icebreakers/monorepo-templates。
195
- * 这里只解析 package.json 路径,避免 CLI 启动时加载模板包入口。
196
- */
197
- const templatesPackageDir = path$2.dirname(require.resolve("@icebreakers/monorepo-templates/package.json"));
198
- const assetsDir = path$2.join(templatesPackageDir, "assets");
199
- const templatesDir = path$2.join(templatesPackageDir, "templates");
200
- /**
201
- * monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
202
- */
203
- const rootDir = path$2.resolve(packageDir, "..", "..");
204
- //#endregion
205
- //#region src/commands/init/tooling/types.ts
206
- const initToolingTargets = [
207
- "commitlint",
208
- "eslint",
209
- "stylelint",
210
- "lint-staged",
211
- "tsconfig",
212
- "vitest"
213
- ];
214
- //#endregion
215
- export { readJson as C, writeJson as E, readJSON as S, writeJSON as T, isIgnorableFsError as _, rootDir as a, outputJson as b, devDependencies as c, logger as d, copy as f, fs as g, exists as h, packageDir as i, name as l, ensureFile as m, assetsDir as n, templatesDir as o, ensureDir as p, cliName as r, dependencies as s, initToolingTargets as t, version as u, outputFile as v, remove as w, pathExists as x, outputJSON as y };