@cogito.ai/cli 0.3.1 → 0.3.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.
- package/README.md +181 -0
- package/dist/templates/web-nextjs/.env.example +4 -0
- package/dist/templates/web-nextjs/.vscode/settings.json +3 -0
- package/dist/templates/web-nextjs/README.md +25 -1
- package/dist/templates/web-nextjs/apps/docs/.source/browser.ts +1 -1
- package/dist/templates/web-nextjs/apps/docs/.source/server.ts +4 -3
- package/dist/templates/web-nextjs/apps/docs/content/docs/features/auth.mdx +139 -0
- package/dist/templates/web-nextjs/apps/web/components.json +25 -0
- package/dist/templates/web-nextjs/apps/web/messages/en.json +27 -3
- package/dist/templates/web-nextjs/apps/web/messages/zh.json +29 -5
- package/dist/templates/web-nextjs/apps/web/middleware.ts +54 -9
- package/dist/templates/web-nextjs/apps/web/package.json +13 -1
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(auth)/login/page.tsx +142 -0
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(auth)/signup/page.tsx +151 -0
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(protected)/dashboard/page.tsx +42 -0
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(protected)/layout.tsx +22 -0
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/globals.css +129 -3
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/layout.tsx +12 -7
- package/dist/templates/web-nextjs/apps/web/src/app/auth/callback/route.ts +21 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/alert.tsx +76 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/button.tsx +58 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/form.tsx +154 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/input.tsx +20 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/label.tsx +20 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/sonner.tsx +50 -0
- package/dist/templates/web-nextjs/apps/web/src/core/repositories/IAuthRepository.ts +9 -0
- package/dist/templates/web-nextjs/apps/web/src/core/types/auth.ts +14 -0
- package/dist/templates/web-nextjs/apps/web/src/features/auth/__contract__.ts +14 -0
- package/dist/templates/web-nextjs/apps/web/src/features/auth/actions.ts +86 -0
- package/dist/templates/web-nextjs/apps/web/src/features/auth/index.ts +1 -0
- package/dist/templates/web-nextjs/apps/web/src/i18n/config.ts +12 -0
- package/dist/templates/web-nextjs/apps/web/src/i18n/request.ts +3 -1
- package/dist/templates/web-nextjs/apps/web/src/infra/db/SupabaseAuthRepository.ts +63 -0
- package/dist/templates/web-nextjs/apps/web/src/infra/db/client.ts +39 -1
- package/dist/templates/web-nextjs/apps/web/src/infra/db/schema.ts +5 -5
- package/dist/templates/web-nextjs/apps/web/src/infra/providers.ts +6 -0
- package/dist/templates/web-nextjs/apps/web/src/lib/utils.ts +6 -0
- package/dist/templates/web-nextjs/apps/web/src/lib/validations/auth.ts +20 -0
- package/dist/templates/web-nextjs/apps/web/src/styles/shadcn-tailwind.css +95 -0
- package/dist/templates/web-nextjs/apps/web/src/styles/tw-animate.css +1 -0
- package/dist/templates/web-nextjs/pnpm-lock.yaml +2327 -17
- package/package.json +1 -1
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/hello/page.tsx +0 -45
- package/dist/templates/web-nextjs/apps/web/src/core/repositories/IGreetingRepository.ts +0 -14
- package/dist/templates/web-nextjs/apps/web/src/core/types/greeting.ts +0 -9
- package/dist/templates/web-nextjs/apps/web/src/features/hello/__contract__.ts +0 -16
- package/dist/templates/web-nextjs/apps/web/src/features/hello/hello.test.ts +0 -16
- package/dist/templates/web-nextjs/apps/web/src/features/hello/index.ts +0 -5
- package/dist/templates/web-nextjs/apps/web/src/features/hello/service.ts +0 -12
- package/dist/templates/web-nextjs/apps/web/src/infra/db/SupabaseGreetingRepository.ts +0 -58
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getTranslations } from 'next-intl/server'
|
|
2
|
-
import { greet } from '@/features/hello'
|
|
3
|
-
import type { Greeting } from '@/core/types/greeting'
|
|
4
|
-
|
|
5
|
-
async function loadRecentGreetings(): Promise<Greeting[]> {
|
|
6
|
-
// Gracefully skip DB access when Supabase is not configured.
|
|
7
|
-
if (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY) {
|
|
8
|
-
return []
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
const { SupabaseGreetingRepository } = await import('@/infra/db/SupabaseGreetingRepository')
|
|
13
|
-
const repo = new SupabaseGreetingRepository()
|
|
14
|
-
return await repo.findRecent()
|
|
15
|
-
} catch {
|
|
16
|
-
return []
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default async function HelloPage() {
|
|
21
|
-
const t = await getTranslations('hello')
|
|
22
|
-
const greeting = greet('World')
|
|
23
|
-
const recentGreetings = await loadRecentGreetings()
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<main className="flex min-h-screen flex-col items-center justify-center p-24">
|
|
27
|
-
<h1 className="text-4xl font-bold">{t('title')}</h1>
|
|
28
|
-
<p className="mt-4 text-xl text-gray-700">{greeting}</p>
|
|
29
|
-
<p className="mt-2 text-gray-500">{t('greeting', { name: 'World' })}</p>
|
|
30
|
-
|
|
31
|
-
{recentGreetings.length > 0 && (
|
|
32
|
-
<section className="mt-8">
|
|
33
|
-
<h2 className="text-lg font-semibold">Recent greetings</h2>
|
|
34
|
-
<ul className="mt-2 space-y-1">
|
|
35
|
-
{recentGreetings.map((g) => (
|
|
36
|
-
<li key={g.id} className="text-sm text-gray-600">
|
|
37
|
-
{g.name} — {g.createdAt}
|
|
38
|
-
</li>
|
|
39
|
-
))}
|
|
40
|
-
</ul>
|
|
41
|
-
</section>
|
|
42
|
-
)}
|
|
43
|
-
</main>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Greeting } from '../types/greeting'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Repository interface for Greeting persistence.
|
|
5
|
-
* Uses domain types only — no Supabase types leak through.
|
|
6
|
-
* Implement this in src/infra/db/ to swap storage backends.
|
|
7
|
-
*/
|
|
8
|
-
export interface IGreetingRepository {
|
|
9
|
-
/** Persist a new greeting and return the saved record. */
|
|
10
|
-
save(name: string): Promise<Greeting>
|
|
11
|
-
|
|
12
|
-
/** Return the most recent greeting records. */
|
|
13
|
-
findRecent(): Promise<Greeting[]>
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contract for the `hello` feature.
|
|
3
|
-
*
|
|
4
|
-
* Defines the public API boundary: input/output types and the exported function signature.
|
|
5
|
-
* Only symbols declared here may be exported from `index.ts`.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** Input accepted by the hello feature. */
|
|
9
|
-
export interface HelloInput {
|
|
10
|
-
name: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Output returned by the hello feature. */
|
|
14
|
-
export interface HelloOutput {
|
|
15
|
-
greeting: string
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { greet } from './index'
|
|
3
|
-
|
|
4
|
-
describe('hello feature — greet()', () => {
|
|
5
|
-
it('returns a greeting with the provided name', () => {
|
|
6
|
-
expect(greet('Alice')).toBe('Hello, Alice!')
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
it("returns a greeting with 'World' when name is an empty string", () => {
|
|
10
|
-
expect(greet('')).toBe('Hello, World!')
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it("returns a greeting with 'World' when name is only whitespace", () => {
|
|
14
|
-
expect(greet(' ')).toBe('Hello, World!')
|
|
15
|
-
})
|
|
16
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hello feature — pure business logic, no side effects.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns a greeting string for the given name.
|
|
7
|
-
* Falls back to "World" when name is empty.
|
|
8
|
-
*/
|
|
9
|
-
export function greet(name: string): string {
|
|
10
|
-
const target = name.trim() || 'World'
|
|
11
|
-
return `Hello, ${target}!`
|
|
12
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { IGreetingRepository } from '@/core/repositories/IGreetingRepository'
|
|
2
|
-
import type { Greeting } from '@/core/types/greeting'
|
|
3
|
-
import { getServerClient } from './client'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Supabase implementation of IGreetingRepository.
|
|
7
|
-
* Operates on the `greetings` table.
|
|
8
|
-
*
|
|
9
|
-
* Table schema (create in Supabase SQL editor):
|
|
10
|
-
* ```sql
|
|
11
|
-
* create table greetings (
|
|
12
|
-
* id uuid primary key default gen_random_uuid(),
|
|
13
|
-
* name text not null,
|
|
14
|
-
* created_at timestamptz not null default now()
|
|
15
|
-
* );
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class SupabaseGreetingRepository implements IGreetingRepository {
|
|
19
|
-
async save(name: string): Promise<Greeting> {
|
|
20
|
-
const supabase = await getServerClient()
|
|
21
|
-
|
|
22
|
-
const { data, error } = await supabase
|
|
23
|
-
.from('greetings')
|
|
24
|
-
.insert({ name })
|
|
25
|
-
.select('id, name, created_at')
|
|
26
|
-
.single()
|
|
27
|
-
|
|
28
|
-
if (error !== null || data === null) {
|
|
29
|
-
throw new Error(`Failed to save greeting: ${error?.message ?? 'unknown'}`)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
id: data.id as string,
|
|
34
|
-
name: data.name as string,
|
|
35
|
-
createdAt: (data.created_at as string) ?? new Date().toISOString(),
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async findRecent(): Promise<Greeting[]> {
|
|
40
|
-
const supabase = await getServerClient()
|
|
41
|
-
|
|
42
|
-
const { data, error } = await supabase
|
|
43
|
-
.from('greetings')
|
|
44
|
-
.select('id, name, created_at')
|
|
45
|
-
.order('created_at', { ascending: false })
|
|
46
|
-
.limit(10)
|
|
47
|
-
|
|
48
|
-
if (error !== null) {
|
|
49
|
-
throw new Error(`Failed to fetch greetings: ${error.message}`)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (data ?? []).map((row) => ({
|
|
53
|
-
id: row.id as string,
|
|
54
|
-
name: row.name as string,
|
|
55
|
-
createdAt: (row.created_at as string) ?? '',
|
|
56
|
-
}))
|
|
57
|
-
}
|
|
58
|
-
}
|