Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 2b4d25f

Browse files
author
Nir Galon
authored
Update ngrx (#75)
* Upgrade angular-cli and ngrx versions * Fix new ngrx/store and ngrx/effects * Fix tests
1 parent 83782aa commit 2b4d25f

24 files changed

+275
-227
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ script:
3939
# Client
4040
- cd ../client && npm run lint
4141
- npm run test
42-
- npm run build -- --prod
42+
- npm run build
4343
- cd dist && ws --port 4200&
4444
- npm run e2e
4545

client/.angular-cli.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"tsconfig": "tsconfig.app.json",
1919
"testTsconfig": "tsconfig.spec.json",
2020
"prefix": "app",
21+
"serviceWorker": true,
2122
"styles": [
2223
"styles.scss"
2324
],
@@ -55,6 +56,7 @@
5556
},
5657
"defaults": {
5758
"styleExt": "scss",
58-
"component": {}
59+
"component": {
60+
}
5961
}
6062
}

client/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
npm-debug.log
3333
testem.log
3434
/typings
35+
yarn-error.log
3536

3637
# e2e
3738
/e2e/*.js

client/e2e/app.e2e-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ClientPage } from './app.po';
1+
import { AppPage } from './app.po';
22

33
describe('client App', () => {
4-
let page: ClientPage;
4+
let page: AppPage;
55

66
beforeEach(() => {
7-
page = new ClientPage();
7+
page = new AppPage();
88
});
99
});

client/e2e/app.po.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { browser, by, element } from 'protractor';
22

3-
export class ClientPage {
3+
export class AppPage {
44
navigateTo() {
55
return browser.get('/');
66
}

client/karma.conf.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Karma configuration file, see link for more information
2-
// https://karma-runner.github.io/0.13/config/configuration-file.html
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

44
module.exports = function (config) {
55
config.set({
@@ -12,14 +12,6 @@ module.exports = function (config) {
1212
require('karma-coverage-istanbul-reporter'),
1313
require('@angular/cli/plugins/karma')
1414
],
15-
files: [{
16-
pattern: './node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
17-
included: true,
18-
watched: true
19-
}, {
20-
pattern: './src/test.ts',
21-
watched: false
22-
}],
2315
client:{
2416
clearContext: false // leave Jasmine Spec Runner output visible in browser
2517
},

client/package.json

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,45 @@
44
"license": "ISC",
55
"scripts": {
66
"ng": "ng",
7-
"start": "ng serve --host=0.0.0.0 --proxy-config proxy.conf.json",
8-
"build": "ng build",
7+
"start": "ng serve --proxy-config proxy.conf.json --open",
8+
"build": "ng build --prod --aot --build-optimizer",
99
"test": "ng test --single-run --code-coverage",
1010
"lint": "ng lint",
11-
"e2e": "ng e2e",
12-
"sw": "sw-precache --root=dist --config=sw-precache-config.js"
11+
"e2e": "ng e2e"
1312
},
1413
"private": false,
1514
"dependencies": {
16-
"@angular/animations": "^4.0.0",
17-
"@angular/common": "^4.0.0",
18-
"@angular/compiler": "^4.0.0",
19-
"@angular/core": "^4.0.0",
20-
"@angular/forms": "^4.0.0",
21-
"@angular/http": "^4.0.0",
15+
"@angular/animations": "^4.2.4",
16+
"@angular/common": "^4.2.4",
17+
"@angular/compiler": "^4.2.4",
18+
"@angular/core": "^4.2.4",
19+
"@angular/forms": "^4.2.4",
20+
"@angular/http": "^4.2.4",
2221
"@angular/material": "^2.0.0-beta.8",
23-
"@angular/platform-browser": "^4.0.0",
24-
"@angular/platform-browser-dynamic": "^4.0.0",
25-
"@angular/router": "^4.0.0",
22+
"@angular/platform-browser": "^4.2.4",
23+
"@angular/platform-browser-dynamic": "^4.2.4",
24+
"@angular/router": "^4.2.4",
25+
"@angular/service-worker": "^1.0.0-beta.16",
2626
"@ngrx/core": "^1.2.0",
27-
"@ngrx/effects": "^2.0.4",
28-
"@ngrx/store": "^2.2.3",
27+
"@ngrx/effects": "^4.0.5",
28+
"@ngrx/store": "^4.0.3",
2929
"core-js": "^2.4.1",
3030
"hammerjs": "^2.0.8",
3131
"reselect": "^3.0.1",
32-
"rxjs": "^5.4.1",
32+
"rxjs": "^5.4.2",
3333
"zone.js": "^0.8.14"
3434
},
3535
"devDependencies": {
3636
"@angular/cdk": "^2.0.0-beta.8",
37-
"@angular/cli": "1.2.6",
38-
"@angular/compiler-cli": "^4.0.0",
39-
"@angular/language-service": "^4.0.0",
40-
"@ngrx/store-devtools": "^3.2.4",
37+
"@angular/cli": "1.3.1",
38+
"@angular/compiler-cli": "^4.2.4",
39+
"@angular/language-service": "^4.2.4",
40+
"@ngrx/store-devtools": "^4.0.0",
4141
"@types/hammerjs": "^2.0.34",
4242
"@types/jasmine": "~2.5.53",
4343
"@types/jasminewd2": "~2.0.2",
4444
"@types/node": "~6.0.60",
45-
"codelyzer": "~3.0.1",
45+
"codelyzer": "~3.1.1",
4646
"jasmine-core": "~2.6.2",
4747
"jasmine-spec-reporter": "~4.1.0",
4848
"karma": "~1.7.0",
@@ -53,8 +53,7 @@
5353
"karma-jasmine-html-reporter": "^0.2.2",
5454
"ngrx-store-freeze": "^0.1.9",
5555
"protractor": "~5.1.2",
56-
"sw-precache": "^5.2.0",
57-
"ts-node": "~3.0.4",
56+
"ts-node": "~3.2.0",
5857
"tslint": "~5.3.2",
5958
"typescript": "~2.3.3"
6059
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
import { NgModule } from '@angular/core';
3-
import { RouterModule, Routes } from '@angular/router';
2+
import { Routes, RouterModule } from '@angular/router';
43

54
import { UsersComponent } from './components/users/users.component';
65

@@ -9,9 +8,8 @@ const routes: Routes = [
98
{ path: 'users', component: UsersComponent },
109
];
1110

12-
1311
@NgModule({
14-
imports: [ RouterModule.forRoot(routes) ],
15-
exports: [ RouterModule ]
12+
imports: [RouterModule.forRoot(routes)],
13+
exports: [RouterModule]
1614
})
17-
export class AppRoutingModule {}
15+
export class AppRoutingModule { }

client/src/app/app.module.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import 'hammerjs';
33
import { BrowserModule } from '@angular/platform-browser';
44
import { NgModule } from '@angular/core';
55
import { HttpModule } from '@angular/http';
6+
7+
import { MaterialModule } from '@angular/material';
8+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
9+
610
import { StoreModule } from '@ngrx/store';
711
import { EffectsModule } from '@ngrx/effects';
812
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
9-
import { MaterialModule } from '@angular/material';
10-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
1113

12-
import { reducer } from './reducers';
14+
import { reducers } from './reducers';
1315
import { AppRoutingModule } from './app-routing.module';
1416

1517
import { AppComponent } from './app.component';
@@ -19,6 +21,8 @@ import { UserEffects } from './effects/user';
1921

2022
import { UserService } from './services/user.service';
2123

24+
import { environment } from '../environments/environment';
25+
2226
@NgModule({
2327
declarations: [
2428
AppComponent,
@@ -30,9 +34,11 @@ import { UserService } from './services/user.service';
3034
AppRoutingModule,
3135
MaterialModule,
3236
BrowserAnimationsModule,
33-
StoreModule.provideStore(reducer),
34-
StoreDevtoolsModule.instrumentOnlyWithExtension(),
35-
EffectsModule.run(UserEffects),
37+
StoreModule.forRoot(reducers),
38+
!environment.production ? StoreDevtoolsModule.instrument() : [],
39+
EffectsModule.forRoot([
40+
UserEffects,
41+
]),
3642
],
3743
providers: [
3844
UserService,

client/src/app/components/users/users.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { By } from '@angular/platform-browser';
55
import { DebugElement } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
77
import { MaterialModule } from '@angular/material';
8-
import { reducer } from '../../reducers';
8+
import { reducers } from '../../reducers';
99
import { StoreModule } from '@ngrx/store';
1010
import 'rxjs/add/observable/of';
1111

@@ -32,7 +32,7 @@ describe('UsersComponent', () => {
3232
TestBed.configureTestingModule({
3333
imports: [
3434
MaterialModule,
35-
StoreModule.provideStore(reducer)
35+
StoreModule.forRoot(reducers),
3636
],
3737
declarations: [ UsersComponent ],
3838
schemas: [ NO_ERRORS_SCHEMA ]

0 commit comments

Comments
 (0)