Skip to content

Commit e2671a6

Browse files
committed
Updated seed
1 parent f805d18 commit e2671a6

24 files changed

+183
-537
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2+
typings
23
dist

00-seed/README.md

Lines changed: 19 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,31 @@
1-
# angular2-webpack
1+
# Todo App
22

3-
[![Dependency Status](https://david-dm.org/preboot/angular2-webpack/status.svg)](https://david-dm.org/preboot/angular2-webpack#info=dependencies) [![devDependency Status](https://david-dm.org/preboot/angular2-webpack/dev-status.svg)](https://david-dm.org/preboot/angular2-webpack#info=devDependencies)
4-
[![Join the chat at https://gitter.im/preboot/angular2-webpack](https://badges.gitter.im/preboot/angular2-webpack.svg)](https://gitter.im/preboot/angular2-webpack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3+
![todo](https://cloud.githubusercontent.com/assets/5430091/17703525/a41fe46a-6397-11e6-986f-47f606714bd3.gif)
54

6-
**Note: This guide is following the Angular's [Style Guide](http://angular.io/styleguide) so I will be changing conventions here and there eventually. You are free to use your own conventions with this starter.**
7-
**Note 2: There is no conventions yet for RC5 on the style guide so there will be a future update here for that.**
5+
## Running the app
86

9-
A complete, yet simple, starter for Angular 2 using Webpack.
10-
11-
This seed repo serves as an Angular 2 starter for anyone looking to get up and running with Angular 2 and TypeScript fast. Using [Webpack](http://webpack.github.io/) for building our files and assisting with boilerplate. We're also using Protractor for our end-to-end story and Karma for our unit tests.
12-
* Best practices in file and application organization for [Angular 2](https://angular.io/).
13-
* Ready to go build system using [Webpack](https://webpack.github.io/docs/) for working with [TypeScript](http://www.typescriptlang.org/).
14-
* Testing Angular 2 code with [Jasmine](http://jasmine.github.io/) and [Karma](http://karma-runner.github.io/).
15-
* Coverage with [Istanbul](https://github.com/gotwarlost/istanbul)
16-
* End-to-end Angular 2 code using [Protractor](https://angular.github.io/protractor/).
17-
* Stylesheets with [SASS](http://sass-lang.com/) (not required, it supports regular css too).
18-
* Error reported with [TSLint](http://palantir.github.io/tslint/) and [Codelyzer](https://github.com/mgechev/codelyzer).
19-
* Documentation with [TypeDoc](http://typedoc.io/).
20-
21-
>Warning: Make sure you're using the latest version of Node.js and NPM
22-
23-
[Is Angular 2 Ready Yet?](http://splintercode.github.io/is-angular-2-ready/)
24-
25-
### Quick start
26-
27-
> Clone/Download the repo then edit `app.ts` inside [`/src/app/app.component.ts`](/src/app/app.component.ts)
7+
Clone this repo using:
288

299
```bash
30-
# clone our repo
31-
$ git clone https://github.com/preboot/angular2-webpack.git my-app
32-
33-
# change directory to your app
34-
$ cd my-app
35-
36-
# install the dependencies with npm
37-
$ npm install
38-
39-
# start the server
40-
$ npm start
10+
git clone https://github.com/shansm/todo-app.git
11+
cd todo-app
4112
```
42-
go to [http://localhost:8080](http://localhost:8080) in your browser.
43-
44-
# Table of Contents
45-
46-
* [Getting Started](#getting-started)
47-
* [Dependencies](#dependencies)
48-
* [Installing](#installing)
49-
* [Developing](#developing)
50-
* [Testing](#testing)
51-
* [Production](#production)
52-
* [Documentation](#documentation)
53-
* [Frequently asked questions](#faq)
54-
* [TypeScript](#typescript)
55-
* [License](#license)
56-
57-
# Getting Started
58-
59-
## Dependencies
6013

61-
What you need to run this app:
62-
* `node` and `npm` (Use [NVM](https://github.com/creationix/nvm))
63-
* Ensure you're running Node (`v5.x.x`+) and NPM (`3.x.x`+)
14+
Install all dependencies with:
6415

65-
## Installing
66-
67-
* `fork` this repo
68-
* `clone` your fork
69-
* `npm install` to install all dependencies
70-
71-
## Developing
72-
73-
After you have installed all dependencies you can now start developing with:
74-
75-
* `npm start`
16+
```bash
17+
npm i
18+
```
7619

77-
It will start a local server using `webpack-dev-server` which will watch, build (in-memory), and reload for you. The application can be checked at `http://localhost:8080`.
20+
Now you'll need a backend API. I recommend [json-server](https://github.com/typicode/json-server) along with [todos-list](https://github.com/shansm/todos-list).
7821

79-
As an alternative, you can work using Hot Module Replacement (HMR):
22+
Once the backend is up and running you can now run this app with:
8023

81-
* `npm run start:hmr`
24+
```bash
25+
npm start
26+
```
8227

83-
And you are all set! You can now modify your components on the fly without having to reload the entire page.
28+
It will start a local server using `webpack-dev-server` and then head over to `http://localhost:8080`.
8429

8530
## Testing
8631

@@ -91,66 +36,6 @@ And you are all set! You can now modify your components on the fly without havin
9136

9237
#### 2. End-to-End Tests (aka. e2e, integration)
9338

94-
* single run:
95-
* in a tab, *if not already running!*: `npm start`
96-
* in a new tab: `npm run webdriver-start`
97-
* in another new tab: `npm run e2e`
98-
* interactive mode:
99-
* instead of the last command above, you can run: `npm run e2e-live`
100-
* when debugging or first writing test suites, you may find it helpful to try out Protractor commands without starting up the entire test suite. You can do this with the element explorer.
101-
* you can learn more about [Protractor Interactive Mode here](https://github.com/angular/protractor/blob/master/docs/debugging.md#testing-out-protractor-interactively)
102-
103-
## Production
104-
105-
To build your application, run:
106-
107-
* `npm run build`
108-
109-
You can now go to `/dist` and deploy that to your server!
110-
111-
## Documentation
112-
113-
You can generate api docs (using [TypeDoc](http://typedoc.io/)) for your code with the following:
114-
115-
* `npm run docs`
116-
117-
# FAQ
118-
119-
#### Do I need to add script / link tags into index.html ?
120-
121-
No, Webpack will add all the needed Javascript bundles as script tags and all the CSS files as link tags. The advantage is that you don't need to modify the index.html every time you build your solution to update the hashes.
122-
123-
#### How to include external angular 2 libraries ?
124-
125-
It's simple, just install the lib via npm and import it in your code when you need it. Don't forget that you need to configure some external libs in the [bootstrap](https://github.com/preboot/angular2-webpack/blob/master/src/main.ts) of your application.
126-
127-
#### How to include external css files such as bootstrap.css ?
128-
129-
Just install the lib and import the css files in [vendor.ts](https://github.com/preboot/angular2-webpack/blob/master/src/vendor.ts). For example this is how to do it with bootstrap:
130-
131-
```sh
132-
npm install bootstrap@next --save
133-
```
134-
135-
And in [vendor.ts](https://github.com/preboot/angular2-webpack/blob/master/src/vendor.ts) add the following:
136-
137-
```ts
138-
import 'bootstrap/dist/css/bootstrap.css';
139-
```
140-
141-
# TypeScript
142-
143-
> To take full advantage of TypeScript with autocomplete you would have to use an editor with the correct TypeScript plugins.
144-
145-
## Use a TypeScript-aware editor
146-
147-
We have good experience using these editors:
148-
149-
* [Visual Studio Code](https://code.visualstudio.com/)
150-
* [Webstorm 11+](https://www.jetbrains.com/webstorm/download/)
151-
* [Atom](https://atom.io/) with [TypeScript plugin](https://atom.io/packages/atom-typescript)
152-
* [Sublime Text](http://www.sublimetext.com/3) with [Typescript-Sublime-Plugin](https://github.com/Microsoft/Typescript-Sublime-plugin#installation)
153-
154-
# License
155-
156-
[MIT](/LICENSE)
39+
* in a tab, *if not already running!*: `npm start`
40+
* in a new tab: `npm run webdriver-start`
41+
* in another new tab: `npm run e2e`

00-seed/karma-shim.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
Error.stackTraceLimit = Infinity;
22

3-
require('core-js/client/shim');
3+
require('es6-shim');
44
require('reflect-metadata');
55

66
require('ts-helpers');
77

88
require('zone.js/dist/zone');
99
require('zone.js/dist/long-stack-trace-zone');
10-
require('zone.js/dist/proxy');
11-
require('zone.js/dist/sync-test');
12-
require('zone.js/dist/jasmine-patch');
1310
require('zone.js/dist/async-test');
1411
require('zone.js/dist/fake-async-test');
12+
require('zone.js/dist/sync-test');
13+
require('zone.js/dist/proxy'); // since zone.js 0.6.15
14+
require('zone.js/dist/jasmine-patch'); // put here since zone.js 0.6.14
1515

1616
/*
1717
Ok, this is kinda crazy. We can use the the context method on

00-seed/karma.conf.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ var path = require('path');
22

33
var webpackConfig = require('./webpack.config');
44

5-
var ENV = process.env.npm_lifecycle_event;
6-
var isTestWatch = ENV === 'test-watch';
7-
85
module.exports = function (config) {
96
var _config = {
107

@@ -37,14 +34,35 @@ module.exports = function (config) {
3734
stats: 'errors-only'
3835
},
3936

37+
coverageReporter: {
38+
dir: 'coverage/',
39+
reporters: [{
40+
type: 'json',
41+
dir: 'coverage',
42+
subdir: 'json',
43+
file: 'coverage-final.json'
44+
}]
45+
},
46+
47+
remapIstanbulReporter: {
48+
src: 'coverage/json/coverage-final.json',
49+
reports: {
50+
lcovonly: 'coverage/json/lcov.info',
51+
html: 'coverage/html',
52+
'text': null
53+
},
54+
timeoutNotCreated: 1000, // default value
55+
timeoutNoMoreFiles: 1000 // default value
56+
},
57+
4058
webpackServer: {
4159
noInfo: true // please don't spam the console when running in karma!
4260
},
4361

4462
// test results reporter to use
4563
// possible values: 'dots', 'progress', 'mocha'
4664
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
47-
reporters: ["mocha"],
65+
reporters: ["mocha", "coverage", "karma-remap-istanbul"],
4866

4967
// web server port
5068
port: 9876,
@@ -61,27 +79,13 @@ module.exports = function (config) {
6179

6280
// start these browsers
6381
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
64-
browsers: isTestWatch ? ['Chrome'] : ['PhantomJS'],
82+
browsers: ['PhantomJS'], // you can also use Chrome
6583

6684
// Continuous Integration mode
6785
// if true, Karma captures browsers, runs the tests and exits
6886
singleRun: true
6987
};
7088

71-
if (!isTestWatch) {
72-
_config.reporters.push("coverage");
73-
74-
_config.coverageReporter = {
75-
dir: 'coverage/',
76-
reporters: [{
77-
type: 'json',
78-
dir: 'coverage',
79-
subdir: 'json',
80-
file: 'coverage-final.json'
81-
}]
82-
};
83-
}
84-
8589
config.set(_config);
8690

8791
};

00-seed/package.json

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@
88
"clean-start": "npm run clean-install && npm start",
99
"watch": "webpack --watch --progress --profile",
1010
"build": "rimraf dist && webpack --progress --profile --bail",
11-
"server": "webpack-dashboard -- webpack-dev-server --inline --port 8080",
11+
"server": "webpack-dev-server --inline --progress --port 8080",
1212
"webdriver-update": "webdriver-manager update",
1313
"webdriver-start": "webdriver-manager start",
1414
"lint": "tslint --force \"src/**/*.ts\"",
1515
"e2e": "protractor",
1616
"e2e-live": "protractor --elementExplorer",
1717
"pretest": "npm run lint",
1818
"test": "karma start",
19-
"posttest": "remap-istanbul -i coverage/json/coverage-final.json -o coverage/html -t html",
2019
"test-watch": "karma start --no-single-run --auto-watch",
2120
"ci": "npm run e2e && npm run test",
2221
"docs": "typedoc --options typedoc.json src/app/app.component.ts",
2322
"start": "npm run server",
24-
"start:hmr": "npm run server -- --hot",
25-
"postinstall": "npm run webdriver-update"
23+
"postinstall": "npm run webdriver-update && typings install"
2624
},
2725
"dependencies": {
2826
"@angular/common": "2.0.0",
@@ -33,34 +31,31 @@
3331
"@angular/platform-browser": "2.0.0",
3432
"@angular/platform-browser-dynamic": "2.0.0",
3533
"@angular/router": "3.0.0",
36-
"core-js": "^2.4.1",
34+
"angular2-in-memory-web-api": "0.0.15",
35+
"bootstrap": "^4.0.0-alpha.4",
36+
"es6-shim": "^0.35.0",
3737
"reflect-metadata": "^0.1.3",
3838
"rxjs": "5.0.0-beta.12",
3939
"zone.js": "^0.6.21"
4040
},
4141
"devDependencies": {
42-
"@angularclass/hmr": "^1.0.1",
43-
"@angularclass/hmr-loader": "^1.0.0",
44-
"@types/core-js": "^0.9.0",
45-
"@types/jasmine": "^2.2.29",
46-
"@types/node": "^6.0.38",
47-
"@types/protractor": "^1.5.16",
48-
"@types/selenium-webdriver": "2.44.26",
4942
"angular2-template-loader": "^0.4.0",
5043
"autoprefixer": "^6.3.2",
51-
"awesome-typescript-loader": "^2.2.4",
5244
"codelyzer": "0.0.26",
45+
"concurrently": "^2.0.0",
5346
"copy-webpack-plugin": "^3.0.0",
5447
"css-loader": "^0.23.0",
5548
"extract-text-webpack-plugin": "^1.0.1",
5649
"file-loader": "^0.9.0",
5750
"html-loader": "^0.4.0",
5851
"html-webpack-plugin": "^2.8.1",
5952
"istanbul-instrumenter-loader": "^0.2.0",
53+
"jade": "^1.11.0",
54+
"jade-loader": "^0.8.0",
6055
"jasmine-core": "^2.3.4",
6156
"jasmine-spec-reporter": "^2.4.0",
6257
"json-loader": "^0.5.3",
63-
"karma": "1.1.2",
58+
"karma": "1.1.1",
6459
"karma-chrome-launcher": "^1.0.1",
6560
"karma-coverage": "^1.0.0",
6661
"karma-jasmine": "^1.0.2",
@@ -74,28 +69,22 @@
7469
"phantomjs-prebuilt": "^2.1.4",
7570
"postcss-loader": "^0.9.1",
7671
"protractor": "^3.1.1",
72+
"pug": "^0.1.0",
7773
"raw-loader": "0.5.1",
7874
"remap-istanbul": "^0.6.4",
7975
"rimraf": "^2.5.1",
8076
"sass-loader": "^4.0.0",
8177
"shelljs": "^0.7.0",
8278
"style-loader": "^0.13.0",
8379
"ts-helpers": "^1.1.1",
80+
"ts-loader": "^0.8.1",
8481
"tslint": "^3.4.0",
8582
"tslint-loader": "^2.1.0",
8683
"typedoc": "^0.4.4",
87-
"typescript": "2.0.2",
84+
"typescript": "^1.8.0",
85+
"typings": "^1.0.4",
8886
"url-loader": "^0.5.6",
8987
"webpack": "^1.12.13",
90-
"webpack-dashboard": "^0.1.8",
9188
"webpack-dev-server": "^1.14.1"
92-
},
93-
"keywords": [
94-
"angular 2",
95-
"angular2",
96-
"angular 2 webpack",
97-
"angular 2 webpack starter",
98-
"angular 2 webpack seed",
99-
"angular 2 project starter"
100-
]
89+
}
10190
}

00-seed/protractor.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exports.config = {
22
baseUrl: 'http://localhost:8080/',
33

44
specs: [
5-
'src/**/*.e2e-spec.js'
5+
'src/**/*/**/*.e2e-spec.js'
66
],
77
exclude: [],
88

00-seed/src/polyfills.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'core-js/client/shim';
1+
import 'es6-shim';
22
import 'reflect-metadata';
33
require('zone.js/dist/zone');
44

@@ -14,3 +14,4 @@ if (process.env.ENV === 'build') {
1414

1515
require('zone.js/dist/long-stack-trace-zone');
1616
}
17+

0 commit comments

Comments
 (0)