@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/cli-tools",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI utilities for Hot Updater",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"oxc-transform": "0.82.1",
|
|
43
|
+
"@hot-updater/plugin-core": "0.21.12"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
42
46
|
"@clack/prompts": "0.11.0",
|
|
43
47
|
"boxen": "^8.0.1",
|
|
44
48
|
"cosmiconfig": "9.0.0",
|
|
@@ -46,16 +50,20 @@
|
|
|
46
50
|
"es-toolkit": "^1.32.0",
|
|
47
51
|
"fast-glob": "3.3.3",
|
|
48
52
|
"jszip": "^3.10.1",
|
|
49
|
-
"oxc-transform": "0.82.1",
|
|
50
53
|
"picocolors": "1.1.1",
|
|
51
54
|
"tar": "^7.5.1",
|
|
52
55
|
"workspace-tools": "^0.36.4",
|
|
53
|
-
"@hot-updater/plugin-core": "0.21.10"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
56
|
"@types/node": "^20",
|
|
57
57
|
"typescript": "5.8.2",
|
|
58
|
-
"@hot-updater/test-utils": "0.21.
|
|
58
|
+
"@hot-updater/test-utils": "0.21.12"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"typescript": "*"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"typescript": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
59
67
|
},
|
|
60
68
|
"scripts": {
|
|
61
69
|
"build": "tsdown",
|
package/dist/ConfigBuilder.cjs
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/ConfigBuilder.ts
|
|
3
|
-
var ConfigBuilder = class {
|
|
4
|
-
buildType = null;
|
|
5
|
-
storageInfo = null;
|
|
6
|
-
databaseInfo = null;
|
|
7
|
-
intermediateCode = "";
|
|
8
|
-
collectedImports = /* @__PURE__ */ new Map();
|
|
9
|
-
constructor() {
|
|
10
|
-
this.addImport({
|
|
11
|
-
pkg: "dotenv",
|
|
12
|
-
named: ["config"]
|
|
13
|
-
});
|
|
14
|
-
this.addImport({
|
|
15
|
-
pkg: "hot-updater",
|
|
16
|
-
named: ["defineConfig"]
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
addImport(info) {
|
|
20
|
-
const pkg = info.pkg;
|
|
21
|
-
const existing = this.collectedImports.get(pkg);
|
|
22
|
-
if (existing) {
|
|
23
|
-
if (info.named) for (const n of info.named) existing.named.add(n);
|
|
24
|
-
if (info.defaultOrNamespace && !existing.defaultOrNamespace) existing.defaultOrNamespace = info.defaultOrNamespace;
|
|
25
|
-
if (info.sideEffect && !existing.sideEffect) existing.sideEffect = true;
|
|
26
|
-
} else this.collectedImports.set(pkg, {
|
|
27
|
-
named: new Set(info.named ?? []),
|
|
28
|
-
defaultOrNamespace: info.defaultOrNamespace,
|
|
29
|
-
sideEffect: info.sideEffect ?? false
|
|
30
|
-
});
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
addImports(imports) {
|
|
34
|
-
for (const imp of imports) this.addImport(imp);
|
|
35
|
-
}
|
|
36
|
-
generateImportStatements() {
|
|
37
|
-
const importLines = [];
|
|
38
|
-
const sortedPackages = Array.from(this.collectedImports.keys()).sort((a, b) => {
|
|
39
|
-
const isABuild = a.startsWith("@hot-updater/");
|
|
40
|
-
if (isABuild !== b.startsWith("@hot-updater/")) return isABuild ? -1 : 1;
|
|
41
|
-
if (a === "dotenv/config") return -1;
|
|
42
|
-
if (b === "dotenv/config") return 1;
|
|
43
|
-
const isAdminA = a === "firebase-admin";
|
|
44
|
-
if (isAdminA !== (b === "firebase-admin")) return isAdminA ? -1 : 1;
|
|
45
|
-
return a.localeCompare(b);
|
|
46
|
-
});
|
|
47
|
-
for (const pkg of sortedPackages) {
|
|
48
|
-
const info = this.collectedImports.get(pkg);
|
|
49
|
-
if (info.sideEffect) importLines.push(`import "${pkg}";`);
|
|
50
|
-
else if (info.defaultOrNamespace) if (pkg === "firebase-admin" && info.named.size > 0) importLines.push(`import ${info.defaultOrNamespace}, { ${Array.from(info.named).sort().join(", ")} } from "${pkg}";`);
|
|
51
|
-
else importLines.push(`import ${info.defaultOrNamespace} from "${pkg}";`);
|
|
52
|
-
else if (info.named.size > 0) {
|
|
53
|
-
const namedPart = Array.from(info.named).sort().join(", ");
|
|
54
|
-
importLines.push(`import { ${namedPart} } from "${pkg}";`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return importLines.join("\n");
|
|
58
|
-
}
|
|
59
|
-
generateBuildConfigString() {
|
|
60
|
-
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
61
|
-
switch (this.buildType) {
|
|
62
|
-
case "bare": return "bare({ enableHermes: true })";
|
|
63
|
-
case "rock": return "rock()";
|
|
64
|
-
case "expo": return "expo()";
|
|
65
|
-
default: throw new Error(`Invalid build type: ${this.buildType}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
setBuildType(buildType) {
|
|
69
|
-
if (this.buildType) console.warn("Build type is being set multiple times. Overwriting previous value.");
|
|
70
|
-
this.buildType = buildType;
|
|
71
|
-
this.addImport({
|
|
72
|
-
pkg: `@hot-updater/${buildType}`,
|
|
73
|
-
named: [buildType]
|
|
74
|
-
});
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
setStorage(storageConfig) {
|
|
78
|
-
this.storageInfo = storageConfig;
|
|
79
|
-
this.addImports(storageConfig.imports);
|
|
80
|
-
if (storageConfig.imports.some((imp) => imp.pkg.includes("firebase"))) this.addImport({
|
|
81
|
-
pkg: "firebase-admin",
|
|
82
|
-
defaultOrNamespace: "* as admin"
|
|
83
|
-
});
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
setDatabase(databaseConfig) {
|
|
87
|
-
this.databaseInfo = databaseConfig;
|
|
88
|
-
this.addImports(databaseConfig.imports);
|
|
89
|
-
if (databaseConfig.imports.some((imp) => imp.pkg.includes("firebase"))) this.addImport({
|
|
90
|
-
pkg: "firebase-admin",
|
|
91
|
-
defaultOrNamespace: "* as admin"
|
|
92
|
-
});
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
setIntermediateCode(code) {
|
|
96
|
-
this.intermediateCode = code.trim();
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
getResult() {
|
|
100
|
-
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
101
|
-
if (!this.storageInfo) throw new Error("Storage config must be set using .setStorage()");
|
|
102
|
-
if (!this.databaseInfo) throw new Error("Database config must be set using .setDatabase()");
|
|
103
|
-
const importStatements = this.generateImportStatements();
|
|
104
|
-
const buildConfigString = this.generateBuildConfigString();
|
|
105
|
-
return `
|
|
106
|
-
${importStatements}
|
|
107
|
-
|
|
108
|
-
config({ path: ".env.hotupdater" });
|
|
109
|
-
|
|
110
|
-
${this.intermediateCode ? `${this.intermediateCode}\n` : ""}
|
|
111
|
-
export default defineConfig({
|
|
112
|
-
build: ${buildConfigString},
|
|
113
|
-
storage: ${this.storageInfo.configString},
|
|
114
|
-
database: ${this.databaseInfo.configString},
|
|
115
|
-
updateStrategy: "appVersion", // or "fingerprint"
|
|
116
|
-
});
|
|
117
|
-
`.trim();
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
exports.ConfigBuilder = ConfigBuilder;
|
package/dist/ConfigBuilder.d.cts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region src/ConfigBuilder.d.ts
|
|
2
|
-
type BuildType = "bare" | "rock" | "expo";
|
|
3
|
-
type ImportInfo = {
|
|
4
|
-
pkg: string;
|
|
5
|
-
named?: string[];
|
|
6
|
-
defaultOrNamespace?: string;
|
|
7
|
-
sideEffect?: boolean;
|
|
8
|
-
};
|
|
9
|
-
type ProviderConfig = {
|
|
10
|
-
imports: ImportInfo[];
|
|
11
|
-
configString: string;
|
|
12
|
-
};
|
|
13
|
-
interface IConfigBuilder {
|
|
14
|
-
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
15
|
-
setBuildType(buildType: BuildType): this;
|
|
16
|
-
/** Sets the storage configuration and adds its required imports. */
|
|
17
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
18
|
-
/** Sets the database configuration and adds its required imports. */
|
|
19
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
20
|
-
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
21
|
-
setIntermediateCode(code: string): this;
|
|
22
|
-
/** Assembles and returns the final configuration string. */
|
|
23
|
-
getResult(): string;
|
|
24
|
-
}
|
|
25
|
-
declare class ConfigBuilder implements IConfigBuilder {
|
|
26
|
-
private buildType;
|
|
27
|
-
private storageInfo;
|
|
28
|
-
private databaseInfo;
|
|
29
|
-
private intermediateCode;
|
|
30
|
-
private collectedImports;
|
|
31
|
-
constructor();
|
|
32
|
-
addImport(info: ImportInfo): this;
|
|
33
|
-
private addImports;
|
|
34
|
-
private generateImportStatements;
|
|
35
|
-
private generateBuildConfigString;
|
|
36
|
-
setBuildType(buildType: BuildType): this;
|
|
37
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
38
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
39
|
-
setIntermediateCode(code: string): this;
|
|
40
|
-
getResult(): string;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { BuildType, ConfigBuilder, IConfigBuilder, ImportInfo, ProviderConfig };
|
package/dist/ConfigBuilder.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region src/ConfigBuilder.d.ts
|
|
2
|
-
type BuildType = "bare" | "rock" | "expo";
|
|
3
|
-
type ImportInfo = {
|
|
4
|
-
pkg: string;
|
|
5
|
-
named?: string[];
|
|
6
|
-
defaultOrNamespace?: string;
|
|
7
|
-
sideEffect?: boolean;
|
|
8
|
-
};
|
|
9
|
-
type ProviderConfig = {
|
|
10
|
-
imports: ImportInfo[];
|
|
11
|
-
configString: string;
|
|
12
|
-
};
|
|
13
|
-
interface IConfigBuilder {
|
|
14
|
-
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
15
|
-
setBuildType(buildType: BuildType): this;
|
|
16
|
-
/** Sets the storage configuration and adds its required imports. */
|
|
17
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
18
|
-
/** Sets the database configuration and adds its required imports. */
|
|
19
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
20
|
-
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
21
|
-
setIntermediateCode(code: string): this;
|
|
22
|
-
/** Assembles and returns the final configuration string. */
|
|
23
|
-
getResult(): string;
|
|
24
|
-
}
|
|
25
|
-
declare class ConfigBuilder implements IConfigBuilder {
|
|
26
|
-
private buildType;
|
|
27
|
-
private storageInfo;
|
|
28
|
-
private databaseInfo;
|
|
29
|
-
private intermediateCode;
|
|
30
|
-
private collectedImports;
|
|
31
|
-
constructor();
|
|
32
|
-
addImport(info: ImportInfo): this;
|
|
33
|
-
private addImports;
|
|
34
|
-
private generateImportStatements;
|
|
35
|
-
private generateBuildConfigString;
|
|
36
|
-
setBuildType(buildType: BuildType): this;
|
|
37
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
38
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
39
|
-
setIntermediateCode(code: string): this;
|
|
40
|
-
getResult(): string;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { BuildType, ConfigBuilder, IConfigBuilder, ImportInfo, ProviderConfig };
|
package/dist/ConfigBuilder.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
//#region src/ConfigBuilder.ts
|
|
2
|
-
var ConfigBuilder = class {
|
|
3
|
-
buildType = null;
|
|
4
|
-
storageInfo = null;
|
|
5
|
-
databaseInfo = null;
|
|
6
|
-
intermediateCode = "";
|
|
7
|
-
collectedImports = /* @__PURE__ */ new Map();
|
|
8
|
-
constructor() {
|
|
9
|
-
this.addImport({
|
|
10
|
-
pkg: "dotenv",
|
|
11
|
-
named: ["config"]
|
|
12
|
-
});
|
|
13
|
-
this.addImport({
|
|
14
|
-
pkg: "hot-updater",
|
|
15
|
-
named: ["defineConfig"]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
addImport(info) {
|
|
19
|
-
const pkg = info.pkg;
|
|
20
|
-
const existing = this.collectedImports.get(pkg);
|
|
21
|
-
if (existing) {
|
|
22
|
-
if (info.named) for (const n of info.named) existing.named.add(n);
|
|
23
|
-
if (info.defaultOrNamespace && !existing.defaultOrNamespace) existing.defaultOrNamespace = info.defaultOrNamespace;
|
|
24
|
-
if (info.sideEffect && !existing.sideEffect) existing.sideEffect = true;
|
|
25
|
-
} else this.collectedImports.set(pkg, {
|
|
26
|
-
named: new Set(info.named ?? []),
|
|
27
|
-
defaultOrNamespace: info.defaultOrNamespace,
|
|
28
|
-
sideEffect: info.sideEffect ?? false
|
|
29
|
-
});
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
addImports(imports) {
|
|
33
|
-
for (const imp of imports) this.addImport(imp);
|
|
34
|
-
}
|
|
35
|
-
generateImportStatements() {
|
|
36
|
-
const importLines = [];
|
|
37
|
-
const sortedPackages = Array.from(this.collectedImports.keys()).sort((a, b) => {
|
|
38
|
-
const isABuild = a.startsWith("@hot-updater/");
|
|
39
|
-
if (isABuild !== b.startsWith("@hot-updater/")) return isABuild ? -1 : 1;
|
|
40
|
-
if (a === "dotenv/config") return -1;
|
|
41
|
-
if (b === "dotenv/config") return 1;
|
|
42
|
-
const isAdminA = a === "firebase-admin";
|
|
43
|
-
if (isAdminA !== (b === "firebase-admin")) return isAdminA ? -1 : 1;
|
|
44
|
-
return a.localeCompare(b);
|
|
45
|
-
});
|
|
46
|
-
for (const pkg of sortedPackages) {
|
|
47
|
-
const info = this.collectedImports.get(pkg);
|
|
48
|
-
if (info.sideEffect) importLines.push(`import "${pkg}";`);
|
|
49
|
-
else if (info.defaultOrNamespace) if (pkg === "firebase-admin" && info.named.size > 0) importLines.push(`import ${info.defaultOrNamespace}, { ${Array.from(info.named).sort().join(", ")} } from "${pkg}";`);
|
|
50
|
-
else importLines.push(`import ${info.defaultOrNamespace} from "${pkg}";`);
|
|
51
|
-
else if (info.named.size > 0) {
|
|
52
|
-
const namedPart = Array.from(info.named).sort().join(", ");
|
|
53
|
-
importLines.push(`import { ${namedPart} } from "${pkg}";`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return importLines.join("\n");
|
|
57
|
-
}
|
|
58
|
-
generateBuildConfigString() {
|
|
59
|
-
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
60
|
-
switch (this.buildType) {
|
|
61
|
-
case "bare": return "bare({ enableHermes: true })";
|
|
62
|
-
case "rock": return "rock()";
|
|
63
|
-
case "expo": return "expo()";
|
|
64
|
-
default: throw new Error(`Invalid build type: ${this.buildType}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
setBuildType(buildType) {
|
|
68
|
-
if (this.buildType) console.warn("Build type is being set multiple times. Overwriting previous value.");
|
|
69
|
-
this.buildType = buildType;
|
|
70
|
-
this.addImport({
|
|
71
|
-
pkg: `@hot-updater/${buildType}`,
|
|
72
|
-
named: [buildType]
|
|
73
|
-
});
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
setStorage(storageConfig) {
|
|
77
|
-
this.storageInfo = storageConfig;
|
|
78
|
-
this.addImports(storageConfig.imports);
|
|
79
|
-
if (storageConfig.imports.some((imp) => imp.pkg.includes("firebase"))) this.addImport({
|
|
80
|
-
pkg: "firebase-admin",
|
|
81
|
-
defaultOrNamespace: "* as admin"
|
|
82
|
-
});
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
setDatabase(databaseConfig) {
|
|
86
|
-
this.databaseInfo = databaseConfig;
|
|
87
|
-
this.addImports(databaseConfig.imports);
|
|
88
|
-
if (databaseConfig.imports.some((imp) => imp.pkg.includes("firebase"))) this.addImport({
|
|
89
|
-
pkg: "firebase-admin",
|
|
90
|
-
defaultOrNamespace: "* as admin"
|
|
91
|
-
});
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
setIntermediateCode(code) {
|
|
95
|
-
this.intermediateCode = code.trim();
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
getResult() {
|
|
99
|
-
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
100
|
-
if (!this.storageInfo) throw new Error("Storage config must be set using .setStorage()");
|
|
101
|
-
if (!this.databaseInfo) throw new Error("Database config must be set using .setDatabase()");
|
|
102
|
-
const importStatements = this.generateImportStatements();
|
|
103
|
-
const buildConfigString = this.generateBuildConfigString();
|
|
104
|
-
return `
|
|
105
|
-
${importStatements}
|
|
106
|
-
|
|
107
|
-
config({ path: ".env.hotupdater" });
|
|
108
|
-
|
|
109
|
-
${this.intermediateCode ? `${this.intermediateCode}\n` : ""}
|
|
110
|
-
export default defineConfig({
|
|
111
|
-
build: ${buildConfigString},
|
|
112
|
-
storage: ${this.storageInfo.configString},
|
|
113
|
-
database: ${this.databaseInfo.configString},
|
|
114
|
-
updateStrategy: "appVersion", // or "fingerprint"
|
|
115
|
-
});
|
|
116
|
-
`.trim();
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
//#endregion
|
|
121
|
-
export { ConfigBuilder };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
|
|
25
|
-
exports.__toESM = __toESM;
|
package/dist/banner.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let boxen = require("boxen");
|
|
3
|
-
boxen = require_rolldown_runtime.__toESM(boxen);
|
|
4
|
-
let picocolors = require("picocolors");
|
|
5
|
-
picocolors = require_rolldown_runtime.__toESM(picocolors);
|
|
6
|
-
|
|
7
|
-
//#region src/banner.ts
|
|
8
|
-
const link = (url) => {
|
|
9
|
-
return picocolors.default.green(picocolors.default.underline(url));
|
|
10
|
-
};
|
|
11
|
-
const banner = (version) => (0, boxen.default)([
|
|
12
|
-
`${picocolors.default.bold("Hot Updater - React Native OTA Solution")} ${version ? `v${version}` : ""}`,
|
|
13
|
-
"",
|
|
14
|
-
`Github: ${link("https://github.com/gronxb/hot-updater")}`,
|
|
15
|
-
"Give a ⭐️ if you like it!"
|
|
16
|
-
].join("\n"), {
|
|
17
|
-
padding: 1,
|
|
18
|
-
borderStyle: "round",
|
|
19
|
-
borderColor: "green",
|
|
20
|
-
textAlignment: "center"
|
|
21
|
-
});
|
|
22
|
-
const printBanner = (version) => {
|
|
23
|
-
console.log(banner(version));
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.banner = banner;
|
|
28
|
-
exports.link = link;
|
|
29
|
-
exports.printBanner = printBanner;
|
package/dist/banner.d.cts
DELETED
package/dist/banner.d.ts
DELETED
package/dist/banner.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import boxen from "boxen";
|
|
2
|
-
import picocolors from "picocolors";
|
|
3
|
-
|
|
4
|
-
//#region src/banner.ts
|
|
5
|
-
const link = (url) => {
|
|
6
|
-
return picocolors.green(picocolors.underline(url));
|
|
7
|
-
};
|
|
8
|
-
const banner = (version) => boxen([
|
|
9
|
-
`${picocolors.bold("Hot Updater - React Native OTA Solution")} ${version ? `v${version}` : ""}`,
|
|
10
|
-
"",
|
|
11
|
-
`Github: ${link("https://github.com/gronxb/hot-updater")}`,
|
|
12
|
-
"Give a ⭐️ if you like it!"
|
|
13
|
-
].join("\n"), {
|
|
14
|
-
padding: 1,
|
|
15
|
-
borderStyle: "round",
|
|
16
|
-
borderColor: "green",
|
|
17
|
-
textAlignment: "center"
|
|
18
|
-
});
|
|
19
|
-
const printBanner = (version) => {
|
|
20
|
-
console.log(banner(version));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { banner, link, printBanner };
|
package/dist/colors.d.cts
DELETED
package/dist/colors.d.ts
DELETED
package/dist/colors.js
DELETED
package/dist/copyDirToTmp.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_cwd = require('./cwd.cjs');
|
|
3
|
-
let fs_promises = require("fs/promises");
|
|
4
|
-
fs_promises = require_rolldown_runtime.__toESM(fs_promises);
|
|
5
|
-
let path = require("path");
|
|
6
|
-
path = require_rolldown_runtime.__toESM(path);
|
|
7
|
-
|
|
8
|
-
//#region src/copyDirToTmp.ts
|
|
9
|
-
const copyDirToTmp = async (dir, childDirname) => {
|
|
10
|
-
const cwd = require_cwd.getCwd();
|
|
11
|
-
const hotUpdaterDir = path.default.join(cwd, ".hot-updater");
|
|
12
|
-
const tmpDir = childDirname ? path.default.join(hotUpdaterDir, childDirname) : hotUpdaterDir;
|
|
13
|
-
try {
|
|
14
|
-
await fs_promises.default.rm(tmpDir, {
|
|
15
|
-
recursive: true,
|
|
16
|
-
force: true
|
|
17
|
-
});
|
|
18
|
-
} catch {}
|
|
19
|
-
await fs_promises.default.mkdir(tmpDir, { recursive: true });
|
|
20
|
-
await fs_promises.default.cp(dir, tmpDir, { recursive: true });
|
|
21
|
-
return {
|
|
22
|
-
tmpDir: hotUpdaterDir,
|
|
23
|
-
removeTmpDir: () => fs_promises.default.rm(hotUpdaterDir, { recursive: true })
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
exports.copyDirToTmp = copyDirToTmp;
|
package/dist/copyDirToTmp.d.cts
DELETED
package/dist/copyDirToTmp.d.ts
DELETED
package/dist/copyDirToTmp.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getCwd } from "./cwd.js";
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
//#region src/copyDirToTmp.ts
|
|
6
|
-
const copyDirToTmp = async (dir, childDirname) => {
|
|
7
|
-
const cwd = getCwd();
|
|
8
|
-
const hotUpdaterDir = path.join(cwd, ".hot-updater");
|
|
9
|
-
const tmpDir = childDirname ? path.join(hotUpdaterDir, childDirname) : hotUpdaterDir;
|
|
10
|
-
try {
|
|
11
|
-
await fs.rm(tmpDir, {
|
|
12
|
-
recursive: true,
|
|
13
|
-
force: true
|
|
14
|
-
});
|
|
15
|
-
} catch {}
|
|
16
|
-
await fs.mkdir(tmpDir, { recursive: true });
|
|
17
|
-
await fs.cp(dir, tmpDir, { recursive: true });
|
|
18
|
-
return {
|
|
19
|
-
tmpDir: hotUpdaterDir,
|
|
20
|
-
removeTmpDir: () => fs.rm(hotUpdaterDir, { recursive: true })
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { copyDirToTmp };
|
package/dist/createTarBr.cjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let fs_promises = require("fs/promises");
|
|
3
|
-
fs_promises = require_rolldown_runtime.__toESM(fs_promises);
|
|
4
|
-
let path = require("path");
|
|
5
|
-
path = require_rolldown_runtime.__toESM(path);
|
|
6
|
-
let tar = require("tar");
|
|
7
|
-
tar = require_rolldown_runtime.__toESM(tar);
|
|
8
|
-
let zlib = require("zlib");
|
|
9
|
-
zlib = require_rolldown_runtime.__toESM(zlib);
|
|
10
|
-
|
|
11
|
-
//#region src/createTarBr.ts
|
|
12
|
-
const createTarBrTargetFiles = async ({ outfile, targetFiles }) => {
|
|
13
|
-
await fs_promises.default.rm(outfile, { force: true });
|
|
14
|
-
const tmpDir = path.default.join(path.default.dirname(outfile), `.tmp-tar-${Date.now()}`);
|
|
15
|
-
await fs_promises.default.mkdir(tmpDir, { recursive: true });
|
|
16
|
-
try {
|
|
17
|
-
for (const target of targetFiles) {
|
|
18
|
-
const sourcePath = target.path;
|
|
19
|
-
const destPath = path.default.join(tmpDir, target.name);
|
|
20
|
-
await fs_promises.default.mkdir(path.default.dirname(destPath), { recursive: true });
|
|
21
|
-
if ((await fs_promises.default.stat(sourcePath)).isDirectory()) await copyDir(sourcePath, destPath);
|
|
22
|
-
else await fs_promises.default.copyFile(sourcePath, destPath);
|
|
23
|
-
}
|
|
24
|
-
const tmpTarFile = outfile.replace(/\.tar\.br$/, ".tar");
|
|
25
|
-
await tar.create({
|
|
26
|
-
file: tmpTarFile,
|
|
27
|
-
cwd: tmpDir,
|
|
28
|
-
portable: true,
|
|
29
|
-
mtime: /* @__PURE__ */ new Date(0),
|
|
30
|
-
gzip: false
|
|
31
|
-
}, await fs_promises.default.readdir(tmpDir));
|
|
32
|
-
const compressedData = (0, zlib.brotliCompressSync)(await fs_promises.default.readFile(tmpTarFile), { params: {
|
|
33
|
-
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
|
|
34
|
-
[zlib.constants.BROTLI_PARAM_LGWIN]: 24
|
|
35
|
-
} });
|
|
36
|
-
await fs_promises.default.mkdir(path.default.dirname(outfile), { recursive: true });
|
|
37
|
-
await fs_promises.default.writeFile(outfile, compressedData);
|
|
38
|
-
await fs_promises.default.rm(tmpTarFile, { force: true });
|
|
39
|
-
return outfile;
|
|
40
|
-
} finally {
|
|
41
|
-
await fs_promises.default.rm(tmpDir, {
|
|
42
|
-
recursive: true,
|
|
43
|
-
force: true
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
async function copyDir(src, dest) {
|
|
48
|
-
await fs_promises.default.mkdir(dest, { recursive: true });
|
|
49
|
-
const entries = await fs_promises.default.readdir(src, { withFileTypes: true });
|
|
50
|
-
for (const entry of entries) {
|
|
51
|
-
const srcPath = path.default.join(src, entry.name);
|
|
52
|
-
const destPath = path.default.join(dest, entry.name);
|
|
53
|
-
if (entry.isDirectory()) await copyDir(srcPath, destPath);
|
|
54
|
-
else await fs_promises.default.copyFile(srcPath, destPath);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const createTarBr = async ({ outfile, targetDir, excludeExts = [] }) => {
|
|
58
|
-
await fs_promises.default.rm(outfile, { force: true });
|
|
59
|
-
const tmpTarFile = outfile.replace(/\.tar\.br$/, ".tar");
|
|
60
|
-
async function getFiles(dir, baseDir = "") {
|
|
61
|
-
const entries = await fs_promises.default.readdir(dir, { withFileTypes: true });
|
|
62
|
-
const files = [];
|
|
63
|
-
for (const entry of entries) {
|
|
64
|
-
if (excludeExts.some((pattern) => entry.name.includes(pattern))) continue;
|
|
65
|
-
const fullPath = path.default.join(dir, entry.name);
|
|
66
|
-
const relativePath = path.default.join(baseDir, entry.name);
|
|
67
|
-
if (entry.isDirectory()) {
|
|
68
|
-
const subFiles = await getFiles(fullPath, relativePath);
|
|
69
|
-
files.push(...subFiles);
|
|
70
|
-
} else files.push(relativePath);
|
|
71
|
-
}
|
|
72
|
-
return files;
|
|
73
|
-
}
|
|
74
|
-
const filesToInclude = await getFiles(targetDir);
|
|
75
|
-
filesToInclude.sort();
|
|
76
|
-
await tar.create({
|
|
77
|
-
file: tmpTarFile,
|
|
78
|
-
cwd: targetDir,
|
|
79
|
-
portable: true,
|
|
80
|
-
mtime: /* @__PURE__ */ new Date(0),
|
|
81
|
-
gzip: false
|
|
82
|
-
}, filesToInclude);
|
|
83
|
-
const compressedData = (0, zlib.brotliCompressSync)(await fs_promises.default.readFile(tmpTarFile), { params: {
|
|
84
|
-
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
|
|
85
|
-
[zlib.constants.BROTLI_PARAM_LGWIN]: 24
|
|
86
|
-
} });
|
|
87
|
-
await fs_promises.default.writeFile(outfile, compressedData);
|
|
88
|
-
await fs_promises.default.rm(tmpTarFile, { force: true });
|
|
89
|
-
return outfile;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
exports.createTarBr = createTarBr;
|
|
94
|
-
exports.createTarBrTargetFiles = createTarBrTargetFiles;
|
package/dist/createTarBr.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/createTarBr.d.ts
|
|
2
|
-
declare const createTarBrTargetFiles: ({
|
|
3
|
-
outfile,
|
|
4
|
-
targetFiles
|
|
5
|
-
}: {
|
|
6
|
-
targetFiles: {
|
|
7
|
-
path: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}[];
|
|
10
|
-
outfile: string;
|
|
11
|
-
}) => Promise<string>;
|
|
12
|
-
declare const createTarBr: ({
|
|
13
|
-
outfile,
|
|
14
|
-
targetDir,
|
|
15
|
-
excludeExts
|
|
16
|
-
}: {
|
|
17
|
-
targetDir: string;
|
|
18
|
-
outfile: string;
|
|
19
|
-
excludeExts?: string[];
|
|
20
|
-
}) => Promise<string>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { createTarBr, createTarBrTargetFiles };
|