Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 30db72c

Browse files
committed
docs(cli-quickstart): add cli-quickstart chapter
1 parent a595eb8 commit 30db72c

38 files changed

+644
-5
lines changed

gulpfile.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,19 @@ function findAndRunE2eTests(filter) {
167167
// fileName; then shut down the example. All protractor output is appended
168168
// to the outputFile.
169169
function runE2eTsTests(appDir, protractorConfigFilename, outputFile) {
170-
// start the app
171-
var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
172-
var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
170+
// spawn tasks to start the app
171+
var appBuildSpawnInfo;
172+
var appRunSpawnInfo;
173+
174+
if (fs.existsSync(path.join(appDir, 'angular-cli.json'))) {
175+
appBuildSpawnInfo = spawnExt('npm',['run','build:cli'], { cwd: appDir });
176+
appRunSpawnInfo = spawnExt('npm',['run','http-server:cli', '--', '-s' ], { cwd: appDir });
177+
} else {
178+
appBuildSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
179+
appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
180+
}
173181

174-
return runProtractor(tscRunSpawnInfo.promise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
182+
return runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
175183
}
176184

177185
function runProtractor(prepPromise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// gulp run-e2e-tests --filter=cli-quickstart
2+
describe('angular2-cli-quickstart App', () => {
3+
beforeEach(() => {
4+
return browser.get('/');
5+
})
6+
7+
it('should display message saying app works', () => {
8+
var pageTitle = element(by.css('angular2-cli-quickstart-app h1')).getText()
9+
expect(pageTitle).toEqual('My First Angular 2 App');
10+
});
11+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Language: JavaScript
2+
BasedOnStyle: Google
3+
ColumnLimit: 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
7+
# dependencies
8+
/node_modules
9+
/bower_components
10+
11+
# IDEs and editors
12+
/.idea
13+
14+
# misc
15+
/.sass-cache
16+
/connect.lock
17+
/coverage/*
18+
/libpeerconnection.log
19+
npm-debug.log
20+
testem.log
21+
/typings
22+
23+
# e2e
24+
/e2e/*.js
25+
/e2e/*.map
26+
27+
#System Files
28+
.DS_Store
29+
Thumbs.db
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* global require, module */
2+
3+
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
4+
5+
module.exports = function(defaults) {
6+
return new Angular2App(defaults, {
7+
vendorNpmFiles: [
8+
'systemjs/dist/system-polyfills.js',
9+
'systemjs/dist/system.src.js',
10+
'zone.js/dist/*.js',
11+
'es6-shim/es6-shim.js',
12+
'reflect-metadata/*.js',
13+
'rxjs/**/*.js',
14+
'@angular/**/*.js'
15+
]
16+
});
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"project": {
3+
"version": "1.0.0-beta.4",
4+
"name": "angular2-cli-quickstart"
5+
},
6+
"apps": [
7+
{
8+
"main": "src/main.ts",
9+
"tsconfig": "src/tsconfig.json",
10+
"mobile": false
11+
}
12+
],
13+
"addons": [],
14+
"packages": [],
15+
"e2e": {
16+
"protractor": {
17+
"config": "config/protractor.conf.js"
18+
}
19+
},
20+
"test": {
21+
"karma": {
22+
"config": "config/karma.conf.js"
23+
}
24+
},
25+
"defaults": {
26+
"prefix": "app",
27+
"sourceDir": "src",
28+
"styleExt": "css"
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: false
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* jshint node: true */
2+
3+
module.exports = function(environment) {
4+
return {
5+
environment: environment,
6+
baseURL: '/',
7+
locationType: 'auto'
8+
};
9+
};
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*global jasmine */
2+
var SpecReporter = require('jasmine-spec-reporter');
3+
4+
exports.config = {
5+
allScriptsTimeout: 11000,
6+
specs: [
7+
'../e2e/**/*.e2e.ts'
8+
],
9+
capabilities: {
10+
'browserName': 'chrome'
11+
},
12+
directConnect: true,
13+
baseUrl: 'http://localhost:4200/',
14+
framework: 'jasmine',
15+
jasmineNodeOpts: {
16+
showColors: true,
17+
defaultTimeoutInterval: 30000,
18+
print: function() {}
19+
},
20+
useAllAngular2AppRoots: true,
21+
beforeLaunch: function() {
22+
require('ts-node').register({
23+
project: 'e2e'
24+
});
25+
},
26+
onPrepare: function() {
27+
jasmine.getEnv().addReporter(new SpecReporter());
28+
}
29+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Angular2CliQuickstartPage } from './app.po';
2+
3+
describe('angular2-cli-quickstart App', function() {
4+
let page: Angular2CliQuickstartPage;
5+
6+
beforeEach(() => {
7+
page = new Angular2CliQuickstartPage();
8+
});
9+
10+
// #docregion title
11+
it('should display message saying app works', () => {
12+
page.navigateTo();
13+
expect(page.getParagraphText()).toEqual('My First Angular 2 App');
14+
});
15+
// #enddocregion title
16+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class Angular2CliQuickstartPage {
2+
navigateTo() {
3+
return browser.get('/');
4+
}
5+
6+
getParagraphText() {
7+
return element(by.css('angular2-cli-quickstart-app h1')).getText();
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../typings/main.d.ts" />

public/docs/_examples/cli-quickstart/ts/example-config.json

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "angular2-cli-quickstart",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"angular-cli": {},
6+
"scripts": {
7+
"start": "ng server",
8+
"postinstall": "typings install",
9+
"lint": "tslint \"src/**/*.ts\"",
10+
"test": "ng test",
11+
"pree2e": "webdriver-manager update",
12+
"e2e": "protractor"
13+
},
14+
"private": true,
15+
"dependencies": {
16+
"@angular/common": "2.0.0-rc.1",
17+
"@angular/compiler": "2.0.0-rc.1",
18+
"@angular/core": "2.0.0-rc.1",
19+
"@angular/http": "2.0.0-rc.1",
20+
"@angular/platform-browser": "2.0.0-rc.1",
21+
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
22+
"@angular/router": "2.0.0-rc.1",
23+
"es6-shim": "^0.35.0",
24+
"reflect-metadata": "0.1.3",
25+
"rxjs": "5.0.0-beta.6",
26+
"systemjs": "0.19.26",
27+
"zone.js": "^0.6.12"
28+
},
29+
"devDependencies": {
30+
"angular-cli": "^1.0.0-beta.4",
31+
"codelyzer": "0.0.14",
32+
"ember-cli-inject-live-reload": "^1.4.0",
33+
"jasmine-core": "^2.4.1",
34+
"jasmine-spec-reporter": "^2.4.0",
35+
"karma": "^0.13.15",
36+
"karma-chrome-launcher": "^0.2.3",
37+
"karma-jasmine": "^0.3.8",
38+
"protractor": "^3.3.0",
39+
"ts-node": "^0.5.5",
40+
"tslint": "^3.6.0",
41+
"typescript": "^1.8.10",
42+
"typings": "^0.8.1"
43+
}
44+
}

public/docs/_examples/cli-quickstart/ts/public/.gitignore

Whitespace-only changes.

public/docs/_examples/cli-quickstart/ts/public/.npmignore

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* #docregion */
2+
h1 {
3+
color: #369;
4+
font-family: Arial, Helvetica, sans-serif;
5+
font-size: 250%;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>
2+
{{title}}
3+
</h1>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
beforeEachProviders,
3+
describe,
4+
expect,
5+
it,
6+
inject
7+
} from '@angular/core/testing';
8+
import { Angular2CliQuickstartAppComponent } from '../app/angular2-cli-quickstart.component';
9+
10+
beforeEachProviders(() => [Angular2CliQuickstartAppComponent]);
11+
12+
describe('App: Angular2CliQuickstart', () => {
13+
it('should create the app',
14+
inject([Angular2CliQuickstartAppComponent], (app: Angular2CliQuickstartAppComponent) => {
15+
expect(app).toBeTruthy();
16+
}));
17+
18+
// #docregion title
19+
it('should have as title \'My First Angular 2 App\'',
20+
inject([Angular2CliQuickstartAppComponent], (app: Angular2CliQuickstartAppComponent) => {
21+
expect(app.title).toEqual('My First Angular 2 App');
22+
}));
23+
// #enddocregion title
24+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
moduleId: module.id,
5+
selector: 'angular2-cli-quickstart-app',
6+
templateUrl: 'angular2-cli-quickstart.component.html',
7+
styleUrls: ['angular2-cli-quickstart.component.css']
8+
})
9+
// #docregion title
10+
export class Angular2CliQuickstartAppComponent {
11+
title = 'My First Angular 2 App';
12+
}
13+
// #enddocregion title
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// The file for the current environment will overwrite this one during build
2+
// Different environments can be found in config/environment.{dev|prod}.ts
3+
// The build system defaults to the dev environment
4+
5+
export const environment = {
6+
production: false
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {environment} from './environment';
2+
export {Angular2CliQuickstartAppComponent} from './angular2-cli-quickstart.component';

public/docs/_examples/cli-quickstart/ts/src/app/shared/index.ts

Whitespace-only changes.
Binary file not shown.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Angular2CliQuickstart</title>
6+
<base href="/">
7+
8+
{{#unless environment.production}}
9+
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
10+
{{/unless}}
11+
<meta name="viewport" content="width=device-width, initial-scale=1">
12+
<link rel="icon" type="image/x-icon" href="favicon.ico">
13+
</head>
14+
<body>
15+
<angular2-cli-quickstart-app>Loading...</angular2-cli-quickstart-app>
16+
17+
18+
19+
{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
20+
<script>
21+
System.import('system-config.js').then(function () {
22+
System.import('main');
23+
}).catch(console.error.bind(console));
24+
</script>
25+
26+
27+
28+
29+
30+
</body>
31+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { bootstrap } from '@angular/platform-browser-dynamic';
2+
import { enableProdMode } from '@angular/core';
3+
import { Angular2CliQuickstartAppComponent, environment } from './app/';
4+
5+
if (environment.production) {
6+
enableProdMode();
7+
}
8+
9+
bootstrap(Angular2CliQuickstartAppComponent);
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Angular2 Cli Quickstart",
3+
"icons": [
4+
{
5+
"src": "icon.png",
6+
"sizes": "96x96",
7+
"type": "image/png"
8+
}
9+
],
10+
"start_url": "/index.html",
11+
"display": "standalone",
12+
"orientation": "portrait"
13+
}

0 commit comments

Comments
 (0)