diff --git a/courses/tutorial/README.md b/courses/tutorial/README.md index 915696e..bfbbc66 100644 --- a/courses/tutorial/README.md +++ b/courses/tutorial/README.md @@ -6,14 +6,20 @@ ハンズオンを円滑に進行するために、事前に開発環境の準備を行います。 +このハンズオンに必要な開発環境は以下のとおりです + +- Node.js 6.x +- Angular-CLI 1.0.0-beta.24 + ### Node.jsのインストール -[Node.js](http://nodejs.org/)からお使いのOSに合わせたNode.jsをインストールしてください。 +[Node.js](https://nodejs.org/ja/)からお使いのOSに合わせたNode.jsをインストールしてください。 ターミナル(コマンドプロンプト)を開いて以下のコマンドが実行できればインストール成功です ``` $ node -v +v6.9.1 ``` ### Angular-CLIのインストール diff --git a/courses/tutorial/ch-1/.editorconfig b/courses/tutorial/ch-1/.editorconfig index f352616..6e87a00 100644 --- a/courses/tutorial/ch-1/.editorconfig +++ b/courses/tutorial/ch-1/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/courses/tutorial/ch-1/.gitignore b/courses/tutorial/ch-1/.gitignore index fccc4d9..fe6f8a7 100644 --- a/courses/tutorial/ch-1/.gitignore +++ b/courses/tutorial/ch-1/.gitignore @@ -6,15 +6,22 @@ # dependencies /node_modules -/bower_components # IDEs and editors /.idea .project .classpath +.c9/ *.launch .settings/ +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + # misc /.sass-cache /connect.lock diff --git a/courses/tutorial/ch-1/angular-cli.json b/courses/tutorial/ch-1/angular-cli.json index 1362bad..a349493 100644 --- a/courses/tutorial/ch-1/angular-cli.json +++ b/courses/tutorial/ch-1/angular-cli.json @@ -1,13 +1,16 @@ { "project": { - "version": "1.0.0-beta.15", + "version": "1.0.0-beta.24", "name": "hello-angular" }, "apps": [ { "root": "src", "outDir": "dist", - "assets": "assets", + "assets": [ + "assets", + "favicon.ico" + ], "index": "index.html", "main": "main.ts", "test": "test.ts", @@ -39,6 +42,18 @@ }, "defaults": { "styleExt": "css", - "prefixInterfaces": false + "prefixInterfaces": false, + "inline": { + "style": false, + "template": false + }, + "spec": { + "class": false, + "component": true, + "directive": true, + "module": false, + "pipe": true, + "service": true + } } } diff --git a/courses/tutorial/ch-1/e2e/app.e2e-spec.ts b/courses/tutorial/ch-1/e2e/app.e2e-spec.ts index 89e4124..2e5557b 100644 --- a/courses/tutorial/ch-1/e2e/app.e2e-spec.ts +++ b/courses/tutorial/ch-1/e2e/app.e2e-spec.ts @@ -1,10 +1,10 @@ -import { Ch1Page } from './app.po'; +import { HelloAngularPage } from './app.po'; -describe('ch-1 App', function() { - let page: Ch1Page; +describe('hello-angular App', function() { + let page: HelloAngularPage; beforeEach(() => { - page = new Ch1Page(); + page = new HelloAngularPage(); }); it('should display message saying app works', () => { diff --git a/courses/tutorial/ch-1/e2e/app.po.ts b/courses/tutorial/ch-1/e2e/app.po.ts index 42a4dd3..0cf8138 100644 --- a/courses/tutorial/ch-1/e2e/app.po.ts +++ b/courses/tutorial/ch-1/e2e/app.po.ts @@ -1,6 +1,6 @@ -import { browser, element, by } from 'protractor/globals'; +import { browser, element, by } from 'protractor'; -export class Ch1Page { +export class HelloAngularPage { navigateTo() { return browser.get('/'); } diff --git a/courses/tutorial/ch-1/karma.conf.js b/courses/tutorial/ch-1/karma.conf.js index e28922a..1f2613a 100644 --- a/courses/tutorial/ch-1/karma.conf.js +++ b/courses/tutorial/ch-1/karma.conf.js @@ -17,6 +17,9 @@ module.exports = function (config) { preprocessors: { './src/test.ts': ['angular-cli'] }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, remapIstanbulReporter: { reports: { html: 'coverage', @@ -27,7 +30,9 @@ module.exports = function (config) { config: './angular-cli.json', environment: 'dev' }, - reporters: ['progress', 'karma-remap-istanbul'], + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/courses/tutorial/ch-1/package.json b/courses/tutorial/ch-1/package.json index a14e6ff..9b6c36c 100644 --- a/courses/tutorial/ch-1/package.json +++ b/courses/tutorial/ch-1/package.json @@ -1,44 +1,47 @@ { - "name": "ch-1", + "name": "hello-angular", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { + "ng": "ng", "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", - "pree2e": "webdriver-manager update", + "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", + "@angular/common": "^2.3.1", + "@angular/compiler": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", + "@angular/http": "^2.3.1", + "@angular/platform-browser": "^2.3.1", + "@angular/platform-browser-dynamic": "^2.3.1", + "@angular/router": "^3.3.1", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { - "@types/jasmine": "^2.2.30", - "angular-cli": "1.0.0-beta.15", - "codelyzer": "~0.0.26", - "jasmine-core": "2.4.1", + "@angular/compiler-cli": "^2.3.1", + "@types/jasmine": "2.5.38", + "@types/node": "^6.0.42", + "angular-cli": "1.0.0-beta.24", + "codelyzer": "~2.0.0-beta.1", + "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "protractor": "4.0.5", + "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "3.13.0", - "typescript": "2.0.2" + "tslint": "^4.0.2", + "typescript": "~2.0.3" } } diff --git a/courses/tutorial/ch-1/protractor.conf.js b/courses/tutorial/ch-1/protractor.conf.js index 169743b..ffded70 100644 --- a/courses/tutorial/ch-1/protractor.conf.js +++ b/courses/tutorial/ch-1/protractor.conf.js @@ -1,5 +1,5 @@ // Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js +// https://github.com/angular/protractor/blob/master/lib/config.ts /*global jasmine */ var SpecReporter = require('jasmine-spec-reporter'); diff --git a/courses/tutorial/ch-1/src/app/app.component.spec.ts b/courses/tutorial/ch-1/src/app/app.component.spec.ts index 98a2280..3ad633e 100644 --- a/courses/tutorial/ch-1/src/app/app.component.spec.ts +++ b/courses/tutorial/ch-1/src/app/app.component.spec.ts @@ -3,13 +3,14 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; -describe('App: Ch1', () => { +describe('AppComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }); + TestBed.compileComponents(); }); it('should create the app', async(() => { diff --git a/courses/tutorial/ch-1/src/app/app.component.ts b/courses/tutorial/ch-1/src/app/app.component.ts index 2d36620..ff63e05 100644 --- a/courses/tutorial/ch-1/src/app/app.component.ts +++ b/courses/tutorial/ch-1/src/app/app.component.ts @@ -6,5 +6,5 @@ import { Component } from '@angular/core'; styleUrls: ['./app.component.css'] }) export class AppComponent { - title = 'Hello Angular!'; + title = 'app works!'; } diff --git a/courses/tutorial/ch-1/src/index.html b/courses/tutorial/ch-1/src/index.html index 2490203..5b22106 100644 --- a/courses/tutorial/ch-1/src/index.html +++ b/courses/tutorial/ch-1/src/index.html @@ -2,12 +2,11 @@ - Hello Angular + HelloAngular - Loading... diff --git a/courses/tutorial/ch-1/src/main.ts b/courses/tutorial/ch-1/src/main.ts index 5c3c520..ac78a71 100644 --- a/courses/tutorial/ch-1/src/main.ts +++ b/courses/tutorial/ch-1/src/main.ts @@ -3,7 +3,7 @@ import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { AppModule } from './app/'; +import { AppModule } from './app/app.module'; if (environment.production) { enableProdMode(); diff --git a/courses/tutorial/ch-1/src/styles.css b/courses/tutorial/ch-1/src/styles.css index e50a47e..90d4ee0 100644 --- a/courses/tutorial/ch-1/src/styles.css +++ b/courses/tutorial/ch-1/src/styles.css @@ -1 +1 @@ -/* You can add global styles to this file, and also import other style files */ \ No newline at end of file +/* You can add global styles to this file, and also import other style files */ diff --git a/courses/tutorial/ch-1/src/test.ts b/courses/tutorial/ch-1/src/test.ts index 7727c8e..be44dc5 100644 --- a/courses/tutorial/ch-1/src/test.ts +++ b/courses/tutorial/ch-1/src/test.ts @@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test'; import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -14,21 +19,14 @@ declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; - -Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') -]) - // First, initialize the Angular testing environment. - .then(([testing, testingBrowser]) => { - testing.getTestBed().initTestEnvironment( - testingBrowser.BrowserDynamicTestingModule, - testingBrowser.platformBrowserDynamicTesting() - ); - }) - // Then we find all the tests. - .then(() => require.context('./', true, /\.spec\.ts/)) - // And load the modules. - .then(context => context.keys().map(context)) - // Finally, start Karma to run the tests. - .then(__karma__.start, __karma__.error); +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +let context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/courses/tutorial/ch-1/src/tsconfig.json b/courses/tutorial/ch-1/src/tsconfig.json index 9b4c84c..1cf713a 100644 --- a/courses/tutorial/ch-1/src/tsconfig.json +++ b/courses/tutorial/ch-1/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/courses/tutorial/ch-1/tslint.json b/courses/tutorial/ch-1/tslint.json index 29f24ee..640d02c 100644 --- a/courses/tutorial/ch-1/tslint.json +++ b/courses/tutorial/ch-1/tslint.json @@ -16,7 +16,6 @@ "spaces" ], "label-position": true, - "label-undefined": true, "max-line-length": [ true, 140 @@ -39,7 +38,6 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, @@ -49,8 +47,6 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, - "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, @@ -93,12 +89,8 @@ "check-type" ], - "directive-selector-prefix": [true, "app"], - "component-selector-prefix": [true, "app"], - "directive-selector-name": [true, "camelCase"], - "component-selector-name": [true, "kebab-case"], - "directive-selector-type": [true, "attribute"], - "component-selector-type": [true, "element"], + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -107,6 +99,9 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true } } diff --git a/courses/tutorial/ch-2/.editorconfig b/courses/tutorial/ch-2/.editorconfig index f352616..6e87a00 100644 --- a/courses/tutorial/ch-2/.editorconfig +++ b/courses/tutorial/ch-2/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/courses/tutorial/ch-2/.gitignore b/courses/tutorial/ch-2/.gitignore index fccc4d9..fe6f8a7 100644 --- a/courses/tutorial/ch-2/.gitignore +++ b/courses/tutorial/ch-2/.gitignore @@ -6,15 +6,22 @@ # dependencies /node_modules -/bower_components # IDEs and editors /.idea .project .classpath +.c9/ *.launch .settings/ +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + # misc /.sass-cache /connect.lock diff --git a/courses/tutorial/ch-2/angular-cli.json b/courses/tutorial/ch-2/angular-cli.json index 1362bad..a349493 100644 --- a/courses/tutorial/ch-2/angular-cli.json +++ b/courses/tutorial/ch-2/angular-cli.json @@ -1,13 +1,16 @@ { "project": { - "version": "1.0.0-beta.15", + "version": "1.0.0-beta.24", "name": "hello-angular" }, "apps": [ { "root": "src", "outDir": "dist", - "assets": "assets", + "assets": [ + "assets", + "favicon.ico" + ], "index": "index.html", "main": "main.ts", "test": "test.ts", @@ -39,6 +42,18 @@ }, "defaults": { "styleExt": "css", - "prefixInterfaces": false + "prefixInterfaces": false, + "inline": { + "style": false, + "template": false + }, + "spec": { + "class": false, + "component": true, + "directive": true, + "module": false, + "pipe": true, + "service": true + } } } diff --git a/courses/tutorial/ch-2/e2e/app.e2e-spec.ts b/courses/tutorial/ch-2/e2e/app.e2e-spec.ts index 89e4124..2e5557b 100644 --- a/courses/tutorial/ch-2/e2e/app.e2e-spec.ts +++ b/courses/tutorial/ch-2/e2e/app.e2e-spec.ts @@ -1,10 +1,10 @@ -import { Ch1Page } from './app.po'; +import { HelloAngularPage } from './app.po'; -describe('ch-1 App', function() { - let page: Ch1Page; +describe('hello-angular App', function() { + let page: HelloAngularPage; beforeEach(() => { - page = new Ch1Page(); + page = new HelloAngularPage(); }); it('should display message saying app works', () => { diff --git a/courses/tutorial/ch-2/e2e/app.po.ts b/courses/tutorial/ch-2/e2e/app.po.ts index 42a4dd3..0cf8138 100644 --- a/courses/tutorial/ch-2/e2e/app.po.ts +++ b/courses/tutorial/ch-2/e2e/app.po.ts @@ -1,6 +1,6 @@ -import { browser, element, by } from 'protractor/globals'; +import { browser, element, by } from 'protractor'; -export class Ch1Page { +export class HelloAngularPage { navigateTo() { return browser.get('/'); } diff --git a/courses/tutorial/ch-2/karma.conf.js b/courses/tutorial/ch-2/karma.conf.js index e28922a..1f2613a 100644 --- a/courses/tutorial/ch-2/karma.conf.js +++ b/courses/tutorial/ch-2/karma.conf.js @@ -17,6 +17,9 @@ module.exports = function (config) { preprocessors: { './src/test.ts': ['angular-cli'] }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, remapIstanbulReporter: { reports: { html: 'coverage', @@ -27,7 +30,9 @@ module.exports = function (config) { config: './angular-cli.json', environment: 'dev' }, - reporters: ['progress', 'karma-remap-istanbul'], + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/courses/tutorial/ch-2/package.json b/courses/tutorial/ch-2/package.json index a14e6ff..9b6c36c 100644 --- a/courses/tutorial/ch-2/package.json +++ b/courses/tutorial/ch-2/package.json @@ -1,44 +1,47 @@ { - "name": "ch-1", + "name": "hello-angular", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { + "ng": "ng", "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", - "pree2e": "webdriver-manager update", + "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", + "@angular/common": "^2.3.1", + "@angular/compiler": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", + "@angular/http": "^2.3.1", + "@angular/platform-browser": "^2.3.1", + "@angular/platform-browser-dynamic": "^2.3.1", + "@angular/router": "^3.3.1", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { - "@types/jasmine": "^2.2.30", - "angular-cli": "1.0.0-beta.15", - "codelyzer": "~0.0.26", - "jasmine-core": "2.4.1", + "@angular/compiler-cli": "^2.3.1", + "@types/jasmine": "2.5.38", + "@types/node": "^6.0.42", + "angular-cli": "1.0.0-beta.24", + "codelyzer": "~2.0.0-beta.1", + "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "protractor": "4.0.5", + "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "3.13.0", - "typescript": "2.0.2" + "tslint": "^4.0.2", + "typescript": "~2.0.3" } } diff --git a/courses/tutorial/ch-2/protractor.conf.js b/courses/tutorial/ch-2/protractor.conf.js index 169743b..ffded70 100644 --- a/courses/tutorial/ch-2/protractor.conf.js +++ b/courses/tutorial/ch-2/protractor.conf.js @@ -1,5 +1,5 @@ // Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js +// https://github.com/angular/protractor/blob/master/lib/config.ts /*global jasmine */ var SpecReporter = require('jasmine-spec-reporter'); diff --git a/courses/tutorial/ch-2/src/app/app.component.spec.ts b/courses/tutorial/ch-2/src/app/app.component.spec.ts index 98a2280..3ad633e 100644 --- a/courses/tutorial/ch-2/src/app/app.component.spec.ts +++ b/courses/tutorial/ch-2/src/app/app.component.spec.ts @@ -3,13 +3,14 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; -describe('App: Ch1', () => { +describe('AppComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }); + TestBed.compileComponents(); }); it('should create the app', async(() => { diff --git a/courses/tutorial/ch-2/src/index.html b/courses/tutorial/ch-2/src/index.html index 2490203..5b22106 100644 --- a/courses/tutorial/ch-2/src/index.html +++ b/courses/tutorial/ch-2/src/index.html @@ -2,12 +2,11 @@ - Hello Angular + HelloAngular - Loading... diff --git a/courses/tutorial/ch-2/src/main.ts b/courses/tutorial/ch-2/src/main.ts index 5c3c520..ac78a71 100644 --- a/courses/tutorial/ch-2/src/main.ts +++ b/courses/tutorial/ch-2/src/main.ts @@ -3,7 +3,7 @@ import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { AppModule } from './app/'; +import { AppModule } from './app/app.module'; if (environment.production) { enableProdMode(); diff --git a/courses/tutorial/ch-2/src/styles.css b/courses/tutorial/ch-2/src/styles.css index e50a47e..90d4ee0 100644 --- a/courses/tutorial/ch-2/src/styles.css +++ b/courses/tutorial/ch-2/src/styles.css @@ -1 +1 @@ -/* You can add global styles to this file, and also import other style files */ \ No newline at end of file +/* You can add global styles to this file, and also import other style files */ diff --git a/courses/tutorial/ch-2/src/test.ts b/courses/tutorial/ch-2/src/test.ts index 7727c8e..be44dc5 100644 --- a/courses/tutorial/ch-2/src/test.ts +++ b/courses/tutorial/ch-2/src/test.ts @@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test'; import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -14,21 +19,14 @@ declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; - -Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') -]) - // First, initialize the Angular testing environment. - .then(([testing, testingBrowser]) => { - testing.getTestBed().initTestEnvironment( - testingBrowser.BrowserDynamicTestingModule, - testingBrowser.platformBrowserDynamicTesting() - ); - }) - // Then we find all the tests. - .then(() => require.context('./', true, /\.spec\.ts/)) - // And load the modules. - .then(context => context.keys().map(context)) - // Finally, start Karma to run the tests. - .then(__karma__.start, __karma__.error); +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +let context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/courses/tutorial/ch-2/src/tsconfig.json b/courses/tutorial/ch-2/src/tsconfig.json index 9b4c84c..1cf713a 100644 --- a/courses/tutorial/ch-2/src/tsconfig.json +++ b/courses/tutorial/ch-2/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/courses/tutorial/ch-2/tslint.json b/courses/tutorial/ch-2/tslint.json index 29f24ee..640d02c 100644 --- a/courses/tutorial/ch-2/tslint.json +++ b/courses/tutorial/ch-2/tslint.json @@ -16,7 +16,6 @@ "spaces" ], "label-position": true, - "label-undefined": true, "max-line-length": [ true, 140 @@ -39,7 +38,6 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, @@ -49,8 +47,6 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, - "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, @@ -93,12 +89,8 @@ "check-type" ], - "directive-selector-prefix": [true, "app"], - "component-selector-prefix": [true, "app"], - "directive-selector-name": [true, "camelCase"], - "component-selector-name": [true, "kebab-case"], - "directive-selector-type": [true, "attribute"], - "component-selector-type": [true, "element"], + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -107,6 +99,9 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true } } diff --git a/courses/tutorial/ch-3/.editorconfig b/courses/tutorial/ch-3/.editorconfig index f352616..6e87a00 100644 --- a/courses/tutorial/ch-3/.editorconfig +++ b/courses/tutorial/ch-3/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/courses/tutorial/ch-3/.gitignore b/courses/tutorial/ch-3/.gitignore index fccc4d9..fe6f8a7 100644 --- a/courses/tutorial/ch-3/.gitignore +++ b/courses/tutorial/ch-3/.gitignore @@ -6,15 +6,22 @@ # dependencies /node_modules -/bower_components # IDEs and editors /.idea .project .classpath +.c9/ *.launch .settings/ +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + # misc /.sass-cache /connect.lock diff --git a/courses/tutorial/ch-3/angular-cli.json b/courses/tutorial/ch-3/angular-cli.json index 1362bad..a349493 100644 --- a/courses/tutorial/ch-3/angular-cli.json +++ b/courses/tutorial/ch-3/angular-cli.json @@ -1,13 +1,16 @@ { "project": { - "version": "1.0.0-beta.15", + "version": "1.0.0-beta.24", "name": "hello-angular" }, "apps": [ { "root": "src", "outDir": "dist", - "assets": "assets", + "assets": [ + "assets", + "favicon.ico" + ], "index": "index.html", "main": "main.ts", "test": "test.ts", @@ -39,6 +42,18 @@ }, "defaults": { "styleExt": "css", - "prefixInterfaces": false + "prefixInterfaces": false, + "inline": { + "style": false, + "template": false + }, + "spec": { + "class": false, + "component": true, + "directive": true, + "module": false, + "pipe": true, + "service": true + } } } diff --git a/courses/tutorial/ch-3/e2e/app.e2e-spec.ts b/courses/tutorial/ch-3/e2e/app.e2e-spec.ts index 89e4124..2e5557b 100644 --- a/courses/tutorial/ch-3/e2e/app.e2e-spec.ts +++ b/courses/tutorial/ch-3/e2e/app.e2e-spec.ts @@ -1,10 +1,10 @@ -import { Ch1Page } from './app.po'; +import { HelloAngularPage } from './app.po'; -describe('ch-1 App', function() { - let page: Ch1Page; +describe('hello-angular App', function() { + let page: HelloAngularPage; beforeEach(() => { - page = new Ch1Page(); + page = new HelloAngularPage(); }); it('should display message saying app works', () => { diff --git a/courses/tutorial/ch-3/e2e/app.po.ts b/courses/tutorial/ch-3/e2e/app.po.ts index 42a4dd3..0cf8138 100644 --- a/courses/tutorial/ch-3/e2e/app.po.ts +++ b/courses/tutorial/ch-3/e2e/app.po.ts @@ -1,6 +1,6 @@ -import { browser, element, by } from 'protractor/globals'; +import { browser, element, by } from 'protractor'; -export class Ch1Page { +export class HelloAngularPage { navigateTo() { return browser.get('/'); } diff --git a/courses/tutorial/ch-3/karma.conf.js b/courses/tutorial/ch-3/karma.conf.js index e28922a..1f2613a 100644 --- a/courses/tutorial/ch-3/karma.conf.js +++ b/courses/tutorial/ch-3/karma.conf.js @@ -17,6 +17,9 @@ module.exports = function (config) { preprocessors: { './src/test.ts': ['angular-cli'] }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, remapIstanbulReporter: { reports: { html: 'coverage', @@ -27,7 +30,9 @@ module.exports = function (config) { config: './angular-cli.json', environment: 'dev' }, - reporters: ['progress', 'karma-remap-istanbul'], + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/courses/tutorial/ch-3/package.json b/courses/tutorial/ch-3/package.json index a14e6ff..9b6c36c 100644 --- a/courses/tutorial/ch-3/package.json +++ b/courses/tutorial/ch-3/package.json @@ -1,44 +1,47 @@ { - "name": "ch-1", + "name": "hello-angular", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { + "ng": "ng", "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", - "pree2e": "webdriver-manager update", + "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", + "@angular/common": "^2.3.1", + "@angular/compiler": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", + "@angular/http": "^2.3.1", + "@angular/platform-browser": "^2.3.1", + "@angular/platform-browser-dynamic": "^2.3.1", + "@angular/router": "^3.3.1", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { - "@types/jasmine": "^2.2.30", - "angular-cli": "1.0.0-beta.15", - "codelyzer": "~0.0.26", - "jasmine-core": "2.4.1", + "@angular/compiler-cli": "^2.3.1", + "@types/jasmine": "2.5.38", + "@types/node": "^6.0.42", + "angular-cli": "1.0.0-beta.24", + "codelyzer": "~2.0.0-beta.1", + "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "protractor": "4.0.5", + "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "3.13.0", - "typescript": "2.0.2" + "tslint": "^4.0.2", + "typescript": "~2.0.3" } } diff --git a/courses/tutorial/ch-3/protractor.conf.js b/courses/tutorial/ch-3/protractor.conf.js index 169743b..ffded70 100644 --- a/courses/tutorial/ch-3/protractor.conf.js +++ b/courses/tutorial/ch-3/protractor.conf.js @@ -1,5 +1,5 @@ // Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js +// https://github.com/angular/protractor/blob/master/lib/config.ts /*global jasmine */ var SpecReporter = require('jasmine-spec-reporter'); diff --git a/courses/tutorial/ch-3/src/app/app.component.spec.ts b/courses/tutorial/ch-3/src/app/app.component.spec.ts index 98a2280..3ad633e 100644 --- a/courses/tutorial/ch-3/src/app/app.component.spec.ts +++ b/courses/tutorial/ch-3/src/app/app.component.spec.ts @@ -3,13 +3,14 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; -describe('App: Ch1', () => { +describe('AppComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }); + TestBed.compileComponents(); }); it('should create the app', async(() => { diff --git a/courses/tutorial/ch-3/src/index.html b/courses/tutorial/ch-3/src/index.html index 2490203..5b22106 100644 --- a/courses/tutorial/ch-3/src/index.html +++ b/courses/tutorial/ch-3/src/index.html @@ -2,12 +2,11 @@ - Hello Angular + HelloAngular - Loading... diff --git a/courses/tutorial/ch-3/src/main.ts b/courses/tutorial/ch-3/src/main.ts index 5c3c520..ac78a71 100644 --- a/courses/tutorial/ch-3/src/main.ts +++ b/courses/tutorial/ch-3/src/main.ts @@ -3,7 +3,7 @@ import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { AppModule } from './app/'; +import { AppModule } from './app/app.module'; if (environment.production) { enableProdMode(); diff --git a/courses/tutorial/ch-3/src/styles.css b/courses/tutorial/ch-3/src/styles.css index e50a47e..90d4ee0 100644 --- a/courses/tutorial/ch-3/src/styles.css +++ b/courses/tutorial/ch-3/src/styles.css @@ -1 +1 @@ -/* You can add global styles to this file, and also import other style files */ \ No newline at end of file +/* You can add global styles to this file, and also import other style files */ diff --git a/courses/tutorial/ch-3/src/test.ts b/courses/tutorial/ch-3/src/test.ts index 7727c8e..be44dc5 100644 --- a/courses/tutorial/ch-3/src/test.ts +++ b/courses/tutorial/ch-3/src/test.ts @@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test'; import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -14,21 +19,14 @@ declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; - -Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') -]) - // First, initialize the Angular testing environment. - .then(([testing, testingBrowser]) => { - testing.getTestBed().initTestEnvironment( - testingBrowser.BrowserDynamicTestingModule, - testingBrowser.platformBrowserDynamicTesting() - ); - }) - // Then we find all the tests. - .then(() => require.context('./', true, /\.spec\.ts/)) - // And load the modules. - .then(context => context.keys().map(context)) - // Finally, start Karma to run the tests. - .then(__karma__.start, __karma__.error); +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +let context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/courses/tutorial/ch-3/src/tsconfig.json b/courses/tutorial/ch-3/src/tsconfig.json index 9b4c84c..1cf713a 100644 --- a/courses/tutorial/ch-3/src/tsconfig.json +++ b/courses/tutorial/ch-3/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/courses/tutorial/ch-3/tslint.json b/courses/tutorial/ch-3/tslint.json index 29f24ee..640d02c 100644 --- a/courses/tutorial/ch-3/tslint.json +++ b/courses/tutorial/ch-3/tslint.json @@ -16,7 +16,6 @@ "spaces" ], "label-position": true, - "label-undefined": true, "max-line-length": [ true, 140 @@ -39,7 +38,6 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, @@ -49,8 +47,6 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, - "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, @@ -93,12 +89,8 @@ "check-type" ], - "directive-selector-prefix": [true, "app"], - "component-selector-prefix": [true, "app"], - "directive-selector-name": [true, "camelCase"], - "component-selector-name": [true, "kebab-case"], - "directive-selector-type": [true, "attribute"], - "component-selector-type": [true, "element"], + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -107,6 +99,9 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true } } diff --git a/courses/tutorial/ch-4/.editorconfig b/courses/tutorial/ch-4/.editorconfig index f352616..6e87a00 100644 --- a/courses/tutorial/ch-4/.editorconfig +++ b/courses/tutorial/ch-4/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/courses/tutorial/ch-4/.gitignore b/courses/tutorial/ch-4/.gitignore index fccc4d9..fe6f8a7 100644 --- a/courses/tutorial/ch-4/.gitignore +++ b/courses/tutorial/ch-4/.gitignore @@ -6,15 +6,22 @@ # dependencies /node_modules -/bower_components # IDEs and editors /.idea .project .classpath +.c9/ *.launch .settings/ +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + # misc /.sass-cache /connect.lock diff --git a/courses/tutorial/ch-4/angular-cli.json b/courses/tutorial/ch-4/angular-cli.json index 1362bad..a349493 100644 --- a/courses/tutorial/ch-4/angular-cli.json +++ b/courses/tutorial/ch-4/angular-cli.json @@ -1,13 +1,16 @@ { "project": { - "version": "1.0.0-beta.15", + "version": "1.0.0-beta.24", "name": "hello-angular" }, "apps": [ { "root": "src", "outDir": "dist", - "assets": "assets", + "assets": [ + "assets", + "favicon.ico" + ], "index": "index.html", "main": "main.ts", "test": "test.ts", @@ -39,6 +42,18 @@ }, "defaults": { "styleExt": "css", - "prefixInterfaces": false + "prefixInterfaces": false, + "inline": { + "style": false, + "template": false + }, + "spec": { + "class": false, + "component": true, + "directive": true, + "module": false, + "pipe": true, + "service": true + } } } diff --git a/courses/tutorial/ch-4/e2e/app.e2e-spec.ts b/courses/tutorial/ch-4/e2e/app.e2e-spec.ts index 89e4124..2e5557b 100644 --- a/courses/tutorial/ch-4/e2e/app.e2e-spec.ts +++ b/courses/tutorial/ch-4/e2e/app.e2e-spec.ts @@ -1,10 +1,10 @@ -import { Ch1Page } from './app.po'; +import { HelloAngularPage } from './app.po'; -describe('ch-1 App', function() { - let page: Ch1Page; +describe('hello-angular App', function() { + let page: HelloAngularPage; beforeEach(() => { - page = new Ch1Page(); + page = new HelloAngularPage(); }); it('should display message saying app works', () => { diff --git a/courses/tutorial/ch-4/e2e/app.po.ts b/courses/tutorial/ch-4/e2e/app.po.ts index 42a4dd3..0cf8138 100644 --- a/courses/tutorial/ch-4/e2e/app.po.ts +++ b/courses/tutorial/ch-4/e2e/app.po.ts @@ -1,6 +1,6 @@ -import { browser, element, by } from 'protractor/globals'; +import { browser, element, by } from 'protractor'; -export class Ch1Page { +export class HelloAngularPage { navigateTo() { return browser.get('/'); } diff --git a/courses/tutorial/ch-4/karma.conf.js b/courses/tutorial/ch-4/karma.conf.js index e28922a..1f2613a 100644 --- a/courses/tutorial/ch-4/karma.conf.js +++ b/courses/tutorial/ch-4/karma.conf.js @@ -17,6 +17,9 @@ module.exports = function (config) { preprocessors: { './src/test.ts': ['angular-cli'] }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, remapIstanbulReporter: { reports: { html: 'coverage', @@ -27,7 +30,9 @@ module.exports = function (config) { config: './angular-cli.json', environment: 'dev' }, - reporters: ['progress', 'karma-remap-istanbul'], + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/courses/tutorial/ch-4/package.json b/courses/tutorial/ch-4/package.json index a14e6ff..9b6c36c 100644 --- a/courses/tutorial/ch-4/package.json +++ b/courses/tutorial/ch-4/package.json @@ -1,44 +1,47 @@ { - "name": "ch-1", + "name": "hello-angular", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { + "ng": "ng", "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", - "pree2e": "webdriver-manager update", + "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", + "@angular/common": "^2.3.1", + "@angular/compiler": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", + "@angular/http": "^2.3.1", + "@angular/platform-browser": "^2.3.1", + "@angular/platform-browser-dynamic": "^2.3.1", + "@angular/router": "^3.3.1", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { - "@types/jasmine": "^2.2.30", - "angular-cli": "1.0.0-beta.15", - "codelyzer": "~0.0.26", - "jasmine-core": "2.4.1", + "@angular/compiler-cli": "^2.3.1", + "@types/jasmine": "2.5.38", + "@types/node": "^6.0.42", + "angular-cli": "1.0.0-beta.24", + "codelyzer": "~2.0.0-beta.1", + "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "protractor": "4.0.5", + "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "3.13.0", - "typescript": "2.0.2" + "tslint": "^4.0.2", + "typescript": "~2.0.3" } } diff --git a/courses/tutorial/ch-4/protractor.conf.js b/courses/tutorial/ch-4/protractor.conf.js index 169743b..ffded70 100644 --- a/courses/tutorial/ch-4/protractor.conf.js +++ b/courses/tutorial/ch-4/protractor.conf.js @@ -1,5 +1,5 @@ // Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js +// https://github.com/angular/protractor/blob/master/lib/config.ts /*global jasmine */ var SpecReporter = require('jasmine-spec-reporter'); diff --git a/courses/tutorial/ch-4/src/app/app.component.spec.ts b/courses/tutorial/ch-4/src/app/app.component.spec.ts index 98a2280..3ad633e 100644 --- a/courses/tutorial/ch-4/src/app/app.component.spec.ts +++ b/courses/tutorial/ch-4/src/app/app.component.spec.ts @@ -3,13 +3,14 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; -describe('App: Ch1', () => { +describe('AppComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }); + TestBed.compileComponents(); }); it('should create the app', async(() => { diff --git a/courses/tutorial/ch-4/src/index.html b/courses/tutorial/ch-4/src/index.html index 2490203..5b22106 100644 --- a/courses/tutorial/ch-4/src/index.html +++ b/courses/tutorial/ch-4/src/index.html @@ -2,12 +2,11 @@ - Hello Angular + HelloAngular - Loading... diff --git a/courses/tutorial/ch-4/src/main.ts b/courses/tutorial/ch-4/src/main.ts index 5c3c520..ac78a71 100644 --- a/courses/tutorial/ch-4/src/main.ts +++ b/courses/tutorial/ch-4/src/main.ts @@ -3,7 +3,7 @@ import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { AppModule } from './app/'; +import { AppModule } from './app/app.module'; if (environment.production) { enableProdMode(); diff --git a/courses/tutorial/ch-4/src/styles.css b/courses/tutorial/ch-4/src/styles.css index e50a47e..90d4ee0 100644 --- a/courses/tutorial/ch-4/src/styles.css +++ b/courses/tutorial/ch-4/src/styles.css @@ -1 +1 @@ -/* You can add global styles to this file, and also import other style files */ \ No newline at end of file +/* You can add global styles to this file, and also import other style files */ diff --git a/courses/tutorial/ch-4/src/test.ts b/courses/tutorial/ch-4/src/test.ts index 7727c8e..be44dc5 100644 --- a/courses/tutorial/ch-4/src/test.ts +++ b/courses/tutorial/ch-4/src/test.ts @@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test'; import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -14,21 +19,14 @@ declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; - -Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') -]) - // First, initialize the Angular testing environment. - .then(([testing, testingBrowser]) => { - testing.getTestBed().initTestEnvironment( - testingBrowser.BrowserDynamicTestingModule, - testingBrowser.platformBrowserDynamicTesting() - ); - }) - // Then we find all the tests. - .then(() => require.context('./', true, /\.spec\.ts/)) - // And load the modules. - .then(context => context.keys().map(context)) - // Finally, start Karma to run the tests. - .then(__karma__.start, __karma__.error); +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +let context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/courses/tutorial/ch-4/src/tsconfig.json b/courses/tutorial/ch-4/src/tsconfig.json index 9b4c84c..1cf713a 100644 --- a/courses/tutorial/ch-4/src/tsconfig.json +++ b/courses/tutorial/ch-4/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/courses/tutorial/ch-4/tslint.json b/courses/tutorial/ch-4/tslint.json index 29f24ee..640d02c 100644 --- a/courses/tutorial/ch-4/tslint.json +++ b/courses/tutorial/ch-4/tslint.json @@ -16,7 +16,6 @@ "spaces" ], "label-position": true, - "label-undefined": true, "max-line-length": [ true, 140 @@ -39,7 +38,6 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, @@ -49,8 +47,6 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, - "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, @@ -93,12 +89,8 @@ "check-type" ], - "directive-selector-prefix": [true, "app"], - "component-selector-prefix": [true, "app"], - "directive-selector-name": [true, "camelCase"], - "component-selector-name": [true, "kebab-case"], - "directive-selector-type": [true, "attribute"], - "component-selector-type": [true, "element"], + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -107,6 +99,9 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true } } diff --git a/courses/tutorial/ch-5/.editorconfig b/courses/tutorial/ch-5/.editorconfig index f352616..6e87a00 100644 --- a/courses/tutorial/ch-5/.editorconfig +++ b/courses/tutorial/ch-5/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/courses/tutorial/ch-5/.gitignore b/courses/tutorial/ch-5/.gitignore index fccc4d9..fe6f8a7 100644 --- a/courses/tutorial/ch-5/.gitignore +++ b/courses/tutorial/ch-5/.gitignore @@ -6,15 +6,22 @@ # dependencies /node_modules -/bower_components # IDEs and editors /.idea .project .classpath +.c9/ *.launch .settings/ +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + # misc /.sass-cache /connect.lock diff --git a/courses/tutorial/ch-5/angular-cli.json b/courses/tutorial/ch-5/angular-cli.json index 1362bad..a349493 100644 --- a/courses/tutorial/ch-5/angular-cli.json +++ b/courses/tutorial/ch-5/angular-cli.json @@ -1,13 +1,16 @@ { "project": { - "version": "1.0.0-beta.15", + "version": "1.0.0-beta.24", "name": "hello-angular" }, "apps": [ { "root": "src", "outDir": "dist", - "assets": "assets", + "assets": [ + "assets", + "favicon.ico" + ], "index": "index.html", "main": "main.ts", "test": "test.ts", @@ -39,6 +42,18 @@ }, "defaults": { "styleExt": "css", - "prefixInterfaces": false + "prefixInterfaces": false, + "inline": { + "style": false, + "template": false + }, + "spec": { + "class": false, + "component": true, + "directive": true, + "module": false, + "pipe": true, + "service": true + } } } diff --git a/courses/tutorial/ch-5/e2e/app.e2e-spec.ts b/courses/tutorial/ch-5/e2e/app.e2e-spec.ts index 89e4124..2e5557b 100644 --- a/courses/tutorial/ch-5/e2e/app.e2e-spec.ts +++ b/courses/tutorial/ch-5/e2e/app.e2e-spec.ts @@ -1,10 +1,10 @@ -import { Ch1Page } from './app.po'; +import { HelloAngularPage } from './app.po'; -describe('ch-1 App', function() { - let page: Ch1Page; +describe('hello-angular App', function() { + let page: HelloAngularPage; beforeEach(() => { - page = new Ch1Page(); + page = new HelloAngularPage(); }); it('should display message saying app works', () => { diff --git a/courses/tutorial/ch-5/e2e/app.po.ts b/courses/tutorial/ch-5/e2e/app.po.ts index 42a4dd3..0cf8138 100644 --- a/courses/tutorial/ch-5/e2e/app.po.ts +++ b/courses/tutorial/ch-5/e2e/app.po.ts @@ -1,6 +1,6 @@ -import { browser, element, by } from 'protractor/globals'; +import { browser, element, by } from 'protractor'; -export class Ch1Page { +export class HelloAngularPage { navigateTo() { return browser.get('/'); } diff --git a/courses/tutorial/ch-5/karma.conf.js b/courses/tutorial/ch-5/karma.conf.js index e28922a..1f2613a 100644 --- a/courses/tutorial/ch-5/karma.conf.js +++ b/courses/tutorial/ch-5/karma.conf.js @@ -17,6 +17,9 @@ module.exports = function (config) { preprocessors: { './src/test.ts': ['angular-cli'] }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, remapIstanbulReporter: { reports: { html: 'coverage', @@ -27,7 +30,9 @@ module.exports = function (config) { config: './angular-cli.json', environment: 'dev' }, - reporters: ['progress', 'karma-remap-istanbul'], + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/courses/tutorial/ch-5/package.json b/courses/tutorial/ch-5/package.json index a14e6ff..9b6c36c 100644 --- a/courses/tutorial/ch-5/package.json +++ b/courses/tutorial/ch-5/package.json @@ -1,44 +1,47 @@ { - "name": "ch-1", + "name": "hello-angular", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { + "ng": "ng", "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", - "pree2e": "webdriver-manager update", + "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", + "@angular/common": "^2.3.1", + "@angular/compiler": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", + "@angular/http": "^2.3.1", + "@angular/platform-browser": "^2.3.1", + "@angular/platform-browser-dynamic": "^2.3.1", + "@angular/router": "^3.3.1", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { - "@types/jasmine": "^2.2.30", - "angular-cli": "1.0.0-beta.15", - "codelyzer": "~0.0.26", - "jasmine-core": "2.4.1", + "@angular/compiler-cli": "^2.3.1", + "@types/jasmine": "2.5.38", + "@types/node": "^6.0.42", + "angular-cli": "1.0.0-beta.24", + "codelyzer": "~2.0.0-beta.1", + "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "protractor": "4.0.5", + "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "3.13.0", - "typescript": "2.0.2" + "tslint": "^4.0.2", + "typescript": "~2.0.3" } } diff --git a/courses/tutorial/ch-5/protractor.conf.js b/courses/tutorial/ch-5/protractor.conf.js index 169743b..ffded70 100644 --- a/courses/tutorial/ch-5/protractor.conf.js +++ b/courses/tutorial/ch-5/protractor.conf.js @@ -1,5 +1,5 @@ // Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js +// https://github.com/angular/protractor/blob/master/lib/config.ts /*global jasmine */ var SpecReporter = require('jasmine-spec-reporter'); diff --git a/courses/tutorial/ch-5/src/app/app.component.spec.ts b/courses/tutorial/ch-5/src/app/app.component.spec.ts index 98a2280..3ad633e 100644 --- a/courses/tutorial/ch-5/src/app/app.component.spec.ts +++ b/courses/tutorial/ch-5/src/app/app.component.spec.ts @@ -3,13 +3,14 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; -describe('App: Ch1', () => { +describe('AppComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }); + TestBed.compileComponents(); }); it('should create the app', async(() => { diff --git a/courses/tutorial/ch-5/src/index.html b/courses/tutorial/ch-5/src/index.html index 2490203..5b22106 100644 --- a/courses/tutorial/ch-5/src/index.html +++ b/courses/tutorial/ch-5/src/index.html @@ -2,12 +2,11 @@ - Hello Angular + HelloAngular - Loading... diff --git a/courses/tutorial/ch-5/src/main.ts b/courses/tutorial/ch-5/src/main.ts index 5c3c520..ac78a71 100644 --- a/courses/tutorial/ch-5/src/main.ts +++ b/courses/tutorial/ch-5/src/main.ts @@ -3,7 +3,7 @@ import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { AppModule } from './app/'; +import { AppModule } from './app/app.module'; if (environment.production) { enableProdMode(); diff --git a/courses/tutorial/ch-5/src/styles.css b/courses/tutorial/ch-5/src/styles.css index e50a47e..90d4ee0 100644 --- a/courses/tutorial/ch-5/src/styles.css +++ b/courses/tutorial/ch-5/src/styles.css @@ -1 +1 @@ -/* You can add global styles to this file, and also import other style files */ \ No newline at end of file +/* You can add global styles to this file, and also import other style files */ diff --git a/courses/tutorial/ch-5/src/test.ts b/courses/tutorial/ch-5/src/test.ts index 7727c8e..be44dc5 100644 --- a/courses/tutorial/ch-5/src/test.ts +++ b/courses/tutorial/ch-5/src/test.ts @@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test'; import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -14,21 +19,14 @@ declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; - -Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') -]) - // First, initialize the Angular testing environment. - .then(([testing, testingBrowser]) => { - testing.getTestBed().initTestEnvironment( - testingBrowser.BrowserDynamicTestingModule, - testingBrowser.platformBrowserDynamicTesting() - ); - }) - // Then we find all the tests. - .then(() => require.context('./', true, /\.spec\.ts/)) - // And load the modules. - .then(context => context.keys().map(context)) - // Finally, start Karma to run the tests. - .then(__karma__.start, __karma__.error); +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +let context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/courses/tutorial/ch-5/src/tsconfig.json b/courses/tutorial/ch-5/src/tsconfig.json index 9b4c84c..1cf713a 100644 --- a/courses/tutorial/ch-5/src/tsconfig.json +++ b/courses/tutorial/ch-5/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/courses/tutorial/ch-5/tslint.json b/courses/tutorial/ch-5/tslint.json index 29f24ee..640d02c 100644 --- a/courses/tutorial/ch-5/tslint.json +++ b/courses/tutorial/ch-5/tslint.json @@ -16,7 +16,6 @@ "spaces" ], "label-position": true, - "label-undefined": true, "max-line-length": [ true, 140 @@ -39,7 +38,6 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, @@ -49,8 +47,6 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, - "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, @@ -93,12 +89,8 @@ "check-type" ], - "directive-selector-prefix": [true, "app"], - "component-selector-prefix": [true, "app"], - "directive-selector-name": [true, "camelCase"], - "component-selector-name": [true, "kebab-case"], - "directive-selector-type": [true, "attribute"], - "component-selector-type": [true, "element"], + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -107,6 +99,9 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true } } diff --git a/courses/tutorial/ch-6/.editorconfig b/courses/tutorial/ch-6/.editorconfig index f352616..6e87a00 100644 --- a/courses/tutorial/ch-6/.editorconfig +++ b/courses/tutorial/ch-6/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/courses/tutorial/ch-6/.gitignore b/courses/tutorial/ch-6/.gitignore index fccc4d9..fe6f8a7 100644 --- a/courses/tutorial/ch-6/.gitignore +++ b/courses/tutorial/ch-6/.gitignore @@ -6,15 +6,22 @@ # dependencies /node_modules -/bower_components # IDEs and editors /.idea .project .classpath +.c9/ *.launch .settings/ +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + # misc /.sass-cache /connect.lock diff --git a/courses/tutorial/ch-6/README.md b/courses/tutorial/ch-6/README.md index 9f4438d..9d85915 100644 --- a/courses/tutorial/ch-6/README.md +++ b/courses/tutorial/ch-6/README.md @@ -49,16 +49,20 @@ export class HeroesComponent { import { Component } from '@angular/core'; @Component({ selector: 'app-root', - template: ` -

