From 1c4eabcaaf6dd80d4e7c7cc229b466f2b5347179 Mon Sep 17 00:00:00 2001 From: Ian Hunter Date: Mon, 27 Oct 2025 20:04:17 +1100 Subject: [PATCH 1/3] remove utils we dont need this anymore: --- config/typescript/base.json | 3 -- packages/utils/biome.jsonc | 4 -- packages/utils/package.json | 32 ------------ packages/utils/rollup.config.js | 26 ---------- packages/utils/rollup.config.mjs | 45 ----------------- packages/utils/src/index.ts | 9 ---- packages/utils/src/url.ts | 83 -------------------------------- packages/utils/tsconfig.json | 10 ---- 8 files changed, 212 deletions(-) delete mode 100644 packages/utils/biome.jsonc delete mode 100644 packages/utils/package.json delete mode 100644 packages/utils/rollup.config.js delete mode 100644 packages/utils/rollup.config.mjs delete mode 100644 packages/utils/src/index.ts delete mode 100644 packages/utils/src/url.ts delete mode 100644 packages/utils/tsconfig.json diff --git a/config/typescript/base.json b/config/typescript/base.json index 889ba9c..d3a85a8 100644 --- a/config/typescript/base.json +++ b/config/typescript/base.json @@ -35,9 +35,6 @@ { "@startupkit/auth": "packages/auth" }, - { - "@startupkit/utils": "packages/utils" - }, { "startupkit": "packages/cli" } diff --git a/packages/utils/biome.jsonc b/packages/utils/biome.jsonc deleted file mode 100644 index 0616ee4..0000000 --- a/packages/utils/biome.jsonc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", - "extends": ["@config/biome"] -} diff --git a/packages/utils/package.json b/packages/utils/package.json deleted file mode 100644 index f433783..0000000 --- a/packages/utils/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "@startupkit/utils", - "version": "0.4.0", - "author": "Ian Hunter ", - "license": "ISC", - "description": "Utility functions for StartupKit", - "homepage": "https://startupkit.com", - "repository": { - "type": "git", - "url": "https://github.com/01-studio/startupkit" - }, - "type": "module", - "exports": { - ".": { - "types": "./dist/types/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "scripts": { - "clean": "rm -rf ./dist ./.turbo", - "build": "rollup -c && tsc --emitDeclarationOnly", - "build:watch": "npx chokidar-cli \"src/**/*\" -c \"pnpm run build\" --initial", - "typecheck": "tsc --noEmit", - "lint": "biome check", - "lint:fix": "biome check --write" - }, - "devDependencies": { - "@config/biome": "workspace:*", - "@config/tsconfig": "workspace:*", - "@types/node": "^22.4.0" - } -} diff --git a/packages/utils/rollup.config.js b/packages/utils/rollup.config.js deleted file mode 100644 index 4ae52ff..0000000 --- a/packages/utils/rollup.config.js +++ /dev/null @@ -1,26 +0,0 @@ -import commonjs from "@rollup/plugin-commonjs" -import { swc } from "@rollup/plugin-swc" -import { preserveDirectives } from "rollup-preserve-directives" - -const config = [ - { - input: ["src/index.ts"], - output: { - dir: "dist/esm", - format: "esm", - preserveModules: true, - preserveModulesRoot: "src" - }, - plugins: [ - commonjs(), - swc({ - jsc: { - target: "es2022" - } - }), - preserveDirectives() - ] - } -] - -export default config diff --git a/packages/utils/rollup.config.mjs b/packages/utils/rollup.config.mjs deleted file mode 100644 index 110a9e7..0000000 --- a/packages/utils/rollup.config.mjs +++ /dev/null @@ -1,45 +0,0 @@ -import esbuild from "rollup-plugin-esbuild" -import preserveDirectives from "rollup-preserve-directives" - -import { readFileSync } from "node:fs" -import { dirname, resolve } from "node:path" -import { fileURLToPath } from "node:url" - -const __filename = fileURLToPath(import.meta.url) -const __dirname = dirname(__filename) -const pkg = JSON.parse( - readFileSync(resolve(__dirname, "package.json"), "utf-8") -) -const external = Object.keys(pkg.dependencies || {}) // Make all dependencies external - -export default { - input: ["src/index.ts"], - output: [ - { - dir: "dist/cjs", - format: "cjs" - }, - { - dir: "dist/esm", - format: "esm" - } - ], - external, - plugins: [ - esbuild({ - include: /\.[jt]sx?$/, - exclude: /node_modules/, - sourceMap: true, - minify: process.env.NODE_ENV === "production", - target: "esnext", - jsx: "transform", - jsxFactory: "React.createElement", - jsxFragment: "React.Fragment", - tsconfig: "tsconfig.json", - loaders: { - ".json": "json" - } - }), - preserveDirectives() - ] -} diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts deleted file mode 100644 index 647d158..0000000 --- a/packages/utils/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Gets the absolute URL by combining the base URL with the provided path - * @param path The path to append to the base URL - * @returns The complete URL - */ -export function getURL(path: string): string { - const baseURL = process.env.NEXT_PUBLIC_URL || process.env.VERCEL_URL || "" - return `${baseURL}${path}` -} diff --git a/packages/utils/src/url.ts b/packages/utils/src/url.ts deleted file mode 100644 index c79d172..0000000 --- a/packages/utils/src/url.ts +++ /dev/null @@ -1,83 +0,0 @@ -export const getURL = (path = "") => { - let url = "http://localhost:3000/" - - if (process.env.NEXT_PUBLIC_SITE_URL?.trim()) { - url = process.env.NEXT_PUBLIC_SITE_URL - } else if (process.env.NEXT_PUBLIC_VERCEL_URL?.trim()) { - url = process.env.NEXT_PUBLIC_VERCEL_URL - } - - // Trim the URL and remove trailing slash if exists. - url = url.replace(/\/+$/, "") - // Make sure to include `https://` when not localhost. - url = url.includes("http") ? url : `https://${url}` - // Ensure path starts without a slash to avoid double slashes in the final URL. - const _path = path.replace(/^\/+/, "") - - // Concatenate the URL and the path. - return _path ? `${url}/${_path}` : url -} - -const toastKeyMap: Record = { - status: ["status", "status_description"], - error: ["error", "error_description"] -} - -const getToastRedirect = ( - path: string, - toastType: string, - toastName: string, - toastDescription = "", - disableButton = false, - arbitraryParams = "" -): string => { - const [nameKey, descriptionKey] = toastKeyMap[toastType] - - let redirectPath = `${path}?${nameKey}=${encodeURIComponent(toastName)}` - - if (toastDescription) { - redirectPath += `&${descriptionKey}=${encodeURIComponent(toastDescription)}` - } - - if (disableButton) { - redirectPath += "&disable_button=true" - } - - if (arbitraryParams) { - redirectPath += `&${arbitraryParams}` - } - - return redirectPath -} - -export const getStatusRedirect = ( - path: string, - statusName: string, - statusDescription = "", - disableButton = false, - arbitraryParams = "" -) => - getToastRedirect( - path, - "status", - statusName, - statusDescription, - disableButton, - arbitraryParams - ) - -export const getErrorRedirect = ( - path: string, - errorName: string, - errorDescription = "", - disableButton = false, - arbitraryParams = "" -) => - getToastRedirect( - path, - "error", - errorName, - errorDescription, - disableButton, - arbitraryParams - ) diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json deleted file mode 100644 index bf2219c..0000000 --- a/packages/utils/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "@config/tsconfig/library.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "./dist", - "declarationDir": "./dist/types" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] -} From 380470df71a1aa4df371e37789aae3b83bed1ec5 Mon Sep 17 00:00:00 2001 From: Ian Hunter Date: Mon, 27 Oct 2025 20:12:33 +1100 Subject: [PATCH 2/3] more --- .github/workflows/templates-build.yml | 6 ++---- .github/workflows/test-cli.yml | 3 +-- .ruler/AGENTS.md | 4 +--- templates/repo/packages/auth/src/index.ts | 2 +- templates/repo/packages/auth/src/lib/auth.ts | 6 ++++-- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/templates-build.yml b/.github/workflows/templates-build.yml index be269fb..c560e78 100644 --- a/.github/workflows/templates-build.yml +++ b/.github/workflows/templates-build.yml @@ -44,8 +44,7 @@ jobs: pkg.pnpm = pkg.pnpm || {}; pkg.pnpm.overrides = { '@startupkit/auth': 'link:' + workspace + '/packages/auth', - '@startupkit/analytics': 'link:' + workspace + '/packages/analytics', - '@startupkit/utils': 'link:' + workspace + '/packages/utils' + '@startupkit/analytics': 'link:' + workspace + '/packages/analytics' }; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); console.log('Overrides added:', pkg.pnpm.overrides); @@ -102,8 +101,7 @@ jobs: pkg.pnpm = pkg.pnpm || {}; pkg.pnpm.overrides = { '@startupkit/auth': 'link:' + workspace + '/packages/auth', - '@startupkit/analytics': 'link:' + workspace + '/packages/analytics', - '@startupkit/utils': 'link:' + workspace + '/packages/utils' + '@startupkit/analytics': 'link:' + workspace + '/packages/analytics' }; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); console.log('Overrides added:', pkg.pnpm.overrides); diff --git a/.github/workflows/test-cli.yml b/.github/workflows/test-cli.yml index 4890013..35716de 100644 --- a/.github/workflows/test-cli.yml +++ b/.github/workflows/test-cli.yml @@ -232,8 +232,7 @@ jobs: pkg.pnpm = pkg.pnpm || {}; pkg.pnpm.overrides = { '@startupkit/auth': 'link:' + workspace + '/packages/auth', - '@startupkit/analytics': 'link:' + workspace + '/packages/analytics', - '@startupkit/utils': 'link:' + workspace + '/packages/utils' + '@startupkit/analytics': 'link:' + workspace + '/packages/analytics' }; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); console.log('Overrides added:', pkg.pnpm.overrides); diff --git a/.ruler/AGENTS.md b/.ruler/AGENTS.md index 32048e2..bee1047 100644 --- a/.ruler/AGENTS.md +++ b/.ruler/AGENTS.md @@ -17,8 +17,7 @@ This is a **pnpm monorepo** built with **TypeScript**, **Next.js 16**, **React 1 ├── packages/ # Published npm packages │ ├── analytics/ # @startupkit/analytics npm package │ ├── auth/ # @startupkit/auth npm package -│ ├── cli/ # startupkit CLI tool -│ └── utils/ # @startupkit/utils npm package +│ └── cli/ # startupkit CLI tool ├── templates/ # Scaffolding templates │ ├── next/ # Next.js app template │ ├── package/ # Generic package template @@ -36,7 +35,6 @@ This is a **pnpm monorepo** built with **TypeScript**, **Next.js 16**, **React 1 - **`packages/cli`** - The `startupkit` CLI tool for scaffolding projects - **`packages/analytics`** - Published to npm as `@startupkit/analytics` - **`packages/auth`** - Published to npm as `@startupkit/auth` -- **`packages/utils`** - Published to npm as `@startupkit/utils` **Templates**: - **`templates/repo`** - Full monorepo template (most comprehensive) diff --git a/templates/repo/packages/auth/src/index.ts b/templates/repo/packages/auth/src/index.ts index fe7b8b2..01217af 100644 --- a/templates/repo/packages/auth/src/index.ts +++ b/templates/repo/packages/auth/src/index.ts @@ -11,5 +11,5 @@ export * from "./types" // Note: Type assertions needed due to plugin type complexities export const authClient = createAuthClient({ basePath: "/auth", - plugins: [adminClient(), emailOTPClient()] + plugins: [adminClient() as never, emailOTPClient()] }) diff --git a/templates/repo/packages/auth/src/lib/auth.ts b/templates/repo/packages/auth/src/lib/auth.ts index cb90412..b8c8758 100644 --- a/templates/repo/packages/auth/src/lib/auth.ts +++ b/templates/repo/packages/auth/src/lib/auth.ts @@ -57,7 +57,9 @@ export const auth = betterAuth({ if (newSession) { await db .update(users) - .set({ lastSeenAt: new Date() }) + .set({ + lastSeenAt: new Date() + }) .where(eq(users.id, newSession.user.id)) const [user] = await db @@ -86,7 +88,7 @@ export const auth = betterAuth({ }) }, plugins: [ - admin(), + admin() as never, emailOTP({ sendVerificationOTP }), From 046bacf7edb7d97430831bb66d0b98980f649a67 Mon Sep 17 00:00:00 2001 From: Ian Hunter Date: Mon, 27 Oct 2025 20:16:14 +1100 Subject: [PATCH 3/3] remove this junk --- templates/repo/packages/auth/src/index.ts | 2 +- templates/repo/packages/auth/src/lib/auth.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/packages/auth/src/index.ts b/templates/repo/packages/auth/src/index.ts index 01217af..fe7b8b2 100644 --- a/templates/repo/packages/auth/src/index.ts +++ b/templates/repo/packages/auth/src/index.ts @@ -11,5 +11,5 @@ export * from "./types" // Note: Type assertions needed due to plugin type complexities export const authClient = createAuthClient({ basePath: "/auth", - plugins: [adminClient() as never, emailOTPClient()] + plugins: [adminClient(), emailOTPClient()] }) diff --git a/templates/repo/packages/auth/src/lib/auth.ts b/templates/repo/packages/auth/src/lib/auth.ts index b8c8758..6406efd 100644 --- a/templates/repo/packages/auth/src/lib/auth.ts +++ b/templates/repo/packages/auth/src/lib/auth.ts @@ -88,7 +88,7 @@ export const auth = betterAuth({ }) }, plugins: [ - admin() as never, + admin(), emailOTP({ sendVerificationOTP }),