@donotdev/cli 0.0.3 → 0.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.
Files changed (48) hide show
  1. package/dependencies-matrix.json +12 -24
  2. package/dist/bin/commands/bump.d.ts +1 -1
  3. package/dist/bin/commands/format.d.ts +1 -1
  4. package/dist/bin/commands/lint.d.ts +1 -1
  5. package/package.json +1 -9
  6. package/templates/app-demo/src/themes.css.example +108 -156
  7. package/templates/app-next/src/locales/home_en.json.example +6 -0
  8. package/templates/app-next/src/pages/HomePage.tsx.example +152 -8
  9. package/templates/app-next/src/themes.css.example +92 -140
  10. package/templates/app-vite/src/App.tsx.example +2 -2
  11. package/templates/app-vite/src/locales/home_en.json.example +6 -0
  12. package/templates/app-vite/src/pages/HomePage.tsx.example +149 -8
  13. package/templates/app-vite/src/themes.css.example +90 -138
  14. package/templates/root-consumer/guides/AGENT_START_HERE.md.example +83 -61
  15. package/templates/root-consumer/guides/COMPONENTS_ATOMIC.md.example +134 -0
  16. package/templates/root-consumer/guides/COMPONENTS_CRUD.md.example +70 -0
  17. package/templates/root-consumer/guides/COMPONENTS_UI.md.example +135 -0
  18. package/templates/root-consumer/guides/ENV_SETUP.md.example +14 -0
  19. package/templates/root-consumer/guides/INDEX.md.example +17 -25
  20. package/templates/root-consumer/guides/SETUP_AUTH.md.example +77 -0
  21. package/templates/root-consumer/guides/SETUP_BILLING.md.example +78 -0
  22. package/templates/root-consumer/guides/SETUP_FUNCTIONS.md.example +62 -0
  23. package/templates/root-consumer/guides/SETUP_I18N.md.example +48 -0
  24. package/templates/root-consumer/guides/SETUP_LAYOUTS.md.example +108 -0
  25. package/templates/root-consumer/guides/SETUP_OAUTH.md.example +53 -0
  26. package/templates/root-consumer/guides/SETUP_PAGES.md.example +112 -0
  27. package/templates/root-consumer/guides/SETUP_THEMES.md.example +107 -0
  28. package/templates/root-consumer/guides/advanced/COOKIE_REFERENCE.md.example +252 -0
  29. package/templates/root-consumer/guides/{EMULATOR_SETUP.md.example → advanced/EMULATORS.md.example} +1 -1
  30. package/templates/root-consumer/guides/{VERSION_CONTROL.md.example → advanced/VERSION_CONTROL.md.example} +0 -7
  31. package/templates/root-consumer/guides/AUTH_SETUP.md.example +0 -92
  32. package/templates/root-consumer/guides/BILLING_SETUP.md.example +0 -120
  33. package/templates/root-consumer/guides/CLI.md.example +0 -293
  34. package/templates/root-consumer/guides/COMPONENTS.md.example +0 -875
  35. package/templates/root-consumer/guides/FEATURES.md.example +0 -286
  36. package/templates/root-consumer/guides/FRAMEWORK_OVERVIEW.md.example +0 -97
  37. package/templates/root-consumer/guides/FUNCTIONS.md.example +0 -177
  38. package/templates/root-consumer/guides/GETTING_STARTED.md.example +0 -451
  39. package/templates/root-consumer/guides/HOW_TO_USE.md.example +0 -296
  40. package/templates/root-consumer/guides/I18N_SETUP.md.example +0 -204
  41. package/templates/root-consumer/guides/IMPORT_PATTERNS.md.example +0 -79
  42. package/templates/root-consumer/guides/INSTALLATION.md.example +0 -296
  43. package/templates/root-consumer/guides/LAYOUTS.md.example +0 -310
  44. package/templates/root-consumer/guides/PAGES_SETUP.md.example +0 -123
  45. package/templates/root-consumer/guides/STYLING.md.example +0 -273
  46. package/templates/root-consumer/guides/THEMING_SETUP.md.example +0 -119
  47. /package/templates/root-consumer/guides/{CONFIG_SETUP.md.example → SETUP_APP_CONFIG.md.example} +0 -0
  48. /package/templates/root-consumer/guides/{APP_CHECK_SETUP.md.example → advanced/APP_CHECK.md.example} +0 -0
