hdoc-tools 0.56.1 → 0.57.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/.puppeteerrc.cjs +24 -7
- package/hdoc-build.js +25 -2
- package/hdoc-install-browser.js +5 -6
- package/npm-shrinkwrap.json +3 -3
- package/package.json +1 -1
package/.puppeteerrc.cjs
CHANGED
|
@@ -9,13 +9,30 @@
|
|
|
9
9
|
// not where the browser is launched from at runtime.
|
|
10
10
|
const path = require("node:path");
|
|
11
11
|
|
|
12
|
+
// Single source of truth for the browser build and cache location. Both the
|
|
13
|
+
// install script (hdoc-install-browser.js) and the runtime launch
|
|
14
|
+
// (hdoc-build.js) import these so provisioning and launch can never disagree.
|
|
15
|
+
//
|
|
16
|
+
// Keep chromeBuild in lockstep with the puppeteer version in package.json
|
|
17
|
+
// (puppeteer 25.1.0 ships Chrome 149.0.7827.22).
|
|
18
|
+
const chromeBuild = "149.0.7827.22";
|
|
19
|
+
|
|
20
|
+
// Pin a fixed, user-independent cache dir inside the package root. Under a
|
|
21
|
+
// global install, postinstall runs as root (sudo) while `hdoc` later runs as a
|
|
22
|
+
// normal user; os.homedir() resolves to different homes for each, so the old
|
|
23
|
+
// ~/.cache/puppeteer default left the browser in root's home and the runtime
|
|
24
|
+
// launch (a normal user) never found it. Anchoring to __dirname makes
|
|
25
|
+
// install-time provisioning and runtime launch agree on one absolute path.
|
|
26
|
+
//
|
|
27
|
+
// NOTE: Puppeteer only auto-discovers this file via cosmiconfig by searching up
|
|
28
|
+
// from process.cwd(). At install time cwd is the package root, so skipDownload
|
|
29
|
+
// is honored. At runtime cwd is the user's docbook repo, so this file is NEVER
|
|
30
|
+
// found and cacheDir here is ignored — hdoc-build.js therefore computes an
|
|
31
|
+
// explicit executablePath from these exports rather than relying on discovery.
|
|
32
|
+
const cacheDir = path.join(__dirname, ".cache", "puppeteer");
|
|
33
|
+
|
|
12
34
|
module.exports = {
|
|
13
35
|
skipDownload: true,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// a normal user; os.homedir() resolves to different homes for each, so the
|
|
17
|
-
// old ~/.cache/puppeteer default left the browser in root's home and the
|
|
18
|
-
// runtime launch (a normal user) never found it. Anchoring to __dirname makes
|
|
19
|
-
// install-time provisioning and runtime launch agree on one absolute path.
|
|
20
|
-
cacheDir: path.join(__dirname, ".cache", "puppeteer"),
|
|
36
|
+
cacheDir,
|
|
37
|
+
chromeBuild,
|
|
21
38
|
};
|
package/hdoc-build.js
CHANGED
|
@@ -1331,8 +1331,31 @@
|
|
|
1331
1331
|
// Get a list of MD files in work_path
|
|
1332
1332
|
hdoc.scan_dir(work_path, dreeOptions, build_file_callback);
|
|
1333
1333
|
|
|
1334
|
-
// Create a Chromium browser instance generate PDFs and validate links with
|
|
1335
|
-
|
|
1334
|
+
// Create a Chromium browser instance generate PDFs and validate links with.
|
|
1335
|
+
// Resolve the executable explicitly from the browser cache provisioned by
|
|
1336
|
+
// hdoc-install-browser.js. We cannot rely on Puppeteer auto-discovering
|
|
1337
|
+
// .puppeteerrc.cjs at runtime: cosmiconfig searches up from process.cwd()
|
|
1338
|
+
// (the user's docbook repo), never the global node_modules where our config
|
|
1339
|
+
// and cache live, so Puppeteer would fall back to ~/.cache/puppeteer and
|
|
1340
|
+
// fail with "Could not find Chrome". headless:"shell" launches
|
|
1341
|
+
// chrome-headless-shell, so resolve that binary specifically.
|
|
1342
|
+
const {
|
|
1343
|
+
computeExecutablePath,
|
|
1344
|
+
detectBrowserPlatform,
|
|
1345
|
+
Browser,
|
|
1346
|
+
} = require("@puppeteer/browsers");
|
|
1347
|
+
const puppeteerConfig = require(path.join(__dirname, ".puppeteerrc.cjs"));
|
|
1348
|
+
const executablePath = computeExecutablePath({
|
|
1349
|
+
browser: Browser.CHROMEHEADLESSSHELL,
|
|
1350
|
+
buildId: puppeteerConfig.chromeBuild,
|
|
1351
|
+
cacheDir: process.env.PUPPETEER_CACHE_DIR || puppeteerConfig.cacheDir,
|
|
1352
|
+
platform: detectBrowserPlatform(),
|
|
1353
|
+
});
|
|
1354
|
+
browser = await puppeteer.launch({
|
|
1355
|
+
headless: "shell",
|
|
1356
|
+
executablePath,
|
|
1357
|
+
args: ['--no-sandbox'],
|
|
1358
|
+
});
|
|
1336
1359
|
|
|
1337
1360
|
// Work through MD files and convert to HTML
|
|
1338
1361
|
const mdPromiseArray = [];
|
package/hdoc-install-browser.js
CHANGED
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
Browser,
|
|
29
29
|
} = require("@puppeteer/browsers");
|
|
30
30
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
const
|
|
31
|
+
// Build id + cache dir come from the shared .puppeteerrc.cjs so install and
|
|
32
|
+
// runtime launch can never drift apart.
|
|
33
|
+
const puppeteerConfig = require(path.join(__dirname, ".puppeteerrc.cjs"));
|
|
34
|
+
const CHROME_BUILD = puppeteerConfig.chromeBuild;
|
|
34
35
|
const MAX_ATTEMPTS = 3;
|
|
35
36
|
|
|
36
37
|
const RED = "\x1b[31m";
|
|
@@ -46,9 +47,7 @@
|
|
|
46
47
|
// os.homedir()) guarantees we install to exactly the path the browser is
|
|
47
48
|
// later launched from — critical for `sudo npm i -g`, where postinstall runs
|
|
48
49
|
// as root but `hdoc` runs as a normal user with a different home directory.
|
|
49
|
-
const cacheDir =
|
|
50
|
-
process.env.PUPPETEER_CACHE_DIR ||
|
|
51
|
-
require(path.join(__dirname, ".puppeteerrc.cjs")).cacheDir;
|
|
50
|
+
const cacheDir = process.env.PUPPETEER_CACHE_DIR || puppeteerConfig.cacheDir;
|
|
52
51
|
|
|
53
52
|
let platform;
|
|
54
53
|
try {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hdoc-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "hdoc-tools",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.57.1",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"archiver": "8.0.0",
|
|
16
16
|
"better-sqlite3": "12.11.1",
|
|
17
17
|
"cheerio": "1.2.0",
|
|
18
|
-
"compression": "
|
|
18
|
+
"compression": "1.8.1",
|
|
19
19
|
"express": "5.2.1",
|
|
20
20
|
"markdown-it": "14.2.0",
|
|
21
21
|
"markdown-it-container": "4.0.0",
|