feat: update deploy parsing

This commit is contained in:
lucas-neynar 2025-03-21 14:08:06 -07:00
parent 01231de8f4
commit 28cafb2808
No known key found for this signature in database
3 changed files with 112 additions and 69 deletions

View File

@ -17,6 +17,12 @@ cd <PROJECT_NAME>
npm run dev
```
## Deploy to Vercel
For projects that have made minimal changes to the quickstart template, deploy to vercel by running:
```{bash}
npm run deploy:vercel
```
## Building for Production
To create a production build, run:

View File

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

View File

@ -373,13 +373,7 @@ async function deployToVercel(useGitHub = false) {
...(process.env.NEYNAR_API_KEY && { NEYNAR_API_KEY: process.env.NEYNAR_API_KEY }),
...(process.env.NEYNAR_CLIENT_ID && { NEYNAR_CLIENT_ID: process.env.NEYNAR_CLIENT_ID }),
// Frame metadata and images
...(process.env.NEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL && {
NEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL: process.env.NEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL
}),
...(process.env.NEXT_PUBLIC_FRAME_ICON_IMAGE_URL && {
NEXT_PUBLIC_FRAME_ICON_IMAGE_URL: process.env.NEXT_PUBLIC_FRAME_ICON_IMAGE_URL
}),
// Frame metadata
...(frameMetadata && { FRAME_METADATA: frameMetadata }),
// Public vars
@ -388,8 +382,6 @@ async function deployToVercel(useGitHub = false) {
.filter(([key]) => key.startsWith('NEXT_PUBLIC_'))
)
};
console.log('vercelEnv');
console.log(vercelEnv);
// Add or update env vars in Vercel project
console.log('\n📝 Setting up environment variables...');
@ -439,18 +431,31 @@ async function deployToVercel(useGitHub = false) {
// Verify the actual domain after deployment
console.log('\n🔍 Verifying deployment domain...');
const projectOutput = execSync('vercel project ls', {
// Create a temporary file path
const tempOutputFile = path.join(projectRoot, 'vercel_output.txt');
try {
// Redirect output to a file
execSync(`vercel project ls > "${tempOutputFile}" 2>&1`, {
cwd: projectRoot,
encoding: 'utf8',
stdio: ['inherit', 'pipe', 'inherit'] // Capture stdout but show stderr
shell: true
});
const projectLines = projectOutput.split('\n');
// Read the output file
const projectOutput = fs.readFileSync(tempOutputFile, 'utf8');
console.log('Raw project output:', projectOutput);
// Process the output
const projectLines = projectOutput
.split('\n')
.filter(line => line.includes('https://'));
console.log('Project lines:', projectLines);
// Find the line containing our project name
const currentProject = projectLines.find(line =>
line.includes(projectName) && line.includes('https://')
line.includes(projectName)
);
console.log('Current project line:', currentProject);
@ -504,6 +509,22 @@ async function deployToVercel(useGitHub = false) {
console.warn('⚠️ Warning: Failed to update NEXTAUTH_URL with correct domain');
}
// Update NEXT_PUBLIC_URL
try {
execSync(`vercel env rm NEXT_PUBLIC_URL production -y`, {
cwd: projectRoot,
stdio: 'ignore',
env: process.env
});
execSync(`printf "%s" "https://${actualDomain}" | vercel env add NEXT_PUBLIC_URL production`, {
cwd: projectRoot,
stdio: 'inherit',
env: process.env
});
} catch (error) {
console.warn('⚠️ Warning: Failed to update NEXT_PUBLIC_URL with correct domain');
}
// Redeploy with updated environment variables
console.log('\n📦 Redeploying with correct domain...');
execSync('vercel deploy --prod', {
@ -521,6 +542,22 @@ async function deployToVercel(useGitHub = false) {
console.warn('⚠️ Could not find project in Vercel project list');
}
// Clean up the temporary file
fs.unlinkSync(tempOutputFile);
} catch (error) {
console.error('Error:', error);
// Try to read the output file even if there was an error
try {
if (fs.existsSync(tempOutputFile)) {
const errorOutput = fs.readFileSync(tempOutputFile, 'utf8');
console.log('Error output file contents:', errorOutput);
fs.unlinkSync(tempOutputFile);
}
} catch (readError) {
console.error('Error reading output file:', readError);
}
}
console.log('\n✨ Deployment complete! Your frame is now live at:');
console.log(`🌐 https://${domain}`);