create-next-style-guide 0.1.2 → 0.1.4
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/dist/index.js +379 -74
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/template/.env.example +12 -2
- package/template/.env.production.example +11 -0
- package/template/.env.staging.example +12 -0
- package/template/README.md +3 -0
- package/template/docs/style-guide/ops/env.md +23 -0
- package/template/docs/style-guide/overview/architecture.md +1 -1
- package/template/gitignore +2 -0
package/package.json
CHANGED
package/template/.env.example
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
# Local / development — copy to `.env`
|
|
2
|
+
# cp .env.example .env
|
|
3
|
+
#
|
|
4
|
+
# Other templates: `.env.staging.example`, `.env.production.example`
|
|
5
|
+
|
|
1
6
|
# Public app URL (browser)
|
|
2
7
|
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
3
8
|
|
|
4
|
-
#
|
|
5
|
-
API_URL=http://localhost:8000
|
|
9
|
+
# API origin (server + client)
|
|
6
10
|
NEXT_PUBLIC_API_URL=http://localhost:8000
|
|
11
|
+
|
|
12
|
+
# Optional server-only API origin (if you proxy and keep secrets off the client)
|
|
13
|
+
# API_URL=http://localhost:8000
|
|
14
|
+
|
|
15
|
+
# Auth.js (only when auth=authjs was enabled at scaffold)
|
|
16
|
+
# AUTH_SECRET=
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Production — do not copy secrets into git.
|
|
2
|
+
# Set these in Vercel / Docker / your host secret manager.
|
|
3
|
+
|
|
4
|
+
NEXT_PUBLIC_APP_URL=https://example.com
|
|
5
|
+
NEXT_PUBLIC_API_URL=https://api.example.com
|
|
6
|
+
|
|
7
|
+
# API_URL=https://api.example.com
|
|
8
|
+
|
|
9
|
+
# Auth.js — required in production when authjs is enabled
|
|
10
|
+
# AUTH_SECRET=
|
|
11
|
+
# Generate: openssl rand -base64 32
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Staging — copy to `.env.staging` (or inject via your host / CI)
|
|
2
|
+
# cp .env.staging.example .env.staging
|
|
3
|
+
#
|
|
4
|
+
# Never commit real secrets. Prefer the host’s secret store.
|
|
5
|
+
|
|
6
|
+
NEXT_PUBLIC_APP_URL=https://staging.example.com
|
|
7
|
+
NEXT_PUBLIC_API_URL=https://api.staging.example.com
|
|
8
|
+
|
|
9
|
+
# API_URL=https://api.staging.example.com
|
|
10
|
+
|
|
11
|
+
# Auth.js
|
|
12
|
+
# AUTH_SECRET=
|
package/template/README.md
CHANGED
|
@@ -21,8 +21,11 @@ Next.js App Router app generated with [next-style-guide](https://github.com/alid
|
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
cp .env.example .env
|
|
24
|
+
# Staging / production templates: .env.staging.example · .env.production.example
|
|
24
25
|
__PACKAGE_MANAGER__ install
|
|
25
26
|
__PACKAGE_MANAGER__ dev
|
|
26
27
|
```
|
|
27
28
|
|
|
29
|
+
Env docs: [`docs/style-guide/ops/env.md`](docs/style-guide/ops/env.md)
|
|
30
|
+
|
|
28
31
|
App: [http://localhost:3000](http://localhost:3000)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Environment
|
|
2
|
+
|
|
3
|
+
Validated public env lives in `src/lib/env.ts` (`NEXT_PUBLIC_*` only).
|
|
4
|
+
|
|
5
|
+
## Templates
|
|
6
|
+
|
|
7
|
+
| File | Use |
|
|
8
|
+
|------|-----|
|
|
9
|
+
| `.env.example` | Local development → copy to `.env` |
|
|
10
|
+
| `.env.staging.example` | Staging values / CI staging |
|
|
11
|
+
| `.env.production.example` | Production checklist (set on the host) |
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cp .env.example .env
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`.env`, `.env.local`, `.env.*.local` are gitignored. `*.example` files are safe to commit.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
1. Browser-visible values must use the `NEXT_PUBLIC_` prefix.
|
|
22
|
+
2. Secrets (e.g. `AUTH_SECRET`) never go in `NEXT_PUBLIC_*` or client bundles.
|
|
23
|
+
3. Staging/production: prefer the host secret store over committed `.env` files.
|
|
@@ -18,4 +18,4 @@ src/hooks/ · types/ · constants/
|
|
|
18
18
|
2. **Colocate by usage** — one route → that route's `_components/`; two+ routes → `src/components/`.
|
|
19
19
|
3. **Server first** — prefer RSC; `"use client"` only at the leaves that need interactivity.
|
|
20
20
|
4. **One HTTP doorway** — `src/lib/http.ts` and/or generated `src/endpoints/*` (when enabled). Avoid ad-hoc `fetch` in UI.
|
|
21
|
-
5. **Split server cache vs UI state** — TanStack Query
|
|
21
|
+
5. **Split server cache vs UI state** — When both are enabled: **TanStack Query** owns server/async cache (lists, refetch, mutations). **Zustand/Redux** owns client-only UI/session flags. Do not mirror API lists into the store.
|