You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by me...@apache.org on 2018/10/12 08:25:34 UTC
ranger git commit: RANGER-2220 minify JavaScript files during
packaging
Repository: ranger
Updated Branches:
refs/heads/master b152d207d -> 2dae7b0f6
RANGER-2220 minify JavaScript files during packaging
Signed-off-by: Mehul Parikh <me...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/2dae7b0f
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/2dae7b0f
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/2dae7b0f
Branch: refs/heads/master
Commit: 2dae7b0f6edd50c07546b5d1eee87044f02d6b7c
Parents: b152d20
Author: Csaba Koncz <cs...@gmail.com>
Authored: Thu Sep 13 14:58:14 2018 +0200
Committer: Mehul Parikh <me...@apache.org>
Committed: Fri Oct 12 13:55:13 2018 +0530
----------------------------------------------------------------------
pom.xml | 4 +
security-admin/pom.xml | 79 +++++++++++++++++++-
security-admin/src/main/webapp/index.html | 11 ++-
.../libs/bower/backbone-forms/js/bootstrap.js | 2 +-
.../js/backbone.bootstrap-modal.js | 12 +--
security-admin/src/main/webapp/minify.build.js | 28 +++++++
.../src/main/webapp/package-lock.json | 14 ++++
security-admin/src/main/webapp/package.json | 10 +++
security-admin/src/main/webapp/scripts/Init.js | 41 ++++------
security-admin/src/main/webapp/scripts/Main.js | 3 +-
10 files changed, 159 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 51622ed..cbeb01e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -603,6 +603,10 @@
<exclude>**/target/apidocs/**</exclude>
<exclude>**/target/kms/apidocs/**</exclude>
<exclude>**/importPolicy/*.json</exclude>
+ <exclude>**/node/**</exclude>
+ <exclude>**/node_modules/**</exclude>
+ <exclude>**/package.json</exclude>
+ <exclude>**/package-lock.json</exclude>
</excludes>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/pom.xml
----------------------------------------------------------------------
diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index f45392f..7f81e68 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -560,15 +560,24 @@
<goal>replace</goal>
</goals>
<configuration>
+ <basedir>${project.build.directory}/${project.build.finalName}</basedir>
<includes>
- <include>security-admin/target/${project.build.finalName}/index.html</include>
- <include>security-admin/target/${project.build.finalName}/scripts/Init.js</include>
+ <include>index.html</include>
+ <include>scripts/Init.js</include>
</includes>
<replacements>
<replacement>
<token>build.version</token>
<value>${project.version}</value>
</replacement>
+ <replacement>
+ <token>(?m)\<\!-- *dev *--\>(.*)$</token>
+ <value>\<\!-- dev $1 --\></value>
+ </replacement>
+ <replacement>
+ <token>\<\!-- *prod *(.*) *--\></token>
+ <value>\<\!-- prod --\>$1</value>
+ </replacement>
</replacements>
</configuration>
</execution>
@@ -585,6 +594,72 @@
<target>1.7</target>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/webapp</directory>
+ <includes>
+ <include>package.json</include>
+ <include>package-lock.json</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.6</version>
+ <configuration>
+ <workingDirectory>${project.build.directory}</workingDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>prepare-package</phase>
+ <id>install node and npm</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <configuration>
+ <nodeVersion>v8.12.0</nodeVersion>
+ <npmVersion>6.4.1</npmVersion>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>prepare-package</phase>
+ <id>npm install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>prepare-package</phase>
+ <id>npm run r.js</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>run r.js -- -o ${project.build.finalName}/minify.build.js</arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<resources>
<resource>
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/index.html b/security-admin/src/main/webapp/index.html
index 60ef5a7..4eb9735 100644
--- a/security-admin/src/main/webapp/index.html
+++ b/security-admin/src/main/webapp/index.html
@@ -120,10 +120,15 @@
<i class="icon-arrow-up bigger-120 _allowNav"></i>
</a>
+ <script src="libs/bower/requirejs/js/require.js"></script>
+
+ <!--
+ the script tags below are commented/uncommented during the packaging phase.
+ (see the replacer configuration in POM)
+ -->
+ <!-- dev --><script src="scripts/Init.js?ver=build.version"></script>
+ <!-- prod <script src="scripts/Main.min.js?ver=build.version"></script> -->
- <!-- build:js scripts/main.js -->
- <script data-main="scripts/Init.js?ver=build.version" src="libs/bower/requirejs/js/require.js"></script>
- <!-- endbuild -->
<script type="text/javascript">
require.config({
waitSeconds : 0
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/libs/bower/backbone-forms/js/bootstrap.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/libs/bower/backbone-forms/js/bootstrap.js b/security-admin/src/main/webapp/libs/bower/backbone-forms/js/bootstrap.js
index 2761755..b8e4384 100644
--- a/security-admin/src/main/webapp/libs/bower/backbone-forms/js/bootstrap.js
+++ b/security-admin/src/main/webapp/libs/bower/backbone-forms/js/bootstrap.js
@@ -3,7 +3,7 @@
*
* 'data-*' attributes control where elements are placed
*/
-define(['jquery', 'underscore', 'backbone', 'backbone-forms'], function($, _, Backbone) {
+define(['jquery', 'underscore', 'backbone', 'backbone-forms', 'backbone-forms.list'], function($, _, Backbone) {
var Form = Backbone.Form;
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/libs/bower/backbone.bootstrap-modal/js/backbone.bootstrap-modal.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/libs/bower/backbone.bootstrap-modal/js/backbone.bootstrap-modal.js b/security-admin/src/main/webapp/libs/bower/backbone.bootstrap-modal/js/backbone.bootstrap-modal.js
index 6cd05b0..7c5efc2 100644
--- a/security-admin/src/main/webapp/libs/bower/backbone.bootstrap-modal/js/backbone.bootstrap-modal.js
+++ b/security-admin/src/main/webapp/libs/bower/backbone.bootstrap-modal/js/backbone.bootstrap-modal.js
@@ -260,16 +260,6 @@
module.exports = Modal;
}
- //AMD / RequireJS
- if (typeof define === 'function' && define.amd) {
- return define(function() {
- Backbone.BootstrapModal = Modal;
- })
- }
-
- //Regular; add to Backbone.Bootstrap.Modal
- else {
- Backbone.BootstrapModal = Modal;
- }
+ Backbone.BootstrapModal = Modal;
})(jQuery, _, Backbone);
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/minify.build.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/minify.build.js b/security-admin/src/main/webapp/minify.build.js
new file mode 100644
index 0000000..4b94bb1
--- /dev/null
+++ b/security-admin/src/main/webapp/minify.build.js
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+{
+ mainConfigFile: 'scripts/Init.js',
+ baseUrl: 'scripts',
+ wrapShim: true,
+ generateSourceMaps: true,
+ name: 'Main',
+ insertRequire: ['Main'],
+ out: 'scripts/Main.min.js'
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/package-lock.json
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/package-lock.json b/security-admin/src/main/webapp/package-lock.json
new file mode 100644
index 0000000..f7a7283
--- /dev/null
+++ b/security-admin/src/main/webapp/package-lock.json
@@ -0,0 +1,14 @@
+{
+ "name": "security-admin",
+ "version": "2.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "requirejs": {
+ "version": "2.3.6",
+ "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
+ "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
+ "dev": true
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/package.json
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/package.json b/security-admin/src/main/webapp/package.json
new file mode 100644
index 0000000..9f22744
--- /dev/null
+++ b/security-admin/src/main/webapp/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "security-admin",
+ "version": "2.0.0",
+ "scripts": {
+ "r.js": "r.js"
+ },
+ "devDependencies": {
+ "requirejs": "^2.3.6"
+ }
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/scripts/Init.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/Init.js b/security-admin/src/main/webapp/scripts/Init.js
index 4493f62..52b49e5 100644
--- a/security-admin/src/main/webapp/scripts/Init.js
+++ b/security-admin/src/main/webapp/scripts/Init.js
@@ -19,24 +19,17 @@
require.config({
-// baseUrl: "/scripts",
+ baseUrl: "scripts",
urlArgs : 'ver=build.version',
-
+
/* starting point for application */
- deps: ['backbone.marionette', 'bootstrap', 'Main','globalize','utils/XALangSupport'],
+ deps: ['Main'],
shim: {
- backbone: {
- deps: [ 'underscore', 'jquery'],
- exports: 'Backbone'
- },
bootstrap: {
deps: ['jquery'],
- exports: 'jquery'
- },
- backgrid : {
- deps: [ 'backbone','backbone-fetch-cache']
+ exports: 'jQuery'
},
'backgrid-paginator' : {
deps: [ 'backbone', 'backgrid' ]
@@ -44,9 +37,6 @@
'backgrid-filter' : {
deps: [ 'backbone', 'backgrid' ]
},
- 'backbone-forms.templates' : {
- deps: [ 'backbone-forms.list', 'backbone-forms' ]
- },
'backbone-forms.XAOverrides' : {
deps: [ 'backbone-forms' ]
},
@@ -74,7 +64,7 @@
'bootstrap-datepicker' : {
deps: ['bootstrap']
} ,
-
+
'bootstrap-notify' : {
deps: ['jquery','bootstrap'],
},
@@ -85,9 +75,6 @@
'localstorage' :{
deps : ['backbone','underscore','jquery']
},
- 'backbone-fetch-cache' :{
- deps : ['backbone','underscore','jquery']
- },
'visualsearch': {
deps: [ 'jquery', 'jquery-ui','backbone','underscore']
},
@@ -111,21 +98,21 @@
/* alias all marionette libs */
'backbone.marionette' : '../libs/bower/backbone.marionette/js/backbone.marionette',
- 'backbone.wreqr' : '../libs/bower/backbone.wreqr/js/backbone.wreqr',
+ 'backbone.wreqr' : '../libs/bower/backbone.wreqr/js/backbone.wreqr',
'backbone.babysitter' : '../libs/bower/backbone.babysitter/js/backbone.babysitter',
/* alias the bootstrap js lib */
bootstrap : '../libs/bower/bootstrap/js/bootstrap',
-
+
/* BackGrid for Tables */
'backgrid' : '../libs/other/backgrid/backgrid',
'backbone-fetch-cache' : '../libs/other/backbone.fetch-cache',
-
+
'backgrid-paginator' : '../libs/bower/backgrid-paginator/js/backgrid-paginator',
'backgrid-filter' : '../libs/bower/backgrid-filter/js/backgrid-filter',
-
+
'backbone-pageable' : '../libs/bower/backbone-pageable/js/backbone-pageable',
- 'localstorage' : '../libs/bower/backbone.localstorage/backbone.localStorage',
+ 'localstorage' : '../libs/bower/backbone.localstorage/backbone.localStorage',
'backbone-forms' : '../libs/bower/backbone-forms/js/backbone-forms',
'backbone-forms.list' : '../libs/bower/backbone-forms/js/list',
'backbone-forms.templates' : '../libs/bower/backbone-forms/js/bootstrap',
@@ -158,12 +145,12 @@
},
hbs: {
- disableI18n: true,
+ disableI18n: true,
helperPathCallback: // Callback to determine the path to look for helpers
function (name) { // ('/template/helpers/'+name by default)
- return "../helpers/XAHelpers";
+ return "../helpers/XAHelpers";
},
- templateExtension: "html",
- compileOptions: {}
+ templateExtension: "html",
+ compileOptions: {}
}
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ranger/blob/2dae7b0f/security-admin/src/main/webapp/scripts/Main.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/Main.js b/security-admin/src/main/webapp/scripts/Main.js
index d518afb..9414146 100644
--- a/security-admin/src/main/webapp/scripts/Main.js
+++ b/security-admin/src/main/webapp/scripts/Main.js
@@ -26,7 +26,8 @@
'modules/XAOverrides',
'modules/RestCsrf',
'utils/XAUtils',
- 'hbs!tmpl/common/loading_tmpl'
+ 'hbs!tmpl/common/loading_tmpl',
+ 'backbone-fetch-cache'
],
function ( Backbone, App, RegionManager, AppRouter, AppController, XAOverrides,RestCSRF, XAUtils, loadingHTML ) {
'use strict';