From f3f8924fa98e87d6909c7660aa5351c276360d17 Mon Sep 17 00:00:00 2001 From: veganbeef Date: Thu, 8 May 2025 10:49:15 -0700 Subject: [PATCH] fix: windows compatibility --- bin/init.js | 29 ++++++++++++++++++++++++----- package.json | 2 +- scripts/build.js | 7 ++++++- scripts/deploy.js | 13 ++++++++++--- scripts/dev.js | 7 +++---- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/bin/init.js b/bin/init.js index ebf5730..7f70a50 100644 --- a/bin/init.js +++ b/bin/init.js @@ -224,9 +224,20 @@ export async function init() { try { console.log(`\nCloning repository from ${REPO_URL}...`); // Use separate commands for better cross-platform compatibility - execSync(`git clone ${REPO_URL} "${projectPath}"`, { stdio: 'inherit' }); - execSync('git fetch origin main', { cwd: projectPath, stdio: 'inherit' }); - execSync('git reset --hard origin/main', { cwd: projectPath, stdio: 'inherit' }); + execSync(`git clone ${REPO_URL} "${projectPath}"`, { + stdio: 'inherit', + shell: process.platform === 'win32' + }); + execSync('git fetch origin main', { + cwd: projectPath, + stdio: 'inherit', + shell: process.platform === 'win32' + }); + execSync('git reset --hard origin/main', { + cwd: projectPath, + stdio: 'inherit', + shell: process.platform === 'win32' + }); } catch (error) { console.error('\n❌ Error: Failed to create project directory.'); console.error('Please make sure you have write permissions and try again.'); @@ -353,8 +364,16 @@ export async function init() { // Install dependencies console.log('\nInstalling dependencies...'); - execSync('npm cache clean --force', { cwd: projectPath, stdio: 'inherit' }); - execSync('npm install', { cwd: projectPath, stdio: 'inherit' }); + execSync('npm cache clean --force', { + cwd: projectPath, + stdio: 'inherit', + shell: process.platform === 'win32' + }); + execSync('npm install', { + cwd: projectPath, + stdio: 'inherit', + shell: process.platform === 'win32' + }); // Remove the bin directory console.log('\nRemoving bin directory...'); diff --git a/package.json b/package.json index 6ba8e42..4dba629 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@neynar/create-farcaster-mini-app", - "version": "1.2.19", + "version": "1.2.21", "type": "module", "private": false, "access": "public", diff --git a/scripts/build.js b/scripts/build.js index ebab645..e00c77c 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -388,7 +388,12 @@ async function main() { // Run next build console.log('\nBuilding Next.js application...'); - execSync('next build', { cwd: projectRoot, stdio: 'inherit' }); + const nextBin = path.normalize(path.join(projectRoot, 'node_modules', '.bin', 'next')); + execSync(`"${nextBin}" build`, { + cwd: projectRoot, + stdio: 'inherit', + shell: process.platform === 'win32' + }); console.log('\n✨ Build complete! Your frame is ready for deployment. 🪐'); console.log('📝 Make sure to configure the environment variables from .env in your hosting provider'); diff --git a/scripts/deploy.js b/scripts/deploy.js index b746fd7..4f60879 100755 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -245,7 +245,10 @@ async function getGitRemote() { async function checkVercelCLI() { try { - execSync('vercel --version', { stdio: 'ignore' }); + execSync('vercel --version', { + stdio: 'ignore', + shell: process.platform === 'win32' + }); return true; } catch (error) { return false; @@ -254,7 +257,10 @@ async function checkVercelCLI() { async function installVercelCLI() { console.log('Installing Vercel CLI...'); - execSync('npm install -g vercel', { stdio: 'inherit' }); + execSync('npm install -g vercel', { + stdio: 'inherit', + shell: process.platform === 'win32' + }); } async function loginToVercel() { @@ -383,7 +389,8 @@ async function deployToVercel(useGitHub = false) { console.log('\n⚠️ Note: choosing a longer, more unique project name will help avoid conflicts with other existing domains\n'); execSync('vercel', { cwd: projectRoot, - stdio: 'inherit' + stdio: 'inherit', + shell: process.platform === 'win32' }); // Load project info from .vercel/project.json diff --git a/scripts/dev.js b/scripts/dev.js index 58546f0..8fe48c6 100755 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -128,14 +128,13 @@ async function startDev() { } // Start next dev with appropriate configuration - const nextBin = process.platform === 'win32' - ? path.join(projectRoot, 'node_modules', '.bin', 'next.cmd') - : path.join(projectRoot, 'node_modules', '.bin', 'next'); + const nextBin = path.normalize(path.join(projectRoot, 'node_modules', '.bin', 'next')); nextDev = spawn(nextBin, ['dev'], { stdio: 'inherit', env: { ...process.env, NEXT_PUBLIC_URL: frameUrl, NEXTAUTH_URL: frameUrl }, - cwd: projectRoot + cwd: projectRoot, + shell: process.platform === 'win32' // Add shell option for Windows }); // Handle cleanup