create-mantiq 0.6.1 → 0.7.1
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/package.json +1 -1
- package/src/index.ts +3 -2
- package/src/templates.ts +20 -19
- package/stubs/react/src/App.tsx.stub +1 -1
- package/stubs/react/src/lib/api.ts.stub +2 -2
- package/stubs/react/vite.config.ts.stub +5 -2
- package/stubs/shared/database/factories/UserFactory.ts.stub +4 -6
- package/stubs/shared/tests/feature/users.test.ts.stub +1 -1
- package/stubs/svelte/src/lib/api.ts.stub +2 -2
- package/stubs/vue/src/lib/api.ts.stub +2 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -86,7 +86,7 @@ if (!projectName) {
|
|
|
86
86
|
--theme=${emerald('default|minimal|workspace|corporate|starter')}
|
|
87
87
|
Dashboard theme (shadcn only)
|
|
88
88
|
--auth=${emerald('builtin|none')} Authentication setup
|
|
89
|
-
--with=${emerald('ai')}
|
|
89
|
+
--with=${emerald('ai,studio')} Optional packages (comma-separated)
|
|
90
90
|
--no-git Skip git initialization
|
|
91
91
|
--yes Accept defaults (non-interactive)
|
|
92
92
|
|
|
@@ -95,7 +95,7 @@ if (!projectName) {
|
|
|
95
95
|
bun create mantiq my-app --kit=react
|
|
96
96
|
bun create mantiq my-app --kit=react --ui=shadcn
|
|
97
97
|
bun create mantiq my-app --kit=react --auth=none
|
|
98
|
-
bun create mantiq my-app --kit=react --with=ai
|
|
98
|
+
bun create mantiq my-app --kit=react --with=ai,studio
|
|
99
99
|
`)
|
|
100
100
|
process.exit(1)
|
|
101
101
|
}
|
|
@@ -169,6 +169,7 @@ if (!isCI && !kit) {
|
|
|
169
169
|
if (!flags['with']) {
|
|
170
170
|
optionalPackages = await term.multiSelect('Optional packages', [
|
|
171
171
|
{ value: 'ai', label: 'AI', hint: '@mantiq/ai' },
|
|
172
|
+
{ value: 'studio', label: 'Studio', hint: '@mantiq/studio — admin panel' },
|
|
172
173
|
])
|
|
173
174
|
}
|
|
174
175
|
|
package/src/templates.ts
CHANGED
|
@@ -26,27 +26,28 @@ export function getTemplates(ctx: TemplateContext): Record<string, string> {
|
|
|
26
26
|
|
|
27
27
|
// ── package.json (always dynamic — name + deps) ────────────────────────
|
|
28
28
|
const baseDeps: Record<string, string> = {
|
|
29
|
-
...(ctx.auth !== 'none' ? { '@mantiq/auth': '^0.
|
|
30
|
-
'@mantiq/cli': '^0.
|
|
31
|
-
'@mantiq/core': '^0.
|
|
32
|
-
'@mantiq/database': '^0.
|
|
33
|
-
'@mantiq/events': '^0.
|
|
34
|
-
'@mantiq/filesystem': '^0.
|
|
35
|
-
'@mantiq/heartbeat': '^0.
|
|
36
|
-
'@mantiq/helpers': '^0.
|
|
37
|
-
'@mantiq/logging': '^0.
|
|
38
|
-
'@mantiq/queue': '^0.
|
|
39
|
-
'@mantiq/realtime': '^0.
|
|
40
|
-
'@mantiq/validation': '^0.
|
|
41
|
-
'@mantiq/mail': '^0.
|
|
42
|
-
'@mantiq/notify': '^0.
|
|
43
|
-
'@mantiq/search': '^0.
|
|
44
|
-
'@mantiq/health': '^0.
|
|
45
|
-
...(ctx.optionalPackages.includes('ai') ? { '@mantiq/ai': '^0.
|
|
29
|
+
...(ctx.auth !== 'none' ? { '@mantiq/auth': '^0.7.0' } : {}),
|
|
30
|
+
'@mantiq/cli': '^0.7.0',
|
|
31
|
+
'@mantiq/core': '^0.7.0',
|
|
32
|
+
'@mantiq/database': '^0.7.0',
|
|
33
|
+
'@mantiq/events': '^0.7.0',
|
|
34
|
+
'@mantiq/filesystem': '^0.7.0',
|
|
35
|
+
'@mantiq/heartbeat': '^0.7.0',
|
|
36
|
+
'@mantiq/helpers': '^0.7.0',
|
|
37
|
+
'@mantiq/logging': '^0.7.0',
|
|
38
|
+
'@mantiq/queue': '^0.7.0',
|
|
39
|
+
'@mantiq/realtime': '^0.7.0',
|
|
40
|
+
'@mantiq/validation': '^0.7.0',
|
|
41
|
+
'@mantiq/mail': '^0.7.0',
|
|
42
|
+
'@mantiq/notify': '^0.7.0',
|
|
43
|
+
'@mantiq/search': '^0.7.0',
|
|
44
|
+
'@mantiq/health': '^0.7.0',
|
|
45
|
+
...(ctx.optionalPackages.includes('ai') ? { '@mantiq/ai': '^0.7.0' } : {}),
|
|
46
|
+
...(ctx.optionalPackages.includes('studio') ? { '@mantiq/studio': '^0.7.0' } : {}),
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const baseDevDeps: Record<string, string> = {
|
|
49
|
-
'@mantiq/testing': '^0.
|
|
50
|
+
'@mantiq/testing': '^0.7.0',
|
|
50
51
|
'bun-types': 'latest',
|
|
51
52
|
'typescript': '^5.7.0',
|
|
52
53
|
}
|
|
@@ -85,7 +86,7 @@ export function getTemplates(ctx: TemplateContext): Record<string, string> {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
Object.assign(baseDeps, {
|
|
88
|
-
'@mantiq/vite': '^0.
|
|
89
|
+
'@mantiq/vite': '^0.7.0',
|
|
89
90
|
...uiDeps,
|
|
90
91
|
})
|
|
91
92
|
|
|
@@ -18,7 +18,7 @@ initTheme()
|
|
|
18
18
|
|
|
19
19
|
export function MantiqApp({ pages, initialData }: MantiqAppProps) {
|
|
20
20
|
const windowData = typeof window !== 'undefined' ? window.__MANTIQ_DATA__ : {}
|
|
21
|
-
const initial = initialData ?? windowData
|
|
21
|
+
const initial = initialData ?? windowData ?? {}
|
|
22
22
|
const [page, setPage] = useState<string>(initial._page ?? 'Login')
|
|
23
23
|
const [data, setData] = useState<Record<string, any>>(initial)
|
|
24
24
|
|
|
@@ -3,7 +3,7 @@ function getCookie(name: string): string | null {
|
|
|
3
3
|
return match ? decodeURIComponent(match[1]!) : null
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
type ApiResult<T> = { ok: true; status: number; data: T } | { ok: false; status: number; data:
|
|
6
|
+
type ApiResult<T> = { ok: true; status: number; data: T } | { ok: false; status: number; data: any }
|
|
7
7
|
|
|
8
8
|
export async function api<T = any>(url: string, opts: RequestInit = {}): Promise<ApiResult<T>> {
|
|
9
9
|
const headers: Record<string, string> = { Accept: 'application/json', ...(opts.headers as Record<string, string>) }
|
|
@@ -24,7 +24,7 @@ export async function api<T = any>(url: string, opts: RequestInit = {}): Promise
|
|
|
24
24
|
|
|
25
25
|
const ct = res.headers.get('content-type') ?? ''
|
|
26
26
|
const data = ct.includes('json') ? await res.json() : null
|
|
27
|
-
if (!res.ok) return { ok: false, status: res.status, data
|
|
27
|
+
if (!res.ok) return { ok: false, status: res.status, data }
|
|
28
28
|
return { ok: true, status: res.status, data }
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
2
|
import react from '@vitejs/plugin-react'
|
|
3
3
|
import tailwindcss from '@tailwindcss/vite'
|
|
4
|
+
import { mantiq } from '@mantiq/vite'
|
|
4
5
|
import path from 'path'
|
|
5
6
|
import { writeFileSync, unlinkSync } from 'node:fs'
|
|
6
7
|
|
|
7
|
-
export default defineConfig({
|
|
8
|
+
export default defineConfig(async () => ({
|
|
8
9
|
plugins: [
|
|
9
10
|
react(),
|
|
10
11
|
tailwindcss(),
|
|
12
|
+
// Auto-discovers @mantiq/* plugins (Studio admin panel, etc.)
|
|
13
|
+
...await mantiq(),
|
|
11
14
|
// Write public/hot so the backend knows the dev server is running
|
|
12
15
|
{
|
|
13
16
|
name: 'mantiq-hot',
|
|
@@ -39,4 +42,4 @@ export default defineConfig({
|
|
|
39
42
|
input: ['src/main.tsx', 'src/style.css'],
|
|
40
43
|
},
|
|
41
44
|
},
|
|
42
|
-
})
|
|
45
|
+
}))
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Factory, Faker } from '@mantiq/database'
|
|
2
|
-
import { HashManager } from '@mantiq/core'
|
|
3
2
|
import { User } from '../../app/Models/User.ts'
|
|
4
3
|
|
|
5
4
|
export class UserFactory extends Factory<User> {
|
|
6
5
|
protected model = User
|
|
7
6
|
|
|
8
|
-
override
|
|
9
|
-
const hasher = new HashManager({ bcrypt: { rounds: 10 } })
|
|
7
|
+
override definition(index: number, fake: Faker): Record<string, any> {
|
|
10
8
|
return {
|
|
11
|
-
name:
|
|
12
|
-
email:
|
|
13
|
-
password:
|
|
9
|
+
name: fake.name(),
|
|
10
|
+
email: fake.email(),
|
|
11
|
+
password: 'password',
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
14
|
}
|
|
@@ -3,7 +3,7 @@ function getCookie(name: string): string | null {
|
|
|
3
3
|
return match ? decodeURIComponent(match[1]!) : null
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
type ApiResult<T> = { ok: true; status: number; data: T } | { ok: false; status: number; data:
|
|
6
|
+
type ApiResult<T> = { ok: true; status: number; data: T } | { ok: false; status: number; data: any }
|
|
7
7
|
|
|
8
8
|
export async function api<T = any>(url: string, opts: RequestInit = {}): Promise<ApiResult<T>> {
|
|
9
9
|
const headers: Record<string, string> = { Accept: 'application/json', ...(opts.headers as Record<string, string>) }
|
|
@@ -24,7 +24,7 @@ export async function api<T = any>(url: string, opts: RequestInit = {}): Promise
|
|
|
24
24
|
|
|
25
25
|
const ct = res.headers.get('content-type') ?? ''
|
|
26
26
|
const data = ct.includes('json') ? await res.json() : null
|
|
27
|
-
if (!res.ok) return { ok: false, status: res.status, data
|
|
27
|
+
if (!res.ok) return { ok: false, status: res.status, data }
|
|
28
28
|
return { ok: true, status: res.status, data }
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -3,7 +3,7 @@ function getCookie(name: string): string | null {
|
|
|
3
3
|
return match ? decodeURIComponent(match[1]!) : null
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
type ApiResult<T> = { ok: true; status: number; data: T } | { ok: false; status: number; data:
|
|
6
|
+
type ApiResult<T> = { ok: true; status: number; data: T } | { ok: false; status: number; data: any }
|
|
7
7
|
|
|
8
8
|
export async function api<T = any>(url: string, opts: RequestInit = {}): Promise<ApiResult<T>> {
|
|
9
9
|
const headers: Record<string, string> = { Accept: 'application/json', ...(opts.headers as Record<string, string>) }
|
|
@@ -24,7 +24,7 @@ export async function api<T = any>(url: string, opts: RequestInit = {}): Promise
|
|
|
24
24
|
|
|
25
25
|
const ct = res.headers.get('content-type') ?? ''
|
|
26
26
|
const data = ct.includes('json') ? await res.json() : null
|
|
27
|
-
if (!res.ok) return { ok: false, status: res.status, data
|
|
27
|
+
if (!res.ok) return { ok: false, status: res.status, data }
|
|
28
28
|
return { ok: true, status: res.status, data }
|
|
29
29
|
}
|
|
30
30
|
|