@beignet/cli 0.0.9 → 0.0.10
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/CHANGELOG.md +7 -0
- package/README.md +35 -19
- package/dist/choices.d.ts +32 -3
- package/dist/choices.d.ts.map +1 -1
- package/dist/choices.js +54 -3
- package/dist/choices.js.map +1 -1
- package/dist/create-prompts.d.ts +5 -4
- package/dist/create-prompts.d.ts.map +1 -1
- package/dist/create-prompts.js +22 -4
- package/dist/create-prompts.js.map +1 -1
- package/dist/create.d.ts +7 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +13 -3
- package/dist/create.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/make.d.ts +21 -1
- package/dist/make.d.ts.map +1 -1
- package/dist/make.js +210 -37
- package/dist/make.js.map +1 -1
- package/dist/templates/base.d.ts.map +1 -1
- package/dist/templates/base.js +79 -9
- package/dist/templates/base.js.map +1 -1
- package/dist/templates/db/index.d.ts +21 -0
- package/dist/templates/db/index.d.ts.map +1 -0
- package/dist/templates/db/index.js +14 -0
- package/dist/templates/db/index.js.map +1 -0
- package/dist/templates/db/mysql.d.ts +4 -0
- package/dist/templates/db/mysql.d.ts.map +1 -0
- package/dist/templates/db/mysql.js +972 -0
- package/dist/templates/db/mysql.js.map +1 -0
- package/dist/templates/db/postgres.d.ts +4 -0
- package/dist/templates/db/postgres.d.ts.map +1 -0
- package/dist/templates/db/postgres.js +863 -0
- package/dist/templates/db/postgres.js.map +1 -0
- package/dist/templates/db/sqlite.d.ts +3 -0
- package/dist/templates/db/sqlite.d.ts.map +1 -0
- package/dist/templates/db/sqlite.js +878 -0
- package/dist/templates/db/sqlite.js.map +1 -0
- package/dist/templates/index.d.ts +5 -5
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +21 -20
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/server.d.ts +3 -3
- package/dist/templates/server.d.ts.map +1 -1
- package/dist/templates/server.js +149 -97
- package/dist/templates/server.js.map +1 -1
- package/dist/templates/shared.d.ts +34 -1
- package/dist/templates/shared.d.ts.map +1 -1
- package/dist/templates/shared.js +45 -0
- package/dist/templates/shared.js.map +1 -1
- package/package.json +2 -2
- package/src/choices.ts +70 -3
- package/src/create-prompts.ts +25 -3
- package/src/create.ts +24 -2
- package/src/index.ts +29 -5
- package/src/make.ts +265 -34
- package/src/templates/base.ts +95 -9
- package/src/templates/db/index.ts +34 -0
- package/src/templates/db/mysql.ts +976 -0
- package/src/templates/db/postgres.ts +867 -0
- package/src/templates/{db.ts → db/sqlite.ts} +31 -152
- package/src/templates/index.ts +24 -19
- package/src/templates/server.ts +161 -97
- package/src/templates/shared.ts +90 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../../src/templates/db/sqlite.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,sEAAsE;AACtE,uEAAuE;AACvE,EAAE;AACF,2DAA2D;AAC3D,0EAA0E;AAC1E,+EAA+E;AAC/E,gFAAgF;AAChF,0EAA0E;AAC1E,iEAAiE;AACjE,yEAAyE;AACzE,0EAA0E;AAC1E,yEAAyE;AAIzE,MAAM,KAAK,GAAG;IACZ,aAAa,EAAE;;;;;;;;;CAShB;IACC,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EX;IACC,qBAAqB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFxB;IACC,cAAc,EAAE;;;;;;;;;;;;CAYjB;IACC,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChB;IACC,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDb;IACC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CV;IACC,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCjB;IACC,oEAAoE;IACpE,kEAAkE;IAClE,mBAAmB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EtB;IACC,uBAAuB,EAAE;;;;;;;;;;;;EAYzB;IACA,wBAAwB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyZ1B;CACD,CAAC;AAEF,MAAM,UAAU,aAAa;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export type { IntegrationName, PackageManager, TemplateName, } from "../choices.js";
|
|
2
|
-
export { integrationChoices } from "../choices.js";
|
|
1
|
+
export type { DatabaseName, IntegrationName, PackageManager, TemplateName, } from "../choices.js";
|
|
2
|
+
export { databaseChoices, integrationChoices } from "../choices.js";
|
|
3
3
|
export type { TemplateContext, TemplateFile } from "./shared.js";
|
|
4
4
|
import type { TemplateContext, TemplateFile } from "./shared.js";
|
|
5
5
|
/**
|
|
6
6
|
* Render all template files for a new Beignet app.
|
|
7
7
|
*
|
|
8
8
|
* There is one starter: a full-stack app with a typed API, Better Auth,
|
|
9
|
-
* Drizzle
|
|
10
|
-
* `ctx.api` swaps the UI shell for
|
|
11
|
-
* typed client.
|
|
9
|
+
* Drizzle persistence (SQLite, Postgres, or MySQL via `ctx.database`), pino
|
|
10
|
+
* logging, devtools, and a shadcn UI shell. `ctx.api` swaps the UI shell for
|
|
11
|
+
* a minimal API landing page and a reduced typed client.
|
|
12
12
|
*/
|
|
13
13
|
export declare function getTemplateFiles(ctx: TemplateContext): TemplateFile[];
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBjE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIjE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,YAAY,EAAE,CAkHrE"}
|
package/dist/templates/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { integrationChoices } from "../choices.js";
|
|
1
|
+
export { databaseChoices, integrationChoices } from "../choices.js";
|
|
2
2
|
import { baseFiles, envExample, integrationsDoc, packageJson, readme, } from "./base.js";
|
|
3
|
-
import { dbFiles } from "./db.js";
|
|
4
|
-
import { infrastructurePorts, ports, serverFiles, serverProviders, } from "./server.js";
|
|
3
|
+
import { dbFiles } from "./db/index.js";
|
|
4
|
+
import { betterAuth, env, infrastructurePorts, ports, server, serverFiles, serverProviders, } from "./server.js";
|
|
5
5
|
import { shadcnTemplateFiles } from "./shadcn.js";
|
|
6
6
|
import { shellTemplateFiles } from "./shell.js";
|
|
7
7
|
import { todosFiles } from "./todos.js";
|
|
@@ -9,11 +9,12 @@ import { todosFiles } from "./todos.js";
|
|
|
9
9
|
* Render all template files for a new Beignet app.
|
|
10
10
|
*
|
|
11
11
|
* There is one starter: a full-stack app with a typed API, Better Auth,
|
|
12
|
-
* Drizzle
|
|
13
|
-
* `ctx.api` swaps the UI shell for
|
|
14
|
-
* typed client.
|
|
12
|
+
* Drizzle persistence (SQLite, Postgres, or MySQL via `ctx.database`), pino
|
|
13
|
+
* logging, devtools, and a shadcn UI shell. `ctx.api` swaps the UI shell for
|
|
14
|
+
* a minimal API landing page and a reduced typed client.
|
|
15
15
|
*/
|
|
16
16
|
export function getTemplateFiles(ctx) {
|
|
17
|
+
const db = dbFiles(ctx);
|
|
17
18
|
const templateFiles = [
|
|
18
19
|
{ path: "package.json", content: packageJson(ctx) },
|
|
19
20
|
{ path: "README.md", content: readme(ctx) },
|
|
@@ -78,31 +79,31 @@ export function getTemplateFiles(ctx) {
|
|
|
78
79
|
{ path: "ports/index.ts", content: ports(ctx) },
|
|
79
80
|
{ path: "ports/auth.ts", content: serverFiles.authPort },
|
|
80
81
|
{ path: "infra/app-ports.ts", content: infrastructurePorts(ctx) },
|
|
81
|
-
{ path: "infra/db/database-ready.ts", content:
|
|
82
|
-
{ path: "infra/db/provider.ts", content:
|
|
83
|
-
{ path: "infra/db/repositories.ts", content:
|
|
84
|
-
{ path: "infra/db/reset.ts", content:
|
|
85
|
-
{ path: "infra/db/test-database.ts", content:
|
|
86
|
-
{ path: "infra/db/schema/index.ts", content:
|
|
82
|
+
{ path: "infra/db/database-ready.ts", content: db.databaseReady },
|
|
83
|
+
{ path: "infra/db/provider.ts", content: db.dbProvider },
|
|
84
|
+
{ path: "infra/db/repositories.ts", content: db.dbRepositories },
|
|
85
|
+
{ path: "infra/db/reset.ts", content: db.dbReset },
|
|
86
|
+
{ path: "infra/db/test-database.ts", content: db.dbTestDatabase },
|
|
87
|
+
{ path: "infra/db/schema/index.ts", content: db.dbSchema },
|
|
87
88
|
{
|
|
88
89
|
path: "infra/todos/drizzle-todo-repository.ts",
|
|
89
|
-
content:
|
|
90
|
+
content: db.drizzleTodoRepository,
|
|
90
91
|
},
|
|
91
|
-
{ path: "drizzle.config.ts", content:
|
|
92
|
-
{ path: "drizzle/0000_starter.sql", content:
|
|
92
|
+
{ path: "drizzle.config.ts", content: db.drizzleConfig },
|
|
93
|
+
{ path: "drizzle/0000_starter.sql", content: db.starterMigrationSql },
|
|
93
94
|
{
|
|
94
95
|
path: "drizzle/meta/_journal.json",
|
|
95
|
-
content:
|
|
96
|
+
content: db.starterMigrationJournal,
|
|
96
97
|
},
|
|
97
98
|
{
|
|
98
99
|
path: "drizzle/meta/0000_snapshot.json",
|
|
99
|
-
content:
|
|
100
|
+
content: db.starterMigrationSnapshot,
|
|
100
101
|
},
|
|
101
|
-
{ path: "lib/env.ts", content:
|
|
102
|
+
{ path: "lib/env.ts", content: env(ctx) },
|
|
102
103
|
{ path: "lib/auth.ts", content: serverFiles.authHelpers },
|
|
103
|
-
{ path: "lib/better-auth.ts", content:
|
|
104
|
+
{ path: "lib/better-auth.ts", content: betterAuth(ctx) },
|
|
104
105
|
{ path: "lib/use-case.ts", content: serverFiles.useCaseBuilder },
|
|
105
|
-
{ path: "server/index.ts", content:
|
|
106
|
+
{ path: "server/index.ts", content: server(ctx) },
|
|
106
107
|
{ path: "server/context.ts", content: serverFiles.serverContext },
|
|
107
108
|
{ path: "server/routes.ts", content: serverFiles.serverRoutes },
|
|
108
109
|
{ path: "server/providers.ts", content: serverProviders(ctx) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGpE,OAAO,EACL,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,MAAM,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,UAAU,EACV,GAAG,EACH,mBAAmB,EACnB,KAAK,EACL,MAAM,EACN,WAAW,EACX,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAoB;IACnD,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,GAAmB;QACpC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE;QACnD,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE;QAC3C,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,EAAE;QACpD,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE;QAClD,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE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BAAmB,EAAE,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,aAAa,CAAC,IAAI,CAAC;YACjB,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -2,8 +2,10 @@ import { type TemplateContext } from "./shared.js";
|
|
|
2
2
|
export declare function serverProviders(ctx: TemplateContext): string;
|
|
3
3
|
export declare function ports(ctx: TemplateContext): string;
|
|
4
4
|
export declare function infrastructurePorts(ctx: TemplateContext): string;
|
|
5
|
+
export declare function env(ctx: TemplateContext): string;
|
|
6
|
+
export declare function betterAuth(ctx: TemplateContext): string;
|
|
7
|
+
export declare function server(ctx: TemplateContext): string;
|
|
5
8
|
declare const files: {
|
|
6
|
-
env: string;
|
|
7
9
|
appContext: string;
|
|
8
10
|
sharedErrors: string;
|
|
9
11
|
useCaseBuilder: string;
|
|
@@ -11,13 +13,11 @@ declare const files: {
|
|
|
11
13
|
authPort: string;
|
|
12
14
|
serverRoutes: string;
|
|
13
15
|
serverContext: string;
|
|
14
|
-
server: string;
|
|
15
16
|
apiCatchAllRoute: string;
|
|
16
17
|
healthRoute: string;
|
|
17
18
|
devtoolsRoute: string;
|
|
18
19
|
openApiRoute: string;
|
|
19
20
|
authRoute: string;
|
|
20
|
-
betterAuth: string;
|
|
21
21
|
apiLayout: string;
|
|
22
22
|
apiPage: string;
|
|
23
23
|
apiClientIndex: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/templates/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/templates/server.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAErB,wBAAgB,eAAe,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA4C5D;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAwClD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA2ChE;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA0ChD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAmFvD;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAiDnD;AAED,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;CAkRV,CAAC;AAEF,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,CAAC"}
|
package/dist/templates/server.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { databaseLocalUrl } from "../choices.js";
|
|
2
|
+
import { databaseDescriptor, hasIntegration, } from "./shared.js";
|
|
2
3
|
export function serverProviders(ctx) {
|
|
4
|
+
const db = databaseDescriptor(ctx);
|
|
3
5
|
const imports = [
|
|
4
6
|
'import type { beignetServerOnly } from "@beignet/core/server-only";',
|
|
5
7
|
'import { createDevtoolsProvider } from "@beignet/devtools";',
|
|
6
8
|
'import { createAuthBetterAuthProvider } from "@beignet/provider-auth-better-auth";',
|
|
7
|
-
|
|
9
|
+
`import { ${db.providerFactory} } from "@beignet/provider-db-drizzle/${db.subpath}";`,
|
|
8
10
|
hasIntegration(ctx, "inngest")
|
|
9
11
|
? 'import { inngestProvider } from "@beignet/provider-inngest";'
|
|
10
12
|
: undefined,
|
|
@@ -24,7 +26,7 @@ export function serverProviders(ctx) {
|
|
|
24
26
|
"\tcreateDevtoolsProvider(),",
|
|
25
27
|
"\tcreateAuthBetterAuthProvider<AuthUser, AuthSessionMetadata>(auth),",
|
|
26
28
|
"\tloggerPinoProvider,",
|
|
27
|
-
|
|
29
|
+
`\t${db.providerInstance},`,
|
|
28
30
|
"\tstarterDatabaseProvider,",
|
|
29
31
|
hasIntegration(ctx, "inngest") ? "\tinngestProvider," : undefined,
|
|
30
32
|
hasIntegration(ctx, "resend") ? "\tmailResendProvider," : undefined,
|
|
@@ -34,7 +36,7 @@ export function serverProviders(ctx) {
|
|
|
34
36
|
].filter((entry) => Boolean(entry));
|
|
35
37
|
return `${imports.join("\n")}
|
|
36
38
|
|
|
37
|
-
const
|
|
39
|
+
const ${db.providerInstance} = ${db.providerFactory}({ schema });
|
|
38
40
|
|
|
39
41
|
export const providers = [
|
|
40
42
|
${entries.join("\n")}
|
|
@@ -124,8 +126,14 @@ ${deferred.join("\n")}
|
|
|
124
126
|
});
|
|
125
127
|
`;
|
|
126
128
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
export function env(ctx) {
|
|
130
|
+
const databaseEnvLines = ctx.database === "sqlite"
|
|
131
|
+
? `\t\tSQLITE_DB_URL: z.string().default("file:local.db"),
|
|
132
|
+
\t\tSQLITE_DB_AUTH_TOKEN: z.string().optional(),`
|
|
133
|
+
: `\t\t${databaseDescriptor(ctx).urlEnvVar}: z
|
|
134
|
+
\t\t\t.string()
|
|
135
|
+
\t\t\t.default("${databaseLocalUrl(ctx.database, ctx.name)}"),`;
|
|
136
|
+
return `import { createEnv } from "@beignet/core/config";
|
|
129
137
|
import { z } from "zod";
|
|
130
138
|
|
|
131
139
|
const BooleanEnv = z.enum(["true", "false"]).transform((value) => value === "true");
|
|
@@ -143,8 +151,7 @@ export const env = createEnv({
|
|
|
143
151
|
.default("local-dev-better-auth-secret-change-me"),
|
|
144
152
|
BETTER_AUTH_URL: z.string().url().default("http://localhost:3000"),
|
|
145
153
|
BETTER_AUTH_TRUSTED_ORIGINS: z.string().optional(),
|
|
146
|
-
|
|
147
|
-
SQLITE_DB_AUTH_TOKEN: z.string().optional(),
|
|
154
|
+
${databaseEnvLines}
|
|
148
155
|
LOG_LEVEL: z
|
|
149
156
|
.enum(["trace", "debug", "info", "warn", "error", "fatal"])
|
|
150
157
|
.default("info"),
|
|
@@ -158,7 +165,140 @@ export const isProduction = env.NODE_ENV === "production";
|
|
|
158
165
|
|
|
159
166
|
export const isDevtoolsEnabled =
|
|
160
167
|
env.DEVTOOLS_ENABLED ?? process.env.NODE_ENV !== "production";
|
|
161
|
-
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
export function betterAuth(ctx) {
|
|
171
|
+
const connectionByDatabase = {
|
|
172
|
+
sqlite: `import { createClient } from "@libsql/client";
|
|
173
|
+
import { betterAuth } from "better-auth";
|
|
174
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
175
|
+
import { drizzle } from "drizzle-orm/libsql";
|
|
176
|
+
import { ensureDatabaseReady } from "@/infra/db/database-ready";
|
|
177
|
+
import * as schema from "@/infra/db/schema";
|
|
178
|
+
import { env } from "@/lib/env";
|
|
179
|
+
|
|
180
|
+
const client = createClient({
|
|
181
|
+
url: env.SQLITE_DB_URL,
|
|
182
|
+
authToken: env.SQLITE_DB_AUTH_TOKEN,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Auth routes can be the first thing to touch the database, before any
|
|
186
|
+
// Beignet provider boots, so readiness is enforced here too.
|
|
187
|
+
await ensureDatabaseReady(client);
|
|
188
|
+
|
|
189
|
+
const db = drizzle(client, { schema });`,
|
|
190
|
+
postgres: `import { betterAuth } from "better-auth";
|
|
191
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
192
|
+
import { drizzle } from "drizzle-orm/node-postgres";
|
|
193
|
+
import pg from "pg";
|
|
194
|
+
import { ensureDatabaseReady } from "@/infra/db/database-ready";
|
|
195
|
+
import * as schema from "@/infra/db/schema";
|
|
196
|
+
import { env } from "@/lib/env";
|
|
197
|
+
|
|
198
|
+
const pool = new pg.Pool({ connectionString: env.POSTGRES_DB_URL });
|
|
199
|
+
|
|
200
|
+
// Auth routes can be the first thing to touch the database, before any
|
|
201
|
+
// Beignet provider boots, so readiness is enforced here too.
|
|
202
|
+
await ensureDatabaseReady(pool);
|
|
203
|
+
|
|
204
|
+
const db = drizzle(pool, { schema });`,
|
|
205
|
+
mysql: `import { betterAuth } from "better-auth";
|
|
206
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
207
|
+
import { drizzle } from "drizzle-orm/mysql2";
|
|
208
|
+
import mysql from "mysql2/promise";
|
|
209
|
+
import { ensureDatabaseReady } from "@/infra/db/database-ready";
|
|
210
|
+
import * as schema from "@/infra/db/schema";
|
|
211
|
+
import { env } from "@/lib/env";
|
|
212
|
+
|
|
213
|
+
const pool = mysql.createPool({ uri: env.MYSQL_DB_URL });
|
|
214
|
+
|
|
215
|
+
// Auth routes can be the first thing to touch the database, before any
|
|
216
|
+
// Beignet provider boots, so readiness is enforced here too.
|
|
217
|
+
await ensureDatabaseReady(pool);
|
|
218
|
+
|
|
219
|
+
const db = drizzle(pool, { schema, mode: "default" });`,
|
|
220
|
+
};
|
|
221
|
+
return `${connectionByDatabase[ctx.database]}
|
|
222
|
+
|
|
223
|
+
const trustedOrigins = [
|
|
224
|
+
env.APP_URL,
|
|
225
|
+
env.BETTER_AUTH_URL,
|
|
226
|
+
...(env.BETTER_AUTH_TRUSTED_ORIGINS?.split(",")
|
|
227
|
+
.map((origin) => origin.trim())
|
|
228
|
+
.filter(Boolean) ?? []),
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
export const auth = betterAuth({
|
|
232
|
+
baseURL: env.BETTER_AUTH_URL,
|
|
233
|
+
secret: env.BETTER_AUTH_SECRET,
|
|
234
|
+
trustedOrigins: [...new Set(trustedOrigins)],
|
|
235
|
+
database: drizzleAdapter(db, {
|
|
236
|
+
provider: "${databaseDescriptor(ctx).betterAuthProvider}",
|
|
237
|
+
schema,
|
|
238
|
+
}),
|
|
239
|
+
emailAndPassword: {
|
|
240
|
+
enabled: true,
|
|
241
|
+
},
|
|
242
|
+
user: {
|
|
243
|
+
changeEmail: {
|
|
244
|
+
enabled: true,
|
|
245
|
+
},
|
|
246
|
+
deleteUser: {
|
|
247
|
+
enabled: true,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
export function server(ctx) {
|
|
254
|
+
const db = databaseDescriptor(ctx);
|
|
255
|
+
const providerConfigEntries = ctx.database === "sqlite"
|
|
256
|
+
? `\t\t"drizzle-sqlite": {
|
|
257
|
+
\t\t\tDB_URL: env.SQLITE_DB_URL,
|
|
258
|
+
\t\t\tDB_AUTH_TOKEN: env.SQLITE_DB_AUTH_TOKEN,
|
|
259
|
+
\t\t},`
|
|
260
|
+
: `\t\t"${db.providerName}": {
|
|
261
|
+
\t\t\tDB_URL: env.${db.urlEnvVar},
|
|
262
|
+
\t\t},`;
|
|
263
|
+
return `import type { beignetServerOnly } from "@beignet/core/server-only";
|
|
264
|
+
import { createNextServer } from "@beignet/next";
|
|
265
|
+
import { createIdempotencyHooks } from "@beignet/core/server";
|
|
266
|
+
import type { AppContext } from "@/app-context";
|
|
267
|
+
import { appPorts } from "@/infra/app-ports";
|
|
268
|
+
import { env } from "@/lib/env";
|
|
269
|
+
import { appContext } from "./context";
|
|
270
|
+
import { providers } from "./providers";
|
|
271
|
+
import { routes } from "./routes";
|
|
272
|
+
|
|
273
|
+
export const server = await createNextServer({
|
|
274
|
+
ports: appPorts,
|
|
275
|
+
providers,
|
|
276
|
+
providerConfig: {
|
|
277
|
+
${providerConfigEntries}
|
|
278
|
+
},
|
|
279
|
+
hooks: [createIdempotencyHooks<AppContext>()],
|
|
280
|
+
context: appContext,
|
|
281
|
+
routes,
|
|
282
|
+
mapUnhandledError: ({ err, ctx }) => {
|
|
283
|
+
ctx?.ports.logger.error("Unhandled API error", {
|
|
284
|
+
error: err,
|
|
285
|
+
requestId: ctx?.requestId,
|
|
286
|
+
environment: env.NODE_ENV,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
status: 500,
|
|
291
|
+
body: {
|
|
292
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
293
|
+
message: "Internal server error",
|
|
294
|
+
requestId: ctx?.requestId,
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
`;
|
|
300
|
+
}
|
|
301
|
+
const files = {
|
|
162
302
|
appContext: `import type { ActivityActor, ActivityTenant } from "@beignet/core/ports";
|
|
163
303
|
import type { InferProviderPorts } from "@beignet/core/providers";
|
|
164
304
|
import type { TraceContext } from "@beignet/core/tracing";
|
|
@@ -321,46 +461,6 @@ export const appContext = defineServerContext<AppContext, AppRuntimePorts>()({
|
|
|
321
461
|
tenant: createTenant(input?.tenantId ?? "tenant_default"),
|
|
322
462
|
}),
|
|
323
463
|
});
|
|
324
|
-
`,
|
|
325
|
-
server: `import type { beignetServerOnly } from "@beignet/core/server-only";
|
|
326
|
-
import { createNextServer } from "@beignet/next";
|
|
327
|
-
import { createIdempotencyHooks } from "@beignet/core/server";
|
|
328
|
-
import type { AppContext } from "@/app-context";
|
|
329
|
-
import { appPorts } from "@/infra/app-ports";
|
|
330
|
-
import { env } from "@/lib/env";
|
|
331
|
-
import { appContext } from "./context";
|
|
332
|
-
import { providers } from "./providers";
|
|
333
|
-
import { routes } from "./routes";
|
|
334
|
-
|
|
335
|
-
export const server = await createNextServer({
|
|
336
|
-
ports: appPorts,
|
|
337
|
-
providers,
|
|
338
|
-
providerConfig: {
|
|
339
|
-
"drizzle-sqlite": {
|
|
340
|
-
DB_URL: env.SQLITE_DB_URL,
|
|
341
|
-
DB_AUTH_TOKEN: env.SQLITE_DB_AUTH_TOKEN,
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
hooks: [createIdempotencyHooks<AppContext>()],
|
|
345
|
-
context: appContext,
|
|
346
|
-
routes,
|
|
347
|
-
mapUnhandledError: ({ err, ctx }) => {
|
|
348
|
-
ctx?.ports.logger.error("Unhandled API error", {
|
|
349
|
-
error: err,
|
|
350
|
-
requestId: ctx?.requestId,
|
|
351
|
-
environment: env.NODE_ENV,
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
return {
|
|
355
|
-
status: 500,
|
|
356
|
-
body: {
|
|
357
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
358
|
-
message: "Internal server error",
|
|
359
|
-
requestId: ctx?.requestId,
|
|
360
|
-
},
|
|
361
|
-
};
|
|
362
|
-
},
|
|
363
|
-
});
|
|
364
464
|
`,
|
|
365
465
|
apiCatchAllRoute: `import { server } from "@/server";
|
|
366
466
|
|
|
@@ -410,54 +510,6 @@ export const GET = createOpenAPIHandler(server.contracts, {
|
|
|
410
510
|
import { auth } from "@/lib/better-auth";
|
|
411
511
|
|
|
412
512
|
export const { GET, POST } = toNextJsHandler(auth);
|
|
413
|
-
`,
|
|
414
|
-
betterAuth: `import { createClient } from "@libsql/client";
|
|
415
|
-
import { betterAuth } from "better-auth";
|
|
416
|
-
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
417
|
-
import { drizzle } from "drizzle-orm/libsql";
|
|
418
|
-
import { ensureDatabaseReady } from "@/infra/db/database-ready";
|
|
419
|
-
import * as schema from "@/infra/db/schema";
|
|
420
|
-
import { env } from "@/lib/env";
|
|
421
|
-
|
|
422
|
-
const client = createClient({
|
|
423
|
-
url: env.SQLITE_DB_URL,
|
|
424
|
-
authToken: env.SQLITE_DB_AUTH_TOKEN,
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
// Auth routes can be the first thing to touch the database, before any
|
|
428
|
-
// Beignet provider boots, so readiness is enforced here too.
|
|
429
|
-
await ensureDatabaseReady(client);
|
|
430
|
-
|
|
431
|
-
const db = drizzle(client, { schema });
|
|
432
|
-
|
|
433
|
-
const trustedOrigins = [
|
|
434
|
-
env.APP_URL,
|
|
435
|
-
env.BETTER_AUTH_URL,
|
|
436
|
-
...(env.BETTER_AUTH_TRUSTED_ORIGINS?.split(",")
|
|
437
|
-
.map((origin) => origin.trim())
|
|
438
|
-
.filter(Boolean) ?? []),
|
|
439
|
-
];
|
|
440
|
-
|
|
441
|
-
export const auth = betterAuth({
|
|
442
|
-
baseURL: env.BETTER_AUTH_URL,
|
|
443
|
-
secret: env.BETTER_AUTH_SECRET,
|
|
444
|
-
trustedOrigins: [...new Set(trustedOrigins)],
|
|
445
|
-
database: drizzleAdapter(db, {
|
|
446
|
-
provider: "sqlite",
|
|
447
|
-
schema,
|
|
448
|
-
}),
|
|
449
|
-
emailAndPassword: {
|
|
450
|
-
enabled: true,
|
|
451
|
-
},
|
|
452
|
-
user: {
|
|
453
|
-
changeEmail: {
|
|
454
|
-
enabled: true,
|
|
455
|
-
},
|
|
456
|
-
deleteUser: {
|
|
457
|
-
enabled: true,
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
513
|
`,
|
|
462
514
|
// API-only scaffold frontend: a minimal layout and landing page that point
|
|
463
515
|
// at the contract-backed API surface, plus a typed client without React
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/templates/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/templates/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,cAAc,GAEf,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,eAAe,CAAC,GAAoB;IAClD,MAAM,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG;QACd,qEAAqE;QACrE,6DAA6D;QAC7D,oFAAoF;QACpF,YAAY,EAAE,CAAC,eAAe,yCAAyC,EAAE,CAAC,OAAO,IAAI;QACrF,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC;YAC5B,CAAC,CAAC,8DAA8D;YACh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oBb;IACC,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBf;IACC,cAAc,EAAE;;;;;CAKjB;IACC,WAAW,EAAE;;;;;;;;;;;;;;;CAed;IACC,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BX;IACC,YAAY,EAAE;;;;;;;;;CASf;IACC,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DhB;IACC,gBAAgB,EAAE;;;;;;;;;CASnB;IACC,WAAW,EAAE;;;;;;;;;;;;;;;;CAgBd;IACC,aAAa,EAAE;;;;;;;;CAQhB;IACC,YAAY,EAAE;;;;;;;CAOf;IACC,SAAS,EAAE;;;;CAIZ;IACC,2EAA2E;IAC3E,wEAAwE;IACxE,4EAA4E;IAC5E,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;CAuBZ;IACC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BV;IACC,cAAc,EAAE;;;;;CAKjB;CACA,CAAC;AAEF,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IntegrationName, PackageManager } from "../choices.js";
|
|
1
|
+
import type { DatabaseName, IntegrationName, PackageManager } from "../choices.js";
|
|
2
2
|
/**
|
|
3
3
|
* One generated file emitted by the template generator.
|
|
4
4
|
*/
|
|
@@ -18,6 +18,10 @@ export type TemplateContext = {
|
|
|
18
18
|
*/
|
|
19
19
|
api: boolean;
|
|
20
20
|
integrations: IntegrationName[];
|
|
21
|
+
/**
|
|
22
|
+
* Database backing the starter's Drizzle persistence layer.
|
|
23
|
+
*/
|
|
24
|
+
database: DatabaseName;
|
|
21
25
|
};
|
|
22
26
|
export declare const externalVersions: {
|
|
23
27
|
next: string;
|
|
@@ -37,11 +41,40 @@ export declare const externalVersions: {
|
|
|
37
41
|
drizzleOrm: string;
|
|
38
42
|
inngest: string;
|
|
39
43
|
libsqlClient: string;
|
|
44
|
+
mysql2: string;
|
|
45
|
+
pg: string;
|
|
46
|
+
pglite: string;
|
|
40
47
|
pino: string;
|
|
41
48
|
resend: string;
|
|
49
|
+
typesPg: string;
|
|
42
50
|
upstashRateLimit: string;
|
|
43
51
|
upstashRedis: string;
|
|
44
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Dialect-specific names used when rendering database-aware templates.
|
|
55
|
+
*/
|
|
56
|
+
export type DatabaseDescriptor = {
|
|
57
|
+
name: DatabaseName;
|
|
58
|
+
/** `@beignet/provider-db-drizzle` subpath for this dialect. */
|
|
59
|
+
subpath: "sqlite" | "postgres" | "mysql";
|
|
60
|
+
/** Pascal-case dialect token in provider API names, e.g. `createDrizzle${apiToken}UnitOfWork`. */
|
|
61
|
+
apiToken: "Sqlite" | "Postgres" | "Mysql";
|
|
62
|
+
/** Drizzle database seam type exported from the provider subpath. */
|
|
63
|
+
databaseType: "DrizzleSqliteDatabase" | "DrizzlePostgresDatabase" | "DrizzleMysqlDatabase";
|
|
64
|
+
/** Provider factory exported from the provider subpath. */
|
|
65
|
+
providerFactory: "createDrizzleSqliteProvider" | "createDrizzlePostgresProvider" | "createDrizzleMysqlProvider";
|
|
66
|
+
/** Provider instance const wired in `server/providers.ts`. */
|
|
67
|
+
providerInstance: "drizzleSqliteProvider" | "drizzlePostgresProvider" | "drizzleMysqlProvider";
|
|
68
|
+
/** Runtime provider name used as the `providerConfig` key. */
|
|
69
|
+
providerName: "drizzle-sqlite" | "drizzle-postgres" | "drizzle-mysql";
|
|
70
|
+
/** Connection URL env var read by the provider and app env schema. */
|
|
71
|
+
urlEnvVar: "SQLITE_DB_URL" | "POSTGRES_DB_URL" | "MYSQL_DB_URL";
|
|
72
|
+
/** `drizzle.config.ts` dialect string. */
|
|
73
|
+
drizzleKitDialect: "sqlite" | "postgresql" | "mysql";
|
|
74
|
+
/** Better Auth drizzle adapter provider string. */
|
|
75
|
+
betterAuthProvider: "sqlite" | "pg" | "mysql";
|
|
76
|
+
};
|
|
77
|
+
export declare function databaseDescriptor(ctx: TemplateContext): DatabaseDescriptor;
|
|
45
78
|
export declare function packageRunner(ctx: TemplateContext): string;
|
|
46
79
|
export declare const integrationDeps: Record<IntegrationName, Record<string, string>>;
|
|
47
80
|
export declare function hasIntegration(ctx: TemplateContext, integration: IntegrationName): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/templates/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/templates/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACf,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,+DAA+D;IAC/D,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACzC,kGAAkG;IAClG,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAC1C,qEAAqE;IACrE,YAAY,EACR,uBAAuB,GACvB,yBAAyB,GACzB,sBAAsB,CAAC;IAC3B,2DAA2D;IAC3D,eAAe,EACX,6BAA6B,GAC7B,+BAA+B,GAC/B,4BAA4B,CAAC;IACjC,8DAA8D;IAC9D,gBAAgB,EACZ,uBAAuB,GACvB,yBAAyB,GACzB,sBAAsB,CAAC;IAC3B,8DAA8D;IAC9D,YAAY,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,eAAe,CAAC;IACtE,sEAAsE;IACtE,SAAS,EAAE,eAAe,GAAG,iBAAiB,GAAG,cAAc,CAAC;IAChE,0CAA0C;IAC1C,iBAAiB,EAAE,QAAQ,GAAG,YAAY,GAAG,OAAO,CAAC;IACrD,mDAAmD;IACnD,kBAAkB,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;CAC/C,CAAC;AAyCF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAW1D;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,eAAe,EACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAevB,CAAC;AAEF,wBAAgB,cAAc,CAC5B,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,eAAe,GAC3B,OAAO,CAET;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3C"}
|
package/dist/templates/shared.js
CHANGED
|
@@ -16,11 +16,56 @@ export const externalVersions = {
|
|
|
16
16
|
drizzleOrm: "^0.45.2",
|
|
17
17
|
inngest: "^3.0.0",
|
|
18
18
|
libsqlClient: "^0.14.0",
|
|
19
|
+
mysql2: "^3.12.0",
|
|
20
|
+
pg: "^8.13.0",
|
|
21
|
+
pglite: "^0.5.2",
|
|
19
22
|
pino: "^9.7.0",
|
|
20
23
|
resend: "^4.0.1",
|
|
24
|
+
typesPg: "^8.11.0",
|
|
21
25
|
upstashRateLimit: "^2.0.0",
|
|
22
26
|
upstashRedis: "^1.0.0",
|
|
23
27
|
};
|
|
28
|
+
const databaseDescriptors = {
|
|
29
|
+
sqlite: {
|
|
30
|
+
name: "sqlite",
|
|
31
|
+
subpath: "sqlite",
|
|
32
|
+
apiToken: "Sqlite",
|
|
33
|
+
databaseType: "DrizzleSqliteDatabase",
|
|
34
|
+
providerFactory: "createDrizzleSqliteProvider",
|
|
35
|
+
providerInstance: "drizzleSqliteProvider",
|
|
36
|
+
providerName: "drizzle-sqlite",
|
|
37
|
+
urlEnvVar: "SQLITE_DB_URL",
|
|
38
|
+
drizzleKitDialect: "sqlite",
|
|
39
|
+
betterAuthProvider: "sqlite",
|
|
40
|
+
},
|
|
41
|
+
postgres: {
|
|
42
|
+
name: "postgres",
|
|
43
|
+
subpath: "postgres",
|
|
44
|
+
apiToken: "Postgres",
|
|
45
|
+
databaseType: "DrizzlePostgresDatabase",
|
|
46
|
+
providerFactory: "createDrizzlePostgresProvider",
|
|
47
|
+
providerInstance: "drizzlePostgresProvider",
|
|
48
|
+
providerName: "drizzle-postgres",
|
|
49
|
+
urlEnvVar: "POSTGRES_DB_URL",
|
|
50
|
+
drizzleKitDialect: "postgresql",
|
|
51
|
+
betterAuthProvider: "pg",
|
|
52
|
+
},
|
|
53
|
+
mysql: {
|
|
54
|
+
name: "mysql",
|
|
55
|
+
subpath: "mysql",
|
|
56
|
+
apiToken: "Mysql",
|
|
57
|
+
databaseType: "DrizzleMysqlDatabase",
|
|
58
|
+
providerFactory: "createDrizzleMysqlProvider",
|
|
59
|
+
providerInstance: "drizzleMysqlProvider",
|
|
60
|
+
providerName: "drizzle-mysql",
|
|
61
|
+
urlEnvVar: "MYSQL_DB_URL",
|
|
62
|
+
drizzleKitDialect: "mysql",
|
|
63
|
+
betterAuthProvider: "mysql",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export function databaseDescriptor(ctx) {
|
|
67
|
+
return databaseDescriptors[ctx.database];
|
|
68
|
+
}
|
|
24
69
|
export function packageRunner(ctx) {
|
|
25
70
|
switch (ctx.packageManager) {
|
|
26
71
|
case "npm":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/templates/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/templates/shared.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,SAAS;IACnB,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,SAAS;IACrB,aAAa,EAAE,SAAS;IACxB,GAAG,EAAE,QAAQ;IACb,kBAAkB,EAAE,UAAU;IAC9B,iBAAiB,EAAE,QAAQ;IAC3B,aAAa,EAAE,SAAS;IACxB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,UAAU;IACtB,UAAU,EAAE,SAAS;IACrB,OAAO,EAAE,QAAQ;IACjB,YAAY,EAAE,SAAS;IACvB,MAAM,EAAE,SAAS;IACjB,EAAE,EAAE,SAAS;IACb,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,QAAQ;IAC1B,YAAY,EAAE,QAAQ;CACvB,CAAC;AAoCF,MAAM,mBAAmB,GAA6C;IACpE,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,uBAAuB;QACrC,eAAe,EAAE,6BAA6B;QAC9C,gBAAgB,EAAE,uBAAuB;QACzC,YAAY,EAAE,gBAAgB;QAC9B,SAAS,EAAE,eAAe;QAC1B,iBAAiB,EAAE,QAAQ;QAC3B,kBAAkB,EAAE,QAAQ;KAC7B;IACD,QAAQ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gBAAgB;QACvD,gBAAgB,EAAE,gBAAgB,CAAC,YAAY;KAChD;CACF,CAAC;AAEF,MAAM,UAAU,cAAc,CAC5B,GAAoB,EACpB,WAA4B;IAE5B,OAAO,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,KAAc;IACjC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beignet/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for creating and maintaining Beignet apps.",
|
|
6
6
|
"main": "./dist/lib.js",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"typescript": "^5.3.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@beignet/core": "^0.0.
|
|
69
|
+
"@beignet/core": "^0.0.10",
|
|
70
70
|
"@clack/prompts": "^1.5.1",
|
|
71
71
|
"@stricli/core": "^1.2.7",
|
|
72
72
|
"jiti": "^2.7.0"
|