create-better-t-stack 3.6.2 → 3.6.4
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/dist/index.js +1 -1
- package/dist/{src-D7BpMan5.js → src-DON9UROB.js} +31 -79
- package/package.json +1 -1
- package/templates/backend/convex/packages/backend/package.json.hbs +1 -3
- package/templates/db/prisma/postgres/prisma.config.ts.hbs +0 -2
- package/templates/db/prisma/postgres/src/index.ts.hbs +18 -0
- package/templates/frontend/native/uniwind/app/(drawer)/index.tsx.hbs +40 -2
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as router, i as init, n as createBtsCli, o as sponsors, r as docs, t as builder } from "./src-
|
|
2
|
+
import { a as router, i as init, n as createBtsCli, o as sponsors, r as docs, t as builder } from "./src-DON9UROB.js";
|
|
3
3
|
|
|
4
4
|
export { builder, createBtsCli, docs, init, router, sponsors };
|
|
@@ -88,6 +88,7 @@ const dependencyVersionMap = {
|
|
|
88
88
|
"@prisma/adapter-better-sqlite3": "^7.0.0",
|
|
89
89
|
"@prisma/adapter-pg": "^7.0.0",
|
|
90
90
|
"@prisma/adapter-planetscale": "^7.0.0",
|
|
91
|
+
"@prisma/adapter-ppg": "^7.0.0",
|
|
91
92
|
mongoose: "^8.14.0",
|
|
92
93
|
"vite-plugin-pwa": "^1.0.1",
|
|
93
94
|
"@vite-pwa/assets-generator": "^1.0.0",
|
|
@@ -129,12 +130,12 @@ const dependencyVersionMap = {
|
|
|
129
130
|
"@trpc/server": "^11.5.0",
|
|
130
131
|
"@trpc/client": "^11.5.0",
|
|
131
132
|
next: "15.5.4",
|
|
132
|
-
convex: "^1.
|
|
133
|
-
"@convex-dev/react-query": "^0.
|
|
134
|
-
"convex-svelte": "^0.0.
|
|
133
|
+
convex: "^1.29.3",
|
|
134
|
+
"@convex-dev/react-query": "^0.1.0",
|
|
135
|
+
"convex-svelte": "^0.0.12",
|
|
135
136
|
"convex-nuxt": "0.1.5",
|
|
136
137
|
"convex-vue": "^0.1.5",
|
|
137
|
-
"@convex-dev/better-auth": "^0.9.
|
|
138
|
+
"@convex-dev/better-auth": "^0.9.7",
|
|
138
139
|
"@tanstack/svelte-query": "^5.85.3",
|
|
139
140
|
"@tanstack/svelte-query-devtools": "^5.85.3",
|
|
140
141
|
"@tanstack/vue-query-devtools": "^5.90.2",
|
|
@@ -4242,7 +4243,13 @@ async function setupApi(config) {
|
|
|
4242
4243
|
//#region src/helpers/core/backend-setup.ts
|
|
4243
4244
|
async function setupBackendDependencies(config) {
|
|
4244
4245
|
const { backend, runtime, api, auth, examples, projectDir } = config;
|
|
4245
|
-
if (backend === "convex")
|
|
4246
|
+
if (backend === "convex") {
|
|
4247
|
+
await addPackageDependency({
|
|
4248
|
+
dependencies: ["convex"],
|
|
4249
|
+
projectDir: path.join(projectDir, "packages/backend")
|
|
4250
|
+
});
|
|
4251
|
+
return;
|
|
4252
|
+
}
|
|
4246
4253
|
const framework = backend;
|
|
4247
4254
|
const serverDir = path.join(projectDir, "apps/server");
|
|
4248
4255
|
const dependencies = [];
|
|
@@ -4350,12 +4357,12 @@ async function setupAuth(config) {
|
|
|
4350
4357
|
if (convexBackendDirExists) {
|
|
4351
4358
|
await addPackageDependency({
|
|
4352
4359
|
dependencies: ["better-auth", "@convex-dev/better-auth"],
|
|
4353
|
-
customDependencies: { "better-auth": "1.3.
|
|
4360
|
+
customDependencies: { "better-auth": "1.3.34" },
|
|
4354
4361
|
projectDir: convexBackendDir
|
|
4355
4362
|
});
|
|
4356
4363
|
if (hasNativeForBA) await addPackageDependency({
|
|
4357
4364
|
dependencies: ["@better-auth/expo"],
|
|
4358
|
-
customDependencies: { "@better-auth/expo": "1.3.
|
|
4365
|
+
customDependencies: { "@better-auth/expo": "1.3.34" },
|
|
4359
4366
|
projectDir: convexBackendDir
|
|
4360
4367
|
});
|
|
4361
4368
|
}
|
|
@@ -4365,17 +4372,17 @@ async function setupAuth(config) {
|
|
|
4365
4372
|
const hasViteReactOther = frontend.some((f) => ["tanstack-router", "react-router"].includes(f));
|
|
4366
4373
|
if (hasNextJs) await addPackageDependency({
|
|
4367
4374
|
dependencies: ["better-auth", "@convex-dev/better-auth"],
|
|
4368
|
-
customDependencies: { "better-auth": "1.3.
|
|
4375
|
+
customDependencies: { "better-auth": "1.3.34" },
|
|
4369
4376
|
projectDir: clientDir
|
|
4370
4377
|
});
|
|
4371
4378
|
else if (hasTanStackStart) await addPackageDependency({
|
|
4372
4379
|
dependencies: ["better-auth", "@convex-dev/better-auth"],
|
|
4373
|
-
customDependencies: { "better-auth": "1.3.
|
|
4380
|
+
customDependencies: { "better-auth": "1.3.34" },
|
|
4374
4381
|
projectDir: clientDir
|
|
4375
4382
|
});
|
|
4376
4383
|
else if (hasViteReactOther) await addPackageDependency({
|
|
4377
4384
|
dependencies: ["better-auth", "@convex-dev/better-auth"],
|
|
4378
|
-
customDependencies: { "better-auth": "1.3.
|
|
4385
|
+
customDependencies: { "better-auth": "1.3.34" },
|
|
4379
4386
|
projectDir: clientDir
|
|
4380
4387
|
});
|
|
4381
4388
|
}
|
|
@@ -4389,8 +4396,8 @@ async function setupAuth(config) {
|
|
|
4389
4396
|
"@convex-dev/better-auth"
|
|
4390
4397
|
],
|
|
4391
4398
|
customDependencies: {
|
|
4392
|
-
"better-auth": "1.3.
|
|
4393
|
-
"@better-auth/expo": "1.3.
|
|
4399
|
+
"better-auth": "1.3.34",
|
|
4400
|
+
"@better-auth/expo": "1.3.34"
|
|
4394
4401
|
},
|
|
4395
4402
|
projectDir: nativeDir
|
|
4396
4403
|
});
|
|
@@ -5233,31 +5240,6 @@ async function setupWithCreateDb(serverDir, packageManager) {
|
|
|
5233
5240
|
return null;
|
|
5234
5241
|
}
|
|
5235
5242
|
}
|
|
5236
|
-
async function initPrismaDatabase(serverDir, packageManager) {
|
|
5237
|
-
try {
|
|
5238
|
-
const prismaDir = path.join(serverDir, "prisma");
|
|
5239
|
-
await fs.ensureDir(prismaDir);
|
|
5240
|
-
log.info("Starting Prisma PostgreSQL setup.");
|
|
5241
|
-
await execa(getPackageExecutionCommand(packageManager, "prisma init --db"), {
|
|
5242
|
-
cwd: serverDir,
|
|
5243
|
-
stdio: "inherit",
|
|
5244
|
-
shell: true
|
|
5245
|
-
});
|
|
5246
|
-
log.info(pc.yellow("Please copy the Prisma Postgres URL.\nIt looks like: postgresql://user:password@host:5432/db?sslmode=require"));
|
|
5247
|
-
const databaseUrl = await text({
|
|
5248
|
-
message: "Paste your Prisma Postgres database URL:",
|
|
5249
|
-
validate(value) {
|
|
5250
|
-
if (!value) return "Please enter a database URL";
|
|
5251
|
-
if (!value.startsWith("postgresql://")) return "URL should start with postgresql://";
|
|
5252
|
-
}
|
|
5253
|
-
});
|
|
5254
|
-
if (isCancel(databaseUrl)) return null;
|
|
5255
|
-
return { databaseUrl };
|
|
5256
|
-
} catch (error) {
|
|
5257
|
-
if (error instanceof Error) consola$1.error(error.message);
|
|
5258
|
-
return null;
|
|
5259
|
-
}
|
|
5260
|
-
}
|
|
5261
5243
|
async function writeEnvFile$1(projectDir, backend, config) {
|
|
5262
5244
|
try {
|
|
5263
5245
|
const targetApp = backend === "self" ? "apps/web" : "apps/server";
|
|
@@ -5277,16 +5259,6 @@ async function writeEnvFile$1(projectDir, backend, config) {
|
|
|
5277
5259
|
consola$1.error("Failed to update environment configuration");
|
|
5278
5260
|
}
|
|
5279
5261
|
}
|
|
5280
|
-
async function addDotenvImportToPrismaConfig(projectDir, backend) {
|
|
5281
|
-
try {
|
|
5282
|
-
const prismaConfigPath = path.join(projectDir, "packages/db/prisma.config.ts");
|
|
5283
|
-
let content = await fs.readFile(prismaConfigPath, "utf8");
|
|
5284
|
-
content = `import dotenv from "dotenv";\ndotenv.config({ path: "${backend === "self" ? "../../apps/web/.env" : "../../apps/server/.env"}" });\n${content}`;
|
|
5285
|
-
await fs.writeFile(prismaConfigPath, content);
|
|
5286
|
-
} catch (_error) {
|
|
5287
|
-
consola$1.error("Failed to update prisma.config.ts");
|
|
5288
|
-
}
|
|
5289
|
-
}
|
|
5290
5262
|
function displayManualSetupInstructions$1(target) {
|
|
5291
5263
|
log.info(`Manual Prisma PostgreSQL Setup Instructions:
|
|
5292
5264
|
|
|
@@ -5298,7 +5270,7 @@ function displayManualSetupInstructions$1(target) {
|
|
|
5298
5270
|
DATABASE_URL="your_database_url"`);
|
|
5299
5271
|
}
|
|
5300
5272
|
async function setupPrismaPostgres(config, cliInput) {
|
|
5301
|
-
const { packageManager, projectDir,
|
|
5273
|
+
const { packageManager, projectDir, backend } = config;
|
|
5302
5274
|
const manualDb = cliInput?.manualDb ?? false;
|
|
5303
5275
|
const dbDir = path.join(projectDir, "packages/db");
|
|
5304
5276
|
try {
|
|
@@ -5308,47 +5280,28 @@ async function setupPrismaPostgres(config, cliInput) {
|
|
|
5308
5280
|
displayManualSetupInstructions$1(backend === "self" ? "apps/web" : "apps/server");
|
|
5309
5281
|
return;
|
|
5310
5282
|
}
|
|
5311
|
-
const
|
|
5283
|
+
const setupMode = await select({
|
|
5312
5284
|
message: "Prisma Postgres setup: choose mode",
|
|
5313
5285
|
options: [{
|
|
5314
|
-
label: "Automatic",
|
|
5286
|
+
label: "Automatic (create-db)",
|
|
5315
5287
|
value: "auto",
|
|
5316
|
-
hint: "
|
|
5288
|
+
hint: "Provision a database via Prisma's create-db CLI"
|
|
5317
5289
|
}, {
|
|
5318
5290
|
label: "Manual",
|
|
5319
5291
|
value: "manual",
|
|
5320
|
-
hint: "
|
|
5292
|
+
hint: "Add your own DATABASE_URL later"
|
|
5321
5293
|
}],
|
|
5322
5294
|
initialValue: "auto"
|
|
5323
5295
|
});
|
|
5324
|
-
if (isCancel(
|
|
5325
|
-
if (
|
|
5296
|
+
if (isCancel(setupMode)) return;
|
|
5297
|
+
if (setupMode === "manual") {
|
|
5326
5298
|
await writeEnvFile$1(projectDir, backend);
|
|
5327
5299
|
displayManualSetupInstructions$1(backend === "self" ? "apps/web" : "apps/server");
|
|
5328
5300
|
return;
|
|
5329
5301
|
}
|
|
5330
|
-
const
|
|
5331
|
-
label: "Quick setup with create-db",
|
|
5332
|
-
value: "create-db",
|
|
5333
|
-
hint: "Fastest, automated database creation (no auth)"
|
|
5334
|
-
}];
|
|
5335
|
-
if (orm === "prisma") setupOptions.push({
|
|
5336
|
-
label: "Custom setup with Prisma Init",
|
|
5337
|
-
value: "custom",
|
|
5338
|
-
hint: "More control (requires auth)"
|
|
5339
|
-
});
|
|
5340
|
-
const setupMethod = await select({
|
|
5341
|
-
message: "Choose your Prisma Postgres setup method:",
|
|
5342
|
-
options: setupOptions,
|
|
5343
|
-
initialValue: "create-db"
|
|
5344
|
-
});
|
|
5345
|
-
if (isCancel(setupMethod)) return exitCancelled("Operation cancelled");
|
|
5346
|
-
let prismaConfig = null;
|
|
5347
|
-
if (setupMethod === "create-db") prismaConfig = await setupWithCreateDb(dbDir, packageManager);
|
|
5348
|
-
else prismaConfig = await initPrismaDatabase(dbDir, packageManager);
|
|
5302
|
+
const prismaConfig = await setupWithCreateDb(dbDir, packageManager);
|
|
5349
5303
|
if (prismaConfig) {
|
|
5350
5304
|
await writeEnvFile$1(projectDir, backend, prismaConfig);
|
|
5351
|
-
if (orm === "prisma") await addDotenvImportToPrismaConfig(projectDir, backend);
|
|
5352
5305
|
log.success(pc.green("Prisma Postgres database configured successfully!"));
|
|
5353
5306
|
if (prismaConfig.claimUrl) log.info(pc.blue(`Claim URL saved to .env: ${prismaConfig.claimUrl}`));
|
|
5354
5307
|
} else {
|
|
@@ -5765,7 +5718,8 @@ async function setupDatabase(config, cliInput) {
|
|
|
5765
5718
|
else if (database === "postgres") if (dbSetup === "neon") {
|
|
5766
5719
|
prismaDependencies.push("@prisma/adapter-neon", "@neondatabase/serverless", "ws");
|
|
5767
5720
|
prismaDevDependencies.push("@types/ws");
|
|
5768
|
-
} else
|
|
5721
|
+
} else if (dbSetup === "prisma-postgres") prismaDependencies.push("@prisma/adapter-ppg");
|
|
5722
|
+
else {
|
|
5769
5723
|
prismaDependencies.push("@prisma/adapter-pg");
|
|
5770
5724
|
prismaDependencies.push("pg");
|
|
5771
5725
|
prismaDevDependencies.push("@types/pg");
|
|
@@ -6815,11 +6769,9 @@ async function createProject(options, cliInput) {
|
|
|
6815
6769
|
await setupAddonsTemplate(projectDir, options);
|
|
6816
6770
|
await setupDeploymentTemplates(projectDir, options);
|
|
6817
6771
|
await setupApi(options);
|
|
6772
|
+
if (isConvex || needsServerSetup) await setupBackendDependencies(options);
|
|
6818
6773
|
if (!isConvex) {
|
|
6819
|
-
if (needsServerSetup)
|
|
6820
|
-
await setupBackendDependencies(options);
|
|
6821
|
-
await setupRuntime(options);
|
|
6822
|
-
}
|
|
6774
|
+
if (needsServerSetup) await setupRuntime(options);
|
|
6823
6775
|
await setupDatabase(options, cliInput);
|
|
6824
6776
|
if (options.examples.length > 0 && options.examples[0] !== "none") await setupExamples(options);
|
|
6825
6777
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { defineConfig, env } from 'prisma/config'
|
|
3
|
-
{{#unless (eq dbSetup "prisma-postgres")}}
|
|
4
3
|
import dotenv from 'dotenv'
|
|
5
4
|
|
|
6
5
|
dotenv.config({
|
|
@@ -10,7 +9,6 @@ dotenv.config({
|
|
|
10
9
|
path: "../../apps/server/.env",
|
|
11
10
|
{{/if}}
|
|
12
11
|
})
|
|
13
|
-
{{/unless}}
|
|
14
12
|
|
|
15
13
|
export default defineConfig({
|
|
16
14
|
schema: path.join("prisma", "schema"),
|
|
@@ -13,6 +13,15 @@ const prisma = new PrismaClient({
|
|
|
13
13
|
}),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
+
{{else if (eq dbSetup "prisma-postgres")}}
|
|
17
|
+
import { PrismaPostgresAdapter } from "@prisma/adapter-ppg";
|
|
18
|
+
|
|
19
|
+
const adapter = new PrismaPostgresAdapter({
|
|
20
|
+
connectionString: env.DATABASE_URL || "",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const prisma = new PrismaClient({ adapter });
|
|
24
|
+
|
|
16
25
|
{{else}}
|
|
17
26
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
18
27
|
|
|
@@ -38,6 +47,15 @@ const adapter = new PrismaNeon({
|
|
|
38
47
|
|
|
39
48
|
const prisma = new PrismaClient({ adapter });
|
|
40
49
|
|
|
50
|
+
{{else if (eq dbSetup "prisma-postgres")}}
|
|
51
|
+
import { PrismaPostgresAdapter } from "@prisma/adapter-ppg";
|
|
52
|
+
|
|
53
|
+
const adapter = new PrismaPostgresAdapter({
|
|
54
|
+
connectionString: process.env.DATABASE_URL || "",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const prisma = new PrismaClient({ adapter });
|
|
58
|
+
|
|
41
59
|
{{else}}
|
|
42
60
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
43
61
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Text, View } from "react-native";
|
|
1
|
+
import { Text, View, TouchableOpacity } from "react-native";
|
|
2
2
|
import { Container } from "@/components/container";
|
|
3
3
|
{{#if (eq api "orpc")}}
|
|
4
4
|
import { useQuery } from "@tanstack/react-query";
|
|
@@ -24,7 +24,7 @@ import { SignUp } from "@/components/sign-up";
|
|
|
24
24
|
import { useQuery } from "convex/react";
|
|
25
25
|
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
|
26
26
|
{{/if}}
|
|
27
|
-
{{#unless (eq backend "none")}}
|
|
27
|
+
{{#unless (or (eq backend "none") (and (eq backend "convex") (eq auth "better-auth")))}}
|
|
28
28
|
import { Ionicons } from "@expo/vector-icons";
|
|
29
29
|
{{/unless}}
|
|
30
30
|
import { Card, Chip, useThemeColor } from "heroui-native";
|
|
@@ -142,6 +142,44 @@ return (
|
|
|
142
142
|
<Text className="text-muted">Loading...</Text>
|
|
143
143
|
</AuthLoading>
|
|
144
144
|
{{/if}}
|
|
145
|
+
|
|
146
|
+
{{#if (and (eq backend "convex") (eq auth "better-auth"))}}
|
|
147
|
+
{user ? (
|
|
148
|
+
<Card variant="secondary" className="p-4 mb-4">
|
|
149
|
+
<View className="mb-2">
|
|
150
|
+
<Text className="text-foreground text-base">
|
|
151
|
+
Welcome, <Text className="font-semibold">{user.name}</Text>
|
|
152
|
+
</Text>
|
|
153
|
+
</View>
|
|
154
|
+
<Text className="text-muted text-sm mb-4">{user.email}</Text>
|
|
155
|
+
<TouchableOpacity className="bg-danger px-4 py-2 rounded-md self-start" onPress={()=> {
|
|
156
|
+
authClient.signOut();
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<Text className="text-danger-foreground font-medium">Sign Out</Text>
|
|
160
|
+
</TouchableOpacity>
|
|
161
|
+
</Card>
|
|
162
|
+
) : null}
|
|
163
|
+
<Card variant="secondary" className="p-4 mb-4">
|
|
164
|
+
<Text className="text-foreground font-medium mb-2">API Status</Text>
|
|
165
|
+
<View className="flex-row items-center gap-2">
|
|
166
|
+
<View className={`w-3 h-3 rounded-full ${healthCheck==="OK" ? "bg-success" : "bg-danger" }`} />
|
|
167
|
+
<Text className="text-muted">
|
|
168
|
+
{healthCheck === undefined
|
|
169
|
+
? "Checking..."
|
|
170
|
+
: healthCheck === "OK"
|
|
171
|
+
? "Connected to API"
|
|
172
|
+
: "API Disconnected"}
|
|
173
|
+
</Text>
|
|
174
|
+
</View>
|
|
175
|
+
</Card>
|
|
176
|
+
{!user && (
|
|
177
|
+
<>
|
|
178
|
+
<SignIn />
|
|
179
|
+
<SignUp />
|
|
180
|
+
</>
|
|
181
|
+
)}
|
|
182
|
+
{{/if}}
|
|
145
183
|
</Container>
|
|
146
184
|
);
|
|
147
185
|
}
|