fix: frame metadata formatting

This commit is contained in:
lucas-neynar 2025-03-21 13:08:36 -07:00
parent 1d55fbe940
commit 44eeeddfc2
No known key found for this signature in database
3 changed files with 15 additions and 14 deletions

View File

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

View File

@ -310,12 +310,6 @@ async function main() {
`NEXT_PUBLIC_FRAME_DESCRIPTION="${process.env.NEXT_PUBLIC_FRAME_DESCRIPTION || ''}"`,
`NEXT_PUBLIC_FRAME_BUTTON_TEXT="${buttonText}"`,
// Image URLs (if they exist in current env)
...(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}"`] : []),
// Neynar configuration (if it exists in current env)
...(process.env.NEYNAR_API_KEY ?
[`NEYNAR_API_KEY="${process.env.NEYNAR_API_KEY}"`] : []),

View File

@ -43,7 +43,7 @@ async function generateFarcasterMetadata(domain, accountAddress, seedPhrase, web
});
const encodedSignature = Buffer.from(signature, 'utf-8').toString('base64url');
return {
const metadata = {
accountAssociation: {
header: encodedHeader,
payload: encodedPayload,
@ -61,6 +61,9 @@ async function generateFarcasterMetadata(domain, accountAddress, seedPhrase, web
webhookUrl,
},
};
// Return stringified metadata to ensure proper JSON formatting
return JSON.stringify(metadata);
}
async function loadEnvLocal() {
@ -377,7 +380,7 @@ async function deployToVercel(useGitHub = false) {
...(process.env.NEXT_PUBLIC_FRAME_ICON_IMAGE_URL && {
NEXT_PUBLIC_FRAME_ICON_IMAGE_URL: process.env.NEXT_PUBLIC_FRAME_ICON_IMAGE_URL
}),
...(frameMetadata && { FRAME_METADATA: JSON.stringify(frameMetadata) }),
...(frameMetadata && { FRAME_METADATA: frameMetadata }),
// Public vars
...Object.fromEntries(
@ -385,6 +388,8 @@ 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...');
@ -402,8 +407,8 @@ async function deployToVercel(useGitHub = false) {
// Ignore errors from removal (var might not exist)
}
// Add the new env var
execSync(`echo "${value}" | vercel env add ${key} production`, {
// Add the new env var without newline
execSync(`printf "%s" "${value}" | vercel env add ${key} production`, {
cwd: projectRoot,
stdio: 'inherit',
env: process.env
@ -440,7 +445,9 @@ async function deployToVercel(useGitHub = false) {
});
const projectLines = projectOutput.split('\n');
const currentProject = projectLines.find(line => line.includes('(current)'));
const currentProject = projectLines.find(line => line.includes(projectName));
console.log('currentProject');
console.log(currentProject);
if (currentProject) {
const actualDomain = currentProject.split(/\s+/)[1]?.replace('https://', '');
if (actualDomain && actualDomain !== domain) {
@ -461,7 +468,7 @@ async function deployToVercel(useGitHub = false) {
stdio: 'ignore',
env: process.env
});
execSync(`echo "${JSON.stringify(frameMetadata)}" | vercel env add FRAME_METADATA production`, {
execSync(`printf "%s" "${frameMetadata}" | vercel env add FRAME_METADATA production`, {
cwd: projectRoot,
stdio: 'inherit',
env: process.env
@ -478,7 +485,7 @@ async function deployToVercel(useGitHub = false) {
stdio: 'ignore',
env: process.env
});
execSync(`echo "https://${actualDomain}" | vercel env add NEXTAUTH_URL production`, {
execSync(`printf "%s" "https://${actualDomain}" | vercel env add NEXTAUTH_URL production`, {
cwd: projectRoot,
stdio: 'inherit',
env: process.env