@donotdev/cli 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dependencies-matrix.json +25 -7
- package/dist/bin/commands/build.js +156 -158
- package/dist/bin/commands/bump.js +153 -153
- package/dist/bin/commands/cacheout.js +154 -154
- package/dist/bin/commands/create-app.js +184 -156
- package/dist/bin/commands/create-project.js +154 -154
- package/dist/bin/commands/deploy.js +470 -470
- package/dist/bin/commands/dev.js +155 -155
- package/dist/bin/commands/emu.js +155 -155
- package/dist/bin/commands/format.js +154 -154
- package/dist/bin/commands/lint.js +157 -154
- package/dist/bin/commands/preview.js +155 -155
- package/dist/bin/commands/sync-secrets.js +155 -155
- package/dist/bin/commands/wai.d.ts +11 -0
- package/dist/bin/commands/wai.d.ts.map +1 -0
- package/dist/bin/commands/wai.js +12 -0
- package/dist/bin/commands/wai.js.map +1 -0
- package/dist/bin/dndev.js +24 -8
- package/dist/bin/donotdev.js +24 -8
- package/dist/index.js +524 -497
- package/package.json +1 -1
- package/templates/app-demo/src/config/app.ts.example +12 -0
- package/templates/app-next/src/config/app.ts.example +75 -48
- package/templates/app-vite/index.html.example +71 -37
- package/templates/app-vite/src/config/app.ts.example +75 -47
- package/templates/app-vite/src/pages/FormPageExample.tsx.example +152 -0
- package/templates/app-vite/src/pages/HomePage.tsx.example +81 -134
- package/templates/app-vite/src/pages/ListPageExample.tsx.example +88 -0
- package/templates/functions-firebase/build.mjs.example +8 -1
- package/templates/functions-firebase/functions-firebase/build.mjs.example +8 -1
- package/templates/functions-firebase/functions-firebase/src/index.ts.example +19 -25
- package/templates/functions-firebase/functions.config.js.example +35 -0
- package/templates/root-consumer/entities/ExampleEntity.ts.example +223 -0
- package/templates/root-consumer/entities/demo.ts.example +562 -0
- package/templates/root-consumer/entities/index.ts.example +15 -0
- package/templates/root-consumer/guides/{AGENT_START_HERE.md.example → dndev/AGENT_START_HERE.md.example} +22 -0
- package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +231 -0
- package/templates/root-consumer/guides/{SETUP_AUTH.md.example → dndev/SETUP_AUTH.md.example} +30 -0
- package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +473 -0
- package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +116 -0
- package/templates/root-consumer/guides/wai-way/WAI_WAY_CLI.md.example +404 -0
- package/templates/root-consumer/guides/wai-way/agents/architect.md.example +78 -0
- package/templates/root-consumer/guides/wai-way/agents/builder.md.example +87 -0
- package/templates/root-consumer/guides/wai-way/agents/extractor.md.example +325 -0
- package/templates/root-consumer/guides/wai-way/agents/polisher.md.example +100 -0
- package/templates/root-consumer/guides/wai-way/blueprints/0_brainstorm.md.example +281 -0
- package/templates/root-consumer/guides/wai-way/blueprints/1_scaffold.md.example +77 -0
- package/templates/root-consumer/guides/wai-way/blueprints/2_entities.md.example +104 -0
- package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +124 -0
- package/templates/root-consumer/guides/wai-way/blueprints/4_configure.md.example +165 -0
- package/templates/root-consumer/guides/wai-way/context_map.json.example +95 -0
- package/templates/root-consumer/guides/wai-way/entity_patterns.md.example +840 -0
- package/templates/root-consumer/guides/wai-way/page_patterns.md.example +686 -0
- package/templates/root-consumer/guides/wai-way/presets_guide.md.example +217 -0
- package/templates/root-consumer/guides/wai-way/spec_template.md.example +312 -0
- package/templates/functions-firebase/functions-firebase/src/crud/createEntity.ts.example +0 -19
- package/templates/functions-firebase/functions-firebase/src/crud/deleteEntity.ts.example +0 -14
- package/templates/functions-firebase/functions-firebase/src/crud/getEntity.ts.example +0 -14
- package/templates/functions-firebase/functions-firebase/src/crud/index.ts.example +0 -12
- package/templates/functions-firebase/functions-firebase/src/crud/listEntities.ts.example +0 -14
- package/templates/functions-firebase/functions-firebase/src/crud/updateEntity.ts.example +0 -14
- package/templates/root-consumer/guides/COMPONENTS_CRUD.md.example +0 -70
- package/templates/root-consumer/guides/SETUP_CRUD.md.example +0 -1244
- package/templates/root-consumer/guides/SETUP_FUNCTIONS.md.example +0 -114
- /package/templates/root-consumer/guides/{COMPONENTS_ADV.md.example → dndev/COMPONENTS_ADV.md.example} +0 -0
- /package/templates/root-consumer/guides/{COMPONENTS_ATOMIC.md.example → dndev/COMPONENTS_ATOMIC.md.example} +0 -0
- /package/templates/root-consumer/guides/{COMPONENTS_UI.md.example → dndev/COMPONENTS_UI.md.example} +0 -0
- /package/templates/root-consumer/guides/{ENV_SETUP.md.example → dndev/ENV_SETUP.md.example} +0 -0
- /package/templates/root-consumer/guides/{INDEX.md.example → dndev/INDEX.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_APP_CONFIG.md.example → dndev/SETUP_APP_CONFIG.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_BILLING.md.example → dndev/SETUP_BILLING.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_I18N.md.example → dndev/SETUP_I18N.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_LAYOUTS.md.example → dndev/SETUP_LAYOUTS.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_OAUTH.md.example → dndev/SETUP_OAUTH.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_PAGES.md.example → dndev/SETUP_PAGES.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_PWA.md.example → dndev/SETUP_PWA.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_THEMES.md.example → dndev/SETUP_THEMES.md.example} +0 -0
- /package/templates/root-consumer/guides/{USE_ROUTING.md.example → dndev/USE_ROUTING.md.example} +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/APP_CHECK.md.example +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/COOKIE_REFERENCE.md.example +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/EMULATORS.md.example +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/VERSION_CONTROL.md.example +0 -0
|
@@ -1,163 +1,110 @@
|
|
|
1
|
-
// apps/{{appName}}/src/pages/HomePage.tsx
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* @fileoverview Home
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* @fileoverview Home Page
|
|
3
|
+
*
|
|
4
|
+
* THIS FILE IS YOUR STARTING POINT. Modify the content below.
|
|
5
|
+
*
|
|
6
|
+
* HOW PAGES WORK:
|
|
7
|
+
* 1. Name files *Page.tsx in src/pages/ → auto-discovered as routes
|
|
8
|
+
* 2. Export `meta` for navigation, auth, icons
|
|
9
|
+
* 3. Export default function → your page component
|
|
10
|
+
* 4. Use PageContainer as wrapper → handles layout, scrolling
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
13
|
import { Home } from 'lucide-react';
|
|
11
14
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
CallToAction,
|
|
15
|
-
Card,
|
|
16
|
-
Grid,
|
|
17
|
-
GridArea,
|
|
18
|
-
HeroSection,
|
|
19
|
-
RadioGroup,
|
|
20
|
-
Section,
|
|
21
|
-
Stack,
|
|
22
|
-
Text,
|
|
23
|
-
} from '@donotdev/components';
|
|
24
|
-
import {
|
|
25
|
-
useLayout,
|
|
26
|
-
useTranslation,
|
|
27
|
-
type LayoutPreset,
|
|
28
|
-
type PageMeta,
|
|
29
|
-
} from '@donotdev/core';
|
|
15
|
+
import { Button, HeroSection, Section, Card, Grid, Stack } from '@donotdev/components';
|
|
16
|
+
import type { PageMeta } from '@donotdev/core';
|
|
30
17
|
import { PageContainer, Link } from '@donotdev/ui';
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// PAGE METADATA - Controls routing, navigation, and access
|
|
21
|
+
// ============================================================================
|
|
22
|
+
//
|
|
23
|
+
// namespace → i18n namespace for translations (matches locales/home_en.json)
|
|
24
|
+
// icon → Navigation icon (from lucide-react)
|
|
25
|
+
// nav → Show in navigation (default: true, set false to hide)
|
|
26
|
+
// navGroup → Navigation group: 'main' | 'admin' | 'footer' (default: 'main')
|
|
27
|
+
// route → Custom route path (default: derived from filename)
|
|
28
|
+
// auth → Access control:
|
|
29
|
+
// - undefined → public (anyone can view)
|
|
30
|
+
// - true → requires login
|
|
31
|
+
// - 'admin' → requires admin role
|
|
32
|
+
// - { required: true, role: 'admin' } → full syntax
|
|
33
|
+
// tier → Subscription tier required: 'pro' | 'enterprise'
|
|
34
|
+
// hideFromMenu → Show in routing but hide from navigation menu
|
|
35
|
+
//
|
|
41
36
|
export const NAMESPACE = 'home';
|
|
42
37
|
|
|
43
38
|
export const meta: PageMeta = {
|
|
44
39
|
namespace: NAMESPACE,
|
|
45
40
|
icon: <Home />,
|
|
41
|
+
// nav: true, // Uncomment to hide from navigation
|
|
42
|
+
// navGroup: 'main', // 'main' | 'admin' | 'footer'
|
|
43
|
+
// route: '/', // Custom route (default: / for HomePage)
|
|
44
|
+
// auth: true, // Uncomment to require login
|
|
45
|
+
// auth: 'admin', // Uncomment to require admin role
|
|
46
|
+
// auth: { required: true, role: 'admin' }, // Full syntax
|
|
47
|
+
// tier: 'pro', // Uncomment to require subscription
|
|
48
|
+
// hideFromMenu: true, // Uncomment to hide from menu but keep route
|
|
46
49
|
};
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const { t } = useTranslation([NAMESPACE]);
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// PAGE COMPONENT
|
|
53
|
+
// ============================================================================
|
|
52
54
|
|
|
55
|
+
export default function HomePage() {
|
|
53
56
|
return (
|
|
54
57
|
<PageContainer>
|
|
58
|
+
{/* Hero Section - Full-width banner with title and subtitle */}
|
|
55
59
|
<HeroSection
|
|
56
|
-
title=
|
|
57
|
-
subtitle=
|
|
60
|
+
title="Welcome to Your App"
|
|
61
|
+
subtitle="Built with DoNotDev Framework. Edit this page in src/pages/HomePage.tsx"
|
|
58
62
|
variant="primary"
|
|
59
63
|
/>
|
|
60
64
|
|
|
61
|
-
{/*
|
|
62
|
-
<Section title="
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
value={currentPreset || 'landing'}
|
|
69
|
-
onValueChange={(value) => setLayoutPreset(value as LayoutPreset)}
|
|
70
|
-
gridCols={3}
|
|
71
|
-
items={LAYOUT_PRESETS.map((preset) => ({
|
|
72
|
-
value: preset,
|
|
73
|
-
label: preset.charAt(0).toUpperCase() + preset.slice(1),
|
|
74
|
-
}))}
|
|
75
|
-
/>
|
|
65
|
+
{/* Section - Content block with optional title */}
|
|
66
|
+
<Section title="Getting Started">
|
|
67
|
+
<Grid cols={[1, 1, 2, 3]} gap="medium">
|
|
68
|
+
<Card title="1. Configure" content="Edit src/config/app.ts to set your app name and preset." />
|
|
69
|
+
<Card title="2. Create Pages" content="Add *Page.tsx files in src/pages/ - they auto-route." />
|
|
70
|
+
<Card title="3. Add Content" content="Use components from @donotdev/components." />
|
|
71
|
+
</Grid>
|
|
76
72
|
</Section>
|
|
77
73
|
|
|
78
|
-
{/*
|
|
79
|
-
<Section title="Components
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
{/* Stack - Flexible container for buttons, inline items */}
|
|
75
|
+
<Section title="Layout Components">
|
|
76
|
+
<Stack direction="row" gap="medium" wrap>
|
|
77
|
+
<Button variant="primary">Primary Button</Button>
|
|
78
|
+
<Button variant="outline">Outline Button</Button>
|
|
79
|
+
<Button variant="ghost">Ghost Button</Button>
|
|
80
|
+
</Stack>
|
|
81
|
+
</Section>
|
|
82
|
+
|
|
83
|
+
{/* Call to Action */}
|
|
84
|
+
<Section tone="muted" align="center">
|
|
85
|
+
<Stack gap="medium" align="center">
|
|
86
|
+
<h2>Ready to Build?</h2>
|
|
87
|
+
<p>Check out the guides folder for setup instructions.</p>
|
|
86
88
|
<Stack direction="row" gap="medium">
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
<Button
|
|
90
|
+
variant="primary"
|
|
91
|
+
render={({ children, ...props }) => (
|
|
92
|
+
<Link path="https://donotdev.com" {...props}>{children}</Link>
|
|
93
|
+
)}
|
|
94
|
+
>
|
|
95
|
+
Documentation
|
|
96
|
+
</Button>
|
|
97
|
+
<Button
|
|
98
|
+
variant="outline"
|
|
99
|
+
render={({ children, ...props }) => (
|
|
100
|
+
<Link path="https://discord.gg/donotdev" {...props}>{children}</Link>
|
|
101
|
+
)}
|
|
102
|
+
>
|
|
103
|
+
Join Discord
|
|
104
|
+
</Button>
|
|
93
105
|
</Stack>
|
|
94
|
-
</
|
|
95
|
-
|
|
96
|
-
{/* Grid + GridArea Example */}
|
|
97
|
-
<Card title="Grid + GridArea Components">
|
|
98
|
-
<Text variant="muted">
|
|
99
|
-
Grid with named areas for complex layouts.
|
|
100
|
-
</Text>
|
|
101
|
-
<Grid
|
|
102
|
-
areas={`"header header"
|
|
103
|
-
"sidebar main"
|
|
104
|
-
"footer footer"`}
|
|
105
|
-
templateColumns="1fr 2fr"
|
|
106
|
-
gap="tight"
|
|
107
|
-
>
|
|
108
|
-
<GridArea name="header">
|
|
109
|
-
<Card variant="glass">
|
|
110
|
-
<Text>Header Header</Text>
|
|
111
|
-
</Card>
|
|
112
|
-
</GridArea>
|
|
113
|
-
<GridArea name="main">
|
|
114
|
-
<Card variant="glass">
|
|
115
|
-
<Text>Main 2fr</Text>
|
|
116
|
-
</Card>
|
|
117
|
-
</GridArea>
|
|
118
|
-
<GridArea name="sidebar">
|
|
119
|
-
<Card variant="glass">
|
|
120
|
-
<Text>Sidebar 1fr</Text>
|
|
121
|
-
</Card>
|
|
122
|
-
</GridArea>
|
|
123
|
-
<GridArea name="footer">
|
|
124
|
-
<Card variant="glass">
|
|
125
|
-
<Text>Footer Footer</Text>
|
|
126
|
-
</Card>
|
|
127
|
-
</GridArea>
|
|
128
|
-
</Grid>
|
|
129
|
-
</Card>
|
|
106
|
+
</Stack>
|
|
130
107
|
</Section>
|
|
131
|
-
|
|
132
|
-
{/* CallToAction */}
|
|
133
|
-
<CallToAction
|
|
134
|
-
title="Ready to Build?"
|
|
135
|
-
subtitle="Check out the guides folder for setup instructions."
|
|
136
|
-
primaryAction={
|
|
137
|
-
<Button
|
|
138
|
-
variant="primary"
|
|
139
|
-
render={({ children, ...props }) => (
|
|
140
|
-
<Link path="https://donotdev.com" {...props}>
|
|
141
|
-
{children}
|
|
142
|
-
</Link>
|
|
143
|
-
)}
|
|
144
|
-
>
|
|
145
|
-
Learn More
|
|
146
|
-
</Button>
|
|
147
|
-
}
|
|
148
|
-
secondaryAction={
|
|
149
|
-
<Button
|
|
150
|
-
variant="outline"
|
|
151
|
-
render={({ children, ...props }) => (
|
|
152
|
-
<Link path="https://discord.gg/fbeYWDak" {...props}>
|
|
153
|
-
{children}
|
|
154
|
-
</Link>
|
|
155
|
-
)}
|
|
156
|
-
>
|
|
157
|
-
Join Discord
|
|
158
|
-
</Button>
|
|
159
|
-
}
|
|
160
|
-
/>
|
|
161
108
|
</PageContainer>
|
|
162
109
|
);
|
|
163
110
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Example CRUD List Page
|
|
3
|
+
*
|
|
4
|
+
* COPY THIS FILE and rename (e.g., ProductsListPage.tsx, CustomersListPage.tsx)
|
|
5
|
+
*
|
|
6
|
+
* HOW IT WORKS:
|
|
7
|
+
* 1. Import your entity definition
|
|
8
|
+
* 2. Use EntityList component - it handles everything:
|
|
9
|
+
* - Fetching data (optimized via listFields)
|
|
10
|
+
* - Table columns (respects field visibility by role)
|
|
11
|
+
* - Search, sort, pagination
|
|
12
|
+
* - Create/Edit/Delete actions
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Package } from 'lucide-react';
|
|
16
|
+
|
|
17
|
+
import { EntityList } from '@donotdev/crud';
|
|
18
|
+
import { useAuth } from '@donotdev/auth';
|
|
19
|
+
import type { PageMeta } from '@donotdev/core';
|
|
20
|
+
import { PageContainer } from '@donotdev/ui';
|
|
21
|
+
|
|
22
|
+
// Import your entity from root-level entities folder
|
|
23
|
+
// import { productEntity } from 'entities/Product';
|
|
24
|
+
|
|
25
|
+
// Placeholder - replace with your entity import
|
|
26
|
+
const productEntity = null as any;
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// PAGE METADATA
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
export const NAMESPACE = 'products';
|
|
33
|
+
|
|
34
|
+
export const meta: PageMeta = {
|
|
35
|
+
namespace: NAMESPACE,
|
|
36
|
+
icon: <Package />,
|
|
37
|
+
route: '/products',
|
|
38
|
+
auth: { required: true, role: 'admin' }, // Admin-only page
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// PAGE COMPONENT
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
export default function ProductsListPage() {
|
|
46
|
+
const user = useAuth('user');
|
|
47
|
+
|
|
48
|
+
// Zero-Config: EntityList handles everything automatically:
|
|
49
|
+
// - Fetches data using entity's listFields (optimized query)
|
|
50
|
+
// - Renders columns based on field definitions
|
|
51
|
+
// - Applies visibility rules based on user role
|
|
52
|
+
// - Includes search, sort, pagination
|
|
53
|
+
// - Add/Edit/Delete buttons with proper permissions
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<PageContainer>
|
|
57
|
+
<EntityList
|
|
58
|
+
entity={productEntity}
|
|
59
|
+
userRole={user?.role}
|
|
60
|
+
// Optional overrides:
|
|
61
|
+
// onRowClick={(item) => navigate(`/products/${item.id}`)}
|
|
62
|
+
// createPath="/products/new"
|
|
63
|
+
// hideActions={false}
|
|
64
|
+
// pageSize={25}
|
|
65
|
+
/>
|
|
66
|
+
</PageContainer>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// ALTERNATIVE: Card Grid Layout
|
|
72
|
+
// ============================================================================
|
|
73
|
+
//
|
|
74
|
+
// For a card-based grid instead of table:
|
|
75
|
+
//
|
|
76
|
+
// import { EntityCardList } from '@donotdev/crud';
|
|
77
|
+
//
|
|
78
|
+
// export default function ProductsGridPage() {
|
|
79
|
+
// return (
|
|
80
|
+
// <PageContainer>
|
|
81
|
+
// <EntityCardList
|
|
82
|
+
// entity={productEntity}
|
|
83
|
+
// // Optional: custom card rendering
|
|
84
|
+
// // renderCard={(item) => <CustomProductCard product={item} />}
|
|
85
|
+
// />
|
|
86
|
+
// </PageContainer>
|
|
87
|
+
// );
|
|
88
|
+
// }
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { build } from 'esbuild';
|
|
8
|
-
import {
|
|
8
|
+
import { writeFileSync } from 'fs';
|
|
9
|
+
import { createAppFunctionsConfig, generateFunctionsYamlWithInfo } from '@donotdev/core/functions';
|
|
10
|
+
import { functionsConfig } from './functions.config.js';
|
|
9
11
|
|
|
10
12
|
async function buildFunctions() {
|
|
11
13
|
console.log('🔨 Building {{APP_NAME}} functions...');
|
|
@@ -33,6 +35,11 @@ async function buildFunctions() {
|
|
|
33
35
|
|
|
34
36
|
console.log('✅ {{APP_NAME}} functions built successfully!');
|
|
35
37
|
console.log('📁 Output directory: lib/');
|
|
38
|
+
|
|
39
|
+
// Generate functions.yaml from config
|
|
40
|
+
const { yaml, staticFunctions, crudFunctions } = generateFunctionsYamlWithInfo(functionsConfig);
|
|
41
|
+
writeFileSync('functions.yaml', yaml);
|
|
42
|
+
console.log(`📄 Generated functions.yaml: ${staticFunctions.length} static + ${crudFunctions.length} CRUD functions`);
|
|
36
43
|
|
|
37
44
|
// Log bundle info if metafile is available
|
|
38
45
|
if (result.metafile) {
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { build } from 'esbuild';
|
|
8
|
-
import {
|
|
8
|
+
import { writeFileSync } from 'fs';
|
|
9
|
+
import { createAppFunctionsConfig, generateFunctionsYamlWithInfo } from '@donotdev/core/functions';
|
|
10
|
+
import { functionsConfig } from './functions.config.js';
|
|
9
11
|
|
|
10
12
|
async function buildFunctions() {
|
|
11
13
|
console.log('🔨 Building {{APP_NAME}} functions...');
|
|
@@ -33,6 +35,11 @@ async function buildFunctions() {
|
|
|
33
35
|
|
|
34
36
|
console.log('✅ {{APP_NAME}} functions built successfully!');
|
|
35
37
|
console.log('📁 Output directory: lib/');
|
|
38
|
+
|
|
39
|
+
// Generate functions.yaml from config
|
|
40
|
+
const { yaml, staticFunctions, crudFunctions } = generateFunctionsYamlWithInfo(functionsConfig);
|
|
41
|
+
writeFileSync('functions.yaml', yaml);
|
|
42
|
+
console.log(`📄 Generated functions.yaml: ${staticFunctions.length} static + ${crudFunctions.length} CRUD functions`);
|
|
36
43
|
|
|
37
44
|
// Log bundle info if metafile is available
|
|
38
45
|
if (result.metafile) {
|
|
@@ -2,18 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview {{APP_NAME}} Firebase Functions
|
|
5
|
-
* @description
|
|
5
|
+
* @description Auto-registered CRUD + custom functions for {{APP_NAME}}
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { initializeApp } from 'firebase-admin/app';
|
|
9
|
+
import { registerCrudFunctions } from '@donotdev/functions/firebase';
|
|
10
|
+
import * as entities from 'entities';
|
|
9
11
|
|
|
10
|
-
// Initialize Firebase Admin
|
|
12
|
+
// Initialize Firebase Admin
|
|
11
13
|
if (!(globalThis as any).__FIREBASE_ADMIN_INITIALIZED__) {
|
|
12
14
|
initializeApp();
|
|
13
15
|
(globalThis as any).__FIREBASE_ADMIN_INITIALIZED__ = true;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
//
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// CRUD Functions (auto-registered from entities)
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Registers: create_cars, get_cars, list_cars, update_cars, delete_cars
|
|
22
|
+
// create_customers, get_customers, ... for each entity
|
|
23
|
+
registerCrudFunctions(entities);
|
|
24
|
+
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Auth Functions
|
|
27
|
+
// ============================================================================
|
|
17
28
|
export {
|
|
18
29
|
setCustomClaims,
|
|
19
30
|
getCustomClaims,
|
|
@@ -21,25 +32,8 @@ export {
|
|
|
21
32
|
getUserAuthStatus,
|
|
22
33
|
} from './auth';
|
|
23
34
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from './oauth';
|
|
30
|
-
|
|
31
|
-
// Export CRUD functions
|
|
32
|
-
export {
|
|
33
|
-
createEntity,
|
|
34
|
-
updateEntity,
|
|
35
|
-
deleteEntity,
|
|
36
|
-
getEntity,
|
|
37
|
-
listEntities,
|
|
38
|
-
} from './crud';
|
|
39
|
-
|
|
40
|
-
// Export billing functions
|
|
41
|
-
export {
|
|
42
|
-
processPaymentSuccess,
|
|
43
|
-
refreshSubscriptionStatus,
|
|
44
|
-
stripeWebhook,
|
|
45
|
-
} from './billing';
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Custom Functions (analytics, webhooks, etc.)
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// export { getDashboardMetrics } from './analytics';
|
|
39
|
+
// export { stripeWebhook } from './billing';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// functions/functions.config.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview {{APP_NAME}} Functions Configuration
|
|
5
|
+
* @description Configuration for Firebase Functions deployment
|
|
6
|
+
* @type {import('@donotdev/types').FunctionsConfig}
|
|
7
|
+
*
|
|
8
|
+
* This config file is used to auto-generate functions.yaml during build.
|
|
9
|
+
*
|
|
10
|
+
* - Static functions: List your custom functions here
|
|
11
|
+
* - CRUD functions: List entity names to auto-generate CRUD endpoints
|
|
12
|
+
* (e.g., ['car', 'customer'] generates: create_car, get_car, list_car, update_car, delete_car, etc.)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const functionsConfig = {
|
|
16
|
+
defaults: {
|
|
17
|
+
region: ['us-central1'],
|
|
18
|
+
platform: 'gcfv2',
|
|
19
|
+
labels: { app: '{{APP_NAME}}' },
|
|
20
|
+
},
|
|
21
|
+
functions: {
|
|
22
|
+
// Add your static (non-CRUD) functions here
|
|
23
|
+
// Example:
|
|
24
|
+
// getCustomClaims: { category: 'auth' },
|
|
25
|
+
// setCustomClaims: { category: 'auth' },
|
|
26
|
+
// stripeWebhook: { category: 'billing', trigger: 'http' },
|
|
27
|
+
},
|
|
28
|
+
crud: {
|
|
29
|
+
// List entity names to auto-generate CRUD functions
|
|
30
|
+
// Each entity will generate: create_*, get_*, list_*, update_*, delete_*
|
|
31
|
+
// Example:
|
|
32
|
+
// entities: ['car', 'customer', 'inquiry'],
|
|
33
|
+
entities: [],
|
|
34
|
+
},
|
|
35
|
+
};
|