Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 140 additions & 152 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,187 +1,175 @@
# Angular QuickStart Source
[![Build Status][travis-badge]][travis-badge-url]

This repository holds the TypeScript source code of the [angular.io quickstart](https://angular.io/docs/ts/latest/quickstart.html),
the foundation for most of the documentation samples and potentially a good starting point for your application.
This repository holds the TypeScript source code of the [angular.io quickstart](https://angular.io/docs/ts/latest/quickstart.html)—the foundation for most of the Kendo UI for Angular documentation samples and potentially a good starting point for your application.

It's been extended with testing support so you can start writing tests immediately.
It has 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**
> * 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.
> * 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 Pull Requests (PR).

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.
## Table of Contents

## Updating to a newer version of the Quickstart Repo
* [Version Upgrade of the Repo](#version-upgrade-of-the-repo)
* [Prerequisites](#prerequisites)
* [Creating New Projects with the QuickStart](#creating-new-projects-with-the-quickstart)
* [Deleting Non-Essential Files](#deleting-non-essential-files)
* [Creating New Git Repos](#creating-new-git-repos)
* [Installing NPM Packages](#installing-npm-packages)
* [NPM Scripts](#npm-scripts)
* [Testing](#testing)
* [Unit Tests](#unit-tests)
* [E2E Tests](#e2e-tests)

From time to time the QuickStart will add be enhanced with support for new features or to reflect
changes to the [official Style Guide](https://angular.io/docs/ts/latest/guide/style-guide.html).
## Version Upgrade of the Repo

You can update your existing project to an up-to-date QuickStart by following these instructions:
- Create a new project using the [instructions below](#create-a-new-project-based-on-the-quickstart)
- Copy the code you have in your project's `main.ts` file onto `src/app/main.ts` in the new project
- Copy your old `app` folder into `src/app`
- Delete `src/app/main.ts` if you have one (we now use `src/main.ts` instead)
- Copy your old `index.html`, `styles.css` and `tsconfig.json` into `src/`
- Install all your third party dependencies
- Copy your old `e2e/` folder into `e2e/`
- Copy over any other files you added to your project
- Copy your old `.git` folder into your new project's root
From time to time the QuickStart is enhanced to reflect the support for new features or the changes in the [official Angular Style Guide](https://angular.io/docs/ts/latest/guide/style-guide.html).

To update your existing project to an up-to-date QuickStart:

1. Create a new project by using the [instructions below](#create-a-new-project-based-on-the-quickstart).
1. Copy the code you have in the `main.ts` file of your project onto `src/app/main.ts` in the new project.
1. Copy your old `app` folder into `src/app`.
1. Delete `src/app/main.ts` if you have such a file—Kendo UI for Angular now uses `src/main.ts` instead.
1. Copy your old `index.html`, `styles.css`, and `tsconfig.json` into `src/`.
1. Install all your third-party dependencies.
1. Copy your old `e2e/` folder into `e2e/`.
1. Copy over any other files you added to your project.
1. Copy your old `.git` folder into the root of your new project.

Now you can continue working on the new project.

## Prerequisites

Node.js and npm are essential to Angular development.

<a href="https://docs.npmjs.com/getting-started/installing-node" target="_blank" title="Installing Node.js and updating npm">
Get it now</a> if it's not already installed on your machine.

**Verify that you are running at least node `v4.x.x` and npm `3.x.x`**
by running `node -v` and `npm -v` in a terminal/console window.
Older versions produce errors.

We recommend [nvm](https://github.com/creationix/nvm) for managing multiple versions of node and npm.

## Create a new project based on the QuickStart

Clone this repo into new project folder (e.g., `my-proj`).
```shell
git clone https://github.com/angular/quickstart my-proj
cd my-proj
```

We have no intention of updating the source on `angular/quickstart`.
Discard the `.git` folder..
```shell
rm -rf .git # OS/X (bash)
rd .git /S/Q # windows
```
### Delete _non-essential_ files (optional)

You can quickly delete the _non-essential_ files that concern testing and QuickStart repository maintenance
(***including all git-related artifacts*** such as the `.git` folder and `.gitignore`!)
by entering the following commands while in the project folder:

##### OS/X (bash)
```shell
xargs rm -rf < non-essential-files.osx.txt
rm src/app/*.spec*.ts
rm non-essential-files.osx.txt
```

##### Windows
```shell
for /f %i in (non-essential-files.txt) do del %i /F /S /Q
rd .git /s /q
rd e2e /s /q
```

### Create a new git repo
You could [start writing code](#start-development) now and throw it all away when you're done.
If you'd rather preserve your work under source control, consider taking the following steps.

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

>Recover the deleted `.gitignore` from the QuickStart repository
if you lost it in the _Delete non-essential files_ step.

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*.
```shell
git remote add origin <repo-address>
git push -u origin master
```
## Install npm packages

> See npm and nvm version notes above

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

```shell
npm install
npm start
```

>Doesn't work in _Bash for Windows_ which does not support servers as of January, 2017.

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`.

You're ready to write your application.

### 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 build` - runs the TypeScript compiler once.
* `npm run build:w` - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them.
* `npm run serve` - runs the [lite-server](https://www.npmjs.com/package/lite-server), a light-weight, static file server, written and maintained by
[John Papa](https://github.com/johnpapa) and
[Christopher Martin](https://github.com/cgmartin)
with excellent support for Angular apps that use routing.

Here are the test related scripts:
* `npm test` - compiles, runs and watches the karma unit tests
* `npm run e2e` - compiles and run protractor e2e tests, written in Typescript (*e2e-spec.ts)
Node.js and NPM are essential to Angular development. If not already installed on your machine, <a href="https://docs.npmjs.com/getting-started/installing-node" target="_blank" title="Installing Node.js and updating npm">get it now</a>.

## Testing
> * Verify that you are running at least node `v4.x.x` and npm `3.x.x` by running `node -v` and `npm -v` in a terminal or console window. Previous versions cause errors.

For managing multiple versions of Node.js and NPM, use the [Node Version Manager (NVM)](https://github.com/creationix/nvm).

## Creating New Projects with the QuickStart

1. Clone this repo into a new project folder&mdash;for example, `my-proj`.

```shell
git clone https://github.com/angular/quickstart my-proj
cd my-proj
```

1. Discard the `.git` folder because the team will not be updating the source on `angular/quickstart`.

```shell
rm -rf .git # OS/X (bash)
rd .git /S/Q # windows
```

### (Optional) Deleting Non-Essential Files

To quickly delete the non-essential files that concern testing and QuickStart repository maintenance, including all Git-related artifacts such as the `.git` and `.gitignore` flders, enter the following commands while in the project folder:

* OS/X (bash)

```shell
xargs rm -rf < non-essential-files.osx.txt
rm src/app/*.spec*.ts
rm non-essential-files.osx.txt
```

* Windows

```shell
for /f %i in (non-essential-files.txt) do del %i /F /S /Q
rd .git /s /q
rd e2e /s /q
```

### Creating New Git Repos

You can now [start writing code](#start-development) and discard it all away when you are done.

However, if you want to preserve your work under source control, consider taking the following steps:

1. Initialize this project as a *local git repo* and make the first commit:

The QuickStart documentation doesn't discuss testing.
This repo adds both karma/jasmine unit test and protractor end-to-end testing support.
```shell
git init
git add .
git commit -m "Initial commit"
```

These tools are configured for specific conventions described below.
> If you lost the `.gitignore` folder from the QuickStart repository while you deleted the non-essential files, recover it.

*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.*
1. Create a remote repository for this project on the service of your choice.

1. Grab its address&mdash;for example, `https://github.com/<my-org>/my-proj.git`&mdash;and push the local repo to the remote one.

```shell
git remote add origin <repo-address>
git push -u origin master
```

## Installing NPM Packages

> For more information, refer to the [NPM and NVM version notes](#prerequisites) section.

1. To install the NPM packages, use the description in `package.json`. Verify that it works:

```shell
npm install
npm start
```

> As of January 2017, Bash for Windows does not support servers and this approach does not work in it.

1. 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`. Now you are ready to write your application.

### NPM Scripts

The following list captures the most useful commands in NPM scripts that are defined in `package.json`:

* `npm start`&mdash;Runs the compiler and the server at the same time, both in the watch mode.
* `npm run build`&mdash;Runs the TypeScript compiler once.
* `npm run build:w`&mdash;Runs the TypeScript compiler in the watch mode. The process keeps running, awaiting changes to the TypeScript files and re-compiling when it sees them.
* `npm run serve`&mdash;Runs the [lite-server](https://www.npmjs.com/package/lite-server). The lite-server is a light-weight, static file server, which is written and maintained by [John Papa](https://github.com/johnpapa) and [Christopher Martin](https://github.com/cgmartin) and provides excellent support for Angular applications that use routing.

The following list captures the test related scripts:

* `npm test`&mdash;Compiles, runs, and watches the Karma unit tests.
* `npm run e2e`&mdash;Compiles and runs Protractor end-to-end (E2E) tests that are written in Typescript (`*e2e-spec.ts`).

## Testing

The QuickStart documentation does not discuss testing. This repo adds both the Karma or Jasmine unit test and the Protractor end-to-end testing support. These tools are configured for specific conventions that are described below.

> It is unwise and rarely possible to run the application, the unit tests, and the E2E tests at the same time. It is recommended that you shut down one before starting another.

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

Look for the example `src/app/app.component.spec.ts`.
Add more `.spec.ts` files as you wish; we configured karma to find them.
TypeScript unit-tests are usually located in the `src/app` folder. Make sure their filenames end in `.spec.ts`.

1. Look for the `src/app/app.component.spec.ts` example.

Run it with `npm test`
1. Add as many `.spec.ts` files as you wish. The team configured Karma to find them.

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.
1. Run it by using `npm test`. The command first compiles the application, then simultaneously re-compiles and runs the Karma test-runner. Both Karma and the compiler watch for (different) file changes.

Shut it down manually with `Ctrl-C`.
1. Shut it down manually with `Ctrl`+`C`. The test-runner output appears in the terminal window.

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.
You can update your application and your tests in real-time by 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 use the shut-down command (`Ctrl`+`C`) and restart it. No worries&mdash;it is pretty quick.

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

E2E tests are in the `e2e` directory, side by side with the `src` folder.
Their filenames must end in `.e2e-spec.ts`.
E2E tests are located in the `e2e` directory side by side with the `src` folder. Make sure their filenames end in `.e2e-spec.ts`.

Look for the example `e2e/app.e2e-spec.ts`.
Add more `.e2e-spec.js` files as you wish (although one usually suffices for small projects);
we configured Protractor to find them.
1. Look for the `e2e/app.e2e-spec.ts` example.

Thereafter, run them with `npm run e2e`.
1. Add as many `.e2e-spec.js` files as you wish, although for smaller projects one test is usually sufficient. The team configured Protractor to find them.

That command first compiles, then simultaneously starts the `lite-server` at `localhost:8080`
and launches Protractor.
1. Run them by using `npm run e2e`. The command first compiles, then simultaneously starts the lite-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 `./_test-output/protractor-results.txt` file
which is easier to read; this file is excluded from source control.
The passed or failed test results appear at the bottom of the terminal window. A custom reporter (see `protractor.config.js`) generates a `./_test-output/protractor-results.txt` file, which is easier to read. This file is excluded from source control.

Shut it down manually with `Ctrl-C`.
1. Shut it down manually with `Ctrl`+`C`.

[travis-badge]: https://travis-ci.org/angular/quickstart.svg?branch=master
[travis-badge-url]: https://travis-ci.org/angular/quickstart
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@angular/animations": "^4.0.2",
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/core": "~4.0.0",
Expand All @@ -32,18 +33,21 @@
"@angular/platform-browser": "~4.0.0",
"@angular/platform-browser-dynamic": "~4.0.0",
"@angular/router": "~4.0.0",

"@progress/kendo-angular-buttons": "^0.24.0",
"@progress/kendo-angular-l10n": "^0.3.0",
"@progress/kendo-angular-popup": "^0.17.0",
"@progress/kendo-theme-default": "^2.0.0",
"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.8.4"
},
"devDependencies": {
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "~2.1.0",

"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
Expand All @@ -55,7 +59,6 @@
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",

"@types/node": "^6.0.46",
"@types/jasmine": "2.5.36"
},
Expand Down
17 changes: 15 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import { Component } from '@angular/core';

@Component({
selector: 'my-app',
template: `<h1>Hello {{name}}</h1>`,
styleUrls: [
// load the Kendo UI Default theme
'node_modules/@progress/kendo-theme-default/dist/all.css'
],
template: `
<h1>Hello {{name}}!</h1>
<button kendoButton (click)="onButtonClick()" [primary]="true">My Kendo UI Button</button>
`,
})
export class AppComponent { name = 'Angular'; }
export class AppComponent {
name = 'Angular';

onButtonClick() {
this.name = 'Kendo UI';
}
}
Loading