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 +1 -1
- package/package.json +1 -1
- package/templates/api-only/bin/serve.ts +8 -25
- package/templates/api-only/package.json +4 -4
- package/templates/blog/app/Http/Controllers/Auth/LoginController.ts +1 -1
- package/templates/blog/app/Http/Controllers/Auth/RegisterController.ts +1 -1
- package/templates/blog/app/Http/Controllers/DashboardController.ts +1 -1
- package/templates/blog/app/Http/Controllers/HomeController.ts +1 -1
- package/templates/blog/app/Http/Controllers/ProfileController.ts +2 -2
- package/templates/blog/app/Http/Validators/LoginValidator.ts +2 -2
- package/templates/blog/app/Http/Validators/ProfileValidator.ts +2 -2
- package/templates/blog/app/Http/Validators/RegisterValidator.ts +2 -2
- package/templates/blog/app/Models/User.ts +3 -5
- package/templates/blog/tests/HomeController.test.ts +1 -2
- package/templates/default/app/Http/Controllers/HomeController.ts +1 -1
- package/templates/default/bin/serve.ts +8 -25
- package/templates/default/package.json +4 -4
- package/templates/default/tests/HomeController.test.ts +1 -2
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
|
@@ -7,30 +7,13 @@ try {
|
|
|
7
7
|
process.exit(1)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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.
|
|
22
|
-
"@guren/core": "^1.
|
|
23
|
-
"@guren/orm": "^2.
|
|
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.
|
|
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 }, {
|
|
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, {}, {
|
|
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 }, {
|
|
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
|
-
{
|
|
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
|
-
}, {
|
|
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
|
-
}, {
|
|
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
|
-
.
|
|
11
|
-
.
|
|
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
|
-
.
|
|
14
|
-
.
|
|
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
|
-
.
|
|
18
|
-
.
|
|
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
|
-
|
|
18
|
-
|
|
16
|
+
fillable: ['name', 'email', 'password'],
|
|
19
17
|
// Never serialized by Model.serialize() and stripped from auth.user()
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
hidden: ['passwordHash', 'rememberToken'],
|
|
19
|
+
}) {
|
|
22
20
|
static override relationTypes: { posts: HasManyRecord<PostRecord> } = {
|
|
23
21
|
posts: [],
|
|
24
22
|
}
|
|
@@ -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, {
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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.
|
|
23
|
-
"@guren/core": "^1.
|
|
22
|
+
"@guren/cli": "^2.4.0",
|
|
23
|
+
"@guren/core": "^1.6.0",
|
|
24
24
|
"@guren/inertia-client": "^1.1.0",
|
|
25
|
-
"@guren/orm": "^2.
|
|
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.
|
|
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",
|