Skip to content

Update TS to latest release #2928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
await this.$platformService.trackProjectType(this.$projectData);

if (this.$options.start) {
return this.$debugLiveSyncService.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
return this.$debugLiveSyncService.printDebugInformation(await this.debugService.debug(debugData, debugOptions));
}

this.$config.debugLivesync = true;

await this.$devicesService.detectCurrentlyAttachedDevices();

const devices = this.$devicesService.getDeviceInstances();
// Now let's take data for each device:
const devices = this.$devicesService.getDeviceInstances();
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices.filter(d => !this.platform || d.deviceInfo.platform === this.platform)
.map(d => {
const info: ILiveSyncDeviceInfo = {
Expand Down Expand Up @@ -91,10 +91,7 @@
}

if (this.$devicesService.deviceCount > 1) {
// Starting debugger on emulator.
this.$options.emulator = true;

this.$logger.warn("Multiple devices found! Starting debugger on emulator. If you want to debug on specific device please select device with --device option.".yellow.bold);
this.$errors.failWithoutHelp("Multiple devices found! To debug on specific device please select device with --device option.");
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class LiveSyncPaths {
static FULLSYNC_DIR_NAME = "fullsync";
static IOS_DEVICE_PROJECT_ROOT_PATH = "Library/Application Support/LiveSync";
static IOS_DEVICE_SYNC_ZIP_PATH = "Library/Application Support/LiveSync/sync.zip";
};
}
export const ANGULAR_NAME = "angular";
export const TYPESCRIPT_NAME = "typescript";
export const BUILD_OUTPUT_EVENT_NAME = "buildOutput";
Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/debug.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ interface IDebugServiceBase extends NodeJS.EventEmitter {
* @param {IDebugOptions} debugOptions Describe possible options to modify the behaivor of the debug operation, for example stop on the first line.
* @returns {Promise<T>} Array of URLs that can be used for debugging or a string representing a single url that can be used for debugging.
*/
debug<T>(debugData: IDebugData, debugOptions: IDebugOptions): Promise<T>;
debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string>;
}

interface IDebugService {
Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ interface IDebugLiveSyncService extends ILiveSyncService {
* @param {string[]} information Array of information to be printed. Note that false-like values will be stripped from the array.
* @returns {void}
*/
printDebugInformation(information: string[]): void;
printDebugInformation(information: string): void;
}

interface ILiveSyncWatchInfo {
Expand Down
15 changes: 7 additions & 8 deletions lib/services/android-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
this._device = newDevice;
}

constructor(private $devicesService: Mobile.IDevicesService,
constructor(protected $devicesService: Mobile.IDevicesService,
private $errors: IErrors,
private $logger: ILogger,
private $config: IConfiguration,
private $androidDeviceDiscovery: Mobile.IDeviceDiscovery,
private $androidProcessService: Mobile.IAndroidProcessService,
private $net: INet) {
super();
super($devicesService);
}

public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
return debugOptions.emulator
? this.debugOnEmulator(debugData, debugOptions)
: this.debugOnDevice(debugData, debugOptions);
Expand All @@ -49,7 +49,7 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
return;
}

private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
// Assure we've detected the emulator as device
// For example in case deployOnEmulator had stated new emulator instance
// we need some time to detect it. Let's force detection.
Expand Down Expand Up @@ -82,7 +82,7 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ
return this.device.adb.executeCommand(["forward", `tcp:${local}`, `localabstract:${remote}`]);
}

private async debugOnDevice(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
private async debugOnDevice(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
let packageFile = "";

if (!debugOptions.start && !debugOptions.emulator) {
Expand All @@ -94,9 +94,8 @@ class AndroidDebugService extends DebugServiceBase implements IPlatformDebugServ

let action = (device: Mobile.IAndroidDevice): Promise<string> => this.debugCore(device, packageFile, debugData.applicationIdentifier, debugOptions);

const result = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));

return _.map(result, r => r.result);
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
return deviceActionResult[0].result;
}

private async debugCore(device: Mobile.IAndroidDevice, packageFile: string, packageName: string, debugOptions: IDebugOptions): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
this.$errors.failWithoutHelp(`Your project have installed ${dependency.name} version ${cleanedVerson} but Android platform requires version ${dependency.version}.`);
}
}
};
}
}

