Use tsx and .ts files for validation

This commit is contained in:
Nate Kelley 2025-07-21 16:07:14 -06:00
parent 3f8b05182d
commit 8ee892bf2a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
23 changed files with 28 additions and 24 deletions

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"dev": "npx trigger.dev@v4-beta dev", "dev": "npx trigger.dev@v4-beta dev",
"deploy": "npx trigger.dev@v4-beta deploy", "deploy": "npx trigger.dev@v4-beta deploy",
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "echo 'No build step required but we run it to make sure env is loaded' && tsc --noEmit", "build": "echo 'No build step required but we run it to make sure env is loaded' && tsc --noEmit",
"lint": "biome check --write", "lint": "biome check --write",
"test": "vitest run", "test": "vitest run",

View File

@ -52,6 +52,7 @@
"@biomejs/biome": "^1.9.4", "@biomejs/biome": "^1.9.4",
"@types/node": "^20.19.4", "@types/node": "^20.19.4",
"turbo": "^2.5.5", "turbo": "^2.5.5",
"tsx": "catalog:",
"vitest": "catalog:" "vitest": "catalog:"
}, },
"peerDependencies": { "peerDependencies": {

View File

@ -13,7 +13,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"build:commonjs": "tsc --module commonjs --moduleResolution node", "build:commonjs": "tsc --module commonjs --moduleResolution node",
"build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch", "build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch",

View File

@ -14,7 +14,7 @@
} }
}, },
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"dev": "tsc --watch", "dev": "tsc --watch",

View File

@ -13,7 +13,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"build:commonjs": "tsc --module commonjs --moduleResolution node", "build:commonjs": "tsc --module commonjs --moduleResolution node",
"build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch", "build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch",

View File

@ -19,7 +19,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"build:commonjs": "tsc --module commonjs --moduleResolution node", "build:commonjs": "tsc --module commonjs --moduleResolution node",
"build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch", "build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch",

View File

@ -11,7 +11,7 @@
} }
}, },
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"test": "vitest run", "test": "vitest run",

View File

@ -15,7 +15,7 @@
} }
}, },
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"dev": "tsc --watch", "dev": "tsc --watch",

View File

@ -15,7 +15,7 @@
} }
}, },
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"dev": "tsc --watch", "dev": "tsc --watch",

View File

@ -19,7 +19,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"build:commonjs": "tsc --module commonjs --moduleResolution node", "build:commonjs": "tsc --module commonjs --moduleResolution node",
"build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch", "build:commonjs:watch": "npm run build:commonjs && tsc --module commonjs --moduleResolution node --watch",

View File

@ -14,7 +14,7 @@
} }
}, },
"scripts": { "scripts": {
"prebuild": "node scripts/validate-env.js", "prebuild": "tsx scripts/validate-env.ts",
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"lint": "biome check --write", "lint": "biome check --write",

View File

@ -87,6 +87,9 @@ importers:
'@types/node': '@types/node':
specifier: ^20.19.4 specifier: ^20.19.4
version: 20.19.4 version: 20.19.4
tsx:
specifier: 'catalog:'
version: 4.20.3
turbo: turbo:
specifier: ^2.5.5 specifier: ^2.5.5
version: 2.5.5 version: 2.5.5
@ -143,8 +146,8 @@ importers:
specifier: workspace:* specifier: workspace:*
version: link:../../packages/vitest-config version: link:../../packages/vitest-config
'@hono/zod-validator': '@hono/zod-validator':
specifier: ^0.7.0 specifier: ^0.7.2
version: 0.7.0(hono@4.8.4)(zod@3.25.1) version: 0.7.2(hono@4.8.4)(zod@3.25.1)
'@supabase/supabase-js': '@supabase/supabase-js':
specifier: 'catalog:' specifier: 'catalog:'
version: 2.50.2 version: 2.50.2
@ -2521,11 +2524,11 @@ packages:
engines: {node: '>=6'} engines: {node: '>=6'}
hasBin: true hasBin: true
'@hono/zod-validator@0.7.0': '@hono/zod-validator@0.7.2':
resolution: {integrity: sha512-qe2ZE6sHFE98dcUrbYMtS3bAV8hqcCOflykvZga2S7XhmNSZzT+dIz4OuMILsjLHkJw9JMn912/dB7dQOmuPvg==} resolution: {integrity: sha512-ub5eL/NeZ4eLZawu78JpW/J+dugDAYhwqUIdp9KYScI6PZECij4Hx4UsrthlEUutqDDhPwRI0MscUfNkvn/mqQ==}
peerDependencies: peerDependencies:
hono: '>=3.9.0' hono: '>=3.9.0'
zod: ^3.25.0 zod: ^3.25.0 || ^4.0.0
'@humanwhocodes/config-array@0.13.0': '@humanwhocodes/config-array@0.13.0':
resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==}
@ -13786,7 +13789,7 @@ snapshots:
protobufjs: 7.5.3 protobufjs: 7.5.3
yargs: 17.7.2 yargs: 17.7.2
'@hono/zod-validator@0.7.0(hono@4.8.4)(zod@3.25.1)': '@hono/zod-validator@0.7.2(hono@4.8.4)(zod@3.25.1)':
dependencies: dependencies:
hono: 4.8.4 hono: 4.8.4
zod: 3.25.1 zod: 3.25.1
@ -17442,14 +17445,14 @@ snapshots:
msw: 2.10.4(@types/node@20.19.4)(typescript@5.8.3) msw: 2.10.4(@types/node@20.19.4)(typescript@5.8.3)
vite: 6.3.5(@types/node@20.19.4)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0) vite: 6.3.5(@types/node@20.19.4)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0)
'@vitest/mocker@3.2.4(msw@2.10.4(@types/node@24.0.10)(typescript@5.8.3))(vite@6.3.5(@types/node@20.19.4)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0))': '@vitest/mocker@3.2.4(msw@2.10.4(@types/node@24.0.10)(typescript@5.8.3))(vite@6.3.5(@types/node@24.0.10)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0))':
dependencies: dependencies:
'@vitest/spy': 3.2.4 '@vitest/spy': 3.2.4
estree-walker: 3.0.3 estree-walker: 3.0.3
magic-string: 0.30.17 magic-string: 0.30.17
optionalDependencies: optionalDependencies:
msw: 2.10.4(@types/node@24.0.10)(typescript@5.8.3) msw: 2.10.4(@types/node@24.0.10)(typescript@5.8.3)
vite: 6.3.5(@types/node@20.19.4)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0) vite: 6.3.5(@types/node@24.0.10)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0)
'@vitest/pretty-format@2.0.5': '@vitest/pretty-format@2.0.5':
dependencies: dependencies:
@ -24162,7 +24165,7 @@ snapshots:
dependencies: dependencies:
'@types/chai': 5.2.2 '@types/chai': 5.2.2
'@vitest/expect': 3.2.4 '@vitest/expect': 3.2.4
'@vitest/mocker': 3.2.4(msw@2.10.4(@types/node@24.0.10)(typescript@5.8.3))(vite@6.3.5(@types/node@20.19.4)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0)) '@vitest/mocker': 3.2.4(msw@2.10.4(@types/node@24.0.10)(typescript@5.8.3))(vite@6.3.5(@types/node@24.0.10)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0))
'@vitest/pretty-format': 3.2.4 '@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4 '@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4 '@vitest/snapshot': 3.2.4