{{title}}

- - ` + templateUrl: './app.component.html' }) export class AppComponent { title = 'Tour of Heroes'; } ``` +`src/app/app.component.html` ファイルも新しく作成し、次のようにテンプレートを記述します。 + +```html +

{{title}}

+ +``` + `HeroesComponent` に切り出したヒーロー一覧を、 `` タグで表示しています。 `AppComponent` を作成したら、 `AppModule` の `declarations` を更新して、必要なコンポーネントを登録します。 @@ -134,12 +138,10 @@ imports: [ `AppComponent` のテンプレートを更新します。 -```ts -template: ` -

{{title}}

- Heroes - - ` +```html +

{{title}}

+Heroes + ``` `routerLink` も `RouterModule` から提供されるディレクティブのひとつです。 diff --git a/courses/tutorial/ch-6/angular-cli.json b/courses/tutorial/ch-6/angular-cli.json index 1362bad..a349493 100644 --- a/courses/tutorial/ch-6/angular-cli.json +++ b/courses/tutorial/ch-6/angular-cli.json @@ -1,13 +1,16 @@ { "project": { - "version": "1.0.0-beta.15", + "version": "1.0.0-beta.24", "name": "hello-angular" }, "apps": [ { "root": "src", "outDir": "dist", - "assets": "assets", + "assets": [ + "assets", + "favicon.ico" + ], "index": "index.html", "main": "main.ts", "test": "test.ts", @@ -39,6 +42,18 @@ }, "defaults": { "styleExt": "css", - "prefixInterfaces": false + "prefixInterfaces": false, + "inline": { + "style": false, + "template": false + }, + "spec": { + "class": false, + "component": true, + "directive": true, + "module": false, + "pipe": true, + "service": true + } } } diff --git a/courses/tutorial/ch-6/e2e/app.e2e-spec.ts b/courses/tutorial/ch-6/e2e/app.e2e-spec.ts index 89e4124..2e5557b 100644 --- a/courses/tutorial/ch-6/e2e/app.e2e-spec.ts +++ b/courses/tutorial/ch-6/e2e/app.e2e-spec.ts @@ -1,10 +1,10 @@ -import { Ch1Page } from './app.po'; +import { HelloAngularPage } from './app.po'; -describe('ch-1 App', function() { - let page: Ch1Page; +describe('hello-angular App', function() { + let page: HelloAngularPage; beforeEach(() => { - page = new Ch1Page(); + page = new HelloAngularPage(); }); it('should display message saying app works', () => { diff --git a/courses/tutorial/ch-6/e2e/app.po.ts b/courses/tutorial/ch-6/e2e/app.po.ts index 42a4dd3..0cf8138 100644 --- a/courses/tutorial/ch-6/e2e/app.po.ts +++ b/courses/tutorial/ch-6/e2e/app.po.ts @@ -1,6 +1,6 @@ -import { browser, element, by } from 'protractor/globals'; +import { browser, element, by } from 'protractor'; -export class Ch1Page { +export class HelloAngularPage { navigateTo() { return browser.get('/'); } diff --git a/courses/tutorial/ch-6/karma.conf.js b/courses/tutorial/ch-6/karma.conf.js index e28922a..1f2613a 100644 --- a/courses/tutorial/ch-6/karma.conf.js +++ b/courses/tutorial/ch-6/karma.conf.js @@ -17,6 +17,9 @@ module.exports = function (config) { preprocessors: { './src/test.ts': ['angular-cli'] }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, remapIstanbulReporter: { reports: { html: 'coverage', @@ -27,7 +30,9 @@ module.exports = function (config) { config: './angular-cli.json', environment: 'dev' }, - reporters: ['progress', 'karma-remap-istanbul'], + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/courses/tutorial/ch-6/package.json b/courses/tutorial/ch-6/package.json index a14e6ff..9b6c36c 100644 --- a/courses/tutorial/ch-6/package.json +++ b/courses/tutorial/ch-6/package.json @@ -1,44 +1,47 @@ { - "name": "ch-1", + "name": "hello-angular", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { + "ng": "ng", "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", - "pree2e": "webdriver-manager update", + "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", + "@angular/common": "^2.3.1", + "@angular/compiler": "^2.3.1", + "@angular/core": "^2.3.1", + "@angular/forms": "^2.3.1", + "@angular/http": "^2.3.1", + "@angular/platform-browser": "^2.3.1", + "@angular/platform-browser-dynamic": "^2.3.1", + "@angular/router": "^3.3.1", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { - "@types/jasmine": "^2.2.30", - "angular-cli": "1.0.0-beta.15", - "codelyzer": "~0.0.26", - "jasmine-core": "2.4.1", + "@angular/compiler-cli": "^2.3.1", + "@types/jasmine": "2.5.38", + "@types/node": "^6.0.42", + "angular-cli": "1.0.0-beta.24", + "codelyzer": "~2.0.0-beta.1", + "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "protractor": "4.0.5", + "protractor": "~4.0.13", "ts-node": "1.2.1", - "tslint": "3.13.0", - "typescript": "2.0.2" + "tslint": "^4.0.2", + "typescript": "~2.0.3" } } diff --git a/courses/tutorial/ch-6/protractor.conf.js b/courses/tutorial/ch-6/protractor.conf.js index 169743b..ffded70 100644 --- a/courses/tutorial/ch-6/protractor.conf.js +++ b/courses/tutorial/ch-6/protractor.conf.js @@ -1,5 +1,5 @@ // Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js +// https://github.com/angular/protractor/blob/master/lib/config.ts /*global jasmine */ var SpecReporter = require('jasmine-spec-reporter'); diff --git a/courses/tutorial/ch-6/src/app/app.component.html b/courses/tutorial/ch-6/src/app/app.component.html new file mode 100644 index 0000000..8edcb54 --- /dev/null +++ b/courses/tutorial/ch-6/src/app/app.component.html @@ -0,0 +1,6 @@ +

{{title}}

+ + \ No newline at end of file diff --git a/courses/tutorial/ch-6/src/app/app.component.spec.ts b/courses/tutorial/ch-6/src/app/app.component.spec.ts new file mode 100644 index 0000000..3ad633e --- /dev/null +++ b/courses/tutorial/ch-6/src/app/app.component.spec.ts @@ -0,0 +1,34 @@ +/* tslint:disable:no-unused-variable */ + +import { TestBed, async } from '@angular/core/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + AppComponent + ], + }); + TestBed.compileComponents(); + }); + + it('should create the app', async(() => { + let fixture = TestBed.createComponent(AppComponent); + let app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + })); + + it(`should have as title 'app works!'`, async(() => { + let fixture = TestBed.createComponent(AppComponent); + let app = fixture.debugElement.componentInstance; + expect(app.title).toEqual('app works!'); + })); + + it('should render title in a h1 tag', async(() => { + let fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + let compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector('h1').textContent).toContain('app works!'); + })); +}); diff --git a/courses/tutorial/ch-6/src/app/app.component.ts b/courses/tutorial/ch-6/src/app/app.component.ts index ec3f333..0e311bf 100644 --- a/courses/tutorial/ch-6/src/app/app.component.ts +++ b/courses/tutorial/ch-6/src/app/app.component.ts @@ -1,14 +1,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-root', - template: ` -

{{title}}

- - - `, + templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { diff --git a/courses/tutorial/ch-6/src/app/heroes/heroes.component.html b/courses/tutorial/ch-6/src/app/heroes/heroes.component.html index 27bfc9a..e9da55e 100644 --- a/courses/tutorial/ch-6/src/app/heroes/heroes.component.html +++ b/courses/tutorial/ch-6/src/app/heroes/heroes.component.html @@ -4,4 +4,9 @@

My Heroes

{{hero.id}} {{hero.name}} - \ No newline at end of file +
+

+ {{selectedHero.name | uppercase}} is my hero +

+ +
\ No newline at end of file diff --git a/courses/tutorial/ch-6/src/index.html b/courses/tutorial/ch-6/src/index.html index 2490203..5b22106 100644 --- a/courses/tutorial/ch-6/src/index.html +++ b/courses/tutorial/ch-6/src/index.html @@ -2,12 +2,11 @@ - Hello Angular + HelloAngular - Loading... diff --git a/courses/tutorial/ch-6/src/main.ts b/courses/tutorial/ch-6/src/main.ts index 5c3c520..ac78a71 100644 --- a/courses/tutorial/ch-6/src/main.ts +++ b/courses/tutorial/ch-6/src/main.ts @@ -3,7 +3,7 @@ import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { AppModule } from './app/'; +import { AppModule } from './app/app.module'; if (environment.production) { enableProdMode(); diff --git a/courses/tutorial/ch-6/src/styles.css b/courses/tutorial/ch-6/src/styles.css index 82897ab..90d4ee0 100644 --- a/courses/tutorial/ch-6/src/styles.css +++ b/courses/tutorial/ch-6/src/styles.css @@ -1,23 +1 @@ -/* Master Styles */ -h1 { - color: #369; - font-family: Arial, Helvetica, sans-serif; - font-size: 250%; -} -h2, h3 { - color: #444; - font-family: Arial, Helvetica, sans-serif; - font-weight: lighter; -} -body { - margin: 2em; -} -body, input[text], button { - color: #888; - font-family: Cambria, Georgia; -} -/* . . . */ -/* everywhere else */ -* { - font-family: Arial, Helvetica, sans-serif; -} +/* You can add global styles to this file, and also import other style files */ diff --git a/courses/tutorial/ch-6/src/test.ts b/courses/tutorial/ch-6/src/test.ts index 7727c8e..be44dc5 100644 --- a/courses/tutorial/ch-6/src/test.ts +++ b/courses/tutorial/ch-6/src/test.ts @@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test'; import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; @@ -14,21 +19,14 @@ declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; - -Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') -]) - // First, initialize the Angular testing environment. - .then(([testing, testingBrowser]) => { - testing.getTestBed().initTestEnvironment( - testingBrowser.BrowserDynamicTestingModule, - testingBrowser.platformBrowserDynamicTesting() - ); - }) - // Then we find all the tests. - .then(() => require.context('./', true, /\.spec\.ts/)) - // And load the modules. - .then(context => context.keys().map(context)) - // Finally, start Karma to run the tests. - .then(__karma__.start, __karma__.error); +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +let context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/courses/tutorial/ch-6/src/tsconfig.json b/courses/tutorial/ch-6/src/tsconfig.json index 9b4c84c..1cf713a 100644 --- a/courses/tutorial/ch-6/src/tsconfig.json +++ b/courses/tutorial/ch-6/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/courses/tutorial/ch-6/tslint.json b/courses/tutorial/ch-6/tslint.json index 29f24ee..640d02c 100644 --- a/courses/tutorial/ch-6/tslint.json +++ b/courses/tutorial/ch-6/tslint.json @@ -16,7 +16,6 @@ "spaces" ], "label-position": true, - "label-undefined": true, "max-line-length": [ true, 140 @@ -39,7 +38,6 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, @@ -49,8 +47,6 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, - "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, @@ -93,12 +89,8 @@ "check-type" ], - "directive-selector-prefix": [true, "app"], - "component-selector-prefix": [true, "app"], - "directive-selector-name": [true, "camelCase"], - "component-selector-name": [true, "kebab-case"], - "directive-selector-type": [true, "attribute"], - "component-selector-type": [true, "element"], + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -107,6 +99,9 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true } }