@navneet_25/tempjs 1.0.4 → 2.0.0

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 CHANGED
@@ -30,27 +30,479 @@ List templates from the CLI:
30
30
  tempjs list
31
31
  ```
32
32
 
33
- ## CLI usage
33
+ ## CLI reference
34
+
35
+ ### Discover templates
36
+
37
+ #### `tempjs list`
38
+
39
+ Shows every available template with a short summary:
40
+
41
+ ```bash
42
+ tempjs list
43
+ ```
44
+
45
+ Output includes:
46
+
47
+ - Template **id** (what you pass to `tempjs hotel`, etc.)
48
+ - **Name** and **description**
49
+ - **Tags** (e.g. `admin`, `cms`, `gallery`)
50
+ - **Stack** preview (first few technologies)
51
+
52
+ Run `tempjs info <id>` for full details.
53
+
54
+ #### `tempjs info <template-id>`
55
+
56
+ Shows everything a developer needs before choosing a template:
57
+
58
+ ```bash
59
+ tempjs info hotel
60
+ tempjs info real-estate
61
+ ```
62
+
63
+ Displays:
64
+
65
+ | Field | Example |
66
+ |-------|---------|
67
+ | Version | `1.0.0` |
68
+ | Stack | Next.js 16, React 19, Prisma, MariaDB, … |
69
+ | Node.js | `>=20` |
70
+ | Package manager | `pnpm` |
71
+ | Typical setup time | `~10 min` |
72
+ | Docker | Yes / No |
73
+ | Tags | `admin`, `cms`, `gallery` |
74
+ | Features | Bullet list of capabilities |
75
+ | Source path | `templates/hotel-website-template` |
76
+ | Repository | `github.com/SidhartGautam25/templates` |
77
+ | Quick start commands | Copy-paste examples |
78
+ | Docs file | `DEVELOPER_GUIDE.md` (in generated project) |
79
+
80
+ If the template id is wrong:
81
+
82
+ ```text
83
+ Unknown template: xyz
84
+ Run `tempjs list` to see available templates.
85
+ ```
86
+
87
+ ---
88
+
89
+ ### Create a project
90
+
91
+ #### Basic (copy only)
92
+
93
+ ```bash
94
+ mkdir my-client && cd my-client
95
+ tempjs hotel
96
+ ```
97
+
98
+ Copies template files into the **current directory** (not a subfolder). Does not run theme, brand, or database setup.
99
+
100
+ #### Interactive full setup
101
+
102
+ ```bash
103
+ tempjs hotel config
104
+ # or
105
+ tempjs hotel --config
106
+ ```
107
+
108
+ After copying, prompts for:
109
+
110
+ 1. **Theme** (theme1–theme5)
111
+ 2. **Font pairing** (default, inter, lora-montserrat, …)
112
+ 3. **Brand & contact** (name, URL, phone, email, address)
113
+ 4. **Database & admin** (.env + optional `prisma db push`)
114
+
115
+ #### Non-interactive full setup
116
+
117
+ Use `--yes` (or `-y` / `--no-prompt`) to skip every prompt. Values come from flags; anything not provided uses template defaults.
118
+
119
+ ```bash
120
+ mkdir mi-plaza && cd mi-plaza
121
+
122
+ tempjs hotel --config --yes \
123
+ --theme theme2 \
124
+ --name "Mi Plaza" \
125
+ --base-url "https://miplaza.com" \
126
+ --db-host localhost \
127
+ --db-name mi_plaza_db \
128
+ --admin-user admin \
129
+ --admin-password mypass \
130
+ --skip-db-push
131
+ ```
132
+
133
+ #### Partial automation
134
+
135
+ Configure only what you care about; the rest uses defaults:
136
+
137
+ ```bash
138
+ tempjs hotel --config --yes --theme theme3 --name "Mi Plaza"
139
+ ```
140
+
141
+ Then configure the rest later in the same project directory:
142
+
143
+ ```bash
144
+ tempjs init-db --yes --db-host localhost --db-name mi_plaza_db
145
+ tempjs brand --yes --name "Mi Plaza" --email "hello@miplaza.com"
146
+ tempjs theme --theme theme2 --yes
147
+ tempjs font --font inter --yes
148
+ ```
149
+
150
+ #### Fetch progress
151
+
152
+ When downloading a template, tempjs reports size, file count, and duration:
153
+
154
+ ```text
155
+ Fetching template "hotel"... done (4.2 MB, 130 files, 1.8s, download)
156
+ ```
157
+
158
+ From a linked local dev copy (no network):
159
+
160
+ ```text
161
+ Fetching template "hotel"... done (130 files, 0ms, local copy)
162
+ ```
163
+
164
+ ---
165
+
166
+ ### Template versioning (`.tempjs.json`)
167
+
168
+ Every new project is stamped with a `.tempjs.json` file at the root:
169
+
170
+ ```json
171
+ {
172
+ "template": "hotel",
173
+ "templateVersion": "1.2.0",
174
+ "templateDirectory": "hotel-website-template",
175
+ "generatedAt": "2026-08-26T04:52:13.543Z",
176
+ "updatedAt": "2026-08-26T05:10:00.000Z",
177
+ "repository": "SidhartGautam25/templates",
178
+ "branch": "main",
179
+ "fileHashes": {
180
+ "package.json": "abc123…",
181
+ "lib/database/prisma.ts": "def456…"
182
+ }
183
+ }
184
+ ```
185
+
186
+ | Field | Purpose |
187
+ |-------|---------|
188
+ | `template` | CLI id (`hotel`, `real-estate`) |
189
+ | `templateVersion` | Manifest version when last stamped |
190
+ | `generatedAt` | First `tempjs` run in this folder |
191
+ | `updatedAt` | Last successful `tempjs update --merge` |
192
+ | `fileHashes` | SHA-256 of each template file at stamp time (baseline for updates) |
193
+
194
+ **Commit `.tempjs.json`** to your client repo so you know which template version the project started from.
195
+
196
+ Check version in manifest:
197
+
198
+ ```bash
199
+ tempjs list # shows v1.2.0 next to template name
200
+ tempjs info hotel # shows full version in details
201
+ ```
202
+
203
+ When maintainers bump `"version"` in `templates.json` and push, clients can pull fixes safely.
204
+
205
+ ---
206
+
207
+ ### Update an existing project (`tempjs update`)
208
+
209
+ Use inside a project that has `.tempjs.json` (created by `tempjs hotel`, etc.).
210
+
211
+ #### Check what changed (read-only)
212
+
213
+ ```bash
214
+ cd mi-plaza
215
+ tempjs update --check
216
+ ```
217
+
218
+ Example output:
219
+
220
+ ```text
221
+ Template update report: Hotel Website
222
+ Project version: 1.1.0
223
+ Latest version: 1.2.0
224
+
225
+ Safe updates (1) — template changed, you did not edit:
226
+ ~ lib/utils/slugify.ts
227
+
228
+ Conflicts (1) — you modified these files:
229
+ ! app/components/Hero.tsx
230
+
231
+ 129 file(s) already match the latest template.
232
+ ```
233
+
234
+ | Report section | Meaning |
235
+ |----------------|---------|
236
+ | **New files** | Added in latest template; not in your project yet |
237
+ | **Safe updates** | Template changed; you did **not** edit since generation → can auto-merge |
238
+ | **Conflicts** | You modified files that also changed in the template → manual review |
239
+ | **Removed from template** | No longer in template; **not deleted** from your project |
240
+
241
+ #### Apply non-conflicting updates
242
+
243
+ ```bash
244
+ tempjs update --merge
245
+ # or without prompt:
246
+ tempjs update --merge --yes
247
+ ```
248
+
249
+ Only **new files** and **safe updates** are copied. Conflicts are listed but never overwritten.
250
+
251
+ **Protected paths** (never touched by merge):
252
+
253
+ - `.env`, `.env.*` (except `.env.example`)
254
+ - `constants/site.ts` (brand/contact)
255
+ - `.tempjsrc`, `app/tempjs-theme.css`
256
+ - `.tempjs.json` (updated after merge with new version + hashes)
257
+
258
+ #### Full workflow example
259
+
260
+ ```bash
261
+ # 1. Create client project (stamped v1.1.0)
262
+ mkdir mi-plaza && cd mi-plaza
263
+ tempjs hotel --config --yes --name "Mi Plaza"
264
+
265
+ # 2. Customize freely
266
+ # edit app/components/Hero.tsx, constants/site.ts, .env …
267
+
268
+ # 3. Later — maintainer published template v1.2.0 with bug fixes in lib/
269
+
270
+ tempjs update --check # see safe updates vs conflicts
271
+ tempjs update --merge --yes # apply only non-conflicting fixes
272
+
273
+ # 4. Manually merge conflicts if any (e.g. Hero.tsx)
274
+ ```
275
+
276
+ Use `--remote` to fetch the latest template from GitHub instead of a local linked copy:
277
+
278
+ ```bash
279
+ tempjs update --check --remote
280
+ tempjs update --merge --remote --yes
281
+ ```
282
+
283
+ ---
284
+
285
+ ### Post-init commands (inside a generated project)
286
+
287
+ Run these from the project root (where `package.json` exists):
288
+
289
+ | Command | Purpose |
290
+ |---------|---------|
291
+ | `tempjs theme` | Change color theme |
292
+ | `tempjs font` | Change font pairing |
293
+ | `tempjs brand` | Update brand name, URL, contact info |
294
+ | `tempjs init-db` | Create/update `.env` and sync Prisma schema |
295
+
296
+ Examples:
297
+
298
+ ```bash
299
+ tempjs theme --theme theme3 --yes
300
+ tempjs brand --yes --name "New Name" --email "new@example.com"
301
+ tempjs init-db --yes --db-host 127.0.0.1 --db-name my_db --db-push
302
+ ```
303
+
304
+ When re-running with `--yes`, unspecified fields keep existing values from `constants/site.ts` or `.env`.
305
+
306
+ ---
307
+
308
+ ### All CLI flags
309
+
310
+ #### General
311
+
312
+ | Flag | Short | Description |
313
+ |------|-------|-------------|
314
+ | `--config` | | Run theme + font + brand + database setup after copy |
315
+ | `--yes` | `-y` | Skip all prompts |
316
+ | `--no-prompt` | | Same as `--yes` |
317
+ | `--force` | `-f` | Overwrite existing files; auto-confirm overwrite warnings |
318
+ | `--remote` | | Fetch from GitHub even if local templates exist |
319
+ | `--init-git` | | Run `git init` after copying |
320
+ | `--help` | `-h` | Show help |
321
+
322
+ #### Theme & typography
323
+
324
+ | Flag | Values | Description |
325
+ |------|--------|-------------|
326
+ | `--theme` | `theme1` … `theme5` | Color theme id |
327
+ | `--font` | See table below | Font pairing id |
328
+
329
+ **Theme ids**
330
+
331
+ | Id | Name |
332
+ |----|------|
333
+ | `theme1` | Slate / Blue (default) |
334
+ | `theme2` | Forest / Green |
335
+ | `theme3` | Purple / Violet |
336
+ | `theme4` | Red / Crimson |
337
+ | `theme5` | Amber / Gold |
338
+
339
+ **Font ids**
340
+
341
+ | Id | Pairing |
342
+ |----|---------|
343
+ | `default` | Playfair Display + Outfit (default) |
344
+ | `inter` | Inter + Inter |
345
+ | `lora-montserrat` | Lora + Montserrat |
346
+ | `merriweather-open-sans` | Merriweather + Open Sans |
347
+ | `cinzel-montserrat` | Cinzel + Montserrat |
348
+
349
+ With `--yes`, if `--theme` / `--font` is omitted, the current or default id is used.
350
+
351
+ #### Brand & contact
352
+
353
+ | Flag | Example | Written to |
354
+ |------|---------|------------|
355
+ | `--name` | `"Mi Plaza"` | `constants/site.ts` → brand name |
356
+ | `--short-name` | `"Mi Plaza"` | Short / display name |
357
+ | `--base-url` | `"https://miplaza.com"` | Site URL (also derives `wwwHost`) |
358
+ | `--phone` | `"9876543210"` | Raw phone number |
359
+ | `--phone-display` | `"+91 98765 43210"` | Formatted display phone |
360
+ | `--country-code` | `"91"` | Phone country code |
361
+ | `--email` | `"info@miplaza.com"` | Contact email |
362
+ | `--address` | `"Pune, Maharashtra, India"` | Full address string |
363
+
364
+ Quotes are optional in the shell when the value has no spaces:
365
+
366
+ ```bash
367
+ --email info@miplaza.com
368
+ --name "Mi Plaza"
369
+ --base-url=https://miplaza.com # --key=value also works
370
+ ```
371
+
372
+ #### Database & admin
373
+
374
+ | Flag | Example | Written to |
375
+ |------|---------|------------|
376
+ | `--db-host` | `localhost` | `.env` → `DATABASE_URL` host |
377
+ | `--db-port` | `3306` | Database port |
378
+ | `--db-user` | `root` | Database username |
379
+ | `--db-password` | `secret` | Database password |
380
+ | `--db-name` | `mi_plaza_db` | Database name |
381
+ | `--admin-user` | `admin` | `.env` → `ADMIN_USER` |
382
+ | `--admin-password` | `mypass` | `.env` → `ADMIN_PASSWORD` |
383
+ | `--db-push` | | With `--yes`, run `npx prisma db push` after writing `.env` |
384
+ | `--skip-db-push` | | With `--yes`, skip `prisma db push` |
385
+
386
+ Default database name (if not set): derived from the folder name, e.g. `mi-plaza` → `mi_plaza_db`.
387
+
388
+ **Prisma / database behavior**
389
+
390
+ | Mode | Behavior |
391
+ |------|----------|
392
+ | Interactive `init-db` | Prompts for DB fields; asks whether to run `prisma db push` |
393
+ | `--yes` without flags | Uses defaults / existing `.env` values; runs `prisma db push` |
394
+ | `--yes --skip-db-push` | Writes `.env` only; no Prisma |
395
+ | `--yes --db-push` | Explicitly runs `prisma db push` |
396
+
397
+ Ensure MySQL/MariaDB is running before `--db-push`.
398
+
399
+ ---
400
+
401
+ ### Manifest metadata (`templates.json`)
402
+
403
+ Each template entry can include metadata used by `tempjs list` and `tempjs info`:
404
+
405
+ ```json
406
+ {
407
+ "repository": {
408
+ "owner": "SidhartGautam25",
409
+ "repo": "templates",
410
+ "branch": "main",
411
+ "templatesPath": "templates"
412
+ },
413
+ "templates": {
414
+ "hotel": {
415
+ "directory": "hotel-website-template",
416
+ "name": "Hotel Website",
417
+ "description": "Modern hotel and resort website with admin panel, gallery, and booking features",
418
+ "version": "1.0.0",
419
+ "stack": ["Next.js 16", "React 19", "TypeScript", "Tailwind CSS 4", "Prisma", "MariaDB", "NextAuth"],
420
+ "packageManager": "pnpm",
421
+ "node": ">=20",
422
+ "setupTime": "~10 min",
423
+ "docker": true,
424
+ "tags": ["admin", "cms", "gallery", "booking", "leads"],
425
+ "features": [
426
+ "Admin dashboard for rooms, facilities, reviews, and leads",
427
+ "Gallery and promo banner management",
428
+ "FTP asset upload pipeline"
429
+ ],
430
+ "docs": "DEVELOPER_GUIDE.md"
431
+ }
432
+ }
433
+ }
434
+ ```
435
+
436
+ | Field | Required | Used by |
437
+ |-------|----------|---------|
438
+ | `directory` | Yes | CLI copy path |
439
+ | `name` | Yes | `list`, `info`, success messages |
440
+ | `description` | Yes | `list`, `info` |
441
+ | `version` | No | `info` |
442
+ | `stack` | No | `list`, `info` |
443
+ | `packageManager` | No | `info` |
444
+ | `node` | No | `info` |
445
+ | `setupTime` | No | `info` |
446
+ | `docker` | No | `info` |
447
+ | `tags` | No | `list`, `info` |
448
+ | `features` | No | `info` |
449
+ | `docs` | No | `info` — filename inside generated project |
450
+
451
+ Adding a new template: add the folder + one manifest entry. No CLI code changes required.
452
+
453
+ ---
454
+
455
+ ### Install & update the CLI
456
+
457
+ ```bash
458
+ # First install
459
+ npm install -g @navneet_25/tempjs
460
+
461
+ # Update to latest (recommended after new templates or CLI features)
462
+ npm install -g @navneet_25/tempjs@latest
463
+ ```
464
+
465
+ Current version: **1.4.0** (update, versioning, fetch progress, info, non-interactive flags).
466
+
467
+ See also: [guide.md](./guide.md) for CLI architecture and update algorithm details.
468
+
469
+ Verify:
470
+
471
+ ```bash
472
+ tempjs --help
473
+ tempjs list
474
+ ```
475
+
476
+ ## CLI usage (quick reference)
34
477
 
35
478
  ```bash
