fix(scripts): convert reset-db.js to ESM + require ADMIN_INITIAL_PASSWORD #25
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#25
Loading…
Reference in a new issue
No description provided.
Delete branch "convoy/fix-reset-db-script"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Folds two queued follow-ups from the
pick-a-namearchitect audit (convert-reset-db-to-esm+purge-weak-creds-from-helpers) into a single P2 hygiene convoy. Three bugs inscripts/reset-db.js, all fixed atomically by mirroring the proven post-drop-public-setupshape ofsetup-neon-db.js(commitb63b509).Bugs fixed
require('dotenv'),require('@neondatabase/serverless'), inlinerequire('bcryptjs').package.jsonhas"type": "module"sincebump-next-js, sonpm run reset-dbthrewReferenceErroron Node 22.x. Same bug pattern that hitsetup-neon-db.jspre-drop-public-setupB2.bcrypt.hash('admin123', 12)). Same anti-patterndrop-public-setupB1 removed fromsetup-neon-db.js.console.log('Admin Password: admin123')). Security anti-pattern; post-DPSsetup-neon-db.jsdoes NOT echo passwords.Fix shape (verbatim mirror of
setup-neon-db.js)dotenv,neon,bcrypt)ADMIN_INITIAL_PASSWORDenv-var check at function top with helpful error message pointing to README "First-time admin setup"bcrypt.hash(adminPassword, 12)instead of literalON CONFLICT (email) DO NOTHINGon INSERT (defensive against double-run, matchessetup-neon-db.jsline 149)Verification
node --check scripts/reset-db.js: exit 0npm run lint: 128 problems (baseline preserved, no regression)npm run test:run: 21/21 passrequire(| 0admin123| 0'Admin Password'inscripts/reset-db.jsADMIN_INITIAL_PASSWORDreferences (docstring, const, error msg)NOT live-tested — script is destructive (drops all tables). Operator can optionally run
npm run reset-dbagainst a non-prod Neon branch post-merge to verify end-to-end.Test plan
npm run reset-dbagainst a throwaway Neon branch withADMIN_INITIAL_PASSWORDsetFollow-ups surfaced
lint-against-cjs-in-esm-scripts(P3 polish — add ESLint rule to prevent any futurerequire()inscripts/**under"type": "module"). Surfaced for future convoy queue.Convoy:
.convoys/fix-reset-db-script.mdMade with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.