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