From bbd48804e676b808f1e908866f5b4063aed8ef5a Mon Sep 17 00:00:00 2001 From: Antony Budianto Date: Sat, 28 May 2016 06:27:35 +0700 Subject: [PATCH] Major Restructuring (#88) Bugs: * Fixed reload issue Enhancements: * Made close button look clickable * Folder restructure * Test refactor --- .gitignore | 4 +- .travis.yml | 1 + README.md | 10 ++- assets/styles/bootstrap.scss | 2 - gulp.config.js | 37 ++++++++---- karma-test-shim.js | 2 +- karma.conf.js | 57 +++++++++--------- package.json | 22 +++---- {app => src/app}/app.component.spec.ts | 0 {app => src/app}/app.component.ts | 0 {app => src/app}/app.html | 0 {app => src/app}/app.routes.ts | 0 .../app}/blocks/logger.service.spec.ts | 0 {app => src/app}/blocks/logger.service.ts | 0 {app => src/app}/bundle.ts | 0 {app => src/app}/home/home.component.ts | 0 {app => src/app}/home/home.css | 0 {app => src/app}/home/home.html | 0 {app => src/app}/main.ts | 0 {app => src/app}/navbar/navbar.component.ts | 0 {app => src/app}/navbar/navbar.html | 0 .../app}/simplebind/child.component.spec.ts | 0 .../app}/simplebind/child.component.ts | 0 .../simplebind/simplebind.component.spec.ts | 0 .../app}/simplebind/simplebind.component.ts | 0 {app => src/app}/simplebind/simplebind.html | 0 .../todolist/completed-filter.pipe.spec.ts | 0 .../app}/todolist/completed-filter.pipe.ts | 0 {app => src/app}/todolist/todo.model.ts | 0 .../app}/todolist/todolist.component.spec.ts | 0 .../app}/todolist/todolist.component.ts | 0 {app => src/app}/todolist/todolist.html | 1 + .../fonts/Roboto/Roboto-Regular-webfont.eot | Bin .../fonts/Roboto/Roboto-Regular-webfont.svg | 0 .../fonts/Roboto/Roboto-Regular-webfont.ttf | Bin .../fonts/Roboto/Roboto-Regular-webfont.woff | Bin {assets => src/assets}/images/ng2.jpg | Bin .../assets}/styles/_bootstrap.variables.scss | 0 src/assets/styles/bootstrap.scss | 2 + {assets => src/assets}/styles/fonts.scss | 0 {assets => src/assets}/styles/functions.scss | 0 {assets => src/assets}/styles/main.scss | 0 {assets => src/assets}/styles/mixins.scss | 0 {assets => src/assets}/styles/module.scss | 0 {assets => src/assets}/styles/overrides.scss | 0 {assets => src/assets}/styles/variables.scss | 0 favicon.ico => src/favicon.ico | Bin index.html => src/index.html | 14 ++--- systemjs.conf.js => src/systemjs.conf.js | 3 + {test => src/test}/e2e/home/home.spec.ts | 0 {test => src/test}/test-helpers/global/env.ts | 0 .../test}/test-helpers/global/matchers.ts | 0 {test => src/test}/test-helpers/setup.ts | 0 tasks/build.js | 3 + tasks/clean.js | 12 +--- tasks/test.js | 4 +- tasks/typescript.js | 11 ++-- 57 files changed, 104 insertions(+), 81 deletions(-) delete mode 100644 assets/styles/bootstrap.scss rename {app => src/app}/app.component.spec.ts (100%) rename {app => src/app}/app.component.ts (100%) rename {app => src/app}/app.html (100%) rename {app => src/app}/app.routes.ts (100%) rename {app => src/app}/blocks/logger.service.spec.ts (100%) rename {app => src/app}/blocks/logger.service.ts (100%) rename {app => src/app}/bundle.ts (100%) rename {app => src/app}/home/home.component.ts (100%) rename {app => src/app}/home/home.css (100%) rename {app => src/app}/home/home.html (100%) rename {app => src/app}/main.ts (100%) rename {app => src/app}/navbar/navbar.component.ts (100%) rename {app => src/app}/navbar/navbar.html (100%) rename {app => src/app}/simplebind/child.component.spec.ts (100%) rename {app => src/app}/simplebind/child.component.ts (100%) rename {app => src/app}/simplebind/simplebind.component.spec.ts (100%) rename {app => src/app}/simplebind/simplebind.component.ts (100%) rename {app => src/app}/simplebind/simplebind.html (100%) rename {app => src/app}/todolist/completed-filter.pipe.spec.ts (100%) rename {app => src/app}/todolist/completed-filter.pipe.ts (100%) rename {app => src/app}/todolist/todo.model.ts (100%) rename {app => src/app}/todolist/todolist.component.spec.ts (100%) rename {app => src/app}/todolist/todolist.component.ts (100%) rename {app => src/app}/todolist/todolist.html (98%) rename {assets => src/assets}/fonts/Roboto/Roboto-Regular-webfont.eot (100%) rename {assets => src/assets}/fonts/Roboto/Roboto-Regular-webfont.svg (100%) rename {assets => src/assets}/fonts/Roboto/Roboto-Regular-webfont.ttf (100%) rename {assets => src/assets}/fonts/Roboto/Roboto-Regular-webfont.woff (100%) rename {assets => src/assets}/images/ng2.jpg (100%) rename {assets => src/assets}/styles/_bootstrap.variables.scss (100%) create mode 100644 src/assets/styles/bootstrap.scss rename {assets => src/assets}/styles/fonts.scss (100%) rename {assets => src/assets}/styles/functions.scss (100%) rename {assets => src/assets}/styles/main.scss (100%) rename {assets => src/assets}/styles/mixins.scss (100%) rename {assets => src/assets}/styles/module.scss (100%) rename {assets => src/assets}/styles/overrides.scss (100%) rename {assets => src/assets}/styles/variables.scss (100%) rename favicon.ico => src/favicon.ico (100%) rename index.html => src/index.html (65%) rename systemjs.conf.js => src/systemjs.conf.js (96%) rename {test => src/test}/e2e/home/home.spec.ts (100%) rename {test => src/test}/test-helpers/global/env.ts (100%) rename {test => src/test}/test-helpers/global/matchers.ts (100%) rename {test => src/test}/test-helpers/setup.ts (100%) diff --git a/.gitignore b/.gitignore index a7ac0676..3300511a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ /build /report /typings -/tmp +/src/tmp .DS_Store -assets/styles/*.css \ No newline at end of file +/src/assets/styles/*.css \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index c21dae1f..9e82ea47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,5 @@ node_js: - "4.3" script: gulp build after_script: + - npm install coveralls - npm run-script coveralls diff --git a/README.md b/README.md index e0f82d80..e258c0a5 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,11 @@ > Angular 2 is still in **Release Candidate** stage, please **don't** use this in production + > Follow Angular 2 Changelog [here](https://github.com/angular/angular/blob/master/CHANGELOG.md) +> Live Production Build [Demo](https://antonybudianto.github.io/angular2-starter/) + ## Table of Content * [Introduction](#introduction) * [Installation](#installation) @@ -43,9 +46,12 @@ Please visit the [wiki](https://github.com/antonybudianto/angular2-starter/wiki) Firstly, you need to have [Node.js](https://nodejs.org/en/) - For v4, please use v4.3.x (LTS) or higher (**highly** recommended) - For v5, please use v5.6.x or higher, here is [why](https://nodejs.org/en/blog/vulnerability/february-2016-security-releases/) +- Ready for v6 > You need v4.x or higher for [Protractor](https://angular.github.io/protractor/#/) +Get the starter from [releases page](https://github.com/antonybudianto/angular2-starter/releases) + Then, install these packages globally: ```bash npm install -g gulp @@ -84,7 +90,7 @@ To begin testing, run: ```bash gulp e2e ``` -and it'll compile all E2E spec files in `/test/e2e/*.spec.ts`, boot up Selenium server then launches Chrome browser. +and it'll compile all E2E spec files in `/src/test/e2e/*.spec.ts`, boot up Selenium server then launches Chrome browser. ## Production > All build tasks will run the `gulp test`, the bundle will only be created if the test passed. @@ -101,7 +107,7 @@ The starter defaults to bundle using [SystemJS Builder extension](https://github There is [Webpack extension](https://github.com/ngstarter/ngstarter-webpack-tasks) available too, feel free to swap it as you like. ## Extension -You can extend this starter with many extensions built by open source community. Browse the extensions [here](https://github.com/ngstarter) +You can extend this starter with many extensions built by the community. Browse the extensions [here](https://github.com/ngstarter) ## Contributing Feel free to submit a PR if there are any issues or new features, read [this](https://github.com/antonybudianto/angular2-starter/blob/master/CONTRIBUTING.md) before diff --git a/assets/styles/bootstrap.scss b/assets/styles/bootstrap.scss deleted file mode 100644 index 79a07a58..00000000 --- a/assets/styles/bootstrap.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import 'bootstrap.variables'; -@import '../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap'; \ No newline at end of file diff --git a/gulp.config.js b/gulp.config.js index 41745b6a..70a61bc4 100644 --- a/gulp.config.js +++ b/gulp.config.js @@ -2,18 +2,22 @@ var historyApiFallback = require('connect-history-api-fallback') module.exports = function () { var root = ''; - var app = root + 'app/'; - var test = root + 'test/'; - var tmp = root + 'tmp/'; + var src = root + 'src/'; + var app = src + 'app/'; + var test = src + 'test/'; + var tmp = src + 'tmp/'; + var tmpApp = tmp + 'app/'; + var tmpTest = tmp + 'test/'; var testHelper = test + 'test-helpers/'; var e2e = test + 'e2e/'; - var assets = root + 'assets/'; + var tmpE2E = tmpTest + 'e2e/'; + var assets = src + 'assets/'; var assetsPath = { styles: assets + 'styles/', images: assets + 'images/', fonts: assets + 'fonts/' }; - var index = root + 'index.html'; + var index = src + 'index.html'; var tsFiles = [ app + '**/!(*.spec)+(.ts)' ]; @@ -41,16 +45,19 @@ module.exports = function () { dev: { port: 3000, server: { - baseDir: './', - middleware: [historyApiFallback()] + baseDir: './src/', + middleware: [historyApiFallback()], + routes: { + "/node_modules": "node_modules" + } }, files: [ - "index.html", - "systemjs.conf.js", - "assets/styles/main.css", - "tmp/app/**/*.js", - "app/**/*.css", - "app/**/*.html" + src + "index.html", + src + "systemjs.conf.js", + src + "assets/styles/main.css", + tmpApp + "**/*.js", + app + "**/*.css", + app + "**/*.html" ] }, prod: { @@ -78,9 +85,13 @@ module.exports = function () { var config = { root: root, + src: src, app: app, test: test, tmp: tmp, + tmpApp: tmpApp, + tmpTest: tmpTest, + tmpE2E: tmpE2E, testHelper: testHelper, e2e: e2e, e2eConfig: e2eConfig, diff --git a/karma-test-shim.js b/karma-test-shim.js index f7b19763..de97c325 100644 --- a/karma-test-shim.js +++ b/karma-test-shim.js @@ -30,7 +30,7 @@ function onlySpecFiles(path) { // Normalize paths to module names. function file2moduleName(filePath) { return filePath.replace(/\\/g, '/') - .replace(/^\/base\//, '') + .replace(/^\/base\/src\/tmp\//, '') .replace(/\.js/, ''); } diff --git a/karma.conf.js b/karma.conf.js index 876ac2c6..e3e04144 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,20 +1,17 @@ module.exports = function(config) { + var gulpConfig = require('./gulp.config')(); var dependencies = require('./package.json').dependencies; var excludedDependencies = [ 'systemjs', 'zone.js', 'font-awesome' ]; var configuration = { - basePath: '', + basePath: './', frameworks: ['jasmine'], browsers: ['PhantomJS'], reporters: ['progress', 'coverage'], - preprocessors: { - 'tmp/app/**/!(*.spec)+(.js)': ['coverage'], - 'tmp/app/**/*.js': ['sourcemap'], - 'tmp/test/**/*.js': ['sourcemap'] - }, + preprocessors: {}, // Generate json used for remap-istanbul coverageReporter: { @@ -26,38 +23,20 @@ module.exports = function(config) { files: [ 'node_modules/traceur/bin/traceur-runtime.js', - // IE required polyfills, in this exact order 'node_modules/es6-shim/es6-shim.min.js', 'node_modules/systemjs/dist/system-polyfills.js', 'node_modules/zone.js/dist/zone.js', 'node_modules/reflect-metadata/Reflect.js', 'node_modules/zone.js/dist/async-test.js', 'node_modules/zone.js/dist/fake-async-test.js', - 'node_modules/systemjs/dist/system.src.js', - - 'tmp/test/test-helpers/global/**/*.js', - 'systemjs.conf.js', - 'karma-test-shim.js', - - { pattern: 'tmp/app/**/*.js', included: false }, - { pattern: 'tmp/test/test-helpers/*.js', included: false }, - - // paths loaded via Angular's component compiler - // (these paths need to be rewritten, see proxies section) - { pattern: 'app/**/*.html', included: false }, - { pattern: 'app/**/*.css', included: false }, - - // paths to support debugging with source maps in dev tools - { pattern: 'app/**/*.ts', included: false, watched: false }, - { pattern: 'tmp/app/**/*.js.map', included: false, watched: false } + 'node_modules/systemjs/dist/system.src.js' ], // proxied base paths proxies: { // required for component assests fetched by Angular's compiler - "/app/": "/base/app/", - "/tmp/app/": "/base/tmp/app/", - "/tmp/test/": "/base/tmp/test/", + "/app/": "/base/src/app/", + "/tmp/": "/base/src/tmp/", "/node_modules/": "/base/node_modules/" }, @@ -67,6 +46,24 @@ module.exports = function(config) { autoWatch: true, }; + configuration.preprocessors[gulpConfig.tmpApp + '**/!(*.spec)+(.js)'] = ['coverage']; + configuration.preprocessors[gulpConfig.tmpApp + '**/*.js'] = ['sourcemap']; + configuration.preprocessors[gulpConfig.tmpTest + '**/*.js'] = ['sourcemap']; + + var files = [ + gulpConfig.tmpTest + 'test-helpers/global/**/*.js', + gulpConfig.src + 'systemjs.conf.js', + 'karma-test-shim.js', + createFilePattern(gulpConfig.tmpApp + '**/*.js', { included: false }), + createFilePattern(gulpConfig.tmpTest + 'test-helpers/*.js', { included: false }), + createFilePattern(gulpConfig.app + '**/*.html', { included: false }), + createFilePattern(gulpConfig.app + '**/*.css', { included: false }), + createFilePattern(gulpConfig.app + '**/*.ts', { included: false, watched: false }), + createFilePattern(gulpConfig.tmpApp + '**/*.js.map', { included: false, watched: false }) + ]; + + configuration.files = configuration.files.concat(files); + Object.keys(dependencies).forEach(function(key) { if(excludedDependencies.indexOf(key) >= 0) { return; } @@ -84,4 +81,10 @@ module.exports = function(config) { } config.set(configuration); + + // Helpers + function createFilePattern(path, config) { + config.pattern = path; + return config; + } } diff --git a/package.json b/package.json index 1ad73fa2..a9b82c8d 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "angular2-starter", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "author": "Antony Budianto", - "description": "Angular 2 Starter with Gulp, Karma, Jasmine, Protractor using SystemJS", - "main": "index.html", + "description": "Angular 2 Starter with extensible features", + "main": "src/tmp/app/main.js", "repository": { "type": "git", "url": "https://github.com/antonybudianto/angular2-starter.git" @@ -19,6 +19,8 @@ "starter", "seed", "gulp", + "webpack", + "extensible", "systemjs", "systemjs builder", "travis", @@ -42,17 +44,16 @@ "es6-shim": "^0.35.0", "font-awesome": "^4.6.1", "jquery": "^2.2.3", - "lodash": "^4.11.0", + "lodash": "^4.13.1", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", - "systemjs": "^0.19.27", + "systemjs": "^0.19.29", "zone.js": "^0.6.12" }, "devDependencies": { "browser-sync": "^2.12.8", "codelyzer": "0.0.19", "connect-history-api-fallback": "^1.2.0", - "coveralls": "^2.11.9", "del": "~2.2.0", "glob": "^7.0.3", "gulp": "^3.9.1", @@ -74,15 +75,14 @@ "karma-jasmine": "~1.0.2", "karma-phantomjs-launcher": "~1.0.0", "karma-sourcemap-loader": "^0.3.7", - "ngstarter-systemjs-tasks": "^1.0.0-rc.0", + "ngstarter-systemjs-tasks": "1.0.0-rc.1", "phantomjs-prebuilt": "^2.1.7", "remap-istanbul": "~0.6.4", "require-dir": "~0.3.0", - "run-sequence": "^1.2.0", - "systemjs-builder": "~0.15.16", - "traceur": "~0.0.108", + "run-sequence": "^1.2.1", + "traceur": "~0.0.110", "tslint": "^3.10.2", - "typings": "^1.0.3", + "typings": "^1.0.4", "yargs": "^4.7.1" } } diff --git a/app/app.component.spec.ts b/src/app/app.component.spec.ts similarity index 100% rename from app/app.component.spec.ts rename to src/app/app.component.spec.ts diff --git a/app/app.component.ts b/src/app/app.component.ts similarity index 100% rename from app/app.component.ts rename to src/app/app.component.ts diff --git a/app/app.html b/src/app/app.html similarity index 100% rename from app/app.html rename to src/app/app.html diff --git a/app/app.routes.ts b/src/app/app.routes.ts similarity index 100% rename from app/app.routes.ts rename to src/app/app.routes.ts diff --git a/app/blocks/logger.service.spec.ts b/src/app/blocks/logger.service.spec.ts similarity index 100% rename from app/blocks/logger.service.spec.ts rename to src/app/blocks/logger.service.spec.ts diff --git a/app/blocks/logger.service.ts b/src/app/blocks/logger.service.ts similarity index 100% rename from app/blocks/logger.service.ts rename to src/app/blocks/logger.service.ts diff --git a/app/bundle.ts b/src/app/bundle.ts similarity index 100% rename from app/bundle.ts rename to src/app/bundle.ts diff --git a/app/home/home.component.ts b/src/app/home/home.component.ts similarity index 100% rename from app/home/home.component.ts rename to src/app/home/home.component.ts diff --git a/app/home/home.css b/src/app/home/home.css similarity index 100% rename from app/home/home.css rename to src/app/home/home.css diff --git a/app/home/home.html b/src/app/home/home.html similarity index 100% rename from app/home/home.html rename to src/app/home/home.html diff --git a/app/main.ts b/src/app/main.ts similarity index 100% rename from app/main.ts rename to src/app/main.ts diff --git a/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts similarity index 100% rename from app/navbar/navbar.component.ts rename to src/app/navbar/navbar.component.ts diff --git a/app/navbar/navbar.html b/src/app/navbar/navbar.html similarity index 100% rename from app/navbar/navbar.html rename to src/app/navbar/navbar.html diff --git a/app/simplebind/child.component.spec.ts b/src/app/simplebind/child.component.spec.ts similarity index 100% rename from app/simplebind/child.component.spec.ts rename to src/app/simplebind/child.component.spec.ts diff --git a/app/simplebind/child.component.ts b/src/app/simplebind/child.component.ts similarity index 100% rename from app/simplebind/child.component.ts rename to src/app/simplebind/child.component.ts diff --git a/app/simplebind/simplebind.component.spec.ts b/src/app/simplebind/simplebind.component.spec.ts similarity index 100% rename from app/simplebind/simplebind.component.spec.ts rename to src/app/simplebind/simplebind.component.spec.ts diff --git a/app/simplebind/simplebind.component.ts b/src/app/simplebind/simplebind.component.ts similarity index 100% rename from app/simplebind/simplebind.component.ts rename to src/app/simplebind/simplebind.component.ts diff --git a/app/simplebind/simplebind.html b/src/app/simplebind/simplebind.html similarity index 100% rename from app/simplebind/simplebind.html rename to src/app/simplebind/simplebind.html diff --git a/app/todolist/completed-filter.pipe.spec.ts b/src/app/todolist/completed-filter.pipe.spec.ts similarity index 100% rename from app/todolist/completed-filter.pipe.spec.ts rename to src/app/todolist/completed-filter.pipe.spec.ts diff --git a/app/todolist/completed-filter.pipe.ts b/src/app/todolist/completed-filter.pipe.ts similarity index 100% rename from app/todolist/completed-filter.pipe.ts rename to src/app/todolist/completed-filter.pipe.ts diff --git a/app/todolist/todo.model.ts b/src/app/todolist/todo.model.ts similarity index 100% rename from app/todolist/todo.model.ts rename to src/app/todolist/todo.model.ts diff --git a/app/todolist/todolist.component.spec.ts b/src/app/todolist/todolist.component.spec.ts similarity index 100% rename from app/todolist/todolist.component.spec.ts rename to src/app/todolist/todolist.component.spec.ts diff --git a/app/todolist/todolist.component.ts b/src/app/todolist/todolist.component.ts similarity index 100% rename from app/todolist/todolist.component.ts rename to src/app/todolist/todolist.component.ts diff --git a/app/todolist/todolist.html b/src/app/todolist/todolist.html similarity index 98% rename from app/todolist/todolist.html rename to src/app/todolist/todolist.html index d9a43293..f7416068 100644 --- a/app/todolist/todolist.html +++ b/src/app/todolist/todolist.html @@ -1,6 +1,7 @@