@@ -0,0 +1,112 @@
1
+ # Setup: Pages & Routing
2
+
3
+ **Most is pre-configured.** Drop `*Page.tsx` files. Routes auto-discovered, navigation auto-generated, sitemap auto-built.
4
+
5
+ ---
6
+
7
+ ## Standard Use
8
+
9
+ **Pattern:** `src/pages/**/*Page.tsx` → routes
10
+
11
+ **Basic page structure:**
12
+ ```tsx
13
+ // src/pages/AboutPage.tsx
14
+ import { PageContainer } from '@donotdev/ui';
15
+
16
+ export const NAMESPACE = 'about';
17
+
18
+ export const meta: PageMeta = {
19
+ namespace: NAMESPACE,
20
+ };
21
+
22
+ export default function AboutPage() {
23
+ return <PageContainer><h1>About</h1></PageContainer>;
24
+ }
25
+ ```
26
+
27
+ **Cookie-cutter pattern (Landing page):**
28
+ ```tsx
29
+ import { PageContainer } from '@donotdev/ui';
30
+ import { HeroSection, Section, Card, CallToAction } from '@donotdev/components';
31
+
32
+ export default function HomePage() {
33
+ return (
34
+ <PageContainer>
35
+ <HeroSection title="Welcome" subtitle="Build fast" variant="primary" />
36
+ <Section title="Features" gridCols={3}>
37
+ <Card title="Fast" />
38
+ <Card title="Simple" />
39
+ <Card title="Powerful" />
40
+ </Section>
41
+ <CallToAction title="Get Started" primaryAction={<Button>Sign Up</Button>} />
42
+ </PageContainer>
43
+ );
44
+ }
45
+ ```
46
+
47
+ **Drop files, get routes. No config needed.**
48
+
49
+ **Component reference:** See [COMPONENTS_ATOMIC.md](./COMPONENTS_ATOMIC.md) for atomic components, [COMPONENTS_UI.md](./COMPONENTS_UI.md) for layout components.
50
+
51
+ ---
52
+
53
+ ## Advanced: All PageMeta Props
54
+
55
+ ```tsx
56
+ export const meta: PageMeta = {
57
+ // Translation/SEO namespace
58
+ namespace: NAMESPACE,
59
+
60
+ // Route configuration
61
+ route: '/custom-url', // Override auto-generated path
62
+ route: { params: ['slug'] }, // Dynamic: /blog/:slug
63
+
64
+ // Page title (optional - auto-extracted from filename)
65
+ title: 'Custom Title',
66
+
67
+ // Navigation icon (lucide-react JSX only)
68
+ icon: <Rocket />, // Menu icon (default: Link)
69
+
70
+ // Hide from navigation menu
71
+ hideFromMenu: false, // Default: false (shows in nav)
72
+
73
+ // Authentication
74
+ auth: true, // Simple: auth required
75
+ auth: { required: true }, // Explicit: auth required
76
+ auth: { required: true, role: 'admin' }, // Role-based access
77
+ auth: { required: true, tier: 'pro' }, // Tier-based access
78
+ auth: {
79
+ required: true,
80
+ validate: (role, tier) => role === 'admin' && tier === 'pro'
81
+ }, // Custom validation
82
+ };
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Advanced: Dynamic Routes & Navigation
88
+
89
+ ```tsx
90
+ // Dynamic route
91
+ export const meta: PageMeta = {
92
+ namespace: 'blog',
93
+ route: { params: ['slug'] }, // → /blog/:slug
94
+ };
95
+
96
+ export default function BlogPostPage() {
97
+ const { slug } = useParams<{ slug: string }>();
98
+ return <PageContainer><h1>{slug}</h1></PageContainer>;
99
+ }
100
+
101
+ // Manual navigation
102
+ import { useNavigate, Link } from '@donotdev/ui';
103
+ const navigate = useNavigate();
104
+ navigate('/about');
105
+ <Link path="/about">About</Link>
106
+ ```
107
+
108
+ **Pre-configured:** Navigation menu auto-generated, sitemap auto-built (if `generateSitemap: true`).
109
+
110
+ ---
111
+
112
+ **Drop files, get routes. Framework handles the rest.**
@@ -0,0 +1,107 @@
1
+ # Setup: Themes
2
+
3
+ **Most is pre-configured.** Override CSS variables in `src/themes.css`. Framework handles theme switching, auto-computed colors.
4
+
5
+ ---
6
+
7
+ ## Standard Use
8
+
9
+ **File:** `src/themes.css` (scaffolded with all variables)
10
+
11
+ **Override colors:**
12
+ ```css
13
+ :root {
14
+ /* Brand colors */
15
+ --primary: #2563eb;
16
+ --secondary: #9333ea;
17
+ --accent: #ec4899;
18
+
19
+ /* Base colors */
20
+ --background: #ffffff;
21
+ --foreground: #000000;
22
+ }
23
+ ```
24
+
25
+ **Add custom theme:**
26
+ ```css
27
+ .ocean {
28
+ --theme-icon: 'Waves';
29
+ --theme-label: 'Ocean';
30
+ --primary: #0ea5e9;
31
+ --background: #001a33;
32
+ --foreground: #e0f2fe;
33
+ }
34
+ ```
35
+
36
+ **Framework auto-computes:** Surfaces (card, popover), muted colors, borders, text on brand colors.
37
+
38
+ ---
39
+
40
+ ## Advanced: All CSS Variables
41
+
42
+ **Brand colors:**
43
+ ```css
44
+ --primary, --secondary, --accent
45
+ --primary-foreground, --secondary-foreground, --accent-foreground
46
+ ```
47
+
48
+ **Base colors:**
49
+ ```css
50
+ --background, --foreground
51
+ ```
52
+
53
+ **Status colors:**
54
+ ```css
55
+ --success, --warning, --destructive
56
+ --success-foreground, --warning-foreground, --destructive-foreground
57
+ ```
58
+
59
+ **Surfaces:**
60
+ ```css
61
+ --card, --card-foreground
62
+ --popover, --popover-foreground
63
+ --muted, --muted-foreground
64
+ --border, --input, --ring
65
+ ```
66
+
67
+ **Theme metadata:**
68
+ ```css
69
+ --theme-icon: 'Sun'; /* Lucide icon name */
70
+ --theme-label: 'Light'; /* Display name */
71
+ --theme-is-dark: 0; /* 0 = light, 1 = dark */
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Advanced: Styling Overrides
77
+
78
+ **Utility classes:**
79
+ ```tsx
80
+ <Card className="dndev-gap-sm" /> // Gap utilities
81
+ <div className="dndev-flex dndev-gap-md" /> // Layout utilities
82
+ ```
83
+
84
+ **Data attributes:**
85
+ ```tsx
86
+ <HeroSection data-text-align="center" title="Centered" />
87
+ <div data-gap="medium" data-radius="md" />
88
+ ```
89
+
90
+ **Inline styles:**
91
+ ```tsx
92
+ <Button style={{ minWidth: '200px' }} />
93
+ ```
94
+
95
+ **Global CSS rules:**
96
+ ```css
97
+ /* src/themes.css */
98
+ .dndev-button {
99
+ border-radius: 8px; /* Override default */
100
+ }
101
+ ```
102
+
103
+ **Framework respects your overrides.** All components use CSS variables, so color changes propagate automatically.
104
+
105
+ ---
106
+
107
+ **Override variables, get themes. Framework handles the rest.**
@@ -0,0 +1,252 @@
1
+ # Cookie Reference Guide
2
+
3
+ **For Framework Consumers: GDPR Compliance**
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ This guide maps DoNotDev framework features to the cookies they set, helping you configure your cookie consent banner and privacy policy correctly.
10
+
11
+ ---
12
+
13
+ ## Cookie Categories (GDPR)
14
+
15
+ - **Necessary** - Essential for service to function (no consent required per GDPR Article 6(1)(f))
16
+ - **Functional** - Enhances experience (requires consent per GDPR Article 6(1)(a))
17
+ - **Analytics** - Usage tracking (requires consent)
18
+ - **Marketing** - Advertising/tracking (requires consent)
19
+
20
+ ---
21
+
22
+ ## Feature Cookie Mapping
23
+
24
+ ### Authentication (`@donotdev/auth`)
25
+
26
+ **Provider: Firebase Authentication**
27
+
28
+ | Cookie Name | Category | Purpose | Expires |
29
+ |------------|----------|---------|---------|
30
+ | `__session` | Necessary | Session authentication token | Session |
31
+ | `__Secure-*` | Necessary | Security tokens (HTTPS only) | Varies |
32
+
33
+ **GDPR Status:** Necessary - Authentication is essential for account-based services.
34
+
35
+ **Environment Variables:**
36
+ ```bash
37
+ VITE_FIREBASE_API_KEY=your-key
38
+ VITE_FIREBASE_PROJECT_ID=your-project
39
+ ```
40
+
41
+ ---
42
+
43
+ ### OAuth (`@donotdev/oauth`)
44
+
45
+ **Providers: Google, GitHub OAuth**
46
+
47
+ | Cookie Name | Category | Purpose | Expires |
48
+ |------------|----------|---------|---------|
49
+ | OAuth state cookies | Necessary | CSRF protection during OAuth flow | Session |
50
+ | Provider session cookies | Necessary | Maintain OAuth session | Per provider |
51
+
52
+ **GDPR Status:** Necessary - Part of authentication flow.
53
+
54
+ **Environment Variables:**
55
+ ```bash
56
+ VITE_AUTH_PARTNERS=google,github
57
+ ```
58
+
59
+ **Third-party cookies set by OAuth providers:**
60
+ - **Google:** `SID`, `HSID`, `SSID`, `APISID`, `SAPISID` (necessary for OAuth)
61
+ - **GitHub:** `user_session`, `logged_in` (necessary for OAuth)
62
+
63
+ ---
64
+
65
+ ### Billing (`@donotdev/billing`)
66
+
67
+ **Provider: Stripe**
68
+
69
+ | Cookie Name | Category | Purpose | Expires |
70
+ |------------|----------|---------|---------|
71
+ | `__stripe_mid` | Necessary | Fraud prevention | 1 year |
72
+ | `__stripe_sid` | Necessary | Checkout session | 30 minutes |
73
+
74
+ **GDPR Status:** Necessary - Required for payment processing and fraud prevention.
75
+
76
+ **Environment Variables:**
77
+ ```bash
78
+ VITE_STRIPE_PUBLIC_KEY=pk_live_xxx
79
+ ```
80
+
81
+ **Stripe Privacy:** Stripe sets these cookies when Checkout or Customer Portal is opened. They're classified as necessary for PCI compliance and fraud prevention.
82
+
83
+ ---
84
+
85
+ ### Framework Core Cookies
86
+
87
+ **Set by `@donotdev/core`**
88
+
89
+ | Cookie Name | Category | Purpose | Expires |
90
+ |------------|----------|---------|---------|
91
+ | `dndev-cookie-consent` | Necessary | Stores user's cookie preferences | 365 days |
92
+ | `dndev-theme` | Necessary | Remembers dark/light mode preference | 365 days |
93
+ | `dndev-lang` | Necessary | Remembers language preference | 365 days |
94
+
95
+ **GDPR Status:** Necessary (essential for UX, no tracking, purely local preferences)
96
+
97
+ ---
98
+
99
+ ## Analytics & Marketing (Optional)
100
+
101
+ These are NOT included in the framework but commonly added by consumers:
102
+
103
+ ### Google Analytics
104
+
105
+ | Cookie Name | Category | Purpose | Expires |
106
+ |------------|----------|---------|---------|
107
+ | `_ga` | Analytics | Distinguish users | 2 years |
108
+ | `_gid` | Analytics | Distinguish users | 24 hours |
109
+ | `_gat` | Analytics | Throttle requests | 1 minute |
110
+
111
+ **GDPR Status:** Analytics - Requires explicit consent.
112
+
113
+ **Setup:** Consumer must add Google Analytics script and obtain consent.
114
+
115
+ ### Facebook Pixel
116
+
117
+ | Cookie Name | Category | Purpose | Expires |
118
+ |------------|----------|---------|---------|
119
+ | `_fbp` | Marketing | Track conversions | 90 days |
120
+
121
+ **GDPR Status:** Marketing - Requires explicit consent.
122
+
123
+ ---
124
+
125
+ ## Cookie Banner Configuration
126
+
127
+ ### Minimal Setup (Auth + Billing + Theme/Lang)
128
+
129
+ If your app only uses auth, billing, theme, and language preferences, all cookies are **necessary**:
130
+
131
+ ```typescript
132
+ // src/config/app.ts
133
+ export const appConfig: AppConfig = {
134
+ features: {
135
+ // No config needed - all framework cookies are necessary
136
+ },
137
+ };
138
+ ```
139
+
140
+ **Result:** No cookie banner shown - all cookies are GDPR-compliant without consent.
141
+
142
+ ### With Analytics/Marketing
143
+
144
+ If you add Google Analytics or marketing pixels:
145
+
146
+ ```typescript
147
+ // src/config/app.ts
148
+ export const appConfig: AppConfig = {
149
+ features: {
150
+ requiredCookies: ['necessary', 'functional', 'analytics'],
151
+ },
152
+ };
153
+ ```
154
+
155
+ **Result:** Cookie banner shows all categories, users must consent to analytics.
156
+
157
+ ---
158
+
159
+ ## Privacy Policy Template
160
+
161
+ **Example text for your privacy policy:**
162
+
163
+ ```markdown
164
+ ## Cookies We Use
165
+
166
+ ### Essential Cookies (Always Active)
167
+
168
+ We use essential cookies that are necessary for our service to function:
169
+
170
+ - **Authentication** (Firebase): Maintains your login session
171
+ - **Payment Processing** (Stripe): Enables secure payments and fraud prevention
172
+ - **Cookie Preferences**: Remembers your cookie consent choices
173
+
174
+ These cookies are essential and cannot be disabled.
175
+
176
+ ### Functional Cookies (Optional)
177
+
178
+ With your consent, we use functional cookies to enhance your experience:
179
+
180
+ - **Theme Preference**: Remembers your dark/light mode choice
181
+ - **Language Preference**: Remembers your selected language
182
+
183
+ You can disable these in cookie settings.
184
+
185
+ ### Analytics Cookies (Optional) [If applicable]
186
+
187
+ With your consent, we use Google Analytics to understand how visitors use our site.
188
+ This helps us improve the user experience.
189
+
190
+ You can disable these in cookie settings.
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Testing Cookie Compliance
196
+
197
+ ### Check What Cookies Are Set
198
+
199
+ ```javascript
200
+ // Browser console
201
+ document.cookie
202
+ ```
203
+
204
+ ### Verify Consent Before Analytics
205
+
206
+ ```typescript
207
+ import { useConsent } from '@donotdev/core';
208
+
209
+ function MyAnalytics() {
210
+ const hasAnalyticsConsent = useConsent('hasCategory')('analytics');
211
+
212
+ useEffect(() => {
213
+ if (hasAnalyticsConsent) {
214
+ // Initialize Google Analytics
215
+ }
216
+ }, [hasAnalyticsConsent]);
217
+ }
218
+ ```
219
+
220
+ ---
221
+
222
+ ## GDPR Compliance Checklist
223
+
224
+ - [ ] List all cookies in privacy policy with categories
225
+ - [ ] Only set analytics/marketing cookies after consent
226
+ - [ ] Provide cookie settings link in footer
227
+ - [ ] Allow users to withdraw consent
228
+ - [ ] Store consent for 12 months maximum
229
+ - [ ] Don't block essential features if functional cookies declined
230
+
231
+ **Framework handles:** Consent storage, banner UI, category management
232
+
233
+ **You handle:** Privacy policy text, analytics integration, marketing pixels
234
+
235
+ ---
236
+
237
+ ## Quick Reference
238
+
239
+ | Feature | Cookies | Category | Consent Required? |
240
+ |---------|---------|----------|-------------------|
241
+ | Auth | `__session`, `__Secure-*` | Necessary | No |
242
+ | OAuth | Provider session cookies | Necessary | No |
243
+ | Billing | `__stripe_mid`, `__stripe_sid` | Necessary | No |
244
+ | Theme | `dndev-theme` | Necessary | No |
245
+ | Language | `dndev-lang` | Necessary | No |
246
+ | Consent | `dndev-cookie-consent` | Necessary | No |
247
+ | Analytics | `_ga`, `_gid` | Analytics | Yes |
248
+ | Marketing | `_fbp`, etc. | Marketing | Yes |
249
+
250
+ ---
251
+
252
+ **Need help?** Check your browser DevTools → Application → Cookies to see exactly what's being set.
@@ -37,7 +37,7 @@ STRIPE_WEBHOOK_SECRET=whsec_... # Your permanent production webhook secret
37
37
 
38
38
  ```bash
