@donotdev/cli 0.3.1 → 0.3.2

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.
Files changed (99) hide show
  1. package/dependencies-matrix.json +51 -27
  2. package/dist/bin/commands/agent-setup.js +28 -18
  3. package/dist/bin/commands/build.js +1086 -58
  4. package/dist/bin/commands/bump.js +337 -53
  5. package/dist/bin/commands/cacheout.js +28 -18
  6. package/dist/bin/commands/coach.js +33 -25
  7. package/dist/bin/commands/create-app.js +597 -244
  8. package/dist/bin/commands/create-project.js +607 -254
  9. package/dist/bin/commands/db-check.js +37 -28
  10. package/dist/bin/commands/db.js +37 -28
  11. package/dist/bin/commands/deploy.js +13758 -11807
  12. package/dist/bin/commands/dev.js +50 -34
  13. package/dist/bin/commands/doctor.js +33 -25
  14. package/dist/bin/commands/emu.js +65 -43
  15. package/dist/bin/commands/format.js +28 -18
  16. package/dist/bin/commands/get-demo.js +81 -46
  17. package/dist/bin/commands/make-admin.js +966 -905
  18. package/dist/bin/commands/preview.js +50 -34
  19. package/dist/bin/commands/seed.js +37 -28
  20. package/dist/bin/commands/setup-cicd.js +1286 -87
  21. package/dist/bin/commands/setup.js +152 -138
  22. package/dist/bin/commands/staging.js +13758 -11807
  23. package/dist/bin/commands/sync-secrets.js +152 -132
  24. package/dist/bin/commands/type-check.js +1086 -39
  25. package/dist/bin/commands/wai.js +28 -18
  26. package/dist/bin/dndev.js +501 -27
  27. package/dist/index.js +14568 -12497
  28. package/package.json +1 -1
  29. package/templates/app-demo/index.html.example +0 -1
  30. package/templates/app-demo/src/pages/ConditionalFormPage.tsx.example +2 -2
  31. package/templates/app-demo/src/pages/ShowcaseDetailPage.tsx.example +1 -0
  32. package/templates/app-demo/tsconfig.json.example +1 -1
  33. package/templates/app-dndev/index.html.example +1 -3
  34. package/templates/app-expo/app/_layout.tsx.example +1 -1
  35. package/templates/app-expo/app/form.tsx.example +10 -3
  36. package/templates/app-expo/app/index.tsx.example +3 -3
  37. package/templates/app-expo/app/list.tsx.example +2 -2
  38. package/templates/app-expo/app/profile.tsx.example +4 -3
  39. package/templates/app-expo/app/signin.tsx.example +2 -2
  40. package/templates/app-expo/babel.config.js.example +23 -6
  41. package/templates/app-expo/metro.config.js.example +7 -17
  42. package/templates/app-expo/tsconfig.json.example +2 -1
  43. package/templates/app-next/src/app/AppDocument.tsx.example +2 -3
  44. package/templates/app-vite/index.html.example +1 -3
  45. package/templates/app-vite/src/locales/home_en.json.example +6 -6
  46. package/templates/app-vite/src/pages/FormPageExample.tsx.example +1 -1
  47. package/templates/app-vite/src/pages/HomePage.tsx.example +3 -3
  48. package/templates/deploy-config/firebase.json.example +6 -5
  49. package/templates/deploy-config/tsconfig.functions.json.example +2 -7
  50. package/templates/deploy-config/vercel.json.example +5 -56
  51. package/templates/functions-firebase/README.md.example +8 -8
  52. package/templates/functions-firebase/functions.config.js.example +2 -1
  53. package/templates/functions-firebase/src/index.ts.example +4 -3
  54. package/templates/functions-firebase/src/oauth/exchangeToken.ts.example +8 -6
  55. package/templates/functions-firebase/src/oauth/refreshToken.ts.example +8 -6
  56. package/templates/functions-firebase/tsconfig.json.example +3 -5
  57. package/templates/functions-supabase/supabase/config.toml.example +2 -1
  58. package/templates/functions-supabase/supabase/functions/change-plan/index.ts.example +2 -3
  59. package/templates/functions-supabase/supabase/functions/create-checkout-session/index.ts.example +2 -3
  60. package/templates/functions-supabase/supabase/functions/stripe-webhook/index.ts.example +2 -3
  61. package/templates/functions-vercel/README.md.example +15 -25
  62. package/templates/functions-vercel/build.mjs.example +4 -46
  63. package/templates/functions-vercel/src/api/auth/setCustomClaims.ts.example +6 -11
  64. package/templates/functions-vercel/src/api/billing/handleStripeWebhook.ts.example +2 -3
  65. package/templates/functions-vercel/src/api/oauth/checkGitHubAccess.ts.example +5 -11
  66. package/templates/functions-vercel/src/api/oauth/exchangeToken.ts.example +5 -11
  67. package/templates/functions-vercel/src/api/oauth/grantGitHubAccess.ts.example +5 -11
  68. package/templates/functions-vercel/tsconfig.json.example +5 -6
  69. package/templates/github/workflows/firebase-deploy.yml.example +1 -1
  70. package/templates/preset-admin/src/pages/DashboardPage.tsx.example +3 -2
  71. package/templates/preset-admin/src/pages/ReportsPage.tsx.example +13 -12
  72. package/templates/preset-admin/src/pages/SettingsPage.tsx.example +5 -5
  73. package/templates/preset-admin/src/pages/UsersPage.tsx.example +13 -12
  74. package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +5 -5
  75. package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +1 -4
  76. package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +10 -12
  77. package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +7 -4
  78. package/templates/preset-landing/src/pages/AboutPage.tsx.example +11 -9
  79. package/templates/preset-landing/src/pages/ContactPage.tsx.example +13 -7
  80. package/templates/preset-landing/src/pages/HomePage.tsx.example +50 -32
  81. package/templates/preset-saas/src/pages/DashboardPage.tsx.example +1 -1
  82. package/templates/preset-saas/src/pages/HomePage.tsx.example +3 -2
  83. package/templates/preset-saas/src/pages/PricingPage.tsx.example +4 -3
  84. package/templates/preset-saas/src/pages/ProfilePage.tsx.example +7 -7
  85. package/templates/preset-saas/src/pages/SettingsPage.tsx.example +3 -3
  86. package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +101 -10
  87. package/templates/root-consumer/.claude/rules/definition-of-done.md.example +2 -2
  88. package/templates/root-consumer/.claude/rules/framework.md.example +1 -1
  89. package/templates/root-consumer/.claude/settings.json.example +0 -11
  90. package/templates/root-consumer/.claude/skills/build/SKILL.md.example +1 -1
  91. package/templates/root-consumer/.dndev/args.json.example +2 -2
  92. package/templates/root-consumer/.env.example +1 -1
  93. package/templates/root-consumer/AGENTS.md.example +3 -3
  94. package/templates/root-consumer/README.md.example +1 -1
  95. package/templates/functions-vercel/src/api/oauth/disconnect.ts.example +0 -20
  96. package/templates/functions-vercel/src/api/oauth/getConnections.ts.example +0 -20
  97. package/templates/functions-vercel/src/api/oauth/refreshToken.ts.example +0 -20
  98. package/templates/functions-vercel/vercel.json.example +0 -14
  99. package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +0 -18
