@done-coding/cli-utils 0.7.0-alpha.0 → 0.7.1-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-utils",
3
- "version": "0.7.0-alpha.0",
3
+ "version": "0.7.1-alpha.0",
4
4
  "description": "cli utils",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -67,5 +67,5 @@
67
67
  "semver": "^7.5.4",
68
68
  "yargs": "^17.7.2"
69
69
  },
70
- "gitHead": "ff1616738586a268b50f46dce762774fa5fa6d52"
70
+ "gitHead": "3376f5fbbf8b87c791316e76df06028afd650e08"
71
71
  }
package/types/index.d.ts CHANGED
@@ -1,14 +1,520 @@
1
- export * from "./log";
2
- export * from "./look-for";
3
- export * from "./aes";
4
- export * from "./prompts";
5
- export * from "./cli";
6
- export * from "./editor";
7
- export * from "./config-file";
8
- export * from "./json5";
9
- export * from "./lodash";
10
- export * from "./package-json";
11
- export * from "./git";
12
- export * from "./husky";
13
- export * from "./file-operate";
14
- export * from "./cli-config";
1
+ import type { ArgumentsCamelCase } from 'yargs';
2
+ import chalk from 'chalk';
3
+ import type { CommandModule } from 'yargs';
4
+ import _curry from 'lodash.curry';
5
+ import _get from 'lodash.get';
6
+ import json5 from 'json5';
7
+ import { Answers as PromptAnswers } from 'prompts';
8
+ import { Choice as PromptChoice } from 'prompts';
9
+ import { Falsy as PromptFalsy } from 'prompts';
10
+ import { InitialReturnValue as PromptInitialReturnValue } from 'prompts';
11
+ import { PromptObject } from 'prompts';
12
+ import { Options as PromptOptions } from 'prompts';
13
+ import { PrevCaller as PromptPrevCaller } from 'prompts';
14
+ import prompts from 'prompts';
15
+ import { PromptType } from 'prompts';
16
+ import { ValueOrFunc as PromptValueOrFunc } from 'prompts';
17
+ import _set from 'lodash.set';
18
+ import yargs from 'yargs';
19
+ import type { Argv as YargsArgv } from 'yargs';
20
+ import type { Options as YargsOptions } from 'yargs';
21
+
22
+ /** 添加 husky hooks */
23
+ export declare const addHuskyHooks: <H extends string>({ hookNames, rootDir, getCode, }: {
24
+ hookNames: H[];
25
+ /** 运行目录 */
26
+ rootDir: string;
27
+ /** 获取husky hooks 添加的代码 */
28
+ getCode: (hook: string) => string;
29
+ }) => void;
30
+
31
+ /** 添加package.json配置 */
32
+ export declare const addPackageConfig: ({ patchConfig, rootDir, }: {
33
+ patchConfig?: Record<string, any> | undefined;
34
+ rootDir: string;
35
+ }) => void;
36
+
37
+ export { ArgumentsCamelCase }
38
+
39
+ export { chalk }
40
+
41
+ /** 检测当前正在变基 */
42
+ export declare const checkCurrentIsRebasing: (rootDir: string) => boolean;
43
+
44
+ /** 处理函数参数类型 */
45
+ export declare type CliHandlerArgv<O> = ArgumentsCamelCase<O> | O;
46
+
47
+ /** cli 信息 */
48
+ export declare interface CliInfo {
49
+ /** 命令 */
50
+ command?: string;
51
+ /** 用法 */
52
+ usage?: string;
53
+ /** 描述信息 */
54
+ describe?: string;
55
+ /** 版本号 */
56
+ version?: string;
57
+ /** 必传命令数 */
58
+ demandCommandCount?: number;
59
+ /** 选项 */
60
+ options?: {
61
+ [key in string]: YargsOptions;
62
+ };
63
+ /** 子命令 */
64
+ subcommands?: CommandModule[];
65
+ /** 位置信息 */
66
+ positionals?: {
67
+ [key in string]: Parameters<typeof yargs.positional>[1];
68
+ };
69
+ /** 处理函数 */
70
+ handler?: CommandModule["handler"];
71
+ }
72
+
73
+ export { CommandModule }
74
+
75
+ /** 配置文件通用选项 */
76
+ export declare interface ConfigFileCommonOptions {
77
+ /**
78
+ * 相对于路径
79
+ * ---
80
+ * 绝对路径 path.resolve(rootDir, configPath)
81
+ */
82
+ configPath: string;
83
+ /** 项目根目录 */
84
+ rootDir: string;
85
+ }
86
+
87
+ /** 创建主命令 */
88
+ export declare const createMainCommand: ({ handler, ...config }: CliInfo) => Promise<void | {
89
+ [x: string]: unknown;
90
+ _: (string | number)[];
91
+ $0: string;
92
+ }>;
93
+
94
+ /** 创建子命令模块 */
95
+ export declare const createSubcommand: (cliInfo: SubCliInfo) => CommandModule;
96
+
97
+ export { _curry }
98
+
99
+ /** AES 解密 */
100
+ export declare function decryptAES({ encryptedText, secretKey, }: {
101
+ encryptedText: string;
102
+ secretKey: string;
103
+ }): string;
104
+
105
+ /** 编辑器类型枚举 */
106
+ export declare enum EditorTypeEnum {
107
+ /** vscode */
108
+ VSCODE = "VsCode",
109
+ /** cursor */
110
+ CURSOR = "Cursor",
111
+ /** 其他编辑器 */
112
+ OTHER = "\u5176\u4ED6"
113
+ }
114
+
115
+ /** AES 加密 */
116
+ export declare function encryptAES({ text, secretKey, }: {
117
+ text: string;
118
+ secretKey: string;
119
+ }): string;
120
+
121
+ /** 文件添加执行权限 */
122
+ export declare const fileAddX: (filePath: string) => void;
123
+
124
+ export { _get }
125
+
126
+ /** 根据hookName获取(将)提交的信息 */
127
+ export declare const getCommitByHookName: ({ hookName, rootDir, }: {
128
+ hookName: SupportGetCommitByHookName;
129
+ rootDir: string;
130
+ }) => string;
131
+
132
+ /** 获取配置文件通用选项 */
133
+ export declare const getConfigFileCommonOptions: ({ configPathDefault, rootDirDefault, }: {
134
+ configPathDefault: string;
135
+ rootDirDefault?: string | undefined;
136
+ }) => Record<keyof ConfigFileCommonOptions, YargsOptions>;
137
+
138
+ /** 获取当前分支最近提交列表 */
139
+ export declare const getCurrentBranchLastCommitList: ({ count, }?: {
140
+ count?: number | undefined;
141
+ /** 某个hash之后的提交 */
142
+ afterHash?: string | undefined;
143
+ }) => GitLogItemInfo[];
144
+
145
+ /** 获取当前分支名 */
146
+ export declare const getCurrentBranchName: () => string | undefined;
147
+
148
+ /** 获取编辑器类型 */
149
+ export declare const getEditorType: () => Promise<any>;
150
+
151
+ /**
152
+ * 获取git 最后提交信息
153
+ */
154
+ export declare const getGitLastCommitInfo: ({ remoteAlias, }?: GetGitLastCommitParams) => GitLastCommitInfo;
155
+
156
+ /** 获取git最好提交信息参数 */
157
+ export declare interface GetGitLastCommitParams {
158
+ /**
159
+ * 远程仓库别名
160
+ */
161
+ remoteAlias?: GitRemoteInfo["alias"];
162
+ }
163
+
164
+ /** 获取git项目目录 */
165
+ export declare const getGitProjectDir: (rootDir: string) => string;
166
+
167
+ /** 获取最后的reflog */
168
+ export declare const getLastReflogList: ({ count, filterItem, }?: {
169
+ count?: number | undefined;
170
+ /** 某个hash之后的提交 */
171
+ afterHash?: string | undefined;
172
+ /** 过滤函数 */
173
+ filterItem?: ((item: GitReflogItemInfoRaw) => boolean) | undefined;
174
+ }) => GitReflogItemInfo[];
175
+
176
+ /** 获取package.json文件内容 */
177
+ export declare const getPackageJson: <R extends PackageJson>({ rootDir, }: {
178
+ rootDir: string;
179
+ }) => R;
180
+
181
+ /** 获取依赖包版本 */
182
+ export declare const getRelyPkgVersion: <R extends PackageJson>({ rootDir, pkgJson, pkgName, isDevPkg, }: {
183
+ rootDir: string;
184
+ pkgJson?: R | undefined;
185
+ pkgName: string;
186
+ /** 是开发依赖包 */
187
+ isDevPkg: boolean;
188
+ }) => string | undefined;
189
+
190
+ /** 获取 rootDir 选项 */
191
+ export declare const getRootDirOptions: (rootDirDefault?: string) => {
192
+ rootDir: YargsOptions;
193
+ };
194
+
195
+ /** 获取是否使用默认配置 */
196
+ export declare const getUseDefaultConfig: () => Promise<any>;
197
+
198
+ /** git checkout信息 */
199
+ export declare interface GitCheckoutInfo {
200
+ fromBranch: string;
201
+ toBranch: string;
202
+ }
203
+
204
+ /**
205
+ * git最后提交信息
206
+ */
207
+ export declare interface GitLastCommitInfo {
208
+ /**
209
+ * 最后一次提交hash值
210
+ */
211
+ lastHash: string;
212
+ /**
213
+ * 最后一次提交者
214
+ */
215
+ lastCommitter: string;
216
+ /**
217
+ * 最后一次提交者拼音
218
+ */
219
+ lastCommitterPinYin: string;
220
+ /**
221
+ * 最后一次提交者邮箱
222
+ */
223
+ lastCommitEmail: string;
224
+ /**
225
+ * 最后一次提交信息
226
+ */
227
+ lastCommitMsg: string;
228
+ /**
229
+ * 用户名
230
+ */
231
+ userName: string;
232
+ /**
233
+ * 用户名拼音
234
+ */
235
+ userNamePinYin: string;
236
+ /**
237
+ * 邮箱
238
+ */
239
+ userEmail: string;
240
+ /**
241
+ * 分知名
242
+ */
243
+ branchName: string;
244
+ /** 远程仓库信息 */
245
+ remoteInfo?: GitRemoteInfo;
246
+ }
247
+
248
+ /** git日志通用信息 */
249
+ export declare interface GitLogCommonInfo {
250
+ hash: string;
251
+ /** 提交信息 */
252
+ message: string;
253
+ /** 合并信息 */
254
+ mergeInfo?: GitMergeBranchInfo;
255
+ }
256
+
257
+ export declare interface GitLogItemInfo extends GitLogCommonInfo {
258
+ /** 作者 */
259
+ author: string;
260
+ /** 作者邮箱 */
261
+ authorEmail: string;
262
+ /** 创作日期 */
263
+ createDate: string;
264
+ /** 提交者 */
265
+ committer: string;
266
+ /** 提交者邮箱 */
267
+ committerEmail: string;
268
+ /** 提交时间 */
269
+ commitTime: string;
270
+ }
271
+
272
+ /** git合并分支信息 */
273
+ export declare interface GitMergeBranchInfo {
274
+ /** 合并的源分支 */
275
+ fromBranch: string;
276
+ /** 合并到该分支 */
277
+ toBranch?: string;
278
+ }
279
+
280
+ export declare interface GitRebaseInfo {
281
+ /** rebase的阶段 */
282
+ stage?: GitRefLogRebaseStage;
283
+ /** 变基的原始分支 */
284
+ originBranch: string;
285
+ /** 变基的目标分支 */
286
+ targetBranch: string;
287
+ }
288
+
289
+ /** reflog信息 */
290
+ export declare interface GitReflogItemInfo extends Omit<GitReflogItemInfoRaw, "fullMessage">, Pick<GitLogCommonInfo, "message"> {
291
+ type: GitRefLogTypeEnum;
292
+ }
293
+
294
+ /** 提交日志信息 */
295
+ export declare interface GitReflogItemInfoRaw extends Omit<GitLogCommonInfo, "message"> {
296
+ hash: string;
297
+ /** 完整信息 */
298
+ fullMessage: string;
299
+ /** 提交者 */
300
+ committer: string;
301
+ /** 提交者邮箱 */
302
+ committerEmail: string;
303
+ /** 提交时间 */
304
+ commitTime: string;
305
+ }
306
+
307
+ /** rebase的阶段 */
308
+ export declare type GitRefLogRebaseStage = GitRefLogTypeEnum.REBASE_START | GitRefLogTypeEnum.REBASE_FINISH | GitRefLogTypeEnum.REBASE_ABORT | GitRefLogTypeEnum.REBASE_CONTINUE;
309
+
310
+ /** reflog类型 */
311
+ export declare enum GitRefLogTypeEnum {
312
+ /** checkout */
313
+ CHECKOUT = "checkout",
314
+ /** merge $branch */
315
+ MERGE = "merge",
316
+ /** 提交 */
317
+ COMMIT = "commit",
318
+ /** 合并提交 */
319
+ COMMIT_MERGE = "commit (merge)",
320
+ /** pull $origin $branch */
321
+ PULL = "pull",
322
+ /** reset */
323
+ RESET = "reset",
324
+ /** rebase (start) */
325
+ REBASE_START = "rebase (start)",
326
+ /** rebase (finish) */
327
+ REBASE_FINISH = "rebase (finish)",
328
+ /** rebase (abort) */
329
+ REBASE_ABORT = "rebase (abort)",
330
+ /** rebase (continue) */
331
+ REBASE_CONTINUE = "rebase (continue)"
332
+ }
333
+
334
+ /** 远程仓库信息 */
335
+ export declare interface GitRemoteInfo {
336
+ /**
337
+ * 远程仓库别名
338
+ */
339
+ alias?: string;
340
+ /**
341
+ * 仓库地址
342
+ */
343
+ url?: string;
344
+ }
345
+
346
+ export declare enum HooksNameEnum {
347
+ /** 预提交 */
348
+ PRE_COMMIT = "pre-commit",
349
+ /** 预合并提交 */
350
+ PRE_MERGE_COMMIT = "pre-merge-commit",
351
+ /** 准备提交信息 */
352
+ PREPARE_COMMIT_MSG = "prepare-commit-msg",
353
+ /** 提交消息 */
354
+ COMMIT_MSG = "commit-msg",
355
+ /** 变基前 */
356
+ PRE_REBASE = "pre-rebase",
357
+ /** 提交后 */
358
+ POST_COMMIT = "post-commit",
359
+ /** 合并后 */
360
+ POST_MERGE = "post-merge",
361
+ /** 推送前 */
362
+ PRE_PUSH = "pre-push"
363
+ }
364
+
365
+ /** 初始化配置文件 */
366
+ export declare const initConfigFile: <T>(content: T, argv: CliHandlerArgv<InitConfigFileOptions>) => Promise<string>;
367
+
368
+ /** 初始化文件选项 */
369
+ export declare type InitConfigFileOptions = ConfigFileCommonOptions;
370
+
371
+ /** 初始化配置文件通用处理器 */
372
+ export declare const initHandlerCommon: <T>(content: T, argv: CliHandlerArgv<InitConfigFileOptions>, { onFileGenerated, edit, }?: {
373
+ /** 文件已生成 */
374
+ onFileGenerated?: ((path: string) => void) | undefined;
375
+ edit?: boolean | undefined;
376
+ }) => Promise<void>;
377
+
378
+ export { json5 }
379
+
380
+ /** 日志 */
381
+ export declare const log: ((type: LogTypeEnum, ...messages: string[]) => void) & {
382
+ /** 成功 */
383
+ success: (...messages: string[]) => void;
384
+ /** /步骤 */
385
+ stage: (...messages: string[]) => void;
386
+ /** 提示信息 */
387
+ info: (...messages: string[]) => void;
388
+ /** 警告 */
389
+ warn: (...messages: string[]) => void;
390
+ /** 错误 */
391
+ error: (...messages: string[]) => void;
392
+ /** 跳过 */
393
+ skip: (...messages: string[]) => void;
394
+ };
395
+
396
+ /** 日志类型 */
397
+ declare enum LogTypeEnum {
398
+ /** 成功 */
399
+ SUCCESS = "green",
400
+ /** 步骤 */
401
+ STAGE = "blue",
402
+ /** 提示信息 */
403
+ INFO = "cyan",
404
+ /** 警告 */
405
+ WARN = "yellow",
406
+ /** 错误 */
407
+ ERROR = "red",
408
+ /** 跳过 */
409
+ SKIP = "gray"
410
+ }
411
+
412
+ /**
413
+ * 查找目标文件或目录
414
+ */
415
+ export declare const lookForParentTarget: (target: string, { currentDir, isFindFarthest, }?: {
416
+ currentDir?: string | undefined;
417
+ isFindFarthest?: boolean | undefined;
418
+ }) => string | undefined;
419
+
420
+ /** 用编辑器打开文件 */
421
+ export declare const openFileInEditor: (path: string, editorType: EditorTypeEnum) => void;
422
+
423
+ /** package.json文件内容 */
424
+ export declare interface PackageJson {
425
+ name: string;
426
+ version?: string;
427
+ bin?: Record<string, string> | string;
428
+ scripts?: Record<string, string>;
429
+ files?: string[];
430
+ dependencies?: Record<string, string>;
431
+ devDependencies?: Record<string, string>;
432
+ peerDependencies?: Record<string, string>;
433
+ }
434
+
435
+ export { PromptAnswers }
436
+
437
+ export { PromptChoice }
438
+
439
+ export { PromptFalsy }
440
+
441
+ export { PromptInitialReturnValue }
442
+
443
+ export { PromptObject }
444
+
445
+ export { PromptOptions }
446
+
447
+ export { PromptPrevCaller }
448
+
449
+ export { PromptType }
450
+
451
+ export { PromptValueOrFunc }
452
+
453
+ /** 推送git发布信息到远程仓库 */
454
+ export declare const pushGitPublishInfoToRemote: ({ branchName, version, remoteInfo, }: {
455
+ branchName: string;
456
+ version: string;
457
+ remoteInfo?: GitRemoteInfo | undefined;
458
+ }) => void;
459
+
460
+ /** 读取配置 */
461
+ export declare const readCliConfig: <R>({ moduleName, onSuccess, }: {
462
+ moduleName: string;
463
+ onSuccess: (params: {
464
+ repoUrl: string;
465
+ /** 配置文件相对路径 */
466
+ cliConfigFileRelativePath: string;
467
+ /** 配置文件目录相对路径 */
468
+ cliConfigDirRelativePath: string;
469
+ /** 配置文件内容 */
470
+ config: R;
471
+ /** 配置临时目录 */
472
+ configTemporaryDir: string;
473
+ }) => void | Promise<void>;
474
+ }) => Promise<R>;
475
+
476
+ /** 读取配置文件 */
477
+ export declare const readConfigFile: <T>(options: ReadConfigFileOptions, onNotExists?: (() => T) | undefined) => Promise<T>;
478
+
479
+ /** 读取配置文件选项 */
480
+ export declare type ReadConfigFileOptions = ConfigFileCommonOptions;
481
+
482
+ /** 解析checkoutInfo */
483
+ export declare const resolveCheckoutInfoByRefInfo: (message: string) => {
484
+ fromBranch: string;
485
+ toBranch: string;
486
+ } | undefined;
487
+
488
+ /** 解析合并信息-通过提交信息 */
489
+ export declare const resolveMergeInfoByCommitMsg: (commitMsg?: string) => GitMergeBranchInfo | undefined;
490
+
491
+ /** 从reflog action解析合并信息 */
492
+ export declare const resolveMergeInfoByGitReflogAction: () => GitMergeBranchInfo | undefined;
493
+
494
+ /** 从reflog type解析合并信息 */
495
+ export declare const resolveMergeInfoByRefType: (type: string) => GitMergeBranchInfo | undefined;
496
+
497
+ export { _set }
498
+
499
+ /** 子cli信息 */
500
+ export declare interface SubCliInfo extends CliInfo {
501
+ /** 命令 */
502
+ command: string;
503
+ }
504
+
505
+ /** 支持通过提交钩子获取提交信息的 */
506
+ export declare const SUPPORT_GET_COMMIT_BY_HOOKS_NAMES: readonly [HooksNameEnum.PREPARE_COMMIT_MSG, HooksNameEnum.COMMIT_MSG];
507
+
508
+ export declare type SupportGetCommitByHookName = (typeof SUPPORT_GET_COMMIT_BY_HOOKS_NAMES)[number];
509
+
510
+ /** prompts 拓展 */
511
+ export declare const xPrompts: (questions: prompts.PromptObject<string> | prompts.PromptObject<string>[], options?: prompts.Options | undefined) => Promise<prompts.Answers<string>>;
512
+
513
+ export { YargsArgv }
514
+
515
+ export { YargsOptions }
516
+
517
+
518
+ export * from "json5";
519
+
520
+ export { }
package/types/aes.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /** AES 加密 */
2
- export declare function encryptAES({ text, secretKey, }: {
3
- text: string;
4
- secretKey: string;
5
- }): string;
6
- /** AES 解密 */
7
- export declare function decryptAES({ encryptedText, secretKey, }: {
8
- encryptedText: string;
9
- secretKey: string;
10
- }): string;
@@ -1,15 +0,0 @@
1
- /** 读取配置 */
2
- export declare const readCliConfig: <R>({ moduleName, onSuccess, }: {
3
- moduleName: string;
4
- onSuccess: (params: {
5
- repoUrl: string;
6
- /** 配置文件相对路径 */
7
- cliConfigFileRelativePath: string;
8
- /** 配置文件目录相对路径 */
9
- cliConfigDirRelativePath: string;
10
- /** 配置文件内容 */
11
- config: R;
12
- /** 配置临时目录 */
13
- configTemporaryDir: string;
14
- }) => void | Promise<void>;
15
- }) => Promise<R>;
package/types/cli.d.ts DELETED
@@ -1,43 +0,0 @@
1
- import type { ArgumentsCamelCase, CommandModule, Options as YargsOptions, Argv as YargsArgv } from "yargs";
2
- import yargs from "yargs";
3
- export { ArgumentsCamelCase, CommandModule, YargsOptions, YargsArgv };
4
- /** cli 信息 */
5
- export interface CliInfo {
6
- /** 命令 */
7
- command?: string;
8
- /** 用法 */
9
- usage?: string;
10
- /** 描述信息 */
11
- describe?: string;
12
- /** 版本号 */
13
- version?: string;
14
- /** 必传命令数 */
15
- demandCommandCount?: number;
16
- /** 选项 */
17
- options?: {
18
- [key in string]: YargsOptions;
19
- };
20
- /** 子命令 */
21
- subcommands?: CommandModule[];
22
- /** 位置信息 */
23
- positionals?: {
24
- [key in string]: Parameters<typeof yargs.positional>[1];
25
- };
26
- /** 处理函数 */
27
- handler?: CommandModule["handler"];
28
- }
29
- /** 子cli信息 */
30
- export interface SubCliInfo extends CliInfo {
31
- /** 命令 */
32
- command: string;
33
- }
34
- /** 处理函数参数类型 */
35
- export type CliHandlerArgv<O> = ArgumentsCamelCase<O> | O;
36
- /** 创建主命令 */
37
- export declare const createMainCommand: ({ handler, ...config }: CliInfo) => Promise<void | {
38
- [x: string]: unknown;
39
- _: (string | number)[];
40
- $0: string;
41
- }>;
42
- /** 创建子命令模块 */
43
- export declare const createSubcommand: (cliInfo: SubCliInfo) => CommandModule;
@@ -1,37 +0,0 @@
1
- import type { CliHandlerArgv, YargsOptions } from "./cli";
2
- /** 配置文件通用选项 */
3
- export interface ConfigFileCommonOptions {
4
- /**
5
- * 相对于路径
6
- * ---
7
- * 绝对路径 path.resolve(rootDir, configPath)
8
- */
9
- configPath: string;
10
- /** 项目根目录 */
11
- rootDir: string;
12
- }
13
- /** 初始化文件选项 */
14
- export type InitConfigFileOptions = ConfigFileCommonOptions;
15
- /** 读取配置文件选项 */
16
- export type ReadConfigFileOptions = ConfigFileCommonOptions;
17
- /** 获取 rootDir 选项 */
18
- export declare const getRootDirOptions: (rootDirDefault?: string) => {
19
- rootDir: YargsOptions;
20
- };
21
- /** 获取配置文件通用选项 */
22
- export declare const getConfigFileCommonOptions: ({ configPathDefault, rootDirDefault, }: {
23
- configPathDefault: string;
24
- rootDirDefault?: string | undefined;
25
- }) => Record<keyof ConfigFileCommonOptions, YargsOptions>;
26
- /** 初始化配置文件 */
27
- export declare const initConfigFile: <T>(content: T, argv: CliHandlerArgv<InitConfigFileOptions>) => Promise<string>;
28
- /** 初始化配置文件通用处理器 */
29
- export declare const initHandlerCommon: <T>(content: T, argv: CliHandlerArgv<InitConfigFileOptions>, { onFileGenerated, edit, }?: {
30
- /** 文件已生成 */
31
- onFileGenerated?: ((path: string) => void) | undefined;
32
- edit?: boolean | undefined;
33
- }) => Promise<void>;
34
- /** 读取配置文件 */
35
- export declare const readConfigFile: <T>(options: ReadConfigFileOptions, onNotExists?: (() => T) | undefined) => Promise<T>;
36
- /** 获取是否使用默认配置 */
37
- export declare const getUseDefaultConfig: () => Promise<any>;
package/types/editor.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /** 编辑器类型枚举 */
2
- export declare enum EditorTypeEnum {
3
- /** vscode */
4
- VSCODE = "VsCode",
5
- /** cursor */
6
- CURSOR = "Cursor",
7
- /** 其他编辑器 */
8
- OTHER = "\u5176\u4ED6"
9
- }
10
- /** 获取编辑器类型 */
11
- export declare const getEditorType: () => Promise<any>;
12
- /** 用编辑器打开文件 */
13
- export declare const openFileInEditor: (path: string, editorType: EditorTypeEnum) => void;
@@ -1,2 +0,0 @@
1
- /** 文件添加执行权限 */
2
- export declare const fileAddX: (filePath: string) => void;
@@ -1,2 +0,0 @@
1
- /** 获取git项目目录 */
2
- export declare const getGitProjectDir: (rootDir: string) => string;
@@ -1,2 +0,0 @@
1
- /** 获取当前分支名 */
2
- export declare const getCurrentBranchName: () => string | undefined;
@@ -1,5 +0,0 @@
1
- /** 解析checkoutInfo */
2
- export declare const resolveCheckoutInfoByRefInfo: (message: string) => {
3
- fromBranch: string;
4
- toBranch: string;
5
- } | undefined;
@@ -1,64 +0,0 @@
1
- import { HooksNameEnum } from '../husky';
2
- import type { GitRemoteInfo } from "./remote-operate";
3
- /** 支持通过提交钩子获取提交信息的 */
4
- export declare const SUPPORT_GET_COMMIT_BY_HOOKS_NAMES: readonly [HooksNameEnum.PREPARE_COMMIT_MSG, HooksNameEnum.COMMIT_MSG];
5
- export type SupportGetCommitByHookName = (typeof SUPPORT_GET_COMMIT_BY_HOOKS_NAMES)[number];
6
- /** 根据hookName获取(将)提交的信息 */
7
- export declare const getCommitByHookName: ({ hookName, rootDir, }: {
8
- hookName: SupportGetCommitByHookName;
9
- rootDir: string;
10
- }) => string;
11
- /**
12
- * git最后提交信息
13
- */
14
- export interface GitLastCommitInfo {
15
- /**
16
- * 最后一次提交hash值
17
- */
18
- lastHash: string;
19
- /**
20
- * 最后一次提交者
21
- */
22
- lastCommitter: string;
23
- /**
24
- * 最后一次提交者拼音
25
- */
26
- lastCommitterPinYin: string;
27
- /**
28
- * 最后一次提交者邮箱
29
- */
30
- lastCommitEmail: string;
31
- /**
32
- * 最后一次提交信息
33
- */
34
- lastCommitMsg: string;
35
- /**
36
- * 用户名
37
- */
38
- userName: string;
39
- /**
40
- * 用户名拼音
41
- */
42
- userNamePinYin: string;
43
- /**
44
- * 邮箱
45
- */
46
- userEmail: string;
47
- /**
48
- * 分知名
49
- */
50
- branchName: string;
51
- /** 远程仓库信息 */
52
- remoteInfo?: GitRemoteInfo;
53
- }
54
- /** 获取git最好提交信息参数 */
55
- export interface GetGitLastCommitParams {
56
- /**
57
- * 远程仓库别名
58
- */
59
- remoteAlias?: GitRemoteInfo["alias"];
60
- }
61
- /**
62
- * 获取git 最后提交信息
63
- */
64
- export declare const getGitLastCommitInfo: ({ remoteAlias, }?: GetGitLastCommitParams) => GitLastCommitInfo;
@@ -1,8 +0,0 @@
1
- export * from "./base-info-resolve";
2
- export * from "./branch-resolve";
3
- export * from "./checkout-resolve";
4
- export * from "./commit-resolve";
5
- export * from "./log-resolve";
6
- export * from "./merge-resolve";
7
- export * from "./rebase-resolve";
8
- export * from "./remote-operate";
@@ -1,91 +0,0 @@
1
- import { type GitMergeBranchInfo } from "./merge-resolve";
2
- /** git checkout信息 */
3
- export interface GitCheckoutInfo {
4
- fromBranch: string;
5
- toBranch: string;
6
- }
7
- /** git日志通用信息 */
8
- export interface GitLogCommonInfo {
9
- hash: string;
10
- /** 提交信息 */
11
- message: string;
12
- /** 合并信息 */
13
- mergeInfo?: GitMergeBranchInfo;
14
- }
15
- export interface GitLogItemInfo extends GitLogCommonInfo {
16
- /** 作者 */
17
- author: string;
18
- /** 作者邮箱 */
19
- authorEmail: string;
20
- /** 创作日期 */
21
- createDate: string;
22
- /** 提交者 */
23
- committer: string;
24
- /** 提交者邮箱 */
25
- committerEmail: string;
26
- /** 提交时间 */
27
- commitTime: string;
28
- }
29
- /** 提交日志信息 */
30
- export interface GitReflogItemInfoRaw extends Omit<GitLogCommonInfo, "message"> {
31
- hash: string;
32
- /** 完整信息 */
33
- fullMessage: string;
34
- /** 提交者 */
35
- committer: string;
36
- /** 提交者邮箱 */
37
- committerEmail: string;
38
- /** 提交时间 */
39
- commitTime: string;
40
- }
41
- /** reflog类型 */
42
- export declare enum GitRefLogTypeEnum {
43
- /** checkout */
44
- CHECKOUT = "checkout",
45
- /** merge $branch */
46
- MERGE = "merge",
47
- /** 提交 */
48
- COMMIT = "commit",
49
- /** 合并提交 */
50
- COMMIT_MERGE = "commit (merge)",
51
- /** pull $origin $branch */
52
- PULL = "pull",
53
- /** reset */
54
- RESET = "reset",
55
- /** rebase (start) */
56
- REBASE_START = "rebase (start)",
57
- /** rebase (finish) */
58
- REBASE_FINISH = "rebase (finish)",
59
- /** rebase (abort) */
60
- REBASE_ABORT = "rebase (abort)",
61
- /** rebase (continue) */
62
- REBASE_CONTINUE = "rebase (continue)"
63
- }
64
- /** rebase的阶段 */
65
- export type GitRefLogRebaseStage = GitRefLogTypeEnum.REBASE_START | GitRefLogTypeEnum.REBASE_FINISH | GitRefLogTypeEnum.REBASE_ABORT | GitRefLogTypeEnum.REBASE_CONTINUE;
66
- export interface GitRebaseInfo {
67
- /** rebase的阶段 */
68
- stage?: GitRefLogRebaseStage;
69
- /** 变基的原始分支 */
70
- originBranch: string;
71
- /** 变基的目标分支 */
72
- targetBranch: string;
73
- }
74
- /** reflog信息 */
75
- export interface GitReflogItemInfo extends Omit<GitReflogItemInfoRaw, "fullMessage">, Pick<GitLogCommonInfo, "message"> {
76
- type: GitRefLogTypeEnum;
77
- }
78
- /** 获取当前分支最近提交列表 */
79
- export declare const getCurrentBranchLastCommitList: ({ count, }?: {
80
- count?: number | undefined;
81
- /** 某个hash之后的提交 */
82
- afterHash?: string | undefined;
83
- }) => GitLogItemInfo[];
84
- /** 获取最后的reflog */
85
- export declare const getLastReflogList: ({ count, filterItem, }?: {
86
- count?: number | undefined;
87
- /** 某个hash之后的提交 */
88
- afterHash?: string | undefined;
89
- /** 过滤函数 */
90
- filterItem?: ((item: GitReflogItemInfoRaw) => boolean) | undefined;
91
- }) => GitReflogItemInfo[];
@@ -1,13 +0,0 @@
1
- /** git合并分支信息 */
2
- export interface GitMergeBranchInfo {
3
- /** 合并的源分支 */
4
- fromBranch: string;
5
- /** 合并到该分支 */
6
- toBranch?: string;
7
- }
8
- /** 解析合并信息-通过提交信息 */
9
- export declare const resolveMergeInfoByCommitMsg: (commitMsg?: string) => GitMergeBranchInfo | undefined;
10
- /** 从reflog type解析合并信息 */
11
- export declare const resolveMergeInfoByRefType: (type: string) => GitMergeBranchInfo | undefined;
12
- /** 从reflog action解析合并信息 */
13
- export declare const resolveMergeInfoByGitReflogAction: () => GitMergeBranchInfo | undefined;
@@ -1,2 +0,0 @@
1
- /** 检测当前正在变基 */
2
- export declare const checkCurrentIsRebasing: (rootDir: string) => boolean;
@@ -1,17 +0,0 @@
1
- /** 远程仓库信息 */
2
- export interface GitRemoteInfo {
3
- /**
4
- * 远程仓库别名
5
- */
6
- alias?: string;
7
- /**
8
- * 仓库地址
9
- */
10
- url?: string;
11
- }
12
- /** 推送git发布信息到远程仓库 */
13
- export declare const pushGitPublishInfoToRemote: ({ branchName, version, remoteInfo, }: {
14
- branchName: string;
15
- version: string;
16
- remoteInfo?: GitRemoteInfo | undefined;
17
- }) => void;
package/types/husky.d.ts DELETED
@@ -1,26 +0,0 @@
1
- export declare enum HooksNameEnum {
2
- /** 预提交 */
3
- PRE_COMMIT = "pre-commit",
4
- /** 预合并提交 */
5
- PRE_MERGE_COMMIT = "pre-merge-commit",
6
- /** 准备提交信息 */
7
- PREPARE_COMMIT_MSG = "prepare-commit-msg",
8
- /** 提交消息 */
9
- COMMIT_MSG = "commit-msg",
10
- /** 变基前 */
11
- PRE_REBASE = "pre-rebase",
12
- /** 提交后 */
13
- POST_COMMIT = "post-commit",
14
- /** 合并后 */
15
- POST_MERGE = "post-merge",
16
- /** 推送前 */
17
- PRE_PUSH = "pre-push"
18
- }
19
- /** 添加 husky hooks */
20
- export declare const addHuskyHooks: <H extends string>({ hookNames, rootDir, getCode, }: {
21
- hookNames: H[];
22
- /** 运行目录 */
23
- rootDir: string;
24
- /** 获取husky hooks 添加的代码 */
25
- getCode: (hook: string) => string;
26
- }) => void;
package/types/json5.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import json5 from "json5";
2
- export { json5 };
3
- export * from "json5";
package/types/lodash.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import _get from "lodash.get";
2
- import _set from "lodash.set";
3
- import _curry from "lodash.curry";
4
- export { _get, _set, _curry };
package/types/log.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import chalk from "chalk";
2
- export { chalk };
3
- /** 日志类型 */
4
- declare enum LogTypeEnum {
5
- /** 成功 */
6
- SUCCESS = "green",
7
- /** 步骤 */
8
- STAGE = "blue",
9
- /** 提示信息 */
10
- INFO = "cyan",
11
- /** 警告 */
12
- WARN = "yellow",
13
- /** 错误 */
14
- ERROR = "red",
15
- /** 跳过 */
16
- SKIP = "gray"
17
- }
18
- /** 日志 */
19
- export declare const log: ((type: LogTypeEnum, ...messages: string[]) => void) & {
20
- /** 成功 */
21
- success: (...messages: string[]) => void;
22
- /** /步骤 */
23
- stage: (...messages: string[]) => void;
24
- /** 提示信息 */
25
- info: (...messages: string[]) => void;
26
- /** 警告 */
27
- warn: (...messages: string[]) => void;
28
- /** 错误 */
29
- error: (...messages: string[]) => void;
30
- /** 跳过 */
31
- skip: (...messages: string[]) => void;
32
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * 查找目标文件或目录
3
- */
4
- export declare const lookForParentTarget: (target: string, { currentDir, isFindFarthest, }?: {
5
- currentDir?: string | undefined;
6
- isFindFarthest?: boolean | undefined;
7
- }) => string | undefined;
@@ -1,28 +0,0 @@
1
- /** package.json文件内容 */
2
- export interface PackageJson {
3
- name: string;
4
- version?: string;
5
- bin?: Record<string, string> | string;
6
- scripts?: Record<string, string>;
7
- files?: string[];
8
- dependencies?: Record<string, string>;
9
- devDependencies?: Record<string, string>;
10
- peerDependencies?: Record<string, string>;
11
- }
12
- /** 获取package.json文件内容 */
13
- export declare const getPackageJson: <R extends PackageJson>({ rootDir, }: {
14
- rootDir: string;
15
- }) => R;
16
- /** 获取依赖包版本 */
17
- export declare const getRelyPkgVersion: <R extends PackageJson>({ rootDir, pkgJson, pkgName, isDevPkg, }: {
18
- rootDir: string;
19
- pkgJson?: R | undefined;
20
- pkgName: string;
21
- /** 是开发依赖包 */
22
- isDevPkg: boolean;
23
- }) => string | undefined;
24
- /** 添加package.json配置 */
25
- export declare const addPackageConfig: ({ patchConfig, rootDir, }: {
26
- patchConfig?: Record<string, any> | undefined;
27
- rootDir: string;
28
- }) => void;
@@ -1,4 +0,0 @@
1
- import prompts from "prompts";
2
- export type { Choice as PromptChoice, Options as PromptOptions, PromptObject, Answers as PromptAnswers, PrevCaller as PromptPrevCaller, Falsy as PromptFalsy, PromptType, ValueOrFunc as PromptValueOrFunc, InitialReturnValue as PromptInitialReturnValue, } from "prompts";
3
- /** prompts 拓展 */
4
- export declare const xPrompts: (questions: prompts.PromptObject<string> | prompts.PromptObject<string>[], options?: prompts.Options | undefined) => Promise<prompts.Answers<string>>;