Skip to content

Commit 9e8c34d

Browse files
Merge pull request #1304 from NativeScript/vladimirov/merge-rel-master
Merge 1.5.1 in master
2 parents 58f7e25 + 374145d commit 9e8c34d

9 files changed

+55
-21
lines changed

CHANGELOG.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
NativeScript CLI Changelog
22
================
33

4+
1.5.1 (2015, December 03)
5+
==
6+
### New
7+
* [Implemented #452](https://github.com/NativeScript/nativescript-cli/issues/452): Build should report malformed XML.
8+
* [Implemented #1263](https://github.com/NativeScript/nativescript-cli/issues/1263): Add timestamps to LiveSync messages.
9+
10+
### Fixed
11+
* [Fixed #1234](https://github.com/NativeScript/nativescript-cli/issues/1234): LiveSync does not work for iOS platform specific .xml/.css files on iOS Simulator.
12+
* [Fixed #1242](https://github.com/NativeScript/nativescript-cli/issues/1242): `ANDROID_HOME environment variable is not set correctly` error is thrown when `tns run ios --log trace` command is executed.
13+
* [Fixed #1245](https://github.com/NativeScript/nativescript-cli/issues/1245): `TypeError: Cannot read property 'match' of null` error is thrown on various commands.
14+
* [Fixed #1246](https://github.com/NativeScript/nativescript-cli/issues/1246): LiveSync on android device is throwing ENAMTOOLONG error on Windows.
15+
* [Fixed #1253](https://github.com/NativeScript/nativescript-cli/issues/1253): iOS debugger does not work with iOS Simulator with Xcode7+.
16+
* [Fixed #1268](https://github.com/NativeScript/nativescript-cli/issues/1268): Hook failures treated as bad user input.
17+
418
1.5.0 (2015, November 24)
519
==
620

@@ -280,7 +294,7 @@ Building NativeScript projects for Android requires Android SDK 22, Android SDK
280294
* Introduced new project structure. To migrate to the new structure, complete the following steps.
281295
1. Manually move all files and folders from the inner `app` folder one level up inside the outer `app` folder.
282296
1. Remove the now empty inner `app` folder.
283-
1. Verify that your project structure reflects the structure described [here](README.md#create-project).
297+
1. Verify that your project structure reflects the structure described [here](https://github.com/NativeScript/nativescript-cli/blob/production/README.md#create-project).
284298

285299
### New
286300

lib/android-tools-info.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
3838
private $logger: ILogger,
3939
private $options: IOptions) {}
4040

41-
public getPathToAndroidExecutable(): IFuture<string> {
41+
public getPathToAndroidExecutable(options?: {showWarningsAsErrors: boolean}): IFuture<string> {
4242
return ((): string => {
43+
if(options) {
44+
this.showWarningsAsErrors = options.showWarningsAsErrors;
45+
}
4346
if (!this.pathToAndroidExecutable) {
4447
if(this.validateAndroidHomeEnvVariable(this.androidHome).wait()) {
4548
let androidPath = path.join(this.androidHome, "tools", this.androidExecutableName);
4649
if(!this.trySetAndroidPath(androidPath).wait() && !this.trySetAndroidPath(this.androidExecutableName).wait()) {
4750
this.printMessage(`Unable to find "${this.androidExecutableName}" executable file. Make sure you have set ANDROID_HOME environment variable correctly.`);
4851
}
4952
} else {
50-
this.printMessage("ANDROID_HOME environment variable is not set correctly.");
53+
this.$logger.trace("ANDROID_HOME environment variable is not set correctly.");
5154
}
5255
}
5356

@@ -338,11 +341,14 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
338341
return (() => {
339342
if (!this.installedTargetsCache) {
340343
try {
341-
let result = this.$childProcess.spawnFromEvent(this.getPathToAndroidExecutable().wait(), ["list", "targets"], "close", {}, {throwError: false}).wait();
342-
if(result.stdout) {
343-
this.$logger.trace(result.stdout);
344-
this.installedTargetsCache = [];
345-
result.stdout.replace(/id: \d+ or "(.+)"/g, (m:string, p1:string) => (this.installedTargetsCache.push(p1), m));
344+
let pathToAndroidExecutable = this.getPathToAndroidExecutable().wait();
345+
if(pathToAndroidExecutable) {
346+
let result = this.$childProcess.spawnFromEvent(pathToAndroidExecutable, ["list", "targets"], "close", {}, {throwError: false}).wait();
347+
if(result && result.stdout) {
348+
this.$logger.trace(result.stdout);
349+
this.installedTargetsCache = [];
350+
result.stdout.replace(/id: \d+ or "(.+)"/g, (m:string, p1:string) => (this.installedTargetsCache.push(p1), m));
351+
}
346352
}
347353
} catch(err) {
348354
this.$logger.trace("Unable to get Android targets. Error is: " + err);

lib/declarations.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ interface IAndroidToolsInfo {
126126
/**
127127
* Returns the path to `android` executable. It should be `$ANDROID_HOME/tools/android`.
128128
* In case ANDROID_HOME is not defined, check if `android` is part of $PATH.
129+
* @param {any} options Defines if the warning messages should treated as error.
129130
* @return {string} Path to the `android` executable.
130131
*/
131-
getPathToAndroidExecutable(): IFuture<string>;
132+
getPathToAndroidExecutable(options?: {showWarningsAsErrors: boolean}): IFuture<string>;
132133

133134
/**
134135
* Gets the path to `adb` executable from ANDROID_HOME. It should be `$ANDROID_HOME/platform-tools/adb` in case it exists.

lib/services/android-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
7979
this.validateProjectName(this.$projectData.projectName);
8080

8181
// this call will fail in case `android` is not set correctly.
82-
this.$androidToolsInfo.getPathToAndroidExecutable().wait();
82+
this.$androidToolsInfo.getPathToAndroidExecutable({showWarningsAsErrors: true}).wait();
8383
this.$androidToolsInfo.validateJavacVersion(this.$sysInfo.getSysInfo(path.join(__dirname, "..", "..", "package.json")).wait().javacVersion, {showWarningsAsErrors: true}).wait();
8484
}).future<void>()();
8585
}

lib/services/platform-service.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as helpers from "../common/helpers";
88
import * as semver from "semver";
99
import * as minimatch from "minimatch";
1010
import Future = require("fibers/future");
11+
import {EOL} from "os";
1112

1213
export class PlatformService implements IPlatformService {
1314
private static TNS_MODULES_FOLDER_NAME = "tns_modules";
@@ -179,15 +180,20 @@ export class PlatformService implements IPlatformService {
179180
.forEach(file => {
180181
let fileContents = this.$fs.readText(file).wait();
181182
let hasErrors = false;
182-
let domErrorHandler = (level:any, msg:string) => hasErrors = true;
183+
let errorOutput = "";
184+
let domErrorHandler = (level:any, msg:string) => {
185+
errorOutput += level + EOL + msg + EOL;
186+
hasErrors = true;
187+
};
183188
let parser = new DomParser({
184189
locator:{},
185190
errorHandler: domErrorHandler
186191
});
187192
parser.parseFromString(fileContents, "text/xml");
188193
xmlHasErrors = xmlHasErrors || hasErrors;
189-
if (xmlHasErrors) {
190-
this.$logger.out("Error: ".red.bold + file + " has syntax errors.".red.bold);
194+
if (hasErrors) {
195+
this.$logger.warn(`${file} has syntax errors.`);
196+
this.$logger.out(errorOutput);
191197
}
192198
});
193199
return !xmlHasErrors;
@@ -231,10 +237,7 @@ export class PlatformService implements IPlatformService {
231237
}
232238

233239
// verify .xml files are well-formed
234-
let validXmlFiles = this.checkXmlFiles(sourceFiles).wait();
235-
if (!validXmlFiles) {
236-
return false;
237-
}
240+
this.checkXmlFiles(sourceFiles).wait();
238241

239242
// Remove .ts and .js.map files
240243
PlatformService.EXCLUDE_FILES_PATTERN.forEach(pattern => sourceFiles = sourceFiles.filter(file => !minimatch(file, pattern, {nocase: true})));

lib/services/usb-livesync-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as semver from "semver";
99
import * as net from "net";
1010
import Future = require("fibers/future");
1111
import * as helpers from "../common/helpers";
12+
import * as moment from "moment";
1213

1314
export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncServiceBase implements IUsbLiveSyncService {
1415

@@ -149,7 +150,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
149150
});
150151
}
151152

152-
this.$logger.info(`Successfully synced application ${this.$projectData.projectId}.`);
153+
this.$logger.info(`Successfully synced application ${this.$projectData.projectId} at ${moment().format("ll LTS")}.`);
153154
}).future<void>()();
154155
});
155156
};

test/platform-service.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,17 @@ describe('Platform Service Tests', () => {
331331
projectData.projectDir = tempFolder;
332332

333333
platformService = testInjector.resolve("platformService");
334-
let result = platformService.preparePlatform("android").wait();
334+
let oldLoggerWarner = testInjector.resolve("$logger").warn;
335+
let warnings: string = "";
336+
try {
337+
testInjector.resolve("$logger").warn = (text: string) => warnings += text;
338+
platformService.preparePlatform("android").wait();
339+
} finally {
340+
testInjector.resolve("$logger").warn = oldLoggerWarner;
341+
}
335342

336343
// Asserts that prepare has caught invalid xml
337-
assert.isFalse(result);
344+
assert.isFalse(warnings.indexOf("has errors") !== -1);
338345
});
339346
});
340347
});

test/test-bootstrap.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as shelljs from "shelljs";
2+
shelljs.config.silent = true;
13
global._ = require("lodash");
24
global.$injector = require("../lib/common/yok").injector;
35

0 commit comments

Comments
 (0)