update to .env.local

This commit is contained in:
lucas-neynar 2025-03-14 18:48:29 -07:00
parent 6f105d37c7
commit 82f0b3510a
No known key found for this signature in database

View File

@ -161,7 +161,7 @@ async function init() {
{
type: 'password',
name: 'seedPhrase',
message: 'Enter your Farcaster custody account seed phrase to generate a signed manifest for your frame\n(optional -- leave blank to create an unsigned frame)\n(seed phrase is only ever stored locally)\n\nSeed phrase:',
message: 'Enter your Farcaster custody account seed phrase to generate a signed manifest for your frame\n(optional -- leave blank to create an unsigned frame)\n(seed phrase is only ever stored in .env.local)\n\nSeed phrase:',
default: null
}
]);
@ -301,12 +301,12 @@ async function init() {
// Handle .env file
console.log('\nSetting up environment variables...');
const envExamplePath = path.join(projectPath, '.env.example');
const envPath = path.join(projectPath, '.env');
const envLocalPath = path.join(projectPath, '.env.local');
if (fs.existsSync(envExamplePath)) {
// Read the example file content
const envExampleContent = fs.readFileSync(envExamplePath, 'utf8');
// Write it to .env
fs.writeFileSync(envPath, envExampleContent);
// Write it to .env.local
fs.writeFileSync(envLocalPath, envExampleContent);
// Generate custody address from seed phrase
if (answers.seedPhrase) {
@ -318,27 +318,32 @@ async function init() {
const neynarApiKey = answers.useNeynar ? answers.neynarApiKey : 'FARCASTER_V2_FRAMES_DEMO';
const fid = await lookupFidByCustodyAddress(custodyAddress, neynarApiKey);
// Write seed phrase and FID to .env for manifest signature generation
fs.appendFileSync(envPath, `\nSEED_PHRASE="${answers.seedPhrase}"`);
fs.appendFileSync(envPath, `\nFID="${fid}"`);
// Write seed phrase and FID to .env.local for manifest signature generation
fs.appendFileSync(envLocalPath, `\nSEED_PHRASE="${answers.seedPhrase}"`);
fs.appendFileSync(envLocalPath, `\nFID="${fid}"`);
}
if (answers.splashImageUrl) {
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL="${answers.splashImageUrl}"`);
fs.appendFileSync(envLocalPath, `\nNEXT_PUBLIC_FRAME_SPLASH_IMAGE_URL="${answers.splashImageUrl}"`);
}
if (answers.iconImageUrl) {
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_ICON_IMAGE_URL="${answers.iconImageUrl}"`);
fs.appendFileSync(envLocalPath, `\nNEXT_PUBLIC_FRAME_ICON_IMAGE_URL="${answers.iconImageUrl}"`);
}
// Append all remaining environment variables
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_NAME="${answers.projectName}"`);
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_DESCRIPTION="${answers.description}"`);
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_BUTTON_TEXT="${answers.buttonText}"`);
fs.appendFileSync(envPath, `\nNEYNAR_API_KEY="${answers.useNeynar ? answers.neynarApiKey : 'FARCASTER_V2_FRAMES_DEMO'}"`);
fs.appendFileSync(envLocalPath, `\nNEXT_PUBLIC_FRAME_NAME="${answers.projectName}"`);
fs.appendFileSync(envLocalPath, `\nNEXT_PUBLIC_FRAME_DESCRIPTION="${answers.description}"`);
fs.appendFileSync(envLocalPath, `\nNEXT_PUBLIC_FRAME_BUTTON_TEXT="${answers.buttonText}"`);
fs.appendFileSync(envLocalPath, `\nNEYNAR_API_KEY="${answers.useNeynar ? answers.neynarApiKey : 'FARCASTER_V2_FRAMES_DEMO'}"`);
fs.unlinkSync(envExamplePath);
console.log('\nCreated .env file from .env.example');
console.log('\nCreated .env.local file from .env.example');
// Add .env.local to .gitignore
const gitignorePath = path.join(projectPath, '.gitignore');
fs.appendFileSync(gitignorePath, '\n\n# Local environment variables\n.env.local\n.env.local.*');
console.log('Added .env.local to .gitignore');
} else {
console.log('\n.env.example does not exist, skipping copy and remove operations');
}