Skip to content

chore: update to Angular 4.1 and TypeScript 2.3 (#775) #776

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 1 commit into from
May 3, 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
68 changes: 39 additions & 29 deletions nativescript-angular/bin/update-app-ng-deps
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
#!/usr/bin/env node

var path = require("path");
var fs = require("fs");

var binPath = __dirname;
var pluginPath = path.dirname(binPath);
var pluginPackageJsonPath = path.join(pluginPath, "package.json");
var projectPath = path.dirname(path.dirname(pluginPath));
var appPackageJsonPath = path.join(projectPath, "package.json");

var appPackageJson = JSON.parse(fs.readFileSync(appPackageJsonPath, "utf8"));
var pluginPackageJson = JSON.parse(fs.readFileSync(pluginPackageJsonPath, "utf8"));

Object.keys(pluginPackageJson.dependencies).forEach(function(dependencyName) {
var version = pluginPackageJson.dependencies[dependencyName];
if (dependencyName.startsWith("@angular") || dependencyName === "rxjs") {
appPackageJson.dependencies[dependencyName] = version;
console.log("Updated dependency '" + dependencyName + "' to version: " + version + ".");
}
});

Object.keys(pluginPackageJson.devDependencies).forEach(function(dependencyName) {
var version = pluginPackageJson.devDependencies[dependencyName];
if (dependencyName.startsWith("@angular") || dependencyName === "zone.js") {
appPackageJson.devDependencies[dependencyName] = version;
console.log("Updated dev dependency '" + dependencyName + "' to version: " + version + ".");
}
});

fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
const path = require("path");
const fs = require("fs");

const binPath = __dirname;
const pluginPath = path.dirname(binPath);
const pluginPackageJsonPath = path.join(pluginPath, "package.json");
const pluginPackageJson = JSON.parse(fs.readFileSync(pluginPackageJsonPath, "utf8"));
const pluginPeerDeps = pluginPackageJson.peerDependencies;

const projectPath = path.dirname(path.dirname(pluginPath));
const appPackageJsonPath = path.join(projectPath, "package.json");
const appPackageJson = JSON.parse(fs.readFileSync(appPackageJsonPath, "utf8"));

const shouldUpdateDependency = name => name.startsWith("@angular") ||
name === "rxjs" ||
name === "zone.js";

let updatedDependencies = appPackageJson.dependencies;

// set app dependencies to ones required from plugin (peer)
Object.keys(pluginPeerDeps)
.filter(shouldUpdateDependency)
.forEach(dependencyName => {
const version = pluginPackageJson.peerDependencies[dependencyName];
updatedDependencies[dependencyName] = version;
console.log(`Updated dependency ${dependencyName} to version: ${version}.`);
});

// remove platform-browser-dynamic if present
const browserDynamicDependency = "@angular/platform-browser-dynamic";
if (updatedDependencies.hasOwnProperty(browserDynamicDependency)) {
delete updatedDependencies[browserDynamicDependency];
console.log(`Removed ${browserDynamicDependency}`);
}

let updatedPackageJson = appPackageJson;
updatedPackageJson.dependencies = updatedDependencies;

fs.writeFileSync(appPackageJsonPath, JSON.stringify(updatedPackageJson, null, 2));

console.log("\nAngular dependencies updated. Don't forget to run `npm install`.");
5 changes: 3 additions & 2 deletions nativescript-angular/directives/list-view-comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
if (!viewRef) {
listViewError("ViewReference not found for item " + index + ". View recycling is not working");
}
};
}

if (!viewRef) {
listViewLog("onItemLoading: " + index + " - Creating view from template");
Expand Down Expand Up @@ -234,7 +234,8 @@ function getSingleViewRecursive(nodes: Array<any>, nestLevel: number): View {
export interface ComponentView {
rootNodes: Array<any>;
destroy(): void;
};
}

export type RootLocator = (nodes: Array<any>, nestLevel: number) => View;

export function getItemViewRoot(viewRef: ComponentView, rootLocator: RootLocator = getSingleViewRecursive): View {
Expand Down
4 changes: 2 additions & 2 deletions nativescript-angular/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export { NSHttp } from "./http/ns-http";

export function nsHttpFactory(backend, options, nsFileSystem) {
return new NSHttp(backend, options, nsFileSystem);
};
}

export function nsXSRFStrategyFactory() {
return new NSXSRFStrategy();
};
}

@NgModule({
providers: [
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/nativescript.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { NS_DIRECTIVES } from "./directives";

export function errorHandlerFactory() {
return new ErrorHandler(true);
};
}

@NgModule({
declarations: [
Expand Down
44 changes: 22 additions & 22 deletions nativescript-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/NativeScript/nativescript-angular.git"
},
"scripts": {
"tslint": "tslint --project tsconfig.json --config tslint.json",
"tslint": "tslint --project tsconfig.json --config tslint.json --type-check",
"postinstall": "node postinstall.js",
"tsc": "tsc -p tsconfig.json",
"ngc": "ngc -p tsconfig.json",
Expand All @@ -43,32 +43,32 @@
"reflect-metadata": "^0.1.8"
},
"peerDependencies": {
"@angular/core": "~4.0.0",
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/router": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1 || >=3.0.0-2017",
"@angular/common": "~4.0.0 || ~4.1.0",
"@angular/compiler": "~4.0.0 || ~4.1.0",
"@angular/core": "~4.0.0 || ~4.1.0",
"@angular/forms": "~4.0.0 || ~4.1.0",
"@angular/http": "~4.0.0 || ~4.1.0",
"@angular/platform-browser": "~4.0.0 || ~4.1.0",
"@angular/router": "~4.0.0 || ~4.1.0",
"rxjs": "^5.0.1",
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1 || >=3.0.0-2017",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/core": "~4.0.0",
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/compiler-cli": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/animations": "~4.0.0",
"@angular/router": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"codelyzer": "~3.0.0-beta.4",
"tns-core-modules": "internal-preview",
"tslint": "~4.5.0",
"typescript": "~2.2.1",
"@angular/animations": "~4.0.0 || ~4.1.0",
"@angular/common": "~4.0.0 || ~4.1.0",
"@angular/compiler": "~4.0.0 || ~4.1.0",
"@angular/compiler-cli": "~4.0.0 || ~4.1.0",
"@angular/core": "~4.0.0 || ~4.1.0",
"@angular/forms": "~4.0.0 || ~4.1.0",
"@angular/http": "~4.0.0 || ~4.1.0",
"@angular/platform-browser": "~4.0.0 || ~4.1.0",
"@angular/router": "~4.0.0 || ~4.1.0",
"codelyzer": "^3.0.1",
"rxjs": "^5.0.1",
"tns-core-modules": "internal-preview",
"tslint": "^5.1.0",
"typescript": "^2.3.2",
"zone.js": "^0.8.4"
}
}
2 changes: 1 addition & 1 deletion nativescript-angular/platform-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class NativeScriptPlatformRef extends PlatformRef {

get injector(): Injector {
return this.platform.injector;
};
}

destroy(): void {
this.platform.destroy();
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"genDir": ".",
"skipMetadataEmit": false,
"skipTemplateCodegen": true,
"debug": true
"strictMetadataEmit": true
}
}
1 change: 0 additions & 1 deletion nativescript-angular/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"radix": false,
"switch-default": true,
Expand Down
Loading