Skip to content

Add CLI update prompts, system notices, and admin broadcast - #280

Merged
neuromechanist merged 2 commits into
devfrom
279-cli-update-prompts-and-admin-broadcast-notifications
Mar 11, 2026
Merged

neuromechanist merged 2 commits into
devfrom
279-cli-update-prompts-and-admin-broadcast-notifications

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Implements #279 across three features:

  • CLI update check: Non-blocking npm registry check with 24h cache (~/.config/nemar/update-check.json). Displays a yellow banner after command output when a newer version is available. Detects bun vs bunx install method. Disabled with NEMAR_NO_UPDATE_CHECK=1.
  • System notices: D1-backed notices with level (info/warning/critical), scope (all/admins/members), and optional expiry. Admin CRUD via nemar admin notice list/set/clear. CLI fetches and displays active notices on startup with per-account dismissal tracking.
  • Admin broadcast emails: nemar admin notify --to all|admins|members --subject "..." --body "..." sends markdown-formatted emails via Resend batch API (100-recipient chunks). New announcements email preference category (opt-out, defaults enabled). Audit trail in broadcast_emails D1 table.

New files

  • src/lib/update-check.ts - CLI update check with cache
  • src/lib/notices.ts - CLI notice display and dismissal
  • backend/src/services/notices.ts - Notice CRUD service
  • backend/src/services/broadcast.ts - Broadcast service + markdown-to-HTML converter
  • backend/src/db/migrations/0016_notices.sql - Notices table
  • backend/src/db/migrations/0017_broadcast_emails.sql - Broadcast audit table

Modified files

  • src/index.ts - Update check hooks, notice preAction, parseAsync
  • src/lib/config.ts - Added dismissedNoticeIds field
  • src/lib/api.ts - New API functions, announcements in EmailPreferences
  • src/commands/admin.ts - Notice + notify commands, announcements in email-prefs
  • backend/src/services/email.ts - Added announcements to EmailPreferences
  • backend/src/routes/admin.ts - Notice CRUD routes, broadcast endpoint
  • backend/src/index.ts - GET /notices with optional auth
  • test/email-preferences.test.ts - Updated expectations for announcements field

Test plan

  • All 604 existing tests pass (0 failures)
  • Build succeeds (CLI + backend)
  • TypeScript type-check passes
  • E2E: Create a notice, verify it appears in CLI, clear it
  • E2E: Broadcast with --dry-run, then real send
  • Verify update check banner appears after cache populated

- CLI update check: non-blocking npm registry check with 24h cache,
  yellow banner after command output, bun/bunx install detection
- System notices: D1-backed notices with level/scope/expiry, admin
  CRUD commands, CLI display on preAction with dismissal tracking
- Admin broadcast emails: markdown-to-HTML converter, Resend batch
  API in 100-recipient chunks, announcements email preference
- Migrations 0016 (notices) and 0017 (broadcast_emails)

Closes #279
@github-actions

github-actions Bot commented Mar 11, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR280

Version: 0.7.17-PR280.501382d
Commit: 501382d


🤖 Updated on each push.

- Add try-catch to GET /notices route for graceful degradation
- Add verbose logging to empty catches in update-check and notices
- Remove redundant NoticeRow interface in notices service
- Add audit failure warning and missing data warning in broadcast
- Remove redundant updateBannerPrinted guard in index.ts
- Add .catch() to program.parseAsync()
- Fix "all disabled" test to actually disable announcements
- Add unit tests for markdownToEmailHtml and normalizeVersion
@neuromechanist
neuromechanist merged commit 1fea691 into dev Mar 11, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the 279-cli-update-prompts-and-admin-broadcast-notifications branch March 11, 2026 08:29

This branch was previously deployed

1 inactive deployment
npm — 501382d4 Deployed Mar 11, 2026 by neuromechanist via publish #480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant