Repository: ambari Updated Branches: refs/heads/trunk 18ae06d3e -> 2a6dd58f5
AMBARI-21946 Log Search UI: reorganize generated files structure. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2a6dd58f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2a6dd58f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2a6dd58f Branch: refs/heads/trunk Commit: 2a6dd58f506b5e9fcaf7b435e645c2397fe35855 Parents: 18ae06d Author: ababiichuk <ababiic...@hortonworks.com> Authored: Wed Sep 13 16:19:25 2017 +0300 Committer: ababiichuk <ababiic...@hortonworks.com> Committed: Wed Sep 13 16:56:56 2017 +0300 ---------------------------------------------------------------------- .../ambari-logsearch-web/.angular-cli.json | 34 +- ambari-logsearch/ambari-logsearch-web/README.md | 10 +- .../ambari-logsearch-web/package.json | 34 +- ambari-logsearch/ambari-logsearch-web/pom.xml | 1 + .../ambari-logsearch-web/src/app/app.module.ts | 2 +- .../ambari-logsearch-web/webpack.config.js | 530 +++++++++++++++++++ 6 files changed, 571 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/2a6dd58f/ambari-logsearch/ambari-logsearch-web/.angular-cli.json ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/.angular-cli.json b/ambari-logsearch/ambari-logsearch-web/.angular-cli.json index 70fd7b6..267f5e0 100644 --- a/ambari-logsearch/ambari-logsearch-web/.angular-cli.json +++ b/ambari-logsearch/ambari-logsearch-web/.angular-cli.json @@ -1,12 +1,12 @@ { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { - "name": "ambari-logsearch-web" + "name": "ambari-logsearch-web", + "ejected": true }, "apps": [ { "root": "src", - "outDir": "dist", "assets": [ "assets", "favicon.ico" @@ -15,20 +15,8 @@ "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", - "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", - "prefix": "app", - "styles": [ - "styles.less", - "../node_modules/bootstrap/dist/css/bootstrap.min.css", - "../node_modules/font-awesome/css/font-awesome.min.css", - "../src/vendor/css/bootstrap-logsearch.min.css" - ], - "scripts": [ - "../node_modules/jquery/dist/jquery.min.js", - "../node_modules/bootstrap/dist/js/bootstrap.min.js", - "../src/vendor/js/bootstrap-logsearch.min.js" - ], + "prefix": "", "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", @@ -36,11 +24,6 @@ } } ], - "e2e": { - "protractor": { - "config": "./protractor.conf.js" - } - }, "lint": [ { "project": "src/tsconfig.app.json" @@ -52,13 +35,8 @@ "project": "e2e/tsconfig.e2e.json" } ], - "test": { - "karma": { - "config": "./karma.conf.js" - } - }, "defaults": { - "styleExt": "less", - "component": {} - } + "styleExt": "less" + }, + "packageManager": "yarn" } http://git-wip-us.apache.org/repos/asf/ambari/blob/2a6dd58f/ambari-logsearch/ambari-logsearch-web/README.md ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/README.md b/ambari-logsearch/ambari-logsearch-web/README.md index ff1456e..081d22a 100644 --- a/ambari-logsearch/ambari-logsearch-web/README.md +++ b/ambari-logsearch/ambari-logsearch-web/README.md @@ -4,7 +4,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular ## Development server -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. +Run `npm start` or `yarn start` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. ## Code scaffolding @@ -12,16 +12,16 @@ Run `ng generate component component-name` to generate a new component. You can ## Build -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. +Run `npm run build` or `yarn build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `npm run build-prod` or `yarn build-prod` command for a production build. ## Running unit tests -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). +Run `npm test` or `yarn test` to execute the unit tests via [Karma](https://karma-runner.github.io). ## Running end-to-end tests -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). -Before running the tests make sure you are serving the app via `ng serve`. +Run `npm run e2e` or `yarn e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). +Before running the tests make sure you are serving the app via `npm start` or `yarn start`. ## Further help http://git-wip-us.apache.org/repos/asf/ambari/blob/2a6dd58f/ambari-logsearch/ambari-logsearch-web/package.json ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/package.json b/ambari-logsearch/ambari-logsearch-web/package.json index 0892d85..7e8a0ba 100644 --- a/ambari-logsearch/ambari-logsearch-web/package.json +++ b/ambari-logsearch/ambari-logsearch-web/package.json @@ -4,12 +4,13 @@ "license": "Apache 2.0", "scripts": { "ng": "ng", - "start": "ng serve", - "build": "ng build", - "build-prod": "ng build -prod", - "test": "ng test", + "start": "webpack-dev-server --port=4200", + "build": "webpack", + "build-prod": "NODE_ENV='production' webpack -p", + "test": "karma start ./karma.conf.js", "lint": "ng lint", - "e2e": "ng e2e" + "e2e": "protractor ./protractor.conf.js", + "pree2e": "webdriver-manager update --standalone false --gecko false --quiet" }, "dependencies": { "@angular/common": "^4.0.0", @@ -60,6 +61,27 @@ "protractor": "~5.1.0", "ts-node": "~2.0.0", "tslint": "~4.5.0", - "typescript": "~2.2.0" + "typescript": "~2.2.0", + "webpack-dev-server": "~2.7.1", + "webpack": "~3.5.5", + "autoprefixer": "^6.5.3", + "css-loader": "^0.28.1", + "cssnano": "^3.10.0", + "exports-loader": "^0.6.3", + "file-loader": "^0.10.0", + "html-webpack-plugin": "^2.29.0", + "less-loader": "^4.0.5", + "postcss-loader": "^1.3.3", + "postcss-url": "^5.1.2", + "raw-loader": "^0.5.1", + "sass-loader": "^6.0.3", + "source-map-loader": "^0.2.0", + "istanbul-instrumenter-loader": "^2.0.0", + "style-loader": "^0.13.1", + "stylus-loader": "^3.0.1", + "url-loader": "^0.5.7", + "circular-dependency-plugin": "^3.0.0", + "webpack-concat-plugin": "1.4.0", + "copy-webpack-plugin": "^4.0.1" } } http://git-wip-us.apache.org/repos/asf/ambari/blob/2a6dd58f/ambari-logsearch/ambari-logsearch-web/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/pom.xml b/ambari-logsearch/ambari-logsearch-web/pom.xml index 075527b..7a6b02e 100644 --- a/ambari-logsearch/ambari-logsearch-web/pom.xml +++ b/ambari-logsearch/ambari-logsearch-web/pom.xml @@ -117,6 +117,7 @@ <include>karma.conf.js</include> <include>tsconfig.json</include> <include>tslint.json</include> + <include>webpack.config.js</include> </includes> </resource> </resources> http://git-wip-us.apache.org/repos/asf/ambari/blob/2a6dd58f/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts b/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts index c15ecbc..8ea933c 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts @@ -79,7 +79,7 @@ import {TimeZoneAbbrPipe} from '@app/pipes/timezone-abbr.pipe'; export function HttpLoaderFactory(http: Http) { // adding 'static' parameter to step over mock data request - return new TranslateHttpLoader(http, 'assets/i18n/', '.json?static=true'); + return new TranslateHttpLoader(http, 'resources/assets/i18n/', '.json?static=true'); } export function getXHRBackend(injector: Injector, browser: BrowserXhr, xsrf: XSRFStrategy, options: ResponseOptions): any { http://git-wip-us.apache.org/repos/asf/ambari/blob/2a6dd58f/ambari-logsearch/ambari-logsearch-web/webpack.config.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/webpack.config.js b/ambari-logsearch/ambari-logsearch-web/webpack.config.js new file mode 100644 index 0000000..72eaa7f --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web/webpack.config.js @@ -0,0 +1,530 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); +const path = require('path'); +const ConcatPlugin = require('webpack-concat-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const ProgressPlugin = require('webpack/lib/ProgressPlugin'); +const CircularDependencyPlugin = require('circular-dependency-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const autoprefixer = require('autoprefixer'); +const postcssUrl = require('postcss-url'); +const cssnano = require('cssnano'); + +const {NoEmitOnErrorsPlugin, SourceMapDevToolPlugin, NamedModulesPlugin} = require('webpack'); +const {InsertConcatAssetsWebpackPlugin, NamedLazyChunksWebpackPlugin, BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack'); +const {CommonsChunkPlugin} = require('webpack').optimize; +const {AotPlugin} = require('@ngtools/webpack'); + +const nodeModules = path.join(process.cwd(), 'node_modules'); +const realNodeModules = fs.realpathSync(nodeModules); +const genDirNodeModules = path.join(process.cwd(), 'src', '$$_gendir', 'node_modules'); +const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"]; +const minimizeCss = false; +const baseHref = ""; +const deployUrl = ""; +const postcssPlugins = function () { + // safe settings based on: https://github.com/ben-eb/cssnano/issues/358#issuecomment-283696193 + const importantCommentRe = /@preserve|@license|[@#]\s*source(?:Mapping)?URL|^!/i; + const minimizeOptions = { + autoprefixer: false, + safe: true, + mergeLonghand: false, + discardComments: { remove: (comment) => !importantCommentRe.test(comment) } + }; + return [ + postcssUrl({ + url: (URL) => { + // Only convert root relative URLs, which CSS-Loader won't process into require(). + if (!URL.startsWith('/') || URL.startsWith('//')) { + return URL; + } + if (deployUrl.match(/:\/\//)) { + // If deployUrl contains a scheme, ignore baseHref use deployUrl as is. + return `${deployUrl.replace(/\/$/, '')}${URL}`; + } + else if (baseHref.match(/:\/\//)) { + // If baseHref contains a scheme, include it as is. + return baseHref.replace(/\/$/, '') + + `/${deployUrl}/${URL}`.replace(/\/\/+/g, '/'); + } + else { + // Join together base-href, deploy-url and the original URL. + // Also dedupe multiple slashes into single ones. + return `/${baseHref}/${deployUrl}/${URL}`.replace(/\/\/+/g, '/'); + } + } + }), + autoprefixer(), + ].concat(minimizeCss ? [cssnano(minimizeOptions)] : []); + }; + +module.exports = { + "resolve": { + "extensions": [ + ".ts", + ".js" + ], + "modules": [ + "./node_modules", + "./node_modules" + ], + "symlinks": true + }, + "resolveLoader": { + "modules": [ + "./node_modules", + "./node_modules" + ] + }, + "entry": { + "main": [ + "./src/main.ts" + ], + "polyfills": [ + "./src/polyfills.ts" + ], + "styles": [ + "./src/styles.less", + "./node_modules/bootstrap/dist/css/bootstrap.min.css", + "./node_modules/font-awesome/css/font-awesome.min.css", + "./src/vendor/css/bootstrap-logsearch.min.css" + ] + }, + "output": { + "path": path.join(process.cwd(), "dist/resources"), + "publicPath": "resources/", + "filename": "[name].bundle.js", + "chunkFilename": "[id].chunk.js" + }, + "module": { + "rules": [ + { + "enforce": "pre", + "test": /\.js$/, + "loader": "source-map-loader", + "exclude": [ + /(\\|\/)node_modules(\\|\/)/ + ] + }, + { + "test": /\.html$/, + "loader": "raw-loader" + }, + { + "test": /\.(eot|svg|cur)$/, + "loader": "file-loader?name=[name].[ext]" + }, + { + "test": /\.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/, + "loader": "url-loader?name=[name].[ext]&limit=10000" + }, + { + "exclude": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.css$/, + "use": [ + "exports-loader?module.exports.toString()", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + } + ] + }, + { + "exclude": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.scss$|\.sass$/, + "use": [ + "exports-loader?module.exports.toString()", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + }, + { + "loader": "sass-loader", + "options": { + "sourceMap": false, + "precision": 8, + "includePaths": [] + } + } + ] + }, + { + "exclude": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.less$/, + "use": [ + "exports-loader?module.exports.toString()", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + }, + { + "loader": "less-loader", + "options": { + "sourceMap": false, + "paths": [] + } + } + ] + }, + { + "exclude": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.styl$/, + "use": [ + "exports-loader?module.exports.toString()", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + }, + { + "loader": "stylus-loader", + "options": { + "sourceMap": false, + "paths": [] + } + } + ] + }, + { + "include": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.css$/, + "use": [ + "style-loader", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + } + ] + }, + { + "include": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.scss$|\.sass$/, + "use": [ + "style-loader", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + }, + { + "loader": "sass-loader", + "options": { + "sourceMap": false, + "precision": 8, + "includePaths": [] + } + } + ] + }, + { + "include": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.less$/, + "use": [ + "style-loader", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + }, + { + "loader": "less-loader", + "options": { + "sourceMap": false, + "paths": [] + } + } + ] + }, + { + "include": [ + path.join(process.cwd(), "src/styles.less"), + path.join(process.cwd(), "node_modules/bootstrap/dist/css/bootstrap.min.css"), + path.join(process.cwd(), "node_modules/font-awesome/css/font-awesome.min.css"), + path.join(process.cwd(), "src/vendor/css/bootstrap-logsearch.min.css") + ], + "test": /\.styl$/, + "use": [ + "style-loader", + { + "loader": "css-loader", + "options": { + "sourceMap": false, + "importLoaders": 1 + } + }, + { + "loader": "postcss-loader", + "options": { + "ident": "postcss", + "plugins": postcssPlugins + } + }, + { + "loader": "stylus-loader", + "options": { + "sourceMap": false, + "paths": [] + } + } + ] + }, + { + "test": /\.ts$/, + "loader": "@ngtools/webpack" + } + ] + }, + "plugins": [ + new NoEmitOnErrorsPlugin(), + new ConcatPlugin({ + "uglify": false, + "sourceMap": true, + "name": "scripts", + "fileName": "../resources/[name].bundle.js", + "filesToConcat": [ + "node_modules/jquery/dist/jquery.min.js", + "node_modules/bootstrap/dist/js/bootstrap.min.js", + "src/vendor/js/bootstrap-logsearch.min.js" + ] + }), + new InsertConcatAssetsWebpackPlugin([ + "scripts" + ]), + new CopyWebpackPlugin([ + { + "context": "src/", + "to": "", + "from": { + "glob": "assets/**/*", + "dot": true + } + }, + { + "context": "src/", + "to": "../favicon.ico", + "from": { + "glob": "favicon.ico", + "dot": true + } + } + ], { + "ignore": [ + ".gitkeep" + ], + "debug": "warning" + }), + new ProgressPlugin(), + new CircularDependencyPlugin({ + "exclude": /(\\|\/)node_modules(\\|\/)/, + "failOnError": false + }), + new NamedLazyChunksWebpackPlugin(), + new HtmlWebpackPlugin({ + "template": "./src/index.html", + "filename": "../index.html", + "hash": false, + "inject": true, + "compile": true, + "favicon": false, + "minify": false, + "cache": true, + "showErrors": true, + "chunks": "all", + "excludeChunks": [], + "title": "Webpack App", + "xhtml": true, + "chunksSortMode": function sort(left, right) { + let leftIndex = entryPoints.indexOf(left.names[0]); + let rightindex = entryPoints.indexOf(right.names[0]); + if (leftIndex > rightindex) { + return 1; + } + else if (leftIndex < rightindex) { + return -1; + } + else { + return 0; + } + } + }), + new BaseHrefWebpackPlugin({}), + new CommonsChunkPlugin({ + "name": [ + "inline" + ], + "minChunks": null + }), + new CommonsChunkPlugin({ + "name": [ + "vendor" + ], + "minChunks": (module) => { + return module.resource + && (module.resource.startsWith(nodeModules) + || module.resource.startsWith(genDirNodeModules) + || module.resource.startsWith(realNodeModules)); + }, + "chunks": [ + "main" + ] + }), + new SourceMapDevToolPlugin({ + "filename": "[file].map[query]", + "moduleFilenameTemplate": "[resource-path]", + "fallbackModuleFilenameTemplate": "[resource-path]?[hash]", + "sourceRoot": "webpack:///" + }), + new CommonsChunkPlugin({ + "name": [ + "main" + ], + "minChunks": 2, + "async": "common" + }), + new NamedModulesPlugin({}), + new AotPlugin({ + "mainPath": "main.ts", + "replaceExport": false, + "hostReplacementPaths": { + "environments/environment.ts": `environments/environment${process.env.NODE_ENV === "production" ? ".prod" : ""}.ts` + }, + "exclude": [], + "tsConfigPath": "src/tsconfig.app.json", + "skipCodeGeneration": true + }) + ], + "node": { + "fs": "empty", + "global": true, + "crypto": "empty", + "tls": "empty", + "net": "empty", + "process": true, + "module": false, + "clearImmediate": false, + "setImmediate": false + }, + "devServer": { + "contentBase": path.join(process.cwd(), "dist"), + "historyApiFallback": true + } +};