Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit d9d09b0

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #307 from telerik/fatme/merge-release-ns0.10
Merge release tns0.10.0
2 parents 6ae5a33 + 234321f commit d9d09b0

10 files changed

+33
-39
lines changed

definitions/mobile.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ declare module Mobile {
4646
start(deviceIdentifier: string, adbPath: string): any;
4747
}
4848

49+
interface ILogcatPrinter {
50+
print(line: string): void;
51+
}
52+
4953
interface IDebugOnDeviceSetup {
5054
frontEndPath?: string;
5155
}

mobile/android/android-device.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
174174
var startPackageCommand = this.composeCommand("shell am start -a android.intent.action.MAIN -n %s/%s -c android.intent.category.LAUNCHER", packageName, this.$staticConfig.START_PACKAGE_ACTIVITY_NAME);
175175
this.$childProcess.exec(startPackageCommand).wait();
176176

177-
if (options.printAppOutput) {
177+
if (!options.justlaunch) {
178178
this.openDeviceLogStream();
179179
}
180180
}).future<void>()();

mobile/android/android-emulator-services.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class AndroidEmulatorServices implements Mobile.IEmulatorPlatformServices {
113113
{ stdio: "ignore", detached: true });
114114
this.$fs.futureFromEvent(childProcess, "close").wait();
115115

116-
if (options.printAppOutput) {
116+
if (!options.justlaunch) {
117117
this.$logcatHelper.start(emulatorId, this.adbFilePath);
118118
}
119119
}).future<void>()();

mobile/android/logcat-helper.ts

+5-27
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
///<reference path="../../../.d.ts"/>
22
"use strict";
33
import byline = require("byline");
4+
import util = require("util");
45

56
export class LogcatHelper implements Mobile.ILogcatHelper {
6-
private lineRegex = /.\/(.+?)\s*\(\s*(\d+?)\): (.*)/;
7-
87
constructor(private $childProcess: IChildProcess,
9-
private $logger: ILogger) {
8+
private $logcatPrinter: Mobile.ILogcatPrinter,
9+
private $logger: ILogger){
1010

1111
}
1212

1313
public start(deviceIdentifier: string, adbPath: string): any {
14+
this.$childProcess.exec(util.format("%s -s %s logcat -c", adbPath, deviceIdentifier)).wait(); // remove cached logs
1415
var adbLogcat = this.$childProcess.spawn(adbPath, ["-s", deviceIdentifier, "logcat"]);
1516
var lineStream = byline(adbLogcat.stdout);
1617

@@ -26,33 +27,10 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
2627

2728
lineStream.on('data', (line: NodeBuffer) => {
2829
var lineText = line.toString();
29-
var log = this.getConsoleLogFromLine(lineText);
30-
if(log) {
31-
if(log.tag) {
32-
this.$logger.out("%s: %s", log.tag, log.message);
33-
} else {
34-
this.$logger.out(log.message);
35-
}
36-
}
30+
this.$logcatPrinter.print(lineText);
3731
});
3832

3933
return adbLogcat;
4034
}
41-
42-
private getConsoleLogFromLine(lineText: String): any {
43-
var acceptedTags = ["chromium", "Web Console", "JS"];
44-
45-
//sample line is "I/Web Console( 4438): Received Event: deviceready at file:///storage/emulated/0/Icenium/com.telerik.TestApp/js/index.js:48"
46-
var match = lineText.match(this.lineRegex);
47-
if(match) {
48-
if(acceptedTags.indexOf(match[1]) !== -1) {
49-
return {tag: match[1], message: match[3]};
50-
}
51-
} else if(_.any(acceptedTags, (tag: string) => { return lineText.indexOf(tag) !== -1; })) {
52-
return {message: match[3]};
53-
}
54-
55-
return null;
56-
}
5735
}
5836
$injector.register("logcatHelper", LogcatHelper);

