Skip to content

Commit 1b18dcd

Browse files
committed
refactor: the CLI builds aar files if necessary even with no --syncAllFiles flag
1 parent bdc92dd commit 1b18dcd

File tree

6 files changed

+9
-60
lines changed

6 files changed

+9
-60
lines changed

lib/services/android-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
436436
tempPluginDirPath: path.join(projectData.platformsDir, "tempPlugin")
437437
};
438438

439-
this.prebuildNativePlugin(options);
439+
await this.prebuildNativePlugin(options);
440440
}
441441
}
442442

lib/services/livesync/livesync-service.ts

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as path from "path";
22
import * as choki from "chokidar";
33
import { EOL } from "os";
44
import { EventEmitter } from "events";
5-
import { hook, executeActionByChunks, isBuildFromCLI } from "../../common/helpers";
5+
import { hook, isBuildFromCLI } from "../../common/helpers";
66
import { PACKAGE_JSON_FILE_NAME, LiveSyncTrackActionNames, USER_INTERACTION_NEEDED_EVENT_NAME, DEBUGGER_ATTACHED_EVENT_NAME, DEBUGGER_DETACHED_EVENT_NAME, TrackActionNames } from "../../constants";
7-
import { DEFAULT_CHUNK_SIZE, DeviceTypes, DeviceDiscoveryEventNames } from "../../common/constants";
7+
import { DeviceTypes, DeviceDiscoveryEventNames } from "../../common/constants";
88
import { cache } from "../../common/decorators";
99

1010
const deviceDescriptorPrimaryKey = "identifier";
@@ -37,8 +37,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
3737
private $debugDataService: IDebugDataService,
3838
private $analyticsService: IAnalyticsService,
3939
private $usbLiveSyncService: DeprecatedUsbLiveSyncService,
40-
private $injector: IInjector,
41-
private $platformsData: IPlatformsData) {
40+
private $injector: IInjector) {
4241
super();
4342
}
4443

@@ -463,26 +462,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
463462
const platform = device.deviceInfo.platform;
464463
const deviceBuildInfoDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier);
465464

