mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 20:37:44 +00:00
chore: use tsconfig monorepo setup (#4826)
This commit is contained in:
@@ -24,14 +24,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild --clean",
|
||||
"dev": "concurrently \"unbuild --watch\" \"npm run dev:types\"",
|
||||
"dev:types": "tsc --project tsconfig.declarations.json --watch",
|
||||
"build:types": "tsc --project tsconfig.declarations.json",
|
||||
"stub": "unbuild --stub",
|
||||
"test": "vitest",
|
||||
"bump": "bumpp",
|
||||
"prepare": "prisma generate --schema ./src/adapters/prisma-adapter/test/normal-tests/schema.prisma && prisma generate --schema ./src/adapters/prisma-adapter/test/number-id-tests/schema.prisma",
|
||||
"typecheck": "tsc --noEmit"
|
||||
"typecheck": "tsc --project tsconfig.json"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
|
||||
@@ -18,8 +18,7 @@ export const opts = ({
|
||||
}: {
|
||||
database: BetterAuthOptions["database"];
|
||||
isNumberIdTest: boolean;
|
||||
}) =>
|
||||
({
|
||||
}): BetterAuthOptions => ({
|
||||
database: database,
|
||||
user: {
|
||||
fields: {
|
||||
@@ -40,7 +39,7 @@ export const opts = ({
|
||||
useNumberId: isNumberIdTest,
|
||||
},
|
||||
},
|
||||
}) satisfies BetterAuthOptions;
|
||||
});
|
||||
|
||||
const sqlite = new Database(path.join(__dirname, "test.db"));
|
||||
const mysql = createPool("mysql://user:password@localhost:3306/better_auth");
|
||||
|
||||
@@ -29,7 +29,6 @@ import { kakao } from "./kakao";
|
||||
import { naver } from "./naver";
|
||||
import { line } from "./line";
|
||||
import { paypal } from "./paypal";
|
||||
import type { OAuthProvider } from "../oauth2";
|
||||
|
||||
export const socialProviders = {
|
||||
apple,
|
||||
@@ -62,11 +61,6 @@ export const socialProviders = {
|
||||
naver,
|
||||
line,
|
||||
paypal,
|
||||
} satisfies {
|
||||
[key: string]: (
|
||||
// todo: fix any here
|
||||
config: any,
|
||||
) => OAuthProvider;
|
||||
};
|
||||
|
||||
export const socialProviderList = Object.keys(socialProviders) as [
|
||||
|
||||
@@ -115,7 +115,7 @@ export async function getTestInstance<
|
||||
...options?.advanced,
|
||||
},
|
||||
plugins: [bearer(), ...(options?.plugins || [])],
|
||||
} as unknown as O extends undefined ? typeof opts : O & typeof opts);
|
||||
} as unknown as O);
|
||||
|
||||
const testUser = {
|
||||
email: "test@test.com",
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false,
|
||||
"composite": false,
|
||||
"target": "es2022",
|
||||
"incremental": true,
|
||||
"moduleResolution": "Bundler",
|
||||
"strict": true,
|
||||
"moduleDetection": "force",
|
||||
"module": "Preserve",
|
||||
"skipLibCheck": true,
|
||||
"types": ["node"],
|
||||
"isolatedModules": true,
|
||||
"preserveSymlinks": true,
|
||||
"noImplicitOverride": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/test/**/*.ts",
|
||||
"**/test-utils/**/*.ts"
|
||||
],
|
||||
"references": [],
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
@@ -1,25 +1,11 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "es2022",
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"module": "ESNext",
|
||||
"noEmit": true,
|
||||
"moduleResolution": "Bundler",
|
||||
"moduleDetection": "force",
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"composite": false,
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": ".tsbuildinfo",
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"downlevelIteration": true
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["esnext", "dom", "dom.iterable"],
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"types": ["node", "bun"]
|
||||
},
|
||||
"exclude": ["**/dist", "node_modules"],
|
||||
"references": [],
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"stub": "unbuild --stub",
|
||||
"start": "node ./dist/index.mjs",
|
||||
"dev": "tsx ./src/index.ts",
|
||||
"test": "vitest"
|
||||
"test": "vitest",
|
||||
"typecheck": "tsc --project tsconfig.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
@@ -33,6 +34,7 @@
|
||||
"exports": "./dist/index.mjs",
|
||||
"bin": "./dist/index.mjs",
|
||||
"devDependencies": {
|
||||
"@types/semver": "^7.7.1",
|
||||
"tsx": "^4.20.5",
|
||||
"typescript": "catalog:",
|
||||
"unbuild": "catalog:"
|
||||
@@ -54,6 +56,7 @@
|
||||
"dotenv": "^17.2.2",
|
||||
"drizzle-orm": "^0.33.0",
|
||||
"get-tsconfig": "^4.10.1",
|
||||
"jiti": "^2.6.0",
|
||||
"open": "^10.2.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prisma": "^5.22.0",
|
||||
|
||||
14
packages/cli/tsconfig.json
Normal file
14
packages/cli/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
}
|
||||
],
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -14,7 +14,8 @@
|
||||
"test": "vitest",
|
||||
"build": "unbuild --clean",
|
||||
"dev": "unbuild --watch",
|
||||
"stub": "unbuild --stub"
|
||||
"stub": "unbuild --stub",
|
||||
"typecheck": "tsc --project tsconfig.json"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
@@ -51,6 +52,7 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@better-fetch/fetch": "catalog:",
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"better-auth": "workspace:*",
|
||||
"better-sqlite3": "^12.2.0",
|
||||
"expo-constants": "~17.1.7",
|
||||
@@ -58,6 +60,7 @@
|
||||
"expo-linking": "~7.1.7",
|
||||
"expo-secure-store": "~14.2.3",
|
||||
"expo-web-browser": "~14.2.0",
|
||||
"react-native": "~0.80.2",
|
||||
"unbuild": "^3.6.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { BetterAuthClientPlugin, Store } from "better-auth/types";
|
||||
import type { BetterAuthClientPlugin, Store } from "better-auth/types";
|
||||
import * as Linking from "expo-linking";
|
||||
import { Platform } from "react-native";
|
||||
import Constants from "expo-constants";
|
||||
import { BetterFetchOption } from "@better-fetch/fetch";
|
||||
import type { BetterFetchOption } from "@better-fetch/fetch";
|
||||
|
||||
interface CookieAttributes {
|
||||
value: string;
|
||||
@@ -23,15 +23,15 @@ export function parseSetCookieHeader(
|
||||
cookies.forEach((cookie) => {
|
||||
const parts = cookie.split(";").map((p) => p.trim());
|
||||
const [nameValue, ...attributes] = parts;
|
||||
const [name, ...valueParts] = nameValue.split("=");
|
||||
const [name, ...valueParts] = nameValue!.split("=");
|
||||
const value = valueParts.join("=");
|
||||
const cookieObj: CookieAttributes = { value };
|
||||
attributes.forEach((attr) => {
|
||||
const [attrName, ...attrValueParts] = attr.split("=");
|
||||
const attrValue = attrValueParts.join("=");
|
||||
cookieObj[attrName.toLowerCase() as "value"] = attrValue;
|
||||
cookieObj[attrName!.toLowerCase() as "value"] = attrValue;
|
||||
});
|
||||
cookieMap.set(name, cookieObj);
|
||||
cookieMap.set(name!, cookieObj);
|
||||
});
|
||||
return cookieMap;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ describe("expo", async () => {
|
||||
provider: "google",
|
||||
callbackURL: "/dashboard",
|
||||
});
|
||||
const stateId = res?.url?.split("state=")[1].split("&")[0];
|
||||
const stateId = res?.url?.split("state=")[1]!.split("&")[0];
|
||||
const ctx = await auth.$context;
|
||||
if (!stateId) {
|
||||
throw new Error("State ID not found");
|
||||
@@ -157,9 +157,9 @@ describe("expo", async () => {
|
||||
});
|
||||
|
||||
it("should preserve unchanged client store session properties on signout", async () => {
|
||||
const before = client.$store.atoms.session.get();
|
||||
const before = client.$store.atoms.session!.get();
|
||||
await client.signOut();
|
||||
const after = client.$store.atoms.session.get();
|
||||
const after = client.$store.atoms.session!.get();
|
||||
|
||||
expect(after).toMatchObject({
|
||||
...before,
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false,
|
||||
"composite": false,
|
||||
"target": "es2022",
|
||||
"incremental": true,
|
||||
"moduleResolution": "Bundler",
|
||||
"strict": true,
|
||||
"moduleDetection": "force",
|
||||
"module": "Preserve",
|
||||
"skipLibCheck": true,
|
||||
"types": ["node"],
|
||||
"isolatedModules": true,
|
||||
"tsBuildInfoFile": ".tsbuildinfo",
|
||||
"preserveSymlinks": true,
|
||||
"noImplicitOverride": true
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"references": [],
|
||||
"include": ["src/**/*"]
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
}
|
||||
],
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
"scripts": {
|
||||
"test": "vitest",
|
||||
"build": "unbuild",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"dev": "unbuild --watch"
|
||||
"dev": "unbuild --watch",
|
||||
"typecheck": "tsc --project tsconfig.json"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "es2022",
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"module": "ESNext",
|
||||
"noEmit": true,
|
||||
"moduleResolution": "Bundler",
|
||||
"moduleDetection": "force",
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
}
|
||||
],
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
"scripts": {
|
||||
"test": "vitest",
|
||||
"build": "unbuild",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"dev": "unbuild --watch"
|
||||
"dev": "unbuild --watch",
|
||||
"typecheck": "tsc --project tsconfig.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -29,7 +29,7 @@ export async function onCheckoutSessionCompleted(
|
||||
checkoutSession?.client_reference_id ||
|
||||
checkoutSession?.metadata?.referenceId;
|
||||
const subscriptionId = checkoutSession?.metadata?.subscriptionId;
|
||||
const seats = subscription.items.data[0].quantity;
|
||||
const seats = subscription.items.data[0]!.quantity;
|
||||
if (referenceId && subscriptionId) {
|
||||
const trial =
|
||||
subscription.trial_start && subscription.trial_end
|
||||
@@ -47,10 +47,10 @@ export async function onCheckoutSessionCompleted(
|
||||
status: subscription.status,
|
||||
updatedAt: new Date(),
|
||||
periodStart: new Date(
|
||||
subscription.items.data[0].current_period_start * 1000,
|
||||
subscription.items.data[0]!.current_period_start * 1000,
|
||||
),
|
||||
periodEnd: new Date(
|
||||
subscription.items.data[0].current_period_end * 1000,
|
||||
subscription.items.data[0]!.current_period_end * 1000,
|
||||
),
|
||||
stripeSubscriptionId: checkoutSession.subscription as string,
|
||||
seats,
|
||||
@@ -106,9 +106,9 @@ export async function onSubscriptionUpdated(
|
||||
return;
|
||||
}
|
||||
const subscriptionUpdated = event.data.object as Stripe.Subscription;
|
||||
const priceId = subscriptionUpdated.items.data[0].price.id;
|
||||
const priceId = subscriptionUpdated.items.data[0]!.price.id;
|
||||
const priceLookupKey =
|
||||
subscriptionUpdated.items.data[0].price.lookup_key || null;
|
||||
subscriptionUpdated.items.data[0]!.price.lookup_key || null;
|
||||
const plan = await getPlanByPriceInfo(options, priceId, priceLookupKey);
|
||||
|
||||
const subscriptionId = subscriptionUpdated.metadata?.subscriptionId;
|
||||
@@ -137,11 +137,11 @@ export async function onSubscriptionUpdated(
|
||||
}
|
||||
subscription = activeSub;
|
||||
} else {
|
||||
subscription = subs[0];
|
||||
subscription = subs[0]!;
|
||||
}
|
||||
}
|
||||
|
||||
const seats = subscriptionUpdated.items.data[0].quantity;
|
||||
const seats = subscriptionUpdated.items.data[0]!.quantity;
|
||||
await ctx.context.adapter.update({
|
||||
model: "subscription",
|
||||
update: {
|
||||
@@ -154,10 +154,10 @@ export async function onSubscriptionUpdated(
|
||||
updatedAt: new Date(),
|
||||
status: subscriptionUpdated.status,
|
||||
periodStart: new Date(
|
||||
subscriptionUpdated.items.data[0].current_period_start * 1000,
|
||||
subscriptionUpdated.items.data[0]!.current_period_start * 1000,
|
||||
),
|
||||
periodEnd: new Date(
|
||||
subscriptionUpdated.items.data[0].current_period_end * 1000,
|
||||
subscriptionUpdated.items.data[0]!.current_period_end * 1000,
|
||||
),
|
||||
cancelAtPeriodEnd: subscriptionUpdated.cancel_at_period_end,
|
||||
seats,
|
||||
|
||||
@@ -1026,8 +1026,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
||||
if (stripeSubscription) {
|
||||
const plan = await getPlanByPriceInfo(
|
||||
options,
|
||||
stripeSubscription.items.data[0]?.price.id,
|
||||
stripeSubscription.items.data[0]?.price.lookup_key,
|
||||
stripeSubscription.items.data[0]?.price.id!,
|
||||
stripeSubscription.items.data[0]?.price.lookup_key!,
|
||||
);
|
||||
|
||||
if (plan && subscription) {
|
||||
@@ -1038,11 +1038,11 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
||||
seats: stripeSubscription.items.data[0]?.quantity || 1,
|
||||
plan: plan.name.toLowerCase(),
|
||||
periodEnd: new Date(
|
||||
stripeSubscription.items.data[0]?.current_period_end *
|
||||
stripeSubscription.items.data[0]?.current_period_end! *
|
||||
1000,
|
||||
),
|
||||
periodStart: new Date(
|
||||
stripeSubscription.items.data[0]?.current_period_start *
|
||||
stripeSubscription.items.data[0]?.current_period_start! *
|
||||
1000,
|
||||
),
|
||||
stripeSubscriptionId: stripeSubscription.id,
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "es2022",
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"module": "ESNext",
|
||||
"noEmit": true,
|
||||
"moduleResolution": "Bundler",
|
||||
"moduleDetection": "force",
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
}
|
||||
],
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
433
pnpm-lock.yaml
generated
433
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,42 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "es2022",
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"module": "Preserve",
|
||||
"noEmit": true,
|
||||
"moduleDetection": "force",
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"strict": true,
|
||||
"target": "esnext",
|
||||
"downlevelIteration": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"skipLibCheck": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
"exactOptionalPropertyTypes": false,
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"composite": true,
|
||||
"incremental": true,
|
||||
"noErrorTruncation": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "./packages/better-auth"
|
||||
},
|
||||
{
|
||||
"path": "./packages/cli"
|
||||
},
|
||||
{
|
||||
"path": "./packages/expo"
|
||||
},
|
||||
{
|
||||
"path": "./packages/sso"
|
||||
},
|
||||
{
|
||||
"path": "./packages/stripe"
|
||||
}
|
||||
],
|
||||
"files": [],
|
||||
"include": [],
|
||||
"exclude": ["**/dist/**", "**/node_modules/**", "**/examples/**"]
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"outputs": []
|
||||
},
|
||||
"typecheck": {
|
||||
"outputs": [],
|
||||
"outputs": [".tsbuildinfo", "dist/**"],
|
||||
"cache": true
|
||||
},
|
||||
"deploy": {
|
||||
|
||||
Reference in New Issue
Block a user