Reference site: Example Studio on ipal-kit (reference/), index for agents, CI job
reference/ is one complete client site on the plugin (made-up company, pl/en, MongoDB, every library block and template, token standard light/dark, forms, consent, SEO/GEO, enforced CSP, 2FA, base + demo seeds, Coolify runbook, smoke tests). It uses the plugin as file:.. (injected) and is not shipped. - docs/agent/reference-site/INDEX.md (generated by scripts/reference-index.mjs, kept current by test/referenceIndex.test.ts) - AGENT.md section and pointers in ipal-site, ipal-setup, ipal-reference, ipal-upgrade, ipal-block; release steps in PROGRAMISTA §8.1b - CI: reference (fast) on every push, reference-full on main; doctor steps wired, commented until ipal-doctor ships Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8bb5ebd394
commit
8adac41f92
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Creates (or resets) the smoke-test admin with a known TOTP secret, so e2e/smoke.spec.ts signs in through
|
||||
* the real 2FA screen instead of skipping it. LOCAL / CI database only:
|
||||
* pnpm payload run e2e/create-test-admin.ts
|
||||
* Values come from E2E_ADMIN_EMAIL / E2E_ADMIN_PASSWORD / E2E_TOTP_SECRET (.env.example). Not a seed: seeds
|
||||
* never create users (docs/seeding.md).
|
||||
*/
|
||||
import config from '@payload-config'
|
||||
import { isLocalDatabase } from '@intecion/ipal-kit/seed'
|
||||
import { getPayload } from 'payload'
|
||||
|
||||
const { E2E_ADMIN_EMAIL: email, E2E_ADMIN_PASSWORD: password, E2E_TOTP_SECRET: totpSecret } = process.env
|
||||
if (!email || !password || !totpSecret) {throw new Error('Set E2E_ADMIN_EMAIL, E2E_ADMIN_PASSWORD and E2E_TOTP_SECRET (.env.example).')}
|
||||
if (process.env.NODE_ENV === 'production' && !process.env.CI) {throw new Error('Refusing: NODE_ENV=production outside CI.')}
|
||||
if (!isLocalDatabase(process.env.DATABASE_URI ?? '')) {throw new Error('Refusing: DATABASE_URI is not a local database.')}
|
||||
|
||||
const payload = await getPayload({ config })
|
||||
const data = { email, hasTotp: true, password, roles: ['admin'], totpSecret }
|
||||
const found = await payload.find({ collection: 'users', limit: 1, overrideAccess: true, where: { email: { equals: email } } })
|
||||
if (found.docs[0]) {
|
||||
await payload.update({ id: found.docs[0].id, collection: 'users', data: data as never, overrideAccess: true })
|
||||
} else {
|
||||
await payload.create({ collection: 'users', data: data as never, overrideAccess: true })
|
||||
}
|
||||
console.log(`[e2e] test admin ready: ${email}`)
|
||||
process.exit(0)
|
||||
Reference in New Issue
Block a user