Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Added comments to Gruntfile.js

Mike McGanndd54081cf3d2
diff --git a/Gruntfile.js b/Gruntfile.js
index 7af396a76..ba3aaf956 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,8 +1,17 @@
+/*
+ * NASA Worldview
+ *
+ * This code was originally developed at NASA/Goddard Space Flight Center for
+ * the Earth Science Data and Information System (ESDIS) project.
+ *
+ * Copyright (C) 2013 - 2014 United States Government as represented by the
+ * Administrator of the National Aeronautics and Space Administration.
+ * All Rights Reserved.
+ */
var moment = require("./node_modules/moment/moment");
var buildTimestamp = moment.utc().format("MMMM DD, YYYY [-] HH:mm [UTC]");
var buildNonce = moment.utc().format("YYYYMMDDHHmmssSSS");
-var revision =
module.exports = function(grunt) {
@@ -25,24 +34,34 @@ module.exports = function(grunt) {
},
copy: {
+ // Copies all configuration files to the build directory.
+ // Generating the master file may change the source files and this
+ // keeps the originals pristine.
config: {
files: [
{ expand: true, cwd: "etc/config/",
src: "config/**", dest: "build" }
]
},
+ // Copies the web root from the source directory to the build
+ // directory
web: {
files: [
{ expand: true, cwd: "src",
src: "**", dest: "build/worldview-debug/web" }
]
},
+
+ // Copies the auxillary binary files and/or scripts from the
+ // source directory to the build directory.
bin: {
files: [
{ expand: true, cwd: "bin",
src: "**", dest: "build/worldview-debug/bin" }
]
},
+ // Copies the concatenated JavaScript and CSS files to the
+ // final location in the release web root being built.
concat: {
files: [
{ expand: false, src: "build/worldview.js",
@@ -51,6 +70,11 @@ module.exports = function(grunt) {
dest: "build/worldview-debug/web" }
]
},
+ // Copies the finished version of the debugging web root to
+ // create a release web root. JavaScript and CSS files are omitted
+ // since the concatenated version is used instead. Files that
+ // must be included in non-concatenated form should be copied
+ // over too
release: {
files: [
{ expand: true, cwd: "build/worldview-debug",
@@ -65,6 +89,9 @@ module.exports = function(grunt) {
dest: "build/worldview/web" }
]
},
+ // Since the location of the CSS changes when using the
+ // concatenated file. "hoist" up all the dependencies found
+ // in the ext directory by one directory.
ext: {
files: [
{ expand: true,
@@ -83,36 +110,49 @@ module.exports = function(grunt) {
},
exec: {
+ // Create Worldview color palettes from ACT files provided by
+ // the Earth Observatory
act: {
command: "python etc/config/act2json.py build/config/palettes"
},
+ // Create Worldview color palettes from VRT files provided by
+ // the GIBS team
vrt: {
command: "python etc/config/vrt2json.py " +
"--layers-dir build/config/layers " +
"build/config/palettes"
},
+ // Combine all configuration json files into one.
config: {
command: "python etc/config/generate-config.py " +
"--config-dir build/config " +
"--output build/worldview-debug/web/data/config.json"
},
+ // Create a minified verison of the configuration file for
+ // the release web root.
config_min: {
command: "python etc/config/generate-config.py " +
"--config-dir build/config " +
"--minify " +
"--output build/config.min.json"
},
+ // Creates a combined configuration file for use in the source
+ // tree
config_src: {
command: "python etc/config/generate-config.py " +
"--config-dir build/config " +
"--output src/data/config.json"
},
+ // After removing JavaScript and CSS files that are no longer
+ // need in a release build, there are a lot of empty directories.
+ // Remove all of them.
empty: {
command: "find build -type d -empty -delete"
}
},
replace: {
+ // Add in the timestamp of the build as needed
timestamp: {
src: ["build/worldview-debug/web/js/**/*.js"],
overwrite: true,
@@ -121,6 +161,8 @@ module.exports = function(grunt) {
to: buildTimestamp
}]
},
+ // Add in the version of this build as needed. Update the version
+ // in package.json
version: {
src: ["build/worldview-debug/web/js/**/*.js"],
overwrite: true,
@@ -129,6 +171,7 @@ module.exports = function(grunt) {
to: "<%= pkg.version %>"
}]
},
+ // Add in a timestamp nonce to URIs for cache busting
nonce: {
src: [
"build/worldview-debug/web/**/*.html",
@@ -140,6 +183,8 @@ module.exports = function(grunt) {
to: buildNonce
}]
},
+ // Remove all development links <!-- link.dev --> and uncomment
+ // all the release links <1-- link.prod -->
links: {
src: ["build/worldview-debug/web/**/*.html"],
overwrite: true,
@@ -154,18 +199,22 @@ module.exports = function(grunt) {
},
concat: {
+ // Combine all the Worldview JavaScript files into one file.
wv_js: {
src: wvJs,
dest: "build/worldview-debug/web/js/wv.js"
},
+ // Combine all the Worldview CSS files into one file.
wv_css: {
src: wvCss,
dest: "build/worldview-debug/web/css/wv.css"
},
+ // Combine all the external library JavaScript files into one file.
ext_js: {
src: extJs,
dest: "build/worldview-debug/web/ext/ext.js"
},
+ // Combine all the external library CSS files into one file.
ext_css: {
src: extCss,
dest: "build/worldview-debug/web/ext/ext.css"
@@ -173,6 +222,7 @@ module.exports = function(grunt) {
},
uglify: {
+ // Minifiy the concatenated Worldview JavaScript file.
wv_js: {
options: {
banner: banner
@@ -183,6 +233,7 @@ module.exports = function(grunt) {
]
}
},
+ // Minifiy the concatenated external libraries JavaScript file.
ext_js: {
files: {
"build/worldview/web/ext/ext.js": [
@@ -194,6 +245,7 @@ module.exports = function(grunt) {
},
cssmin: {
+ // Minifiy the concatenated Worldview CSS file.
wv_css: {
options: {
banner: banner,
@@ -205,6 +257,7 @@ module.exports = function(grunt) {
]
}
},
+ // Minifiy the concatenated external libraries CSS file.
ext_css: {
options: {
banner: banner,
@@ -219,14 +272,19 @@ module.exports = function(grunt) {
},
lineremover: {
+ // After removing all the <!-- link.dev --> references, there
+ // are a lot of blank lines in index.html. Remove them
release: {
files: {
- "build/worldview/web/index.html": "build/worldview/web/index.html"
+ "build/worldview/web/index.html":
+ "build/worldview/web/index.html"
}
}
},
compress: {
+ // Create a tarball of the debug build with a version number and
+ // git revision.
debug_versioned: {
options: {
archive: "dist/" +
@@ -241,6 +299,8 @@ module.exports = function(grunt) {
dest: "worldview-debug"
}]
},
+ // Create a tarball of the debug build without versioning
+ // information.
debug: {
options: {
archive: "dist/worldview-debug.tar.gz"
@@ -250,6 +310,8 @@ module.exports = function(grunt) {
dest: "worldview-debug"
}]
},
+ // Create a tarball of the release build with a version number and
+ // git revision.
release_versioned: {
options: {
archive: "dist/" +
@@ -263,6 +325,8 @@ module.exports = function(grunt) {
dest: "worldview"
}]
},
+ // Create a tarball of the release build without versioning
+ // information.
release: {
options: {
archive: "dist/worldview.tar.gz"
@@ -277,6 +341,9 @@ module.exports = function(grunt) {
remove: {
build: ["build"],
dist: ["dist"],
+ // Removes all JavaScript, CSS, and auxillary files not necessary
+ // in a release build. Place exceptions for JavaScript and
+ // CSS here.
source: [
"build/worldview-debug/web/**/*.css",
"build/worldview-debug/web/**/*.js",