mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-08 01:06:43 +02:00
scripts: fix generate-config-doc, handle usage errors
This commit is contained in:
parent
d1561f8ebc
commit
6603c1a6e6
|
@ -18,6 +18,7 @@
|
||||||
"coverage": "run-s test:* && nyc --nycrc-path=test/.nycrc-report.json report",
|
"coverage": "run-s test:* && nyc --nycrc-path=test/.nycrc-report.json report",
|
||||||
"dev": "cross-env NODE_ENV=development ts-node --project server/tsconfig.json server/index.ts start --dev",
|
"dev": "cross-env NODE_ENV=development ts-node --project server/tsconfig.json server/index.ts start --dev",
|
||||||
"format:prettier": "prettier --write \"**/*.*\"",
|
"format:prettier": "prettier --write \"**/*.*\"",
|
||||||
|
"generate:config:doc": "ts-node scripts/generate-config-doc.js",
|
||||||
"lint:check-eslint": "eslint-config-prettier .eslintrc.cjs",
|
"lint:check-eslint": "eslint-config-prettier .eslintrc.cjs",
|
||||||
"lint:eslint": "eslint . --report-unused-disable-directives --color",
|
"lint:eslint": "eslint . --report-unused-disable-directives --color",
|
||||||
"lint:prettier": "prettier --list-different \"**/*.*\"",
|
"lint:prettier": "prettier --list-different \"**/*.*\"",
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Usage: `node generate-config-doc.js DOC_REPO_PATH`
|
// Usage: `npm run generate:config:doc DOC_REPO_PATH`
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
// ```sh
|
// ```sh
|
||||||
// node scripts/generate-config-doc.js ../thelounge.github.io/
|
// npm run generate:config:doc ../thelounge.github.io/
|
||||||
// ```
|
// ```
|
||||||
|
|
||||||
const {readFileSync, writeFileSync} = require("fs");
|
const {readFileSync, writeFileSync} = require("fs");
|
||||||
const colors = require("chalk");
|
const colors = require("chalk");
|
||||||
const log = require("../server/log");
|
const log = require("../server/log").default;
|
||||||
const {join} = require("path");
|
const {join} = require("path");
|
||||||
const {spawnSync} = require("child_process");
|
const {spawnSync} = require("child_process");
|
||||||
|
|
||||||
|
@ -20,8 +20,18 @@ function getGitUsername() {
|
||||||
|
|
||||||
const configContent = readFileSync(join(__dirname, "..", "defaults", "config.js"), "utf8");
|
const configContent = readFileSync(join(__dirname, "..", "defaults", "config.js"), "utf8");
|
||||||
|
|
||||||
|
const docRoot = process.argv[2];
|
||||||
|
|
||||||
|
if (!docRoot) {
|
||||||
|
log.error("Missing DOC_REPO_PATH. Pass the path to the cloned `thelounge.github.io` repo.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const docPath = join(process.argv[2], "_includes", "config.js.md");
|
const docPath = join(process.argv[2], "_includes", "config.js.md");
|
||||||
|
|
||||||
|
/** @type {string[]} */
|
||||||
|
const acc = [];
|
||||||
|
|
||||||
const extractedDoc = configContent
|
const extractedDoc = configContent
|
||||||
.replace(/https:\/\/thelounge\.chat\/docs/g, "/docs") // make links relative
|
.replace(/https:\/\/thelounge\.chat\/docs/g, "/docs") // make links relative
|
||||||
.split("\n")
|
.split("\n")
|
||||||
|
@ -37,7 +47,7 @@ const extractedDoc = configContent
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, [])
|
}, acc)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
const infoBlockHeader = `<!--
|
const infoBlockHeader = `<!--
|
||||||
|
|
Loading…
Reference in a new issue