Skip to content

Commit cd7c327

Browse files
committed
Address PR comments
1 parent fe1df79 commit cd7c327

10 files changed

+24
-41
lines changed

lib/commands/debug.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ export abstract class DebugPlatformCommand implements ICommand {
6969
skipWatcher: !this.$options.watch || this.$options.justlaunch,
7070
watchAllFiles: this.$options.syncAllFiles
7171
};
72-
const projectFilesConfig: IProjectFilesConfig = {
73-
configuration: this.$options.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase()
74-
};
75-
await this.$debugLiveSyncService.liveSync(deviceDescriptors, liveSyncInfo, projectFilesConfig);
72+
await this.$debugLiveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
7673
}
7774

7875
public async getDeviceForDebug(): Promise<Mobile.IDevice> {

lib/commands/run.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ERROR_NO_VALID_SUBCOMMAND_FORMAT, Configurations } from "../common/constants";
1+
import { ERROR_NO_VALID_SUBCOMMAND_FORMAT } from "../common/constants";
22

33
export class RunCommandBase implements ICommand {
44
protected platform: string;
@@ -116,10 +116,7 @@ export class RunCommandBase implements ICommand {
116116
watchAllFiles: this.$options.syncAllFiles,
117117
clean: this.$options.clean
118118
};
119-
const projectFilesConfig: IProjectFilesConfig = {
120-
configuration: this.$options.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase()
121-
};
122-
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo, projectFilesConfig);
119+
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
123120
}
124121
}
125122

lib/commands/test.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { Configurations } from "../common/constants";
1+
import * as helpers from "../common/helpers";
22

