From aa2b085b333cbb87f9a715197b8cf99cc62c782b Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Thu, 10 Sep 2026 07:09:48 +0000 Subject: [PATCH] chore(seed): dedupe isValidEmail into lib/users Seven seed topic files re-declared the same permissive email regex locally. Reuse the existing authoritative isValidEmail in dev/seed/lib/users.ts. --- dev/seed/app/api-token.ts | 6 +----- dev/seed/app/create-user.ts | 6 +----- dev/seed/app/kilo-pass-stripe.ts | 5 +---- dev/seed/app/mobile-sheet-fixtures.ts | 6 +----- dev/seed/app/paged-history.ts | 5 +---- dev/seed/app/session-pr-link.ts | 6 +----- dev/seed/app/user-id.ts | 6 +----- 7 files changed, 7 insertions(+), 33 deletions(-) diff --git a/dev/seed/app/api-token.ts b/dev/seed/app/api-token.ts index 743cb9ac11..767a109c46 100644 --- a/dev/seed/app/api-token.ts +++ b/dev/seed/app/api-token.ts @@ -4,6 +4,7 @@ import { eq, or } from 'drizzle-orm'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import type { SeedResult } from '../index'; export const usage = ' [options]'; @@ -32,11 +33,6 @@ function printUsage(): void { console.log(' pnpm dev:seed app:api-token ada@example.com --expires-days=30 --admin'); } -function isValidEmail(email: string): boolean { - // Intentionally permissive; we only guard against obvious nonsense in dev. - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - function parsePositiveInteger(value: string, flagName: string): number { if (!/^\d+$/.test(value)) { throw new Error(`${flagName} must be a positive integer`); diff --git a/dev/seed/app/create-user.ts b/dev/seed/app/create-user.ts index 0194b7312c..f2cccb4e8a 100644 --- a/dev/seed/app/create-user.ts +++ b/dev/seed/app/create-user.ts @@ -5,6 +5,7 @@ import { eq } from 'drizzle-orm'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import { createSeedStripeCustomer, deleteSeedStripeCustomer } from '../lib/stripe'; import type { SeedResult } from '../index'; @@ -28,11 +29,6 @@ function printUsage(): void { console.log(' pnpm dev:seed app:create-user "Evgeny" evgeny@kilocode.ai --admin'); } -function isValidEmail(email: string): boolean { - // Intentionally permissive; we only guard against obvious nonsense in dev. - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - export async function run(...args: string[]): Promise { if (args.includes('--help') || args.includes('-h')) { printUsage(); diff --git a/dev/seed/app/kilo-pass-stripe.ts b/dev/seed/app/kilo-pass-stripe.ts index 8a9f7bc0a8..6494c301b6 100644 --- a/dev/seed/app/kilo-pass-stripe.ts +++ b/dev/seed/app/kilo-pass-stripe.ts @@ -7,6 +7,7 @@ import Stripe from 'stripe'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import { createSeedStripeCustomer, deleteSeedStripeCustomer } from '../lib/stripe'; import type { SeedResult } from '../index'; @@ -63,10 +64,6 @@ function printUsage(): void { console.log(' pnpm dev:seed app:kilo-pass-stripe e2e-w4b-android-stripe@example.com'); } -function isValidEmail(email: string): boolean { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - async function deleteSeedStripeSubscription(subscriptionId: string): Promise { try { await getStripe().subscriptions.cancel(subscriptionId); diff --git a/dev/seed/app/mobile-sheet-fixtures.ts b/dev/seed/app/mobile-sheet-fixtures.ts index a526ce9205..b99160503c 100644 --- a/dev/seed/app/mobile-sheet-fixtures.ts +++ b/dev/seed/app/mobile-sheet-fixtures.ts @@ -6,6 +6,7 @@ import { and, eq, inArray, or } from 'drizzle-orm'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import { normalizedGitHubUrl, readFixtureIntegration, @@ -57,11 +58,6 @@ function printUsage(): void { ); } -function isValidEmail(email: string): boolean { - // Intentionally permissive; we only guard against obvious nonsense in dev. - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - function sleep(ms: number): Promise { return new Promise(resolve => setTimeout(resolve, ms)); } diff --git a/dev/seed/app/paged-history.ts b/dev/seed/app/paged-history.ts index 4bb2d44edf..1e98e248e1 100644 --- a/dev/seed/app/paged-history.ts +++ b/dev/seed/app/paged-history.ts @@ -7,6 +7,7 @@ import { and, eq, or } from 'drizzle-orm'; import type { SeedResult } from '../index'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import { buildAssistantMessageItem, buildSessionItem, @@ -41,10 +42,6 @@ function printUsage(): void { console.log(' pnpm -s dev:seed app:paged-history evgeny@kilocode.ai --json'); } -function isValidEmail(email: string): boolean { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - function sleep(ms: number): Promise { return new Promise(resolve => setTimeout(resolve, ms)); } diff --git a/dev/seed/app/session-pr-link.ts b/dev/seed/app/session-pr-link.ts index 3d96098bb5..e3b02a2da2 100644 --- a/dev/seed/app/session-pr-link.ts +++ b/dev/seed/app/session-pr-link.ts @@ -3,6 +3,7 @@ import { and, eq, like, or, sql } from 'drizzle-orm'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import type { SeedResult } from '../index'; export const usage = @@ -69,11 +70,6 @@ function printUsage(): void { ); } -function isValidEmail(email: string): boolean { - // Intentionally permissive; we only guard against obvious nonsense in dev. - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - function sessionTitleFor(sessionId: string): string { if (sessionId.includes('e2eprhappy')) return 'E2E PR happy'; if (sessionId.includes('e2eprempty')) return 'E2E PR empty'; diff --git a/dev/seed/app/user-id.ts b/dev/seed/app/user-id.ts index 502a05af8c..a3e2b23a04 100644 --- a/dev/seed/app/user-id.ts +++ b/dev/seed/app/user-id.ts @@ -3,6 +3,7 @@ import { eq, or } from 'drizzle-orm'; import { getSeedDb } from '../lib/db'; import { normalizeSeedEmail } from '../lib/email'; +import { isValidEmail } from '../lib/users'; import type { SeedResult } from '../index'; export const usage = ''; @@ -18,11 +19,6 @@ function printUsage(): void { console.log(' pnpm -s dev:seed app:user-id ada@example.com --json | jq -r .userId'); } -function isValidEmail(email: string): boolean { - // Intentionally permissive; we only guard against obvious nonsense in dev. - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -} - export async function run(...args: string[]): Promise { if (args.includes('--help') || args.includes('-h')) { printUsage();