[
  {
    "path": ".cix.yml",
    "content": "test:\n    script:\n        # - scripts/rel-push-prog\n    only:\n        - /^wrk.*$/\n\ndeploy:\n    script:\n        - scripts/rel-push-prog\n        - npm publish\n    only:\n        - /^rel.*$/\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\npublic\n\n# node\nnode_modules\n*.log\n\n# bower\nbower_components\nsrc/vendor\n\n# docker\nDockerfile\ndocker-compose.yaml\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n\t\"singleQuote\": true,\n\t\"printWidth\": 80,\n\t\"semi\": false,\n\t\"useTabs\": false,\n\t\"tabWidth\": 2\n}\n"
  },
  {
    "path": "CHANGES",
    "content": "Version 2.0.6 - 2018-10-28\n- log relative path while watching styles (#45)\n\n\nVersion 2.0.5 - 2017-12-12\n- Fix scripts task build source\n\n\nVersion 2.0.4 - 2017-12-12\n- Set saner htmlmin defaults\n\n\nVersion 2.0.3 - 2017-12-12\n- Make cleancss the default styles transformation\n- Display pipeline being executed\n- Restore default styles logic\n- Add callback to sequence call\n- Display space optimization achieved\n\n\nVersion 2.0.2 - 2017-12-12\n- Fix plugin names\n\n\nVersion 2.0.1 - 2017-12-12\n- Run styles/scripts tasks on watch invocation\n- Use proper JSON syntax\n- Fix update instructions\n- Add granular imagemin configuration\n- Adjust default .hugulprc\n\n\nVersion 2.0.0 - 2017-12-12\n- Read/compile sass and scss (#37)\n- Replace var (#34)\n- Replace yarn with npm5\n- Use standard format\n- Implement hugulp next\n- Add init command\n- Clean up & add logging\n- Code refactoring\n- Add missing package\n- Update docs for v2\n- Implements next\n- Remove v1 code\n- Fix inclusion of production files\n- Use vscode instead of atom\n\n\nVersion 1.4.0 - 2017-11-27\n- Add docker support (#24)\n- Minifyhtml (#31)\n\n\nVersion 1.3.0 - 2017-03-20\n- Add less support\n- Ignore log files\n- Expand glob for assets\n- Update README\n- Remove log file\n- Release 1.2.0\n- Display hugulp version\n- Add less to watched files\n- Upgrade dependencies\n- Replace gulp.watch with gulp-watch\n- Fix styles folder watch\n- Update README\n\n\nVersion 1.2.0 - 2017-03-18\n- Ignore log files\n- Add less support\n- Expand glob for assets\n- Update README\n- Remove log file\n\n\nVersion 1.1.2 - 2017-03-17\n- Process subdirectories\n\n\nVersion 1.1.1 - 2017-02-12\n- Fix build command\n\n\nVersion 1.1.0 - 2017-01-28\n- Use hugo default config file\n\n\nVersion 1.0.0 - 2017-01-08\n- Add commander dependency\n- Create cli interface\n- Rename src folder to assets\n- Remove files no longer required\n- Support css files\n- Rewrite instructions\n- Publish to npm on CI\n- Update package.json upon new release\n\n\nVersion 0.1.0 - 2017-01-06\n- Initial commit\n- syntax fix for package.json\n- Add missing semicolons\n- Replace tabs with spaces\n- Update reference.js\n- - Update packages\n- Improve project details and instructions\n- Fix syntax error\n- Delete public folder when running gulp task. Also delete (if existing) the public folder inside hugo.\n- Update dependencies\n- Implement CI automation\n- Add missing variable\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Juan B. Rodriguez\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# DEPRECATION NOTICE\n\nI'll archive the repo by the end of August 2021.\n\nThe main reason is [Hugo pipes](https://gohugo.io/hugo-pipes/) are built-in and pretty much cover what Hugulp does.\n\nI think the only part missing is image optimization, but I think you can build a pipe to do it.\n\nThe other reason is it badly needs an update to gulp 4 and although it doesn't seem like that hard a task, I don't have the appetite to do it.\n\n# hugulp 2\n\n## v2 Breaking changes\n\nIf you're using hugulp v1, please take note of the following changes:\n\n* hugo is no longer invoked by hugulp\n\n  use hugo as per its docs, then invoke hugulp build\n\n* put your assets in the static folder\n\n  for example, static/styles, static/images, static/scripts\n\n* themes are supported out of the box\n\n_Note: If you need sass/less/js pre-processing, read v2 docs below_\n\n## Description\n\n`hugulp` is a tool to optimize the assets of a [Hugo](https://gohugo.io) website.\n\nThe main idea is to recreate the famous [Ruby on Rails Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html), which minifies, concatenates and fingerprints the assets used in your website.\n\nThis leads to less and smaller network requests to your page, improving overall user experience.\n\nRead [this blog post](https://jbrio.net/posts/mobile-friendly-website-2/) and [this article](https://medium.com/@juanbrodriguez/hugulp-a-hugo-gulp-toolchain-94f72ccc3577) for additional context.\n\n_Note: These articles refer to v1_\n\nIt's internally driven by [Gulp](https://gulpjs.com).\n\nThis project Includes the following tools, tasks and workflows:\n\n* [sass](https://github.com/dlmanning/gulp-sass) (super fast libsass)\n* [less](https://github.com/plus3network/gulp-less)\n* [autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer)\n* [clean-css](https://github.com/scniro/gulp-clean-css)\n* [jshint](https://github.com/spalger/gulp-jshint)\n* [uglify](https://github.com/terinjokes/gulp-uglify)\n* [imagemin](https://github.com/sindresorhus/gulp-imagemin) (only [changed images](https://github.com/sindresorhus/gulp-changed))\n* [gulp-rev](https://github.com/sindresorhus/gulp-rev), [gulp-rev-replace](https://github.com/jamesknelson/gulp-rev-replace) (fingerprinting)\n* [htmlmin](https://github.com/jonschlinkert/gulp-htmlmin)\n* [watch](https://github.com/floatdrop/gulp-watch)\n\n## Installation\n\n[Node](https://nodejs.org) needs to be installed in your system.\n\nThen just\n\n```bash\n$ npm install -g hugulp\n```\n\nOr you can build and run using [docker](https://www.docker.com):\n\n```bash\n# Default docker setup:\n$ ./scripts/create-docker-machine-and-run-it\n\n# -- OR --\n\n# Run with custom machine name, specific hugo version, specific node version and run docker in detached mode:\n$ ./scripts/create-docker-machine-and-run-it -a app-devel -g 0.20.6 -n 6.10.0 -d\n```\n\n**Note:** You only run the `./scripts/create-docker-machine-and-run-it` if you want to create a new docker machine. Once the docker machine is created, you have to use docker commands to manage it. Please be familiar with docker in this regard.\n\n## Getting Started\n\nThe most common usage scenario would be:\n\n```bash\n$ hugo new site yoursite\n$ cd yoursite\n$ hugulp init\n# create content\n# add images (static/images), css (static/styles) and javascript (static/scripts)\n$ hugo server -D # for development\n# development is done, ready to publish\n$ rm -rf public # clean up public folder, it will be re-generated by hugo\n$ hugo # for release/production/deployment\n$ hugulp build # optimize the site by running the asset pipeline\n```\n\nAnother scenario would be to include sass/less pre-processing:\n\n```bash\n$ hugo new site yoursite\n$ cd yoursite\n$ hugulp init\n# create content\n# add images (static/images), and javascript (static/scripts)\n# add sass/less (assets/styles)\n$ hugo server -D # for development\n$ hugulp watch # to convert sass/less (assets/styles) into css (static/styles)\n# development is done, ready to publish\n$ rm -rf public # clean up public folder, it will be re-generated by hugo\n$ hugo # for release/production/deployment\n$ hugulp build # optimize the site by running the asset pipeline\n```\n\nIn both cases, you could chain the last 3 commands:\n\n```bash\n$ rm -rf public && hugo && hugulp build\n```\n\n`hugulp` requires a configuration file (`.hugulprc`), which is created by the `hugulp init` command (you can create the file manually if you want).\n\nThis is the default `.hugulprc`:\n\n```json\n{\n  \"version\": 2,\n  \"pipeline\": [\"images\", \"styles\", \"scripts\", \"fingerprint\", \"html\"],\n  \"path\": {\n    \"styles\": \"styles\",\n    \"images\": \"images\",\n    \"scripts\": \"scripts\"\n  },\n  \"watch\": {\n    \"source\": \"assets\",\n    \"target\": \"static\"\n  },\n  \"build\": {\n    \"source\": \"public\",\n    \"target\": \"public\"\n  },\n  \"autoprefixer\": {\n    \"browsers\": [\"last 2 versions\"]\n  },\n  \"cleancss\": {\n    \"advanced\": false\n  },\n  \"htmlmin\": {\n    \"collapseWhitespace\": true\n  },\n  \"gifsicle\": { \"interlaced\": true },\n  \"jpegtran\": { \"progressive\": true },\n  \"optipng\": { \"optimizationLevel\": 5 },\n  \"svgo\": {\n    \"plugins\": [{ \"removeViewBox\": true }, { \"cleanupIDs\": false }]\n  }\n}\n```\n\nYou can easily customize `hugulp`'s behavior, by modifying this configuration file, as described below.\n\n## Available Commands\n\n### hugulp watch\n\n`hugulp` will assist you if you're using sass/less (and javascript), which require pre-processing.\n\nIt will watch for changes to styles or script files, process them and write them to hugo's static folder, according to the following table\n\n| In Folder      |      Looks for       | Operation                              | Written to     |\n| -------------- | :------------------: | -------------------------------------- | -------------- |\n| assets/styles  | s[a\\|c]ss, less, css | Convert sass/less to css               | static/styles  |\n| assets/scripts |          js          | Lint javascript code (_soon babelify_) | static/scripts |\n\n_Note: It searches the folders recursively_\n\nThe table above applies to `hugulp` run with a default `.hugulprc`.\n\nYou can customize the folder names: `resources` instead of `assets`, `js` instead of `scripts` and so on.\n\nThis is described in the `.hugulprc` section below.\n\n### hugulp build\n\nIt optimizes the site that hugo built, by running the asset pipeline as defined in `.hugulprc` (field _pipeline_).\n\nAdditionally, files are not watched for changes\n\n### hugulp version\n\nDisplay installed version.\n\n### hugulp init\n\nCreate a default `.hugulprc`.\n\n## Configuration\n\nBy editing the `.hugulprc` configuration file, you can customize almost anything about `hugulp`.\n\nDescription of each field follows:\n\n### pipeline\n\nDefines which tasks of the asset pipeline will be executed (`hugulp build` command)\n\nType: array <br>\nDefault:\n\n```json\n\"pipeline\": [\"images\", \"styles\", \"scripts\", \"fingerprint\", \"html\"]\n```\n\n| Task        | Description                                                        |\n| ----------- | ------------------------------------------------------------------ |\n| images      | minify images with `imagemin`                                      |\n| styles      | pre-process `sass`/`less`/css, then `clean-css`                    |\n| scripts     | `jshint`, then `uglify`                                            |\n| fingerprint | fingerprint with `rev`, then replace references with `rev-replace` |\n| html        | minify html with `htmlmin`                                         |\n\nLet's say you don't want to fingerprint the assets. Just set _pipeline_ to\n\n```json\n\"pipeline\": [\"images\", \"styles\", \"scripts\", \"html\"]\n```\n\nBy removing the _fingerprint_ task, it will not be executed.\n\nNote that tasks are executed sequentially.\n\n### path\n\nDefines the name of the folders where your assets are located/will be transferred to.\n\nType: object <br>\nDefault:\n\n```json\n\"path\": {\n  \"styles\": \"styles\",\n  \"images\": \"images\",\n  \"scripts\": \"scripts\"\n}\n```\n\nSo if you prefer your styles folder to be called css, and scripts to be called js, you would change it to:\n\n```json\n\"path\": {\n  \"styles\": \"css\",\n  \"images\": \"images\",\n  \"scripts\": \"js\"\n}\n```\n\n### watch\n\nDefine which folders to watch for changes, for the `hugulp watch` command.\n\nType: object <br>\nDefault:\n\n```json\n\"watch\": {\n  \"source\": \"assets\",\n  \"target\": \"static\"\n}\n```\n\nThis field works together with the path field.\n\nWith a default `.hugulprc`, it will watch `assets/styles` and `assets/scripts` (recursively).\n\nIf you customized `path` as per above, it will watch `assets/css` and `assets/js`.\n\nIf you additionally want the `assets` folder to be called `resources`, change _source_ to `resources`\n\n```json\n\"watch\": {\n  \"source\": \"resources\",\n  \"target\": \"static\"\n}\n```\n\nthen it will watch `resources/css` and `resources/js`\n\nFinally, the changes will be written to the well-known hugo static folder.\n\nWith a default `.hugulprc`, files will be written to `static/styles` and `static/scripts`.\n\n### build\n\nDefines the folders referenced during the `hugulp build` command\n\nType: object <br>\nDefault:\n\n```json\n\"build\": {\n  \"source\": \"public\",\n  \"target\": \"public\"\n}\n```\n\nThis should generally be left unchanged.\n\n`hugo` will output to the public folder by default, so `hugulp build` will process the files in-place.\n\n### autoprefixer\n\nOptions for `autoprefixer`. Check [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) for documentation.\n\nTask: `styles`\n\nType: object<br>\nDefault:\n\n```json\n\"autoprefixer\": {\n  \"browsers\": [\"last 2 versions\"]\n}\n```\n\n### cleancss\n\nOptions for `clean-css`. Check [gulp-clean-css](https://github.com/scniro/gulp-clean-css) for documentation.\n\nTask: `styles`\n\nDefault:\n\n```json\n\"cleancss\": {\n  \"advanced\": false\n}\n```\n\n### htmlmin\n\nOptions for `htmlmin`. Check [gulp-htmlmin](https://github.com/jonschlinkert/gulp-htmlmin) for documentation.\n\nTask: `html`\n\nDefault:\n\n```json\n\"htmlmin\": {\n  \"collapsedWhitespace\": true\n}\n```\n\n### gifsicle\n\nOptions for `gifsicle`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.\n\nTask: `images`\n\nDefault:\n\n```json\n\"gifsicle\": {\n  \"interlaced\": true\n}\n```\n\n### jpegtran\n\nOptions for `jpegtran`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.\n\nTask: `images`\n\nDefault:\n\n```json\n\"jpegtran\": {\n  \"progressive\": true\n}\n```\n\n### optipng\n\nOptions for `optipng`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.\n\nTask: `images`\n\nDefault:\n\n```json\n\"optipng\": {\n  \"optimizationLevel\": 5\n}\n```\n\n### svgo\n\nOptions for `svgo`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.\n\nTask: `images`\n\nDefault:\n\n```json\n\"svgo\": {\n  \"plugins\": [{ \"removeViewBox\": true }, { \"cleanupIDs\": false }]\n}\n```\n\n## How to update\n\nWhenever a new `hugulp` version becomes available, you can update it by running\n\n```bash\n$ npm install -g hugulp\n```\n\n## PR\n\nPull Requests are welcome :thumbsup:.\n\n## Share\n\nMade by [Juan B. Rodriguez](http://jbrodriguez.io), with a MIT License.\n\nPlease [share the article or leave your comments](http://jbrodriguez.io/mobile-friendly-website-2/).\n"
  },
  {
    "path": "VERSION",
    "content": "2.0.6\n"
  },
  {
    "path": "docker/Dockerfile.template",
    "content": "FROM node:7.9.0-alpine\n# Set environment variable\nARG RUN_AS=node\nARG HUGO_VERSION=0.20.6\nARG HUGO_BINARY=\"hugo_${HUGO_VERSION}_Linux-64bit\"\nRUN apk update && apk add py-pygments && rm -rf /var/cache/apk/*\n# Download and install hugo\nRUN mkdir /usr/local/hugo\nADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY}.tar.gz \\\n    /usr/local/hugo/\nRUN tar xzf /usr/local/hugo/${HUGO_BINARY}.tar.gz -C /usr/local/hugo/ \\\n    && ln -s /usr/local/hugo/hugo /usr/local/bin/hugo \\\n    && rm /usr/local/hugo/${HUGO_BINARY}.tar.gz\nRUN npm install -g hugulp\nENV HOME=/home/$RUN_AS\nCOPY package.json $HOME/web/\nRUN chmod 755 $HOME/* && chown -R $RUN_AS:$RUN_AS $HOME/*\nUSER $RUN_AS\n# Change working directory\nWORKDIR $HOME/web/\nUSER root\nCOPY . $HOME/web/\nRUN chown -R $RUN_AS:$RUN_AS $HOME/*\nUSER $RUN_AS"
  },
  {
    "path": "docker/docker-compose.yaml.template",
    "content": "---\nversion: '3'\nservices:\n  app:\n    labels: \n      app: \"app\"\n    build:\n      context: .\n    command: /bin/sh -c './scripts/create-hugo-site -a ./app;cd app;hugulp watch'\n    volumes:\n      - .:/home/node/app\n      - /home/node/app/node_modules\n    ports:\n      - \"3000:3000\"\n      - \"3001:3001\"\n"
  },
  {
    "path": "gulp/build.js",
    "content": "// system\nconst fs = require('fs')\nconst path = require('path')\n\n// parameters\nconst config = JSON.parse(\n  fs.readFileSync(path.join(process.cwd(), '.hugulprc'))\n)\n\n// common\nconst gulp = require('gulp')\nconst sequence = require('run-sequence')\nconst debug = require('gulp-debug')\nconst size = require('gulp-size')\nconst pump = require('pump')\nconst gutil = require('gulp-util')\n\n// images\nconst imagemin = require('gulp-imagemin')\n\n// styles\nconst autoprefixer = require('gulp-autoprefixer')\nconst cleancss = require('gulp-clean-css')\nconst merge = require('merge-stream')\nconst concat = require('gulp-concat')\nconst helper = require('./util')\n// const changed = require('gulp-changed')\n\n// scripts\nconst jshint = require('gulp-jshint')\nconst uglify = require('gulp-uglify')\n\n// revision\nconst rev = require('gulp-rev')\nconst revdel = require('rev-del')\nconst delorg = require('gulp-rev-delete-original')\nconst del = require('del')\n\n// reference\nconst replace = require('gulp-rev-replace')\n\n// minify html\nconst htmlmin = require('gulp-htmlmin')\n\ngulp.task('build', function(cb) {\n  gutil.log(\n    gutil.colors.green(`building site ... (${JSON.stringify(config.pipeline)})`)\n  )\n\n  // config.pipeline is an array of task names\n  // i.e.: ['images', 'styles']\n  sequence(...config.pipeline, cb)\n})\n\n// .pipe(changed('staging/img'))\ngulp.task('images', function() {\n  return gulp\n    .src(path.join(config.build.source, config.path.images, '**', '*.*')) // i.e.: public/images/**/*.*\n    .pipe(\n      imagemin([\n        imagemin.gifsicle(config.gifsicle),\n        imagemin.jpegtran(config.jpegtran),\n        imagemin.optipng(config.optipng),\n        imagemin.svgo(config.svgo)\n      ])\n    )\n    .pipe(gulp.dest(path.join(config.build.target, config.path.images))) // i.e.: public/images\n})\n\ngulp.task('styles:cleancss', function() {\n  const streams = helper.getStylesStreams()\n\n  return merge(...streams)\n    .pipe(autoprefixer(config.autoprefixer))\n    .pipe(cleancss(config.cleancss))\n    .pipe(concat('styles.css'))\n    .pipe(size({ title: 'styles: ' }))\n    .pipe(gulp.dest(path.join(config.build.target, config.path.styles))) // i.e.: public/styles/styles.css\n})\n\n// default styles task\ngulp.task('styles', function(cb) {\n  sequence('styles:cleancss', cb)\n})\n\ngulp.task('scripts', function() {\n  return gulp\n    .src(path.join(config.watch.source, config.path.scripts, '**', '*.js'))\n    .pipe(jshint())\n    .pipe(jshint.reporter('default'))\n    .pipe(uglify())\n    .pipe(size({ title: 'scripts: ' }))\n    .pipe(gulp.dest(path.join(config.build.target, config.path.scripts)))\n})\n\ngulp.task('revision', function() {\n  return gulp\n    .src(\n      [\n        path.join(config.build.source, config.path.styles, '**/*.css'),\n        path.join(config.build.source, config.path.scripts, '**/*.js'),\n        path.join(config.build.source, config.path.images, '**/*.*')\n      ],\n      { base: path.join(process.cwd(), config.build.source) }\n    )\n    .pipe(rev())\n    .pipe(delorg())\n    .pipe(gulp.dest(config.build.target))\n    .pipe(rev.manifest())\n    .pipe(revdel({ dest: config.build.target }))\n    .pipe(gulp.dest(config.build.target))\n})\n\ngulp.task('reference', function() {\n  const manifest = gulp.src(path.join(config.build.source, 'rev-manifest.json'))\n\n  return gulp\n    .src([\n      path.join(config.build.source, '**/*.html'),\n      path.join(config.build.source, '**/*.xml'),\n      path.join(config.build.source, '**/*.css')\n    ])\n    .pipe(\n      replace({\n        manifest: manifest,\n        replaceInExtensions: ['.html', '.xml', '.css']\n      })\n    )\n    .pipe(gulp.dest(config.build.target))\n})\n\ngulp.task('fingerprint', function(cb) {\n  sequence('revision', 'reference', cb)\n})\n\ngulp.task('html', function(cb) {\n  pump(\n    [\n      gulp.src(path.join(config.build.source, '**', '*.html')),\n      htmlmin(config.htmlmin),\n      size({ title: 'html: ' }),\n      gulp.dest(config.build.target)\n    ],\n    cb\n  )\n})\n"
  },
  {
    "path": "gulp/util.js",
    "content": "// system\nconst fs = require('fs')\nconst path = require('path')\n\n// common\nconst gulp = require('gulp')\n\n// styles\nconst sass = require('gulp-sass')\nconst less = require('gulp-less')\nconst concat = require('gulp-concat')\n\n// parameters\nconst config = JSON.parse(\n  fs.readFileSync(path.join(process.cwd(), '.hugulprc'))\n)\n\n// helper functions\nfunction getStylesStreams() {\n  const lessStream = gulp\n    .src(path.join(config.watch.source, config.path.styles, '**/*.less')) // i.e.: assets/styles/**/*.less\n    .pipe(less())\n    .pipe(concat('less-files.css'))\n\n  const scssStream = gulp\n    .src(path.join(config.watch.source, config.path.styles, '**/*.s[a|c]ss')) // i.e.: assets/styles/**/*.s[a|c]ss\n    .pipe(sass())\n    .pipe(concat('scss-files.css'))\n\n  const cssStream = gulp\n    .src(path.join(config.watch.source, config.path.styles, '**/*.css')) // i.e.: assets/styles/**/*.css\n    .pipe(concat('css-files.css'))\n\n  return [lessStream, scssStream, cssStream]\n}\n\nmodule.exports = { getStylesStreams }\n"
  },
  {
    "path": "gulp/watch.js",
    "content": "// system\nconst fs = require('fs')\nconst path = require('path')\n\n// parameters\nconst config = JSON.parse(\n  fs.readFileSync(path.join(process.cwd(), '.hugulprc'))\n)\n\n// common\nconst gulp = require('gulp')\nconst sequence = require('run-sequence')\nconst watch = require('gulp-watch')\nconst gutil = require('gulp-util')\n\n// styles\nconst merge = require('merge-stream')\nconst concat = require('gulp-concat')\nconst helper = require('./util')\n\n// scripts\nconst jshint = require('gulp-jshint')\n\ngulp.task('watch', function() {\n  const styles = [\n    path.join(config.watch.source, config.path.styles, '**', '*.s[a|c]ss'),\n    path.join(config.watch.source, config.path.styles, '**', '*.less'),\n    path.join(config.watch.source, config.path.styles, '**', '*.css')\n  ]\n\n  gutil.log(gutil.colors.green(`running styles task ...`))\n  gulp.start('styles')\n\n  gutil.log(gutil.colors.green(`watching ${JSON.stringify(styles)}`))\n\n  watch(styles, {}, function handle(param) {\n    const relativePath = function(path) {\n      return path.substring(String(process.cwd()).length)\n    }\n    gutil.log(\n      gutil.colors.yellow(\n        `styles: ${JSON.stringify(relativePath(param.history[0]))} - ${param.event}`\n      )\n    )\n\n    gulp.start('styles')\n  })\n\n  const scripts = [\n    path.join(config.watch.source, config.path.scripts, '**', '*.js')\n  ]\n\n  gutil.log(gutil.colors.green(`running scripts task ...`))\n  gulp.start('scripts')\n\n  gutil.log(gutil.colors.green(`watching ${JSON.stringify(scripts)}`))\n\n  watch(scripts, {}, function handle(param) {\n    gutil.log(\n      gutil.colors.yellow(\n        `scripts: ${JSON.stringify(param.history[0])} - ${param.event}`\n      )\n    )\n\n    gulp.start('scripts')\n  })\n})\n\ngulp.task('styles:cleancss', function() {\n  const streams = helper.getStylesStreams()\n\n  return merge(...streams)\n    .pipe(concat('styles.css'))\n    .pipe(gulp.dest(path.join(config.watch.target, config.path.styles))) // i.e.: static/styles/styles.css\n})\n\n// default styles task\ngulp.task('styles', function(cb) {\n  sequence('styles:cleancss', cb)\n})\n\ngulp.task('scripts', function() {\n  return gulp\n    .src(path.join(config.watch.source, config.path.scripts, '**', '*.js'))\n    .pipe(jshint())\n    .pipe(jshint.reporter('default'))\n    .pipe(gulp.dest(path.join(config.watch.target, config.path.scripts)))\n})\n"
  },
  {
    "path": "index.js",
    "content": "#!/usr/bin/env node\n\nconst path = require('path')\nconst fs = require('fs')\nconst program = require('commander')\nconst gulp = require('gulp')\nconst pkginfo = require('pkginfo')(module, 'version')\nconst gutil = require('gulp-util')\n\nfunction init() {\n  gutil.log(gutil.colors.red(`hugulp v${module.exports.version}`))\n\n  const hugulpRc = path.join(process.cwd(), '.hugulprc')\n\n  if (fs.existsSync(hugulpRc)) {\n    gutil.log(\n      gutil.colors.yellow('.hugulprc already exists (initialization skipped)')\n    )\n    return\n  }\n\n  const config = {\n    version: 2,\n    pipeline: ['images', 'styles', 'scripts', 'fingerprint', 'html'],\n    path: {\n      styles: 'styles',\n      images: 'images',\n      scripts: 'scripts'\n    },\n    watch: {\n      source: 'assets',\n      target: 'static'\n    },\n    build: {\n      source: 'public',\n      target: 'public'\n    },\n    autoprefixer: {\n      browsers: ['last 2 versions']\n    },\n    cleancss: {\n      advanced: false\n    },\n    htmlmin: {\n      collapseWhitespace: true\n    },\n    gifsicle: { interlaced: true },\n    jpegtran: { progressive: true },\n    optipng: { optimizationLevel: 5 },\n    svgo: {\n      plugins: [{ removeViewBox: true }, { cleanupIDs: false }]\n    }\n  }\n\n  fs.writeFileSync(hugulpRc, JSON.stringify(config, null, '  '))\n\n  gutil.log(\n    gutil.colors.green(\n      'hugulp has been initialized (.hugulprc was created with default values)'\n    )\n  )\n}\n\nfunction build() {\n  gutil.log(gutil.colors.red(`hugulp v${module.exports.version}`))\n\n  require(path.join(fs.realpathSync(__dirname), 'gulp', 'build'))\n  gulp.start('build')\n}\n\nfunction watch() {\n  gutil.log(gutil.colors.red(`hugulp v${module.exports.version}`))\n\n  require(path.join(fs.realpathSync(__dirname), 'gulp', 'watch'))\n  gulp.start('watch')\n}\n\nfunction version() {\n  console.log('hugulp v' + module.exports.version)\n}\n\nprogram\n  .command('init')\n  .description('create default .hugulprc')\n  .action(init)\n\nprogram\n  .command('version')\n  .description('display version information')\n  .action(version)\n\nprogram\n  .command('build')\n  .description('optimize site (for publishing purposes)')\n  .action(build)\n\nprogram\n  .command('watch')\n  .description('watch for changes to styles and/or javascript')\n  .action(watch)\n\nprogram.parse(process.argv)\n"
  },
  {
    "path": "metadata/changes/0.1.0.txt",
    "content": "2017-01-06 - 0.1.0\n- Initial commit\n- syntax fix for package.json\n- Add missing semicolons\n- Replace tabs with spaces\n- Update reference.js\n- - Update packages\n- Improve project details and instructions\n- Fix syntax error\n- Delete public folder when running gulp task. Also delete (if existing) the public folder inside hugo.\n- Update dependencies\n- Implement CI automation\n- Add missing variable\n\n\n"
  },
  {
    "path": "metadata/changes/1.0.0.txt",
    "content": "2017-01-08 - 1.0.0\nhugulp is now a standalone tool.\n\nThis allows for the following improvements\n- Easier to work on multiple sites\n- Easier to update\n- Can be used in CI/CD workflows\n"
  },
  {
    "path": "metadata/changes/1.1.0.txt",
    "content": "2017-01-28 - 1.1.0\n\nhugulp now uses hugo default config file (config.toml)\n\nYou can specify an alternative config, via a command line switch\n-c, --config\n"
  },
  {
    "path": "metadata/changes/1.1.1.txt",
    "content": "2017-02-12 - 1.1.1\n\n```hugulp build``` now creates a site without drafts and without\nbaseUrl\n"
  },
  {
    "path": "metadata/changes/1.1.2.txt",
    "content": "2017-03-17 - 1.1.2\n\n```hugulp``` now processes subdirectories in the assets folders, if present.\n"
  },
  {
    "path": "metadata/changes/1.2.0.txt",
    "content": "2017-03-18 - 1.2.0\n\nAdd support for less files\n"
  },
  {
    "path": "metadata/changes/1.3.0.txt",
    "content": "2017-03-20 - 1.3.0\n\nAdded a command to display the current version: ```hugulp version```\n\nA bug that was preventing the styles folder to react to changes was fixed.\n\nAdditionally:\n- Upgrade dependencies\n- Replace gulp.watch with gulp-watch\n"
  },
  {
    "path": "metadata/changes/1.4.0.txt",
    "content": "2017-11-27 - 1.4.0\n\n- Add docker support (#24)\n- Minifyhtml (#31)\n"
  },
  {
    "path": "metadata/changes/2.0.0.txt",
    "content": "2017-12-12 - 2.0.0\n\nThis is a re-thinking of hugulp, in order to be more flexible and better support hugo's features.\n\nhugulp now works as a post-processor, optimizing the output that hugo generates in the public folder.\n\nYou can now invoke hugo from the command line as it best suits you and use any theme you want.\n\nCheck the README for v2 docs.\n"
  },
  {
    "path": "metadata/changes/2.0.1.txt",
    "content": "2017-12-12 - 2.0.1\n\n- Run styles/scripts tasks on watch invocation\n- Add granular imagemin configuration\n- Adjust default .hugulprc\n- Fix JSON syntax in README\n- Fix update instructions\n"
  },
  {
    "path": "metadata/changes/2.0.2.txt",
    "content": "2017-12-12 - 2.0.2\n\n- Fix plugin names\n"
  },
  {
    "path": "metadata/changes/2.0.3.txt",
    "content": "2017-12-12 - 2.0.3\n\n- Make sure all tasks are executed\n- Display pipeline being executed\n- Display space optimization achieved\n"
  },
  {
    "path": "metadata/changes/2.0.4.txt",
    "content": "2017-12-12 - 2.0.4\n\n- Set saner htmlmin defaults\n"
  },
  {
    "path": "metadata/changes/2.0.5.txt",
    "content": "2017-12-12 - 2.0.5\n\n- Fix scripts task build source\n"
  },
  {
    "path": "metadata/changes/2.0.6.txt",
    "content": "2018-10-28 - 2.0.6\n\n- Log relative path while watching styles"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"hugulp\",\n  \"version\": \"2.0.6\",\n  \"description\": \"website\",\n  \"files\": [\n    \"index.js\",\n    \"gulp\"\n  ],\n  \"bin\": {\n    \"hugulp\": \"./index.js\"\n  },\n  \"scripts\": {\n    \"gulp\": \"gulp\",\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"Juan B. Rodriguez\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"commander\": \"^2.12.2\",\n    \"del\": \"^3.0.0\",\n    \"gulp\": \"^3.9.1\",\n    \"gulp-autoprefixer\": \"^4.0.0\",\n    \"gulp-changed\": \"^3.1.1\",\n    \"gulp-clean-css\": \"^3.9.0\",\n    \"gulp-concat\": \"^2.6.1\",\n    \"gulp-debug\": \"^3.1.0\",\n    \"gulp-htmlmin\": \"^3.0.0\",\n    \"gulp-imagemin\": \"^4.0.0\",\n    \"gulp-jshint\": \"^2.0.4\",\n    \"gulp-less\": \"^3.3.2\",\n    \"gulp-rev\": \"^8.1.0\",\n    \"gulp-rev-delete-original\": \"^0.2.3\",\n    \"gulp-rev-replace\": \"^0.4.3\",\n    \"gulp-sass\": \"^3.1.0\",\n    \"gulp-size\": \"^2.1.0\",\n    \"gulp-svgmin\": \"^1.2.4\",\n    \"gulp-uglify\": \"^3.0.0\",\n    \"gulp-util\": \"^3.0.8\",\n    \"gulp-watch\": \"^4.3.11\",\n    \"jshint\": \"^2.9.5\",\n    \"merge-stream\": \"^1.0.1\",\n    \"path\": \"^0.12.7\",\n    \"pkginfo\": \"^0.4.1\",\n    \"pump\": \"^2.0.0\",\n    \"rev-del\": \"^1.0.5\",\n    \"run-sequence\": \"^2.2.0\"\n  }\n}\n"
  },
  {
    "path": "scripts/bump-hook",
    "content": "#!/usr/bin/env bash\n\nfunction error {\n\tNAME=$1\n\n\tprintf \"$1\"\n\texit 1\n}\n\nAPP_VERSION=$(cat VERSION 2> /dev/null)\n\nif [[ -z $APP_VERSION ]]; then\n\terror \"Unable to find VERSION file. Please check and try again\"\nfi\n\necho \"Version is $APP_VERSION\"\n\nnpm --no-git-tag-version -f version ${APP_VERSION}\n\nTAG=`git describe --abbrev=0 --tags 2> /dev/null`\n\nif [[ -z \"$TAG\" ]]; then\n\tCOMMITS=`git --no-pager log --reverse --pretty=format:'- %s' | egrep -v '.*Closes' | egrep -v '.*Merge' 2> /dev/null`\nelse\n\tCOMMITS=`git --no-pager log --reverse --pretty=format:'- %s' \"$TAG\"...HEAD | egrep -v '.*Closes' | egrep -v '.*Merge' 2> /dev/null`\nfi\n\nPREVIOUS=`cat metadata/changes/${TAG}.txt 2> /dev/null`\n\ncat <<EOF > metadata/changes/${APP_VERSION}.txt\n`date +%F` - ${APP_VERSION}\n${COMMITS}\n\n${PREVIOUS}\nEOF\n\ncode metadata/changes/${APP_VERSION}.txt\n\necho \"Bumped versions successfully\"\n"
  },
  {
    "path": "scripts/create-docker-machine-and-run-it",
    "content": "#!/bin/bash\n#\n# Setup a docker machine for development\nset -eu\n\nreadonly PROGNAME=$(basename \"$0\")\nreadonly ARGS=(\"$@\")\n# Docker settings\nHUGO_VERSION=0.20.6\nNODE_VERSION=\"7.9.0-alpine\"\nAPP_NAME=\"app\"\nDETACHED=\ncheck_where_cmd_is_run() {\n  # Check if script is being run from the root directory\n  if [ ! -d 'gulp' ]; then\n    cat <<- EOF\n\t\tPlease run this script from the root directory.\n\n\t\tExample:\n\t\t\t./scripts/create-docker-machine-and-run-it\n\n\t\t-- OR --\n\n\t\tbash ./scripts/create-docker-machine-and-run-it\n\t\tEOF\n\t\texit 1\n\tfi\n}\n\nusage() {\n  cat <<- EOF\n\tUsage: ./scripts/$PROGNAME optional options\n\n\tSetups a docker machine and runs it for development.\n\n\tOPTIONS:\n\t   -g --hugo-version the hugo version to be installed. Minus v or version prefix. It defaults to 0.9\n\t   -n --node-version the node version to be installed. Minus v or version prefix. It defaults to 6.10.0\n\t   -a --app-name the name of the app. It defaults to app\n\t   -d --detached detached mode: Run containers in the background, print new container names.\n\t   -h --help show this help\n\n\tExamples:\n\tRun with default settings:\n\n\t   ./scripts/$PROGNAME\n\n\tRun with custom machine name, specific hugo version, specific node version and run docker in detached mode:\n\n\t   bash ./scripts/$PROGNAME -a app-name -g 0.9 -n 6.10.0\n\tEOF\n}\n\ncmdline() {\n  local arg=\n  local args=\n  for arg; do\n    local delim=\"\"\n    case \"$arg\" in\n      # Copied from: http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/\n      # Translate --machine-name to -m (short options)\n      --hugo-version)   args=\"${args}-g \";;\n      --node-version)   args=\"${args}-n \";;\n      --app-name)       args=\"${args}-a \";;\n      --detached)       args=\"${args}-d \";;\n      --help)           args=\"${args}-h \";;\n      #pass through anything else\n      *) [[ \"${arg:0:1}\" == \"-\" ]] || delim=\"\\\"\"\n          args=\"${args}${delim}${arg}${delim} \";;\n    esac\n  done\n  while getopts \"g:n:a:dh\" OPTION; do\n    case \"$OPTION\" in\n      h)\n        usage\n        exit 0\n        ;;\n      g)\n        HUGO_VERSION=$OPTARG\n        ;;\n      n)\n        NODE_VERSION=$OPTARG\n        ;;\n      a)\n        APP_NAME=$OPTARG\n        ;;\n      d)\n        DETACHED='-d'\n        ;;\n    esac\n  done\n  return 0\n}\n\ncreate_docker_file() {\n  # Check to make sure Dockerfile exist\n  if [ ! -f './docker/Dockerfile.template' ]; then\n    echo \"This script requires ./docker/Dockerfile.template file to setup docker.\"\n  exit 1\n  fi\n  echo \"Creating Dockerfile file...\"\n  cp ./docker/Dockerfile.template ./Dockerfile\n  # Replace some lines in existing Dockerfile.\n  # Set sed -i option to '' to prevent it from creating backup files\n  # Replace node version set value\n  sed -i '' -e \"s|^FROM node:\\([0-9\\.]*\\).*|FROM node:$NODE_VERSION|\" \\\n    Dockerfile\n  # Replace hugo version with set value\n  sed -i '' -e \"s|^ARG HUGO_VERSION=\\([0-9\\.]*\\).*|ARG HUGO_VERSION=$HUGO_VERSION|\" \\\n    Dockerfile\n  # Replace app home directory with set value\n  sed -i '' -e \"s|\\$HOME/[a-zA-Z0-9]*/$|\\$HOME/$APP_NAME/|g\" \\\n    Dockerfile\n  echo \"Dockerfile successfully created.\"\n}\n\nsetup_docker() {\n  # Check if docker is installed on the machine\n  if ! docker version > /dev/null; then\n    echo \"Please docker-engine and docker-compose are required to be installed on the host machine\"\n    echo \"https://docs.docker.com/engine/installation/\"\n    echo \"https://docs.docker.com/compose/\"\n    exit 1\n  fi\n  create_docker_file\n}\n\nsetup_docker_compose() {\n  # Check to make sure docker-compose template file exist\n  if [ ! -f './docker/docker-compose.yaml.template' ]; then\n    echo \"This script requires ./docker/docker-compose.yaml.template file to setup docker-compose.\"\n    exit 1\n  fi\n  echo \"Creating docker-compose.yaml file...\"\n  cp ./docker/docker-compose.yaml.template ./docker-compose.yaml\n  echo \"docker-compose.yaml successfully created.\"\n  sed -i '' -e \"s/app:/${APP_NAME}:/\" \\\n    docker-compose.yaml\n  sed -i '' -e \"s/app/$APP_NAME/g\" \\\n    docker-compose.yaml\n  if [[ \"$DETACHED\" != \"\" ]]; then\n    docker-compose up --build \"$DETACHED\" \"$APP_NAME\"\n  else\n    docker-compose up --build \"$APP_NAME\"\n  fi\n}\n\n#######################\n#    Main function    #\n#######################\nif [[ $# -gt 0 ]]; then\n  cmdline \"${ARGS[@]}\"\nfi\ncheck_where_cmd_is_run\nsetup_docker\nsetup_docker_compose\n"
  },
  {
    "path": "scripts/create-hugo-site",
    "content": "#!/bin/sh\n#\n# Creates pre-requiste hugo site\nset -eu\n\nreadonly PROGNAME=$(basename \"$0\")\nreadonly ARGS=\"$@\"\nAPP_NAME=\"app\"\n\nusage() {\n\tcat <<- EOF\n\tUsage: ./scripts/$PROGNAME optional options\n\n\tCreates folders needed to run hulgulp if they do not exist\n\n\tOPTIONS:\n\t\t-a --app-name the name of the app. It defaults to app\n\t\t-h --help show this help\n\n\tExample:\n\tRun with a hugo website name set to website\n\n\t\t./scripts/$PROGNAME -a website\n\tEOF\n}\n\ncmdline() {\n  local arg=\n  local args=\n  for arg; do\n    local delim=\"\"\n    case \"$arg\" in\n      # Copied from: http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/\n      # Translate --machine-name to -m (short options)\n      --app-name)       args=\"${args}-a \";;\n      --help)           args=\"${args}-h \";;\n      #pass through anything else\n      *) [[ \"${arg:0:1}\" == \"-\" ]] || delim=\"\\\"\"\n          args=\"${args}${delim}${arg}${delim} \";;\n    esac\n  done\n\n  OPTIND=1\n  while getopts \"ha:\" OPTION; do\n    case \"$OPTION\" in\n      h)\n        usage\n        exit 0\n        ;;\n      a)\n        APP_NAME=$OPTARG\n        ;;\n    esac\n  done\n  shift \"$((OPTIND-1))\" # Shift off the options and optional --.\n  return 0\n}\n\ncreate_hugo_site() {\n  if [ ! -d \"$APP_NAME\" ]; then\n    hugo new site \"$APP_NAME\"\n  fi\n}\n\ncreate_assets_folders() {\n  if [ ! -d \"${APP_NAME}/assets\" ]; then\n    mkdir -p \"${APP_NAME}\"/assets/img\n    mkdir -p \"${APP_NAME}\"/assets/styles\n    mkdir -p \"${APP_NAME}\"/assets/scripts\n  fi\n}\n\n#######################\n#    Main function    #\n#######################\nif [[ $# -gt 0 ]]; then\n  cmdline \"$@\"\nfi\ncreate_hugo_site\ncreate_assets_folders\n"
  },
  {
    "path": "scripts/rel-push-prog",
    "content": "#!/usr/bin/env bash\n\nfunction error {\n  echo -e \"$1\" >&2\n  exit 1\n}\n\nPROG=\"hugulp\"\nVERSION=`cat VERSION 2> /dev/null`\n\ngit checkout rel/$VERSION\n\n# This sections deals with pushing the current tag\n# to the $PROG github repo\nREMOTE=`git remote get-url github 2> /dev/null`\nif [[ -z \"$REMOTE\" ]]; then\n\tgit remote add github gitjbr:jbrodriguez/$PROG.git\nelse\n\tgit remote set-url github gitjbr:jbrodriguez/$PROG.git\nfi\n\n# TAG=`git describe --abbrev=0 --tags 2> /dev/null`\n# if [[ -z \"$TAG\" ]]; then\n# \terror \"Unable to retrieve latest tag\"\n# fi\n\nBRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)\nif [[ -z $BRANCH ]]; then\n\terror \"Unable to obtain branch name. Please check and try again.\"\nfi\n\ngit push --tags github $BRANCH\nif [ $? -ne 0 ]; then\n\terror \"Unable to push branch ${BRANCH} to github\"\nfi\n\nDESCRIPTION=`cat metadata/changes/$VERSION.txt 2> /dev/null`\n\ngithub-release --verbose release \\\n    --user jbrodriguez \\\n    --repo \"$PROG\" \\\n    --tag \"$VERSION\" \\\n    --name \"$VERSION\" \\\n    --description \"$DESCRIPTION\" \\\n"
  }
]