fix: running setup on windows, db:push on windows

This commit is contained in:
John Yeo
2025-06-19 10:40:55 +01:00
parent b606a162c4
commit 964a2c841d
7 changed files with 32 additions and 21 deletions

4
.npmrc
View File

@@ -1,2 +1,4 @@
optionalDependencies=false
install-optional=false
install-optional=false
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

View File

@@ -7,7 +7,8 @@
"vite"
],
"type": "module",
"scripts": {
"scripts": {
"postinstall": "pnpm -F shared build",
"vite:build": "pnpm -F shared build && pnpm -F vite build",
"vite:start": "pnpm -F vite start",
"server:build": "pnpm -F shared build && pnpm -F server prod:build",
@@ -16,9 +17,9 @@
"server:workers": "pnpm -F server workers:start",
"dev": "concurrently \"cd server && npm run dev\" \"cd vite && npm run dev\" \"redis-server\"",
"setup": "node setup.js",
"db:push": "pnpm -F shared db:push",
"db:push": " pnpm -F shared db:push",
"db:generate": "pnpm -F shared db:generate",
"db:migrate": "pnpm -F shared db:migrate",
"db:migrate": " pnpm -F shared db:migrate",
"docker:up": "docker compose -f docker-compose.dev.yml up --build"
},
"dependencies": {

12
pnpm-lock.yaml generated
View File

@@ -241,6 +241,9 @@ importers:
shared:
dependencies:
cross-env:
specifier: ^7.0.3
version: 7.0.3
decimal.js:
specifier: ^10.5.0
version: 10.5.0
@@ -3014,6 +3017,11 @@ packages:
cron@3.5.0:
resolution: {integrity: sha512-0eYZqCnapmxYcV06uktql93wNWdlTmmBFP2iYz+JPVcQqlyFYcn1lFuIk4R54pkOmE7mcldTAPZv6X5XA4Q46A==}
cross-env@7.0.3:
resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==}
engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'}
hasBin: true
cross-spawn@7.0.6:
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
engines: {node: '>= 8'}
@@ -8180,6 +8188,10 @@ snapshots:
'@types/luxon': 3.4.2
luxon: 3.5.0
cross-env@7.0.3:
dependencies:
cross-spawn: 7.0.6
cross-spawn@7.0.6:
dependencies:
path-key: 3.1.1

View File

@@ -16,16 +16,10 @@
"prod:start": "node dist/src/index.js",
"cron": "tsx src/cron.ts",
"cron:start": "node --no-deprecation dist/src/cron.js",
"clean": "tsx src/clean.ts",
"testa-parallel": "mocha 'tests/alex/00_setup.ts' && mocha --parallel --timeout 10000000 'tests/alex/**/*.ts' --ignore 'tests/alex/00_setup.ts'",
"testa": "mocha 'tests/alex/00_setup.ts' && mocha --timeout 10000000 'tests/alex/01_free.ts' --ignore 'tests/alex/00_setup.ts'",
"test": "mocha --timeout 10000000 'tests/**/*.ts' --ignore 'tests/alex/**/*.ts'",
"test-custom": "mocha --timeout 1000000 'tests/01_product.ts'",
"db:pull": "NODE_OPTIONS='--import tsx' drizzle-kit pull",
"db:generate": "NODE_OPTIONS='--import tsx' drizzle-kit generate",
"db:migrate": "NODE_OPTIONS='--import tsx' drizzle-kit migrate",
"db:push": "NODE_OPTIONS='--import tsx' drizzle-kit push ",
"db:custom": "NODE_OPTIONS='--import tsx' drizzle-kit generate --custom --name=add_new_col",
"benchmark": "tsx benchmarks/index.ts",
"benchmark:customer": "tsx benchmarks/index.ts customer",
"benchmark:attach": "tsx benchmarks/index.ts attach",

View File

@@ -39,7 +39,7 @@ const getOrCreateSupabaseOrg = async () => {
const orgListResult = spawnSync(
'npx',
['supabase', 'orgs', 'list'],
{ encoding: 'utf-8' }
{ encoding: 'utf-8', shell: true }
);
if (orgListResult.status !== 0) {
console.error(chalk.red('❌ Failed to list Supabase orgs.'));
@@ -77,7 +77,7 @@ const getOrCreateSupabaseOrg = async () => {
const createOrgResult = spawnSync(
'npx',
['supabase', 'orgs', 'create', orgName],
{ stdio: 'inherit', encoding: 'utf-8' }
{ stdio: 'inherit', encoding: 'utf-8', shell: true }
);
if (createOrgResult.status !== 0) {
console.error(chalk.red('❌ Failed to create Supabase organization.'));
@@ -96,7 +96,7 @@ const generateSupabaseDatabaseUrl = async () => {
console.log(chalk.magentaBright('\n================ Supabase Setup ================\n'));
console.log(chalk.blueBright('\nLaunching Supabase login...'));
spawnSync('npx', ['supabase', 'login'], { stdio: 'inherit' });
spawnSync('npx', ['supabase', 'login'], { stdio: 'inherit', shell: true });
// Step 3.5: Ensure org exists and select one
await getOrCreateSupabaseOrg();
@@ -112,7 +112,7 @@ const generateSupabaseDatabaseUrl = async () => {
const createResult = spawnSync(
'npx',
['supabase', 'projects', 'create', projectName, '--db-password', dbPassword],
{ stdio: 'inherit', encoding: 'utf-8' }
{ stdio: 'inherit', encoding: 'utf-8', shell: true }
);
if (createResult.status !== 0) {
@@ -124,7 +124,7 @@ const generateSupabaseDatabaseUrl = async () => {
const listResult = spawnSync(
'npx',
['supabase', 'projects', 'list', '--output', 'json'],
{ encoding: 'utf-8' }
{ encoding: 'utf-8', shell: true }
);
if (listResult.status !== 0) {
@@ -327,7 +327,7 @@ async function main() {
if (runDbPush) {
console.log(chalk.blueBright('\nRunning "pnpm run db:push"...'));
const dbPushResult = spawnSync('pnpm', ['run', 'db:push'], { stdio: 'inherit', encoding: 'utf-8' });
const dbPushResult = spawnSync('pnpm', ['run', 'db:push'], { stdio: 'inherit', encoding: 'utf-8', shell: true });
if (dbPushResult.status !== 0) {
console.error(chalk.red('❌ Failed to run "pnpm run db:push". Please check the error above.'));
process.exit(1);

View File

@@ -15,9 +15,9 @@
"scripts": {
"build": "tsc",
"dev": "nodemon --watch . --ext ts --ignore dist --exec 'pnpm run build'",
"db:push": "NODE_OPTIONS='--import tsx' drizzle-kit push --config drizzle.config.ts",
"db:generate": "NODE_OPTIONS='--import tsx' drizzle-kit generate --config drizzle.config.ts",
"db:migrate": "NODE_OPTIONS='--import tsx' drizzle-kit migrate --config drizzle.config.ts"
"db:push": "cross-env NODE_OPTIONS=\"--import tsx\" pnpm exec drizzle-kit push --config drizzle.config.ts",
"db:generate": "cross-env NODE_OPTIONS=\"--import tsx\" pnpm exec drizzle-kit generate --config drizzle.config.ts",
"db:migrate": "cross-env NODE_OPTIONS=\"--import tsx\" pnpm exec drizzle-kit migrate --config drizzle.config.ts"
},
"dependencies": {
"decimal.js": "^10.5.0",
@@ -25,7 +25,8 @@
"drizzle-kit": "^0.31.1",
"drizzle-orm": "^0.43.1",
"drizzle-zod": "^0.8.2",
"zod": "^3.25.23"
"zod": "^3.25.23",
"cross-env": "^7.0.3"
},
"devDependencies": {
"@types/node": "^24.0.3",

View File

@@ -10,7 +10,8 @@
"moduleResolution": "NodeNext",
"target": "ES2020",
"outDir": "./dist",
"rootDir": "."
"rootDir": ".",
},
"include": ["./**/*"],
"types": ["node"],