36
479
  tempjs list # show available templates
37
- tempjs hotel # create project from hotel template using default theme
38
- tempjs hotel config # create project and run interactive theme/font setup
39
- tempjs theme # change/reset the theme of an initialized project
40
- tempjs font # change/reset the font pairing of an initialized project
480
+ tempjs info hotel # detailed template metadata (stack, features, setup)
481
+ tempjs hotel # create project from hotel template
482
+ tempjs hotel config # interactive setup (theme, font, brand, database)
483
+ tempjs hotel --config --yes # non-interactive setup with defaults
484
+ tempjs theme --theme theme3 --yes
485
+ tempjs brand --yes --name "Mi Plaza" --base-url "https://miplaza.com"
486
+ tempjs init-db --yes --db-host localhost --db-name my_db --skip-db-push
41
487
  tempjs real-estate --force # overwrite existing files
42
488
  tempjs --help # show help
43
489
  ```
44
490
 
45
- ### Options
491
+ ### Options (summary)
492
+
493
+ | Option | Description |
494
+ |--------|-------------|
495
+ | `--config` | Run full setup (theme, font, brand, db) after copying |
496
+ | `--yes`, `-y`, `--no-prompt` | Skip all prompts; use defaults or flag values |
497
+ | `--force`, `-f` | Overwrite files without prompting |
498
+ | `--theme`, `--font` | Theme/font id (see CLI reference above) |
499
+ | `--name`, `--base-url`, `--email`, … | Brand/contact fields (non-interactive) |
500
+ | `--db-host`, `--db-name`, `--admin-user`, … | Database and admin credentials |
501
+ | `--db-push` / `--skip-db-push` | Control `prisma db push` with `--yes` |
502
+ | `--remote` | Fetch from GitHub even when local templates exist |
503
+ | `--init-git` | Run `git init` after copying |
46
504
 
47
- | Option | Description |
48
- |---------------|-------------|
49
- | `--config` | Prompt for theme and font pairings during template initialization |
50
- | `--force` | Overwrite files in the current directory without prompting |
51
- | `--remote` | Fetch from GitHub even when a local template copy exists |
52
- | `--init-git` | Run `git init` after copying (optional) |
53
- | `--help` | Show help |
505
+ See **CLI reference** above for full flag tables, theme/font ids, and examples.
54
506
 
55
507
  The CLI copies template **contents** into the current directory — not a nested folder:
56
508
 
@@ -104,7 +556,9 @@ npm link
104
556
 
105
557
  ## Configuration
106
558
 
107
- All template mappings live in **`templates.json`** at the repository root:
559
+ All template mappings and metadata live in **`templates.json`** at the repository root. See **Manifest metadata (`templates.json`)** in the CLI reference for every field.
560
+
561
+ Minimal example:
108
562
 
109
563
  ```json