private cleanResValues(targetSdkVersion: number, projectData: IProjectData, frameworkVersion: string): void {
Expand Down
7 changes: 5 additions & 2 deletions lib/services/debug-service-base.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { EventEmitter } from "events";

export abstract class DebugServiceBase extends EventEmitter implements IPlatformDebugService {
constructor(protected $devicesService: Mobile.IDevicesService) { super(); }

public abstract get platform(): string;

public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]>;
public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string>;

public abstract async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void>;

Expand All @@ -12,7 +14,8 @@ export abstract class DebugServiceBase extends EventEmitter implements IPlatform
protected getCanExecuteAction(deviceIdentifier: string): (device: Mobile.IDevice) => boolean {
return (device: Mobile.IDevice): boolean => {
if (deviceIdentifier) {
return device.deviceInfo.identifier === deviceIdentifier;
return device.deviceInfo.identifier === deviceIdentifier
|| device.deviceInfo.identifier === this.$devicesService.getDeviceByDeviceOption().deviceInfo.identifier;
} else {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/services/debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class DebugService extends EventEmitter implements IDebugService {
// For now we can only check if app is running on Android.
// After we find a way to check on iOS we should use it here.
const isAppRunning = true;
let result: string[];
let result: string;
debugOptions.chrome = true;

const debugService = this.getDebugService(device);
Expand All @@ -59,9 +59,9 @@ export class DebugService extends EventEmitter implements IDebugService {
this.$errors.failWithoutHelp(`Debugging on iOS devices is not supported for ${platform()} yet.`);
}

result = await debugService.debug<string[]>(debugData, debugOptions);
result = await debugService.debug(debugData, debugOptions);
} else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
result = await debugService.debug<string[]>(debugData, debugOptions);
result = await debugService.debug(debugData, debugOptions);
}

return _.first(result);
Expand Down
2 changes: 1 addition & 1 deletion lib/services/init-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class InitService implements IInitService {

projectData[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE][platformData.frameworkPackageName] = _.extend(currentPlatformData, await this.getVersionData(platformData.frameworkPackageName));
}
};
}
}

let dependencies = projectData.dependencies;
Expand Down
24 changes: 12 additions & 12 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
private _childProcess: ChildProcess;
private _socketProxy: any;

constructor(private $platformService: IPlatformService,
constructor(protected $devicesService: Mobile.IDevicesService,
private $platformService: IPlatformService,
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices,
private $devicesService: Mobile.IDevicesService,
private $childProcess: IChildProcess,
private $logger: ILogger,
private $errors: IErrors,
Expand All @@ -32,7 +32,7 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
private $processService: IProcessService,
private $socketProxyFactory: ISocketProxyFactory) {
super();
super($devicesService);
this.$processService.attachToProcessExitSignals(this, this.debugStop);
this.$socketProxyFactory.on(CONNECTION_ERROR_EVENT_NAME, (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e));
}
Expand All @@ -41,7 +41,7 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
return "ios";
}

public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
if (debugOptions.debugBrk && debugOptions.start) {
this.$errors.failWithoutHelp("Expected exactly one of the --debug-brk or --start options.");
}
Expand All @@ -52,9 +52,9 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService

if (debugOptions.emulator) {
if (debugOptions.start) {
return [await this.emulatorStart(debugData, debugOptions)];
return await this.emulatorStart(debugData, debugOptions);
} else {
return [await this.emulatorDebugBrk(debugData, debugOptions)];
return await this.emulatorDebugBrk(debugData, debugOptions);
}
} else {
if (debugOptions.start) {
Expand Down Expand Up @@ -149,7 +149,7 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
return result;
}

private async deviceDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
private async deviceDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
const action = async (device: iOSDevice.IOSDevice) => {
if (device.isEmulator) {
Expand All @@ -171,20 +171,20 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService
return result;
};

const results = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
return _.map(results, r => r.result);
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
return deviceActionResult[0].result;
}

private async debugBrkCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
await this.$iOSSocketRequestExecutor.executeLaunchRequest(device.deviceInfo.identifier, TIMEOUT_SECONDS, TIMEOUT_SECONDS, debugData.applicationIdentifier, debugOptions.debugBrk);
return this.wireDebuggerClient(debugData, debugOptions, device);
}

private async deviceStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string[]> {
private async deviceStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
const action = async (device: Mobile.IiOSDevice) => device.isEmulator ? await this.emulatorStart(debugData, debugOptions) : await this.deviceStartCore(device, debugData, debugOptions);
const results = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
return _.map(results, r => r.result);
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
return deviceActionResult[0].result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously this has not been failing when the deviceActionResult is null/undefined or empty array, but now it will fail with error - Cannot read property result of undefined. Is this expected? In case not, you can use:

return deviceActionResult && deviceActionResult[0] && deviceActionResult[0].result;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this will never happen. Disregard the comment,

}

private async deviceStartCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
private getAllLibsForPluginWithFileExtension(pluginData: IPluginData, fileExtension: string): string[] {
let filterCallback = (fileName: string, pluginPlatformsFolderPath: string) => path.extname(fileName) === fileExtension;
return this.getAllNativeLibrariesForPlugin(pluginData, IOSProjectService.IOS_PLATFORM_NAME, filterCallback);
};
}

