From 364e6c39ad76ec38eb738dab10275655f655a191 Mon Sep 17 00:00:00 2001 From: Aurelsicoko Date: Tue, 10 Oct 2017 11:11:17 +0200 Subject: [PATCH] Build documentation with Travis it works as expected --- .travis.yml | 1 + package.json | 5 +++-- scripts/documentation.js | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 scripts/documentation.js diff --git a/.travis.yml b/.travis.yml index f6aeb77b2d..56e1f71cad 100755 --- a/.travis.yml +++ b/.travis.yml @@ -20,4 +20,5 @@ install: - npm run setup script: + - npm run doc - npm run test diff --git a/package.json b/package.json index 89a2bf6301..37ecd298d4 100755 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-react": "^6.8.0", "eslint-plugin-redux-saga": "^0.3.0", + "gitbook-cli": "^2.3.2", "istanbul": "~0.4.2", "lerna": "^2.0.0", "mocha": "~2.4.5", @@ -23,6 +24,7 @@ "scripts": { "clean": "npm run removesymlinkdependencies && rm -rf package-lock.json && rm -rf packages/*/package-lock.json", "clean:all": "npm run removesymlinkdependencies && rm -rf package-lock.json && rm -rf packages/*/package-lock.json && rm -rf packages/*/node_modules", + "doc": "node ./scripts/documentation.js", "release": "npm run clean:all && npm install && npm run createsymlinkdependencies && lerna exec --concurrency 1 -- npm install && npm run removesymlinkdependencies && node ./scripts/publish.js $TAG", "createsymlinkdependencies": "node ./scripts/createSymlinkDependencies.js", "removesymlinkdependencies": "node ./scripts/removeSymlinkDependencies.js", @@ -56,6 +58,5 @@ "node": ">= 7.0.0", "npm": ">= 3.0.0" }, - "license": "MIT", - "dependencies": {} + "license": "MIT" } diff --git a/scripts/documentation.js b/scripts/documentation.js new file mode 100644 index 0000000000..2952711698 --- /dev/null +++ b/scripts/documentation.js @@ -0,0 +1,23 @@ +const _ = require('lodash'); +const fs = require('fs'); +const path = require('path'); +const shell = require('shelljs'); + +try { + const versions = fs.readdirSync(path.resolve(process.cwd(), 'docs'), 'utf8'); + + _.forEach(versions, (version) => { + console.log(`Strapi install plugins version ${version}`); + shell.exec(`${path.join(process.cwd(), 'node_modules', '.bin', 'gitbook')} install ${path.join(process.cwd(), 'docs', version)}`); + console.log(`Strapi build version ${version}`); + shell.exec(`${path.join(process.cwd(), 'node_modules', '.bin', 'gitbook')} build ${path.join(process.cwd(), 'docs', version)}`); + }); + + console.log('Documentation has been built with success'); +} catch (err) { + if (err.stdout) { + return console.log(err.stdout.toString('utf8')); + } + + console.log(err); +}