feat(admin): add ephemeral staging DB, read-only posts overview, and dynamic search
- Implement ephemeral staging mode (APP_ENV=staging) to isolate test/dev DB writes in /tmp - Add read-only posts management dashboard under /guanli/posts with live links and comment counters - Add hot re-indexing endpoint (/guanli/reindex) to refresh Markdown without restarting server - Replace static recommended search config with dynamic frequency-based trending searches - Remove early scaffold mockup file (dropbox/zh.md) and clean legacy mock test queries - Add native Makefile with dev, dev-persistent, test, lint, and docker targets - Update test suite and documentation for development workflows
This commit is contained in:
@@ -188,22 +188,36 @@ Post content in Chinese...
|
||||
|
||||
---
|
||||
|
||||
## 8. Development & Deployment
|
||||
## 8. Development & Makefile Workflows
|
||||
|
||||
### Run Locally
|
||||
The platform includes a native `Makefile` designed to protect your production data while developing and testing:
|
||||
|
||||
```bash
|
||||
# 1. Install dependencies
|
||||
npm install
|
||||
|
||||
# 2. Run automated test suite (6/6 suites)
|
||||
npm test
|
||||
# 2. Run local development in Safe Ephemeral Staging Mode (Default)
|
||||
make dev
|
||||
# -> Copies site.db to a temp file in /tmp so your real database is NEVER mutated.
|
||||
# -> Discards all test queries and mock comments automatically on exit.
|
||||
|
||||
# 3. Start local development server (uses ./sample-content by default)
|
||||
npm start
|
||||
# Server runs at http://localhost:3000
|
||||
# 3. Run development in Persistent Mode (only when you intentionally want to save changes to site.db)
|
||||
make dev-persistent
|
||||
|
||||
# 4. Run automated test suite (in isolated temp DB)
|
||||
make test
|
||||
|
||||
# 5. Run project linter
|
||||
make lint
|
||||
|
||||
# 6. Clean temporary staging artifacts
|
||||
make clean
|
||||
```
|
||||
|
||||
### Database Isolation Architecture
|
||||
- **Safe by Default**: Running `npm run dev` or `make dev` automatically runs with `APP_ENV=staging`.
|
||||
- **Ephemeral Sandbox**: In staging or test mode (`NODE_ENV=test`), `server/services/db.js` mirrors the real SQLite database into a temporary sandbox in `os.tmpdir()`. You get 100% full application functionality, but all writes are discarded on exit, keeping `sample-content/data/site.db` 100% pristine.
|
||||
|
||||
### Docker Build
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user