@microbuild/cli 0.1.0

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 (38) hide show
  1. package/README.md +555 -0
  2. package/dist/chunk-6YA3DSAE.js +362 -0
  3. package/dist/chunk-6YA3DSAE.js.map +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +2279 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/outdated-TV5ERBNC.js +110 -0
  8. package/dist/outdated-TV5ERBNC.js.map +1 -0
  9. package/dist/templates/api/auth-callback-route.ts +36 -0
  10. package/dist/templates/api/auth-headers.ts +72 -0
  11. package/dist/templates/api/auth-login-route.ts +63 -0
  12. package/dist/templates/api/auth-logout-route.ts +41 -0
  13. package/dist/templates/api/auth-user-route.ts +71 -0
  14. package/dist/templates/api/fields-route.ts +44 -0
  15. package/dist/templates/api/files-id-route.ts +116 -0
  16. package/dist/templates/api/files-route.ts +83 -0
  17. package/dist/templates/api/items-id-route.ts +120 -0
  18. package/dist/templates/api/items-route.ts +88 -0
  19. package/dist/templates/api/login-page.tsx +142 -0
  20. package/dist/templates/api/relations-route.ts +46 -0
  21. package/dist/templates/app/design-tokens.css +183 -0
  22. package/dist/templates/app/globals.css +58 -0
  23. package/dist/templates/app/layout.tsx +49 -0
  24. package/dist/templates/app/page.tsx +23 -0
  25. package/dist/templates/components/ColorSchemeToggle.tsx +35 -0
  26. package/dist/templates/lib/common-utils.ts +156 -0
  27. package/dist/templates/lib/hooks/index.ts +98 -0
  28. package/dist/templates/lib/services/index.ts +26 -0
  29. package/dist/templates/lib/theme.ts +241 -0
  30. package/dist/templates/lib/types/index.ts +10 -0
  31. package/dist/templates/lib/utils-index.ts +32 -0
  32. package/dist/templates/lib/utils.ts +14 -0
  33. package/dist/templates/lib/vform/index.ts +24 -0
  34. package/dist/templates/middleware/middleware.ts +29 -0
  35. package/dist/templates/supabase/client.ts +25 -0
  36. package/dist/templates/supabase/middleware.ts +66 -0
  37. package/dist/templates/supabase/server.ts +45 -0
  38. package/package.json +61 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Microbuild Hooks
