Skip to content

Commit 3de21f9

Browse files
FatmeFatme
authored andcommitted
Merge pull request #756 from NativeScript/fatme/merge-release-1.2.2
Merge release 1.2.2
2 parents 595cb73 + b0abf92 commit 3de21f9

22 files changed

+246
-99
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
NativeScript CLI Changelog
22
================
33

4-
1.2.0 (2015, July 22)
4+
1.2.1 (2015, July 27)
5+
==
6+
7+
### Fixed
8+
9+
* [Fixed #690](https://github.com/NativeScript/nativescript-cli/issues/690): The `$ tns debug ios --debug-brk` command does not work.
10+
11+
1.2.0 (2015, July 24)
512
==
613

714
### New

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Apache License
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright (c) 2015 Telerik AD
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

docs/man_pages/project/testing/debug-android.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Debugs your project on a connected device, in a native emulator or in Genymotion
2323
* `--stop` - Detaches the debug tools.
2424
* `--get-port` - Retrieves the port on which you are debugging your application.
2525
* `--debug-port` - Sets a new port on which to attach the debug tools.
26+
* `--timeout` - Sets the number of seconds that NativeScript CLI will wait for the debugger to boot. If not set, the default timeout is 90 seconds.
2627

2728
### Attributes
2829
* `<Device ID>` is the index or name of the target device as listed by `$ tns device`

docs/man_pages/project/testing/debug-ios.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Debugs your project on a connected device or in the iOS Simulator. <% if(isHtml)
2020
* `--start` - Attaches the debug tools to a deployed and running app and launches the developer tools of your Safari browser.
2121
* `--emulator` - Indicates that you want to debug your app in the iOS simulator.
2222
* `--no-client` - If set, the NativeScript CLI attaches the debug tools but does not launch the developer tools in Safari.
23+
* `--timeout` - Sets the number of seconds that NativeScript CLI will wait for the debugger to boot. If not set, the default timeout is 90 seconds.
2324

2425
### Attributes
2526
* `<Device ID>` is the index or name of the target device as listed by `$ tns device`

docs/man_pages/project/testing/livesync-ios.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ livesync ios
33

44
Usage | Synopsis
55
------|-------
6-
General | `$ tns livesync ios [--device <Device ID>] [--watch]`
6+
General | `$ tns livesync ios [--device <Device ID>] [--watch] [--emulator]`
77

8-
Synchronizes the latest changes in your project to iOS devices.
8+
Synchronizes the latest changes in your project to iOS devices or iOS simulator.
99

1010
### Options
1111
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device.
1212
* `--device` - Specifies the serial number or the index of the connected device to which you want to synchronize changes. To list all connected devices, grouped by platform, run `$ tns device`
13+
* `--emulator` - If set, changes are synchronized to iOS simulator.
1314

1415
### Attributes
1516
* `<Device ID>` is the device index or identifier as listed by `$ tns device`

lib/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase imple
2828
public CLIENT_NAME_ALIAS = "NativeScript";
2929
public ANALYTICS_API_KEY = "5752dabccfc54c4ab82aea9626b7338e";
3030
public TRACK_FEATURE_USAGE_SETTING_NAME = "TrackFeatureUsage";
31+
public ERROR_REPORT_SETTING_NAME = "TrackExceptions";
3132
public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID";
3233
public START_PACKAGE_ACTIVITY_NAME = "com.tns.NativeScriptActivity";
3334

lib/declarations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface INpmInstallationManager {
1515
install(packageName: string, options?: INpmInstallOptions): IFuture<string>;
1616
getLatestVersion(packageName: string): IFuture<string>;
1717
getCachedPackagePath(packageName: string, version: string): string;
18+
addCleanCopyToCache(packageName: string, version: string): IFuture<void>;
1819
}
1920

2021
interface INpmInstallOptions {
@@ -56,6 +57,7 @@ interface IUsbLiveSyncService {
5657

5758
interface IPlatformSpecificUsbLiveSyncService {
5859
restartApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]): IFuture<void>;
60+
beforeLiveSyncAction?(deviceAppData: Mobile.IDeviceAppData): IFuture<void>;
5961
}
6062

6163
interface IOptions extends ICommonOptions {

lib/definitions/shelljs.d.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/npm-installation-manager.ts

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import semver = require("semver");
66
import npm = require("npm");
77
import constants = require("./constants");
88

9-
export class NpmInstallationManager {
9+
export class NpmInstallationManager implements INpmInstallationManager {
1010
private static NPM_LOAD_FAILED = "Failed to retrieve data from npm. Please try again a little bit later.";
1111
private versionsCache: IDictionary<string[]>;
1212

@@ -27,13 +27,18 @@ export class NpmInstallationManager {
2727
public getCachedPackagePath(packageName: string, version: string): string {
2828
return path.join(this.getCacheRootPath(), packageName, version, "package");
2929
}
30-
30+
3131
public addToCache(packageName: string, version: string): IFuture<void> {
3232
return (() => {
33-
this.$npm.cache(packageName, version).wait();
34-
let packagePath = path.join(this.getCacheRootPath(), packageName, version, "package");
35-
if(!this.isPackageUnpacked(packagePath).wait()) {
36-
this.cacheUnpack(packageName, version).wait();
33+
let cachedPackagePath = this.getCachedPackagePath(packageName, version);
34+
if(!this.$fs.exists(cachedPackagePath).wait()) {
35+
this.addToCacheCore(packageName, version).wait();
36+
}
37+
38+
if(!this.isShasumOfPackageCorrect(packageName, version).wait()) {
39+
// In some cases the package is not fully downloaded and the framework directory is missing
40+
// Try removing the old package and add the real one to cache again
41+
this.addCleanCopyToCache(packageName, version).wait();
3742
}
3843
}).future<void>()();
3944
}
@@ -73,6 +78,43 @@ export class NpmInstallationManager {
7378
}).future<string>()();
7479
}
7580

81+
public addCleanCopyToCache(packageName: string, version: string): IFuture<void> {
82+
return (() => {
83+
let packagePath = path.join(this.getCacheRootPath(), packageName, version);
84+
this.$logger.trace(`Deleting: ${packagePath}.`);
85+
this.$fs.deleteDirectory(packagePath).wait();
86+
this.addToCacheCore(packageName, version).wait();
87+
if(!this.isShasumOfPackageCorrect(packageName, version).wait()) {
88+
this.$errors.failWithoutHelp(`Unable to add package ${packageName} with version ${version} to npm cache. Try cleaning your cache and execute the command again.`)
89+
}
90+
}).future<void>()();
91+
}
92+
93+
private addToCacheCore(packageName: string, version: string): IFuture<void> {
94+
return (() => {
95+
this.$npm.cache(packageName, version).wait();
96+
let packagePath = path.join(this.getCacheRootPath(), packageName, version, "package");
97+
if(!this.isPackageUnpacked(packagePath).wait()) {
98+
this.cacheUnpack(packageName, version).wait();
99+
}
100+
}).future<void>()();
101+
}
102+
103+
private isShasumOfPackageCorrect(packageName: string, version: string): IFuture<boolean> {
104+
return ((): boolean => {
105+
let shasumProperty = "dist.shasum";
106+
let cachedPackagePath = this.getCachedPackagePath(packageName, version);
107+
let realShasum = this.$npm.view(`${packageName}@${version}`, shasumProperty).wait()[version][shasumProperty];
108+
let packageTgz = cachedPackagePath + ".tgz";
109+
let currentShasum = "";
110+
if(this.$fs.exists(packageTgz).wait()) {
111+
currentShasum = this.$fs.getFileShasum(packageTgz).wait();
112+
}
113+
this.$logger.trace(`Checking shasum of package: ${packageName}@${version}: expected ${realShasum}, actual ${currentShasum}.`);
114+
return realShasum === currentShasum;
115+
}).future<boolean>()();
116+
}
117+
76118
private installCore(packageName: string, pathToSave: string, version: string): IFuture<string> {
77119
return (() => {
78120
if (this.$options.frameworkPath) {
@@ -116,7 +158,8 @@ export class NpmInstallationManager {
116158
private isPackageUnpacked(packagePath: string): IFuture<boolean> {
117159
return (() => {
118160
return this.$fs.getFsStats(packagePath).wait().isDirectory() &&
119-
this.$fs.enumerateFilesInDirectorySync(packagePath).length > 1;
161+
this.$fs.exists(path.join(packagePath, "framework")).wait() &&
162+
this.$fs.enumerateFilesInDirectorySync(path.join(packagePath, "framework")).length > 1;
120163
}).future<boolean>()();
121164
}
122165
}

0 commit comments

Comments
 (0)