aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Hand <joe@joeahand.com>2016-12-17 13:23:02 -0800
committerJoe Hand <joe@joeahand.com>2016-12-17 13:23:02 -0800
commit0ab374236a130f1ed834fd24c7cb2b9a94e0103d (patch)
treef13a0795304cee26981b00f122339820fb81d0b1
parentc8966c84ba4005889b45fc418c48499f33deddac (diff)
downloaddat-docs-0ab374236a130f1ed834fd24c7cb2b9a94e0103d.tar.gz
dat-docs-0ab374236a130f1ed834fd24c7cb2b9a94e0103d.zip
add sync script for travis
-rw-r--r--.travis.yml2
-rw-r--r--package.json8
-rw-r--r--scripts/build.js (renamed from build.js)3
-rw-r--r--scripts/sync.js35
4 files changed, 44 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml
index 3fd792c..9c03b91 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,5 +23,5 @@ install:
deploy:
provider: script
- script: npm run deploy
+ script: npm run travis:update && npm run deploy
skip_cleanup: true
diff --git a/package.json b/package.json
index 6475b62..b73a5b7 100644
--- a/package.json
+++ b/package.json
@@ -4,9 +4,12 @@
"description": "Documentation for Dat and the surrounding ecosystem.",
"main": "index.js",
"scripts": {
+ "travis:update": "npm run travis:list && npm run travis:sync",
+ "travis:list": "npm run update:list && cat repos.txt | node scripts/sync.js",
+ "travis:sync": "cat repos.txt | ecosystem-docs read -d ./.data | node scripts/build.js",
"update": "npm run update:list && npm run update:build",
"update:list": "curl -Ssl https://raw.githubusercontent.com/clkao/awesome-dat/master/readme.md | grep '📔' | egrep -o 'github.com/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+' | cut -f 2- -d / | uniq > repos.txt",
- "update:build": "cat repos.txt | ecosystem-docs sync && cat repos.txt | ecosystem-docs read | node build.js",
+ "update:build": "cat repos.txt | ecosystem-docs sync && cat repos.txt | ecosystem-docs read | node scripts/build.js",
"build:local": "npm run build:css && minidocs docs -c docs/contents.json -i dat -o dist -l ./node_modules/dat-design/public/img/dat-data-logo.svg -t 'Dat Data' -s assets/styles.css --pushstate",
"build:deploy": "npm run build:css && minidocs docs -c docs/contents.json -i dat -o dist -l ./node_modules/dat-design/public/img/dat-data-logo.svg -t 'Dat Data' -s assets/styles.css --full-html",
"build:css": "node-sass --importer node_modules/node-sass-magic-importer assets/styles.scss assets/styles.css",
@@ -29,7 +32,8 @@
"dependencies": {
"dat-design": "^1.2.11",
"gh-pages": "^0.11.0",
- "minidocs": "^4.0.5"
+ "minidocs": "^4.0.5",
+ "split2": "^2.1.0"
},
"devDependencies": {
"budo": "^8.3.0",
diff --git a/build.js b/scripts/build.js
index 6f3cc22..136d99a 100644
--- a/build.js
+++ b/scripts/build.js
@@ -1,7 +1,8 @@
var fs = require('fs')
+var mkdirp = require('mkdirp')
var ndjson = require('ndjson')
-fs.mkdirSync('docs/modules')
+mkdirp.sync('docs/modules')
process.stdin.pipe(ndjson.parse()).on('data', function (obj) {
fs.writeFileSync('docs/modules/' + obj.name + '.md', obj.readme)
})
diff --git a/scripts/sync.js b/scripts/sync.js
new file mode 100644
index 0000000..73e86b7
--- /dev/null
+++ b/scripts/sync.js
@@ -0,0 +1,35 @@
+var path = require('path')
+var ghAuth = require('ghauth')
+var ecosystem = require('ecosystem-docs')
+var split = require('split2')
+
+var modules = []
+
+process.stdin.pipe(split()).on('data', function (data) {
+ modules.push(data)
+}).on('end', function () {
+ syncModules(modules, function () {
+ process.exit(0)
+ })
+})
+
+function syncModules (modules, cb) {
+ console.log('syncing', modules)
+ if (process.env.GH_TOKEN) return sync(process.env.GH_TOKEN)
+
+ ghAuth({
+ configName: 'ecosystem-docs',
+ userAgent: 'ecosystem-docs',
+ scopes: ['user']
+ }, (err, auth) => {
+ if (err) return cb(err)
+ sync(auth.token)
+ })
+
+ function sync (token) {
+ ecosystem.sync(modules, {
+ data: path.join(__dirname, '..', '.data'),
+ token: token
+ }, cb)
+ }
+} \ No newline at end of file