2019-09-16 00:59:05 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires, no-console */
|
2019-01-28 22:20:32 +00:00
|
|
|
const { resolve } = require("path");
|
|
|
|
const { execSync } = require("child_process");
|
2019-09-16 00:59:05 +00:00
|
|
|
const { writeFileSync, readFileSync, unlinkSync } = require("fs");
|
2019-01-28 22:20:32 +00:00
|
|
|
|
2019-09-16 00:59:05 +00:00
|
|
|
function generateDocs() {
|
2019-09-16 18:59:33 +00:00
|
|
|
const commitHash = execSync("git rev-parse --short HEAD").toString().trim();
|
2019-09-16 00:59:05 +00:00
|
|
|
console.log(`commit hash ${commitHash}`);
|
|
|
|
const outputDir = resolve(__dirname, "../docs");
|
|
|
|
const tmpFile = resolve(outputDir, "tmp.json");
|
|
|
|
const outputFile = resolve(outputDir, "tone.json");
|
|
|
|
// generate the doc file
|
|
|
|
execSync(`npm run docs:json --docs_json=${tmpFile}`);
|
|
|
|
// add the version and commit to the file
|
|
|
|
const json = JSON.parse(readFileSync(tmpFile, "utf-8"));
|
2019-09-16 01:01:28 +00:00
|
|
|
console.log(`doc files: ${json.children.length}`);
|
2019-09-16 00:59:05 +00:00
|
|
|
json.commit = commitHash;
|
|
|
|
const package = JSON.parse(readFileSync(resolve(__dirname, "../package.json"), "utf-8"));
|
|
|
|
json.version = package.version;
|
|
|
|
writeFileSync(outputFile, JSON.stringify(json));
|
|
|
|
unlinkSync(tmpFile);
|
2019-01-28 22:20:32 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 00:59:05 +00:00
|
|
|
generateDocs();
|