fix: frame manifest

This commit is contained in:
lucas-neynar 2025-03-21 13:20:56 -07:00
parent 44eeeddfc2
commit 01231de8f4
No known key found for this signature in database
4 changed files with 60 additions and 45 deletions

View File

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

View File

@ -441,69 +441,84 @@ async function deployToVercel(useGitHub = false) {
console.log('\n🔍 Verifying deployment domain...'); console.log('\n🔍 Verifying deployment domain...');
const projectOutput = execSync('vercel project ls', { const projectOutput = execSync('vercel project ls', {
cwd: projectRoot, cwd: projectRoot,
encoding: 'utf8' encoding: 'utf8',
stdio: ['inherit', 'pipe', 'inherit'] // Capture stdout but show stderr
}); });
const projectLines = projectOutput.split('\n'); const projectLines = projectOutput.split('\n');
const currentProject = projectLines.find(line => line.includes(projectName)); console.log('Project lines:', projectLines);
console.log('currentProject');
console.log(currentProject); // Find the line containing our project name
const currentProject = projectLines.find(line =>
line.includes(projectName) && line.includes('https://')
);
console.log('Current project line:', currentProject);
if (currentProject) { if (currentProject) {
const actualDomain = currentProject.split(/\s+/)[1]?.replace('https://', ''); // Extract the domain from the line
if (actualDomain && actualDomain !== domain) { const domainMatch = currentProject.match(/https:\/\/([^\s]+)/);
console.log(`⚠️ Actual domain (${actualDomain}) differs from assumed domain (${domain})`); if (domainMatch) {
console.log('🔄 Updating environment variables with correct domain...'); const actualDomain = domainMatch[1];
if (actualDomain !== domain) {
// Update domain-dependent environment variables console.log(`⚠️ Actual domain (${actualDomain}) differs from assumed domain (${domain})`);
const webhookUrl = process.env.NEYNAR_API_KEY && process.env.NEYNAR_CLIENT_ID console.log('🔄 Updating environment variables with correct domain...');
? `https://api.neynar.com/f/app/${process.env.NEYNAR_CLIENT_ID}/event`
: `https://${actualDomain}/api/webhook`; // Update domain-dependent environment variables
const webhookUrl = process.env.NEYNAR_API_KEY && process.env.NEYNAR_CLIENT_ID
? `https://api.neynar.com/f/app/${process.env.NEYNAR_CLIENT_ID}/event`
: `https://${actualDomain}/api/webhook`;
if (frameMetadata) { if (frameMetadata) {
frameMetadata = await generateFarcasterMetadata(actualDomain, await validateSeedPhrase(process.env.SEED_PHRASE), process.env.SEED_PHRASE, webhookUrl); frameMetadata = await generateFarcasterMetadata(actualDomain, await validateSeedPhrase(process.env.SEED_PHRASE), process.env.SEED_PHRASE, webhookUrl);
// Update FRAME_METADATA env var // Update FRAME_METADATA env var
try {
execSync(`vercel env rm FRAME_METADATA production -y`, {
cwd: projectRoot,
stdio: 'ignore',
env: process.env
});
execSync(`printf "%s" "${frameMetadata}" | vercel env add FRAME_METADATA production`, {
cwd: projectRoot,
stdio: 'inherit',
env: process.env
});
} catch (error) {
console.warn('⚠️ Warning: Failed to update FRAME_METADATA with correct domain');
}
}
// Update NEXTAUTH_URL
try { try {
execSync(`vercel env rm FRAME_METADATA production -y`, { execSync(`vercel env rm NEXTAUTH_URL production -y`, {
cwd: projectRoot, cwd: projectRoot,
stdio: 'ignore', stdio: 'ignore',
env: process.env env: process.env
}); });
execSync(`printf "%s" "${frameMetadata}" | vercel env add FRAME_METADATA production`, { execSync(`printf "%s" "https://${actualDomain}" | vercel env add NEXTAUTH_URL production`, {
cwd: projectRoot, cwd: projectRoot,
stdio: 'inherit', stdio: 'inherit',
env: process.env env: process.env
}); });
} catch (error) { } catch (error) {
console.warn('⚠️ Warning: Failed to update FRAME_METADATA with correct domain'); console.warn('⚠️ Warning: Failed to update NEXTAUTH_URL with correct domain');
} }
}
// Update NEXTAUTH_URL // Redeploy with updated environment variables
try { console.log('\n📦 Redeploying with correct domain...');
execSync(`vercel env rm NEXTAUTH_URL production -y`, { execSync('vercel deploy --prod', {
cwd: projectRoot,
stdio: 'ignore',
env: process.env
});
execSync(`printf "%s" "https://${actualDomain}" | vercel env add NEXTAUTH_URL production`, {
cwd: projectRoot, cwd: projectRoot,
stdio: 'inherit', stdio: 'inherit',
env: process.env env: process.env
}); });
} catch (error) {
console.warn('⚠️ Warning: Failed to update NEXTAUTH_URL with correct domain'); domain = actualDomain;
} }
} else {
// Redeploy with updated environment variables console.warn('⚠️ Could not extract domain from project line');
console.log('\n📦 Redeploying with correct domain...');
execSync('vercel deploy --prod', {
cwd: projectRoot,
stdio: 'inherit',
env: process.env
});
domain = actualDomain;
} }
} else {
console.warn('⚠️ Could not find project in Vercel project list');
} }

View File

@ -5,8 +5,8 @@ const appUrl = process.env.NEXT_PUBLIC_URL;
// frame preview metadata // frame preview metadata
const appName = process.env.NEXT_PUBLIC_FRAME_NAME; const appName = process.env.NEXT_PUBLIC_FRAME_NAME;
const splashImageUrl = process.env.NEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL || `${appUrl}/splash.png`; const splashImageUrl = `${appUrl}/splash.png`;
const iconUrl = process.env.NEXT_PUBLIC_FRAME_ICON_IMAGE_URL || `${appUrl}/icon.png`; const iconUrl = `${appUrl}/icon.png`;
const framePreviewMetadata = { const framePreviewMetadata = {
version: "next", version: "next",

View File

@ -104,11 +104,11 @@ export async function getFarcasterMetadata(): Promise<FrameMetadata> {
frame: { frame: {
version: "1", version: "1",
name: process.env.NEXT_PUBLIC_FRAME_NAME || "Frames v2 Demo", name: process.env.NEXT_PUBLIC_FRAME_NAME || "Frames v2 Demo",
iconUrl: process.env.NEXT_PUBLIC_FRAME_ICON_IMAGE_URL || `${appUrl}/icon.png`, iconUrl: `${appUrl}/icon.png`,
homeUrl: appUrl, homeUrl: appUrl,
imageUrl: `${appUrl}/opengraph-image`, imageUrl: `${appUrl}/opengraph-image`,
buttonTitle: process.env.NEXT_PUBLIC_FRAME_BUTTON_TEXT || "Launch Frame", buttonTitle: process.env.NEXT_PUBLIC_FRAME_BUTTON_TEXT || "Launch Frame",
splashImageUrl: process.env.NEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL || `${appUrl}/splash.png`, splashImageUrl: `${appUrl}/splash.png`,
splashBackgroundColor: "#f7f7f7", splashBackgroundColor: "#f7f7f7",
webhookUrl, webhookUrl,
}, },