mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-03 22:13:06 +00:00
Compare commits
6 commits
0832dd5ca7
...
c5aef80a12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5aef80a12 | ||
|
|
a5dc06ad80 | ||
|
|
dd4f9d8b99 | ||
|
|
493f4ba997 | ||
|
|
4d6533c040 | ||
|
|
81513d5b14 |
18 changed files with 341 additions and 535 deletions
2
.github/workflows/ci-pr.yml
vendored
2
.github/workflows/ci-pr.yml
vendored
|
|
@ -132,8 +132,6 @@ jobs:
|
|||
GITHUB_BASE_REF: ${{ github.base_ref }}
|
||||
PR_BODY: ${{ github.event.pull_request.body }}
|
||||
run: node scripts/check-plans-only-pr-closes.mjs
|
||||
- name: ImportMap keeps the S3 upload handler
|
||||
run: node scripts/check-importmap-s3.mjs
|
||||
|
||||
- name: Check test file locations
|
||||
run: node scripts/check-test-locations.mjs
|
||||
|
|
|
|||
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
|
|
@ -73,8 +73,6 @@ jobs:
|
|||
|
||||
- name: Check test file locations
|
||||
run: node scripts/check-test-locations.mjs
|
||||
- name: ImportMap keeps the S3 upload handler
|
||||
run: node scripts/check-importmap-s3.mjs
|
||||
- name: Lint
|
||||
run: pnpm lint
|
||||
- name: Format check
|
||||
|
|
|
|||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -26,6 +26,12 @@
|
|||
/.next-e2e-check/
|
||||
/out/
|
||||
|
||||
# Payload importMap (OPS99: build artifact, not committed)
|
||||
/src/app/(payload)/admin/importMap.js
|
||||
|
||||
# OPS99: removed guard script (importMap now generated at build time)
|
||||
/scripts/check-importmap-s3.mjs
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ These are product/architecture constraints — not a ban on editing existing cod
|
|||
### Code Validation
|
||||
|
||||
- To validate typescript correctness after modifying code run `tsc --noEmit`
|
||||
- Generate import maps after creating or modifying components. **Always set the 4 `S3_*` envs (dummy values ok) when running `pnpm generate:importmap`** — without them the generator orphans `@payloadcms/storage-s3/client#S3ClientUploadHandler` and the admin goes blank in production (class OPS69/OPS72/OPS73; `scripts/check-importmap-s3.mjs` + the `importMapS3UploadHandler` unit pin guard this in CI).
|
||||
- **ImportMap is a build artifact (OPS99):** Generated at build time (Dockerfile with dummy S3\_\* envs) and dev time (`pnpm predev`). Never commit `src/app/(payload)/admin/importMap.js` to git — it's in `.gitignore`. The `pnpm predev` hook ensures it exists before `pnpm dev` starts. If you need to regenerate manually, run: `S3_BUCKET=x S3_ENDPOINT=http://127.0.0.1:3900 S3_ACCESS_KEY_ID=x S3_SECRET_ACCESS_KEY=x pnpm generate:importmap`
|
||||
- Any change to a collection/global/field schema requires a migration: `pnpm migrate:create <name>`, then `pnpm migrate` locally. Never rely on `push` (it is `false`). See the `payload-migrations` skill.
|
||||
|
||||
## Project Structure
|
||||
|
|
|
|||
10
Dockerfile
10
Dockerfile
|
|
@ -35,10 +35,20 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||
# layers and image history; migrations run separately through the migrator —
|
||||
# the deploy script applies them BEFORE this build (OPS66: static routes read
|
||||
# the new schema, so the build must see a migrated DB).
|
||||
#
|
||||
# OPS99: Generate importMap with dummy S3_* envs BEFORE next build.
|
||||
# This ensures the production image always has the S3ClientUploadHandler entry,
|
||||
# eliminating the class of bugs where the admin goes blank (OPS69/OPS72/OPS73).
|
||||
# The dummy values are safe because Payload's generator doesn't connect to S3.
|
||||
RUN --mount=type=secret,id=database_url,env=DATABASE_URL \
|
||||
--mount=type=secret,id=payload_secret,env=PAYLOAD_SECRET \
|
||||
S3_BUCKET=build-dummy \
|
||||
S3_ENDPOINT=http://127.0.0.1:3900 \
|
||||
S3_ACCESS_KEY_ID=build-dummy \
|
||||
S3_SECRET_ACCESS_KEY=build-dummy \
|
||||
NEXT_OUTPUT_STANDALONE=1 \
|
||||
NODE_OPTIONS="--no-deprecation --max-old-space-size=8000" \
|
||||
pnpm exec payload generate:importmap && \
|
||||
pnpm exec next build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
|
|
|
|||
43
docs/changelog/2026-08-27-OPS99.md
Normal file
43
docs/changelog/2026-08-27-OPS99.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# OPS99 — Generate importMap during build with dummy S3\_\* envs
|
||||
|
||||
**Date:** 2026-08-27
|
||||
**Issue:** #928
|
||||
**Type:** ops, bug-fix
|
||||
|
||||
## Summary
|
||||
|
||||
Generate the Payload importMap at build time (Dockerfile) and dev time (predev hook) with dummy S3\_\* envs, eliminating the class of bugs where the admin goes blank because the S3ClientUploadHandler entry is missing (OPS69/OPS72/OPS73).
|
||||
|
||||
## Changes
|
||||
|
||||
### Dockerfile
|
||||
|
||||
- Added `pnpm generate:importmap` step with dummy S3\_\* envs BEFORE `next build`
|
||||
- This ensures the production image always has the correct importMap with S3ClientUploadHandler
|
||||
|
||||
### Scripts
|
||||
|
||||
- **Added:** `scripts/predev-importmap.mjs` — predev hook that generates importMap if missing or stale
|
||||
- **Deleted:** `scripts/check-importmap-s3.mjs` — guard script no longer needed (importMap is now generated at build time)
|
||||
- **Deleted:** `tests/unit/importMapS3UploadHandler.unit.spec.ts` — unit pin no longer needed
|
||||
|
||||
### CI/CD
|
||||
|
||||
- Removed `check-importmap-s3.mjs` step from `ci-pr.yml` and `deploy.yml`
|
||||
|
||||
### Configuration
|
||||
|
||||
- Added `src/app/(payload)/admin/importMap.js` to `.gitignore` (build artifact, not committed)
|
||||
- Added `scripts/check-importmap-s3.mjs` to `.gitignore` (deleted file)
|
||||
|
||||
### Documentation
|
||||
|
||||
- Updated `AGENTS.md` with new importMap contract
|
||||
|
||||
## Verification
|
||||
|
||||
- `pnpm typecheck` — passed
|
||||
- `pnpm lint` — passed (0 warnings)
|
||||
- `pnpm format:check` — passed
|
||||
- `pnpm test:unit` — 2681 tests passed
|
||||
- `pnpm build` — successful
|
||||
|
|
@ -0,0 +1 @@
|
|||
**Admin em branco — follow-up: deploy bloqueado pelo reinstall do deps, package.json revertido (2026-08-27):** o fix do importMap (#926, main em `fea6c645`) não conseguia PUBLICAR: o deploy manual falhou 2× no build do migrator — a mudança de `package.json` (script `generate:importmap` → wrapper) invalidou a cache BuildKit da camada `deps` do Dockerfile, o `pnpm install --frozen-lockfile` re-rodou do zero e o `postinstall` do `sharp@0.32.6` (transitivo) estourou o timeout baixando o libvips de `objects.githubusercontent.com` no homeserver (`sharp: Installation error: Request timed out`; o `git fetch` de github.com funciona — o release vai por hostname diferente da CDN). Produção ficou intocada (falha antes do compose swap). Correção: `package.json` revertido ao byte do estado cacheado (`a9f0c61e`) — a cache do `deps` volta a valer e o install nem roda; wrapper `scripts/generate-importmap.mjs` **removido** (ficaria desligado — dead code); proteção mantida pelo guard `check-importmap-s3.mjs` (ci-pr.yml + verify do deploy) + pin unit + contrato. Dívida documentada no post-mortem: hardening da camada `deps` (retry do install / libvips via apk / proxy do download) — sem ele, qualquer mudança futura em package.json/pnpm-lock/pnpm-workspace volta a bustar a cache e travar o deploy igual. Ação: re-dispatch manual do `deploy.yml` (o guard do HEAD exige main atual; o `verify` já passou 19m verde no run anterior).
|
||||
1
docs/changelog/2026-08-27-deploy-sharp-override.md
Normal file
1
docs/changelog/2026-08-27-deploy-sharp-override.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
**Deploy destravado — override sharp@0.32.6 → 0.34.2: o pnpm install deixa de depender de github releases (2026-08-27):** os 4 deploys falhados desde 10:59 UTC morriam na camada `deps` do Dockerfile: o `postinstall` do `sharp@0.32.6` (dependência do `@imgly/background-removal-node`, usado só pelo script local `resize-images.mjs`) baixa o libvips de `objects.githubusercontent.com` e estoura timeout no homeserver (`sharp: Installation error: Request timed out`) — o egress não conclui downloads de github releases embora o `git fetch` funcione (hostname distinto da CDN); a cache do BuildKit não esconde a classe porque o `builder prune` do pós-deploy limpa a camada a cada deploy bem-sucedido. Fix estrutural (PR #929, reverted em outro eixo o #927 que tentou a rota da cache): override no `pnpm-workspace.yaml` força o sharp transitivo para 0.34.2 (versão direta do app) — a partir do 0.33 os binários vêm de pacotes do **npm registry** (`@img/sharp-libvips-*`), alcançável pelo homeserver; lockfile regenerado remove o sharp@0.32.6 e toda a subárvore do prebuild-install (−296 linhas, tar-fs/simple-get/bare-\*/etc.). Verificação: `pnpm why sharp` (imgly → 0.34.2 via override; next/payload → 0.34.5), smoke do `resize-images` (processamento webp OK), format/lint/tsc verdes, suíte int completa verde (78/712), gate:ci verde, PR CI verde. **Deploy do main (`4d6533c0`, run 33074305879) verde: verify 19m + deploy 16m — e o admin voltou a renderizar em produção** (login do Payload com formulário, 0 erros de console; verificação read-only via browser, confirmação final do humano pendente). Candidato a registro no runbook: a regra "nenhum binário de github releases no `pnpm install` de produção" — qualquer dep futura que baixe de github.com/objects.githubusercontent.com na instalação volta a travar o deploy.
|
||||
170
docs/plans/ops99-importmap-build-impl.md
Normal file
170
docs/plans/ops99-importmap-build-impl.md
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
# OPS99: Generate importMap during build with dummy S3\_\* envs
|
||||
|
||||
## 1. Reading of intention
|
||||
|
||||
**Problem:** The committed `importMap.js` loses the `S3ClientUploadHandler` entry when regenerated without S3*\* envs, causing the admin to go blank in production (class OPS69/OPS72/OPS73). The current guard mechanism (CI check + unit pin) catches drift but requires manual regeneration with dummy S3*\* envs.
|
||||
|
||||
**Goal:** Eliminate the committed importMap as the source of truth for the S3 upload handler. Instead, generate it during the Docker build with dummy S3\_\* envs, so the production image always has the correct entry.
|
||||
|
||||
**Key insight:** The importMap is a build artifact, not source code. It should be generated at build time with the same environment the production image will run in.
|
||||
|
||||
## 2. Recommended approach
|
||||
|
||||
### Primary approach: Generate importMap in Dockerfile builder stage
|
||||
|
||||
**Steps:**
|
||||
|
||||
1. **Dockerfile builder stage:** Add `pnpm generate:importmap` with dummy S3\_\* envs BEFORE `next build`
|
||||
2. **Retire unit pin:** Remove `tests/unit/importMapS3UploadHandler.unit.spec.ts`
|
||||
3. **Simplify CI guard:** Update `scripts/check-importmap-s3.mjs` to verify the builder generates correctly (not that committed file matches)
|
||||
4. **Dev/worktree predev:** Add a predev hook that generates importMap if missing or stale
|
||||
5. **Update docs:** Remove "rode generate:importmap" from AGENTS.md, add new contract
|
||||
|
||||
### Options considered and rejected
|
||||
|
||||
| Option | Why rejected |
|
||||
| -------------------------------------------- | ------------------------------------------------------------------- |
|
||||
| **Keep committed importMap + improve guard** | perpetuates the drift problem; guard catches but doesn't prevent |
|
||||
| **Generate in CI only** | dev/worktrees still need the file; adds CI dependency for local dev |
|
||||
| **Generate in next.config.js** | Payload's generate:importmap is a CLI command, not a Next.js plugin |
|
||||
| **Store importMap in S3** | overengineering; the file is small and deterministic |
|
||||
|
||||
## 3. Verifiable phases
|
||||
|
||||
### Phase 1: Dockerfile builder stage (production fix)
|
||||
|
||||
**Files to modify:**
|
||||
|
||||
- `Dockerfile`: Add S3\_\* dummy envs and generate:importmap step
|
||||
|
||||
**Changes:**
|
||||
|
||||
```dockerfile
|
||||
# In builder stage, before next build:
|
||||
RUN --mount=type=secret,id=database_url,env=DATABASE_URL \
|
||||
--mount=type=secret,id=payload_secret,env=PAYLOAD_SECRET \
|
||||
S3_BUCKET=build-dummy \
|
||||
S3_ENDPOINT=http://127.0.0.1:3900 \
|
||||
S3_ACCESS_KEY_ID=build-dummy \
|
||||
S3_SECRET_ACCESS_KEY=build-dummy \
|
||||
NEXT_OUTPUT_STANDALONE=1 \
|
||||
NODE_OPTIONS="--no-deprecation --max-old-space-size=8000" \
|
||||
pnpm exec payload generate:importmap && \
|
||||
pnpm exec next build
|
||||
```
|
||||
|
||||
**Verification:**
|
||||
|
||||
- Build Docker image locally: `docker build --target builder .`
|
||||
- Check `src/app/(payload)/admin/importMap.js` contains S3ClientUploadHandler
|
||||
- Deploy to homeserver and verify admin loads
|
||||
|
||||
### Phase 2: Retire unit pin and update CI guard
|
||||
|
||||
**Files to modify:**
|
||||
|
||||
- Delete: `tests/unit/importMapS3UploadHandler.unit.spec.ts`
|
||||
- Modify: `scripts/check-importmap-s3.mjs`
|
||||
|
||||
**Changes to guard script:**
|
||||
|
||||
- Remove the "regenerate and diff against committed" logic
|
||||
- Instead, verify that the committed importMap is NOT required for production
|
||||
- Or: remove the guard entirely since the builder now generates correctly
|
||||
|
||||
**Verification:**
|
||||
|
||||
- Run `pnpm test:unit` (should pass without the deleted test)
|
||||
- Run CI checks (guard should pass or be removed)
|
||||
|
||||
### Phase 3: Dev/worktree predev hook
|
||||
|
||||
**Files to modify:**
|
||||
|
||||
- `package.json`: Add `predev` script
|
||||
- Create: `scripts/predev-importmap.mjs` (or add to existing `scripts/dev.mjs`)
|
||||
|
||||
**Changes:**
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"predev": "node scripts/predev-importmap.mjs"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The predev script should:
|
||||
|
||||
1. Check if `src/app/(payload)/admin/importMap.js` exists
|
||||
2. If missing or stale (compare mtime with payload.config.ts), regenerate with dummy S3\_\* envs
|
||||
3. Use the same dummy values as the CI guard
|
||||
|
||||
**Verification:**
|
||||
|
||||
- Delete importMap.js, run `pnpm dev` → file should be regenerated
|
||||
- Modify payload.config.ts, run `pnpm dev` → file should be regenerated
|
||||
|
||||
### Phase 4: Documentation updates
|
||||
|
||||
**Files to modify:**
|
||||
|
||||
- `AGENTS.md`: Update "rode generate:importmap" rule
|
||||
- `docs/AGENT-OPS.md`: Update if present
|
||||
|
||||
**New contract:**
|
||||
|
||||
- ImportMap is generated at build time (Docker) and dev time (predev hook)
|
||||
- Never commit importMap.js to repo (add to .gitignore)
|
||||
- CI guard can be removed or simplified to verify builder works
|
||||
|
||||
## 4. Rabbit holes / out of scope
|
||||
|
||||
### Rabbit holes (avoid)
|
||||
|
||||
1. **Trying to make Payload auto-generate importMap** - This would require modifying Payload core, out of scope
|
||||
2. **Moving S3 config to runtime** - The gating is intentional; keep it
|
||||
3. **Changing the S3 storage plugin** - Only the importMap generation changes
|
||||
4. **Modifying the deploy script** - The builder stage handles it now
|
||||
|
||||
### Out of scope
|
||||
|
||||
- Changing how Payload generates the importMap (internal to Payload)
|
||||
- Modifying the S3 storage plugin behavior
|
||||
- Changing the media collection configuration
|
||||
- Updating the CI pipeline beyond the guard removal
|
||||
|
||||
## 5. Risks and mitigation
|
||||
|
||||
| Risk | Impact | Mitigation |
|
||||
| ---------------------------------------- | -------------------------------- | ------------------------------------------------------------------- |
|
||||
| **Builder fails to generate importMap** | Admin breaks in production | Keep committed importMap as fallback in .gitignore (not tracked) |
|
||||
| **Dev predev hook slows startup** | Developer experience | Only regenerate if file missing or stale (check mtime) |
|
||||
| **Dummy S3\_\* envs cause side effects** | Unexpected behavior during build | Use clearly dummy values; Payload's generator doesn't connect to S3 |
|
||||
| **ImportMap generation order matters** | Build fails | Generate BEFORE next build (as planned) |
|
||||
|
||||
## 6. Engineering acceptance
|
||||
|
||||
### Acceptance criteria
|
||||
|
||||
1. **Production image** has correct importMap with S3ClientUploadHandler
|
||||
2. **Admin loads** in production without manual importMap regeneration
|
||||
3. **Dev workflow** auto-generates importMap when needed
|
||||
4. **CI checks** pass (guard either updated or removed)
|
||||
5. **No committed importMap** in git history (add to .gitignore)
|
||||
|
||||
### Verification steps
|
||||
|
||||
1. `docker build --target builder .` succeeds and generates importMap
|
||||
2. `pnpm dev` generates importMap if missing
|
||||
3. `pnpm test:unit` passes (without deleted test)
|
||||
4. Deploy to homeserver: admin loads correctly
|
||||
5. `git status` shows importMap.js as untracked (in .gitignore)
|
||||
|
||||
### Decision quality self-score: 4/5
|
||||
|
||||
- **Caro vs barato:** Deliberate about what's expensive to reverse (committed importMap vs generated)
|
||||
- **Form:** Options considered, recommendation clear
|
||||
- **Appetite:** Respects the intention's scope (build-time generation)
|
||||
- **Depth check:** Reuses existing `generate:importmap` script, no shallow pass-throughs
|
||||
- **Rabbit holes:** Named explicitly (Payload core, S3 plugin changes)
|
||||
|
|
@ -4,24 +4,24 @@
|
|||
|
||||
## Registro
|
||||
|
||||
| Campo | Valor |
|
||||
| ------------------- | ---------------- |
|
||||
| Data do post-mortem | 2026-08-26 |
|
||||
| Severidade | crítica |
|
||||
| Ambiente | prod |
|
||||
| Issue(s) | sem Issue |
|
||||
| PR do fix | — (em andamento) |
|
||||
| Detectado por | humano |
|
||||
| Campo | Valor |
|
||||
| ------------------- | --------------------------------------------------- |
|
||||
| Data do post-mortem | 2026-08-26 |
|
||||
| Severidade | crítica |
|
||||
| Ambiente | prod |
|
||||
| Issue(s) | sem Issue |
|
||||
| PR do fix | #926 (+ #927 e #929 para os desbloqueios do deploy) |
|
||||
| Detectado por | humano |
|
||||
|
||||
## Timeline
|
||||
|
||||
| Momento | Data/hora | Evento |
|
||||
| ------------------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Início provável | 2026-08-23 | commit 1c865bd8 (refactor "E1 simplify — pin loading/retry/stale-quirk no spec e tipo local") regenerou o importMap sem as envs S3\_\*, removendo a entrada do handler |
|
||||
| Detecção | 2026-08-26 | relato do usuário: admin em branco em produção |
|
||||
| Correção mergeada | em andamento | PR ainda sem número |
|
||||
| Deploy | ainda não feito | dispatch manual do deploy.yml (só humano) |
|
||||
| Verificado em prod | não | aguarda deploy + confirmação do humano |
|
||||
| Momento | Data/hora | Evento |
|
||||
| ------------------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Início provável | 2026-08-23 | commit 1c865bd8 (refactor "E1 simplify — pin loading/retry/stale-quirk no spec e tipo local") regenerou o importMap sem as envs S3\_\*, removendo a entrada do handler |
|
||||
| Detecção | 2026-08-26 | relato do usuário: admin em branco em produção |
|
||||
| Correção mergeada | 2026-08-27 | PRs #926 (importMap +2 linhas + guard/pin), #927 (package.json revertido — desbloqueio 1 do deploy), #929 (override sharp — desbloqueio 2 do deploy) |
|
||||
| Deploy | 2026-08-27 | dispatch manual do deploy.yml (run 33074305879, 12:56 UTC) — verify 19m + deploy 16m verdes, revision `4d6533c0` |
|
||||
| Verificado em prod | 2026-08-27 | verificação read-only via browser: `/admin/login` renderiza o formulário (Email/Senha/Login, título "Login - Payload"), 0 erros de console; confirmação final do humano pendente |
|
||||
|
||||
## O bug
|
||||
|
||||
|
|
@ -54,25 +54,26 @@ Regeneração do importMap com envs S3\_\* dummy — o diff foi de exatamente +2
|
|||
- Suíte: unit completa 284 arquivos / 2682 testes verdes; `tsc --noEmit` e lint exit 0
|
||||
- E2E original: admin servido com S3\_\* dummy (PORT 4093) — login renderiza (título "Login - Payload", form Email/Senha), login admin@test.invalid funciona, dashboard "Painel de Controle - Payload" monta, log do servidor com 0 `getFromImportMap`, 0 erros de console
|
||||
- CI: gate:fast verde (284 arquivos, 2682 testes)
|
||||
- Prod: não verificado — aguarda deploy manual + confirmação do humano
|
||||
- Prod: deploy do run 33074305879 (revision `4d6533c0`) concluído verde; verificação read-only via browser (2026-08-27): `/admin/login` renderiza o formulário com 0 erros de console — confirmação final do humano pendente
|
||||
|
||||
## Prevenção
|
||||
|
||||
| Estratégia | Custo | Estado |
|
||||
| ------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------ |
|
||||
| Pin unit `importMapS3UploadHandler.unit.spec.ts` (falha se a entrada sumir) | barata | implementada agora (mesmo PR) |
|
||||
| Guard `scripts/check-importmap-s3.mjs` no ci-pr.yml (content guards) e no job verify do deploy.yml | barata | implementada agora (mesmo PR) |
|
||||
| Wrapper `scripts/generate-importmap.mjs` no `pnpm generate:importmap` (injeta S3\_\* dummy quando ausentes) | barata | implementada agora (mesmo PR) |
|
||||
| Contrato compartilhado `scripts/lib/importMapContract.mjs` (chave + prefixo do handler, chaves das envs S3) | barata | implementada agora (mesmo PR) |
|
||||
| AGENTS.md: instrução das envs S3\_\* no generate:importmap + referência aos guards | barata | implementada agora (mesmo PR) |
|
||||
| Gerar o importMap no BUILD (prebuild com S3\_\* via BuildKit secrets) em vez de commitá-lo | cara | documentada — não implementada neste fluxo |
|
||||
| Tornar o plugin s3Storage incondicional no config (adaptador local em dev) | cara | documentada — não implementada neste fluxo |
|
||||
| Smoke real de deploy: abrir /admin em headless e assertar o mount da raiz Payload (não só HTTP 200) | cara | documentada — não implementada neste fluxo |
|
||||
| Fail-fast/erro estruturado quando getFromImportMap retorna undefined (hoje é console.error silencioso no log do servidor) | cara | documentada — não implementada neste fluxo |
|
||||
| Estratégia | Custo | Estado |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Pin unit `importMapS3UploadHandler.unit.spec.ts` (falha se a entrada sumir) | barata | implementada agora (mesmo PR) |
|
||||
| Guard `scripts/check-importmap-s3.mjs` no ci-pr.yml (content guards) e no job verify do deploy.yml | barata | implementada agora (mesmo PR) |
|
||||
| Wrapper `scripts/generate-importmap.mjs` no `pnpm generate:importmap` (injeta S3\_\* dummy quando ausentes) | barata | removida no follow-up (2026-08-27) — a mudança de package.json invalida a cache BuildKit da camada `deps` no homeserver e força reinstall cujo `postinstall` do `sharp@0.32.6` falha (timeout do libvips em objects.githubusercontent.com; 2 deploys falhos). Re-ligar junto com o hardening do Dockerfile |
|
||||
| Contrato compartilhado `scripts/lib/importMapContract.mjs` (chave + prefixo do handler, chaves das envs S3) | barata | implementada agora (mesmo PR) |
|
||||
| AGENTS.md: instrução das envs S3\_\* no generate:importmap + referência aos guards | barata | implementada agora (mesmo PR) |
|
||||
| Gerar o importMap no BUILD (prebuild com S3\_\* via BuildKit secrets) em vez de commitá-lo | cara | documentada — não implementada neste fluxo |
|
||||
| Tornar o plugin s3Storage incondicional no config (adaptador local em dev) | cara | documentada — não implementada neste fluxo |
|
||||
| Smoke real de deploy: abrir /admin em headless e assertar o mount da raiz Payload (não só HTTP 200) | cara | documentada — não implementada neste fluxo |
|
||||
| Fail-fast/erro estruturado quando getFromImportMap retorna undefined (hoje é console.error silencioso no log do servidor) | cara | documentada — não implementada neste fluxo |
|
||||
| Hardening da camada `deps` do Dockerfile (retry do `pnpm install` / libvips via apk / proxy do download do sharp) — o egress do homeserver para objects.githubusercontent.com não conclui downloads | cara | resolvida em grande parte pelo PR #929 (override sharp → binários via npm registry, alcançável); retry/proxy seguem documentados para deps futuras que usem github releases |
|
||||
|
||||
**Estratégia implementada:** pin unit que falha se o handler sumir do importMap; guard de CI+deploy que regenera com S3\_\* dummy e falha em divergência (drift + restore do arquivo); wrapper do `generate:importmap` que injeta as envs dummy — a regeneração local nunca mais orfa o handler; contrato compartilhado da chave/prefixo e das envs; doc no AGENTS.md.
|
||||
**Estratégia implementada:** pin unit que falha se o handler sumir do importMap; guard de CI+deploy que regenera com S3\_\* dummy e falha em divergência (drift + restore do arquivo); contrato compartilhado da chave/prefixo e das envs; doc no AGENTS.md. O wrapper do `generate:importmap` foi removido no follow-up (a mudança de package.json que o ligava quebrou o deploy — ver tabela); a proteção fica com o guard + pin.
|
||||
|
||||
**Estratégia documentada (cara):** gerar o importMap no build (elimina a classe: artefato gerado não drift; toca o pipeline do homeserver); tornar o s3Storage incondicional (estabiliza o importMap; muda storage local e caminho de media); smoke de deploy que abre /admin em headless e asserta o mount da raiz Payload; fail-fast estruturado quando getFromImportMap retorna undefined.
|
||||
**Estratégia documentada (cara):** gerar o importMap no build (elimina a classe: artefato gerado não drift; toca o pipeline do homeserver); tornar o s3Storage incondicional (estabiliza o importMap; muda storage local e caminho de media); smoke de deploy que abre /admin em headless e asserta o mount da raiz Payload; fail-fast estruturado quando getFromImportMap retorna undefined; hardening da camada `deps` do Dockerfile contra o reinstall completo no homeserver.
|
||||
|
||||
## Lições
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
"build:tse-city-codes": "cross-env NODE_OPTIONS=\"--no-deprecation --import=tsx/esm\" node scripts/build-bahia-tse-city-codes.mjs",
|
||||
"dev": "node scripts/dev.mjs",
|
||||
"devsafe": "rm -rf .next && node scripts/dev.mjs",
|
||||
"predev": "node scripts/predev-importmap.mjs",
|
||||
"format": "prettier --write .",
|
||||
"format:check": "prettier --check .",
|
||||
"gate:fast": "pnpm lint && pnpm typecheck && pnpm test:unit",
|
||||
|
|
@ -61,7 +62,7 @@
|
|||
"changelog:build": "node scripts/build-changelog.mjs",
|
||||
"changelog:read": "node scripts/build-changelog.mjs --stdout",
|
||||
"changelog:check": "node scripts/build-changelog.mjs --check",
|
||||
"generate:importmap": "node scripts/generate-importmap.mjs",
|
||||
"generate:importmap": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload generate:importmap",
|
||||
"generate:types": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload generate:types",
|
||||
"migrate": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload migrate",
|
||||
"migrate:create": "cross-env NODE_OPTIONS=\"--no-deprecation --conditions=react-server\" payload migrate:create",
|
||||
|
|
|
|||
300
pnpm-lock.yaml
300
pnpm-lock.yaml
|
|
@ -4,6 +4,9 @@ settings:
|
|||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
overrides:
|
||||
sharp@0.32.6: 0.34.2
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
|
|
@ -4031,14 +4034,6 @@ packages:
|
|||
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
b4a@1.8.1:
|
||||
resolution: {integrity: sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==}
|
||||
peerDependencies:
|
||||
react-native-b4a: '*'
|
||||
peerDependenciesMeta:
|
||||
react-native-b4a:
|
||||
optional: true
|
||||
|
||||
babel-plugin-macros@3.1.0:
|
||||
resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
|
||||
engines: {node: '>=10', npm: '>=6'}
|
||||
|
|
@ -4053,43 +4048,6 @@ packages:
|
|||
resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==}
|
||||
engines: {node: 18 || 20 || >=22}
|
||||
|
||||
bare-events@2.9.1:
|
||||
resolution: {integrity: sha512-Z0oHEHAFDZkffN8Qc39zNZjQlMDkPJRyyyZieU1VH7u8c5S+qHZ2S8ixdKIAxEjfHO7FJxXmJWgteOghVanIsg==}
|
||||
peerDependencies:
|
||||
bare-abort-controller: '*'
|
||||
peerDependenciesMeta:
|
||||
bare-abort-controller:
|
||||
optional: true
|
||||
|
||||
bare-fs@4.8.0:
|
||||
resolution: {integrity: sha512-fM+MhCvdQhZ7NV6S95a07gPSqjIYKn6mFaXfx266wN3ajZGl/+1AzH+ubkXQ0fFZvOe2nk9VHkzdYkQE5zMV3Q==}
|
||||
engines: {bare: '>=1.28.0'}
|
||||
peerDependencies:
|
||||
bare-buffer: '*'
|
||||
peerDependenciesMeta:
|
||||
bare-buffer:
|
||||
optional: true
|
||||
|
||||
bare-path@3.1.1:
|
||||
resolution: {integrity: sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==}
|
||||
|
||||
bare-stream@2.13.3:
|
||||
resolution: {integrity: sha512-Kc+brLqvEqGkjyfiwJmImAOqLZL7OsoLKuavx+hJjgVV3nLTOjloJyPMFxjUPerGGHrNH0fLU06jjykMLWrERQ==}
|
||||
peerDependencies:
|
||||
bare-abort-controller: '*'
|
||||
bare-buffer: '*'
|
||||
bare-events: '*'
|
||||
peerDependenciesMeta:
|
||||
bare-abort-controller:
|
||||
optional: true
|
||||
bare-buffer:
|
||||
optional: true
|
||||
bare-events:
|
||||
optional: true
|
||||
|
||||
bare-url@2.5.2:
|
||||
resolution: {integrity: sha512-L13PCJzKG8RGvx8V1/DdMi12ERhC3tprr7/8a94BxpmnRsFqxh5XZNdhtMxu5HPkRshYOOWRGY8lDP7ZhpG9Cg==}
|
||||
|
||||
base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
|
||||
|
|
@ -4226,9 +4184,6 @@ packages:
|
|||
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
|
||||
chownr@1.1.4:
|
||||
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
|
||||
|
||||
chownr@3.0.0:
|
||||
resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -4488,10 +4443,6 @@ packages:
|
|||
decode-named-character-reference@1.3.0:
|
||||
resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}
|
||||
|
||||
decompress-response@6.0.0:
|
||||
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
dedent@1.7.2:
|
||||
resolution: {integrity: sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==}
|
||||
peerDependencies:
|
||||
|
|
@ -5009,9 +4960,6 @@ packages:
|
|||
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
events-universal@1.0.1:
|
||||
resolution: {integrity: sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==}
|
||||
|
||||
events@3.3.0:
|
||||
resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}
|
||||
engines: {node: '>=0.8.x'}
|
||||
|
|
@ -5036,10 +4984,6 @@ packages:
|
|||
resolution: {integrity: sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA==}
|
||||
engines: {node: ^18.19.0 || >=20.5.0}
|
||||
|
||||
expand-template@2.0.3:
|
||||
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
expand-tilde@2.0.2:
|
||||
resolution: {integrity: sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
|
@ -5067,9 +5011,6 @@ packages:
|
|||
fast-deep-equal@3.1.3:
|
||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||
|
||||
fast-fifo@1.3.2:
|
||||
resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==}
|
||||
|
||||
fast-glob@3.3.1:
|
||||
resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==}
|
||||
engines: {node: '>=8.6.0'}
|
||||
|
|
@ -5183,9 +5124,6 @@ packages:
|
|||
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
fs-constants@1.0.0:
|
||||
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
||||
|
||||
fs-extra@11.3.4:
|
||||
resolution: {integrity: sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA==}
|
||||
engines: {node: '>=14.14'}
|
||||
|
|
@ -5276,9 +5214,6 @@ packages:
|
|||
get-tsconfig@4.8.1:
|
||||
resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==}
|
||||
|
||||
github-from-package@0.0.0:
|
||||
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
||||
|
||||
glob-parent@5.1.2:
|
||||
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
|
||||
engines: {node: '>= 6'}
|
||||
|
|
@ -6207,10 +6142,6 @@ packages:
|
|||
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
mimic-response@3.1.0:
|
||||
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
minimalistic-assert@1.0.1:
|
||||
resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==}
|
||||
|
||||
|
|
@ -6239,9 +6170,6 @@ packages:
|
|||
resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
mkdirp-classic@0.5.3:
|
||||
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
||||
|
||||
module-definition@6.0.2:
|
||||
resolution: {integrity: sha512-SvAU3lB0+Yjbq55yHY3wkRZBOh+fhU1SnIF3IFbTewv6mtAh7yUT8ACHAJ2mGIJ7tCes2QuCL/cl6m0JSZ/ArA==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -6282,9 +6210,6 @@ packages:
|
|||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
napi-build-utils@2.0.0:
|
||||
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
|
||||
|
||||
napi-postinstall@0.3.4:
|
||||
resolution: {integrity: sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==}
|
||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||
|
|
@ -6327,13 +6252,6 @@ packages:
|
|||
sass:
|
||||
optional: true
|
||||
|
||||
node-abi@3.94.0:
|
||||
resolution: {integrity: sha512-W5ZNO5KRPB5TkYmGVD9F6YqhsglXJzE6etpbmT+f6EQElhiX/UTG551cnsRGvLG3fyZEg9HwaDmNmj5nwJ4z9g==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
node-addon-api@6.1.0:
|
||||
resolution: {integrity: sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==}
|
||||
|
||||
node-domexception@1.0.0:
|
||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||
engines: {node: '>=10.5.0'}
|
||||
|
|
@ -6725,12 +6643,6 @@ packages:
|
|||
resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
prebuild-install@7.1.3:
|
||||
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
|
||||
hasBin: true
|
||||
|
||||
precinct@12.3.2:
|
||||
resolution: {integrity: sha512-JbJevI1K80z8e/WIyDt/4vUN/4qcfBSKKqOjJA4mosPPPb7zODKRJQV7YN7apVWN3k58nZYm/vEsLgEGYmnxwg==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -7173,10 +7085,6 @@ packages:
|
|||
resolution: {integrity: sha512-dWN9aw+fszDEMPdRqAVmv5xgrsO60r5XDinHvrCjyfSW/FOiOrJJpYHGDI67+ItIwhTGHK1cXCM5YPAWVOsUtw==}
|
||||
hasBin: true
|
||||
|
||||
sharp@0.32.6:
|
||||
resolution: {integrity: sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==}
|
||||
engines: {node: '>=14.15.0'}
|
||||
|
||||
sharp@0.34.2:
|
||||
resolution: {integrity: sha512-lszvBmB9QURERtyKT2bNmsgxXK0ShJrL/fvqlonCo7e6xBF8nT8xU6pW+PMIbLsz0RxQk3rgH9kd8UmvOzlMJg==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
|
|
@ -7222,12 +7130,6 @@ packages:
|
|||
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
simple-concat@1.0.1:
|
||||
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
|
||||
|
||||
simple-get@4.0.1:
|
||||
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
|
||||
|
||||
simple-swizzle@0.2.4:
|
||||
resolution: {integrity: sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==}
|
||||
|
||||
|
|
@ -7316,9 +7218,6 @@ packages:
|
|||
resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
|
||||
streamx@2.28.0:
|
||||
resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==}
|
||||
|
||||
strict-event-emitter@0.5.1:
|
||||
resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==}
|
||||
|
||||
|
|
@ -7472,26 +7371,10 @@ packages:
|
|||
resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar-fs@2.1.5:
|
||||
resolution: {integrity: sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==}
|
||||
|
||||
tar-fs@3.1.3:
|
||||
resolution: {integrity: sha512-/hU4AXnIdZu+Gvl1pk0oI5f5HxWsCJRtY2aFaJdk9VvyL48DWU6iU5WAIPG+wIi1YvWA6eTJvIviP/tMAZZNwQ==}
|
||||
|
||||
tar-stream@2.2.0:
|
||||
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar-stream@3.2.0:
|
||||
resolution: {integrity: sha512-ojzvCvVaNp6aOTFmG7jaRD0meowIAuPc3cMMhSgKiVWws1GyHbGd/xvnyuRKcKlMpt3qvxx6r0hreCNITP9hIg==}
|
||||
|
||||
tar@7.5.22:
|
||||
resolution: {integrity: sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
teex@1.0.1:
|
||||
resolution: {integrity: sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==}
|
||||
|
||||
temporal-polyfill@1.0.3:
|
||||
resolution: {integrity: sha512-U8vuzZBc+dfMIfl8wXWcedfI7AJCxJjjVBIRpJUvIz5+UAp555UJDHguKsfZqHWaHRSdVUThm7mqqIWhN/xPBQ==}
|
||||
|
||||
|
|
@ -7501,9 +7384,6 @@ packages:
|
|||
temporal-utils@1.0.1:
|
||||
resolution: {integrity: sha512-HAixuesxFQIUaQk3ptX2jhfO/FsOkgVkDDMawvp6n/fkB1q6BKfs3lURw9I+pK/2e2e/q/vrLrxmeqauBoyGMQ==}
|
||||
|
||||
text-decoder@1.2.7:
|
||||
resolution: {integrity: sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==}
|
||||
|
||||
thread-stream@3.1.0:
|
||||
resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==}
|
||||
|
||||
|
|
@ -7649,9 +7529,6 @@ packages:
|
|||
resolution: {integrity: sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
|
||||
tw-animate-css@1.4.0:
|
||||
resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==}
|
||||
|
||||
|
|
@ -9388,12 +9265,8 @@ snapshots:
|
|||
lodash: 4.17.23
|
||||
ndarray: 1.0.19
|
||||
onnxruntime-node: 1.17.3
|
||||
sharp: 0.32.6
|
||||
sharp: 0.34.2
|
||||
zod: 3.21.4
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
'@inquirer/ansi@1.0.2': {}
|
||||
|
||||
|
|
@ -11987,8 +11860,6 @@ snapshots:
|
|||
|
||||
axobject-query@4.1.0: {}
|
||||
|
||||
b4a@1.8.1: {}
|
||||
|
||||
babel-plugin-macros@3.1.0:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.29.7
|
||||
|
|
@ -12001,35 +11872,6 @@ snapshots:
|
|||
|
||||
balanced-match@4.0.4: {}
|
||||
|
||||
bare-events@2.9.1: {}
|
||||
|
||||
bare-fs@4.8.0:
|
||||
dependencies:
|
||||
bare-events: 2.9.1
|
||||
bare-path: 3.1.1
|
||||
bare-stream: 2.13.3(bare-events@2.9.1)
|
||||
bare-url: 2.5.2
|
||||
fast-fifo: 1.3.2
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
bare-path@3.1.1: {}
|
||||
|
||||
bare-stream@2.13.3(bare-events@2.9.1):
|
||||
dependencies:
|
||||
b4a: 1.8.1
|
||||
streamx: 2.28.0
|
||||
teex: 1.0.1
|
||||
optionalDependencies:
|
||||
bare-events: 2.9.1
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
bare-url@2.5.2:
|
||||
dependencies:
|
||||
bare-path: 3.1.1
|
||||
|
||||
base64-js@1.5.1: {}
|
||||
|
||||
baseline-browser-mapping@2.9.19: {}
|
||||
|
|
@ -12178,8 +12020,6 @@ snapshots:
|
|||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
|
||||
chownr@1.1.4: {}
|
||||
|
||||
chownr@3.0.0: {}
|
||||
|
||||
ci-info@4.4.0: {}
|
||||
|
|
@ -12397,10 +12237,6 @@ snapshots:
|
|||
dependencies:
|
||||
character-entities: 2.0.2
|
||||
|
||||
decompress-response@6.0.0:
|
||||
dependencies:
|
||||
mimic-response: 3.1.0
|
||||
|
||||
dedent@1.7.2(babel-plugin-macros@3.1.0):
|
||||
optionalDependencies:
|
||||
babel-plugin-macros: 3.1.0
|
||||
|
|
@ -13038,12 +12874,6 @@ snapshots:
|
|||
|
||||
etag@1.8.1: {}
|
||||
|
||||
events-universal@1.0.1:
|
||||
dependencies:
|
||||
bare-events: 2.9.1
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
|
||||
events@3.3.0: {}
|
||||
|
||||
eventsource-parser@3.0.6: {}
|
||||
|
|
@ -13081,8 +12911,6 @@ snapshots:
|
|||
strip-final-newline: 4.0.0
|
||||
yoctocolors: 2.1.2
|
||||
|
||||
expand-template@2.0.3: {}
|
||||
|
||||
expand-tilde@2.0.2:
|
||||
dependencies:
|
||||
homedir-polyfill: 1.0.3
|
||||
|
|
@ -13133,8 +12961,6 @@ snapshots:
|
|||
|
||||
fast-deep-equal@3.1.3: {}
|
||||
|
||||
fast-fifo@1.3.2: {}
|
||||
|
||||
fast-glob@3.3.1:
|
||||
dependencies:
|
||||
'@nodelib/fs.stat': 2.0.5
|
||||
|
|
@ -13274,8 +13100,6 @@ snapshots:
|
|||
|
||||
fresh@2.0.0: {}
|
||||
|
||||
fs-constants@1.0.0: {}
|
||||
|
||||
fs-extra@11.3.4:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.11
|
||||
|
|
@ -13367,8 +13191,6 @@ snapshots:
|
|||
dependencies:
|
||||
resolve-pkg-maps: 1.0.0
|
||||
|
||||
github-from-package@0.0.0: {}
|
||||
|
||||
glob-parent@5.1.2:
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
|
@ -14483,8 +14305,6 @@ snapshots:
|
|||
|
||||
mimic-function@5.0.1: {}
|
||||
|
||||
mimic-response@3.1.0: {}
|
||||
|
||||
minimalistic-assert@1.0.1: {}
|
||||
|
||||
minimatch@10.2.4:
|
||||
|
|
@ -14511,8 +14331,6 @@ snapshots:
|
|||
dependencies:
|
||||
minipass: 7.1.3
|
||||
|
||||
mkdirp-classic@0.5.3: {}
|
||||
|
||||
module-definition@6.0.2:
|
||||
dependencies:
|
||||
ast-module-types: 6.0.2
|
||||
|
|
@ -14562,8 +14380,6 @@ snapshots:
|
|||
|
||||
nanoid@3.3.16: {}
|
||||
|
||||
napi-build-utils@2.0.0: {}
|
||||
|
||||
napi-postinstall@0.3.4: {}
|
||||
|
||||
natural-compare@1.4.0: {}
|
||||
|
|
@ -14605,12 +14421,6 @@ snapshots:
|
|||
- '@babel/core'
|
||||
- babel-plugin-macros
|
||||
|
||||
node-abi@3.94.0:
|
||||
dependencies:
|
||||
semver: 7.7.4
|
||||
|
||||
node-addon-api@6.1.0: {}
|
||||
|
||||
node-domexception@1.0.0: {}
|
||||
|
||||
node-fetch@3.3.2:
|
||||
|
|
@ -15093,21 +14903,6 @@ snapshots:
|
|||
|
||||
powershell-utils@0.1.0: {}
|
||||
|
||||
prebuild-install@7.1.3:
|
||||
dependencies:
|
||||
detect-libc: 2.1.2
|
||||
expand-template: 2.0.3
|
||||
github-from-package: 0.0.0
|
||||
minimist: 1.2.8
|
||||
mkdirp-classic: 0.5.3
|
||||
napi-build-utils: 2.0.0
|
||||
node-abi: 3.94.0
|
||||
pump: 3.0.3
|
||||
rc: 1.2.8
|
||||
simple-get: 4.0.1
|
||||
tar-fs: 2.1.5
|
||||
tunnel-agent: 0.6.0
|
||||
|
||||
precinct@12.3.2:
|
||||
dependencies:
|
||||
'@dependents/detective-less': 5.0.3
|
||||
|
|
@ -15743,21 +15538,6 @@ snapshots:
|
|||
- supports-color
|
||||
- typescript
|
||||
|
||||
sharp@0.32.6:
|
||||
dependencies:
|
||||
color: 4.2.3
|
||||
detect-libc: 2.1.2
|
||||
node-addon-api: 6.1.0
|
||||
prebuild-install: 7.1.3
|
||||
semver: 7.7.4
|
||||
simple-get: 4.0.1
|
||||
tar-fs: 3.1.3
|
||||
tunnel-agent: 0.6.0
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
sharp@0.34.2:
|
||||
dependencies:
|
||||
color: 4.2.3
|
||||
|
|
@ -15866,14 +15646,6 @@ snapshots:
|
|||
|
||||
signal-exit@4.1.0: {}
|
||||
|
||||
simple-concat@1.0.1: {}
|
||||
|
||||
simple-get@4.0.1:
|
||||
dependencies:
|
||||
decompress-response: 6.0.0
|
||||
once: 1.4.0
|
||||
simple-concat: 1.0.1
|
||||
|
||||
simple-swizzle@0.2.4:
|
||||
dependencies:
|
||||
is-arrayish: 0.3.4
|
||||
|
|
@ -15945,15 +15717,6 @@ snapshots:
|
|||
|
||||
streamsearch@1.1.0: {}
|
||||
|
||||
streamx@2.28.0:
|
||||
dependencies:
|
||||
events-universal: 1.0.1
|
||||
fast-fifo: 1.3.2
|
||||
text-decoder: 1.2.7
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
strict-event-emitter@0.5.1: {}
|
||||
|
||||
string-width@4.2.3:
|
||||
|
|
@ -16115,44 +15878,6 @@ snapshots:
|
|||
|
||||
tapable@2.3.3: {}
|
||||
|
||||
tar-fs@2.1.5:
|
||||
dependencies:
|
||||
chownr: 1.1.4
|
||||
mkdirp-classic: 0.5.3
|
||||
pump: 3.0.3
|
||||
tar-stream: 2.2.0
|
||||
|
||||
tar-fs@3.1.3:
|
||||
dependencies:
|
||||
pump: 3.0.3
|
||||
tar-stream: 3.2.0
|
||||
optionalDependencies:
|
||||
bare-fs: 4.8.0
|
||||
bare-path: 3.1.1
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
tar-stream@2.2.0:
|
||||
dependencies:
|
||||
bl: 4.1.0
|
||||
end-of-stream: 1.4.5
|
||||
fs-constants: 1.0.0
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.2
|
||||
|
||||
tar-stream@3.2.0:
|
||||
dependencies:
|
||||
b4a: 1.8.1
|
||||
bare-fs: 4.8.0
|
||||
fast-fifo: 1.3.2
|
||||
streamx: 2.28.0
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
tar@7.5.22:
|
||||
dependencies:
|
||||
'@isaacs/fs-minipass': 4.0.1
|
||||
|
|
@ -16161,13 +15886,6 @@ snapshots:
|
|||
minizlib: 3.1.0
|
||||
yallist: 5.0.0
|
||||
|
||||
teex@1.0.1:
|
||||
dependencies:
|
||||
streamx: 2.28.0
|
||||
transitivePeerDependencies:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
temporal-polyfill@1.0.3:
|
||||
dependencies:
|
||||
temporal-spec: 1.0.1
|
||||
|
|
@ -16177,12 +15895,6 @@ snapshots:
|
|||
|
||||
temporal-utils@1.0.1: {}
|
||||
|
||||
text-decoder@1.2.7:
|
||||
dependencies:
|
||||
b4a: 1.8.1
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
thread-stream@3.1.0:
|
||||
dependencies:
|
||||
real-require: 0.2.0
|
||||
|
|
@ -16320,10 +16032,6 @@ snapshots:
|
|||
dependencies:
|
||||
tslib: 1.14.1
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
tw-animate-css@1.4.0: {}
|
||||
|
||||
type-check@0.4.0:
|
||||
|
|
|
|||
|
|
@ -2,3 +2,12 @@ onlyBuiltDependencies:
|
|||
- sharp
|
||||
- esbuild
|
||||
- unrs-resolver
|
||||
|
||||
# The homeserver cannot download the libvips binaries from GitHub releases
|
||||
# (objects.githubusercontent.com times out), which sharp@0.32.6 ships via
|
||||
# prebuild-install. sharp 0.33+ bundles libvips through npm-registry packages
|
||||
# (@img/sharp-libvips-*), which the homeserver CAN reach. Force the transitive
|
||||
# sharp of @imgly/background-removal-node (script local only) onto the app's
|
||||
# own version so every sharp install is registry-based.
|
||||
overrides:
|
||||
'sharp@0.32.6': 0.34.2
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Guard: the committed importMap must include the S3ClientUploadHandler entry
|
||||
* (OPS69/OPS72/OPS73 class — regenerating the importMap without the S3_* envs
|
||||
* silently orphans it, and the admin goes blank in production).
|
||||
*
|
||||
* Regenerates the importMap with dummy S3_* envs (same trick as the OPS69
|
||||
* fix — the CLI iterates the config without a DB) and fails if the committed
|
||||
* file drifts. The working-tree file is restored afterwards so a failure
|
||||
* leaves the checkout untouched; the drift is printed in the error.
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { S3_STORAGE_ENV_KEYS } from './lib/importMapContract.mjs'
|
||||
|
||||
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const importMapPath = path.join(repoRoot, 'src/app/(payload)/admin/importMap.js')
|
||||
|
||||
if (!existsSync(importMapPath)) {
|
||||
console.error(`importMap not found at ${importMapPath}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const committed = readFileSync(importMapPath, 'utf8')
|
||||
|
||||
const GUARD_S3_DUMMY = {
|
||||
S3_BUCKET: 'guard-bucket',
|
||||
S3_ENDPOINT: 'http://127.0.0.1:3900',
|
||||
S3_ACCESS_KEY_ID: 'guard-access-key',
|
||||
S3_SECRET_ACCESS_KEY: 'guard-secret-key',
|
||||
}
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
// Same NODE_OPTIONS as the package.json `generate:importmap` script —
|
||||
// the payload CLI loads server-only modules.
|
||||
NODE_OPTIONS: '--no-deprecation --conditions=react-server',
|
||||
// Dummy S3_* envs gate the s3Storage plugin in (see mediaStorage.ts) so the
|
||||
// generation is prod-faithful; the generator never connects to the bucket.
|
||||
...Object.fromEntries(S3_STORAGE_ENV_KEYS.map((key) => [key, GUARD_S3_DUMMY[key]])),
|
||||
// The payload config needs a secret and a database URL to build, even
|
||||
// though the generator never connects (iterateConfig, no DB).
|
||||
PAYLOAD_SECRET: process.env.PAYLOAD_SECRET || 'guard-secret',
|
||||
DATABASE_URL: process.env.DATABASE_URL || 'postgresql://guard:guard@127.0.0.1:1/guard',
|
||||
}
|
||||
|
||||
try {
|
||||
execFileSync('pnpm', ['exec', 'payload', 'generate:importmap'], {
|
||||
cwd: repoRoot,
|
||||
env,
|
||||
stdio: 'pipe',
|
||||
})
|
||||
} catch (error) {
|
||||
restore(committed)
|
||||
console.error('guard-importmap: payload generate:importmap failed')
|
||||
console.error(error.stderr?.toString() || error.message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const generated = readFileSync(importMapPath, 'utf8')
|
||||
if (generated !== committed) {
|
||||
restore(committed)
|
||||
console.error(
|
||||
[
|
||||
'guard-importmap: the committed importMap drifted from the generation',
|
||||
'with S3_* envs set. Regenerate it with the S3_* envs (dummy values are',
|
||||
'fine) and commit the result:',
|
||||
'',
|
||||
' S3_BUCKET=x S3_ENDPOINT=http://127.0.0.1:3900 \\',
|
||||
' S3_ACCESS_KEY_ID=x S3_SECRET_ACCESS_KEY=x pnpm generate:importmap',
|
||||
'',
|
||||
'Drift (committed -> generated):',
|
||||
].join('\n'),
|
||||
)
|
||||
const drift = diffLines(committed, generated)
|
||||
console.error(drift)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Minimal line diff (no external deps): removed lines prefixed with "-",
|
||||
// added lines with "+".
|
||||
function diffLines(before, after) {
|
||||
const beforeLines = before.split('\n')
|
||||
const afterLines = after.split('\n')
|
||||
const out = []
|
||||
let i = 0
|
||||
let j = 0
|
||||
while (i < beforeLines.length && j < afterLines.length) {
|
||||
if (beforeLines[i] === afterLines[j]) {
|
||||
i += 1
|
||||
j += 1
|
||||
} else {
|
||||
const nextInBefore = beforeLines.indexOf(afterLines[j], i + 1)
|
||||
const nextInAfter = afterLines.indexOf(beforeLines[i], j + 1)
|
||||
if (nextInAfter === -1) {
|
||||
out.push(`- ${beforeLines[i]}`)
|
||||
i += 1
|
||||
} else if (nextInBefore === -1) {
|
||||
out.push(`+ ${afterLines[j]}`)
|
||||
j += 1
|
||||
} else if (nextInAfter - j <= nextInBefore - i) {
|
||||
out.push(`+ ${afterLines[j]}`)
|
||||
j += 1
|
||||
} else {
|
||||
out.push(`- ${beforeLines[i]}`)
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
while (i < beforeLines.length) out.push(`- ${beforeLines[i++]}`)
|
||||
while (j < afterLines.length) out.push(`+ ${afterLines[j++]}`)
|
||||
return out.join('\n')
|
||||
}
|
||||
|
||||
function restore(content) {
|
||||
writeFileSync(importMapPath, content)
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Wrapper for `payload generate:importmap` that always injects dummy S3_*
|
||||
* envs (when unset) so the generated importMap carries the
|
||||
* S3ClientUploadHandler entry — regenerating without the S3_* envs silently
|
||||
* orphans it and the admin goes blank in production (class
|
||||
* OPS69/OPS72/OPS73). Dummy values are fine: the generator only iterates the
|
||||
* config, it never connects to the bucket.
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process'
|
||||
|
||||
import { S3_STORAGE_ENV_KEYS } from './lib/importMapContract.mjs'
|
||||
|
||||
const DUMMY = {
|
||||
S3_BUCKET: 'dev-dummy-bucket',
|
||||
S3_ENDPOINT: 'http://127.0.0.1:3900',
|
||||
S3_ACCESS_KEY_ID: 'dev-dummy-access-key',
|
||||
S3_SECRET_ACCESS_KEY: 'dev-dummy-secret-key',
|
||||
}
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
// Same NODE_OPTIONS as before — the payload CLI loads server-only modules.
|
||||
NODE_OPTIONS: '--no-deprecation --conditions=react-server',
|
||||
...Object.fromEntries(
|
||||
S3_STORAGE_ENV_KEYS.map((key) => [key, process.env[key]?.trim() || DUMMY[key]]),
|
||||
),
|
||||
}
|
||||
|
||||
const result = spawnSync('payload', ['generate:importmap'], {
|
||||
stdio: 'inherit',
|
||||
env,
|
||||
})
|
||||
|
||||
process.exit(result.status ?? 1)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/**
|
||||
* Contract shared by the importMap unit pin and the CI guard. The admin goes
|
||||
* blank in production when the importMap loses the S3 upload handler entry
|
||||
* (class OPS69/OPS72/OPS73 — the importMap regenerated without the S3_* envs).
|
||||
*/
|
||||
export const S3_UPLOAD_HANDLER_KEY = '@payloadcms/storage-s3/client#S3ClientUploadHandler'
|
||||
|
||||
export const S3_UPLOAD_HANDLER_IMPORT_PREFIX =
|
||||
'import { S3ClientUploadHandler as S3ClientUploadHandler_'
|
||||
|
||||
/**
|
||||
* Env keys that gate the s3Storage plugin (see src/utilities/mediaStorage.ts).
|
||||
* Kept in sync by the `importMapContract` unit pin.
|
||||
*/
|
||||
export const S3_STORAGE_ENV_KEYS = [
|
||||
'S3_BUCKET',
|
||||
'S3_ENDPOINT',
|
||||
'S3_ACCESS_KEY_ID',
|
||||
'S3_SECRET_ACCESS_KEY',
|
||||
]
|
||||
64
scripts/predev-importmap.mjs
Normal file
64
scripts/predev-importmap.mjs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Predev hook: generate importMap if missing or stale (OPS99).
|
||||
*
|
||||
* The importMap is now a build artifact, not committed to git. This script
|
||||
* ensures it exists before `pnpm dev` starts, using dummy S3_* envs.
|
||||
*
|
||||
* Checks if the file exists and is newer than payload.config.ts.
|
||||
* If missing or stale, regenerates with dummy S3_* envs.
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { existsSync, statSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const importMapPath = path.join(repoRoot, 'src/app/(payload)/admin/importMap.js')
|
||||
const payloadConfigPath = path.join(repoRoot, 'payload.config.ts')
|
||||
|
||||
// Dummy S3_* envs for generation (same as Dockerfile and CI guard)
|
||||
const DUMMY_S3_ENV = {
|
||||
S3_BUCKET: 'dev-dummy',
|
||||
S3_ENDPOINT: 'http://127.0.0.1:3900',
|
||||
S3_ACCESS_KEY_ID: 'dev-dummy',
|
||||
S3_SECRET_ACCESS_KEY: 'dev-dummy',
|
||||
}
|
||||
|
||||
function needsRegeneration() {
|
||||
if (!existsSync(importMapPath)) return true
|
||||
if (!existsSync(payloadConfigPath)) return false
|
||||
|
||||
const importMapMtime = statSync(importMapPath).mtimeMs
|
||||
const configMtime = statSync(payloadConfigPath).mtimeMs
|
||||
return configMtime > importMapMtime
|
||||
}
|
||||
|
||||
function generateImportMap() {
|
||||
console.log('[predev-importmap] generating importMap with dummy S3_* envs...')
|
||||
const env = {
|
||||
...process.env,
|
||||
NODE_OPTIONS: '--no-deprecation --conditions=react-server',
|
||||
PAYLOAD_SECRET: process.env.PAYLOAD_SECRET || 'dev-secret',
|
||||
DATABASE_URL: process.env.DATABASE_URL || 'postgresql://dev:dev@127.0.0.1:5432/teqo',
|
||||
...DUMMY_S3_ENV,
|
||||
}
|
||||
|
||||
try {
|
||||
execFileSync('pnpm', ['exec', 'payload', 'generate:importmap'], {
|
||||
cwd: repoRoot,
|
||||
env,
|
||||
stdio: 'inherit',
|
||||
})
|
||||
console.log('[predev-importmap] importMap generated successfully')
|
||||
} catch (_error) {
|
||||
console.error('[predev-importmap] failed to generate importMap')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if (needsRegeneration()) {
|
||||
generateImportMap()
|
||||
} else {
|
||||
console.log('[predev-importmap] importMap is up to date')
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import { readFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
S3_UPLOAD_HANDLER_IMPORT_PREFIX,
|
||||
S3_UPLOAD_HANDLER_KEY,
|
||||
} from '../../scripts/lib/importMapContract.mjs'
|
||||
|
||||
// The admin goes blank in production when this entry is missing: with the
|
||||
// S3_* envs set, the media collection uses the s3Storage plugin and the admin
|
||||
// config references this handler — getFromImportMap returns undefined, the
|
||||
// Payload root never mounts, and the admin renders an empty page with zero
|
||||
// console errors (class OPS69/OPS72/OPS73; orphaned again by 1c865bd8,
|
||||
// 2026-08-23). Regenerating the importMap without the S3_* envs silently
|
||||
// removes the entry — this pin fails the exact drift.
|
||||
|
||||
const importMapPath = path.resolve(__dirname, '../../src/app/(payload)/admin/importMap.js')
|
||||
|
||||
describe('importMap (admin)', () => {
|
||||
it('keeps the S3ClientUploadHandler entry required by the prod S3 storage', () => {
|
||||
const source = readFileSync(importMapPath, 'utf8')
|
||||
|
||||
// Import + map entry, like the generator emits (+2 lines in the file).
|
||||
expect(source).toContain(S3_UPLOAD_HANDLER_IMPORT_PREFIX)
|
||||
expect(source).toContain(`${S3_UPLOAD_HANDLER_KEY}": S3ClientUploadHandler_`)
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue