@donotdev/cli 0.0.37 → 0.1.1

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 (119) hide show
  1. package/LICENSE.md +21 -48
  2. package/dependencies-matrix.json +108 -58
  3. package/dist/bin/commands/agent-setup.js +7196 -123
  4. package/dist/bin/commands/build.js +3341 -207
  5. package/dist/bin/commands/bump.js +268 -24
  6. package/dist/bin/commands/cacheout.js +262 -13
  7. package/dist/bin/commands/coach.js +365 -61
  8. package/dist/bin/commands/create-app.js +261 -14
  9. package/dist/bin/commands/create-project.js +270 -15
  10. package/dist/bin/commands/db.js +10743 -2346
  11. package/dist/bin/commands/deploy.js +4202 -776
  12. package/dist/bin/commands/dev.js +353 -38
  13. package/dist/bin/commands/doctor.js +412 -108
  14. package/dist/bin/commands/emu.js +392 -57
  15. package/dist/bin/commands/format.js +250 -15
  16. package/dist/bin/commands/get-demo.js +261 -14
  17. package/dist/bin/commands/make-admin.js +10022 -1552
  18. package/dist/bin/commands/preview.js +353 -38
  19. package/dist/bin/commands/seed.js +10743 -2346
  20. package/dist/bin/commands/setup-cicd.js +456 -133
  21. package/dist/bin/commands/setup.js +428 -125
  22. package/dist/bin/commands/staging.js +4202 -776
  23. package/dist/bin/commands/sync-secrets.js +250 -14
  24. package/dist/bin/commands/type-check.js +249 -13
  25. package/dist/bin/commands/wai.js +249 -13
  26. package/dist/bin/dndev.js +33 -4
  27. package/dist/bin/donotdev.js +33 -4
  28. package/dist/index.js +4278 -856
  29. package/{templates/root-consumer/guides/dndev/advanced/VERSION_CONTROL.md.example → guidelines/VERSION_CONTROL.md} +7 -11
  30. package/package.json +3 -2
  31. package/templates/app-demo/src/themes.css.example +21 -0
  32. package/templates/app-dndev/index.html.example +0 -3
  33. package/templates/app-dndev/src/themes.css.example +21 -0
  34. package/templates/app-next/src/app/layout.tsx.example +13 -4
  35. package/templates/app-next/src/themes.css.example +21 -0
  36. package/templates/app-vite/csp.example.json +44 -0
  37. package/templates/app-vite/index.html.example +0 -3
  38. package/templates/app-vite/src/themes.css.example +21 -0
  39. package/templates/functions-supabase/supabase/functions/.env.example +12 -0
  40. package/templates/functions-supabase/supabase/functions/disconnect-oauth/index.ts.example +7 -0
  41. package/templates/functions-supabase/supabase/functions/exchange-token/index.ts.example +7 -0
  42. package/templates/functions-supabase/supabase/functions/get-connections/index.ts.example +7 -0
  43. package/templates/functions-supabase/supabase/functions/refresh-token/index.ts.example +7 -0
  44. package/templates/functions-supabase/supabase/migrations/20250101000000_idempotency.sql +3 -0
  45. package/templates/functions-supabase/supabase/migrations/20250101000001_rate_limits.sql +3 -0
  46. package/templates/functions-supabase/supabase/migrations/20250101000003_operation_metrics.sql +3 -0
  47. package/templates/preset-admin/src/pages/DashboardPage.tsx.example +189 -0
  48. package/templates/preset-admin/src/pages/EntityPage.tsx.example +84 -0
  49. package/templates/preset-admin/src/pages/ReportsPage.tsx.example +243 -0
  50. package/templates/preset-admin/src/pages/SettingsPage.tsx.example +283 -0
  51. package/templates/preset-admin/src/pages/UsersPage.tsx.example +128 -0
  52. package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +167 -0
  53. package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +187 -0
  54. package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +244 -0
  55. package/templates/preset-ecommerce/src/pages/HomePage.tsx.example +268 -0
  56. package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +228 -0
  57. package/templates/preset-landing/src/pages/AboutPage.tsx.example +237 -0
  58. package/templates/preset-landing/src/pages/ContactPage.tsx.example +192 -0
  59. package/templates/preset-landing/src/pages/HomePage.tsx.example +399 -0
  60. package/templates/preset-saas/src/pages/DashboardPage.tsx.example +195 -0
  61. package/templates/preset-saas/src/pages/HomePage.tsx.example +270 -0
  62. package/templates/preset-saas/src/pages/PricingPage.tsx.example +204 -0
  63. package/templates/preset-saas/src/pages/ProfilePage.tsx.example +191 -0
  64. package/templates/preset-saas/src/pages/SettingsPage.tsx.example +292 -0
  65. package/templates/root-consumer/.claude/hooks/framework-compliance.sh.example +56 -0
  66. package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +61 -0
  67. package/templates/root-consumer/.claude/hooks/guard-files.sh.example +46 -0
  68. package/templates/root-consumer/.claude/hooks/guard-mcp.sh.example +91 -0
  69. package/templates/root-consumer/.claude/hooks/guard-secrets.sh.example +67 -0
  70. package/templates/root-consumer/.claude/hooks/guard-write.sh.example +89 -0
  71. package/templates/root-consumer/.claude/hooks/session-start.sh.example +50 -0
  72. package/templates/root-consumer/.claude/hooks/track-mcp-lookup.sh.example +20 -0
  73. package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +18 -0
  74. package/templates/root-consumer/.claude/rules/consumer-ux.md.example +32 -0
  75. package/templates/root-consumer/.claude/rules/definition-of-done.md.example +32 -0
  76. package/templates/root-consumer/.claude/rules/framework.md.example +39 -0
  77. package/templates/root-consumer/.claude/rules/git.md.example +14 -0
  78. package/templates/root-consumer/.claude/rules/security.md.example +13 -0
  79. package/templates/root-consumer/.claude/settings.json.example +123 -1
  80. package/templates/root-consumer/.claude/skills/brainstorm/SKILL.md.example +16 -0
  81. package/templates/root-consumer/.claude/skills/build/SKILL.md.example +103 -25
  82. package/templates/root-consumer/.claude/skills/design/SKILL.md.example +17 -0
  83. package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +33 -16
  84. package/templates/root-consumer/.claude/skills/polish/SKILL.md.example +50 -37
  85. package/templates/root-consumer/AI.md.example +2 -2
  86. package/templates/root-consumer/CLAUDE.md.example +33 -1
  87. package/templates/root-consumer/guides/dndev/INDEX.md.example +23 -27
  88. package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +3 -2
  89. package/templates/root-consumer/guides/dndev/SETUP_OAUTH.md.example +12 -6
  90. package/templates/root-consumer/guides/dndev/SETUP_SUPABASE.md.example +50 -3
  91. package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +13 -15
  92. package/templates/app-demo/public/manifest.json.example +0 -10
  93. package/templates/app-dndev/public/manifest.json.example +0 -10
  94. package/templates/root-consumer/.claude/commands/brainstorm.md.example +0 -147
  95. package/templates/root-consumer/.claude/commands/build.md.example +0 -131
  96. package/templates/root-consumer/.claude/commands/design.md.example +0 -153
  97. package/templates/root-consumer/.claude/commands/grill.md.example +0 -108
  98. package/templates/root-consumer/.claude/commands/polish.md.example +0 -146
  99. package/templates/root-consumer/.claude/commands/techdebt.md.example +0 -28
  100. package/templates/root-consumer/guides/dndev/COMPONENTS_ATOMIC.md.example +0 -180
  101. package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +0 -234
  102. package/templates/root-consumer/guides/dndev/COMPONENTS_UI.md.example +0 -136
  103. package/templates/root-consumer/guides/dndev/COMPONENT_API.md.example +0 -195
  104. package/templates/root-consumer/guides/dndev/ENV_SETUP.md.example +0 -219
  105. package/templates/root-consumer/guides/dndev/GOTCHAS.md.example +0 -197
  106. package/templates/root-consumer/guides/dndev/SETUP_APP_CONFIG.md.example +0 -132
  107. package/templates/root-consumer/guides/dndev/SETUP_BLOG.md.example +0 -280
  108. package/templates/root-consumer/guides/dndev/SETUP_CICD.md.example +0 -115
  109. package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +0 -334
  110. package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +0 -9
  111. package/templates/root-consumer/guides/dndev/SETUP_I18N.md.example +0 -233
  112. package/templates/root-consumer/guides/dndev/SETUP_LAYOUTS.md.example +0 -158
  113. package/templates/root-consumer/guides/dndev/SETUP_PAGES.md.example +0 -205
  114. package/templates/root-consumer/guides/dndev/SETUP_PWA.md.example +0 -213
  115. package/templates/root-consumer/guides/dndev/SETUP_TESTING.md.example +0 -184
  116. package/templates/root-consumer/guides/dndev/SETUP_THEMES.md.example +0 -111
  117. package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +0 -260
  118. package/templates/root-consumer/guides/dndev/USE_ROUTING.md.example +0 -499
  119. package/templates/root-consumer/guides/dndev/essences_reference.css.example +0 -288
