From d2dc8b7a642a71379d4bcbfbfcaf1d7c2b88e3c6 Mon Sep 17 00:00:00 2001 From: lucas-neynar Date: Sat, 15 Mar 2025 13:36:43 -0700 Subject: [PATCH] debug git clone inconsistencies --- bin/index.js | 41 +++++++++++++++++++++++++++++++++++++++-- dev.js | 27 +++++++++++++++++++++++---- package.json | 2 +- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/bin/index.js b/bin/index.js index b0f9c1d..31b17c9 100755 --- a/bin/index.js +++ b/bin/index.js @@ -11,7 +11,7 @@ import { mnemonicToAccount } from 'viem/accounts'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const REPO_URL = 'https://github.com/neynarxyz/create-neynar-farcaster-frame.git'; +const REPO_URL = 'https://github.com/neynarxyz/create-neynar-farcaster-frame.git#main'; const SCRIPT_VERSION = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')).version; function printWelcomeMessage() { @@ -223,7 +223,17 @@ async function init() { // Clone the repository try { - execSync(`git clone ${REPO_URL} "${projectPath}"`); + console.log(`\nCloning repository from ${REPO_URL}...`); + execSync(`git clone -b main ${REPO_URL} "${projectPath}" && cd "${projectPath}" && git fetch origin main && git reset --hard origin/main`); + + // Debug: Check initial page.tsx content + const pagePath = path.join(projectPath, 'src', 'app', 'page.tsx'); + if (fs.existsSync(pagePath)) { + console.log('\nInitial page.tsx content:'); + console.log(fs.readFileSync(pagePath, 'utf8')); + } else { + console.log('\npage.tsx does not exist after clone'); + } } catch (error) { console.error('\nāŒ Error: Failed to create project directory.'); console.error('Please make sure you have write permissions and try again.'); @@ -234,6 +244,13 @@ async function init() { console.log('\nRemoving .git directory...'); fs.rmSync(path.join(projectPath, '.git'), { recursive: true, force: true }); + // Debug: Check page.tsx content after .git removal + const pagePath = path.join(projectPath, 'src', 'app', 'page.tsx'); + if (fs.existsSync(pagePath)) { + console.log('\npage.tsx content after .git removal:'); + console.log(fs.readFileSync(pagePath, 'utf8')); + } + // Remove package-lock.json console.log('\nRemoving package-lock.json...'); const packageLockPath = path.join(projectPath, 'package-lock.json'); @@ -245,6 +262,13 @@ async function init() { console.log('\nUpdating package.json...'); const packageJsonPath = path.join(projectPath, 'package.json'); let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + + // Debug: Check page.tsx content after package.json update + if (fs.existsSync(pagePath)) { + console.log('\npage.tsx content after package.json update:'); + console.log(fs.readFileSync(pagePath, 'utf8')); + } + packageJson.name = projectName; packageJson.version = '0.1.0'; delete packageJson.author; @@ -357,8 +381,21 @@ async function init() { // Install dependencies console.log('\nInstalling dependencies...'); + + // Debug: Check page.tsx content before npm install + if (fs.existsSync(pagePath)) { + console.log('\npage.tsx content before npm install:'); + console.log(fs.readFileSync(pagePath, 'utf8')); + } + execSync('npm install', { cwd: projectPath, stdio: 'inherit' }); + // Debug: Check page.tsx content after npm install + if (fs.existsSync(pagePath)) { + console.log('\npage.tsx content after npm install:'); + console.log(fs.readFileSync(pagePath, 'utf8')); + } + // Remove the bin directory console.log('\nRemoving bin directory...'); const binPath = path.join(projectPath, 'bin'); diff --git a/dev.js b/dev.js index 5b748a7..8fc942c 100644 --- a/dev.js +++ b/dev.js @@ -20,7 +20,7 @@ async function startDev() { šŸ’» To test on desktop: 1. Open the localtunnel URL in your browser: ${tunnel.url} - 2. Enter your IP address in the password field${ip ? `: ${ip}` : ''} + 2. Enter your IP address in the password field${ip ? `: ${ip}` : ''} (note that this IP may be incorrect if you are using a VPN) 3. Click "Click to Submit" -- your frame should now load in the browser 4. Navigate to the Warpcast Frame Developer Tools: https://warpcast.com/~/developers/frames 5. Enter your frame URL: ${tunnel.url} @@ -49,15 +49,33 @@ async function startDev() { if (isCleaningUp) return; isCleaningUp = true; + console.log('\n\nShutting down...'); + try { if (nextDev) { - nextDev.kill(); - console.log('\nšŸ›‘ Next.js dev server stopped'); + // Kill the main process first + nextDev.kill('SIGKILL'); + // Then kill any remaining child processes in the group + process.kill(-nextDev.pid); + console.log('šŸ›‘ Next.js dev server stopped'); } if (tunnel) { await tunnel.close(); - console.log('\n🌐 Tunnel closed'); + console.log('🌐 Tunnel closed'); + } + + // Force kill any remaining processes on port 3000 + try { + if (process.platform === 'darwin') { // macOS + await spawn('lsof', ['-ti', ':3000']).stdout.on('data', (data) => { + data.toString().split('\n').forEach(pid => { + if (pid) process.kill(parseInt(pid), 'SIGKILL'); + }); + }); + } + } catch (e) { + // Ignore errors if no process found } } catch (error) { console.error('Error during cleanup:', error); @@ -69,6 +87,7 @@ async function startDev() { // Handle process termination process.on('SIGINT', cleanup); process.on('SIGTERM', cleanup); + process.on('exit', cleanup); tunnel.on('close', cleanup); } diff --git a/package.json b/package.json index 1d52708..c63941f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-neynar-farcaster-frame", - "version": "1.0.3", + "version": "1.0.4", "type": "module", "files": [ "bin/index.js"