voidflow 0.11.0 → 0.12.0
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
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { chmodSync, mkdtempSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* GitHub's ubuntu-24.04 runners disable unprivileged user namespaces via
|
|
7
|
+
* AppArmor, so Chrome aborts at launch ("No usable sandbox!"). Returns a shell
|
|
8
|
+
* wrapper that runs `chrome` with --no-sandbox, for use as CHROME_PATH /
|
|
9
|
+
* PUPPETEER_EXECUTABLE_PATH. Only used in CI, where the browser loads our own
|
|
10
|
+
* static build and nothing untrusted.
|
|
11
|
+
*/
|
|
12
|
+
export function noSandboxWrapper(chrome: string): string {
|
|
13
|
+
const dir = mkdtempSync(join(tmpdir(), 'voidflow-chrome-'))
|
|
14
|
+
const wrapper = join(dir, 'chrome-no-sandbox')
|
|
15
|
+
// Single-quote the path for sh; escape any embedded single quotes.
|
|
16
|
+
const quoted = `'${chrome.replaceAll("'", `'\\''`)}'`
|
|
17
|
+
writeFileSync(wrapper, `#!/bin/sh\nexec ${quoted} --no-sandbox "$@"\n`)
|
|
18
|
+
chmodSync(wrapper, 0o755)
|
|
19
|
+
return wrapper
|
|
20
|
+
}
|
|
@@ -17,6 +17,7 @@ import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
|
17
17
|
import { homedir } from 'node:os'
|
|
18
18
|
import { join, resolve } from 'node:path'
|
|
19
19
|
import { parseArgs } from 'node:util'
|
|
20
|
+
import { noSandboxWrapper } from './chrome.ts'
|
|
20
21
|
|
|
21
22
|
const { values } = parseArgs({
|
|
22
23
|
options: {
|
|
@@ -94,9 +95,21 @@ const site = `http://localhost:${server.port}`
|
|
|
94
95
|
const chrome = findPlaywrightChromium()
|
|
95
96
|
const env: Record<string, string | undefined> = { ...process.env }
|
|
96
97
|
if (chrome) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
// CI runners (ubuntu-24.04) can't create Chrome's sandbox; see chrome.ts.
|
|
99
|
+
// Set VOIDFLOW_CHROME_SANDBOX=1 to keep the sandbox on.
|
|
100
|
+
const launcher =
|
|
101
|
+
process.platform === 'linux' &&
|
|
102
|
+
process.env.CI &&
|
|
103
|
+
!process.env.VOIDFLOW_CHROME_SANDBOX
|
|
104
|
+
? noSandboxWrapper(chrome)
|
|
105
|
+
: chrome
|
|
106
|
+
env.CHROME_PATH = launcher
|
|
107
|
+
env.PUPPETEER_EXECUTABLE_PATH = launcher
|
|
108
|
+
console.log(
|
|
109
|
+
launcher === chrome
|
|
110
|
+
? `Using Chromium: ${chrome}`
|
|
111
|
+
: `Using Chromium: ${chrome} (--no-sandbox for CI)`,
|
|
112
|
+
)
|
|
100
113
|
} else {
|
|
101
114
|
console.log('No Playwright Chromium found; relying on system Chrome lookup.')
|
|
102
115
|
}
|