39
39
  # Start emulators for a specific app
40
- dn emu showcase
40
+ dndev emu showcase
41
41
  ```
42
42
 
43
43
  If you need Stripe webhook forwarding, the emulator command will provide instructions on how to start the Stripe CLI and where to paste the temporary webhook secret.
@@ -171,11 +171,4 @@ Review the migration guide before updating.
171
171
 
172
172
  ---
173
173
 
174
- ## Related
175
-
176
- - **[Dependency System](../../docs/development/DEPENDENCY_SYSTEM.md)** - How dependency management works
177
- - **[Architecture Hub](../../docs/architecture/INDEX.md)** - Framework structure
178
-
179
- ---
180
-
181
174
  **Keep your dependencies up to date. Stay secure. Stay compatible.**
@@ -1,92 +0,0 @@
1
- # Authentication Setup
2
-
3
- **For AI Agents:** Configure auth providers and routes. Framework handles the rest.
4
-
5
- ---
6
-
7
- ## 1. Environment Variables
8
-
9
- ```bash
10
- # .env
11
- VITE_AUTH_PARTNERS=password,emailLink,google,github,facebook
12
- ```
13
-
14
- **Available Firebase Auth providers:** `password`, `emailLink`, `google`, `github`, `facebook`, `twitter`, `microsoft`, `yahoo`, `apple`
15
-
16
- **Default:** If not set, only `google` is enabled.
17
-
18
- ---
19
-
20
- ## 2. App Configuration
21
-
22
- ```typescript
23
- // apps/your-app/src/config/app.ts
24
- import type { AppConfig } from '@donotdev/core';
25
-
26
- export const appConfig: AppConfig = {
27
- auth: {
28
- authRoute: '/login', // Redirect when auth required (default: '/login')
29
- roleRoute: '/404', // Redirect when role insufficient (default: '/404')
30
- tierRoute: '/404', // Redirect when tier insufficient (default: '/404')
31
- loginPath: '/login', // Optional: Login page path (undefined = show providers in header)
32
- profilePath: '/profile', // Optional: Profile page path (default: '/profile')
33
- },
34
- };
35
- ```
36
-
37
- ---
38
-
39
- ## 3. Firebase Console Setup
40
-
41
- **User must enable providers in Firebase Console:**
42
- - Authentication > Sign-in method
43
- - Enable Email/Password (for `password` and `emailLink`)
44
- - Enable OAuth providers (Google, GitHub, etc.) and configure credentials
45
-
46
- ---
47
-
48
- ## What You Get
49
-
50
- **Automatic:**
51
- - ✅ `AuthHeader` component in layout (null if auth not needed)
52
- - ✅ OAuth callbacks handled automatically
53
- - ✅ Protected routes via `PageMeta.auth`
54
- - ✅ Session management
55
-
56
- **Components:**
57
- - `AuthHeader`, `AuthMenu` from `@donotdev/ui`
58
- - `LoginTemplate` from `@donotdev/templates`
59
- - `EmailPasswordForm`, `MultipleAuthProviders` from `@donotdev/auth`
60
-
61
- **Hook:**
62
- ```typescript
63
- import { useAuth } from '@donotdev/auth';
64
-
65
- const user = useAuth('user');
66
- const signIn = useAuth('signInWithEmail');
67
- const signOut = useAuth('signOut');
68
- ```
69
-
70
- ---
71
-
72
- ## Protected Route Example
73
-
74
- ```typescript
75
- // apps/your-app/src/pages/DashboardPage.tsx
76
- export const meta = {
77
- namespace: 'dashboard',
78
- auth: { required: true }, // ← Protected route
79
- };
80
-
81
- export default function DashboardPage() {
82
- const user = useAuth('user');
83
- return <PageContainer>Welcome, {user?.displayName}!</PageContainer>;
84
- }
85
- ```
86
-
87
- ---
88
-
89
- **Files to modify:**
90
- - `.env` - Add `VITE_AUTH_PARTNERS`
91
- - `src/config/app.ts` - Add `auth` config
92
- - `src/pages/**/*.tsx` - Add `auth` to `PageMeta` for protected routes
@@ -1,120 +0,0 @@
1
- # Billing Setup
2
-
3
- **For AI Agents:** Create Stripe config files. Framework handles checkout, webhooks, subscriptions.
4
-
5
- ---
6
-
7
- ## 1. Environment Variables
8
-
9
- **Local Emulators (.env.local):**
10
- ```bash
11
- # apps/your-app/functions/.env.local
12
- STRIPE_SECRET_KEY=sk_test_xxx
13
- STRIPE_WEBHOOK_SECRET=whsec_xxx # Get from 'stripe listen'
14
- ```
15
-
16
- **Production (.env):**
17
- ```bash
18
- # apps/your-app/functions/.env
19
- STRIPE_SECRET_KEY=sk_live_xxx
20
- STRIPE_WEBHOOK_SECRET=whsec_xxx # Permanent production secret
21
- ```
22
-
23
- **Frontend (.env):**
24
- ```bash
25
- # apps/your-app/.env
26
- VITE_STRIPE_PUBLISHABLE_KEY=pk_test_xxx
27
- ```
28
-
29
- ---
30
-
31
- ## 2. Stripe Dashboard
32
-
33
- **User must:**
34
- 1. Create products in Stripe Dashboard
35
- 2. Copy Price IDs (starts with `price_...`)
36
-
37
- ---
38
-
39
- ## 3. Frontend Config
40
-
41
- ```typescript
42
- // apps/your-app/src/config/stripeFrontConfig.ts
43
- import type { StripeFrontConfig } from '@donotdev/core';
44
-
45
- export const stripeFrontConfig: StripeFrontConfig = {
46
- pro_plan: {
47
- name: 'Pro Plan',
48
- price: 29,
49
- currency: 'USD',
50
- description: 'Perfect for growing teams',
51
- features: ['Unlimited projects', 'Priority support'],
52
- priceId: 'price_1234567890', // ← Stripe Price ID
53
- allowPromotionCodes: true,
54
- },
55
- };
56
- ```
57
-
58
- ---
59
-
60
- ## 4. Backend Config
61
-
62
- ```typescript
63
- // apps/your-app/functions/src/config/stripeBackConfig.ts
64
- import type { StripeBackConfig } from '@donotdev/core';
65
-
66
- export const stripeBackConfig: StripeBackConfig = {
67
- pro_plan: {
68
- type: 'StripeSubscription', // or 'StripePayment'
69
- name: 'Pro Plan',
70
- price: 2900, // In cents
71
- currency: 'USD',
72
- priceId: process.env.STRIPE_PRICE_PRO_PLAN!,
73
- tier: 'pro',
74
- duration: 'month',
75
-
76
- // Optional hooks
77
- onPurchaseSuccess: async (userId, metadata) => {
78
- // Grant features, send email, etc.
79
- },
80
- onSubscriptionCancelled: async (userId) => {
81
- // Revoke features, etc.
82
- },
83
- },
84
- };
85
- ```
86
-
87
- ---
88
-
89
- ## 5. Wire Up Functions
90
-
91
- ```typescript
92
- // apps/your-app/functions/src/index.ts
93
- import { createCheckoutSession } from '@donotdev/functions/firebase';
94
- import { stripeBackConfig } from './config/stripeBackConfig';
95
-
96
- export const createCheckout = createCheckoutSession(stripeBackConfig);
97
- ```
98
-
99
- ---
100
-
101
- ## What You Get
102
-
103
- **Components:**
104
- - `SubscriptionTemplate`, `PaymentTemplate` from `@donotdev/templates`
105
- - `ProductCard`, `SubscriptionManager` from `@donotdev/billing`
106
-
107
- **Hook:**
108
- ```typescript
109
- import { useStripeBilling } from '@donotdev/billing';
110
-
111
- const checkout = useStripeBilling('checkout');
112
- await checkout({ priceId: 'price_123', mode: 'subscription' });
113
- ```
114
-
115
- ---
116
-
117
- **Files to create:**
118
- - `src/config/stripeFrontConfig.ts` - Frontend config
119
- - `functions/src/config/stripeBackConfig.ts` - Backend config
120
- - `functions/src/index.ts` - Wire up functions