cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblot...@apache.org
Subject docs commit: Added browsersync. Madegulpfile watch and rebuild properly.
Date Mon, 27 Jul 2015 07:48:05 GMT
Repository: cordova-docs
Updated Branches:
  refs/heads/cordova-website 76e114052 -> f48cf69ee


Added browsersync. Madegulpfile watch and rebuild properly.


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

Branch: refs/heads/cordova-website
Commit: f48cf69ee65d3f7ac3d392166d57cd2024249d7e
Parents: 76e1140
Author: Dmitry Blotsky <dmitry.blotsky@gmail.com>
Authored: Mon Jul 27 00:47:54 2015 -0700
Committer: Dmitry Blotsky <dmitry.blotsky@gmail.com>
Committed: Mon Jul 27 00:47:54 2015 -0700

----------------------------------------------------------------------
 gulpfile.js  | 96 +++++++++++++++++++++++++++++++++++++------------------
 package.json |  1 +
 2 files changed, 66 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/f48cf69e/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index 97f818f..6bd358c 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -5,23 +5,28 @@ var path          = require("path");
 var fse           = require("fs-extra");
 var child_process = require("child_process");
 
-var gulp    = require("gulp");
-var less    = require("gulp-less");
-var sass    = require("gulp-sass");
-var vstream = require("vinyl-source-stream");
-var buffer  = require("vinyl-buffer");
+var gulp        = require("gulp");
+var less        = require("gulp-less");
+var sass        = require("gulp-sass");
+var vstream     = require("vinyl-source-stream");
+var buffer      = require("vinyl-buffer");
+var browsersync = require("browser-sync");
 
 // constants
 var CONFIG_FILES = ["_config.yml", "_defaults.yml"];
 var JEKYLL_FLAGS = ["--trace", "--config", CONFIG_FILES.join(",")];
 
-var SOURCE_DIR  = "www";
-var BIN_DIR     = path.join("tools", "bin");
-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 BUILD_DIR   = "public";
+var SOURCE_DIR = "www";
+var BUILD_DIR  = "public";
+
+var DEFAULTS_FILE  = "_defaults.yml";
+var DATA_DIR       = path.join(SOURCE_DIR, "_data");
+var LANGUAGES_FILE = path.join(DATA_DIR, "languages.yml");
+var TOC_DIR        = path.join(DATA_DIR, "toc");
+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 BIN_DIR        = path.join("tools", "bin");
 
 // helpers
 function execPiped(command, args, fileName) {
@@ -41,43 +46,72 @@ function bin(name) {
 }
 
 // tasks
+gulp.task("default", ["build"], function () {
+    gulp.run("serve");
+    gulp.run("watch");
+});
+
 gulp.task("watch", function () {
-    gulp.watch(path.join(CSS_SRC_DIR, "**", "*"), function(event) {
-        gulp.run("styles");
-    });
+    gulp.watch(
+        [
+            path.join(CSS_SRC_DIR, "**", "*"),
+        ],
+        ["styles", "regenerate"]
+    );
+    gulp.watch(
+        [
+            path.join(DOCS_DIR, "**", "*.md"),
+            path.join(DOCS_DIR, "**", "*.html"),
+        ],
+        ["configs", "regenerate"]
+    );
+    gulp.watch(
+        [
+            path.join(SOURCE_DIR, "**", "*.html"),
+            path.join(SOURCE_DIR, "**", "*.md"),
+            path.join(SOURCE_DIR, "**", "*.js"),
+            path.join(SOURCE_DIR, "**", "*.yml"),
+            path.join(CSS_OUT_DIR, "**", "*.css"),
+        ],
+        ["regenerate"]
+    );
 });
 
-gulp.task("build", ["defaults", "languages", "toc", "styles"], function (done) {
+gulp.task("generate", function (done) {
     exec("jekyll", ["build"].concat(JEKYLL_FLAGS), done);
 });
 
-gulp.task("serve", ["defaults", "languages", "toc", "styles"], function (done) {
-    exec("jekyll", ["serve", "--watch"].concat(JEKYLL_FLAGS), done);
+gulp.task("regenerate", ["generate"], function () {
+    browsersync.reload();
 });
 
-gulp.task("defaults", function () {
-    execPiped("python", [bin("gen_defaults.py"), DOCS_DIR], "_defaults.yml")
-        .pipe(gulp.dest("."));
+gulp.task("build", ["styles", "configs"], function () {
+    gulp.run("generate");
 });
 
-gulp.task("languages", function () {
-    execPiped("python", [bin("gen_languages.py"), DOCS_DIR], "languages.yml")
-        .pipe(gulp.dest(DATA_DIR));
+gulp.task("serve", function (done) {
+    browsersync({
+        notify: true,
+        server: {
+            baseDir: BUILD_DIR
+        }
+    });
 });
 
-gulp.task("toc", function (done) {
+gulp.task("configs", function (done) {
+    execPiped("python", [bin("gen_defaults.py"), DOCS_DIR], DEFAULTS_FILE)
+        .pipe(gulp.dest("."));
+    execPiped("python", [bin("gen_languages.py"), DOCS_DIR], LANGUAGES_FILE)
+        .pipe(gulp.dest("."));
     exec("python", [bin("gen_toc.py"), SOURCE_DIR], done);
 });
 
 gulp.task("styles", function() {
-
     gulp.src(path.join(CSS_SRC_DIR, "**", "*.less"))
         .pipe(less())
         .pipe(gulp.dest(CSS_OUT_DIR));
-
     gulp.src(path.join(CSS_SRC_DIR, "**", "*.css"))
         .pipe(gulp.dest(CSS_OUT_DIR));
-
     gulp.src(path.join(CSS_SRC_DIR, "**", "*.scss"))
         .pipe(sass().on("error", sass.logError))
         .pipe(gulp.dest(CSS_OUT_DIR));
@@ -91,7 +125,7 @@ gulp.task("link-bugs", function (done) {
 gulp.task("clean", function () {
     fse.remove(BUILD_DIR);
     fse.remove(path.join(DATA_DIR, "toc", "*.yml"));
-    fse.remove(path.join(DATA_DIR, "languages.yml"));
-    fse.remove(path.join(CSS_OUT_DIR));
-    fse.remove("_defaults.yml");
+    fse.remove(CSS_OUT_DIR);
+    fse.remove(LANGUAGES_FILE);
+    fse.remove(DEFAULTS_FILE);
 });

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/f48cf69e/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 8ea5ee8..77aa13f 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
   "author": "Apache Software Foundation",
   "license": "Apache Version 2.0",
   "dependencies": {
+    "browser-sync": "^2.8.0",
     "cheerio": "^0.17.0",
     "esrever": "^0.1.0",
     "fs-extra": "^0.11.1",


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


Mime
View raw message