@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
package/dist/index.d.mts
CHANGED
|
@@ -1,703 +1,283 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { $ as LintStagedToolingConfig, A as ConfigValues, B as PackageJson, C as defineEslintConfig, Ct as createTimestampFolderName, D as defineVitestConfig, Dt as loadAgenticTasks, E as defineTsconfigConfig, Et as generateAgenticTemplates, F as WorkspacePackage, G as AiCommandConfig, H as PackageJsonExports, I as WorkspacePackageManifest, J as CreateChoiceOption, K as CleanCommandConfig, L as WorkspacePackageSummary, M as SimpleGitOptions, N as GetWorkspacePackagesOptions, O as defineVitestProjectConfig, Ot as CliOpts, P as WorkspaceData, Q as InitCommandConfig, R as WorkspacePackageSummaryData, S as defineCommitlintConfig, St as GenerateAgenticTemplateOptions, T as defineStylelintConfig, Tt as generateAgenticTemplate, U as PackageJsonPerson, V as PackageJsonBugs, W as PackageJsonRepository, X as EslintToolingConfig, Y as CreateCommandConfig, Z as HuskyToolingConfig, _ as createMonorepoLintStagedConfig, _t as getTemplateMap, a as MonorepoEslintConfig, at as UpgradeCommandConfig, b as createMonorepoVitestConfig, bt as AgenticTemplateFormat, c as MonorepoStylelintConfig, ct as init, d as MonorepoVitestConfigOverrides, dt as normalizeInitToolingTargets, et as MirrorCommandConfig, f as MonorepoVitestConfigResult, ft as initToolingTargets, g as createMonorepoEslintConfig, gt as getCreateChoices, h as createMonorepoCommitlintConfig, ht as CreateNewProjectPlan, i as MonorepoCommitlintConfig, it as TsconfigToolingConfig, j as SimpleGit, k as loadMonorepoToolingConfig, l as MonorepoTsconfig, lt as initMetadata, m as MonorepoVitestProjectConfigResult, mt as CreateNewProjectOptions, n as DefineVitestConfigOptions, nt as StylelintToolingConfig, o as MonorepoLintStagedConfig, ot as VitestProjectToolingConfig, p as MonorepoVitestProjectConfigOptions, pt as createNewProject, q as CommitlintToolingConfig, r as DefineVitestProjectConfigOptions, rt as ToolingConfig, s as MonorepoLintStagedConfigOptions, st as VitestToolingConfig, t as DefineConfigOptions, tt as MonorepoConfig, u as MonorepoVitestConfigOptions, ut as initTooling, v as createMonorepoStylelintConfig, vt as resolveCreateNewProjectPlan, w as defineLintStagedConfig, wt as defaultAgenticBaseDir, x as createMonorepoVitestProjectConfig, xt as AgenticTemplateTask, y as createMonorepoTsconfig, yt as templateMap, z as WorkspacePackageWithJsonPath } from "./index-BBxViYZd.mjs";
|
|
2
2
|
import gitUrlParse from "git-url-parse";
|
|
3
|
-
import * as simple_git0 from "simple-git";
|
|
4
|
-
import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
|
|
3
|
+
import * as _$simple_git0 from "simple-git";
|
|
5
4
|
import { mkdtemp, readFile, stat, writeFile } from "node:fs/promises";
|
|
6
|
-
import * as consola from "consola";
|
|
7
|
-
import {
|
|
5
|
+
import * as _$consola from "consola";
|
|
6
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
7
|
+
import { isGitignoreFile, toPublishGitignorePath, toWorkspaceGitignorePath } from "@icebreakers/monorepo-templates";
|
|
8
8
|
import crypto from "node:crypto";
|
|
9
|
-
import
|
|
9
|
+
import { Buffer } from "node:buffer";
|
|
10
10
|
|
|
11
|
-
//#region src/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* 是否开启交互模式,开启后每一步都会提示用户确认。
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
interactive?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* 是否使用 core 版资产,只同步最精简的文件集合。
|
|
23
|
-
* @default false
|
|
24
|
-
*/
|
|
25
|
-
core?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
|
|
28
|
-
* @default ''
|
|
29
|
-
*/
|
|
30
|
-
outDir?: string;
|
|
31
|
-
/**
|
|
32
|
-
* 命令执行的工作目录。
|
|
33
|
-
* @default process.cwd()
|
|
34
|
-
*/
|
|
35
|
-
cwd?: string;
|
|
36
|
-
/**
|
|
37
|
-
* 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
skipOverwrite?: boolean;
|
|
11
|
+
//#region src/commands/check.d.ts
|
|
12
|
+
interface RecommendedCheckOptions {
|
|
13
|
+
cwd: string;
|
|
14
|
+
full?: boolean;
|
|
15
|
+
staged?: boolean;
|
|
16
|
+
editFile?: string;
|
|
41
17
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
output?: string;
|
|
48
|
-
force?: boolean;
|
|
49
|
-
format?: AgenticTemplateFormat;
|
|
50
|
-
/**
|
|
51
|
-
* 任务名,用于快速生成带目录与后缀的文件。
|
|
52
|
-
*/
|
|
53
|
-
name?: string;
|
|
54
|
-
/**
|
|
55
|
-
* 基础目录,配合 name 使用。
|
|
56
|
-
* @default 'agentic/prompts'
|
|
57
|
-
*/
|
|
58
|
-
baseDir?: string;
|
|
59
|
-
/**
|
|
60
|
-
* 自动生成目录时使用的自定义文件夹名称。
|
|
61
|
-
* @default 自动生成的时间戳
|
|
62
|
-
*/
|
|
63
|
-
folderName?: string;
|
|
18
|
+
type RecommendedCheckMode = 'commit-msg' | 'full' | 'staged' | 'default';
|
|
19
|
+
interface RecommendedCheckPlanCommand {
|
|
20
|
+
name: string;
|
|
21
|
+
command: string;
|
|
22
|
+
description: string;
|
|
64
23
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*/
|
|
73
|
-
declare function generateAgenticTemplate(options?: GenerateAgenticTemplateOptions): Promise<string>;
|
|
74
|
-
declare function loadAgenticTasks(filePath: string, cwd: string): Promise<AgenticTemplateTask[]>;
|
|
75
|
-
declare function generateAgenticTemplates(tasks: AgenticTemplateTask[], defaults?: GenerateAgenticTemplateOptions): Promise<string[]>;
|
|
24
|
+
interface RecommendedCheckPlan {
|
|
25
|
+
cwd: string;
|
|
26
|
+
mode: RecommendedCheckMode;
|
|
27
|
+
commands: RecommendedCheckPlanCommand[];
|
|
28
|
+
}
|
|
29
|
+
declare function resolveRecommendedCheckPlan(options: RecommendedCheckOptions): RecommendedCheckPlan;
|
|
30
|
+
declare function runRecommendedCheck(options: RecommendedCheckOptions): Promise<void>;
|
|
76
31
|
//#endregion
|
|
77
|
-
//#region src/commands/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
readonly tsup: {
|
|
83
|
-
readonly source: "tsup";
|
|
84
|
-
readonly target: "packages/tsup";
|
|
85
|
-
};
|
|
86
|
-
readonly tsdown: {
|
|
87
|
-
readonly source: "tsdown";
|
|
88
|
-
readonly target: "packages/tsdown";
|
|
89
|
-
};
|
|
90
|
-
readonly unbuild: {
|
|
91
|
-
readonly source: "unbuild";
|
|
92
|
-
readonly target: "packages/unbuild";
|
|
93
|
-
};
|
|
94
|
-
readonly 'vue-lib': {
|
|
95
|
-
readonly source: "vue-lib";
|
|
96
|
-
readonly target: "packages/vue-lib";
|
|
97
|
-
};
|
|
98
|
-
readonly 'hono-server': {
|
|
99
|
-
readonly source: "server";
|
|
100
|
-
readonly target: "apps/server";
|
|
101
|
-
};
|
|
102
|
-
readonly 'vue-hono': {
|
|
103
|
-
readonly source: "client";
|
|
104
|
-
readonly target: "apps/client";
|
|
105
|
-
};
|
|
106
|
-
readonly vitepress: {
|
|
107
|
-
readonly source: "vitepress";
|
|
108
|
-
readonly target: "apps/website";
|
|
109
|
-
};
|
|
110
|
-
readonly cli: {
|
|
111
|
-
readonly source: "cli";
|
|
112
|
-
readonly target: "apps/cli";
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
type CreateNewProjectType = keyof typeof templateMap;
|
|
116
|
-
interface CreateNewProjectOptions {
|
|
117
|
-
name?: string;
|
|
118
|
-
cwd?: string;
|
|
119
|
-
renameJson?: boolean;
|
|
120
|
-
type?: CreateNewProjectType | string;
|
|
32
|
+
//#region src/commands/config.d.ts
|
|
33
|
+
interface ConfigInspection {
|
|
34
|
+
cwd: string;
|
|
35
|
+
file: string | null;
|
|
36
|
+
config: MonorepoConfig;
|
|
121
37
|
}
|
|
122
|
-
|
|
123
|
-
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
124
|
-
*/
|
|
125
|
-
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
126
|
-
readonly name: "unbuild 打包";
|
|
127
|
-
readonly value: "unbuild";
|
|
128
|
-
} | {
|
|
129
|
-
readonly name: "tsup 打包";
|
|
130
|
-
readonly value: "tsup";
|
|
131
|
-
} | {
|
|
132
|
-
readonly name: "tsdown 打包";
|
|
133
|
-
readonly value: "tsdown";
|
|
134
|
-
} | {
|
|
135
|
-
readonly name: "vue 组件";
|
|
136
|
-
readonly value: "vue-lib";
|
|
137
|
-
} | {
|
|
138
|
-
readonly name: "vue hono 全栈";
|
|
139
|
-
readonly value: "vue-hono";
|
|
140
|
-
} | {
|
|
141
|
-
readonly name: "hono 模板";
|
|
142
|
-
readonly value: "hono-server";
|
|
143
|
-
} | {
|
|
144
|
-
readonly name: "vitepress 文档";
|
|
145
|
-
readonly value: "vitepress";
|
|
146
|
-
} | {
|
|
147
|
-
readonly name: "cli 模板";
|
|
148
|
-
readonly value: "cli";
|
|
149
|
-
})[];
|
|
150
|
-
/**
|
|
151
|
-
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
152
|
-
*/
|
|
153
|
-
declare function getTemplateMap(extra?: Record<string, string | TemplateDefinition>): Record<string, TemplateDefinition>;
|
|
154
|
-
/**
|
|
155
|
-
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
156
|
-
*/
|
|
157
|
-
declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
|
|
38
|
+
declare function inspectMonorepoConfig(cwd: string): Promise<ConfigInspection>;
|
|
158
39
|
//#endregion
|
|
159
|
-
//#region src/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
40
|
+
//#region src/commands/doctor.d.ts
|
|
41
|
+
type DoctorStatus = 'pass' | 'warn' | 'fail';
|
|
42
|
+
interface DoctorCheck {
|
|
43
|
+
id: string;
|
|
44
|
+
title: string;
|
|
45
|
+
status: DoctorStatus;
|
|
46
|
+
detail: string;
|
|
47
|
+
fix?: string;
|
|
48
|
+
}
|
|
49
|
+
interface DoctorSummary {
|
|
50
|
+
pass: number;
|
|
51
|
+
warn: number;
|
|
52
|
+
fail: number;
|
|
53
|
+
}
|
|
54
|
+
interface DoctorReport {
|
|
55
|
+
cwd: string;
|
|
56
|
+
workspaceDir: string;
|
|
57
|
+
packageCount: number;
|
|
58
|
+
checks: DoctorCheck[];
|
|
59
|
+
summary: DoctorSummary;
|
|
179
60
|
}
|
|
61
|
+
declare function runDoctor(cwd: string): Promise<{
|
|
62
|
+
cwd: string;
|
|
63
|
+
workspaceDir: string;
|
|
64
|
+
packageCount: number;
|
|
65
|
+
checks: DoctorCheck[];
|
|
66
|
+
summary: DoctorSummary;
|
|
67
|
+
}>;
|
|
180
68
|
//#endregion
|
|
181
|
-
//#region src/
|
|
182
|
-
interface
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
baseDir?: string;
|
|
193
|
-
/**
|
|
194
|
-
* 是否允许覆盖已存在文件。
|
|
195
|
-
* @default false
|
|
196
|
-
*/
|
|
197
|
-
force?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* 模板格式。
|
|
200
|
-
* @default 'md'
|
|
201
|
-
*/
|
|
202
|
-
format?: AgenticTemplateFormat;
|
|
203
|
-
/**
|
|
204
|
-
* 任务清单文件路径(JSON 数组),用于批量生成。
|
|
205
|
-
* @default undefined
|
|
206
|
-
*/
|
|
207
|
-
tasksFile?: string;
|
|
69
|
+
//#region src/commands/env.d.ts
|
|
70
|
+
interface EnvInfo {
|
|
71
|
+
cwd: string;
|
|
72
|
+
workspaceDir: string;
|
|
73
|
+
packageManager?: string;
|
|
74
|
+
nodeVersion: string;
|
|
75
|
+
nodeRange?: string;
|
|
76
|
+
pnpmVersion?: string;
|
|
77
|
+
platform: string;
|
|
78
|
+
arch: string;
|
|
79
|
+
packageCount: number;
|
|
208
80
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
* 自定义模板根目录。
|
|
215
|
-
* @default 内置模板所在的 `packages/monorepo/templates`
|
|
216
|
-
*/
|
|
217
|
-
templatesDir?: string;
|
|
218
|
-
/**
|
|
219
|
-
* 扩展模板映射表,key 为类型,value 为模板来源/目标路径。
|
|
220
|
-
* @default 内置 `templateMap`
|
|
221
|
-
*/
|
|
222
|
-
templateMap?: Record<string, string | TemplateDefinition>;
|
|
223
|
-
/**
|
|
224
|
-
* 自定义交互提示的选项列表。
|
|
225
|
-
* @default 内置 `baseChoices`
|
|
226
|
-
*/
|
|
227
|
-
choices?: CreateChoiceOption[];
|
|
228
|
-
/**
|
|
229
|
-
* 当未选择模板时使用的默认模板。
|
|
230
|
-
* @default 'unbuild'
|
|
231
|
-
*/
|
|
232
|
-
defaultTemplate?: CreateNewProjectOptions['type'];
|
|
81
|
+
interface EnvSnapshot {
|
|
82
|
+
generatedAt: string;
|
|
83
|
+
env: EnvInfo;
|
|
84
|
+
doctor: DoctorReport;
|
|
85
|
+
checkPlan: RecommendedCheckPlan;
|
|
233
86
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
*/
|
|
242
|
-
value: string;
|
|
243
|
-
/**
|
|
244
|
-
* 选项展示名称。
|
|
245
|
-
* @default value
|
|
246
|
-
*/
|
|
247
|
-
name?: string;
|
|
248
|
-
/**
|
|
249
|
-
* 选项描述信息。
|
|
250
|
-
* @default undefined
|
|
251
|
-
*/
|
|
252
|
-
description?: string;
|
|
253
|
-
/**
|
|
254
|
-
* 短名称,用于命令行紧凑展示。
|
|
255
|
-
* @default undefined
|
|
256
|
-
*/
|
|
257
|
-
short?: string;
|
|
258
|
-
/**
|
|
259
|
-
* 设置为 true 或字符串即可禁用该选项并显示原因。
|
|
260
|
-
* @default false
|
|
261
|
-
*/
|
|
262
|
-
disabled?: boolean | string;
|
|
87
|
+
interface EnvSupportBundle {
|
|
88
|
+
generatedAt: string;
|
|
89
|
+
env: EnvInfo;
|
|
90
|
+
paths: EnvPaths;
|
|
91
|
+
config: ConfigInspection;
|
|
92
|
+
doctor: DoctorReport;
|
|
93
|
+
checkPlan: RecommendedCheckPlan;
|
|
263
94
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* 是否跳过交互直接清理全部。
|
|
270
|
-
* @default false
|
|
271
|
-
*/
|
|
272
|
-
autoConfirm?: boolean;
|
|
273
|
-
/**
|
|
274
|
-
* 不允许被清理的包名列表。
|
|
275
|
-
* @default []
|
|
276
|
-
*/
|
|
277
|
-
ignorePackages?: string[];
|
|
278
|
-
/**
|
|
279
|
-
* 是否包含 private 包。
|
|
280
|
-
* @default true
|
|
281
|
-
*/
|
|
282
|
-
includePrivate?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* 强制写回的 @icebreakers/monorepo 版本。
|
|
285
|
-
* @default 当前依赖版本
|
|
286
|
-
*/
|
|
287
|
-
pinnedVersion?: string;
|
|
95
|
+
interface EnvPathEntry {
|
|
96
|
+
path: string;
|
|
97
|
+
relativePath: string;
|
|
98
|
+
exists: boolean;
|
|
288
99
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
*/
|
|
307
|
-
packages?: string[];
|
|
100
|
+
interface EnvPaths {
|
|
101
|
+
cwd: string;
|
|
102
|
+
workspaceDir: string;
|
|
103
|
+
paths: {
|
|
104
|
+
packageJson: EnvPathEntry;
|
|
105
|
+
workspaceManifest: EnvPathEntry;
|
|
106
|
+
repoctlConfig: EnvPathEntry;
|
|
107
|
+
repoctlConfigs: EnvPathEntry[];
|
|
108
|
+
legacyConfig: EnvPathEntry;
|
|
109
|
+
legacyConfigs: EnvPathEntry[];
|
|
110
|
+
toolingDir: EnvPathEntry;
|
|
111
|
+
reportsDir: EnvPathEntry;
|
|
112
|
+
doctorReport: EnvPathEntry;
|
|
113
|
+
envReport: EnvPathEntry;
|
|
114
|
+
snapshotReport: EnvPathEntry;
|
|
115
|
+
checkPlanReport: EnvPathEntry;
|
|
116
|
+
};
|
|
308
117
|
}
|
|
118
|
+
declare function collectEnvInfo(cwd: string): Promise<EnvInfo>;
|
|
119
|
+
declare function collectEnvPaths(cwd: string): Promise<EnvPaths>;
|
|
120
|
+
declare function collectEnvSnapshot(cwd: string, now?: Date): Promise<EnvSnapshot>;
|
|
121
|
+
declare function collectEnvSupportBundle(cwd: string, now?: Date): Promise<EnvSupportBundle>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/commands/skills.d.ts
|
|
309
124
|
/**
|
|
310
|
-
*
|
|
125
|
+
* 当前支持的 skills 同步目标。
|
|
311
126
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
* @default []
|
|
316
|
-
*/
|
|
317
|
-
targets?: string[];
|
|
318
|
-
/**
|
|
319
|
-
* 是否与默认目标合并,false 表示完全覆盖。
|
|
320
|
-
* @default true
|
|
321
|
-
*/
|
|
322
|
-
mergeTargets?: boolean;
|
|
127
|
+
declare const skillTargets: readonly ["codex", "claude"];
|
|
128
|
+
type SkillTarget = typeof skillTargets[number];
|
|
129
|
+
interface SyncSkillsOptions {
|
|
323
130
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
131
|
+
* 当前工作目录。
|
|
132
|
+
* 仅用于生成更友好的错误提示。
|
|
133
|
+
* @default process.cwd()
|
|
326
134
|
*/
|
|
327
|
-
|
|
135
|
+
cwd?: string;
|
|
328
136
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
137
|
+
* 需要同步的目标列表。
|
|
138
|
+
* 未提供时会在 CLI 中交互选择。
|
|
139
|
+
* @default undefined
|
|
331
140
|
*/
|
|
332
|
-
|
|
141
|
+
targets?: SkillTarget[];
|
|
333
142
|
}
|
|
334
143
|
/**
|
|
335
|
-
*
|
|
144
|
+
* 计算各个目标平台的 skills 安装路径。
|
|
145
|
+
*
|
|
146
|
+
* @param homeDir 用户 home 目录,默认取 `os.homedir()`
|
|
336
147
|
*/
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* 是否跳过 README 生成。
|
|
340
|
-
* @default false
|
|
341
|
-
*/
|
|
342
|
-
skipReadme?: boolean;
|
|
343
|
-
/**
|
|
344
|
-
* 是否跳过 package.json 写入。
|
|
345
|
-
* @default false
|
|
346
|
-
*/
|
|
347
|
-
skipPkgJson?: boolean;
|
|
348
|
-
/**
|
|
349
|
-
* 是否跳过 changeset 的更新。
|
|
350
|
-
* @default false
|
|
351
|
-
*/
|
|
352
|
-
skipChangeset?: boolean;
|
|
353
|
-
/**
|
|
354
|
-
* 是否跳过 Issue 模版 discussions 链接的更新。
|
|
355
|
-
* @default false
|
|
356
|
-
*/
|
|
357
|
-
skipIssueTemplateConfig?: boolean;
|
|
358
|
-
}
|
|
148
|
+
declare function getSkillTargetPaths(homeDir?: string): Record<SkillTarget, string>;
|
|
359
149
|
/**
|
|
360
|
-
*
|
|
150
|
+
* 将内置 skills 同步到一个或多个目标平台目录。
|
|
151
|
+
*
|
|
152
|
+
* @param options 同步选项
|
|
153
|
+
* @returns 成功同步的目标及落盘路径列表
|
|
361
154
|
*/
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
155
|
+
declare function syncSkills(options?: SyncSkillsOptions): Promise<{
|
|
156
|
+
target: SkillTarget;
|
|
157
|
+
dest: string;
|
|
158
|
+
}[]>;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/commands/templates.d.ts
|
|
161
|
+
type TemplateHealthStatus = 'pass' | 'warn' | 'fail';
|
|
162
|
+
interface TemplateHealthCheck {
|
|
163
|
+
id: string;
|
|
164
|
+
status: TemplateHealthStatus;
|
|
165
|
+
title: string;
|
|
166
|
+
detail: string;
|
|
167
|
+
template?: string;
|
|
168
|
+
fix?: string;
|
|
368
169
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* 按命令分类的可选配置。
|
|
375
|
-
* @default {}
|
|
376
|
-
*/
|
|
377
|
-
commands?: {
|
|
378
|
-
ai?: AiCommandConfig;
|
|
379
|
-
create?: CreateCommandConfig;
|
|
380
|
-
clean?: CleanCommandConfig;
|
|
381
|
-
sync?: SyncCommandConfig;
|
|
382
|
-
upgrade?: UpgradeCommandConfig;
|
|
383
|
-
init?: InitCommandConfig;
|
|
384
|
-
mirror?: MirrorCommandConfig;
|
|
385
|
-
};
|
|
170
|
+
interface TemplateHealthSummary {
|
|
171
|
+
pass: number;
|
|
172
|
+
warn: number;
|
|
173
|
+
fail: number;
|
|
386
174
|
}
|
|
175
|
+
interface TemplateHealthReport {
|
|
176
|
+
templatesDir: string;
|
|
177
|
+
templateCount: number;
|
|
178
|
+
checks: TemplateHealthCheck[];
|
|
179
|
+
summary: TemplateHealthSummary;
|
|
180
|
+
}
|
|
181
|
+
interface CheckTemplatesOptions {
|
|
182
|
+
templatesDir?: string;
|
|
183
|
+
}
|
|
184
|
+
declare function checkTemplates(options?: CheckTemplatesOptions): Promise<TemplateHealthReport>;
|
|
387
185
|
//#endregion
|
|
388
|
-
//#region
|
|
389
|
-
interface
|
|
390
|
-
/**
|
|
391
|
-
* The name is what your thing is called.
|
|
392
|
-
* Some rules:
|
|
393
|
-
* - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
|
|
394
|
-
* - The name can’t start with a dot or an underscore.
|
|
395
|
-
* - New packages must not have uppercase letters in the name.
|
|
396
|
-
* - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
|
|
397
|
-
*/
|
|
398
|
-
name?: string;
|
|
399
|
-
/**
|
|
400
|
-
* Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
|
|
401
|
-
*/
|
|
402
|
-
version?: string;
|
|
403
|
-
/**
|
|
404
|
-
* Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
|
|
405
|
-
*/
|
|
406
|
-
description?: string;
|
|
407
|
-
/**
|
|
408
|
-
* Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
|
|
409
|
-
*/
|
|
410
|
-
keywords?: string[];
|
|
411
|
-
/**
|
|
412
|
-
* The url to the project homepage.
|
|
413
|
-
*/
|
|
414
|
-
homepage?: string;
|
|
415
|
-
/**
|
|
416
|
-
* The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
|
|
417
|
-
*/
|
|
418
|
-
bugs?: string | {
|
|
419
|
-
url?: string;
|
|
420
|
-
email?: string;
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
|
|
424
|
-
*/
|
|
425
|
-
license?: string;
|
|
426
|
-
/**
|
|
427
|
-
* Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
|
|
428
|
-
* For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
|
|
429
|
-
*/
|
|
430
|
-
repository?: string | {
|
|
431
|
-
type: string;
|
|
432
|
-
url: string;
|
|
433
|
-
/**
|
|
434
|
-
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
|
|
435
|
-
*/
|
|
436
|
-
directory?: string;
|
|
437
|
-
};
|
|
438
|
-
/**
|
|
439
|
-
* The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
|
|
440
|
-
*/
|
|
441
|
-
scripts?: PackageJsonScripts;
|
|
442
|
-
/**
|
|
443
|
-
* If you set `"private": true` in your package.json, then npm will refuse to publish it.
|
|
444
|
-
*/
|
|
445
|
-
private?: boolean;
|
|
446
|
-
/**
|
|
447
|
-
* The “author” is one person.
|
|
448
|
-
*/
|
|
449
|
-
author?: PackageJsonPerson;
|
|
450
|
-
/**
|
|
451
|
-
* “contributors” is an array of people.
|
|
452
|
-
*/
|
|
453
|
-
contributors?: PackageJsonPerson[];
|
|
454
|
-
/**
|
|
455
|
-
* An object containing a URL that provides up-to-date information
|
|
456
|
-
* about ways to help fund development of your package,
|
|
457
|
-
* a string URL, or an array of objects and string URLs
|
|
458
|
-
*/
|
|
459
|
-
funding?: PackageJsonFunding | PackageJsonFunding[];
|
|
460
|
-
/**
|
|
461
|
-
* The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
|
|
462
|
-
*/
|
|
463
|
-
files?: string[];
|
|
464
|
-
/**
|
|
465
|
-
* The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
|
|
466
|
-
* This should be a module ID relative to the root of your package folder.
|
|
467
|
-
* For most modules, it makes the most sense to have a main script and often not much else.
|
|
468
|
-
*/
|
|
469
|
-
main?: string;
|
|
470
|
-
/**
|
|
471
|
-
* If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
|
|
472
|
-
*/
|
|
473
|
-
browser?: string | Record<string, string | false>;
|
|
474
|
-
/**
|
|
475
|
-
* The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
|
|
476
|
-
*/
|
|
477
|
-
unpkg?: string;
|
|
186
|
+
//#region src/commands/verify/index.d.ts
|
|
187
|
+
interface VerifyCommandOptions {
|
|
478
188
|
/**
|
|
479
|
-
*
|
|
480
|
-
|
|
481
|
-
bin?: string | Record<string, string>;
|
|
482
|
-
/**
|
|
483
|
-
* Specify either a single file or an array of filenames to put in place for the `man` program to find.
|
|
484
|
-
*/
|
|
485
|
-
man?: string | string[];
|
|
486
|
-
/**
|
|
487
|
-
* Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
|
|
488
|
-
*/
|
|
489
|
-
dependencies?: Record<string, string>;
|
|
490
|
-
/**
|
|
491
|
-
* If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
|
|
492
|
-
* In this case, it’s best to map these additional items in a `devDependencies` object.
|
|
493
|
-
*/
|
|
494
|
-
devDependencies?: Record<string, string>;
|
|
495
|
-
/**
|
|
496
|
-
* If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
|
|
497
|
-
*/
|
|
498
|
-
optionalDependencies?: Record<string, string>;
|
|
499
|
-
/**
|
|
500
|
-
* In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
|
|
501
|
-
*/
|
|
502
|
-
peerDependencies?: Record<string, string>;
|
|
503
|
-
/**
|
|
504
|
-
* TypeScript typings, typically ending by `.d.ts`.
|
|
505
|
-
*/
|
|
506
|
-
types?: string;
|
|
507
|
-
/**
|
|
508
|
-
* This field is synonymous with `types`.
|
|
509
|
-
*/
|
|
510
|
-
typings?: string;
|
|
511
|
-
/**
|
|
512
|
-
* Non-Standard Node.js alternate entry-point to main.
|
|
513
|
-
* An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
|
|
514
|
-
*/
|
|
515
|
-
module?: string;
|
|
516
|
-
/**
|
|
517
|
-
* Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
|
|
518
|
-
*
|
|
519
|
-
* Docs:
|
|
520
|
-
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
|
|
521
|
-
*
|
|
522
|
-
* @default 'commonjs'
|
|
523
|
-
* @since Node.js v14
|
|
189
|
+
* 命令执行根目录。
|
|
190
|
+
* @default process.cwd()
|
|
524
191
|
*/
|
|
525
|
-
|
|
192
|
+
cwd?: string;
|
|
193
|
+
}
|
|
194
|
+
interface PrePushVerifyOptions extends VerifyCommandOptions {
|
|
526
195
|
/**
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
* Docs:
|
|
532
|
-
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
|
|
533
|
-
*
|
|
534
|
-
* @since Node.js v12.7
|
|
196
|
+
* pre-push hook 的 stdin 原始文本。
|
|
197
|
+
* 未提供时会从真实 stdin 读取。
|
|
198
|
+
* @default undefined
|
|
535
199
|
*/
|
|
536
|
-
|
|
200
|
+
stdinText?: string;
|
|
537
201
|
/**
|
|
538
|
-
*
|
|
539
|
-
*
|
|
202
|
+
* 参与变更归属计算的 workspace 列表。
|
|
203
|
+
* @default 内置 `defaultWorkspaceOrder`
|
|
540
204
|
*/
|
|
541
|
-
|
|
205
|
+
workspaces?: string[];
|
|
542
206
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* This field is an array of glob patterns or an object with specific configurations for managing
|
|
546
|
-
* multiple packages in a single repository.
|
|
207
|
+
* 可注入的 `execFileSync` 实现,主要用于测试。
|
|
208
|
+
* @default node:child_process.execFileSync
|
|
547
209
|
*/
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Workspace package paths. Glob patterns are supported.
|
|
551
|
-
*/
|
|
552
|
-
packages?: string[];
|
|
553
|
-
/**
|
|
554
|
-
* Packages to block from hoisting to the workspace root.
|
|
555
|
-
* Uses glob patterns to match module paths in the dependency tree.
|
|
556
|
-
*
|
|
557
|
-
* Docs:
|
|
558
|
-
* - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
|
|
559
|
-
*/
|
|
560
|
-
nohoist?: string[];
|
|
561
|
-
};
|
|
210
|
+
execFile?: typeof execFileSync;
|
|
562
211
|
/**
|
|
563
|
-
*
|
|
564
|
-
*
|
|
212
|
+
* 可注入的 `spawnSync` 实现,主要用于测试。
|
|
213
|
+
* @default node:child_process.spawnSync
|
|
565
214
|
*/
|
|
566
|
-
|
|
215
|
+
spawn?: typeof spawnSync;
|
|
216
|
+
}
|
|
217
|
+
interface StagedTypecheckOptions extends VerifyCommandOptions {
|
|
567
218
|
/**
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
* {
|
|
571
|
-
* "os": ["darwin", "linux"]
|
|
572
|
-
* }
|
|
573
|
-
* ```
|
|
574
|
-
* You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
|
|
575
|
-
* ```json
|
|
576
|
-
* {
|
|
577
|
-
* "os": ["!win32"]
|
|
578
|
-
* }
|
|
579
|
-
* ```
|
|
580
|
-
* The host operating system is determined by `process.platform`
|
|
581
|
-
* It is allowed to both block and allow an item, although there isn't any good reason to do this.
|
|
219
|
+
* 可注入的 `spawnSync` 实现,主要用于测试。
|
|
220
|
+
* @default node:child_process.spawnSync
|
|
582
221
|
*/
|
|
583
|
-
|
|
222
|
+
spawn?: typeof spawnSync;
|
|
223
|
+
}
|
|
224
|
+
interface CommitMsgVerifyOptions extends VerifyCommandOptions {
|
|
584
225
|
/**
|
|
585
|
-
*
|
|
586
|
-
* ```json
|
|
587
|
-
* {
|
|
588
|
-
* "cpu": ["x64", "ia32"]
|
|
589
|
-
* }
|
|
590
|
-
* ```
|
|
591
|
-
* Like the `os` option, you can also block architectures:
|
|
592
|
-
* ```json
|
|
593
|
-
* {
|
|
594
|
-
* "cpu": ["!arm", "!mips"]
|
|
595
|
-
* }
|
|
596
|
-
* ```
|
|
597
|
-
* The host architecture is determined by `process.arch`
|
|
226
|
+
* commit message 文件路径。
|
|
598
227
|
*/
|
|
599
|
-
|
|
228
|
+
editFile: string;
|
|
600
229
|
/**
|
|
601
|
-
*
|
|
230
|
+
* 可注入的 `spawnSync` 实现,主要用于测试。
|
|
231
|
+
* @default node:child_process.spawnSync
|
|
602
232
|
*/
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
*/
|
|
607
|
-
registry?: string;
|
|
608
|
-
/**
|
|
609
|
-
* The tag that will be used if the package is published.
|
|
610
|
-
*/
|
|
611
|
-
tag?: string;
|
|
612
|
-
/**
|
|
613
|
-
* The access level that will be used if the package is published.
|
|
614
|
-
*/
|
|
615
|
-
access?: "public" | "restricted";
|
|
616
|
-
/**
|
|
617
|
-
* **pnpm-only**
|
|
618
|
-
*
|
|
619
|
-
* By default, for portability reasons, no files except those listed in
|
|
620
|
-
* the bin field will be marked as executable in the resulting package
|
|
621
|
-
* archive. The executableFiles field lets you declare additional fields
|
|
622
|
-
* that must have the executable flag (+x) set even if
|
|
623
|
-
* they aren't directly accessible through the bin field.
|
|
624
|
-
*/
|
|
625
|
-
executableFiles?: string[];
|
|
626
|
-
/**
|
|
627
|
-
* **pnpm-only**
|
|
628
|
-
*
|
|
629
|
-
* You also can use the field `publishConfig.directory` to customize
|
|
630
|
-
* the published subdirectory relative to the current `package.json`.
|
|
631
|
-
*
|
|
632
|
-
* It is expected to have a modified version of the current package in
|
|
633
|
-
* the specified directory (usually using third party build tools).
|
|
634
|
-
*/
|
|
635
|
-
directory?: string;
|
|
636
|
-
/**
|
|
637
|
-
* **pnpm-only**
|
|
638
|
-
*
|
|
639
|
-
* When set to `true`, the project will be symlinked from the
|
|
640
|
-
* `publishConfig.directory` location during local development.
|
|
641
|
-
* @default true
|
|
642
|
-
*/
|
|
643
|
-
linkDirectory?: boolean;
|
|
644
|
-
} & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
|
|
233
|
+
spawn?: typeof spawnSync;
|
|
234
|
+
}
|
|
235
|
+
interface PreCommitVerifyOptions extends VerifyCommandOptions {
|
|
645
236
|
/**
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
* Should be of the format: `<name>@<version>[#hash]`
|
|
237
|
+
* 可注入的 `spawnSync` 实现,主要用于测试。
|
|
238
|
+
* @default node:child_process.spawnSync
|
|
649
239
|
*/
|
|
650
|
-
|
|
651
|
-
[key: string]: any;
|
|
240
|
+
spawn?: typeof spawnSync;
|
|
652
241
|
}
|
|
653
242
|
/**
|
|
654
|
-
*
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
*
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
*
|
|
663
|
-
*/
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
*
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
interface SyncSkillsOptions {
|
|
693
|
-
cwd?: string;
|
|
694
|
-
targets?: SkillTarget[];
|
|
695
|
-
}
|
|
696
|
-
declare function getSkillTargetPaths(homeDir?: string): Record<SkillTarget, string>;
|
|
697
|
-
declare function syncSkills(options?: SyncSkillsOptions): Promise<{
|
|
698
|
-
target: SkillTarget;
|
|
699
|
-
dest: string;
|
|
700
|
-
}[]>;
|
|
243
|
+
* 执行 pre-push 校验。
|
|
244
|
+
*
|
|
245
|
+
* 该函数会根据 push 范围内的改动文件,推导需要运行的 workspace 任务:
|
|
246
|
+
* - workspace 内改动:按包执行 `build` / `test` / `tsd`
|
|
247
|
+
* - 根级配置改动:在仓库根执行 `build` / `test` / `tsd`
|
|
248
|
+
* - 无论改动范围如何,都会强制在仓库根执行整仓 `lint` 与 `typecheck`
|
|
249
|
+
*
|
|
250
|
+
* @param options pre-push 运行参数
|
|
251
|
+
* @returns Promise<void>
|
|
252
|
+
*/
|
|
253
|
+
declare function verifyPrePush(options?: PrePushVerifyOptions): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* 对暂存区中涉及类型检查的文件,按最近的 workspace 归属执行 `typecheck`。
|
|
256
|
+
*
|
|
257
|
+
* 当前识别的扩展名:`.ts`、`.tsx`、`.mts`、`.cts`、`.vue`。
|
|
258
|
+
*
|
|
259
|
+
* @param stagedFiles 暂存区文件路径列表
|
|
260
|
+
* @param options 运行参数
|
|
261
|
+
*/
|
|
262
|
+
declare function verifyStagedTypecheck(stagedFiles: string[], options?: StagedTypecheckOptions): void;
|
|
263
|
+
/**
|
|
264
|
+
* 执行 commit-msg 校验。
|
|
265
|
+
*
|
|
266
|
+
* 优先读取 `tooling.husky.commitMsgCommand`;若未配置,则回退到
|
|
267
|
+
* `pnpm exec commitlint --edit <editFile>`。
|
|
268
|
+
*
|
|
269
|
+
* @param options commit-msg 运行参数
|
|
270
|
+
*/
|
|
271
|
+
declare function verifyCommitMsg(options: CommitMsgVerifyOptions): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* 执行 pre-commit 校验。
|
|
274
|
+
*
|
|
275
|
+
* 优先读取 `tooling.husky.preCommitCommand`;若未配置,则回退到
|
|
276
|
+
* `pnpm exec lint-staged`。
|
|
277
|
+
*
|
|
278
|
+
* @param options pre-commit 运行参数
|
|
279
|
+
*/
|
|
280
|
+
declare function verifyPreCommit(options?: PreCommitVerifyOptions): Promise<void>;
|
|
701
281
|
//#endregion
|
|
702
282
|
//#region src/core/git.d.ts
|
|
703
283
|
/**
|
|
@@ -710,7 +290,7 @@ declare class GitClient {
|
|
|
710
290
|
/**
|
|
711
291
|
* 读取 Git 的 config 列表,原样返回 simple-git 的结果。
|
|
712
292
|
*/
|
|
713
|
-
listConfig(): simple_git0.Response<simple_git0.ConfigListSummary>;
|
|
293
|
+
listConfig(): _$simple_git0.Response<_$simple_git0.ConfigListSummary>;
|
|
714
294
|
/**
|
|
715
295
|
* 初始化配置缓存,避免多次访问 Git 产生的性能损耗。
|
|
716
296
|
*/
|
|
@@ -742,31 +322,35 @@ declare class GitClient {
|
|
|
742
322
|
//#endregion
|
|
743
323
|
//#region src/core/workspace.d.ts
|
|
744
324
|
/**
|
|
745
|
-
*
|
|
325
|
+
* 清空当前进程内的 workspace 发现缓存。
|
|
326
|
+
*
|
|
327
|
+
* 普通 CLI 命令执行后进程会退出;长期运行的集成测试或程序化调用在修改
|
|
328
|
+
* `pnpm-workspace.yaml` / package 目录后,可以调用它让后续扫描重新读磁盘。
|
|
746
329
|
*/
|
|
747
|
-
declare function
|
|
748
|
-
pkgJsonPath: string;
|
|
749
|
-
rootDir: _pnpm_types0.ProjectRootDir;
|
|
750
|
-
rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
|
|
751
|
-
modulesDir?: string;
|
|
752
|
-
manifest: _pnpm_types0.ProjectManifest;
|
|
753
|
-
writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
754
|
-
}[]>;
|
|
330
|
+
declare function clearWorkspaceCache(): void;
|
|
755
331
|
/**
|
|
756
|
-
*
|
|
332
|
+
* 读取 pnpm workspace 下的所有包,并根据选项做过滤。
|
|
333
|
+
*
|
|
334
|
+
* 默认值:
|
|
335
|
+
* - `ignoreRootPackage`: `true`
|
|
336
|
+
* - `ignorePrivatePackage`: `true`
|
|
337
|
+
*
|
|
338
|
+
* @param workspaceDir workspace 根目录
|
|
339
|
+
* @param options 过滤选项
|
|
340
|
+
* @returns 带有 `pkgJsonPath` 字段的 workspace package 列表
|
|
757
341
|
*/
|
|
758
|
-
declare function
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
342
|
+
declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<WorkspacePackageWithJsonPath[]>;
|
|
343
|
+
/**
|
|
344
|
+
* 一次性返回 `cwd`、真实 `workspaceDir` 与过滤后的包列表。
|
|
345
|
+
*
|
|
346
|
+
* @param cwd 当前工作目录
|
|
347
|
+
* @param options 传给 `getWorkspacePackages()` 的过滤选项
|
|
348
|
+
*/
|
|
349
|
+
declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<WorkspaceData>;
|
|
350
|
+
/**
|
|
351
|
+
* 返回适合展示和程序化消费的 workspace package 摘要。
|
|
352
|
+
*/
|
|
353
|
+
declare function getWorkspacePackageSummaries(cwd: string, options?: GetWorkspacePackagesOptions): Promise<WorkspacePackageSummaryData>;
|
|
770
354
|
//#endregion
|
|
771
355
|
//#region src/commands/clean.d.ts
|
|
772
356
|
/**
|
|
@@ -774,24 +358,12 @@ declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOpt
|
|
|
774
358
|
*/
|
|
775
359
|
declare function cleanProjects(cwd: string, overrides?: Partial<CleanCommandConfig>): Promise<void>;
|
|
776
360
|
//#endregion
|
|
777
|
-
//#region src/commands/init/index.d.ts
|
|
778
|
-
/**
|
|
779
|
-
* 初始化命令入口,根据配置逐步生成基础文件。
|
|
780
|
-
*/
|
|
781
|
-
declare function init(cwd: string): Promise<void>;
|
|
782
|
-
//#endregion
|
|
783
361
|
//#region src/commands/mirror/binaryMirror.d.ts
|
|
784
362
|
/**
|
|
785
363
|
* 根据中国大陆镜像源,自动向 VSCode settings.json 注入终端环境变量。
|
|
786
364
|
*/
|
|
787
365
|
declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
|
|
788
366
|
//#endregion
|
|
789
|
-
//#region src/commands/sync.d.ts
|
|
790
|
-
/**
|
|
791
|
-
* 批量执行 `cnpm sync`(或自定义命令),将所有包同步到 npmmirror。
|
|
792
|
-
*/
|
|
793
|
-
declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOptions): Promise<void>;
|
|
794
|
-
//#endregion
|
|
795
367
|
//#region src/commands/upgrade/index.d.ts
|
|
796
368
|
/**
|
|
797
369
|
* 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
|
|
@@ -803,80 +375,171 @@ declare let name: string;
|
|
|
803
375
|
declare let version: string;
|
|
804
376
|
//#endregion
|
|
805
377
|
//#region src/constants.d.ts
|
|
378
|
+
/**
|
|
379
|
+
* 用户默认看到的 CLI 名称。兼容别名仍然可用,但帮助文案统一引导到 repo。
|
|
380
|
+
*/
|
|
381
|
+
declare const cliName = "repo";
|
|
806
382
|
/**
|
|
807
383
|
* @icebreakers/monorepo 包的根目录。
|
|
808
384
|
*/
|
|
809
385
|
declare const packageDir: string;
|
|
386
|
+
declare const assetsDir: string;
|
|
387
|
+
declare const templatesDir: string;
|
|
810
388
|
/**
|
|
811
389
|
* monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
|
|
812
390
|
*/
|
|
813
391
|
declare const rootDir: string;
|
|
814
392
|
//#endregion
|
|
815
393
|
//#region src/core/config.d.ts
|
|
394
|
+
interface LoadedMonorepoConfig {
|
|
395
|
+
file: string | null;
|
|
396
|
+
config: MonorepoConfig;
|
|
397
|
+
}
|
|
398
|
+
declare const configExtensions: readonly ["ts", "mts", "cts", "js", "mjs", "cjs"];
|
|
399
|
+
declare function getMonorepoConfigCandidates(cwd: string): {
|
|
400
|
+
repoctl: string[];
|
|
401
|
+
monorepo: string[];
|
|
402
|
+
};
|
|
816
403
|
/**
|
|
817
|
-
*
|
|
404
|
+
* 为 `repoctl.config.ts` / `monorepo.config.ts` 提供类型提示的辅助函数。
|
|
405
|
+
*
|
|
406
|
+
* 推荐在用户项目中这样写:
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* import { defineMonorepoConfig } from '@icebreakers/monorepo'
|
|
411
|
+
*
|
|
412
|
+
* export default defineMonorepoConfig({
|
|
413
|
+
* tooling: {
|
|
414
|
+
* vitest: {
|
|
415
|
+
* includeWorkspaceRootConfig: false,
|
|
416
|
+
* },
|
|
417
|
+
* },
|
|
418
|
+
* })
|
|
419
|
+
* ```
|
|
818
420
|
*/
|
|
819
421
|
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
820
422
|
/**
|
|
821
|
-
*
|
|
423
|
+
* 加载配置对象和实际命中的配置文件路径,供诊断和脚本集成使用。
|
|
424
|
+
* 优先级为 `repoctl.config.*`,如果两者同时存在则直接报错。
|
|
425
|
+
*
|
|
426
|
+
* @param cwd 配置文件解析起点
|
|
427
|
+
* @returns 配置文件路径和解析后的配置对象;未找到时 file 为 null、config 为空对象
|
|
428
|
+
*/
|
|
429
|
+
declare function loadMonorepoConfigDetails(cwd: string): Promise<LoadedMonorepoConfig>;
|
|
430
|
+
/**
|
|
431
|
+
* 加载指定目录的 `repoctl.config.*` 或 `monorepo.config.*`,并在当前进程内做内存缓存。
|
|
432
|
+
* 优先级为 `repoctl.config.*`,如果两者同时存在则直接报错。
|
|
433
|
+
*
|
|
434
|
+
* @param cwd 配置文件解析起点
|
|
435
|
+
* @returns 解析后的配置对象;未找到时返回空对象
|
|
822
436
|
*/
|
|
823
437
|
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
824
438
|
/**
|
|
825
|
-
*
|
|
439
|
+
* 获取单个命令对应的配置块。
|
|
440
|
+
*
|
|
441
|
+
* @param name 命令名称,对应 `repoctl.config.ts` / `monorepo.config.ts -> commands.<name>`
|
|
442
|
+
* @param cwd 配置文件解析起点
|
|
443
|
+
* @returns 对应命令配置;未配置时返回空对象
|
|
826
444
|
*/
|
|
827
445
|
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region src/core/context.d.ts
|
|
830
446
|
/**
|
|
831
|
-
*
|
|
447
|
+
* 获取 `repoctl.config.ts` / `monorepo.config.ts` 中完整的 `tooling` 配置块。
|
|
448
|
+
*
|
|
449
|
+
* @param cwd 配置文件解析起点
|
|
450
|
+
* @returns `tooling` 配置;未配置时返回空对象
|
|
832
451
|
*/
|
|
833
|
-
declare function
|
|
452
|
+
declare function resolveToolingConfig(cwd: string): Promise<NonNullable<MonorepoConfig['tooling']>>;
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/core/context.d.ts
|
|
455
|
+
interface Context {
|
|
834
456
|
cwd: string;
|
|
835
457
|
git: GitClient;
|
|
836
|
-
gitUrl:
|
|
837
|
-
gitUser:
|
|
838
|
-
name: string | string[] | undefined;
|
|
839
|
-
email: string | string[] | undefined;
|
|
840
|
-
};
|
|
458
|
+
gitUrl: Awaited<ReturnType<GitClient['getGitUrl']>>;
|
|
459
|
+
gitUser: Awaited<ReturnType<GitClient['getUser']>>;
|
|
841
460
|
workspaceDir: string;
|
|
842
461
|
workspaceFilepath: string;
|
|
843
|
-
packages:
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
|
|
847
|
-
modulesDir?: string;
|
|
848
|
-
manifest: _pnpm_types0.ProjectManifest;
|
|
849
|
-
writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
850
|
-
}[];
|
|
851
|
-
config: MonorepoConfig;
|
|
852
|
-
}>;
|
|
462
|
+
packages: Awaited<ReturnType<typeof getWorkspaceData>>['packages'];
|
|
463
|
+
config: Awaited<ReturnType<typeof loadMonorepoConfig>>;
|
|
464
|
+
}
|
|
853
465
|
/**
|
|
854
|
-
*
|
|
466
|
+
* 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
|
|
855
467
|
*/
|
|
856
|
-
|
|
468
|
+
declare function createContext(cwd: string): Promise<Context>;
|
|
857
469
|
//#endregion
|
|
858
470
|
//#region src/core/logger.d.ts
|
|
859
471
|
/**
|
|
860
472
|
* 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
|
|
861
473
|
*/
|
|
862
|
-
declare const logger: consola.ConsolaInstance;
|
|
474
|
+
declare const logger: _$consola.ConsolaInstance;
|
|
863
475
|
//#endregion
|
|
864
476
|
//#region src/utils/fs.d.ts
|
|
477
|
+
/**
|
|
478
|
+
* JSON 输出选项。
|
|
479
|
+
*/
|
|
865
480
|
interface JsonWriteOptions {
|
|
481
|
+
/**
|
|
482
|
+
* `JSON.stringify` 缩进空格数。
|
|
483
|
+
* @default undefined
|
|
484
|
+
*/
|
|
866
485
|
spaces?: number;
|
|
867
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* 判断文件或目录是否存在。
|
|
489
|
+
*
|
|
490
|
+
* @param targetPath 目标路径
|
|
491
|
+
* @returns 存在时返回 `true`
|
|
492
|
+
*/
|
|
868
493
|
declare function pathExists(targetPath: string): Promise<boolean>;
|
|
494
|
+
/**
|
|
495
|
+
* `pathExists()` 的别名。
|
|
496
|
+
*/
|
|
869
497
|
declare const exists: typeof pathExists;
|
|
498
|
+
/**
|
|
499
|
+
* 递归创建目录。
|
|
500
|
+
*/
|
|
870
501
|
declare function ensureDir(targetPath: string): Promise<void>;
|
|
502
|
+
/**
|
|
503
|
+
* 确保文件存在;若父目录不存在会自动创建。
|
|
504
|
+
*/
|
|
871
505
|
declare function ensureFile(targetPath: string): Promise<void>;
|
|
506
|
+
/**
|
|
507
|
+
* 递归删除文件或目录。
|
|
508
|
+
*
|
|
509
|
+
* 默认启用 `force: true`、`recursive: true`,并带少量重试。
|
|
510
|
+
*/
|
|
872
511
|
declare function remove(targetPath: string): Promise<void>;
|
|
512
|
+
/**
|
|
513
|
+
* 递归复制文件或目录。
|
|
514
|
+
*/
|
|
873
515
|
declare function copy(sourcePath: string, targetPath: string): Promise<void>;
|
|
516
|
+
/**
|
|
517
|
+
* 自动创建父目录后写入文件。
|
|
518
|
+
*/
|
|
874
519
|
declare function outputFile(targetPath: string, data: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2]): Promise<void>;
|
|
520
|
+
/**
|
|
521
|
+
* 读取 JSON 文件并解析。
|
|
522
|
+
*/
|
|
875
523
|
declare function readJson<T = any>(targetPath: string): Promise<T>;
|
|
524
|
+
/**
|
|
525
|
+
* `readJson()` 的别名。
|
|
526
|
+
*/
|
|
876
527
|
declare const readJSON: typeof readJson;
|
|
528
|
+
/**
|
|
529
|
+
* 写入 JSON 文件,不会自动创建父目录。
|
|
530
|
+
*/
|
|
877
531
|
declare function writeJson(targetPath: string, data: unknown, options?: JsonWriteOptions): Promise<void>;
|
|
532
|
+
/**
|
|
533
|
+
* `writeJson()` 的别名。
|
|
534
|
+
*/
|
|
878
535
|
declare const writeJSON: typeof writeJson;
|
|
536
|
+
/**
|
|
537
|
+
* 自动创建父目录后写入 JSON 文件。
|
|
538
|
+
*/
|
|
879
539
|
declare function outputJson(targetPath: string, data: unknown, options?: JsonWriteOptions): Promise<void>;
|
|
540
|
+
/**
|
|
541
|
+
* `outputJson()` 的别名。
|
|
542
|
+
*/
|
|
880
543
|
declare const outputJSON: typeof outputJson;
|
|
881
544
|
/**
|
|
882
545
|
* 判断是否为可忽略的文件系统错误。
|
|
@@ -893,11 +556,18 @@ declare function updateIssueTemplateConfig(source: string, repoName?: string): s
|
|
|
893
556
|
//#endregion
|
|
894
557
|
//#region src/utils/hash.d.ts
|
|
895
558
|
/**
|
|
896
|
-
*
|
|
559
|
+
* 生成给定内容的 md5 摘要。
|
|
560
|
+
*
|
|
561
|
+
* @param data 任意 `crypto.BinaryLike` 内容
|
|
562
|
+
* @returns 32 位十六进制 md5 字符串
|
|
897
563
|
*/
|
|
898
564
|
declare function getFileHash(data: crypto.BinaryLike): string;
|
|
899
565
|
/**
|
|
900
|
-
*
|
|
566
|
+
* 对比两段内容的 md5,判断内容是否发生变化。
|
|
567
|
+
*
|
|
568
|
+
* @param src 当前内容
|
|
569
|
+
* @param dest 旧内容
|
|
570
|
+
* @returns 两者 md5 不一致时返回 `true`
|
|
901
571
|
*/
|
|
902
572
|
declare function isFileChanged(src: crypto.BinaryLike, dest: crypto.BinaryLike): boolean;
|
|
903
573
|
//#endregion
|
|
@@ -915,4 +585,4 @@ declare function escapeStringRegexp(str: string): string;
|
|
|
915
585
|
*/
|
|
916
586
|
declare function isMatch(str: string, arr: RegExp[]): boolean;
|
|
917
587
|
//#endregion
|
|
918
|
-
export { type AgenticTemplateFormat, type AgenticTemplateTask, type AiCommandConfig, type CleanCommandConfig, type CliOpts, type ConfigValues, Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GenerateAgenticTemplateOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, JsonWriteOptions, type MirrorCommandConfig, type MonorepoConfig,
|
|
588
|
+
export { type AgenticTemplateFormat, type AgenticTemplateTask, type AiCommandConfig, type CheckTemplatesOptions, type CleanCommandConfig, type CliOpts, type CommitMsgVerifyOptions, type CommitlintToolingConfig, type ConfigInspection, ConfigValues, Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type CreateNewProjectPlan, DefineConfigOptions, DefineVitestConfigOptions, DefineVitestProjectConfigOptions, type DoctorCheck, type DoctorReport, type DoctorStatus, type DoctorSummary, type EnvInfo, type EnvPathEntry, type EnvPaths, type EnvSnapshot, type EnvSupportBundle, type EslintToolingConfig, type GenerateAgenticTemplateOptions, type GetWorkspacePackagesOptions, GitClient, type HuskyToolingConfig, type InitCommandConfig, JsonWriteOptions, type LintStagedToolingConfig, LoadedMonorepoConfig, type MirrorCommandConfig, MonorepoCommitlintConfig, type MonorepoConfig, MonorepoEslintConfig, MonorepoLintStagedConfig, MonorepoLintStagedConfigOptions, MonorepoStylelintConfig, MonorepoTsconfig, MonorepoVitestConfigOptions, MonorepoVitestConfigOverrides, MonorepoVitestConfigResult, MonorepoVitestProjectConfigOptions, MonorepoVitestProjectConfigResult, PackageJson, PackageJsonBugs, PackageJsonExports, PackageJsonPerson, PackageJsonRepository, type PreCommitVerifyOptions, type PrePushVerifyOptions, type RecommendedCheckMode, type RecommendedCheckOptions, type RecommendedCheckPlan, type RecommendedCheckPlanCommand, SimpleGit, SimpleGitOptions, type SkillTarget, type StagedTypecheckOptions, type StylelintToolingConfig, type SyncSkillsOptions, type TemplateHealthCheck, type TemplateHealthReport, type TemplateHealthStatus, type TemplateHealthSummary, type ToolingConfig, TsconfigToolingConfig, type UpgradeCommandConfig, type VerifyCommandOptions, type VitestProjectToolingConfig, type VitestToolingConfig, WorkspaceData, WorkspacePackage, WorkspacePackageManifest, WorkspacePackageSummary, WorkspacePackageSummaryData, WorkspacePackageWithJsonPath, assetsDir, checkTemplates, cleanProjects, clearWorkspaceCache, cliName, collectEnvInfo, collectEnvPaths, collectEnvSnapshot, collectEnvSupportBundle, configExtensions, copy, createContext, createMonorepoCommitlintConfig, createMonorepoEslintConfig, createMonorepoLintStagedConfig, createMonorepoStylelintConfig, createMonorepoTsconfig, createMonorepoVitestConfig, createMonorepoVitestProjectConfig, createNewProject, createTimestampFolderName, defaultAgenticBaseDir, defineCommitlintConfig, defineEslintConfig, defineLintStagedConfig, defineMonorepoConfig, defineStylelintConfig, defineTsconfigConfig, defineVitestConfig, defineVitestProjectConfig, ensureDir, ensureFile, escapeStringRegexp, exists, generateAgenticTemplate, generateAgenticTemplates, getCreateChoices, getFileHash, getMonorepoConfigCandidates, getSkillTargetPaths, getTemplateMap, getWorkspaceData, getWorkspacePackageSummaries, getWorkspacePackages, init, initMetadata, initTooling, initToolingTargets, inspectMonorepoConfig, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadAgenticTasks, loadMonorepoConfig, loadMonorepoConfigDetails, loadMonorepoToolingConfig, logger, normalizeInitToolingTargets, outputFile, outputJSON, outputJson, packageDir, name as packageName, pathExists, readJSON, readJson, remove, resolveCommandConfig, resolveCreateNewProjectPlan, resolveRecommendedCheckPlan, resolveToolingConfig, rootDir, runDoctor, runRecommendedCheck, setByPath, setVscodeBinaryMirror, skillTargets, syncSkills, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, updateIssueTemplateConfig, upgradeMonorepo, verifyCommitMsg, verifyPreCommit, verifyPrePush, verifyStagedTypecheck, version, writeJSON, writeJson };
|