From 4eebd3828e78c78745f409bbe673599f0ca2507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Copin?= Date: Wed, 10 Feb 2016 00:11:31 +0100 Subject: [PATCH] Initial commit --- .editorconfig | 15 ++ .gitignore | 43 ++++ .jshintrc | 25 ++ .travis.yml | 24 ++ CONTRIBUTING.md | 15 ++ LICENSE | 21 ++ README.md | 233 ++++++++++++++++++ appveyor.yml | 35 +++ gulpfile.ts | 80 ++++++ karma.conf.js | 103 ++++++++ package.json | 99 ++++++++ protractor.conf.js | 43 ++++ src/about/components/about.e2e.ts | 20 ++ src/about/components/about.html | 14 ++ src/about/components/about.spec.ts | 51 ++++ src/about/components/about.ts | 23 ++ src/app/components/app.css | 33 +++ src/app/components/app.e2e.ts | 27 ++ src/app/components/app.html | 8 + src/app/components/app.spec.ts | 48 ++++ src/app/components/app.ts | 23 ++ src/assets/img/smile.png | Bin 0 -> 2018 bytes src/assets/main.css | 1 + src/home/components/home.css | 10 + src/home/components/home.e2e.ts | 21 ++ src/home/components/home.html | 10 + src/home/components/home.spec.ts | 31 +++ src/home/components/home.ts | 8 + src/hot_loader_main.ts | 11 + src/index.html | 58 +++++ src/main.ts | 20 ++ src/shared/services/name_list.spec.ts | 16 ++ src/shared/services/name_list.ts | 10 + src/sw.js | 12 + test-main.js | 73 ++++++ tools/config.ts | 126 ++++++++++ tools/manual_typings/angular2-hot-loader.d.ts | 9 + tools/manual_typings/connect-livereload.d.ts | 5 + tools/manual_typings/karma.d.ts | 12 + tools/manual_typings/merge-stream.d.ts | 8 + tools/manual_typings/open.d.ts | 9 + tools/manual_typings/slash.d.ts | 5 + tools/manual_typings/tiny-lr.d.ts | 10 + tools/tasks/build.assets.dev.ts | 12 + tools/tasks/build.assets.prod.ts | 26 ++ tools/tasks/build.bundles.ts | 48 ++++ tools/tasks/build.docs.ts | 29 +++ tools/tasks/build.html_css.prod.ts | 41 +++ tools/tasks/build.index.dev.ts | 37 +++ tools/tasks/build.index.prod.ts | 43 ++++ tools/tasks/build.js.dev.ts | 24 ++ tools/tasks/build.js.prod.ts | 24 ++ tools/tasks/build.test.ts | 22 ++ tools/tasks/check.versions.ts | 35 +++ tools/tasks/clean.ts | 45 ++++ tools/tasks/karma.start.ts | 11 + tools/tasks/npm.ts | 5 + tools/tasks/serve.docs.ts | 7 + tools/tasks/server.start.ts | 7 + tools/tasks/tslint.ts | 21 ++ tools/tasks/watch.dev.ts | 8 + tools/tasks/watch.serve.ts | 12 + tools/tasks/watch.test.ts | 8 + tools/utils.ts | 11 + tools/utils/code_change_tools.ts | 44 ++++ tools/utils/server.ts | 28 +++ tools/utils/tasks_tools.ts | 64 +++++ tools/utils/template_injectables.ts | 27 ++ tools/utils/template_locals.ts | 6 + tsconfig.json | 19 ++ tslint.json | 36 +++ typings.json | 41 +++ 72 files changed, 2189 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 appveyor.yml create mode 100644 gulpfile.ts create mode 100644 karma.conf.js create mode 100644 package.json create mode 100644 protractor.conf.js create mode 100644 src/about/components/about.e2e.ts create mode 100644 src/about/components/about.html create mode 100644 src/about/components/about.spec.ts create mode 100644 src/about/components/about.ts create mode 100644 src/app/components/app.css create mode 100644 src/app/components/app.e2e.ts create mode 100644 src/app/components/app.html create mode 100644 src/app/components/app.spec.ts create mode 100644 src/app/components/app.ts create mode 100644 src/assets/img/smile.png create mode 100644 src/assets/main.css create mode 100644 src/home/components/home.css create mode 100644 src/home/components/home.e2e.ts create mode 100644 src/home/components/home.html create mode 100644 src/home/components/home.spec.ts create mode 100644 src/home/components/home.ts create mode 100644 src/hot_loader_main.ts create mode 100644 src/index.html create mode 100644 src/main.ts create mode 100644 src/shared/services/name_list.spec.ts create mode 100644 src/shared/services/name_list.ts create mode 100644 src/sw.js create mode 100644 test-main.js create mode 100644 tools/config.ts create mode 100644 tools/manual_typings/angular2-hot-loader.d.ts create mode 100644 tools/manual_typings/connect-livereload.d.ts create mode 100644 tools/manual_typings/karma.d.ts create mode 100644 tools/manual_typings/merge-stream.d.ts create mode 100644 tools/manual_typings/open.d.ts create mode 100644 tools/manual_typings/slash.d.ts create mode 100644 tools/manual_typings/tiny-lr.d.ts create mode 100644 tools/tasks/build.assets.dev.ts create mode 100644 tools/tasks/build.assets.prod.ts create mode 100644 tools/tasks/build.bundles.ts create mode 100644 tools/tasks/build.docs.ts create mode 100644 tools/tasks/build.html_css.prod.ts create mode 100644 tools/tasks/build.index.dev.ts create mode 100644 tools/tasks/build.index.prod.ts create mode 100644 tools/tasks/build.js.dev.ts create mode 100644 tools/tasks/build.js.prod.ts create mode 100644 tools/tasks/build.test.ts create mode 100644 tools/tasks/check.versions.ts create mode 100644 tools/tasks/clean.ts create mode 100644 tools/tasks/karma.start.ts create mode 100644 tools/tasks/npm.ts create mode 100644 tools/tasks/serve.docs.ts create mode 100644 tools/tasks/server.start.ts create mode 100644 tools/tasks/tslint.ts create mode 100644 tools/tasks/watch.dev.ts create mode 100644 tools/tasks/watch.serve.ts create mode 100644 tools/tasks/watch.test.ts create mode 100644 tools/utils.ts create mode 100644 tools/utils/code_change_tools.ts create mode 100644 tools/utils/server.ts create mode 100644 tools/utils/tasks_tools.ts create mode 100644 tools/utils/template_injectables.ts create mode 100644 tools/utils/template_locals.ts create mode 100644 tsconfig.json create mode 100644 tslint.json create mode 100644 typings.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f1cc3ad --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..790816d --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +/node_modules/ +/typings/ + +# Users Environment Variables +.lock-wscript +.tsdrc + +#IDE configuration files +.idea +.vscode +*.iml + +dist +dev +docs +lib +test +tools/typings/tsd +tmp diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..0f847e2 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,25 @@ +{ + "bitwise": true, + "immed": true, + "newcap": true, + "noarg": true, + "noempty": true, + "nonew": true, + "trailing": true, + "maxlen": 200, + "boss": true, + "eqnull": true, + "expr": true, + "globalstrict": true, + "laxbreak": true, + "loopfunc": true, + "sub": true, + "undef": true, + "indent": 2, + "unused": true, + + "node": true, + "globals": { + "System": true + } +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..81840f4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: node_js +node_js: +- '4.0' +- '4.1' +- '5.1' +sudo: false +services: +before_install: +- npm --version +- export CHROME_BIN=chromium-browser +- export DISPLAY=:99.0 +- sh -e /etc/init.d/xvfb start +before_script: +notifications: + email: true +after_failure: cat /home/travis/build/mgechev/angular2-seed/npm-debug.log +branches: + only: + - master +env: + global: + # https://github.com/DefinitelyTyped/tsd#tsdrc + # Token has no scope (read-only access to public information) + - TSD_GITHUB_TOKEN=9b18c72997769f3867ef2ec470e626d39661795d diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9fd3342 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +## Submitting Pull Requests + +**Please follow these basic steps to simplify pull request reviews - if you don't you'll probably just be asked to anyway.** + +* Please rebase your branch against the current master +* Run ```npm install``` to make sure your development dependencies are up-to-date +* Please ensure that the test suite passes **and** that code is lint free before submitting a PR by running: + * ```npm test``` +* If you've added new functionality, **please** include tests which validate its behaviour +* Make reference to possible [issues](https://github.com/mgechev/angular2-seed/issues) on PR comment + +## Submitting bug reports + +* Please detail the affected browser(s) and operating system(s) +* Please be sure to state which version of node **and** npm you're using diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..51ae5dc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Minko Gechev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9ab1af5 --- /dev/null +++ b/README.md @@ -0,0 +1,233 @@ +# Introduction + +[![Build Status](https://travis-ci.org/mgechev/angular2-seed.svg?branch=master)](https://travis-ci.org/mgechev/angular2-seed) +[![Join the chat at https://gitter.im/mgechev/angular2-seed](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mgechev/angular2-seed?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) +[![Dependency Status](https://david-dm.org/mgechev/angular2-seed.svg)](https://david-dm.org/mgechev/angular2-seed) +[![devDependency Status](https://david-dm.org/mgechev/angular2-seed/dev-status.svg)](https://david-dm.org/mgechev/angular2-seed#info=devDependencies) + +A seed project for Angular 2 apps. + +It is something similar to the Angular Quick Start but does the entire build with gulp. + +`angular2-seed` provides the following features: + +- Ready to go, statically typed build system using gulp for working with TypeScript. +- Production and development builds. +- Sample unit tests with Jasmine and Karma. +- End-to-end tests with Protractor. +- Development server with Livereload. +- Experimental hot loading support. +- Following the best practices for your application’s structure. +- Manager of your type definitions using [typings](https://github.com/typings/typings). +- Basic Service Worker, which implements "Cache then network strategy". + +# How to start + +**Note** that this seed project requires node v4.x.x or higher and npm 2.14.7. + +You must have `ts-node` installed as global. If you don't, use: + +```bash +npm install -g ts-node +``` + +In order to start the seed use: + + +```bash +git clone --depth 1 https://github.com/mgechev/angular2-seed.git +cd angular2-seed +# install the project's dependencies +npm install +# watches your files and uses livereload by default +npm start +# api document for the app +npm run docs + +# dev build +npm run build.dev +# prod build +npm run build.prod +``` + +## Using the experimental hot loader support + +If you want to try the experimental [hot loading](http://blog.mgechev.com/2015/10/26/angular2-hot-loader-hot-loading-tooling/) support use: + +``` +npm start -- --hot-loader true +``` + +Note that the hot loader is still in experimental phase of development and there are some missing features. If you experience any issues with it report them at [here](https://github.com/mgechev/angular2-hot-loader/issues). + +_Does not rely on any global dependencies._ + +# Table of Content + +- [Introduction](#introduction) +- [How to start](#how-to-start) + * [Using the experimental hot loader support](#using-the-experimental-hot-loader-support) +- [Table of Content](#table-of-content) +- [Configuration](#configuration) +- [How to extend?](#how-to-extend) +- [Running tests](#running-tests) +- [Contributing](#contributing) +- [Examples](#examples) +- [Directory Structure](#directory-structure) +- [Contributors](#contributors) +- [Change Log](#change-log) +- [License](#license) + +# Configuration + +Default application server configuration + +```javascript +var PORT = 5555; +var LIVE_RELOAD_PORT = 4002; +var DOCS_PORT = 4003; +var APP_BASE = '/'; +``` + +Configure at runtime + +```bash +npm start -- --port 8080 --reload-port 4000 --base /my-app/ +``` + +# How to extend? + +Visit the [Wiki page](https://github.com/mgechev/angular2-seed/wiki) of the project. + +# Running tests + +```bash +npm test + +# Debug - In two different shell windows +npm run build.test.watch # 1st window +npm run karma.start # 2nd window + +# e2e (aka. end-to-end, integration) - In three different shell windows +# Make sure you don't have a global instance of Protractor +npm start +# npm run webdriver-update <- You will need to run this the first time +npm run webdriver-start +npm run e2e + +# e2e live mode - Protractor interactive mode +# Instead of last command above, you can use: +npm run e2e-live +``` +You can learn more about [Protractor Interactive Mode here](https://github.com/angular/protractor/blob/master/docs/debugging.md#testing-out-protractor-interactively) + +# Contributing + +Please see the [CONTRIBUTING](https://github.com/mgechev/angular2-seed/blob/master/CONTRIBUTING.md) file for guidelines. + +# Examples + +Forks of this project demonstrate how to extend and integrate with other libraries: + + - https://github.com/justindujardin/angular2-seed - integration with [ng2-material](https://github.com/justindujardin/ng2-material) + - https://github.com/AngularShowcase/angular2-sample-app - sample Angular 2 application + - https://github.com/AngularShowcase/ng2-bootstrap-sbadmin - ng2-bootstrap-sbadmin + - https://github.com/AngularShowcase/angular2-seed-ng2-highcharts - Simple application including a [Highcharts](http://www.highcharts.com) graph. + - https://github.com/tarlepp/angular-sailsjs-boilerplate-frontend-angular2 - Example application for [Sails.js](http://sailsjs.org/) integration. + +# Directory Structure + +``` +. +├── CONTRIBUTING.md +├── LICENSE +├── README.md +├── src +│ ├── about +│ │ └── components +│ │ ├── about.e2e.ts +│ │ ├── about.html +│ │ ├── about.ts +│ │ └── about.spec.ts +│ ├── app +│ │ └── components +│ │ ├── app.css +│ │ ├── app.e2e.ts +│ │ ├── app.html +│ │ ├── app.ts +│ │ └── app.spec.ts +│ ├── assets +│ │ ├── img +│ │ │ └── smile.png +│ │ └── main.css +│ ├── home +│ │ └── components +│ │ ├── home.css +│ │ ├── home.html +│ │ ├── home.ts +│ │ ├── home.e2e.ts +│ │ └── home.spec.ts +│ ├── shared +│ │ └── services +│ │ ├── name_list.ts +│ │ └── name_list.spec.ts +│ ├── hot_loader_main.ts +│ ├── main.ts +│ └── index.html +├── dist +├── test +├── tools +│ ├── manual_typings +│ ├── tasks +│ ├── utils +│ ├── config.ts +│ └── utils.ts +├── appveyor.yml +├── gulpfile.ts +├── karma.conf.js +├── package.json +├── protractor.conf.js +├── test-main.js +├── tsconfig.json +├── tslint.json +└── typings.json +``` + +# Contributors + +[mgechev](https://github.com/mgechev) |[ludohenin](https://github.com/ludohenin) |[tarlepp](https://github.com/tarlepp) |[NathanWalker](https://github.com/NathanWalker) |[jesperronn](https://github.com/jesperronn) |[aboeglin](https://github.com/aboeglin) | +:---: |:---: |:---: |:---: |:---: |:---: | +[mgechev](https://github.com/mgechev) |[ludohenin](https://github.com/ludohenin) |[tarlepp](https://github.com/tarlepp) |[NathanWalker](https://github.com/NathanWalker) |[jesperronn](https://github.com/jesperronn) |[aboeglin](https://github.com/aboeglin) | + +[ryzy](https://github.com/ryzy) |[natarajanmca11](https://github.com/natarajanmca11) |[JakePartusch](https://github.com/JakePartusch) |[larsthorup](https://github.com/larsthorup) |[ouq77](https://github.com/ouq77) |[jerryorta-dev](https://github.com/jerryorta-dev) | +:---: |:---: |:---: |:---: |:---: |:---: | +[ryzy](https://github.com/ryzy) |[natarajanmca11](https://github.com/natarajanmca11) |[JakePartusch](https://github.com/JakePartusch) |[larsthorup](https://github.com/larsthorup) |[ouq77](https://github.com/ouq77) |[jerryorta-dev](https://github.com/jerryorta-dev) | + +[evanplaice](https://github.com/evanplaice) |[LuxDie](https://github.com/LuxDie) |[c-ice](https://github.com/c-ice) |[TuiKiken](https://github.com/TuiKiken) |[juristr](https://github.com/juristr) |[johnjelinek](https://github.com/johnjelinek) | +:---: |:---: |:---: |:---: |:---: |:---: | +[evanplaice](https://github.com/evanplaice) |[LuxDie](https://github.com/LuxDie) |[c-ice](https://github.com/c-ice) |[TuiKiken](https://github.com/TuiKiken) |[juristr](https://github.com/juristr) |[johnjelinek](https://github.com/johnjelinek) | + +[devanp92](https://github.com/devanp92) |[dstockhammer](https://github.com/dstockhammer) |[dwido](https://github.com/dwido) |[briantopping](https://github.com/briantopping) |[koodikindral](https://github.com/koodikindral) |[dszymczuk](https://github.com/dszymczuk) | +:---: |:---: |:---: |:---: |:---: |:---: | +[devanp92](https://github.com/devanp92) |[dstockhammer](https://github.com/dstockhammer) |[dwido](https://github.com/dwido) |[briantopping](https://github.com/briantopping) |[koodikindral](https://github.com/koodikindral) |[dszymczuk](https://github.com/dszymczuk) | + +[justindujardin](https://github.com/justindujardin) |[lihaibh](https://github.com/lihaibh) |[Brooooooklyn](https://github.com/Brooooooklyn) |[tandu](https://github.com/tandu) |[markharding](https://github.com/markharding) |[mjwwit](https://github.com/mjwwit) | +:---: |:---: |:---: |:---: |:---: |:---: | +[justindujardin](https://github.com/justindujardin) |[lihaibh](https://github.com/lihaibh) |[Brooooooklyn](https://github.com/Brooooooklyn) |[tandu](https://github.com/tandu) |[markharding](https://github.com/markharding) |[mjwwit](https://github.com/mjwwit) | + +[robertpenner](https://github.com/robertpenner) |[ocombe](https://github.com/ocombe) |[typekpb](https://github.com/typekpb) |[philipooo](https://github.com/philipooo) |[redian](https://github.com/redian) |[Bigous](https://github.com/Bigous) | +:---: |:---: |:---: |:---: |:---: |:---: | +[robertpenner](https://github.com/robertpenner) |[ocombe](https://github.com/ocombe) |[typekpb](https://github.com/typekpb) |[philipooo](https://github.com/philipooo) |[redian](https://github.com/redian) |[Bigous](https://github.com/Bigous) | + +[gdi2290](https://github.com/gdi2290) |[sclausen](https://github.com/sclausen) |[butterfieldcons](https://github.com/butterfieldcons) |[jgolla](https://github.com/jgolla) |[ultrasonicsoft](https://github.com/ultrasonicsoft) | +:---: |:---: |:---: |:---: |:---: | +[gdi2290](https://github.com/gdi2290) |[sclausen](https://github.com/sclausen) |[butterfieldcons](https://github.com/butterfieldcons) |[jgolla](https://github.com/jgolla) |[ultrasonicsoft](https://github.com/ultrasonicsoft) | + +# Change Log + +You can follow the [Angular 2 change log here](https://github.com/angular/angular/blob/master/CHANGELOG.md). + +# License + +MIT \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..cd67f61 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,35 @@ +# AppVeyor file +# http://www.appveyor.com/docs/appveyor-yml +# This file: cloned from https://github.com/gruntjs/grunt/blob/master/appveyor.yml + +# Build version format +version: "{build}" + +# Test against this version of Node.js +environment: + nodejs_version: "4.1.0" + # https://github.com/DefinitelyTyped/tsd#tsdrc + # Token has no scope (read-only access to public information) + TSD_GITHUB_TOKEN: "9b18c72997769f3867ef2ec470e626d39661795d" + +build: off + +clone_depth: 10 + +# Fix line endings on Windows +init: + - git config --global core.autocrlf true + +install: + - ps: Install-Product node $env:nodejs_version + - npm install -g npm + - ps: $env:path = $env:appdata + "\npm;" + $env:path + - npm install + +test_script: + # Output useful info for debugging. + - node --version && npm --version + # We test multiple Windows shells because of prior stdout buffering issues + # filed against Grunt. https://github.com/joyent/node/issues/3584 + - ps: "npm --version # PowerShell" # Pass comment to PS for easier debugging + - npm test diff --git a/gulpfile.ts b/gulpfile.ts new file mode 100644 index 0000000..91bfe4b --- /dev/null +++ b/gulpfile.ts @@ -0,0 +1,80 @@ +import * as gulp from 'gulp'; +import {runSequence, task} from './tools/utils'; + +// -------------- +// Clean (override). +gulp.task('clean', task('clean', 'all')); +gulp.task('clean.dist', task('clean', 'dist')); +gulp.task('clean.test', task('clean', 'test')); +gulp.task('clean.tmp', task('clean', 'tmp')); + +gulp.task('check.versions', task('check.versions')); +gulp.task('build.docs', task('build.docs')); +gulp.task('serve.docs', task('serve.docs')); + +// -------------- +// Postinstall. +gulp.task('postinstall', done => + runSequence('clean', + 'npm', + done)); + +// -------------- +// Build dev. +gulp.task('build.dev', done => + runSequence('clean.dist', + 'tslint', + 'build.assets.dev', + 'build.js.dev', + 'build.index.dev', + done)); + +// -------------- +// Build prod. +gulp.task('build.prod', done => + runSequence('clean.dist', + 'clean.tmp', + 'tslint', + 'build.assets.prod', + 'build.html_css.prod', + 'build.js.prod', + 'build.bundles', + 'build.index.prod', + done)); + +// -------------- +// Watch. +gulp.task('build.dev.watch', done => + runSequence('build.dev', + 'watch.dev', + done)); + +gulp.task('build.test.watch', done => + runSequence('build.test', + 'watch.test', + done)); + +// -------------- +// Test. +gulp.task('test', done => + runSequence('clean.test', + 'tslint', + 'build.test', + 'karma.start', + done)); + +// -------------- +// Serve. +gulp.task('serve', done => + runSequence('build.dev', + 'server.start', + 'watch.serve', + done)); + +// -------------- +// Docs +// Disabled until https://github.com/sebastian-lenz/typedoc/issues/162 gets resolved +gulp.task('docs', done => + runSequence('build.docs', + 'serve.docs', + done)); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..adca690 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,103 @@ +// Karma configuration +// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time) +'use strict'; + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: './', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'node_modules/zone.js/dist/zone-microtask.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', + 'node_modules/zone.js/dist/jasmine-patch.js', + 'node_modules/es6-module-loader/dist/es6-module-loader.js', + 'node_modules/traceur/bin/traceur-runtime.js', // Required by PhantomJS2, otherwise it shouts ReferenceError: Can't find variable: require + 'node_modules/traceur/bin/traceur.js', + 'node_modules/systemjs/dist/system.src.js', + 'node_modules/reflect-metadata/Reflect.js', + + { pattern: 'node_modules/angular2/**/*.js', included: false, watched: false }, + { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, + { pattern: 'test/**/*.js', included: false, watched: true }, + { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it + + 'test-main.js' + ], + + + // list of files to exclude + exclude: [ + 'node_modules/angular2/**/*spec.js' + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['mocha'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [ + 'PhantomJS2', + 'Chrome' + ], + + + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); + + if (process.env.APPVEYOR) { + config.browsers = ['IE']; + config.singleRun = true; + config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough + } + + if (process.env.TRAVIS || process.env.CIRCLECI) { + config.browsers = ['Chrome_travis_ci']; + config.singleRun = true; + } +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..939decd --- /dev/null +++ b/package.json @@ -0,0 +1,99 @@ +{ + "name": "hydra-admin", + "version": "0.0.0", + "description": "Build auto-generated admin for Hydra API", + "repository": { + "url": "https://github.com/gregcop1/hydra-admin" + }, + "scripts": { + "build.dev": "gulp build.dev", + "build.dev.watch": "gulp build.dev.watch", + "build.prod": "gulp build.prod", + "build.test": "gulp build.test", + "build.test.watch": "gulp build.test.watch", + "clean-ng2": "rimraf node_modules/angular2/manual_typings node_modules/angular2/typings", + "docs": "npm run gulp -- build.docs && npm run gulp -- serve.docs", + "e2e": "protractor", + "e2e-live": "protractor --elementExplorer", + "gulp": "gulp", + "karma": "karma", + "karma.start": "karma start", + "postinstall": "typings install && npm run clean-ng2 && gulp check.versions && gulp postinstall", + "reinstall": "rimraf node_modules && npm cache clean && npm install", + "start": "gulp serve --env dev", + "serve.dev": "gulp serve --env dev", + "tasks.list": "gulp --tasks-simple", + "test": "gulp test", + "webdriver-update": "webdriver-manager update", + "webdriver-start": "webdriver-manager start" + }, + "author": "Gregory Copin ", + "license": "MIT", + "devDependencies": { + "angular2-hot-loader": "0.0.17", + "async": "^1.4.2", + "browser-sync": "^2.11.1", + "browserify": "^13.0.0", + "chalk": "^1.1.1", + "connect": "^3.4.1", + "connect-livereload": "^0.5.3", + "del": "^2.2.0", + "event-stream": "^3.3.2", + "express": "~4.13.1", + "extend": "^3.0.0", + "gulp": "^3.9.0", + "gulp-concat": "^2.5.2", + "gulp-cssnano": "^2.0.0", + "gulp-filter": "^2.0.2", + "gulp-inject": "^1.3.1", + "gulp-inline-ng2-template": "^0.0.7", + "gulp-load-plugins": "^0.10.0", + "gulp-plumber": "~1.0.1", + "gulp-shell": "~0.4.3", + "gulp-sourcemaps": "~1.5.2", + "gulp-template": "^3.0.0", + "gulp-tslint": "^3.3.0", + "gulp-tslint-stylish": "^1.0.4", + "gulp-typedoc": "^1.2.1", + "gulp-typescript": "~2.8.2", + "gulp-uglify": "^1.2.0", + "gulp-util": "^3.0.7", + "gulp-watch": "^4.2.4", + "jasmine-core": "~2.3.4", + "jasmine-spec-reporter": "^2.4.0", + "karma": "~0.13.15", + "karma-chrome-launcher": "~0.2.0", + "karma-ie-launcher": "^0.2.0", + "karma-jasmine": "~0.3.6", + "karma-mocha-reporter": "^1.1.1", + "karma-phantomjs2-launcher": "^0.4.0", + "merge-stream": "^1.0.0", + "open": "0.0.5", + "protractor": "^3.0.0", + "rimraf": "^2.5.1", + "run-sequence": "^1.1.0", + "semver": "^5.0.3", + "serve-static": "^1.9.2", + "slash": "~1.0.0", + "stream-series": "^0.1.1", + "tiny-lr": "^0.2.1", + "traceur": "^0.0.91", + "ts-node": "^0.5.4", + "typedoc": "^0.3.12", + "typescript": "~1.7.3", + "typings": "^0.6.2", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0", + "yargs": "^3.32.0" + }, + "dependencies": { + "angular2": "2.0.0-beta.2", + "bootstrap": "^3.3.5", + "es6-module-loader": "^0.17.8", + "es6-shim": "^0.33.3", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-beta.0", + "systemjs": "~0.19.18", + "zone.js": "0.5.10" + } +} diff --git a/protractor.conf.js b/protractor.conf.js new file mode 100644 index 0000000..78f5fe9 --- /dev/null +++ b/protractor.conf.js @@ -0,0 +1,43 @@ +exports.config = { + baseUrl: 'http://localhost:5555', + + specs: [ + 'dist/dev/**/*.e2e.js' + ], + exclude: [], + + framework: 'jasmine2', + + allScriptsTimeout: 110000, + + jasmineNodeOpts: { + showTiming: true, + showColors: true, + isVerbose: false, + includeStackTrace: false, + defaultTimeoutInterval: 400000 + }, + directConnect: true, + + capabilities: { + 'browserName': 'chrome' + }, + + onPrepare: function() { + var SpecReporter = require('jasmine-spec-reporter'); + // add jasmine spec reporter + jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true})); + + browser.ignoreSynchronization = false; + }, + + + /** + * Angular 2 configuration + * + * useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching + * `rootEl` + * + */ + useAllAngular2AppRoots: true +}; diff --git a/src/about/components/about.e2e.ts b/src/about/components/about.e2e.ts new file mode 100644 index 0000000..4b9bb20 --- /dev/null +++ b/src/about/components/about.e2e.ts @@ -0,0 +1,20 @@ +describe('About', function() { + + beforeEach(function() { + browser.get('#/about'); + }); + + it('should have an input', function() { + expect(element(by.css('app section about form input')).isPresent()).toEqual(true); + }); + + it('should have a list of computer scientists', function() { + expect(element(by.css('app section about ul')).getText()).toEqual('Dijkstra\nKnuth\nTuring\nHopper'); + }); + + it('should add a name to the list using the form', function() { + element(by.css('app section about form input')).sendKeys('Tim Berners-Lee'); + element(by.css('app section about form button')).click(); + expect(element(by.css('app section about ul')).getText()).toEqual('Dijkstra\nKnuth\nTuring\nHopper\nTim Berners-Lee'); + }); +}); diff --git a/src/about/components/about.html b/src/about/components/about.html new file mode 100644 index 0000000..8c141b3 --- /dev/null +++ b/src/about/components/about.html @@ -0,0 +1,14 @@ +

