hot-updater 0.1.1 → 0.1.3
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 +97 -85
- package/dist/index.js +97 -85
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -179,66 +179,72 @@ var import_plugin_core = require("@hot-updater/plugin-core");
|
|
|
179
179
|
var import_utils = require("@hot-updater/utils");
|
|
180
180
|
var deploy = async (options) => {
|
|
181
181
|
const s = (0, import_prompts.spinner)();
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
182
|
+
try {
|
|
183
|
+
const config = await (0, import_plugin_core.loadConfig)();
|
|
184
|
+
if (!config) {
|
|
185
|
+
console.error("No config found. Please run `hot-updater init` first.");
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
(0, import_prompts.intro)("Please provide a description for the bundle.");
|
|
189
|
+
const description = await (0, import_prompts.text)({ message: "Description" });
|
|
190
|
+
const cwd = (0, import_plugin_core.getCwd)();
|
|
191
|
+
const targetVersion = options.targetVersion ?? await getDefaultTargetVersion(cwd, options.platform);
|
|
192
|
+
if (!targetVersion) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
"Target version not found. Please provide a target version."
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
s.start("Build in progress");
|
|
198
|
+
const { buildPath } = await config.build({
|
|
199
|
+
cwd,
|
|
200
|
+
platform: options.platform
|
|
201
|
+
});
|
|
202
|
+
s.message("Checking existing updates...");
|
|
203
|
+
await createZip(buildPath, "build.zip");
|
|
204
|
+
const bundlePath = buildPath.concat(".zip");
|
|
205
|
+
const hash = await getFileHashFromFile(bundlePath);
|
|
206
|
+
const newBundleVersion = formatDate(/* @__PURE__ */ new Date());
|
|
207
|
+
const deployPlugin = config.deploy({
|
|
208
|
+
cwd
|
|
209
|
+
});
|
|
210
|
+
const updateSources = await deployPlugin.getUpdateSources();
|
|
211
|
+
const targetVersions = (0, import_utils.filterTargetVersion)(
|
|
212
|
+
updateSources ?? [],
|
|
213
|
+
targetVersion,
|
|
214
|
+
options.platform
|
|
194
215
|
);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
await createZip(buildPath, "build.zip");
|
|
203
|
-
const bundlePath = buildPath.concat(".zip");
|
|
204
|
-
const hash = await getFileHashFromFile(bundlePath);
|
|
205
|
-
const newBundleVersion = formatDate(/* @__PURE__ */ new Date());
|
|
206
|
-
const deployPlugin = config.deploy({
|
|
207
|
-
cwd
|
|
208
|
-
});
|
|
209
|
-
const updateSources = await deployPlugin.getUpdateSources();
|
|
210
|
-
const targetVersions = (0, import_utils.filterTargetVersion)(
|
|
211
|
-
updateSources ?? [],
|
|
212
|
-
targetVersion,
|
|
213
|
-
options.platform
|
|
214
|
-
);
|
|
215
|
-
if (targetVersions.length > 0) {
|
|
216
|
-
const recentVersion = targetVersions[0];
|
|
217
|
-
const recentHash = recentVersion?.hash;
|
|
218
|
-
if (recentHash === hash) {
|
|
219
|
-
s.stop("The update already exists.", -1);
|
|
220
|
-
return;
|
|
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
|
+
}
|
|
221
223
|
}
|
|
224
|
+
s.message("Uploading bundle...");
|
|
225
|
+
const { file } = await deployPlugin.uploadBundle(
|
|
226
|
+
options.platform,
|
|
227
|
+
newBundleVersion,
|
|
228
|
+
bundlePath
|
|
229
|
+
);
|
|
230
|
+
await deployPlugin.appendUpdateSource({
|
|
231
|
+
forceUpdate: options.forceUpdate,
|
|
232
|
+
platform: options.platform,
|
|
233
|
+
file,
|
|
234
|
+
hash,
|
|
235
|
+
description: String(description),
|
|
236
|
+
targetVersion,
|
|
237
|
+
bundleVersion: newBundleVersion,
|
|
238
|
+
enabled: true
|
|
239
|
+
});
|
|
240
|
+
await deployPlugin.commitUpdateSource();
|
|
241
|
+
await import_promises4.default.rm(bundlePath);
|
|
242
|
+
s.stop("Uploading Success !", 0);
|
|
243
|
+
} catch (e) {
|
|
244
|
+
s.stop("Uploading Failed !", -1);
|
|
245
|
+
console.error(e);
|
|
246
|
+
process.exit(-1);
|
|
222
247
|
}
|
|
223
|
-
s.message("Uploading bundle...");
|
|
224
|
-
const { file } = await deployPlugin.uploadBundle(
|
|
225
|
-
options.platform,
|
|
226
|
-
newBundleVersion,
|
|
227
|
-
bundlePath
|
|
228
|
-
);
|
|
229
|
-
await deployPlugin.appendUpdateSource({
|
|
230
|
-
forceUpdate: options.forceUpdate,
|
|
231
|
-
platform: options.platform,
|
|
232
|
-
file,
|
|
233
|
-
hash,
|
|
234
|
-
description: String(description),
|
|
235
|
-
targetVersion,
|
|
236
|
-
bundleVersion: newBundleVersion,
|
|
237
|
-
enabled: true
|
|
238
|
-
});
|
|
239
|
-
await deployPlugin.commitUpdateSource();
|
|
240
|
-
await import_promises4.default.rm(bundlePath);
|
|
241
|
-
s.stop("Uploading Success !", 0);
|
|
242
248
|
};
|
|
243
249
|
|
|
244
250
|
// src/commands/generateSecretKey.ts
|
|
@@ -258,35 +264,41 @@ var import_plugin_core2 = require("@hot-updater/plugin-core");
|
|
|
258
264
|
var import_plugin_core3 = require("@hot-updater/plugin-core");
|
|
259
265
|
var prune = async (options) => {
|
|
260
266
|
const s = p.spinner();
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
267
|
+
try {
|
|
268
|
+
const config = await (0, import_plugin_core3.loadConfig)();
|
|
269
|
+
if (!config) {
|
|
270
|
+
console.error("No config found. Please run `hot-updater init` first.");
|
|
271
|
+
process.exit(1);
|
|
272
|
+
}
|
|
273
|
+
const cwd = (0, import_plugin_core2.getCwd)();
|
|
274
|
+
const deployPlugin = config.deploy({
|
|
275
|
+
cwd
|
|
276
|
+
// spinner: s,
|
|
277
|
+
});
|
|
278
|
+
s.start("Checking existing updates");
|
|
279
|
+
const updateSources = await deployPlugin.getUpdateSources();
|
|
280
|
+
const activeSources = updateSources.filter((source) => source.enabled);
|
|
281
|
+
const inactiveSources = updateSources.filter((source) => !source.enabled);
|
|
282
|
+
if (inactiveSources.length === 0) {
|
|
283
|
+
s.stop("No inactive versions found", -1);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
s.message("Pruning updates");
|
|
287
|
+
await deployPlugin.setUpdateSources(activeSources);
|
|
288
|
+
await deployPlugin.commitUpdateSource();
|
|
289
|
+
for (const source of inactiveSources) {
|
|
290
|
+
const key = await deployPlugin.deleteBundle(
|
|
291
|
+
options.platform,
|
|
292
|
+
source.bundleVersion
|
|
293
|
+
);
|
|
294
|
+
p.log.info(`deleting: ${key}`);
|
|
295
|
+
}
|
|
296
|
+
s.stop("Done");
|
|
297
|
+
} catch (e) {
|
|
298
|
+
s.stop("Pruning Failed !", -1);
|
|
299
|
+
console.error(e);
|
|
300
|
+
process.exit(-1);
|
|
288
301
|
}
|
|
289
|
-
s.stop("Done");
|
|
290
302
|
};
|
|
291
303
|
|
|
292
304
|
// src/packageJson.ts
|
package/dist/index.js
CHANGED
|
@@ -159,66 +159,72 @@ import { getCwd, loadConfig } from "@hot-updater/plugin-core";
|
|
|
159
159
|
import { filterTargetVersion } from "@hot-updater/utils";
|
|
160
160
|
var deploy = async (options) => {
|
|
161
161
|
const s = spinner();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
162
|
+
try {
|
|
163
|
+
const config = await loadConfig();
|
|
164
|
+
if (!config) {
|
|
165
|
+
console.error("No config found. Please run `hot-updater init` first.");
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
intro("Please provide a description for the bundle.");
|
|
169
|
+
const description = await text({ message: "Description" });
|
|
170
|
+
const cwd = getCwd();
|
|
171
|
+
const targetVersion = options.targetVersion ?? await getDefaultTargetVersion(cwd, options.platform);
|
|
172
|
+
if (!targetVersion) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
"Target version not found. Please provide a target version."
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
s.start("Build in progress");
|
|
178
|
+
const { buildPath } = await config.build({
|
|
179
|
+
cwd,
|
|
180
|
+
platform: options.platform
|
|
181
|
+
});
|
|
182
|
+
s.message("Checking existing updates...");
|
|
183
|
+
await createZip(buildPath, "build.zip");
|
|
184
|
+
const bundlePath = buildPath.concat(".zip");
|
|
185
|
+
const hash = await getFileHashFromFile(bundlePath);
|
|
186
|
+
const newBundleVersion = formatDate(/* @__PURE__ */ new Date());
|
|
187
|
+
const deployPlugin = config.deploy({
|
|
188
|
+
cwd
|
|
189
|
+
});
|
|
190
|
+
const updateSources = await deployPlugin.getUpdateSources();
|
|
191
|
+
const targetVersions = filterTargetVersion(
|
|
192
|
+
updateSources ?? [],
|
|
193
|
+
targetVersion,
|
|
194
|
+
options.platform
|
|
174
195
|
);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
await createZip(buildPath, "build.zip");
|
|
183
|
-
const bundlePath = buildPath.concat(".zip");
|
|
184
|
-
const hash = await getFileHashFromFile(bundlePath);
|
|
185
|
-
const newBundleVersion = formatDate(/* @__PURE__ */ new Date());
|
|
186
|
-
const deployPlugin = config.deploy({
|
|
187
|
-
cwd
|
|
188
|
-
});
|
|
189
|
-
const updateSources = await deployPlugin.getUpdateSources();
|
|
190
|
-
const targetVersions = filterTargetVersion(
|
|
191
|
-
updateSources ?? [],
|
|
192
|
-
targetVersion,
|
|
193
|
-
options.platform
|
|
194
|
-
);
|
|
195
|
-
if (targetVersions.length > 0) {
|
|
196
|
-
const recentVersion = targetVersions[0];
|
|
197
|
-
const recentHash = recentVersion?.hash;
|
|
198
|
-
if (recentHash === hash) {
|
|
199
|
-
s.stop("The update already exists.", -1);
|
|
200
|
-
return;
|
|
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
|
+
}
|
|
201
203
|
}
|
|
204
|
+
s.message("Uploading bundle...");
|
|
205
|
+
const { file } = await deployPlugin.uploadBundle(
|
|
206
|
+
options.platform,
|
|
207
|
+
newBundleVersion,
|
|
208
|
+
bundlePath
|
|
209
|
+
);
|
|
210
|
+
await deployPlugin.appendUpdateSource({
|
|
211
|
+
forceUpdate: options.forceUpdate,
|
|
212
|
+
platform: options.platform,
|
|
213
|
+
file,
|
|
214
|
+
hash,
|
|
215
|
+
description: String(description),
|
|
216
|
+
targetVersion,
|
|
217
|
+
bundleVersion: newBundleVersion,
|
|
218
|
+
enabled: true
|
|
219
|
+
});
|
|
220
|
+
await deployPlugin.commitUpdateSource();
|
|
221
|
+
await fs4.rm(bundlePath);
|
|
222
|
+
s.stop("Uploading Success !", 0);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
s.stop("Uploading Failed !", -1);
|
|
225
|
+
console.error(e);
|
|
226
|
+
process.exit(-1);
|
|
202
227
|
}
|
|
203
|
-
s.message("Uploading bundle...");
|
|
204
|
-
const { file } = await deployPlugin.uploadBundle(
|
|
205
|
-
options.platform,
|
|
206
|
-
newBundleVersion,
|
|
207
|
-
bundlePath
|
|
208
|
-
);
|
|
209
|
-
await deployPlugin.appendUpdateSource({
|
|
210
|
-
forceUpdate: options.forceUpdate,
|
|
211
|
-
platform: options.platform,
|
|
212
|
-
file,
|
|
213
|
-
hash,
|
|
214
|
-
description: String(description),
|
|
215
|
-
targetVersion,
|
|
216
|
-
bundleVersion: newBundleVersion,
|
|
217
|
-
enabled: true
|
|
218
|
-
});
|
|
219
|
-
await deployPlugin.commitUpdateSource();
|
|
220
|
-
await fs4.rm(bundlePath);
|
|
221
|
-
s.stop("Uploading Success !", 0);
|
|
222
228
|
};
|
|
223
229
|
|
|
224
230
|
// src/commands/generateSecretKey.ts
|
|
@@ -238,35 +244,41 @@ import { getCwd as getCwd2 } from "@hot-updater/plugin-core";
|
|
|
238
244
|
import { loadConfig as loadConfig2 } from "@hot-updater/plugin-core";
|
|
239
245
|
var prune = async (options) => {
|
|
240
246
|
const s = p.spinner();
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
247
|
+
try {
|
|
248
|
+
const config = await loadConfig2();
|
|
249
|
+
if (!config) {
|
|
250
|
+
console.error("No config found. Please run `hot-updater init` first.");
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
const cwd = getCwd2();
|
|
254
|
+
const deployPlugin = config.deploy({
|
|
255
|
+
cwd
|
|
256
|
+
// spinner: s,
|
|
257
|
+
});
|
|
258
|
+
s.start("Checking existing updates");
|
|
259
|
+
const updateSources = await deployPlugin.getUpdateSources();
|
|
260
|
+
const activeSources = updateSources.filter((source) => source.enabled);
|
|
261
|
+
const inactiveSources = updateSources.filter((source) => !source.enabled);
|
|
262
|
+
if (inactiveSources.length === 0) {
|
|
263
|
+
s.stop("No inactive versions found", -1);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
s.message("Pruning updates");
|
|
267
|
+
await deployPlugin.setUpdateSources(activeSources);
|
|
268
|
+
await deployPlugin.commitUpdateSource();
|
|
269
|
+
for (const source of inactiveSources) {
|
|
270
|
+
const key = await deployPlugin.deleteBundle(
|
|
271
|
+
options.platform,
|
|
272
|
+
source.bundleVersion
|
|
273
|
+
);
|
|
274
|
+
p.log.info(`deleting: ${key}`);
|
|
275
|
+
}
|
|
276
|
+
s.stop("Done");
|
|
277
|
+
} catch (e) {
|
|
278
|
+
s.stop("Pruning Failed !", -1);
|
|
279
|
+
console.error(e);
|
|
280
|
+
process.exit(-1);
|
|
268
281
|
}
|
|
269
|
-
s.stop("Done");
|
|
270
282
|
};
|
|
271
283
|
|
|
272
284
|
// src/packageJson.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hot-updater",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hot-updater": "./dist/index.js"
|
|
7
7
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@clack/prompts": "^0.7.0",
|
|
32
32
|
"@hono/node-server": "^1.13.4",
|
|
33
|
-
"@hot-updater/console": "0.1.
|
|
33
|
+
"@hot-updater/console": "0.1.3",
|
|
34
34
|
"boxen": "^8.0.1",
|
|
35
35
|
"commander": "^11.1.0",
|
|
36
36
|
"cosmiconfig": "^9.0.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"plist": "^3.1.0",
|
|
41
41
|
"read-package-up": "^11.0.0",
|
|
42
42
|
"workspace-tools": "^0.36.4",
|
|
43
|
-
"@hot-updater/plugin-core": "0.1.
|
|
44
|
-
"@hot-updater/utils": "0.1.
|
|
43
|
+
"@hot-updater/plugin-core": "0.1.3",
|
|
44
|
+
"@hot-updater/utils": "0.1.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/connect": "^3.4.38",
|