@liuli-util/cli 3.22.0 → 3.22.1
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/bin.js +1 -1
- package/dist/PathUtil.d.ts +7 -0
- package/dist/PathUtil.d.ts.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +217 -0
- package/dist/bin.js.map +7 -0
- package/dist/commands/deploy/DeployService.d.ts +74 -0
- package/dist/commands/deploy/DeployService.d.ts.map +1 -0
- package/dist/commands/deploy/deploy.d.ts +3 -0
- package/dist/commands/deploy/deploy.d.ts.map +1 -0
- package/dist/commands/deploy/index.d.ts +3 -0
- package/dist/commands/deploy/index.d.ts.map +1 -0
- package/dist/commands/deploy/util/PromiseUtil.d.ts +14 -0
- package/dist/commands/deploy/util/PromiseUtil.d.ts.map +1 -0
- package/dist/commands/deploy/util/createArchive.d.ts +10 -0
- package/dist/commands/deploy/util/createArchive.d.ts.map +1 -0
- package/dist/commands/deploy/util/execPromise.d.ts +5 -0
- package/dist/commands/deploy/util/execPromise.d.ts.map +1 -0
- package/dist/commands/deploy/util/validate.d.ts +8 -0
- package/dist/commands/deploy/util/validate.d.ts.map +1 -0
- package/dist/commands/deploy/util/wait.d.ts +9 -0
- package/dist/commands/deploy/util/wait.d.ts.map +1 -0
- package/dist/commands/esbuild/ESBuildProgram.d.ts +77 -0
- package/dist/commands/esbuild/ESBuildProgram.d.ts.map +1 -0
- package/dist/commands/esbuild/index.d.ts +3 -0
- package/dist/commands/esbuild/index.d.ts.map +1 -0
- package/dist/commands/esbuild/util/autoExternal.d.ts +7 -0
- package/dist/commands/esbuild/util/autoExternal.d.ts.map +1 -0
- package/dist/commands/esbuild/util/debounce.d.ts +15 -0
- package/dist/commands/esbuild/util/debounce.d.ts.map +1 -0
- package/dist/commands/esbuild/util/env.d.ts +16 -0
- package/dist/commands/esbuild/util/env.d.ts.map +1 -0
- package/dist/commands/esbuild/util/getPkgGlobalName.d.ts +6 -0
- package/dist/commands/esbuild/util/getPkgGlobalName.d.ts.map +1 -0
- package/dist/commands/esbuild/util/index.d.ts +11 -0
- package/dist/commands/esbuild/util/index.d.ts.map +1 -0
- package/dist/commands/esbuild/util/log.d.ts +3 -0
- package/dist/commands/esbuild/util/log.d.ts.map +1 -0
- package/dist/commands/esbuild/util/metafile.d.ts +7 -0
- package/dist/commands/esbuild/util/metafile.d.ts.map +1 -0
- package/dist/commands/esbuild/util/nativeNodeModules.d.ts +7 -0
- package/dist/commands/esbuild/util/nativeNodeModules.d.ts.map +1 -0
- package/dist/commands/esbuild/util/nodeExternal.d.ts +6 -0
- package/dist/commands/esbuild/util/nodeExternal.d.ts.map +1 -0
- package/dist/commands/esbuild/util/raw.d.ts +7 -0
- package/dist/commands/esbuild/util/raw.d.ts.map +1 -0
- package/dist/commands/esbuild/util/resolve.d.ts +8 -0
- package/dist/commands/esbuild/util/resolve.d.ts.map +1 -0
- package/dist/commands/esbuild/util/sideEffect.d.ts +8 -0
- package/dist/commands/esbuild/util/sideEffect.d.ts.map +1 -0
- package/dist/commands/esbuild/util/userJS.d.ts +3 -0
- package/dist/commands/esbuild/util/userJS.d.ts.map +1 -0
- package/dist/commands/generate/GenerateProgram.d.ts +18 -0
- package/dist/commands/generate/GenerateProgram.d.ts.map +1 -0
- package/dist/commands/generate/index.d.ts +3 -0
- package/dist/commands/generate/index.d.ts.map +1 -0
- package/dist/commands/sync/SyncProgram.d.ts +15 -0
- package/dist/commands/sync/SyncProgram.d.ts.map +1 -0
- package/dist/commands/sync/index.d.ts +3 -0
- package/dist/commands/sync/index.d.ts.map +1 -0
- package/dist/commands/sync/when.d.ts +21 -0
- package/dist/commands/sync/when.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +8 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +7 -0
- package/dist/utils/AsyncArray.d.ts +21 -0
- package/dist/utils/AsyncArray.d.ts.map +1 -0
- package/dist/utils/appendScript.d.ts +7 -0
- package/dist/utils/appendScript.d.ts.map +1 -0
- package/dist/utils/arrayToMap.d.ts +3 -0
- package/dist/utils/arrayToMap.d.ts.map +1 -0
- package/dist/utils/findParent.d.ts +8 -0
- package/dist/utils/findParent.d.ts.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/nodeCacheDir.d.ts +2 -0
- package/dist/utils/nodeCacheDir.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { EventExtPromise } from './util/PromiseUtil';
|
|
2
|
+
import { ConnectOptions } from 'ssh2-sftp-client';
|
|
3
|
+
export interface DeployEvents {
|
|
4
|
+
process(title: string): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 部署服务接口
|
|
8
|
+
*/
|
|
9
|
+
export interface IDeployService {
|
|
10
|
+
validate(): [isValidate: boolean, errorText: string];
|
|
11
|
+
/**
|
|
12
|
+
* 部署
|
|
13
|
+
*/
|
|
14
|
+
deploy(): EventExtPromise<void, DeployEvents>;
|
|
15
|
+
}
|
|
16
|
+
export declare enum DeployTypeEnum {
|
|
17
|
+
GhPages = "gh-pages",
|
|
18
|
+
Sftp = "sftp"
|
|
19
|
+
}
|
|
20
|
+
export interface BaseDeployOptions {
|
|
21
|
+
cwd: string;
|
|
22
|
+
debug: boolean;
|
|
23
|
+
type: DeployTypeEnum;
|
|
24
|
+
}
|
|
25
|
+
export interface SftpDeployOptions extends Omit<BaseDeployOptions, 'type'> {
|
|
26
|
+
dist: string;
|
|
27
|
+
dest: string;
|
|
28
|
+
sshConfig: ConnectOptions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* sftp 集成到远端
|
|
32
|
+
*/
|
|
33
|
+
export declare class SftpDeployService implements IDeployService {
|
|
34
|
+
private readonly options;
|
|
35
|
+
constructor(options: SftpDeployOptions);
|
|
36
|
+
deploy(): EventExtPromise<void, DeployEvents>;
|
|
37
|
+
validate(): [isValidate: boolean, errorText: string];
|
|
38
|
+
}
|
|
39
|
+
export interface GhPagesDeployOptions extends Omit<BaseDeployOptions, 'type'> {
|
|
40
|
+
/**
|
|
41
|
+
* 推送的本地目录
|
|
42
|
+
*/
|
|
43
|
+
dist: string;
|
|
44
|
+
/**
|
|
45
|
+
* 推送的远端目录,默认为分支根目录
|
|
46
|
+
*/
|
|
47
|
+
dest?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 推送的项目 git 地址,默认为当前项目
|
|
50
|
+
*/
|
|
51
|
+
repo?: string;
|
|
52
|
+
/**
|
|
53
|
+
* 推送的远端,默认为 origin
|
|
54
|
+
*/
|
|
55
|
+
remote?: string;
|
|
56
|
+
/**
|
|
57
|
+
* 远端分支名,默认为 gh-pages
|
|
58
|
+
*/
|
|
59
|
+
branch?: string;
|
|
60
|
+
/**
|
|
61
|
+
* 是否增量推送,默认会清理 dest 目录
|
|
62
|
+
*/
|
|
63
|
+
add?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 将本地静态资源推送到 gh-pages 远端
|
|
67
|
+
*/
|
|
68
|
+
export declare class GhPagesDeployService implements IDeployService {
|
|
69
|
+
private readonly options;
|
|
70
|
+
constructor(options: GhPagesDeployOptions);
|
|
71
|
+
deploy(): EventExtPromise<void, DeployEvents>;
|
|
72
|
+
validate(): [isValid: boolean, errorText: string];
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=DeployService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeployService.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/DeployService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,oBAAoB,CAAA;AACjE,OAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAUzD,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;IACpD;;OAEG;IACH,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;CAC9C;AAED,oBAAY,cAAc;IACxB,OAAO,aAAa;IACpB,IAAI,SAAS;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,cAAc,CAAA;CAC1B;AAED;;GAEG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,iBAAiB;IAEvD,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC;IAc7C,QAAQ,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC;CAsBrD;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAC3E;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,cAAc;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,oBAAoB;IAE1D,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC;IAwF7C,QAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC;CAmBlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAMlB,MAAM,iBAAiB,CAAA;AAgBxB,wBAAsB,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,aAAa,SAG0E,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConditionalKeys, PromiseValue } from 'type-fest';
|
|
2
|
+
declare type VoidFunc = ((...args: any[]) => void) | undefined;
|
|
3
|
+
export declare type EventExtPromise<T, E> = Promise<T> & {
|
|
4
|
+
on<K extends ConditionalKeys<E, VoidFunc>>(type: K, callback: E[K]): EventExtPromise<T, E>;
|
|
5
|
+
};
|
|
6
|
+
export declare class PromiseUtil {
|
|
7
|
+
/**
|
|
8
|
+
* 创建一个支持 on* 事件的 Promise 实例
|
|
9
|
+
* @param executor
|
|
10
|
+
*/
|
|
11
|
+
static wrapOnEvent<F extends (events: any) => Promise<any>, E extends Parameters<F>[0], K extends ConditionalKeys<E, VoidFunc>>(executor: F): EventExtPromise<PromiseValue<ReturnType<F>>, E>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=PromiseUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromiseUtil.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/util/PromiseUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAEzD,aAAK,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;AAEtD,oBAAY,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG;IAC/C,EAAE,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAC3F,CAAA;AAED,qBAAa,WAAW;IACtB;;;OAGG;IACH,MAAM,CAAC,WAAW,CAChB,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACvC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1B,CAAC,SAAS,eAAe,CAAC,CAAC,EAAE,QAAQ,CAAC,EACtC,QAAQ,EAAE,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAgBhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createArchive.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/util/createArchive.ts"],"names":[],"mappings":"AAIA,oBAAY,cAAc,GAAG;IAE3B,SAAS,EAAE,MAAM,CAAA;IAEjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execPromise.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/util/execPromise.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAQ,WAAW,EAAE,MAAM,eAAe,CAAA;AAEjD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAU5F"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JSONSchemaType } from 'ajv';
|
|
2
|
+
/**
|
|
3
|
+
* 使用 ajv 校验数据
|
|
4
|
+
* @param schema json 模式配置
|
|
5
|
+
* @param data 校验的数据
|
|
6
|
+
*/
|
|
7
|
+
export declare function validate<T>(schema: JSONSchemaType<T>, data: T): [isValid: boolean, errorText: string];
|
|
8
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/util/validate.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAIzC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAQrG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 等待指定的时间/等待指定表达式成立
|
|
3
|
+
* 如果未指定等待条件则立刻执行
|
|
4
|
+
* 注: 此实现在 nodejs 10- 会存在宏任务与微任务的问题,切记 async-await 本质上还是 Promise 的语法糖,实际上并非真正的同步函数!!!即便在浏览器,也不要依赖于这种特性。
|
|
5
|
+
* @param param 等待时间/等待条件
|
|
6
|
+
* @returns Promise 对象
|
|
7
|
+
*/
|
|
8
|
+
export declare function wait(param?: number | (() => boolean | Promise<boolean>)): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/util/wait.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAevF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BuildOptions, Platform, Plugin } from 'esbuild';
|
|
2
|
+
import { IOptions } from 'glob';
|
|
3
|
+
import Spinnies from 'spinnies';
|
|
4
|
+
interface ESBuildProgramOptions {
|
|
5
|
+
base: string;
|
|
6
|
+
isWatch: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface Task {
|
|
9
|
+
title: string;
|
|
10
|
+
task(): Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export declare type TaskTypeEnum = 'esm' | 'cjs' | 'iife' | 'cli' | 'dts' | 'userjs';
|
|
13
|
+
export declare class ESBuildProgram {
|
|
14
|
+
private readonly options;
|
|
15
|
+
constructor(options: ESBuildProgramOptions);
|
|
16
|
+
set isWatch(isWatch: boolean);
|
|
17
|
+
static readonly globalExternal: string[];
|
|
18
|
+
/**
|
|
19
|
+
* 获取所有依赖
|
|
20
|
+
*/
|
|
21
|
+
static getDeps(base: string): Promise<string[]>;
|
|
22
|
+
/**
|
|
23
|
+
* 获取所在模块的类型
|
|
24
|
+
*/
|
|
25
|
+
static getPlatform(base: string): Promise<Platform>;
|
|
26
|
+
static getWatchOptions(base: string): {
|
|
27
|
+
pattern: string;
|
|
28
|
+
options: IOptions;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 生成类型定义
|
|
32
|
+
*/
|
|
33
|
+
genDTS(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* 获取构建 cjs 的选项
|
|
36
|
+
*/
|
|
37
|
+
getBuildUserJSOption(): BuildOptions;
|
|
38
|
+
/**
|
|
39
|
+
* 获取构建 cjs 的选项
|
|
40
|
+
* @param deps
|
|
41
|
+
*/
|
|
42
|
+
getBuildCjsOption({ deps, platform }: {
|
|
43
|
+
deps: string[];
|
|
44
|
+
platform: Platform;
|
|
45
|
+
}): BuildOptions;
|
|
46
|
+
/**
|
|
47
|
+
* 获取构建 esm 的选项
|
|
48
|
+
* @param deps
|
|
49
|
+
*/
|
|
50
|
+
getBuildESMOption({ deps, platform }: {
|
|
51
|
+
deps: string[];
|
|
52
|
+
platform: Platform;
|
|
53
|
+
}): BuildOptions;
|
|
54
|
+
/**
|
|
55
|
+
* 获取构建 iife 的选项
|
|
56
|
+
* @param deps
|
|
57
|
+
*/
|
|
58
|
+
getBuildIifeOption({ platform, globalName }: {
|
|
59
|
+
platform: Platform;
|
|
60
|
+
globalName: string;
|
|
61
|
+
}): BuildOptions;
|
|
62
|
+
/**
|
|
63
|
+
* 获取构建 cli 的选项
|
|
64
|
+
* @param deps
|
|
65
|
+
*/
|
|
66
|
+
getBuildCliOption({ platform }: {
|
|
67
|
+
deps: string[];
|
|
68
|
+
platform: Platform;
|
|
69
|
+
}): BuildOptions;
|
|
70
|
+
static getPlugins(platform: string): Plugin[];
|
|
71
|
+
build(options: BuildOptions): Promise<void>;
|
|
72
|
+
getTasks(): Promise<Record<TaskTypeEnum, Task>>;
|
|
73
|
+
static execTask(spinnies: Spinnies, task: Task): Promise<void>;
|
|
74
|
+
execTasks(tasks: Task[]): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=ESBuildProgram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ESBuildProgram.d.ts","sourceRoot":"","sources":["../../../src/commands/esbuild/ESBuildProgram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAM/D,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAE/B,OAAO,QAAQ,MAAM,UAAU,CAAA;AAM/B,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,UAAU,IAAI;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;CACrB;AAED,oBAAY,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE5E,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,qBAAqB;IAE3D,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAE3B;IAED,MAAM,CAAC,QAAQ,CAAC,cAAc,WAA4C;IAE1E;;OAEG;WACU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IASrD;;OAEG;WACU,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBzD,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;QACpC,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,QAAQ,CAAA;KAClB;IAQD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB7B;;OAEG;IACH,oBAAoB,IAAI,YAAY;IAcpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,YAAY;IAgB3F;;;OAGG;IACH,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,YAAY;IAgB3F;;;OAGG;IACH,kBAAkB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY;IAgBtG;;;OAGG;IACH,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,YAAY;IAoBrF,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAQvC,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;WA0DxC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9D,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAmB9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/esbuild/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,eAAO,MAAM,cAAc,SAiDxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoExternal.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/autoExternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC;;;GAGG;AACF,wBAAgB,YAAY,IAAI,MAAM,CAetC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 函数去抖
|
|
3
|
+
* 去抖 (debounce) 去抖就是对于一定时间段的连续的函数调用,只让其执行一次
|
|
4
|
+
* 注: 包装后的函数如果两次操作间隔小于 delay 则不会被执行, 如果一直在操作就会一直不执行, 直到操作停止的时间大于 delay 最小间隔时间才会执行一次, 不管任何时间调用都需要停止操作等待最小延迟时间
|
|
5
|
+
* 应用场景主要在那些连续的操作, 例如页面滚动监听, 包装后的函数只会执行最后一次
|
|
6
|
+
* 注: 该函数第一次调用一定不会执行,第一次一定拿不到缓存值,后面的连续调用都会拿到上一次的缓存值。如果需要在第一次调用获取到的缓存值,则需要传入第三个参数 {@param init},默认为 {@code undefined} 的可选参数
|
|
7
|
+
* 注: 返回函数结果的高阶函数需要使用 {@see Proxy} 实现,以避免原函数原型链上的信息丢失
|
|
8
|
+
*
|
|
9
|
+
* @param fn 真正需要执行的操作
|
|
10
|
+
* @param delay 最小延迟时间,单位为 ms
|
|
11
|
+
* @param init 初始的缓存值,不填默认为 {@see undefined}
|
|
12
|
+
* @return 包装后有去抖功能的函数。该函数是异步的,与需要包装的函数 {@param fn} 是否异步没有太大关联
|
|
13
|
+
*/
|
|
14
|
+
export declare function debounce<T extends (...args: any[]) => any, R extends (...args: Parameters<T>) => Promise<ReturnType<T>>>(fn: T, delay: number, init?: any): R;
|
|
15
|
+
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/debounce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACjC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC5D,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,GAAU,GAAG,CAAC,CAY3C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* Create a map of replacements for environment variables.
|
|
4
|
+
* @return A map of variables.
|
|
5
|
+
*/
|
|
6
|
+
export declare function defineProcessEnv(): Record<string, string>;
|
|
7
|
+
export declare function defineImportEnv(): Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Pass environment variables to esbuild.
|
|
10
|
+
* @return An esbuild plugin.
|
|
11
|
+
*/
|
|
12
|
+
export declare function env(options: {
|
|
13
|
+
process?: boolean;
|
|
14
|
+
import?: boolean;
|
|
15
|
+
}): Plugin;
|
|
16
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAchC;;;GAGG;AACH,wBAAgB,gBAAgB,2BAc/B;AAED,wBAAgB,eAAe,2BAS9B;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAiB5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPkgGlobalName.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/getPkgGlobalName.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './autoExternal';
|
|
2
|
+
export * from './env';
|
|
3
|
+
export * from './log';
|
|
4
|
+
export * from './metafile';
|
|
5
|
+
export * from './nativeNodeModules';
|
|
6
|
+
export * from './nodeExternal';
|
|
7
|
+
export * from './raw';
|
|
8
|
+
export * from './resolve';
|
|
9
|
+
export * from './sideEffect';
|
|
10
|
+
export * from './userJS';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA;AACrB,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,SAAS,CAAA;AAE7C,wBAAgB,GAAG,IAAI,MAAM,CAiB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metafile.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/metafile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGhC;;;GAGG;AACF,wBAAgB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAStD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeNodeModules.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/nativeNodeModules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAoC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExternal.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/nodeExternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAUrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/raw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAIhC;;;GAGG;AACH,wBAAgB,GAAG,IAAI,MAAM,CAkB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,SAAS,CAAA;AAGvC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAarE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sideEffect.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/sideEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userJS.d.ts","sourceRoot":"","sources":["../../../../src/commands/esbuild/util/userJS.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAqBhC,wBAAgB,MAAM,IAAI,MAAM,CAgB/B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum TemplateTypeEnum {
|
|
2
|
+
Cli = "cli",
|
|
3
|
+
Lib = "lib"
|
|
4
|
+
}
|
|
5
|
+
export interface GenerateConfig {
|
|
6
|
+
template: TemplateTypeEnum;
|
|
7
|
+
dest: string;
|
|
8
|
+
initSync?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class GenerateProgram {
|
|
11
|
+
/**
|
|
12
|
+
* 生成项目
|
|
13
|
+
*/
|
|
14
|
+
generate(config: GenerateConfig): Promise<void>;
|
|
15
|
+
static updatePackageJSON(destFile: string): Promise<void>;
|
|
16
|
+
static updateReadme(destFile: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=GenerateProgram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateProgram.d.ts","sourceRoot":"","sources":["../../../src/commands/generate/GenerateProgram.ts"],"names":[],"mappings":"AAMA,oBAAY,gBAAgB;IAC1B,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,qBAAa,eAAe;IAC1B;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;WAyDxC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAclD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/generate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAW3C,eAAO,MAAM,eAAe,SAWxB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function mergeJson(base: string, json: object): Promise<void>;
|
|
2
|
+
export declare type SyncConfigType = 'prettier' | 'commitlint' | 'simplehooks' | 'workspaces' | 'gitignore' | 'eslint-ts' | 'eslint-vue-ts' | 'eslint-react-ts' | 'jest';
|
|
3
|
+
export interface SyncConfig {
|
|
4
|
+
type: SyncConfigType;
|
|
5
|
+
handler(): Promise<void>;
|
|
6
|
+
when?(): Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare class SyncProgram {
|
|
9
|
+
private readonly base;
|
|
10
|
+
constructor(base: string);
|
|
11
|
+
private syncConfigs;
|
|
12
|
+
sync(): Promise<void>;
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=SyncProgram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncProgram.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/SyncProgram.ts"],"names":[],"mappings":"AAaA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzE;AAED,oBAAY,cAAc,GACtB,UAAU,GACV,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,WAAW,GACX,WAAW,GACX,eAAe,GACf,iBAAiB,GACjB,MAAM,CAAA;AAEV,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAA;IACpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CAC1B;AAED,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IACzC,OAAO,CAAC,WAAW,CA8IlB;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAarB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAsB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,WAAW,SAUrB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否包含 package.json
|
|
3
|
+
* @param cwd
|
|
4
|
+
*/
|
|
5
|
+
export declare function isNpmPackage(cwd?: string): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* 判断是 yarn2 monorepo 项目
|
|
8
|
+
* @param cwd
|
|
9
|
+
*/
|
|
10
|
+
export declare function isYarnRoot(cwd?: string): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* 判断是 yarn2 monorepo 的子模块
|
|
13
|
+
*/
|
|
14
|
+
export declare function isYarnSubModule(cwd?: string): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* 是否包含指定依赖
|
|
17
|
+
* @param deps
|
|
18
|
+
* @param cwd
|
|
19
|
+
*/
|
|
20
|
+
export declare function isIncludeDep(deps: string[], cwd?: string): Promise<boolean>;
|
|
21
|
+
//# sourceMappingURL=when.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/when.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAsB,YAAY,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhF;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAM9E;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CASnF;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOhG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA;AACnD,cAAc,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var q=Object.defineProperty;var G=(s,e,t)=>e in s?q(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var D=(s=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(s,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):s)(function(s){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+s+'" is not supported')});var y=(s,e,t)=>(G(s,typeof e!="symbol"?e+"":e,t),t);import{build as $}from"esbuild";import{pathExists as B,readFile as Q,readJson as R,remove as X}from"fs-extra";import*as a from"path";import{Project as Z}from"ts-morph";import{promise as _}from"glob-promise";import{watch as ee}from"chokidar";import te from"spinnies";function S(s,e,t=null){let i,n=t;return async function(...r){return new Promise(o=>{i&&clearTimeout(i),i=setTimeout(()=>o(n=s(...r)),e),setTimeout(()=>o(n),e)})}}import{parse as ie}from"json5";function M(s){return(s.startsWith("@")?s.slice(s.indexOf("/")+1):s).split("-").map(t=>t.slice(0,1).toUpperCase()+t.slice(1).toLowerCase()).join("")}import{writeJson as Ee}from"fs-extra";function C(){return{name:"native-node-modules",setup(s){s.onResolve({filter:/\.node$/,namespace:"file"},t=>({path:D.resolve(t.path,{paths:[t.resolveDir]}),namespace:"node-file"})),s.onLoad({filter:/.*/,namespace:"node-file"},t=>({contents:`
|
|
2
|
+
import path from ${JSON.stringify(t.path)}
|
|
3
|
+
try { module.exports = require(path) }
|
|
4
|
+
catch {}
|
|
5
|
+
`})),s.onResolve({filter:/\.node$/,namespace:"node-file"},t=>({path:t.path,namespace:"file"}));let e=s.initialOptions;e.loader=e.loader||{},e.loader[".node"]="file"}}}function F(){return{name:"nodeExternals",setup(s){s.onResolve({filter:/(^node:)/},e=>({path:e.path.slice(5),external:!0}))}}}import{readFile as Ce}from"fs-extra";function j(s){return{name:"resolve",setup(e){e.onResolve({filter:/.*/},async t=>{let i=s.find(n=>n[0]===t.path);if(!!i)return await e.resolve(i[1])})}}}import{readJson as z}from"fs-extra";import A from"path";function H(s){return["// ==UserScript==",...Object.entries(s).map(([e,t])=>Array.isArray(t)?t.map(i=>`// @${e} ${i}`):`// @${e} ${t}`).flat(),"// ==/UserScript=="].join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`}function W(){return{name:"userJS",async setup(s){let e=await z(A.resolve(s.initialOptions.absWorkingDir,"package.json"));if(!e.userjs)throw new Error("userjs is not supported");s.initialOptions.banner||(s.initialOptions.banner={}),s.initialOptions.banner.js=H(e.userjs)}}}var p=class{constructor(e){this.options=e}set isWatch(e){this.options.isWatch=e}static async getDeps(e){let t=await R(a.resolve(e,"package.json"));return Object.keys({...t.dependencies,...t.devDependencies,...t.peerDependencies})}static async getPlatform(e){let t=a.resolve(e,"tsconfig.json");if(await B(t)&&ie(await Q(t,"utf-8"))?.compilerOptions?.lib?.some(r=>r.toLowerCase()==="dom"))return"browser";let i=a.resolve(e,"package.json");if(await B(i)){let n=await R(i);if(Object.keys(n.devDependencies??{}).includes("@types/node"))return"node"}return"neutral"}static getWatchOptions(e){return{pattern:"src/**/*.ts",options:{cwd:e,ignore:"**/__tests__/**/*"}}}async genDTS(){let e=this.options.base,{pattern:t,options:i}=p.getWatchOptions(this.options.base),n=new Z({tsConfigFilePath:a.resolve(e,"tsconfig.json"),skipAddingFilesFromTsConfig:!0,compilerOptions:{emitDeclarationOnly:!0,noEmit:!1,incremental:this.options.isWatch}}),r=(await _(t,i)).map(o=>a.resolve(e,o));n.addSourceFilesAtPaths(r),await n.emit({emitOnlyDtsFiles:!0})}getBuildUserJSOption(){return{entryPoints:[a.resolve(this.options.base,"./src/index.ts")],outfile:a.resolve(this.options.base,"./dist/index.user.js"),format:"iife",bundle:!0,external:[...p.globalExternal],platform:"browser",plugins:[W()],incremental:this.options.isWatch,absWorkingDir:this.options.base}}getBuildCjsOption({deps:e,platform:t}){return{entryPoints:[a.resolve(this.options.base,"./src/index.ts")],outfile:a.resolve(this.options.base,"./dist/index.js"),format:"cjs",sourcemap:!0,bundle:!0,external:[...p.globalExternal,...e],platform:t,minify:!this.options.isWatch,incremental:this.options.isWatch,metafile:this.options.isWatch,plugins:[j([["@liuli-util/esbuild-plugins/src/","@liuli-util/esbuild-plugins"]])]}}getBuildESMOption({deps:e,platform:t}){return{entryPoints:[a.resolve(this.options.base,"./src/index.ts")],outfile:a.resolve(this.options.base,"./dist/index.esm.js"),format:"esm",sourcemap:!0,bundle:!0,external:[...p.globalExternal,...e],platform:t,minify:!this.options.isWatch,incremental:this.options.isWatch,metafile:this.options.isWatch,plugins:[j([["@liuli-util/esbuild-plugins/src/","@liuli-util/esbuild-plugins"]])]}}getBuildIifeOption({platform:e,globalName:t}){return{entryPoints:[a.resolve(this.options.base,"./src/index.ts")],outfile:a.resolve(this.options.base,"./dist/index.iife.js"),format:"iife",sourcemap:!0,bundle:!0,external:[...p.globalExternal],platform:e,minify:!this.options.isWatch,incremental:this.options.isWatch,metafile:this.options.isWatch,globalName:t}}getBuildCliOption({platform:e}){let t=p.getPlugins(e);return{entryPoints:[a.resolve(this.options.base,"./src/bin.ts")],outfile:a.resolve(this.options.base,"./dist/bin.js"),format:"cjs",sourcemap:!0,platform:e,bundle:!0,banner:{js:"#!/usr/bin/env node"},external:[...p.globalExternal],plugins:t,minify:!this.options.isWatch,incremental:this.options.isWatch,metafile:this.options.isWatch}}static getPlugins(e){let t=[];return e==="node"&&t.push(F(),C()),t}async build(e){await $(e)}async getTasks(){let e=await p.getDeps(this.options.base),t=await p.getPlatform(this.options.base);return{esm:{title:"\u6784\u5EFA esm",task:()=>this.build(this.getBuildESMOption({deps:e,platform:t}))},cjs:{title:"\u6784\u5EFA cjs",task:()=>this.build(this.getBuildCjsOption({deps:e,platform:t}))},iife:{title:"\u6784\u5EFA iife",task:async()=>await this.build(this.getBuildIifeOption({platform:t,globalName:M((await R(a.resolve(this.options.base,"./package.json"))).name)}))},cli:{title:"\u6784\u5EFA cli",task:()=>$(this.getBuildCliOption({deps:e,platform:t}))},dts:{title:"\u751F\u6210\u7C7B\u578B\u5B9A\u4E49",task:()=>this.genDTS()},userjs:{title:"\u6253\u5305 userjs",task:()=>this.build(this.getBuildUserJSOption())}}}static async execTask(e,t){let i=Date.now();e.add(t.title,{text:t.title});try{await t.task(),e.succeed(t.title,{text:`${t.title}: ${Date.now()-i}ms`})}catch{e.fail(t.title,{text:t.title})}}async execTasks(e){let t=async()=>{let r=Date.now(),o=new te;await Promise.all(e.map(async k=>p.execTask(o,k))),console.log(`\u6784\u5EFA\u5B8C\u6210: ${Date.now()-r}ms`)};if(!this.options.isWatch){await X(a.resolve(this.options.base,"dist")),await t();return}let{pattern:i,options:n}=p.getWatchOptions(this.options.base);await new Promise((r,o)=>{ee(i,n).on("error",o).on("all",S(t,10))})}},O=p;y(O,"globalExternal",["esbuild","pnpapi","ts-morph","ssh2"]);import m from"path";import{copy as fe,pathExists as Y,readdir as de,readFile as ge,readJSON as he,remove as ye,writeFile as we,writeJSON as Pe}from"fs-extra";import{prompt as J}from"enquirer";import{readFile as ae,readJson as P,writeFile as oe,writeJson as V}from"fs-extra";import h from"path";import{merge as U}from"lodash";import pe from"@liuli-util/prettier-standard-config/package.json";import le from"@liuli-util/eslint-config-ts/package.json";import ce from"@liuli-util/eslint-config-react-ts/package.json";import me from"@liuli-util/commitlint-standard-config/package.json";import{prompt as ue}from"enquirer";import{pathExists as ne,readJson as K}from"fs-extra";import*as w from"path";function N(s,e,t=i=>i){return s.reduce((i,n,r,o)=>i.set(e(n,r,o),t(n,r,o)),new Map)}function I(s,e){return s?s.includes(e)?s:s+" && "+e:e}import se from"path";function E(s,e){let t=e(s);function i(n){if(n)return s;let r=se.dirname(s);return r===s?null:E(r,e)}return t instanceof Promise?t.then(i):i(t)}var L=(r=>(r.Filter="filter",r.Map="map",r.ForEach="forEach",r.Reduce="reduce",r.FlatMap="flatMap",r))(L||{}),u=class{constructor(e,t){this.type=e;this.args=t;this.type=e,this.args=t}};y(u,"Type",L);var l=class{constructor(e){this.arr=e}static reduce(e,t,i){return e.reduce((n,r,o)=>n.then(k=>t(k,r,o)),Promise.resolve(i))}static map(e,t){return Promise.all(e.map((i,n)=>t(i,n)))}static async filter(e,t){let i=[];return await l.map(e,async(n,r)=>{await t(n,r)&&i.push(n)}),i}static async flatMap(e,t){return(await Promise.all(e.map((i,n)=>t(i,n)))).flatMap(i=>i)}static async forEach(e,t){await l.map(e,t)}tasks=[];map(e){return this.tasks.push(new u("map",[e])),this}flatMap(e){return this.tasks.push(new u("flatMap",[e])),this}filter(e){return this.tasks.push(new u("filter",[e])),this}async forEach(e){this.tasks.push(new u("map",[e])),await this}then(e,t){let i=this.value();return i.then(n=>(e&&e(i),n)).catch(n=>{throw t&&t(n),n}),i}async value(){let e=this.arr;for(let t of this.tasks)switch(t.type){case"filter":e=await l.filter(e,t.args[0]);break;case"map":e=await l.map(e,t.args[0]);break;case"flatMap":e=await l.flatMap(e,t.args[0]);break;case"forEach":await l.forEach(e,t.args[0]);return;case"reduce":return await l.reduce(e,t.args[0],t.args[1])}return e}};async function c(s=process.cwd()){return await ne(w.resolve(s,"./package.json"))}async function f(s=process.cwd()){return await c(s)?!!(await K(w.resolve(s,"./package.json"))).workspaces:!1}async function x(s=process.cwd()){return!await c(s)||await f(s)?!1:await E(w.dirname(s),f)!==null}async function v(s,e=process.cwd()){if(!await c(e))return!1;let t=await K(w.resolve(e,"./package.json")),i=new Set(Object.keys({...t.dependencies,...t.devDependencies}));return s.every(n=>i.has(n))}import re from"path";var d=class{};y(d,"RootPath",re.resolve(__dirname,".."));async function g(s,e){let t=h.resolve(s,"./package.json");await V(t,U(await P(t),e),{spaces:2})}var T=class{constructor(e){this.base=e}syncConfigs=[{type:"workspaces",handler:async()=>{let e=h.resolve(this.base,"./package.json"),t=h.resolve(this.base,"lerna.json"),i=await P(e),n=await P(t);n.packages=i.workspaces,await V(t,n,{spaces:2})},when:f},{type:"prettier",handler:async()=>{await g(this.base,{prettier:"@liuli-util/prettier-standard-config",devDependencies:{prettier:"^2.3.2","@liuli-util/prettier-standard-config":`^${pe.version}`}})},async when(){return await c()&&(await f()||!await x())}},{type:"commitlint",handler:async()=>{await g(this.base,{"simple-git-hooks":{"commit-msg":"yarn commitlint --edit $1"},commitlint:{extends:["@liuli-util/commitlint-standard-config"]},devDependencies:{"@commitlint/cli":"^12.1.4","@liuli-util/commitlint-standard-config":`^${me.version}`}})},async when(){return await c()&&(await f()||!await x())}},{type:"gitignore",handler:async()=>{let e=h.resolve(this.base,".gitignore");await oe(e,await ae(h.resolve(d.RootPath,"_gitignore"),"utf-8"))}},{type:"eslint-ts",handler:async()=>{await g(this.base,{eslintConfig:{extends:["@liuli-util/eslint-config-ts"]},devDependencies:{"@liuli-util/eslint-config-ts":`^${le.version}`}})},async when(){return await c()&&!await v(["vue"])&&!await v(["react"])}},{type:"eslint-react-ts",handler:async()=>{await g(this.base,{eslintConfig:{extends:["@liuli-util/eslint-config-react-ts"]},devDependencies:{"@liuli-util/eslint-config-react-ts":`^${ce.version}`}})},async when(){return await c()&&await v(["react"])}},{type:"jest",handler:async()=>{await g(this.base,{jest:{preset:"ts-jest",testMatch:["<rootDir>/src/**/__tests__/*.test.ts"]},devDependencies:{jest:"^27.4.3","ts-jest":"^27.0.7"}})}},{type:"simplehooks",handler:async()=>{let e=await P(h.resolve(this.base,"./package.json")),t={};e.prettier&&(t["src/**/*.{ts,tsx,js,jsx,css,vue}"]=["prettier --write","git add"]),e.eslintConfig&&(t["src/**/*.{ts,tsx,js,jsx}"]=["eslint --fix --quiet","git add"]);let i={scripts:{postinstall:I(e?.scripts?.postinstall,"npx simple-git-hooks")},"simple-git-hooks":{"pre-commit":"yarn lint-staged"},"lint-staged":t,devDependencies:{"simple-git-hooks":"^2.5.1","lint-staged":"^11.1.1"}};e.commitlint&&(i=U(i,{"simple-git-hooks":{"commit-msg":"yarn commitlint --edit $1"}})),await g(this.base,i)},async when(){return await c()&&(await f()||!await x())}}];async sync(){let{sync:e}=await P(h.resolve(this.base,"package.json"));if(!e)return;let t=this.syncConfigs.filter(i=>e.includes(i.type));for(let i of t)await i.handler()}async init(){let e=N(await l.filter(this.syncConfigs,async i=>i.when?await i.when():!0),i=>i.type),t=await ue({type:"multiselect",message:"\u8BF7\u9009\u62E9\u9700\u8981\u540C\u6B65\u7684\u914D\u7F6E\u9879",name:"sync",choices:[...e.keys()]});await g(this.base,{sync:t.sync})}};var be=(t=>(t.Cli="cli",t.Lib="lib",t))(be||{}),b=class{async generate(e){if(!e.dest){let{dest:n}=await J({name:"dest",type:"input",message:"\u8BF7\u8F93\u5165\u9879\u76EE\u540D",validate(r){return r.trim()!==""}});e.dest=m.resolve(n)}if(!e.template){let{template:n}=await J({name:"template",type:"select",message:"\u8BF7\u9009\u62E9\u6A21\u677F",choices:["lib","cli"]});e.template=n}let t=m.resolve(d.RootPath,`templates/${e.template}`),i=m.resolve(e.dest);if(await Y(i)&&(await de(i)).some(n=>Y(n))){let{override:n}=await J({name:"override",type:"confirm",initial:!0,message:"\u76EE\u6807\u4F4D\u7F6E\u4E0D\u662F\u4E00\u4E2A\u7A7A\u76EE\u5F55\uFF0C\u786E\u8BA4\u8981\u8986\u76D6\u4E48\uFF1F"});if(!n)return}if(await ye(i),await fe(t,i,{filter:n=>m.basename(n)!=="node_modules"}),await b.updatePackageJSON(i),await b.updateReadme(i),e.initSync){let n=new T(m.resolve(e.dest));await n.init(),await n.sync()}}static async updatePackageJSON(e){let t=m.resolve(e,"package.json");await Pe(t,{...await he(t),name:m.basename(e)},{spaces:2})}static async updateReadme(e){let t=m.resolve(e,"README.md"),i=await ge(t,"utf-8");i=i.replace("template",m.basename(e)),await we(t,i)}};export{O as ESBuildProgram,b as GenerateProgram,T as SyncProgram,be as TemplateTypeEnum,g as mergeJson};
|
|
8
|
+
//# sourceMappingURL=index.esm.js.map
|