diff --git a/.gitignore b/.gitignore index 089b3d1f34..cdae132383 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ Thumbs.db # Typing TSD # /src/typings/tsd/ +/src/typings/ /typings/ /tsd_typings/ diff --git a/README.md b/README.md index 97b48a36db..0396736676 100644 --- a/README.md +++ b/README.md @@ -38,19 +38,37 @@ Warning: Angular 2.0 is not production ready yet! ```bash # clone our repo -git clone https://github.com/angularclass/angular2-webpack-starter.git +git clone https://github.com/ngUpgraders/ng-forward-webpack-starter.git # change directory to our repo -cd angular2-webpack-starter +cd ng-forward-webpack-starter # install the repo with npm npm install +# install types definitions via tsd +tsd install + # start the server npm start ``` go to [http://localhost:3000](http://localhost:3000) in your browser +> Move from Angular 1 to 2 by changing branch + +```bash +# change branch +git checkout angular2 + +# install angular2 dependencies +npm install + +# start the server +npm start +``` + +go to [http://localhost:3000](http://localhost:3000) in your browser + # Table of Contents * [File Structure](#file-structure) * [Getting Started](#getting-started) diff --git a/package.json b/package.json index 7a1cc5e63c..1a70bf8dce 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "clean": "rimraf node_modules doc", "clean-install": "npm run clean && npm install", "clean-start": "npm run clean && npm start", + "postinstall": "tsd install", "watch": "webpack --watch", "server": "webpack-dev-server --inline --colors --display-error-details --display-cached --port 3000", "express": "node ./examples/server/express-server-example.js", @@ -40,6 +41,7 @@ "reflect-metadata": "0.1.2" }, "devDependencies": { + "chai": "^3.4.1", "css-loader": "^0.21.0", "exports-loader": "0.6.2", "expose-loader": "0.7.0", diff --git a/spec.bundle.js b/spec.bundle.js index abdd1e6921..5841699ae6 100644 --- a/spec.bundle.js +++ b/spec.bundle.js @@ -10,8 +10,6 @@ */ Error.stackTraceLimit = Infinity; require('reflect-metadata'); -require('angular2/test'); -require('angular2/mock'); /* Ok, this is kinda crazy. We can use the the context method on diff --git a/src/app/app.ts b/src/app/app.ts index 6ce2ea3e03..cee87bac47 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -15,27 +15,37 @@ import {Component} from 'ng-forward/cjs'; // Every Angular template is first compiled by the browser before Angular runs it's compiler template: `
-

Hello {{ app.title }}

+

{{app.title}}

- Your Content Here -
+ Todo List - +
+
- -
this.title = {{ app.title | json }}
-
this.data = {{ app.data | json }}
- +
` }) export class App { // These are member type title: string; - data: Array = []; // default data + list: string[]; + constructor() { - this.title = 'ng-forward'; + this.title = 'ng-forward with Angular 1.x'; + this.list = ['Study', 'Work', 'Party']; + } + + addElement($event): void { + $event.preventDefault(); + + if ($event.keyCode === 13) { + this.list.push($event.target.value); + $event.target.value = ''; + } } } diff --git a/src/typings/_custom.d.ts b/src/typings/_custom.d.ts deleted file mode 100644 index 9f21b263db..0000000000 --- a/src/typings/_custom.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Our custom types - */ -/// -/// diff --git a/src/typings/browser.d.ts b/src/typings/browser.d.ts deleted file mode 100644 index 0cfb56f77b..0000000000 --- a/src/typings/browser.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -interface ObjectConstructor { - assign(target: any, ...sources: any[]): any; - observe(target: any, callback: Function, acceptList?: Array): void; -} \ No newline at end of file diff --git a/src/typings/webpack.d.ts b/src/typings/webpack.d.ts deleted file mode 100644 index d13b64c3b4..0000000000 --- a/src/typings/webpack.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare var require: any; -declare var __filename: string; -declare var __dirname: string; -declare var global: any; -declare var module: any; diff --git a/src/vendor.ts b/src/vendor.ts new file mode 100644 index 0000000000..0be74aaa37 --- /dev/null +++ b/src/vendor.ts @@ -0,0 +1,2 @@ +import '@reactivex/rxjs'; +import 'reflect-metadata'; diff --git a/test/app/app.spec.ts b/test/app/app.spec.ts index 9d951fbe91..4f85f402f7 100644 --- a/test/app/app.spec.ts +++ b/test/app/app.spec.ts @@ -1,9 +1,20 @@ /// +/** + * Module dependencies. + */ +import chai = require('chai'); + +/** + * Globals + */ + +var expect = chai.expect; + describe('App', () => { it('should also be able to test', () => { - expect(true).toBe(true); + expect(true).to.equals(true); }); }); diff --git a/tsd.json b/tsd.json new file mode 100644 index 0000000000..08a50da784 --- /dev/null +++ b/tsd.json @@ -0,0 +1,39 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "src/typings", + "bundle": "src/typings/_custom.d.ts", + "installed": { + "angularjs/angular.d.ts": { + "commit": "c2c22c3b953fe9730d4802022d5e0d18d083909e" + }, + "jquery/jquery.d.ts": { + "commit": "c2c22c3b953fe9730d4802022d5e0d18d083909e" + }, + "angularjs/angular-mocks.d.ts": { + "commit": "9fb1a5074160e679289b56b99a763104926a4a24" + }, + "es6-shim/es6-shim.d.ts": { + "commit": "62eedc3121a5e28c50473d2e4a9cefbcb9c3957f" + }, + "angular-ui-router/angular-ui-router.d.ts": { + "commit": "c2c22c3b953fe9730d4802022d5e0d18d083909e" + }, + "mocha/mocha.d.ts": { + "commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9" + }, + "sinon/sinon.d.ts": { + "commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9" + }, + "assertion-error/assertion-error.d.ts": { + "commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9" + }, + "chai/chai.d.ts": { + "commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9" + }, + "sinon-chai/sinon-chai.d.ts": { + "commit": "a9ded5b70ede34486731ef6c2e6865f5e9911fc3" + } + } +} diff --git a/webpack.config.js b/webpack.config.js index 0fbe9ff664..648c675610 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -55,17 +55,7 @@ module.exports = { // entry: { - 'angular2': [ - // Angular 2 Deps - '@reactivex/rxjs', - 'zone.js', - 'reflect-metadata', - // to ensure these modules are grouped together in one file - 'angular2/angular2', - 'angular2/core', - 'angular2/router', - 'angular2/http' - ], + 'angular2': './src/vendor', 'app': [ // App