Skip to content

Commit d1bfe33

Browse files
author
linuxlover
committed
Start
0 parents  commit d1bfe33

24 files changed

+1256
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
13+
[*.md]
14+
max_line_length = 0
15+
trim_trailing_whitespace = false
16+
17+
# Indentation override
18+
#[lib/**.js]
19+
#[{package.json,.travis.yml}]
20+
#[**/**.js]

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.idea
2+
typings/**
3+
node_modules
4+
jspm_packages
5+
link-checker-results.txt
6+
**/*npm-debug.log.*
7+
*.js
8+
*.js.map
9+
e2e/**/*.js
10+
e2e/**/*.js.map
11+
_test-output
12+
_temp
13+
14+
!karma*.js
15+
!protractor*.js
16+
!systemjs.config.js
17+
!typings/typings.d.ts
18+
!wallaby.js

CHANGELOG.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<a name="0.2.5"></a>
2+
# 0.2.5 (2016-06-30)
3+
* Angular 2 RC4 version
4+
* Updated new forms and router
5+
6+
<a name="0.2.4"></a>
7+
# 0.2.4 (2016-06-21)
8+
* Angular 2 RC3 version
9+
* Add new forms and router
10+
* Add support for TS e2e tests
11+
12+
<a name="0.2.3"></a>
13+
# 0.2.3 (2016-06-15)
14+
* Angular 2 RC2 version
15+
16+
<a name="0.2.2"></a>
17+
# 0.2.2 (2016-05-21)
18+
* Update to Typings 1.x
19+
20+
<a name="0.2.1"></a>
21+
# 0.2.1 (2016-05-03)
22+
* Angular 2 RC01 version
23+
24+
<a name="0.2.0"></a>
25+
# 0.2.0 (2016-05-02)
26+
* Angular 2 RC0 version
27+
28+
<a name="0.1.17"></a>
29+
# 0.1.17 (2016-04-29)
30+
* update packages
31+
* Angular 2 beta 17
32+
* RxJS 5.0.0-beta.6
33+
* a2-in-memory-web-api 0.1.17
34+
35+
<a name="0.1.16"></a>
36+
# 0.1.16 (2016-04-26)
37+
* update packages
38+
* Angular 2 beta 16
39+
* a2-in-memory-web-api 0.1.6
40+
* protractor 3.3.0
41+
* typings 0.8.1
42+
* zone.js 0.6.12
43+
44+
* added favicon.ico
45+
46+
* testing
47+
- updated wallaby.js and karma.conf.js
48+
- updated app.component.spec.ts
49+
50+
51+
<a name="0.1.15"></a>
52+
# 0.1.15 (2016-04-13)
53+
* Add testing support
54+
* npm scripts
55+
* karma/jasmine
56+
* protractor
57+
58+
* update packages
59+
* Angular 2 beta 15
60+
* lite-server 2.2.0
61+
* systemjs 0.19.26
62+
* typescript 1.8.10
63+
* typings 0.7.12
64+
65+
* add run packages
66+
* a2-in-memory-web-api
67+
68+
* add testing dev-dependency packages
69+
* canonical-path: 0.0.2,
70+
* http-server: ^0.9.0,
71+
* jasmine-core: ~2.4.1,
72+
* karma: ^0.13.22,
73+
* karma-chrome-launcher: ^0.2.3,
74+
* karma-cli: ^0.1.2,
75+
* karma-htmlfile-reporter: ^0.2.2,
76+
* karma-jasmine: ^0.3.8,
77+
* protractor: ^3.2.2,
78+
* rimraf: ^2.5.2
79+
80+
<a name="0.1.14"></a>
81+
# 0.1.14 (2016-04-07)
82+
* update packages
83+
* Angular 2 beta 14
84+
* lite-server 2.2.0
85+
* typings 0.7.12
86+
87+
<a name="0.1.13"></a>
88+
# 0.1.13 (2016-03-31)
89+
* update packages
90+
* Angular 2 beta 13
91+
92+
<a name="0.1.12"></a>
93+
# 0.1.12 (2016-03-23)
94+
* update packages
95+
* Angular 2 beta 12
96+
* zones 0.6.6
97+
* remove es6-promise because no longer needed.
98+
99+
<a name="0.1.11"></a>
100+
# 0.1.11 (2016-03-18)
101+
* update packages
102+
* Angular 2 beta 11
103+
* zones 0.6.4
104+
* typescript 1.8.9
105+
* typings 0.7.9

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# To build and run with Docker:
2+
#
3+
# $ docker build -t ng2-quickstart .
4+
# $ docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart
5+
#
6+
FROM node:latest
7+
8+
RUN mkdir -p /quickstart /home/nodejs && \
9+
groupadd -r nodejs && \
10+
useradd -r -g nodejs -d /home/nodejs -s /sbin/nologin nodejs && \
11+
chown -R nodejs:nodejs /home/nodejs
12+
13+
WORKDIR /quickstart
14+
COPY package.json typings.json /quickstart/
15+
RUN npm install --unsafe-perm=true
16+
17+
COPY . /quickstart
18+
RUN chown -R nodejs:nodejs /quickstart
19+
USER nodejs
20+
21+
CMD npm start

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2014-2016 Google, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Angular 2 QuickStart Source
2+
3+
This repository holds the TypeScript source code of the [angular.io quickstart](https://angular.io/docs/ts/latest/quickstart.html),
4+
the foundation for most of the documentation samples and potentially a good starting point for your application.
5+
6+
It's been extended with testing support so you can start writing tests immediately.
7+
8+
**This is not the perfect arrangement for your application. It is not designed for production.
9+
It exists primarily to get you started quickly with learning and prototyping in Angular 2**
10+
11+
We are unlikely to accept suggestions about how to grow this QuickStart into something it is not.
12+
Please keep that in mind before posting issues and PRs.
13+
14+
## Prerequisites
15+
16+
Node.js and npm are essential to Angular 2 development.
17+
18+
<a href="https://docs.npmjs.com/getting-started/installing-node" target="_blank" title="Installing Node.js and updating npm">
19+
Get it now</a> if it's not already installed on your machine.
20+
21+
**Verify that you are running at least node `v5.x.x` and npm `3.x.x`**
22+
by running `node -v` and `npm -v` in a terminal/console window.
23+
Older versions produce errors.
24+
25+
We recommend [nvm](https://github.com/creationix/nvm) for managing multiple versions of node and npm.
26+
27+
## Create a new project based on the QuickStart
28+
29+
Clone this repo into new project folder (e.g., `my-proj`).
30+
```bash
31+
git clone https://github.com/angular/quickstart my-proj
32+
cd my-proj
33+
```
34+
35+
We have no intention of updating the source on `angular/quickstart`.
36+
Discard everything "git-like" by deleting the `.git` folder.
37+
```bash
38+
rm -rf .git // non-Windows
39+
rd .git /S/Q // windows
40+
```
41+
42+
### Create a new git repo
43+
You could [start writing code](#start-development) now and throw it all away when you're done.
44+
If you'd rather preserve your work under source control, consider taking the following steps.
45+
46+
Initialize this project as a *local git repo* and make the first commit:
47+
```bash
48+
git init
49+
git add .
50+
git commit -m "Initial commit"
51+
```
52+
53+
Create a *remote repository* for this project on the service of your choice.
54+
55+
Grab its address (e.g. *`https://github.com/<my-org>/my-proj.git`*) and push the *local repo* to the *remote*.
56+
```bash
57+
git remote add origin <repo-address>
58+
git push -u origin master
59+
```
60+
## Install npm packages
61+
62+
> See npm and nvm version notes above
63+
64+
Install the npm packages described in the `package.json` and verify that it works:
65+
66+
**Attention Windows Developers: You must run all of these commands in administrator mode**.
67+
68+
```bash
69+
npm install
70+
npm start
71+
```
72+
73+
> If the `typings` folder doesn't show up after `npm install` please install them manually with:
74+
75+
> `npm run typings -- install`
76+
77+
The `npm start` command first compiles the application,
78+
then simultaneously re-compiles and runs the `lite-server`.
79+
Both the compiler and the server watch for file changes.
80+
81+
Shut it down manually with Ctrl-C.
82+
83+
You're ready to write your application.
84+
85+
### npm scripts
86+
87+
We've captured many of the most useful commands in npm scripts defined in the `package.json`:
88+
89+
* `npm start` - runs the compiler and a server at the same time, both in "watch mode".
90+
* `npm run tsc` - runs the TypeScript compiler once.
91+
* `npm run tsc:w` - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them.
92+
* `npm run lite` - runs the [lite-server](https://www.npmjs.com/package/lite-server), a light-weight, static file server, written and maintained by
93+
[John Papa](https://github.com/johnpapa) and
94+
[Christopher Martin](https://github.com/cgmartin)
95+
with excellent support for Angular apps that use routing.
96+
* `npm run typings` - runs the typings tool.
97+
* `npm run postinstall` - called by *npm* automatically *after* it successfully completes package installation. This script installs the TypeScript definition files this app requires.
98+
Here are the test related scripts:
99+
* `npm test` - compiles, runs and watches the karma unit tests
100+
* `npm run e2e` - run protractor e2e tests, written in JavaScript (*e2e-spec.js)
101+
102+
## Testing
103+
104+
The QuickStart documentation doesn't discuss testing.
105+
This repo adds both karma/jasmine unit test and protractor end-to-end testing support.
106+
107+
These tools are configured for specific conventions described below.
108+
109+
*It is unwise and rarely possible to run the application, the unit tests, and the e2e tests at the same time.
110+
We recommend that you shut down one before starting another.*
111+
112+
### Unit Tests
113+
TypeScript unit-tests are usually in the `app` folder. Their filenames must end in `.spec`.
114+
115+
Look for the example `app/app.component.spec.ts`.
116+
Add more `.spec.ts` files as you wish; we configured karma to find them.
117+
118+
Run it with `npm test`
119+
120+
That command first compiles the application, then simultaneously re-compiles and runs the karma test-runner.
121+
Both the compiler and the karma watch for (different) file changes.
122+
123+
Shut it down manually with Ctrl-C.
124+
125+
Test-runner output appears in the terminal window.
126+
We can update our app and our tests in real-time, keeping a weather eye on the console for broken tests.
127+
Karma is occasionally confused and it is often necessary to shut down its browser or even shut the command down (Ctrl-C) and
128+
restart it. No worries; it's pretty quick.
129+
130+
The `HTML-Reporter` is also wired in. That produces a prettier output; look for it in `~_test-output/tests.html`.
131+
132+
### End-to-end (E2E) Tests
133+
134+
E2E tests are in the `e2e` directory, side by side with the `app` folder.
135+
Their filenames must end in `.e2e-spec.ts`.
136+
137+
Look for the example `e2e/app.e2e-spec.ts`.
138+
Add more `.e2e-spec.js` files as you wish (although one usually suffices for small projects);
139+
we configured protractor to find them.
140+
141+
Thereafter, run them with `npm run e2e`.
142+
143+
That command first compiles, then simultaneously starts the Http-Server at `localhost:8080`
144+
and launches protractor.
145+
146+
The pass/fail test results appear at the bottom of the terminal window.
147+
A custom reporter (see `protractor.config.js`) generates a `./_test-output/protractor-results.txt` file
148+
which is easier to read; this file is excluded from source control.
149+
150+
Shut it down manually with Ctrl-C.

app/app.component.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* tslint:disable:no-unused-variable */
2+
import { AppComponent } from './app.component';
3+
4+
import { async, inject } from '@angular/core/testing';
5+
6+
import { TestComponentBuilder } from '@angular/core/testing';
7+
8+
import { By } from '@angular/platform-browser';
9+
import { provide } from '@angular/core';
10+
import { ViewMetadata } from '@angular/core';
11+
import { PromiseWrapper } from '@angular/core/src/facade/promise';
12+
13+
//////// SPECS /////////////
14+
15+
/// Delete this
16+
describe('Smoke test', () => {
17+
it('should run a passing test', () => {
18+
expect(true).toEqual(true, 'should pass');
19+
});
20+
});
21+
22+
describe('AppComponent with TCB', function () {
23+
24+
it('should instantiate component',
25+
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
26+
27+
tcb.createAsync(AppComponent).then(fixture => {
28+
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
29+
});
30+
})));
31+
32+
it('should have expected <h1> text',
33+
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
34+
35+
tcb.createAsync(AppComponent).then(fixture => {
36+
// fixture.detectChanges(); // would need to resolve a binding but we don't have a binding
37+
38+
let h1 = fixture.debugElement.query(el => el.name === 'h1').nativeElement; // it works
39+
40+
h1 = fixture.debugElement.query(By.css('h1')).nativeElement; // preferred
41+
42+
expect(h1.innerText).toMatch(/angular 2 app/i, '<h1> should say something about "Angular 2 App"');
43+
});
44+
45+
})));
46+
});

app/app.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'my-app',
5+
template: '<h1>My First Angular 2 App</h1>'
6+
})
7+
export class AppComponent { }

0 commit comments

Comments
 (0)