Skip to content
This repository was archived by the owner on Sep 21, 2018. It is now read-only.

Commit a4c5ec0

Browse files
committed
chore(build): Switch to angular-cli for build pipeline
1 parent 7591b30 commit a4c5ec0

26 files changed

+8219
-160
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ books and add them to their collection. This application utilizes [@ngrx/db](htt
88
to persist the collection across sessions; [@ngrx/store](https://github.com/ngrx/store) to manage
99
the state of the app and to cache requests made to the Google Books API;
1010
[@angular/router](https://github.com/angular/angular) to manage navigation between routes;
11-
and [@ngrx/effects](https://github.com/ngrx/effects) to isolate side effects.
11+
and [@ngrx/effects](https://github.com/ngrx/effects) to isolate side effects.
12+
13+
Built with [angular-cli](https://github.com/angular/angular-cli)
1214

1315
### Included
1416
- [ngrx/store](https://github.com/ngrx/store) - RxJS powered state management for Angular2 apps, inspired by Redux
@@ -24,14 +26,21 @@ and [@ngrx/effects](https://github.com/ngrx/effects) to isolate side effects.
2426
# clone the repo
2527
git clone https://github.com/ngrx/example-app.git
2628

29+
2730
# change directory to repo
2831
cd example-app
2932

30-
# run npm install
33+
# Use npm or yarn to install the dependencies:
3134
npm install
3235

36+
# OR
37+
yarn
38+
3339
# start the server
34-
npm start
40+
ng serve
3541
```
3642

37-
Navigate to [http://localhost:8080/](http://localhost:8080/) in your browser
43+
Navigate to [http://localhost:4200/](http://localhost:4200/) in your browser
44+
45+
_NOTE:_ The above setup instructions assume you have added local npm bin folders to your path.
46+
If this is not the case you will need to install the angular-cli globally.

angular-cli.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"project": {
3+
"version": "1.0.0-beta.17",
4+
"name": "example"
5+
},
6+
"apps": [
7+
{
8+
"root": "src",
9+
"outDir": "dist",
10+
"assets": "assets",
11+
"index": "index.html",
12+
"main": "main.ts",
13+
"test": "test.ts",
14+
"tsconfig": "tsconfig.json",
15+
"prefix": "app",
16+
"mobile": false,
17+
"styles": [
18+
"styles.css"
19+
],
20+
"scripts": [],
21+
"environments": {
22+
"source": "environments/environment.ts",
23+
"dev": "environments/environment.ts",
24+
"prod": "environments/environment.prod.ts"
25+
}
26+
}
27+
],
28+
"addons": [],
29+
"packages": [],
30+
"e2e": {
31+
"protractor": {
32+
"config": "./protractor.conf.js"
33+
}
34+
},
35+
"test": {
36+
"karma": {
37+
"config": "./karma.conf.js"
38+
}
39+
},
40+
"defaults": {
41+
"styleExt": "css",
42+
"prefixInterfaces": false
43+
}
44+
}

karma.conf.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/0.13/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', 'angular-cli'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-remap-istanbul'),
12+
require('angular-cli/plugins/karma')
13+
],
14+
files: [
15+
{ pattern: './src/test.ts', watched: false }
16+
],
17+
preprocessors: {
18+
'./src/test.ts': ['angular-cli']
19+
},
20+
remapIstanbulReporter: {
21+
reports: {
22+
html: 'coverage',
23+
lcovonly: './coverage/coverage.lcov'
24+
}
25+
},
26+
angularCli: {
27+
config: './angular-cli.json',
28+
environment: 'dev'
29+
},
30+
reporters: ['progress', 'karma-remap-istanbul'],
31+
port: 9876,
32+
colors: true,
33+
logLevel: config.LOG_INFO,
34+
autoWatch: true,
35+
browsers: ['Chrome'],
36+
singleRun: false
37+
});
38+
};

package.json

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Example application demoing the @ngrx platform",
55
"main": "index.ts",
66
"scripts": {
7-
"build": "webpack -p --env.prod",
7+
"build": "webpack --env.prod",
88
"start": "webpack-dev-server"
99
},
1010
"repository": {
@@ -22,17 +22,17 @@
2222
"npm": ">= 3"
2323
},
2424
"dependencies": {
25-
"@angular/common": "^2.0.0",
26-
"@angular/compiler": "^2.0.0",
27-
"@angular/compiler-cli": "^0.6.0",
28-
"@angular/core": "^2.0.0",
29-
"@angular/forms": "^2.0.0",
30-
"@angular/http": "^2.0.0",
25+
"@angular/common": "^2.1.0",
26+
"@angular/compiler": "^2.1.0",
27+
"@angular/compiler-cli": "^2.1.0",
28+
"@angular/core": "^2.1.0",
29+
"@angular/forms": "^2.1.0",
30+
"@angular/http": "^2.1.0",
3131
"@angular/material": "^2.0.0-alpha.9-3",
32-
"@angular/platform-browser": "^2.0.0",
33-
"@angular/platform-browser-dynamic": "^2.0.0",
34-
"@angular/platform-server": "^2.0.0",
35-
"@angular/router": "^3.0.0",
32+
"@angular/platform-browser": "^2.1.0",
33+
"@angular/platform-browser-dynamic": "^2.1.0",
34+
"@angular/platform-server": "^2.1.0",
35+
"@angular/router": "^3.1.0",
3636
"@ngrx/core": "^1.0.0",
3737
"@ngrx/db": "^2.0.0",
3838
"@ngrx/effects": "^2.0.0",
@@ -42,29 +42,24 @@
4242
"core-js": "^2.2.2",
4343
"ngrx-store-freeze": "^0.1.0",
4444
"rxjs": "^5.0.0-beta.12",
45-
"zone.js": "^0.6.12"
45+
"ts-helpers": "^1.1.1",
46+
"zone.js": "^0.6.25"
4647
},
4748
"devDependencies": {
48-
"@ngtools/webpack": "^1.0.0",
49-
"@types/hammerjs": "^2.0.32",
50-
"awesome-typescript-loader": "^2.2.4",
51-
"codelyzer": "^0.0.19",
52-
"cpy-cli": "^1.0.1",
53-
"css-loader": "^0.25.0",
54-
"html-loader": "^0.4.4",
55-
"html-webpack-plugin": "^2.22.0",
56-
"json-loader": "^0.5.4",
57-
"raw-loader": "^0.5.1",
58-
"rimraf": "^2.5.4",
59-
"source-map-loader": "^0.1.5",
60-
"string-replace-loader": "^1.0.3",
61-
"style-loader": "^0.13.1",
62-
"ts-helpers": "^1.1.1",
63-
"ts-node": "^0.7.1",
64-
"tslint": "^3.7.1",
65-
"tslint-loader": "^2.1.3",
66-
"typescript": "2.0.2",
67-
"webpack": "^2.1.0-beta.22",
68-
"webpack-dev-server": "^2.1.0-beta.4"
49+
"@types/jasmine": "^2.2.30",
50+
"@types/node": "^6.0.42",
51+
"angular-cli": "1.0.0-beta.17",
52+
"codelyzer": "~0.0.26",
53+
"jasmine-core": "2.4.1",
54+
"jasmine-spec-reporter": "2.5.0",
55+
"karma": "1.2.0",
56+
"karma-chrome-launcher": "^2.0.0",
57+
"karma-cli": "^1.0.1",
58+
"karma-jasmine": "^1.0.2",
59+
"karma-remap-istanbul": "^0.2.1",
60+
"protractor": "4.0.9",
61+
"ts-node": "1.2.1",
62+
"tslint": "3.13.0",
63+
"typescript": "2.0.2"
6964
}
7065
}

protractor.conf.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Protractor configuration file, see link for more information
2+
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
3+
4+
/*global jasmine */
5+
var SpecReporter = require('jasmine-spec-reporter');
6+
7+
exports.config = {
8+
allScriptsTimeout: 11000,
9+
specs: [
10+
'./e2e/**/*.e2e-spec.ts'
11+
],
12+
capabilities: {
13+
'browserName': 'chrome'
14+
},
15+
directConnect: true,
16+
baseUrl: 'http://localhost:4200/',
17+
framework: 'jasmine',
18+
jasmineNodeOpts: {
19+
showColors: true,
20+
defaultTimeoutInterval: 30000,
21+
print: function() {}
22+
},
23+
useAllAngular2AppRoots: true,
24+
beforeLaunch: function() {
25+
require('ts-node').register({
26+
project: 'e2e'
27+
});
28+
},
29+
onPrepare: function() {
30+
jasmine.getEnv().addReporter(new SpecReporter());
31+
}
32+
};

src/app/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { NgModule } from '@angular/core';
12
import { CommonModule } from '@angular/common';
23
import { MaterialModule } from '@angular/material';
3-
import { NgModule } from '@angular/core';
44
import { ReactiveFormsModule } from '@angular/forms';
55
import { RouterModule } from '@angular/router';
66

src/app/effects/book.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class BookEffects {
3838
search$: Observable<Action> = this.actions$
3939
.ofType(book.ActionTypes.SEARCH)
4040
.debounceTime(300)
41-
.map<string>(action => action.payload)
41+
.map((action: book.SearchAction) => action.payload)
4242
.switchMap(query => {
4343
if (query === '') {
4444
return empty();

src/app/guards/book-exists.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class BookExistsGuard implements CanActivate {
5757
hasBookInApi(id: string): Observable<boolean> {
5858
return this.googleBooks.retrieveBook(id)
5959
.map(bookEntity => new book.LoadAction(bookEntity))
60-
.do(action => this.store.dispatch(action))
60+
.do((action: book.LoadAction) => this.store.dispatch(action))
6161
.map(book => !!book)
6262
.catch(() => {
6363
this.router.navigate(['/404']);

src/app/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './app.module';

src/app/reducers/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Observable } from 'rxjs/Observable';
55
import { combineLatest } from 'rxjs/observable/combineLatest';
66
import { ActionReducer } from '@ngrx/store';
77
import * as fromRouter from '@ngrx/router-store';
8+
import { environment } from '../../environments/environment';
89
import { Book } from '../models/book';
910

1011
/**
@@ -75,11 +76,11 @@ const reducers = {
7576
router: fromRouter.routerReducer,
7677
};
7778

78-
const developmentReducer = compose(storeFreeze, combineReducers)(reducers);
79-
const productionReducer = combineReducers(reducers);
79+
const developmentReducer: ActionReducer<State> = compose(storeFreeze, combineReducers)(reducers);
80+
const productionReducer: ActionReducer<State> = combineReducers(reducers);
8081

8182
export function reducer(state: any, action: any) {
82-
if (PROD) {
83+
if (environment.production) {
8384
return productionReducer(state, action);
8485
}
8586
else {
@@ -103,7 +104,7 @@ export function reducer(state: any, action: any) {
103104
* }
104105
* }
105106
* ```
106-
*
107+
*
107108
* Note that this is equivalent to:
108109
* ```ts
109110
* class MyComponent {
@@ -112,7 +113,7 @@ export function reducer(state: any, action: any) {
112113
* }
113114
* }
114115
* ```
115-
*
116+
*
116117
*/
117118
export function getBooksState(state$: Observable<State>) {
118119
return state$.select(state => state.books);
@@ -127,7 +128,7 @@ export function reducer(state: any, action: any) {
127128
* first select the books state then we pass the state to the book
128129
* reducer's getBooks selector, finally returning an observable
129130
* of search results.
130-
*
131+
*
131132
* Share memoizes the selector functions and published the result. This means
132133
* every time you call the selector, you will get back the same result
133134
* observable. Each subscription to the resultant observable
@@ -196,4 +197,4 @@ export const isSelectedBookInCollection = function (state$: Observable<State>) {
196197
export const getLayoutState = (state$: Observable<State>) =>
197198
state$.select(state => state.layout);
198199

199-
export const getShowSidenav = compose(fromLayout.getShowSidenav, getLayoutState);
200+
export const getShowSidenav = compose(fromLayout.getShowSidenav, getLayoutState);

0 commit comments

Comments
 (0)