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

docs(cli-quickstart): add cli-quickstart chapter #1241

Closed
wants to merge 2 commits into from
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
16 changes: 12 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,19 @@ function findAndRunE2eTests(filter) {
// fileName; then shut down the example. All protractor output is appended
// to the outputFile.
function runE2eTsTests(appDir, protractorConfigFilename, outputFile) {
// start the app
var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
// spawn tasks to start the app
var appBuildSpawnInfo;
var appRunSpawnInfo;

if (fs.existsSync(path.join(appDir, 'angular-cli.json'))) {
appBuildSpawnInfo = spawnExt('npm',['run','build:cli'], { cwd: appDir });
appRunSpawnInfo = spawnExt('npm',['run','http-server:cli', '--', '-s' ], { cwd: appDir });
} else {
appBuildSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
}

return runProtractor(tscRunSpawnInfo.promise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
return runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
}

function runProtractor(prepPromise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile) {
Expand Down
11 changes: 11 additions & 0 deletions public/docs/_examples/cli-quickstart/e2e-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// gulp run-e2e-tests --filter=cli-quickstart
describe('angular2-cli-quickstart App', () => {
beforeEach(() => {
return browser.get('/');
})

it('should display message saying app works', () => {
var pageTitle = element(by.css('angular2-cli-quickstart-app h1')).getText()
expect(pageTitle).toEqual('My First Angular 2 App');
});
});
3 changes: 3 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Language: JavaScript
BasedOnStyle: Google
ColumnLimit: 100
29 changes: 29 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

#System Files
.DS_Store
Thumbs.db
17 changes: 17 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/angular-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* global require, module */

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist/*.js',
'es6-shim/es6-shim.js',
'reflect-metadata/*.js',
'rxjs/**/*.js',
'@angular/**/*.js'
]
});
};
30 changes: 30 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/angular-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"project": {
"version": "1.0.0-beta.4",
"name": "angular2-cli-quickstart"
},
"apps": [
{
"main": "src/main.ts",
"tsconfig": "src/tsconfig.json",
"mobile": false
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "config/protractor.conf.js"
}
},
"test": {
"karma": {
"config": "config/karma.conf.js"
}
},
"defaults": {
"prefix": "app",
"sourceDir": "src",
"styleExt": "css"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: false
};
10 changes: 10 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* jshint node: true */

module.exports = function(environment) {
return {
environment: environment,
baseURL: '/',
locationType: 'auto'
};
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
29 changes: 29 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/config/protractor.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
specs: [
'../e2e/**/*.e2e.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
}
};
16 changes: 16 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/e2e/app.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Angular2CliQuickstartPage } from './app.po';

describe('angular2-cli-quickstart App', function() {
let page: Angular2CliQuickstartPage;

beforeEach(() => {
page = new Angular2CliQuickstartPage();
});

// #docregion title
it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('My First Angular 2 App');
});
// #enddocregion title
});
9 changes: 9 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/e2e/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class Angular2CliQuickstartPage {
navigateTo() {
return browser.get('/');
}

getParagraphText() {
return element(by.css('angular2-cli-quickstart-app h1')).getText();
}
}
1 change: 1 addition & 0 deletions public/docs/_examples/cli-quickstart/ts/e2e/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../typings/main.d.ts" />
45 changes: 45 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/package.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "angular2-cli-quickstart",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng server",
"postinstall": "typings install",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",

"core-js": "^2.4.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.26",
"zone.js": "^0.6.12"
},
"devDependencies": {
"angular-cli": "^1.0.0-beta.5",
"codelyzer": "0.0.14",
"ember-cli-inject-live-reload": "^1.4.0",
"jasmine-core": "^2.4.1",
"jasmine-spec-reporter": "^2.4.0",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.3",
"karma-jasmine": "^0.3.8",
"protractor": "^3.3.0",
"ts-node": "^0.5.5",
"tslint": "^3.6.0",
"typescript": "^1.8.10",
"typings": "^0.8.1"
}
}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* #docregion */
h1 {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: 250%;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>
{{title}}
</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
beforeEachProviders,
describe,
expect,
it,
inject
} from '@angular/core/testing';
import { Angular2CliQuickstartAppComponent } from '../app/angular2-cli-quickstart.component';

beforeEachProviders(() => [Angular2CliQuickstartAppComponent]);

describe('App: Angular2CliQuickstart', () => {
it('should create the app',
inject([Angular2CliQuickstartAppComponent], (app: Angular2CliQuickstartAppComponent) => {
expect(app).toBeTruthy();
}));

// #docregion title
it('should have as title \'My First Angular 2 App\'',
inject([Angular2CliQuickstartAppComponent], (app: Angular2CliQuickstartAppComponent) => {
expect(app.title).toEqual('My First Angular 2 App');
}));
// #enddocregion title
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core';

@Component({
moduleId: module.id,
selector: 'angular2-cli-quickstart-app',
templateUrl: 'angular2-cli-quickstart.component.html',
styleUrls: ['angular2-cli-quickstart.component.css']
})
// #docregion title
export class Angular2CliQuickstartAppComponent {
title = 'My First Angular 2 App';
}
// #enddocregion title
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// The file for the current environment will overwrite this one during build
// Different environments can be found in config/environment.{dev|prod}.ts
// The build system defaults to the dev environment

export const environment = {
production: false
};
2 changes: 2 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/src/app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {environment} from './environment';
export {Angular2CliQuickstartAppComponent} from './angular2-cli-quickstart.component';
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Angular2CliQuickstart</title>
<base href="/">

{{#unless environment.production}}
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
{{/unless}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<angular2-cli-quickstart-app>Loading...</angular2-cli-quickstart-app>



{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
<script>
System.import('system-config.js').then(function () {
System.import('main');
}).catch(console.error.bind(console));
</script>





</body>
</html>
10 changes: 10 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { Angular2CliQuickstartAppComponent, environment } from './app/';

if (environment.production) {
enableProdMode();
}

bootstrap(Angular2CliQuickstartAppComponent);

13 changes: 13 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/src/manifest.webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Angular2 Cli Quickstart",
"icons": [
{
"src": "icon.png",
"sizes": "96x96",
"type": "image/png"
}
],
"start_url": "/index.html",
"display": "standalone",
"orientation": "portrait"
}
Loading