33
function RunTestCommandFactory(platform: string) {
44
return function RunTestCommand(
55
$options: IOptions,
66
$testExecutionService: ITestExecutionService,
77
$projectData: IProjectData) {
88
$projectData.initializeProjectData();
9-
const projectFilesConfig: IProjectFilesConfig = {
10-
configuration: this.$options.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase()
11-
};
9+
const projectFilesConfig = helpers.getProjectFilesConfig(this.$options.release);
1210
this.execute = (args: string[]): Promise<void> => $testExecutionService.startTestRunner(platform, $projectData, projectFilesConfig);
1311
this.allowedParameters = [];
1412
};
@@ -20,9 +18,7 @@ $injector.registerCommand("dev-test|ios", RunTestCommandFactory('iOS'));
2018
function RunKarmaTestCommandFactory(platform: string) {
2119
return function RunKarmaTestCommand($options: IOptions, $testExecutionService: ITestExecutionService, $projectData: IProjectData) {
2220
$projectData.initializeProjectData();
23-
const projectFilesConfig: IProjectFilesConfig = {
24-
configuration: this.$options.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase()
25-
};
21+
const projectFilesConfig = helpers.getProjectFilesConfig(this.$options.release);
2622
this.execute = (args: string[]): Promise<void> => $testExecutionService.startKarmaServer(platform, $projectData, projectFilesConfig);
2723
this.allowedParameters = [];
2824
};

lib/definitions/livesync.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ interface ILiveSyncService {
154154
* @param {ILiveSyncInfo} liveSyncData Describes the LiveSync operation - for which project directory is the operation and other settings.
155155
* @returns {Promise<void>}
156156
*/
157-
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo, projectFilesConfig: IProjectFilesConfig): Promise<void>;
157+
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void>;
158158

159159
/**
160160
* Stops LiveSync operation for specified directory.
@@ -203,7 +203,7 @@ interface IFullSyncInfo {
203203

204204
interface IPlatformLiveSyncService {
205205
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
206-
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo, projectFilesConfig: IProjectFilesConfig): Promise<ILiveSyncResultInfo>;
206+
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
207207
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
208208
}
209209

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I
5858
};
5959
}
6060

61-
public liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo, projectFilesConfig: IProjectFilesConfig): Promise<ILiveSyncResultInfo> {
61+
public liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo> {
6262
if (liveSyncInfo.isRebuilt) {
6363
// In this case we should execute fullsync because iOS Runtime requires the full content of app dir to be extracted in the root of sync dir.
6464
return this.fullSync({ projectData: liveSyncInfo.projectData, device, syncAllFiles: liveSyncInfo.syncAllFiles, watch: true });
6565
} else {
66-
return super.liveSyncWatchAction(device, liveSyncInfo, projectFilesConfig);
66+
return super.liveSyncWatchAction(device, liveSyncInfo);
6767
}
6868
}
6969

lib/services/livesync/livesync-service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
3434
}
3535

3636
public async liveSync(deviceDescriptors: ILiveSyncDeviceInfo[],
37-
liveSyncData: ILiveSyncInfo, projectFilesConfig: IProjectFilesConfig): Promise<void> {
37+
liveSyncData: ILiveSyncInfo): Promise<void> {
3838
const projectData = this.$projectDataService.getProjectData(liveSyncData.projectDir);
3939
await this.$pluginsService.ensureAllDependenciesAreInstalled(projectData);
40-
await this.liveSyncOperation(deviceDescriptors, liveSyncData, projectData, projectFilesConfig);
40+
await this.liveSyncOperation(deviceDescriptors, liveSyncData, projectData);
4141
}
4242

4343
public async stopLiveSync(projectDir: string, deviceIdentifiers?: string[]): Promise<void> {
@@ -117,7 +117,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
117117

118118
@hook("liveSync")
119119
private async liveSyncOperation(deviceDescriptors: ILiveSyncDeviceInfo[],
120-
liveSyncData: ILiveSyncInfo, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void> {
120+
liveSyncData: ILiveSyncInfo, projectData: IProjectData): Promise<void> {
121121
// In case liveSync is called for a second time for the same projectDir.
122122
const isAlreadyLiveSyncing = this.liveSyncProcessesInfo[projectData.projectDir] && !this.liveSyncProcessesInfo[projectData.projectDir].isStopped;
123123
this.setLiveSyncProcessInfo(liveSyncData.projectDir, deviceDescriptors);
@@ -130,7 +130,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
130130
// Should be set after prepare
131131
this.$injector.resolve<DeprecatedUsbLiveSyncService>("usbLiveSyncService").isInitialized = true;
132132

133-
await this.startWatcher(projectData, liveSyncData, projectFilesConfig);
133+
await this.startWatcher(projectData, liveSyncData);
134134
}
135135
}
136136

@@ -272,7 +272,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
272272
};
273273
}
274274

275-
private async startWatcher(projectData: IProjectData, liveSyncData: ILiveSyncInfo, projectFilesConfig: IProjectFilesConfig): Promise<void> {
275+
private async startWatcher(projectData: IProjectData, liveSyncData: ILiveSyncInfo): Promise<void> {
276276
let pattern = [APP_FOLDER_NAME];
277277

278278
if (liveSyncData.watchAllFiles) {
@@ -338,7 +338,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
338338
useLiveEdit: liveSyncData.useLiveEdit
339339
};
340340

341-
const liveSyncResultInfo = await service.liveSyncWatchAction(device, settings, projectFilesConfig);
341+
const liveSyncResultInfo = await service.liveSyncWatchAction(device, settings);
342342
await this.refreshApplication(projectData, liveSyncResultInfo);
343343
},
344344
(device: Mobile.IDevice) => {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ export abstract class PlatformLiveSyncServiceBase {
5353
};
5454
}
5555

56-
public async liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo, projectFilesConfig: IProjectFilesConfig): Promise<ILiveSyncResultInfo> {
56+
public async liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo> {
5757
const projectData = liveSyncInfo.projectData;
5858
const syncInfo = _.merge<IFullSyncInfo>({ device, watch: true }, liveSyncInfo);
5959
const deviceAppData = await this.getAppData(syncInfo);
6060

6161
let modifiedLocalToDevicePaths: Mobile.ILocalToDevicePathData[] = [];
6262
if (liveSyncInfo.filesToSync.length) {
6363
const filesToSync = liveSyncInfo.filesToSync;
64-
const mappedFiles = _.map(filesToSync, filePath => this.$projectFilesProvider.mapFilePath(filePath, device.deviceInfo.platform, projectData, projectFilesConfig));
64+
const mappedFiles = _.map(filesToSync, filePath => this.$projectFilesProvider.mapFilePath(filePath, device.deviceInfo.platform, projectData));
6565

6666
// Some plugins modify platforms dir on afterPrepare (check nativescript-dev-sass) - we want to sync only existing file.
6767
const existingFiles = mappedFiles.filter(m => this.$fs.exists(m));
@@ -85,7 +85,7 @@ export abstract class PlatformLiveSyncServiceBase {
8585
const filePaths = liveSyncInfo.filesToRemove;
8686
const platformData = this.$platformsData.getPlatformData(device.deviceInfo.platform, projectData);
8787

88-
const mappedFiles = _.map(filePaths, filePath => this.$projectFilesProvider.mapFilePath(filePath, device.deviceInfo.platform, projectData, projectFilesConfig));
88+
const mappedFiles = _.map(filePaths, filePath => this.$projectFilesProvider.mapFilePath(filePath, device.deviceInfo.platform, projectData));
8989
const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, APP_FOLDER_NAME);
9090
const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, mappedFiles, []);
9191
modifiedLocalToDevicePaths.push(...localToDevicePaths);

lib/services/platform-service.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as semver from "semver";
66
import { EventEmitter } from "events";
77
import { AppFilesUpdater } from "./app-files-updater";
88
import { attachAwaitDetach } from "../common/helpers";
9-
import { Configurations } from "../common/constants";
9+
1010
import * as temp from "temp";
1111
temp.track();
1212
let clui = require("clui");
@@ -305,11 +305,8 @@ export class PlatformService extends EventEmitter implements IPlatformService {
305305
this.copyAppResources(platform, projectData);
306306
await platformData.platformProjectService.prepareProject(projectData, platformSpecificData);
307307
}
308-
308+
const projectFilesConfig = helpers.getProjectFilesConfig(appFilesUpdaterOptions.release);
309309
if (!changesInfo || changesInfo.modulesChanged) {
310-
const projectFilesConfig: IProjectFilesConfig = {
311-
configuration: appFilesUpdaterOptions.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase()
312-
};
313310
await this.copyTnsModules(platform, projectData, projectFilesConfig);
314311
} else if (appFilesUpdaterOptions.bundle) {
315312
let dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir);
@@ -329,10 +326,6 @@ export class PlatformService extends EventEmitter implements IPlatformService {
329326
excludedDirs.push(constants.TNS_MODULES_FOLDER_NAME);
330327
}
331328

332-
const projectFilesConfig: IProjectFilesConfig = {
333-
configuration: appFilesUpdaterOptions.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase()
334-
};
335-
336329
this.$projectFilesManager.processPlatformSpecificFiles(directoryPath, platform, projectFilesConfig, excludedDirs);
337330

338331
if (!changesInfo || changesInfo.configChanged || changesInfo.modulesChanged) {

lib/services/test-execution-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class TestExecutionService implements ITestExecutionService {
114114

115115
const liveSyncInfo: ILiveSyncInfo = { projectDir: projectData.projectDir, skipWatcher: !this.$options.watch || this.$options.justlaunch, watchAllFiles: this.$options.syncAllFiles };
116116

117-
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo, projectFilesConfig);
117+
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
118118

119119
if (this.$options.debugBrk) {
120120
this.$logger.info('Starting debugger...');
@@ -224,7 +224,7 @@ class TestExecutionService implements ITestExecutionService {
224224
});
225225

226226
const liveSyncInfo: ILiveSyncInfo = { projectDir: projectData.projectDir, skipWatcher: !this.$options.watch || this.$options.justlaunch, watchAllFiles: this.$options.syncAllFiles };
227-
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo, projectFilesConfig);
227+
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
228228
}
229229
};
230230

0 commit comments

Comments
 (0)