@@ -2,6 +2,7 @@
2
2
  # .claude/hooks/guard-bash.sh
3
3
  # PreToolUse hook for Bash commands.
4
4
  # Blocks dangerous/wrong commands. Exit 2 = block, exit 0 = allow.
5
+ # tsc / install checks look at command words only (not heredocs, quotes, comments).
5
6
  # Uses bun -e for JSON parsing (bun-first project).
6
7
 
7
8
  set -euo pipefail
@@ -12,20 +13,110 @@ COMMAND=$(echo "$INPUT" | bun -e "process.stdout.write(JSON.parse(await Bun.stdi
12
13
 
13
14
  # --- HARD BLOCKS (exit 2) ---
14
15
 
16
+ # Command-word analysis (tsc / package-manager install).
17
+ # Splits the command into simple commands (on ; & | ( ) and newlines), ignoring quoted strings,
18
+ # comments and heredoc bodies, then looks only at each command's leading words.
19
+ # Prints "tsc" or "install" for the first offending simple command, nothing otherwise.
20
+ ANALYZER=$(cat <<'JS'
21
+ const src = await Bun.stdin.text();
22
+ const cmds = [];
23
+ let words = [];
24
+ let cur = '';
25
+ let inWord = false;
26
+ const heredocs = [];
27
+ const endWord = () => {
28
+ if (inWord) { words.push(cur); cur = ''; inWord = false; }
29
+ };
30
+ const endCmd = () => {
31
+ endWord();
32
+ if (words.length) { cmds.push(words); words = []; }
33
+ };
34
+ let i = 0;
35
+ while (i < src.length) {
36
+ const c = src[i];
37
+ if (c === '\\') { cur += src[i + 1] ?? ''; inWord = true; i += 2; continue; }
38
+ if (c === "'") {
39
+ const j = src.indexOf("'", i + 1);
40
+ const e = j < 0 ? src.length : j;
41
+ cur += src.slice(i + 1, e); inWord = true; i = e + 1; continue;
42
+ }
43
+ if (c === '"') {
44
+ let j = i + 1;
45
+ while (j < src.length && src[j] !== '"') { if (src[j] === '\\') j++; j++; }
46
+ cur += src.slice(i + 1, j); inWord = true; i = j + 1; continue;
47
+ }
48
+ if (c === '#' && !inWord) {
49
+ while (i < src.length && src[i] !== '\n') i++;
50
+ continue;
51
+ }
52
+ if (c === '<' && src[i + 1] === '<' && src[i + 2] !== '<') {
53
+ endWord();
54
+ i += 2;
55
+ const strip = src[i] === '-';
56
+ if (strip) i++;
57
+ while (src[i] === ' ' || src[i] === '\t') i++;
58
+ let delim = '';
59
+ while (i < src.length && !/[\s;&|()<>]/.test(src[i])) {
60
+ if (src[i] !== "'" && src[i] !== '"' && src[i] !== '\\') delim += src[i];
61
+ i++;
62
+ }
63
+ heredocs.push({ delim, strip });
64
+ continue;
65
+ }
66
+ if (c === '\n') {
67
+ endCmd();
68
+ i++;
69
+ for (const h of heredocs) {
70
+ while (i < src.length) {
71
+ let e = src.indexOf('\n', i);
72
+ if (e < 0) e = src.length;
73
+ const line = src.slice(i, e);
74
+ i = e + 1;
75
+ if ((h.strip ? line.replace(/^\t+/, '') : line) === h.delim) break;
76
+ }
77
+ }
78
+ heredocs.length = 0;
79
+ continue;
80
+ }
81
+ if (c === ';' || c === '&' || c === '|' || c === '(' || c === ')') { endCmd(); i++; continue; }
82
+ if (c === ' ' || c === '\t' || c === '\r') { endWord(); i++; continue; }
83
+ cur += c; inWord = true; i++;
84
+ }
85
+ endCmd();
86
+
87
+ const base = (w) => w.slice(w.lastIndexOf('/') + 1);
88
+ const PM = ['bun', 'npm', 'yarn', 'pnpm'];
89
+ let verdict = '';
90
+ for (const w0 of cmds) {
91
+ let w = w0;
92
+ while (w.length && (/^[A-Za-z_][A-Za-z0-9_]*=/.test(w[0]) || ['time', 'exec', 'command'].includes(w[0]))) w = w.slice(1);
93
+ if (!w.length) continue;
94
+ const head = base(w[0]);
95
+ let rest = w.slice(1);
96
+ let runner = ['bunx', 'npx', 'pnpx'].includes(head);
97
+ if ((head === 'pnpm' && ['dlx', 'exec'].includes(rest[0])) || (head === 'bun' && rest[0] === 'x')) {
98
+ runner = true;
99
+ rest = rest.slice(1);
100
+ }
101
+ if (head === 'tsc') { verdict = 'tsc'; break; }
102
+ if (runner && rest.find((a) => !a.startsWith('-')) === 'tsc') { verdict = 'tsc'; break; }
103
+ if (PM.includes(head) && (rest[0] === 'install' || rest[0] === 'i') && !verdict) verdict = 'install';
104
+ }
105
+ process.stdout.write(verdict);
106
+ JS
107
+ )
108
+ VERDICT=$(printf '%s' "$COMMAND" | bun -e "$ANALYZER")
109
+
15
110
  # Block raw TypeScript compiler (must use dn tc)
16
- if echo "$COMMAND" | grep -qE '(^|\s|;|&&|\|)(bunx|npx|pnpx)\s+tsc(\s|$)'; then
17
- echo "BLOCKED: Use 'dn tc' for type-checking, never bunx/npx tsc." >&2
18
- exit 2
19
- fi
20
- if echo "$COMMAND" | grep -qE '(^|\s|;|&&|\|)tsc(\s|$)'; then
21
- echo "BLOCKED: Use 'dn tc' for type-checking, never raw tsc." >&2
111
+ if [ "$VERDICT" = "tsc" ]; then
112
+ echo "BLOCKED: Use 'dn tc' for type-checking, never raw tsc / bunx tsc / npx tsc." >&2
22
113
  exit 2
23
114
  fi
24
115
 
25
- # Block full reinstall (deps are managed by the workspace)
116
+ # Block reinstall once dependencies are installed (the first install of a fresh scaffold is allowed)
26
117
  # bun add IS allowed — consumer projects may need additional packages
27
- if echo "$COMMAND" | grep -qE '(^|\s|;|&&|\|)(bun|npm|yarn|pnpm)\s+install(\s|$)'; then
28
- echo "BLOCKED: Use 'bun add <pkg>' to add specific packages. Full reinstall is not needed." >&2
118
+ if [ "$VERDICT" = "install" ] && [ -d "${CLAUDE_PROJECT_DIR:-.}/node_modules" ]; then
119
+ echo "BLOCKED: Dependencies are already installed. Use 'bun add <pkg>' to add a package; a full reinstall is not needed." >&2
29
120
  exit 2
30
121
  fi
31
122
 
@@ -52,7 +143,7 @@ if echo "$COMMAND" | grep -qE 'rm\s+-rf\s+(/|\.|\*|src|apps|packages|node_module
52
143
  fi
53
144
 
54
145
  # Block skip hooks
55
- if echo "$COMMAND" | grep -qE '--no-verify'; then
146
+ if echo "$COMMAND" | grep -qE -- '--no-verify'; then
56
147
  echo "BLOCKED: --no-verify skips safety hooks. Fix the root cause instead." >&2
57
148
  exit 2
58
149
  fi
@@ -10,7 +10,7 @@ Every change is incomplete until ALL applicable items are done.
10
10
  ## Mandatory (every change)
11
11
 
12
12
  1. **Code** - simple, follows existing patterns, robust, secure
13
- 2. **Typecheck** - `dn tc` passes
13
+ 2. **Typecheck** - `dn tc` passes, run once at the end of the work batch (before commit / deploy), never after each change or feature
14
14
  3. **i18n** - all user-facing strings via `t('key')`. Locale files updated.
15
15
 
16
16
  ## Mandatory for new features
@@ -30,7 +30,7 @@ Every skill output MUST end with:
30
30
  ```
31
31
  ## Definition of Done
32
32
  - [x] Code: <files changed>
33
- - [x] Typecheck: dn tc - PASS
33
+ - [x] Typecheck: dn tc - PASS, or deferred (more work follows in the batch)
34
34
  - [x] i18n: <locale files updated, or N/A>
35
35
  - [x] Tests: <test file, or N/A>
36
36
  - [x] Spec compliance: <verified, or N/A>
@@ -22,7 +22,7 @@ Before hand-building a page, run `search_framework("Template")` and use the matc
22
22
 
23
23
  ## Use framework components, not HTML
24
24
 
25
- `<div>` → Stack | `<button>` → Button | `<input>` → TextInput | `<a>` → Link | `<p>`/`<h1>` → Text | `<table>` → DataTable | `<form>` → Form | `<ul>` → List | `<img>` → Image
25
+ `<div>` → Stack | `<button>` → Button | `<input>` → Input | `<a>` → Link | `<p>`/`<h1>` → Text | `<table>` → DataTable | `<form>` → Form | `<ul>` → List | `<img>` → ResponsiveImg (takes the `image` full/thumb pair)
26
26
 
27
27
  Hook-enforced. Native HTML in source files is blocked.
28
28
 
@@ -42,17 +42,6 @@
42
42
  }
43
43
  ]
44
44
  }
45
- ],
46
- "Stop": [
47
- {
48
- "matcher": "",
49
- "hooks": [
50
- {
51
- "type": "command",
52
- "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/typecheck-stop.sh\""
53
- }
54
- ]
55
- }
56
45
  ]
57
46
  },
58
47
  "permissions": {
@@ -34,7 +34,7 @@ Rules:
34
34
  dn tc
35
35
  ```
36
36
 
37
- Type-check must pass before completion.
37
+ Type-check must pass before commit / deploy. Run it once at the end of the work batch (before commit / deploy), never after each change or feature: skip this step when more work follows in the batch.
38
38
 
39
39
  ## Step 3 - Complete Phase
40
40
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "platform": "firebase",
2
+ "platform": "{{platform}}",
3
3
  "strictness": "enforced",
4
- "features": ["crud", "auth", "i18n", "billing", "oauth", "functions"],
4
+ "features": ["crud", "auth", "i18n"],
5
5
  "region": "europe-west1"
6
6
  }
