@hot-updater/cli-tools 0.21.10 → 0.21.12
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/dist/index.cjs +79804 -43
- package/dist/index.d.cts +173 -16
- package/dist/index.d.ts +173 -16
- package/dist/index.js +79765 -18
- package/package.json +14 -6
- package/dist/ConfigBuilder.cjs +0 -122
- package/dist/ConfigBuilder.d.cts +0 -43
- package/dist/ConfigBuilder.d.ts +0 -43
- package/dist/ConfigBuilder.js +0 -121
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/banner.cjs +0 -29
- package/dist/banner.d.cts +0 -6
- package/dist/banner.d.ts +0 -6
- package/dist/banner.js +0 -24
- package/dist/colors.d.cts +0 -2
- package/dist/colors.d.ts +0 -2
- package/dist/colors.js +0 -3
- package/dist/copyDirToTmp.cjs +0 -28
- package/dist/copyDirToTmp.d.cts +0 -7
- package/dist/copyDirToTmp.d.ts +0 -7
- package/dist/copyDirToTmp.js +0 -25
- package/dist/createTarBr.cjs +0 -94
- package/dist/createTarBr.d.cts +0 -22
- package/dist/createTarBr.d.ts +0 -22
- package/dist/createTarBr.js +0 -88
- package/dist/createTarGz.cjs +0 -78
- package/dist/createTarGz.d.cts +0 -22
- package/dist/createTarGz.d.ts +0 -22
- package/dist/createTarGz.js +0 -73
- package/dist/createZip.cjs +0 -80
- package/dist/createZip.d.cts +0 -22
- package/dist/createZip.d.ts +0 -22
- package/dist/createZip.js +0 -75
- package/dist/crypto.cjs +0 -27
- package/dist/crypto.d.cts +0 -5
- package/dist/crypto.d.ts +0 -5
- package/dist/crypto.js +0 -24
- package/dist/cwd.cjs +0 -9
- package/dist/cwd.d.cts +0 -4
- package/dist/cwd.d.ts +0 -4
- package/dist/cwd.js +0 -7
- package/dist/getAndroidSdkPath.cjs +0 -10
- package/dist/getAndroidSdkPath.d.cts +0 -4
- package/dist/getAndroidSdkPath.d.ts +0 -4
- package/dist/getAndroidSdkPath.js +0 -9
- package/dist/isObject.cjs +0 -8
- package/dist/isObject.js +0 -7
- package/dist/loadConfig.cjs +0 -100
- package/dist/loadConfig.d.cts +0 -12
- package/dist/loadConfig.d.ts +0 -12
- package/dist/loadConfig.js +0 -93
- package/dist/log.cjs +0 -16
- package/dist/log.d.cts +0 -11
- package/dist/log.d.ts +0 -11
- package/dist/log.js +0 -14
- package/dist/makeEnv.cjs +0 -57
- package/dist/makeEnv.d.cts +0 -8
- package/dist/makeEnv.d.ts +0 -8
- package/dist/makeEnv.js +0 -55
- package/dist/prompts.d.cts +0 -2
- package/dist/prompts.d.ts +0 -2
- package/dist/prompts.js +0 -3
- package/dist/transformEnv.cjs +0 -14
- package/dist/transformEnv.d.cts +0 -4
- package/dist/transformEnv.d.ts +0 -4
- package/dist/transformEnv.js +0 -11
- package/dist/transformTemplate.cjs +0 -22
- package/dist/transformTemplate.d.cts +0 -15
- package/dist/transformTemplate.d.ts +0 -15
- package/dist/transformTemplate.js +0 -21
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,174 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import colors from "picocolors";
|
|
2
|
+
import { ConfigInput, Platform, RequiredDeep } from "@hot-updater/plugin-core";
|
|
3
|
+
import * as p from "@clack/prompts";
|
|
4
|
+
|
|
5
|
+
//#region src/banner.d.ts
|
|
6
|
+
declare const link: (url: string) => string;
|
|
7
|
+
declare const banner: (version?: string) => string;
|
|
8
|
+
declare const printBanner: (version?: string) => void;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/ConfigBuilder.d.ts
|
|
11
|
+
type BuildType = "bare" | "rock" | "expo";
|
|
12
|
+
type ImportInfo = {
|
|
13
|
+
pkg: string;
|
|
14
|
+
named?: string[];
|
|
15
|
+
defaultOrNamespace?: string;
|
|
16
|
+
sideEffect?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type ProviderConfig = {
|
|
19
|
+
imports: ImportInfo[];
|
|
20
|
+
configString: string;
|
|
21
|
+
};
|
|
22
|
+
interface IConfigBuilder {
|
|
23
|
+
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
24
|
+
setBuildType(buildType: BuildType): this;
|
|
25
|
+
/** Sets the storage configuration and adds its required imports. */
|
|
26
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
27
|
+
/** Sets the database configuration and adds its required imports. */
|
|
28
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
29
|
+
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
30
|
+
setIntermediateCode(code: string): this;
|
|
31
|
+
/** Assembles and returns the final configuration string. */
|
|
32
|
+
getResult(): string;
|
|
33
|
+
}
|
|
34
|
+
declare class ConfigBuilder implements IConfigBuilder {
|
|
35
|
+
private buildType;
|
|
36
|
+
private storageInfo;
|
|
37
|
+
private databaseInfo;
|
|
38
|
+
private intermediateCode;
|
|
39
|
+
private collectedImports;
|
|
40
|
+
constructor();
|
|
41
|
+
addImport(info: ImportInfo): this;
|
|
42
|
+
private addImports;
|
|
43
|
+
private generateImportStatements;
|
|
44
|
+
private generateBuildConfigString;
|
|
45
|
+
setBuildType(buildType: BuildType): this;
|
|
46
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
47
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
48
|
+
setIntermediateCode(code: string): this;
|
|
49
|
+
getResult(): string;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/copyDirToTmp.d.ts
|
|
53
|
+
declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
54
|
+
tmpDir: string;
|
|
55
|
+
removeTmpDir: () => Promise<void>;
|
|
56
|
+
}>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/createTarBr.d.ts
|
|
59
|
+
declare const createTarBrTargetFiles: ({
|
|
60
|
+
outfile,
|
|
61
|
+
targetFiles
|
|
62
|
+
}: {
|
|
63
|
+
targetFiles: {
|
|
64
|
+
path: string;
|
|
65
|
+
name: string;
|
|
66
|
+
}[];
|
|
67
|
+
outfile: string;
|
|
68
|
+
}) => Promise<string>;
|
|
69
|
+
declare const createTarBr: ({
|
|
70
|
+
outfile,
|
|
71
|
+
targetDir,
|
|
72
|
+
excludeExts
|
|
73
|
+
}: {
|
|
74
|
+
targetDir: string;
|
|
75
|
+
outfile: string;
|
|
76
|
+
excludeExts?: string[];
|
|
77
|
+
}) => Promise<string>;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/createTarGz.d.ts
|
|
80
|
+
declare const createTarGzTargetFiles: ({
|
|
81
|
+
outfile,
|
|
82
|
+
targetFiles
|
|
83
|
+
}: {
|
|
84
|
+
targetFiles: {
|
|
85
|
+
path: string;
|
|
86
|
+
name: string;
|
|
87
|
+
}[];
|
|
88
|
+
outfile: string;
|
|
89
|
+
}) => Promise<string>;
|
|
90
|
+
declare const createTarGz: ({
|
|
91
|
+
outfile,
|
|
92
|
+
targetDir,
|
|
93
|
+
excludeExts
|
|
94
|
+
}: {
|
|
95
|
+
targetDir: string;
|
|
96
|
+
outfile: string;
|
|
97
|
+
excludeExts?: string[];
|
|
98
|
+
}) => Promise<string>;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/createZip.d.ts
|
|
101
|
+
declare const createZipTargetFiles: ({
|
|
102
|
+
outfile,
|
|
103
|
+
targetFiles
|
|
104
|
+
}: {
|
|
105
|
+
targetFiles: {
|
|
106
|
+
path: string;
|
|
107
|
+
name: string;
|
|
108
|
+
}[];
|
|
109
|
+
outfile: string;
|
|
110
|
+
}) => Promise<string>;
|
|
111
|
+
declare const createZip: ({
|
|
112
|
+
outfile,
|
|
113
|
+
targetDir,
|
|
114
|
+
excludeExts
|
|
115
|
+
}: {
|
|
116
|
+
targetDir: string;
|
|
117
|
+
outfile: string;
|
|
118
|
+
excludeExts?: string[];
|
|
119
|
+
}) => Promise<string>;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/crypto.d.ts
|
|
122
|
+
declare const encryptJson: (jsonData: Record<string, any>, secretKey: string) => string;
|
|
123
|
+
declare const decryptJson: <T>(encryptedData: string, secretKey: string) => T;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/cwd.d.ts
|
|
126
|
+
declare const getCwd: () => string;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/getAndroidSdkPath.d.ts
|
|
129
|
+
declare function getAndroidSdkPath(): string;
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/loadConfig.d.ts
|
|
132
|
+
type HotUpdaterConfigOptions = {
|
|
133
|
+
platform: Platform;
|
|
134
|
+
channel: string;
|
|
135
|
+
} | null;
|
|
136
|
+
type ConfigResponse = RequiredDeep<ConfigInput>;
|
|
137
|
+
declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
|
|
138
|
+
declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/log.d.ts
|
|
141
|
+
declare const log: {
|
|
142
|
+
normal: (message: string | number | null | undefined) => void;
|
|
143
|
+
success: (message: string | number | null | undefined) => void;
|
|
144
|
+
info: (message: string | number | null | undefined) => void;
|
|
145
|
+
error: (message: string | number | null | undefined) => void;
|
|
146
|
+
warn: (message: string | number | null | undefined) => void;
|
|
147
|
+
debug: (message: string | number | null | undefined) => void;
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/makeEnv.d.ts
|
|
151
|
+
type EnvVarValue = string | {
|
|
152
|
+
comment: string;
|
|
153
|
+
value: string;
|
|
154
|
+
};
|
|
155
|
+
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/transformEnv.d.ts
|
|
158
|
+
declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/transformTemplate.d.ts
|
|
161
|
+
type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
|
|
162
|
+
type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]: string };
|
|
163
|
+
/**
|
|
164
|
+
* Replaces placeholders in the format %%key%% in a template string with values from the values object.
|
|
165
|
+
* Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* const str = "Hello %%name%%, you are %%age%% years old."
|
|
169
|
+
* const result = transformTemplate(str, { name: "John", age: "20" })
|
|
170
|
+
* // Result: "Hello John, you are 20 years old."
|
|
171
|
+
*/
|
|
172
|
+
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
173
|
+
//#endregion
|
|
17
174
|
export { BuildType, ConfigBuilder, ConfigResponse, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, ProviderConfig, banner, colors, copyDirToTmp, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, encryptJson, getAndroidSdkPath, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, p, printBanner, transformEnv, transformTemplate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,174 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import colors from "picocolors";
|
|
2
|
+
import { ConfigInput, Platform, RequiredDeep } from "@hot-updater/plugin-core";
|
|
3
|
+
import * as p from "@clack/prompts";
|
|
4
|
+
|
|
5
|
+
//#region src/banner.d.ts
|
|
6
|
+
declare const link: (url: string) => string;
|
|
7
|
+
declare const banner: (version?: string) => string;
|
|
8
|
+
declare const printBanner: (version?: string) => void;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/ConfigBuilder.d.ts
|
|
11
|
+
type BuildType = "bare" | "rock" | "expo";
|
|
12
|
+
type ImportInfo = {
|
|
13
|
+
pkg: string;
|
|
14
|
+
named?: string[];
|
|
15
|
+
defaultOrNamespace?: string;
|
|
16
|
+
sideEffect?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type ProviderConfig = {
|
|
19
|
+
imports: ImportInfo[];
|
|
20
|
+
configString: string;
|
|
21
|
+
};
|
|
22
|
+
interface IConfigBuilder {
|
|
23
|
+
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
24
|
+
setBuildType(buildType: BuildType): this;
|
|
25
|
+
/** Sets the storage configuration and adds its required imports. */
|
|
26
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
27
|
+
/** Sets the database configuration and adds its required imports. */
|
|
28
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
29
|
+
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
30
|
+
setIntermediateCode(code: string): this;
|
|
31
|
+
/** Assembles and returns the final configuration string. */
|
|
32
|
+
getResult(): string;
|
|
33
|
+
}
|
|
34
|
+
declare class ConfigBuilder implements IConfigBuilder {
|
|
35
|
+
private buildType;
|
|
36
|
+
private storageInfo;
|
|
37
|
+
private databaseInfo;
|
|
38
|
+
private intermediateCode;
|
|
39
|
+
private collectedImports;
|
|
40
|
+
constructor();
|
|
41
|
+
addImport(info: ImportInfo): this;
|
|
42
|
+
private addImports;
|
|
43
|
+
private generateImportStatements;
|
|
44
|
+
private generateBuildConfigString;
|
|
45
|
+
setBuildType(buildType: BuildType): this;
|
|
46
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
47
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
48
|
+
setIntermediateCode(code: string): this;
|
|
49
|
+
getResult(): string;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/copyDirToTmp.d.ts
|
|
53
|
+
declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
54
|
+
tmpDir: string;
|
|
55
|
+
removeTmpDir: () => Promise<void>;
|
|
56
|
+
}>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/createTarBr.d.ts
|
|
59
|
+
declare const createTarBrTargetFiles: ({
|
|
60
|
+
outfile,
|
|
61
|
+
targetFiles
|
|
62
|
+
}: {
|
|
63
|
+
targetFiles: {
|
|
64
|
+
path: string;
|
|
65
|
+
name: string;
|
|
66
|
+
}[];
|
|
67
|
+
outfile: string;
|
|
68
|
+
}) => Promise<string>;
|
|
69
|
+
declare const createTarBr: ({
|
|
70
|
+
outfile,
|
|
71
|
+
targetDir,
|
|
72
|
+
excludeExts
|
|
73
|
+
}: {
|
|
74
|
+
targetDir: string;
|
|
75
|
+
outfile: string;
|
|
76
|
+
excludeExts?: string[];
|
|
77
|
+
}) => Promise<string>;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/createTarGz.d.ts
|
|
80
|
+
declare const createTarGzTargetFiles: ({
|
|
81
|
+
outfile,
|
|
82
|
+
targetFiles
|
|
83
|
+
}: {
|
|
84
|
+
targetFiles: {
|
|
85
|
+
path: string;
|
|
86
|
+
name: string;
|
|
87
|
+
}[];
|
|
88
|
+
outfile: string;
|
|
89
|
+
}) => Promise<string>;
|
|
90
|
+
declare const createTarGz: ({
|
|
91
|
+
outfile,
|
|
92
|
+
targetDir,
|
|
93
|
+
excludeExts
|
|
94
|
+
}: {
|
|
95
|
+
targetDir: string;
|
|
96
|
+
outfile: string;
|
|
97
|
+
excludeExts?: string[];
|
|
98
|
+
}) => Promise<string>;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/createZip.d.ts
|
|
101
|
+
declare const createZipTargetFiles: ({
|
|
102
|
+
outfile,
|
|
103
|
+
targetFiles
|
|
104
|
+
}: {
|
|
105
|
+
targetFiles: {
|
|
106
|
+
path: string;
|
|
107
|
+
name: string;
|
|
108
|
+
}[];
|
|
109
|
+
outfile: string;
|
|
110
|
+
}) => Promise<string>;
|
|
111
|
+
declare const createZip: ({
|
|
112
|
+
outfile,
|
|
113
|
+
targetDir,
|
|
114
|
+
excludeExts
|
|
115
|
+
}: {
|
|
116
|
+
targetDir: string;
|
|
117
|
+
outfile: string;
|
|
118
|
+
excludeExts?: string[];
|
|
119
|
+
}) => Promise<string>;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/crypto.d.ts
|
|
122
|
+
declare const encryptJson: (jsonData: Record<string, any>, secretKey: string) => string;
|
|
123
|
+
declare const decryptJson: <T>(encryptedData: string, secretKey: string) => T;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/cwd.d.ts
|
|
126
|
+
declare const getCwd: () => string;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/getAndroidSdkPath.d.ts
|
|
129
|
+
declare function getAndroidSdkPath(): string;
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/loadConfig.d.ts
|
|
132
|
+
type HotUpdaterConfigOptions = {
|
|
133
|
+
platform: Platform;
|
|
134
|
+
channel: string;
|
|
135
|
+
} | null;
|
|
136
|
+
type ConfigResponse = RequiredDeep<ConfigInput>;
|
|
137
|
+
declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
|
|
138
|
+
declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/log.d.ts
|
|
141
|
+
declare const log: {
|
|
142
|
+
normal: (message: string | number | null | undefined) => void;
|
|
143
|
+
success: (message: string | number | null | undefined) => void;
|
|
144
|
+
info: (message: string | number | null | undefined) => void;
|
|
145
|
+
error: (message: string | number | null | undefined) => void;
|
|
146
|
+
warn: (message: string | number | null | undefined) => void;
|
|
147
|
+
debug: (message: string | number | null | undefined) => void;
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/makeEnv.d.ts
|
|
151
|
+
type EnvVarValue = string | {
|
|
152
|
+
comment: string;
|
|
153
|
+
value: string;
|
|
154
|
+
};
|
|
155
|
+
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/transformEnv.d.ts
|
|
158
|
+
declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/transformTemplate.d.ts
|
|
161
|
+
type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
|
|
162
|
+
type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]: string };
|
|
163
|
+
/**
|
|
164
|
+
* Replaces placeholders in the format %%key%% in a template string with values from the values object.
|
|
165
|
+
* Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* const str = "Hello %%name%%, you are %%age%% years old."
|
|
169
|
+
* const result = transformTemplate(str, { name: "John", age: "20" })
|
|
170
|
+
* // Result: "Hello John, you are 20 years old."
|
|
171
|
+
*/
|
|
172
|
+
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
173
|
+
//#endregion
|
|
17
174
|
export { BuildType, ConfigBuilder, ConfigResponse, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, ProviderConfig, banner, colors, copyDirToTmp, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, encryptJson, getAndroidSdkPath, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, p, printBanner, transformEnv, transformTemplate };
|