Skip to content

Commit

Permalink
initial uprev to ng2.rc1 -- some issues with ui-router need alpha5
Browse files Browse the repository at this point in the history
  • Loading branch information
earlyster committed May 10, 2016
2 parents 8150d9f + fdf6196 commit 2fc06a3
Show file tree
Hide file tree
Showing 30 changed files with 997 additions and 83 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -0,0 +1 @@
node_modules/
20 changes: 20 additions & 0 deletions .editorconfig
@@ -0,0 +1,20 @@
# http://editorconfig.org
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
trim_trailing_whitespace = false

# Indentation override
#[lib/**.js]
#[{package.json,.travis.yml}]
#[**/**.js]
20 changes: 18 additions & 2 deletions .gitignore
@@ -1,7 +1,23 @@
typings/
node_modules/
.idea
typings/**
node_modules
jspm_packages
link-checker-results.txt
**/*npm-debug.log.*
*.js
*.js.map
<<<<<<< HEAD
*.ipr
*.iml
*.iws
=======
_test-output
_temp

!**/*e2e-spec.js
!karma*.js
!protractor*.js
!systemjs.config.js
!typings/typings.d.ts
!wallaby.js
>>>>>>> fdf619609f2a85940fe1b9a021648b68f8aea822
69 changes: 68 additions & 1 deletion CHANGELOG.md
@@ -1,3 +1,70 @@
<a name="0.2.1"></a>
# 0.2.1 (2016-05-03)
* Angular 2 RC01 version

<a name="0.2.0"></a>
# 0.2.0 (2016-05-02)
* Angular 2 RC0 version

<a name="0.1.17"></a>
# 0.1.17 (2016-04-29)
* update packages
* Angular 2 beta 17
* RxJS 5.0.0-beta.6
* a2-in-memory-web-api 0.1.17

<a name="0.1.16"></a>
# 0.1.16 (2016-04-26)
* update packages
* Angular 2 beta 16
* a2-in-memory-web-api 0.1.6
* protractor 3.3.0
* typings 0.8.1
* zone.js 0.6.12

* added favicon.ico

* testing
- updated wallaby.js and karma.conf.js
- updated app.component.spec.ts


<a name="0.1.15"></a>
# 0.1.15 (2016-04-13)
* Add testing support
* npm scripts
* karma/jasmine
* protractor

* update packages
* Angular 2 beta 15
* lite-server 2.2.0
* systemjs 0.19.26
* typescript 1.8.10
* typings 0.7.12

* add run packages
* a2-in-memory-web-api

* add testing dev-dependency packages
* canonical-path: 0.0.2,
* http-server: ^0.9.0,
* jasmine-core: ~2.4.1,
* karma: ^0.13.22,
* karma-chrome-launcher: ^0.2.3,
* karma-cli: ^0.1.2,
* karma-htmlfile-reporter: ^0.2.2,
* karma-jasmine: ^0.3.8,
* protractor: ^3.2.2,
* rimraf: ^2.5.2

<a name="0.1.14"></a>
# 0.1.14 (2016-04-07)
* update packages
* Angular 2 beta 14
* lite-server 2.2.0
* typings 0.7.12

<a name="0.1.13"></a>
# 0.1.13 (2016-03-31)
* update packages
Expand All @@ -16,4 +83,4 @@
* Angular 2 beta 11
* zones 0.6.4
* typescript 1.8.9
* typings 0.7.9
* typings 0.7.9
21 changes: 21 additions & 0 deletions Dockerfile
@@ -0,0 +1,21 @@
# To build and run with Docker:
#
# $ docker build -t ng2-quickstart .
# $ docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart
#
FROM node:latest

RUN mkdir -p /quickstart /home/nodejs && \
groupadd -r nodejs && \
useradd -r -g nodejs -d /home/nodejs -s /sbin/nologin nodejs && \
chown -R nodejs:nodejs /home/nodejs

WORKDIR /quickstart
COPY package.json typings.json /quickstart/
RUN npm install --unsafe-perm=true

COPY . /quickstart
RUN chown -R nodejs:nodejs /quickstart
USER nodejs

CMD npm start
124 changes: 123 additions & 1 deletion README.md
Expand Up @@ -2,9 +2,22 @@

### Start development

<<<<<<< HEAD
Install the npm packages described in the `package.json` and verify that it works:
=======
It's been extended with testing support so you can start writing tests immediately.

**This is not the perfect arrangement for your application. It is not designed for production.
It exists primarily to get you started quickly with learning and prototyping in Angular 2**

We are unlikely to accept suggestions about how to grow this QuickStart into something it is not.
Please keep that in mind before posting issues and PRs.

## Create a new project based on the QuickStart
>>>>>>> fdf619609f2a85940fe1b9a021648b68f8aea822
```bash
<<<<<<< HEAD
git clone https://github.com/ui-router/quickstart-ng2.git
cd quickstart-ng2
npm install
Expand All @@ -13,6 +26,17 @@ npm start
```

### UI-Router for NG2 quickstart highlights:
=======
git clone https://github.com/angular/quickstart my-proj
cd my-proj
```
We have no intention of updating the source on `angular/quickstart`.
Discard everything "git-like" by deleting the `.git` folder.
```bash
rm -rf .git
```
>>>>>>> fdf619609f2a85940fe1b9a021648b68f8aea822
- We're using npm and systemjs. We added a dependency on latest `ui-router-ng2` in [package.json](https://github.com/ui-router/quickstart-ng2/blob/1.0.2/package.json#L19)
- Import UI-Router classes [directly from `"ui-router-ng2"`](https://github.com/ui-router/quickstart-ng2/blob/1.0.2/app/app.component.ts#L2)
Expand All @@ -23,11 +47,47 @@ npm start
- When bootstrapping: include the `UIROUTER_PROVIDERS` and [define a provider for your `UIRouterConfig`](https://github.com/ui-router/quickstart-ng2/blob/1.0.2/app/_bootstrap/bootstrap.ts#L17-L18)


<<<<<<< HEAD
---

=======
Initialize this project as a *local git repo* and make the first commit:
```bash
git init
git add .
git commit -m "Initial commit"
```

Create a *remote repository* for this project on the service of your choice.

Grab its address (e.g. *`https://github.com/<my-org>/my-proj.git`*) and push the *local repo* to the *remote*.
```bash
git remote add origin <repo-address>
git push -u origin master
```
## Install npm packages

Install the npm packages described in the `package.json` and verify that it works:

**Attention Windows Developers: You must run all of these commands in administrator mode**

```bash
npm install
npm start
```

The `npm start` command first compiles the application,
then simultaneously re-compiles and runs the `lite-server`.
Both the compiler and the server watch for file changes.

Shut it down manually with Ctrl-C.

>>>>>>> fdf619609f2a85940fe1b9a021648b68f8aea822
You're ready to write your application.

Remember the npm scripts in `package.json`:
### npm scripts

We've captured many of the most useful commands in npm scripts defined in the `package.json`:

* `npm start` - runs the compiler and a server at the same time, both in "watch mode".
* `npm run tsc` - runs the TypeScript compiler once.
Expand All @@ -39,5 +99,67 @@ with excellent support for Angular apps that use routing.
* `npm run typings` - runs the typings tool.
* `npm run postinstall` - called by *npm* automatically *after* it successfully completes package installation. This script installs the TypeScript definition files this app requires.

<<<<<<< HEAD
(This repo is forked from https://github.com/angular/quickstart)

=======
Here are the test related scripts:
* `npm test` - compiles, runs and watches the karma unit tests
* `npm run webdriver:update` - ONE TIME update for protractor end-to-end (e2e) tests
* `npm run e2e` - run protractor e2e tests, written in JavaScript (*e2e-spec.js)

## Testing

The QuickStart documentation doesn't discuss testing.
This repo adds both karma/jasmine unit test and protractor end-to-end testing support.

These tools are configured for specific conventions described below.

*It is unwise and rarely possible to run the application, the unit tests, and the e2e tests at the same time.
We recommend that you shut down one before starting another.*

### Unit Tests
TypeScript unit-tests are usually in the `app` folder. Their filenames must end in `.spec`.

Look for the example `app/app.component.spec.ts`.
Add more `.spec.ts` files as you wish; we configured karma to find them.

Run it with `npm test`

That command first compiles the application, then simultaneously re-compiles and runs the karma test-runner.
Both the compiler and the karma watch for (different) file changes.

Shut it down manually with Ctrl-C.

Test-runner output appears in the terminal window.
We can update our app and our tests in real-time, keeping a weather eye on the console for broken tests.
Karma is occasionally confused and it is often necessary to shut down its browser or even shut the command down (Ctrl-C) and
restart it. No worries; it's pretty quick.

The `HTML-Reporter` is also wired in. That produces a prettier output; look for it in `~_test-output/tests.html`.

### End-to-end (E2E) Tests

**BEFORE RUNNING THE FIRST TEST** you must update the Selenium webdriver. Run `npm run webdriver:update`.

E2E tests are usually at the project root, above the `app` folder.
Their filenames must end in `e2e-spec.js`.

E2E tests must be written in JavaScript (the author has not figured out how to write them in TS yet).

Look for the example `e2e-spec.ts` in the root folder.
Add more `e2e-spec.js` files as you wish (although one usually suffices for small projects);
we configured protractor to find them.


Thereafter, run them with `npm run e2e`.

That command first compiles, then simultaneously starts the Http-Server at `localhost:8080`
and launches protractor.

The pass/fail test results appear at the bottom of the terminal window.
A custom reporter (see `protractor.config.js`) generates a `./protractor-results.txt` file
which is easier to read; this file is excluded from source control.

Shut it down manually with Ctrl-C.
>>>>>>> fdf619609f2a85940fe1b9a021648b68f8aea822
6 changes: 3 additions & 3 deletions app/_bootstrap/bootstrap.ts
@@ -1,8 +1,8 @@
import {trace, UIROUTER_PROVIDERS, UiView, UIRouterConfig, Category} from "ui-router-ng2";
import {MyUIRouterConfig} from "./router.config";
import {HTTP_PROVIDERS} from "angular2/http";
import {provide} from "angular2/core";
import {bootstrap} from 'angular2/platform/browser';
import {HTTP_PROVIDERS} from "@angular/http";
import {provide} from "@angular/core";
import {bootstrap} from '@angular/platform-browser-dynamic';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/map';

Expand Down
12 changes: 6 additions & 6 deletions app/_bootstrap/router.config.ts
@@ -1,7 +1,7 @@
import {UIRouter} from "ui-router-ng2/router";
import {INITIAL_STATES} from "../app.states";
import {Http} from "angular2/http";
import {Injectable, Injector} from "angular2/core";
import {Http} from "@angular/http";
import {Injectable, Injector} from "@angular/core";

/**
* This class should is added to the Angular 2 bootstrap() providers and is injected by the
Expand All @@ -21,13 +21,13 @@ export class MyUIRouterConfig {
uiRouter.urlRouterProvider.otherwise(() => uiRouter.stateService.go("app", null, null));

// As of 1.0.0-alpha.2, ui-router only supports ng1-style string-based injection for resolves and transition hooks.
// We're working on more ng2-friendly DI.
// We're working on more ng2-friendly DI.

// In the meantime, you can map global providers to DI strings here. Use the strings
// to inject the service into your resolve or transition hook. (see foo.states.ts)

let rootState = uiRouter.stateRegistry.root();

rootState.resolve['http'] = () => this.injector.get(Http);
}
}
}

0 comments on commit 2fc06a3

Please sign in to comment.