Skip to content

Commit c3db9c2

Browse files
committed
chore: cleanup (mostly formatting)
1 parent 806855c commit c3db9c2

28 files changed

+359
-305
lines changed

lib/commands/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
5555
{
5656
...this.$options.argv,
5757
// we disable buildFilterDevicesArch for build only to ensure we dont use it in production builds
58-
buildFilterDevicesArch: false
58+
buildFilterDevicesArch: false,
5959
}
6060
);
6161
const outputPath = await this.$buildController.prepareAndBuild(buildData);

lib/common/mobile/android/android-device.ts

+21-14
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ interface IAndroidDeviceDetails {
1313
name: string;
1414
release: string;
1515
brand: string;
16-
'cpu.abi': string;
17-
'cpu.abilist64': string;
18-
'cpu.abilist32': string;
16+
"cpu.abi": string;
17+
"cpu.abilist64": string;
18+
"cpu.abilist32": string;
1919
}
2020

2121
interface IAdbDeviceStatusInfo {
@@ -99,7 +99,10 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
9999
identifier: this.identifier,
100100
displayName: details.name,
101101
model: details.model,
102-
abis: details['cpu.abilist64'].split(',').concat(details['cpu.abilist32'].split(',')),
102+
abis: [
103+
...details["cpu.abilist64"].split(","),
104+
...details["cpu.abilist32"].split(","),
105+
],
103106
version,
104107
vendor: details.brand,
105108
platform: this.$devicePlatformsConstants.Android,
@@ -115,12 +118,14 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
115118
: [DeviceConnectionType.USB];
116119

117120
if (this.isEmulator) {
118-
this.deviceInfo.displayName = await this.$androidEmulatorServices.getRunningEmulatorName(
119-
this.identifier
120-
);
121-
this.deviceInfo.imageIdentifier = await this.$androidEmulatorServices.getRunningEmulatorImageIdentifier(
122-
this.identifier
123-
);
121+
this.deviceInfo.displayName =
122+
await this.$androidEmulatorServices.getRunningEmulatorName(
123+
this.identifier
124+
);
125+
this.deviceInfo.imageIdentifier =
126+
await this.$androidEmulatorServices.getRunningEmulatorImageIdentifier(
127+
this.identifier
128+
);
124129
}
125130

126131
this.$logger.trace(this.deviceInfo);
@@ -165,9 +170,10 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
165170
// sample line is "ro.build.version.release=4.4" in /system/build.prop
166171
// sample line from getprop is: [ro.build.version.release]: [6.0]
167172
// NOTE: some props do not have value: [ro.build.version.base_os]: []
168-
const match = /(?:\[?ro\.build\.version|ro\.product|ro\.build)\.(.+?)]?(?:\:|=)(?:\s*?\[)?(.*?)]?$/.exec(
169-
value
170-
);
173+
const match =
174+
/(?:\[?ro\.build\.version|ro\.product|ro\.build)\.(.+?)]?(?:\:|=)(?:\s*?\[)?(.*?)]?$/.exec(
175+
value
176+
);
171177
if (match) {
172178
parsedDetails[match[1]] = match[2];
173179
}
@@ -193,7 +199,8 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
193199
}
194200

