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

Commit fb49cbe

Browse files
Foxandxsswardbell
authored andcommitted
docs(cli-quickstart): add cli 5 min quickstart
closes #1606
1 parent f3205f5 commit fb49cbe

31 files changed

+672
-7
lines changed

gulpfile.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,19 @@ function findAndRunE2eTests(filter, outputFile) {
221221
// fileName; then shut down the example. All protractor output is appended
222222
// to the outputFile.
223223
function runE2eTsTests(appDir, outputFile) {
224-
// start the app
225-
var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
226-
var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
224+
// spawn tasks to start the app
225+
var appBuildSpawnInfo;
226+
var appRunSpawnInfo;
227227

228-
return runProtractor(tscRunSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
228+
if (fs.existsSync(path.join(appDir, 'angular-cli.json'))) {
229+
appBuildSpawnInfo = spawnExt('npm', ['run', 'build:cli'], { cwd: appDir });
230+
appRunSpawnInfo = spawnExt('npm', ['run', 'http-server:cli', '--', '-s'], { cwd: appDir });
231+
} else {
232+
appBuildSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
233+
appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
234+
}
235+
236+
return runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
229237
}
230238

231239
function runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="../_protractor/e2e.d.ts" />
2+
describe('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('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,38 @@
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
30+
31+
# angular.io overrides
32+
!angular-cli.json
33+
!angular-cli-build.js
34+
!config/environment.js
35+
!config/karma-test.js
36+
!config/karma.conf.js
37+
!config/protractor.conf.js
38+
!src/typings.d.ts
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|js.map)',
11+
'es6-shim/es6-shim.js',
12+
'reflect-metadata/**/*.+(js|js.map)',
13+
'rxjs/**/*.+(js|js.map)',
14+
'@angular/**/*.+(js|js.map)'
15+
]
16+
});
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"project": {
3+
"version": "1.0.0-beta.5",
4+
"name": "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+
"prefixInterfaces": false
30+
}
31+
}
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,42 @@
1+
module.exports = function (config) {
2+
config.set({
3+
basePath: '..',
4+
frameworks: ['jasmine'],
5+
plugins: [
6+
require('karma-jasmine'),
7+
require('karma-chrome-launcher')
8+
],
9+
customLaunchers: {
10+
// chrome setup for travis CI using chromium
11+
Chrome_travis_ci: {
12+
base: 'Chrome',
13+
flags: ['--no-sandbox']
14+
}
15+
},
16+
files: [
17+
{ pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
18+
{ pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
19+
{ pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
20+
{ pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
21+
{ pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
22+
{ pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
23+
24+
{ pattern: 'config/karma-test-shim.js', included: true, watched: true },
25+
26+
// Distribution folder.
27+
{ pattern: 'dist/**/*', included: false, watched: true }
28+
],
29+
exclude: [
30+
// Vendor packages might include spec files. We don't want to use those.
31+
'dist/vendor/**/*.spec.js'
32+
],
33+
preprocessors: {},
34+
reporters: ['progress'],
35+
port: 9876,
36+
colors: true,
37+
logLevel: config.LOG_INFO,
38+
autoWatch: true,
39+
browsers: ['Chrome'],
40+
singleRun: false
41+
});
42+
};
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,14 @@
1+
import { CliQuickstartPage } from './app.po';
2+
3+
describe('cli-quickstart App', function() {
4+
let page: CliQuickstartPage;
5+
6+
beforeEach(() => {
7+
page = new CliQuickstartPage();
8+
});
9+
10+
it('should display message saying app works', () => {
11+
page.navigateTo();
12+
expect(page.getParagraphText()).toEqual('cli-quickstart works!');
13+
});
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class CliQuickstartPage {
2+
navigateTo() {
3+
return browser.get('/');
4+
}
5+
6+
getParagraphText() {
7+
return element(by.css('cli-quickstart-app h1')).getText();
8+
}
9+
}

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

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,2 @@
1+
<!-- #docregion -->
2+
<h1>{{title}}</h1>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {
2+
beforeEachProviders,
3+
describe,
4+
expect,
5+
it,
6+
inject
7+
} from '@angular/core/testing';
8+
import { CliQuickstartAppComponent } from '../app/cli-quickstart.component';
9+
10+
beforeEachProviders(() => [CliQuickstartAppComponent]);
11+
12+
describe('App: CliQuickstart', () => {
13+
it('should create the app',
14+
inject([CliQuickstartAppComponent], (app: CliQuickstartAppComponent) => {
15+
expect(app).toBeTruthy();
16+
}));
17+
18+
it('should have as title \'cli-quickstart works!\'',
19+
inject([CliQuickstartAppComponent], (app: CliQuickstartAppComponent) => {
20+
expect(app.title).toEqual('cli-quickstart works!');
21+
}));
22+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// #docregion import
2+
import { Component } from '@angular/core';
3+
// #enddocregion import
4+
5+
// #docregion metadata
6+
@Component({
7+
moduleId: module.id,
8+
selector: 'cli-quickstart-app',
9+
templateUrl: 'cli-quickstart.component.html',
10+
styleUrls: ['cli-quickstart.component.css']
11+
})
12+
// #enddocregion metadata
13+
// #docregion title, class
14+
export class CliQuickstartAppComponent {
15+
title = 'My First Angular 2 App';
16+
}
17+
// #enddocregion title, class
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 * from './environment';
2+
export * from './cli-quickstart.component';

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

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

0 commit comments

Comments
 (0)