cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblot...@apache.org
Subject [2/2] docs commit: Cleaned up gulpfile. Made some names more consistent. Fixed some minor bugs.
Date Thu, 20 Aug 2015 04:58:25 GMT
Cleaned up gulpfile. Made some names more consistent. Fixed some minor bugs.


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/6e2984ae
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/6e2984ae
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/6e2984ae

Branch: refs/heads/cordova-website
Commit: 6e2984ae18350725e5306d4614b77bc93ddaeef0
Parents: 0a3b791
Author: Dmitry Blotsky <dmitry.blotsky@gmail.com>
Authored: Wed Aug 19 21:57:45 2015 -0700
Committer: Dmitry Blotsky <dmitry.blotsky@gmail.com>
Committed: Wed Aug 19 21:57:45 2015 -0700

----------------------------------------------------------------------
 .gitignore                       |   6 +-
 README.md                        |   8 +-
 _config.yml                      |   2 +-
 _dev.yml                         |   4 +-
 _prod.yml                        |   4 +-
 gulpfile.js                      | 236 +++++++++++++++++++---------------
 www/_data/.gitignore             |   2 +-
 www/_includes/head.html          |   3 -
 www/static/css-src/_plugins.scss |   8 +-
 www/static/js/main.js            |   2 +-
 10 files changed, 152 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index f116d60..db0161f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,8 @@
-public
-deploy
+build-*
 *.pyc
 _defaults.yml
 www/_data/languages.yml
 node_modules
 www/static/css
-www/static/react
+www/static/js/plugins.js
 Gemfile.lock
-settings.json

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index dcf087b..88f71fa 100644
--- a/README.md
+++ b/README.md
@@ -91,15 +91,15 @@ This section requires basic knowledge of SVN. If you do not know how to
use SVN,
 
 First, inspect `_prod.yml` to check that the correct `baseurl` is used. For pre-production
deployment, it should be some non-empty folder (e.g. `"/use-the-force-luke"`), and for a production
deployment it should be empty (i.e. `""`). To then build the full website, run:
 
-    gulp deploy
+    gulp build --prod
 
-A folder called `deploy` will be created, and will contain the whole website. Then, in a
directory *outside* of the `cordova-docs` repository, check out the SVN repository that contains
the currently deployed website by running (committer access required):
+A folder called `build-prod` will be created, and will contain the whole website. Then, in
a directory *outside* of the `cordova-docs` repository, check out the SVN repository that
contains the currently deployed website by running (committer access required):
 
     svn checkout https://svn.apache.org/repos/asf/cordova/site cordova-website
 
-Now, copy the `cordova-docs/deploy/` directory to the corresponding directory in SVN (i.e.
something like `cordova-website/public/use-the-force-luke/` for the pre-production deployment,
or just `cordova-website/public/` for the production deployment):
+Now, copy the `cordova-docs/build-prod/` directory to the corresponding directory in SVN
(i.e. something like `cordova-website/public/use-the-force-luke/` for the pre-production deployment,
or just `cordova-website/public/` for the production deployment):
 
-    cp -R cordova-docs/deploy/ cordova-website/public/use-the-force-luke/
+    cp -R cordova-docs/build-prod/ cordova-website/public/use-the-force-luke/
 
 Finally, go into the cordova-website directory and commit *all* the changes introduced the
newly copied files. The commit might take a while (upwards of 30min), depending on the number
of files copied.
 

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/_config.yml
----------------------------------------------------------------------
diff --git a/_config.yml b/_config.yml
index 6889e29..34f5140 100644
--- a/_config.yml
+++ b/_config.yml
@@ -17,7 +17,7 @@ repo:
 # Build settings
 # =======
 source:      www
-destination: public
+destination: build-dev
 
 keep_files: [".git", ".svn", "wiki-images", "images", "downloads"]
 

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/_dev.yml
----------------------------------------------------------------------
diff --git a/_dev.yml b/_dev.yml
index 75e82ec..1696da3 100644
--- a/_dev.yml
+++ b/_dev.yml
@@ -1,6 +1,6 @@
 exclude:
     - static/css-src
-    - static/react-src
+    - static/plugins
     - docs/de
     - docs/es
     - docs/fr
@@ -36,6 +36,6 @@ exclude:
     - docs/en/3.5.0
     - docs/en/3.6.0
     - docs/en/4.0.0
