create-guren-app 1.1.0 → 1.3.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/dist/cli.js +13 -1
- package/package.json +1 -1
- package/templates/api-only/.env.example +7 -0
- package/templates/api-only/config/database.ts +13 -1
- package/templates/api-only/docs/adr/0001-record-architecture-decisions.md +47 -0
- package/templates/api-only/drizzle.config.ts +5 -0
- package/templates/api-only/package.json +3 -2
- package/templates/default/.env.example +7 -0
- package/templates/default/config/database.ts +13 -1
- package/templates/default/docs/adr/0001-record-architecture-decisions.md +47 -0
- package/templates/default/drizzle.config.ts +5 -0
- package/templates/default/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -1847,10 +1847,22 @@ export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDa
|
|
|
1847
1847
|
}
|
|
1848
1848
|
return `import { createSqliteDatabase } from '@guren/orm'
|
|
1849
1849
|
|
|
1850
|
+
// \`bun test\` sets NODE_ENV=test automatically, so the test suite reads and
|
|
1851
|
+
// writes a separate SQLite file and never touches the development database \u2014
|
|
1852
|
+
// this takes priority over DATABASE_URL, which .env sets unconditionally.
|
|
1853
|
+
// Override the test DB path itself with TEST_DATABASE_URL if needed (e.g. to
|
|
1854
|
+
// shard parallel CI runs); DATABASE_URL is still authoritative outside tests.
|
|
1855
|
+
function resolveDatabaseFilename(): string {
|
|
1856
|
+
if (process.env.NODE_ENV === 'test') {
|
|
1857
|
+
return process.env.TEST_DATABASE_URL ?? './data/guren.test.db'
|
|
1858
|
+
}
|
|
1859
|
+
return process.env.DATABASE_URL ?? '${url}'
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1850
1862
|
const database = createSqliteDatabase({
|
|
1851
1863
|
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
1852
1864
|
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
1853
|
-
filename:
|
|
1865
|
+
filename: resolveDatabaseFilename,
|
|
1854
1866
|
})
|
|
1855
1867
|
|
|
1856
1868
|
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
package/package.json
CHANGED
|
@@ -7,6 +7,9 @@ APP_URL=http://localhost:3333
|
|
|
7
7
|
PORT=3333
|
|
8
8
|
HOST=0.0.0.0
|
|
9
9
|
|
|
10
|
+
# bun test automatically sets NODE_ENV=test, which points the app at
|
|
11
|
+
# ./data/guren.test.db instead — this line is only used outside tests.
|
|
12
|
+
# Override the test DB path itself with TEST_DATABASE_URL if you need to.
|
|
10
13
|
DATABASE_URL=./data/guren.db
|
|
11
14
|
|
|
12
15
|
REDIS_URL=
|
|
@@ -30,3 +33,7 @@ MAIL_FROM_NAME="${APP_NAME}"
|
|
|
30
33
|
# OAUTH_GOOGLE_CLIENT_ID=
|
|
31
34
|
# OAUTH_GOOGLE_CLIENT_SECRET=
|
|
32
35
|
# OAUTH_GOOGLE_REDIRECT_URI=http://localhost:3333/auth/google/callback
|
|
36
|
+
|
|
37
|
+
# OAUTH_DISCORD_CLIENT_ID=
|
|
38
|
+
# OAUTH_DISCORD_CLIENT_SECRET=
|
|
39
|
+
# OAUTH_DISCORD_REDIRECT_URI=http://localhost:3333/auth/discord/callback
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { createSqliteDatabase } from '@guren/orm'
|
|
2
2
|
|
|
3
|
+
// `bun test` sets NODE_ENV=test automatically, so the test suite reads and
|
|
4
|
+
// writes a separate SQLite file and never touches the development database —
|
|
5
|
+
// this takes priority over DATABASE_URL, which .env sets unconditionally.
|
|
6
|
+
// Override the test DB path itself with TEST_DATABASE_URL if needed (e.g. to
|
|
7
|
+
// shard parallel CI runs); DATABASE_URL is still authoritative outside tests.
|
|
8
|
+
function resolveDatabaseFilename(): string {
|
|
9
|
+
if (process.env.NODE_ENV === 'test') {
|
|
10
|
+
return process.env.TEST_DATABASE_URL ?? './data/guren.test.db'
|
|
11
|
+
}
|
|
12
|
+
return process.env.DATABASE_URL ?? './data/guren.db'
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
const database = createSqliteDatabase({
|
|
4
16
|
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
5
17
|
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
6
|
-
filename:
|
|
18
|
+
filename: resolveDatabaseFilename,
|
|
7
19
|
})
|
|
8
20
|
|
|
9
21
|
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: adr
|
|
3
|
+
status: accepted
|
|
4
|
+
entities: []
|
|
5
|
+
related: []
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Record architecture decisions
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
Code shows *what* the system does; it cannot show *why*. Decisions —
|
|
13
|
+
business rules, trade-offs, rejected alternatives — live in people's
|
|
14
|
+
heads and get lost. AI coding agents working on this codebase have the
|
|
15
|
+
same problem: without recorded decisions they can only infer intent.
|
|
16
|
+
|
|
17
|
+
## Decision
|
|
18
|
+
|
|
19
|
+
We record significant decisions as numbered ADRs in this directory,
|
|
20
|
+
created with:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bunx guren make:adr "Title of the decision"
|
|
24
|
+
bunx guren make:adr "Title" --entity Invoice # prefills the links below
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Each ADR declares what it governs in its frontmatter:
|
|
28
|
+
|
|
29
|
+
- `entities: [Invoice]` — model class names the decision affects.
|
|
30
|
+
`bunx guren context Invoice` then surfaces this ADR to anyone (human
|
|
31
|
+
or agent) working on that model.
|
|
32
|
+
- `related: [app/Http/Controllers/InvoiceController.ts]` — files or
|
|
33
|
+
globs the decision touches.
|
|
34
|
+
- `status:` — `draft` → `accepted`; mark `superseded` when replaced
|
|
35
|
+
(and write the replacement).
|
|
36
|
+
|
|
37
|
+
Once declared, the links are verified: `bunx guren check` reports a
|
|
38
|
+
renamed file a doc points at, or a removed model a doc names, as a
|
|
39
|
+
failure, and `bunx guren check --docs` gates CI on it (non-zero exit).
|
|
40
|
+
Keep frontmatter current in the same change that moves the code.
|
|
41
|
+
|
|
42
|
+
## Consequences
|
|
43
|
+
|
|
44
|
+
Decisions stay discoverable from the code they govern, at the cost of
|
|
45
|
+
writing them down and keeping links fresh — declared links are checked,
|
|
46
|
+
so they can be trusted. (An ADR with no links, like this one, is valid;
|
|
47
|
+
it simply isn't surfaced by `guren context`.)
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { defineConfig } from 'drizzle-kit'
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
+
// `guren make:module` wires each modules/<name>/db/schema.ts into this
|
|
5
|
+
// file automatically via a re-export, so this single path is enough by
|
|
6
|
+
// default. If you'd rather point drizzle-kit at every module schema
|
|
7
|
+
// directly instead, `schema` also accepts an array of paths/globs, e.g.
|
|
8
|
+
// schema: ['./db/schema.ts', './modules/*/db/schema.ts'].
|
|
4
9
|
schema: './db/schema.ts',
|
|
5
10
|
out: './db/migrations',
|
|
6
11
|
dialect: 'sqlite',
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "bun run codegen && bun run dev:server",
|
|
8
|
-
"dev:server": "bun bin/serve.ts",
|
|
7
|
+
"dev": "bun run codegen && GUREN_MCP=1 bun run dev:server",
|
|
8
|
+
"dev:server": "bun --hot bin/serve.ts",
|
|
9
9
|
"codegen": "bunx guren codegen --routes routes/api.ts --force",
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
11
|
"db:make": "bunx guren make:migration",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"drizzle-orm": "1.0.0-rc.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
+
"@guren/testing": "^1.0.0",
|
|
26
27
|
"bun-types": "^1.3.1",
|
|
27
28
|
"drizzle-kit": "1.0.0-rc.4",
|
|
28
29
|
"mysql2": "^3.11.3",
|
|
@@ -7,6 +7,9 @@ APP_URL=http://localhost:3333
|
|
|
7
7
|
PORT=3333
|
|
8
8
|
HOST=0.0.0.0
|
|
9
9
|
|
|
10
|
+
# bun test automatically sets NODE_ENV=test, which points the app at
|
|
11
|
+
# ./data/guren.test.db instead — this line is only used outside tests.
|
|
12
|
+
# Override the test DB path itself with TEST_DATABASE_URL if you need to.
|
|
10
13
|
DATABASE_URL=./data/guren.db
|
|
11
14
|
|
|
12
15
|
REDIS_URL=
|
|
@@ -34,5 +37,9 @@ MAIL_FROM_NAME="${APP_NAME}"
|
|
|
34
37
|
# OAUTH_GOOGLE_CLIENT_SECRET=
|
|
35
38
|
# OAUTH_GOOGLE_REDIRECT_URI=http://localhost:3333/auth/google/callback
|
|
36
39
|
|
|
40
|
+
# OAUTH_DISCORD_CLIENT_ID=
|
|
41
|
+
# OAUTH_DISCORD_CLIENT_SECRET=
|
|
42
|
+
# OAUTH_DISCORD_REDIRECT_URI=http://localhost:3333/auth/discord/callback
|
|
43
|
+
|
|
37
44
|
# Optional: point to an already-running external Vite dev server.
|
|
38
45
|
# VITE_DEV_SERVER_URL=http://localhost:5173
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { createSqliteDatabase } from '@guren/orm'
|
|
2
2
|
|
|
3
|
+
// `bun test` sets NODE_ENV=test automatically, so the test suite reads and
|
|
4
|
+
// writes a separate SQLite file and never touches the development database —
|
|
5
|
+
// this takes priority over DATABASE_URL, which .env sets unconditionally.
|
|
6
|
+
// Override the test DB path itself with TEST_DATABASE_URL if needed (e.g. to
|
|
7
|
+
// shard parallel CI runs); DATABASE_URL is still authoritative outside tests.
|
|
8
|
+
function resolveDatabaseFilename(): string {
|
|
9
|
+
if (process.env.NODE_ENV === 'test') {
|
|
10
|
+
return process.env.TEST_DATABASE_URL ?? './data/guren.test.db'
|
|
11
|
+
}
|
|
12
|
+
return process.env.DATABASE_URL ?? './data/guren.db'
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
const database = createSqliteDatabase({
|
|
4
16
|
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
5
17
|
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
6
|
-
filename:
|
|
18
|
+
filename: resolveDatabaseFilename,
|
|
7
19
|
})
|
|
8
20
|
|
|
9
21
|
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: adr
|
|
3
|
+
status: accepted
|
|
4
|
+
entities: []
|
|
5
|
+
related: []
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Record architecture decisions
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
Code shows *what* the system does; it cannot show *why*. Decisions —
|
|
13
|
+
business rules, trade-offs, rejected alternatives — live in people's
|
|
14
|
+
heads and get lost. AI coding agents working on this codebase have the
|
|
15
|
+
same problem: without recorded decisions they can only infer intent.
|
|
16
|
+
|
|
17
|
+
## Decision
|
|
18
|
+
|
|
19
|
+
We record significant decisions as numbered ADRs in this directory,
|
|
20
|
+
created with:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bunx guren make:adr "Title of the decision"
|
|
24
|
+
bunx guren make:adr "Title" --entity Invoice # prefills the links below
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Each ADR declares what it governs in its frontmatter:
|
|
28
|
+
|
|
29
|
+
- `entities: [Invoice]` — model class names the decision affects.
|
|
30
|
+
`bunx guren context Invoice` then surfaces this ADR to anyone (human
|
|
31
|
+
or agent) working on that model.
|
|
32
|
+
- `related: [app/Http/Controllers/InvoiceController.ts]` — files or
|
|
33
|
+
globs the decision touches.
|
|
34
|
+
- `status:` — `draft` → `accepted`; mark `superseded` when replaced
|
|
35
|
+
(and write the replacement).
|
|
36
|
+
|
|
37
|
+
Once declared, the links are verified: `bunx guren check` reports a
|
|
38
|
+
renamed file a doc points at, or a removed model a doc names, as a
|
|
39
|
+
failure, and `bunx guren check --docs` gates CI on it (non-zero exit).
|
|
40
|
+
Keep frontmatter current in the same change that moves the code.
|
|
41
|
+
|
|
42
|
+
## Consequences
|
|
43
|
+
|
|
44
|
+
Decisions stay discoverable from the code they govern, at the cost of
|
|
45
|
+
writing them down and keeping links fresh — declared links are checked,
|
|
46
|
+
so they can be trusted. (An ADR with no links, like this one, is valid;
|
|
47
|
+
it simply isn't surfaced by `guren context`.)
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { defineConfig } from 'drizzle-kit'
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
+
// `guren make:module` wires each modules/<name>/db/schema.ts into this
|
|
5
|
+
// file automatically via a re-export, so this single path is enough by
|
|
6
|
+
// default. If you'd rather point drizzle-kit at every module schema
|
|
7
|
+
// directly instead, `schema` also accepts an array of paths/globs, e.g.
|
|
8
|
+
// schema: ['./db/schema.ts', './modules/*/db/schema.ts'].
|
|
4
9
|
schema: './db/schema.ts',
|
|
5
10
|
out: './db/migrations',
|
|
6
11
|
dialect: 'sqlite',
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"codegen": "bunx guren codegen --force",
|
|
8
|
-
"dev": "bun run codegen && bun run dev:server",
|
|
9
|
-
"dev:server": "bun bin/serve.ts",
|
|
8
|
+
"dev": "bun run codegen && GUREN_MCP=1 bun run dev:server",
|
|
9
|
+
"dev:server": "bun --hot bin/serve.ts",
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
11
|
"build": "bun run codegen && bunx vite build",
|
|
12
12
|
"preview": "NODE_ENV=production bun bin/serve.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"zod": "^4.4.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@guren/testing": "^1.0.0",
|
|
31
32
|
"@types/react": "^19.0.0",
|
|
32
33
|
"@types/react-dom": "^19.0.0",
|
|
33
34
|
"bun-types": "^1.3.1",
|