mobile/ios/ios-core.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ export class GDBServer implements Mobile.IGDBServer {
10951095
if(hostInfo.isWindows()) {
10961096
this.send("vCont;c");
10971097
} else {
1098-
if (options.printAppOutput) {
1098+
if (!options.justlaunch) {
10991099
this.socket.pipe(new GDBStandardOutputAdapter()).pipe(process.stdout);
11001100
this.socket.pipe(new GDBSignalWatcher());
11011101
this.send("vCont;c");

mobile/ios/ios-emulator-services.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class IosEmulatorServices implements Mobile.IEmulatorPlatformServices {
6666
"--timeout", options.timeout
6767
];
6868

69-
if(options.printAppOutput) {
69+
if(!options.justlaunch) {
7070
opts.push("--logging");
7171
} else {
7272
if(emulatorOptions) {

mobile/ios/ios-proxy-services.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ export class HouseArrestClient implements Mobile.IHouseArrestClient {
383383

384384
export class IOSSyslog {
385385
private plistService: Mobile.IiOSDeviceSocket;
386-
private matchRegex = new RegExp(".*?((Cordova.{3}|AppBuilder)\\[\\d+\\] <Warning>: )", 'i');
387386

388387
constructor(private device: Mobile.IIOSDevice,
389388
private $logger: ILogger,
@@ -392,13 +391,17 @@ export class IOSSyslog {
392391
}
393392

394393
public read(): void {
394+
var shouldLog = false;
395+
setTimeout(() => shouldLog = true, 2500);
396+
395397
var printData = (data: NodeBuffer) => {
396-
var output = ref.readCString(data, 0);
397-
if(this.matchRegex.test(output)) {
398-
this.$logger.out(output);
398+
if(shouldLog) {
399+
var output = ref.readCString(data, 0);
400+
this.$logger.write(output);
399401
}
400402
};
401403

404+
402405
this.plistService.readSystemLog(printData);
403406
}
404407
}

options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var knownOpts: any = {
3131
"start": Boolean,
3232
"stop": Boolean,
3333
"ddi": String, // the path to developer disk image
34-
"print-app-output": Boolean
34+
"justlaunch": Boolean
3535
};
3636
var shorthands: IStringDictionary = {
3737
"v": "verbose",

services/analytics-service.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import path = require("path");
66
import helpers = require("../helpers");
77
import options = require("../options");
88
import os = require("os");
9-
var xmlhttprequest = require("xmlhttprequest");
9+
// HACK
10+
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
11+
global.XMLHttpRequest.prototype.withCredentials = false;
12+
// HACK -end
1013

1114
export class AnalyticsService implements IAnalyticsService {
1215
private excluded = ["help", "feature-usage-tracking"];
@@ -131,7 +134,6 @@ export class AnalyticsService implements IAnalyticsService {
131134
var settings = global._eqatec.createSettings(this.$staticConfig.ANALYTICS_API_KEY);
132135
settings.useHttps = false;
133136
settings.userAgent = this.getUserAgentString();
134-
settings.xmlHttpRequest = new xmlhttprequest.XMLHttpRequest();
135137
settings.version = this.$staticConfig.version;
136138
settings.loggingInterface = {
137139
logMessage: this.$logger.trace.bind(this.$logger),
@@ -155,9 +157,16 @@ export class AnalyticsService implements IAnalyticsService {
155157
}
156158

157159
this._eqatecMonitor.start();
160+
161+
this.reportNodeVersion();
158162
}).future<void>()();
159163
}
160164

165+
private reportNodeVersion() {
166+
var reportedVersion: string = process.version.slice(1).replace(/[.]/g, "_");
167+
this._eqatecMonitor.trackFeature("NodeJSVersion." + reportedVersion);
168+
}
169+
161170
private getUserAgentString(): string {
162171
var userAgentString: string;
163172
var osType = os.type();

services/cancellation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class CancellationService implements ICancellationService {
6161
}
6262

6363
private static get killSwitchDir(): string {
64-
return path.join(options.profileDir, "KillSwitches");
64+
return path.join(os.tmpdir(), process.env.SUDO_USER || process.env.USER || process.env.USERNAME, "KillSwitches");
6565
}
6666

6767
private static makeKillSwitchFileName(name: string): string {

0 commit comments

Comments
 (0)