195201
private async getType(): Promise<string> {
196-
const runningEmulatorIds = await this.$androidEmulatorServices.getRunningEmulatorIds();
202+
const runningEmulatorIds =
203+
await this.$androidEmulatorServices.getRunningEmulatorIds();
197204
if (
198205
_.find(runningEmulatorIds, (emulatorId) => emulatorId === this.identifier)
199206
) {

lib/controllers/build-controller.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ export class BuildController extends EventEmitter implements IBuildController {
165165
return true;
166166
}
167167

168-
const validBuildOutputData = platformData.getValidBuildOutputData(
169-
buildData
170-
);
168+
const validBuildOutputData =
169+
platformData.getValidBuildOutputData(buildData);
171170
const packages = this.$buildArtifactsService.getAllAppPackages(
172171
outputPath,
173172
validBuildOutputData
@@ -176,9 +175,8 @@ export class BuildController extends EventEmitter implements IBuildController {
176175
return true;
177176
}
178177

179-
const prepareInfo = this.$projectChangesService.getPrepareInfo(
180-
platformData
181-
);
178+
const prepareInfo =
179+
this.$projectChangesService.getPrepareInfo(platformData);
182180
const buildInfo = this.$buildInfoFileService.getLocalBuildInfo(
183181
platformData,
184182
buildData

lib/controllers/deploy-controller.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export class DeployController {
2424
};
2525
await this.$prepareController.prepare(prepareData);
2626
await deviceDescriptor.buildAction();
27-
await this.$deviceInstallAppService.installOnDevice(
28-
device,
29-
{ ...deviceDescriptor.buildData, buildForDevice: !device.isEmulator }
30-
);
27+
await this.$deviceInstallAppService.installOnDevice(device, {
28+
...deviceDescriptor.buildData,
29+
buildForDevice: !device.isEmulator,
30+
});
3131
};
3232

3333
await this.$devicesService.execute(

lib/controllers/platform-controller.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ export class PlatformController implements IPlatformController {
6262

6363
this.$logger.trace("Determined package to install is", packageToInstall);
6464

65-
const installedPlatformVersion = await this.$addPlatformService.addPlatformSafe(
66-
projectData,
67-
platformData,
68-
packageToInstall,
69-
addPlatformData
70-
);
65+
const installedPlatformVersion =
66+
await this.$addPlatformService.addPlatformSafe(
67+
projectData,
68+
platformData,
69+
packageToInstall,
70+
addPlatformData
71+
);
7172
const buildPath = projectData.platformsDir;
72-
this.$fs.ensureDirectoryExists(
73-
path.join(projectData.platformsDir, platform)
74-
);
73+
this.$fs.ensureDirectoryExists(path.join(buildPath, platform));
7574

7675
if (this.$mobileHelper.isAndroidPlatform(platform)) {
7776
const gradlePropertiesPath = path.resolve(
@@ -80,7 +79,8 @@ export class PlatformController implements IPlatformController {
8079
);
8180
const commentHeader = "# App configuration";
8281
const appPath = projectData.getAppDirectoryRelativePath();
83-
const appResourcesPath = projectData.getAppResourcesRelativeDirectoryPath();
82+
const appResourcesPath =
83+
projectData.getAppResourcesRelativeDirectoryPath();
8484

8585
let gradlePropertiesContents = "";
8686
if (this.$fs.exists(gradlePropertiesPath)) {
@@ -162,9 +162,10 @@ export class PlatformController implements IPlatformController {
162162

163163
if (!desiredRuntimePackage.version) {
164164
// if no version is explicitly added, then we use the latest
165-
desiredRuntimePackage.version = await this.$packageInstallationManager.getLatestCompatibleVersion(
166-
desiredRuntimePackage.name
167-
);
165+
desiredRuntimePackage.version =
166+
await this.$packageInstallationManager.getLatestCompatibleVersion(
167+
desiredRuntimePackage.name
168+
);
168169
}
169170
// const currentPlatformData = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
170171
// version = (currentPlatformData && currentPlatformData.version) ||
@@ -187,9 +188,8 @@ export class PlatformController implements IPlatformController {
187188

188189
const shouldAddNativePlatform =
189190
!nativePrepare || !nativePrepare.skipNativePrepare;
190-
const prepareInfo = this.$projectChangesService.getPrepareInfo(
191-
platformData
192-
);
191+
const prepareInfo =
192+
this.$projectChangesService.getPrepareInfo(platformData);
193193
const requiresNativePlatformAdd =
194194
prepareInfo &&
195195
prepareInfo.nativePlatformStatus ===

lib/controllers/prepare-controller.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ export class PrepareController extends EventEmitter {
289289
data.platform.toLowerCase() === platformData.platformNameLowerCase
290290
) {
291291
if (this.isFileWatcherPaused()) return;
292-
this.emitPrepareEvent({ ...data, files: data.files ?? [], hasNativeChanges: false });
292+
this.emitPrepareEvent({
293+
...data,
294+
files: data.files ?? [],
295+
hasNativeChanges: false,
296+
});
293297
}
294298
};
295299

lib/controllers/run-controller.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ export class RunController extends EventEmitter implements IRunController {
112112
data.platform,
113113
projectData
114114
);
115-
await this.syncChangedDataOnDevices(data, projectData, platformData, liveSyncInfo);
115+
await this.syncChangedDataOnDevices(
116+
data,
117+
projectData,
118+
platformData,
119+
liveSyncInfo
120+
);
116121
}
117122
};
118123

@@ -537,7 +542,7 @@ export class RunController extends EventEmitter implements IRunController {
537542
await deviceDescriptor.buildAction();
538543
rebuiltInformation[platformData.platformNameLowerCase] = {
539544
isEmulator: device.isEmulator,
540-
platform: platformData.platformNameLowerCase
545+
platform: platformData.platformNameLowerCase,
541546
};
542547
} else {
543548
await this.$analyticsService.trackEventActionInGoogleAnalytics({

lib/declarations.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,9 @@ interface IAndroidBundleOptions {
579579
}
580580

581581
interface IAndroidOptions {
582+
gradleArgs: string[];
582583
gradleFlavor: string;
583584
gradlePath: string;
584-
gradleArgs: string[];
585585
}
586586

587587
interface ITypingsOptions {

lib/definitions/android-plugin-migrator.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ interface IBuildAndroidPluginData extends Partial<IProjectDir> {
4848
/**
4949
* Optional custom Gradle arguments.
5050
*/
51-
gradleArgs?: string[],
51+
gradleArgs?: string[];
5252
}

lib/definitions/build.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ interface IAndroidBuildData
3131
IAndroidSigningData,
3232
IHasAndroidBundle {
3333
buildFilterDevicesArch?: boolean;
34-
gradlePath?: string;
35-
gradleFlavor?: string;
3634
gradleArgs?: string[];
35+
gradleFlavor?: string;
36+
gradlePath?: string;
3737
}
3838

3939
interface IAndroidSigningData {

lib/options.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ export class Options {
219219
default: false,
220220
hasSensitiveValue: false,
221221
},
222+
gradleArgs: {
223+
type: OptionType.String,
224+
hasSensitiveValue: false,
225+
array: true,
226+
},
222227
gradleFlavor: { type: OptionType.String, hasSensitiveValue: false },
223228
gradlePath: { type: OptionType.String, hasSensitiveValue: false },
224-
gradleArgs: { type: OptionType.String, hasSensitiveValue: false, array: true },
225229
aab: { type: OptionType.Boolean, hasSensitiveValue: false },
226230
filterDevicesArch: { type: OptionType.Boolean, hasSensitiveValue: false },
227231
performance: { type: OptionType.Object, hasSensitiveValue: true },
@@ -424,9 +428,8 @@ export class Options {
424428
this.$settingsService.setSettings({
425429
profileDir: <string>this.argv.profileDir,
426430
});
427-
this.argv.profileDir = this.argv[
428-
"profile-dir"
429-
] = this.$settingsService.getProfileDir();
431+
this.argv.profileDir = this.argv["profile-dir"] =
432+
this.$settingsService.getProfileDir();
430433

431434
// if justlaunch is set, it takes precedence over the --watch flag and the default true value
432435
if (this.argv.justlaunch) {

lib/project-data.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ export class ProjectData implements IProjectData {
165165
path.basename(projectDir)
166166
);
167167
this.nsConfig = nsConfig;
168-
this.platformsDir = path.join(projectDir, this.getBuildRelativeDirectoryPath());
168+
this.platformsDir = path.join(
169+
projectDir,
170+
this.getBuildRelativeDirectoryPath()
171+
);
169172
this.projectFilePath = projectFilePath;
170173
this.projectIdentifiers = this.initializeProjectIdentifiers(nsConfig);
171174
this.packageJsonData = packageJsonData;
@@ -217,11 +220,10 @@ export class ProjectData implements IProjectData {
217220
appResourcesDir,
218221
this.$devicePlatformsConstants.Android
219222
);
220-
const androidManifestDir = this.$androidResourcesMigrationService.hasMigrated(
221-
appResourcesDir
222-
)
223-
? path.join(androidDirPath, constants.SRC_DIR, constants.MAIN_DIR)
224-
: androidDirPath;
223+
const androidManifestDir =
224+
this.$androidResourcesMigrationService.hasMigrated(appResourcesDir)
225+
? path.join(androidDirPath, constants.SRC_DIR, constants.MAIN_DIR)
226+
: androidDirPath;
225227

226228
return path.join(androidManifestDir, constants.MANIFEST_FILE_NAME);
227229
}
@@ -244,7 +246,8 @@ export class ProjectData implements IProjectData {
244246
}
245247

246248
public getAppResourcesDirectoryPath(projectDir?: string): string {
247-
const appResourcesRelativePath = this.getAppResourcesRelativeDirectoryPath();
249+
const appResourcesRelativePath =
250+
this.getAppResourcesRelativeDirectoryPath();
248251

249252
return this.resolveToProjectDir(appResourcesRelativePath, projectDir);
250253
}
@@ -271,10 +274,7 @@ export class ProjectData implements IProjectData {
271274
}
272275

273276
public getBuildRelativeDirectoryPath(): string {
274-
if (
275-
this.nsConfig &&
276-
this.nsConfig[constants.CONFIG_NS_BUILD_ENTRY]
277-
) {
277+
if (this.nsConfig && this.nsConfig[constants.CONFIG_NS_BUILD_ENTRY]) {
278278
return this.nsConfig[constants.CONFIG_NS_BUILD_ENTRY];
279279
}
280280

lib/services/android-plugin-build-service.ts

+16-11
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
361361
this.$fs.copyFile(path.join(dir, "*"), destination);
362362
}
363363
}
364-
private extractNamespaceFromManifest(manifestPath:string): string {
364+
private extractNamespaceFromManifest(manifestPath: string): string {
365365
const fileContent = this.$fs.readText(manifestPath);
366366
const contentRegex = new RegExp('package="(.*?)"');
367367
const match = fileContent.match(contentRegex);
@@ -394,10 +394,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
394394
if (this.$projectData.nsConfig.android.gradleVersion) {
395395
gradleVersion = this.$projectData.nsConfig.android.gradleVersion;
396396
}
397-
this.replaceGradleVersion(
398-
pluginTempDir,
399-
gradleVersion
400-
);
397+
this.replaceGradleVersion(pluginTempDir, gradleVersion);
401398

402399
this.replaceGradleAndroidPluginVersion(
403400
buildGradlePath,
@@ -407,13 +404,19 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
407404
// In gradle 8 every android project must have a namespace in "android"
408405
// and the package property in manifest is now forbidden
409406
// let s replace it
410-
const manifestFilePath = this.getManifest(path.join(pluginTempDir, 'src', 'main'));
407+
const manifestFilePath = this.getManifest(
408+
path.join(pluginTempDir, "src", "main")
409+
);
411410
let pluginNamespace = this.extractNamespaceFromManifest(manifestFilePath);
412411
if (!pluginNamespace) {
413-
pluginNamespace = pluginName.replace(/@/g, '').replace(/[/-]/g, '.')
412+
pluginNamespace = pluginName.replace(/@/g, "").replace(/[/-]/g, ".");
414413
}
415414

416-
this.replaceFileContent(buildGradlePath, "{{pluginNamespace}}", pluginNamespace);
415+
this.replaceFileContent(
416+
buildGradlePath,
417+
"{{pluginNamespace}}",
418+
pluginNamespace
419+
);
417420
this.replaceFileContent(buildGradlePath, "{{pluginName}}", pluginName);
418421
this.replaceFileContent(settingsGradlePath, "{{pluginName}}", pluginName);
419422
}
@@ -779,9 +782,11 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
779782
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`,
780783
];
781784
if (pluginBuildSettings.gradleArgs) {
782-
const additionalArgs: string[] = []
783-
pluginBuildSettings.gradleArgs.forEach(arg=>{
784-
additionalArgs.push(...arg.split(' -P').map((a,i) => i === 0 ? a : `-P${a}`));
785+
const additionalArgs: string[] = [];
786+
pluginBuildSettings.gradleArgs.forEach((arg) => {
787+
additionalArgs.push(
788+
...arg.split(" -P").map((a, i) => (i === 0 ? a : `-P${a}`))
789+
);
785790
});
786791
localArgs.push(...additionalArgs);
787792
}

0 commit comments

Comments
 (0)