hot-updater 0.1.4 → 0.1.5
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/chunk-M76SRQA4.js +48 -0
- package/dist/config.js +4 -1
- package/dist/index.cjs +52 -72
- package/dist/index.js +74 -77
- package/dist/plugins/babel.cjs +15165 -0
- package/dist/plugins/babel.d.cts +5 -0
- package/dist/plugins/babel.d.ts +5 -0
- package/dist/plugins/babel.js +15127 -0
- package/package.json +25 -9
- package/dist/chunk-XCQPUXG2.js +0 -10
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.3.0_@swc+core@1.7.42_@swc+helpers@0.5.15__jiti@1.21.6_postcss@8.4.47_typescript@5.6.2_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
|
|
31
|
+
import { fileURLToPath } from "url";
|
|
32
|
+
import path from "path";
|
|
33
|
+
var getFilename, getDirname, __dirname;
|
|
34
|
+
var init_esm_shims = __esm({
|
|
35
|
+
"../../node_modules/.pnpm/tsup@8.3.0_@swc+core@1.7.42_@swc+helpers@0.5.15__jiti@1.21.6_postcss@8.4.47_typescript@5.6.2_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
|
|
36
|
+
"use strict";
|
|
37
|
+
getFilename = () => fileURLToPath(import.meta.url);
|
|
38
|
+
getDirname = () => path.dirname(getFilename());
|
|
39
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
__commonJS,
|
|
45
|
+
__toESM,
|
|
46
|
+
__dirname,
|
|
47
|
+
init_esm_shims
|
|
48
|
+
};
|
package/dist/config.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
// src/commands/console.ts
|
|
27
27
|
var import_node_server = require("@hono/node-server");
|
|
28
28
|
var import_console = __toESM(require("@hot-updater/console"), 1);
|
|
29
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
29
30
|
var openConsole = () => {
|
|
30
31
|
(0, import_node_server.serve)(
|
|
31
32
|
{
|
|
@@ -33,7 +34,11 @@ var openConsole = () => {
|
|
|
33
34
|
port: 1422
|
|
34
35
|
},
|
|
35
36
|
(info) => {
|
|
36
|
-
console.log(
|
|
37
|
+
console.log(
|
|
38
|
+
`Server running on ${import_picocolors.default.magenta(
|
|
39
|
+
import_picocolors.default.underline(`http://localhost:${info.port}`)
|
|
40
|
+
)}`
|
|
41
|
+
);
|
|
37
42
|
}
|
|
38
43
|
);
|
|
39
44
|
};
|
|
@@ -48,6 +53,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
48
53
|
var import_jszip = __toESM(require("jszip"), 1);
|
|
49
54
|
var createZip = async (dirPath, filename) => {
|
|
50
55
|
const zip = new import_jszip.default();
|
|
56
|
+
await import_promises.default.rm(import_path.default.join(dirPath, filename), { force: true });
|
|
51
57
|
async function addFiles(dir, zipFolder) {
|
|
52
58
|
const files = await import_promises.default.readdir(dir);
|
|
53
59
|
files.sort();
|
|
@@ -81,17 +87,6 @@ var createZip = async (dirPath, filename) => {
|
|
|
81
87
|
await import_promises.default.writeFile(filename, content);
|
|
82
88
|
};
|
|
83
89
|
|
|
84
|
-
// src/utils/formatDate.ts
|
|
85
|
-
var formatDate = (date) => {
|
|
86
|
-
const year = date.getFullYear();
|
|
87
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
88
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
89
|
-
const hours = String(date.getHours()).padStart(2, "0");
|
|
90
|
-
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
91
|
-
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
92
|
-
return Number(`${year}${month}${day}${hours}${minutes}${seconds}`);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
90
|
// src/utils/getDefaultTargetVersion.ts
|
|
96
91
|
var import_child_process = require("child_process");
|
|
97
92
|
var import_path2 = __toESM(require("path"), 1);
|
|
@@ -174,9 +169,22 @@ var getFileHashFromFile = async (filepath) => {
|
|
|
174
169
|
}
|
|
175
170
|
};
|
|
176
171
|
|
|
172
|
+
// src/utils/getLatestGitCommitMessage.ts
|
|
173
|
+
var import_child_process2 = require("child_process");
|
|
174
|
+
var getLatestGitCommitMessage = () => {
|
|
175
|
+
return new Promise((resolve) => {
|
|
176
|
+
(0, import_child_process2.exec)("git log --decorate --pretty=format:%s -1", (error, stdout) => {
|
|
177
|
+
if (error) {
|
|
178
|
+
resolve(null);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
resolve(stdout.trim());
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
177
186
|
// src/commands/deploy.ts
|
|
178
187
|
var import_plugin_core = require("@hot-updater/plugin-core");
|
|
179
|
-
var import_utils = require("@hot-updater/utils");
|
|
180
188
|
var deploy = async (options) => {
|
|
181
189
|
const s = (0, import_prompts.spinner)();
|
|
182
190
|
try {
|
|
@@ -185,9 +193,8 @@ var deploy = async (options) => {
|
|
|
185
193
|
console.error("No config found. Please run `hot-updater init` first.");
|
|
186
194
|
process.exit(1);
|
|
187
195
|
}
|
|
188
|
-
(0, import_prompts.intro)("Please provide a description for the bundle.");
|
|
189
|
-
const description = await (0, import_prompts.text)({ message: "Description" });
|
|
190
196
|
const cwd = (0, import_plugin_core.getCwd)();
|
|
197
|
+
const message = await getLatestGitCommitMessage();
|
|
191
198
|
const targetVersion = options.targetVersion ?? await getDefaultTargetVersion(cwd, options.platform);
|
|
192
199
|
if (!targetVersion) {
|
|
193
200
|
throw new Error(
|
|
@@ -195,7 +202,7 @@ var deploy = async (options) => {
|
|
|
195
202
|
);
|
|
196
203
|
}
|
|
197
204
|
s.start("Build in progress");
|
|
198
|
-
const { buildPath } = await config.build({
|
|
205
|
+
const { buildPath, bundleId } = await config.build({
|
|
199
206
|
cwd,
|
|
200
207
|
platform: options.platform
|
|
201
208
|
});
|
|
@@ -203,41 +210,26 @@ var deploy = async (options) => {
|
|
|
203
210
|
await createZip(buildPath, "build.zip");
|
|
204
211
|
const bundlePath = buildPath.concat(".zip");
|
|
205
212
|
const hash = await getFileHashFromFile(bundlePath);
|
|
206
|
-
const
|
|
207
|
-
const deployPlugin = config.deploy({
|
|
213
|
+
const databasePlugin = config.database({
|
|
208
214
|
cwd
|
|
209
215
|
});
|
|
210
|
-
const updateSources = await deployPlugin.getUpdateSources();
|
|
211
|
-
const targetVersions = (0, import_utils.filterTargetVersion)(
|
|
212
|
-
updateSources ?? [],
|
|
213
|
-
targetVersion,
|
|
214
|
-
options.platform
|
|
215
|
-
);
|
|
216
|
-
if (targetVersions.length > 0) {
|
|
217
|
-
const recentVersion = targetVersions[0];
|
|
218
|
-
const recentHash = recentVersion?.hash;
|
|
219
|
-
if (recentHash === hash) {
|
|
220
|
-
s.stop("The update already exists.", -1);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
216
|
s.message("Uploading bundle...");
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
await deployPlugin.appendUpdateSource({
|
|
217
|
+
const storagePlugin = config.storage({
|
|
218
|
+
cwd
|
|
219
|
+
});
|
|
220
|
+
const { file } = await storagePlugin.uploadBundle(bundleId, bundlePath);
|
|
221
|
+
await databasePlugin.appendBundle({
|
|
231
222
|
forceUpdate: options.forceUpdate,
|
|
232
223
|
platform: options.platform,
|
|
233
224
|
file,
|
|
234
225
|
hash,
|
|
235
|
-
|
|
226
|
+
message: message ?? void 0,
|
|
236
227
|
targetVersion,
|
|
237
|
-
|
|
228
|
+
id: bundleId,
|
|
238
229
|
enabled: true
|
|
239
230
|
});
|
|
240
|
-
await
|
|
231
|
+
await databasePlugin.commitBundle();
|
|
232
|
+
await databasePlugin.onUnmount?.();
|
|
241
233
|
await import_promises4.default.rm(bundlePath);
|
|
242
234
|
s.stop("Uploading Success !", 0);
|
|
243
235
|
} catch (e) {
|
|
@@ -262,7 +254,7 @@ var generateSecretKey = async () => {
|
|
|
262
254
|
var p = __toESM(require("@clack/prompts"), 1);
|
|
263
255
|
var import_plugin_core2 = require("@hot-updater/plugin-core");
|
|
264
256
|
var import_plugin_core3 = require("@hot-updater/plugin-core");
|
|
265
|
-
var prune = async (
|
|
257
|
+
var prune = async () => {
|
|
266
258
|
const s = p.spinner();
|
|
267
259
|
try {
|
|
268
260
|
const config = await (0, import_plugin_core3.loadConfig)();
|
|
@@ -271,26 +263,26 @@ var prune = async (options) => {
|
|
|
271
263
|
process.exit(1);
|
|
272
264
|
}
|
|
273
265
|
const cwd = (0, import_plugin_core2.getCwd)();
|
|
274
|
-
const
|
|
266
|
+
const databasePlugin = config.database({
|
|
275
267
|
cwd
|
|
276
|
-
// spinner: s,
|
|
277
268
|
});
|
|
278
269
|
s.start("Checking existing updates");
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
270
|
+
const bundles = await databasePlugin.getBundles();
|
|
271
|
+
const activeBundles = bundles.filter((bundle) => bundle.enabled);
|
|
272
|
+
const inactiveBundles = bundles.filter((bundle) => !bundle.enabled);
|
|
273
|
+
if (inactiveBundles.length === 0) {
|
|
283
274
|
s.stop("No inactive versions found", -1);
|
|
284
275
|
return;
|
|
285
276
|
}
|
|
286
277
|
s.message("Pruning updates");
|
|
287
|
-
await
|
|
288
|
-
await
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
278
|
+
await databasePlugin.setBundles(activeBundles);
|
|
279
|
+
await databasePlugin.commitBundle();
|
|
280
|
+
await databasePlugin.onUnmount?.();
|
|
281
|
+
const storagePlugin = config.storage({
|
|
282
|
+
cwd
|
|
283
|
+
});
|
|
284
|
+
for (const bundle of inactiveBundles) {
|
|
285
|
+
const key = await storagePlugin.deleteBundle(bundle.id);
|
|
294
286
|
p.log.info(`deleting: ${key}`);
|
|
295
287
|
}
|
|
296
288
|
s.stop("Done");
|
|
@@ -310,13 +302,13 @@ var version = packageJsonData?.packageJson.version;
|
|
|
310
302
|
|
|
311
303
|
// src/components/banner.tsx
|
|
312
304
|
var import_boxen = __toESM(require("boxen"), 1);
|
|
313
|
-
var
|
|
305
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
314
306
|
var banner = (0, import_boxen.default)(
|
|
315
307
|
[
|
|
316
|
-
`${
|
|
308
|
+
`${import_picocolors2.default.bold("Hot Updater - React Native OTA Solution")} v${version}`,
|
|
317
309
|
"",
|
|
318
|
-
`Github: ${
|
|
319
|
-
|
|
310
|
+
`Github: ${import_picocolors2.default.magenta(
|
|
311
|
+
import_picocolors2.default.underline("https://github.com/gronxb/hot-updater")
|
|
320
312
|
)}`,
|
|
321
313
|
"Give a \u2B50\uFE0F if you like it!"
|
|
322
314
|
].join("\n"),
|
|
@@ -379,17 +371,5 @@ program.command("app-version").description("get the current app version").action
|
|
|
379
371
|
import_plugin_core4.log.info(`Android version: ${androidVersion}`);
|
|
380
372
|
import_plugin_core4.log.info(`iOS version: ${iosVersion}`);
|
|
381
373
|
});
|
|
382
|
-
program.command("prune").description("prune all the inactive versions").
|
|
383
|
-
new import_commander.Option("-p, --platform <platform>", "specify the platform").choices([
|
|
384
|
-
"ios",
|
|
385
|
-
"android"
|
|
386
|
-
])
|
|
387
|
-
).action(async (options) => {
|
|
388
|
-
if (!options.platform) {
|
|
389
|
-
options.platform = await getPlatform(
|
|
390
|
-
"Which platform do you want to prune?"
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
prune(options);
|
|
394
|
-
});
|
|
374
|
+
program.command("prune").description("prune all the inactive versions").action(prune);
|
|
395
375
|
program.parse(process.argv);
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
__dirname
|
|
4
|
-
|
|
3
|
+
__dirname,
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-M76SRQA4.js";
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
init_esm_shims();
|
|
5
9
|
|
|
6
10
|
// src/commands/console.ts
|
|
11
|
+
init_esm_shims();
|
|
7
12
|
import { serve } from "@hono/node-server";
|
|
8
13
|
import app from "@hot-updater/console";
|
|
14
|
+
import picocolors from "picocolors";
|
|
9
15
|
var openConsole = () => {
|
|
10
16
|
serve(
|
|
11
17
|
{
|
|
@@ -13,21 +19,28 @@ var openConsole = () => {
|
|
|
13
19
|
port: 1422
|
|
14
20
|
},
|
|
15
21
|
(info) => {
|
|
16
|
-
console.log(
|
|
22
|
+
console.log(
|
|
23
|
+
`Server running on ${picocolors.magenta(
|
|
24
|
+
picocolors.underline(`http://localhost:${info.port}`)
|
|
25
|
+
)}`
|
|
26
|
+
);
|
|
17
27
|
}
|
|
18
28
|
);
|
|
19
29
|
};
|
|
20
30
|
|
|
21
31
|
// src/commands/deploy.ts
|
|
32
|
+
init_esm_shims();
|
|
22
33
|
import fs4 from "node:fs/promises";
|
|
23
|
-
import {
|
|
34
|
+
import { spinner } from "@clack/prompts";
|
|
24
35
|
|
|
25
36
|
// src/utils/createZip.ts
|
|
37
|
+
init_esm_shims();
|
|
26
38
|
import path from "path";
|
|
27
39
|
import fs from "fs/promises";
|
|
28
40
|
import JSZip from "jszip";
|
|
29
41
|
var createZip = async (dirPath, filename) => {
|
|
30
42
|
const zip = new JSZip();
|
|
43
|
+
await fs.rm(path.join(dirPath, filename), { force: true });
|
|
31
44
|
async function addFiles(dir, zipFolder) {
|
|
32
45
|
const files = await fs.readdir(dir);
|
|
33
46
|
files.sort();
|
|
@@ -61,18 +74,8 @@ var createZip = async (dirPath, filename) => {
|
|
|
61
74
|
await fs.writeFile(filename, content);
|
|
62
75
|
};
|
|
63
76
|
|
|
64
|
-
// src/utils/formatDate.ts
|
|
65
|
-
var formatDate = (date) => {
|
|
66
|
-
const year = date.getFullYear();
|
|
67
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
68
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
69
|
-
const hours = String(date.getHours()).padStart(2, "0");
|
|
70
|
-
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
71
|
-
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
72
|
-
return Number(`${year}${month}${day}${hours}${minutes}${seconds}`);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
77
|
// src/utils/getDefaultTargetVersion.ts
|
|
78
|
+
init_esm_shims();
|
|
76
79
|
import { exec } from "child_process";
|
|
77
80
|
import path2 from "path";
|
|
78
81
|
import util from "util";
|
|
@@ -136,6 +139,7 @@ var getDefaultTargetVersion = async (cwd, platform) => {
|
|
|
136
139
|
};
|
|
137
140
|
|
|
138
141
|
// src/utils/getFileHash.ts
|
|
142
|
+
init_esm_shims();
|
|
139
143
|
import crypto from "crypto";
|
|
140
144
|
import fs3 from "fs/promises";
|
|
141
145
|
var getFileHashFromFile = async (filepath) => {
|
|
@@ -154,9 +158,23 @@ var getFileHashFromFile = async (filepath) => {
|
|
|
154
158
|
}
|
|
155
159
|
};
|
|
156
160
|
|
|
161
|
+
// src/utils/getLatestGitCommitMessage.ts
|
|
162
|
+
init_esm_shims();
|
|
163
|
+
import { exec as exec2 } from "child_process";
|
|
164
|
+
var getLatestGitCommitMessage = () => {
|
|
165
|
+
return new Promise((resolve) => {
|
|
166
|
+
exec2("git log --decorate --pretty=format:%s -1", (error, stdout) => {
|
|
167
|
+
if (error) {
|
|
168
|
+
resolve(null);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
resolve(stdout.trim());
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
157
176
|
// src/commands/deploy.ts
|
|
158
177
|
import { getCwd, loadConfig } from "@hot-updater/plugin-core";
|
|
159
|
-
import { filterTargetVersion } from "@hot-updater/utils";
|
|
160
178
|
var deploy = async (options) => {
|
|
161
179
|
const s = spinner();
|
|
162
180
|
try {
|
|
@@ -165,9 +183,8 @@ var deploy = async (options) => {
|
|
|
165
183
|
console.error("No config found. Please run `hot-updater init` first.");
|
|
166
184
|
process.exit(1);
|
|
167
185
|
}
|
|
168
|
-
intro("Please provide a description for the bundle.");
|
|
169
|
-
const description = await text({ message: "Description" });
|
|
170
186
|
const cwd = getCwd();
|
|
187
|
+
const message = await getLatestGitCommitMessage();
|
|
171
188
|
const targetVersion = options.targetVersion ?? await getDefaultTargetVersion(cwd, options.platform);
|
|
172
189
|
if (!targetVersion) {
|
|
173
190
|
throw new Error(
|
|
@@ -175,7 +192,7 @@ var deploy = async (options) => {
|
|
|
175
192
|
);
|
|
176
193
|
}
|
|
177
194
|
s.start("Build in progress");
|
|
178
|
-
const { buildPath } = await config.build({
|
|
195
|
+
const { buildPath, bundleId } = await config.build({
|
|
179
196
|
cwd,
|
|
180
197
|
platform: options.platform
|
|
181
198
|
});
|
|
@@ -183,41 +200,26 @@ var deploy = async (options) => {
|
|
|
183
200
|
await createZip(buildPath, "build.zip");
|
|
184
201
|
const bundlePath = buildPath.concat(".zip");
|
|
185
202
|
const hash = await getFileHashFromFile(bundlePath);
|
|
186
|
-
const
|
|
187
|
-
const deployPlugin = config.deploy({
|
|
203
|
+
const databasePlugin = config.database({
|
|
188
204
|
cwd
|
|
189
205
|
});
|
|
190
|
-
const updateSources = await deployPlugin.getUpdateSources();
|
|
191
|
-
const targetVersions = filterTargetVersion(
|
|
192
|
-
updateSources ?? [],
|
|
193
|
-
targetVersion,
|
|
194
|
-
options.platform
|
|
195
|
-
);
|
|
196
|
-
if (targetVersions.length > 0) {
|
|
197
|
-
const recentVersion = targetVersions[0];
|
|
198
|
-
const recentHash = recentVersion?.hash;
|
|
199
|
-
if (recentHash === hash) {
|
|
200
|
-
s.stop("The update already exists.", -1);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
206
|
s.message("Uploading bundle...");
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
await deployPlugin.appendUpdateSource({
|
|
207
|
+
const storagePlugin = config.storage({
|
|
208
|
+
cwd
|
|
209
|
+
});
|
|
210
|
+
const { file } = await storagePlugin.uploadBundle(bundleId, bundlePath);
|
|
211
|
+
await databasePlugin.appendBundle({
|
|
211
212
|
forceUpdate: options.forceUpdate,
|
|
212
213
|
platform: options.platform,
|
|
213
214
|
file,
|
|
214
215
|
hash,
|
|
215
|
-
|
|
216
|
+
message: message ?? void 0,
|
|
216
217
|
targetVersion,
|
|
217
|
-
|
|
218
|
+
id: bundleId,
|
|
218
219
|
enabled: true
|
|
219
220
|
});
|
|
220
|
-
await
|
|
221
|
+
await databasePlugin.commitBundle();
|
|
222
|
+
await databasePlugin.onUnmount?.();
|
|
221
223
|
await fs4.rm(bundlePath);
|
|
222
224
|
s.stop("Uploading Success !", 0);
|
|
223
225
|
} catch (e) {
|
|
@@ -228,21 +230,23 @@ var deploy = async (options) => {
|
|
|
228
230
|
};
|
|
229
231
|
|
|
230
232
|
// src/commands/generateSecretKey.ts
|
|
233
|
+
init_esm_shims();
|
|
231
234
|
import crypto2 from "crypto";
|
|
232
|
-
import { text
|
|
235
|
+
import { text } from "@clack/prompts";
|
|
233
236
|
var generateSecretKey = async () => {
|
|
234
237
|
const secretKey = crypto2.randomBytes(32).toString("hex");
|
|
235
|
-
await
|
|
238
|
+
await text({
|
|
236
239
|
message: "Secret Key: ",
|
|
237
240
|
initialValue: secretKey
|
|
238
241
|
});
|
|
239
242
|
};
|
|
240
243
|
|
|
241
244
|
// src/commands/prune.ts
|
|
245
|
+
init_esm_shims();
|
|
242
246
|
import * as p from "@clack/prompts";
|
|
243
247
|
import { getCwd as getCwd2 } from "@hot-updater/plugin-core";
|
|
244
248
|
import { loadConfig as loadConfig2 } from "@hot-updater/plugin-core";
|
|
245
|
-
var prune = async (
|
|
249
|
+
var prune = async () => {
|
|
246
250
|
const s = p.spinner();
|
|
247
251
|
try {
|
|
248
252
|
const config = await loadConfig2();
|
|
@@ -251,26 +255,26 @@ var prune = async (options) => {
|
|
|
251
255
|
process.exit(1);
|
|
252
256
|
}
|
|
253
257
|
const cwd = getCwd2();
|
|
254
|
-
const
|
|
258
|
+
const databasePlugin = config.database({
|
|
255
259
|
cwd
|
|
256
|
-
// spinner: s,
|
|
257
260
|
});
|
|
258
261
|
s.start("Checking existing updates");
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
262
|
+
const bundles = await databasePlugin.getBundles();
|
|
263
|
+
const activeBundles = bundles.filter((bundle) => bundle.enabled);
|
|
264
|
+
const inactiveBundles = bundles.filter((bundle) => !bundle.enabled);
|
|
265
|
+
if (inactiveBundles.length === 0) {
|
|
263
266
|
s.stop("No inactive versions found", -1);
|
|
264
267
|
return;
|
|
265
268
|
}
|
|
266
269
|
s.message("Pruning updates");
|
|
267
|
-
await
|
|
268
|
-
await
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
await databasePlugin.setBundles(activeBundles);
|
|
271
|
+
await databasePlugin.commitBundle();
|
|
272
|
+
await databasePlugin.onUnmount?.();
|
|
273
|
+
const storagePlugin = config.storage({
|
|
274
|
+
cwd
|
|
275
|
+
});
|
|
276
|
+
for (const bundle of inactiveBundles) {
|
|
277
|
+
const key = await storagePlugin.deleteBundle(bundle.id);
|
|
274
278
|
p.log.info(`deleting: ${key}`);
|
|
275
279
|
}
|
|
276
280
|
s.stop("Done");
|
|
@@ -281,7 +285,11 @@ var prune = async (options) => {
|
|
|
281
285
|
}
|
|
282
286
|
};
|
|
283
287
|
|
|
288
|
+
// src/components/banner.tsx
|
|
289
|
+
init_esm_shims();
|
|
290
|
+
|
|
284
291
|
// src/packageJson.ts
|
|
292
|
+
init_esm_shims();
|
|
285
293
|
import { readPackageUpSync } from "read-package-up";
|
|
286
294
|
var packageJsonData = readPackageUpSync({
|
|
287
295
|
cwd: __dirname
|
|
@@ -290,13 +298,13 @@ var version = packageJsonData?.packageJson.version;
|
|
|
290
298
|
|
|
291
299
|
// src/components/banner.tsx
|
|
292
300
|
import boxen from "boxen";
|
|
293
|
-
import
|
|
301
|
+
import picocolors2 from "picocolors";
|
|
294
302
|
var banner = boxen(
|
|
295
303
|
[
|
|
296
|
-
`${
|
|
304
|
+
`${picocolors2.bold("Hot Updater - React Native OTA Solution")} v${version}`,
|
|
297
305
|
"",
|
|
298
|
-
`Github: ${
|
|
299
|
-
|
|
306
|
+
`Github: ${picocolors2.magenta(
|
|
307
|
+
picocolors2.underline("https://github.com/gronxb/hot-updater")
|
|
300
308
|
)}`,
|
|
301
309
|
"Give a \u2B50\uFE0F if you like it!"
|
|
302
310
|
].join("\n"),
|
|
@@ -309,6 +317,7 @@ var banner = boxen(
|
|
|
309
317
|
);
|
|
310
318
|
|
|
311
319
|
// src/prompts/getPlatform.ts
|
|
320
|
+
init_esm_shims();
|
|
312
321
|
import { select } from "@clack/prompts";
|
|
313
322
|
var getPlatform = async (message) => {
|
|
314
323
|
const platform = await select({
|
|
@@ -359,17 +368,5 @@ program.command("app-version").description("get the current app version").action
|
|
|
359
368
|
log2.info(`Android version: ${androidVersion}`);
|
|
360
369
|
log2.info(`iOS version: ${iosVersion}`);
|
|
361
370
|
});
|
|
362
|
-
program.command("prune").description("prune all the inactive versions").
|
|
363
|
-
new Option("-p, --platform <platform>", "specify the platform").choices([
|
|
364
|
-
"ios",
|
|
365
|
-
"android"
|
|
366
|
-
])
|
|
367
|
-
).action(async (options) => {
|
|
368
|
-
if (!options.platform) {
|
|
369
|
-
options.platform = await getPlatform(
|
|
370
|
-
"Which platform do you want to prune?"
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
prune(options);
|
|
374
|
-
});
|
|
371
|
+
program.command("prune").description("prune all the inactive versions").action(prune);
|
|
375
372
|
program.parse(process.argv);
|