F-3: pnpm e2e:built puts the reference site's generated files back, also on failure
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
e77c607bca
commit
01219b69d3
+17
-1
@@ -13,10 +13,12 @@
|
||||
* Needs what the reference site's "Production check" needs (reference/README.md): reference/.env with a local,
|
||||
* seeded database and the E2E_* test admin. The test admins are reset by Playwright's global setup.
|
||||
* Port: E2E_BASE_URL (default http://localhost:3100), the same value as NEXT_PUBLIC_SERVER_URL in reference/.env.
|
||||
* The reference site's generated files (payload-types.ts, the import map) are put back as they were at the end,
|
||||
* also when a step fails: the working tree is the same after the run.
|
||||
* Options: --only=webpack | --only=turbopack; --skip-plugin-build (dist and the injected copy are current).
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
||||
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
@@ -48,6 +50,20 @@ if (!args.includes('--skip-plugin-build')) {
|
||||
run('build the plugin', 'pnpm', ['build'], root)
|
||||
run('refresh the plugin copy in the reference site', 'pnpm', ['install', '--ignore-workspace'], site)
|
||||
}
|
||||
// The run starts Payload with the fixture's collections, and Payload rewrites the site's generated types then. The
|
||||
// tree must be as it was after a required release step: the file is put back at the end — also when a step fails.
|
||||
const generated = ['src/payload-types.ts', 'src/app/(payload)/admin/importMap.js'].map((rel) => path.join(site, rel)).filter((file) => existsSync(file)).map((file) => ({ before: readFileSync(file), file }))
|
||||
const restore = () => {
|
||||
for (const { before, file } of generated) {
|
||||
if (!existsSync(file) || !readFileSync(file).equals(before)) {
|
||||
writeFileSync(file, before)
|
||||
console.log(`[e2e:built] restored ${path.relative(root, file)} (rewritten with the fixture's collections during the run)`)
|
||||
}
|
||||
}
|
||||
}
|
||||
process.on('exit', restore)
|
||||
for (const signal of ['SIGINT', 'SIGTERM']) {process.on(signal, () => process.exit(130))}
|
||||
|
||||
const fixture = { E2E_LATE_STAFF: '1', NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ''} --max-old-space-size=3072`.trim() }
|
||||
const passed = []
|
||||
for (const bundler of bundlers) {
|
||||
|
||||
Reference in New Issue
Block a user