create-guren-app 1.6.2 → 1.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/dist/cli.js CHANGED
@@ -1562,7 +1562,7 @@ async function runMain(cmd, opts = {}) {
1562
1562
 
1563
1563
  // src/blueprints.ts
1564
1564
  import { randomBytes } from "crypto";
1565
- import { cp, readFile, rename, rm, writeFile } from "fs/promises";
1565
+ import { cp, readdir as readdir2, readFile, rename, rm, writeFile } from "fs/promises";
1566
1566
  import { basename, dirname, join, relative } from "path";
1567
1567
  import process2 from "process";
1568
1568
  import { fileURLToPath } from "url";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-guren-app",
3
- "version": "1.6.2",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -7,18 +7,31 @@ try {
7
7
  process.exit(1)
8
8
  }
9
9
 
10
- const requestedPort = Number.parseInt(process.env.PORT ?? '', 10) || 3333
10
+ // `PORT=0` means "any free port", so this tests for a number, not truthiness.
11
+ const parsedPort = Number.parseInt(process.env.PORT ?? '', 10)
12
+ const requestedPort = Number.isInteger(parsedPort) ? parsedPort : 3333
11
13
  const hostname = process.env.HOST ?? '0.0.0.0'
14
+
15
+ // In development a busy port moves to the next one. Set GUREN_STRICT_PORT=1 to
16
+ // bind the requested port or fail — see the deployment guide.
12
17
  const isDevelopment = process.env.NODE_ENV !== 'production'
18
+ const canWalkPorts =
19
+ isDevelopment && requestedPort !== 0 && process.env.GUREN_STRICT_PORT !== '1'
20
+ const attempts = canWalkPorts ? 20 : 1
21
+
22
+ // This file owns the retry, so the framework must not retry underneath it —
23
+ // newer framework versions walk inside listen() themselves, and the two loops
24
+ // would nest into a much wider search reported against the wrong ports.
25
+ process.env.GUREN_STRICT_PORT = '1'
13
26
 
14
- for (let offset = 0; offset < 20; offset += 1) {
27
+ for (let offset = 0; offset < attempts; offset += 1) {
15
28
  const port = requestedPort + offset
16
29
 
17
30
  try {
18
31
  await app.listen({ port, hostname })
19
32
  break
20
33
  } catch (error) {
21
- if (!isDevelopment || !isAddressInUse(error) || offset === 19) {
34
+ if (!isAddressInUse(error) || offset === attempts - 1) {
22
35
  throw error
23
36
  }
24
37
 
@@ -18,13 +18,13 @@
18
18
  "test": "bun test"
19
19
  },
20
20
  "dependencies": {
21
- "@guren/cli": "^2.2.0",
22
- "@guren/core": "^1.5.1",
23
- "@guren/orm": "^2.2.0",
21
+ "@guren/cli": "^2.3.1",
22
+ "@guren/core": "^1.5.2",
23
+ "@guren/orm": "^2.2.2",
24
24
  "drizzle-orm": "1.0.0-rc.4"
25
25
  },
26
26
  "devDependencies": {
27
- "@guren/testing": "^1.3.0",
27
+ "@guren/testing": "^1.4.1",
28
28
  "bun-types": "^1.3.1",
29
29
  "drizzle-kit": "1.0.0-rc.4",
30
30
  "typescript": "^5.4.0"
@@ -5,7 +5,7 @@ import { pages } from '@/.guren/pages.gen'
5
5
  export default class LoginController extends Controller {
6
6
  async show(): Promise<Response> {
7
7
  const email = this.request.query('email') ?? ''
8
- return this.inertia(pages.auth.Login, { email }, { url: this.request.path, title: 'Login' })
8
+ return this.inertia(pages.auth.Login, { email }, { title: 'Login' })
9
9
  }
10
10
 
11
11
  async store(): Promise<Response> {
@@ -5,7 +5,7 @@ import { pages } from '@/.guren/pages.gen'
5
5
 
6
6
  export default class RegisterController extends Controller {
7
7
  async show(): Promise<Response> {
8
- return this.inertia(pages.auth.Register, {}, { url: this.request.path, title: 'Register' })
8
+ return this.inertia(pages.auth.Register, {}, { title: 'Register' })
9
9
  }
10
10
 
11
11
  async store(): Promise<Response> {
@@ -12,6 +12,6 @@ export default class DashboardController extends Controller {
12
12
  email: currentUser.email,
13
13
  }
14
14
  : null
15
- return this.inertia(pages.dashboard.Index, { user }, { url: this.request.path, title: 'Dashboard' })
15
+ return this.inertia(pages.dashboard.Index, { user }, { title: 'Dashboard' })
16
16
  }
17
17
  }
@@ -16,7 +16,7 @@ export default class HomeController extends Controller {
16
16
  return this.inertia(
17
17
  pages.Home,
18
18
  { latest: latest.map((post) => new PostResource(post).toJSON()) },
19
- { url: this.request.path, title: '__APP_TITLE__' },
19
+ { title: '__APP_TITLE__' },
20
20
  )
21
21
  }
22
22
  }
@@ -15,7 +15,7 @@ export default class ProfileController extends Controller {
15
15
  name: user.name,
16
16
  email: user.email,
17
17
  },
18
- }, { url: this.request.path, title: 'Profile' })
18
+ }, { title: 'Profile' })
19
19
  }
20
20
 
21
21
  async update(): Promise<Response> {
@@ -49,6 +49,6 @@ export default class ProfileController extends Controller {
49
49
  return this.inertia(pages.profile.Edit, {
50
50
  profile: { name, email },
51
51
  status: 'Profile updated successfully.',
52
- }, { url: this.request.path, title: 'Profile' })
52
+ }, { title: 'Profile' })
53
53
  }