+ For reward, here is a list of awesome computer scientists! +

+ +

+ You want more? Add them yourself! +

+
+ + +
+ diff --git a/src/about/components/about.spec.ts b/src/about/components/about.spec.ts new file mode 100644 index 0000000..a9aed45 --- /dev/null +++ b/src/about/components/about.spec.ts @@ -0,0 +1,51 @@ +import { + TestComponentBuilder, + describe, + expect, + injectAsync, + it +} from 'angular2/testing'; +import {Component} from 'angular2/core'; +import {DOM} from 'angular2/src/platform/dom/dom_adapter'; +import {AboutCmp} from './about'; +import {NameList} from '../../shared/services/name_list'; + + +export function main() { + describe('About component', () => { + it('should work', + injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb.createAsync(TestComponent) + .then(rootTC => { + rootTC.detectChanges(); + + let aboutInstance = rootTC.debugElement.componentViewChildren[0].componentInstance; + let aboutDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement; + let nameListLen = function () { + return aboutInstance.list.names.length; + }; + + expect(aboutInstance.list).toEqual(jasmine.any(NameList)); + expect(nameListLen()).toEqual(4); + expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen()); + + aboutInstance.newName = 'Minko'; + aboutInstance.addName(); + rootTC.detectChanges(); + + expect(nameListLen()).toEqual(5); + expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen()); + + expect(DOM.querySelectorAll(aboutDOMEl, 'li')[4].textContent).toEqual('Minko'); + }); + })); + }); +} + +@Component({ + providers: [NameList], + selector: 'test-cmp', + template: '
', + directives: [AboutCmp] +}) +class TestComponent {} diff --git a/src/about/components/about.ts b/src/about/components/about.ts new file mode 100644 index 0000000..35925a0 --- /dev/null +++ b/src/about/components/about.ts @@ -0,0 +1,23 @@ +import {Component} from 'angular2/core'; +import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common'; + +import {NameList} from '../../shared/services/name_list'; + +@Component({ + selector: 'about', + templateUrl: './about/components/about.html', + directives: [FORM_DIRECTIVES, CORE_DIRECTIVES] +}) +export class AboutCmp { + newName: string; + constructor(public list: NameList) {} + /* + * @param newname any text as input. + * @returns return false to prevent default form submit behavior to refresh the page. + */ + addName(): boolean { + this.list.add(this.newName); + this.newName = ''; + return false; + } +} diff --git a/src/app/components/app.css b/src/app/components/app.css new file mode 100644 index 0000000..f6815c2 --- /dev/null +++ b/src/app/components/app.css @@ -0,0 +1,33 @@ +.sample-app-content { + font-family: Verdana; +} +.sample-app-content h1 { + color: #999; + font-size: 3em; +} +.sample-app-content h2 { + color: #990000; + font-size: 2em; +} +.sample-app-content p, +.sample-app-content nav { + padding: 30px; +} +.sample-app-content li, +.sample-app-content p { + font-size: 1.2em; +} +.sample-app-content li { + font-family: Consolas; +} +.sample-app-content nav a { + display: inline-block; + margin-right: 15px; +} +.sample-app-content input, +.sample-app-content button { + padding: 5px; + font-size: 1em; + outline: none; +} + diff --git a/src/app/components/app.e2e.ts b/src/app/components/app.e2e.ts new file mode 100644 index 0000000..0c043de --- /dev/null +++ b/src/app/components/app.e2e.ts @@ -0,0 +1,27 @@ +describe('App', function() { + + beforeEach(function() { + browser.get(''); + }); + + it('should have a title', function() { + expect(browser.getTitle()).toEqual('My Angular2 App'); + }); + + it('should have
', function() { + expect(element(by.css('app section')).isPresent()).toEqual(true); + }); + + it('should have