@hot-updater/android-helper 0.28.0 → 0.29.0
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 +31 -43
- package/dist/index.d.cts +0 -1
- package/dist/{index.d.ts → index.d.mts} +0 -1
- package/dist/{index.js → index.mjs} +4 -13
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,23 +20,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
20
|
value: mod,
|
|
20
21
|
enumerable: true
|
|
21
22
|
}) : target, mod));
|
|
22
|
-
|
|
23
23
|
//#endregion
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
let __hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
27
|
-
__hot_updater_plugin_core = __toESM(__hot_updater_plugin_core);
|
|
24
|
+
let _hot_updater_cli_tools = require("@hot-updater/cli-tools");
|
|
25
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
28
26
|
let path = require("path");
|
|
29
27
|
path = __toESM(path);
|
|
30
28
|
let execa = require("execa");
|
|
31
|
-
execa = __toESM(execa);
|
|
32
29
|
let fs = require("fs");
|
|
33
30
|
fs = __toESM(fs);
|
|
34
31
|
let node_os = require("node:os");
|
|
35
32
|
node_os = __toESM(node_os);
|
|
36
|
-
|
|
37
33
|
//#region src/utils/createGradleLogger.ts
|
|
38
|
-
const createGradleLogger = ({ logPrefix }) => new
|
|
34
|
+
const createGradleLogger = ({ logPrefix }) => new _hot_updater_cli_tools.BuildLogger({
|
|
39
35
|
logPrefix,
|
|
40
36
|
importantLogPatterns: [
|
|
41
37
|
"error:",
|
|
@@ -146,7 +142,6 @@ const createGradleLogger = ({ logPrefix }) => new __hot_updater_cli_tools.BuildL
|
|
|
146
142
|
["BUILD SUCCESSFUL", /\d+ actionable tasks:/]
|
|
147
143
|
]
|
|
148
144
|
});
|
|
149
|
-
|
|
150
145
|
//#endregion
|
|
151
146
|
//#region src/builder/runGradle.ts
|
|
152
147
|
/**
|
|
@@ -182,7 +177,7 @@ async function runGradle({ tasks, logPrefix, args, androidProjectPath, appModule
|
|
|
182
177
|
const gradleArgs = getTaskNames(appModuleName, tasks);
|
|
183
178
|
gradleArgs.push("-x", "lint");
|
|
184
179
|
if (args.extraParams) gradleArgs.push(...args.extraParams);
|
|
185
|
-
|
|
180
|
+
_hot_updater_cli_tools.p.log.info(`Run Gradle Settings:
|
|
186
181
|
Project ${androidProjectPath}
|
|
187
182
|
App Moudle ${appModuleName}
|
|
188
183
|
Tasks ${tasks.join(", ")}
|
|
@@ -192,19 +187,19 @@ Args ${gradleArgs.join(" ")}
|
|
|
192
187
|
const logger = createGradleLogger({ logPrefix });
|
|
193
188
|
await logger.start();
|
|
194
189
|
try {
|
|
195
|
-
const process
|
|
190
|
+
const process = (0, execa.execa)(getGradleWrapper(), gradleArgs, {
|
|
196
191
|
cwd: androidProjectPath,
|
|
197
192
|
all: true
|
|
198
193
|
});
|
|
199
|
-
const outputStream = process
|
|
194
|
+
const outputStream = process.all ?? process.stdout;
|
|
200
195
|
if (outputStream) await logger.processStream(outputStream);
|
|
201
|
-
await process
|
|
196
|
+
await process;
|
|
202
197
|
logger.stop();
|
|
203
198
|
} catch (e) {
|
|
204
199
|
logger.writeError(e);
|
|
205
200
|
logger.stop("Build failed", false);
|
|
206
|
-
if (e instanceof execa.ExecaError)
|
|
207
|
-
else if (e instanceof Error)
|
|
201
|
+
if (e instanceof execa.ExecaError) _hot_updater_cli_tools.p.log.error(getCleanedErrorMessage(e));
|
|
202
|
+
else if (e instanceof Error) _hot_updater_cli_tools.p.log.error(e.message);
|
|
208
203
|
throw new Error("Failed to build the app. See the error above for details from Gradle.");
|
|
209
204
|
} finally {
|
|
210
205
|
await logger.close();
|
|
@@ -244,23 +239,21 @@ async function getBuildOutputFilePath({ aab, appModuleName, buildDirectory, vari
|
|
|
244
239
|
const outputFile = `${appModuleName}-${variant}.${aab ? "aab" : "apk"}`;
|
|
245
240
|
const outputFilePath = path.default.join(buildDirectory, outputFile);
|
|
246
241
|
if (fs.default.existsSync(outputFilePath)) return outputFilePath;
|
|
247
|
-
|
|
242
|
+
_hot_updater_cli_tools.p.log.error(`Failed to find the output file for ${outputFilePath}`);
|
|
248
243
|
process.exit(1);
|
|
249
244
|
}
|
|
250
|
-
|
|
251
245
|
//#endregion
|
|
252
246
|
//#region src/buildAndroid.ts
|
|
253
247
|
const buildAndroid = async ({ schemeConfig }) => {
|
|
254
|
-
const androidProjectPath = path.default.join((0,
|
|
248
|
+
const androidProjectPath = path.default.join((0, _hot_updater_cli_tools.getCwd)(), "android");
|
|
255
249
|
return runGradle({
|
|
256
|
-
args: { extraParams: [`-PMIN_BUNDLE_ID=${(0,
|
|
250
|
+
args: { extraParams: [`-PMIN_BUNDLE_ID=${(0, _hot_updater_plugin_core.generateMinBundleId)()}`] },
|
|
257
251
|
appModuleName: schemeConfig.appModuleName,
|
|
258
252
|
tasks: schemeConfig.aab ? [`bundle${schemeConfig.variant}`] : [`assemble${schemeConfig.variant}`],
|
|
259
253
|
logPrefix: `android-${schemeConfig.hotUpdaterSchemeName}-build`,
|
|
260
254
|
androidProjectPath
|
|
261
255
|
});
|
|
262
256
|
};
|
|
263
|
-
|
|
264
257
|
//#endregion
|
|
265
258
|
//#region src/utils/device.ts
|
|
266
259
|
/**
|
|
@@ -308,7 +301,7 @@ async function tryRunAdbReverse({ port = 8081, deviceId }) {
|
|
|
308
301
|
`tcp:${port}`,
|
|
309
302
|
`tcp:${port}`
|
|
310
303
|
];
|
|
311
|
-
|
|
304
|
+
_hot_updater_cli_tools.p.log.info(`Connecting "${deviceId}" to the development server`);
|
|
312
305
|
await (0, execa.execa)(adbPath, adbArgs);
|
|
313
306
|
} catch (_error) {
|
|
314
307
|
throw new Error(`Failed to connect "${deviceId}" to development server using "adb reverse"`);
|
|
@@ -447,7 +440,7 @@ const getAvailableDevicePort = async (startPort = defaultPort) => {
|
|
|
447
440
|
*/
|
|
448
441
|
const tryLaunchEmulator = async (name) => {
|
|
449
442
|
const port = await getAvailableDevicePort();
|
|
450
|
-
const spinner =
|
|
443
|
+
const spinner = _hot_updater_cli_tools.p.spinner();
|
|
451
444
|
spinner.start("Looking for available emulators");
|
|
452
445
|
const emulators = await getEmulatorNames();
|
|
453
446
|
const emulatorName = name ?? emulators[0];
|
|
@@ -510,30 +503,30 @@ const matchingDevice = (devices, deviceArg) => {
|
|
|
510
503
|
const selectTargetDevice = async ({ interactive, deviceOption }) => {
|
|
511
504
|
const availableDevices = await listDevices();
|
|
512
505
|
if (deviceOption === true && !interactive) {
|
|
513
|
-
|
|
506
|
+
_hot_updater_cli_tools.p.log.error("you can't select device manually with non-interactive cli mode(without -i option).");
|
|
514
507
|
process.exit(1);
|
|
515
508
|
}
|
|
516
509
|
if (typeof deviceOption === "string") {
|
|
517
510
|
const matchedDevice = matchingDevice(availableDevices, deviceOption);
|
|
518
511
|
if (!matchedDevice) {
|
|
519
|
-
|
|
512
|
+
_hot_updater_cli_tools.p.log.error(`device '${deviceOption}' isn't included in the attached devices.`);
|
|
520
513
|
process.exit(1);
|
|
521
514
|
}
|
|
522
515
|
return matchedDevice;
|
|
523
516
|
}
|
|
524
517
|
if (interactive) {
|
|
525
518
|
if (!availableDevices.length) {
|
|
526
|
-
|
|
519
|
+
_hot_updater_cli_tools.p.log.error("you passed -d option but there is no attached adb devices.");
|
|
527
520
|
process.exit(1);
|
|
528
521
|
}
|
|
529
|
-
const device = await
|
|
522
|
+
const device = await _hot_updater_cli_tools.p.select({
|
|
530
523
|
message: "Target Device",
|
|
531
524
|
options: availableDevices.map((d) => ({
|
|
532
525
|
value: d,
|
|
533
526
|
label: d.readableName
|
|
534
527
|
}))
|
|
535
528
|
});
|
|
536
|
-
if (
|
|
529
|
+
if (_hot_updater_cli_tools.p.isCancel(device)) process.exit(1);
|
|
537
530
|
return device;
|
|
538
531
|
}
|
|
539
532
|
};
|
|
@@ -545,12 +538,11 @@ const Device = {
|
|
|
545
538
|
listDevices,
|
|
546
539
|
selectTargetDevice
|
|
547
540
|
};
|
|
548
|
-
|
|
549
541
|
//#endregion
|
|
550
542
|
//#region src/runner/tryInstallAppOnDevice.ts
|
|
551
543
|
const tryInstallAppOnDevice = async ({ device, apkPath }) => {
|
|
552
544
|
if (!device.deviceId) {
|
|
553
|
-
|
|
545
|
+
_hot_updater_cli_tools.p.log.warn(`No device with id "${device.deviceId}", skipping launching the app.`);
|
|
554
546
|
return;
|
|
555
547
|
}
|
|
556
548
|
const deviceId = device.deviceId;
|
|
@@ -563,7 +555,7 @@ const tryInstallAppOnDevice = async ({ device, apkPath }) => {
|
|
|
563
555
|
];
|
|
564
556
|
adbArgs.push(apkPath);
|
|
565
557
|
const adbPath = Device.getAdbPath();
|
|
566
|
-
const spinner =
|
|
558
|
+
const spinner = _hot_updater_cli_tools.p.spinner();
|
|
567
559
|
spinner.start(`Installing the app on ${device.readableName} (id: ${deviceId})`);
|
|
568
560
|
try {
|
|
569
561
|
await (0, execa.execa)(adbPath, adbArgs);
|
|
@@ -575,12 +567,11 @@ const tryInstallAppOnDevice = async ({ device, apkPath }) => {
|
|
|
575
567
|
throw new Error(typeof errorMessage === "string" ? errorMessage : "Installation failed");
|
|
576
568
|
}
|
|
577
569
|
};
|
|
578
|
-
|
|
579
570
|
//#endregion
|
|
580
571
|
//#region src/runner/tryLaunchAppOnDevice.ts
|
|
581
572
|
async function tryLaunchAppOnDevice({ device, port, mainActivity, applicationId, packageName }) {
|
|
582
573
|
if (!device.deviceId) {
|
|
583
|
-
|
|
574
|
+
_hot_updater_cli_tools.p.log.warn(`No device with id "${device.deviceId}", skipping launching the app.`);
|
|
584
575
|
return;
|
|
585
576
|
}
|
|
586
577
|
const deviceId = device.deviceId;
|
|
@@ -603,7 +594,7 @@ async function tryLaunchAppOnDevice({ device, port, mainActivity, applicationId,
|
|
|
603
594
|
adbArgs.unshift("-s", deviceId);
|
|
604
595
|
const adbPath = Device.getAdbPath();
|
|
605
596
|
console.debug(`Running ${adbPath} ${adbArgs.join(" ")}.`);
|
|
606
|
-
const spinner =
|
|
597
|
+
const spinner = _hot_updater_cli_tools.p.spinner();
|
|
607
598
|
spinner.start(`Launching the app on ${device.readableName} (id: ${deviceId})`);
|
|
608
599
|
try {
|
|
609
600
|
await (0, execa.execa)(adbPath, adbArgs);
|
|
@@ -613,14 +604,13 @@ async function tryLaunchAppOnDevice({ device, port, mainActivity, applicationId,
|
|
|
613
604
|
throw new Error(`Failed to launch the app on ${device.readableName}`);
|
|
614
605
|
}
|
|
615
606
|
}
|
|
616
|
-
|
|
617
607
|
//#endregion
|
|
618
608
|
//#region src/runAndroid.ts
|
|
619
609
|
const runAndroid = async ({ schemeConfig, runOption }) => {
|
|
620
610
|
const { interactive, device: deviceOption } = runOption;
|
|
621
|
-
const androidProjectPath = path.default.join((0,
|
|
611
|
+
const androidProjectPath = path.default.join((0, _hot_updater_cli_tools.getCwd)(), "android");
|
|
622
612
|
if (schemeConfig.aab) {
|
|
623
|
-
|
|
613
|
+
_hot_updater_cli_tools.p.log.error("aab scheme can't not be run");
|
|
624
614
|
process.exit(1);
|
|
625
615
|
}
|
|
626
616
|
const device = await Device.selectTargetDevice({
|
|
@@ -633,12 +623,12 @@ const runAndroid = async ({ schemeConfig, runOption }) => {
|
|
|
633
623
|
}
|
|
634
624
|
if (!device.deviceId) throw new Error("Failed to run on any device");
|
|
635
625
|
} else if ((await Device.getConnectedDevices()).length === 0) {
|
|
636
|
-
|
|
626
|
+
_hot_updater_cli_tools.p.log.info("No devices found. Launching first available emulator.");
|
|
637
627
|
await Device.tryLaunchEmulator();
|
|
638
628
|
}
|
|
639
629
|
const task = `assemble${schemeConfig.variant}`;
|
|
640
630
|
const result = await runGradle({
|
|
641
|
-
args: { extraParams: [`-PMIN_BUNDLE_ID=${(0,
|
|
631
|
+
args: { extraParams: [`-PMIN_BUNDLE_ID=${(0, _hot_updater_plugin_core.generateMinBundleId)()}`] },
|
|
642
632
|
appModuleName: schemeConfig.appModuleName,
|
|
643
633
|
logPrefix: `android-${schemeConfig.hotUpdaterSchemeName}-run`,
|
|
644
634
|
tasks: [task],
|
|
@@ -658,10 +648,9 @@ const runAndroid = async ({ schemeConfig, runOption }) => {
|
|
|
658
648
|
port: runOption.port
|
|
659
649
|
});
|
|
660
650
|
}
|
|
661
|
-
|
|
651
|
+
_hot_updater_cli_tools.p.outro("Success 🎉");
|
|
662
652
|
return result;
|
|
663
653
|
};
|
|
664
|
-
|
|
665
654
|
//#endregion
|
|
666
655
|
//#region src/utils/enrichNativeBuildAndroidScheme.ts
|
|
667
656
|
const enrichNativeBuildAndroidScheme = async ({ schemeConfig, hotUpdaterSchemeName }) => {
|
|
@@ -674,8 +663,7 @@ const enrichNativeBuildAndroidScheme = async ({ schemeConfig, hotUpdaterSchemeNa
|
|
|
674
663
|
hotUpdaterSchemeName
|
|
675
664
|
};
|
|
676
665
|
};
|
|
677
|
-
|
|
678
666
|
//#endregion
|
|
679
667
|
exports.buildAndroid = buildAndroid;
|
|
680
668
|
exports.enrichNativeBuildAndroidScheme = enrichNativeBuildAndroidScheme;
|
|
681
|
-
exports.runAndroid = runAndroid;
|
|
669
|
+
exports.runAndroid = runAndroid;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,6 @@ import path from "path";
|
|
|
4
4
|
import { ExecaError, execa } from "execa";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import os from "node:os";
|
|
7
|
-
|
|
8
7
|
//#region src/utils/createGradleLogger.ts
|
|
9
8
|
const createGradleLogger = ({ logPrefix }) => new BuildLogger({
|
|
10
9
|
logPrefix,
|
|
@@ -117,7 +116,6 @@ const createGradleLogger = ({ logPrefix }) => new BuildLogger({
|
|
|
117
116
|
["BUILD SUCCESSFUL", /\d+ actionable tasks:/]
|
|
118
117
|
]
|
|
119
118
|
});
|
|
120
|
-
|
|
121
119
|
//#endregion
|
|
122
120
|
//#region src/builder/runGradle.ts
|
|
123
121
|
/**
|
|
@@ -163,13 +161,13 @@ Args ${gradleArgs.join(" ")}
|
|
|
163
161
|
const logger = createGradleLogger({ logPrefix });
|
|
164
162
|
await logger.start();
|
|
165
163
|
try {
|
|
166
|
-
const process
|
|
164
|
+
const process = execa(getGradleWrapper(), gradleArgs, {
|
|
167
165
|
cwd: androidProjectPath,
|
|
168
166
|
all: true
|
|
169
167
|
});
|
|
170
|
-
const outputStream = process
|
|
168
|
+
const outputStream = process.all ?? process.stdout;
|
|
171
169
|
if (outputStream) await logger.processStream(outputStream);
|
|
172
|
-
await process
|
|
170
|
+
await process;
|
|
173
171
|
logger.stop();
|
|
174
172
|
} catch (e) {
|
|
175
173
|
logger.writeError(e);
|
|
@@ -218,7 +216,6 @@ async function getBuildOutputFilePath({ aab, appModuleName, buildDirectory, vari
|
|
|
218
216
|
p.log.error(`Failed to find the output file for ${outputFilePath}`);
|
|
219
217
|
process.exit(1);
|
|
220
218
|
}
|
|
221
|
-
|
|
222
219
|
//#endregion
|
|
223
220
|
//#region src/buildAndroid.ts
|
|
224
221
|
const buildAndroid = async ({ schemeConfig }) => {
|
|
@@ -231,7 +228,6 @@ const buildAndroid = async ({ schemeConfig }) => {
|
|
|
231
228
|
androidProjectPath
|
|
232
229
|
});
|
|
233
230
|
};
|
|
234
|
-
|
|
235
231
|
//#endregion
|
|
236
232
|
//#region src/utils/device.ts
|
|
237
233
|
/**
|
|
@@ -516,7 +512,6 @@ const Device = {
|
|
|
516
512
|
listDevices,
|
|
517
513
|
selectTargetDevice
|
|
518
514
|
};
|
|
519
|
-
|
|
520
515
|
//#endregion
|
|
521
516
|
//#region src/runner/tryInstallAppOnDevice.ts
|
|
522
517
|
const tryInstallAppOnDevice = async ({ device, apkPath }) => {
|
|
@@ -546,7 +541,6 @@ const tryInstallAppOnDevice = async ({ device, apkPath }) => {
|
|
|
546
541
|
throw new Error(typeof errorMessage === "string" ? errorMessage : "Installation failed");
|
|
547
542
|
}
|
|
548
543
|
};
|
|
549
|
-
|
|
550
544
|
//#endregion
|
|
551
545
|
//#region src/runner/tryLaunchAppOnDevice.ts
|
|
552
546
|
async function tryLaunchAppOnDevice({ device, port, mainActivity, applicationId, packageName }) {
|
|
@@ -584,7 +578,6 @@ async function tryLaunchAppOnDevice({ device, port, mainActivity, applicationId,
|
|
|
584
578
|
throw new Error(`Failed to launch the app on ${device.readableName}`);
|
|
585
579
|
}
|
|
586
580
|
}
|
|
587
|
-
|
|
588
581
|
//#endregion
|
|
589
582
|
//#region src/runAndroid.ts
|
|
590
583
|
const runAndroid = async ({ schemeConfig, runOption }) => {
|
|
@@ -632,7 +625,6 @@ const runAndroid = async ({ schemeConfig, runOption }) => {
|
|
|
632
625
|
p.outro("Success 🎉");
|
|
633
626
|
return result;
|
|
634
627
|
};
|
|
635
|
-
|
|
636
628
|
//#endregion
|
|
637
629
|
//#region src/utils/enrichNativeBuildAndroidScheme.ts
|
|
638
630
|
const enrichNativeBuildAndroidScheme = async ({ schemeConfig, hotUpdaterSchemeName }) => {
|
|
@@ -645,6 +637,5 @@ const enrichNativeBuildAndroidScheme = async ({ schemeConfig, hotUpdaterSchemeNa
|
|
|
645
637
|
hotUpdaterSchemeName
|
|
646
638
|
};
|
|
647
639
|
};
|
|
648
|
-
|
|
649
640
|
//#endregion
|
|
650
|
-
export { buildAndroid, enrichNativeBuildAndroidScheme, runAndroid };
|
|
641
|
+
export { buildAndroid, enrichNativeBuildAndroidScheme, runAndroid };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/android-helper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
|
-
"module": "dist/index.
|
|
7
|
-
"types": "dist/index.d.
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.cts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"import": "./dist/index.
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
11
|
"require": "./dist/index.cjs"
|
|
12
12
|
},
|
|
13
13
|
"./package.json": "./package.json"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"execa": "9.5.2",
|
|
28
|
-
"@hot-updater/
|
|
29
|
-
"@hot-updater/core": "0.
|
|
30
|
-
"@hot-updater/
|
|
28
|
+
"@hot-updater/cli-tools": "0.29.0",
|
|
29
|
+
"@hot-updater/plugin-core": "0.29.0",
|
|
30
|
+
"@hot-updater/core": "0.29.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^20"
|