From 862d10afa26876c7133ca13ecb785c663b55b805 Mon Sep 17 00:00:00 2001 From: Alexis Georges Date: Tue, 15 May 2018 09:27:27 +0200 Subject: [PATCH] feat(stark-all): update to Angular 6, Rxjs 6, Webpack 4, TypeScript 2.7.2 Adapt angular.json in each package. Adapt rollup config for Rxjs 6 ISSUES CLOSED: #359, #258, #19 --- combine-packages-coverage.js | 9 +- package.json | 29 ++-- packages/rollup.config.common-data.js | 21 +-- packages/stark-build/config/build-utils.js | 54 ++++--- packages/stark-build/config/ng-cli-utils.js | 28 ++-- packages/stark-build/config/webpack.common.js | 67 ++++---- packages/stark-build/config/webpack.dev.js | 21 ++- packages/stark-build/config/webpack.prod.js | 113 +++++++------- packages/stark-build/config/webpack.test.js | 2 +- packages/stark-build/package.json | 49 +++--- packages/stark-build/tsconfig.json | 4 +- packages/stark-core/.ng-cli-config.json | 16 -- packages/stark-core/angular.json | 30 ++++ .../stark-core/karma.conf.typescript.ci.js | 19 +-- packages/stark-core/package.json | 16 +- .../src/common/translations/translations.ts | 20 +-- .../http-abstract-repository.spec.ts | 2 +- .../repository/http-abstract-repository.ts | 2 +- .../http/services/http.service.intf.ts | 2 +- .../http/services/http.service.spec.ts | 81 +++++----- .../src/modules/http/services/http.service.ts | 23 +-- .../src/modules/http/testing/http.mock.ts | 2 +- .../logging/services/logging.service.spec.ts | 6 +- .../logging/services/logging.service.ts | 3 +- .../routing/services/routing.service.intf.ts | 2 +- .../routing/services/routing.service.spec.ts | 68 ++++----- .../routing/services/routing.service.ts | 6 +- .../modules/routing/testing/routing.mock.ts | 2 +- .../session/services/session.service.intf.ts | 2 +- .../session/services/session.service.spec.ts | 11 +- .../session/services/session.service.ts | 7 +- .../modules/session/testing/session.mock.ts | 2 +- .../settings/effects/settings.effects.spec.ts | 4 +- .../settings/effects/settings.effects.ts | 4 +- .../services/settings.service.spec.ts | 2 +- .../settings/services/settings.service.ts | 2 +- .../user/repository/user.repository.intf.ts | 2 +- .../user/repository/user.repository.ts | 2 +- .../user/services/user.service.intf.ts | 2 +- .../user/services/user.service.spec.ts | 6 +- .../src/modules/user/services/user.service.ts | 8 +- packages/stark-testing/helpers.js | 9 +- .../stark-testing/karma.conf.typescript.ci.js | 12 +- .../stark-testing/karma.conf.typescript.js | 14 +- packages/stark-testing/package.json | 12 +- packages/stark-ui/.ng-cli-config.json | 19 --- packages/stark-ui/angular.json | 37 +++++ packages/stark-ui/karma.conf.typescript.ci.js | 21 +-- packages/stark-ui/karma.conf.typescript.js | 30 ++-- packages/stark-ui/package.json | 17 ++- .../components/app-logo.component.pcss | 8 +- .../components/app-logo.component.spec.ts | 19 ++- .../app-logo/components/app-logo.component.ts | 7 +- starter/.angular-cli.json | 67 -------- starter/angular.json | 143 ++++++++++++++++++ starter/package.json | 42 ++--- starter/src/app/about/about.component.ts | 2 +- starter/src/app/app.routes.ts | 5 +- starter/src/app/home/home.component.ts | 2 +- starter/src/app/home/title/title.service.ts | 2 +- tsconfig-test.json | 0 61 files changed, 647 insertions(+), 572 deletions(-) delete mode 100644 packages/stark-core/.ng-cli-config.json create mode 100644 packages/stark-core/angular.json delete mode 100644 packages/stark-ui/.ng-cli-config.json create mode 100644 packages/stark-ui/angular.json delete mode 100644 starter/.angular-cli.json create mode 100644 starter/angular.json delete mode 100644 tsconfig-test.json diff --git a/combine-packages-coverage.js b/combine-packages-coverage.js index 78914f4884..604c455e53 100644 --- a/combine-packages-coverage.js +++ b/combine-packages-coverage.js @@ -1,14 +1,11 @@ const fs = require("fs"); -const StreamConcat = require('stream-concat'); +const StreamConcat = require("stream-concat"); // add the reports of all the different Stark packages to be combined -const fileNames = [ - "packages/stark-core/reports/coverage/packages/lcov.info", - "packages/stark-ui/reports/coverage/packages/lcov.info" -]; +const fileNames = ["packages/stark-core/reports/coverage/packages/lcov.info", "packages/stark-ui/reports/coverage/packages/lcov.info"]; let fileIndex = 0; -const nextStream = function () { +const nextStream = function() { if (fileIndex === fileNames.length) { return null; } diff --git a/package.json b/package.json index 5cfa371237..d3f02156e2 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,17 @@ "npm": ">=5.3.0" }, "devDependencies": { - "@angular/common": "5.2.10", - "@angular/compiler": "5.2.10", - "@angular/compiler-cli": "5.2.10", - "@angular/core": "5.2.10", - "@angular/material": "5.2.5", - "@angular/platform-browser": "5.2.10", - "@angular/platform-browser-dynamic": "5.2.10", - "@angular/router": "5.2.10", + "@angular/animations": "6.0.2", + "@angular/cli": "6.0.1", + "@angular/common": "6.0.2", + "@angular/compiler": "6.0.2", + "@angular/compiler-cli": "6.0.2", + "@angular/core": "6.0.2", + "@angular/forms": "6.0.2", + "@angular/material": "6.0.2", + "@angular/platform-browser": "6.0.2", + "@angular/platform-browser-dynamic": "6.0.2", + "@angular/router": "6.0.2", "@commitlint/cli": "6.1.3", "@commitlint/config-conventional": "6.1.3", "@ngtools/json-schema": "1.1.0", @@ -38,18 +41,19 @@ "lint-staged": "7.0.4", "prettier": "1.12.1", "release-it": "7.2.1", - "rollup": "0.58.1", - "rollup-plugin-commonjs": "9.1.0", + "rollup": "0.59.0", + "rollup-plugin-commonjs": "9.1.3", "rollup-plugin-node-resolve": "3.3.0", "rollup-plugin-sourcemaps": "0.4.2", - "rxjs": "5.6.0-forward-compat.4", + "rxjs": "6.1.0", + "rxjs-compat": "6.1.0", "stream-concat": "0.3.0", "stylelint": "9.2.0", "stylelint-config-prettier": "3.2.0", "tslint": "5.10.0", "tslint-config-prettier": "1.12.0", "tslint-sonarts": "1.6.0", - "typescript": "2.6.2", + "typescript": "2.7.2", "uglify-es": "3.3.9" }, "scripts": { @@ -95,7 +99,6 @@ "install:ci:starter": "cd starter && npm ci && cd ..", "install:travis:all": "npm run install:stark-build && npm run install:stark-testing && npm run install:stark-core && npm run install:stark-ui && npm run build:trace && npm run update:starter", "ngc": "ngc", - "prebuild": "node ./packages/validate-packages.js", "precommit": "lint-staged", "prettier-check": "prettier **/*.{css,js,json,pcss,scss,ts} --write", "preupdate:starter": "npm run clean:starter", diff --git a/packages/rollup.config.common-data.js b/packages/rollup.config.common-data.js index 23dca208e2..a0a00c206e 100644 --- a/packages/rollup.config.common-data.js +++ b/packages/rollup.config.common-data.js @@ -25,26 +25,7 @@ const globals = { uuid: "uuid", rxjs: "rxjs", - - // this should be the preferred way to import RxJS operators: https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md - // we should only use that in our code base - "rxjs/operators": "rxjs.operators", - "rxjs/operators/catchError": "rxjs.operators.catchError", - "rxjs/operators/filter": "rxjs.operators.filter", - "rxjs/operators/map": "rxjs.operators.map", - "rxjs/operators/mergeMap": "rxjs.operators.mergeMap", - "rxjs/operators/retryWhen": "rxjs.operators.retryWhen", - "rxjs/operators/take": "rxjs.operators.take", - - "rxjs/observable/defer": "rxjs/observable/defer", - "rxjs/observable/empty": "rxjs.observable.empty", - "rxjs/observable/timer": "rxjs.observable.time", - "rxjs/observable/fromPromise": "rxjs.observable.fromPromise", - "rxjs/observable/throw": "rxjs.observable.throw", - - "rxjs/Observable": "Rx", - "rxjs/Subject": "Rx" - //"rxjs/Subscription": "Rx", + "rxjs/operators": "rxjs.operators" // TODO add lines such as the one below to make sure that stark modules that depend on other stark modules can find those // '@nationalbankbelgium/core': 'stark.core', diff --git a/packages/stark-build/config/build-utils.js b/packages/stark-build/config/build-utils.js index bd9c526ec3..cc4facec16 100644 --- a/packages/stark-build/config/build-utils.js +++ b/packages/stark-build/config/build-utils.js @@ -12,7 +12,7 @@ const DEFAULT_METADATA = { AOT: process.env.BUILD_AOT || helpers.hasNpmFlag("aot"), E2E: !!process.env.BUILD_E2E, WATCH: helpers.hasProcessFlag("watch"), - tsConfigPath: getAngularCliAppConfig().tsconfig, + tsConfigPath: getAngularCliAppConfig()["architect"]["build"]["options"].tsConfig, environment: "" }; @@ -31,13 +31,20 @@ function readTsConfig(tsConfigPath) { function getEnvironmentFile(environment) { if (typeof environment === "string") { - let fileName = helpers.root("src/" + getAngularCliAppConfig().environments[environment]); + let fileName = helpers.root("src/environments/environment.ts"); + let fileNameAlt; + let angularCliEnvConfig = getAngularCliAppConfig()["architect"]["build"]["configurations"][environment]; + + if (angularCliEnvConfig && angularCliEnvConfig.fileReplacements) { + fileName = helpers.root(angularCliEnvConfig.fileReplacements.with); + fileNameAlt = helpers.root(angularCliEnvConfig.fileReplacements.replace); + } if (fs.existsSync(fileName)) { return fileName; - } else if (fs.existsSync((fileName = helpers.root("src/" + getAngularCliAppConfig().environmentSource)))) { + } else if (fs.existsSync(fileNameAlt)) { console.warn(`Could not find environment file for ${environment}, loading default environment file`); - return fileName; + return fileNameAlt; } else { throw new Error("Environment file not found."); } @@ -62,8 +69,8 @@ function rxjsAlias(supportES2015) { } /** - * Foreach installed NationalBankBelgium packages, read assets.json file in the root of the module. - * Based on assets.json file, fill an array with the needed assets for the module. + * Foreach installed NationalBankBelgium packages, read angular.json file in the root of the module. + * Based on angular.json file, fill an array with the needed assets for the module. * Then return those to be read by CopyWebpackPlugin. */ function getNbbAssetsConfig() { @@ -73,14 +80,18 @@ function getNbbAssetsConfig() { const nbbPackages = ngCliUtils.getDirectoriesNames(helpers.root(NBB_MODULES_PATH)); for (const nbbPackage of nbbPackages) { - const ngCliConfigPath = helpers.root(NBB_MODULES_PATH + "/" + nbbPackage + "/" + ".ng-cli-config.json"); + const ngCliConfigPath = helpers.root(NBB_MODULES_PATH + "/" + nbbPackage + "/" + "angular.json"); if (fs.existsSync(ngCliConfigPath)) { const packageCliConfig = require(ngCliConfigPath); const cliConfig = ngCliUtils.validateAngularCLIConfig(packageCliConfig); if (cliConfig) { - if (cliConfig["apps"] && cliConfig["apps"][0] && cliConfig["apps"][0].assets) { - customAssets = [...customAssets, ...getCopyWebpackPluginConfig(cliConfig["apps"][0].assets)]; + let cliProjectConfig; + if (cliConfig["defaultProject"] && (cliProjectConfig = cliConfig["projects"][cliConfig["defaultProject"]])) { + customAssets = [ + ...customAssets, + ...getCopyWebpackPluginConfig(cliProjectConfig["architect"]["build"]["options"].assets) + ]; } } } @@ -90,26 +101,31 @@ function getNbbAssetsConfig() { } /** - * Returns assets set in .angular-cli.json file of the project. + * Returns assets set in angular.json file of the project. */ function getApplicationAssetsConfig() { const appConfig = getAngularCliAppConfig(); - if (appConfig.assets) { - return getCopyWebpackPluginConfig(appConfig.assets); + if ( + appConfig["architect"] && + appConfig["architect"]["build"] && + appConfig["architect"]["build"]["options"] && + appConfig["architect"]["build"]["options"]["assets"] + ) { + return getCopyWebpackPluginConfig(appConfig["architect"]["build"]["options"]["assets"]); } return []; } function getAngularCliAppConfig() { - const applicationAngularCliConfigPath = helpers.root(".angular-cli.json"); + const applicationAngularCliConfigPath = helpers.root("angular.json"); if (fs.existsSync(applicationAngularCliConfigPath)) { const angularCliConfig = require(applicationAngularCliConfigPath); const cliConfig = ngCliUtils.validateAngularCLIConfig(angularCliConfig); if (cliConfig) { - if (cliConfig["apps"] && cliConfig["apps"][0]) { - return cliConfig["apps"][0]; + if (cliConfig["defaultProject"] && cliConfig["projects"][cliConfig["defaultProject"]]) { + return cliConfig["projects"][cliConfig["defaultProject"]]; } else { throw new Error("Angular-cli config apps is wrong. Please adapt it to follow Angular CLI way."); } @@ -117,7 +133,7 @@ function getAngularCliAppConfig() { throw new Error("Parsing " + applicationAngularCliConfigPath + " failed. Ensure the file is valid JSON."); } } else { - throw new Error(".angular-cli.json is not present. Please add this at the root your project because stark-build needs this."); + throw new Error("angular.json is not present. Please add this at the root your project because stark-build needs this."); } } @@ -129,8 +145,8 @@ function getAngularCliAppConfig() { function getCopyWebpackPluginConfig(assets) { const appConfig = getAngularCliAppConfig(); - const projectRoot = helpers.root(""); - const appRoot = helpers.root(appConfig.root); + const projectRoot = helpers.root(appConfig.root); + const appRoot = helpers.root(appConfig.sourceRoot); return assets.map(asset => { // Convert all string assets to object notation. @@ -144,7 +160,7 @@ function getCopyWebpackPluginConfig(assets) { // specify a configuration flag. // Also prevent writing outside the project path. That is not overridable. // For info: Comparing to implementation of Angular, "buildOptions.outputPath" has been replaced by "appConfig.outDir" - const absoluteOutputPath = path.resolve(projectRoot, appConfig.outDir); + const absoluteOutputPath = path.resolve(projectRoot, appConfig["architect"]["build"]["options"]["outputPath"]); const absoluteAssetOutput = path.resolve(absoluteOutputPath, asset.output); const outputRelativeOutput = path.relative(absoluteOutputPath, absoluteAssetOutput); if (outputRelativeOutput.startsWith("..") || path.isAbsolute(outputRelativeOutput)) { diff --git a/packages/stark-build/config/ng-cli-utils.js b/packages/stark-build/config/ng-cli-utils.js index 16240d6671..970ae34ae8 100644 --- a/packages/stark-build/config/ng-cli-utils.js +++ b/packages/stark-build/config/ng-cli-utils.js @@ -1,5 +1,7 @@ const path = require("path"); const fs = require("fs"); +const cliUtilConfig = require("@angular/cli/utilities/config"); +const { formatDiagnostics } = require("@angular/compiler-cli/ngtools2"); function isDirectory(path) { try { @@ -22,18 +24,26 @@ function getDirectoriesNames(source) { * @returns {*} */ function validateAngularCLIConfig(jsonConfig) { - const SchemaClassFactory = require("@ngtools/json-schema").SchemaClassFactory; - const schema = require("@angular/cli/lib/config/schema.json"); + // FIXME Adapt usage for Angular CLI 6 + return jsonConfig; - const config = new (SchemaClassFactory(schema))(jsonConfig); - try { - const serializedConfig = JSON.parse(config.$$serialize("application/json")); - return serializedConfig; - } catch (error) { - return false; - } + // const SchemaClassFactory = require("@ngtools/json-schema").SchemaClassFactory; + // const schema = require("@angular/cli/lib/config/schema.json"); + // + // const config = new (SchemaClassFactory(schema))(jsonConfig); + // try { + // const serializedConfig = JSON.parse(config.$$serialize("application/json")); + // return serializedConfig; + // } catch (error) { + // return false; + // } +} + +function getWorkspace() { + return cliUtilConfig.getWorkspace(); } exports.getDirectoriesNames = getDirectoriesNames; exports.isDirectory = isDirectory; exports.validateAngularCLIConfig = validateAngularCLIConfig; +exports.getWorkspace = getWorkspace; diff --git a/packages/stark-build/config/webpack.common.js b/packages/stark-build/config/webpack.common.js index 53910f3103..96d44d9971 100644 --- a/packages/stark-build/config/webpack.common.js +++ b/packages/stark-build/config/webpack.common.js @@ -9,15 +9,14 @@ const commonData = require("./webpack.common-data.js"); // common configuration * problem with copy-webpack-plugin */ // const DefinePlugin = require("webpack/lib/DefinePlugin"); -const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); +const SplitChunksPlugin = require("webpack/lib/optimize/SplitChunksPlugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const BaseHrefWebpackPlugin = require("base-href-webpack-plugin").BaseHrefWebpackPlugin; // const InlineManifestWebpackPlugin = require("inline-manifest-webpack-plugin"); // const ScriptExtHtmlWebpackPlugin = require("script-ext-html-webpack-plugin"); const { AngularCompilerPlugin } = require("@ngtools/webpack"); -const { NamedLazyChunksWebpackPlugin } = require("@angular/cli/plugins/webpack"); -const NoEmitOnErrorsPlugin = require("webpack/lib/NoEmitOnErrorsPlugin"); +const AngularNamedLazyChunksWebpackPlugin = require("angular-named-lazy-chunks-webpack-plugin"); const WebpackSHAHash = require("webpack-sha-hash"); const ContextReplacementPlugin = require("webpack/lib/ContextReplacementPlugin"); const PurifyPlugin = require("@angular-devkit/build-optimizer").PurifyPlugin; @@ -68,7 +67,7 @@ module.exports = function(options) { }; const angularCliAppConfig = buildUtils.getAngularCliAppConfig(); - const rootDir = angularCliAppConfig.root; + const rootDir = angularCliAppConfig.sourceRoot; return { /** @@ -106,7 +105,7 @@ module.exports = function(options) { * The entry point for the bundle * Our Angular.js app * - * See: http://webpack.github.io/docs/configuration.html#entry + * See: https://webpack.js.org/configuration/entry-context/#entry */ entry: entry, @@ -152,6 +151,10 @@ module.exports = function(options) { alias: buildUtils.rxjsAlias(supportES2015) }, + optimization: { + noEmitOnErrors: true + }, + /** * Options affecting the normal modules. * @@ -193,7 +196,12 @@ module.exports = function(options) { enforce: "pre", test: /\.js$/, use: ["source-map-loader"], - exclude: [/\.ngfactory\.js$/, /\.ngstyle\.js$/, helpers.root("node_modules/@ng-idle")] + exclude: [ + /\.ngfactory\.js$/, + /\.ngstyle\.js$/, + helpers.root("node_modules/rxjs-compat"), + helpers.root("node_modules/@ng-idle") + ] }, /** @@ -307,23 +315,17 @@ module.exports = function(options) { // }), /** - * Plugin: NamedLazyChunksWebpackPlugin + * Plugin: AngularNamedLazyChunksWebpackPlugin * Description: Assigns names to the async chunks generated by Webpack for lazy routes in an Angular app. * - * See: https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/plugins/named-lazy-chunks-webpack-plugin.ts + * TODO See if it is available in Angular Dev Kit + * See: https://github.com/angular/angular-cli/issues/8184 + * See: https://github.com/Independer/angular-named-lazy-chunks-webpack-plugin */ - new NamedLazyChunksWebpackPlugin(), + new AngularNamedLazyChunksWebpackPlugin(), new PurifyPlugin(), - /** - * Plugin: NoEmitOnErrorsPlugin - * Description: Only emit files when there are no errors. - * - * See: https://webpack.js.org/plugins/no-emit-on-errors-plugin - */ - new NoEmitOnErrorsPlugin(), - /** * Plugin: CommonsChunkPlugin * Description: Shares common code between the pages. @@ -332,21 +334,22 @@ module.exports = function(options) { * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app */ - new CommonsChunkPlugin({ - name: "polyfills", - chunks: ["polyfills"] - }), - - new CommonsChunkPlugin({ - minChunks: Infinity, - name: "inline" - }), - new CommonsChunkPlugin({ - name: "main", - async: "common", - children: true, - minChunks: 2 - }), + // FIXME Configure splitChunks + // new CommonsChunkPlugin({ + // name: "polyfills", + // chunks: ["polyfills"] + // }), + // + // new CommonsChunkPlugin({ + // minChunks: Infinity, + // name: "inline" + // }), + // new CommonsChunkPlugin({ + // name: "main", + // async: "common", + // children: true, + // minChunks: 2 + // }), /** * Plugin: CopyWebpackPlugin diff --git a/packages/stark-build/config/webpack.dev.js b/packages/stark-build/config/webpack.dev.js index e34835210e..16e9fc0e50 100644 --- a/packages/stark-build/config/webpack.dev.js +++ b/packages/stark-build/config/webpack.dev.js @@ -9,7 +9,6 @@ const commonData = require("./webpack.common-data.js"); // the settings that are /** * Webpack Plugins */ -const NamedModulesPlugin = require("webpack/lib/NamedModulesPlugin"); const SourceMapDevToolPlugin = require("webpack/lib/SourceMapDevToolPlugin"); const WriteFilePlugin = require("write-file-webpack-plugin"); @@ -64,7 +63,7 @@ module.exports = function(env) { ]; const angularCliAppConfig = buildUtils.getAngularCliAppConfig(); - const rootDir = angularCliAppConfig.root; + const rootDir = angularCliAppConfig.sourceRoot; return webpackMerge(commonConfig({ ENV: ENV, metadata: METADATA }), { /** @@ -74,6 +73,12 @@ module.exports = function(env) { */ target: "web", // <== can be omitted as default is "web" + mode: "development", + + optimization: { + namedModules: true + }, + /** * Options affecting the output of the compilation. * @@ -85,7 +90,7 @@ module.exports = function(env) { * * See: https://webpack.js.org/configuration/output/#output-path */ - path: helpers.root(angularCliAppConfig.outDir), + path: helpers.root(angularCliAppConfig.architect.build.options.outputPath), /** * This option specifies the public URL of the output directory when referenced in a browser. @@ -94,7 +99,7 @@ module.exports = function(env) { * * See: https://webpack.js.org/configuration/output/#output-publicpath */ - publicPath: angularCliAppConfig.deployUrl, + publicPath: angularCliAppConfig.architect.build.options.deployUrl, /** * Specifies the name of each output file on disk. @@ -212,14 +217,6 @@ module.exports = function(env) { sourceRoot: "webpack:///" }), - /** - * Plugin: NamedModulesPlugin (experimental) - * Description: Uses file names as module name. - * - * See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb - */ - new NamedModulesPlugin(), - /** * Plugin: WriteFilePlugin * Description: This plugin makes sure that bundles and assets are written to disk diff --git a/packages/stark-build/config/webpack.prod.js b/packages/stark-build/config/webpack.prod.js index 46e1adb93b..a01ceb3869 100644 --- a/packages/stark-build/config/webpack.prod.js +++ b/packages/stark-build/config/webpack.prod.js @@ -17,10 +17,10 @@ const commonData = require("./webpack.common-data.js"); * Webpack Plugins */ const SourceMapDevToolPlugin = require("webpack/lib/SourceMapDevToolPlugin"); -const ExtractTextPlugin = require("extract-text-webpack-plugin"); const HashedModuleIdsPlugin = require("webpack/lib/HashedModuleIdsPlugin"); const PurifyPlugin = require("@angular-devkit/build-optimizer").PurifyPlugin; -const ModuleConcatenationPlugin = require("webpack/lib/optimize/ModuleConcatenationPlugin"); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); function getUglifyOptions(supportES2015) { @@ -56,7 +56,7 @@ module.exports = function() { }); const angularCliAppConfig = buildUtils.getAngularCliAppConfig(); - const rootDir = angularCliAppConfig.root; + const rootDir = angularCliAppConfig.sourceRoot; METADATA.environment = METADATA.E2E ? "e2e.prod" : "prod"; @@ -73,6 +73,29 @@ module.exports = function() { optimizationBailout: true // display bailout reasons (ModuleConcatenationPlugin debugging) }, + mode: "production", + + optimization: { + minimizer: [ + /** + * Plugin: UglifyJsPlugin + * Description: Minimize all JavaScript output of chunks. + * Loaders are switched into minimizing mode. + * + * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin + * + * NOTE: To debug prod builds uncomment //debug lines and comment //prod lines + */ + new UglifyJsPlugin({ + sourceMap: true, + uglifyOptions: getUglifyOptions(supportES2015) + }), + + new OptimizeCSSAssetsPlugin({}) + ], + concatenateModules: true + }, + /** * Options affecting the output of the compilation. * @@ -84,7 +107,7 @@ module.exports = function() { * * See: https://webpack.js.org/configuration/output/#output-path */ - path: helpers.root(angularCliAppConfig.outDir), + path: helpers.root(angularCliAppConfig.architect.build.options.outputPath), /** * This option specifies the public URL of the output directory when referenced in a browser. @@ -93,7 +116,7 @@ module.exports = function() { * * See: https://webpack.js.org/configuration/output/#output-publicpath */ - publicPath: angularCliAppConfig.deployUrl, + publicPath: angularCliAppConfig.architect.build.options.deployUrl, /** * Specifies the name of each output file on disk. @@ -127,10 +150,7 @@ module.exports = function() { */ { test: /\.css$/, - loader: ExtractTextPlugin.extract({ - fallback: "style-loader", - use: "css-loader" - }), + use: [MiniCssExtractPlugin.loader, "css-loader"], include: [helpers.root(rootDir, "styles")] }, @@ -139,10 +159,7 @@ module.exports = function() { */ { test: /\.scss$/, - loader: ExtractTextPlugin.extract({ - fallback: "style-loader", - use: "css-loader!sass-loader" - }), + use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"], include: [helpers.root(rootDir, "styles")] }, @@ -151,30 +168,28 @@ module.exports = function() { */ { test: /\.pcss$/, - loader: ExtractTextPlugin.extract({ - fallback: "style-loader", - use: [ - { - loader: "css-loader", - options: { - //modules: true, // to check if needed - //minimize: true, - // even if disabled, sourceMaps gets generated - sourceMap: false, // true - autoprefixer: false, - // see https://github.com/webpack-contrib/css-loader#importloaders) - importLoaders: 1 // 1 => postcss-loader - } - }, - { - loader: "postcss-loader", - options: { - sourceMap: true, - plugins: commonData.postcssPlugins - } + use: [ + MiniCssExtractPlugin.loader, + { + loader: "css-loader", + options: { + //modules: true, // to check if needed + //minimize: true, + // even if disabled, sourceMaps gets generated + sourceMap: false, // true + autoprefixer: false, + // see https://github.com/webpack-contrib/css-loader#importloaders) + importLoaders: 1 // 1 => postcss-loader + } + }, + { + loader: "postcss-loader", + options: { + sourceMap: true, + plugins: commonData.postcssPlugins } - ] - }), + } + ], include: [helpers.root(rootDir, "styles")] } ] @@ -207,12 +222,15 @@ module.exports = function() { }), /** - * Plugin: ExtractTextPlugin + * Plugin: MiniCssExtractPlugin * Description: Extracts imported CSS files into external stylesheet * - * See: https://github.com/webpack/extract-text-webpack-plugin + * See: https://github.com/webpack-contrib/mini-css-extract-plugin */ - new ExtractTextPlugin("[name].[contenthash].css"), + new MiniCssExtractPlugin({ + filename: "[name].[contenthash].css", + chunkFilename: "[id].[contenthash].css" + }), // TODO remove since it's probably useless here (defined in webpack.common.js) new PurifyPlugin() /* buildOptimizer */, @@ -220,22 +238,7 @@ module.exports = function() { /** * See: https://webpack.js.org/plugins/hashed-module-ids-plugin/ */ - new HashedModuleIdsPlugin(), - new ModuleConcatenationPlugin(), - - /** - * Plugin: UglifyJsPlugin - * Description: Minimize all JavaScript output of chunks. - * Loaders are switched into minimizing mode. - * - * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin - * - * NOTE: To debug prod builds uncomment //debug lines and comment //prod lines - */ - new UglifyJsPlugin({ - sourceMap: true, - uglifyOptions: getUglifyOptions(supportES2015) - }) + new HashedModuleIdsPlugin() ] }); }; diff --git a/packages/stark-build/config/webpack.test.js b/packages/stark-build/config/webpack.test.js index 1f6f7c1f9a..c88acc0cbd 100644 --- a/packages/stark-build/config/webpack.test.js +++ b/packages/stark-build/config/webpack.test.js @@ -19,7 +19,7 @@ const ContextReplacementPlugin = require("webpack/lib/ContextReplacementPlugin") const ENV = (process.env.ENV = process.env.NODE_ENV = "test"); const angularCliAppConfig = buildUtils.getAngularCliAppConfig(); -const rootDir = angularCliAppConfig.root; +const rootDir = angularCliAppConfig.sourceRoot; /** * Webpack configuration diff --git a/packages/stark-build/package.json b/packages/stark-build/package.json index 5c4e457bd8..e281301aa1 100644 --- a/packages/stark-build/package.json +++ b/packages/stark-build/package.json @@ -18,44 +18,48 @@ "npm": ">=5.3.0" }, "dependencies": { - "@angular-devkit/build-optimizer": "0.4.9", + "@angular-devkit/build-angular": "0.6.1", + "@angular-devkit/build-optimizer": "0.6.1", "@angularclass/hmr": "2.1.3", - "@types/webpack": "3.8.11", + "@types/webpack": "4.1.7", "add-asset-html-webpack-plugin": "2.1.3", + "angular-named-lazy-chunks-webpack-plugin": "2.0.0", "angular2-template-loader": "0.6.2", "assets-webpack-plugin": "3.5.1", - "awesome-typescript-loader": "3.5.0", + "awesome-typescript-loader": "5.0.0", "base-href-webpack-plugin": "1.0.2", + "circular-dependency-plugin": "5.0.2", "codelyzer": "4.3.0", "copy-webpack-plugin": "4.5.1", "css-loader": "0.28.11", "exports-loader": "0.7.0", "expose-loader": "0.7.5", - "extract-text-webpack-plugin": "3.0.2", "file-loader": "1.1.11", "html-webpack-plugin": "3.2.0", "husky": "0.14.3", "imports-loader": "0.8.0", - "inline-manifest-webpack-plugin": "3.0.1", - "lint-staged": "7.0.4", - "node-sass": "4.8.3", + "inline-manifest-webpack-plugin": "4.0.0", + "lint-staged": "7.1.0", + "mini-css-extract-plugin": "0.4.0", + "node-sass": "4.9.0", "postcss-cssnext": "3.1.0", "postcss-import": "11.1.0", - "postcss-loader": "2.1.4", - "postcss-nesting": "4.2.1", + "postcss-loader": "2.1.5", + "postcss-nesting": "5.0.0", "postcss-simple-extend": "1.0.0", "postcss-url": "7.3.2", "preload-webpack-plugin": "2.3.0", "prettier": "1.12.1", + "optimize-css-assets-webpack-plugin": "4.0.1", "raw-loader": "0.5.1", "sass-loader": "7.0.1", "script-ext-html-webpack-plugin": "2.0.1", "source-map-loader": "0.2.3", "string-replace-loader": "2.1.1", + "style-loader": "0.21.0", "stylelint": "9.2.0", "stylelint-config-prettier": "3.2.0", "stylelint-webpack-plugin": "0.10.4", - "style-loader": "0.20.3", "to-string-loader": "1.1.5", "tslint": "5.10.0", "tslint-config-prettier": "1.12.0", @@ -63,26 +67,27 @@ "tslint-sonarts": "1.6.0", "uglifyjs-webpack-plugin": "1.2.5", "url-loader": "1.0.1", - "webpack": "3.11.0", - "webpack-dev-middleware": "2.0.6", - "webpack-dev-server": "2.11.2", + "webpack": "4.8.3", + "webpack-cli": "2.1.3", + "webpack-dev-middleware": "3.1.3", + "webpack-dev-server": "3.1.4", "webpack-dll-bundles-plugin": "^1.0.0-beta.5", "webpack-merge": "4.1.2", "webpack-monitor": "1.0.14", "webpack-sha-hash": "2.0.0", - "write-file-webpack-plugin": "4.2.0" + "write-file-webpack-plugin": "4.3.1" }, "devDependencies": { - "@angular/cli": "1.7.4", - "@angular/compiler": "5.2.10", - "@angular/compiler-cli": "5.2.10" + "@angular/cli": "6.0.1", + "@angular/compiler": "6.0.2", + "@angular/compiler-cli": "6.0.2" }, "peerDependencies": { - "@angular/cli": "1.x", - "@angular/compiler": "5.x", - "@angular/compiler-cli": "5.x", - "@angular/platform-browser": "5.x", - "@angular/platform-browser-dynamic": "5.x" + "@angular/cli": "6.x", + "@angular/compiler": "6.x", + "@angular/compiler-cli": "6.x", + "@angular/platform-browser": "6.x", + "@angular/platform-browser-dynamic": "6.x" }, "scripts": { "clean": "npx rimraf dist", diff --git a/packages/stark-build/tsconfig.json b/packages/stark-build/tsconfig.json index a9837837e5..ca67f11dcf 100644 --- a/packages/stark-build/tsconfig.json +++ b/packages/stark-build/tsconfig.json @@ -45,7 +45,9 @@ "rootDirs": ["./src", "./config"], "lib": ["dom", "dom.iterable", "es2017"], "typeRoots": ["./node_modules/@types"], - "paths": {} + "paths": {}, + // FIXME set this to true asap we have a newer version of IntelliJ + "strictPropertyInitialization": false }, "exclude": ["node_modules", "dist", "packages/stark-build/config-stark"], "awesomeTypescriptLoaderOptions": { diff --git a/packages/stark-core/.ng-cli-config.json b/packages/stark-core/.ng-cli-config.json deleted file mode 100644 index 5830a4c008..0000000000 --- a/packages/stark-core/.ng-cli-config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "project": { - "name": "stark-core" - }, - "apps": [ - { - "root": "src", - "outDir": "dist", - "assets": [], - "test": "base.spec.ts", - "tsconfig": "tsconfig-build.json", - "testTsconfig": "tsconfig.spec.json" - } - ] -} diff --git a/packages/stark-core/angular.json b/packages/stark-core/angular.json new file mode 100644 index 0000000000..6a8e4f6e0f --- /dev/null +++ b/packages/stark-core/angular.json @@ -0,0 +1,30 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoots": "projects", + "projects": { + "stark-core": { + "root": "", + "sourceRoot": "src", + "projectType": "library", + "architect": { + "build": { + "options": { + "outputPath": "dist", + "tsConfig": "tsconfig-build.json", + "assets": [] + } + }, + "test": { + "options": { + "main": "base.spec.ts", + "outputPath": "dist", + "tsConfig": "tsconfig.spec.json", + "assets": [] + } + } + } + } + }, + "defaultProject": "stark-core" +} diff --git a/packages/stark-core/karma.conf.typescript.ci.js b/packages/stark-core/karma.conf.typescript.ci.js index 9aa8abd0e9..7b315fc06b 100644 --- a/packages/stark-core/karma.conf.typescript.ci.js +++ b/packages/stark-core/karma.conf.typescript.ci.js @@ -6,19 +6,12 @@ const helpers = require("./node_modules/@nationalbankbelgium/stark-testing/helpe const defaultKarmaCIConfig = require("./node_modules/@nationalbankbelgium/stark-testing/karma.conf.typescript.ci.js").rawKarmaConfig; // start customizing the KarmaCI configuration from stark-testing -const starkCoreSpecificConfiguration = Object.assign( - {}, - defaultKarmaCIConfig, - { - // change the path of the report so that Coveralls takes the right path to the source files - coverageIstanbulReporter: Object.assign( - defaultKarmaCIConfig.coverageIstanbulReporter, - { - dir: helpers.root("reports/coverage/packages") - } - ) - } -); +const starkCoreSpecificConfiguration = Object.assign({}, defaultKarmaCIConfig, { + // change the path of the report so that Coveralls takes the right path to the source files + coverageIstanbulReporter: Object.assign(defaultKarmaCIConfig.coverageIstanbulReporter, { + dir: helpers.root("reports/coverage/packages") + }) +}); // export the configuration function that karma expects and simply return the stark configuration module.exports = config => { diff --git a/packages/stark-core/package.json b/packages/stark-core/package.json index 0d6d69e1fb..0fc1e66a32 100644 --- a/packages/stark-core/package.json +++ b/packages/stark-core/package.json @@ -28,14 +28,13 @@ "dependencies": { "@ng-idle/core": "2.0.0-beta.15", "@ng-idle/keepalive": "2.0.0-beta.15", - "@ngx-translate/core": "9.1.1", "@ngrx/effects": "5.2.0", "@ngrx/store": "5.2.0", + "@ngx-translate/core": "10.0.1", "@types/core-js": "0.9.46", - "@types/jasmine": "2.8.6", "@types/node": "6.0.106", "@types/uuid": "3.4.3", - "@uirouter/angular": "1.0.1", + "@uirouter/angular": "2.0.0", "cerialize": "0.1.18", "class-validator": "0.7.3", "core-js": "2.5.5", @@ -49,11 +48,12 @@ "@nationalbankbelgium/stark-testing": "../stark-testing" }, "peerDependencies": { - "@angular/common": "5.x", - "@angular/core": "5.x", - "@angular/router": "5.x", - "rxjs": "5.x", - "typescript": ">=2.6.0 && <2.7.0" + "@angular/common": "6.x", + "@angular/core": "6.x", + "@angular/router": "6.x", + "rxjs": "6.x", + "rxjs-compat": "6.x", + "typescript": ">=2.7.2 && <2.8.0" }, "scripts": { "clean": "npx rimraf dist", diff --git a/packages/stark-core/src/common/translations/translations.ts b/packages/stark-core/src/common/translations/translations.ts index d54f0a1a1f..4f2cbac3bf 100644 --- a/packages/stark-core/src/common/translations/translations.ts +++ b/packages/stark-core/src/common/translations/translations.ts @@ -7,18 +7,18 @@ import { translationsFr } from "./translations/fr"; import { translationsNl } from "./translations/nl"; /** - * This function can be used by Stark modules to merge their translations into existing translations, + * This function can be used by Stark modules to merge their translations into existing translations, * without losing any existing translations. - * + * * There are three 'levels' that can provide translations: * 1. Common: for the Stark framework, they are stored in the 'translations' folder in the current folder. * 2. Module: each module contains it's own translations, to make Stark fully modular. * 3. App: the translations provided by the client application that implements the Stark framework. - * + * * These levels have a hierarchy, where the common translations have to lowest priority and the translations - * of the client application have the highest priority. This means that if one or more levels have a - * translation with the same key, the translation with the highest priority 'wins'. - * + * of the client application have the highest priority. This means that if one or more levels have a + * translation with the same key, the translation with the highest priority 'wins'. + * * Functionality: * First the existing translations are stored in a variable 'translations'. * The function then iterates over the 'args' parameters. @@ -27,12 +27,12 @@ import { translationsNl } from "./translations/nl"; * 2. The 'common' translations are added in the translateService * 3. The 'module' translations are added in the translateService, replacing any existing translations * 4. The 'stored' translations are added in the translateService, replacing any existing translations - * + * * @param translateService - * Description: a reference to the translateService instance + * Description: a reference to the translateService instance * @param args - * Description: a list of StarkLocales that contain the translations for a specific language - * + * Description: a list of StarkLocales that contain the translations for a specific language + * * @example: * mergeTranslations(this.translateService, english, french, dutch); */ diff --git a/packages/stark-core/src/modules/http/repository/http-abstract-repository.spec.ts b/packages/stark-core/src/modules/http/repository/http-abstract-repository.spec.ts index 443474792f..55d5e7f990 100644 --- a/packages/stark-core/src/modules/http/repository/http-abstract-repository.spec.ts +++ b/packages/stark-core/src/modules/http/repository/http-abstract-repository.spec.ts @@ -1,4 +1,4 @@ -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { AbstractStarkHttpRepository } from "./http-abstract-repository"; import { StarkSerializable } from "../../../serialization"; import { diff --git a/packages/stark-core/src/modules/http/repository/http-abstract-repository.ts b/packages/stark-core/src/modules/http/repository/http-abstract-repository.ts index ff5d93a770..015fa4cd57 100644 --- a/packages/stark-core/src/modules/http/repository/http-abstract-repository.ts +++ b/packages/stark-core/src/modules/http/repository/http-abstract-repository.ts @@ -1,4 +1,4 @@ -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { StarkBackend } from "../entities/backend"; import { StarkCollectionResponseWrapper, StarkResource, StarkSingleItemResponseWrapper } from "../entities"; import { diff --git a/packages/stark-core/src/modules/http/services/http.service.intf.ts b/packages/stark-core/src/modules/http/services/http.service.intf.ts index 03194f09a6..a31981d468 100644 --- a/packages/stark-core/src/modules/http/services/http.service.intf.ts +++ b/packages/stark-core/src/modules/http/services/http.service.intf.ts @@ -1,7 +1,7 @@ import { InjectionToken } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { StarkCollectionResponseWrapper, StarkHttpRequest, StarkResource, StarkSingleItemResponseWrapper } from "../entities"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; export const starkHttpServiceName: string = "StarkHttpService"; export const STARK_HTTP_SERVICE: InjectionToken> = new InjectionToken>(starkHttpServiceName); diff --git a/packages/stark-core/src/modules/http/services/http.service.spec.ts b/packages/stark-core/src/modules/http/services/http.service.spec.ts index 7c2b992d25..19818e0c5a 100644 --- a/packages/stark-core/src/modules/http/services/http.service.spec.ts +++ b/packages/stark-core/src/modules/http/services/http.service.spec.ts @@ -2,13 +2,8 @@ import createSpyObj = jasmine.createSpyObj; import Spy = jasmine.Spy; import SpyObj = jasmine.SpyObj; import { autoserialize, autoserializeAs, inheritSerialization, Serialize } from "cerialize"; -import { Observable } from "rxjs/Observable"; -import { of } from "rxjs/observable/of"; -import { _throw as observableThrow } from "rxjs/observable/throw"; -// FIXME: importing from single entry "rxjs/operators" together with webpack's scope hoisting prevents dead code removal -// see https://github.com/ReactiveX/rxjs/issues/2981 -import { catchError } from "rxjs/operators/catchError"; -import { ErrorObservable } from "rxjs/observable/ErrorObservable"; +import { Observable, of, throwError } from "rxjs"; +import { catchError } from "rxjs/operators"; import { HttpClient, HttpHeaders, HttpResponse, HttpErrorResponse } from "@angular/common/http"; import { StarkHttpServiceImpl } from "./http.service"; @@ -400,7 +395,7 @@ describe("Service: StarkHttpService", () => { error: mockHttpError, headers: httpHeadersGetter(httpHeaders) }; - httpMock.get.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.get.and.returnValue(throwError(httpErrorResponse)); const resultObs: Observable> = starkHttpService.executeSingleItemRequest( request @@ -431,10 +426,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.get.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -512,7 +507,7 @@ describe("Service: StarkHttpService", () => { error: mockHttpError, headers: httpHeadersGetter(httpHeaders) }; - httpMock.delete.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.delete.and.returnValue(throwError(httpErrorResponse)); const resultObs: Observable> = starkHttpService.executeSingleItemRequest( request @@ -543,10 +538,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.delete.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -767,7 +762,7 @@ describe("Service: StarkHttpService", () => { error: mockHttpError, headers: httpHeadersGetter(httpHeaders) }; - httpMock.post.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.post.and.returnValue(throwError(httpErrorResponse)); request.requestType = StarkHttpRequestType.UPDATE; @@ -805,10 +800,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.post.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -838,7 +833,7 @@ describe("Service: StarkHttpService", () => { error: mockHttpError, headers: httpHeadersGetter(httpHeaders) }; - httpMock.put.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.put.and.returnValue(throwError(httpErrorResponse)); request.requestType = StarkHttpRequestType.UPDATE_IDEMPOTENT; @@ -876,10 +871,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.put.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -1023,7 +1018,7 @@ describe("Service: StarkHttpService", () => { error: mockHttpError, headers: httpHeadersGetter(httpHeaders) }; - httpMock.post.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.post.and.returnValue(throwError(httpErrorResponse)); const resultObs: Observable> = starkHttpService.executeSingleItemRequest( request @@ -1060,10 +1055,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.post.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -1098,9 +1093,18 @@ describe("Service: StarkHttpService", () => { item: mockResourceWithoutEtag, serializer: mockResourceSerializer }; - const result: ErrorObservable = starkHttpService.executeSingleItemRequest(request); - expect(result instanceof ErrorObservable).toBe(true); - expect(result.error).toContain("Unknown request type"); + + starkHttpService.executeSingleItemRequest(request).subscribe( + () => { + fail("The 'next' function should not be called in case of error"); + }, + (error: any) => { + expect(error).toContain("Unknown request type"); + }, + () => { + fail("The 'complete' function should not be called in case of error"); + } + ); }); }); }); @@ -1490,7 +1494,7 @@ describe("Service: StarkHttpService", () => { headers: httpHeadersGetter(httpHeaders) }; - httpMock.get.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.get.and.returnValue(throwError(httpErrorResponse)); const resultObs: Observable> = starkHttpService.executeCollectionRequest( request @@ -1521,10 +1525,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.get.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -1929,7 +1933,7 @@ describe("Service: StarkHttpService", () => { error: mockHttpError, headers: httpHeadersGetter(httpHeaders) }; - httpMock.post.and.returnValue(observableThrow(httpErrorResponse)); + httpMock.post.and.returnValue(throwError(httpErrorResponse)); const resultObs: Observable> = starkHttpService.executeCollectionRequest( request @@ -1965,10 +1969,10 @@ describe("Service: StarkHttpService", () => { }; let errorCounter: number = 0; httpMock.post.and.returnValue( - observableThrow(httpErrorResponse).pipe( + throwError(httpErrorResponse).pipe( catchError((err: any) => { errorCounter++; - return observableThrow(err); + return throwError(err); }) ) ); @@ -2003,9 +2007,18 @@ describe("Service: StarkHttpService", () => { item: undefined, serializer: mockResourceSerializer }; - const result: ErrorObservable = starkHttpService.executeCollectionRequest(request); - expect(result instanceof ErrorObservable).toBe(true); - expect(result.error).toContain("Unknown request type"); + + starkHttpService.executeSingleItemRequest(request).subscribe( + () => { + fail("The 'next' function should not be called in case of error"); + }, + (error: any) => { + expect(error).toContain("Unknown request type"); + }, + () => { + fail("The 'complete' function should not be called in case of error"); + } + ); }); }); }); diff --git a/packages/stark-core/src/modules/http/services/http.service.ts b/packages/stark-core/src/modules/http/services/http.service.ts index e0fadc6b77..29e4b9ce39 100644 --- a/packages/stark-core/src/modules/http/services/http.service.ts +++ b/packages/stark-core/src/modules/http/services/http.service.ts @@ -1,16 +1,7 @@ const _cloneDeep: Function = require("lodash/cloneDeep"); import { Deserialize, Serialize } from "cerialize"; -import { Observable } from "rxjs/Observable"; -import { ErrorObservable } from "rxjs/observable/ErrorObservable"; -import { timer } from "rxjs/observable/timer"; -import { _throw as observableThrow } from "rxjs/observable/throw"; -// FIXME: importing from single entry "rxjs/operators" together with webpack's scope hoisting prevents dead code removal -// see https://github.com/ReactiveX/rxjs/issues/2981 -// import { catchError, map, mergeMap, retryWhen } from "rxjs/operators"; -import { catchError } from "rxjs/operators/catchError"; -import { map } from "rxjs/operators/map"; -import { retryWhen } from "rxjs/operators/retryWhen"; -import { mergeMap } from "rxjs/operators/mergeMap"; +import { Observable, timer, throwError } from "rxjs"; +import { catchError, map, mergeMap, retryWhen } from "rxjs/operators"; import { Inject, Injectable } from "@angular/core"; import { HttpClient, HttpErrorResponse, HttpHeaders, HttpResponse } from "@angular/common/http"; @@ -96,7 +87,7 @@ export class StarkHttpServiceImpl

