@infly/libs 2.4.1 → 2.5.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 +469 -459
- package/bin/cli.js +7 -4
- package/build/before-build.js +50 -0
- package/build/docker/docker-build-push.js +8 -3
- package/build/docker/minimal-context.js +32 -1
- package/build/docker/project-install.js +163 -0
- package/build/docker/release-identity.js +22 -0
- package/build/docker/source-snapshot.js +44 -0
- package/build/docker/target-release.js +860 -739
- package/index.d.ts +277 -0
- package/package.json +4 -2
- package/script/git-automation/index.js +828 -858
- package/script/git-automation/root-update.js +31 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @infly/libs TypeScript 类型声明
|
|
3
|
+
*
|
|
4
|
+
* 为框架无关工具库提供基本类型支持,改善消费方的开发体验。
|
|
5
|
+
* 覆盖包根入口和全部显式稳定 sub-path exports。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare module "@infly/libs" {
|
|
9
|
+
/**
|
|
10
|
+
* 初始化 @infly/libs。仅在显式调用时懒加载 Vue 2 适配器。
|
|
11
|
+
* @param projectRoot - 项目根目录路径
|
|
12
|
+
*/
|
|
13
|
+
export function init(projectRoot?: string): void;
|
|
14
|
+
|
|
15
|
+
export const name: "@infly/libs";
|
|
16
|
+
export const framework: "agnostic";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module "@infly/libs/module/Uts.js" {
|
|
20
|
+
/**
|
|
21
|
+
* 通用工具方法聚合对象。
|
|
22
|
+
* 聚合了 @infly/ts-libs 的所有导出,向后兼容 Uts.xxx() 调用方式。
|
|
23
|
+
*/
|
|
24
|
+
const Uts: Record<string, any>;
|
|
25
|
+
export default Uts;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module "@infly/libs/adapters/vue2/module/REST.js" {
|
|
29
|
+
interface RESTConfig {
|
|
30
|
+
baseURL?: string;
|
|
31
|
+
timeout?: number;
|
|
32
|
+
headers?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface RequestConfig {
|
|
36
|
+
params?: Record<string, any>;
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
responseType?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const REST: {
|
|
42
|
+
get<T = any>(url: string, config?: RequestConfig): Promise<T>;
|
|
43
|
+
post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<T>;
|
|
44
|
+
put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<T>;
|
|
45
|
+
delete<T = any>(url: string, config?: RequestConfig): Promise<T>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default REST;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module "@infly/libs/adapters/vue2/module/TokenService.js" {
|
|
52
|
+
interface TokenInfo {
|
|
53
|
+
token: string;
|
|
54
|
+
refreshToken?: string;
|
|
55
|
+
expiresAt?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const TokenService: {
|
|
59
|
+
getToken(): string | null;
|
|
60
|
+
setToken(token: string): void;
|
|
61
|
+
removeToken(): void;
|
|
62
|
+
getRefreshToken(): string | null;
|
|
63
|
+
setRefreshToken(token: string): void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default TokenService;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---- 显式稳定 sub-path exports ----
|
|
70
|
+
|
|
71
|
+
declare module "@infly/libs/build" {
|
|
72
|
+
/** 构建环境标识(如 "prod" / "stage") */
|
|
73
|
+
export const ENV: string;
|
|
74
|
+
|
|
75
|
+
/** 构建上下文环境变量 */
|
|
76
|
+
export function createBuildContext(options?: Record<string, any>): Record<string, any>;
|
|
77
|
+
|
|
78
|
+
/** 解析构建上下文 */
|
|
79
|
+
export function parseBuildContext(options?: Record<string, any>): Record<string, any>;
|
|
80
|
+
|
|
81
|
+
/** 目标发布分支 */
|
|
82
|
+
export function getTargetBranch(packageJson: object, mode: string): string;
|
|
83
|
+
|
|
84
|
+
/** 更新公共包源码 */
|
|
85
|
+
export function updatePackageSources(rootDir: string, packages: any[], targetBranch: string): void;
|
|
86
|
+
|
|
87
|
+
/** 更新应用与 dist 仓库源码 */
|
|
88
|
+
export function updateAppAndDistSources(rootDir: string, packages: any[], targetBranch: string): void;
|
|
89
|
+
|
|
90
|
+
/** 更新全部源码 */
|
|
91
|
+
export function updateAllSources(rootDir: string, packages: any[], targetBranch: string): void;
|
|
92
|
+
|
|
93
|
+
/** dist 仓库任务清单 */
|
|
94
|
+
export function getDistRepoTasks(rootDir: string, packages: any[]): any[];
|
|
95
|
+
|
|
96
|
+
/** 打印 dry-run 源码更新计划 */
|
|
97
|
+
export function printDryRunSourceUpdatePlan(rootDir: string, packages: any[], targetBranch: string): void;
|
|
98
|
+
|
|
99
|
+
/** 批量 webhook 通知 */
|
|
100
|
+
export function postBatchWebhook(rootDir: string, options?: Record<string, any>): Promise<void>;
|
|
101
|
+
|
|
102
|
+
/** 启动批量预览 */
|
|
103
|
+
export function startBatchPreviews(rootDir: string, packages: any[], options?: Record<string, any>): Promise<any>;
|
|
104
|
+
|
|
105
|
+
/** 执行命令 */
|
|
106
|
+
export function run(command: string, args: string[], options?: Record<string, any>): Promise<void>;
|
|
107
|
+
|
|
108
|
+
/** 后台启动命令 */
|
|
109
|
+
export function spawnBackground(command: string, args: string[], options?: Record<string, any>): unknown;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare module "@infly/libs/concurrency" {
|
|
113
|
+
/**
|
|
114
|
+
* 并发限流执行器。
|
|
115
|
+
* @param items - 待处理项
|
|
116
|
+
* @param concurrency - 最大并发数
|
|
117
|
+
* @param worker - 单项处理函数
|
|
118
|
+
*/
|
|
119
|
+
export function runWithConcurrency<T>(
|
|
120
|
+
items: readonly T[],
|
|
121
|
+
concurrency: number,
|
|
122
|
+
worker: (item: T, index: number) => Promise<void> | void,
|
|
123
|
+
): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare module "@infly/libs/progress" {
|
|
127
|
+
interface ProgressLineOptions {
|
|
128
|
+
label: string;
|
|
129
|
+
completed: number;
|
|
130
|
+
total: number;
|
|
131
|
+
path?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function formatProgressLine(options: ProgressLineOptions): string;
|
|
135
|
+
|
|
136
|
+
export function createProgressReporter(options?: Record<string, any>): {
|
|
137
|
+
start(message: string, total: number): void;
|
|
138
|
+
update(done: number, message?: string): void;
|
|
139
|
+
finish(message?: string): void;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export function formatSwitchSummary(
|
|
143
|
+
name: string,
|
|
144
|
+
totalMs: number,
|
|
145
|
+
dependencyResult: unknown,
|
|
146
|
+
timings?: unknown,
|
|
147
|
+
): string;
|
|
148
|
+
|
|
149
|
+
export function formatSlowStatusDetails(details: unknown, thresholdMs?: number): string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare module "@infly/libs/npm-release" {
|
|
153
|
+
/** 解析稳定版本号,返回 [major, minor, patch] */
|
|
154
|
+
export function parseStableVersion(version: string): number[];
|
|
155
|
+
|
|
156
|
+
/** patch +1 */
|
|
157
|
+
export function bumpPatch(version: string): string;
|
|
158
|
+
|
|
159
|
+
/** 比较两个稳定版本号:左 > 右返回 1,相等返回 0,否则 -1 */
|
|
160
|
+
export function compareVersions(left: string, right: string): number;
|
|
161
|
+
|
|
162
|
+
/** 生成发布计划(含 registry 版本核对与目标版本计算;registryVersions 中为 null 表示从未发布的首次发布) */
|
|
163
|
+
export function buildReleasePlan(
|
|
164
|
+
packages: any[],
|
|
165
|
+
registryVersions: Record<string, string | null>,
|
|
166
|
+
options?: { prepared?: boolean },
|
|
167
|
+
): any[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare module "@infly/libs/workspace-packages" {
|
|
171
|
+
export const DEPENDENCY_SECTIONS: string[];
|
|
172
|
+
|
|
173
|
+
export function normalizeWorkspacePath(filePath: string): string;
|
|
174
|
+
|
|
175
|
+
/** 发现 workspace 包 */
|
|
176
|
+
export function discoverWorkspacePackages(rootDir: string, options?: Record<string, any>): any[];
|
|
177
|
+
|
|
178
|
+
/** 包内部依赖名集合 */
|
|
179
|
+
export function getInternalDependencies(pkg: object, packageNames: string[]): string[];
|
|
180
|
+
|
|
181
|
+
/** 按变更路径计算受影响包(含反向 workspace 依赖方) */
|
|
182
|
+
export function selectAffectedWorkspacePackages(
|
|
183
|
+
changedPaths: string[],
|
|
184
|
+
packages: any[],
|
|
185
|
+
options?: Record<string, any>,
|
|
186
|
+
): any[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare module "@infly/libs/workspace-config" {
|
|
190
|
+
export function readJson(filePath: string): any;
|
|
191
|
+
|
|
192
|
+
export function readWorkspaceList(content: string, sectionName: string): string[];
|
|
193
|
+
|
|
194
|
+
export function readWorkspaceSection(workspaceFile: string, sectionName: string): string[];
|
|
195
|
+
|
|
196
|
+
export function readWorkspaceSectionWithFallback(
|
|
197
|
+
workspaceFile: string,
|
|
198
|
+
sectionName: string,
|
|
199
|
+
fallbackSectionName: string,
|
|
200
|
+
): string[];
|
|
201
|
+
|
|
202
|
+
export function expandWorkspacePattern(rootDir: string, pattern: string): string[];
|
|
203
|
+
|
|
204
|
+
export function getWorkspacePackages(
|
|
205
|
+
rootDir: string,
|
|
206
|
+
workspaceFile: string,
|
|
207
|
+
sectionName?: string,
|
|
208
|
+
fallbackSectionName?: string,
|
|
209
|
+
scriptName?: string,
|
|
210
|
+
): any[];
|
|
211
|
+
|
|
212
|
+
export function toTurboFilter(value: unknown): string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
declare module "@infly/libs/cli/project-command" {
|
|
216
|
+
export function loadConfig(cwd?: string): { config: object; configDir: string };
|
|
217
|
+
|
|
218
|
+
export function resolveBuildPlatforms(targets: unknown, buildConfig: object, targetName: string): string[];
|
|
219
|
+
|
|
220
|
+
export function runProjectCommand(options?: Record<string, any>, dependencies?: Record<string, any>): Promise<object>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare module "@infly/libs/cli/select-option" {
|
|
224
|
+
/** 用户选择退出(取消)的哨兵值 */
|
|
225
|
+
export const EXIT_SELECTION: string;
|
|
226
|
+
|
|
227
|
+
export function makePromptCancellationSafe<T>(prompt: () => Promise<T>): Promise<T>;
|
|
228
|
+
|
|
229
|
+
export function selectOption(
|
|
230
|
+
message: string,
|
|
231
|
+
choices: Array<{ value: string; label?: string }>,
|
|
232
|
+
dependencies?: Record<string, any>,
|
|
233
|
+
): Promise<string>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare module "@infly/libs/adapters/webpack/auto-export" {
|
|
237
|
+
/** 自动收集 require.context 下的文件导出 */
|
|
238
|
+
export function autoExportFiles(requireContext: unknown): Record<string, unknown>;
|
|
239
|
+
|
|
240
|
+
/** 将收集到的导出合并到目标对象 */
|
|
241
|
+
export function autoExportToModule(requireContext: unknown, targetExports: object): void;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare module "@infly/libs/git/configure" {
|
|
245
|
+
export function configureMergeDriver(): void;
|
|
246
|
+
|
|
247
|
+
export function configureGitAliases(): void;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
declare module "@infly/libs/git/submodule-status" {
|
|
251
|
+
interface SubmoduleInfo {
|
|
252
|
+
name: string;
|
|
253
|
+
path: string;
|
|
254
|
+
configuredBranch: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function runGit(cwd: string, args: string[], options?: { allowFailure?: boolean }): string;
|
|
258
|
+
|
|
259
|
+
export function getConfiguredSubmodules(rootDir: string): SubmoduleInfo[];
|
|
260
|
+
|
|
261
|
+
export function getParentPointer(rootDir: string, submodulePath: string): string;
|
|
262
|
+
|
|
263
|
+
export function inspectSubmodule(rootDir: string, submodule: SubmoduleInfo): {
|
|
264
|
+
path: string;
|
|
265
|
+
branch: string;
|
|
266
|
+
head: string;
|
|
267
|
+
pointer: string;
|
|
268
|
+
originMaster: string;
|
|
269
|
+
state: string;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
declare module "@infly/libs/git/submodules" {
|
|
274
|
+
export function normalizeRelativePath(value: string): string;
|
|
275
|
+
|
|
276
|
+
export function parseGitmodulesPaths(rootDir: string): string[];
|
|
277
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infly/libs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "不受前端框架限制的独立工具库",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
9
|
+
"index.d.ts",
|
|
9
10
|
"bin/",
|
|
10
11
|
"compat/",
|
|
11
12
|
"core/",
|
|
@@ -82,7 +83,8 @@
|
|
|
82
83
|
"vitest": "^4.0.0",
|
|
83
84
|
"eslint": "^9.0.0",
|
|
84
85
|
"@eslint/js": "^9.0.0",
|
|
85
|
-
"globals": "^15.0.0"
|
|
86
|
+
"globals": "^15.0.0",
|
|
87
|
+
"@vitest/coverage-v8": "4.1.10"
|
|
86
88
|
},
|
|
87
89
|
"peerDependencies": {
|
|
88
90
|
"axios": "^0.27.2",
|