@@ -1,195 +0,0 @@
1
- # Component API Reference
2
-
3
- **SOURCE OF TRUTH. If prop not listed here, it does not exist.**
4
-
5
- ---
6
-
7
- ## Button
8
- ```tsx
9
- <Button>Label</Button>
10
- <Button variant="primary">Label</Button>
11
- <Button onClick={fn}>Label</Button>
12
- ```
13
- | Prop | Type | Default |
14
- |------|------|---------|
15
- | variant | `'default'` \| `'primary'` \| `'secondary'` \| `'accent'` \| `'destructive'` \| `'ghost'` \| `'outline'` \| `'link'` | `'default'` |
16
- | icon | `LucideIcon` \| `ReactNode` | - |
17
- | iconEnd | `boolean` | `false` |
18
- | display | `'auto'` \| `'compact'` \| `'full'` | `'auto'` |
19
- | tooltip | `string` | - |
20
- | floating | `boolean` | `false` |
21
- | fullWidth | `boolean` | `false` |
22
- | loading | `boolean` | `false` |
23
- | loadingText | `string` | - |
24
- | progress | `number` (0-100) | - |
25
- | disabled | `boolean` | `false` |
26
- | render | `(props) => ReactNode` | - |
27
-
28
- **NO: size, tone, gap**
29
-
30
- ---
31
-
32
- ## Text
33
- ```tsx
34
- <Text>Content</Text>
35
- <Text level="h1">Heading</Text>
36
- <Text as="p">Paragraph</Text>
37
- ```
38
- | Prop | Type | Default |
39
- |------|------|---------|
40
- | as | `'h1'`-`'h6'` \| `'p'` \| `'span'` \| `'div'` \| `'li'` \| `'label'` \| `'code'` | `'div'` |
41
- | level | `'h1'`-`'h6'` \| `'body'` \| `'small'` \| `'caption'` | auto from `as` |
42
- | variant | `'default'` \| `'muted'` \| `'primary'` \| `'secondary'` \| `'accent'` \| `'success'` \| `'warning'` \| `'destructive'` \| `'code'` | `'default'` |
43
- | align | `'start'` \| `'center'` \| `'end'` | `'start'` |
44
- | weight | `'normal'` \| `'medium'` \| `'semibold'` \| `'bold'` | - |
45
-
46
- **NO: size, tone, color**
47
-
48
- ---
49
-
50
- ## Stack
51
- ```tsx
52
- <Stack>children</Stack>
53
- <Stack direction="row">children</Stack>
54
- ```
55
- | Prop | Type | Default |
56
- |------|------|---------|
57
- | as | `ElementType` | `'div'` |
58
- | direction | `'row'` \| `'column'` \| `'row-reverse'` \| `'column-reverse'` | `'column'` |
59
- | align | `'start'` \| `'center'` \| `'end'` \| `'stretch'` \| `'baseline'` | `'stretch'` |
60
- | justify | `'start'` \| `'center'` \| `'end'` \| `'between'` \| `'around'` \| `'evenly'` | `'start'` |
61
- | gap | `'none'` \| `'tight'` \| `'medium'` \| `'large'` | `'medium'` |
62
- | wrap | `'nowrap'` \| `'wrap'` \| `'wrap-reverse'` | `'nowrap'` |
63
- | width | `'full'` \| `'fit'` \| `'auto'` | `'full'` |
64
- | centered | `boolean` | `false` |
65
-
66
- **NO: spacing, size**
67
-
68
- ---
69
-
70
- ## Card
71
- ```tsx
72
- <Card>children</Card>
73
- <Card title="Title">children</Card>
74
- <Card onClick={fn}>children</Card>
75
- ```
76
- | Prop | Type | Default |
77
- |------|------|---------|
78
- | variant | `'default'` \| `'muted'` \| `'primary'` \| `'secondary'` \| `'accent'` | `'default'` |
79
- | title | `string` \| `ReactNode` | - |
80
- | subtitle | `string` \| `ReactNode` | - |
81
- | icon | `LucideIcon` | - |
82
- | content | `string` \| `string[]` \| `ReactNode` | - |
83
- | footer | `ReactNode` | - |
84
- | onClick | `() => void` | - |
85
- | clickable | `boolean` | auto from onClick |
86
- | elevated | `boolean` | `false` |
87
- | asChild | `boolean` | `false` |
88
-
89
- **NO: size, padding, margin**
90
-
91
- ---
92
-
93
- ## Grid
94
- ```tsx
95
- <Grid>children</Grid>
96
- <Grid cols={3}>children</Grid>
97
- <Grid cols={[1, 1, 2, 3]}>children</Grid>
98
- ```
99
- | Prop | Type | Default |
100
- |------|------|---------|
101
- | as | `ElementType` | `'div'` |
102
- | cols | `number` \| `[mobile, tablet, laptop, desktop]` | `1` |
103
- | gap | `'none'` \| `'tight'` \| `'medium'` \| `'large'` | `'medium'` |
104
- | align | `'start'` \| `'center'` \| `'end'` \| `'stretch'` | `'stretch'` |
105
- | justify | `'start'` \| `'center'` \| `'end'` \| `'stretch'` | `'stretch'` |
106
-
107
- **NO: spacing, columns (use cols)**
108
-
109
- ---
110
-
111
- ## Section
112
- ```tsx
113
- <Section title="Title">children</Section>
114
- ```
115
- | Prop | Type | Default |
116
- |------|------|---------|
117
- | as | `'section'` \| `'article'` \| `'aside'` \| `'div'` \| `'main'` | `'section'` |
118
- | title | `string` | - |
119
- | separator | `boolean` | `false` |
120
- | tone | `'base'` \| `'muted'` \| `'elevated'` \| `'contrast'` \| `'accent'` | `'base'` |
121
- | align | `'start'` \| `'center'` \| `'end'` | `'center'` |
122
- | gridCols | `number` \| `[mobile, tablet, laptop, desktop]` | - |
123
- | gridGap | `'none'` \| `'tight'` \| `'medium'` \| `'large'` | `'medium'` |
124
- | collapsible | `boolean` | `false` |
125
- | defaultOpen | `boolean` | `false` |
126
-
127
- **NO: padding, margin, background**
128
-
129
- ---
130
-
131
- ## Badge
132
- ```tsx
133
- <Badge>Label</Badge>
134
- <Badge variant="primary">Label</Badge>
135
- ```
136
- | Prop | Type | Default |
137
- |------|------|---------|
138
- | as | `'div'` \| `'span'` \| `'mark'` | `'div'` |
139
- | variant | `'default'` \| `'muted'` \| `'primary'` \| `'secondary'` \| `'accent'` \| `'success'` \| `'warning'` \| `'destructive'` \| `'outline'` | `'default'` |
140
- | tooltip | `string` | - |
141
-
142
- **NO: size, color**
143
-
144
- ---
145
-
146
- ## Spinner
147
- ```tsx
148
- <Spinner />
149
- <Spinner overlay />
150
- ```
151
- | Prop | Type | Default |
152
- |------|------|---------|
153
- | overlay | `boolean` | `false` |
154
- | variant | `'default'` \| `'primary'` \| `'secondary'` \| `'accent'` \| `'success'` \| `'warning'` \| `'destructive'` | `'primary'` |
155
-
156
- **NO: size**
157
-
158
- ---
159
-
160
- ## Separator
161
- ```tsx
162
- <Separator />
163
- ```
164
- | Prop | Type | Default |
165
- |------|------|---------|
166
- | orientation | `'horizontal'` \| `'vertical'` | `'horizontal'` |
167
- | variant | `'default'` \| `'muted'` \| `'accent'` | `'default'` |
168
-
169
- ---
170
-
171
- ## EntityFormRenderer
172
- ```tsx
173
- <EntityFormRenderer entity={entity} operation="create" onSubmit={fn} />
174
- ```
175
- | Prop | Type | Default |
176
- |------|------|---------|
177
- | entity | `Entity` | required |
178
- | operation | `'create'` \| `'edit'` | `'create'` |
179
- | onSubmit | `(data) => void` | required |
180
- | defaultValues | `Record<string, unknown>` | - |
181
- | loading | `boolean` | `false` |
182
- | submitText | `string` | - |
183
- | cancelText | `string` | - |
184
- | onCancel | `() => void` | - |
185
- | viewerRole | `string` | `'guest'` |
186
-
187
- **NO: fields (renders all editable fields automatically)**
188
-
189
- ---
190
-
191
- ## BEFORE WRITING JSX
192
-
193
- 1. Check this file
194
- 2. If prop not listed → don't use it
195
- 3. When in doubt → use defaults only
@@ -1,219 +0,0 @@
1
- # Getting Started
2
-
3
- **The complete onboarding flow — from `dndev init` to deployed app.**
4
-
5
- If you haven’t run `dndev init` yet, see [AGENT_START_HERE.md](./AGENT_START_HERE.md) § **Getting started (for humans)** (P0 → Install CLI → Run AI.md → Enjoy).
6
-
7
- ---
8
-
9
- ## The Flow
10
-
11
- ```
12
- bun install → install dependencies
13
- dndev dev → start app, read the homepage setup guide
14
- dndev coach → see what to configure (numbered checklist)
15
- (fill in .env values from dashboard)
16
- dndev setup → validate .env, automate provider config
17
- dndev doctor → health check
18
- dndev emu start → test locally with emulators (Firebase)
19
- dndev deploy → deploy to production
20
- ```
21
-
22
- ---
23
-
24
- ## Step 1: Install & Run
25
-
26
- ```bash
27
- bun install
28
- dndev dev
29
- ```
30
-
31
- Open the app. The homepage shows every setup step with instructions.
32
-
33
- ---
34
-
35
- ## Step 2: Git
36
-
37
- ```bash
38
- git init
39
- git add . && git commit -m "Initial scaffold"
40
- ```
41
-
42
- Create a repo on GitHub, then:
43
-
44
- ```bash
45
- git remote add origin <your-repo-url>
46
- git push -u origin main
47
- ```
48
-
49
- ---
50
-
51
- ## Step 3: Backend Setup
52
-
53
- ### 1. See what to configure
54
-
55
- ```bash
56
- dndev coach
57
- ```
58
-
59
- Prints a numbered checklist: which dashboard to visit, what to copy, where to paste it. No automation, no prompts.
60
-
61
- ### 2. Fill in credentials
62
-
63
- Follow the coach checklist. Paste **public** credentials into `apps/<app>/.env`, and **secret** keys into `.dndev.secrets` at project root.
64
-
65
- ### 3. Run setup
66
-
67
- ```bash
68
- dndev setup
69
- ```
70
-
71
- Validates all required env vars are present, runs provider automation (CLI linking, migrations, etc.), and runs an inline health check. If values are missing, it tells you which ones and points you back to `dndev coach`.
72
-
73
- See [SETUP_FIREBASE.md](./SETUP_FIREBASE.md) or [SETUP_SUPABASE.md](./SETUP_SUPABASE.md) for full details. See [Secrets Philosophy](#secrets-philosophy) for how we handle secret keys.
74
-
75
- ---
76
-
77
- ## Step 4: Test Locally
78
-
79
- ```bash
80
- dndev emu start # Firebase emulators
81
- ```
82
-
83
- Select services: Auth + Firestore + Functions. This starts Firebase emulators so you can develop without touching production.
84
-
85
- For Supabase, development runs against your Supabase project directly (or use `supabase start` for local Supabase if installed).
86
-
87
- ---
88
-
89
- ## Step 5: Build With AI
90
-
91
- Open the project in **Cursor**, **Claude Code**, **Windsurf**, or **AntiGravity**.
92
-
93
- The AI reads `AI.md` and follows the WAI-WAY protocol:
94
- - Phase 0: Brainstorm -> produce a spec
95
- - Phase 1: Scaffold -> create pages
96
- - Phase 2: Entities -> define data models
97
- - Phase 3: Compose -> build pages with components
98
- - Phase 4: Configure -> generate tests, firestore rules, CI/CD
99
-
100
- Read `guides/wai-way/WAI_WAY_CLI.md` for the full workflow.
101
-
102
- ---
103
-
104
- ## Step 6: Deploy
105
-
106
- ```bash
107
- dndev deploy
108
- ```
109
-
110
- Deploys hosting + functions + rules. Syncs runtime secrets automatically before deploying functions.
111
-
112
- ---
113
-
114
- ## Secrets Philosophy
115
-
116
- **DoNotDev follows strict rules about credentials:**
117
-
118
- ### Tier 1: Public Keys -- We Ask Directly
119
-
120
- These are safe to share, shipped in your client JS bundle. We ask for them during setup.
121
-
122
- | Key | Where It Goes |
123
- |-----|--------------|
124
- | Firebase API key, project ID, auth domain, etc. | `apps/<app>/.env` as `VITE_FIREBASE_*` |
125
- | Supabase project URL | `apps/<app>/.env` as `VITE_SUPABASE_URL` |
126
- | Supabase anon key (public JWT) | `apps/<app>/.env` as `VITE_SUPABASE_ANON_KEY` |
127
- | Stripe publishable key | `apps/<app>/.env` as `VITE_STRIPE_PUBLISHABLE_KEY` |
128
-
129
- ### Tier 2: Secret Keys -- One File, Project Root
130
-
131
- All secret keys go in **`.dndev.secrets`** at project root (gitignored). One file, every secret.
132
-
133
- | Key | How To Get It |
134
- |-----|---------------|
135
- | `VERCEL_TOKEN` | https://vercel.com/account/tokens |
136
- | `SUPABASE_SECRET_KEY` | Supabase Dashboard → Settings → API |
137
- | `SUPABASE_ACCESS_TOKEN` | https://supabase.com/dashboard/account/tokens |
138
- | `STRIPE_SECRET_KEY` | https://dashboard.stripe.com/apikeys |
139
- | `STRIPE_WEBHOOK_SECRET` | Stripe Dashboard → Webhooks |
140
-
141
- Resolution order: `process.env` (CI) → `.dndev.secrets` (local) → legacy paths (with warning).
142
-
143
- Then sync to your runtime:
144
-
145
- ```bash
146
- dndev sync-secrets # -> Firebase Secret Manager or Vercel env
147
- dndev sync-secrets --target github # -> GitHub Secrets (for CI/CD)
148
- ```
149
-
150
- ### Tier 3: Service Account Files -- Download, Place, Gitignore
151
-
152
- | File | Where It Goes | How To Get It |
153
- |------|--------------|---------------|
154
- | `service-account-key.json` | App root (next to firebase.json) | Firebase Console -> Settings -> Service Accounts |
155
- | `service-account-key.staging.json` | Same location, for staging | Same, from staging project |
156
-
157
- These files are `.gitignored`. Never commit them. For CI/CD, upload the file content as a GitHub Secret and decode it in your workflow.
158
-
159
- ---
160
-
161
- ## Environment Variables
162
-
163
- **Public config** lives in each app's `.env`. **Secrets** live in `.dndev.secrets` at project root.
164
-
165
- ```
166
- my-project/
167
- +-- .dndev.secrets <-- ALL secrets (gitignored)
168
- +-- .dndev.secrets.example <-- Template (committed)
169
- +-- apps/
170
- | +-- my-app/
171
- | +-- .env <-- Public keys: VITE_*, VERCEL_ORG_ID, VERCEL_PROJECT_ID
172
- | +-- .env.staging <-- Used by dndev staging
173
- | +-- .env.production <-- Production overrides
174
- | +-- service-account-key.json <-- Firebase SA (gitignored)
175
- ```
176
-
177
- **Rules:**
178
- - `VITE_*` / `NEXT_PUBLIC_*` vars → `apps/<app>/.env` (public, shipped to browser)
179
- - `VERCEL_ORG_ID` / `VERCEL_PROJECT_ID` → `apps/<app>/.env` (public, per-app)
180
- - All secret keys → `.dndev.secrets` at project root (one file, gitignored)
181
- - Service account files → app root, gitignored
182
-
183
- ---
184
-
185
- ## CLI Commands
186
-
187
- | Command | What It Does |
188
- |---------|-------------|
189
- | `dndev dev` | Start dev server |
190
- | `dndev emu start` | Start Firebase emulators |
191
- | `dndev coach` | Show what to configure (numbered checklist) |
192
- | `dndev setup` | Validate .env, automate provider config, health check |
193
- | `dndev doctor` | Check project health (providers, .env) |
194
- | `dndev deploy` | **Firebase:** hosting + functions + rules. **Supabase:** deploys frontend to [Vercel](https://vercel.com) (via scaffolded vercel.json) and Edge Functions to Supabase. Set `VITE_SUPABASE_*` in Vercel project env. |
195
- | `dndev staging` | Deploy to staging environment |
196
- | `dndev sync-secrets` | Push .dndev.secrets to runtime (Firebase/Vercel) |
197
- | `dndev sync-secrets --target github` | Push secrets to GitHub Secrets (CI/CD) |
198
- | `bun test` | Run tests (after Phase 4) |
199
- | `bun run type-check` | TypeScript validation |
200
-
201
- ---
202
-
203
- ## What's Optional
204
-
205
- | Feature | Required? | When to Set Up |
206
- |---------|-----------|---------------|
207
- | Git + GitHub | Recommended | Before starting development |
208
- | Firebase or Supabase | Yes (pick one) | Before building any features |
209
- | Cloud Functions | If using server logic | Before deploying functions |
210
- | Stripe | If using billing | When adding payment features |
211
- | GitHub Actions CI/CD | Optional | Phase 4 generates the workflow |
212
- | Staging environment | Optional | When you want a test environment |
213
- | Custom domain | Optional | After first deploy |
214
- | Sentry | Optional | When you want error tracking |
215
- | i18n | Optional | Phase 4 or after launch |
216
-
217
- ---
218
-
219
- **Start here: `bun install && dndev dev`. The homepage tells you everything else.**
@@ -1,197 +0,0 @@
1
- # Framework Gotchas
2
-
3
- **Common mistakes. Read before coding. Phase tags show when each matters most.**
4
-
5
- ---
6
-
7
- ## Imports [Phase 1, 2, 3]
8
-
9
- **Server code MUST use `/server` imports — client imports crash on deploy.**
10
-
11
- ```typescript
12
- // ✅ CORRECT
13
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
14
- import { handleError } from '@donotdev/core/server';
15
-
16
- // ❌ WRONG - crashes on deploy
17
- import { getFirestore } from '@donotdev/firebase';
18
- import { handleError } from '@donotdev/core';
19
- ```
20
-
21
- **Rule:** Always use `/server` suffix for `@donotdev/core/server`, `@donotdev/firebase/server`, `@donotdev/security/server`.
22
-
23
- **ESM only — never use `require()`.**
24
-
25
- ```typescript
26
- // ❌ WRONG
27
- const { something } = require('@donotdev/package');
28
-
29
- // ✅ CORRECT
30
- import { something } from '@donotdev/package';
31
- ```
32
-
33
- **Import ordering is mandatory:**
34
- 1. React (values, then types)
35
- 2. Other vendors (values, then types)
36
- 3. `@donotdev/*` packages (values, then types)
37
- 4. Relative imports (values, then types)
38
-
39
- One line for values, one line for types. Blank line between categories.
40
-
41
- ---
42
-
43
- ## Routing [Phase 1, 3]
44
-
45
- **Never import from `react-router-dom` — use framework routing.**
46
-
47
- ```tsx
48
- // ❌ WRONG - breaks framework features
49
- import { Link, useNavigate, useParams } from 'react-router-dom';
50
-
51
- // ✅ CORRECT
52
- import { Link, useNavigate, useParams } from '@donotdev/ui';
53
- ```
54
-
55
- **Routes are auto-discovered** from `src/pages/*Page.tsx` with `pageMeta`. Don't use `<Routes>`, `<Route>`, or manual `<Outlet />`.
56
-
57
- **Use `useRouteParam('id')` for typed route params** — not `useParams()` from react-router-dom.
58
-
59
- **Navigation is auto-built.** Use `<DnDevNavigationMenu>` or `useNavigationItems()`. Don't build nav manually — you lose auth filtering and route discovery.
60
-
61
- ---
62
-
63
- ## Styling [Phase 3, 4]
64
-
65
- **No inline `fontSize` or `font-size` — use `Text` level prop.**
66
-
67
- ```tsx
68
- // ❌ WRONG
69
- <Text style={{ fontSize: '18px' }}>Title</Text>
70
-
71
- // ✅ CORRECT
72
- <Text level="h2">Title</Text>
73
- ```
74
-
75
- Levels: `h1`, `h2`, `h3`, `h4`, `body`, `small`, `caption`. Limit to 2–3 levels per page.
76
-
77
- **RTL: Always use `start`/`end` — never `left`/`right`.**
78
-
79
- ```css
80
- /* ❌ WRONG - breaks RTL */
81
- text-align: left;
82
-
83
- /* ✅ CORRECT - works in both LTR and RTL */
84
- text-align: start;
85
- ```
86
-
87
- Same for inline styles: `textAlign: 'start'` not `textAlign: 'left'`. Same for data attributes: `data-text-align="start|center|end"`.
88
-
89
- ---
90
-
91
- ## Components [Phase 3]
92
-
93
- **Always `lookup_symbol` before using any `@donotdev` component.** Never guess props.
94
-
95
- Common wrong props:
96
- - `Button`: no `size`, `tone`, `gap` — use `variant`, `display`
97
- - `Text`: no `size`, `tone`, `color` — use `level`, `variant`
98
- - `Stack`: no `spacing`, `size` — use `gap`
99
- - `Card`: no `padding`, `margin`, `size` — use `title`, `subtitle`, `content`, `footer`
100
- - `Grid`: no `columns` — use `cols`
101
-
102
- **If you can't do it with framework components:** Stop. Tell the user what's missing. Don't invent custom workarounds.
103
-
104
- ---
105
-
106
- ## CRUD [Phase 2, 3]
107
-
108
- **Hidden fields are auto-added by `defineEntity()` — don't define them manually:**
109
- - `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`
110
-
111
- **Status field — extend, don't redefine.**
112
- The `status` field is auto-added with locked `visibility: 'admin'`, `editable: 'admin'`, `type: 'select'`. Only `validation.options` can be extended.
113
-
114
- ```typescript
115
- // ❌ WRONG - these properties are silently ignored
116
- status: { type: 'select', visibility: 'owner', editable: 'admin', validation: { options: [...] } }
117
-
118
- // ✅ CORRECT - only extend options (merged after defaults: draft, available, deleted)
119
- status: { validation: { options: [{ value: 'shipped', label: 'Shipped' }] } }
120
- ```
121
-
122
- **Scope field is auto-added** when `scope` is configured. Don't manually define the scope field (e.g., `companyId`).
123
-
124
- **Custom form fields MUST use framework's `useController`:**
125
-
126
- ```typescript
127
- // ❌ WRONG
128
- import { useController } from 'react-hook-form';
129
-
130
- // ✅ CORRECT
131
- import { useController } from '@donotdev/crud';
132
- ```
133
-
134
- **Form components receive `control` prop, not `field` prop.**
135
-
136
- **Price field is structured:** `{ amount, currency, vatIncluded, discountPercent }`. Don't store computed discount amounts.
137
-
138
- **File uploads are deferred** — files upload on form submit, not on selection. Images show optimistic blob URLs.
139
-
140
- **Entity namespace defaults to `entity-{name}`** (lowercase). Translation files must match: `locales/entity-product_en.json`.
141
-
142
- ---
143
-
144
- ## Functions [Phase 3, 4]
145
-
146
- **Use `createFunction` for custom functions — 3 params, everything included:**
147
-
148
- ```typescript
149
- import { createFunction } from '@donotdev/functions/firebase';
150
-
151
- export const myFunction = createFunction(schema, 'operation_name', async (data, { uid }) => {
152
- // Your logic
153
- });
154
- ```
155
-
156
- **Use `createBaseFunction` only when you need custom config** (memory, timeout, region override).
157
-
158
- **Deploy with `dndev deploy`** — not `firebase deploy`. Manual deploy causes CORS 403 on preflight because Cloud Run blocks unauthenticated OPTIONS by default.
159
-
160
- **Naming:** Export in camelCase (`getDashboardMetrics`), operation ID in snake_case (`get_dashboard_metrics`).
161
-
162
- **CRUD functions are one-liner:** `export const crud = createCrudFunctions(entities);` — generates all CRUD endpoints per entity. Access controlled via `entity.access`.
163
-
164
- ---
165
-
166
- ## i18n [Phase 3, 4]
167
-
168
- **Phase 3: hardcode strings. Phase 4: add translations.** Don't i18n too early.
169
-
170
- **Two loading strategies:**
171
- - **Eager** (always loaded): `src/locales/common_en.json` — navigation, buttons, common UI
172
- - **Lazy** (loaded per page): `src/pages/locales/home_en.json` — page-specific content
173
-
174
- **Status field translations** fall back: `entity-{name}` namespace → `crud` namespace.
175
-
176
- **Rich text uses `<Trans>` component** with supported tags only: `<accent>`, `<primary>`, `<muted>`, `<success>`, `<warning>`, `<error>`, `<bold>`, `<code>`.
177
-
178
- **Array translations use `tList`:**
179
- ```tsx
180
- import { tList } from '@donotdev/ui';
181
- <Card content={tList(t, 'features.items', 4)} />
182
- ```
183
-
184
- ---
185
-
186
- ## Dependencies [Phase 1]
187
-
188
- **Apps don't declare bundled deps.** Framework packages (`@donotdev/*`) provide everything. Don't add `react-router-dom`, `react-hook-form`, `valibot`, etc. to app's `package.json` — they come through framework deps.
189
-
190
- **Environment variables:**
191
- - Client: `apps/my-app/.env` (prefix with `VITE_*`)
192
- - Server: `functions/.env` (secrets: `STRIPE_*`, OAuth tokens)
193
- - Local overrides: `.env.local` (gitignored)
194
-
195
- ---
196
-
197
- **When in doubt: search the codebase first, ask the user second, never guess.**