@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Command-line interface for DoNotDev Framework",
5
5
  "type": "module",
6
6
  "private": false,
@@ -3,7 +3,6 @@
3
3
 
4
4
  <head>
5
5
  <meta charset="UTF-8" />
6
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
6
 
8
7
  <!-- Meta tags -->
9
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -50,7 +50,7 @@ export default function ConditionalFormPage() {
50
50
  }}
51
51
  submitText="Get Quote"
52
52
  cancelText={null}
53
- warnOnUnsavedChanges={false}
53
+ successPath={null}
54
54
  hideVisibilityInfo
55
55
  />
56
56
  </Card>
@@ -74,7 +74,7 @@ export default function ConditionalFormPage() {
74
74
  }}
75
75
  submitText="Book Now"
76
76
  cancelText={null}
77
- warnOnUnsavedChanges={false}
77
+ successPath={null}
78
78
  hideVisibilityInfo
79
79
  />
80
80
  </Card>
@@ -18,6 +18,7 @@ export const meta: PageMeta = {
18
18
  route: '/showcase/:id',
19
19
  hideFromMenu: true,
20
20
  preset: 'admin',
21
+ seo: { noindex: true },
21
22
  };
22
23
 
23
24
  export default function ShowcaseDetailPage() {
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../../tsconfig.vite.json",
2
+ "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "baseUrl": ".",
5
5
  "types": ["node", "vite/client"]
@@ -5,10 +5,8 @@
5
5
 
6
6
  <!-- ✅ CORE: Performance-critical meta tags first -->
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
- <meta name="color-scheme" content="light dark" />
9
8
 
10
- <!-- ✅ DnDev: Framework will inject FaviconHead here -->
11
- <!-- All favicon links will be added by FaviconHead component -->
9
+ <!-- ✅ DnDev: the build adds the favicon tags (icons, theme-color, color-scheme) to <head> -->
12
10
 
13
11
  <!-- ✅ DnDev: Asset manifest injection point -->
14
12
  <!-- window.__DNDEV_ASSETS__ and __DNDEV_ASSET_MANIFEST__ injected here -->
@@ -16,7 +16,7 @@ import { useAuth } from '@donotdev/auth';
16
16
  * Inner layout — rendered inside ExpoAppProviders so useAuth() has context.
17
17
  */
18
18
  function AppStack() {
19
- const { user } = useAuth();
19
+ const user = useAuth('user');
20
20
 
21
21
  return (
22
22
  <Stack
@@ -14,7 +14,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';
14
14
  import { useLocalSearchParams, useRouter } from 'expo-router';
15
15
 
16
16
  import { EntityFormRenderer, Stack, Text } from '@donotdev/expo';
17
- import { useCrud } from '@donotdev/crud';
17
+ import { useCrud, useCrudDoc } from '@donotdev/crud';
18
18
 
19
19
  // import { productEntity } from '../entities/Product';
20
20
  const productEntity = null as any; // replace with your entity
@@ -26,6 +26,8 @@ export default function FormPage() {
26
26
  const router = useRouter();
27
27
  const { id } = useLocalSearchParams<{ id?: string }>();
28
28
  const { add, update } = useCrud(productEntity);
29
+ // Existing record (edit mode): read through the CRUD cache
30
+ const { data: record } = useCrudDoc(productEntity, id ?? null);
29
31
  const [submitting, setSubmitting] = useState(false);
30
32
 
31
33
  const handleSubmit = async (data: unknown) => {
@@ -43,9 +45,14 @@ export default function FormPage() {
43
45
 
44
46
  return (
45
47
  <SafeAreaView style={{ flex: 1 }}>
46
- <Stack spacing={16} style={{ flex: 1, padding: 16 }}>
48
+ <Stack gap={16} style={{ flex: 1, padding: 16 }}>
47
49
  <Text level="h2">{id ? 'Edit' : 'Create'}</Text>
48
- <EntityFormRenderer entity={productEntity} entityId={id} onSubmit={handleSubmit} />
50
+ <EntityFormRenderer
51
+ entity={productEntity}
52
+ operation={id ? 'edit' : 'create'}
53
+ defaultValues={record ?? undefined}
54
+ onSubmit={handleSubmit}
55
+ />
49
56
  </Stack>
50
57
  </SafeAreaView>
51
58
  );
@@ -17,11 +17,11 @@ import { useAuth } from '@donotdev/auth';
17
17
  */
18
18
  export default function HomePage() {
19
19
  const navigate = useNavigate();
20
- const { user } = useAuth();
20
+ const user = useAuth('user');
21
21
 
22
22
  return (
23
23
  <View style={styles.container}>
24
- <Stack spacing={24} style={styles.content}>
24
+ <Stack gap={24} style={styles.content}>
25
25
  <Text level="h1">Welcome to {{appName}}</Text>
26
26
 
27
27
  <Card title="Getting Started">
@@ -29,7 +29,7 @@ export default function HomePage() {
29
29
  Your Expo app is running! Follow these steps to get started:
30
30
  </Text>
31
31
 
32
- <Stack spacing={16} style={styles.steps}>
32
+ <Stack gap={16} style={styles.steps}>
33
33
  <View>
34
34
  <Text level="h3">1. Backend Setup</Text>
35
35
  <Text level="small">
@@ -19,11 +19,11 @@ const productEntity = null as any; // replace with your entity
19
19
  * List page component — shows all records for an entity
20
20
  */
21
21
  export default function ListPage() {
22
- const { user } = useAuth();
22
+ const user = useAuth('user');
23
23
 
24
24
  return (
25
25
  <SafeAreaView style={{ flex: 1 }}>
26
- <Stack spacing={16} style={{ flex: 1, padding: 16 }}>
26
+ <Stack gap={16} style={{ flex: 1, padding: 16 }}>
27
27
  <Text level="h2">Products</Text>
28
28
  <EntityCardList entity={productEntity} userRole={user?.role} />
29
29
  </Stack>
@@ -16,7 +16,8 @@ import { useNavigate } from '@donotdev/expo';
16
16
  * Profile page component
17
17
  */
18
18
  export default function ProfilePage() {
19
- const { user, signOut } = useAuth();
19
+ const user = useAuth('user');
20
+ const signOut = useAuth('signOut');
20
21
  const navigate = useNavigate();
21
22
 
22
23
  if (!user) {
@@ -31,11 +32,11 @@ export default function ProfilePage() {
31
32
 
32
33
  return (
33
34
  <View style={styles.container}>
34
- <Stack spacing={24} style={styles.content}>
35
+ <Stack gap={24} style={styles.content}>
35
36
  <Text level="h1">Profile</Text>
36
37
 
37
38
  <Card title="Account Information">
38
- <Stack spacing={12}>
39
+ <Stack gap={12}>
39
40
  <View>
40
41
  <Text level="small" style={styles.label}>Email</Text>
41
42
  <Text level="body">{user.email}</Text>
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { View, StyleSheet } from 'react-native';
11
11
  import { Text, Card, Stack, Button } from '@donotdev/expo';
12
- import { MultipleAuthProviders } from '@donotdev/expo';
12
+ import { MultipleAuthProviders } from '@donotdev/expo/features';
13
13
  import { useNavigate } from '@donotdev/expo';
14
14
 
15
15
  /**
@@ -20,7 +20,7 @@ export default function SignInPage() {
20
20
 
21
21
  return (
22
22
  <View style={styles.container}>
23
- <Stack spacing={24} style={styles.content}>
23
+ <Stack gap={24} style={styles.content}>
24
24
  <Text level="h1">Sign In</Text>
25
25
 
26
26
  <Card title="Welcome Back">
@@ -1,10 +1,27 @@
1
- module.exports = function (api) {
1
+ // Learn more https://docs.expo.dev/versions/latest/config/babel/
2
+ // ESM: the app package.json is "type": "module". Keep the name babel.config.js:
3
+ // Expo only detects that name and otherwise adds its default preset a second time.
4
+ import { createRequire } from 'node:module';
5
+ import path from 'node:path';
6
+
7
+ const require = createRequire(import.meta.url);
8
+
9
+ // The preset Expo itself uses, resolved through `expo` (its dependency): the app needs
10
+ // no babel-preset-expo dependency, isolated installs do not hoist it.
11
+ const babelPresetExpo = require.resolve('babel-preset-expo', {
12
+ paths: [path.dirname(require.resolve('expo/package.json'))],
13
+ });
14
+
15
+ export default function (api) {
2
16
  api.cache(true);
3
17
  return {
4
- presets: ['babel-preset-expo'],
5
- plugins: [
6
- // Required for expo-router
7
- 'expo-router/babel',
18
+ presets: [
19
+ [
20
+ babelPresetExpo,
21
+ // @donotdev packages read import.meta.env (Vite/Next builds). Hermes has no
22
+ // import.meta: the preset polyfills it on native too.
23
+ { unstable_transformImportMeta: true },
24
+ ],
8
25
  ],
9
26
  };
10
- };
27
+ }
@@ -1,20 +1,10 @@
1
1
  // Learn more https://docs.expo.dev/guides/customizing-metro
2
- const { getDefaultConfig } = require('expo/metro-config');
3
- const path = require('path');
2
+ // ESM: the app package.json is "type": "module".
3
+ // Expo configures Metro for monorepos itself (SDK 52+): do not set watchFolders or
4
+ // node_modules paths here, they replace Expo's and hide the workspace node_modules.
5
+ import { getDefaultConfig } from 'expo/metro-config.js';
4
6
 
5
- const projectRoot = __dirname;
6
- const workspaceRoot = path.resolve(projectRoot, '../..');
7
+ /** @type {import('expo/metro-config.js').MetroConfig} */
8
+ const config = getDefaultConfig(import.meta.dirname);
7
9
 
8
- /** @type {import('expo/metro-config').MetroConfig} */
9
- const config = getDefaultConfig(projectRoot);
10
-
11
- // Watch workspace packages (not the entire root — avoids churning on unrelated changes)
12
- config.watchFolders = [path.resolve(workspaceRoot, 'packages')];
13
-
14
- // Let Metro resolve from both the app's own node_modules and the workspace root
15
- config.resolver.nodeModulesDirs = [
16
- path.resolve(projectRoot, 'node_modules'),
17
- path.resolve(workspaceRoot, 'node_modules'),
18
- ];
19
-
20
- module.exports = config;
10
+ export default config;
@@ -14,6 +14,7 @@
14
14
  "expo-env.d.ts"
15
15
  ],
16
16
  "exclude": [
17
- "node_modules"
17
+ "node_modules",
18
+ "supabase"
18
19
  ]
19
20
  }
@@ -13,8 +13,8 @@ import '../globals.css';
13
13
 
14
14
  /**
15
15
  * Site-level metadata only. Page title, description, canonical, Open Graph and JSON-LD
16
- * come from the framework's AutoMetaTags (PageMeta + i18n) and from <Seo> on pages
17
- * that render a record. Do not set `title` or `description` here: they would ship as
16
+ * come from the framework's AutoMetaTags (PageMeta + i18n), and on entity pages from
17
+ * the generated page's server metadata. Do not set `title` or `description` here: they would ship as
18
18
  * a second <title>/<meta name="description"> in every page's HTML.
19
19
  */
20
20
  const appUrl = process.env.NEXT_PUBLIC_APP_URL;
@@ -49,7 +49,6 @@ export function AppDocument({
49
49
  suppressHydrationWarning
50
50
  >
51
51
  <head>
52
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
53
52
  <FontPreloadLinks />
54
53
  </head>
55
54
  <body className="light">{children}</body>
@@ -5,10 +5,8 @@
5
5
 
6
6
  <!-- ✅ CORE: Performance-critical meta tags first -->
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
- <meta name="color-scheme" content="light dark" />
9
8
 
10
- <!-- ✅ DnDev: Framework will inject FaviconHead here -->
11
- <!-- All favicon links will be added by FaviconHead component -->
9
+ <!-- ✅ DnDev: the build adds the favicon tags (icons, theme-color, color-scheme) to <head> -->
12
10
 
13
11
  <!-- ✅ DnDev: Asset manifest injection point -->
14
12
  <!-- window.__DNDEV_ASSETS__ and __DNDEV_ASSET_MANIFEST__ injected here -->
@@ -1,6 +1,6 @@
1
- {
2
- "hero": {
3
- "title": "Welcome to DnDev",
4
- "subtitle": "Your app is ready. Explore the framework patterns below."
5
- }
6
- }
1
+ {
2
+ "hero": {
3
+ "title": "Welcome to DnDev",
4
+ "subtitle": "Your app is ready. Explore the framework patterns below."
5
+ }
6
+ }
@@ -133,7 +133,7 @@ export default function ProductPage() {
133
133
  entity={productEntity}
134
134
  operation="edit"
135
135
  onSubmit={handleSubmit}
136
- defaultValues={formData} // Loaded data
136
+ defaultValues={formData ?? undefined} // Loaded data
137
137
  submitText={t('update')}
138
138
  // Cancel automatically navigates to /products (or cancelPath if provided)
139
139
  cancelPath="/products"
@@ -136,9 +136,9 @@ export default function HomePage() {
136
136
  title="Secrets (Stripe, OAuth, etc.)"
137
137
  subtitle="Server-side API keys for Cloud Functions"
138
138
  content={[
139
- 'Add secrets to functions/.env (not the app .env)',
139
+ 'Add secrets to .dndev.secrets at the project root (not the app .env)',
140
140
  'Run: dndev sync-secrets to push to Firebase Secret Manager',
141
- 'Secrets are auto-loaded by Cloud Functions at runtime',
141
+ 'Each function gets the secrets it declares (defineSecret)',
142
142
  'Never put server secrets in VITE_ variables',
143
143
  ]}
144
144
  />
@@ -149,7 +149,7 @@ export default function HomePage() {
149
149
  content={[
150
150
  'Go to dashboard.stripe.com → create account',
151
151
  'Get API keys from Developers → API Keys',
152
- 'Add to functions/.env: STRIPE_SECRET_KEY=sk_test_...',
152
+ 'Add to .dndev.secrets: STRIPE_SECRET_KEY=sk_test_...',
153
153
  'Add to .env: VITE_STRIPE_PUBLISHABLE_KEY=pk_test_...',
154
154
  'Set up webhook: Developers → Webhooks → Add endpoint',
155
155
  'Webhook URL: https://<your-functions-url>/stripeWebhook',
@@ -2,6 +2,7 @@
2
2
  "hosting": {
3
3
  "public": "dist",
4
4
  "site": "{{YOUR_FIREBASE_PROJECT_ID}}",
5
+ "cleanUrls": true,
5
6
  "ignore": [
6
7
  "firebase.json",
7
8
  "**/.*",
@@ -18,7 +19,7 @@
18
19
  },
19
20
  {
20
21
  "source": "**",
21
- "destination": "/index.html"
22
+ "destination": "/_shell.html"
22
23
  }
23
24
  ],
24
25
  "headers": [
@@ -300,7 +301,7 @@
300
301
  ]
301
302
  }
302
303
  ]
303
- }{{#includeFunctions}},
304
+ }{{#includeFirebaseFunctions}},
304
305
  "functions": [
305
306
  {
306
307
  "source": "functions",
@@ -316,7 +317,7 @@
316
317
  ],
317
318
  "runtime": "nodejs22"
318
319
  }
319
- ],
320
+ ]{{/includeFirebaseFunctions}}{{#includeFunctions}},
320
321
  "firestore": {
321
322
  "rules": "firestore.rules",
322
323
  "indexes": "firestore.indexes.json"
@@ -327,10 +328,10 @@
327
328
  "emulators": {
328
329
  "auth": {
329
330
  "port": 9099
330
- }{{#includeFunctions}},
331
+ }{{#includeFirebaseFunctions}},
331
332
  "functions": {
332
333
  "port": 5001
333
- },
334
+ }{{/includeFirebaseFunctions}}{{#includeFunctions}},
334
335
  "firestore": {
335
336
  "port": 8080
336
337
  },
@@ -5,11 +5,6 @@
5
5
  "moduleResolution": "NodeNext",
6
6
  "lib": ["ES2022"],
7
7
  "types": ["node"],
8
- "noEmit": false,
9
- "outDir": "./functions/lib",
10
- "rootDir": "./functions/src"
11
- },
12
- "include": ["functions/src/**/*", "entities/**/*"],
13
- "exclude": ["node_modules", "**/node_modules", "**/dist", "**/.next", "**/lib"]
8
+ "noEmit": true
9
+ }
14
10
  }
15
-
@@ -1,66 +1,15 @@
1
1
  {{#isNextjs}}{
2
2
  "framework": "nextjs",
3
- "installCommand": "bun install"{{#includeVercelFunctions}},
4
- "functions": {
5
- "functions/src/api/**/*.ts": {
6
- "runtime": "@vercel/node@3"
7
- }
8
- },
9
- "rewrites": [
10
- {
11
- "source": "/api/(.*)",
12
- "destination": "/functions/src/api/$1"
13
- }
14
- ]{{/includeVercelFunctions}}{{#includeVercelFunctions}},
15
- "env": {
16
- "STRIPE_SECRET_KEY": "@stripe-secret-key",
17
- "STRIPE_WEBHOOK_SECRET": "@stripe-webhook-secret",
18
- "STRIPE_PUBLISHABLE_KEY": "@stripe-publishable-key"{{#isFirebase}},
19
- "FIREBASE_ADMIN_PRIVATE_KEY": "@firebase-admin-private-key",
20
- "FIREBASE_PROJECT_ID": "@firebase-project-id",
21
- "FIREBASE_CLIENT_EMAIL": "@firebase-client-email"{{/isFirebase}}{{#isSupabase}},
22
- "SUPABASE_URL": "@supabase-url",
23
- "SUPABASE_SERVICE_ROLE_KEY": "@supabase-service-role-key"{{/isSupabase}}{{#needsOAuth}},
24
- "GITHUB_PERSONAL_ACCESS_TOKEN": "@github-token",
25
- "GITHUB_REPO_OWNER": "@github-repo-owner",
26
- "GITHUB_REPO_NAME": "@github-repo-name"{{/needsOAuth}}
27
- }{{/includeVercelFunctions}}
3
+ "installCommand": "bun install"
28
4
  }{{/isNextjs}}{{^isNextjs}}{
29
5
  "buildCommand": "bun run build",
30
6
  "outputDirectory": "dist",
31
- "installCommand": "bun install",{{#includeVercelFunctions}}
32
- "functions": {
33
- "functions/src/api/**/*.ts": {
34
- "runtime": "@vercel/node@3"
35
- }
36
- },
37
- "rewrites": [
38
- {
39
- "source": "/api/(.*)",
40
- "destination": "/functions/src/api/$1"
41
- },
42
- {
43
- "source": "/(.*)",
44
- "destination": "/index.html"
45
- }
46
- ]{{/includeVercelFunctions}}{{^includeVercelFunctions}}
7
+ "installCommand": "bun install",
8
+ "cleanUrls": true,
47
9
  "rewrites": [
48
10
  {
49
11
  "source": "/(.*)",
50
- "destination": "/index.html"
12
+ "destination": "/_shell"
51
13
  }
52
- ]{{/includeVercelFunctions}}{{#includeVercelFunctions}},
53
- "env": {
54
- "STRIPE_SECRET_KEY": "@stripe-secret-key",
55
- "STRIPE_WEBHOOK_SECRET": "@stripe-webhook-secret",
56
- "STRIPE_PUBLISHABLE_KEY": "@stripe-publishable-key"{{#isFirebase}},
57
- "FIREBASE_ADMIN_PRIVATE_KEY": "@firebase-admin-private-key",
58
- "FIREBASE_PROJECT_ID": "@firebase-project-id",
59
- "FIREBASE_CLIENT_EMAIL": "@firebase-client-email"{{/isFirebase}}{{#isSupabase}},
60
- "SUPABASE_URL": "@supabase-url",
61
- "SUPABASE_SERVICE_ROLE_KEY": "@supabase-service-role-key"{{/isSupabase}}{{#needsOAuth}},
62
- "GITHUB_PERSONAL_ACCESS_TOKEN": "@github-token",
63
- "GITHUB_REPO_OWNER": "@github-repo-owner",
64
- "GITHUB_REPO_NAME": "@github-repo-name"{{/needsOAuth}}
65
- }{{/includeVercelFunctions}}
14
+ ]
66
15
  }{{/isNextjs}}
@@ -33,9 +33,9 @@ import { handleError } from '@donotdev/core';
33
33
  functions/
34
34
  ├── src/
35
35
  │ ├── auth/ # Authentication functions
36
- │ ├── oauth/ # OAuth functions
37
- │ ├── billing/ # Billing functions
38
- │ └── index.ts # Main functions entry point
36
+ {{#needsOAuth}}│ ├── oauth/ # OAuth functions
37
+ {{/needsOAuth}}{{#needsBilling}}│ ├── billing/ # Billing functions
38
+ {{/needsBilling}}│ └── index.ts # Main functions entry point
39
39
  ├── package.json # Dependencies and scripts
40
40
  ├── tsconfig.json # TypeScript configuration
41
41
  ├── functions.yaml # Firebase function manifest (manually maintained - must match functions exported from src/index.ts)
@@ -47,9 +47,9 @@ functions/
47
47
  ## Features
48
48
 
49
49
  - **Authentication Management**: User custom claims and auth status
50
- - **OAuth Integration**: GitHub access management
51
- - **Billing Processing**: Stripe checkout and webhook handling
52
- - **Secure API Layer**: Professional frontend-backend communication
50
+ {{#needsOAuth}}- **OAuth Integration**: GitHub access management
51
+ {{/needsOAuth}}{{#needsBilling}}- **Billing Processing**: Stripe checkout and webhook handling
52
+ {{/needsBilling}}- **Secure API Layer**: Professional frontend-backend communication
53
53
  - **Error Handling**: Comprehensive error handling and logging
54
54
 
55
55
  ## Environment Variables
@@ -124,7 +124,7 @@ bun run serve
124
124
  bun run dev
125
125
  ```
126
126
 
127
- ## API Endpoints
127
+ {{#needsBilling}}## API Endpoints
128
128
 
129
129
  ### Stripe Webhook
130
130
 
@@ -137,7 +137,7 @@ bun run dev
137
137
  - **Integration**: Direct Stripe calls (no function needed)
138
138
  - **Purpose**: Creates Stripe checkout sessions for purchases
139
139
 
140
- ## Security
140
+ {{/needsBilling}}## Security
141
141
 
142
142
  - All functions require authentication
143
143
  - Webhook signature verification
@@ -6,7 +6,8 @@
6
6
  * @type {import('@donotdev/types').FunctionsConfig}
7
7
  *
8
8
  * Static functions are AUTO-DETECTED from src/index.ts exports.
9
- * Secrets are AUTO-DETECTED from .env (non-config keys).
9
+ * Secrets are bound per function from its declaration in code
10
+ * (`secrets: [defineSecret('X')]`); values go in .dndev.secrets at the project root.
10
11
  * You only need to list CRUD entities and set defaults.
11
12
  *
12
13
  * Use the `functions` object ONLY for overrides (e.g., HTTP triggers for webhooks).
@@ -20,14 +20,14 @@ export {
20
20
  removeCustomClaims,
21
21
  getUserAuthStatus,
22
22
  } from './auth';
23
-
23
+ {{#needsOAuth}}
24
24
  // Export OAuth functions
25
25
  export {
26
26
  grantGitHubAccess,
27
27
  revokeGitHubAccess,
28
28
  checkGitHubAccess,
29
29
  } from './oauth';
30
-
30
+ {{/needsOAuth}}
31
31
  // Export CRUD functions
32
32
  export {
33
33
  createEntity,
@@ -36,9 +36,10 @@ export {
36
36
  getEntity,
37
37
  listEntities,
38
38
  } from './crud';
39
-
39
+ {{#needsBilling}}
40
40
  // Export billing functions
41
41
  export {
42
42
  refreshSubscriptionStatus,
43
43
  stripeWebhook,
44
44
  } from './billing';
45
+ {{/needsBilling}}
@@ -1,14 +1,16 @@
1
1
  // functions/src/oauth/exchangeToken.ts
2
2
 
3
3
  /**
4
- * @fileoverview {{APP_NAME}} Exchange Token Wrapper
5
- * @description Wrapper for framework's exchangeToken with {{APP_NAME}}-specific configuration
4
+ * @fileoverview {{APP_NAME}} Exchange Token
5
+ * @description Framework OAuth code exchange for the providers {{APP_NAME}} uses
6
6
  */
7
7
 
8
- import { exchangeToken as frameworkExchangeToken } from '@donotdev/functions/firebase';
8
+ import { createExchangeToken } from '@donotdev/functions/firebase';
9
9
 
10
10
  /**
11
- * {{APP_NAME}} OAuth token exchange
12
- * Wraps the framework function with {{APP_NAME}}-specific configuration
11
+ * {{APP_NAME}} OAuth token exchange.
12
+ * List every provider the app connects: each one's `{PROVIDER}_CLIENT_SECRET`
13
+ * is declared (bound at deploy, value in .dndev.secrets) and any other provider
14
+ * is rejected. `{PROVIDER}_CLIENT_ID` goes in functions/.env.
13
15
  */
14
- export const exchangeToken = frameworkExchangeToken;
16
+ export const exchangeToken = createExchangeToken(['github']);
@@ -1,14 +1,16 @@
1
1
  // functions/src/oauth/refreshToken.ts
2
2
 
3
3
  /**
4
- * @fileoverview {{APP_NAME}} Refresh Token Wrapper
5
- * @description Wrapper for framework's refreshToken with {{APP_NAME}}-specific configuration
4
+ * @fileoverview {{APP_NAME}} Refresh Token
5
+ * @description Framework OAuth token refresh for the providers {{APP_NAME}} uses
6
6
  */
7
7
 
8
- import { refreshToken as frameworkRefreshToken } from '@donotdev/functions/firebase';
8
+ import { createRefreshToken } from '@donotdev/functions/firebase';
9
9
 
10
10
  /**
11
- * {{APP_NAME}} OAuth token refresh
12
- * Wraps the framework function with {{APP_NAME}}-specific configuration
11
+ * {{APP_NAME}} OAuth token refresh.
12
+ * Same provider list as exchangeToken: each one's `{PROVIDER}_CLIENT_SECRET`
13
+ * is declared (bound at deploy, value in .dndev.secrets) and any other provider
14
+ * is rejected. `{PROVIDER}_CLIENT_ID` goes in functions/.env.
13
15
  */
14
- export const refreshToken = frameworkRefreshToken;
16
+ export const refreshToken = createRefreshToken(['github']);
@@ -3,11 +3,9 @@
3
3
  "compilerOptions": {
4
4
  "module": "preserve",
5
5
  "moduleResolution": "bundler",
6
- "outDir": "./lib",
7
- "rootDir": "./src",
8
- "declaration": true,
9
- "declarationMap": true,
10
- "sourceMap": true
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "jsx": "react-jsx",
8
+ "noUncheckedIndexedAccess": false
11
9
  },
12
10
  "include": ["src/**/*"],
13
11
  "exclude": ["node_modules", "lib", "**/*.test.ts"]
@@ -57,7 +57,8 @@ inspector_port = 8083
57
57
  enabled = true
58
58
  port = 54327
59
59
  backend = "postgres"
60
-
60
+ {{#needsBilling}}
61
61
  # Stripe authenticates webhook calls with its signature, not a Supabase JWT
62
62
  [functions.stripe-webhook]
63
63
  verify_jwt = false
64
+ {{/needsBilling}}