adds unique query param value on build to force invalidation of TP assets

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/054ab7e9
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/054ab7e9
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/054ab7e9

Branch: refs/heads/master
Commit: 054ab7e9ad6d31802d8cf1b0dfc68128cf7edac1
Parents: c024c71
Author: Jeremy Mitchell <mitchell...@gmail.com>
Authored: Tue Aug 8 12:03:08 2017 -0600
Committer: Dewayne Richardson <dewr...@apache.org>
Committed: Tue Aug 8 13:15:52 2017 -0600

----------------------------------------------------------------------
 traffic_portal/Gruntfile.js            |  5 +++
 traffic_portal/grunt/string-replace.js | 59 ++++++++++++++++++++++++
 traffic_portal/package.json            | 70 ++++++++++++++---------------
 3 files changed, 99 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/054ab7e9/traffic_portal/Gruntfile.js
----------------------------------------------------------------------
diff --git a/traffic_portal/Gruntfile.js b/traffic_portal/Gruntfile.js
index 5f32f25..ac0314b 100644
--- a/traffic_portal/Gruntfile.js
+++ b/traffic_portal/Gruntfile.js
@@ -30,6 +30,9 @@ module.exports = function (grunt) {
     // load grunt task configurations
     require('load-grunt-config')(grunt);
 
+    // load string replacement functionality. used to add query params to 
index.html to bust cache on upgrade
+    require('grunt-string-replace')(grunt);
+
     // default task - when you type 'grunt' it really runs as 'grunt dev'
     grunt.registerTask('default', ['dev']);
 
@@ -50,6 +53,7 @@ module.exports = function (grunt) {
     grunt.registerTask('build', [
         'clean',
         'copy:dist',
+        'string-replace',
         'build-css',
         'build-js',
         'build-shared-libs'
@@ -58,6 +62,7 @@ module.exports = function (grunt) {
     grunt.registerTask('build-dev', [
         'clean',
         'copy:dev',
+        'string-replace',
         'build-css-dev',
         'build-js-dev',
         'build-shared-libs-dev'

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/054ab7e9/traffic_portal/grunt/string-replace.js
----------------------------------------------------------------------
diff --git a/traffic_portal/grunt/string-replace.js 
b/traffic_portal/grunt/string-replace.js
new file mode 100644
index 0000000..26296d3
--- /dev/null
+++ b/traffic_portal/grunt/string-replace.js
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+module.exports = {
+               files: {
+                       expand: true,
+                       cwd: '<%= globalConfig.distdir %>/public',
+                       dest: '<%= globalConfig.distdir %>/public',
+                       src: 'index.html',
+               },
+               options: {
+                       replacements: [
+                               {
+                                       pattern: 'theme.css',
+                                       replacement: 'theme.css?built=' + 
Date.now()
+                               },
+                               {
+                                       pattern: 'loading.css',
+                                       replacement: 'loading.css?built=' + 
Date.now()
+                               },
+                               {
+                                       pattern: 'main.css',
+                                       replacement: 'main.css?built=' + 
Date.now()
+                               },
+                               {
+                                       pattern: 'custom.css',
+                                       replacement: 'custom.css?built=' + 
Date.now()
+                               },
+                               {
+                                       pattern: 'shared-libs.js',
+                                       replacement: 'shared-libs.js?built=' + 
Date.now()
+                               },
+                               {
+                                       pattern: 'app.js',
+                                       replacement: 'app.js?built=' + 
Date.now()
+                               },
+                               {
+                                       pattern: 'config.js',
+                                       replacement: 'config.js?built=' + 
Date.now()
+                               }
+                       ]
+               }
+};

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/054ab7e9/traffic_portal/package.json
----------------------------------------------------------------------
diff --git a/traffic_portal/package.json b/traffic_portal/package.json
index 069c22f..6f51e0e 100755
--- a/traffic_portal/package.json
+++ b/traffic_portal/package.json
@@ -1,37 +1,37 @@
 {
-    "name": "traffic_portal",
-    "devDependencies": {
-        "morgan": "1.7.0",
-        "connect-modrewrite": "0.10.1",
-        "connect-timeout": "1.8.0",
-        "ssl-root-cas": "1.2.3",
-        "express": "4.15.2",
-        "requirejs": "2.3.3",
-        "connect-livereload": "0.5.4",
-        "grunt": "0.4.5",
-        "grunt-adam-compass": "0.7.1",
-        "grunt-browserify2": "0.1.8",
-        "grunt-concurrent": "2.2.1",
-        "grunt-contrib-clean": "1.0.0",
-        "grunt-contrib-concat": "1.0.0",
-        "grunt-contrib-copy": "0.8.2",
-        "grunt-contrib-cssmin": "0.14.0",
-        "grunt-contrib-htmlmin": "0.6.0",
-        "grunt-contrib-jshint": "1.0.0",
-        "grunt-contrib-uglify": "0.11.1",
-        "grunt-contrib-watch": "0.6.1",
-        "grunt-express-server": "0.5.2",
-        "grunt-html2js": "0.3.5",
-        "grunt-install-dependencies": "0.2.0",
-        "grunt-newer": "1.1.2",
-        "grunt-rev": "0.1.0",
-        "grunt-usemin": "3.0.0",
-        "grunt-wiredep": "2.0.0",
-        "load-grunt-config": "0.19.1",
-        "load-grunt-tasks": "3.4.1",
-        "time-grunt": "1.3.0"
-    },
-    "engines": {
-        "node": "0.11.14"
-    }
+  "name": "traffic_portal",
+  "devDependencies": {
+    "connect-livereload": "0.5.4",
+    "connect-modrewrite": "0.10.1",
+    "connect-timeout": "1.8.0",
+    "express": "4.15.2",
+    "grunt": "0.4.5",
+    "grunt-adam-compass": "0.7.1",
+    "grunt-browserify2": "0.1.8",
+    "grunt-concurrent": "2.2.1",
+    "grunt-contrib-clean": "1.0.0",
+    "grunt-contrib-concat": "1.0.0",
+    "grunt-contrib-copy": "0.8.2",
+    "grunt-contrib-cssmin": "0.14.0",
+    "grunt-contrib-htmlmin": "0.6.0",
+    "grunt-contrib-jshint": "1.0.0",
+    "grunt-contrib-uglify": "0.11.1",
+    "grunt-contrib-watch": "0.6.1",
+    "grunt-express-server": "0.5.2",
+    "grunt-html2js": "0.3.5",
+    "grunt-install-dependencies": "0.2.0",
+    "grunt-newer": "1.1.2",
+    "grunt-string-replace": "1.3.1",
+    "grunt-usemin": "3.0.0",
+    "grunt-wiredep": "2.0.0",
+    "load-grunt-config": "0.19.1",
+    "load-grunt-tasks": "3.4.1",
+    "morgan": "1.7.0",
+    "requirejs": "2.3.3",
+    "ssl-root-cas": "1.2.3",
+    "time-grunt": "1.3.0"
+  },
+  "engines": {
+    "node": "0.11.14"
+  }
 }

Reply via email to