Skip to content

Commit 9c20c32

Browse files
Ismaestroiramos
authored and
iramos
committed
feat(migration): added Angular CLI version
1 parent 2c040c2 commit 9c20c32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1725
-0
lines changed

angular-cli.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"project": {
3+
"version": "1.0.0-beta.24",
4+
"name": "angular-hero-cli"
5+
},
6+
"apps": [
7+
{
8+
"root": "src",
9+
"outDir": "dist",
10+
"assets": [
11+
"assets",
12+
"favicon.ico"
13+
],
14+
"index": "index.html",
15+
"main": "main.ts",
16+
"test": "test.ts",
17+
"tsconfig": "tsconfig.json",
18+
"prefix": "toh",
19+
"mobile": false,
20+
"styles": [
21+
"assets/css/styles.css"
22+
],
23+
"scripts": [],
24+
"environments": {
25+
"source": "environments/environment.ts",
26+
"dev": "environments/environment.ts",
27+
"prod": "environments/environment.prod.ts"
28+
}
29+
}
30+
],
31+
"addons": [],
32+
"packages": [],
33+
"e2e": {
34+
"protractor": {
35+
"config": "./protractor.conf.js"
36+
}
37+
},
38+
"test": {
39+
"karma": {
40+
"config": "./karma.conf.js"
41+
}
42+
},
43+
"defaults": {
44+
"styleExt": "css",
45+
"prefixInterfaces": false,
46+
"inline": {
47+
"style": false,
48+
"template": false
49+
},
50+
"spec": {
51+
"class": false,
52+
"component": true,
53+
"directive": true,
54+
"module": false,
55+
"pipe": true,
56+
"service": true
57+
}
58+
}
59+
}

e2e/app.e2e-spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {AngularTOHPage} from './app.po';
2+
3+
describe('angular-hero-cli App', function () {
4+
let page: AngularTOHPage;
5+
6+
beforeEach(() => {
7+
page = new AngularTOHPage();
8+
});
9+
10+
it('Title', () => {
11+
page.navigateTo();
12+
expect(page.getParagraphText()).toEqual('Tour of Heroes');
13+
});
14+
});

e2e/app.po.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {browser, element, by} from 'protractor';
2+
3+
export class AngularTOHPage {
4+
navigateTo() {
5+
return browser.get('/');
6+
}
7+
8+
getParagraphText() {
9+
return element(by.css('toh-app > h1')).getText();
10+
}
11+
}

e2e/tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"declaration": false,
5+
"emitDecoratorMetadata": true,
6+
"experimentalDecorators": true,
7+
"module": "commonjs",
8+
"moduleResolution": "node",
9+
"outDir": "../dist/out-tsc-e2e",
10+
"sourceMap": true,
11+
"target": "es5",
12+
"typeRoots": [
13+
"../node_modules/@types"
14+
]
15+
}
16+
}

karma.conf.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports = function (config) {
2+
config.set({
3+
basePath: '',
4+
frameworks: ['jasmine', 'angular-cli'],
5+
plugins: [
6+
require('karma-jasmine'),
7+
require('karma-chrome-launcher'),
8+
require('karma-remap-istanbul'),
9+
require('angular-cli/plugins/karma')
10+
],
11+
files: [
12+
{pattern: './src/test.ts', watched: false}
13+
],
14+
preprocessors: {
15+
'./src/test.ts': ['angular-cli']
16+
},
17+
mime: {
18+
'text/x-typescript': ['ts', 'tsx']
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: config.angularCli && config.angularCli.codeCoverage
31+
? ['progress', 'karma-remap-istanbul']
32+
: ['progress'],
33+
port: 9876,
34+
colors: true,
35+
logLevel: config.LOG_INFO,
36+
autoWatch: true,
37+
browsers: ['Chrome'],
38+
singleRun: false
39+
});
40+
};

package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "angular-hero-cli",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"angular-cli": {},
6+
"scripts": {
7+
"start": "npm run server | npm run ng",
8+
"server": "json-server --port 3000 --watch server/db.json --routes server/routes.json",
9+
"ng": "ng serve --proxy-config proxy.conf.json",
10+
"tslint": "tslint \"src/**/*.ts\"; exit 0",
11+
"test": "ng test",
12+
"e2e": "npm run pree2e | protractor",
13+
"pree2e": "webdriver-manager update --standalone false --gecko false"
14+
},
15+
"private": true,
16+
"dependencies": {
17+
"@angular/common": "^2.3.1",
18+
"@angular/compiler": "^2.3.1",
19+
"@angular/core": "^2.3.1",
20+
"@angular/forms": "^2.3.1",
21+
"@angular/http": "^2.3.1",
22+
"@angular/platform-browser": "^2.3.1",
23+
"@angular/platform-browser-dynamic": "^2.3.1",
24+
"@angular/router": "^3.3.1",
25+
"core-js": "^2.4.1",
26+
"json-server": "^0.9.4",
27+
"rxjs": "^5.0.1",
28+
"ts-helpers": "^1.1.1",
29+
"zone.js": "^0.7.2"
30+
},
31+
"devDependencies": {
32+
"@angular/compiler-cli": "^2.3.1",
33+
"@types/jasmine": "2.5.38",
34+
"@types/node": "^6.0.42",
35+
"angular-cli": "1.0.0-beta.24",
36+
"codelyzer": "~2.0.0-beta.1",
37+
"jasmine-core": "2.5.2",
38+
"jasmine-spec-reporter": "2.5.0",
39+
"karma": "1.2.0",
40+
"karma-chrome-launcher": "^2.0.0",
41+
"karma-cli": "^1.0.1",
42+
"karma-jasmine": "^1.0.2",
43+
"karma-remap-istanbul": "^0.2.1",
44+
"protractor": "~4.0.13",
45+
"ts-node": "1.2.1",
46+
"tslint": "^4.0.2",
47+
"typescript": "~2.0.3"
48+
}
49+
}

