use neynar notifs

This commit is contained in:
lucas-neynar
2025-03-14 17:02:56 -07:00
parent 710c8255bf
commit c9deb0512c
8 changed files with 187 additions and 212 deletions

View File

@@ -11,7 +11,7 @@ import { mnemonicToAccount } from 'viem/accounts';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const REPO_URL = 'https://github.com/lucas-neynar/frames-v2-quickstart.git';
const REPO_URL = 'https://github.com/neynarxyz/create-neynar-farcaster-frame.git';
const SCRIPT_VERSION = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')).version;
function printWelcomeMessage() {
@@ -24,7 +24,7 @@ function printWelcomeMessage() {
console.log(`
${purple}╔═══════════════════════════════════════════════════╗${reset}
${purple}║ ║${reset}
${purple}${reset} ${bright}Welcome to Frames v2 Quickstart${reset} ${purple}${reset}
${purple}${reset} ${bright}Welcome to Frames v2 Quickstart by Neynar${reset} ${purple}${reset}
${purple}${reset} ${dim}The fastest way to build Farcaster Frames${reset} ${purple}${reset}
${purple}║ ║${reset}
${purple}╚═══════════════════════════════════════════════════╝${reset}
@@ -112,31 +112,48 @@ async function init() {
name: 'iconImageUrl',
message: 'Enter the URL for your app icon\n(optional -- leave blank to use the default public/icon.png image or replace public/icon.png with your own)\n\nExternal app icon URL:',
default: null
},
{
type: 'confirm',
name: 'useNeynar',
message: 'Would you like to use Neynar in your frame?',
default: false
}
]);
// If using Neynar, ask for API key
if (answers.useNeynar) {
const neynarAnswers = await inquirer.prompt([
// Handle Neynar API key
const neynarFlow = await inquirer.prompt([
{
type: 'confirm',
name: 'useNeynar',
message: '🪐 Neynar is an API that makes it easy to build on Farcaster.\n\nBenefits of using Neynar in your frame:\n- Pre-configured webhook handling (no setup required)\n- Automatic frame analytics in your dev portal\n- Send manual notifications from dev.neynar.com\n- Built-in rate limiting and error handling\n\nWould you like to use Neynar in your frame?',
default: true
}
]);
if (neynarFlow.useNeynar) {
const neynarKeyAnswer = await inquirer.prompt([
{
type: 'password',
name: 'neynarApiKey',
message: 'Enter your Neynar API key:',
validate: (input) => {
if (input.trim() === '') {
return 'Neynar API key cannot be empty';
}
return true;
}
message: 'Enter your Neynar API key (or press enter to skip):',
default: null
}
]);
answers.neynarApiKey = neynarAnswers.neynarApiKey;
if (!neynarKeyAnswer.neynarApiKey) {
const useDemoKey = await inquirer.prompt([
{
type: 'confirm',
name: 'useDemo',
message: 'Would you like to try the demo Neynar API key?',
default: true
}
]);
answers.useNeynar = useDemoKey.useDemo;
answers.neynarApiKey = useDemoKey.useDemo ? 'FARCASTER_V2_FRAMES_DEMO' : null;
} else {
answers.useNeynar = true;
answers.neynarApiKey = neynarKeyAnswer.neynarApiKey;
}
} else {
answers.useNeynar = false;
answers.neynarApiKey = null;
}
// Ask for seed phrase last
@@ -329,7 +346,7 @@ async function init() {
// Update README
console.log('\nUpdating README...');
const readmePath = path.join(projectPath, 'README.md');
const prependText = `<!-- generated by frames-v2-quickstart version ${SCRIPT_VERSION} -->\n\n`;
const prependText = `<!-- generated by create-neynar-farcaster-frame version ${SCRIPT_VERSION} -->\n\n`;
if (fs.existsSync(readmePath)) {
const originalReadmeContent = fs.readFileSync(readmePath, { encoding: 'utf8' });
const updatedReadmeContent = prependText + originalReadmeContent;
@@ -353,7 +370,7 @@ async function init() {
console.log('\nInitializing git repository...');
execSync('git init', { cwd: projectPath });
execSync('git add .', { cwd: projectPath });
execSync('git commit -m "initial commit from frames-v2-quickstart"', { cwd: projectPath });
execSync('git commit -m "initial commit from create-neynar-farcaster-frame"', { cwd: projectPath });
// Calculate border length based on message length
const message = `✨🪐 Successfully created frame ${projectName} with git and dependencies installed! 🪐✨`;