single-file-cli 2.6.0 → 2.6.2
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/.github/workflows/ci.yml +24 -0
- package/build-dev.sh +35 -14
- package/build.sh +1 -1
- package/deno.json +1 -1
- package/eslint.config.mjs +1 -1
- package/lib/cdp-client.js +29 -18
- package/lib/single-file-archive.js +5 -5
- package/lib/single-file-bundle.js +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -1
- package/test/e2e/automation-detection.test.js +2 -3
- package/test/e2e/backend-fetch.test.js +91 -0
- package/test/e2e/blocked-url-pattern.test.js +2 -3
- package/test/e2e/browser-profile.test.js +2 -3
- package/test/e2e/compress-content.test.js +3 -4
- package/test/e2e/crawl-save-archive.test.js +3 -4
- package/test/e2e/crawl.test.js +2 -3
- package/test/e2e/errors-file.test.js +2 -3
- package/test/e2e/frame-gate.test.js +2 -3
- package/test/e2e/http-header.test.js +2 -3
- package/test/e2e/oopif.test.js +2 -3
- package/test/e2e/output-json.test.js +2 -3
- package/test/e2e/service-worker.test.js +2 -3
- package/test/e2e/timeouts.test.js +2 -3
- package/test/e2e/urls-file.test.js +2 -3
- package/test/target.js +32 -0
- package/test/unit/archive-packager.test.js +2 -1
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.6.
|
|
1
|
+
export const version = "2.6.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "single-file-cli",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "SingleFile CLI",
|
|
5
5
|
"author": "Gildas Lormeau",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"type": "module",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "node --test --test-concurrency=2 \"test/**/*.test.js\"",
|
|
19
|
+
"test:dev": "SINGLE_FILE_TARGET=dev node --test --test-concurrency=2 \"test/**/*.test.js\"",
|
|
19
20
|
"lint": "eslint ."
|
|
20
21
|
},
|
|
21
22
|
"bin": {
|
|
@@ -5,12 +5,11 @@ import { execFile } from "node:child_process";
|
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { join
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { join } from "node:path";
|
|
10
9
|
import process from "node:process";
|
|
10
|
+
import { cliDirectory } from "../target.js";
|
|
11
11
|
|
|
12
12
|
const execFileAsync = promisify(execFile);
|
|
13
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
14
13
|
|
|
15
14
|
test("pages are not captured as controlled by automation", { timeout: 120000 }, async () => {
|
|
16
15
|
const server = createServer((_, response) => response
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* global URL */
|
|
2
|
+
|
|
3
|
+
import { test } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { createServer } from "node:http";
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import process from "node:process";
|
|
12
|
+
import { cliDirectory } from "../target.js";
|
|
13
|
+
|
|
14
|
+
const execFileAsync = promisify(execFile);
|
|
15
|
+
|
|
16
|
+
test("the backend fetch presents the same user agent as the browser", { timeout: 120000 }, async () => {
|
|
17
|
+
const requests = [];
|
|
18
|
+
// no access-control-allow-origin, so the browser sends the request, refuses the
|
|
19
|
+
// response and the page falls back to the fetch made outside the browser
|
|
20
|
+
const resourceServer = createServer((request, response) => {
|
|
21
|
+
const { pathname } = new URL(request.url, "http://127.0.0.1");
|
|
22
|
+
requests.push({ headers: request.headers });
|
|
23
|
+
if (pathname === "/cors.css") {
|
|
24
|
+
response.writeHead(200, { "content-type": "text/css" }).end("h2 { color: rgb(11,22,33); }");
|
|
25
|
+
} else {
|
|
26
|
+
response.writeHead(404).end();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
await new Promise(resolve => resourceServer.listen(0, "127.0.0.1", resolve));
|
|
30
|
+
const styleUrl = "http://127.0.0.1:" + resourceServer.address().port + "/cors.css";
|
|
31
|
+
const server = createServer((request, response) => {
|
|
32
|
+
response.writeHead(200, { "content-type": "text/html" }).end(
|
|
33
|
+
"<html><head><link rel=\"stylesheet\" href=\"" + styleUrl + "\"></head><body><h2>styled</h2></body></html>");
|
|
34
|
+
});
|
|
35
|
+
await new Promise(resolve => server.listen(0, "localhost", resolve));
|
|
36
|
+
const directory = await mkdtemp(join(tmpdir(), "single-file-test-"));
|
|
37
|
+
try {
|
|
38
|
+
const outputPath = join(directory, "out.html");
|
|
39
|
+
const url = "http://localhost:" + server.address().port + "/top.html";
|
|
40
|
+
await execFileAsync(process.execPath, ["single-file-node.js", url, outputPath], { cwd: cliDirectory });
|
|
41
|
+
// the fetch made outside the browser sends no sec-fetch-dest; it does send
|
|
42
|
+
// sec-fetch-mode, which node sets on every request, so that one tells nothing
|
|
43
|
+
const browserRequest = requests.find(({ headers }) => headers["sec-fetch-dest"] !== undefined);
|
|
44
|
+
const backendRequest = requests.find(({ headers }) => headers["sec-fetch-dest"] === undefined);
|
|
45
|
+
assert.ok(browserRequest, "the resource was not fetched by the browser");
|
|
46
|
+
assert.ok(backendRequest, "the resource was not fetched outside the browser");
|
|
47
|
+
assert.equal(backendRequest.headers["user-agent"], browserRequest.headers["user-agent"],
|
|
48
|
+
"the backend fetch presented another user agent than the browser");
|
|
49
|
+
} finally {
|
|
50
|
+
await rm(directory, { recursive: true });
|
|
51
|
+
server.close();
|
|
52
|
+
resourceServer.close();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("the backend fetch presents the user agent given on the command line", { timeout: 120000 }, async () => {
|
|
57
|
+
const USER_AGENT = "SingleFileProbe/1.0";
|
|
58
|
+
const requests = [];
|
|
59
|
+
const resourceServer = createServer((request, response) => {
|
|
60
|
+
const { pathname } = new URL(request.url, "http://127.0.0.1");
|
|
61
|
+
requests.push({ headers: request.headers });
|
|
62
|
+
if (pathname === "/cors.css") {
|
|
63
|
+
response.writeHead(200, { "content-type": "text/css" }).end("h2 { color: rgb(11,22,33); }");
|
|
64
|
+
} else {
|
|
65
|
+
response.writeHead(404).end();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
await new Promise(resolve => resourceServer.listen(0, "127.0.0.1", resolve));
|
|
69
|
+
const styleUrl = "http://127.0.0.1:" + resourceServer.address().port + "/cors.css";
|
|
70
|
+
const server = createServer((request, response) => {
|
|
71
|
+
response.writeHead(200, { "content-type": "text/html" }).end(
|
|
72
|
+
"<html><head><link rel=\"stylesheet\" href=\"" + styleUrl + "\"></head><body><h2>styled</h2></body></html>");
|
|
73
|
+
});
|
|
74
|
+
await new Promise(resolve => server.listen(0, "localhost", resolve));
|
|
75
|
+
const directory = await mkdtemp(join(tmpdir(), "single-file-test-"));
|
|
76
|
+
try {
|
|
77
|
+
const outputPath = join(directory, "out.html");
|
|
78
|
+
const url = "http://localhost:" + server.address().port + "/top.html";
|
|
79
|
+
await execFileAsync(process.execPath, [
|
|
80
|
+
"single-file-node.js", url, outputPath,
|
|
81
|
+
"--user-agent", USER_AGENT
|
|
82
|
+
], { cwd: cliDirectory });
|
|
83
|
+
assert.ok(requests.length, "the resource was not fetched");
|
|
84
|
+
assert.ok(requests.every(({ headers }) => headers["user-agent"] === USER_AGENT),
|
|
85
|
+
"a request presented another user agent: " + JSON.stringify(requests.map(({ headers }) => headers["user-agent"])));
|
|
86
|
+
} finally {
|
|
87
|
+
await rm(directory, { recursive: true });
|
|
88
|
+
server.close();
|
|
89
|
+
resourceServer.close();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
@@ -7,12 +7,11 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
12
|
+
import { cliDirectory } from "../target.js";
|
|
13
13
|
|
|
14
14
|
const execFileAsync = promisify(execFile);
|
|
15
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
16
15
|
|
|
17
16
|
test("a blocked URL is never requested", { timeout: 120000 }, async () => {
|
|
18
17
|
const BLOCKED_STYLE = "rgb(123,45,67)";
|
|
@@ -5,12 +5,11 @@ import { execFile } from "node:child_process";
|
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { mkdtemp, mkdir, readdir, readFile, writeFile, rm } from "node:fs/promises";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { join
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { join } from "node:path";
|
|
10
9
|
import process from "node:process";
|
|
10
|
+
import { cliDirectory } from "../target.js";
|
|
11
11
|
|
|
12
12
|
const execFileAsync = promisify(execFile);
|
|
13
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
14
13
|
|
|
15
14
|
test("a browser profile is copied and left unmodified by a capture", { timeout: 120000 }, async () => {
|
|
16
15
|
const server = createServer((_, response) => response
|
|
@@ -7,13 +7,12 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
13
|
-
|
|
12
|
+
const { configure, ZipReader, Uint8ArrayReader } = await importLibModule("single-file-archive.js");
|
|
13
|
+
import { cliDirectory, importLibModule } from "../target.js";
|
|
14
14
|
|
|
15
15
|
const execFileAsync = promisify(execFile);
|
|
16
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
17
16
|
const TEST_TIMEOUT = 120000;
|
|
18
17
|
const END_OF_CENTRAL_DIRECTORY_SIGNATURE = 0x06054b50;
|
|
19
18
|
const END_OF_CENTRAL_DIRECTORY_LENGTH = 22;
|
|
@@ -7,13 +7,12 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readdir, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
13
|
-
|
|
12
|
+
const { configure, ZipReader, Uint8ArrayReader, TextWriter } = await importLibModule("single-file-archive.js");
|
|
13
|
+
import { cliDirectory, importLibModule } from "../target.js";
|
|
14
14
|
|
|
15
15
|
const execFileAsync = promisify(execFile);
|
|
16
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
17
16
|
const TEST_TIMEOUT = 120000;
|
|
18
17
|
|
|
19
18
|
const crawlPromises = new Map();
|
package/test/e2e/crawl.test.js
CHANGED
|
@@ -7,12 +7,11 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readdir, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
12
|
+
import { cliDirectory } from "../target.js";
|
|
13
13
|
|
|
14
14
|
const execFileAsync = promisify(execFile);
|
|
15
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
16
15
|
const TEST_TIMEOUT = 120000;
|
|
17
16
|
|
|
18
17
|
let crawlPromise;
|
|
@@ -4,12 +4,11 @@ import { execFile } from "node:child_process";
|
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
|
-
import { join
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { join } from "node:path";
|
|
9
8
|
import process from "node:process";
|
|
9
|
+
import { cliDirectory } from "../target.js";
|
|
10
10
|
|
|
11
11
|
const execFileAsync = promisify(execFile);
|
|
12
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
13
12
|
|
|
14
13
|
test("errors file lines include the error message and the exit code is nonzero", { timeout: 120000 }, async () => {
|
|
15
14
|
const directory = await mkdtemp(join(tmpdir(), "single-file-test-"));
|
|
@@ -7,13 +7,12 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import { Buffer } from "node:buffer";
|
|
13
12
|
import process from "node:process";
|
|
13
|
+
import { cliDirectory } from "../target.js";
|
|
14
14
|
|
|
15
15
|
const execFileAsync = promisify(execFile);
|
|
16
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
17
16
|
const LOAD_MARKER = "MARKER_ADDED_AFTER_LOAD_EVENT";
|
|
18
17
|
const SLOW_RESOURCE_DELAY = 3500;
|
|
19
18
|
const PIXEL_PNG = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==", "base64");
|
|
@@ -7,12 +7,11 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
12
|
+
import { cliDirectory } from "../target.js";
|
|
13
13
|
|
|
14
14
|
const execFileAsync = promisify(execFile);
|
|
15
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
16
15
|
|
|
17
16
|
test("extra HTTP headers do not make cross-origin resources send a preflight", { timeout: 120000 }, async () => {
|
|
18
17
|
const STYLE = "rgb(11,22,33)";
|
package/test/e2e/oopif.test.js
CHANGED
|
@@ -7,12 +7,11 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
12
|
+
import { cliDirectory } from "../target.js";
|
|
13
13
|
|
|
14
14
|
const execFileAsync = promisify(execFile);
|
|
15
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
16
15
|
const FRAME_MARKER = "OUT_OF_PROCESS_FRAME_CONTENT";
|
|
17
16
|
|
|
18
17
|
test("blocked URL patterns and extra HTTP headers apply in cross-origin frames", { timeout: 120000 }, async () => {
|
|
@@ -5,13 +5,12 @@ import { execFile } from "node:child_process";
|
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { join
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { join } from "node:path";
|
|
10
9
|
import { Buffer } from "node:buffer";
|
|
11
10
|
import process from "node:process";
|
|
11
|
+
import { cliDirectory } from "../target.js";
|
|
12
12
|
|
|
13
13
|
const execFileAsync = promisify(execFile);
|
|
14
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
15
14
|
const ZIP_SIGNATURE = "PK\u0003\u0004";
|
|
16
15
|
|
|
17
16
|
test("output-json embeds compressed content as base64", { timeout: 120000 }, async () => {
|
|
@@ -7,12 +7,11 @@ import { execFile } from "node:child_process";
|
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { join
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { join } from "node:path";
|
|
12
11
|
import process from "node:process";
|
|
12
|
+
import { cliDirectory } from "../target.js";
|
|
13
13
|
|
|
14
14
|
const execFileAsync = promisify(execFile);
|
|
15
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
16
15
|
|
|
17
16
|
// the worker fetches a marked URL instead of passing the request through, so a
|
|
18
17
|
// request reaching the server proves the service worker is the one that made it
|
|
@@ -8,12 +8,11 @@ import { promisify } from "node:util";
|
|
|
8
8
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
9
9
|
import { Buffer } from "node:buffer";
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
11
|
-
import { join
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { join } from "node:path";
|
|
13
12
|
import process from "node:process";
|
|
13
|
+
import { cliDirectory } from "../target.js";
|
|
14
14
|
|
|
15
15
|
const execFileAsync = promisify(execFile);
|
|
16
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
17
16
|
|
|
18
17
|
test("load timeout is reported when the page never loads", { timeout: 120000 }, async () => {
|
|
19
18
|
const server = createServer(() => { });
|
|
@@ -5,12 +5,11 @@ import { execFile } from "node:child_process";
|
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { join
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { join } from "node:path";
|
|
10
9
|
import process from "node:process";
|
|
10
|
+
import { cliDirectory } from "../target.js";
|
|
11
11
|
|
|
12
12
|
const execFileAsync = promisify(execFile);
|
|
13
|
-
const cliDirectory = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
14
13
|
|
|
15
14
|
test("duplicate urls in a urls file are captured once", { timeout: 120000 }, async () => {
|
|
16
15
|
const server = createServer((_, response) => response
|
package/test/target.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Which directory the e2e tests spawn the CLI from decides what they actually prove. By default it
|
|
2
|
+
// is the repository root, which runs the committed lib/ — a build of the *pinned npm release* of
|
|
3
|
+
// single-file-core. So after fixing something in a local single-file-core checkout, a green suite
|
|
4
|
+
// here says nothing about the fix: the tests never loaded that code.
|
|
5
|
+
//
|
|
6
|
+
// SINGLE_FILE_TARGET=dev points them at .dev/ instead, the tree build-dev.sh stages from
|
|
7
|
+
// ../single-file-core. Same suite, same assertions, against the unreleased core:
|
|
8
|
+
//
|
|
9
|
+
// ./build-dev.sh && npm run test:dev
|
|
10
|
+
//
|
|
11
|
+
// The missing-directory check is deliberately loud. A silent fallback to the repository root would
|
|
12
|
+
// reintroduce exactly the failure this exists to prevent — tests passing against the wrong code.
|
|
13
|
+
import { join, dirname } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import process from "node:process";
|
|
17
|
+
|
|
18
|
+
const repositoryDirectory = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
19
|
+
const useDevBuild = process.env.SINGLE_FILE_TARGET === "dev";
|
|
20
|
+
const cliDirectory = useDevBuild ? join(repositoryDirectory, ".dev") : repositoryDirectory;
|
|
21
|
+
|
|
22
|
+
if (useDevBuild && !existsSync(join(cliDirectory, "lib", "single-file-bundle.js"))) {
|
|
23
|
+
throw new Error("SINGLE_FILE_TARGET=dev is set but .dev/ holds no build — run ./build-dev.sh first");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Unit tests import generated modules directly. They have to go through here too, or they keep
|
|
27
|
+
// testing the released build while the e2e tests exercise the dev one.
|
|
28
|
+
function importLibModule(name) {
|
|
29
|
+
return import(join(cliDirectory, "lib", name));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { cliDirectory, repositoryDirectory, useDevBuild, importLibModule };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
|
-
import {
|
|
3
|
+
import { importLibModule } from "../target.js";
|
|
4
|
+
const { createPagesArchive, configure, ZipWriter, ZipReader, Uint8ArrayReader, Uint8ArrayWriter, TextReader, TextWriter } = await importLibModule("single-file-archive.js");
|
|
4
5
|
|
|
5
6
|
configure({ useWebWorkers: false });
|
|
6
7
|
|