doc-detective 4.0.0-beta.1-dev.8 → 4.0.1-dev.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/package.json +1 -1
- package/scripts/createCjsWrapper.js +31 -0
- package/scripts/postinstall.js +98 -0
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { build } from "esbuild";
|
|
2
|
+
import { copyFile } from "fs/promises";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const distDir = path.join(__dirname, "..", "dist");
|
|
9
|
+
|
|
10
|
+
await build({
|
|
11
|
+
entryPoints: [path.join(distDir, "index.js")],
|
|
12
|
+
outfile: path.join(distDir, "index.cjs"),
|
|
13
|
+
bundle: true,
|
|
14
|
+
format: "cjs",
|
|
15
|
+
platform: "node",
|
|
16
|
+
packages: "external",
|
|
17
|
+
define: {
|
|
18
|
+
"import.meta.url": "importMetaUrl",
|
|
19
|
+
},
|
|
20
|
+
banner: {
|
|
21
|
+
js: "const importMetaUrl = require('url').pathToFileURL(__filename).href;",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
await copyFile(
|
|
26
|
+
path.join(distDir, "index.d.ts"),
|
|
27
|
+
path.join(distDir, "index.d.cts")
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
console.log("Created CJS bundle at dist/index.cjs");
|
|
31
|
+
console.log("Copied type definitions to dist/index.d.cts");
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import * as browsers from "@puppeteer/browsers";
|
|
4
|
+
import * as geckodriver from "geckodriver";
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await installBrowsers();
|
|
10
|
+
// await installAppiumDepencencies();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
main();
|
|
14
|
+
|
|
15
|
+
async function installBrowsers() {
|
|
16
|
+
// Move to package root directory to correctly set browser snapshot directory
|
|
17
|
+
let cwd = process.cwd();
|
|
18
|
+
process.chdir(path.join(__dirname, ".."));
|
|
19
|
+
|
|
20
|
+
// Meta
|
|
21
|
+
const browser_platform = browsers.detectBrowserPlatform();
|
|
22
|
+
const cacheDir = path.resolve("browser-snapshots");
|
|
23
|
+
|
|
24
|
+
// Install Chrome
|
|
25
|
+
try {
|
|
26
|
+
console.log("Installing Chrome browser");
|
|
27
|
+
let browser = "chrome";
|
|
28
|
+
let buildId = await browsers.resolveBuildId(
|
|
29
|
+
browser,
|
|
30
|
+
browser_platform,
|
|
31
|
+
"stable"
|
|
32
|
+
);
|
|
33
|
+
await browsers.install({
|
|
34
|
+
browser,
|
|
35
|
+
buildId,
|
|
36
|
+
cacheDir,
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.log("Chrome download not available.", error);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Install Firefox
|
|
43
|
+
try {
|
|
44
|
+
console.log("Installing Firefox browser");
|
|
45
|
+
let browser = "firefox";
|
|
46
|
+
let buildId = await browsers.resolveBuildId(
|
|
47
|
+
browser,
|
|
48
|
+
browser_platform,
|
|
49
|
+
"latest"
|
|
50
|
+
);
|
|
51
|
+
await browsers.install({
|
|
52
|
+
browser,
|
|
53
|
+
buildId,
|
|
54
|
+
cacheDir,
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.log("Firefox download not available.", error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Install ChromeDriver
|
|
61
|
+
try {
|
|
62
|
+
console.log("Installing ChromeDriver binary");
|
|
63
|
+
let browser = "chromedriver";
|
|
64
|
+
let buildId = await browsers.resolveBuildId(
|
|
65
|
+
browser,
|
|
66
|
+
browser_platform,
|
|
67
|
+
"stable"
|
|
68
|
+
);
|
|
69
|
+
await browsers.install({
|
|
70
|
+
browser,
|
|
71
|
+
buildId,
|
|
72
|
+
cacheDir,
|
|
73
|
+
});
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.log("ChromeDriver download not available.", error);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Install Geckodriver
|
|
79
|
+
try {
|
|
80
|
+
console.log("Installing Geckodriver binary");
|
|
81
|
+
let binPath;
|
|
82
|
+
if (__dirname.includes("AppData\\Roaming\\")) {
|
|
83
|
+
// Running from global install on Windows
|
|
84
|
+
binPath = path.join(__dirname.split("node_modules")[0]);
|
|
85
|
+
} else if (__dirname.includes("node_modules")) {
|
|
86
|
+
// If running from node_modules
|
|
87
|
+
binPath = path.join(__dirname, "../../.bin");
|
|
88
|
+
} else {
|
|
89
|
+
binPath = path.join(__dirname, "../node_modules/.bin");
|
|
90
|
+
}
|
|
91
|
+
process.env.GECKODRIVER_CACHE_DIR = binPath;
|
|
92
|
+
await geckodriver.download();
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.log("Geckodriver download not available.", error);
|
|
95
|
+
}
|
|
96
|
+
// Move back to original directory
|
|
97
|
+
process.chdir(cwd);
|
|
98
|
+
}
|