@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.
Files changed (70) hide show
  1. package/dist/index.cjs +79804 -43
  2. package/dist/index.d.cts +173 -16
  3. package/dist/index.d.ts +173 -16
  4. package/dist/index.js +79765 -18
  5. package/package.json +14 -6
  6. package/dist/ConfigBuilder.cjs +0 -122
  7. package/dist/ConfigBuilder.d.cts +0 -43
  8. package/dist/ConfigBuilder.d.ts +0 -43
  9. package/dist/ConfigBuilder.js +0 -121
  10. package/dist/_virtual/rolldown_runtime.cjs +0 -25
  11. package/dist/banner.cjs +0 -29
  12. package/dist/banner.d.cts +0 -6
  13. package/dist/banner.d.ts +0 -6
  14. package/dist/banner.js +0 -24
  15. package/dist/colors.d.cts +0 -2
  16. package/dist/colors.d.ts +0 -2
  17. package/dist/colors.js +0 -3
  18. package/dist/copyDirToTmp.cjs +0 -28
  19. package/dist/copyDirToTmp.d.cts +0 -7
  20. package/dist/copyDirToTmp.d.ts +0 -7
  21. package/dist/copyDirToTmp.js +0 -25
  22. package/dist/createTarBr.cjs +0 -94
  23. package/dist/createTarBr.d.cts +0 -22
  24. package/dist/createTarBr.d.ts +0 -22
  25. package/dist/createTarBr.js +0 -88
  26. package/dist/createTarGz.cjs +0 -78
  27. package/dist/createTarGz.d.cts +0 -22
  28. package/dist/createTarGz.d.ts +0 -22
  29. package/dist/createTarGz.js +0 -73
  30. package/dist/createZip.cjs +0 -80
  31. package/dist/createZip.d.cts +0 -22
  32. package/dist/createZip.d.ts +0 -22
  33. package/dist/createZip.js +0 -75
  34. package/dist/crypto.cjs +0 -27
  35. package/dist/crypto.d.cts +0 -5
  36. package/dist/crypto.d.ts +0 -5
  37. package/dist/crypto.js +0 -24
  38. package/dist/cwd.cjs +0 -9
  39. package/dist/cwd.d.cts +0 -4
  40. package/dist/cwd.d.ts +0 -4
  41. package/dist/cwd.js +0 -7
  42. package/dist/getAndroidSdkPath.cjs +0 -10
  43. package/dist/getAndroidSdkPath.d.cts +0 -4
  44. package/dist/getAndroidSdkPath.d.ts +0 -4
  45. package/dist/getAndroidSdkPath.js +0 -9
  46. package/dist/isObject.cjs +0 -8
  47. package/dist/isObject.js +0 -7
  48. package/dist/loadConfig.cjs +0 -100
  49. package/dist/loadConfig.d.cts +0 -12
  50. package/dist/loadConfig.d.ts +0 -12
  51. package/dist/loadConfig.js +0 -93
  52. package/dist/log.cjs +0 -16
  53. package/dist/log.d.cts +0 -11
  54. package/dist/log.d.ts +0 -11
  55. package/dist/log.js +0 -14
  56. package/dist/makeEnv.cjs +0 -57
  57. package/dist/makeEnv.d.cts +0 -8
  58. package/dist/makeEnv.d.ts +0 -8
  59. package/dist/makeEnv.js +0 -55
  60. package/dist/prompts.d.cts +0 -2
  61. package/dist/prompts.d.ts +0 -2
  62. package/dist/prompts.js +0 -3
  63. package/dist/transformEnv.cjs +0 -14
  64. package/dist/transformEnv.d.cts +0 -4
  65. package/dist/transformEnv.d.ts +0 -4
  66. package/dist/transformEnv.js +0 -11
  67. package/dist/transformTemplate.cjs +0 -22
  68. package/dist/transformTemplate.d.cts +0 -15
  69. package/dist/transformTemplate.d.ts +0 -15
  70. package/dist/transformTemplate.js +0 -21
package/dist/index.d.cts CHANGED
@@ -1,17 +1,174 @@
1
- import { banner, link, printBanner } from "./banner.cjs";
2
- import { BuildType, ConfigBuilder, IConfigBuilder, ImportInfo, ProviderConfig } from "./ConfigBuilder.cjs";
3
- import { colors } from "./colors.cjs";
4
- import { copyDirToTmp } from "./copyDirToTmp.cjs";
5
- import { createTarBr, createTarBrTargetFiles } from "./createTarBr.cjs";
6
- import { createTarGz, createTarGzTargetFiles } from "./createTarGz.cjs";
7
- import { createZip, createZipTargetFiles } from "./createZip.cjs";
8
- import { decryptJson, encryptJson } from "./crypto.cjs";
9
- import { getCwd } from "./cwd.cjs";
10
- import { getAndroidSdkPath } from "./getAndroidSdkPath.cjs";
11
- import { ConfigResponse, HotUpdaterConfigOptions, loadConfig, loadConfigSync } from "./loadConfig.cjs";
12
- import { log } from "./log.cjs";
13
- import { makeEnv } from "./makeEnv.cjs";
14
- import { p } from "./prompts.cjs";
15
- import { transformEnv } from "./transformEnv.cjs";
16
- import { transformTemplate } from "./transformTemplate.cjs";
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 { banner, link, printBanner } from "./banner.js";
2
- import { BuildType, ConfigBuilder, IConfigBuilder, ImportInfo, ProviderConfig } from "./ConfigBuilder.js";
3
- import { colors } from "./colors.js";
4
- import { copyDirToTmp } from "./copyDirToTmp.js";
5
- import { createTarBr, createTarBrTargetFiles } from "./createTarBr.js";
6
- import { createTarGz, createTarGzTargetFiles } from "./createTarGz.js";
7
- import { createZip, createZipTargetFiles } from "./createZip.js";
8
- import { decryptJson, encryptJson } from "./crypto.js";
9
- import { getCwd } from "./cwd.js";
10
- import { getAndroidSdkPath } from "./getAndroidSdkPath.js";
11
- import { ConfigResponse, HotUpdaterConfigOptions, loadConfig, loadConfigSync } from "./loadConfig.js";
12
- import { log } from "./log.js";
13
- import { makeEnv } from "./makeEnv.js";
14
- import { p } from "./prompts.js";
15
- import { transformEnv } from "./transformEnv.js";
16
- import { transformTemplate } from "./transformTemplate.js";
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 };