@taraxvoid/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/README.md +15 -6
- package/package.json +1 -1
- package/scripts/unlighthouse/chrome.ts +20 -0
- package/scripts/unlighthouse/run.ts +16 -3
package/README.md
CHANGED
|
@@ -107,10 +107,11 @@ static directory on a free port and runs
|
|
|
107
107
|
[Unlighthouse](https://unlighthouse.dev/) against it, reusing Playwright's
|
|
108
108
|
Chromium. It exits non-zero if a category budget in the site's config fails.
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
Add `@taraxvoid/voidflow` as a devDependency and call the bin from the site's
|
|
111
|
+
`package.json`:
|
|
111
112
|
|
|
112
113
|
```json
|
|
113
|
-
"test:e2e:lighthouse": "bun run build &&
|
|
114
|
+
"test:e2e:lighthouse": "bun run build && unlighthouse-runner --dir dist"
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
Options: `--dir` (default `dist`, use `dist/client` for Cloudflare adapter
|
|
@@ -126,12 +127,20 @@ change. Sites implement that script with the shared check, which runs
|
|
|
126
127
|
`license-checker` in the site's repo root and fails on GPL, AGPL, SSPL and
|
|
127
128
|
similar copyleft licenses (LGPL is allowed).
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
With `@taraxvoid/voidflow` as a devDependency, call the bin from the site's
|
|
131
|
+
`package.json`:
|
|
130
132
|
|
|
131
133
|
```json
|
|
132
|
-
"check:licenses": "
|
|
134
|
+
"check:licenses": "check-licenses"
|
|
133
135
|
```
|
|
134
136
|
|
|
137
|
+
Don't use `bunx --package @taraxvoid/voidflow@<version> ...` for these. It
|
|
138
|
+
duplicates the version pin outside the lockfile and Renovate, and `bunx` reads
|
|
139
|
+
the global `~/.bunfig.toml` rather than the site's, so a global
|
|
140
|
+
`minimumReleaseAge` that doesn't exclude `@taraxvoid/voidflow` blocks it
|
|
141
|
+
locally (including in the pre-commit hook) for 3 days after every release.
|
|
142
|
+
The devDependency's bins are installed under the site's own `bunfig.toml`.
|
|
143
|
+
|
|
135
144
|
### Playwright preview config
|
|
136
145
|
|
|
137
146
|
Shared `playwright.config` for Astro sites that run e2e against
|
|
@@ -182,12 +191,12 @@ remote's `ref` tag, and tool versions in a `justfile` (annotate the line above
|
|
|
182
191
|
with `# renovate: datasource=... depName=...`). Requires the Renovate GitHub App
|
|
183
192
|
on the repo.
|
|
184
193
|
|
|
185
|
-
||||||| 4041a59
|
|
186
194
|
## Git hooks (lefthook)
|
|
187
195
|
|
|
188
196
|
[`lefthook/site.yml`](lefthook/site.yml) is the shared hook set for the site
|
|
189
197
|
stack, consumed as a lefthook remote. It calls the site's own `package.json`
|
|
190
|
-
scripts (
|
|
198
|
+
scripts (`<pm> run --if-present`, so a missing script is skipped; `<pm>` is pnpm
|
|
199
|
+
when the repo has a `pnpm-lock.yaml`, bun otherwise):
|
|
191
200
|
|
|
192
201
|
- `pre-commit`: dependency guard, `format` (formatted files are re-staged),
|
|
193
202
|
`lint:actions`, `check`, `test:unit`, and `check:licenses` / `audit` when the
|
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
|
}
|