hdoc-tools 0.55.2 → 0.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hdoc.js +47 -1
- package/package.json +1 -1
package/hdoc.js
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
const preRun = require("./validateNodeVer.js");
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
// Point Puppeteer at the browser cache provisioned by hdoc-install-browser.js.
|
|
8
|
+
// Puppeteer discovers .puppeteerrc.cjs via cosmiconfig searching up from
|
|
9
|
+
// process.cwd(), which at runtime is the user's docbook repo — never the
|
|
10
|
+
// global node_modules where our config (and cache) live. So the pinned
|
|
11
|
+
// cacheDir there is invisible at launch and Puppeteer falls back to
|
|
12
|
+
// ~/.cache/puppeteer, which is empty (browser is under the package dir). The
|
|
13
|
+
// PUPPETEER_CACHE_DIR env var IS honored at launch regardless of cwd, so set
|
|
14
|
+
// it here from the same shared config. An explicit override always wins.
|
|
15
|
+
if (!process.env.PUPPETEER_CACHE_DIR) {
|
|
16
|
+
process.env.PUPPETEER_CACHE_DIR = require(
|
|
17
|
+
path.join(__dirname, ".puppeteerrc.cjs"),
|
|
18
|
+
).cacheDir;
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
const hdoc = require(path.join(__dirname, "hdoc-module.js"));
|
|
7
22
|
|
|
8
23
|
const packageFile = path.join(__dirname, "package.json");
|
|
@@ -128,7 +143,19 @@
|
|
|
128
143
|
let source_path = process.cwd();
|
|
129
144
|
let ui_path = path.join(__dirname, "ui");
|
|
130
145
|
let editor_path = path.join(__dirname, "editor", "dist");
|
|
131
|
-
|
|
146
|
+
// Default the GitHub token from the environment so nobody has to hand-pass a
|
|
147
|
+
// secret on the command line (and it never lands in shell history). GITHUB_TOKEN
|
|
148
|
+
// is the GitHub Actions / CI standard; GH_TOKEN is the gh-CLI convention. An
|
|
149
|
+
// explicit --git-token flag (parsed below) overrides either.
|
|
150
|
+
let git_token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN || "";
|
|
151
|
+
// Track where the token came from purely so we can log it (masked) later — helps
|
|
152
|
+
// contributors confirm auth is active rather than silently falling back to the
|
|
153
|
+
// unauthenticated 60/hr limit because of a typo'd env var or wrong scope.
|
|
154
|
+
let git_token_source = process.env.GITHUB_TOKEN
|
|
155
|
+
? "GITHUB_TOKEN env"
|
|
156
|
+
: process.env.GH_TOKEN
|
|
157
|
+
? "GH_TOKEN env"
|
|
158
|
+
: "";
|
|
132
159
|
let command = ""; // Our command to run
|
|
133
160
|
let build_version = "";
|
|
134
161
|
let verbose = false;
|
|
@@ -170,6 +197,7 @@
|
|
|
170
197
|
x++;
|
|
171
198
|
if (x < process.argv.length) {
|
|
172
199
|
git_token = process.argv[x];
|
|
200
|
+
git_token_source = "--git-token flag";
|
|
173
201
|
}
|
|
174
202
|
} else if (process.argv[x].toLowerCase() === "--set-version") {
|
|
175
203
|
x++;
|
|
@@ -197,6 +225,24 @@
|
|
|
197
225
|
console.log(" Server Path:", __dirname);
|
|
198
226
|
console.log(" Document Path:", source_path, "\r\n");
|
|
199
227
|
|
|
228
|
+
// Confirm GitHub auth status for commands that pull contributor data, so a
|
|
229
|
+
// contributor can see at a glance whether the rate-limit-lifting token is
|
|
230
|
+
// actually in effect. Show only a short masked preview — never the full token.
|
|
231
|
+
if (command.toLowerCase() === "build" || command.toLowerCase() === "validate") {
|
|
232
|
+
if (git_token) {
|
|
233
|
+
const masked =
|
|
234
|
+
git_token.length > 8
|
|
235
|
+
? `${git_token.slice(0, 4)}…${git_token.slice(-2)}`
|
|
236
|
+
: "…";
|
|
237
|
+
console.log(` GitHub Token: using ${git_token_source} [${masked}]`, "\r\n");
|
|
238
|
+
} else {
|
|
239
|
+
console.log(
|
|
240
|
+
" GitHub Token: none — using unauthenticated GitHub API (60 requests/hour). Set GITHUB_TOKEN to raise the limit.",
|
|
241
|
+
"\r\n",
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
200
246
|
|
|
201
247
|
// Add validated-links.txt to .gitignore if it doesn't exist
|
|
202
248
|
const gitignorePath = path.join(source_path, ".gitignore");
|