create-better-t-stack 3.1.5-canary.b53fc7d5 → 3.1.6
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-AeW2CVNz.js → src-DeOVz-ZI.js} +3 -3
- package/package.json +1 -1
- package/templates/auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +27 -19
- package/templates/payments/polar/web/react/tanstack-start/src/functions/get-payment.ts.hbs +15 -0
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1388,7 +1388,7 @@ const getLatestCLIVersion = () => {
|
|
|
1388
1388
|
*/
|
|
1389
1389
|
function isTelemetryEnabled() {
|
|
1390
1390
|
const BTS_TELEMETRY_DISABLED = process.env.BTS_TELEMETRY_DISABLED;
|
|
1391
|
-
const BTS_TELEMETRY = "
|
|
1391
|
+
const BTS_TELEMETRY = "1";
|
|
1392
1392
|
if (BTS_TELEMETRY_DISABLED !== void 0) return BTS_TELEMETRY_DISABLED !== "1";
|
|
1393
1393
|
if (BTS_TELEMETRY !== void 0) return BTS_TELEMETRY === "1";
|
|
1394
1394
|
return true;
|
|
@@ -1396,8 +1396,8 @@ function isTelemetryEnabled() {
|
|
|
1396
1396
|
|
|
1397
1397
|
//#endregion
|
|
1398
1398
|
//#region src/utils/analytics.ts
|
|
1399
|
-
const POSTHOG_API_KEY = "
|
|
1400
|
-
const POSTHOG_HOST = "
|
|
1399
|
+
const POSTHOG_API_KEY = "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs";
|
|
1400
|
+
const POSTHOG_HOST = "https://us.i.posthog.com";
|
|
1401
1401
|
function generateSessionId() {
|
|
1402
1402
|
const rand = Math.random().toString(36).slice(2);
|
|
1403
1403
|
return `cli_${Date.now().toString(36)}${rand}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -2,6 +2,7 @@ import { getUser } from "@/functions/get-user";
|
|
|
2
2
|
{{#if (eq payments "polar") }}
|
|
3
3
|
import { Button } from "@/components/ui/button";
|
|
4
4
|
import { authClient } from "@/lib/auth-client";
|
|
5
|
+
import { getPayment } from "@/functions/get-payment";
|
|
5
6
|
{{/if}}
|
|
6
7
|
{{#if (eq api "trpc") }}
|
|
7
8
|
import { useTRPC } from "@/utils/trpc";
|
|
@@ -17,7 +18,12 @@ export const Route = createFileRoute("/dashboard")({
|
|
|
17
18
|
component: RouteComponent,
|
|
18
19
|
beforeLoad: async () => {
|
|
19
20
|
const session = await getUser();
|
|
21
|
+
{{#if (eq payments "polar") }}
|
|
22
|
+
const customerState = await getPayment();
|
|
23
|
+
return { session, customerState };
|
|
24
|
+
{{else}}
|
|
20
25
|
return { session };
|
|
26
|
+
{{/if}}
|
|
21
27
|
},
|
|
22
28
|
loader: async ({ context }) => {
|
|
23
29
|
if (!context.session) {
|
|
@@ -25,12 +31,6 @@ export const Route = createFileRoute("/dashboard")({
|
|
|
25
31
|
to: "/login",
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
|
-
{{#if (eq payments "polar") }}
|
|
29
|
-
const { data: customerState } = await authClient.customer.state();
|
|
30
|
-
return { session: context.session, customerState };
|
|
31
|
-
{{else}}
|
|
32
|
-
return { session: context.session };
|
|
33
|
-
{{/if}}
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -47,7 +47,7 @@ function RouteComponent() {
|
|
|
47
47
|
|
|
48
48
|
{{#if (eq payments "polar") }}
|
|
49
49
|
const hasProSubscription = (customerState?.activeSubscriptions?.length ?? 0) > 0;
|
|
50
|
-
console.log("Active subscriptions:", customerState?.activeSubscriptions);
|
|
50
|
+
// For debugging: console.log("Active subscriptions:", customerState?.activeSubscriptions);
|
|
51
51
|
{{/if}}
|
|
52
52
|
|
|
53
53
|
return (
|
|
@@ -55,21 +55,29 @@ function RouteComponent() {
|
|
|
55
55
|
<h1>Dashboard</h1>
|
|
56
56
|
<p>Welcome {session?.user.name}</p>
|
|
57
57
|
{{#if (eq api "trpc") }}
|
|
58
|
-
|
|
58
|
+
<p>API: {privateData.data?.message}</p>
|
|
59
59
|
{{else if (eq api "orpc") }}
|
|
60
|
-
|
|
60
|
+
<p>API: {privateData.data?.message}</p>
|
|
61
61
|
{{/if}}
|
|
62
62
|
{{#if (eq payments "polar") }}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
<p>Plan: {hasProSubscription ? "Pro" : "Free"}</p>
|
|
64
|
+
{hasProSubscription ? (
|
|
65
|
+
<Button
|
|
66
|
+
onClick={async function handlePortal() {
|
|
67
|
+
await authClient.customer.portal();
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
Manage Subscription
|
|
71
|
+
</Button>
|
|
72
|
+
) : (
|
|
73
|
+
<Button
|
|
74
|
+
onClick={async function handleUpgrade() {
|
|
75
|
+
await authClient.checkout({ slug: "pro" });
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
Upgrade to Pro
|
|
79
|
+
</Button>
|
|
80
|
+
)}
|
|
73
81
|
{{/if}}
|
|
74
82
|
</div>
|
|
75
83
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { authClient } from "@/lib/auth-client";
|
|
2
|
+
import { authMiddleware } from "@/middleware/auth";
|
|
3
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { getRequestHeaders } from "@tanstack/react-start/server";
|
|
5
|
+
|
|
6
|
+
export const getPayment = createServerFn({ method: "GET" })
|
|
7
|
+
.middleware([authMiddleware])
|
|
8
|
+
.handler(async () => {
|
|
9
|
+
const { data: customerState } = await authClient.customer.state({
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
headers: getRequestHeaders()
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return customerState;
|
|
15
|
+
});
|