@quyentran93/servercn-cli 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/dist/cli.js +2778 -0
- package/dist/cli.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Servercn
|
|
2
|
+
|
|
3
|
+
Servercn is a component registry for building Node.js backends by composition.
|
|
4
|
+
|
|
5
|
+
> The shadcn/ui philosophy for Node.js backends
|
|
6
|
+
|
|
7
|
+
Visit [Servercn](https://servercn.vercel.app) for more information.
|
|
8
|
+
|
|
9
|
+
[GitHub Link](https://github.com/akkaldhami/servercn)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx servercn-cli init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Existing projects: upgrades & template drift
|
|
20
|
+
|
|
21
|
+
`init` copies a **snapshot** of a foundation and registry at that moment. When you bump `servercn-cli` or we publish new templates, your repo is **not** auto-updated.
|
|
22
|
+
|
|
23
|
+
| What changed upstream | What to do in an already-initialized project |
|
|
24
|
+
|------------------------|---------------------------------------------|
|
|
25
|
+
| CLI only (bugfixes, logging) | Usually **nothing** unless you rely on a specific fix. |
|
|
26
|
+
| Registry / templates (new files, `@servercn` markers, `--merge` wiring, moved paths) | Read **release notes**; then **patch manually** from docs, run `add <slug> --merge` (after markers exist), use `add --force` if you accept overwrites, or **create a new project** and port code. |
|
|
27
|
+
| Foundation (e.g. `express-starter` layout) | **No automatic sync.** Compare diffs manually, or scaffold a new project and migrate. |
|
|
28
|
+
|
|
29
|
+
Run **`npx servercn-cli doctor`** in your project for a short checklist and optional checks for merge markers (Express starters with merge-capable components).
|
|
30
|
+
|
|
31
|
+
## Add Components
|
|
32
|
+
|
|
33
|
+
Add specific modules to your existing project. This allows for incremental adoption.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx servercn-cli add [component-name]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Add multiple components like this:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx servercn-cli add logger jwt-utils
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Scaffold: `--force` vs `--merge`
|
|
46
|
+
|
|
47
|
+
By default, `add` **skips** files that already exist so your edits are preserved. That can leave a component half-applied when templates share paths with your foundation.
|
|
48
|
+
|
|
49
|
+
- **`--force` (`-f`)** replaces every conflicting file with the template from the registry. You may lose local changes; run lint/typecheck afterward.
|
|
50
|
+
- **`--merge`** applies **merge-only** template files: they must be a single pair of lines
|
|
51
|
+
`// @servercn:begin <slug>` … `// @servercn:end <slug>`
|
|
52
|
+
The CLI replaces **only** the inner region in the existing file. Your code **outside** those markers stays intact.
|
|
53
|
+
|
|
54
|
+
**Components with merge wiring in the registry (slug = marker id):**
|
|
55
|
+
|
|
56
|
+
| Slug | Merge target (typical) |
|
|
57
|
+
|------|-------------------------|
|
|
58
|
+
| `rate-limiter` | `src/app.ts` |
|
|
59
|
+
| `security-header` | `src/app.ts` |
|
|
60
|
+
| `async-handler` | `src/app.ts` (MVC) or `src/routes/index.ts` (feature architecture) |
|
|
61
|
+
|
|
62
|
+
The `express-starter` foundation ships **empty** marker blocks for these slugs where needed. Older projects must add the same blocks manually (or use `--force`).
|
|
63
|
+
|
|
64
|
+
`--merge` is **ignored** when `--force` is set.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx servercn-cli add rate-limiter --merge
|
|
68
|
+
npx servercn-cli add security-header --merge
|
|
69
|
+
npx servercn-cli add async-handler --merge
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Run `npm run test:merge-marker` in this package to verify the marker merge helper.
|
|
73
|
+
|
|
74
|
+
Visit [Servercn](https://servercn.vercel.app) for more information.
|