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

closes #1606
This commit is contained in:
Foxandxss
2016-06-05 20:25:16 +02:00
committed by Ward Bell
parent f3205f5beb
commit fb49cbe33f
31 changed files with 672 additions and 7 deletions
@@ -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');
});
});
@@ -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
@@ -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)'
]
});
};
@@ -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
}
}
@@ -0,0 +1,3 @@
export const environment = {
production: false
};
@@ -0,0 +1,10 @@
/* jshint node: true */
module.exports = function(environment) {
return {
environment: environment,
baseURL: '/',
locationType: 'auto'
};
};
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
@@ -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
});
};
@@ -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());
}
};
@@ -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!');
});
});
@@ -0,0 +1,9 @@
export class CliQuickstartPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('cli-quickstart-app h1')).getText();
}
}
@@ -0,0 +1,6 @@
/* #docregion */
h1 {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: 250%;
}
@@ -0,0 +1,2 @@
<!-- #docregion -->
<h1>{{title}}</h1>
@@ -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!');
}));
});
@@ -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
@@ -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
};
@@ -0,0 +1,2 @@
export * from './environment';
export * from './cli-quickstart.component';
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -0,0 +1,35 @@
<!-- #docplaster -->
<!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>
<!-- #docregion body -->
<body>
<cli-quickstart-app>Loading...</cli-quickstart-app>
<!-- #enddocregion body -->
{{#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 -->
<!-- #docregion body -->
</body>
<!-- #enddocregion body -->
</html>
@@ -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
@@ -0,0 +1,54 @@
/***********************************************************************************************
* User Configuration.
**********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
};
/** User packages configuration. */
const packages: any = {
};
////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
* Everything underneath this line is managed by the CLI.
**********************************************************************************************/
const barrels: string[] = [
// Angular specific barrels.
'@angular/core',
'@angular/common',
'@angular/compiler',
'@angular/http',
'@angular/router',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
// Thirdparty barrels.
'rxjs',
// App specific barrels.
'app',
'app/shared',
/** @cli-barrel */
];
const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
cliSystemConfigPackages[barrelName] = { main: 'index' };
});
/** Type declaration for ambient System. */
declare var System: any;
// Apply the CLI SystemJS configuration.
System.config({
map: {
'@angular': 'vendor/@angular',
'rxjs': 'vendor/rxjs',
'main': 'main.js'
},
packages: cliSystemConfigPackages
});
// Apply the user's configuration.
System.config({ map, packages });
@@ -0,0 +1 @@
/// <reference path="../typings/index.d.ts" />