diff --git a/.gitignore b/.gitignore index 1824b939..02d67216 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ yarn-error.log .vscode/ manifest.yml .imdone/ - +website/site/data/contributors.yml /coverage/ diff --git a/website/gulpfile.babel.js b/website/gulpfile.babel.js index ee52417e..ab8b757c 100755 --- a/website/gulpfile.babel.js +++ b/website/gulpfile.babel.js @@ -1,8 +1,11 @@ import gulp from "gulp"; import cp from "child_process"; -import hugoBin from "hugo-bin" +import hugoBin from "hugo-bin"; import gutil from "gulp-util"; import postcss from "gulp-postcss"; +import transform from "gulp-transform"; +import yaml from "yamljs"; +import rename from "gulp-rename"; import cssImport from "postcss-import"; import neatgrid from "postcss-neat"; import nestedcss from "postcss-nested"; @@ -18,53 +21,94 @@ import webpackConfig from "./webpack.conf"; const browserSync = BrowserSync.create(); const defaultArgs = ["-d", "../dist", "-s", "site", "-v"]; -gulp.task("hugo", (cb) => buildSite(cb)); -gulp.task("hugo-preview", (cb) => buildSite(cb, ["--buildDrafts", "--buildFuture"])); +function buildSite(cb, options) { + const args = options ? defaultArgs.concat(options) : defaultArgs; + return cp.spawn(hugoBin, args, { stdio: "inherit" }).on("close", code => { + if (code === 0) { + browserSync.reload(); + cb(); + } else { + browserSync.notify("Hugo build failed :("); + cb("Hugo build failed"); + } + }); +} + +gulp.task("hugo", ["copy"], cb => buildSite(cb)); +gulp.task("hugo-preview", ["copy"], cb => + buildSite(cb, ["--buildDrafts", "--buildFuture"]) +); gulp.task("build", ["css", "js", "fonts", "images", "hugo"]); gulp.task("build-preview", ["css", "js", "fonts", "images", "hugo-preview"]); -gulp.task("css", () => ( - gulp.src("./src/css/**/*.css") - .pipe(postcss([ - cssImport({from: "./src/css/main.css"}), - neatgrid(), - nestedcss(), - colorfunctions(), - hdBackgrounds(), - cssextend(), - cssvars({variables: styleVariables})])) +gulp.task("css", () => + gulp + .src("./src/css/**/*.css") + .pipe( + postcss([ + cssImport({ from: "./src/css/main.css" }), + neatgrid(), + nestedcss(), + colorfunctions(), + hdBackgrounds(), + cssextend(), + cssvars({ variables: styleVariables }) + ]) + ) .pipe(gulp.dest("./dist/css")) .pipe(browserSync.stream()) -)); +); -gulp.task("js", (cb) => { +gulp.task("js", cb => { const myConfig = Object.assign({}, webpackConfig); webpack(myConfig, (err, stats) => { if (err) throw new gutil.PluginError("webpack", err); - gutil.log("[webpack]", stats.toString({ - colors: true, - progress: true - })); + gutil.log( + "[webpack]", + stats.toString({ + colors: true, + progress: true + }) + ); browserSync.reload(); cb(); }); }); -gulp.task("fonts", () => ( - gulp.src("./src/fonts/**/*") +gulp.task("fonts", () => + gulp + .src("./src/fonts/**/*") .pipe(gulp.dest("./dist/fonts")) .pipe(browserSync.stream()) -)); +); -gulp.task("images", () => ( - gulp.src("./src/img/**/*") +gulp.task("images", () => + gulp + .src("./src/img/**/*") .pipe(gulp.dest("./dist/img")) .pipe(browserSync.stream()) -)); +); -gulp.task("server", ["hugo", "css", "js", "fonts", "images"], () => { +gulp.task("copy", () => + gulp + .src("../.all-contributorsrc") + .pipe( + transform( + "utf8", + content => + new Promise((resolve, reject) => { + const contributors = JSON.parse(content); + resolve(yaml.dump({ contributors: contributors.contributors })); + }) + ) + ) + .pipe(rename("contributors.yml")) + .pipe(gulp.dest("./site/data")) +); + +gulp.task("server", ["css", "js", "fonts", "images", "hugo"], () => { browserSync.init({ server: { baseDir: "./dist" @@ -77,18 +121,3 @@ gulp.task("server", ["hugo", "css", "js", "fonts", "images"], () => { gulp.watch("./src/fonts/**/*", ["fonts"]); gulp.watch("./site/**/*", ["hugo"]); }); - -function buildSite(cb, options) { - const args = options ? defaultArgs.concat(options) : defaultArgs; - - return cp.spawn(hugoBin, args, {stdio: "inherit"}).on("close", (code) => { - if (code === 0) { - browserSync.reload(); - cb(); - } else { - browserSync.notify("Hugo build failed :("); - cb("Hugo build failed"); - } - }); -} - diff --git a/website/package.json b/website/package.json index 94f0cf82..83a9ca39 100755 --- a/website/package.json +++ b/website/package.json @@ -32,6 +32,8 @@ "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-postcss": "^6.1.1", + "gulp-rename": "^1.2.2", + "gulp-transform": "^3.0.5", "gulp-util": "^3.0.7", "hugo-bin": "^0.18.0", "imports-loader": "^0.6.5", diff --git a/website/yarn.lock b/website/yarn.lock index 72c4300a..18831883 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -2,6 +2,31 @@ # yarn lockfile v1 +"@types/gulp-util@*": + version "3.0.34" + resolved "https://registry.yarnpkg.com/@types/gulp-util/-/gulp-util-3.0.34.tgz#d1291ebf706d93f46eb8df11344bbfd96247697e" + dependencies: + "@types/node" "*" + "@types/through2" "*" + "@types/vinyl" "*" + chalk "^2.2.0" + +"@types/node@*": + version "8.0.56" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.56.tgz#c4652f88d7a677e26ccc16c1485c282ce28f1ce9" + +"@types/through2@*": + version "2.0.33" + resolved "https://registry.yarnpkg.com/@types/through2/-/through2-2.0.33.tgz#1ff2e88a100dfb5b140e7bb98791f1194400d131" + dependencies: + "@types/node" "*" + +"@types/vinyl@*": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@types/vinyl/-/vinyl-2.0.1.tgz#6b414dfdcd4a785e8e76e87565ed29e79490d9b7" + dependencies: + "@types/node" "*" + abbrev@1: version "1.1.0" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" @@ -1071,7 +1096,7 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.1: +chalk@^2.0.1, chalk@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" dependencies: @@ -2686,7 +2711,7 @@ gulp-postcss@^6.1.1: postcss-load-config "^1.1.0" vinyl-sourcemaps-apply "^0.2.1" -gulp-rename@^1.2.0: +gulp-rename@^1.2.0, gulp-rename@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.2.2.tgz#3ad4428763f05e2764dec1c67d868db275687817" @@ -2700,6 +2725,15 @@ gulp-sourcemaps@1.6.0: through2 "^2.0.0" vinyl "^1.0.0" +gulp-transform@^3.0.5: + version "3.0.5" + resolved "https://registry.yarnpkg.com/gulp-transform/-/gulp-transform-3.0.5.tgz#6972674a77dc30672d6b7746a173ef0506fe37b2" + dependencies: + "@types/gulp-util" "*" + "@types/node" "*" + gulp-util "^3.0.8" + tslib "^1.7.1" + gulp-util@^3.0.0, gulp-util@^3.0.1, gulp-util@^3.0.7, gulp-util@^3.0.8: version "3.0.8" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" @@ -6048,6 +6082,10 @@ tryit@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" +tslib@^1.7.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.1.tgz#6946af2d1d651a7b1863b531d6e5afa41aa44eac" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"