-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish_docs.js
executable file
·46 lines (35 loc) · 1.41 KB
/
publish_docs.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
#!/usr/bin/env node
const publishYalcPackage = require('./publish_yalc_package');
const util = require('./util');
util.packageDir();
const fs = require('fs');
const path = require('path');
const _exec = util._exec;
const sh = require('shelljs');
const readlineSync = require('readline-sync');
const TYPEDOC_CONFIG = JSON.parse(fs.readFileSync('./typedoc.json'));
const PKGJSON = JSON.parse(fs.readFileSync('./package.json'));
const DOCGEN_CONFIG = PKGJSON.docgen || {};
const version = PKGJSON.version;
const GIT_URL = "[email protected]:ui-router/ui-router.github.io.git";
const installTargetDir = path.join(".downstream_cache", "ui-router.gihub.io");
const PAGES_DIR = path.join(installTargetDir, DOCGEN_CONFIG.publishDir);
sh.rm('-rf', installTargetDir);
_exec(`git clone ${GIT_URL} ${installTargetDir}`);
util.packageDir();
sh.rm('-rf', path.join(PAGES_DIR, 'latest'));
sh.cp('-r', TYPEDOC_CONFIG.out, path.join(PAGES_DIR, 'latest'));
sh.rm('-rf', path.join(PAGES_DIR, version));
sh.cp('-r', TYPEDOC_CONFIG.out, path.join(PAGES_DIR, version));
sh.cd(PAGES_DIR);
_exec("./process_docs.sh");
_exec("git add .");
sh.echo("\n\nSpot check the docs, then run these commands to publish:\n\n");
sh.echo("cd " + PAGES_DIR);
sh.echo(`git commit -m 'publish docs for ${version}'`);
sh.echo(`git push`);
if (readlineSync.keyInYN('Publish docs?')) {
sh.cd(PAGES_DIR);
_exec(`git commit -m 'publish docs for ${version}'`);
_exec(`git push`);
}