create-guren-app 1.7.0 → 1.7.2

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.7.0",
3
+ "version": "1.7.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -7,30 +7,13 @@ 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 port = Number.isInteger(parsedPort) ? parsedPort : 3333
11
13
  const hostname = process.env.HOST ?? '0.0.0.0'
12
- const isDevelopment = process.env.NODE_ENV !== 'production'
13
14
 
14
- for (let offset = 0; offset < 20; offset += 1) {
15
- const port = requestedPort + offset
16
-
17
- try {
18
- await app.listen({ port, hostname })
19
- break
20
- } catch (error) {
21
- if (!isDevelopment || !isAddressInUse(error) || offset === 19) {
22
- throw error
23
- }
24
-
25
- console.warn(`Port ${port} is in use, trying ${port + 1}...`)
26
- }
27
- }
28
-
29
- function isAddressInUse(error: unknown): boolean {
30
- return Boolean(
31
- error &&
32
- typeof error === 'object' &&
33
- 'code' in error &&
34
- (error as { code?: unknown }).code === 'EADDRINUSE',
35
- )
36
- }
15
+ // The walk past a busy port lives in listen() now, which is also the only
16
+ // place that can report which port it ended up on. Set GUREN_STRICT_PORT=1 to
17
+ // fail fast instead — what an automated consumer wants when it has to know
18
+ // the app under test is the one answering.
19
+ await app.listen({ port, hostname })
@@ -18,13 +18,13 @@
18
18
  "test": "bun test"
19
19
  },
20
20
  "dependencies": {
21
- "@guren/cli": "^2.3.0",
22
- "@guren/core": "^1.5.2",
23
- "@guren/orm": "^2.2.1",
21
+ "@guren/cli": "^2.4.0",
22
+ "@guren/core": "^1.6.0",
23
+ "@guren/orm": "^2.3.0",
24
24
  "drizzle-orm": "1.0.0-rc.4"
25
25
  },
26
26
  "devDependencies": {
27
- "@guren/testing": "^1.4.0",
27
+ "@guren/testing": "^1.5.0",
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
  }
@@ -7,8 +7,8 @@ export const LoginSchema = z.object({
7
7
  .string()
8
8
  .trim()
9
9
  .min(1, 'Email is required.')
10
- .email('The email address is badly formatted.')
11
- .toLowerCase(),
10
+ .toLowerCase()
11
+ .pipe(z.email('The email address is badly formatted.')),
12
12
  password: z
13
13
  .string()
14
14
  .min(1, 'Password is required.'),
@@ -10,8 +10,8 @@ export const ProfileUpdateSchema = z.object({
10
10
  .string()
11
11
  .trim()
12
12
  .min(1, 'Email is required.')
13
- .email('Enter a valid email address.')
14
- .toLowerCase(),
13
+ .toLowerCase()
14
+ .pipe(z.email('Enter a valid email address.')),
15
15
  password: z
16
16
  .string()
17
17
  .trim()
@@ -14,8 +14,8 @@ export const RegisterSchema = z
14
14
  .string()
15
15
  .trim()
16
16
  .min(1, 'Email is required.')
17
- .email('The email address is badly formatted.')
18
- .toLowerCase(),
17
+ .toLowerCase()
18
+ .pipe(z.email('The email address is badly formatted.')),
19
19
  password: z
20
20
  .string()
21
21
  .min(8, 'Password must be at least 8 characters.'),
@@ -9,16 +9,14 @@ export class User extends defineModel(users, {
9
9
  // Derived from the plain `password`, so callers never set it directly
10
10
  optionalOnCreate: ['passwordHash'],
11
11
  requireOnCreate: ['password'],
12
- }) {
13
12
  // passwordHash and rememberToken are denied from mass assignment by
14
13
  // AuthenticatableModel itself. `name` and `email` are the only remaining
15
14
  // columns, so this fillable list matches what would be mass-assignable
16
15
  // anyway — it stays explicit so a later column addition needs an opt-in.
17
- static fillable = ['name', 'email', 'password']
18
-
16
+ fillable: ['name', 'email', 'password'],
19
17
  // Never serialized by Model.serialize() and stripped from auth.user()
20
- static override hidden = ['passwordHash', 'rememberToken']
21
-
18
+ hidden: ['passwordHash', 'rememberToken'],
19
+ }) {
22
20
  static override relationTypes: { posts: HasManyRecord<PostRecord> } = {
23
21
  posts: [],
24
22
  }
@@ -11,8 +11,7 @@ describe('app', () => {
11
11
  let http: TestApp
12
12
 
13
13
  beforeAll(async () => {
14
- await app.boot()
15
- http = TestApp.fromFetch((request) => app.fetch(request))
14
+ http = await TestApp.fromApp(app)
16
15
  })
17
16
 
18
17
  it('answers the health check', async () => {
@@ -8,6 +8,6 @@ export default class HomeController extends Controller {
8
8
  message: this.t('messages.welcome', { name: '__APP_TITLE__' }),
9
9
  }
10
10
 
11
- return this.inertia(pages.Home, props, { url: this.request.path, title: '__APP_TITLE__' })
11
+ return this.inertia(pages.Home, props, { title: '__APP_TITLE__' })
12
12
  }
13
13
  }
@@ -7,30 +7,13 @@ 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 port = Number.isInteger(parsedPort) ? parsedPort : 3333
11
13
  const hostname = process.env.HOST ?? '0.0.0.0'
12
- const isDevelopment = process.env.NODE_ENV !== 'production'
13
14
 
14
- for (let offset = 0; offset < 20; offset += 1) {
15
- const port = requestedPort + offset
16
-
17
- try {
18
- await app.listen({ port, hostname })
19
- break
20
- } catch (error) {
21
- if (!isDevelopment || !isAddressInUse(error) || offset === 19) {
22
- throw error
23
- }
24
-
25
- console.warn(`Port ${port} is in use, trying ${port + 1}...`)
26
- }
27
- }
28
-
29
- function isAddressInUse(error: unknown): boolean {
30
- return Boolean(
31
- error &&
32
- typeof error === 'object' &&
33
- 'code' in error &&
34
- (error as { code?: unknown }).code === 'EADDRINUSE',
35
- )
36
- }
15
+ // The walk past a busy port lives in listen() now, which is also the only
16
+ // place that can report which port it ended up on. Set GUREN_STRICT_PORT=1 to
17
+ // fail fast instead — what an automated consumer wants when it has to know
18
+ // the app under test is the one answering.
19
+ await app.listen({ port, hostname })
@@ -19,10 +19,10 @@
19
19
  "db:seed": "bunx guren db:seed"
20
20
  },
21
21
  "dependencies": {
22
- "@guren/cli": "^2.3.0",
23
- "@guren/core": "^1.5.2",
22
+ "@guren/cli": "^2.4.0",
23
+ "@guren/core": "^1.6.0",
24
24
  "@guren/inertia-client": "^1.1.0",
25
- "@guren/orm": "^2.2.1",
25
+ "@guren/orm": "^2.3.0",
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.4.0",
33
+ "@guren/testing": "^1.5.0",
34
34
  "@tailwindcss/vite": "^4.2.2",
35
35
  "@types/react": "^19.0.0",
36
36
  "@types/react-dom": "^19.0.0",
@@ -7,8 +7,7 @@ describe('app', () => {
7
7
  let http: TestApp
8
8
 
9
9
  beforeAll(async () => {
10
- await app.boot()
11
- http = TestApp.fromFetch((request) => app.fetch(request))
10
+ http = await TestApp.fromApp(app)
12
11
  })
13
12
 
14
13
  it('serves the translated home page', async () => {