forked from GeekyAnts/native-base-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulateBookJson.js
executable file
·78 lines (78 loc) · 2.38 KB
/
populateBookJson.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 'use strict';
//
// const https = require('https');
// const fs = require('fs');
// const spawnSync = require('child_process').spawnSync;
//
// var options = {
// hostname: 'api.github.com',
// port: 443,
// path: '/repos/GeekyAnts/native-base-docs/branches',
// method: 'GET',
// headers: {
// 'User-Agent': 'Mozilla /5.0 (Compatible MSIE 9.0;Windows NT 6.1;WOW64; Trident/5.0)',
// 'Accept': 'application/vnd.github.v3+json'
// }
// };
//
// var populateBookJson = (branches) => {
//
// spawnSync('git', ['checkout', 'master'], {stdio: 'inherit'});
//
// const bookJsonContents = require('./book.json');
//
// bookJsonContents.pluginsConfig.versions.options = [];
//
// for(let i=0; i<branches.length; i++) {
// if(branches[i].name === 'master') {
// bookJsonContents.pluginsConfig.versions.options.push({
// value: 'http://rawgit.com/GeekyAnts/native-base-docs/master/_book/index.html',
// text: 'latest'
// });
// } else {
// bookJsonContents.pluginsConfig.versions.options.push({
// value: 'http://rawgit.com/GeekyAnts/native-base-docs/' + branches[i].name + '/_book/index.html',
// text: branches[i].name
// });
// }
// }
//
// bookJsonContents.pluginsConfig.versions.options.push({
// value: 'http://rawgit.com/GeekyAnts/native-base-docs/master/_book/index.html',
// text: '-- select version --',
// selected: false
// });
//
// fs.writeFileSync(__dirname + '/book.json', JSON.stringify(bookJsonContents, null, 4), {encoding: 'utf8'});
//
// spawnSync('gitbook', ['build'], {stdio: 'inherit'});
// spawnSync('git', ['add', 'book.json'], {stdio: 'inherit'});
// spawnSync('git', ['add', '_book'], {stdio: 'inherit'});
// spawnSync('git', ['commit', '-m', 'rebuild book with all versions'], {stdio: 'inherit'});
// spawnSync('git', ['push', 'origin', 'master'], {stdio: 'inherit'});
// }
//
// var req = https.request(options, (res) => {
//
// var responseData = '';
//
// res.setEncoding('utf8');
//
// res.on('data', (chunk) => {
// responseData += chunk;
// });
//
// res.on('end', function () {
// try {
// console.log('responseData', responseData);
// populateBookJson(JSON.parse(responseData));
// } catch(err) {
// console.log('error: ', err);
// }
// });
// });
//
// req.on('error', (e) => {
// console.error(e);
// });
// req.end();