@donotdev/cli 0.2.2 → 0.2.3

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 (45) hide show
  1. package/dependencies-matrix.json +39 -38
  2. package/dist/bin/commands/agent-setup.js +135 -67
  3. package/dist/bin/commands/build.js +288 -232
  4. package/dist/bin/commands/bump.js +293 -250
  5. package/dist/bin/commands/cacheout.js +59 -49
  6. package/dist/bin/commands/coach.js +80 -50
  7. package/dist/bin/commands/create-app.js +501 -228
  8. package/dist/bin/commands/create-project.js +377 -241
  9. package/dist/bin/commands/db.js +1873 -1804
  10. package/dist/bin/commands/deploy.js +476 -287
  11. package/dist/bin/commands/dev.js +139 -108
  12. package/dist/bin/commands/doctor.js +91 -57
  13. package/dist/bin/commands/emu.js +196 -154
  14. package/dist/bin/commands/format.js +83 -50
  15. package/dist/bin/commands/get-demo.js +422 -197
  16. package/dist/bin/commands/make-admin.js +813 -707
  17. package/dist/bin/commands/preview.js +139 -108
  18. package/dist/bin/commands/seed.js +1874 -1809
  19. package/dist/bin/commands/setup-cicd.js +258 -204
  20. package/dist/bin/commands/setup.js +346 -247
  21. package/dist/bin/commands/staging.js +476 -287
  22. package/dist/bin/commands/sync-secrets.js +472 -141
  23. package/dist/bin/commands/type-check.js +163 -119
  24. package/dist/bin/commands/wai.js +53 -46
  25. package/dist/bin/dndev.js +10 -1
  26. package/dist/bin/donotdev.js +18 -8
  27. package/dist/index.js +590 -373
  28. package/package.json +2 -2
  29. package/templates/app-dndev/src/pages/legal/LegalNoticePage.tsx.example +1 -1
  30. package/templates/app-dndev/src/pages/legal/PrivacyPage.tsx.example +1 -1
  31. package/templates/app-dndev/src/pages/legal/TermsPage.tsx.example +1 -1
  32. package/templates/app-next/src/app/AppDocument.tsx.example +57 -0
  33. package/templates/app-next/src/app/ClientLayout.tsx.example +6 -2
  34. package/templates/app-next/src/pages/legal/LegalNoticePage.tsx.example +1 -1
  35. package/templates/app-next/src/pages/legal/PrivacyPage.tsx.example +1 -1
  36. package/templates/app-next/src/pages/legal/TermsPage.tsx.example +1 -1
  37. package/templates/app-vite/src/pages/FormPageExample.tsx.example +21 -16
  38. package/templates/app-vite/src/pages/legal/LegalNoticePage.tsx.example +1 -1
  39. package/templates/app-vite/src/pages/legal/PrivacyPage.tsx.example +1 -1
  40. package/templates/app-vite/src/pages/legal/TermsPage.tsx.example +1 -1
  41. package/templates/overlay-supabase/src/config/providers.nextjs.ts.example +37 -0
  42. package/templates/root-consumer/.claude/hooks/guard-write.sh.example +5 -1
  43. package/templates/root-consumer/.gitignore.example +7 -1
  44. package/templates/app-next/src/app/layout.tsx.example +0 -80
  45. package/templates/app-next/src/app/not-found.tsx.example +0 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Command-line interface for DoNotDev Framework",
5
5
  "type": "module",
6
6
  "private": false,
@@ -32,7 +32,7 @@
32
32
  "type-check": "bunx tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@clack/prompts": "^1.8.1",
35
+ "@clack/prompts": "^1.9.0",
36
36
  "commander": "^14.0.3",
37
37
  "fast-glob": "^3.3.3"