-    # - docs/en/5.0.0
+    - docs/en/5.0.0
     - docs/en/5.1.1
     # - docs/en/edge

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/_prod.yml
----------------------------------------------------------------------
diff --git a/_prod.yml b/_prod.yml
index c97b100..c9999c1 100644
--- a/_prod.yml
+++ b/_prod.yml
@@ -1,5 +1,5 @@
 baseurl: "/use-the-force-luke"
-destination: deploy
+destination: build-prod
 exclude:
     - static/css-src
-    - static/react-src
+    - static/plugins

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index 9bb93e0..318b674 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -6,6 +6,7 @@ var fse           = require("fs-extra");
 var child_process = require("child_process");
 
 var gulp        = require("gulp");
+var gutil       = require("gulp-util");
 var less        = require("gulp-less");
 var sass        = require("gulp-sass");
 var vstream     = require("vinyl-source-stream");
@@ -13,36 +14,49 @@ var buffer      = require("vinyl-buffer");
 var browsersync = require("browser-sync");
 var header      = require("gulp-header");
 
-var concat     = require('gulp-concat');
-var gutil      = require('gulp-util');
-var browserify = require('browserify');
-var argv       = require('yargs').argv;
-var reactify   = require('reactify');
-var uglify     = require('gulp-uglify');
-var envify     = require('envify');
+var browserify = require("browserify");
+var reactify   = require("reactify");
+var uglify     = require("gulp-uglify");
+var envify     = require("envify");
 
 // constants
 var CONFIG_FILES = ["_config.yml", "_defaults.yml"];
 var DEV_FLAGS    = ["--config", CONFIG_FILES.concat(["_dev.yml"]).join(","), "--trace"];
 var PROD_FLAGS   = ["--config", CONFIG_FILES.concat(["_prod.yml"]).join(",")];
 
-var SOURCE_DIR = "www";
-var BUILD_DIR  = "public";
-var DEPLOY_DIR = "deploy";
-
-var WATCH_INTERVAL = 1000; // in milliseconds
+var YAML_FRONT_MATTER = "---\n---\n";
+var WATCH_INTERVAL    = 1000; // in milliseconds
+
+var ROOT_DIR   = ".";
+var SOURCE_DIR = path.join(ROOT_DIR, "www");
+var DEV_DIR    = path.join(ROOT_DIR, "build-dev");
+var PROD_DIR   = path.join(ROOT_DIR, "build-prod");
+
+var DATA_DIR         = path.join(SOURCE_DIR, "_data");
+var DOCS_DIR         = path.join(SOURCE_DIR, "docs");
+var CSS_SRC_DIR      = path.join(SOURCE_DIR, "static", "css-src");
+var CSS_OUT_DIR      = path.join(SOURCE_DIR, "static", "css");
+var PLUGINS_SRC_DIR  = path.join(SOURCE_DIR, "static", "plugins");
+var JS_DIR           = path.join(SOURCE_DIR, "static", "js");
+var BIN_DIR          = path.join(ROOT_DIR, "tools", "bin");
+
+var CONFIG_FILE       = path.join(ROOT_DIR, "_config.yml");
+var DEFAULTS_FILE     = path.join(ROOT_DIR, "_defaults.yml");
+var LANGUAGES_FILE    = path.join(DATA_DIR, "languages.yml");
+var PLUGINS_FILE_NAME = "plugins.js";
+var PLUGINS_FILE      = path.join(JS_DIR, PLUGINS_FILE_NAME);
+var PLUGINS_SRC_FILE  = path.join(PLUGINS_SRC_DIR, "app.js");
+
+// default variables
+var prod = false;
+
+// passed options
+if (gutil.env.prod) {
+    prod = true;
+}
 
