@mars-stack/cli 7.0.3 → 7.0.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/README.md CHANGED
@@ -36,6 +36,7 @@ mars create my-app
36
36
  ### `mars add feature <name>`
37
37
 
38
38
  Generate a feature module at `src/features/<name>/` with:
39
+
39
40
  - `server/index.ts` -- typed CRUD operations with `import 'server-only'`
40
41
  - `types.ts` -- Zod validation schemas and TypeScript types
41
42
 
@@ -121,6 +122,18 @@ mars upgrade # upgrade to latest
121
122
  mars upgrade --dry-run # preview what would change
122
123
  ```
123
124
 
125
+ ### `mars template sync`
126
+
127
+ Copy upstream **template plumbing** (scripts, auth shell files, and other manifest-listed paths) from the CLI-bundled template into an **existing** Mars project. Requires `.mars/scaffold.json` at the project root (from `mars create`); exits with an error if missing.
128
+
129
+ ```bash
130
+ mars template sync --dry-run # list planned changes, no writes
131
+ mars template sync # default: plumbing category only
132
+ mars template sync --only user-owned --force # overwrite user-owned paths too (backups under .mars/backups/)
133
+ ```
134
+
135
+ **vs `mars upgrade`:** `mars upgrade` bumps Mars npm packages only — it does **not** re-copy template source files. Use `mars template sync` when a CLI release includes fixes to `ensure-db.mjs`, proxy, or other synced paths. See the Mars monorepo [scaffold-template-sync-upgrade](https://github.com/greaveselliott/mars/blob/main/docs/exec-plans/active/scaffold-template-sync-upgrade.md) exec plan for the safety model and path inventory.
136
+
124
137
  ### `mars telemetry <enable|disable>`
125
138
 
126
139
  Opt in or out of anonymous usage analytics. Stored in `~/.marsrc`. Tracks command usage and feature selections only -- never project names, file contents, or env vars.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mars-stack/cli",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "description": "MARS CLI: scaffold, configure, and maintain SaaS apps",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -68,6 +68,7 @@ src/
68
68
  ## Config
69
69
 
70
70
  `src/config/app.config.ts` is the single source of truth for:
71
+
71
72
  - App identity (name, URL, support email)
72
73
  - Feature flags (auth, admin, billing, notifications, etc.)
73
74
  - Service providers (email, storage, database, payments, etc.)
@@ -91,6 +92,19 @@ yarn db:studio # Open Prisma Studio
91
92
 
92
93
  **Email verification (local):** With console email, after register you land on `/verify` and use **“Click here to verify your email”** (no inbox needed). Set `AUTO_VERIFY_EMAIL=true` to skip that for **new** signups instead. `AUTO_VERIFY_EMAIL` applies when `yarn dev` runs or `APP_URL` points at `localhost` / `127.0.0.1`; ignored on Vercel production. Older accounts stay unverified until you use the link or Prisma Studio.
93
94
 
95
+ ## Updating scaffold plumbing (`mars template sync`)
96
+
97
+ When you install a newer **`@mars-stack/cli`**, pull upstream template fixes into this repo with **`mars template sync`** from the project root (requires `.mars/scaffold.json` from `mars create`). If that file is missing, the CLI reports that the directory is not a Mars scaffold — you cannot sync a non-Mars project.
98
+
99
+ - **`mars template sync --dry-run`** — print the planned file operations; no writes.
100
+ - **Default** — sync **plumbing** paths from the bundled template manifest (scripts, shared shell, etc.).
101
+ - **`--force`** — also apply **user-owned** manifest entries; previous files are copied to **`.mars/backups/<timestamp>/`** before overwrite. Use when you deliberately want upstream versions of those paths.
102
+ - **`--only <category>`** — e.g. `plumbing` or `user-owned` (latter typically with `--force`).
103
+
104
+ Deep context: [scaffold-template-sync-upgrade](https://github.com/greaveselliott/mars/blob/main/docs/exec-plans/active/scaffold-template-sync-upgrade.md) in the Mars monorepo (path inventory and safety model). Skill for agents: [.cursor/skills/mars-upgrade-scaffold/](.cursor/skills/mars-upgrade-scaffold/).
105
+
106
+ **vs `mars upgrade`:** `mars upgrade` only bumps Mars **npm** packages and reinstalls — it does **not** re-copy template files. Use template sync when plumbing (e.g. `ensure-db.mjs`) changed in a CLI release.
107
+
94
108
  ## Working Discipline
95
109
 
96
110
  1. **Commit after every step.** When executing a plan, commit after each completed task — not at the end. Version control is the progress log. Each commit message should reference the plan and step (e.g., `feat(billing): add Subscription model (billing-plan step 1.1)`).
@@ -103,6 +117,7 @@ After **generator changes**, **template sync**, or before a **release**, run the
103
117
 
104
118
  ## Pointers
105
119
 
120
+ - **Updating your app:** [README.md](README.md) — entry point; this section and `mars template sync` above.
106
121
  - **Architecture details:** [docs/design-docs/](docs/design-docs/)
107
122
  - **Core beliefs:** [docs/design-docs/core-beliefs.md](docs/design-docs/core-beliefs.md)
108
123
  - **Conversation feedback:** [docs/design-docs/conversation-as-system-record.md](docs/design-docs/conversation-as-system-record.md)
@@ -0,0 +1,30 @@
1
+ # Mars application template
2
+
3
+ This directory is the **Next.js app template** copied by `mars create` into a new project. In the Mars monorepo it is developed and tested here; published **`@mars-stack/cli`** bundles the same tree at release time.
4
+
5
+ ## Updating your Mars app
6
+
7
+ After you upgrade **`@mars-stack/cli`** or want upstream fixes for scaffold **plumbing** (scripts, auth shell files, shared wiring listed in the sync manifest), run from your **project root**:
8
+
9
+ ```bash
10
+ mars template sync --dry-run # preview planned copies
11
+ mars template sync # apply (default: plumbing only)
12
+ ```
13
+
14
+ **Requirements:** the project must be a Mars scaffold with **`.mars/scaffold.json`**. If that file is missing, the CLI exits with an error — this command does not apply to arbitrary Next.js repos.
15
+
16
+ **Flags:**
17
+
18
+ | Flag | Meaning |
19
+ | ------------------- | -------------------------------------------------------------------------------------------------------------- |
20
+ | `--dry-run` | Show what would change; no files written |
21
+ | `--force` | Also sync **user-owned** manifest paths; always backs up replaced files under **`.mars/backups/<timestamp>/`** |
22
+ | `--only <category>` | Limit to `plumbing` (default) or `user-owned` (usually with `--force`) |
23
+
24
+ **Safety:** Default sync overwrites **plumbing** files that the CLI owns (infrastructure). **User-owned** paths are skipped unless you pass **`--force`**, and overwrites are preceded by backups. Do not use `--force` on a dirty tree without reviewing `--dry-run` output.
25
+
26
+ **Not `mars upgrade`:** `mars upgrade` bumps **`@mars-stack/core`** and **`@mars-stack/ui`** in `package.json` and reinstalls — it does **not** copy template source files. Use **both** commands when you need new package versions **and** refreshed plumbing (e.g. `scripts/ensure-db.mjs`).
27
+
28
+ **Further reading (Mars monorepo):** [scaffold-template-sync-upgrade](https://github.com/greaveselliott/mars/blob/main/docs/exec-plans/active/scaffold-template-sync-upgrade.md) — full manifest, path inventory, and task history.
29
+
30
+ **Agents:** see [.cursor/skills/mars-upgrade-scaffold/](.cursor/skills/mars-upgrade-scaffold/) and [AGENTS.md](AGENTS.md).
@@ -0,0 +1,21 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { describe, expect, it } from 'vitest';
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const readmePath = join(__dirname, '../../README.md');
8
+
9
+ /** MARS-046: user-facing template sync docs stay discoverable in copied scaffolds */
10
+ describe('template README (mars template sync)', () => {
11
+ const content = readFileSync(readmePath, 'utf8');
12
+
13
+ it('documents dry-run, force, scaffold fingerprint, backups, and upgrade distinction', () => {
14
+ expect(content).toMatch(/`--dry-run`/);
15
+ expect(content).toMatch(/`--force`/);
16
+ expect(content).toMatch(/\.mars\/scaffold\.json/);
17
+ expect(content).toMatch(/\.mars\/backups/);
18
+ expect(content).toMatch(/`mars upgrade`/);
19
+ expect(content).toMatch(/mars template sync/);
20
+ });
21
+ });