View File

@ -241,7 +241,7 @@ async function main() {
console.log(`\n📋 Next steps:`); console.log(`\n📋 Next steps:`);
console.log(` 1. cd ${config.type === 'package' ? 'packages' : 'apps'}/${config.name}`); console.log(` 1. cd ${config.type === 'package' ? 'packages' : 'apps'}/${config.name}`);
console.log(` 2. Update the env.d.ts file with your environment variable types`); console.log(` 2. Update the env.d.ts file with your environment variable types`);
console.log(` 3. Add any required env vars to scripts/validate-env.js`); console.log(` 3. Add any required env vars to scripts/validate-env.ts`);
console.log(` 4. Make sure required env vars are defined in the root .env file`); console.log(` 4. Make sure required env vars are defined in the root .env file`);
console.log(` 5. Add your source code in the src/ directory`); console.log(` 5. Add your source code in the src/ directory`);
console.log(` 6. Run 'npm run build' to build the ${config.type}`); console.log(` 6. Run 'npm run build' to build the ${config.type}`);
@ -272,7 +272,7 @@ async function createPackageFiles(config: PackageConfig) {
}, },
}, },
scripts: { scripts: {
prebuild: "node scripts/validate-env.js", prebuild: "tsx scripts/validate-env.ts",
build: "tsc", build: "tsc",
typecheck: "tsc --noEmit", typecheck: "tsc --noEmit",
dev: "tsc --watch", dev: "tsc --watch",
@ -363,7 +363,7 @@ export const howdy = () => {
await writeFile(join(directory, "src", "lib", "index.ts"), libIndex); await writeFile(join(directory, "src", "lib", "index.ts"), libIndex);
// Create a proper validate-env.js script // Create a proper validate-env.ts script
const validateEnv = `#!/usr/bin/env node const validateEnv = `#!/usr/bin/env node
// This script uses the shared env-utils to validate environment variables // This script uses the shared env-utils to validate environment variables
@ -388,7 +388,7 @@ if (hasErrors) {
} }
`; `;
await writeFile(join(directory, "scripts", "validate-env.js"), validateEnv); await writeFile(join(directory, "scripts", "validate-env.ts"), validateEnv);
// Create .gitignore for TypeScript build artifacts // Create .gitignore for TypeScript build artifacts
const gitignore = `# TypeScript build artifacts const gitignore = `# TypeScript build artifacts
@ -440,7 +440,7 @@ test-results/
console.log("📄 Created vitest.config.ts"); console.log("📄 Created vitest.config.ts");
console.log("📄 Created src/index.ts"); console.log("📄 Created src/index.ts");
console.log("📄 Created src/lib/index.ts"); console.log("📄 Created src/lib/index.ts");
console.log("📄 Created scripts/validate-env.js"); console.log("📄 Created scripts/validate-env.ts");
console.log("📄 Created .gitignore"); console.log("📄 Created .gitignore");
} }