implements StarkHttpS if (httpResponse$) { return this.getSingleItemResponseWrapperObservable(httpResponse$, request); } else { - return observableThrow( + return throwError( "Unknown request type encountered " + request.requestType + ". For collection requests, " + @@ -134,7 +125,7 @@ export class StarkHttpServiceImpl

implements StarkHttpS return this.getCollectionResponseWrapperObservable(httpResponse$, request); } else { // we return directly here because otherwise compilation fails (can't assign the ErrorObservable type to Subject) - return observableThrow( + return throwError( "Unknown request type encountered " + request.requestType + ". For single requests (no " + @@ -424,7 +415,7 @@ export class StarkHttpServiceImpl

implements StarkHttpS retries++; return timer(this.retryDelay); } else { - return observableThrow(error); + return throwError(error); } }) ); @@ -432,9 +423,9 @@ export class StarkHttpServiceImpl

implements StarkHttpS ); } - private createHttpErrorWrapper(httpErrorResponse: HttpErrorResponse, meaningfulError: Error): ErrorObservable { + private createHttpErrorWrapper(httpErrorResponse: HttpErrorResponse, meaningfulError: Error): Observable { const httpResponseHeaders: Map = this.getResponseHeaders(httpErrorResponse.headers); - return observableThrow(new StarkHttpErrorWrapperImpl(httpErrorResponse, httpResponseHeaders, meaningfulError)); + return throwError(new StarkHttpErrorWrapperImpl(httpErrorResponse, httpResponseHeaders, meaningfulError)); } private serialize(entity: P, request: StarkHttpRequest

): string | object { diff --git a/packages/stark-core/src/modules/http/testing/http.mock.ts b/packages/stark-core/src/modules/http/testing/http.mock.ts index 9f2d3cfc93..f25c31f541 100644 --- a/packages/stark-core/src/modules/http/testing/http.mock.ts +++ b/packages/stark-core/src/modules/http/testing/http.mock.ts @@ -1,7 +1,7 @@ import { StarkHttpService } from "../services"; import { StarkHttpRequest, StarkSingleItemResponseWrapper, StarkCollectionResponseWrapper } from "../entities"; import { HttpClient } from "@angular/common/http"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; export class MockStarkHttpService implements StarkHttpService { public readonly rawHttpClient: HttpClient; diff --git a/packages/stark-core/src/modules/logging/services/logging.service.spec.ts b/packages/stark-core/src/modules/logging/services/logging.service.spec.ts index f8ff12a3cd..08cfaed612 100644 --- a/packages/stark-core/src/modules/logging/services/logging.service.spec.ts +++ b/packages/stark-core/src/modules/logging/services/logging.service.spec.ts @@ -1,8 +1,6 @@ import Spy = jasmine.Spy; import { Action, Store } from "@ngrx/store"; -import { Observable } from "rxjs/Observable"; -import { of } from "rxjs/observable/of"; -import { _throw as observableThrow } from "rxjs/observable/throw"; +import { Observable, of, throwError } from "rxjs"; import { Serialize } from "cerialize"; import { StarkLoggingActionTypes, FlushLogMessages } from "../../logging/actions"; @@ -286,7 +284,7 @@ describe("Service: StarkLoggingService", () => { it("should fail to persist messages when the back-end fails", () => { expect(mockStarkLogging.messages.length).toBe(loggingFlushPersistSize); - const sendRequestSpy: Spy = spyOn(loggingService, "sendRequest").and.callFake(() => observableThrow("ko")); + const sendRequestSpy: Spy = spyOn(loggingService, "sendRequest").and.callFake(() => throwError("ko")); const errorSpy: Spy = spyOn(loggingService, "error"); const data: string = JSON.stringify(Serialize(mockStarkLogging, StarkLoggingImpl)); loggingService.persistLogMessagesHelper(); diff --git a/packages/stark-core/src/modules/logging/services/logging.service.ts b/packages/stark-core/src/modules/logging/services/logging.service.ts index 43c98387bd..184d153339 100644 --- a/packages/stark-core/src/modules/logging/services/logging.service.ts +++ b/packages/stark-core/src/modules/logging/services/logging.service.ts @@ -4,8 +4,7 @@ import { Serialize } from "cerialize"; import { validateSync } from "class-validator"; import { Store, select } from "@ngrx/store"; -import { Observable } from "rxjs/Observable"; -import { Subject } from "rxjs/Subject"; +import { Observable, Subject } from "rxjs"; import { Inject, Injectable } from "@angular/core"; diff --git a/packages/stark-core/src/modules/routing/services/routing.service.intf.ts b/packages/stark-core/src/modules/routing/services/routing.service.intf.ts index 7209175b0b..415c314472 100644 --- a/packages/stark-core/src/modules/routing/services/routing.service.intf.ts +++ b/packages/stark-core/src/modules/routing/services/routing.service.intf.ts @@ -1,4 +1,4 @@ -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { HookFn, HookMatchCriteria, HookRegOptions, RawParams, StateDeclaration, StateObject, TransitionOptions } from "@uirouter/core"; import { StarkStateConfigWithParams } from "./state-config-with-params.intf"; diff --git a/packages/stark-core/src/modules/routing/services/routing.service.spec.ts b/packages/stark-core/src/modules/routing/services/routing.service.spec.ts index a4b58058da..f55debec6b 100644 --- a/packages/stark-core/src/modules/routing/services/routing.service.spec.ts +++ b/packages/stark-core/src/modules/routing/services/routing.service.spec.ts @@ -2,10 +2,8 @@ import { Component, NgModuleFactoryLoader, NO_ERRORS_SCHEMA, SystemJsNgModuleLoa import { TestBed, fakeAsync, tick, inject } from "@angular/core/testing"; import { Ng2StateDeclaration, UIRouterModule } from "@uirouter/angular"; import { StateDeclaration, StateObject, StateService, TransitionService, UIRouter } from "@uirouter/core"; -import { switchMap } from "rxjs/operators/switchMap"; -import { catchError } from "rxjs/operators/catchError"; -import { tap } from "rxjs/operators/tap"; -import { _throw as observableThrow } from "rxjs/observable/throw"; +import { catchError, switchMap, tap } from "rxjs/operators"; +import { throwError } from "rxjs"; import { Store } from "@ngrx/store"; import { StarkRoutingServiceImpl } from "./routing.service"; import { StarkLoggingService } from "../../logging/services"; @@ -444,7 +442,7 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledTimes(1); }), catchError((error: any) => { - return observableThrow("getCurrentState " + error); + return throwError("getCurrentState " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -464,7 +462,7 @@ describe("Service: StarkRoutingService", () => { expect(currentStateName).toBe(currentState.name); }), catchError((error: any) => { - return observableThrow("getCurrentStateName " + error); + return throwError("getCurrentStateName " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -485,7 +483,7 @@ describe("Service: StarkRoutingService", () => { expect(currentStateConfig.url).toBe("/page-01"); }), catchError((error: any) => { - return observableThrow("getCurrentStateConfig " + error); + return throwError("getCurrentStateConfig " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -565,7 +563,7 @@ describe("Service: StarkRoutingService", () => { expect(currentStateParams.onBehalfView).toBe(true); }), catchError((error: any) => { - return observableThrow("navigateTo " + error); + return throwError("navigateTo " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -588,7 +586,7 @@ describe("Service: StarkRoutingService", () => { expect(isCurrentUIState).toBe(false); }), catchError((error: any) => { - return observableThrow("isCurrentUiState " + error); + return throwError("isCurrentUiState " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -623,7 +621,7 @@ describe("Service: StarkRoutingService", () => { expect(isCurrentUIState).toBe(false); }), catchError((error: any) => { - return observableThrow("isCurrentUiState " + error); + return throwError("isCurrentUiState " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -647,7 +645,7 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledWith("page-01", undefined, undefined); }), catchError((error: any) => { - return observableThrow("navigateTo " + error); + return throwError("navigateTo " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -664,14 +662,14 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledWith("page-01", undefined, { reload: true }); }), catchError((error: any) => { - return observableThrow("navigateTo " + error); + return throwError("navigateTo " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); }); it("should navigate to a non-existing page", (done: DoneFn) => { - spyOn($state, "go").and.returnValue(observableThrow("uh-oh").toPromise()); + spyOn($state, "go").and.returnValue(throwError("uh-oh").toPromise()); routingService .navigateTo("whatever") @@ -680,7 +678,7 @@ describe("Service: StarkRoutingService", () => { fail("whatever"); }), catchError((error: any) => { - return observableThrow(error); + return throwError(error); }) ) .subscribe( @@ -710,7 +708,7 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledWith("homepage", undefined, undefined); }), catchError((error: any) => { - return observableThrow("navigateToHome " + error); + return throwError("navigateToHome " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -742,7 +740,7 @@ describe("Service: StarkRoutingService", () => { expect(currentStateParams.onBehalfView).toBe(true); }), catchError((error: any) => { - return observableThrow("navigateToHome " + error); + return throwError("navigateToHome " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -757,15 +755,15 @@ describe("Service: StarkRoutingService", () => { .navigateTo("homepage") .pipe( catchError((error: any) => { - return observableThrow("navigateTo homepage " + error); + return throwError("navigateTo homepage " + error); }), switchMap(() => routingService.navigateTo("page-01")), catchError((error: any) => { - return observableThrow("navigateTo page-01 " + error); + return throwError("navigateTo page-01 " + error); }), switchMap(() => routingService.navigateTo("page-01-01")), catchError((error: any) => { - return observableThrow("navigateTo page-01-01 " + error); + return throwError("navigateTo page-01-01 " + error); }), switchMap(() => routingService.navigateToPrevious()), tap((enteredState: StateObject) => { @@ -775,7 +773,7 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledWith("page-01", undefined, undefined); }), catchError((error: any) => { - return observableThrow("navigateToPrevious " + error); + return throwError("navigateToPrevious " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -793,7 +791,7 @@ describe("Service: StarkRoutingService", () => { .navigateTo("page-01") .pipe( catchError((error: any) => { - return observableThrow("navigateTo homepage " + error); + return throwError("navigateTo homepage " + error); }), switchMap(() => routingService.reload()), tap((enteredState: StateObject) => { @@ -802,14 +800,14 @@ describe("Service: StarkRoutingService", () => { expect(enteredState.name).toBe("page-01"); }), catchError((error: any) => { - return observableThrow("reload " + error); + return throwError("reload " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); }); it("should reload the current page", (done: DoneFn) => { - spyOn($state, "reload").and.returnValue(observableThrow("Reload has failed").toPromise()); + spyOn($state, "reload").and.returnValue(throwError("Reload has failed").toPromise()); const statesConfig: StateDeclaration[] = $state.get(); expect(statesConfig.length).toBe(numberOfMockStates); // UI-Router's root state + defined states @@ -818,12 +816,12 @@ describe("Service: StarkRoutingService", () => { .navigateTo("page-01") .pipe( catchError((error: any) => { - return observableThrow("navigateTo homepage " + error); + return throwError("navigateTo homepage " + error); }), switchMap(() => routingService.reload()), catchError((error: any) => { expect(error).toBe("Reload has failed"); - return observableThrow("reload " + error); + return throwError("reload " + error); }) ) .subscribe(() => () => fail("the test should not enter the next block"), () => done()); @@ -838,11 +836,11 @@ describe("Service: StarkRoutingService", () => { .navigateTo("page-01") .pipe( catchError((error: any) => { - return observableThrow("navigateTo page-01 " + error); + return throwError("navigateTo page-01 " + error); }), switchMap(() => routingService.navigateTo("page-01")), catchError((error: any) => { - return observableThrow("navigateTo page-01 " + error); + return throwError("navigateTo page-01 " + error); }), tap((enteredState: StateObject) => { expect(mockLogger.warn).toHaveBeenCalledTimes(1); @@ -855,7 +853,7 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledWith("page-01", undefined, undefined); }), catchError((error: any) => { - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -870,7 +868,7 @@ describe("Service: StarkRoutingService", () => { .navigateTo("page-01-01") .pipe( catchError((error: any) => { - return observableThrow("navigateTo page-01-01 " + error); + return throwError("navigateTo page-01-01 " + error); }), tap((enteredState: StateObject) => { expect(mockLogger.warn).toHaveBeenCalledTimes(1); @@ -883,7 +881,7 @@ describe("Service: StarkRoutingService", () => { expect($state.go).toHaveBeenCalledWith("page-01-01", undefined, undefined); }), catchError((error: any) => { - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => done(), (error: any) => fail(error)); @@ -903,7 +901,7 @@ describe("Service: StarkRoutingService", () => { expect(mockLogger.warn).toHaveBeenCalledTimes(1); const message: string = (mockLogger.warn).calls.argsFor(0)[0]; expect(message).toMatch(/Route transition rejected/); - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => fail("this block should not be executed"), () => done()); @@ -921,7 +919,7 @@ describe("Service: StarkRoutingService", () => { expect(mockLogger.error).toHaveBeenCalledTimes(2); const message: string = (mockLogger.error).calls.argsFor(0)[0]; expect(message).toMatch(/Error during route transition/); - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => fail("this block should not be executed"), () => done()); @@ -939,7 +937,7 @@ describe("Service: StarkRoutingService", () => { expect(mockLogger.warn).toHaveBeenCalledTimes(1); const message: string = (mockLogger.warn).calls.argsFor(0)[0]; expect(message).toMatch(/transition aborted/); - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => fail("this block should not be executed"), () => done()); @@ -957,7 +955,7 @@ describe("Service: StarkRoutingService", () => { expect(mockLogger.error).toHaveBeenCalledTimes(2); const message: string = (mockLogger.error).calls.argsFor(0)[0]; expect(message).toMatch(/An error occurred with a resolve in the new state/); - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => fail("this block should not be executed"), () => done()); @@ -971,7 +969,7 @@ describe("Service: StarkRoutingService", () => { expect(mockLogger.error).toHaveBeenCalledTimes(1); const message: string = (mockLogger.error).calls.argsFor(0)[0]; expect(message).toMatch(/The target state does NOT exist/); - return observableThrow("navigationErrorHandler " + error); + return throwError("navigationErrorHandler " + error); }) ) .subscribe(() => fail("this block should not be executed"), () => done()); diff --git a/packages/stark-core/src/modules/routing/services/routing.service.ts b/packages/stark-core/src/modules/routing/services/routing.service.ts index 59d7d5aab7..bba662526d 100644 --- a/packages/stark-core/src/modules/routing/services/routing.service.ts +++ b/packages/stark-core/src/modules/routing/services/routing.service.ts @@ -1,7 +1,7 @@ import { Action, Store } from "@ngrx/store"; -import { Observable } from "rxjs/Observable"; -import { fromPromise } from "rxjs/observable/fromPromise"; -import { empty } from "rxjs/observable/empty"; +import { Observable, empty } from "rxjs"; +// FIXME Is fromPromise still valid ? +import { fromPromise } from "rxjs/internal/observable/fromPromise"; import { Inject, Injectable } from "@angular/core"; import { StarkLoggingService, STARK_LOGGING_SERVICE } from "../../logging/services"; diff --git a/packages/stark-core/src/modules/routing/testing/routing.mock.ts b/packages/stark-core/src/modules/routing/testing/routing.mock.ts index 3eb40cc6a7..9b7d033343 100644 --- a/packages/stark-core/src/modules/routing/testing/routing.mock.ts +++ b/packages/stark-core/src/modules/routing/testing/routing.mock.ts @@ -1,5 +1,5 @@ import { StarkRoutingService, StarkStateConfigWithParams } from "../services"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { HookFn, HookMatchCriteria, HookRegOptions, RawParams, StateDeclaration, StateObject, TransitionOptions } from "@uirouter/core"; export class MockStarkRoutingService implements StarkRoutingService { diff --git a/packages/stark-core/src/modules/session/services/session.service.intf.ts b/packages/stark-core/src/modules/session/services/session.service.intf.ts index 2705bcbec9..9a10ea2fbd 100644 --- a/packages/stark-core/src/modules/session/services/session.service.intf.ts +++ b/packages/stark-core/src/modules/session/services/session.service.intf.ts @@ -1,5 +1,5 @@ import { InjectionToken } from "@angular/core"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { StarkUser } from "../../user/entities"; export const starkSessionServiceName: string = "StarkSessionService"; diff --git a/packages/stark-core/src/modules/session/services/session.service.spec.ts b/packages/stark-core/src/modules/session/services/session.service.spec.ts index 28ee8cca4b..dd9a6c0cf1 100644 --- a/packages/stark-core/src/modules/session/services/session.service.spec.ts +++ b/packages/stark-core/src/modules/session/services/session.service.spec.ts @@ -6,13 +6,8 @@ import { Store } from "@ngrx/store"; import { TranslateService } from "@ngx-translate/core"; import { HookMatchCriteria, Predicate } from "@uirouter/core"; -import { Observable } from "rxjs/Observable"; -import { Subject } from "rxjs/Subject"; -import { Subscriber } from "rxjs/Subscriber"; -import { defer } from "rxjs/observable/defer"; -import { of } from "rxjs/observable/of"; -import { take } from "rxjs/operators/take"; -import { _throw as observableThrow } from "rxjs/observable/throw"; +import { Observable, Subject, Subscriber, defer, of, throwError } from "rxjs"; +import { take } from "rxjs/operators"; import { SessionTimeoutCountdownFinish, @@ -796,7 +791,7 @@ describe("Service: StarkSessionService", () => { }); it("should not change the language in case of failure and dispatch the FAILURE action", () => { - (mockTranslateService.use).and.returnValue(observableThrow("dummy error")); + (mockTranslateService.use).and.returnValue(throwError("dummy error")); sessionService.setCurrentLanguage("FR"); diff --git a/packages/stark-core/src/modules/session/services/session.service.ts b/packages/stark-core/src/modules/session/services/session.service.ts index 2cfb442d6f..32550eb306 100644 --- a/packages/stark-core/src/modules/session/services/session.service.ts +++ b/packages/stark-core/src/modules/session/services/session.service.ts @@ -5,11 +5,8 @@ import { Keepalive } from "@ng-idle/keepalive"; import { TranslateService } from "@ngx-translate/core"; import { Store, select } from "@ngrx/store"; import { StateObject } from "@uirouter/core"; -import { Observable } from "rxjs/Observable"; -import { Subject } from "rxjs/Subject"; -import { take } from "rxjs/operators/take"; -import { map } from "rxjs/operators/map"; -import { defer } from "rxjs/observable/defer"; +import { Observable, Subject, defer } from "rxjs"; +import { map, take } from "rxjs/operators"; import { validateSync } from "class-validator"; import { StarkLoggingService, STARK_LOGGING_SERVICE } from "../../logging/services"; diff --git a/packages/stark-core/src/modules/session/testing/session.mock.ts b/packages/stark-core/src/modules/session/testing/session.mock.ts index 854b2e3ccf..a9d543580f 100644 --- a/packages/stark-core/src/modules/session/testing/session.mock.ts +++ b/packages/stark-core/src/modules/session/testing/session.mock.ts @@ -1,6 +1,6 @@ import { StarkHttpHeaders } from "../../http"; import { StarkSessionService } from "../services"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; export class MockStarkSessionService implements StarkSessionService { public fakePreAuthenticationHeaders: Map; diff --git a/packages/stark-core/src/modules/settings/effects/settings.effects.spec.ts b/packages/stark-core/src/modules/settings/effects/settings.effects.spec.ts index 750ebf203d..e6d0db8fd3 100644 --- a/packages/stark-core/src/modules/settings/effects/settings.effects.spec.ts +++ b/packages/stark-core/src/modules/settings/effects/settings.effects.spec.ts @@ -1,15 +1,13 @@ import Spy = jasmine.Spy; import createSpyObj = jasmine.createSpyObj; -import { Observer } from "rxjs/Observer"; import { StarkSettingsEffects } from "./settings.effects"; import { SetPreferredLanguage } from "../actions"; import { StarkSessionService, starkSessionServiceName } from "../../session/services"; import { MockStarkSessionService } from "../../session/testing"; import { TestBed } from "@angular/core/testing"; -import { Observable } from "rxjs/Observable"; +import { Observable, Observer, ReplaySubject } from "rxjs"; import { provideMockActions } from "@ngrx/effects/testing"; -import { ReplaySubject } from "rxjs/ReplaySubject"; describe("Effect: StarkSettingsEffects", () => { let settingsEffects: StarkSettingsEffects; diff --git a/packages/stark-core/src/modules/settings/effects/settings.effects.ts b/packages/stark-core/src/modules/settings/effects/settings.effects.ts index ddc7782ce7..a629b62c96 100644 --- a/packages/stark-core/src/modules/settings/effects/settings.effects.ts +++ b/packages/stark-core/src/modules/settings/effects/settings.effects.ts @@ -1,7 +1,7 @@ import { Inject, Injectable } from "@angular/core"; import { Actions, Effect, ofType } from "@ngrx/effects"; -import { Observable } from "rxjs/Observable"; -import { map } from "rxjs/operators/map"; +import { Observable } from "rxjs"; +import { map } from "rxjs/operators"; import { StarkSettingsActionTypes, SetPreferredLanguage } from "../actions"; import { StarkSessionService, starkSessionServiceName } from "../../session/services"; diff --git a/packages/stark-core/src/modules/settings/services/settings.service.spec.ts b/packages/stark-core/src/modules/settings/services/settings.service.spec.ts index b6ca089b7a..bc04dfe3cd 100644 --- a/packages/stark-core/src/modules/settings/services/settings.service.spec.ts +++ b/packages/stark-core/src/modules/settings/services/settings.service.spec.ts @@ -13,7 +13,7 @@ import { StarkCoreApplicationState } from "../../../common/store"; import { StarkSettingsServiceImpl } from "./settings.service"; import { SetPreferredLanguage } from "../actions"; import { StarkUser } from "../../user"; -import { of } from "rxjs/observable/of"; +import { of } from "rxjs"; import Spy = jasmine.Spy; describe("Service: StarkSettingsService", () => { diff --git a/packages/stark-core/src/modules/settings/services/settings.service.ts b/packages/stark-core/src/modules/settings/services/settings.service.ts index 3769722194..5601fbe0ce 100644 --- a/packages/stark-core/src/modules/settings/services/settings.service.ts +++ b/packages/stark-core/src/modules/settings/services/settings.service.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from "@angular/core"; import { select, Store } from "@ngrx/store"; -import { filter } from "rxjs/operators/filter"; +import { filter } from "rxjs/operators"; import { StarkLoggingService, starkLoggingServiceName } from "../../logging/services"; import { StarkSettingsService, starkSettingsServiceName } from "./settings.service.intf"; diff --git a/packages/stark-core/src/modules/user/repository/user.repository.intf.ts b/packages/stark-core/src/modules/user/repository/user.repository.intf.ts index e90ba48a3a..a631a7ed9a 100644 --- a/packages/stark-core/src/modules/user/repository/user.repository.intf.ts +++ b/packages/stark-core/src/modules/user/repository/user.repository.intf.ts @@ -1,4 +1,4 @@ -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { StarkUser } from "../entities"; import { StarkSingleItemResponseWrapper } from "../../http/entities"; diff --git a/packages/stark-core/src/modules/user/repository/user.repository.ts b/packages/stark-core/src/modules/user/repository/user.repository.ts index 9dbec89915..18376c7c5d 100644 --- a/packages/stark-core/src/modules/user/repository/user.repository.ts +++ b/packages/stark-core/src/modules/user/repository/user.repository.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from "@angular/core"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { StarkSerializable } from "../../../serialization"; import { StarkUser } from "../entities"; import { StarkHttpRequest, StarkSingleItemResponseWrapper } from "../../http/entities"; diff --git a/packages/stark-core/src/modules/user/services/user.service.intf.ts b/packages/stark-core/src/modules/user/services/user.service.intf.ts index ea099a82a1..86733c1dc6 100644 --- a/packages/stark-core/src/modules/user/services/user.service.intf.ts +++ b/packages/stark-core/src/modules/user/services/user.service.intf.ts @@ -1,5 +1,5 @@ import { InjectionToken } from "@angular/core"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { StarkUser } from "../entities"; export const starkUserServiceName: string = "StarkUserService"; diff --git a/packages/stark-core/src/modules/user/services/user.service.spec.ts b/packages/stark-core/src/modules/user/services/user.service.spec.ts index 5bace19aa2..a1cc9b2ae0 100644 --- a/packages/stark-core/src/modules/user/services/user.service.spec.ts +++ b/packages/stark-core/src/modules/user/services/user.service.spec.ts @@ -1,9 +1,7 @@ import Spy = jasmine.Spy; import createSpyObj = jasmine.createSpyObj; import { Store } from "@ngrx/store"; -import { Observer } from "rxjs/Observer"; -import { of } from "rxjs/observable/of"; -import { _throw as observableThrow } from "rxjs/observable/throw"; +import { Observer, of, throwError } from "rxjs"; import { Deserialize } from "cerialize"; import { @@ -276,7 +274,7 @@ describe("Service: StarkUserService", () => { dummyError ); - (mockUserRepository.getUser).and.returnValue(observableThrow(mockErrorResponseWrapper)); + (mockUserRepository.getUser).and.returnValue(throwError(mockErrorResponseWrapper)); userService.fetchUserProfile().subscribe(mockObserver); diff --git a/packages/stark-core/src/modules/user/services/user.service.ts b/packages/stark-core/src/modules/user/services/user.service.ts index eddcddcf10..4a714b68b8 100644 --- a/packages/stark-core/src/modules/user/services/user.service.ts +++ b/packages/stark-core/src/modules/user/services/user.service.ts @@ -1,10 +1,8 @@ import { Inject, Injectable } from "@angular/core"; import { Store } from "@ngrx/store"; import { validateSync } from "class-validator"; -import { Observable } from "rxjs/Observable"; -import { map } from "rxjs/operators/map"; -import { catchError } from "rxjs/operators/catchError"; -import { _throw as observableThrow } from "rxjs/observable/throw"; +import { Observable, throwError } from "rxjs"; +import { map, catchError } from "rxjs/operators"; import { StarkHttpErrorWrapper, StarkSingleItemResponseWrapper } from "../../http/entities"; import { StarkUser } from "../../user/entities"; @@ -87,7 +85,7 @@ export class StarkUserServiceImpl implements StarkUserService { catchError((error: StarkHttpErrorWrapper | Error) => { this.store.dispatch(new FetchUserProfileFailure(error)); - return observableThrow(error); + return throwError(error); }) ); } diff --git a/packages/stark-testing/helpers.js b/packages/stark-testing/helpers.js index 92fad9f151..756ea2ca7d 100644 --- a/packages/stark-testing/helpers.js +++ b/packages/stark-testing/helpers.js @@ -10,22 +10,19 @@ const _root = path.resolve(process.cwd(), "."); // project root folder const root = path.join.bind(path, _root); function getAngularCliAppConfig() { - const applicationAngularCliConfigPath = root(".angular-cli.json"); - const packageAngularCliConfigPath = root(".ng-cli-config.json"); + const applicationAngularCliConfigPath = root("angular.json"); let angularCliConfigPath; if (fs.existsSync(applicationAngularCliConfigPath)) { angularCliConfigPath = applicationAngularCliConfigPath; - } else if (fs.existsSync(packageAngularCliConfigPath)) { - angularCliConfigPath = packageAngularCliConfigPath; } else { throw new Error(".angular-cli.json is not present. Please add this at the root your project because stark-build needs this."); } const angularCliConfig = require(angularCliConfigPath); - if (angularCliConfig["apps"] && angularCliConfig["apps"][0]) { - return angularCliConfig["apps"][0]; + if (angularCliConfig["defaultProject"] && angularCliConfig["projects"][angularCliConfig["defaultProject"]]) { + return angularCliConfig["projects"][angularCliConfig["defaultProject"]]; } else { throw new Error("Angular-cli config apps is wrong. Please adapt it to follow Angular CLI way."); } diff --git a/packages/stark-testing/karma.conf.typescript.ci.js b/packages/stark-testing/karma.conf.typescript.ci.js index 9d98d5a5de..df2e85b03c 100644 --- a/packages/stark-testing/karma.conf.typescript.ci.js +++ b/packages/stark-testing/karma.conf.typescript.ci.js @@ -16,9 +16,9 @@ const rawKarmaConfig = { // list of files / patterns to load in the browser files: [ - {pattern: helpers.root(helpers.getAngularCliAppConfig().test)}, - {pattern: helpers.root("src/**/*.ts")}, - {pattern: helpers.root("src/**/*.html")} + { pattern: helpers.root(helpers.getAngularCliAppConfig()["architect"]["test"]["options"].main) }, + { pattern: helpers.root("src/**/*.ts") }, + { pattern: helpers.root("src/**/*.html") } ], // list of files to exclude @@ -46,7 +46,7 @@ const rawKarmaConfig = { require("karma-typescript-angular2-transform") // see https://github.com/monounity/karma-typescript-angular2-transform ] }, - tsconfig: helpers.getAngularCliAppConfig().testTsconfig + tsconfig: helpers.getAngularCliAppConfig()["architect"]["test"]["options"].tsConfig }, // IMPORTANT: define the custom instrumenter here to support the latest Istanbul API @@ -96,7 +96,7 @@ const rawKarmaConfig = { // level of logging // see: http://karma-runner.github.io/2.0/config/configuration-file.html - // possible values: + // possible values: // "OFF" = config.LOG_DISABLE // "ERROR" = config.LOG_ERROR // "WARN" = config.LOG_WARN @@ -135,7 +135,7 @@ const rawKarmaConfig = { module.exports = { // Karma configuration // reference: http://karma-runner.github.io/2.0/config/configuration-file.html - default: function (config) { + default: function(config) { // Interesting idea to avoid having multiple config files // if (process.env.TRAVIS || process.env.CIRCLECI) { // config.browsers = ['ChromeHeadlessNoSandbox']; diff --git a/packages/stark-testing/karma.conf.typescript.js b/packages/stark-testing/karma.conf.typescript.js index 8401529724..921180b8d2 100644 --- a/packages/stark-testing/karma.conf.typescript.js +++ b/packages/stark-testing/karma.conf.typescript.js @@ -11,9 +11,9 @@ const rawKarmaConfig = { // list of files / patterns to load in the browser files: [ - {pattern: helpers.root(helpers.getAngularCliAppConfig().test)}, - {pattern: helpers.root("src/**/*.ts")}, - {pattern: helpers.root("src/**/*.html")} + { pattern: helpers.root(helpers.getAngularCliAppConfig()["architect"]["test"]["options"].main) }, + { pattern: helpers.root("src/**/*.ts") }, + { pattern: helpers.root("src/**/*.html") } ], // list of files to exclude @@ -41,7 +41,7 @@ const rawKarmaConfig = { require("karma-typescript-angular2-transform") // see https://github.com/monounity/karma-typescript-angular2-transform ] }, - tsconfig: helpers.getAngularCliAppConfig().testTsconfig + tsconfig: helpers.getAngularCliAppConfig()["architect"]["test"]["options"].tsConfig }, // test results reporter to use @@ -59,7 +59,7 @@ const rawKarmaConfig = { // level of logging // see: http://karma-runner.github.io/2.0/config/configuration-file.html - // possible values: + // possible values: // "OFF" = config.LOG_DISABLE // "ERROR" = config.LOG_ERROR // "WARN" = config.LOG_WARN @@ -88,8 +88,8 @@ const rawKarmaConfig = { module.exports = { // Karma configuration // reference: http://karma-runner.github.io/2.0/config/configuration-file.html - default: function (config) { + default: function(config) { config.set(rawKarmaConfig); }, rawKarmaConfig: rawKarmaConfig -}; +}; diff --git a/packages/stark-testing/package.json b/packages/stark-testing/package.json index 068061ce27..0491055d2b 100644 --- a/packages/stark-testing/package.json +++ b/packages/stark-testing/package.json @@ -20,21 +20,21 @@ "npm": ">=5.3.0" }, "dependencies": { - "@types/jasmine": "2.8.6", + "@types/jasmine": "2.8.7", "@types/node": "6.0.106", - "coveralls": "3.0.0", + "coveralls": "3.0.1", "istanbul-lib-instrument": "1.10.1", "jasmine-core": "3.1.0", - "karma": "2.0.0", + "karma": "2.0.2", "karma-chrome-launcher": "2.2.0", - "karma-coverage": "1.1.1", + "karma-coverage": "1.1.2", "karma-coverage-istanbul-reporter": "1.4.2", - "karma-jasmine": "1.1.1", + "karma-jasmine": "1.1.2", "karma-mocha-reporter": "2.2.5", "karma-sourcemap-loader": "0.3.7", "karma-typescript": "3.0.12", "karma-typescript-angular2-transform": "1.0.2", - "puppeteer": "1.3.0" + "puppeteer": "1.4.0" }, "scripts": { "clean": "npx rimraf dist", diff --git a/packages/stark-ui/.ng-cli-config.json b/packages/stark-ui/.ng-cli-config.json deleted file mode 100644 index 997b30a6c9..0000000000 --- a/packages/stark-ui/.ng-cli-config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "project": { - "name": "stark-ui" - }, - "apps": [ - { - "root": "src", - "outDir": "dist", - "assets": [ - { "glob": "**/*", "input": "../node_modules/@nationalbankbelgium/stark-ui/assets", "output": "./assets/stark-ui/" }, - { "glob": "**/*", "input": "../node_modules/@nationalbankbelgium/stark-ui/src/modules/app-logo/assets", "output": "./assets/stark-ui/app-logo/" } - ], - "test": "base.spec.ts", - "tsconfig": "tsconfig-build.json", - "testTsconfig": "tsconfig.spec.json" - } - ] -} diff --git a/packages/stark-ui/angular.json b/packages/stark-ui/angular.json new file mode 100644 index 0000000000..52f85b2ba3 --- /dev/null +++ b/packages/stark-ui/angular.json @@ -0,0 +1,37 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoots": "projects", + "projects": { + "stark-ui": { + "root": "", + "sourceRoot": "src", + "projectType": "library", + "architect": { + "build": { + "options": { + "outputPath": "dist", + "tsConfig": "tsconfig-build.json", + "assets": [ + { "glob": "**/*", "input": "../node_modules/@nationalbankbelgium/stark-ui/assets", "output": "./assets/stark-ui/" }, + { + "glob": "**/*", + "input": "../node_modules/@nationalbankbelgium/stark-ui/src/modules/app-logo/assets", + "output": "./assets/stark-ui/app-logo/" + } + ] + } + }, + "test": { + "options": { + "main": "base.spec.ts", + "outputPath": "dist", + "tsConfig": "tsconfig.spec.json", + "assets": [] + } + } + } + } + }, + "defaultProject": "stark-ui" +} diff --git a/packages/stark-ui/karma.conf.typescript.ci.js b/packages/stark-ui/karma.conf.typescript.ci.js index beb36f5d67..2f879cce1d 100644 --- a/packages/stark-ui/karma.conf.typescript.ci.js +++ b/packages/stark-ui/karma.conf.typescript.ci.js @@ -12,24 +12,15 @@ const starkUiSpecificConfiguration = Object.assign( defaultKarmaCIConfig, { // change the module resolution for the KarmaTypescript bundler - karmaTypescriptConfig: Object.assign( - defaultKarmaCIConfig.karmaTypescriptConfig, - { - bundlerOptions: Object.assign( - defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, - karmaTypescriptBundlerAliasResolution - ) - } - ) + karmaTypescriptConfig: Object.assign(defaultKarmaCIConfig.karmaTypescriptConfig, { + bundlerOptions: Object.assign(defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, karmaTypescriptBundlerAliasResolution) + }) }, { // change the path of the report so that Coveralls takes the right path to the source files - coverageIstanbulReporter: Object.assign( - defaultKarmaCIConfig.coverageIstanbulReporter, - { - dir: helpers.root("reports/coverage/packages") - } - ) + coverageIstanbulReporter: Object.assign(defaultKarmaCIConfig.coverageIstanbulReporter, { + dir: helpers.root("reports/coverage/packages") + }) } ); diff --git a/packages/stark-ui/karma.conf.typescript.js b/packages/stark-ui/karma.conf.typescript.js index efc3a0a5fd..a609c33313 100644 --- a/packages/stark-ui/karma.conf.typescript.js +++ b/packages/stark-ui/karma.conf.typescript.js @@ -17,35 +17,25 @@ const karmaTypescriptBundlerAliasResolution = { "@uirouter/angular": "../stark-core/node_modules/@uirouter/angular/_bundles/ui-router-ng2.js", "@uirouter/core": "../stark-core/node_modules/@uirouter/core/lib/index.js", "@uirouter/rx": "../stark-core/node_modules/@uirouter/rx/lib/index.js", - "cerialize": "../stark-core/node_modules/cerialize/index.js", + cerialize: "../stark-core/node_modules/cerialize/index.js", "class-validator": "../stark-core/node_modules/class-validator/index.js", - "moment": "../stark-core/node_modules/moment/moment.js", - "ibantools": "../stark-core/node_modules/ibantools/build/ibantools.js" + moment: "../stark-core/node_modules/moment/moment.js", + ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js" } } }; // start customizing the KarmaCI configuration from stark-testing -const starkUiSpecificConfiguration = Object.assign( - {}, - defaultKarmaCIConfig, - { - // change the module resolution for the KarmaTypescript bundler - karmaTypescriptConfig: Object.assign( - defaultKarmaCIConfig.karmaTypescriptConfig, - { - bundlerOptions: Object.assign( - defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, - karmaTypescriptBundlerAliasResolution - ) - } - ) - } -); +const starkUiSpecificConfiguration = Object.assign({}, defaultKarmaCIConfig, { + // change the module resolution for the KarmaTypescript bundler + karmaTypescriptConfig: Object.assign(defaultKarmaCIConfig.karmaTypescriptConfig, { + bundlerOptions: Object.assign(defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, karmaTypescriptBundlerAliasResolution) + }) +}); // export the configuration function that karma expects and simply return the stark configuration module.exports = { - default: function (config) { + default: function(config) { return config.set(starkUiSpecificConfiguration); }, karmaTypescriptBundlerAliasResolution: karmaTypescriptBundlerAliasResolution diff --git a/packages/stark-ui/package.json b/packages/stark-ui/package.json index 722161e009..57cf2a239d 100644 --- a/packages/stark-ui/package.json +++ b/packages/stark-ui/package.json @@ -33,15 +33,16 @@ "@nationalbankbelgium/stark-testing": "../stark-testing" }, "peerDependencies": { - "@angular/common": "5.x", - "@angular/compiler": "5.x", - "@angular/core": "5.x", - "@angular/material": "5.x", - "@angular/platform-browser": "5.x", - "@angular/platform-browser-dynamic": "5.x", - "@angular/router": "5.x", + "@angular/common": "6.x", + "@angular/compiler": "6.x", + "@angular/core": "6.x", + "@angular/material": "6.x", + "@angular/platform-browser": "6.x", + "@angular/platform-browser-dynamic": "6.x", + "@angular/router": "6.x", "@nationalbankbelgium/stark-core": "0.0.0-PLACEHOLDER-VERSION", - "typescript": ">=2.6.0 && <2.7.0" + "rxjs": "6.x", + "typescript": ">=2.7.2 && <2.8.0" }, "scripts": { "clean": "npx rimraf dist", diff --git a/packages/stark-ui/src/modules/app-logo/components/app-logo.component.pcss b/packages/stark-ui/src/modules/app-logo/components/app-logo.component.pcss index 249ff42b8c..d006952fec 100644 --- a/packages/stark-ui/src/modules/app-logo/components/app-logo.component.pcss +++ b/packages/stark-ui/src/modules/app-logo/components/app-logo.component.pcss @@ -11,11 +11,11 @@ .stark-app-logo { & i { display: block; - width: 60px; - height: 64px; + width: 60px; + height: 64px; margin-top: 4px; background-image: url(/assets/stark-ui/app-logo/angular.png); /* FIXME: add image for tablet */ - background-size: 100% 100%; + background-size: 100% 100%; } } } @@ -27,7 +27,7 @@ width: 120px; height: 128px; background-image: url(/assets/stark-ui/app-logo/angular.png); /* FIXME: add image for desktop */ - background-size: 100% 100%; + background-size: 100% 100%; } } } diff --git a/packages/stark-ui/src/modules/app-logo/components/app-logo.component.spec.ts b/packages/stark-ui/src/modules/app-logo/components/app-logo.component.spec.ts index 04b20d76bf..7e760f8e55 100644 --- a/packages/stark-ui/src/modules/app-logo/components/app-logo.component.spec.ts +++ b/packages/stark-ui/src/modules/app-logo/components/app-logo.component.spec.ts @@ -5,7 +5,7 @@ import { MockStarkRoutingService, STARK_LOGGING_SERVICE, STARK_ROUTING_SERVICE -} from "@nationalbankbelgium/stark-core" +} from "@nationalbankbelgium/stark-core"; import { StarkAppLogoComponent } from "./app-logo.component"; import Spy = jasmine.Spy; import SpyObj = jasmine.SpyObj; @@ -22,14 +22,14 @@ describe("AppLogoComponent", () => { TestBed.configureTestingModule({ declarations: [StarkAppLogoComponent], providers: [ - {provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService()}, - {provide: STARK_ROUTING_SERVICE, useClass: MockStarkRoutingService} + { provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() }, + { provide: STARK_ROUTING_SERVICE, useClass: MockStarkRoutingService } ], schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes }) - /** - * Compile template and css - */ + /** + * Compile template and css + */ .compileComponents(); })); @@ -44,11 +44,10 @@ describe("AppLogoComponent", () => { }); describe("on initialization", () => { - it("should set internal component properties", () => { expect(fixture).toBeDefined(); expect(comp).toBeDefined(); - + expect(comp.logger).not.toBeNull(); expect(comp.logger).toBeDefined(); expect(comp.routingService).not.toBeNull(); @@ -62,8 +61,8 @@ describe("AppLogoComponent", () => { describe("logoClickHandler()", () => { it("should navigate to Home", () => { - const dummyClickEvent:SpyObj = createSpyObj("dummyClickEvent", ["preventDefault"]); - + const dummyClickEvent: SpyObj = createSpyObj("dummyClickEvent", ["preventDefault"]); + comp.homeStateParams = { someParam: "dummy param" }; diff --git a/packages/stark-ui/src/modules/app-logo/components/app-logo.component.ts b/packages/stark-ui/src/modules/app-logo/components/app-logo.component.ts index 535e88ec17..1eebfdb21c 100644 --- a/packages/stark-ui/src/modules/app-logo/components/app-logo.component.ts +++ b/packages/stark-ui/src/modules/app-logo/components/app-logo.component.ts @@ -1,10 +1,5 @@ import { Component, Inject, Input, OnInit, ViewEncapsulation } from "@angular/core"; -import { - STARK_LOGGING_SERVICE, - STARK_ROUTING_SERVICE, - StarkLoggingService, - StarkRoutingService -} from "@nationalbankbelgium/stark-core"; +import { STARK_LOGGING_SERVICE, STARK_ROUTING_SERVICE, StarkLoggingService, StarkRoutingService } from "@nationalbankbelgium/stark-core"; const componentName: string = "stark-app-logo"; diff --git a/starter/.angular-cli.json b/starter/.angular-cli.json deleted file mode 100644 index ef15ff2800..0000000000 --- a/starter/.angular-cli.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "project": { - "name": "starter", - "ejected": true - }, - "apps": [ - { - "root": "src", - "outDir": "dist", - "assets": [ - { - "glob": "mdi.svg", - "input": "../node_modules/@mdi/angular-material", - "output": "./assets/icons" - }, - { - "glob": "**/*", - "input": "./assets/img/", - "output": "./assets/img/" - }, - { - "glob": "**/*", - "input": "../assets/", - "output": "./assets/" - }, - { - "glob": "**/*", - "input": "../assets-base/", - "output": "./" - } - ], - "deployUrl": "", - "baseHref": "/", - "index": "index.html", - "main": "main.browser.ts", - "polyfills": "polyfills.browser.ts", - "test": "base.spec.ts", - "tsconfig": "tsconfig.app.json", - "testTsconfig": "tsconfig.spec.json", - "prefix": "app", - "styles": ["styles.css"], - "scripts": [], - "environmentSource": "environments/environment.ts", - "environments": { - "dev": "environments/environment.ts", - "hmr": "environments/environment.hmr.ts", - "prod": "environments/environment.prod.ts", - "e2e.prod": "environments/environment.e2e.prod.ts" - } - } - ], - "lint": [ - { - "project": "tsconfig.app.json", - "exclude": "**/node_modules/**" - }, - { - "project": "tsconfig.spec.json", - "exclude": "**/node_modules/**" - } - ], - "defaults": { - "styleExt": "pcss", - "component": {} - } -} diff --git a/starter/angular.json b/starter/angular.json new file mode 100644 index 0000000000..455a168027 --- /dev/null +++ b/starter/angular.json @@ -0,0 +1,143 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "starter": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist", + "index": "src/index.html", + "main": "src/main.browser.ts", + "tsConfig": "tsconfig.app.json", + "polyfills": "src/polyfills.browser.ts", + "assets": [ + { + "glob": "mdi.svg", + "input": "node_modules/@mdi/angular-material", + "output": "./assets/icons" + }, + { + "glob": "**/*", + "input": "src/assets/img", + "output": "./assets/img" + }, + { + "glob": "**/*", + "input": "assets", + "output": "./assets" + }, + { + "glob": "**/*", + "input": "assets-base", + "output": "./" + } + ], + "styles": ["src/styles.css"], + "scripts": [] + }, + "configurations": { + "hmr": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.hmr.ts" + } + ] + }, + "production": { + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ] + }, + "e2e.prod": { + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.e2e.prod.ts" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "starter:build" + }, + "configurations": { + "hmr": { + "browserTarget": "starter:build:hmr" + }, + "production": { + "browserTarget": "starter:build:production" + }, + "e2e.prod": { + "browserTarget": "starter:build:e2e.prod" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "starter:build" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": ["tsconfig.app.json", "tsconfig.spec.json"], + "exclude": ["**/node_modules/**"] + } + }, + "test": { + "options": { + "main": "base.spec.ts", + "tsConfig": "tsconfig.spec.json" + } + } + } + }, + "starter-e2e": { + "root": "", + "sourceRoot": "", + "projectType": "application" + } + }, + "defaultProject": "starter", + "schematics": { + "@schematics/angular:component": { + "prefix": "app", + "styleext": "pcss" + }, + "@schematics/angular:directive": { + "prefix": "app" + } + } +} diff --git a/starter/package.json b/starter/package.json index 2e640c3e3e..58d6b71ac1 100644 --- a/starter/package.json +++ b/starter/package.json @@ -107,36 +107,36 @@ ] }, "dependencies": { - "@angular/animations": "5.2.10", - "@angular/cli": "1.7.4", - "@angular/common": "5.2.10", - "@angular/compiler": "5.2.10", - "@angular/compiler-cli": "5.2.10", - "@angular/core": "5.2.10", - "@angular/forms": "5.2.10", - "@angular/platform-browser": "5.2.10", - "@angular/platform-browser-dynamic": "5.2.10", - "@angular/platform-server": "5.2.10", - "@angular/router": "5.2.10", - "@mdi/angular-material": "2.2.43", - "@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.2-00dc6a6.tgz", - "@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.0.0-alpha.2-00dc6a6.tgz", + "@angular/animations": "6.0.2", + "@angular/cli": "6.0.1", + "@angular/common": "6.0.2", + "@angular/compiler": "6.0.2", + "@angular/compiler-cli": "6.0.2", + "@angular/core": "6.0.2", + "@angular/forms": "6.0.2", + "@angular/platform-browser": "6.0.2", + "@angular/platform-browser-dynamic": "6.0.2", + "@angular/platform-server": "6.0.2", + "@angular/router": "6.0.2", + "@mdi/angular-material": "2.3.54", + "@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.2-187557b.tgz", + "@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.0.0-alpha.2-187557b.tgz", "@ngrx/store": "5.2.0", - "@uirouter/angular": "1.0.1", "@uirouter/visualizer": "6.0.0", - "core-js": "2.5.5", + "core-js": "2.5.6", "eligrey-classlist-js-polyfill": "1.2.20180112", "event-source-polyfill": "0.0.12", "http-server": "0.11.1", "ngrx-store-freeze": "0.2.2", "ngrx-store-logger": "0.2.1", "reflect-metadata": "0.1.12", - "rxjs": "5.6.0-forward-compat.4", + "rxjs": "6.1.0", + "rxjs-compat": "6.1.0", "web-animations-js": "2.3.1" }, "devDependencies": { - "@nationalbankbelgium/stark-build": "file:../dist/packages-dist/stark-build/nationalbankbelgium-stark-build-10.0.0-alpha.2-00dc6a6.tgz", - "@nationalbankbelgium/stark-testing": "file:../dist/packages-dist/stark-testing/nationalbankbelgium-stark-testing-10.0.0-alpha.2-00dc6a6.tgz", + "@nationalbankbelgium/stark-build": "file:../dist/packages-dist/stark-build/nationalbankbelgium-stark-build-10.0.0-alpha.2-187557b.tgz", + "@nationalbankbelgium/stark-testing": "file:../dist/packages-dist/stark-testing/nationalbankbelgium-stark-testing-10.0.0-alpha.2-187557b.tgz", "@types/core-js": "0.9.46", "@types/hammerjs": "2.0.35", "@types/node": "6.0.106", @@ -144,7 +144,7 @@ "@types/uglify-js": "3.0.2", "cross-env": "^5.0.0", "find-root": "^1.0.0", - "gh-pages": "^1.0.0", + "gh-pages": "1.1.0", "npm-run-all": "^4.0.2", "optimize-js-plugin": "0.0.4", "parse5": "^3.0.2", @@ -152,6 +152,6 @@ "rimraf": "2.6.2", "ts-node": "3.3.0", "tslib": "1.8.1", - "typescript": "2.6.2" + "typescript": "2.7.2" } } diff --git a/starter/src/app/about/about.component.ts b/starter/src/app/about/about.component.ts index d7a8122ba8..223d1bc18b 100644 --- a/starter/src/app/about/about.component.ts +++ b/starter/src/app/about/about.component.ts @@ -1,5 +1,5 @@ import { Component, Inject, Input, OnInit } from "@angular/core"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { StarkLoggingService, STARK_LOGGING_SERVICE } from "@nationalbankbelgium/stark-core"; @Component({ diff --git a/starter/src/app/app.routes.ts b/starter/src/app/app.routes.ts index c11a6c2c06..3875e80950 100644 --- a/starter/src/app/app.routes.ts +++ b/starter/src/app/app.routes.ts @@ -2,9 +2,8 @@ import { HomeComponent } from "./home"; import { AboutComponent } from "./about"; import { NoContentComponent } from "./no-content"; import { Ng2StateDeclaration, Transition } from "@uirouter/angular"; -import { of } from "rxjs/observable/of"; -import { delay } from "rxjs/operators/delay"; -import { Observable } from "rxjs/Observable"; +import { Observable, of } from "rxjs"; +import { delay } from "rxjs/operators"; export function getResolvedData(): Observable { console.warn("resolve data being fetched... please wait..."); diff --git a/starter/src/app/home/home.component.ts b/starter/src/app/home/home.component.ts index 53ec8e80d1..6bdc107327 100644 --- a/starter/src/app/home/home.component.ts +++ b/starter/src/app/home/home.component.ts @@ -15,7 +15,7 @@ import { StarkQueryParam, StarkSingleItemResponseWrapper } from "@nationalbankbelgium/stark-core"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; import { AppState } from "../app.service"; import { Title } from "./title"; diff --git a/starter/src/app/home/title/title.service.ts b/starter/src/app/home/title/title.service.ts index a45a920174..06199786f7 100644 --- a/starter/src/app/home/title/title.service.ts +++ b/starter/src/app/home/title/title.service.ts @@ -1,6 +1,6 @@ import { Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; -import { Observable } from "rxjs/Observable"; +import { Observable } from "rxjs"; @Injectable() export class Title { diff --git a/tsconfig-test.json b/tsconfig-test.json deleted file mode 100644 index e69de29bb2..0000000000