diff --git a/README.md b/README.md index 2ee521d597d58995d0ae967470e4fe482246421b..a121f339a01f51219cc6286ac9a5ff5d7e45372b 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,10 @@ Android (livesync device): npm run start.livesync.android.device * Requires an image setup via AVD Manager. [Learn more here](http://developer.android.com/intl/zh-tw/tools/devices/managing-avds.html) and [here](https://github.com/NativeScript/nativescript-cli#the-commands). +OR... + +* [GenyMotion Android Emulator](https://www.genymotion.com/) + ## Electron App #### Develop diff --git a/gulpfile.ts b/gulpfile.ts index 409cc5326a5d51d5e50935d6473b60f6c201cc5b..663ff862b80d8e9a6e58f1913df402e73ed25127 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -2,11 +2,12 @@ import * as gulp from 'gulp'; import * as util from 'gulp-util'; import * as runSequence from 'run-sequence'; -import { PROJECT_TASKS_DIR, SEED_TASKS_DIR } from './tools/config'; +import Config from './tools/config'; import { loadTasks } from './tools/utils'; -loadTasks(SEED_TASKS_DIR); -loadTasks(PROJECT_TASKS_DIR); + +loadTasks(Config.SEED_TASKS_DIR); +loadTasks(Config.PROJECT_TASKS_DIR); // -------------- diff --git a/nativescript/app/native.module.ts b/nativescript/app/native.module.ts index 212cdd1866222a51b57564c97f4eb6f8b5591f88..0d76283f8c5b3a738ca6a9ffb7a34cecda20a062 100644 --- a/nativescript/app/native.module.ts +++ b/nativescript/app/native.module.ts @@ -4,12 +4,9 @@ import { NativeScriptFormsModule } from 'nativescript-angular/forms'; import { NativeScriptHttpModule } from "nativescript-angular/http"; import { NativeScriptRouterModule } from 'nativescript-angular/router'; import { RouterExtensions as TNSRouterExtensions } from 'nativescript-angular/router/router-extensions'; -import { NativescriptPlatformLocation } from 'nativescript-angular/router/ns-platform-location'; -import { NSLocationStrategy } from 'nativescript-angular/router/ns-location-strategy'; // angular import { NgModule } from '@angular/core'; -import { LocationStrategy, PlatformLocation } from '@angular/common'; // libs import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate'; diff --git a/nativescript/package.json b/nativescript/package.json index fa79a8900c9621734d0f32585382a7f0d2d89a2e..6c997e0d7f4238ea27b34dfcf538337c305a86c8 100644 --- a/nativescript/package.json +++ b/nativescript/package.json @@ -15,41 +15,41 @@ "clean": "rm -rf platforms node_modules lib hooks" }, "dependencies": { - "@angular/common": "2.0.0-rc.6", - "@angular/compiler": "2.0.0-rc.6", - "@angular/core": "2.0.0-rc.6", - "@angular/forms": "2.0.0-rc.6", - "@angular/http": "2.0.0-rc.6", - "@angular/platform-browser": "2.0.0-rc.6", - "@angular/platform-browser-dynamic": "2.0.0-rc.6", - "@angular/platform-server": "2.0.0-rc.6", - "@angular/router": "3.0.0-rc.2", - "@ngrx/core": "1.1.0", - "@ngrx/store": "2.1.2", - "angulartics2": "1.1.5", - "es6-promise": "3.0.2", - "es6-shim": "0.35.0", - "lodash": "4.13.1", + "@angular/core": "2.0.0", + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/platform-server": "2.0.0", + "@angular/router": "3.0.0", + "@ngrx/core": "^1.2.0", + "@ngrx/store": "^2.1.2", + "angulartics2": "^1.1.6", + "es6-promise": "^3.0.2", + "es6-shim": "^0.35.0", + "lodash": "^4.15.0", "nativescript-angular": "next", - "nativescript-ng2-translate": "1.2.0", - "ng2-translate": "2.4.3", + "nativescript-ng2-translate": "^1.2.0", + "ng2-translate": "^2.4.4", "parse5": "1.4.2", "punycode": "1.3.2", "querystring": "0.2.0", - "reflect-metadata": "0.1.3", - "rxjs": "5.0.0-beta.11", - "tns-core-modules": "2.2.1", - "url": "0.10.3", - "zone.js": "0.6.17" + "reflect-metadata": "^0.1.8", + "rxjs": "5.0.0-beta.12", + "tns-core-modules": "^2.2.1", + "url": "0.10.3" }, "devDependencies": { + "zone.js": "^0.6.21", "babel-traverse": "6.9.0", - "babel-types": "6.9.0", - "babylon": "6.8.0", + "babel-types": "6.10.0", + "babylon": "6.8.1", "filewalker": "0.1.2", "lazy": "1.0.11", - "nativescript-dev-typescript": "0.3.2", - "shelljs": "0.5.3", - "typescript": "1.8.10" + "nativescript-dev-typescript": "^0.3.2", + "shelljs": "^0.7.0", + "typescript": "^1.8.10" } -} +} \ No newline at end of file diff --git a/nativescript/tsconfig.json b/nativescript/tsconfig.json index 3d29b1d44feecda418937cc2b4c8ad409bbfee07..972fb4d72230eed80cd93d689cf1f963a3f29754 100644 --- a/nativescript/tsconfig.json +++ b/nativescript/tsconfig.json @@ -5,7 +5,8 @@ "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, - "noEmitHelpers": true + "noEmitHelpers": true, + "noEmitOnError": true }, "exclude": [ "node_modules", diff --git a/package.json b/package.json index 9c7f0c73039bd81427bfb7380a31faed55b4255f..bdf7293124f88c34328473ef496e04b7e0d257e0 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,8 @@ ], "license": "Apache-2.0", "devDependencies": { - "@angular/compiler-cli": "^0.6.0", - "@angular/platform-server": "^2.0.0-rc.6", + "@angular/compiler-cli": "^0.6.1", + "@angular/platform-server": "2.0.0", "@angular/tsc-wrapped": "^0.3.0", "async": "^2.0.0", "autoprefixer": "^6.3.7", @@ -72,7 +72,7 @@ "colorguard": "^1.2.0", "compression": "^1.6.2", "connect": "^3.4.1", - "connect-history-api-fallback": "^1.2.0", + "connect-history-api-fallback": "^1.3.0", "connect-livereload": "^0.5.4", "cssnano": "^3.7.3", "deep-extend": "^0.4.1", @@ -148,14 +148,15 @@ "yargs": "^4.8.0" }, "dependencies": { - "@angular/common": "2.0.0-rc.6", - "@angular/compiler": "2.0.0-rc.6", - "@angular/core": "2.0.0-rc.6", - "@angular/forms": "2.0.0-rc.6", - "@angular/http": "2.0.0-rc.6", - "@angular/platform-browser": "2.0.0-rc.6", - "@angular/platform-browser-dynamic": "2.0.0-rc.6", - "@angular/router": "3.0.0-rc.2", + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/router": "3.0.0", + "@ngrx/core": "^1.2.0", "@angular2-material/button": "2.0.0-alpha.8-1", "@angular2-material/button-toggle": "2.0.0-alpha.8-1", "@angular2-material/card": "2.0.0-alpha.8-1", @@ -175,16 +176,15 @@ "@angular2-material/tabs": "2.0.0-alpha.8-1", "@angular2-material/toolbar": "2.0.0-alpha.8-1", "@angular2-material/tooltip": "2.0.0-alpha.8-1", - "@ngrx/core": "^1.1.0", "@ngrx/store": "^2.1.2", "angulartics2": "^1.1.5", - "es6-module-loader": "^0.17.8", + "es-module-loader": "^1.0.0", "core-js": "^2.4.1", - "lodash": "^4.13.1", - "ng2-translate": "^2.4.3", + "lodash": "^4.15.0", + "ng2-translate": "^2.4.4", "reflect-metadata": "^0.1.8", - "rxjs": "5.0.0-beta.11", + "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "0.6.17" + "zone.js": "0.6.21" } } diff --git a/src/client/app/frameworks/i18n/services/multilingual.service.ts b/src/client/app/frameworks/i18n/services/multilingual.service.ts index f1f78716c1820332547b969af7aceaaee55b652e..39b1b05ec7cdcf3d8da57b18b782cdc01131ad05 100644 --- a/src/client/app/frameworks/i18n/services/multilingual.service.ts +++ b/src/client/app/frameworks/i18n/services/multilingual.service.ts @@ -32,7 +32,7 @@ export const MULTILINGUAL_ACTIONS: any = { export const multilingualReducer: ActionReducer<MultilingualStateI> = (state: MultilingualStateI = initialState, action: Action) => { switch (action.type) { case MULTILINGUAL_ACTIONS.LANG_CHANGE: - return Object.assign({}, state, action.payload); + return (<any>Object).assign({}, state, action.payload); default: return state; } diff --git a/src/client/main.web.prod.ts b/src/client/main.web.prod.ts index 33cc4841d655a68f1f2dfad377e23ee481dd5976..f6ed21afad63a23f2afa9a971aaab3275c05abf2 100644 --- a/src/client/main.web.prod.ts +++ b/src/client/main.web.prod.ts @@ -2,9 +2,15 @@ * Bootstraps the application and makes the ROUTER_PROVIDERS and the APP_BASE_HREF available to it. * @see https://angular.io/docs/ts/latest/api/platform-browser-dynamic/index/bootstrap-function.html */ -import { WebModuleNgFactory } from './web.module.ngfactory'; +import { enableProdMode } from '@angular/core'; import { platformBrowser } from '@angular/platform-browser'; +import { WebModuleNgFactory } from './web.module.ngfactory'; + +if (String('<%= ENV %>') === 'prod' || String('<%= TARGET_DESKTOP_BUILD %>') === 'true') { + enableProdMode(); +} + platformBrowser().bootstrapModuleFactory(WebModuleNgFactory); // In order to start the Service Worker located at "./worker.js" diff --git a/tools/config.ts b/tools/config.ts index 1123c8f8ec1b99952e42bac6a4604f26ae211fa9..c9082fd8529607d8a317b2821cbc87d131db0eb1 100644 --- a/tools/config.ts +++ b/tools/config.ts @@ -1,4 +1,4 @@ import { ProjectConfig } from './config/project.config'; const config: ProjectConfig = new ProjectConfig(); -export = config; +export default config; diff --git a/tools/config/seed.config.ts b/tools/config/seed.config.ts index c295f099ff37342078725f5d9b4f283faf7ac123..686a75aeb0a4dddd8ede8cd5f45874c23cb69600 100644 --- a/tools/config/seed.config.ts +++ b/tools/config/seed.config.ts @@ -298,7 +298,7 @@ export class SeedConfig { { src: 'zone.js/dist/zone.js', inject: 'libs' }, { src: 'core-js/client/shim.min.js', inject: 'shims' }, { src: 'systemjs/dist/system.src.js', inject: 'shims', env: ENVIRONMENTS.DEVELOPMENT }, - { src: 'rxjs/bundles/Rx.umd.min.js', inject: 'libs', env: ENVIRONMENTS.DEVELOPMENT }, + { src: 'rxjs/bundles/Rx.min.js', inject: 'libs', env: ENVIRONMENTS.DEVELOPMENT }, ]; /** @@ -331,7 +331,7 @@ export class SeedConfig { * The configuration of SystemJS for the `dev` environment. * @type {any} */ - protected SYSTEM_CONFIG_DEV: any = { + SYSTEM_CONFIG_DEV: any = { defaultJSExtensions: true, packageConfigPaths: [ `/node_modules/*/package.json`, @@ -457,6 +457,25 @@ export class SeedConfig { COLOR_GUARD_WHITE_LIST: [string, string][] = [ ]; + protected DEV_REWRITE_RULES = [ + { + from: /^\/node_modules\/.*$/, + to: (context:any) => context.parsedUrl.pathname + }, + { + from: /^\/app\/.*$/, + to: (context:any) => context.parsedUrl.pathname + }, + { + from: /^\/assets\/.*$/, + to: (context:any) => context.parsedUrl.pathname + }, + { + from: /^\/css\/.*$/, + to: (context:any) => context.parsedUrl.pathname + } + ]; + /** * Configurations for NPM module configurations. Add to or override in project.config.ts. * If you like, use the mergeObject() method to assist with this. @@ -470,7 +489,28 @@ export class SeedConfig { * @type {any} */ 'browser-sync': { - middleware: [require('connect-history-api-fallback')({ index: `${this.APP_BASE}index.html` })], + middleware: [require('connect-history-api-fallback')({ + index: `${this.APP_BASE}index.html`, +// rewrites: [ +// { +// from: /^\/node_modules\/.*$/, +// to: (context:any) => context.parsedUrl.pathname +// }, +// { +// from: new RegExp(`^${this.APP_BASE}${this.APP_SRC}$`), +// to: (context:any) => context.parsedUrl.pathname +// }, +// { +// from: /^\/assets\/.*$/, +// to: (context:any) => context.parsedUrl.pathname +// }, +// { +// from: /^\/css\/.*$/, +// to: (context:any) => context.parsedUrl.pathname +// } +// ], +// disableDotRule: true + })], port: this.PORT, startPath: this.APP_BASE, open: argv['b'] ? false : true, diff --git a/tools/env/env-config.interface.ts b/tools/env/env-config.interface.ts index cda825b080c6aab34df4e176861c924741844a53..c4878bf6f55199b25e091eeeb0eec20ff8cf5181 100644 --- a/tools/env/env-config.interface.ts +++ b/tools/env/env-config.interface.ts @@ -1,2 +1,2 @@ -export {EnvConfig} from '../../src/client/app/shared/config/env.config'; +export { EnvConfig } from '../../src/client/app/shared/config/env.config'; diff --git a/tools/tasks/project/desktop.build.ts b/tools/tasks/project/desktop.build.ts index 9d168aa5565f6660dba4a78bf72767992f85097f..3ef46a70cc1a57ecbf4ce38d1880af9bab8ab2f0 100644 --- a/tools/tasks/project/desktop.build.ts +++ b/tools/tasks/project/desktop.build.ts @@ -1,12 +1,12 @@ import * as gulp from 'gulp'; import { join } from 'path'; -import { APP_DEST, APP_SRC } from '../../config'; +import Config from '../../config'; export = () => { let src = [ - join(APP_SRC, 'package.json') + join(Config.APP_SRC, 'package.json') ]; return gulp.src(src) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/project/desktop.libs.ts b/tools/tasks/project/desktop.libs.ts index 5a1e0679b8f66b582c51bfbe8a0ec9f87bd63ede..944d6e6379ad228dff8fd849e30a54f373741486 100644 --- a/tools/tasks/project/desktop.libs.ts +++ b/tools/tasks/project/desktop.libs.ts @@ -1,6 +1,6 @@ import * as gulp from 'gulp'; import {join} from 'path'; -import {APP_DEST} from '../../config'; +import Config from '../../config'; export = () => { let src = [ @@ -16,5 +16,5 @@ export = () => { 'node_modules/@angular2-material/**/*' ]; return gulp.src(src, { base: 'node_modules' }) - .pipe(gulp.dest(join(APP_DEST + '/node_modules'))); + .pipe(gulp.dest(join(Config.APP_DEST + '/node_modules'))); }; diff --git a/tools/tasks/seed/build.assets.dev.ts b/tools/tasks/seed/build.assets.dev.ts index 90001e0f1c447868ab84a130c29aabed79086447..8d6cb6c82660b7b9be2da6648dc703a1fd74ead2 100644 --- a/tools/tasks/seed/build.assets.dev.ts +++ b/tools/tasks/seed/build.assets.dev.ts @@ -1,7 +1,7 @@ import * as gulp from 'gulp'; import { join } from 'path'; -import { APP_DEST, APP_SRC, TEMP_FILES } from '../../config'; +import Config from '../../config'; /** * Executes the build process, copying the assets located in `src/client` over to the appropriate @@ -9,11 +9,11 @@ import { APP_DEST, APP_SRC, TEMP_FILES } from '../../config'; */ export = () => { let paths: string[] = [ - join(APP_SRC, '**'), - '!' + join(APP_SRC, '**', '*.ts'), - '!' + join(APP_SRC, '**', '*.scss') - ].concat(TEMP_FILES.map((p) => { return '!' + p; })); + join(Config.APP_SRC, '**'), + '!' + join(Config.APP_SRC, '**', '*.ts'), + '!' + join(Config.APP_SRC, '**', '*.scss') + ].concat(Config.TEMP_FILES.map((p) => { return '!' + p; })); return gulp.src(paths) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/seed/build.assets.prod.ts b/tools/tasks/seed/build.assets.prod.ts index 89f89a8e72a8bbc18640053858fab4416e2b38a2..2c35f25d0e8fd2327136ee5bfa85bcc7dd72a7fc 100644 --- a/tools/tasks/seed/build.assets.prod.ts +++ b/tools/tasks/seed/build.assets.prod.ts @@ -1,7 +1,7 @@ import * as gulp from 'gulp'; import { join } from 'path'; -import { APP_DEST, APP_SRC, ASSETS_SRC, TEMP_FILES } from '../../config'; +import Config from '../../config'; // TODO There should be more elegant to prevent empty directories from copying let es: any = require('event-stream'); @@ -21,13 +21,13 @@ var onlyDirs = function (es: any) { */ export = () => { return gulp.src([ - join(APP_SRC, '**'), - '!' + join(APP_SRC, '**', '*.ts'), - '!' + join(APP_SRC, '**', '*.css'), - '!' + join(APP_SRC, '**', '*.html'), - '!' + join(APP_SRC, '**', '*.scss'), - '!' + join(ASSETS_SRC, '**', '*.js') - ].concat(TEMP_FILES.map((p) => { return '!' + p; }))) + join(Config.APP_SRC, '**'), + '!' + join(Config.APP_SRC, '**', '*.ts'), + '!' + join(Config.APP_SRC, '**', '*.css'), + '!' + join(Config.APP_SRC, '**', '*.html'), + '!' + join(Config.APP_SRC, '**', '*.scss'), + '!' + join(Config.ASSETS_SRC, '**', '*.js') + ].concat(Config.TEMP_FILES.map((p) => { return '!' + p; }))) .pipe(onlyDirs(es)) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/seed/build.bundles.app.exp.ts b/tools/tasks/seed/build.bundles.app.exp.ts index 23aee8cd33cc82822663f8202ac0ee5caecce1c8..c8ad5dbb3414ce982fe90e806efa3fd8291a8b8b 100644 --- a/tools/tasks/seed/build.bundles.app.exp.ts +++ b/tools/tasks/seed/build.bundles.app.exp.ts @@ -1,13 +1,7 @@ import { join } from 'path'; import * as Builder from 'systemjs-builder'; -import { - BOOTSTRAP_FACTORY_PROD_MODULE, - JS_PROD_APP_BUNDLE, - JS_DEST, - SYSTEM_BUILDER_CONFIG, - TMP_DIR -} from '../../config'; +import Config from '../../config'; const BUNDLER_OPTIONS = { format: 'cjs', @@ -19,10 +13,10 @@ const BUNDLER_OPTIONS = { * Executes the build process, bundling the JavaScript files using the SystemJS builder. */ export = (done: any) => { - let builder = new Builder(SYSTEM_BUILDER_CONFIG); + let builder = new Builder(Config.SYSTEM_BUILDER_CONFIG); builder - .buildStatic(join(TMP_DIR, BOOTSTRAP_FACTORY_PROD_MODULE), - join(JS_DEST, JS_PROD_APP_BUNDLE), + .buildStatic(join(Config.TMP_DIR, Config.BOOTSTRAP_FACTORY_PROD_MODULE), + join(Config.JS_DEST, Config.JS_PROD_APP_BUNDLE), BUNDLER_OPTIONS) .then(() => done()) .catch((err: any) => done(err)); diff --git a/tools/tasks/seed/build.bundles.app.ts b/tools/tasks/seed/build.bundles.app.ts index 26ecc974cb33e617b7416c6625f2e3155a2e97fa..fadff941bf69e840fa45d79e36626a6cd4246ff7 100644 --- a/tools/tasks/seed/build.bundles.app.ts +++ b/tools/tasks/seed/build.bundles.app.ts @@ -1,13 +1,7 @@ import { join } from 'path'; import * as Builder from 'systemjs-builder'; -import { - BOOTSTRAP_PROD_MODULE, - JS_PROD_APP_BUNDLE, - JS_DEST, - SYSTEM_BUILDER_CONFIG, - TMP_DIR -} from '../../config'; +import Config from '../../config'; const BUNDLER_OPTIONS = { format: 'cjs', @@ -19,10 +13,10 @@ const BUNDLER_OPTIONS = { * Executes the build process, bundling the JavaScript files using the SystemJS builder. */ export = (done: any) => { - let builder = new Builder(SYSTEM_BUILDER_CONFIG); + let builder = new Builder(Config.SYSTEM_BUILDER_CONFIG); builder - .buildStatic(join(TMP_DIR, BOOTSTRAP_PROD_MODULE), - join(JS_DEST, JS_PROD_APP_BUNDLE), + .buildStatic(join(Config.TMP_DIR, Config.BOOTSTRAP_PROD_MODULE), + join(Config.JS_DEST, Config.JS_PROD_APP_BUNDLE), BUNDLER_OPTIONS) .then(() => done()) .catch((err: any) => done(err)); diff --git a/tools/tasks/seed/build.bundles.ts b/tools/tasks/seed/build.bundles.ts index 5468df9e9de32d64f4c9147947c15c8ee668a05e..a20487e18e1dcdba2f225a3ede3bca423aca3730 100644 --- a/tools/tasks/seed/build.bundles.ts +++ b/tools/tasks/seed/build.bundles.ts @@ -2,7 +2,7 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import * as merge from 'merge-stream'; -import { DEPENDENCIES, JS_DEST, JS_PROD_SHIMS_BUNDLE } from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); @@ -15,7 +15,7 @@ export = () => merge(bundleShims()); * Returns the shim files to be injected. */ function getShims() { - let libs = DEPENDENCIES + let libs = Config.DEPENDENCIES .filter(d => /\.js$/.test(d.src)); return libs.filter(l => l.inject === 'shims') @@ -29,8 +29,8 @@ function getShims() { */ function bundleShims() { return gulp.src(getShims()) - .pipe(plugins.concat(JS_PROD_SHIMS_BUNDLE)) + .pipe(plugins.concat(Config.JS_PROD_SHIMS_BUNDLE)) // Strip the first (global) 'use strict' added by reflect-metadata, but don't strip any others to avoid unintended scope leaks. .pipe(plugins.replace(/('|")use strict\1;var Reflect;/, 'var Reflect;')) - .pipe(gulp.dest(JS_DEST)); + .pipe(gulp.dest(Config.JS_DEST)); } diff --git a/tools/tasks/seed/build.docs.ts b/tools/tasks/seed/build.docs.ts index eb6e693122bef3b3e09a53039426a72945c0b8c6..310a087d58e9b25cb838f730d4bc25b224b7934f 100644 --- a/tools/tasks/seed/build.docs.ts +++ b/tools/tasks/seed/build.docs.ts @@ -2,7 +2,7 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { APP_SRC, APP_TITLE, DOCS_DEST } from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); @@ -14,9 +14,9 @@ export = () => { let src = [ 'typings/index.d.ts', - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*.spec.ts'), - '!' + join(APP_SRC, '**/*.e2e-spec.ts') + join(Config.APP_SRC, '**/*.ts'), + '!' + join(Config.APP_SRC, '**/*.spec.ts'), + '!' + join(Config.APP_SRC, '**/*.e2e-spec.ts') ]; return gulp.src(src) @@ -27,9 +27,9 @@ export = () => { excludeExternals: true, includeDeclarations: true, // Output options (see typedoc docs) - out: DOCS_DEST, - json: join(DOCS_DEST, 'data/docs.json'), - name: APP_TITLE, + out: Config.DOCS_DEST, + json: join(Config.DOCS_DEST, 'data/docs.json'), + name: Config.APP_TITLE, ignoreCompilerErrors: false, experimentalDecorators: true, version: true diff --git a/tools/tasks/seed/build.html_css.ts b/tools/tasks/seed/build.html_css.ts index d7d45d26b35e847af6f760fe479723a8a71e6446..f58a9b36ab47dfef64c5fc89de7287f3374bbb1b 100644 --- a/tools/tasks/seed/build.html_css.ts +++ b/tools/tasks/seed/build.html_css.ts @@ -6,32 +6,21 @@ import * as merge from 'merge-stream'; import * as util from 'gulp-util'; import { join } from 'path'; -import { - APP_DEST, - APP_SRC, - BROWSER_LIST, - CSS_DEST, - CSS_SRC, - DEPENDENCIES, - ENABLE_SCSS, - ENV, - TMP_DIR, - getPluginConfig, -} from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); const cleanCss = require('gulp-clean-css'); -const gulpConcatCssConfig = getPluginConfig('gulp-concat-css'); +const gulpConcatCssConfig = Config.getPluginConfig('gulp-concat-css'); const processors = [ autoprefixer({ - browsers: BROWSER_LIST + browsers: Config.BROWSER_LIST }) ]; const reportPostCssError = (e: any) => util.log(util.colors.red(e.message)); -const isProd = ENV === 'prod'; +const isProd = Config.ENV === 'prod'; if (isProd) { processors.push( @@ -48,30 +37,30 @@ if (isProd) { * Copies all HTML files in `src/client` over to the `dist/tmp` directory. */ function prepareTemplates() { - return gulp.src(join(APP_SRC, '**', '*.html')) - .pipe(gulp.dest(TMP_DIR)); + return gulp.src(join(Config.APP_SRC, '**', '*.html')) + .pipe(gulp.dest(Config.TMP_DIR)); } /** * Execute the appropriate component-stylesheet processing method based on user stylesheet preference. */ function processComponentStylesheets() { - return ENABLE_SCSS ? processComponentScss() : processComponentCss(); + return Config.ENABLE_SCSS ? processComponentScss() : processComponentCss(); } /** * Process scss files referenced from Angular component `styleUrls` metadata */ function processComponentScss() { - return gulp.src(join(APP_SRC, '**', '*.scss')) + return gulp.src(join(Config.APP_SRC, '**', '*.scss')) .pipe(isProd ? plugins.cached('process-component-scss') : plugins.util.noop()) .pipe(isProd ? plugins.progeny() : plugins.util.noop()) .pipe(plugins.sourcemaps.init()) - .pipe(plugins.sass(getPluginConfig('gulp-sass')).on('error', plugins.sass.logError)) + .pipe(plugins.sass(Config.getPluginConfig('gulp-sass')).on('error', plugins.sass.logError)) .pipe(plugins.postcss(processors)) .on('error', reportPostCssError) .pipe(plugins.sourcemaps.write(isProd ? '.' : '')) - .pipe(gulp.dest(isProd ? TMP_DIR : APP_DEST)); + .pipe(gulp.dest(isProd ? Config.TMP_DIR : Config.APP_DEST)); } /** @@ -80,20 +69,20 @@ function processComponentScss() { */ function processComponentCss() { return gulp.src([ - join(APP_SRC, '**', '*.css'), - '!' + join(APP_SRC, 'assets', '**', '*.css') + join(Config.APP_SRC, '**', '*.css'), + '!' + join(Config.APP_SRC, 'assets', '**', '*.css') ]) .pipe(isProd ? plugins.cached('process-component-css') : plugins.util.noop()) .pipe(plugins.postcss(processors)) .on('error', reportPostCssError) - .pipe(gulp.dest(isProd ? TMP_DIR : APP_DEST)); + .pipe(gulp.dest(isProd ? Config.TMP_DIR : Config.APP_DEST)); } /** * Execute external-stylesheet processing method based on presence of --scss flag. */ function processExternalStylesheets() { - return ENABLE_SCSS ? processAllExternalStylesheets() : processExternalCss(); + return Config.ENABLE_SCSS ? processAllExternalStylesheets() : processExternalCss(); } /** @@ -106,7 +95,7 @@ function processAllExternalStylesheets() { .pipe(plugins.postcss(processors)) .on('error', reportPostCssError) .pipe(isProd ? cleanCss() : plugins.util.noop()) - .pipe(gulp.dest(CSS_DEST)); + .pipe(gulp.dest(Config.CSS_DEST)); } /** @@ -121,7 +110,7 @@ function getExternalCssStream() { * Get an array of filenames referring to all external css stylesheets. */ function getExternalCss() { - return DEPENDENCIES.filter(dep => /\.css$/.test(dep.src)).map(dep => dep.src); + return Config.DEPENDENCIES.filter(dep => /\.css$/.test(dep.src)).map(dep => dep.src); } /** @@ -131,7 +120,7 @@ function getExternalScssStream() { return gulp.src(getExternalScss()) .pipe(isProd ? plugins.cached('process-external-scss') : plugins.util.noop()) .pipe(isProd ? plugins.progeny() : plugins.util.noop()) - .pipe(plugins.sass(getPluginConfig('gulp-sass')).on('error', plugins.sass.logError)); + .pipe(plugins.sass(Config.getPluginConfig('gulp-sass')).on('error', plugins.sass.logError)); } /** @@ -139,8 +128,8 @@ function getExternalScssStream() { * as well as in `src/css`. */ function getExternalScss() { - return DEPENDENCIES.filter(dep => /\.scss$/.test(dep.src)).map(dep => dep.src) - .concat([join(CSS_SRC, '**', '*.scss')]); + return Config.DEPENDENCIES.filter(dep => /\.scss$/.test(dep.src)).map(dep => dep.src) + .concat([join(Config.CSS_SRC, '**', '*.scss')]); } /** @@ -152,7 +141,7 @@ function processExternalCss() { .pipe(isProd ? plugins.concatCss(gulpConcatCssConfig.targetFile, gulpConcatCssConfig.options) : plugins.util.noop()) .on('error', reportPostCssError) .pipe(isProd ? cleanCss() : plugins.util.noop()) - .pipe(gulp.dest(CSS_DEST)); + .pipe(gulp.dest(Config.CSS_DEST)); } /** diff --git a/tools/tasks/seed/build.index.dev.ts b/tools/tasks/seed/build.index.dev.ts index 85814d7aa8b8a765b05b6fcb64c183ace2b692c3..4c762509eed374e9f5eef0e16c1dbefa39c9d2ea 100644 --- a/tools/tasks/seed/build.index.dev.ts +++ b/tools/tasks/seed/build.index.dev.ts @@ -2,7 +2,8 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; import * as slash from 'slash'; -import { APP_BASE, APP_DEST, APP_SRC, DEPENDENCIES, CSS_DEST, ASSETS_SRC, TARGET_DESKTOP } from '../../config'; + +import Config from '../../config'; import { templateLocals } from '../../utils'; const plugins = <any>gulpLoadPlugins(); @@ -12,12 +13,12 @@ const plugins = <any>gulpLoadPlugins(); * Executes the build process, injecting the shims and libs into the `index.hml` for the development environment. */ export = () => { - return gulp.src(join(APP_SRC, 'index.html')) + return gulp.src(join(Config.APP_SRC, 'index.html')) .pipe(inject('shims')) .pipe(inject('libs')) .pipe(inject()) .pipe(plugins.template(templateLocals())) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; /** @@ -36,7 +37,7 @@ function inject(name?: string) { * @param {string} name - The dependency to be mapped. */ function getInjectablesDependenciesRef(name?: string) { - return DEPENDENCIES + return Config.DEPENDENCIES .filter(dep => dep['inject'] && dep['inject'] === (name || true)) .map(mapPath); } @@ -47,10 +48,10 @@ function getInjectablesDependenciesRef(name?: string) { */ function mapPath(dep: any) { let envPath = dep.src; - if (envPath.startsWith(APP_SRC) && !envPath.endsWith('.scss')) { - envPath = join(APP_DEST, envPath.replace(APP_SRC, '')); - } else if (envPath.startsWith(APP_SRC) && envPath.endsWith('.scss')) { - envPath = envPath.replace(ASSETS_SRC, CSS_DEST).replace('.scss', '.css'); + if (envPath.startsWith(Config.APP_SRC) && !envPath.endsWith('.scss')) { + envPath = join(Config.APP_DEST, envPath.replace(Config.APP_SRC, '')); + } else if (envPath.startsWith(Config.APP_SRC) && envPath.endsWith('.scss')) { + envPath = envPath.replace(Config.ASSETS_SRC, Config.CSS_DEST).replace('.scss', '.css'); } return envPath; } @@ -61,14 +62,14 @@ function mapPath(dep: any) { */ function transformPath() { return function (filepath: string) { - if (TARGET_DESKTOP) { - let path = join(APP_BASE, filepath); + if (Config.TARGET_DESKTOP) { + let path = join(Config.APP_BASE, filepath); if (path.indexOf('dist/dev') > -1 || path.indexOf('dist\\dev') > -1) { path = path.replace(/(dist\/dev\/)|(dist\\dev\\)/g, ''); } arguments[0] = path.substring(1) + `?${Date.now()}`; } else { - arguments[0] = join(APP_BASE, filepath) + `?${Date.now()}`; + arguments[0] = join(Config.APP_BASE, filepath) + `?${Date.now()}`; } return slash(plugins.inject.transform.apply(plugins.inject.transform, arguments)); }; diff --git a/tools/tasks/seed/build.index.prod.ts b/tools/tasks/seed/build.index.prod.ts index e9e6a59dbf7c60002a1a92281eb5c82ba51d106b..0c91b22d7948267a29f43cfd06551553807f20f0 100644 --- a/tools/tasks/seed/build.index.prod.ts +++ b/tools/tasks/seed/build.index.prod.ts @@ -3,16 +3,7 @@ import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join, sep, normalize } from 'path'; import * as slash from 'slash'; -import { - APP_BASE, - APP_DEST, - APP_SRC, - CSS_DEST, - CSS_PROD_BUNDLE, - JS_DEST, - JS_PROD_APP_BUNDLE, - JS_PROD_SHIMS_BUNDLE -} from '../../config'; +import Config from '../../config'; import { templateLocals } from '../../utils'; const plugins = <any>gulpLoadPlugins(); @@ -22,11 +13,11 @@ const plugins = <any>gulpLoadPlugins(); * environment. */ export = () => { - return gulp.src(join(APP_SRC, 'index.html')) + return gulp.src(join(Config.APP_SRC, 'index.html')) .pipe(injectJs()) .pipe(injectCss()) .pipe(plugins.template(templateLocals())) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; /** @@ -44,14 +35,14 @@ function inject(...files: Array<string>) { * Injects the bundled JavaScript shims and application bundles for the production environment. */ function injectJs() { - return inject(join(JS_DEST, JS_PROD_SHIMS_BUNDLE), join(JS_DEST, JS_PROD_APP_BUNDLE)); + return inject(join(Config.JS_DEST, Config.JS_PROD_SHIMS_BUNDLE), join(Config.JS_DEST, Config.JS_PROD_APP_BUNDLE)); } /** * Injects the bundled CSS files for the production environment. */ function injectCss() { - return inject(join(CSS_DEST, CSS_PROD_BUNDLE)); + return inject(join(Config.CSS_DEST, Config.CSS_PROD_BUNDLE)); } /** @@ -61,13 +52,13 @@ function injectCss() { function transformPath() { return function(filepath: string) { let path: Array<string> = normalize(filepath).split(sep); - let slice_after = path.indexOf(APP_DEST); + let slice_after = path.indexOf(Config.APP_DEST); if (slice_after>-1) { slice_after++; } else { slice_after = 3; } - arguments[0] = APP_BASE + path.slice(slice_after, path.length).join(sep) + `?${Date.now()}`; + arguments[0] = Config.APP_BASE + path.slice(slice_after, path.length).join(sep) + `?${Date.now()}`; return slash(plugins.inject.transform.apply(plugins.inject.transform, arguments)); }; } diff --git a/tools/tasks/seed/build.js.dev.ts b/tools/tasks/seed/build.js.dev.ts index a01b27acff8128d53cbfeb7b8573ea5d98c3b675..3fad9d74e64cf0ac65983ee7d6a4b2735d290ef5 100644 --- a/tools/tasks/seed/build.js.dev.ts +++ b/tools/tasks/seed/build.js.dev.ts @@ -4,21 +4,14 @@ import * as merge from 'merge-stream'; import * as util from 'gulp-util'; import { join/*, sep, relative*/ } from 'path'; -import { - APP_DEST, - SYSTEM_CONFIG_DEV, - APP_SRC, - NG_FACTORY_FILE, - /*PROJECT_ROOT, */TOOLS_DIR, - TYPED_COMPILE_INTERVAL -} from '../../config'; +import Config from '../../config'; import { makeTsProject, templateLocals } from '../../utils'; const plugins = <any>gulpLoadPlugins(); -const jsonSystemConfig = JSON.stringify(SYSTEM_CONFIG_DEV); +const jsonSystemConfig = JSON.stringify(Config.SYSTEM_CONFIG_DEV); -let typedBuildCounter = TYPED_COMPILE_INTERVAL; // Always start with the typed build. +let typedBuildCounter = Config.TYPED_COMPILE_INTERVAL; // Always start with the typed build. /** * Executes the build process, transpiling the TypeScript files (except the spec and e2e-spec files) for the development @@ -28,13 +21,13 @@ export = () => { let tsProject: any; let typings = gulp.src([ 'typings/index.d.ts', - TOOLS_DIR + '/manual_typings/**/*.d.ts' + Config.TOOLS_DIR + '/manual_typings/**/*.d.ts' ]); let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*.spec.ts'), - '!' + join(APP_SRC, '**/*.e2e-spec.ts'), - '!' + join(APP_SRC, `**/${NG_FACTORY_FILE}.ts`) + join(Config.APP_SRC, '**/*.ts'), + '!' + join(Config.APP_SRC, '**/*.spec.ts'), + '!' + join(Config.APP_SRC, '**/*.e2e-spec.ts'), + '!' + join(Config.APP_SRC, `**/${Config.BOOTSTRAP_FACTORY_PROD_MODULE}.ts`) ]; let projectFiles = gulp.src(src); @@ -42,7 +35,7 @@ export = () => { let isFullCompile = true; // Only do a typed build every X builds, otherwise do a typeless build to speed things up - if (typedBuildCounter < TYPED_COMPILE_INTERVAL) { + if (typedBuildCounter < Config.TYPED_COMPILE_INTERVAL) { isFullCompile = false; tsProject = makeTsProject({isolatedModules: true}); projectFiles = projectFiles.pipe(plugins.cached()); @@ -57,7 +50,7 @@ export = () => { .pipe(plugins.sourcemaps.init()) .pipe(plugins.typescript(tsProject)) .on('error', () => { - typedBuildCounter = TYPED_COMPILE_INTERVAL; + typedBuildCounter = Config.TYPED_COMPILE_INTERVAL; }); if (isFullCompile) { @@ -80,5 +73,5 @@ export = () => { SYSTEM_CONFIG_DEV: jsonSystemConfig } ))) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/seed/build.js.e2e.ts b/tools/tasks/seed/build.js.e2e.ts index 410047f24e31609542d45c2b21001e3a42da6084..d4cd7b6f8ac73320ba7a50b8dd0231e5e1f4ad3e 100644 --- a/tools/tasks/seed/build.js.e2e.ts +++ b/tools/tasks/seed/build.js.e2e.ts @@ -2,17 +2,11 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { - APP_DEST, - APP_SRC, - NG_FACTORY_FILE, - SYSTEM_CONFIG_DEV, - TOOLS_DIR -} from '../../config'; +import Config from '../../config'; import { makeTsProject, templateLocals } from '../../utils'; const plugins = <any>gulpLoadPlugins(); -const jsonSystemConfig = JSON.stringify(SYSTEM_CONFIG_DEV); +const jsonSystemConfig = JSON.stringify(Config.SYSTEM_CONFIG_DEV); /** * Executes the build process, transpiling the TypeScript files (including the e2e-spec files, excluding the spec files) @@ -22,10 +16,10 @@ export = () => { let tsProject = makeTsProject(); let src = [ 'typings/index.d.ts', - TOOLS_DIR + '/manual_typings/**/*.d.ts', - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*.spec.ts'), - '!' + join(APP_SRC, `**/${NG_FACTORY_FILE}.ts`) + Config.TOOLS_DIR + '/manual_typings/**/*.d.ts', + join(Config.APP_SRC, '**/*.ts'), + '!' + join(Config.APP_SRC, '**/*.spec.ts'), + '!' + join(Config.APP_SRC, `**/${Config.BOOTSTRAP_FACTORY_PROD_MODULE}.ts`) ]; let result = gulp.src(src) .pipe(plugins.plumber()) @@ -37,5 +31,5 @@ export = () => { .pipe(plugins.template(Object.assign(templateLocals(), { SYSTEM_CONFIG_DEV: jsonSystemConfig }))) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/seed/build.js.prod.exp.ts b/tools/tasks/seed/build.js.prod.exp.ts index 40044678565ea326544b5d221fb9091edff3fd78..0af227856490c1710ccd12fbf031f874b35ccd06 100644 --- a/tools/tasks/seed/build.js.prod.exp.ts +++ b/tools/tasks/seed/build.js.prod.exp.ts @@ -2,7 +2,7 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { TMP_DIR, TOOLS_DIR } from '../../config'; +import Config from '../../config'; import { makeTsProject, templateLocals } from '../../utils'; const plugins = <any>gulpLoadPlugins(); @@ -15,8 +15,8 @@ export = () => { let tsProject = makeTsProject(); let src = [ 'typings/index.d.ts', - TOOLS_DIR + '/manual_typings/**/*.d.ts', - join(TMP_DIR, '**/*.ts') + Config.TOOLS_DIR + '/manual_typings/**/*.d.ts', + join(Config.TMP_DIR, '**/*.ts') ]; let result = gulp.src(src) .pipe(plugins.plumber()) @@ -28,7 +28,7 @@ export = () => { return result.js .pipe(plugins.template(templateLocals())) - .pipe(gulp.dest(TMP_DIR)) + .pipe(gulp.dest(Config.TMP_DIR)) .on('error', (e: any) => { console.log(e); }); diff --git a/tools/tasks/seed/build.js.prod.ts b/tools/tasks/seed/build.js.prod.ts index 46aab6bc2fc02cccccbb7a56d19c1b5a8bad48ca..0fd3dbefe6dbf452672c1768a7666ce71dbaead8 100644 --- a/tools/tasks/seed/build.js.prod.ts +++ b/tools/tasks/seed/build.js.prod.ts @@ -2,13 +2,13 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { NG_FACTORY_FILE, TMP_DIR, TOOLS_DIR } from '../../config'; +import Config from '../../config'; import { makeTsProject, templateLocals } from '../../utils'; const plugins = <any>gulpLoadPlugins(); const INLINE_OPTIONS = { - base: TMP_DIR, + base: Config.TMP_DIR, useRelativePaths: true, removeLineBreaks: true }; @@ -21,9 +21,9 @@ export = () => { let tsProject = makeTsProject(); let src = [ 'typings/index.d.ts', - TOOLS_DIR + '/manual_typings/**/*.d.ts', - join(TMP_DIR, '**/*.ts'), - '!' + join(TMP_DIR, `**/${NG_FACTORY_FILE}.ts`) + Config.TOOLS_DIR + '/manual_typings/**/*.d.ts', + join(Config.TMP_DIR, '**/*.ts'), + '!' + join(Config.TMP_DIR, `**/${Config.BOOTSTRAP_FACTORY_PROD_MODULE}.ts`) ]; let result = gulp.src(src) .pipe(plugins.plumber()) @@ -36,7 +36,7 @@ export = () => { return result.js .pipe(plugins.template(templateLocals())) - .pipe(gulp.dest(TMP_DIR)) + .pipe(gulp.dest(Config.TMP_DIR)) .on('error', (e: any) => { console.log(e); }); diff --git a/tools/tasks/seed/build.js.test.ts b/tools/tasks/seed/build.js.test.ts index 4a8e5ea76d2931ce4aa0ca01021e9aaa144b5ab0..14ac1ff4191b94e41a5262fa1da3aecc5dd51127 100644 --- a/tools/tasks/seed/build.js.test.ts +++ b/tools/tasks/seed/build.js.test.ts @@ -3,7 +3,7 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join} from 'path'; -import { APP_DEST, APP_SRC, TOOLS_DIR } from '../../config';//ENABLE_SCSS +import Config from '../../config'; import { makeTsProject } from '../../utils'; // import { ViewBroker } from '../../../src/client/app/frameworks/core/utils/view-broker'; @@ -17,8 +17,8 @@ export = () => { let tsProject = makeTsProject(); let src = [ 'typings/index.d.ts', - TOOLS_DIR + '/manual_typings/**/*.d.ts', - join(APP_SRC, '**/*.spec.ts') + Config.TOOLS_DIR + '/manual_typings/**/*.d.ts', + join(Config.APP_SRC, '**/*.spec.ts') ]; let result = gulp.src(src) .pipe(plugins.plumber()) @@ -32,6 +32,7 @@ export = () => { .pipe(plugins.typescript(tsProject)); return result.js - .pipe(gulp.dest(APP_DEST)); + .pipe(plugins.sourcemaps.write()) + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/seed/build.js.tools.ts b/tools/tasks/seed/build.js.tools.ts index 0af1dd9835a608828aaf177cb9e76d5b2f94f42f..56ec8140a61678727a2f257f217a6815c70d3515 100644 --- a/tools/tasks/seed/build.js.tools.ts +++ b/tools/tasks/seed/build.js.tools.ts @@ -2,7 +2,7 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { TOOLS_DIR } from '../../config'; +import Config from '../../config'; import { makeTsProject, templateLocals, } from '../../utils'; const plugins = <any>gulpLoadPlugins(); @@ -14,8 +14,8 @@ export = () => { let tsProject = makeTsProject(); let src = [ 'typings/index.d.ts', - TOOLS_DIR + '/manual_typings/**/*.d.ts', - join(TOOLS_DIR, '**/*.ts') + Config.TOOLS_DIR + '/manual_typings/**/*.d.ts', + join(Config.TOOLS_DIR, '**/*.ts') ]; let result = gulp.src(src, { base: './' }) .pipe(plugins.plumber()) diff --git a/tools/tasks/seed/check.versions.ts b/tools/tasks/seed/check.versions.ts index 5aac0e67737ad7f822cdf99325d2f7ade61d6ce5..f42c2ac7f4b7540fedac90aeababc1fdfa54ac8f 100644 --- a/tools/tasks/seed/check.versions.ts +++ b/tools/tasks/seed/check.versions.ts @@ -1,5 +1,5 @@ import * as util from 'gulp-util'; -import { VERSION_NODE, VERSION_NPM } from '../../config'; +import Config from '../../config'; function reportError(message: string) { console.error(util.colors.white.bgRed.bold(message)); @@ -20,8 +20,8 @@ export = () => { reportError('npm preinstall error: ' + error + stderr); } - if (!semver.gte(stdout, VERSION_NPM)) { - reportError('NPM is not in required version! Required is ' + VERSION_NPM + ' and you\'re using ' + stdout); + if (!semver.gte(stdout, Config.VERSION_NPM)) { + reportError('NPM is not in required version! Required is ' + Config.VERSION_NPM + ' and you\'re using ' + stdout); } }); @@ -31,8 +31,8 @@ export = () => { reportError('npm preinstall error: ' + error + stderr); } - if (!semver.gte(stdout, VERSION_NODE)) { - reportError('NODE is not in required version! Required is ' + VERSION_NODE + ' and you\'re using ' + stdout); + if (!semver.gte(stdout, Config.VERSION_NODE)) { + reportError('NODE is not in required version! Required is ' + Config.VERSION_NODE + ' and you\'re using ' + stdout); } }); }; diff --git a/tools/tasks/seed/clean.all.src.js.ts b/tools/tasks/seed/clean.all.src.js.ts index ab95ee3d808177dba54d35cecb6b2c6a36f52cc3..4162a7bbe4e3d926c8e1223597b9a36f3351f8c1 100644 --- a/tools/tasks/seed/clean.all.src.js.ts +++ b/tools/tasks/seed/clean.all.src.js.ts @@ -4,14 +4,14 @@ import * as util from 'gulp-util'; import * as rimraf from 'rimraf'; import { join } from 'path'; -import { APP_SRC } from '../../config'; +import Config from '../../config'; /** * Executes the build process, deleting all JavaScript and Source Map files (which were transpiled from the TypeScript sources) with in * the `src/client` directory. */ export = (done: any) => { - deleteAndWalk(APP_SRC); + deleteAndWalk(Config.APP_SRC); done(); }; diff --git a/tools/tasks/seed/clean.all.ts b/tools/tasks/seed/clean.all.ts index f1db1da3dabd69a2e0749aef9ac58cf6da245092..9dce922f44d9b2bbd92dd72c3c0065c48a9e11dd 100644 --- a/tools/tasks/seed/clean.all.ts +++ b/tools/tasks/seed/clean.all.ts @@ -1,7 +1,7 @@ -import { DIST_DIR, COVERAGE_DIR } from '../../config'; +import Config from '../../config'; import { clean } from '../../utils'; /** * Executes the build process, cleaning all files within the `/dist` directory. */ -export = clean([DIST_DIR, COVERAGE_DIR]); +export = clean([Config.DIST_DIR, Config.COVERAGE_DIR]); diff --git a/tools/tasks/seed/clean.coverage.ts b/tools/tasks/seed/clean.coverage.ts index d54f19457b5478ef437d59ae5e7dc2d858e97f50..4c934f50c6e9ba1f236cb7901d84fe4f23f5eb71 100644 --- a/tools/tasks/seed/clean.coverage.ts +++ b/tools/tasks/seed/clean.coverage.ts @@ -1,7 +1,7 @@ -import { COVERAGE_DIR } from '../../config'; +import Config from '../../config'; import { clean } from '../../utils'; /** * Executes the build process, cleaning all files within the `/dist/dev` directory. */ -export = clean(COVERAGE_DIR); +export = clean(Config.COVERAGE_DIR); diff --git a/tools/tasks/seed/clean.dev.ts b/tools/tasks/seed/clean.dev.ts index 3717974b5fa3af3a88fced36a2b459daed51b64b..1ce0e82673a54374176272af7f663716a66eb8af 100644 --- a/tools/tasks/seed/clean.dev.ts +++ b/tools/tasks/seed/clean.dev.ts @@ -1,7 +1,7 @@ -import { DEV_DEST } from '../../config'; +import Config from '../../config'; import { clean } from '../../utils'; /** * Executes the build process, cleaning all files within the `/dist/dev` directory. */ -export = clean(DEV_DEST); +export = clean(Config.DEV_DEST); diff --git a/tools/tasks/seed/clean.prod.ts b/tools/tasks/seed/clean.prod.ts index 1864539ec67a3bd107826062527c62bffc95663a..9275064d9fb274b4312e03b4af5082aad84d0518 100644 --- a/tools/tasks/seed/clean.prod.ts +++ b/tools/tasks/seed/clean.prod.ts @@ -1,7 +1,7 @@ -import { PROD_DEST, TMP_DIR } from '../../config'; +import Config from '../../config'; import { clean } from '../../utils'; /** * Executes the build process, cleaning all files within the `/dist/dev` and `dist/tmp` directory. */ -export = clean([PROD_DEST, TMP_DIR]); +export = clean([Config.PROD_DEST, Config.TMP_DIR]); diff --git a/tools/tasks/seed/clean.tools.ts b/tools/tasks/seed/clean.tools.ts index 63a9e947449ca1a86a41ed85eea6869772efa82e..aba8c762d47f889bf7166c96047949f0464b51d0 100644 --- a/tools/tasks/seed/clean.tools.ts +++ b/tools/tasks/seed/clean.tools.ts @@ -3,14 +3,14 @@ import * as util from 'gulp-util'; import * as rimraf from 'rimraf'; import { join } from 'path'; -import { TOOLS_DIR } from '../../config'; +import Config from '../../config'; /** * Executes the build process, deleting all JavaScrip files (which were transpiled from the TypeScript sources) with in * the `tools` directory. */ export = (done: any) => { - deleteAndWalk(TOOLS_DIR); + deleteAndWalk(Config.TOOLS_DIR); done(); }; diff --git a/tools/tasks/seed/compile.ahead.prod.ts b/tools/tasks/seed/compile.ahead.prod.ts index 601beb71641d098d2dc2056b0a4e79921e325d88..fc7e38ec9d05a97da4e48e484b6d617bf718ceab 100644 --- a/tools/tasks/seed/compile.ahead.prod.ts +++ b/tools/tasks/seed/compile.ahead.prod.ts @@ -6,7 +6,7 @@ import { join } from 'path'; import { writeFileSync, readFileSync } from 'fs'; import {CodeGenerator} from '@angular/compiler-cli'; -import { TMP_DIR, BOOTSTRAP_DIR } from '../../config'; +import Config from '../../config'; function codegen( ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.NgcCliOptions, program: ts.Program, @@ -21,17 +21,17 @@ const copyFile = (name: string, from: string, to: string, mod: any = (f: string) export = (done: any) => { // Note: dirty hack until we're able to set config easier - copyFile('tsconfig.json', TMP_DIR, join(TMP_DIR, BOOTSTRAP_DIR), (content: string) => { + copyFile('tsconfig.json', Config.TMP_DIR, join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), (content: string) => { const parsed = JSON.parse(content); parsed.files.push('main.web.ts'); return JSON.stringify(parsed, null, 2); }); - copyFile('typings.d.ts', TMP_DIR, join(TMP_DIR, BOOTSTRAP_DIR), (content: string) => { + copyFile('typings.d.ts', Config.TMP_DIR, join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), (content: string) => { return content.replace('../../typings/index.d.ts', '../../../typings/index.d.ts'); }); const args = argv; const cliOptions = new tsc.NgcCliOptions(args); - tsc.main(join(TMP_DIR, BOOTSTRAP_DIR), cliOptions, codegen) + tsc.main(join(Config.TMP_DIR, Config.BOOTSTRAP_DIR), cliOptions, codegen) .then(done) .catch(e => { console.error(e.stack); diff --git a/tools/tasks/seed/copy.prod.ts b/tools/tasks/seed/copy.prod.ts index b31741d5e677c7478bf4b6ad399c604e3eedd4d8..3d2d8674083a4735d49a29a4ec3db771ae71c7af 100644 --- a/tools/tasks/seed/copy.prod.ts +++ b/tools/tasks/seed/copy.prod.ts @@ -1,19 +1,19 @@ import * as gulp from 'gulp'; import { join } from 'path'; -import { APP_SRC, TMP_DIR } from '../../config'; +import Config from '../../config'; /** * Executes the build task, copying all TypeScript files over to the `dist/tmp` directory. */ export = () => { return gulp.src([ - join(APP_SRC, '**/*.ts'), - join(APP_SRC, '**/*.html'), - join(APP_SRC, '**/*.css'), - join(APP_SRC, '**/*.json'), - '!' + join(APP_SRC, '**/*.spec.ts'), - '!' + join(APP_SRC, '**/*.e2e-spec.ts') + join(Config.APP_SRC, '**/*.ts'), + join(Config.APP_SRC, '**/*.html'), + join(Config.APP_SRC, '**/*.css'), + join(Config.APP_SRC, '**/*.json'), + '!' + join(Config.APP_SRC, '**/*.spec.ts'), + '!' + join(Config.APP_SRC, '**/*.e2e-spec.ts') ]) - .pipe(gulp.dest(TMP_DIR)); + .pipe(gulp.dest(Config.TMP_DIR)); }; diff --git a/tools/tasks/seed/css-lint.ts b/tools/tasks/seed/css-lint.ts index 85b43e51d660b2fcc8b04214c58dac3cd8b26169..5ee4f13d11b042268055235f83202b1479a3ed3d 100644 --- a/tools/tasks/seed/css-lint.ts +++ b/tools/tasks/seed/css-lint.ts @@ -7,19 +7,19 @@ import * as reporter from 'postcss-reporter'; import * as stylelint from 'stylelint'; import { join } from 'path'; -import { APP_ASSETS, APP_SRC, BROWSER_LIST, CSS_SRC, ENV, DEPENDENCIES, ENABLE_SCSS, COLOR_GUARD_WHITE_LIST} from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); -const isProd = ENV === 'prod'; -var stylesheetType = ENABLE_SCSS ? 'scss' : 'css'; +const isProd = Config.ENV === 'prod'; +var stylesheetType = Config.ENABLE_SCSS ? 'scss' : 'css'; const processors = [ doiuse({ - browsers: BROWSER_LIST, + browsers: Config.BROWSER_LIST, }), colorguard({ - whitelist: COLOR_GUARD_WHITE_LIST + whitelist: Config.COLOR_GUARD_WHITE_LIST }), stylelint(), reporter({clearMessages: true}) @@ -27,25 +27,25 @@ const processors = [ function lintComponentStylesheets() { return gulp.src([ - join(APP_SRC, '**', `*.${stylesheetType}`), - `!${join(APP_SRC, 'assets', '**', '*.scss')}`, - `!${join(CSS_SRC, '**', '*.css')}` + join(Config.APP_SRC, '**', `*.${stylesheetType}`), + `!${join(Config.APP_SRC, 'assets', '**', '*.scss')}`, + `!${join(Config.CSS_SRC, '**', '*.css')}` ]).pipe(isProd ? plugins.cached('css-lint') : plugins.util.noop()) - .pipe(ENABLE_SCSS ? plugins.sassLint() : plugins.postcss(processors)) - .pipe(ENABLE_SCSS ? plugins.sassLint.format() : plugins.util.noop()) - .pipe(ENABLE_SCSS ? plugins.sassLint.failOnError() : plugins.util.noop()); + .pipe(Config.ENABLE_SCSS ? plugins.sassLint() : plugins.postcss(processors)) + .pipe(Config.ENABLE_SCSS ? plugins.sassLint.format() : plugins.util.noop()) + .pipe(Config.ENABLE_SCSS ? plugins.sassLint.failOnError() : plugins.util.noop()); } function lintExternalStylesheets() { return gulp.src(getExternalStylesheets().map(r => r.src)) .pipe(isProd ? plugins.cached('css-lint') : plugins.util.noop()) - .pipe(ENABLE_SCSS ? plugins.sassLint() : plugins.postcss(processors)) - .pipe(ENABLE_SCSS ? plugins.sassLint.format() : plugins.util.noop()) - .pipe(ENABLE_SCSS ? plugins.sassLint.failOnError() : plugins.util.noop()); + .pipe(Config.ENABLE_SCSS ? plugins.sassLint() : plugins.postcss(processors)) + .pipe(Config.ENABLE_SCSS ? plugins.sassLint.format() : plugins.util.noop()) + .pipe(Config.ENABLE_SCSS ? plugins.sassLint.failOnError() : plugins.util.noop()); } function getExternalStylesheets() { - let stylesheets = ENABLE_SCSS ? DEPENDENCIES : APP_ASSETS; + let stylesheets = Config.ENABLE_SCSS ? Config.DEPENDENCIES : Config.APP_ASSETS; return stylesheets .filter(d => new RegExp(`\.${stylesheetType}$`) .test(d.src) && !d.vendor); diff --git a/tools/tasks/seed/generate.manifest.ts b/tools/tasks/seed/generate.manifest.ts index 5097c5281aaea0510ae744e5c6dcb5498bd4e77d..2134f57a9240f611c92d187a800a2937b3f0cb8a 100644 --- a/tools/tasks/seed/generate.manifest.ts +++ b/tools/tasks/seed/generate.manifest.ts @@ -1,6 +1,6 @@ import * as gulp from 'gulp'; -import { APP_DEST } from '../../config'; +import Config from '../../config'; /** * Executes the build process, generating the manifest file using `angular2-service-worker`. @@ -10,11 +10,11 @@ export = () => { .gulpGenManifest({ group: [{ name: 'css', - sources: gulp.src(`${APP_DEST}/**/*.css`) + sources: gulp.src(`${Config.APP_DEST}/**/*.css`) }, { name: 'js', - sources: gulp.src(`${APP_DEST}/**/*.js`) + sources: gulp.src(`${Config.APP_DEST}/**/*.js`) }] }) - .pipe(gulp.dest(APP_DEST)); + .pipe(gulp.dest(Config.APP_DEST)); }; diff --git a/tools/tasks/seed/minify.bundles.ts b/tools/tasks/seed/minify.bundles.ts index 60c30ebd3da249f8d3069bf2103023d0bbbbba0b..63bb03655bd7719ced932c0c6659fff88707157b 100644 --- a/tools/tasks/seed/minify.bundles.ts +++ b/tools/tasks/seed/minify.bundles.ts @@ -3,7 +3,7 @@ import * as gulpLoadPlugins from 'gulp-load-plugins'; import * as merge from 'merge-stream'; import { join } from 'path'; -import { JS_DEST, JS_PROD_APP_BUNDLE, JS_PROD_SHIMS_BUNDLE } from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); @@ -18,7 +18,7 @@ const getTask = (target: string, destDir: string) => { export = () => { return merge( - getTask(JS_PROD_APP_BUNDLE, JS_DEST), - getTask(JS_PROD_SHIMS_BUNDLE, JS_DEST) + getTask(Config.JS_PROD_APP_BUNDLE, Config.JS_DEST), + getTask(Config.JS_PROD_SHIMS_BUNDLE, Config.JS_DEST) ); }; diff --git a/tools/tasks/seed/tslint.ts b/tools/tasks/seed/tslint.ts index 3742753951cce53fb7ed9a9e9f2a6e5d45dbb23f..157be2b5f7b53c351e144c7993ca22c67c2a4aa9 100644 --- a/tools/tasks/seed/tslint.ts +++ b/tools/tasks/seed/tslint.ts @@ -2,7 +2,7 @@ import * as gulp from 'gulp'; import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { APP_SRC, CODELYZER_RULES, TOOLS_DIR } from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); @@ -11,19 +11,17 @@ const plugins = <any>gulpLoadPlugins(); */ export = () => { let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*.d.ts'), - join(TOOLS_DIR, '**/*.ts'), - '!' + join(TOOLS_DIR, '**/*.d.ts') + join(Config.APP_SRC, '**/*.ts'), + '!' + join(Config.APP_SRC, '**/*.d.ts'), + join(Config.TOOLS_DIR, '**/*.ts'), + '!' + join(Config.TOOLS_DIR, '**/*.d.ts') ]; return gulp.src(src) .pipe(plugins.tslint({ - rulesDirectory: CODELYZER_RULES + rulesDirectory: Config.CODELYZER_RULES })) - .pipe(plugins.tslint.report(require('tslint-stylish'), { - emitError: require('is-ci'), - sort: true, - bell: true + .pipe(plugins.tslint.report({ + emitError: require('is-ci') })); }; diff --git a/tools/utils/seed/code_change_tools.ts b/tools/utils/seed/code_change_tools.ts index 051462152c3c3952083c51a8ddd7d29da035d370..acb112b0e7d14618d9b3d5a3828ca9b5de5dba2d 100644 --- a/tools/utils/seed/code_change_tools.ts +++ b/tools/utils/seed/code_change_tools.ts @@ -1,13 +1,13 @@ import * as browserSync from 'browser-sync'; // import * as path from 'path'; -import { getPluginConfig } from '../../config'; +import Config from '../../config'; /** * Initialises BrowserSync with the configuration defined in seed.config.ts (or if overriden: project.config.ts). */ let runServer = () => { - browserSync.init(getPluginConfig('browser-sync')); + browserSync.init(Config.getPluginConfig('browser-sync')); }; /** diff --git a/tools/utils/seed/server.ts b/tools/utils/seed/server.ts index 3d461d51911acdfac9c5b2b6b467a286abb96932..7b9abd0d20eafc85b05c892d9f1133103804ebf3 100644 --- a/tools/utils/seed/server.ts +++ b/tools/utils/seed/server.ts @@ -5,7 +5,7 @@ import { resolve } from 'path'; import * as serveStatic from 'serve-static'; import * as codeChangeTool from './code_change_tools'; -import { APP_BASE, COVERAGE_PORT, DOCS_DEST, DOCS_PORT, PORT, PROD_DEST } from '../../config'; +import Config from '../../config'; /** * Serves the Single Page Application. More specifically, calls the `listen` method, which itself launches BrowserSync. @@ -31,12 +31,12 @@ export function serveDocs() { let server = express(); server.use( - APP_BASE, - serveStatic(resolve(process.cwd(), DOCS_DEST)) + Config.APP_BASE, + serveStatic(resolve(process.cwd(), Config.DOCS_DEST)) ); - server.listen(DOCS_PORT, () => - openResource('http://localhost:' + DOCS_PORT + APP_BASE) + server.listen(Config.DOCS_PORT, () => + openResource('http://localhost:' + Config.DOCS_PORT + Config.APP_BASE) ); } @@ -49,12 +49,12 @@ export function serveCoverage() { server.use(compression()); server.use( - APP_BASE, + Config.APP_BASE, serveStatic(resolve(process.cwd(), 'coverage')) ); - server.listen(COVERAGE_PORT, () => - openResource('http://localhost:' + COVERAGE_PORT + APP_BASE) + server.listen(Config.COVERAGE_PORT, () => + openResource('http://localhost:' + Config.COVERAGE_PORT + Config.APP_BASE) ); } @@ -62,16 +62,16 @@ export function serveCoverage() { * Starts a new `express` server, serving the built files from `dist/prod`. */ export function serveProd() { - let root = resolve(process.cwd(), PROD_DEST); + let root = resolve(process.cwd(), Config.PROD_DEST); let server = express(); let compression = require('compression'); server.use(compression()); - server.use(APP_BASE, serveStatic(root)); + server.use(Config.APP_BASE, serveStatic(root)); server.use(fallback('index.html', { root })); - server.listen(PORT, () => - openResource('http://localhost:' + PORT + APP_BASE) + server.listen(Config.PORT, () => + openResource('http://localhost:' + Config.PORT + Config.APP_BASE) ); }; diff --git a/tools/utils/seed/template_locals.ts b/tools/utils/seed/template_locals.ts index 8b29ed721fd56a5b14884f16a13b9309afd52539..250bf844096ec0c59e707f0e3d7d4ce08ecad605 100644 --- a/tools/utils/seed/template_locals.ts +++ b/tools/utils/seed/template_locals.ts @@ -2,7 +2,7 @@ import * as util from 'gulp-util'; import { argv } from 'yargs'; import { join } from 'path'; -import * as CONFIG from '../../config'; +import Config from '../../config'; const getConfig = (path: string, env: string): any => { const configPath = join(path, env); @@ -23,7 +23,7 @@ const getConfig = (path: string, env: string): any => { */ export function templateLocals() { const configEnvName = argv['config-env'] || 'dev'; - const configPath = CONFIG.getPluginConfig('environment-config'); + const configPath = Config.getPluginConfig('environment-config'); const baseConfig = getConfig(configPath, 'base'); const config = getConfig(configPath, configEnvName); @@ -31,7 +31,7 @@ export function templateLocals() { throw new Error('Invalid configuration name'); } - return Object.assign(CONFIG, { + return Object.assign(Config, { ENV_CONFIG: JSON.stringify(Object.assign(baseConfig, config)) }); } diff --git a/tools/utils/seed/tsproject.ts b/tools/utils/seed/tsproject.ts index f51126abc4c804abdab7dedcc9f40365f28ba8d8..87acd53117ce28d72530d7888a16dc8ec0869ebe 100644 --- a/tools/utils/seed/tsproject.ts +++ b/tools/utils/seed/tsproject.ts @@ -1,7 +1,7 @@ import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; -import { APP_SRC } from '../../config'; +import Config from '../../config'; const plugins = <any>gulpLoadPlugins(); @@ -18,7 +18,7 @@ export function makeTsProject(options: Object = {}) { typescript: require('typescript') }, options); tsProjects[optionsHash] = - plugins.typescript.createProject(join(APP_SRC, 'tsconfig.json'), config); + plugins.typescript.createProject(join(Config.APP_SRC, 'tsconfig.json'), config); } return tsProjects[optionsHash]; } diff --git a/tools/utils/seed/watch.ts b/tools/utils/seed/watch.ts index bead2e6d379d50587cba869b9f148b76656c4ea9..0169acdad7aa55d0d134dd1c0fd081194ce3913a 100644 --- a/tools/utils/seed/watch.ts +++ b/tools/utils/seed/watch.ts @@ -2,7 +2,7 @@ import * as gulpLoadPlugins from 'gulp-load-plugins'; import { join } from 'path'; import * as runSequence from 'run-sequence'; -import { APP_SRC, TEMP_FILES } from '../../config'; +import Config from '../../config'; import { notifyLiveReload } from '../../utils'; const plugins = <any>gulpLoadPlugins(); @@ -14,8 +14,8 @@ const plugins = <any>gulpLoadPlugins(); export function watch(taskname: string) { return function () { let paths:string[]=[ - join(APP_SRC,'**') - ].concat(TEMP_FILES.map((p) => { return '!'+p; })); + join(Config.APP_SRC,'**') + ].concat(Config.TEMP_FILES.map((p) => { return '!'+p; })); plugins.watch(paths, (e:any) => runSequence(taskname, () => notifyLiveReload(e))