38
38
  },
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { Building } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { LegalNoticeTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { Shield } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { PrivacyPolicyTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { FileText } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { TermsOfServiceTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -0,0 +1,57 @@
1
+ import type { Metadata } from 'next';
2
+ import type { ReactNode } from 'react';
3
+
4
+ import { FontPreloadLinks } from '@donotdev/ui/next';
5
+
6
+ import '../globals.css';
7
+
8
+ /**
9
+ * Framework fonts are loaded via CSS @font-face rules in dndev.css (bundled).
10
+ * Font preload links are injected at build time; FontPreloadLinks reads the manifest for SSR.
11
+ */
12
+
13
+ /**
14
+ * Site-level metadata only. Page title, description, canonical, Open Graph and JSON-LD
15
+ * come from the framework's AutoMetaTags (PageMeta + i18n) and from <Seo> on pages
16
+ * that render a record. Do not set `title` or `description` here: they would ship as
17
+ * a second <title>/<meta name="description"> in every page's HTML.
18
+ */
19
+ const appUrl = process.env.NEXT_PUBLIC_APP_URL;
20
+ export const metadata: Metadata = {
21
+ ...(appUrl ? { metadataBase: new URL(appUrl) } : {}),
22
+ };
23
+
24
+ /**
25
+ * The app's HTML document: <html>, <head> links and <body>.
26
+ *
27
+ * The framework generates the root layout and renders this document with the page's
28
+ * language (`lang`): the URL's language with 2+ languages (src/app/[lang]/layout),
29
+ * the app's language with one. Every page's HTML, cached pages included, carries its
30
+ * own <html lang>. It also renders the providers (./ClientLayout) below: src/app/(site)
31
+ * renders every page without request data, so pages are static and served from the
32
+ * cache (revalidated hourly) to guests and crawlers; with a cookie session (Supabase),
33
+ * src/app/dndev-session renders the same pages per request with the visitor's cookies.
34
+ * Reading request headers or cookies here, or exporting `dynamic`, would make every
35
+ * page per request: the build refuses it.
36
+ */
37
+ export function AppDocument({
38
+ lang,
39
+ children,
40
+ }: {
41
+ lang: string;
42
+ children: ReactNode;
43
+ }) {
44
+ return (
45
+ <html
46
+ lang={lang}
47
+ className="dndev-design-tokens light"
48
+ suppressHydrationWarning
49
+ >
50
+ <head>
51
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
52
+ <FontPreloadLinks />
53
+ </head>
54
+ <body className="light">{children}</body>
55
+ </html>
56
+ );
57
+ }
@@ -18,9 +18,13 @@ import { appConfig } from '../config/app';
18
18
 
19
19
  interface ClientLayoutProps {
20
20
  children: React.ReactNode;
21
- /** Request Cookie header (language cookie, auth session), from the root layout */
21
+ /**
22
+ * Request Cookie header (auth session): `""` in the generated src/app/(site) layout
23
+ * (cached pages, no request data), the request's in src/app/dndev-session
24
+ * (per-request pages of visitors with an auth cookie)
25
+ */
22
26
  serverCookies: string;
23
- /** Request Accept-Language header, from the root layout */
27
+ /** Request Accept-Language header (`null` on cached pages) */
24
28
  acceptLanguage: string | null;
25
29
  }
26
30
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { Building } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { LegalNoticeTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { Shield } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { PrivacyPolicyTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { FileText } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { TermsOfServiceTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -6,14 +6,13 @@
6
6
  * HOW IT WORKS:
7
7
  * 1. Route: /products/:id (edit) or /products/new (create)
8
8
  * 2. EntityFormRenderer generates form from entity fields
9
- * 3. useCrud provides get/add/update operations
9
+ * 3. useCrudDoc reads the record (cache-backed, server-rendered on SSR);
10
+ * useCrud provides add/update operations
10
11
  * 4. Optimistic updates - navigation is instant, sync happens in background
11
12
  */
12
13
 
13
- import { useEffect, useState } from 'react';
14
-
15
- import { Section, Button, Alert } from '@donotdev/components';
16
- import { useCrud } from '@donotdev/crud';
14
+ import { Section, Button, Alert, Spinner } from '@donotdev/components';
15
+ import { useCrud, useCrudDoc } from '@donotdev/crud';
17
16
  import { useTranslation } from '@donotdev/core';
18
17
  import type { PageMeta } from '@donotdev/core';
19
18
  import { PageContainer, Link, EntityFormRenderer } from '@donotdev/ui';
@@ -53,20 +52,18 @@ export default function ProductPage() {
53
52
  const id = useParam('id');
54
53
  const isNew = id === 'new';
55
54
 
56
- // useCrud provides CRUD operations with optimistic updates
57
- const { get, add, update, error } = useCrud(productEntity);
58
- const [formData, setFormData] = useState<any>(null);
55
+ // useCrud provides write operations with optimistic updates
56
+ const { add, update } = useCrud(productEntity);
59
57
 
60
58
  // ==========================================================================
61
- // FETCH EXISTING DATA (edit mode only)
59
+ // EXISTING DATA (edit mode only)
60
+ // Read through the CRUD cache: fetched during the server render on SSR apps.
61
+ // Never get(id) in a useEffect: effects don't run on the server.
62
62
  // ==========================================================================
63
- useEffect(() => {
64
- if (!isNew && id) {
65
- get(id).then((data) => {
66
- if (data) setFormData(data);
67
- });
68
- }
69
- }, [id, isNew, get]);
63
+ const { data: formData, loading, error } = useCrudDoc(
64
+ productEntity,
65
+ isNew ? null : id
66
+ );
70
67
 
71
68
  // ==========================================================================
72
69
  // FORM SUBMISSION - Optimistic Update Pattern
@@ -102,6 +99,14 @@ export default function ProductPage() {
102
99
  );
103
100
  }
104
101
 
102
+ if (loading) {
103
+ return (
104
+ <PageContainer>
105
+ <Spinner overlay />
106
+ </PageContainer>
107
+ );
108
+ }
109
+
105
110
  // ==========================================================================
106
111
  // RENDER FORM
107
112
  // ==========================================================================
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { Building } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { LegalNoticeTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { Shield } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { PrivacyPolicyTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { FileText } from 'lucide-react';
11
11
 
12
- import { type PageMeta } from '@donotdev/core';
12
+ import type { PageMeta } from '@donotdev/core';
13
13
  import { TermsOfServiceTemplate } from '@donotdev/templates';
14
14
  import { PageContainer } from '@donotdev/ui';
15
15
 
@@ -0,0 +1,37 @@
1
+ // src/config/providers.ts — Supabase provider bootstrap (client)
2
+ // Auto-generated by DoNotDev scaffolding. Edit freely.
3
+ // Imported by the app layout (ClientLayout). Server routes generated by the framework
4
+ // (sitemap, llms.txt) set up their own read-only reader: never import this file there.
5
+
6
+ import { configureProviders } from '@donotdev/core';
7
+ import {
8
+ createBrowserClient,
9
+ SupabaseAuth,
10
+ SupabaseCallableProvider,
11
+ SupabaseCrudAdapter,
12
+ SupabaseStorageAdapter,
13
+ } from '@donotdev/supabase';
14
+
15
+ // Next.js inlines NEXT_PUBLIC_* only when referenced literally.
16
+ const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
17
+ const publicKey = process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_KEY; // sb_publishable_...
18
+
19
+ if (!url || !publicKey) {
20
+ console.warn(
21
+ '[dndev] Supabase not configured. Set NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_PUBLIC_KEY in .env'
22
+ );
23
+ } else {
24
+ // Session in cookies: the server renders the signed-in state on the first render.
25
+ const supabase = createBrowserClient(url, publicKey);
26
+
27
+ /**
28
+ * Register Supabase as the backend provider.
29
+ * Must run before any CRUD/auth/storage operations.
30
+ */
31
+ configureProviders({
32
+ crud: new SupabaseCrudAdapter(supabase),
33
+ auth: new SupabaseAuth(supabase),
34
+ storage: new SupabaseStorageAdapter(supabase, 'uploads'),
35
+ callable: new SupabaseCallableProvider(supabase),
36
+ });
37
+ }
@@ -46,8 +46,12 @@ RESULT=$(echo "$INPUT" | bun -e "
46
46
  // --- LOOKUP GATE (fail closed) ---
47
47
  // Every symbol imported from @donotdev/* must have been passed to
48
48
  // lookup_symbol first (ledger written by record-lookup.sh).
49
+ // Project files only: a file outside this project (e.g. the framework source
50
+ // itself) defines @donotdev symbols rather than consuming them.
51
+ const projectDir = (process.env.CLAUDE_PROJECT_DIR ?? '').replace(/\/+$/, '');
52
+ const inProject = projectDir !== '' && fp.startsWith(projectDir + '/');
49
53
  try {
50
- if (/\.(ts|tsx)$/.test(fp) && !/\.d\.ts$/.test(fp) && !/\/node_modules\//.test(fp)) {
54
+ if (inProject && /\.(ts|tsx)$/.test(fp) && !/\.d\.ts$/.test(fp) && !/\/node_modules\//.test(fp)) {
51
55
  let result = content;
52
56
  if (tn === 'Edit') {
53
57
  const f = Bun.file(fp);
@@ -90,4 +90,10 @@ temp/
90
90
 
91
91
  # Testing
92
92
  /cypress/videos/
93
- /cypress/screenshots/
93
+ /cypress/screenshots/
94
+
95
+ # Deploy / CLI local state (build output, linked project, local branch pointer)
96
+ .vercel/
97
+ **/supabase/functions/.build/
98
+ **/supabase/.branches/
99
+ **/supabase/.temp/
@@ -1,80 +0,0 @@
1
- import type { Metadata } from 'next';
2
- import { headers } from 'next/headers';
3
-
4
- import { getMetadataForPath } from '@donotdev/core/next';
5
- import { FontPreloadLinks } from '@donotdev/ui/next';
6
-
7
- import '../globals.css';
8
- import { ClientLayout } from './ClientLayout';
9
-
10
- /**
11
- * Framework fonts are loaded via CSS @font-face rules in dndev.css (bundled).
12
- * Font preload links are injected at build time; FontPreloadLinks reads the manifest for SSR.
13
- */
14
-
15
- /**
16
- * Dynamic metadata generation from PageMeta exports.
17
- * Same PageMeta convention works in Vite (AutoMetaTags) and Next.js (this function).
18
- * Priority: i18n meta.fullTitle > seo.fullTitle > i18n title | siteName > siteName
19
- *
20
- * For dynamic pages with runtime data, use <Seo> component instead.
21
- */
22
- export async function generateMetadata(): Promise<Metadata> {
23
- // Root layout handles the home page metadata
24
- // Other pages override via their own generateMetadata or <Seo> component
25
- return getMetadataForPath('/');
26
- }
27
-
28
- // SSR (appConfig.ssr): render dynamically at request time. The provider tree is
29
- // store-driven (theme/layout/i18n/overlay read live during render), so it is
30
- // inherently dynamic under React 19. Setting it on the root layout covers every
31
- // route in one place — generated pages, hand-written pages, and /_not-found.
32
- // Content is still fully server-rendered and crawlable. Remove only if this app
33
- // opts back out of SSR and returns to static export.
34
- export const dynamic = 'force-dynamic';
35
-
36
- /**
37
- * Root layout for Next.js App Router
38
- *
39
- * Theme detection happens client-side via ClientLayout to avoid
40
- * Next.js 16 + Turbopack race condition with async layouts.
41
- * Brief FOUC possible on first load, but prevents build-manifest.json errors.
42
- */
43
- /**
44
- * Passes the request's Cookie and Accept-Language headers to the providers: the server
45
- * render and the hydration pass then show the visitor's language and signed-in state
46
- * on the first paint. Async child, so the root layout itself stays synchronous.
47
- */
48
- async function RequestLayout({ children }: { children: React.ReactNode }) {
49
- const requestHeaders = await headers();
50
- return (
51
- <ClientLayout
52
- serverCookies={requestHeaders.get('cookie') ?? ''}
53
- acceptLanguage={requestHeaders.get('accept-language')}
54
- >
55
- {children}
56
- </ClientLayout>
57
- );
58
- }
59
-
60
- export default function RootLayout({
61
- children,
62
- }: {
63
- children: React.ReactNode;
64
- }) {
65
- return (
66
- <html
67
- lang="en"
68
- className="dndev-design-tokens light"
69
- suppressHydrationWarning
70
- >
71
- <head>
72
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
73
- <FontPreloadLinks />
74
- </head>
75
- <body className="light">
76
- <RequestLayout>{children}</RequestLayout>
77
- </body>
78
- </html>
79
- );
80
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * @fileoverview Not found page for Next.js App Router
3
- * @description 404 error page using framework's NotFoundPage component
4
- * Next.js automatically uses this file for unmatched routes
5
- * @version 0.0.1
6
- * @since 0.0.1
7
- * @author AMBROISE PARK Consulting
8
- */
9
-
10
- import { Suspense } from 'react';
11
-
12
- import { NotFoundPage } from '@donotdev/ui';
13
-
14
- // Under appConfig.ssr, /_not-found renders dynamically (real SSR at request time).
15
- // It's a special route (not a generated page.tsx wrapper), so it carries its own
16
- // flag; generated content routes get this automatically from the framework.
17
- // Harmless when SSR is off. Remove if you switch this app back to static export.
18
- export const dynamic = 'force-dynamic';
19
-
20
- /**
21
- * Next.js App Router automatically uses not-found.tsx for 404 errors
22
- * This file exports the framework's NotFoundPage component which provides:
23
- * - Professional full-viewport centered design
24
- * - i18n translation support
25
- * - Dynamic route suggestions
26
- * - Accessible navigation buttons
27
- *
28
- * NotFoundPage uses the routing hooks (useLocation/useNavigate), whose Next
29
- * adapter calls useSearchParams(). In the App Router that forces a client-side
30
- * bailout that throws during static prerender of /_not-found unless wrapped in
31
- * a Suspense boundary.
32
- */
33
- export default function NotFound() {
34
- return (
35
- <Suspense fallback={null}>
36
- <NotFoundPage />
37
- </Suspense>
38
- );
39
- }
40
-