466-
if (liveSyncData.watchAllFiles) {
467-
const platformData: IPlatformData = this.$platformsData.getPlatformData("android", projectData);
468-
const pluginsNeedingRebuild: Array<any> = await platformData.platformProjectService.checkIfPluginsNeedBuild(projectData);
469-
const action = async (buildAarOptions: IBuildOptions) => {
470-
this.$logger.warn(`Building ${buildAarOptions.pluginName}...`);
471-
await platformData.platformProjectService.prebuildNativePlugin(buildAarOptions);
472-
};
473-
const pluginInfo: any = [];
474-
pluginsNeedingRebuild.forEach((item) => {
475-
const options: IBuildOptions = {
476-
pluginName: item.pluginName,
477-
platformsAndroidDirPath: item.platformsAndroidDirPath,
478-
aarOutputDir: item.platformsAndroidDirPath,
479-
tempPluginDirPath: path.join(projectData.platformsDir, 'tempPlugin')
480-
};
481-
pluginInfo.push(options);
482-
});
483-
await executeActionByChunks<IBuildOptions>(pluginInfo, DEFAULT_CHUNK_SIZE, action);
484-
}
485-
486465
await this.ensureLatestAppPackageIsInstalledOnDevice({
487466
device,
488467
preparedPlatforms,
@@ -582,37 +561,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
582561
filesToRemove = [];
583562

584563
const allModifiedFiles = [].concat(currentFilesToSync).concat(currentFilesToRemove);
585-
if (liveSyncData.watchAllFiles) {
586-
587-
const platformData: IPlatformData = this.$platformsData.getPlatformData("android", projectData);
588-
const pluginInfo: any = [];
589-
allModifiedFiles.forEach(async (item) => {
590-
const matchedItem = item.match(/(.*\/node_modules\/[\w-]+)\/platforms\/android\//);
591-
if (matchedItem) {
592-
const matchLength = matchedItem[0].length;
593-
const matchIndex = item.indexOf(matchedItem[0]);
594-
const pluginInputOutputPath = item.substr(0, matchIndex + matchLength);
595-
const pluginPackageJason = require(path.resolve(matchedItem[1], PACKAGE_JSON_FILE_NAME));
596-
597-
if (pluginPackageJason && pluginPackageJason.name) {
598-
const options: IBuildOptions = {
599-
pluginName: pluginPackageJason.name,
600-
platformsAndroidDirPath: pluginInputOutputPath,
601-
aarOutputDir: pluginInputOutputPath,
602-
tempPluginDirPath: path.join(projectData.platformsDir, "tempPlugin")
603-
};
604-
pluginInfo.push(options);
605-
}
606-
}
607-
});
608-
609-
const action = async (buildAarOptions: IBuildOptions) => {
610-
this.$logger.warn(`Building ${buildAarOptions.pluginName}...`);
611-
await platformData.platformProjectService.prebuildNativePlugin(buildAarOptions);
612-
};
613564

614-
await executeActionByChunks<IBuildOptions>(pluginInfo, DEFAULT_CHUNK_SIZE, action);
615-
}
616565
const preparedPlatforms: string[] = [];
617566
const rebuiltInformation: ILiveSyncBuildInfo[] = [];
618567

lib/services/platform-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
191191
const platformData = this.$platformsData.getPlatformData(platformInfo.platform, platformInfo.projectData);
192192

193193
const changesInfo = await this.initialPrepare(platformInfo.platform, platformData, platformInfo.appFilesUpdaterOptions, platformInfo.platformTemplate, platformInfo.projectData, platformInfo.config, platformInfo.nativePrepare, platformInfo);
194-
const requiresNativePrepare = (!platformInfo.nativePrepare || !platformInfo.nativePrepare.skipNativePrepare) && changesInfo.nativePlatformStatus === constants.NativePlatformStatus.requiresPrepare;
194+
const requiresNativePrepare = changesInfo.nativeChanged || (!platformInfo.nativePrepare || !platformInfo.nativePrepare.skipNativePrepare) && changesInfo.nativePlatformStatus === constants.NativePlatformStatus.requiresPrepare;
195195

196196
if (changesInfo.hasChanges || requiresNativePrepare) {
197197
// Always clear up the app directory in platforms if `--bundle` value has changed in between builds or is passed in general
@@ -297,6 +297,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
297297
platformSpecificData,
298298
changesInfo,
299299
filesToSync,
300+
filesToRemove,
300301
projectFilesConfig,
301302
env
302303
});

lib/services/project-changes-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class ProjectChangesService implements IProjectChangesService {
6464
this._changesInfo.packageChanged = this.isProjectFileChanged(projectData, platform);
6565
this._changesInfo.appResourcesChanged = this.containsNewerFiles(projectData.appResourcesDirectoryPath, null, projectData);
6666
/*done because currently all node_modules are traversed, a possible improvement could be traversing only the production dependencies*/
67-
this._changesInfo.nativeChanged = projectChangesOptions.skipModulesNativeCheck ? false : this.containsNewerFiles(
67+
this._changesInfo.nativeChanged = this.containsNewerFiles(
6868
path.join(projectData.projectDir, NODE_MODULES_FOLDER_NAME),
6969
path.join(projectData.projectDir, NODE_MODULES_FOLDER_NAME, "tns-ios-inspector"),
7070
projectData,

lib/tools/node-modules/node-modules-dest-copy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class NpmPluginPrepare {
140140
}
141141

142142
public async preparePlugins(dependencies: IDependencyData[], platform: string, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void> {
143-
if (_.isEmpty(dependencies) || this.allPrepared(dependencies, platform, projectData)) {
143+
if (_.isEmpty(dependencies)) {
144144
return;
145145
}
146146

test/services/livesync-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ class LiveSyncServiceInheritor extends LiveSyncService {
7575
$debugDataService,
7676
$analyticsService,
7777
$usbLiveSyncService,
78-
$injector,
79-
$platformsData
78+
$injector
8079
);
8180
}
8281

0 commit comments

Comments
 (0)