From da1be1b7ab076a43f1ef9658b7919b5b7a632d8f Mon Sep 17 00:00:00 2001 From: vakrilov Date: Mon, 30 May 2016 16:13:10 +0300 Subject: [PATCH 1/4] setup nativescript-angular folder to be packable --- .gitignore | 13 +++-- nativescript-angular/.npmignore | 8 +++ {doc => nativescript-angular}/README.md | 0 .../application.ts | 0 .../common/detached-loader.ts | 0 .../common/utils.ts | 0 .../directives.ts | 0 .../directives/action-bar.ts | 0 .../directives/dialogs.ts | 0 .../directives/list-view-comp.ts | 0 .../directives/platform-filters.ts | 0 .../directives/tab-view.ts | 0 .../dom_adapter.ts | 0 .../element-registry.ts | 0 {src => nativescript-angular}/global.d.ts | 0 .../hooks/before-livesync.js | 0 .../hooks/hook-helper.js | 0 .../modal-dialog.ts | 0 nativescript-angular/package.json | 51 +++++++++++++++++++ .../platform-providers.ts | 0 .../polyfills/array.ts | 0 .../postinstall.js | 0 .../renderer.ts | 0 .../router.ts | 0 .../router/common.ts | 0 .../router/ns-location-strategy.ts | 0 .../router/ns-router-link.ts | 0 .../router/ns-router.ts | 0 .../router/page-router-outlet.ts | 0 nativescript-angular/tsconfig.json | 13 +++++ .../value-accessors/base-value-accessor.ts | 0 .../value-accessors/checked-value-accessor.ts | 0 .../value-accessors/date-value-accessor.ts | 0 .../value-accessors/number-value-accessor.ts | 0 .../selectedIndex-value-accessor.ts | 0 .../value-accessors/text-value-accessor.ts | 0 .../value-accessors/time-value-accessor.ts | 0 .../view-util.ts | 0 .../xhr.ts | 0 package.json | 20 +------- 40 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 nativescript-angular/.npmignore rename {doc => nativescript-angular}/README.md (100%) rename {src/nativescript-angular => nativescript-angular}/application.ts (100%) rename {src/nativescript-angular => nativescript-angular}/common/detached-loader.ts (100%) rename {src/nativescript-angular => nativescript-angular}/common/utils.ts (100%) rename {src/nativescript-angular => nativescript-angular}/directives.ts (100%) rename {src/nativescript-angular => nativescript-angular}/directives/action-bar.ts (100%) rename {src/nativescript-angular => nativescript-angular}/directives/dialogs.ts (100%) rename {src/nativescript-angular => nativescript-angular}/directives/list-view-comp.ts (100%) rename {src/nativescript-angular => nativescript-angular}/directives/platform-filters.ts (100%) rename {src/nativescript-angular => nativescript-angular}/directives/tab-view.ts (100%) rename {src/nativescript-angular => nativescript-angular}/dom_adapter.ts (100%) rename {src/nativescript-angular => nativescript-angular}/element-registry.ts (100%) rename {src => nativescript-angular}/global.d.ts (100%) rename {src/nativescript-angular => nativescript-angular}/hooks/before-livesync.js (100%) rename {src/nativescript-angular => nativescript-angular}/hooks/hook-helper.js (100%) rename {src/nativescript-angular => nativescript-angular}/modal-dialog.ts (100%) create mode 100644 nativescript-angular/package.json rename {src/nativescript-angular => nativescript-angular}/platform-providers.ts (100%) rename {src/nativescript-angular => nativescript-angular}/polyfills/array.ts (100%) rename {src/nativescript-angular => nativescript-angular}/postinstall.js (100%) rename {src/nativescript-angular => nativescript-angular}/renderer.ts (100%) rename {src/nativescript-angular => nativescript-angular}/router.ts (100%) rename {src/nativescript-angular => nativescript-angular}/router/common.ts (100%) rename {src/nativescript-angular => nativescript-angular}/router/ns-location-strategy.ts (100%) rename {src/nativescript-angular => nativescript-angular}/router/ns-router-link.ts (100%) rename {src/nativescript-angular => nativescript-angular}/router/ns-router.ts (100%) rename {src/nativescript-angular => nativescript-angular}/router/page-router-outlet.ts (100%) create mode 100644 nativescript-angular/tsconfig.json rename {src/nativescript-angular => nativescript-angular}/value-accessors/base-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/value-accessors/checked-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/value-accessors/date-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/value-accessors/number-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/value-accessors/selectedIndex-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/value-accessors/text-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/value-accessors/time-value-accessor.ts (100%) rename {src/nativescript-angular => nativescript-angular}/view-util.ts (100%) rename {src/nativescript-angular => nativescript-angular}/xhr.ts (100%) diff --git a/.gitignore b/.gitignore index 151331646..40d66b787 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ -nativescript-angular*.tgz bin/dist node_modules tags -src/nativescript-angular/**/*.js -!src/nativescript-angular/postinstall.js -!src/nativescript-angular/hooks/**/*.js -.baseDir.ts +**/*.js.map + +nativescript-angular/**/*.d.ts +!nativescript-angular/global.d.ts +nativescript-angular/**/*.js +!nativescript-angular/postinstall.js +!nativescript-angular/hooks/**/*.js + .tscache .nvm .vscode diff --git a/nativescript-angular/.npmignore b/nativescript-angular/.npmignore new file mode 100644 index 000000000..9bb892a32 --- /dev/null +++ b/nativescript-angular/.npmignore @@ -0,0 +1,8 @@ +*.tgz + +*.ts +!*.d.ts + +tsconfig.json +global.d.ts +.npmignore diff --git a/doc/README.md b/nativescript-angular/README.md similarity index 100% rename from doc/README.md rename to nativescript-angular/README.md diff --git a/src/nativescript-angular/application.ts b/nativescript-angular/application.ts similarity index 100% rename from src/nativescript-angular/application.ts rename to nativescript-angular/application.ts diff --git a/src/nativescript-angular/common/detached-loader.ts b/nativescript-angular/common/detached-loader.ts similarity index 100% rename from src/nativescript-angular/common/detached-loader.ts rename to nativescript-angular/common/detached-loader.ts diff --git a/src/nativescript-angular/common/utils.ts b/nativescript-angular/common/utils.ts similarity index 100% rename from src/nativescript-angular/common/utils.ts rename to nativescript-angular/common/utils.ts diff --git a/src/nativescript-angular/directives.ts b/nativescript-angular/directives.ts similarity index 100% rename from src/nativescript-angular/directives.ts rename to nativescript-angular/directives.ts diff --git a/src/nativescript-angular/directives/action-bar.ts b/nativescript-angular/directives/action-bar.ts similarity index 100% rename from src/nativescript-angular/directives/action-bar.ts rename to nativescript-angular/directives/action-bar.ts diff --git a/src/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts similarity index 100% rename from src/nativescript-angular/directives/dialogs.ts rename to nativescript-angular/directives/dialogs.ts diff --git a/src/nativescript-angular/directives/list-view-comp.ts b/nativescript-angular/directives/list-view-comp.ts similarity index 100% rename from src/nativescript-angular/directives/list-view-comp.ts rename to nativescript-angular/directives/list-view-comp.ts diff --git a/src/nativescript-angular/directives/platform-filters.ts b/nativescript-angular/directives/platform-filters.ts similarity index 100% rename from src/nativescript-angular/directives/platform-filters.ts rename to nativescript-angular/directives/platform-filters.ts diff --git a/src/nativescript-angular/directives/tab-view.ts b/nativescript-angular/directives/tab-view.ts similarity index 100% rename from src/nativescript-angular/directives/tab-view.ts rename to nativescript-angular/directives/tab-view.ts diff --git a/src/nativescript-angular/dom_adapter.ts b/nativescript-angular/dom_adapter.ts similarity index 100% rename from src/nativescript-angular/dom_adapter.ts rename to nativescript-angular/dom_adapter.ts diff --git a/src/nativescript-angular/element-registry.ts b/nativescript-angular/element-registry.ts similarity index 100% rename from src/nativescript-angular/element-registry.ts rename to nativescript-angular/element-registry.ts diff --git a/src/global.d.ts b/nativescript-angular/global.d.ts similarity index 100% rename from src/global.d.ts rename to nativescript-angular/global.d.ts diff --git a/src/nativescript-angular/hooks/before-livesync.js b/nativescript-angular/hooks/before-livesync.js similarity index 100% rename from src/nativescript-angular/hooks/before-livesync.js rename to nativescript-angular/hooks/before-livesync.js diff --git a/src/nativescript-angular/hooks/hook-helper.js b/nativescript-angular/hooks/hook-helper.js similarity index 100% rename from src/nativescript-angular/hooks/hook-helper.js rename to nativescript-angular/hooks/hook-helper.js diff --git a/src/nativescript-angular/modal-dialog.ts b/nativescript-angular/modal-dialog.ts similarity index 100% rename from src/nativescript-angular/modal-dialog.ts rename to nativescript-angular/modal-dialog.ts diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json new file mode 100644 index 000000000..9990be45c --- /dev/null +++ b/nativescript-angular/package.json @@ -0,0 +1,51 @@ +{ + "name": "nativescript-angular", + "version": "0.1.6", + "description": "An Angular 2 renderer that lets you build mobile apps with NativeScript.", + "homepage": "http://www.telerik.com", + "bugs": "http://www.telerik.com", + "contributors": [ + "Hristo Deshev " + ], + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/nativescript-angular.git" + }, + "scripts": { + "postinstall": "node postinstall.js", + "prepublish": "tsc" + }, + "dependencies": { + "nativescript-intl": "^0.0.2", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/router-deprecated": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/platform-server": "2.0.0-rc.1", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.6", + "zone.js": "^0.6.12", + "parse5": "1.4.2", + "punycode": "1.3.2", + "querystring": "0.2.0", + "url": "0.10.3" + }, + "devDependencies": { + "grunt": "0.4.5", + "grunt-contrib-copy": "0.8.0", + "grunt-contrib-clean": "0.6.0", + "grunt-shell": "1.1.2", + "grunt-file": "1.0.2", + "grunt-env": "0.4.4", + "grunt-ts": "5.0.0-beta.5", + "shelljs": "^0.5.3", + "typescript": "^1.8.10" + }, + "peerDependencies": { + "tns-core-modules": ">=2.0.0 || >=2.1.0-2016 || >=2.0.0-angular-7" + }, + "nativescript": {} +} \ No newline at end of file diff --git a/src/nativescript-angular/platform-providers.ts b/nativescript-angular/platform-providers.ts similarity index 100% rename from src/nativescript-angular/platform-providers.ts rename to nativescript-angular/platform-providers.ts diff --git a/src/nativescript-angular/polyfills/array.ts b/nativescript-angular/polyfills/array.ts similarity index 100% rename from src/nativescript-angular/polyfills/array.ts rename to nativescript-angular/polyfills/array.ts diff --git a/src/nativescript-angular/postinstall.js b/nativescript-angular/postinstall.js similarity index 100% rename from src/nativescript-angular/postinstall.js rename to nativescript-angular/postinstall.js diff --git a/src/nativescript-angular/renderer.ts b/nativescript-angular/renderer.ts similarity index 100% rename from src/nativescript-angular/renderer.ts rename to nativescript-angular/renderer.ts diff --git a/src/nativescript-angular/router.ts b/nativescript-angular/router.ts similarity index 100% rename from src/nativescript-angular/router.ts rename to nativescript-angular/router.ts diff --git a/src/nativescript-angular/router/common.ts b/nativescript-angular/router/common.ts similarity index 100% rename from src/nativescript-angular/router/common.ts rename to nativescript-angular/router/common.ts diff --git a/src/nativescript-angular/router/ns-location-strategy.ts b/nativescript-angular/router/ns-location-strategy.ts similarity index 100% rename from src/nativescript-angular/router/ns-location-strategy.ts rename to nativescript-angular/router/ns-location-strategy.ts diff --git a/src/nativescript-angular/router/ns-router-link.ts b/nativescript-angular/router/ns-router-link.ts similarity index 100% rename from src/nativescript-angular/router/ns-router-link.ts rename to nativescript-angular/router/ns-router-link.ts diff --git a/src/nativescript-angular/router/ns-router.ts b/nativescript-angular/router/ns-router.ts similarity index 100% rename from src/nativescript-angular/router/ns-router.ts rename to nativescript-angular/router/ns-router.ts diff --git a/src/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts similarity index 100% rename from src/nativescript-angular/router/page-router-outlet.ts rename to nativescript-angular/router/page-router-outlet.ts diff --git a/nativescript-angular/tsconfig.json b/nativescript-angular/tsconfig.json new file mode 100644 index 000000000..b0858c9c8 --- /dev/null +++ b/nativescript-angular/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "declaration": true, + "removeComments": false, + "noEmitOnError": true, + "noImplicitAny": false + } +} \ No newline at end of file diff --git a/src/nativescript-angular/value-accessors/base-value-accessor.ts b/nativescript-angular/value-accessors/base-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/base-value-accessor.ts rename to nativescript-angular/value-accessors/base-value-accessor.ts diff --git a/src/nativescript-angular/value-accessors/checked-value-accessor.ts b/nativescript-angular/value-accessors/checked-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/checked-value-accessor.ts rename to nativescript-angular/value-accessors/checked-value-accessor.ts diff --git a/src/nativescript-angular/value-accessors/date-value-accessor.ts b/nativescript-angular/value-accessors/date-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/date-value-accessor.ts rename to nativescript-angular/value-accessors/date-value-accessor.ts diff --git a/src/nativescript-angular/value-accessors/number-value-accessor.ts b/nativescript-angular/value-accessors/number-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/number-value-accessor.ts rename to nativescript-angular/value-accessors/number-value-accessor.ts diff --git a/src/nativescript-angular/value-accessors/selectedIndex-value-accessor.ts b/nativescript-angular/value-accessors/selectedIndex-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/selectedIndex-value-accessor.ts rename to nativescript-angular/value-accessors/selectedIndex-value-accessor.ts diff --git a/src/nativescript-angular/value-accessors/text-value-accessor.ts b/nativescript-angular/value-accessors/text-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/text-value-accessor.ts rename to nativescript-angular/value-accessors/text-value-accessor.ts diff --git a/src/nativescript-angular/value-accessors/time-value-accessor.ts b/nativescript-angular/value-accessors/time-value-accessor.ts similarity index 100% rename from src/nativescript-angular/value-accessors/time-value-accessor.ts rename to nativescript-angular/value-accessors/time-value-accessor.ts diff --git a/src/nativescript-angular/view-util.ts b/nativescript-angular/view-util.ts similarity index 100% rename from src/nativescript-angular/view-util.ts rename to nativescript-angular/view-util.ts diff --git a/src/nativescript-angular/xhr.ts b/nativescript-angular/xhr.ts similarity index 100% rename from src/nativescript-angular/xhr.ts rename to nativescript-angular/xhr.ts diff --git a/package.json b/package.json index 080e12092..d5b0d983c 100644 --- a/package.json +++ b/package.json @@ -14,22 +14,7 @@ }, "scripts": {}, "dependencies": { - "tns-core-modules": "2.0.0-angular-7", - "nativescript-intl": "^0.0.2", - "@angular/common": "2.0.0-rc.1", - "@angular/compiler": "2.0.0-rc.1", - "@angular/core": "2.0.0-rc.1", - "@angular/router-deprecated": "2.0.0-rc.1", - "@angular/platform-browser": "2.0.0-rc.1", - "@angular/platform-browser-dynamic": "2.0.0-rc.1", - "@angular/platform-server": "2.0.0-rc.1", - "reflect-metadata": "^0.1.3", - "rxjs": "5.0.0-beta.6", - "zone.js": "^0.6.12", - "parse5": "1.4.2", - "punycode": "1.3.2", - "querystring": "0.2.0", - "url": "0.10.3" + "tns-core-modules": "2.0.0-angular-7" }, "devDependencies": { "grunt": "0.4.5", @@ -42,8 +27,5 @@ "shelljs": "^0.5.3", "typescript": "^1.8.10" }, - "peerDependencies": { - "tns-core-modules": ">=2.0.0 || >=2.1.0-2016 || >=2.0.0-angular-7" - }, "nativescript": {} } From 5454c5c43f139e46a110b27d71003d433c4f09fd Mon Sep 17 00:00:00 2001 From: vakrilov Date: Mon, 30 May 2016 17:27:55 +0300 Subject: [PATCH 2/4] ng-sample made working with the new structure --- .gitignore | 3 ++- ng-sample/app/app.ts | 6 +++--- ng-sample/app/examples/action-bar/action-bar-test.ts | 4 ++-- ng-sample/app/examples/modal/modal-content.ts | 2 +- ng-sample/app/examples/modal/modal-test.ts | 2 +- ng-sample/app/examples/navigation/login-test.ts | 2 +- ng-sample/app/examples/navigation/nav-component.ts | 2 +- ng-sample/app/examples/navigation/navigation-test.ts | 2 +- ng-sample/app/examples/navigation/router-outlet-test.ts | 2 +- ng-sample/app/examples/renderer-test.ts | 4 ++-- .../hooks/before-livesync/nativescript-angular-sync .js | 1 + ng-sample/hooks/before-prepare/10-copy-renderer.js | 7 ------- ...pt-dev-typescript.js => nativescript-dev-typescript.js} | 0 ng-sample/package.json | 1 + ng-sample/tsconfig.json | 2 -- 15 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 ng-sample/hooks/before-livesync/nativescript-angular-sync .js delete mode 100644 ng-sample/hooks/before-prepare/10-copy-renderer.js rename ng-sample/hooks/before-prepare/{20-nativescript-dev-typescript.js => nativescript-dev-typescript.js} (100%) diff --git a/.gitignore b/.gitignore index 40d66b787..f834ff475 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ node_modules tags **/*.js.map +/hooks + nativescript-angular/**/*.d.ts !nativescript-angular/global.d.ts nativescript-angular/**/*.js @@ -22,7 +24,6 @@ tests/lib tests/node_modules ng-sample/app/**/*.js -ng-sample/app/nativescript-angular ng-sample/app/global.d.ts ng-sample/platforms ng-sample/lib diff --git a/ng-sample/app/app.ts b/ng-sample/app/app.ts index c4d3f0090..f43ef7267 100644 --- a/ng-sample/app/app.ts +++ b/ng-sample/app/app.ts @@ -6,9 +6,9 @@ //profiling.start('application-start'); // this import should be first in order to load some required settings (like globals and reflect-metadata) -import { nativeScriptBootstrap } from "./nativescript-angular/application"; -import { NS_ROUTER_PROVIDERS, routerTraceCategory } from "./nativescript-angular/router"; -import { rendererTraceCategory } from "./nativescript-angular/renderer"; +import { nativeScriptBootstrap } from "nativescript-angular/application"; +import { NS_ROUTER_PROVIDERS, routerTraceCategory } from "nativescript-angular/router"; +import { rendererTraceCategory } from "nativescript-angular/renderer"; import trace = require("trace"); //trace.setCategories(routerTraceCategory + ", " + rendererTraceCategory); diff --git a/ng-sample/app/examples/action-bar/action-bar-test.ts b/ng-sample/app/examples/action-bar/action-bar-test.ts index 3f5c6dc32..729f9bc90 100644 --- a/ng-sample/app/examples/action-bar/action-bar-test.ts +++ b/ng-sample/app/examples/action-bar/action-bar-test.ts @@ -1,8 +1,8 @@ import {Component} from '@angular/core'; import {RouteConfig} from '@angular/router-deprecated'; import { Page} from "ui/page"; -import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../../nativescript-angular/router/ns-router"; -import {NS_DIRECTIVES} from "../../nativescript-angular/directives"; +import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router"; +import {NS_DIRECTIVES} from "nativescript-angular/directives"; @Component({ selector: "first", diff --git a/ng-sample/app/examples/modal/modal-content.ts b/ng-sample/app/examples/modal/modal-content.ts index 3875f0903..b68447e36 100644 --- a/ng-sample/app/examples/modal/modal-content.ts +++ b/ng-sample/app/examples/modal/modal-content.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {ModalDialogParams} from "../../nativescript-angular/directives/dialogs"; +import {ModalDialogParams} from "nativescript-angular/directives/dialogs"; @Component({ selector: 'modal-content', diff --git a/ng-sample/app/examples/modal/modal-test.ts b/ng-sample/app/examples/modal/modal-test.ts index 4a909b5f1..acab890f2 100644 --- a/ng-sample/app/examples/modal/modal-test.ts +++ b/ng-sample/app/examples/modal/modal-test.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import * as dialogs from "ui/dialogs"; -import {ModalDialogService, ModalDialogOptions, ModalDialogHost} from "../../nativescript-angular/directives/dialogs"; +import {ModalDialogService, ModalDialogOptions, ModalDialogHost} from "nativescript-angular/directives/dialogs"; import {ModalContent} from "./modal-content"; @Component({ diff --git a/ng-sample/app/examples/navigation/login-test.ts b/ng-sample/app/examples/navigation/login-test.ts index cec2d17ff..433767d4c 100644 --- a/ng-sample/app/examples/navigation/login-test.ts +++ b/ng-sample/app/examples/navigation/login-test.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {RouteConfig, ROUTER_PROVIDERS, ROUTER_DIRECTIVES, ComponentInstruction, Router, RouteParams, RouteData} from '@angular/router-deprecated'; -import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../../nativescript-angular/router/ns-router"; +import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router"; import {isBlank} from '@angular/core/src/facade/lang'; @Component({ diff --git a/ng-sample/app/examples/navigation/nav-component.ts b/ng-sample/app/examples/navigation/nav-component.ts index 3263927fe..b05483106 100644 --- a/ng-sample/app/examples/navigation/nav-component.ts +++ b/ng-sample/app/examples/navigation/nav-component.ts @@ -4,7 +4,7 @@ import {ROUTER_DIRECTIVES, Router, OnActivate, OnDeactivate, CanReuse, OnReuse, import {Location, LocationStrategy} from '@angular/common'; import {topmost} from "ui/frame"; import {Page} from "ui/page"; -import {NS_ROUTER_DIRECTIVES} from "../../nativescript-angular/router/ns-router"; +import {NS_ROUTER_DIRECTIVES} from "nativescript-angular/router/ns-router"; @Component({ diff --git a/ng-sample/app/examples/navigation/navigation-test.ts b/ng-sample/app/examples/navigation/navigation-test.ts index 45d8fc667..fdcb3fc7a 100644 --- a/ng-sample/app/examples/navigation/navigation-test.ts +++ b/ng-sample/app/examples/navigation/navigation-test.ts @@ -2,7 +2,7 @@ import {Component} from '@angular/core'; import {RouteConfig, ROUTER_PROVIDERS, ROUTER_DIRECTIVES, ComponentInstruction} from '@angular/router-deprecated'; import {NavComponent} from "./nav-component"; -import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../../nativescript-angular/router/ns-router"; +import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router"; @Component({ selector: "start-nav-test", diff --git a/ng-sample/app/examples/navigation/router-outlet-test.ts b/ng-sample/app/examples/navigation/router-outlet-test.ts index ef993ac05..7959e2387 100644 --- a/ng-sample/app/examples/navigation/router-outlet-test.ts +++ b/ng-sample/app/examples/navigation/router-outlet-test.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {RouteConfig, ROUTER_PROVIDERS, ROUTER_DIRECTIVES, ComponentInstruction, RouteParams} from '@angular/router-deprecated'; -import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../../nativescript-angular/router/ns-router"; +import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router"; @Component({ selector: "first", diff --git a/ng-sample/app/examples/renderer-test.ts b/ng-sample/app/examples/renderer-test.ts index 03ca60632..4e273ecb7 100644 --- a/ng-sample/app/examples/renderer-test.ts +++ b/ng-sample/app/examples/renderer-test.ts @@ -1,7 +1,7 @@ import {Component, Directive, Host, ElementRef, Input} from '@angular/core'; import {Observable} from 'data/observable'; -import {TextValueAccessor} from '../nativescript-angular/value-accessors/text-value-accessor'; -import {CheckedValueAccessor} from '../nativescript-angular/value-accessors/checked-value-accessor'; +import {TextValueAccessor} from 'nativescript-angular/value-accessors/text-value-accessor'; +import {CheckedValueAccessor} from 'nativescript-angular/value-accessors/checked-value-accessor'; @Component({ selector: 'templated-component', diff --git a/ng-sample/hooks/before-livesync/nativescript-angular-sync .js b/ng-sample/hooks/before-livesync/nativescript-angular-sync .js new file mode 100644 index 000000000..8d279c8c6 --- /dev/null +++ b/ng-sample/hooks/before-livesync/nativescript-angular-sync .js @@ -0,0 +1 @@ +module.exports = require("nativescript-angular/hooks/before-livesync"); diff --git a/ng-sample/hooks/before-prepare/10-copy-renderer.js b/ng-sample/hooks/before-prepare/10-copy-renderer.js deleted file mode 100644 index adea1f459..000000000 --- a/ng-sample/hooks/before-prepare/10-copy-renderer.js +++ /dev/null @@ -1,7 +0,0 @@ -var path = require('path'); -var shelljs = require('shelljs'); - -module.exports = function() { - shelljs.cp('-Rf', '../src/nativescript-angular', 'app'); - shelljs.cp('-Rf', '../src/global.d.ts', 'app'); -} diff --git a/ng-sample/hooks/before-prepare/20-nativescript-dev-typescript.js b/ng-sample/hooks/before-prepare/nativescript-dev-typescript.js similarity index 100% rename from ng-sample/hooks/before-prepare/20-nativescript-dev-typescript.js rename to ng-sample/hooks/before-prepare/nativescript-dev-typescript.js diff --git a/ng-sample/package.json b/ng-sample/package.json index 2bdb6395b..d2f7d60cb 100644 --- a/ng-sample/package.json +++ b/ng-sample/package.json @@ -24,6 +24,7 @@ "homepage": "https://github.com/NativeScript/template-hello-world", "dependencies": { "tns-core-modules": "2.0.0-angular-7", + "nativescript-angular": "^0.1.6", "nativescript-intl": "^0.0.2", "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", diff --git a/ng-sample/tsconfig.json b/ng-sample/tsconfig.json index f7941352f..6299debe3 100644 --- a/ng-sample/tsconfig.json +++ b/ng-sample/tsconfig.json @@ -1,7 +1,5 @@ { "compilerOptions": { - "outDir": "app", - "rootDir": "app", "module": "commonjs", "target": "es5", "inlineSourceMap": true, From 827bf0f4a3572f389c8bf4239a646a0c4bc01492 Mon Sep 17 00:00:00 2001 From: vakrilov Date: Mon, 30 May 2016 17:40:01 +0300 Subject: [PATCH 3/4] tests made working with the new structure --- .travis.yml | 1 + tests/hooks/before-prepare/10-copy-renderer.js | 7 ------- tests/package.json | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 tests/hooks/before-prepare/10-copy-renderer.js diff --git a/.travis.yml b/.travis.yml index 6e3d24bb7..d2fd47f48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,5 +35,6 @@ script: - npm install - cd ./tests - npm install + - npm install ../nativescript-angular - tns platform add android - tns test android --emulator --justlaunch diff --git a/tests/hooks/before-prepare/10-copy-renderer.js b/tests/hooks/before-prepare/10-copy-renderer.js deleted file mode 100644 index 9d579dcde..000000000 --- a/tests/hooks/before-prepare/10-copy-renderer.js +++ /dev/null @@ -1,7 +0,0 @@ -var execSync = require('child_process').execSync; - -module.exports = function($logger, $projectData, $usbLiveSyncService) { - if (!$usbLiveSyncService.isInitialized) { - execSync("npm run updateTests", { stdio: [0, 1, 2]}); - } -} diff --git a/tests/package.json b/tests/package.json index d0498b533..725894f89 100644 --- a/tests/package.json +++ b/tests/package.json @@ -32,6 +32,7 @@ "dependencies": { "nativescript-unit-test-runner": "^0.3.3", "tns-core-modules": "2.0.0-angular-7", + "nativescript-angular": "^0.1.6", "nativescript-intl": "^0.0.2", "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", From 1712143eab61388e4419e87c0240b667887c6ad1 Mon Sep 17 00:00:00 2001 From: vakrilov Date: Mon, 30 May 2016 18:02:00 +0300 Subject: [PATCH 4/4] Additional cleanup & readme updates & build fixes --- .gitignore | 1 + .travis.yml | 9 +- DEVELOPERS.md | 46 ---------- README.md | 45 ++++++---- gruntfile.js | 139 ------------------------------ nativescript-angular/.npmignore | 3 + nativescript-angular/global.d.ts | 2 +- nativescript-angular/gulpfile.js | 15 ++++ nativescript-angular/package.json | 20 ++--- package.json | 31 ------- tests/tsconfig.json | 2 - 11 files changed, 63 insertions(+), 250 deletions(-) delete mode 100644 DEVELOPERS.md delete mode 100644 gruntfile.js create mode 100644 nativescript-angular/gulpfile.js delete mode 100644 package.json diff --git a/.gitignore b/.gitignore index f834ff475..c51171b48 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ nativescript-angular/**/*.d.ts nativescript-angular/**/*.js !nativescript-angular/postinstall.js !nativescript-angular/hooks/**/*.js +!nativescript-angular/gulpfile.js .tscache .nvm diff --git a/.travis.yml b/.travis.yml index d2fd47f48..9209e2405 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,11 @@ install: - npm install -g nativescript --ignore-scripts - tns usage-reporting disable - tns error-reporting disable + - cd nativescript-angular + - npm install + - cd ../tests + - npm install + - npm install ../nativescript-angular before_script: - echo no | android create avd --force -n test -t android-19 -b armeabi-v7a @@ -32,9 +37,5 @@ before_script: - android-wait-for-emulator script: - - npm install - - cd ./tests - - npm install - - npm install ../nativescript-angular - tns platform add android - tns test android --emulator --justlaunch diff --git a/DEVELOPERS.md b/DEVELOPERS.md deleted file mode 100644 index d0156d4e5..000000000 --- a/DEVELOPERS.md +++ /dev/null @@ -1,46 +0,0 @@ -# NativeScript - Angular 2 integration - -## Running stuff locally - -Clone the repo and cd to the local dir. - -Fetch the git submodules: - -```sh - git submodule --init - git submodule --update -``` - -Install the npm requirements: - -```sh - npm install -``` - -Install the angular npm requirements: - -```sh - cd angular - npm install - cd .. # back to the project root -``` - -Install the angular typings: - -```sh - cd deps/angular/modules/angular2 - tsd reinstall - cd ../../../../ # back to the project root -``` - -Prepare the local angular2 & NativeScript codebases in src/*: - -```sh - grunt prepare -``` - -Compile the project: - -```sh - grunt ts -``` diff --git a/README.md b/README.md index 33dda4bb0..95c2e083b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Integrating NativeScript with Angular 2. # Running locally -# Prerequisites +## Prerequisites Install your native toolchain and NativeScript as described in the docs: @@ -14,31 +14,26 @@ https://docs.nativescript.org/setup/quick-setup ## Install dependencies ``` -$ npm install -g grunt-cli gulp +$ npm install -g gulp ``` Then install the needed NPM packages: ``` +$ cd nativescript-angular $ npm install ``` -## Compile and prepare NativeScript and Angular - -``` -$ grunt -``` - -## Initialize the test NativeScript app (ng-sample) +## Run the sample application (ng-sample) +Intall NPM packages (use the local copy of `nativescript-angular`): ``` $ cd ng-sample $ npm install +$ npm install ../nativescript-angular ``` -The latter installs the `angular2` and `tns-core-modules` packages that you just built by running `grunt prepare` step in the project root. - -## Run the ng-sample app +Start the app: ``` $ tns run android @@ -61,19 +56,37 @@ $ env WEBPACK_BUILD=1 tns run android # Running the tests +Intall NPM packages (use the local copy of `nativescript-angular`): ``` $ cd tests $ npm install +$ npm install ../nativescript-angular +``` + +Start test run: + +``` $ tns test ios --emulator +$ tns test android --emulator ``` # Developer workflow: -1. Make changes to `src/nativescript-angular`, and rebuild with `grunt build`. If succesful, you should get a npm package in the project root. -2. Navigate to the ng-sample subdir: `$ cd ng-sample`. Make some changes to the app or `../src/nativescript-angular`. -3. Run with `$ tns run android` or `$ tns run ios` +## Setup: +Use `npm link` to link `nativescript-angular` in `tests` and `ng-sample` progects: + +``` +cd nativescript-angular +npm link +cd ../ng-sample +npm link nativescript-angular +cd ../tests +npm link nativescript-angular +``` -Note that you should never change files in `ng-sample/src/nativescript-angular/` as they are overwritten with the reference sources in `src/nativescript-angular` on every `grunt app` run. +## Work +1. Make changes to the `test`, `ng-sample` projects or in `nativescript-angular` folder. +2. Run the `tests` or `ng-sample` using as shown above. # Watch the video explaining Angular 2 and NativeScript [NativeScript session on AngularConnect conference](https://www.youtube.com/watch?v=4SbiiyRSIwo) diff --git a/gruntfile.js b/gruntfile.js deleted file mode 100644 index 41b113caf..000000000 --- a/gruntfile.js +++ /dev/null @@ -1,139 +0,0 @@ -var fs = require("fs"); -var path = require("path"); -var shelljs = require("shelljs"); - -module.exports = function(grunt) { - grunt.loadNpmTasks('grunt-ts'); - grunt.loadNpmTasks('grunt-shell'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-env'); - - var outDir = "bin/dist/modules"; - var moduleOutDir = path.join(outDir, "nativescript-angular"); - var moduleOutPackageJson = path.join(moduleOutDir, "package.json"); - var packageName = "nativescript-angular-" + require("./package.json").version + ".tgz"; - - grunt.initConfig({ - ts: { - build: { - src: [ - 'src/**/*.ts', - ], - outDir: outDir, - options: { - fast: 'never', - module: "commonjs", - target: "es5", - sourceMap: true, - experimentalDecorators: true, - emitDecoratorMetadata: true, - declaration: true, - removeComments: false, - compiler: "node_modules/typescript/bin/tsc", - noEmitOnError: true - }, - }, - }, - copy: { - packageJson: { - expand: true, - src: 'package.json', - dest: moduleOutDir - }, - hookScripts: { - cwd: 'src/nativescript-angular', - expand: true, - src: [ - 'postinstall.js', - 'hooks/**/*.js' - ], - dest: moduleOutDir - }, - npmReadme: { - expand: true, - src: 'README.md', - cwd: 'doc', - dest: moduleOutDir - }, - handCodedDefinitions: { - src: '**/*.d.ts', - cwd: 'src/nativescript-angular', - expand: true, - dest: moduleOutDir - }, - }, - clean: { - src: { - expand: true, - cwd: './src', - src: [ - '*.ts', - '!dependencies.d.ts', - '!global.d.ts', - 'angular2', - ] - }, - package: { - src: 'nativescript-angular*.tgz' - }, - }, - shell: { - package: { - command: "npm pack \"" + moduleOutDir + "\"" - }, - updateTests: { - command: "npm install ../" + packageName, - options: { - execOptions: { - cwd: "./tests" - } - } - } - }, - }); - - grunt.registerTask("run", ['ts', 'shell:runApp']); - - grunt.registerTask("cleanAll", [ - 'clean:src', - 'clean:package', - ]); - - grunt.registerTask("package", [ - "copy:handCodedDefinitions", - "copy:npmReadme", - "shell:package", - ]); - - grunt.registerTask("all", [ - "cleanAll", - "build" - ]); - - grunt.registerTask("build", [ - "ts:build", - "copy:packageJson", - "copy:hookScripts", - "add-post-install-script", - "remove-tns-core-modules-dependency", - "package" - ]); - - grunt.registerTask("add-post-install-script", function() { - var packageJson = JSON.parse(fs.readFileSync(moduleOutPackageJson, "utf-8")); - packageJson.scripts = packageJson.scripts || {}; - packageJson.scripts.postinstall = "node postinstall.js"; - fs.writeFileSync(moduleOutPackageJson, JSON.stringify(packageJson, null, " ")); - }); - - grunt.registerTask("remove-tns-core-modules-dependency", function() { - var packageJson = JSON.parse(fs.readFileSync(moduleOutPackageJson, "utf-8")); - delete packageJson.dependencies["tns-core-modules"]; - fs.writeFileSync(moduleOutPackageJson, JSON.stringify(packageJson, null, " ")); - }); - - grunt.registerTask("updateTests", ["all", "shell:updateTests"]); - - grunt.registerTask("default", ["all"]); -}; diff --git a/nativescript-angular/.npmignore b/nativescript-angular/.npmignore index 9bb892a32..7375cfceb 100644 --- a/nativescript-angular/.npmignore +++ b/nativescript-angular/.npmignore @@ -3,6 +3,9 @@ *.ts !*.d.ts +*.js.map + tsconfig.json global.d.ts .npmignore +gulpfile.js \ No newline at end of file diff --git a/nativescript-angular/global.d.ts b/nativescript-angular/global.d.ts index 81ddef2ce..6954b2e13 100644 --- a/nativescript-angular/global.d.ts +++ b/nativescript-angular/global.d.ts @@ -1 +1 @@ -/// +/// diff --git a/nativescript-angular/gulpfile.js b/nativescript-angular/gulpfile.js new file mode 100644 index 000000000..59be64517 --- /dev/null +++ b/nativescript-angular/gulpfile.js @@ -0,0 +1,15 @@ +var gulp = require('gulp'); +var del = require('del'); +var glob = require('glob'); + +gulp.task('clean-defs', function() { + var files = [...glob.sync("*.ts"), ...glob.sync("!(node_modules)/*.ts")] + .map(function(file) { + return file.replace(/.ts$/, '.d.ts'); + }); + + return del(files).then(paths => { + console.log('Definition files cleaned:') + console.log(paths.join('\n')); + }); +}); \ No newline at end of file diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index 9990be45c..6c1560a9d 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -14,7 +14,8 @@ }, "scripts": { "postinstall": "node postinstall.js", - "prepublish": "tsc" + "prepublish": "tsc", + "postpublish": "gulp clean-defs" }, "dependencies": { "nativescript-intl": "^0.0.2", @@ -31,21 +32,18 @@ "parse5": "1.4.2", "punycode": "1.3.2", "querystring": "0.2.0", - "url": "0.10.3" + "url": "0.10.3", + "shelljs": "^0.7.0" }, "devDependencies": { - "grunt": "0.4.5", - "grunt-contrib-copy": "0.8.0", - "grunt-contrib-clean": "0.6.0", - "grunt-shell": "1.1.2", - "grunt-file": "1.0.2", - "grunt-env": "0.4.4", - "grunt-ts": "5.0.0-beta.5", - "shelljs": "^0.5.3", + "del": "^2.2.0", + "glob": "^7.0.3", + "gulp": "^3.9.1", + "tns-core-modules": ">=2.0.0 || >=2.1.0-2016 || >=2.0.0-angular-7", "typescript": "^1.8.10" }, "peerDependencies": { "tns-core-modules": ">=2.0.0 || >=2.1.0-2016 || >=2.0.0-angular-7" }, "nativescript": {} -} \ No newline at end of file +} diff --git a/package.json b/package.json deleted file mode 100644 index d5b0d983c..000000000 --- a/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "nativescript-angular", - "version": "0.1.6", - "description": "An Angular 2 renderer that lets you build mobile apps with NativeScript.", - "homepage": "http://www.telerik.com", - "bugs": "http://www.telerik.com", - "contributors": [ - "Hristo Deshev " - ], - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "https://github.com/NativeScript/nativescript-angular.git" - }, - "scripts": {}, - "dependencies": { - "tns-core-modules": "2.0.0-angular-7" - }, - "devDependencies": { - "grunt": "0.4.5", - "grunt-contrib-copy": "0.8.0", - "grunt-contrib-clean": "0.6.0", - "grunt-shell": "1.1.2", - "grunt-file": "1.0.2", - "grunt-env": "0.4.4", - "grunt-ts": "5.0.0-beta.5", - "shelljs": "^0.5.3", - "typescript": "^1.8.10" - }, - "nativescript": {} -} diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 0b675cf75..96b0d787a 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -1,7 +1,5 @@ { "compilerOptions": { - "outDir": "app", - "rootDir": "app", "module": "commonjs", "target": "es5", "inlineSourceMap": true,