diff --git a/.gitignore b/.gitignore index 653d0b0d144..25d9db75e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -.DS_Store -.jekyll-metadata _site/ .bundle +.DS_Store +.jekyll-metadata bin +node_modules vendor diff --git a/_config.yml b/_config.yml index 7bb0deb670d..c4494f8281a 100644 --- a/_config.yml +++ b/_config.yml @@ -2,8 +2,11 @@ baseurl: "/open-source-handbook" exclude: - bin + - CONTRIBUTING.md - docs - Gemfile* + - node_modules + - package.json - Rakefile - README.md - script diff --git a/package.json b/package.json new file mode 100644 index 00000000000..de9b9f396b2 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "open-source-handbook", + "private": true, + "scripts": { + "test": "script/test" + }, + "devDependencies": { + "async": "^1.5.2", + "glob": "^7.0.5", + "ignore": "^3.1.3", + "js-yaml": "^3.6.1", + "remark-lint": "^4.0.1", + "remark-parse": "^1.0.0", + "remark-retext": "^2.0.0", + "remark-stringify": "^1.0.0", + "retext": "^3.0.0", + "retext-english": "^2.0.0", + "retext-equality": "^2.3.2", + "retext-readability": "^2.0.0", + "retext-simplify": "^2.0.0", + "to-vfile": "^1.0.0", + "unified": "^4.1.2", + "vfile-reporter": "^2.0.0" + } +} diff --git a/script/bootstrap b/script/bootstrap index 599f07e2e7d..ac3de3c6931 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -7,3 +7,6 @@ echo "==> Installing gem dependencies…" bundle check --path vendor/gems 2>&1 > /dev/null || { time bundle install --binstubs bin --path vendor/gems } + +echo "==> Installing node dependencies…" +npm install diff --git a/script/cibuild b/script/cibuild index ecb1ca01868..d9ce5a31f8f 100755 --- a/script/cibuild +++ b/script/cibuild @@ -2,8 +2,9 @@ set -e -export PATH="/usr/share/rbenv/shims:$PATH" +export PATH="/usr/share/rbenv/shims:/usr/local/share/nodenv/shims:$PATH" export RBENV_VERSION="2.1.7-github" +export NODENV_VERSION="v0.10.21" # clean out the ruby environment export RUBYLIB= export RUBYOPT= diff --git a/script/test b/script/test index b79c950fdb8..212a6921362 100755 --- a/script/test +++ b/script/test @@ -5,3 +5,4 @@ set -e script/build --config _config.yml,test/_config.yml bundle exec rake script/html-proofer +script/test-prose diff --git a/script/test-prose b/script/test-prose new file mode 100755 index 00000000000..06d268adeae --- /dev/null +++ b/script/test-prose @@ -0,0 +1,61 @@ +#!/usr/bin/env node + +// Retext stuff +var unified = require('unified'); + +// Remark stuff +var parse = require('remark-parse'); +var lint = require('remark-lint'); +var remark2retext = require('remark-retext'); +var stringify = require('remark-stringify'); + +// Util stuff +var report = require('vfile-reporter'); +var glob = require('glob'); +var fs = require('fs'); +var async = require('async'); +var yaml = require('js-yaml'); +var jekyllConfig = yaml.safeLoad(fs.readFileSync('_config.yml', 'utf8')); +var ignore = require('ignore')().add(jekyllConfig["exclude"]) + +var options = { + // https://github.com/wooorm/remark-lint/blob/master/doc/rules.md + "lint": { + "list-item-indent": "space", // As the gods intended. + "maximum-line-length": false, // turn off line length linting + "no-html": false, // Sadly, need HTML for video embeds + "no-heading-punctuation": false, + "list-item-spacing": false, + }, + "readability": { + "age": 18 + }, + "simplify": { + ignore: [ + "modify", + "contribute", + "previous" + ] + } +}; + +async.map(ignore.filter(glob.sync("**/*.md")), function(file, callback) { + fs.readFile(file, function(err, contents) { + unified() + .use(parse) + .use(lint, options["lint"]) + // .use(remark2retext, unified() + // .use(require('retext-english')) + // .use(require('retext-simplify'), options["simplify"]) + // .use(require('retext-equality')) + // .use(require('retext-readability'), options["readability"]) + // ) + .use(stringify) + .process(contents.toString(), function (err, result) { + result.filename = file; + callback(err, result); + }); + }); +}, function (err, results) { + console.log(report(results)); +});