110
564
  {
@@ -124,6 +578,8 @@ All template mappings live in **`templates.json`** at the repository root:
124
578
  }
125
579
  ```
126
580
 
581
+ For `tempjs info` and richer `tempjs list`, add `version`, `stack`, `tags`, `features`, etc. (documented above).
582
+
127
583
  ### GitHub repository URL
128
584
 
129
585
  Configure in one place — `templates.json` or environment variables:
@@ -134,7 +590,7 @@ Configure in one place — `templates.json` or environment variables:
134
590
  | `TEMPLATES_REPO_OWNER` | GitHub username or org |
135
591
  | `TEMPLATES_REPO_REPO` | Repository name |
136
592
  | `TEMPLATES_REPO_BRANCH`| Branch (default: `main`) |
137
- | `GITHUB_TOKEN` | Optional token for higher API rate limits |
593
+ | `GITHUB_TOKEN` | Optional private repositories only |
138
594
 
139
595
  Example:
140
596
 
@@ -157,36 +613,299 @@ The archive contains the whole templates repo on the wire, but only the requeste
157
613
 
158
614
  ```
159
615
  templates/ # this repository root
160
- ├── README.md
161
- ├── package.json # CLI package (bin: tempjs)
162
- ├── templates.json # manifest + repo config
163
- ├── .gitignore # for THIS repo only (not copied to projects)
616
+ ├── ARCHITECTURE.md # core + overlay design
617
+ ├── packages/
618
+ │ └── core/ # shared source (synced into templates)
619
+ ├── templates/
620
+ │ ├── overlays/ # template-specific source only
621
+ │ │ ├── hotel-website-template/
622
+ │ │ └── real-estate-website-template/
623
+ │ ├── hotel-website-template/ # merged output (what tempjs copies)
624
+ │ └── real-estate-website-template/
625
+ ├── scripts/
626
+ │ └── sync-templates.mjs
627
+ ├── package.json # CLI package + sync scripts
628
+ ├── templates.json
164
629
  ├── cli/
