create-guren-app 1.6.1 → 1.7.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.
- package/package.json +1 -1
- package/templates/api-only/package.json +4 -4
- package/templates/api-only/tsconfig.json +1 -1
- package/templates/blog/app/Providers/AuthProvider.ts +2 -1
- package/templates/blog/src/app.ts +5 -1
- package/templates/blog/tests/HomeController.test.ts +14 -12
- package/templates/default/app/Http/Controllers/HomeController.ts +2 -1
- package/templates/default/lang/en/messages.json +3 -0
- package/templates/default/package.json +5 -5
- package/templates/default/src/app.ts +5 -1
- package/templates/default/tests/HomeController.test.ts +13 -15
package/package.json
CHANGED
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"test": "bun test"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@guren/cli": "^2.
|
|
22
|
-
"@guren/core": "^1.5.
|
|
23
|
-
"@guren/orm": "^2.1
|
|
21
|
+
"@guren/cli": "^2.3.0",
|
|
22
|
+
"@guren/core": "^1.5.2",
|
|
23
|
+
"@guren/orm": "^2.2.1",
|
|
24
24
|
"drizzle-orm": "1.0.0-rc.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@guren/testing": "^1.
|
|
27
|
+
"@guren/testing": "^1.4.0",
|
|
28
28
|
"bun-types": "^1.3.1",
|
|
29
29
|
"drizzle-kit": "1.0.0-rc.4",
|
|
30
30
|
"typescript": "^5.4.0"
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
"@/*": ["./*"]
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"include": ["src/**/*", "app/**/*", "routes/**/*", "config/**/*", "db/**/*", "bin/**/*"],
|
|
18
|
+
"include": [".guren/**/*", "src/**/*", "app/**/*", "routes/**/*", "config/**/*", "db/**/*", "bin/**/*"],
|
|
19
19
|
"exclude": ["node_modules"]
|
|
20
20
|
}
|
|
@@ -20,9 +20,10 @@ export default class AuthProvider extends ServiceProvider {
|
|
|
20
20
|
//
|
|
21
21
|
// shareInertiaProps merges over resolvers registered earlier instead of
|
|
22
22
|
// replacing them, so the framework's flashed `errors` still come through.
|
|
23
|
+
// Passing this.container scopes the props to this app.
|
|
23
24
|
shareInertiaProps(async (ctx) => {
|
|
24
25
|
const auth = ctx.get(AUTH_CONTEXT_KEY) as AuthContext | undefined
|
|
25
26
|
return { auth: { user: await auth?.user() } }
|
|
26
|
-
})
|
|
27
|
+
}, this.container)
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -19,7 +19,7 @@ setInertiaDocument({
|
|
|
19
19
|
// and stopping the app from booting at all. Emailed links do not depend on this
|
|
20
20
|
// — app/Auth/AppUrl.ts resolves those per request and fails closed there.
|
|
21
21
|
function hostAuthorization() {
|
|
22
|
-
const exclude = ['/
|
|
22
|
+
const exclude = ['/health']
|
|
23
23
|
|
|
24
24
|
if (process.env.NODE_ENV !== 'production') {
|
|
25
25
|
return { allowedHosts: ['localhost:*', '127.0.0.1:*'], exclude }
|
|
@@ -40,6 +40,10 @@ const app = createApp({
|
|
|
40
40
|
auth: {},
|
|
41
41
|
routes: registerWebRoutes,
|
|
42
42
|
providers: [DatabaseProvider, AuthProvider, AuthorizationProvider],
|
|
43
|
+
// Translations live in lang/<locale>/*.json. Add locales to `supported`
|
|
44
|
+
// and the request locale is detected from ?locale=, a locale cookie, or
|
|
45
|
+
// Accept-Language. `guren codegen` types the keys for t()/useTranslation().
|
|
46
|
+
i18n: { supported: ['en'] },
|
|
43
47
|
hostAuthorization: hostAuthorization(),
|
|
44
48
|
})
|
|
45
49
|
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { describe, it } from 'bun:test'
|
|
1
|
+
import { beforeAll, describe, it } from 'bun:test'
|
|
2
2
|
import { TestApp } from '@guren/testing'
|
|
3
|
-
import
|
|
4
|
-
import { registerWebRoutes } from '../routes/web.js'
|
|
3
|
+
import app from '../src/app.js'
|
|
5
4
|
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
5
|
+
// Boots the real src/app.ts so tests share its configuration. The blog
|
|
6
|
+
// home page reads posts from the database, so exercising it here would
|
|
7
|
+
// need migrations and fixtures — the golden-path flow already covers it
|
|
8
|
+
// end to end. This starter test keeps `bun test` green out of the box;
|
|
9
9
|
// replace it with real feature tests as you build.
|
|
10
10
|
describe('app', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
let http: TestApp
|
|
12
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
await app.boot()
|
|
15
|
+
http = TestApp.fromFetch((request) => app.fetch(request))
|
|
16
|
+
})
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
it('answers the health check', async () => {
|
|
19
|
+
await http.get('/health').assertOk()
|
|
18
20
|
})
|
|
19
21
|
})
|
|
@@ -4,7 +4,8 @@ import { pages } from '@/.guren/pages.gen'
|
|
|
4
4
|
export default class HomeController extends Controller {
|
|
5
5
|
async index(): Promise<Response> {
|
|
6
6
|
const props = {
|
|
7
|
-
|
|
7
|
+
// Message text lives in lang/en/messages.json (key typed by codegen).
|
|
8
|
+
message: this.t('messages.welcome', { name: '__APP_TITLE__' }),
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
return this.inertia(pages.Home, props, { url: this.request.path, title: '__APP_TITLE__' })
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"db:seed": "bunx guren db:seed"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@guren/cli": "^2.
|
|
23
|
-
"@guren/core": "^1.5.
|
|
24
|
-
"@guren/inertia-client": "^1.0
|
|
25
|
-
"@guren/orm": "^2.1
|
|
22
|
+
"@guren/cli": "^2.3.0",
|
|
23
|
+
"@guren/core": "^1.5.2",
|
|
24
|
+
"@guren/inertia-client": "^1.1.0",
|
|
25
|
+
"@guren/orm": "^2.2.1",
|
|
26
26
|
"@inertiajs/react": "^3.6.1",
|
|
27
27
|
"drizzle-orm": "1.0.0-rc.4",
|
|
28
28
|
"react": "^19.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"zod": "^4.4.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@guren/testing": "^1.
|
|
33
|
+
"@guren/testing": "^1.4.0",
|
|
34
34
|
"@tailwindcss/vite": "^4.2.2",
|
|
35
35
|
"@types/react": "^19.0.0",
|
|
36
36
|
"@types/react-dom": "^19.0.0",
|
|
@@ -18,7 +18,7 @@ setInertiaDocument({
|
|
|
18
18
|
// and stopping the app from booting at all. Emailed links do not depend on this
|
|
19
19
|
// — app/Auth/AppUrl.ts resolves those per request and fails closed there.
|
|
20
20
|
function hostAuthorization() {
|
|
21
|
-
const exclude = ['/
|
|
21
|
+
const exclude = ['/health']
|
|
22
22
|
|
|
23
23
|
if (process.env.NODE_ENV !== 'production') {
|
|
24
24
|
return { allowedHosts: ['localhost:*', '127.0.0.1:*'], exclude }
|
|
@@ -38,6 +38,10 @@ function hostAuthorization() {
|
|
|
38
38
|
const app = createApp({
|
|
39
39
|
routes: registerWebRoutes,
|
|
40
40
|
providers: [DatabaseProvider],
|
|
41
|
+
// Translations live in lang/<locale>/*.json. Add locales to `supported`
|
|
42
|
+
// and the request locale is detected from ?locale=, a locale cookie, or
|
|
43
|
+
// Accept-Language. `guren codegen` types the keys for t()/useTranslation().
|
|
44
|
+
i18n: { supported: ['en'] },
|
|
41
45
|
hostAuthorization: hostAuthorization(),
|
|
42
46
|
})
|
|
43
47
|
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { describe, it } from 'bun:test'
|
|
1
|
+
import { beforeAll, describe, it } from 'bun:test'
|
|
2
2
|
import { TestApp } from '@guren/testing'
|
|
3
|
-
import
|
|
4
|
-
import { registerWebRoutes } from '../routes/web.js'
|
|
3
|
+
import app from '../src/app.js'
|
|
5
4
|
|
|
5
|
+
// Boots the real src/app.ts so tests share its configuration.
|
|
6
6
|
describe('app', () => {
|
|
7
|
-
|
|
8
|
-
const app = await TestApp.create({
|
|
9
|
-
routes: registerWebRoutes,
|
|
10
|
-
providers: [DatabaseProvider],
|
|
11
|
-
})
|
|
7
|
+
let http: TestApp
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
await app.boot()
|
|
11
|
+
http = TestApp.fromFetch((request) => app.fetch(request))
|
|
14
12
|
})
|
|
15
13
|
|
|
16
|
-
it('
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
14
|
+
it('serves the translated home page', async () => {
|
|
15
|
+
const response = await http.get('/').assertOk()
|
|
16
|
+
await response.assertBodyContains('Welcome to')
|
|
17
|
+
})
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
it('answers the health check', async () => {
|
|
20
|
+
await http.get('/health').assertOk()
|
|
23
21
|
})
|
|
24
22
|
})
|