Skip to content

Commit c24b867

Browse files
authored
Merge pull request #2148 from NativeScript/raikov/incremental-run
Implemented incremental prepare
2 parents e84dd6d + a671087 commit c24b867

18 files changed

+233
-83
lines changed

lib/commands/appstore-upload.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ export class PublishIOS implements ICommand {
6363
};
6464
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
6565
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
66-
this.$platformService.prepareAndExecute(platform, () => this.$platformService.buildPlatform(platform, iOSBuildConfig)).wait();
66+
this.$platformService.prepareAndBuild(platform, iOSBuildConfig, true).wait();
6767
ipaFilePath = this.$platformService.lastOutputPath(platform, { isForDevice: iOSBuildConfig.buildForDevice });
6868
} else {
6969
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
70-
if (!this.$platformService.preparePlatform(platform).wait()) {
71-
this.$errors.failWithoutHelp("Failed to prepare project.");
72-
}
70+
this.$platformService.preparePlatform(platform, true).wait();
7371

7472
let platformData = this.$platformsData.getPlatformData(platform);
7573
let iOSProjectService = <IOSProjectService>platformData.platformProjectService;

lib/commands/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class BuildCommandBase {
55
executeCore(args: string[], buildConfig?: IBuildConfig): IFuture<void> {
66
return (() => {
77
let platform = args[0].toLowerCase();
8-
this.$platformService.prepareAndExecute(platform, () => this.$platformService.buildPlatform(platform, buildConfig)).wait();
8+
this.$platformService.prepareAndBuild(platform, buildConfig, true).wait();
99
if(this.$options.copyTo) {
1010
this.$platformService.copyLastOutput(platform, this.$options.copyTo, {isForDevice: this.$options.forDevice}).wait();
1111
}

lib/commands/prepare.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export class PrepareCommand implements ICommand {
55

66
execute(args: string[]): IFuture<void> {
77
return (() => {
8-
if (!this.$platformService.preparePlatform(args[0]).wait()) {
9-
this.$errors.failWithoutHelp("Unable to prepare the project.");
10-
}
8+
this.$platformService.preparePlatform(args[0], true).wait();
119
}).future<void>()();
1210
}
1311

lib/common

lib/definitions/platform.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface IPlatformService {
66
removePlatforms(platforms: string[]): IFuture<void>;
77
updatePlatforms(platforms: string[]): IFuture<void>;
88
runPlatform(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
9-
preparePlatform(platform: string): IFuture<boolean>;
9+
preparePlatform(platform: string, force?: boolean, skipModulesAndResources?: boolean): IFuture<boolean>;
1010
cleanDestinationApp(platform: string): IFuture<void>;
1111
buildPlatform(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
1212
buildForDeploy(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
@@ -23,7 +23,7 @@ interface IPlatformService {
2323
lastOutputPath(platform: string, settings: { isForDevice: boolean }): string;
2424
ensurePlatformInstalled(platform: string): IFuture<void>;
2525

26-
prepareAndExecute(platform: string, executeAction: () => IFuture<void>): IFuture<void>;
26+
prepareAndBuild(platform: string, buildConfig?: IBuildConfig, forceBuild?: boolean): IFuture<void>;
2727
}
2828

2929
interface IPlatformData {

lib/providers/livesync-provider.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ export class LiveSyncProvider implements ILiveSyncProvider {
6969

7070
public preparePlatformForSync(platform: string): IFuture<void> {
7171
return (() => {
72-
if (!this.$platformService.preparePlatform(platform).wait()) {
73-
this.$logger.out("Verify that listed files are well-formed and try again the operation.");
74-
}
72+
this.$platformService.preparePlatform(platform).wait();
7573
}).future<void>()();
7674
}
7775

lib/services/android-debug-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AndroidDebugService implements IDebugService {
111111
let cachedDeviceOption = this.$options.forDevice;
112112
this.$options.forDevice = true;
113113
if (this.$options.rebuild) {
114-
this.$platformService.prepareAndExecute(this.platform, () => this.$platformService.buildPlatform(this.platform)).wait();
114+
this.$platformService.prepareAndBuild(this.platform).wait();
115115
}
116116
this.$options.forDevice = !!cachedDeviceOption;
117117

lib/services/app-files-updater.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export class AppFilesUpdater {
5050
}
5151

5252
protected readSourceDir(): string[] {
53-
return this.fs.enumerateFilesInDirectorySync(this.appSourceDirectoryPath, null, { includeEmptyDirectories: true });
53+
let tnsDir = path.join(this.appSourceDirectoryPath, constants.TNS_MODULES_FOLDER_NAME);
54+
return this.fs.enumerateFilesInDirectorySync(this.appSourceDirectoryPath, null, { includeEmptyDirectories: true }).filter(dirName => dirName !== tnsDir);
5455
}
5556

5657
protected resolveAppSourceFiles(): string[] {

lib/services/ios-debug-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class IOSDebugService implements IDebugService {
102102
return (() => {
103103
let platformData = this.$platformsData.getPlatformData(this.platform);
104104
if (this.$options.rebuild) {
105-
this.$platformService.prepareAndExecute(this.platform, () => this.$platformService.buildPlatform(this.platform)).wait();
105+
this.$platformService.prepareAndBuild(this.platform).wait();
106106
}
107107
let emulatorPackage = this.$platformService.getLatestApplicationPackageForEmulator(platformData).wait();
108108

lib/services/ios-project-service.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1010,30 +1010,30 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10101010

10111011
private mergeProjectXcconfigFiles(): IFuture<void> {
10121012
return (() => {
1013-
this.$fs.deleteFile(this.pluginsDebugXcconfigFilePath).wait();
1014-
this.$fs.deleteFile(this.pluginsReleaseXcconfigFilePath).wait();
1013+
this.$fs.deleteFile(this.$options.release ? this.pluginsReleaseXcconfigFilePath : this.pluginsDebugXcconfigFilePath).wait();
10151014

10161015
let allPlugins: IPluginData[] = (<IPluginsService>this.$injector.resolve("pluginsService")).getAllInstalledPlugins().wait();
10171016
for (let plugin of allPlugins) {
10181017
let pluginPlatformsFolderPath = plugin.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
10191018
let pluginXcconfigFilePath = path.join(pluginPlatformsFolderPath, "build.xcconfig");
10201019
if (this.$fs.exists(pluginXcconfigFilePath).wait()) {
1021-
this.mergeXcconfigFiles(pluginXcconfigFilePath, this.pluginsDebugXcconfigFilePath).wait();
1022-
this.mergeXcconfigFiles(pluginXcconfigFilePath, this.pluginsReleaseXcconfigFilePath).wait();
1020+
this.mergeXcconfigFiles(pluginXcconfigFilePath,this.$options.release ? this.pluginsReleaseXcconfigFilePath : this.pluginsDebugXcconfigFilePath).wait();
10231021
}
10241022
}
10251023

10261024
let appResourcesXcconfigPath = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME, this.platformData.normalizedPlatformName, "build.xcconfig");
10271025
if (this.$fs.exists(appResourcesXcconfigPath).wait()) {
1028-
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.pluginsDebugXcconfigFilePath).wait();
1029-
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.pluginsReleaseXcconfigFilePath).wait();
1026+
this.mergeXcconfigFiles(appResourcesXcconfigPath, this.$options.release ? this.pluginsReleaseXcconfigFilePath : this.pluginsDebugXcconfigFilePath).wait();
10301027
}
10311028

10321029
let podFilesRootDirName = path.join("Pods", "Target Support Files", `Pods-${this.$projectData.projectName}`);
10331030
let podFolder = path.join(this.platformData.projectRoot, podFilesRootDirName);
10341031
if (this.$fs.exists(podFolder).wait()) {
1035-
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.debug.xcconfig`), this.pluginsDebugXcconfigFilePath).wait();
1036-
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.release.xcconfig`), this.pluginsReleaseXcconfigFilePath).wait();
1032+
if (this.$options.release) {
1033+
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.release.xcconfig`), this.pluginsReleaseXcconfigFilePath).wait();
1034+
} else {
1035+
this.mergeXcconfigFiles(path.join(this.platformData.projectRoot, podFilesRootDirName, `Pods-${this.$projectData.projectName}.debug.xcconfig`), this.pluginsDebugXcconfigFilePath).wait();
1036+
}
10371037
}
10381038
}).future<void>()();
10391039
}

lib/services/livesync/android-platform-livesync-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ class AndroidPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
55
protected $devicesService: Mobile.IDevicesService,
66
protected $mobileHelper: Mobile.IMobileHelper,
77
protected $logger: ILogger,
8-
protected $options: ICommonOptions,
8+
protected $options: IOptions,
99
protected $deviceAppDataFactory: Mobile.IDeviceAppDataFactory,
1010
protected $fs: IFileSystem,
1111
protected $injector: IInjector,
1212
protected $projectFilesManager: IProjectFilesManager,
1313
protected $projectFilesProvider: IProjectFilesProvider,
14+
protected $platformService: IPlatformService,
1415
protected $liveSyncProvider: ILiveSyncProvider) {
15-
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $liveSyncProvider);
16+
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $platformService, $liveSyncProvider);
1617
}
1718

1819
public fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void> {

lib/services/livesync/ios-platform-livesync-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ class IOSPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
55
protected $devicesService: Mobile.IDevicesService,
66
protected $mobileHelper: Mobile.IMobileHelper,
77
protected $logger: ILogger,
8-
protected $options: ICommonOptions,
8+
protected $options: IOptions,
99
protected $deviceAppDataFactory: Mobile.IDeviceAppDataFactory,
1010
protected $fs: IFileSystem,
1111
protected $injector: IInjector,
1212
protected $projectFilesManager: IProjectFilesManager,
1313
protected $projectFilesProvider: IProjectFilesProvider,
14+
protected $platformService: IPlatformService,
1415
protected $liveSyncProvider: ILiveSyncProvider) {
15-
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $liveSyncProvider);
16+
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $platformService, $liveSyncProvider);
1617
}
1718

1819
public fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void> {

lib/services/livesync/livesync-service.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ class LiveSyncService implements ILiveSyncService {
8080

8181
private prepareLiveSyncData(platform: string): ILiveSyncData {
8282
platform = platform || this.$devicesService.platform;
83-
if (!this.$platformService.preparePlatform(platform.toLowerCase()).wait()) {
84-
this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation.");
85-
}
86-
83+
this.$platformService.preparePlatform(platform.toLowerCase()).wait();
8784
let platformData = this.$platformsData.getPlatformData(platform.toLowerCase());
8885
if (this.$mobileHelper.isAndroidPlatform(platform)) {
8986
this.ensureAndroidFrameworkVersion(platformData).wait();

lib/services/livesync/platform-livesync-service-base.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
1818
protected $devicesService: Mobile.IDevicesService,
1919
protected $mobileHelper: Mobile.IMobileHelper,
2020
protected $logger: ILogger,
21-
protected $options: ICommonOptions,
21+
protected $options: IOptions,
2222
protected $deviceAppDataFactory: Mobile.IDeviceAppDataFactory,
2323
protected $fs: IFileSystem,
2424
protected $injector: IInjector,
2525
protected $projectFilesManager: IProjectFilesManager,
2626
protected $projectFilesProvider: IProjectFilesProvider,
27+
protected $platformService: IPlatformService,
2728
protected $liveSyncProvider: ILiveSyncProvider) {
2829
this.liveSyncData = _liveSyncData;
2930
this.fileHashes = Object.create(null);
@@ -151,8 +152,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
151152
for (let platformName in this.batch) {
152153
let batch = this.batch[platformName];
153154
batch.syncFiles(((filesToSync:string[]) => {
154-
this.$liveSyncProvider.preparePlatformForSync(platformName).wait();
155-
155+
this.$platformService.preparePlatform(platformName, false, !this.$options.syncAllFiles).wait();
156156
let canExecute = this.getCanExecuteAction(this.liveSyncData.platform, this.liveSyncData.appIdentifier);
157157
let deviceFileAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => this.transferFiles(deviceAppData, localToDevicePaths, this.liveSyncData.projectFilesPath, !filePath);
158158
let action = this.getSyncAction(filesToSync, deviceFileAction, afterFileSyncAction);

0 commit comments

Comments
 (0)