@@ -14,5 +14,5 @@
14
14
  # apps/<your-app>/.env → VITE_FIREBASE_API_KEY=...
15
15
  #
16
16
  # For server-side secrets (Stripe, OAuth):
17
- # functions/.env → STRIPE_SECRET_KEY=sk_...
17
+ # .dndev.secrets (project root) → STRIPE_SECRET_KEY=sk_...
18
18
  # Then run: dndev sync-secrets
@@ -15,7 +15,7 @@ Architecture and API contracts: **`get_guideline(...)`** and **`lookup_symbol(..
15
15
 
16
16
  ## The 5 phases
17
17
 
18
- Work inside an active phase: **`start_phase(N)`** before work, **`complete_phase({ files })`** before moving on, **`dn tc`** before completing a phase when you changed code.
18
+ Work inside an active phase: **`start_phase(N)`** before work, **`complete_phase({ files })`** before moving on, **`dn tc`** once at the end of the work batch (before commit / deploy), never after each change or feature.
19
19
 
20
20
  | Phase | Name | Skill (slash) | Focus |
21
21
  |-------|------|---------------|--------|
@@ -52,7 +52,7 @@ Last resort: after **`lookup_symbol`** + **`search_framework`**. If you must add
52
52
  | Command | Purpose |
53
53
  |---------|---------|
54
54
  | `dndev dev` / `dndev dev:app` | Dev server |
55
- | `dn tc` / `dn tc --package <name>` | Type-check (use after code changes) |
55
+ | `dn tc` / `dn tc --package <name>` | Type-check, once at the end of the work batch (before commit / deploy), never after each change or feature |
56
56
  | `dndev build` | Production build |
57
57
  | `dndev coach` / `dndev setup` / `dndev doctor` | Env and health |
58
58
 
@@ -63,7 +63,7 @@ Run **`dndev --help`** for the full list. **`dndev create-app`** is interactive
63
63
  - **No local database.** The app runs locally against the live Supabase database. Never `--local`, never `supabase start` / `supabase db reset`.
64
64
  - **Live data:** reads OK. Live writes and migrations only on the owner's order.
65
65
  - **Framework changes** arrive via `dn pack --install` run from the framework repo (unpublished build). A `bun install` reverts them: re-run `dn pack`.
66
- - **Test** by running the app locally on the live database. Typecheck with `dn tc`.
66
+ - **Test** by running the app locally on the live database. Typecheck with `dn tc` once at the end of the work batch (before commit / deploy), never after each change or feature.
67
67
  - **Deploy** only on the owner's order.
68
68
 
69
69
  ## Docs and markdown
@@ -46,7 +46,7 @@ dndev emu start # Start Firebase emulators (Auth, Firestore, Functi
46
46
  # Deployment
47
47
  dndev deploy # Deploy to Firebase (hosting + functions + rules)
48
48
  dndev staging # Deploy to staging environment
49
- dndev sync-secrets # Push functions/.env secrets to Firebase Secret Manager
49
+ dndev sync-secrets # Push .dndev.secrets values to Firebase Secret Manager
50
50
 
51
51
  # Quality
52
52
  dn tc # Type-check (preferred)
@@ -1,20 +0,0 @@
1
- // functions/src/api/oauth/disconnect.ts
2
-
3
- /**
4
- * @fileoverview {{APP_NAME}} Disconnect OAuth Wrapper
5
- * @description Wrapper for framework's disconnect with {{APP_NAME}}-specific configuration
6
- */
7
-
8
- import type { NextApiRequest, NextApiResponse } from 'next';
9
- import { disconnect as frameworkDisconnect } from '@donotdev/functions/vercel';
10
-
11
- /**
12
- * {{APP_NAME}} OAuth disconnection
13
- * Wraps the framework function with {{APP_NAME}}-specific configuration
14
- */
15
- export default async function handler(
16
- req: NextApiRequest,
17
- res: NextApiResponse
18
- ) {
19
- return frameworkDisconnect(req, res);
20
- }
@@ -1,20 +0,0 @@
1
- // functions/src/api/oauth/getConnections.ts
2
-
3
- /**
4
- * @fileoverview {{APP_NAME}} Get Connections Wrapper
5
- * @description Wrapper for framework's getConnections with {{APP_NAME}}-specific configuration
6
- */
7
-
8
- import type { NextApiRequest, NextApiResponse } from 'next';
9
- import { getConnections as frameworkGetConnections } from '@donotdev/functions/vercel';
10
-
11
- /**
12
- * {{APP_NAME}} OAuth connections retrieval
13
- * Wraps the framework function with {{APP_NAME}}-specific configuration
14
- */
15
- export default async function handler(
16
- req: NextApiRequest,
17
- res: NextApiResponse
18
- ) {
19
- return frameworkGetConnections(req, res);
20
- }
@@ -1,20 +0,0 @@
1
- // functions/src/api/oauth/refreshToken.ts
2
-
3
- /**
4
- * @fileoverview {{APP_NAME}} Refresh Token Wrapper
5
- * @description Wrapper for framework's refreshToken with {{APP_NAME}}-specific configuration
6
- */
7
-
8
- import type { NextApiRequest, NextApiResponse } from 'next';
9
- import { refreshToken as frameworkRefreshToken } from '@donotdev/functions/vercel';
10
-
11
- /**
12
- * {{APP_NAME}} OAuth token refresh
13
- * Wraps the framework function with {{APP_NAME}}-specific configuration
14
- */
15
- export default async function handler(
16
- req: NextApiRequest,
17
- res: NextApiResponse
18
- ) {
19
- return frameworkRefreshToken(req, res);
20
- }
@@ -1,14 +0,0 @@
1
- {
2
- "functions": {
3
- "src/api/**/*.ts": {
4
- "runtime": "nodejs22.x"
5
- }
6
- },
7
- "env": {
8
- "STRIPE_SECRET_KEY": "@stripe-secret-key",
9
- "STRIPE_WEBHOOK_SECRET": "@stripe-webhook-secret",
10
- "GITHUB_PERSONAL_ACCESS_TOKEN": "@github-token",
11
- "GITHUB_REPO_OWNER": "@github-repo-owner",
12
- "GITHUB_REPO_NAME": "@github-repo-name"
13
- }
14
- }
@@ -1,18 +0,0 @@
1
- #!/bin/bash
2
- # .claude/hooks/typecheck-stop.sh
3
- # Stop hook: run dn tc before declaring done.
4
- # Ensures type safety before any work is considered complete.
5
-
6
- set -euo pipefail
7
-
8
- # Only run if there are uncommitted changes (something was written)
9
- DIRTY=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
10
- [ "$DIRTY" -eq 0 ] && exit 0
11
-
12
- echo "Running typecheck before completion..." >&2
13
- if ! dn tc 2>&1; then
14
- echo '{"decision":"block","reason":"Typecheck failed. Fix type errors before completing."}'
15
- exit 0
16
- fi
17
-
18
- exit 0