private buildPathToCurrentXcodeProjectFile(projectData: IProjectData): string {
return path.join(projectData.platformsDir, "ios", `${projectData.projectName}.xcodeproj`, "project.pbxproj");
Expand Down
13 changes: 6 additions & 7 deletions lib/services/livesync/debug-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DebugLiveSyncService extends LiveSyncService implements IDebugLiveS
await this.$platformService.trackProjectType(this.$projectData);

if (this.$options.start) {
return this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
return this.printDebugInformation(await debugService.debug(debugData, debugOptions));
}

const deviceAppData = liveSyncResultInfo.deviceAppData;
Expand All @@ -66,14 +66,13 @@ export class DebugLiveSyncService extends LiveSyncService implements IDebugLiveS
const buildConfig: IBuildConfig = _.merge({ buildForDevice: !deviceAppData.device.isEmulator }, deployOptions);
debugData.pathToAppPackage = this.$platformService.lastOutputPath(debugService.platform, buildConfig, projectData);

this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
this.printDebugInformation(await debugService.debug(debugData, debugOptions));
}

public printDebugInformation(information: string[]): void {
information = information.filter(i => !!i);
_.each(information, i => {
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${i}${EOL}`.cyan);
});
public printDebugInformation(information: string): void {
if (!!information) {
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${information}${EOL}`.cyan);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
let version: string;
if (currentPlatformData && currentPlatformData[constants.VERSION_STRING]) {
version = currentPlatformData[constants.VERSION_STRING];
};
}

return version;
}
Expand Down Expand Up @@ -669,7 +669,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
} else {
await this.addPlatform(platformParam, platformTemplate, projectData, config);
}
};
}
}

private getCanExecuteAction(platform: string, options: IDeviceEmulator): any {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class PluginsService implements IPluginsService {
let pluginDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, "tns_modules");
await action(pluginDestinationPath, platform.toLowerCase(), platformData);
}
};
}
}

private getInstalledFrameworkVersion(platform: string, projectData: IProjectData): string {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/xcconfig-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class XCConfigService {

/**
* Returns the Value of a Property from a XC Config file.
* @param xcconfigFilePath
* @param xcconfigFilePath
* @param propertyName
*/
public readPropertyValue(xcconfigFilePath: string, propertyName: string): string {
Expand Down
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,29 @@
},
"analyze": true,
"devDependencies": {
"@types/chai": "3.4.34",
"@types/chai-as-promised": "0.0.29",
"@types/chai": "4.0.1",
"@types/chai-as-promised": "0.0.31",
"@types/chokidar": "1.6.0",
"@types/lodash": "4.14.50",
"@types/node": "6.0.61",
"@types/qr-image": "3.2.0",
"@types/request": "0.0.42",
"@types/request": "0.0.45",
"@types/semver": "^5.3.31",
"@types/source-map": "0.5.0",
"chai": "3.5.0",
"chai-as-promised": "6.0.0",
"chai": "4.0.2",
"chai-as-promised": "7.0.0",
"grunt": "1.0.1",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-watch": "1.0.0",
"grunt-shell": "1.3.0",
"grunt-ts": "6.0.0-beta.6",
"grunt-tslint": "4.0.0",
"grunt-ts": "6.0.0-beta.16",
"grunt-tslint": "5.0.1",
"istanbul": "0.4.5",
"mocha": "3.1.2",
"should": "7.0.2",
"source-map-support": "^0.4.14",
"tslint": "4.3.1",
"typescript": "2.1.4"
"tslint": "5.4.3",
"typescript": "2.4.1"
},
"license": "Apache-2.0",
"engines": {
Expand Down
10 changes: 5 additions & 5 deletions test/ios-entitlements-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("IOSEntitlements Service Tests", () => {
testInjector.register("errors", ErrorsLib.Errors);

testInjector.register("pluginsService", {
getAllInstalledPlugins: async () => []
getAllInstalledPlugins: async (): Promise<any[]> => []
});

return testInjector;
Expand Down Expand Up @@ -137,8 +137,8 @@ describe("IOSEntitlements Service Tests", () => {

it("Merge uses the entitlements file from a Plugin", async () => {
let pluginsService = injector.resolve("pluginsService");
let testPluginFolderPath = temp.mkdirSync("testPlugin");
pluginsService.getAllInstalledPlugins = async() => [{
let testPluginFolderPath = temp.mkdirSync("testPlugin");
pluginsService.getAllInstalledPlugins = async () => [{
pluginPlatformsFolderPath: (platform: string) => {
return testPluginFolderPath;
}
Expand All @@ -161,8 +161,8 @@ describe("IOSEntitlements Service Tests", () => {

// setup plugin entitlements
let pluginsService = injector.resolve("pluginsService");
let testPluginFolderPath = temp.mkdirSync("testPlugin");
pluginsService.getAllInstalledPlugins = async() => [{
let testPluginFolderPath = temp.mkdirSync("testPlugin");
pluginsService.getAllInstalledPlugins = async () => [{
pluginPlatformsFolderPath: (platform: string) => {
return testPluginFolderPath;
}
Expand Down
Loading