54
54
  }
@@ -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 = ['/healthcheck', '/up']
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,20 @@
1
- import { describe, it } from 'bun:test'
1
+ import { beforeAll, describe, it } from 'bun:test'
2
2
  import { TestApp } from '@guren/testing'
3
- import DatabaseProvider from '../app/Providers/DatabaseProvider.js'
4
- import { registerWebRoutes } from '../routes/web.js'
3
+ import app from '../src/app.js'
5
4
 
6
- // The blog home page reads posts from the database, so exercising it here
7
- // would need migrations and fixtures — the golden-path flow already covers
8
- // it end to end. This starter test keeps `bun test` green out of the box;
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
- it('answers the health check', async () => {
12
- const app = await TestApp.create({
13
- routes: registerWebRoutes,
14
- providers: [DatabaseProvider],
15
- })
11
+ let http: TestApp
12
+
13
+ beforeAll(async () => {
14
+ http = await TestApp.fromApp(app)
15
+ })
16
16
 
17
- await app.get('/health').assertOk()
17
+ it('answers the health check', async () => {
18
+ await http.get('/health').assertOk()
18
19
  })
19
20
  })
@@ -4,9 +4,10 @@ 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
- message: 'Welcome to __APP_TITLE__!',
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
- return this.inertia(pages.Home, props, { url: this.request.path, title: '__APP_TITLE__' })
11
+ return this.inertia(pages.Home, props, { title: '__APP_TITLE__' })
11
12
  }
12
13
  }
@@ -7,18 +7,31 @@ try {
7
7
  process.exit(1)
8
8
  }
9
9
 
10
- const requestedPort = Number.parseInt(process.env.PORT ?? '', 10) || 3333
10
+ // `PORT=0` means "any free port", so this tests for a number, not truthiness.
11
+ const parsedPort = Number.parseInt(process.env.PORT ?? '', 10)
12
+ const requestedPort = Number.isInteger(parsedPort) ? parsedPort : 3333
11
13
  const hostname = process.env.HOST ?? '0.0.0.0'
14
+
15
+ // In development a busy port moves to the next one. Set GUREN_STRICT_PORT=1 to
16
+ // bind the requested port or fail — see the deployment guide.
12
17
  const isDevelopment = process.env.NODE_ENV !== 'production'
18
+ const canWalkPorts =
19
+ isDevelopment && requestedPort !== 0 && process.env.GUREN_STRICT_PORT !== '1'
20
+ const attempts = canWalkPorts ? 20 : 1
21
+
22
+ // This file owns the retry, so the framework must not retry underneath it —
23
+ // newer framework versions walk inside listen() themselves, and the two loops
24
+ // would nest into a much wider search reported against the wrong ports.
25
+ process.env.GUREN_STRICT_PORT = '1'
13
26
 
14
- for (let offset = 0; offset < 20; offset += 1) {
27
+ for (let offset = 0; offset < attempts; offset += 1) {
15
28
  const port = requestedPort + offset
16
29
 
17
30
  try {
18
31
  await app.listen({ port, hostname })
19
32
  break
20
33
  } catch (error) {
21
- if (!isDevelopment || !isAddressInUse(error) || offset === 19) {
34
+ if (!isAddressInUse(error) || offset === attempts - 1) {
22
35
  throw error
23
36
  }
24
37
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "welcome": "Welcome to :name!"
3
+ }
@@ -19,10 +19,10 @@
19
19
  "db:seed": "bunx guren db:seed"
20
20
  },
21
21
  "dependencies": {
22
- "@guren/cli": "^2.2.0",
23
- "@guren/core": "^1.5.1",
22
+ "@guren/cli": "^2.3.1",
23
+ "@guren/core": "^1.5.2",
24
24
  "@guren/inertia-client": "^1.1.0",
25
- "@guren/orm": "^2.2.0",
25
+ "@guren/orm": "^2.2.2",
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.3.0",
33
+ "@guren/testing": "^1.4.1",
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 = ['/healthcheck', '/up']
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,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 DatabaseProvider from '../app/Providers/DatabaseProvider.js'
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
- it('serves the home page', async () => {
8
- const app = await TestApp.create({
9
- routes: registerWebRoutes,
10
- providers: [DatabaseProvider],
11
- })
7
+ let http: TestApp
12
8
 
13
- await app.get('/').assertOk()
9
+ beforeAll(async () => {
10
+ http = await TestApp.fromApp(app)
14
11
  })
15
12
 
16
- it('answers the health check', async () => {
17
- const app = await TestApp.create({
18
- routes: registerWebRoutes,
19
- providers: [DatabaseProvider],
20
- })
13
+ it('serves the translated home page', async () => {
14
+ const response = await http.get('/').assertOk()
15
+ await response.assertBodyContains('Welcome to')
16
+ })
21
17
 
22
- await app.get('/health').assertOk()
18
+ it('answers the health check', async () => {
19
+ await http.get('/health').assertOk()
23
20
  })
24
21
  })