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

docs(cli-quickstart): add cli 5 min quickstart #1606

Closed
wants to merge 1 commit 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 @@ -223,11 +223,19 @@ function findAndRunE2eTests(filter, outputFile) {
// fileName; then shut down the example. All protractor output is appended
// to the outputFile.
function runE2eTsTests(appDir, 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;

return runProtractor(tscRunSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
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(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
}

function runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile) {
Expand Down
11 changes: 11 additions & 0 deletions public/docs/_examples/cli-quickstart/e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference path="../_protractor/e2e.d.ts" />
describe('cli-quickstart App', () => {
beforeEach(() => {
return browser.get('/');
})

it('should display message saying app works', () => {
var pageTitle = element(by.css('cli-quickstart-app h1')).getText()
expect(pageTitle).toEqual('My First Angular 2 App');
});
});
38 changes: 38 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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

# angular.io overrides
!angular-cli.json
!angular-cli-build.js
!config/environment.js
!config/karma-test.js
!config/karma.conf.js
!config/protractor.conf.js
!src/typings.d.ts
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|js.map)',
'es6-shim/es6-shim.js',
'reflect-metadata/**/*.+(js|js.map)',
'rxjs/**/*.+(js|js.map)',
'@angular/**/*.+(js|js.map)'
]
});
};
31 changes: 31 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,31 @@
{
"project": {
"version": "1.0.0-beta.5",
"name": "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",
"prefixInterfaces": false
}
}
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
};
42 changes: 42 additions & 0 deletions public/docs/_examples/cli-quickstart/ts/config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = function (config) {
config.set({
basePath: '..',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher')
],
customLaunchers: {
// chrome setup for travis CI using chromium
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
{ pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
{ pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
{ pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
{ pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
{ pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
{ pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },

{ pattern: 'config/karma-test-shim.js', included: true, watched: true },

// Distribution folder.
{ pattern: 'dist/**/*', included: false, watched: true }
],
exclude: [
// Vendor packages might include spec files. We don't want to use those.
'dist/vendor/**/*.spec.js'
],
preprocessors: {},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
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());
}
};
14 changes: 14 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,14 @@
import { CliQuickstartPage } from './app.po';

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

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

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('cli-quickstart works!');
});
});
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 CliQuickstartPage {
navigateTo() {
return browser.get('/');
}

getParagraphText() {
return element(by.css('cli-quickstart-app h1')).getText();
}
}
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,22 @@
import {
beforeEachProviders,
describe,
expect,
it,
inject
} from '@angular/core/testing';
import { CliQuickstartAppComponent } from '../app/cli-quickstart.component';

beforeEachProviders(() => [CliQuickstartAppComponent]);

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

it('should have as title \'cli-quickstart works!\'',
inject([CliQuickstartAppComponent], (app: CliQuickstartAppComponent) => {
expect(app.title).toEqual('cli-quickstart works!');
}));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// #docregion import
import { Component } from '@angular/core';
// #enddocregion import

// #docregion metadata
@Component({
moduleId: module.id,
selector: 'cli-quickstart-app',
templateUrl: 'cli-quickstart.component.html',
styleUrls: ['cli-quickstart.component.css']
})
// #enddocregion metadata
// #docregion title, class
export class CliQuickstartAppComponent {
title = 'My First Angular 2 App';
}
// #enddocregion title, class
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 * from './environment';
export * from './cli-quickstart.component';
Binary file not shown.
32 changes: 32 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,32 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CliQuickstart</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>
<cli-quickstart-app>Loading...</cli-quickstart-app>



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




</body>
</html>
18 changes: 18 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,18 @@
// #docplaster
// #docregion important
import { bootstrap } from '@angular/platform-browser-dynamic';

// #enddocregion important
import { enableProdMode } from '@angular/core';
import { environment } from './app/';
// #docregion important
import { CliQuickstartAppComponent } from './app/';
// #enddocregion important
if (environment.production) {
enableProdMode();
}

// #docregion important

bootstrap(CliQuickstartAppComponent);
// #enddocregion important
Loading