Skip to content

Commit 1441d07

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #261 from NativeScript/fatme/remove-tns-releated-code-from-common
Move tns related code to common
2 parents b7e67aa + 4610aed commit 1441d07

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

lib/definitions/project.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ interface IPlatformProjectService {
3030
buildProject(projectRoot: string): IFuture<void>;
3131
isPlatformPrepared(projectRoot: string): IFuture<boolean>;
3232
addLibrary(platformData: IPlatformData, libraryPath: string): IFuture<void>;
33+
getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup;
3334
}

lib/services/android-project-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ class AndroidProjectService implements IPlatformProjectService {
123123
}).future<string>()();
124124
}
125125

126+
public getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup {
127+
return { };
128+
}
129+
126130
private updateMetadata(projectRoot: string): void {
127131
var projMetadataDir = path.join(projectRoot, "assets", "metadata");
128132
var libsmetadataDir = path.join(projectRoot, "../../lib", this.platformData.normalizedPlatformName, AndroidProjectService.METADATA_DIRNAME);

lib/services/ios-project-service.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class IOSProjectService implements IPlatformProjectService {
2020
private $childProcess: IChildProcess,
2121
private $errors: IErrors,
2222
private $logger: ILogger,
23-
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices) { }
23+
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices,
24+
private $npm: INodePackageManager) { }
2425

2526
public get platformData(): IPlatformData {
2627
return {
@@ -195,6 +196,25 @@ class IOSProjectService implements IPlatformProjectService {
195196
}).future<void>()();
196197
}
197198

199+
public getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup {
200+
var tnsIosPackage = "";
201+
if(options.frameworkPath) {
202+
if(this.$fs.getFsStats(options.frameworkPath).wait().isFile()) {
203+
this.$errors.fail("frameworkPath option must be path to directory which contains tns-ios framework");
204+
}
205+
206+
tnsIosPackage = path.resolve(options.frameworkPath);
207+
} else {
208+
tnsIosPackage = this.$npm.install("tns-ios").wait();
209+
}
210+
211+
var safariPath = path.join(tnsIosPackage, "WebInspectorUI/Safari/Main.html");
212+
213+
return {
214+
frontEndPath: safariPath
215+
}
216+
}
217+
198218
private validateDynamicFramework(libraryPath: string): IFuture<void> {
199219
return (() => {
200220
var infoPlistPath = path.join(libraryPath, "Info.plist");

lib/services/platform-service.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,13 @@ export class PlatformService implements IPlatformService {
210210
public debugOnDevice(platform: string): IFuture<void> {
211211
return (() => {
212212
platform = platform.toLowerCase();
213-
213+
var platformData = this.$platformsData.getPlatformData(platform);
214214
var packageFile = "";
215+
var platformData = this.$platformsData.getPlatformData(platform);
215216

216217
if (options["debug-brk"]) {
217218
this.preparePlatform(platform).wait();
218219

219-
var platformData = this.$platformsData.getPlatformData(platform);
220-
221220
var cachedDeviceOption = options.forDevice;
222221
options.forDevice = true;
223222
this.buildPlatform(platform).wait();
@@ -227,8 +226,10 @@ export class PlatformService implements IPlatformService {
227226
this.$logger.out("Using ", packageFile);
228227
}
229228

229+
var debuggerSetup = platformData.platformProjectService.getDebugOnDeviceSetup();
230+
230231
this.$devicesServices.initialize({platform: platform, deviceId: options.device}).wait();
231-
var action = (device: Mobile.IDevice): IFuture<void> => { return device.debug(packageFile, this.$projectData.projectId); };
232+
var action = (device: Mobile.IDevice): IFuture<void> => { return device.debug(packageFile, this.$projectData.projectId, debuggerSetup)};
232233
this.$devicesServices.execute(action).wait();
233234

234235
}).future<void>()();

test/stubs.ts

+3
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
273273
addLibrary(platformData: IPlatformData, libraryPath: string): IFuture<void> {
274274
return Future.fromResult();
275275
}
276+
getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup {
277+
return null;
278+
}
276279
}
277280

278281
export class ProjectDataService implements IProjectDataService {

0 commit comments

Comments
 (0)