3
+ *
4
+ * Re-exports all React hooks.
5
+ * This file is copied to your project and can be customized.
6
+ */
7
+
8
+ // Relation hooks
9
+ export { useRelationM2M, type M2MRelationInfo } from './useRelationM2M';
10
+ export { useRelationM2MItems, type M2MItem, type M2MQueryParams } from './useRelationM2MItems';
11
+ export { useRelationM2O, useRelationM2OItem, type M2ORelationInfo, type M2OItem } from './useRelationM2O';
12
+ export { useRelationO2M, useRelationO2MItems, type O2MRelationInfo, type O2MItem, type O2MQueryParams } from './useRelationO2M';
13
+ export {
14
+ useRelationM2A,
15
+ useRelationM2AItems,
16
+ type M2ARelationInfo,
17
+ type M2AItem,
18
+ type M2AQueryParams
19
+ } from './useRelationM2A';
20
+
21
+ // File hooks
22
+ export {
23
+ useFiles,
24
+ type FileUpload,
25
+ type FileUploadOptions,
26
+ type DirectusFile
27
+ } from './useFiles';
28
+
29
+ // Selection & Preset hooks
30
+ export {
31
+ useSelection,
32
+ type UseSelectionOptions,
33
+ type UseSelectionReturn
34
+ } from './useSelection';
35
+ export {
36
+ usePreset,
37
+ type UsePresetOptions,
38
+ type UsePresetReturn,
39
+ type Filter,
40
+ type Query
41
+ } from './usePreset';
42
+
43
+ // Navigation guard hooks (Directus-style)
44
+ export {
45
+ useEditsGuard,
46
+ useHasEdits,
47
+ type UseEditsGuardOptions,
48
+ type UseEditsGuardReturn
49
+ } from './useEditsGuard';
50
+
51
+ // Clipboard and Storage hooks (Directus-style)
52
+ export {
53
+ useClipboard,
54
+ type UseClipboardOptions,
55
+ type UseClipboardReturn
56
+ } from './useClipboard';
57
+ export {
58
+ useLocalStorage,
59
+ type LocalStorageValue,
60
+ type UseLocalStorageOptions,
61
+ type UseLocalStorageReturn
62
+ } from './useLocalStorage';
63
+
64
+ // Versioning hooks (DaaS workflow + content versioning)
65
+ export {
66
+ useVersions,
67
+ type ContentVersion,
68
+ type UseVersionsOptions,
69
+ type UseVersionsReturn
70
+ } from './useVersions';
71
+ export {
72
+ useWorkflowAssignment,
73
+ type WorkflowAssignment,
74
+ type UseWorkflowAssignmentReturn
75
+ } from './useWorkflowAssignment';
76
+ export {
77
+ useWorkflowVersioning,
78
+ type WorkflowState,
79
+ type WorkflowInstance,
80
+ type UseWorkflowVersioningOptions,
81
+ type UseWorkflowVersioningProps,
82
+ type UseWorkflowVersioningReturn
83
+ } from './useWorkflowVersioning';
84
+
85
+ // API helpers
86
+ export { api, directusAPI, createDirectusAPI, type DirectusAPIConfig, type QueryParams } from './api';
87
+
88
+ // Re-export types for convenience
89
+ export type {
90
+ Relation,
91
+ RelationMeta,
92
+ RelationSchema,
93
+ RelationCollectionMeta,
94
+ RelationFieldInfo
95
+ } from '@/lib/microbuild/types';
96
+
97
+ // Utility functions
98
+ export { apiRequest, isValidPrimaryKey } from './utils';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Microbuild Services
3
+ *
4
+ * Re-exports all service classes.
5
+ * This file is copied to your project and can be customized.
6
+ */
7
+
8
+ export { ItemsService, createItemsService } from './items';
9
+ export { FieldsService, createFieldsService } from './fields';
10
+ export { CollectionsService, createCollectionsService } from './collections';
11
+ export { PermissionsService, createPermissionsService, type FieldPermissions } from './permissions';
12
+ export { apiRequest, type ApiRequestOptions } from './api-request';
13
+
14
+ // DaaS Context Provider for direct API access (bypassing proxy routes)
15
+ export {
16
+ DaaSProvider,
17
+ useDaaSContext,
18
+ useIsDirectDaaSMode,
19
+ setGlobalDaaSConfig,
20
+ getGlobalDaaSConfig,
21
+ buildApiUrl,
22
+ getApiHeaders,
23
+ type DaaSConfig,
24
+ type DaaSContextValue,
25
+ type DaaSProviderProps,
26
+ } from './daas-context';
@@ -0,0 +1,241 @@
1
+ "use client";
2
+
3
+ import { createTheme } from "@mantine/core";
4
+
5
+ export const theme = createTheme({
6
+ colors: {
7
+ primary: [
8
+ "var(--ds-primary-100, #ece6fb)",
9
+ "var(--ds-primary-200, #cfcbfd)",
10
+ "var(--ds-primary-300, #a29bfb)",
11
+ "var(--ds-primary-400, #7857ff)",
12
+ "var(--ds-primary, #5925dc)",
13
+ "var(--ds-primary-600, #491db6)",
14
+ "var(--ds-primary-700, #39178e)",
15
+ "var(--ds-primary-800, #291167)",
16
+ "var(--ds-primary-900, #190a3f)",
17
+ "var(--ds-primary-950, #0f0629)"
18
+ ],
19
+ secondary: [
20
+ "var(--ds-secondary-100, #ebf1ff)",
21
+ "var(--ds-secondary-200, #d3e2ff)",
22
+ "var(--ds-secondary-300, #99bbff)",
23
+ "var(--ds-secondary-400, #70a0ff)",
24
+ "var(--ds-secondary, #1f69ff)",
25
+ "var(--ds-secondary-600, #004ff0)",
26
+ "var(--ds-secondary-700, #0040c2)",
27
+ "var(--ds-secondary-800, #003194)",
28
+ "var(--ds-secondary-900, #002266)",
29
+ "var(--ds-secondary-950, #001a4d)"
30
+ ],
31
+ success: [
32
+ "var(--ds-success-100, #ecfbee)",
33
+ "var(--ds-success-200, #c4e8c8)",
34
+ "var(--ds-success-300, #9dd9a3)",
35
+ "var(--ds-success-400, #58be62)",
36
+ "var(--ds-success-500, #3bb346)",
37
+ "var(--ds-success, #198754)",
38
+ "var(--ds-success-700, #2da337)",
39
+ "var(--ds-success-800, #196f25)",
40
+ "var(--ds-success-900, #0d4f15)",
41
+ "var(--ds-success-950, #0a3e11)"
42
+ ],
43
+ info: [
44
+ "var(--ds-info-100, #e6f3fb)",
45
+ "var(--ds-info-200, #b9d8ee)",
46
+ "var(--ds-info-300, #90c1e4)",
47
+ "var(--ds-info-400, #58a1d4)",
48
+ "var(--ds-info-500, #59a1d4)",
49
+ "var(--ds-info, #0f71bb)",
50
+ "var(--ds-info-700, #0c5b97)",
51
+ "var(--ds-info-800, #0a4776)",
52
+ "var(--ds-info-900, #08395e)",
53
+ "var(--ds-info-950, #062b47)"
54
+ ],
55
+ warning: [
56
+ "var(--ds-warning-100, #fffaeb)",
57
+ "var(--ds-warning-200, #fef0c7)",
58
+ "var(--ds-warning-300, #fedf89)",
59
+ "var(--ds-warning-400, #fec84b)",
60
+ "var(--ds-warning-500, #fdb022)",
61
+ "var(--ds-warning, #f79009)",
62
+ "var(--ds-warning-700, #dc6803)",
63
+ "var(--ds-warning-800, #b7571e)",
64
+ "var(--ds-warning-900, #8f4419)",
65
+ "var(--ds-warning-950, #6d3314)"
66
+ ],
67
+ danger: [
68
+ "var(--ds-danger-100, #fff4f3)",
69
+ "var(--ds-danger-200, #ffcfc8)",
70
+ "var(--ds-danger-300, #fc9c90)",
71
+ "var(--ds-danger-400, #fb7463)",
72
+ "var(--ds-danger-500, #fa5741)",
73
+ "var(--ds-danger, #d7260f)",
74
+ "var(--ds-danger-700, #f8331c)",
75
+ "var(--ds-danger-800, #c4281a)",
76
+ "var(--ds-danger-900, #9a1f15)",
77
+ "var(--ds-danger-950, #72170f)"
78
+ ],
79
+ gray: [
80
+ "var(--ds-gray-100, #f7f7f9)",
81
+ "var(--ds-gray-200, #e4e7ec)",
82
+ "var(--ds-gray-300, #d0d5dd)",
83
+ "var(--ds-gray-400, #98a2b3)",
84
+ "var(--ds-gray-500, #667085)",
85
+ "var(--ds-gray-600, #344054)",
86
+ "var(--ds-gray-700, #1d2939)",
87
+ "var(--ds-gray-800, #101828)",
88
+ "var(--ds-gray-900, #000000)",
89
+ "var(--ds-gray-950, #000000)"
90
+ ]
91
+ },
92
+ primaryColor: "primary",
93
+ fontFamily: "var(--ds-font-family)",
94
+ fontFamilyMonospace:
95
+ "SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace",
96
+ headings: {
97
+ fontWeight: "700",
98
+ fontFamily: "var(--ds-font-family)"
99
+ },
100
+ fontSizes: {
101
+ xs: "var(--ds-font-size-xs)",
102
+ sm: "var(--ds-font-size-sm)",
103
+ md: "var(--ds-font-size-base)",
104
+ lg: "var(--ds-font-size-lg)",
105
+ xl: "var(--ds-font-size-2xl)"
106
+ },
107
+ spacing: {
108
+ xs: "var(--ds-spacing-2)",
109
+ sm: "var(--ds-spacing-4)",
110
+ md: "var(--ds-spacing-6)",
111
+ lg: "var(--ds-spacing-8)",
112
+ xl: "var(--ds-spacing-10)"
113
+ },
114
+ radius: {
115
+ xs: "var(--ds-radius-sm)",
116
+ sm: "var(--ds-radius)",
117
+ md: "var(--ds-radius-md)",
118
+ lg: "var(--ds-radius-lg)",
119
+ xl: "var(--ds-radius-xl)"
120
+ },
121
+ shadows: {
122
+ xs: "var(--ds-shadow-sm)",
123
+ sm: "var(--ds-shadow-sm)",
124
+ md: "var(--ds-shadow)",
125
+ lg: "var(--ds-shadow-lg)",
126
+ xl: "var(--ds-shadow-xl)"
127
+ },
128
+ components: {
129
+ Button: {
130
+ styles: {
131
+ root: {
132
+ borderRadius: "var(--mantine-radius-xs)",
133
+ fontWeight: "400",
134
+ fontSize: "var(--mantine-font-size-md)",
135
+ padding: "0.5rem 1rem",
136
+ transition:
137
+ "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out"
138
+ }
139
+ }
140
+ },
141
+ Input: {
142
+ styles: {
143
+ input: {
144
+ borderRadius: "var(--mantine-radius-xs)",
145
+ borderColor: "var(--mantine-color-gray-4)",
146
+ fontSize: "var(--mantine-font-size-md)",
147
+ padding: "0.5rem 1rem",
148
+ transition: "border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out"
149
+ }
150
+ }
151
+ },
152
+ Card: {
153
+ styles: {
154
+ root: {
155
+ borderRadius: "var(--mantine-radius-xs)",
156
+ borderColor: "var(--mantine-color-gray-4)",
157
+ padding: "1.5rem"
158
+ }
159
+ }
160
+ },
161
+ Paper: {
162
+ styles: {
163
+ root: {
164
+ borderRadius: "var(--mantine-radius-xs)"
165
+ }
166
+ }
167
+ },
168
+ Modal: {
169
+ styles: {
170
+ header: {
171
+ borderBottom: "1px solid var(--ds-gray-200)",
172
+ padding: "var(--ds-spacing-4)",
173
+ marginBottom: 0
174
+ },
175
+ title: {
176
+ fontWeight: 600,
177
+ fontSize: "var(--ds-font-size-lg)"
178
+ },
179
+ body: {
180
+ padding: "var(--ds-spacing-4)"
181
+ },
182
+ content: {
183
+ borderRadius: "var(--ds-radius-lg)"
184
+ },
185
+ close: {
186
+ color: "var(--ds-gray-500)"
187
+ }
188
+ }
189
+ },
190
+ Popover: {
191
+ styles: {
192
+ dropdown: {
193
+ borderRadius: "var(--mantine-radius-sm)",
194
+ boxShadow: "var(--mantine-shadow-md)",
195
+ padding: "var(--mantine-spacing-md)"
196
+ }
197
+ }
198
+ },
199
+ Badge: {
200
+ styles: {
201
+ root: {
202
+ borderRadius: "var(--mantine-radius-xs)",
203
+ fontSize: "0.875rem",
204
+ fontWeight: "700",
205
+ padding: "0.285em 0.571em"
206
+ }
207
+ }
208
+ },
209
+ TextInput: {
210
+ styles: {
211
+ label: {
212
+ fontSize: "var(--mantine-font-size-sm)",
213
+ fontWeight: "500",
214
+ marginBottom: "var(--mantine-spacing-xs)"
215
+ },
216
+ input: {
217
+ fontFamily: "var(--mantine-font-family)"
218
+ }
219
+ }
220
+ },
221
+ NumberInput: {
222
+ styles: {
223
+ label: {
224
+ fontSize: "var(--mantine-font-size-sm)",
225
+ fontWeight: "500",
226
+ marginBottom: "var(--mantine-spacing-xs)"
227
+ }
228
+ }
229
+ },
230
+ Group: {
231
+ defaultProps: {
232
+ gap: "sm"
233
+ }
234
+ },
235
+ Stack: {
236
+ defaultProps: {
237
+ gap: "md"
238
+ }
239
+ }
240
+ }
241
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Microbuild Types
3
+ *
4
+ * Re-exports all type definitions.
5
+ * This file is copied to your project and can be customized.
6
+ */
7
+
8
+ export * from './core';
9
+ export * from './file';
10
+ export * from './relations';
@@ -0,0 +1,32 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Microbuild Utils
4
+ *
5
+ * Re-exports all utility functions.
6
+ * This file is copied to your project and can be customized.
7
+ */
8
+
9
+ // Basic utilities
10
+ export { cn, formatFileSize, getFileCategory, getAssetUrl, slugify, slugify as generateSlug, debounce, isValidPrimaryKey, deepMerge, generateId } from '../common-utils';
11
+
12
+ // Field interface mapping (from @microbuild/utils)
13
+ export {
14
+ getFieldInterface,
15
+ getFieldDefault,
16
+ type InterfaceType,
17
+ type InterfaceConfig,
18
+ } from '../field-interface-mapper';
19
+
20
+ // Field utilities
21
+ export {
22
+ isFieldReadOnly,
23
+ isPresentationField,
24
+ getFieldValidation,
25
+ formatFieldValue,
26
+ } from '../field-interface-mapper';
27
+
28
+ // Interface type definitions
29
+ export type {
30
+ InterfaceDefinition,
31
+ InterfaceGroup,
32
+ } from '../interface-types';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Microbuild Utils - Barrel Export
3
+ *
4
+ * This file re-exports all utilities from the utils folder.
5
+ * It exists to support both import patterns:
6
+ * - import { cn } from '@/lib/microbuild/utils' (folder import)
7
+ * - import { cn } from '@/lib/microbuild/utils.ts' (file import)
8
+ *
9
+ * @microbuild-origin lib/utils
10
+ * @microbuild-version 1.0.0
11
+ */
12
+
13
+ // Re-export everything from the utils folder
14
+ export * from './utils/index';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * VForm - Dynamic Form Component
3
+ *
4
+ * Re-exports VForm and related components.
5
+ * This file is copied to your project and can be customized.
6
+ *
7
+ * NOTE: Import paths must match actual file names (PascalCase for VForm folder)
8
+ */
9
+
10
+ // Main VForm export - VForm.tsx uses PascalCase filename
11
+ export { VForm } from './VForm';
12
+ export type { VFormProps } from './VForm';
13
+
14
+ // Component exports - files in components/ use PascalCase
15
+ export { FormField } from './components/FormField';
16
+ export type { FormFieldProps } from './components/FormField';
17
+
18
+ export { FormFieldLabel } from './components/FormFieldLabel';
19
+
20
+ export { FormFieldInterface } from './components/FormFieldInterface';
21
+ export type { FormFieldInterfaceProps } from './components/FormFieldInterface';
22
+
23
+ export * from './types';
24
+ export * from './utils';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Next.js Middleware
3
+ *
4
+ * Root middleware file that handles auth session refresh.
5
+ * This file is copied to your project by the Microbuild CLI.
6
+ *
7
+ * @microbuild/origin: middleware
8
+ * @microbuild/version: 1.0.0
9
+ */
10
+
11
+ import { type NextRequest } from 'next/server';
12
+ import { updateSession } from '@/lib/supabase/middleware';
13
+
14
+ export async function middleware(request: NextRequest) {
15
+ return await updateSession(request);
16
+ }
17
+
18
+ export const config = {
19
+ matcher: [
20
+ /*
21
+ * Match all request paths except for the ones starting with:
22
+ * - _next/static (static files)
23
+ * - _next/image (image optimization files)
24
+ * - favicon.ico (favicon file)
25
+ * - public folder
26
+ */
27
+ '/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
28
+ ],
29
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Supabase Browser Client
3
+ *
4
+ * Client-side Supabase client for use in React components.
5
+ * This file is copied to your project by the Microbuild CLI.
6
+ *
7
+ * @microbuild/origin: supabase/client
8
+ * @microbuild/version: 1.0.0
9
+ */
10
+
11
+ import { createBrowserClient } from '@supabase/ssr';
12
+
13
+ export function createClient() {
14
+ const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
15
+ const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
16
+
17
+ if (!supabaseUrl || !supabaseAnonKey) {
18
+ throw new Error(
19
+ 'Missing Supabase environment variables. ' +
20
+ 'Please set NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY in .env.local'
21
+ );
22
+ }
23
+
24
+ return createBrowserClient(supabaseUrl, supabaseAnonKey);
25
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Supabase Auth Middleware
3
+ *
4
+ * Refreshes auth tokens and protects routes.
5
+ * This file is copied to your project by the Microbuild CLI.
6
+ *
7
+ * @microbuild/origin: supabase/middleware
8
+ * @microbuild/version: 1.0.0
9
+ */
10
+
11
+ import { createServerClient } from '@supabase/ssr';
12
+ import { NextResponse, type NextRequest } from 'next/server';
13
+
14
+ export async function updateSession(request: NextRequest) {
15
+ const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
16
+ const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
17
+
18
+ if (!supabaseUrl || !supabaseAnonKey) {
19
+ // Allow request to proceed but log warning
20
+ console.warn('Supabase not configured - auth middleware skipped');
21
+ return NextResponse.next({ request });
22
+ }
23
+
24
+ let supabaseResponse = NextResponse.next({ request });
25
+
26
+ const supabase = createServerClient(supabaseUrl, supabaseAnonKey, {
27
+ cookies: {
28
+ getAll() {
29
+ return request.cookies.getAll();
30
+ },
31
+ setAll(cookiesToSet) {
32
+ cookiesToSet.forEach(({ name, value }) =>
33
+ request.cookies.set(name, value)
34
+ );
35
+ supabaseResponse = NextResponse.next({ request });
36
+ cookiesToSet.forEach(({ name, value, options }) =>
37
+ supabaseResponse.cookies.set(name, value, options)
38
+ );
39
+ },
40
+ },
41
+ });
42
+
43
+ // IMPORTANT: Avoid writing any logic between createServerClient and
44
+ // supabase.auth.getUser(). A simple mistake could make it very hard to debug
45
+ // issues with users being randomly logged out.
46
+
47
+ const {
48
+ data: { user },
49
+ } = await supabase.auth.getUser();
50
+
51
+ // Define public routes that don't require authentication
52
+ const publicRoutes = ['/login', '/signup', '/auth', '/api/auth'];
53
+ const isPublicRoute = publicRoutes.some(route =>
54
+ request.nextUrl.pathname.startsWith(route)
55
+ );
56
+ const isApiRoute = request.nextUrl.pathname.startsWith('/api');
57
+
58
+ // Redirect unauthenticated users to login (except for public and API routes)
59
+ if (!user && !isPublicRoute && !isApiRoute) {
60
+ const url = request.nextUrl.clone();
61
+ url.pathname = '/login';
62
+ return NextResponse.redirect(url);
63
+ }
64
+
65
+ return supabaseResponse;
66
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Supabase Server Client
3
+ *
4
+ * Server-side Supabase client for use in Server Components, API routes, and Server Actions.
5
+ * This file is copied to your project by the Microbuild CLI.
6
+ *
7
+ * @microbuild/origin: supabase/server
8
+ * @microbuild/version: 1.0.0
9
+ */
10
+
11
+ import { createServerClient } from '@supabase/ssr';
12
+ import { cookies } from 'next/headers';
13
+
14
+ export async function createClient() {
15
+ const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
16
+ const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
17
+
18
+ if (!supabaseUrl || !supabaseAnonKey) {
19
+ throw new Error(
20
+ 'Missing Supabase environment variables. ' +
21
+ 'Please set NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY in .env.local'
22
+ );
23
+ }
24
+
25
+ const cookieStore = await cookies();
26
+
27
+ return createServerClient(supabaseUrl, supabaseAnonKey, {
28
+ cookies: {
29
+ getAll() {
30
+ return cookieStore.getAll();
31
+ },
32
+ setAll(cookiesToSet) {
33
+ try {
34
+ cookiesToSet.forEach(({ name, value, options }) =>
35
+ cookieStore.set(name, value, options)
36
+ );
37
+ } catch {
38
+ // The `setAll` method was called from a Server Component.
39
+ // This can be ignored if you have middleware refreshing
40
+ // user sessions.
41
+ }
42
+ },
43
+ },
44
+ });
45
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@microbuild/cli",
3
+ "version": "0.1.0",
4
+ "description": "CLI tool for adding Microbuild components to your project - like shadcn/ui",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "microbuild": "dist/index.js"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/microbuild-ui/ui.git",
17
+ "directory": "packages/cli"
18
+ },
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
24
+ "test:coverage": "vitest run --coverage",
25
+ "typecheck": "tsc --noEmit",
26
+ "clean": "rimraf dist",
27
+ "prepublishOnly": "pnpm build"
28
+ },
29
+ "dependencies": {
30
+ "chalk": "^5.3.0",
31
+ "commander": "^11.1.0",
32
+ "fast-glob": "^3.3.2",
33
+ "fs-extra": "^11.2.0",
34
+ "ora": "^8.0.1",
35
+ "prompts": "^2.4.2"
36
+ },
37
+ "devDependencies": {
38
+ "@types/fs-extra": "^11.0.4",
39
+ "@types/node": "^20.10.0",
40
+ "@types/prompts": "^2.4.9",
41
+ "tsup": "^8.0.0",
42
+ "typescript": "^5.3.0",
43
+ "vitest": "^2.1.9"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "README.md"
48
+ ],
49
+ "keywords": [
50
+ "cli",
51
+ "components",
52
+ "directus",
53
+ "cms",
54
+ "microbuild",
55
+ "shadcn",
56
+ "copy-own",
57
+ "ui"
58
+ ],
59
+ "author": "Microbuild",
60
+ "license": "MIT"
61
+ }