debug git clone inconsistencies

This commit is contained in:
lucas-neynar 2025-03-15 13:36:43 -07:00
parent f3d2c475bb
commit d2dc8b7a64
No known key found for this signature in database
3 changed files with 63 additions and 7 deletions

View File

@ -11,7 +11,7 @@ import { mnemonicToAccount } from 'viem/accounts';
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename); 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; const SCRIPT_VERSION = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')).version;
function printWelcomeMessage() { function printWelcomeMessage() {
@ -223,7 +223,17 @@ async function init() {
// Clone the repository // Clone the repository
try { 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) { } catch (error) {
console.error('\n❌ Error: Failed to create project directory.'); console.error('\n❌ Error: Failed to create project directory.');
console.error('Please make sure you have write permissions and try again.'); console.error('Please make sure you have write permissions and try again.');
@ -234,6 +244,13 @@ async function init() {
console.log('\nRemoving .git directory...'); console.log('\nRemoving .git directory...');
fs.rmSync(path.join(projectPath, '.git'), { recursive: true, force: true }); 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 // Remove package-lock.json
console.log('\nRemoving package-lock.json...'); console.log('\nRemoving package-lock.json...');
const packageLockPath = path.join(projectPath, 'package-lock.json'); const packageLockPath = path.join(projectPath, 'package-lock.json');
@ -245,6 +262,13 @@ async function init() {
console.log('\nUpdating package.json...'); console.log('\nUpdating package.json...');
const packageJsonPath = path.join(projectPath, 'package.json'); const packageJsonPath = path.join(projectPath, 'package.json');
let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); 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.name = projectName;
packageJson.version = '0.1.0'; packageJson.version = '0.1.0';
delete packageJson.author; delete packageJson.author;
@ -357,8 +381,21 @@ async function init() {
// Install dependencies // Install dependencies
console.log('\nInstalling 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' }); 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 // Remove the bin directory
console.log('\nRemoving bin directory...'); console.log('\nRemoving bin directory...');
const binPath = path.join(projectPath, 'bin'); const binPath = path.join(projectPath, 'bin');

27
dev.js
View File

@ -20,7 +20,7 @@ async function startDev() {
💻 To test on desktop: 💻 To test on desktop:
1. Open the localtunnel URL in your browser: ${tunnel.url} 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 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 4. Navigate to the Warpcast Frame Developer Tools: https://warpcast.com/~/developers/frames
5. Enter your frame URL: ${tunnel.url} 5. Enter your frame URL: ${tunnel.url}
@ -49,15 +49,33 @@ async function startDev() {
if (isCleaningUp) return; if (isCleaningUp) return;
isCleaningUp = true; isCleaningUp = true;
console.log('\n\nShutting down...');
try { try {
if (nextDev) { if (nextDev) {
nextDev.kill(); // Kill the main process first
console.log('\n🛑 Next.js dev server stopped'); 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) { if (tunnel) {
await tunnel.close(); 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) { } catch (error) {
console.error('Error during cleanup:', error); console.error('Error during cleanup:', error);
@ -69,6 +87,7 @@ async function startDev() {
// Handle process termination // Handle process termination
process.on('SIGINT', cleanup); process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup); process.on('SIGTERM', cleanup);
process.on('exit', cleanup);
tunnel.on('close', cleanup); tunnel.on('close', cleanup);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "create-neynar-farcaster-frame", "name": "create-neynar-farcaster-frame",
"version": "1.0.3", "version": "1.0.4",
"type": "module", "type": "module",
"files": [ "files": [
"bin/index.js" "bin/index.js"