create-guren-app 1.1.0 → 1.2.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 +3 -0
- package/templates/api-only/config/database.ts +13 -1
- package/templates/api-only/package.json +1 -0
- package/templates/default/.env.example +3 -0
- package/templates/default/config/database.ts +13 -1
- package/templates/default/package.json +1 -0
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=
|
|
@@ -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
|
|
@@ -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=
|
|
@@ -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
|