165
- ├── index.js
166
- │ ├── config.js
167
- │ ├── copy.js
168
- │ └── fetch.js
169
- └── templates/
170
- ├── hotel-website-template/
171
- │ ├── .gitignore # copied to generated projects
172
- │ ├── package.json
173
- │ ├── app/
174
- │ └── ...
175
- └── real-estate-website-template/
176
- └── ...
630
+ └── ...
631
+ ```
632
+
633
+ ## Shared core package (Option 1 — implemented)
634
+
635
+ This repo uses **pre-merge sync**: shared code lives in `packages/core/`, template-specific code in `templates/overlays/`, and `pnpm sync-templates` produces the full template folders that `tempjs` copies to users.
636
+
637
+ **Full design doc:** [ARCHITECTURE.md](./ARCHITECTURE.md)
638
+
639
+ ### Quick maintainer commands
640
+
641
+ ```bash
642
+ # After editing packages/core or templates/overlays/*
643
+ pnpm sync-templates
644
+
645
+ # CI / pre-PR check
646
+ pnpm sync-templates:check
647
+ ```
648
+
649
+ ### What developers receive
650
+
651
+ A normal Next.js project with organized `lib/`:
652
+
653
+ - `lib/database/` — Prisma client
654
+ - `lib/features/leads/` — shared lead module
655
+ - `lib/storage/` — FTP uploads
656
+ - `lib/features/<domain>/` — template-specific modules (rooms, projects, …) in overlay
657
+ - `app/` — routes and UI
658
+
659
+ All source is on disk; no submodule, no `@tempjs/core` npm dependency in client projects.
660
+
661
+ ### Comparison (other approaches)
662
+
663
+ | Approach | User gets full source? | Maintained in this repo |
664
+ |----------|------------------------|-------------------------|
665
+ | **Option 1 — pre-merge sync** (current) | Yes | `packages/core` + overlays |
666
+ | CLI merge at copy time | Yes | `packages/core` only in git |
667
+ | npm `@tempjs/core` package | Partial (core in node_modules) | Published package |
668
+
669
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) for diagrams and adding new templates.
670
+
671
+ ---
672
+
673
+ ## Shared core package — design options (reference)
674
+
675
+ Hotel and real-estate templates share a large amount of code (auth, admin shell, leads, FTP, Prisma patterns). A **shared core** reduces duplicate maintenance, but you must decide how that core reaches the **generated project** when someone runs `tempjs hotel`.
676
+
677
+ Generated projects must remain **standalone** — no submodule, no link to the templates repo, no `npm install` required just to get source files from your monorepo layout.
678
+
679
+ Below are the main approaches and what each means for `tempjs` users.
680
+
681
+ ### The core question
682
+
683
+ | Where core lives (your repo) | What `tempjs hotel` must produce |
684
+ |------------------------------|----------------------------------|
685
+ | `packages/core/` (shared) | `hotel-client/` with **all** code needed to build and deploy |
686
+
687
+ The user never sees `packages/core/` as a separate install step unless you explicitly choose that design.
688
+
689
+ ---
690
+
691
+ ### Option 1: Pre-merge into each template (recommended for tempjs)
692
+
693
+ **How it works**
694
+
695
+ - You maintain shared code in `packages/core/` (or `shared/core/`) inside the templates monorepo.
696
+ - A **build/sync script** copies (or rsyncs) core files into each template before commit:
697
+
698
+ ```bash
699
+ pnpm run sync-templates
700
+ # merges packages/core → templates/hotel-website-template/
701
+ # merges packages/core → templates/real-estate-website-template/
702
+ ```
703
+
704
+ - What is **committed** under `templates/hotel-website-template/` already contains the merged code.
705
+ - `tempjs hotel` only extracts that folder — user gets one flat, complete project.
706
+
707
+ ```
708
+ YOUR REPO (maintenance view) WHAT USER GETS (tempjs hotel)
709
+ ───────────────────────── ─────────────────────────────
710
+ packages/core/ hotel-client/
711
+ lib/auth.ts ──sync──► lib/auth.ts
712
+ lib/leads.ts lib/leads.ts
713
+ templates/hotel-website-template/ app/ (hotel-specific)
714
+ app/ (hotel-specific) package.json
715
+ ```
716
+
717
+ **Pros**
718
+
719
+ - Simplest for CLI — no merge logic in `tempjs`
720
+ - User gets 100% source in their repo; easy to customize
721
+ - No extra npm dependency on `@you/template-core`
722
+ - Works with current tarball fetch
723
+
724
+ **Cons**
725
+
726
+ - Duplicated core **in git** across template folders (larger repo)
727
+ - Must run sync script when core changes (can be a CI check)
728
+
729
+ **Maintenance**
730
+
731
+ 1. Fix bug in `packages/core/`
732
+ 2. Run `pnpm sync-templates`
733
+ 3. Commit updated `templates/hotel-website-template/` and `templates/real-estate-website-template/`
734
+ 4. Push — users fetch updated template on next `tempjs hotel`
735
+
736
+ ---
737
+
738
+ ### Option 2: CLI merges core at copy time
739
+
740
+ **How it works**
741
+
742
+ - Core stays only in `packages/core/` (not duplicated in each template folder).
743
+ - `tempjs` downloads/extracts **two** paths from the tarball:
744
+ 1. `packages/core/`
745
+ 2. `templates/hotel-website-template/`
746
+ - CLI merges them into the user's directory (template files override core on conflict).
747
+
748
+ ```
749
+ tempjs fetch
750
+ ├── extract packages/core/ → temp/core/
751
+ └── extract templates/hotel/ → temp/hotel/
752
+ merge(core, hotel) → user's hotel-client/
753
+ ```
754
+
755
+ **Pros**
756
+
757
+ - Single source of core in git — no duplication in template folders
758
+ - User still gets a flat, standalone project (all files copied locally)
759
+
760
+ **Cons**
761
+
762
+ - More complex CLI (merge rules, conflict handling, ordering)
763
+ - Must define what overrides what (template wins over core)
764
+ - Harder to debug if merge goes wrong
765
+
766
+ **Maintenance**
767
+
768
+ - Edit `packages/core/` only
769
+ - Push — CLI merges on every `tempjs hotel` (no per-template sync commit)
770
+
771
+ ---
772
+
773
+ ### Option 3: Published npm package dependency
774
+
775
+ **How it works**
776
+
777
+ - Publish shared code as `@navneet_25/template-core` on npm.
778
+ - Each template's `package.json` includes:
779
+
780
+ ```json
781
+ "dependencies": {
782
+ "@navneet_25/template-core": "^1.0.0"
783
+ }
784
+ ```
785
+
786
+ - `tempjs hotel` copies only the **thin** template (pages, schema, config).
787
+ - User runs `pnpm install` → core lands in `node_modules/@navneet_25/template-core`.
788
+
789
+ **What the user gets**
790
+
791
+ ```
792
+ hotel-client/
793
+ ├── app/ # from template (hotel-specific)
794
+ ├── package.json # lists @navneet_25/template-core
795
+ └── node_modules/
796
+ └── @navneet_25/template-core/ # shared code HERE, not in src/
177
797
  ```
178
798
 
799
+ **Pros**
800
+
801
+ - Clean separation; one core package versioned independently
802
+ - Template folders stay small in the templates repo
803
+
804
+ **Cons**
805
+
806
+ - **Not ideal for agency white-label work** — clients customize by editing `node_modules` or you need a build step anyway
807
+ - Requires publishing and versioning core on every fix
808
+ - Generated project depends on your npm package forever (or until they eject)
809
+ - `tempjs` only transfers template files; **core is not in the tarball path** unless user runs install
810
+
811
+ **When to use**
812
+
813
+ - Internal products where you control upgrades
814
+ - Not ideal if every client project must be fully forkable and editable as plain source
815
+
816
+ ---
817
+
818
+ ### Option 4: pnpm workspace (dev only) + publish flattened templates
819
+
820
+ **How it works**
821
+
822
+ - Monorepo:
823
+
824
+ ```
825
+ packages/core/
826
+ packages/hotel-app/ # imports from @local/core via workspace
827
+ packages/real-estate-app/
828
+ ```
829
+
830
+ - Dev with `workspace:*` references.
831
+ - **Release pipeline** builds each app and outputs a **flattened** tree into `templates/hotel-website-template/` for the CLI (bundle or copy with a tool like `tsup` / custom script).
832
+
833
+ Same end result as Option 1 for users; workspace only helps local dev.
834
+
835
+ ---
836
+
837
+ ### Comparison
838
+
839
+ | Approach | User gets full source? | Core in git once? | CLI complexity | Client customization |
840
+ |----------|------------------------|-------------------|----------------|----------------------|
841
+ | **1. Pre-merge sync** | Yes | No (duplicated in templates) | Low | Easy |
842
+ | **2. CLI merge** | Yes | Yes | High | Easy |
843
+ | **3. npm package** | Partial (core in node_modules) | Yes | Low | Harder |
844
+ | **4. Workspace + flatten** | Yes | Yes (in packages/) | Medium (build step) | Easy |
845
+
846
+ ---
847
+
848
+ ### Recommendation for your project
849
+
850
+ **Start with Option 1 (pre-merge sync script)** unless the repo size or sync friction becomes painful.
851
+
852
+ Reasons:
853
+
854
+ 1. Matches your current `tempjs` design (single folder extract, flat copy).
855
+ 2. Agencies and clients get **all** code in `app/`, `lib/`, etc. — no hidden package.
856
+ 3. No change to tarball fetch or rate limits.
857
+ 4. You can add a GitHub Action: `on push to packages/core → run sync-templates → fail if templates out of date`.
858
+
859
+ **Sketch of a sync script**
860
+
861
+ ```bash
862
+ # scripts/sync-core-to-templates.sh
863
+ CORE=packages/core
864
+ for tpl in hotel-website-template real-estate-website-template; do
865
+ rsync -a --delete "$CORE/" "templates/$tpl/" \
866
+ --exclude template-specific paths if needed
867
+ done
868
+ ```
869
+
870
+ Hotel-specific files stay only in the hotel template; only truly shared files live in core. Template-specific overrides stay in the template folder and are not overwritten if you rsync with care (e.g. sync only `lib/`, `app/components/admin/`, etc.).
871
+
872
+ **When to move to Option 2**
873
+
874
+ - Many templates (5+) and core duplication in git becomes unwieldy.
875
+ - You want a single `packages/core/` commit without touching every template folder.
876
+
877
+ **Avoid Option 3** if your main users are developers who fork, rename, and heavily customize each client site.
878
+
879
+ ---
880
+
881
+ ### What does *not* work well with tempjs
882
+
883
+ | Pattern | Problem |
884
+ |---------|---------|
885
+ | Git submodule in generated project | User gets submodule reference, not standalone repo |
886
+ | `workspace:*` in published template | Broken after copy — no monorepo parent |
887
+ | Copy only template without core | Incomplete project unless core is npm dependency |
888
+
889
+ The rule: **everything required to `pnpm install && pnpm build` must either be in the copied folder or in declared npm dependencies.**
890
+
179
891
  ## Adding a new template
180
892
 
181
893
  1. Add a directory under `templates/`, e.g. `templates/restaurant-website-template/`.
182
894
  2. Include a template-specific `.gitignore` for that stack (Next.js, Vite, etc.).
183
- 3. Add one entry to `templates.json`:
895
+ 3. Add metadata to `templates.json` (recommended):
184
896
 
185
897
  ```json
186
898
  "restaurant": {
187
899
  "directory": "restaurant-website-template",
188
900
  "name": "Restaurant Website",
189
- "description": "Restaurant website with menu and reservations"
901
+ "description": "Restaurant website with menu and reservations",
902
+ "version": "1.0.0",
903
+ "stack": ["Next.js 16", "React 19", "TypeScript", "Tailwind CSS 4"],
904
+ "packageManager": "pnpm",
905
+ "node": ">=20",
906
+ "tags": ["admin", "menu", "reservations"],
907
+ "features": ["Menu management", "Reservation leads"],
908
+ "docs": "DEVELOPER_GUIDE.md"
190
909
  }
191
910
  ```
192
911