Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 58 additions & 58 deletions scripts/test-summary.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
#!/usr/bin/env bun

const proc = Bun.spawn(["bunx", "turbo", "run", "test"]);

await proc.exited;

const output = await new Response(proc.stdout).text();
const errorOutput = await new Response(proc.stderr).text();

process.stdout.write(output);
process.stderr.write(errorOutput);

const fullOutput = output + errorOutput;

console.log("");
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
console.log("📋 TEST SUMMARY");
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");

const passMatch = fullOutput.match(/(\d+) pass/g);
const failMatch = fullOutput.match(/(\d+) fail/g);
const testsMatch = fullOutput.match(/Ran (\d+) tests?/g);

let totalPass = 0;
let totalFail = 0;
let totalTests = 0;

if (passMatch) {
passMatch.forEach((m) => {
totalPass += Number.parseInt(m.split(" ")[0], 10);
});
}

if (failMatch) {
failMatch.forEach((m) => {
totalFail += Number.parseInt(m.split(" ")[0], 10);
});
}

if (testsMatch) {
testsMatch.forEach((m) => {
const num = m.match(/\d+/);
if (num) totalTests += Number.parseInt(num[0], 10);
});
}

if (totalTests > 0) {
console.log(`✅ Passed: ${totalPass} | ❌ Failed: ${totalFail} | 📝 Total Tests: ${totalTests}`);
} else if (totalPass > 0 || totalFail > 0) {
console.log(`✅ Passed: ${totalPass} | ❌ Failed: ${totalFail}`);
} else {
console.log("Run tests to see summary");
}

if (totalFail > 0 || proc.exitCode !== 0) {
process.exit(1);
}
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
#!/usr/bin/env bun
const proc = Bun.spawn(["bunx", "turbo", "run", "test"]);
await proc.exited;
const output = await new Response(proc.stdout).text();
const errorOutput = await new Response(proc.stderr).text();
process.stdout.write(output);
process.stderr.write(errorOutput);
const fullOutput = output + errorOutput;
console.log("");
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
console.log("📋 TEST SUMMARY");
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
const passMatch = fullOutput.match(/(\d+) pass/g);
const failMatch = fullOutput.match(/(\d+) fail/g);
const testsMatch = fullOutput.match(/Ran (\d+) tests?/g);
let totalPass = 0;
let totalFail = 0;
let totalTests = 0;
if (passMatch) {
passMatch.forEach((m) => {
totalPass += Number.parseInt(m.split(" ")[0], 10);
});
}
if (failMatch) {
failMatch.forEach((m) => {
totalFail += Number.parseInt(m.split(" ")[0], 10);
});
}
if (testsMatch) {
testsMatch.forEach((m) => {
const num = m.match(/\d+/);
if (num) totalTests += Number.parseInt(num[0], 10);
});
}
if (totalTests > 0) {
console.log(`✅ Passed: ${totalPass} | ❌ Failed: ${totalFail} | 📝 Total Tests: ${totalTests}`);
} else if (totalPass > 0 || totalFail > 0) {
console.log(`✅ Passed: ${totalPass} | ❌ Failed: ${totalFail}`);
} else {
console.log("Run tests to see summary");
}
if (totalFail > 0 || proc.exitCode !== 0) {
process.exit(1);
}
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
52 changes: 26 additions & 26 deletions templates/auth/src/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "../db";
import * as schema from "../db/schema";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "sqlite",
schema: {
user: schema.user,
session: schema.session,
account: schema.account,
verification: schema.verification,
},
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
secret: process.env.AUTH_SECRET,
baseURL: process.env.AUTH_URL ?? "http://localhost:3000",
trustedOrigins: [process.env.AUTH_URL ?? "http://localhost:3000"],
plugins: [],
});

export type Auth = typeof auth;
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "../db";
import * as schema from "../db/schema";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "sqlite",
schema: {
user: schema.user,
session: schema.session,
account: schema.account,
verification: schema.verification,
},
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
secret: process.env.AUTH_SECRET,
baseURL: process.env.AUTH_URL ?? "http://localhost:3000",
trustedOrigins: [process.env.AUTH_URL ?? "http://localhost:3000"],
plugins: [],
});
export type Auth = typeof auth;
18 changes: 9 additions & 9 deletions templates/auth/src/auth/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { auth } from "./index";

export type Session = typeof auth.$Infer.Session.session;
export type User = typeof auth.$Infer.Session.user;

export type AuthVariables = {
user: User;
session: Session;
};
import type { auth } from "./index";
export type Session = typeof auth.$Infer.Session.session;
export type User = typeof auth.$Infer.Session.user;
export type AuthVariables = {
user: User;
session: Session;
};
62 changes: 31 additions & 31 deletions templates/auth/src/db/auth-schema.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
import { users } from "./schema";

// Auth tables (generated by BetterAuth)
export const sessions = sqliteTable("sessions", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
ipAddress: text("ip_address"),
userAgent: text("user_agent"),
});

export const accounts = sqliteTable(
"accounts",
{
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
provider: text("provider").notNull(),
providerAccountId: text("provider_account_id").notNull(),
accessToken: text("access_token"),
refreshToken: text("refresh_token"),
expiresAt: integer("expires_at", { mode: "timestamp" }),
},
(t) => ({
providerUnique: uniqueIndex("provider_unique").on(t.provider, t.providerAccountId),
}),
);
import { integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
import { users } from "./schema";
// Auth tables (generated by BetterAuth)
export const sessions = sqliteTable("sessions", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
ipAddress: text("ip_address"),
userAgent: text("user_agent"),
});
export const accounts = sqliteTable(
"accounts",
{
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
provider: text("provider").notNull(),
providerAccountId: text("provider_account_id").notNull(),
accessToken: text("access_token"),
refreshToken: text("refresh_token"),
expiresAt: integer("expires_at", { mode: "timestamp" }),
},
(t) => ({
providerUnique: uniqueIndex("provider_unique").on(t.provider, t.providerAccountId),
}),
);
46 changes: 23 additions & 23 deletions templates/auth/src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Database } from "bun:sqlite";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { accounts, sessions } from "./auth-schema";
import * as schema from "./schema";

// Merge all schemas for Drizzle
const fullSchema = {
...schema,
sessions,
accounts,
};

// Note: In a real app, you'd import env from '../lib/env'
// For the auth template, we use a default path
const DB_PATH = process.env.DB_PATH || "./data/auth.db";

const sqlite = new Database(DB_PATH, { create: true });

export const db = drizzle(sqlite, { schema: fullSchema });

// Re-export all schema tables
export { users } from "./schema";
export { sessions, accounts };
import { Database } from "bun:sqlite";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { accounts, sessions } from "./auth-schema";
import * as schema from "./schema";
// Merge all schemas for Drizzle
const fullSchema = {
...schema,
sessions,
accounts,
};
// Note: In a real app, you'd import env from '../lib/env'
// For the auth template, we use a default path
const DB_PATH = process.env.DB_PATH || "./data/auth.db";
const sqlite = new Database(DB_PATH, { create: true });
export const db = drizzle(sqlite, { schema: fullSchema });
// Re-export all schema tables
export { users } from "./schema";
export { sessions, accounts };
Loading
Loading