Skip to content

Commit bb9af69

Browse files
committed
Merge remote-tracking branch 'origin/main' into pre/v9-combined-testing
2 parents dba4e1a + de2cb8c commit bb9af69

File tree

6 files changed

+113
-105
lines changed

6 files changed

+113
-105
lines changed

Gruntfile.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,13 @@ function registerTestingDependenciesTasks(grunt) {
248248
const generatedVersionFilePath = path.join(configsBasePath, "test-deps-versions-generated.json");
249249

250250
grunt.registerTask("generate_unit_testing_dependencies", async function () {
251-
var done = this.async();
252251
const dependenciesVersions = {};
253252
const testDependencies = grunt.file.readJSON(path.join(configsBasePath, "test-dependencies.json"));
254253
for (var dependency of testDependencies) {
255254
const dependencyVersion = dependency.version || await latestVersion(dependency.name);
256255
dependenciesVersions[dependency.name] = dependencyVersion;
257256
}
258257
grunt.file.write(generatedVersionFilePath, JSON.stringify(dependenciesVersions));
259-
done();
260258
});
261259

262260
grunt.registerTask("verify_unit_testing_dependencies", function () {

lib/common/mobile/android/android-emulator-services.ts

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,93 +8,98 @@ import { injector } from "../../yok";
88
import * as semver from "semver";
99

1010
export class AndroidEmulatorServices
11-
implements Mobile.IEmulatorPlatformService {
11+
implements Mobile.IEmulatorPlatformService
12+
{
1213
constructor(
1314
private $androidGenymotionService: Mobile.IAndroidVirtualDeviceService,
1415
private $androidVirtualDeviceService: Mobile.IAndroidVirtualDeviceService,
1516
private $adb: Mobile.IAndroidDebugBridge,
1617
private $childProcess: IChildProcess,
1718
private $emulatorHelper: Mobile.IEmulatorHelper,
1819
private $logger: ILogger,
19-
private $utils: IUtils
20+
private $utils: IUtils,
2021
) {}
2122

2223
public async getEmulatorImages(): Promise<Mobile.IEmulatorImagesOutput> {
2324
const adbDevicesOutput = await this.$adb.getDevicesSafe();
24-
const avdAvailableEmulatorsOutput = await this.$androidVirtualDeviceService.getEmulatorImages(
25-
adbDevicesOutput
26-
);
27-
const genyAvailableDevicesOutput = await this.$androidGenymotionService.getEmulatorImages(
28-
adbDevicesOutput
29-
);
25+
const avdAvailableEmulatorsOutput =
26+
await this.$androidVirtualDeviceService.getEmulatorImages(
27+
adbDevicesOutput,
28+
);
29+
const genyAvailableDevicesOutput =
30+
await this.$androidGenymotionService.getEmulatorImages(adbDevicesOutput);
3031
const devices = _.concat(
3132
avdAvailableEmulatorsOutput.devices,
32-
genyAvailableDevicesOutput.devices
33+
genyAvailableDevicesOutput.devices,
3334
).filter((item) => !!item);
3435

3536
return {
3637
devices,
3738
errors: avdAvailableEmulatorsOutput.errors.concat(
38-
genyAvailableDevicesOutput.errors
39+
genyAvailableDevicesOutput.errors,
3940
),
4041
};
4142
}
4243

4344
public async getRunningEmulatorIds(): Promise<string[]> {
4445
const adbDevicesOutput = await this.$adb.getDevicesSafe();
45-
const avds = await this.$androidVirtualDeviceService.getRunningEmulatorIds(
46-
adbDevicesOutput
47-
);
48-
const genies = await this.$androidGenymotionService.getRunningEmulatorIds(
49-
adbDevicesOutput
50-
);
46+
const avds =
47+
await this.$androidVirtualDeviceService.getRunningEmulatorIds(
48+
adbDevicesOutput,
49+
);
50+
const genies =
51+
await this.$androidGenymotionService.getRunningEmulatorIds(
52+
adbDevicesOutput,
53+
);
5154
return avds.concat(genies);
5255
}
5356

5457
public async getRunningEmulatorName(emulatorId: string): Promise<string> {
55-
let result = await this.$androidVirtualDeviceService.getRunningEmulatorName(
56-
emulatorId
57-
);
58-
if (!result) {
59-
result = await this.$androidGenymotionService.getRunningEmulatorName(
60-
emulatorId
58+
let result =
59+
await this.$androidVirtualDeviceService.getRunningEmulatorName(
60+
emulatorId,
6161
);
62+
if (!result) {
63+
result =
64+
await this.$androidGenymotionService.getRunningEmulatorName(emulatorId);
6265
}
6366

6467
return result;
6568
}
6669

6770
public async getRunningEmulatorImageIdentifier(
68-
emulatorId: string
71+
emulatorId: string,
6972
): Promise<string> {
70-
let result = await this.$androidVirtualDeviceService.getRunningEmulatorImageIdentifier(
71-
emulatorId
72-
);
73-
if (!result) {
74-
result = await this.$androidGenymotionService.getRunningEmulatorImageIdentifier(
75-
emulatorId
73+
let result =
74+
await this.$androidVirtualDeviceService.getRunningEmulatorImageIdentifier(
75+
emulatorId,
7676
);
77+
if (!result) {
78+
result =
79+
await this.$androidGenymotionService.getRunningEmulatorImageIdentifier(
80+
emulatorId,
81+
);
7782
}
7883

7984
return result;
8085
}
8186

8287
public async startEmulator(
83-
options: Mobile.IAndroidStartEmulatorOptions
88+
options: Mobile.IAndroidStartEmulatorOptions,
8489
): Promise<Mobile.IStartEmulatorOutput> {
8590
const output = await this.startEmulatorCore(options);
8691
let bootToCompleteOutput = null;
8792
if (output && output.runningEmulator) {
8893
bootToCompleteOutput = await this.waitForEmulatorBootToComplete(
8994
output.runningEmulator,
9095
output.endTimeEpoch,
91-
options.timeout
96+
options.timeout,
9297
);
9398
}
9499

95100
return {
96101
errors: ((output && output.errors) || []).concat(
97-
(bootToCompleteOutput && bootToCompleteOutput.errors) || []
102+
(bootToCompleteOutput && bootToCompleteOutput.errors) || [],
98103
),
99104
};
100105
}
@@ -104,7 +109,7 @@ export class AndroidEmulatorServices
104109
}
105110

106111
private async startEmulatorCore(
107-
options: Mobile.IAndroidStartEmulatorOptions
112+
options: Mobile.IAndroidStartEmulatorOptions,
108113
): Promise<{
109114
runningEmulator: Mobile.IDeviceInfo;
110115
errors: string[];
@@ -118,7 +123,7 @@ export class AndroidEmulatorServices
118123

119124
let emulator = this.$emulatorHelper.getEmulatorByStartEmulatorOptions(
120125
options,
121-
availableEmulators
126+
availableEmulators,
122127
);
123128
if (
124129
!emulator &&
@@ -158,7 +163,7 @@ export class AndroidEmulatorServices
158163
const emulators = (await this.getEmulatorImages()).devices;
159164
const newEmulator = _.find(
160165
emulators,
161-
(e) => e.imageIdentifier === emulator.imageIdentifier
166+
(e) => e.imageIdentifier === emulator.imageIdentifier,
162167
);
163168
if (newEmulator && this.$emulatorHelper.isEmulatorRunning(newEmulator)) {
164169
return {
@@ -185,29 +190,29 @@ export class AndroidEmulatorServices
185190
let pathToEmulatorExecutable = null;
186191
let startEmulatorArgs = null;
187192
if (emulator.vendor === AndroidVirtualDevice.AVD_VENDOR_NAME) {
188-
pathToEmulatorExecutable = this.$androidVirtualDeviceService
189-
.pathToEmulatorExecutable;
193+
pathToEmulatorExecutable =
194+
this.$androidVirtualDeviceService.pathToEmulatorExecutable;
190195
startEmulatorArgs = this.$androidVirtualDeviceService.startEmulatorArgs(
191-
emulator.imageIdentifier
196+
emulator.imageIdentifier,
192197
);
193198
} else if (
194199
emulator.vendor === AndroidVirtualDevice.GENYMOTION_VENDOR_NAME
195200
) {
196-
pathToEmulatorExecutable = this.$androidGenymotionService
197-
.pathToEmulatorExecutable;
201+
pathToEmulatorExecutable =
202+
this.$androidGenymotionService.pathToEmulatorExecutable;
198203
startEmulatorArgs = this.$androidGenymotionService.startEmulatorArgs(
199-
emulator.imageIdentifier
204+
emulator.imageIdentifier,
200205
);
201206
}
202207

203208
this.$logger.info(
204-
`Starting Android emulator with image ${emulator.imageIdentifier}`
209+
`Starting Android emulator with image ${emulator.imageIdentifier}`,
205210
);
206211

207212
const childProcess = this.$childProcess.spawn(
208213
pathToEmulatorExecutable,
209214
startEmulatorArgs,
210-
{ stdio: "ignore", detached: true }
215+
{ stdio: "ignore", detached: true },
211216
);
212217
childProcess.unref();
213218
childProcess.on("error", (err: Error) => {
@@ -235,25 +240,25 @@ export class AndroidEmulatorServices
235240
const minVersion = semver.coerce(AndroidVirtualDevice.MIN_ANDROID_VERSION);
236241
const bestVersion = best && best.version && semver.coerce(best.version);
237242

238-
return bestVersion && semver.gte(bestVersion, minVersion) ? best : null;
243+
return !bestVersion || semver.gte(bestVersion, minVersion) ? best : null;
239244
}
240245

241246
private async waitForEmulatorBootToComplete(
242247
emulator: Mobile.IDeviceInfo,
243248
endTimeEpoch: number,
244-
timeout: number
249+
timeout: number,
245250
): Promise<{ runningEmulator: Mobile.IDeviceInfo; errors: string[] }> {
246251
this.$logger.info("Waiting for emulator device initialization...", {
247252
[LoggerConfigData.skipNewLine]: true,
248253
});
249254

250255
const isInfiniteWait =
251256
this.$utils.getMilliSecondsTimeout(
252-
timeout || AndroidVirtualDevice.TIMEOUT_SECONDS
257+
timeout || AndroidVirtualDevice.TIMEOUT_SECONDS,
253258
) === 0;
254259
while (getCurrentEpochTime() < endTimeEpoch || isInfiniteWait) {
255260
const isEmulatorBootCompleted = await this.isEmulatorBootCompleted(
256-
emulator.identifier
261+
emulator.identifier,
257262
);
258263
if (isEmulatorBootCompleted) {
259264
this.$logger.info(EOL, { [LoggerConfigData.skipNewLine]: true });
@@ -276,7 +281,7 @@ export class AndroidEmulatorServices
276281
private async isEmulatorBootCompleted(emulatorId: string): Promise<boolean> {
277282
const output = await this.$adb.getPropertyValue(
278283
emulatorId,
279-
"dev.bootcomplete"
284+
"dev.bootcomplete",
280285
);
281286
const matches = output.match("1");
282287
return matches && matches.length > 0;

lib/common/mobile/emulator-helper.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { injector } from "../yok";
55
export class EmulatorHelper implements Mobile.IEmulatorHelper {
66
// https://developer.android.com/guide/topics/manifest/uses-sdk-element
77
public mapAndroidApiLevelToVersion = {
8+
"android-36": "16.0.0",
89
"android-35": "15.0.0",
910
"android-34": "14.0.0",
1011
"android-33": "13.0.0",
@@ -27,7 +28,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
2728
};
2829

2930
public getEmulatorsFromAvailableEmulatorsOutput(
30-
availableEmulatorsOutput: Mobile.IListEmulatorsOutput
31+
availableEmulatorsOutput: Mobile.IListEmulatorsOutput,
3132
): Mobile.IDeviceInfo[] {
3233
return <Mobile.IDeviceInfo[]>_(availableEmulatorsOutput)
3334
.valuesIn()
@@ -38,7 +39,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
3839
}
3940

4041
public getErrorsFromAvailableEmulatorsOutput(
41-
availableEmulatorsOutput: Mobile.IListEmulatorsOutput
42+
availableEmulatorsOutput: Mobile.IListEmulatorsOutput,
4243
): string[] {
4344
return <string[]>_(availableEmulatorsOutput)
4445
.valuesIn()
@@ -50,7 +51,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
5051

5152
public getEmulatorByImageIdentifier(
5253
imageIdentifier: string,
53-
emulators: Mobile.IDeviceInfo[]
54+
emulators: Mobile.IDeviceInfo[],
5455
): Mobile.IDeviceInfo {
5556
const imagerIdentifierLowerCase =
5657
imageIdentifier && imageIdentifier.toLowerCase();
@@ -60,13 +61,13 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
6061
emulator &&
6162
emulator.imageIdentifier &&
6263
imageIdentifier &&
63-
emulator.imageIdentifier.toLowerCase() === imagerIdentifierLowerCase
64+
emulator.imageIdentifier.toLowerCase() === imagerIdentifierLowerCase,
6465
);
6566
}
6667

6768
public getEmulatorByIdOrName(
6869
emulatorIdOrName: string,
69-
emulators: Mobile.IDeviceInfo[]
70+
emulators: Mobile.IDeviceInfo[],
7071
): Mobile.IDeviceInfo {
7172
const emulatorIdOrNameLowerCase =
7273
emulatorIdOrName && emulatorIdOrName.toLowerCase();
@@ -77,7 +78,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
7778
emulatorIdOrNameLowerCase &&
7879
((emulator.identifier &&
7980
emulator.identifier.toLowerCase() === emulatorIdOrNameLowerCase) ||
80-
emulator.displayName.toLowerCase() === emulatorIdOrNameLowerCase)
81+
emulator.displayName.toLowerCase() === emulatorIdOrNameLowerCase),
8182
);
8283
}
8384

@@ -87,7 +88,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
8788

8889
public getEmulatorByStartEmulatorOptions(
8990
options: Mobile.IStartEmulatorOptions,
90-
emulators: Mobile.IDeviceInfo[]
91+
emulators: Mobile.IDeviceInfo[],
9192
): Mobile.IDeviceInfo {
9293
let result: Mobile.IDeviceInfo = null;
9394

@@ -98,7 +99,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
9899
if (!result && options.imageIdentifier) {
99100
result = this.getEmulatorByImageIdentifier(
100101
options.imageIdentifier,
101-
emulators
102+
emulators,
102103
);
103104
}
104105

@@ -111,7 +112,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
111112

112113
public setRunningAndroidEmulatorProperties(
113114
emulatorId: string,
114-
emulator: Mobile.IDeviceInfo
115+
emulator: Mobile.IDeviceInfo,
115116
): void {
116117
emulator.identifier = emulatorId;
117118
emulator.status = RUNNING_EMULATOR_STATUS;

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@rigor789/trapezedev-project": "7.1.2",
6262
"ansi-colors": "^4.1.3",
6363
"archiver": "^7.0.1",
64-
"axios": "1.7.9",
64+
"axios": "1.11.0",
6565
"byline": "5.0.0",
6666
"chalk": "4.1.2",
6767
"chokidar": "4.0.3",
@@ -144,6 +144,7 @@
144144
"@types/ws": "8.5.14",
145145
"@types/xml2js": "0.4.14",
146146
"@types/yargs": "17.0.33",
147+
"braces": ">=3.0.3",
147148
"chai": "5.2.0",
148149
"chai-as-promised": "8.0.1",
149150
"conventional-changelog-cli": "^5.0.0",
@@ -160,7 +161,8 @@
160161
"lint-staged": "~15.4.3",
161162
"mocha": "11.1.0",
162163
"sinon": "19.0.2",
163-
"source-map-support": "0.5.21"
164+
"source-map-support": "0.5.21",
165+
"xml2js": ">=0.5.0"
164166
},
165167
"optionalDependencies": {
166168
"fsevents": "*"
@@ -181,4 +183,4 @@
181183
"lint-staged": {
182184
"*.ts": "prettier --write"
183185
}
184-
}
186+
}

0 commit comments

Comments
 (0)