-var CONFIG_FILE    = "_config.yml";
-var DEFAULTS_FILE  = "_defaults.yml";
-var DATA_DIR       = path.join(SOURCE_DIR, "_data");
-var LANGUAGES_FILE = path.join(DATA_DIR, "languages.yml");
-var DOCS_DIR       = path.join(SOURCE_DIR, "docs");
-var CSS_SRC_DIR    = path.join(SOURCE_DIR, "static", "css-src");
-var CSS_OUT_DIR    = path.join(SOURCE_DIR, "static", "css");
-var REACT_SRC_DIR  = path.join(SOURCE_DIR, "static", "react-src");
-var REACT_OUT_DIR  = path.join(SOURCE_DIR, "static", "react");
-var JS_OUT_DIR     = path.join(SOURCE_DIR, "static", "js")
-var BIN_DIR        = path.join("tools", "bin");
+// computed variables
+var out_dir = prod ? PROD_DIR : DEV_DIR;
 
 // helpers
 function execPiped(command, args, fileName) {
@@ -61,19 +75,24 @@ function bin(name) {
     return path.join(BIN_DIR, name);
 }
 
-// tasks
-gulp.task("default", ["build-dev"], function () {
-    gulp.run("serve");
-    gulp.run("watch");
-});
+function remove(path) {
+    console.log("removing " + path);
+    fse.removeSync(path);
+}
+
+function jekyllBuild(done) {
+    var flags = prod ? PROD_FLAGS : DEV_FLAGS;
+    exec("jekyll.bat", ["build"].concat(flags), done);
+}
 
-gulp.task("watch", function () {
+// tasks
+gulp.task("watch", ["serve"], function () {
     gulp.watch(
         [
             path.join(CSS_SRC_DIR, "**", "*"),
         ],
         {interval: WATCH_INTERVAL},
-        ["styles", "regen-dev"]
+        ["styles"]
     );
     gulp.watch(
         [
@@ -81,123 +100,138 @@ gulp.task("watch", function () {
             path.join(DOCS_DIR, "**", "*.html"),
         ],
         {interval: WATCH_INTERVAL},
-        ["configs", "regen-dev"]
+        ["configs"]
     );
     gulp.watch(
         [
-            path.join(REACT_SRC_DIR, "**", "*.js"),
-            path.join(REACT_SRC_DIR, "**", "*.jsx"),
-            path.join(REACT_SRC_DIR, "**", "*.json"),
+            path.join(PLUGINS_SRC_DIR, "**", "*.js"),
+            path.join(PLUGINS_SRC_DIR, "**", "*.jsx"),
+            path.join(PLUGINS_SRC_DIR, "**", "*.json"),
         ],
         {interval: WATCH_INTERVAL},
-        ["scripts-dev", "regen-dev"]
+        ["plugins"]
     );
     gulp.watch(
         [
-            "*.yml",
-            path.join(DATA_DIR, "**", "*.yml"),
+            path.join(ROOT_DIR, "**", "*.yml"),
             path.join(SOURCE_DIR, "**", "*.html"),
             path.join(SOURCE_DIR, "**", "*.md"),
-            path.join(JS_OUT_DIR, "**", "*.js"),
-            path.join(REACT_OUT_DIR, "*.js"),
+            path.join(JS_DIR, "**", "*.js"),
             path.join(CSS_OUT_DIR, "**", "*.css"),
         ],
         {interval: WATCH_INTERVAL},
-        ["regen-dev"]
+        ["regen"]
     );
 });
 
-gulp.task("gen-dev", function (done) {
-    exec("jekyll.bat", ["build"].concat(DEV_FLAGS), done);
+gulp.task("serve", ["build"], function () {
+    browsersync({
+        notify: true,
+        server: {
+            baseDir: out_dir
+        }
+    });
 });
 
-gulp.task("regen-dev", ["gen-dev"], function () {
-    browsersync.reload();
+gulp.task("gen-full", ["configs", "styles", "plugins"], function (done) {
+    jekyllBuild(done);
 });
 
-gulp.task("build-dev", ["configs", "styles", "scripts-dev"], function () {
-    gulp.run("gen-dev");
+gulp.task("gen-only", function (done) {
+    jekyllBuild(done);
 });
 
-gulp.task("gen-prod", function (done) {
-    exec("jekyll.bat", ["build"].concat(PROD_FLAGS), done);
+gulp.task("regen", ["gen-only"], function () {
+    browsersync.reload();
 });
 
-gulp.task("build-prod", ["configs", "styles", "scripts-prod"], function (done) {
-    gulp.run("gen-prod");
+gulp.task("reload", function () {
+    browsersync.reload();
 });
 
-gulp.task("build", ["build-dev"]);
-gulp.task("deploy", ["build-prod"]);
+gulp.task("languages", function () {
+    return execPiped("node", [bin("gen_languages.js"), DOCS_DIR], LANGUAGES_FILE)
+        .pipe(gulp.dest(ROOT_DIR));
+});
 
-gulp.task("serve", function (done) {
-    browsersync({
-        notify: true,
-        server: {
-            baseDir: BUILD_DIR
-        }
-    });
+gulp.task("defaults", function () {
+    return execPiped("node", [bin("gen_defaults.js"), DOCS_DIR], DEFAULTS_FILE)
+        .pipe(gulp.dest(ROOT_DIR));
 });
 
-gulp.task("configs", function (done) {
-    execPiped("node", [bin("gen_defaults.js"), DOCS_DIR], DEFAULTS_FILE)
-        .pipe(gulp.dest("."));
-    execPiped("node", [bin("gen_languages.js"), DOCS_DIR], LANGUAGES_FILE)
-        .pipe(gulp.dest("."));
+gulp.task("toc", function (done) {
     exec("node", [bin("toc.js"), DOCS_DIR, DATA_DIR], done);
 });
 
-gulp.task("styles", function() {
-    gulp.src(path.join(CSS_SRC_DIR, "**", "*.less"))
+gulp.task("less", function () {
+    return gulp
+        .src(path.join(CSS_SRC_DIR, "**", "*.less"))
         .pipe(less())
-        .pipe(header("---\n---\n"))
-        .pipe(gulp.dest(CSS_OUT_DIR));
-    gulp.src(path.join(CSS_SRC_DIR, "**", "*.css"))
-        .pipe(header("---\n---\n"))
-        .pipe(gulp.dest(CSS_OUT_DIR));
-    gulp.src(path.join(CSS_SRC_DIR, "**", "*.scss"))
+        .pipe(header(YAML_FRONT_MATTER))
+        .pipe(gulp.dest(CSS_OUT_DIR))
+        .pipe(gulp.dest(CSS_OUT_DIR.replace(SOURCE_DIR, out_dir)))
+        .pipe(browsersync.reload({stream: true}));
+})
+
+gulp.task("css", function () {
+    return gulp
+        .src(path.join(CSS_SRC_DIR, "**", "*.css"))
+        .pipe(header(YAML_FRONT_MATTER))
+        .pipe(gulp.dest(CSS_OUT_DIR))
+        .pipe(gulp.dest(CSS_OUT_DIR.replace(SOURCE_DIR, out_dir)))
+        .pipe(browsersync.reload({stream: true}));
+})
+
+gulp.task("sass", function() {
+    return gulp
+        .src(path.join(CSS_SRC_DIR, "**", "*.scss"))
         .pipe(sass().on("error", sass.logError))
-        .pipe(header("---\n---\n"))
-        .pipe(gulp.dest(CSS_OUT_DIR));
+        .pipe(header(YAML_FRONT_MATTER))
+        .pipe(gulp.dest(CSS_OUT_DIR))
+        .pipe(gulp.dest(CSS_OUT_DIR.replace(SOURCE_DIR, out_dir)))
+        .pipe(browsersync.reload({stream: true}));
 });
 
-gulp.task("scripts-dev", function() {
-    return browserify(path.join(REACT_SRC_DIR, 'app.js'), { debug: true })
-        .transform(reactify)
-        .transform(envify)
-        .bundle()
-        .on('error', gutil.log)
-        .pipe(vstream('app.js'))
-        .pipe(buffer())
-        .pipe(gulp.dest(REACT_OUT_DIR));
-});
+gulp.task("plugins", function() {
+
+    if (prod) {
+        process.env.NODE_ENV = "production";
+    }
 
-gulp.task("scripts-prod", function() {
-    // This is needed for envify to remove debug only code from REACT
-    process.env.NODE_ENV = 'production';
-    browserify(path.join(REACT_SRC_DIR, 'app.js'), { debug: false })
+    var stream = browserify(PLUGINS_SRC_FILE, {debug: !prod})
         .transform(reactify)
         .transform(envify)
         .bundle()
-        .on('error', gutil.log)
-        .pipe(vstream('app.js'))
-        .pipe(buffer())
-        .pipe(uglify()) // minify only if not debug build.
-        .on('error', gutil.log)
-        .pipe(gulp.dest(REACT_OUT_DIR));
+        .on("error", gutil.log)
+        .pipe(vstream(PLUGINS_FILE_NAME))
+        .pipe(buffer());
+
+    if (prod) {
+        stream = stream
+            .pipe(uglify())
+            .on("error", gutil.log);
+    }
+
+    return stream.pipe(gulp.dest(JS_DIR));
 });
 
+// compound tasks
+gulp.task("configs", ["toc", "languages", "defaults"]);
+gulp.task("styles", ["less", "css", "sass"]);
+gulp.task("build", ["gen-full"]);
+gulp.task("default", ["watch"]);
+
 // convenience tasks
 gulp.task("link-bugs", function (done) {
     exec(bin("linkify-bugs.sh"), [path.join(SOURCE_DIR, "_posts")], done);
 });
 
 gulp.task("clean", function () {
-    fse.remove(BUILD_DIR);
-    fse.remove(DEPLOY_DIR);
-    fse.remove(path.join(DATA_DIR, "toc", "*-generated.yml"));
-    fse.remove(CSS_OUT_DIR);
-    fse.remove(REACT_OUT_DIR);
-    fse.remove(LANGUAGES_FILE);
-    fse.remove(DEFAULTS_FILE);
+    remove(DEV_DIR);
+    remove(PROD_DIR);
+    remove(path.join(DATA_DIR, "toc", "*-generated.yml"));
+    remove(CSS_OUT_DIR);
+    remove(PLUGINS_FILE);
+    remove(LANGUAGES_FILE);
+    remove(DEFAULTS_FILE);
 });

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/www/_data/.gitignore
----------------------------------------------------------------------
diff --git a/www/_data/.gitignore b/www/_data/.gitignore
index a85bc42..523d0c4 100644
--- a/www/_data/.gitignore
+++ b/www/_data/.gitignore
@@ -1 +1 @@
-toc/*generated.yml
+toc/*-generated.yml

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/www/_includes/head.html
----------------------------------------------------------------------
diff --git a/www/_includes/head.html b/www/_includes/head.html
index d5616b5..7c8464d 100644
--- a/www/_includes/head.html
+++ b/www/_includes/head.html
@@ -12,10 +12,7 @@
     <link rel="canonical" href="{{ site.url }}{{ site.baseurl }}{{ page.url | replace:'index.html',''
}}">
 
     <!-- CSS -->
-    <!-- <link rel="stylesheet" type="text/css" href="{{ site.baseurl }}/static/css/lib/bootstrap.css"
/> -->
     <link rel="stylesheet" type="text/css" href="{{ site.baseurl }}/static/css/main.css">
-    <link rel="stylesheet" type="text/css" href="{{ site.baseurl }}/static/css/master.css">
-    <link rel="stylesheet" type="text/css" href="{{ site.baseurl }}/static/css/docs.css">
 
     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
-->
     <!--[if lt IE 9]>

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/www/static/css-src/_plugins.scss
----------------------------------------------------------------------
diff --git a/www/static/css-src/_plugins.scss b/www/static/css-src/_plugins.scss
index fba7a21..6814431 100644
--- a/www/static/css-src/_plugins.scss
+++ b/www/static/css-src/_plugins.scss
@@ -1,13 +1,13 @@
 .plugins_search_container {
 	max-width:405px;
 	margin:auto;
-	
+
 }
 button.btn {
 	color:white;
 }
 .whatisplugin_box {
-	
+
 	img {
 		float:left;
 		    padding-right: 20px;
@@ -24,7 +24,7 @@ button.btn {
 	margin:0;
 }
 .featured-list-header{
-	margin-top:0;	
+	margin-top:0;
 }
 .well.featured-list {
 	padding:0;
@@ -52,4 +52,4 @@ button.btn {
 	position: absolute;
 	right:0;
 	width:100px;
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/6e2984ae/www/static/js/main.js
----------------------------------------------------------------------
diff --git a/www/static/js/main.js b/www/static/js/main.js
index 7a35752..2473c56 100644
--- a/www/static/js/main.js
+++ b/www/static/js/main.js
@@ -6,4 +6,4 @@ $(function(){ // resize the hero to the innerWidth of the window
 		$('#hero').height(adjusted_window_height);
 		console.log('new height ' + adjusted_window_height)
 	}
- });
\ No newline at end of file
+ });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message