@icebreakers/monorepo 2.1.6 → 3.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/assets/.github/ISSUE_TEMPLATE/bug_report.yml +1 -1
- package/assets/package.json +4 -4
- package/assets/vitest.config.ts +68 -12
- package/bin/monorepo.js +2 -0
- package/dist/cli.cjs +55 -1551
- package/dist/cli.d.cts +1 -2
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +62 -0
- package/dist/index.cjs +43 -1583
- package/dist/index.d.cts +368 -230
- package/dist/index.d.mts +509 -0
- package/dist/index.mjs +3 -0
- package/dist/upgrade-BpSxJA9Y.cjs +1519 -0
- package/dist/upgrade-DKyLL_5k.mjs +1311 -0
- package/package.json +36 -15
- package/templates/apps/client/package.json +7 -7
- package/templates/apps/server/package.json +2 -2
- package/templates/packages/vue-lib-template/package.json +2 -2
- package/bin/copy.js +0 -2
- package/dist/chunk-KQQO4IV5.js +0 -1534
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -76
- package/dist/index.d.ts +0 -371
- package/dist/index.js +0 -70
package/dist/index.d.cts
CHANGED
|
@@ -1,284 +1,402 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
8
|
-
import crypto from
|
|
9
|
-
export { PackageJson } from 'pkg-types';
|
|
1
|
+
import { PackageJson } from "pkg-types";
|
|
2
|
+
import * as simple_git0 from "simple-git";
|
|
3
|
+
import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
|
|
4
|
+
import * as git_url_parse0 from "git-url-parse";
|
|
5
|
+
import gitUrlParse from "git-url-parse";
|
|
6
|
+
import * as _pnpm_types0 from "@pnpm/types";
|
|
7
|
+
import * as consola0 from "consola";
|
|
8
|
+
import crypto from "node:crypto";
|
|
10
9
|
|
|
10
|
+
//#region src/types/cli.d.ts
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* CLI 公用参数,保证各命令对外暴露一致的行为。
|
|
13
13
|
*/
|
|
14
|
-
interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
interface CliOpts {
|
|
15
|
+
/**
|
|
16
|
+
* 是否开启交互模式,开启后每一步都会提示用户确认。
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
interactive?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 是否使用 core 版资产,只同步最精简的文件集合。
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
core?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
|
|
27
|
+
* @default ''
|
|
28
|
+
*/
|
|
29
|
+
outDir?: string;
|
|
30
|
+
/**
|
|
31
|
+
* 命令执行的工作目录。
|
|
32
|
+
* @default process.cwd()
|
|
33
|
+
*/
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/**
|
|
36
|
+
* 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
skipOverwrite?: boolean;
|
|
18
40
|
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/commands/create.d.ts
|
|
19
43
|
/**
|
|
20
|
-
*
|
|
44
|
+
* 内置模板映射表,value 指向仓库中对应模板所在路径。
|
|
21
45
|
*/
|
|
22
|
-
declare
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
46
|
+
declare const templateMap: {
|
|
47
|
+
readonly tsup: "packages/tsup-template";
|
|
48
|
+
readonly tsdown: "packages/tsdown-template";
|
|
49
|
+
readonly unbuild: "packages/unbuild-template";
|
|
50
|
+
readonly 'vue-lib': "packages/vue-lib-template";
|
|
51
|
+
readonly 'hono-server': "apps/server";
|
|
52
|
+
readonly 'vue-hono': "apps/client";
|
|
53
|
+
readonly vitepress: "apps/website";
|
|
54
|
+
readonly cli: "apps/cli";
|
|
55
|
+
};
|
|
56
|
+
type CreateNewProjectType = keyof typeof templateMap;
|
|
57
|
+
interface CreateNewProjectOptions {
|
|
58
|
+
name?: string;
|
|
59
|
+
cwd?: string;
|
|
60
|
+
renameJson?: boolean;
|
|
61
|
+
type?: CreateNewProjectType | string;
|
|
62
|
+
}
|
|
30
63
|
/**
|
|
31
|
-
*
|
|
64
|
+
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
32
65
|
*/
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
66
|
+
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
67
|
+
readonly name: "unbuild 打包";
|
|
68
|
+
readonly value: "unbuild";
|
|
69
|
+
} | {
|
|
70
|
+
readonly name: "tsup 打包";
|
|
71
|
+
readonly value: "tsup";
|
|
72
|
+
} | {
|
|
73
|
+
readonly name: "tsdown 打包";
|
|
74
|
+
readonly value: "tsdown";
|
|
75
|
+
} | {
|
|
76
|
+
readonly name: "vue 组件";
|
|
77
|
+
readonly value: "vue-lib";
|
|
78
|
+
} | {
|
|
79
|
+
readonly name: "vue hono 全栈";
|
|
80
|
+
readonly value: "vue-hono";
|
|
81
|
+
} | {
|
|
82
|
+
readonly name: "hono 模板";
|
|
83
|
+
readonly value: "hono-server";
|
|
84
|
+
} | {
|
|
85
|
+
readonly name: "vitepress 文档";
|
|
86
|
+
readonly value: "vitepress";
|
|
87
|
+
} | {
|
|
88
|
+
readonly name: "cli 模板";
|
|
89
|
+
readonly value: "cli";
|
|
90
|
+
})[];
|
|
46
91
|
/**
|
|
47
|
-
*
|
|
92
|
+
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
48
93
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
94
|
+
declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
|
|
95
|
+
/**
|
|
96
|
+
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
97
|
+
*/
|
|
98
|
+
declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/types/workspace.d.ts
|
|
101
|
+
/**
|
|
102
|
+
* 工作区工具可接收的筛选选项。
|
|
103
|
+
*/
|
|
104
|
+
interface GetWorkspacePackagesOptions {
|
|
105
|
+
/**
|
|
106
|
+
* 是否在结果中排除 workspace 根包。
|
|
107
|
+
* @default true
|
|
108
|
+
*/
|
|
109
|
+
ignoreRootPackage?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* 是否过滤掉标记为 `private` 的包。
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
ignorePrivatePackage?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* 自定义 glob,覆盖 `pnpm-workspace.yaml` 的 `packages` 配置。
|
|
117
|
+
* @default workspace manifest `packages`
|
|
118
|
+
*/
|
|
119
|
+
patterns?: string[];
|
|
55
120
|
}
|
|
56
|
-
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/types/config.d.ts
|
|
57
123
|
/**
|
|
58
124
|
* `monorepo new` 命令的配置项,允许外部覆写模板目录、模板清单等。
|
|
59
125
|
*/
|
|
60
126
|
interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
127
|
+
/**
|
|
128
|
+
* 自定义模板根目录。
|
|
129
|
+
* @default 内置模板所在的 `packages/monorepo/templates`
|
|
130
|
+
*/
|
|
131
|
+
templatesDir?: string;
|
|
132
|
+
/**
|
|
133
|
+
* 扩展模板映射表,key 为类型,value 为模板相对路径。
|
|
134
|
+
* @default 内置 `templateMap`
|
|
135
|
+
*/
|
|
136
|
+
templateMap?: Record<string, string>;
|
|
137
|
+
/**
|
|
138
|
+
* 自定义交互提示的选项列表。
|
|
139
|
+
* @default 内置 `baseChoices`
|
|
140
|
+
*/
|
|
141
|
+
choices?: CreateChoiceOption[];
|
|
142
|
+
/**
|
|
143
|
+
* 当未选择模板时使用的默认模板。
|
|
144
|
+
* @default 'unbuild'
|
|
145
|
+
*/
|
|
146
|
+
defaultTemplate?: CreateNewProjectOptions['type'];
|
|
69
147
|
}
|
|
70
148
|
/**
|
|
71
149
|
* CLI 交互式选择框的选项结构。
|
|
72
150
|
*/
|
|
73
151
|
interface CreateChoiceOption {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
152
|
+
/**
|
|
153
|
+
* 唯一值,将回传给命令逻辑使用。
|
|
154
|
+
* @default undefined
|
|
155
|
+
*/
|
|
156
|
+
value: string;
|
|
157
|
+
/**
|
|
158
|
+
* 选项展示名称。
|
|
159
|
+
* @default value
|
|
160
|
+
*/
|
|
161
|
+
name?: string;
|
|
162
|
+
/**
|
|
163
|
+
* 选项描述信息。
|
|
164
|
+
* @default undefined
|
|
165
|
+
*/
|
|
166
|
+
description?: string;
|
|
167
|
+
/**
|
|
168
|
+
* 短名称,用于命令行紧凑展示。
|
|
169
|
+
* @default undefined
|
|
170
|
+
*/
|
|
171
|
+
short?: string;
|
|
172
|
+
/**
|
|
173
|
+
* 设置为 true 或字符串即可禁用该选项并显示原因。
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
disabled?: boolean | string;
|
|
79
177
|
}
|
|
80
178
|
/**
|
|
81
179
|
* `monorepo clean` 命令配置,可控制自动选择、排除包等行为。
|
|
82
180
|
*/
|
|
83
181
|
interface CleanCommandConfig {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
182
|
+
/**
|
|
183
|
+
* 是否跳过交互直接清理全部。
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
autoConfirm?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* 不允许被清理的包名列表。
|
|
189
|
+
* @default []
|
|
190
|
+
*/
|
|
191
|
+
ignorePackages?: string[];
|
|
192
|
+
/**
|
|
193
|
+
* 是否包含 private 包。
|
|
194
|
+
* @default false
|
|
195
|
+
*/
|
|
196
|
+
includePrivate?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* 强制写回的 @icebreakers/monorepo 版本。
|
|
199
|
+
* @default 当前依赖版本
|
|
200
|
+
*/
|
|
201
|
+
pinnedVersion?: string;
|
|
92
202
|
}
|
|
93
203
|
/**
|
|
94
204
|
* `monorepo sync` 命令配置,可覆盖 workspace 过滤规则或同步命令模板。
|
|
95
205
|
*/
|
|
96
206
|
interface SyncCommandConfig extends Partial<GetWorkspacePackagesOptions> {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
207
|
+
/**
|
|
208
|
+
* 并发执行同步命令的最大数量。
|
|
209
|
+
* @default os.cpus().length
|
|
210
|
+
*/
|
|
211
|
+
concurrency?: number;
|
|
212
|
+
/**
|
|
213
|
+
* 自定义执行的同步命令模板,使用 {name} 占位。
|
|
214
|
+
* @default 'cnpm sync {name}'
|
|
215
|
+
*/
|
|
216
|
+
command?: string;
|
|
217
|
+
/**
|
|
218
|
+
* 仅同步指定的包(按名称过滤)。
|
|
219
|
+
* @default 同步全部可见包
|
|
220
|
+
*/
|
|
221
|
+
packages?: string[];
|
|
103
222
|
}
|
|
104
223
|
/**
|
|
105
224
|
* `monorepo upgrade` 命令配置,覆盖脚本、目标文件等能力。
|
|
106
225
|
*/
|
|
107
226
|
interface UpgradeCommandConfig extends Partial<CliOpts> {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
227
|
+
/**
|
|
228
|
+
* 额外需要写入的目标文件列表。
|
|
229
|
+
* @default []
|
|
230
|
+
*/
|
|
231
|
+
targets?: string[];
|
|
232
|
+
/**
|
|
233
|
+
* 是否与默认目标合并,false 表示完全覆盖。
|
|
234
|
+
* @default true
|
|
235
|
+
*/
|
|
236
|
+
mergeTargets?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* 需要写入 package.json 的脚本集合。
|
|
239
|
+
* @default {}
|
|
240
|
+
*/
|
|
241
|
+
scripts?: Record<string, string>;
|
|
242
|
+
/**
|
|
243
|
+
* 是否跳过生成 changeset markdown。
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
246
|
+
skipChangesetMarkdown?: boolean;
|
|
116
247
|
}
|
|
117
248
|
/**
|
|
118
249
|
* `monorepo init` 命令配置,用于跳过部分初始化步骤。
|
|
119
250
|
*/
|
|
120
251
|
interface InitCommandConfig {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
252
|
+
/**
|
|
253
|
+
* 是否跳过 README 生成。
|
|
254
|
+
* @default false
|
|
255
|
+
*/
|
|
256
|
+
skipReadme?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* 是否跳过 package.json 写入。
|
|
259
|
+
* @default false
|
|
260
|
+
*/
|
|
261
|
+
skipPkgJson?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* 是否跳过 changeset 的更新。
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
266
|
+
skipChangeset?: boolean;
|
|
124
267
|
}
|
|
125
268
|
/**
|
|
126
269
|
* `monorepo mirror` 命令配置,可增加额外的环境变量镜像。
|
|
127
270
|
*/
|
|
128
271
|
interface MirrorCommandConfig {
|
|
129
|
-
|
|
272
|
+
/**
|
|
273
|
+
* 需要注入的环境变量键值对。
|
|
274
|
+
* @default {}
|
|
275
|
+
*/
|
|
276
|
+
env?: Record<string, string>;
|
|
130
277
|
}
|
|
131
278
|
/**
|
|
132
279
|
* 项目级配置入口,按命令划分可插拔的配置块。
|
|
133
280
|
*/
|
|
134
281
|
interface MonorepoConfig {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
282
|
+
/**
|
|
283
|
+
* 按命令分类的可选配置。
|
|
284
|
+
* @default {}
|
|
285
|
+
*/
|
|
286
|
+
commands?: {
|
|
287
|
+
create?: CreateCommandConfig;
|
|
288
|
+
clean?: CleanCommandConfig;
|
|
289
|
+
sync?: SyncCommandConfig;
|
|
290
|
+
upgrade?: UpgradeCommandConfig;
|
|
291
|
+
init?: InitCommandConfig;
|
|
292
|
+
mirror?: MirrorCommandConfig;
|
|
293
|
+
};
|
|
143
294
|
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/core/git.d.ts
|
|
144
297
|
/**
|
|
145
|
-
*
|
|
146
|
-
*/
|
|
147
|
-
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
148
|
-
/**
|
|
149
|
-
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
150
|
-
*/
|
|
151
|
-
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
152
|
-
/**
|
|
153
|
-
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
154
|
-
*/
|
|
155
|
-
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* 内置模板映射表,value 指向仓库中对应模板所在路径。
|
|
298
|
+
* 对 simple-git 的轻量封装,集中处理配置缓存与常用查询。
|
|
159
299
|
*/
|
|
160
|
-
declare
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
300
|
+
declare class GitClient {
|
|
301
|
+
#private;
|
|
302
|
+
private readonly client;
|
|
303
|
+
constructor(options?: Partial<SimpleGitOptions>);
|
|
304
|
+
/**
|
|
305
|
+
* 读取 Git 的 config 列表,原样返回 simple-git 的结果。
|
|
306
|
+
*/
|
|
307
|
+
listConfig(): simple_git0.Response<simple_git0.ConfigListSummary>;
|
|
308
|
+
/**
|
|
309
|
+
* 初始化配置缓存,避免多次访问 Git 产生的性能损耗。
|
|
310
|
+
*/
|
|
311
|
+
init(): Promise<ConfigValues>;
|
|
312
|
+
/**
|
|
313
|
+
* 获取缓存的配置,若未初始化则自动触发 init。
|
|
314
|
+
*/
|
|
315
|
+
getConfig(): Promise<ConfigValues>;
|
|
316
|
+
/**
|
|
317
|
+
* 解析 remote.origin.url,返回 git-url-parse 的结构,便于获取仓库元信息。
|
|
318
|
+
*/
|
|
319
|
+
getGitUrl(): Promise<gitUrlParse.GitUrl | undefined>;
|
|
320
|
+
/**
|
|
321
|
+
* 组合 owner/name,生成常用的仓库名表达。
|
|
322
|
+
*/
|
|
323
|
+
getRepoName(): Promise<string | undefined>;
|
|
324
|
+
/**
|
|
325
|
+
* 从 Git 配置中提取用户信息,用于填充 package.json author 字段。
|
|
326
|
+
*/
|
|
327
|
+
getUser(): Promise<{
|
|
328
|
+
name: string;
|
|
329
|
+
email: string;
|
|
330
|
+
}>;
|
|
331
|
+
/**
|
|
332
|
+
* 获取当前仓库的顶层目录路径。
|
|
333
|
+
*/
|
|
334
|
+
getRepoRoot(): Promise<string | undefined>;
|
|
176
335
|
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/core/workspace.d.ts
|
|
177
338
|
/**
|
|
178
|
-
*
|
|
179
|
-
*/
|
|
180
|
-
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
181
|
-
readonly name: "unbuild 打包";
|
|
182
|
-
readonly value: "unbuild";
|
|
183
|
-
} | {
|
|
184
|
-
readonly name: "tsup 打包";
|
|
185
|
-
readonly value: "tsup";
|
|
186
|
-
} | {
|
|
187
|
-
readonly name: "tsdown 打包";
|
|
188
|
-
readonly value: "tsdown";
|
|
189
|
-
} | {
|
|
190
|
-
readonly name: "vue 组件";
|
|
191
|
-
readonly value: "vue-lib";
|
|
192
|
-
} | {
|
|
193
|
-
readonly name: "vue hono 全栈";
|
|
194
|
-
readonly value: "vue-hono";
|
|
195
|
-
} | {
|
|
196
|
-
readonly name: "hono 模板";
|
|
197
|
-
readonly value: "hono-server";
|
|
198
|
-
} | {
|
|
199
|
-
readonly name: "vitepress 文档";
|
|
200
|
-
readonly value: "vitepress";
|
|
201
|
-
} | {
|
|
202
|
-
readonly name: "cli 模板";
|
|
203
|
-
readonly value: "cli";
|
|
204
|
-
})[];
|
|
205
|
-
/**
|
|
206
|
-
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
207
|
-
*/
|
|
208
|
-
declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
|
|
209
|
-
/**
|
|
210
|
-
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
339
|
+
* 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
|
|
211
340
|
*/
|
|
212
|
-
declare function
|
|
213
|
-
|
|
341
|
+
declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
342
|
+
pkgJsonPath: string;
|
|
343
|
+
rootDir: _pnpm_types0.ProjectRootDir;
|
|
344
|
+
rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
|
|
345
|
+
modulesDir?: string;
|
|
346
|
+
manifest: _pnpm_types0.ProjectManifest;
|
|
347
|
+
writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
348
|
+
}[]>;
|
|
214
349
|
/**
|
|
215
|
-
*
|
|
350
|
+
* 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
|
|
216
351
|
*/
|
|
217
|
-
declare
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
*/
|
|
232
|
-
getConfig(): Promise<ConfigValues>;
|
|
233
|
-
/**
|
|
234
|
-
* 解析 remote.origin.url,返回 git-url-parse 的结构,便于获取仓库元信息。
|
|
235
|
-
*/
|
|
236
|
-
getGitUrl(): Promise<gitUrlParse__default.GitUrl | undefined>;
|
|
237
|
-
/**
|
|
238
|
-
* 组合 owner/name,生成常用的仓库名表达。
|
|
239
|
-
*/
|
|
240
|
-
getRepoName(): Promise<string | undefined>;
|
|
241
|
-
/**
|
|
242
|
-
* 从 Git 配置中提取用户信息,用于填充 package.json author 字段。
|
|
243
|
-
*/
|
|
244
|
-
getUser(): Promise<{
|
|
245
|
-
name: string;
|
|
246
|
-
email: string;
|
|
247
|
-
}>;
|
|
248
|
-
/**
|
|
249
|
-
* 获取当前仓库的顶层目录路径。
|
|
250
|
-
*/
|
|
251
|
-
getRepoRoot(): Promise<string | undefined>;
|
|
252
|
-
}
|
|
253
|
-
|
|
352
|
+
declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
353
|
+
cwd: string;
|
|
354
|
+
workspaceDir: string;
|
|
355
|
+
packages: {
|
|
356
|
+
pkgJsonPath: string;
|
|
357
|
+
rootDir: _pnpm_types0.ProjectRootDir;
|
|
358
|
+
rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
|
|
359
|
+
modulesDir?: string;
|
|
360
|
+
manifest: _pnpm_types0.ProjectManifest;
|
|
361
|
+
writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
362
|
+
}[];
|
|
363
|
+
}>;
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/commands/clean.d.ts
|
|
254
366
|
/**
|
|
255
367
|
* 交互式清理被选中的包目录,同时重写根 package.json 中的 @icebreakers/monorepo 版本。
|
|
256
368
|
*/
|
|
257
369
|
declare function cleanProjects(cwd: string): Promise<void>;
|
|
258
|
-
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/commands/init/index.d.ts
|
|
259
372
|
/**
|
|
260
373
|
* 初始化命令入口,根据配置逐步生成基础文件。
|
|
261
374
|
*/
|
|
262
375
|
declare function init(cwd: string): Promise<void>;
|
|
263
|
-
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/commands/mirror/binaryMirror.d.ts
|
|
264
378
|
/**
|
|
265
379
|
* 根据中国大陆镜像源,自动向 VSCode settings.json 注入终端环境变量。
|
|
266
380
|
*/
|
|
267
381
|
declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
|
|
268
|
-
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region src/commands/sync.d.ts
|
|
269
384
|
/**
|
|
270
385
|
* 批量执行 `cnpm sync`(或自定义命令),将所有包同步到 npmmirror。
|
|
271
386
|
*/
|
|
272
387
|
declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOptions): Promise<void>;
|
|
273
|
-
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/commands/upgrade/index.d.ts
|
|
274
390
|
/**
|
|
275
391
|
* 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
|
|
276
392
|
*/
|
|
277
393
|
declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region package.d.ts
|
|
396
|
+
declare let name: string;
|
|
397
|
+
declare let version: string;
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/constants.d.ts
|
|
282
400
|
/**
|
|
283
401
|
* @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
|
|
284
402
|
*/
|
|
@@ -295,47 +413,65 @@ declare const assetsDir: string;
|
|
|
295
413
|
* monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
|
|
296
414
|
*/
|
|
297
415
|
declare const rootDir: string;
|
|
298
|
-
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/core/config.d.ts
|
|
418
|
+
/**
|
|
419
|
+
* 提供类型提示的辅助函数,供外部定义配置时使用。
|
|
420
|
+
*/
|
|
421
|
+
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
422
|
+
/**
|
|
423
|
+
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
424
|
+
*/
|
|
425
|
+
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
426
|
+
/**
|
|
427
|
+
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
428
|
+
*/
|
|
429
|
+
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/core/context.d.ts
|
|
299
432
|
/**
|
|
300
433
|
* 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
|
|
301
434
|
*/
|
|
302
435
|
declare function createContext(cwd: string): Promise<{
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
436
|
+
cwd: string;
|
|
437
|
+
git: GitClient;
|
|
438
|
+
gitUrl: git_url_parse0.GitUrl | undefined;
|
|
439
|
+
gitUser: {
|
|
440
|
+
name: string;
|
|
441
|
+
email: string;
|
|
442
|
+
};
|
|
443
|
+
workspaceDir: string;
|
|
444
|
+
workspaceFilepath: string;
|
|
445
|
+
packages: {
|
|
446
|
+
pkgJsonPath: string;
|
|
447
|
+
rootDir: _pnpm_types0.ProjectRootDir;
|
|
448
|
+
rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
|
|
449
|
+
modulesDir?: string;
|
|
450
|
+
manifest: _pnpm_types0.ProjectManifest;
|
|
451
|
+
writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
452
|
+
}[];
|
|
453
|
+
config: MonorepoConfig;
|
|
321
454
|
}>;
|
|
322
455
|
/**
|
|
323
456
|
* 统一导出的上下文类型,方便下游函数准确获知可用字段。
|
|
324
457
|
*/
|
|
325
458
|
type Context = Awaited<ReturnType<typeof createContext>>;
|
|
326
|
-
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/core/logger.d.ts
|
|
327
461
|
/**
|
|
328
462
|
* 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
|
|
329
463
|
*/
|
|
330
|
-
declare const logger:
|
|
331
|
-
|
|
464
|
+
declare const logger: consola0.ConsolaInstance;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/utils/fs.d.ts
|
|
332
467
|
/**
|
|
333
468
|
* 判断是否为可忽略的文件系统错误。
|
|
334
469
|
* - ENOENT: 文件已被删除
|
|
335
470
|
* - EBUSY: Windows 中资源被系统占用
|
|
336
471
|
*/
|
|
337
472
|
declare function isIgnorableFsError(error: unknown): error is NodeJS.ErrnoException;
|
|
338
|
-
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/utils/gitignore.d.ts
|
|
339
475
|
/**
|
|
340
476
|
* Map a workspace path (containing `.gitignore`) to its packaged variant.
|
|
341
477
|
*/
|
|
@@ -349,7 +485,8 @@ declare function toWorkspaceGitignorePath(input: string): string;
|
|
|
349
485
|
* should be treated as a gitignore file.
|
|
350
486
|
*/
|
|
351
487
|
declare function isGitignoreFile(name: string): boolean;
|
|
352
|
-
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/utils/hash.d.ts
|
|
353
490
|
/**
|
|
354
491
|
* 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
|
|
355
492
|
*/
|
|
@@ -358,7 +495,8 @@ declare function getFileHash(data: crypto.BinaryLike): string;
|
|
|
358
495
|
* 对比两个文件的 md5,如果不一致则认为内容有变化。
|
|
359
496
|
*/
|
|
360
497
|
declare function isFileChanged(src: crypto.BinaryLike, dest: crypto.BinaryLike): boolean;
|
|
361
|
-
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/utils/regexp.d.ts
|
|
362
500
|
/**
|
|
363
501
|
* 逃逸正则表达式中所有特殊字符,避免被当做模式解析。
|
|
364
502
|
*/
|
|
@@ -367,5 +505,5 @@ declare function escapeStringRegexp(str: string): string;
|
|
|
367
505
|
* 判断字符串是否命中任意一个正则,用于过滤要同步的资产文件。
|
|
368
506
|
*/
|
|
369
507
|
declare function isMatch(str: string, arr: RegExp[]): boolean;
|
|
370
|
-
|
|
371
|
-
export { type CleanCommandConfig, type CliOpts, type Context, type CreateChoiceOption, type CreateCommandConfig,
|
|
508
|
+
//#endregion
|
|
509
|
+
export { type CleanCommandConfig, type CliOpts, type ConfigValues, Context, type CreateChoiceOption, type CreateCommandConfig, CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type PackageJson, type SimpleGit, type SimpleGitOptions, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, upgradeMonorepo, version };
|