create-guren-app 1.8.6 → 1.8.8
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 +16 -35
- package/package.json +1 -1
- package/templates/api-only/package.json +2 -2
- package/templates/api-only/tsconfig.json +1 -1
- package/templates/database/mysql/config/database.ts +12 -0
- package/templates/database/postgres/config/database.ts +12 -0
- package/templates/database/sqlite/config/database.ts +24 -0
- package/templates/default/package.json +2 -2
- package/templates/default/tsconfig.json +14 -7
package/dist/cli.js
CHANGED
|
@@ -1761,42 +1761,22 @@ async function scaffoldEnvFiles(destination) {
|
|
|
1761
1761
|
`, "utf8");
|
|
1762
1762
|
}
|
|
1763
1763
|
var DATABASE_DEFAULTS = {
|
|
1764
|
-
postgres: { url: "postgres://guren:guren@localhost:54322/guren", dialect: "postgresql", dep: { postgres: "^3.4.3" }
|
|
1765
|
-
mysql: { url: "mysql://guren:guren@localhost:33306/guren", dialect: "mysql", dep: { mysql2: "^3.11.3" }
|
|
1766
|
-
sqlite: { url: "./data/guren.db", dialect: "sqlite", dep: null
|
|
1764
|
+
postgres: { url: "postgres://guren:guren@localhost:54322/guren", dialect: "postgresql", dep: { postgres: "^3.4.3" } },
|
|
1765
|
+
mysql: { url: "mysql://guren:guren@localhost:33306/guren", dialect: "mysql", dep: { mysql2: "^3.11.3" } },
|
|
1766
|
+
sqlite: { url: "./data/guren.db", dialect: "sqlite", dep: null }
|
|
1767
1767
|
};
|
|
1768
|
-
function
|
|
1769
|
-
|
|
1770
|
-
const body = driver === "sqlite" ? `// \`bun test\` sets NODE_ENV=test automatically, so the test suite reads and
|
|
1771
|
-
// writes a separate SQLite file and never touches the development database \u2014
|
|
1772
|
-
// this takes priority over DATABASE_URL, which .env sets unconditionally.
|
|
1773
|
-
// Override the test DB path itself with TEST_DATABASE_URL if needed (e.g. to
|
|
1774
|
-
// shard parallel CI runs); DATABASE_URL is still authoritative outside tests.
|
|
1775
|
-
function resolveDatabaseFilename(): string {
|
|
1776
|
-
if (process.env.NODE_ENV === 'test') {
|
|
1777
|
-
return process.env.TEST_DATABASE_URL ?? './data/guren.test.db'
|
|
1778
|
-
}
|
|
1779
|
-
return process.env.DATABASE_URL ?? '${url}'
|
|
1768
|
+
function databaseConfigTemplatePath(driver) {
|
|
1769
|
+
return join(TEMPLATES_ROOT, "database", driver, "config/database.ts");
|
|
1780
1770
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
})`;
|
|
1791
|
-
return `import { ${factory}, type ${seederContext} } from '@guren/orm'
|
|
1792
|
-
|
|
1793
|
-
${body}
|
|
1794
|
-
|
|
1795
|
-
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
1796
|
-
|
|
1797
|
-
/** Annotate seeders with this: \`defineSeeder(async ({ db }: AppSeederContext) => {})\`. */
|
|
1798
|
-
export type AppSeederContext = ${seederContext}
|
|
1799
|
-
`;
|
|
1771
|
+
async function loadDatabaseConfig(driver) {
|
|
1772
|
+
try {
|
|
1773
|
+
return await readFile(databaseConfigTemplatePath(driver), "utf8");
|
|
1774
|
+
} catch (cause) {
|
|
1775
|
+
throw new Error(
|
|
1776
|
+
`Could not read the ${driver} database config template at "${databaseConfigTemplatePath(driver)}". This build of create-guren-app may be incomplete \u2014 please report it at https://github.com/gurenjs/guren/issues and try \`npm create guren-app@latest\` meanwhile.`,
|
|
1777
|
+
{ cause }
|
|
1778
|
+
);
|
|
1779
|
+
}
|
|
1800
1780
|
}
|
|
1801
1781
|
function generateSchema(driver) {
|
|
1802
1782
|
if (driver === "postgres") {
|
|
@@ -1931,8 +1911,9 @@ async function applyDatabaseConfig(destination, driver) {
|
|
|
1931
1911
|
const { url, dep } = DATABASE_DEFAULTS[driver];
|
|
1932
1912
|
const dockerCompose = generateDockerCompose(driver);
|
|
1933
1913
|
const schema = await resolveSchema(destination, driver);
|
|
1914
|
+
const databaseConfig = await loadDatabaseConfig(driver);
|
|
1934
1915
|
await Promise.all([
|
|
1935
|
-
writeFile(join(destination, "config/database.ts"),
|
|
1916
|
+
writeFile(join(destination, "config/database.ts"), databaseConfig, "utf8"),
|
|
1936
1917
|
writeFile(join(destination, "db/schema.ts"), schema, "utf8"),
|
|
1937
1918
|
// Independent of the write above: the selected variant's contents are
|
|
1938
1919
|
// already in `schema`, and no variant shares a path with db/schema.ts.
|
package/package.json
CHANGED
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"test": "bun test"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@guren/cli": "^2.
|
|
21
|
+
"@guren/cli": "^2.9.0",
|
|
22
22
|
"@guren/core": "^1.8.0",
|
|
23
23
|
"@guren/orm": "^2.6.0",
|
|
24
24
|
"drizzle-orm": "1.0.0-rc.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@guren/testing": "^1.
|
|
27
|
+
"@guren/testing": "^1.6.1",
|
|
28
28
|
"bun-types": "^1.3.1",
|
|
29
29
|
"drizzle-kit": "1.0.0-rc.4",
|
|
30
30
|
"typescript": "^5.4.0"
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
"@/*": ["./*"]
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"include": [".guren/**/*", "src/**/*", "app/**/*", "routes/**/*", "config/**/*", "db/**/*", "bin/**/*"],
|
|
18
|
+
"include": [".guren/**/*", "src/**/*", "app/**/*", "routes/**/*", "config/**/*", "db/**/*", "bin/**/*", "*.ts"],
|
|
19
19
|
"exclude": ["node_modules"]
|
|
20
20
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createMySqlDatabase, type MySqlSeederContext } from '@guren/orm'
|
|
2
|
+
|
|
3
|
+
const database = createMySqlDatabase({
|
|
4
|
+
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
5
|
+
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
6
|
+
connectionString: () => process.env.DATABASE_URL ?? 'mysql://guren:guren@localhost:33306/guren',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
10
|
+
|
|
11
|
+
/** Annotate seeders with this: `defineSeeder(async ({ db }: AppSeederContext) => {})`. */
|
|
12
|
+
export type AppSeederContext = MySqlSeederContext
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createPostgresDatabase, type PostgresSeederContext } from '@guren/orm'
|
|
2
|
+
|
|
3
|
+
const database = createPostgresDatabase({
|
|
4
|
+
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
5
|
+
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
6
|
+
connectionString: () => process.env.DATABASE_URL ?? 'postgres://guren:guren@localhost:54322/guren',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
10
|
+
|
|
11
|
+
/** Annotate seeders with this: `defineSeeder(async ({ db }: AppSeederContext) => {})`. */
|
|
12
|
+
export type AppSeederContext = PostgresSeederContext
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSqliteDatabase, type SqliteSeederContext } from '@guren/orm'
|
|
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
|
+
|
|
15
|
+
const database = createSqliteDatabase({
|
|
16
|
+
migrationsFolder: new URL('../db/migrations', import.meta.url),
|
|
17
|
+
seedersFolder: new URL('../db/seeders', import.meta.url),
|
|
18
|
+
filename: resolveDatabaseFilename,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
|
|
22
|
+
|
|
23
|
+
/** Annotate seeders with this: `defineSeeder(async ({ db }: AppSeederContext) => {})`. */
|
|
24
|
+
export type AppSeederContext = SqliteSeederContext
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"db:seed": "bunx guren db:seed"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@guren/cli": "^2.
|
|
22
|
+
"@guren/cli": "^2.9.0",
|
|
23
23
|
"@guren/core": "^1.8.0",
|
|
24
24
|
"@guren/inertia-client": "^1.1.1",
|
|
25
25
|
"@guren/orm": "^2.6.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"zod": "^4.4.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@guren/testing": "^1.
|
|
33
|
+
"@guren/testing": "^1.6.1",
|
|
34
34
|
"@tailwindcss/vite": "^4.2.2",
|
|
35
35
|
"@types/react": "^19.0.0",
|
|
36
36
|
"@types/react-dom": "^19.0.0",
|
|
@@ -23,12 +23,19 @@
|
|
|
23
23
|
"jsx": "react-jsx"
|
|
24
24
|
},
|
|
25
25
|
"include": [
|
|
26
|
-
".guren",
|
|
27
|
-
"src",
|
|
28
|
-
"app",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
26
|
+
".guren/**/*",
|
|
27
|
+
"src/**/*",
|
|
28
|
+
"app/**/*",
|
|
29
|
+
"config/**/*",
|
|
30
|
+
"db/**/*",
|
|
31
|
+
"routes/**/*",
|
|
32
|
+
"resources/js/**/*",
|
|
33
|
+
"types/**/*",
|
|
34
|
+
"bin/**/*",
|
|
35
|
+
"tests/**/*",
|
|
36
|
+
"*.ts"
|
|
37
|
+
],
|
|
38
|
+
"exclude": [
|
|
39
|
+
"node_modules"
|
|
33
40
|
]
|
|
34
41
|
}
|