protractor.conf.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Protractor configuration file, see link for more information
2+
// https://github.com/angular/protractor/blob/master/lib/config.ts
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:3002/',
17+
framework: 'jasmine',
18+
jasmineNodeOpts: {
19+
showColors: true,
20+
defaultTimeoutInterval: 30000,
21+
print: function () {
22+
}
23+
},
24+
useAllAngular2AppRoots: true,
25+
beforeLaunch: function () {
26+
require('ts-node').register({
27+
project: 'e2e'
28+
});
29+
},
30+
onPrepare: function () {
31+
jasmine.getEnv().addReporter(new SpecReporter());
32+
}
33+
};

proxy.conf.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"/api": {
3+
"target": "http://localhost:3000",
4+
"secure": false
5+
}
6+
}

server/db.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"heroesPowers": [
3+
"Really Smart",
4+
"Super Flexible",
5+
"Super Hot",
6+
"Weather Changer"
7+
],
8+
"heroes": [
9+
{
10+
"id": 12,
11+
"name": "Narco",
12+
"power": "Weather Changer",
13+
"alterEgo": "pe"
14+
},
15+
{
16+
"id": 13,
17+
"name": "Bombasto",
18+
"power": "Weather Changer",
19+
"alterEgo": "bombi"
20+
},
21+
{
22+
"id": 14,
23+
"name": "Celeritas",
24+
"power": "Super Hot",
25+
"alterEgo": "cele"
26+
},
27+
{
28+
"id": 15,
29+
"name": "Magneta",
30+
"power": "Really Smart",
31+
"alterEgo": "magne"
32+
},
33+
{
34+
"id": 17,
35+
"name": "Dynama",
36+
"power": "Super Flexible",
37+
"alterEgo": "dy"
38+
},
39+
{
40+
"id": 18,
41+
"name": "Dr IQ",
42+
"power": "Really Smart",
43+
"alterEgo": "iq"
44+
},
45+
{
46+
"id": 19,
47+
"name": "Magma",
48+
"power": "Super Flexible",
49+
"alterEgo": "cold"
50+
},
51+
{
52+
"id": 20,
53+
"name": "Tornado",
54+
"power": "Really Smart",
55+
"alterEgo": "torny"
56+
}
57+
]
58+
}

server/routes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"/api/": "/"
3+
}

src/app/app-routing.module.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {NgModule} from '@angular/core';
2+
import {RouterModule, Routes} from '@angular/router';
3+
4+
import {HeroTopComponent} from './heroes/hero-top/hero-top.component';
5+
6+
const routes: Routes = [
7+
{path: '', redirectTo: '/', pathMatch: 'full'},
8+
{path: '', component: HeroTopComponent}
9+
];
10+
11+
@NgModule({
12+
imports: [
13+
RouterModule.forRoot(routes)
14+
],
15+
exports: [
16+
RouterModule
17+
]
18+
})
19+
20+
export class AppRoutingModule {
21+
}

src/app/app.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>{{title}}</h1>
2+
<toh-nav></toh-nav>
3+
<router-outlet></router-outlet>

src/app/app.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {Component, Inject} from '@angular/core';
2+
3+
import {APP_CONFIG} from './config/app.config';
4+
import {IAppConfig} from './config/iapp.config';
5+
6+
@Component({
7+
selector: 'toh-app',
8+
templateUrl: './app.component.html',
9+
styleUrls: [],
10+
})
11+
12+
export class AppComponent {
13+
title: string;
14+
15+
constructor(@Inject(APP_CONFIG) private appConfig: IAppConfig) {
16+
this.title = this.appConfig.title;
17+
}
18+
}

src/app/app.module.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {NgModule} from '@angular/core';
2+
import {BrowserModule} from '@angular/platform-browser';
3+
import {FormsModule} from '@angular/forms';
4+
import {HttpModule} from '@angular/http';
5+
6+
import {APP_CONFIG, AppConfig} from './config/app.config';
7+
8+
import {AppRoutingModule} from './app-routing.module';
9+
import {SharedModule} from './shared/shared.module';
10+
import {CoreModule} from './core/core.module';
11+
import {HeroesModule} from './heroes/heroes.module';
12+
13+
import {AppComponent} from './app.component';
14+
import {HeroTopComponent} from './heroes/hero-top/hero-top.component';
15+
16+
@NgModule({
17+
imports: [
18+
BrowserModule,
19+
FormsModule,
20+
HttpModule,
21+
AppRoutingModule,
22+
CoreModule,
23+
HeroesModule,
24+
SharedModule
25+
],
26+
declarations: [
27+
AppComponent,
28+
HeroTopComponent
29+
],
30+
providers: [
31+
{provide: APP_CONFIG, useValue: AppConfig}
32+
],
33+
bootstrap: [AppComponent]
34+
})
35+
36+
export class AppModule {
37+
}

0 commit comments

Comments
 (0)