mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-15 23:58:56 -05:00
format
This commit is contained in:
parent
3815f45b44
commit
5fbd9c5c09
@ -90,3 +90,6 @@ build/Release
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
|
||||
# Scripts that should be ignored by eslint
|
||||
scripts/deploy.ts
|
||||
|
||||
32
bin/init.js
32
bin/init.js
@ -488,19 +488,19 @@ export async function init(
|
||||
};
|
||||
|
||||
packageJson.devDependencies = {
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@vercel/sdk": "^1.9.0",
|
||||
"crypto": "^1.0.1",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "15.0.3",
|
||||
"localtunnel": "^2.0.2",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5",
|
||||
"ts-node": "^10.9.2"
|
||||
'@types/node': '^20',
|
||||
'@types/react': '^19',
|
||||
'@types/react-dom': '^19',
|
||||
'@vercel/sdk': '^1.9.0',
|
||||
crypto: '^1.0.1',
|
||||
eslint: '^8',
|
||||
'eslint-config-next': '15.0.3',
|
||||
localtunnel: '^2.0.2',
|
||||
'pino-pretty': '^13.0.0',
|
||||
postcss: '^8',
|
||||
tailwindcss: '^3.4.1',
|
||||
typescript: '^5',
|
||||
'ts-node': '^10.9.2',
|
||||
};
|
||||
|
||||
// Add Neynar SDK if selected
|
||||
@ -553,7 +553,8 @@ export async function init(
|
||||
|
||||
// Regex patterns that match whole lines with export const (with TypeScript types)
|
||||
const patterns = {
|
||||
APP_NAME: /^export const APP_NAME\s*:\s*string\s*=\s*['"`][^'"`]*['"`];$/m,
|
||||
APP_NAME:
|
||||
/^export const APP_NAME\s*:\s*string\s*=\s*['"`][^'"`]*['"`];$/m,
|
||||
APP_DESCRIPTION:
|
||||
/^export const APP_DESCRIPTION\s*:\s*string\s*=\s*['"`][^'"`]*['"`];$/m,
|
||||
APP_PRIMARY_CATEGORY:
|
||||
@ -561,7 +562,8 @@ export async function init(
|
||||
APP_TAGS: /^export const APP_TAGS\s*:\s*string\[\]\s*=\s*\[[^\]]*\];$/m,
|
||||
APP_BUTTON_TEXT:
|
||||
/^export const APP_BUTTON_TEXT\s*:\s*string\s*=\s*['"`][^'"`]*['"`];$/m,
|
||||
USE_WALLET: /^export const USE_WALLET\s*:\s*boolean\s*=\s*(true|false);$/m,
|
||||
USE_WALLET:
|
||||
/^export const USE_WALLET\s*:\s*boolean\s*=\s*(true|false);$/m,
|
||||
ANALYTICS_ENABLED:
|
||||
/^export const ANALYTICS_ENABLED\s*:\s*boolean\s*=\s*(true|false);$/m,
|
||||
};
|
||||
|
||||
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@neynar/create-farcaster-mini-app",
|
||||
"version": "1.6.2",
|
||||
"version": "1.6.3",
|
||||
"type": "module",
|
||||
"private": false,
|
||||
"access": "public",
|
||||
@ -35,6 +35,9 @@
|
||||
"build:raw": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"format:check": "prettier --check .",
|
||||
"format": "prettier --write . && eslint --fix . --max-warnings 50",
|
||||
"deploy:vercel": "ts-node scripts/deploy.ts",
|
||||
"deploy:raw": "vercel --prod",
|
||||
"cleanup": "node scripts/cleanup.js"
|
||||
@ -50,6 +53,11 @@
|
||||
"devDependencies": {
|
||||
"@neynar/nodejs-sdk": "^2.19.0",
|
||||
"@types/node": "^22.13.10",
|
||||
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
||||
"@typescript-eslint/parser": "^8.35.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-next": "^15.0.0",
|
||||
"prettier": "^3.3.3",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,18 +73,20 @@ async function checkRequiredEnvVars(): Promise<void> {
|
||||
name: 'NEXT_PUBLIC_MINI_APP_NAME',
|
||||
message: 'Enter the name for your frame (e.g., My Cool Mini App):',
|
||||
default: APP_NAME,
|
||||
validate: (input: string) => input.trim() !== '' || 'Mini app name cannot be empty'
|
||||
validate: (input: string) =>
|
||||
input.trim() !== '' || 'Mini app name cannot be empty',
|
||||
},
|
||||
{
|
||||
name: 'NEXT_PUBLIC_MINI_APP_BUTTON_TEXT',
|
||||
message: 'Enter the text for your frame button:',
|
||||
default: APP_BUTTON_TEXT ?? 'Launch Mini App',
|
||||
validate: (input: string) => input.trim() !== '' || 'Button text cannot be empty'
|
||||
}
|
||||
validate: (input: string) =>
|
||||
input.trim() !== '' || 'Button text cannot be empty',
|
||||
},
|
||||
];
|
||||
|
||||
const missingVars = requiredVars.filter(
|
||||
(varConfig) => !process.env[varConfig.name]
|
||||
varConfig => !process.env[varConfig.name],
|
||||
);
|
||||
|
||||
if (missingVars.length > 0) {
|
||||
@ -110,7 +112,7 @@ async function checkRequiredEnvVars(): Promise<void> {
|
||||
const newLine = envContent ? '\n' : '';
|
||||
fs.appendFileSync(
|
||||
'.env',
|
||||
`${newLine}${varConfig.name}="${value.trim()}"`
|
||||
`${newLine}${varConfig.name}="${value.trim()}"`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -133,7 +135,7 @@ async function checkRequiredEnvVars(): Promise<void> {
|
||||
if (storeSeedPhrase) {
|
||||
fs.appendFileSync(
|
||||
'.env.local',
|
||||
`\nSPONSOR_SIGNER="${sponsorSigner}"`
|
||||
`\nSPONSOR_SIGNER="${sponsorSigner}"`,
|
||||
);
|
||||
console.log('✅ Sponsor signer preference stored in .env.local');
|
||||
}
|
||||
@ -171,8 +173,8 @@ async function getGitRemote(): Promise<string | null> {
|
||||
|
||||
async function checkVercelCLI(): Promise<boolean> {
|
||||
try {
|
||||
execSync('vercel --version', {
|
||||
stdio: 'ignore'
|
||||
execSync('vercel --version', {
|
||||
stdio: 'ignore',
|
||||
});
|
||||
return true;
|
||||
} catch (error: unknown) {
|
||||
@ -185,8 +187,8 @@ async function checkVercelCLI(): Promise<boolean> {
|
||||
|
||||
async function installVercelCLI(): Promise<void> {
|
||||
console.log('Installing Vercel CLI...');
|
||||
execSync('npm install -g vercel', {
|
||||
stdio: 'inherit'
|
||||
execSync('npm install -g vercel', {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
@ -222,7 +224,9 @@ async function getVercelToken(): Promise<string | null> {
|
||||
return null; // We'll fall back to CLI operations
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error('Not logged in to Vercel CLI. Please run this script again to login.');
|
||||
throw new Error(
|
||||
'Not logged in to Vercel CLI. Please run this script again to login.',
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@ -239,7 +243,7 @@ async function loginToVercel(): Promise<boolean> {
|
||||
console.log('3. Complete the Vercel account setup in your browser');
|
||||
console.log('4. Return here once your Vercel account is created\n');
|
||||
console.log(
|
||||
'\nNote: you may need to cancel this script with ctrl+c and run it again if creating a new vercel account'
|
||||
'\nNote: you may need to cancel this script with ctrl+c and run it again if creating a new vercel account',
|
||||
);
|
||||
|
||||
const child = spawn('vercel', ['login'], {
|
||||
@ -247,14 +251,14 @@ async function loginToVercel(): Promise<boolean> {
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
child.on('close', (code) => {
|
||||
child.on('close', code => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
console.log('\n📱 Waiting for login to complete...');
|
||||
console.log(
|
||||
"If you're creating a new account, please complete the Vercel account setup in your browser first."
|
||||
"If you're creating a new account, please complete the Vercel account setup in your browser first.",
|
||||
);
|
||||
|
||||
for (let i = 0; i < 150; i++) {
|
||||
@ -263,10 +267,13 @@ async function loginToVercel(): Promise<boolean> {
|
||||
console.log('✅ Successfully logged in to Vercel!');
|
||||
return true;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error && error.message.includes('Account not found')) {
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message.includes('Account not found')
|
||||
) {
|
||||
console.log('ℹ️ Waiting for Vercel account setup to complete...');
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +284,12 @@ async function loginToVercel(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function setVercelEnvVarSDK(vercelClient: Vercel, projectId: string, key: string, value: string | object): Promise<boolean> {
|
||||
async function setVercelEnvVarSDK(
|
||||
vercelClient: Vercel,
|
||||
projectId: string,
|
||||
key: string,
|
||||
value: string | object,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
let processedValue: string;
|
||||
if (typeof value === 'object') {
|
||||
@ -291,8 +303,8 @@ async function setVercelEnvVarSDK(vercelClient: Vercel, projectId: string, key:
|
||||
idOrName: projectId,
|
||||
});
|
||||
|
||||
const existingVar = existingVars.envs?.find((env: any) =>
|
||||
env.key === key && env.target?.includes('production')
|
||||
const existingVar = existingVars.envs?.find(
|
||||
(env: any) => env.key === key && env.target?.includes('production'),
|
||||
);
|
||||
|
||||
if (existingVar) {
|
||||
@ -323,14 +335,21 @@ async function setVercelEnvVarSDK(vercelClient: Vercel, projectId: string, key:
|
||||
return true;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.warn(`⚠️ Warning: Failed to set environment variable ${key}:`, error.message);
|
||||
console.warn(
|
||||
`⚠️ Warning: Failed to set environment variable ${key}:`,
|
||||
error.message,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function setVercelEnvVarCLI(key: string, value: string | object, projectRoot: string): Promise<boolean> {
|
||||
async function setVercelEnvVarCLI(
|
||||
key: string,
|
||||
value: string | object,
|
||||
projectRoot: string,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
// Remove existing env var
|
||||
try {
|
||||
@ -365,7 +384,7 @@ async function setVercelEnvVarCLI(key: string, value: string | object, projectRo
|
||||
execSync(command, {
|
||||
cwd: projectRoot,
|
||||
stdio: 'pipe', // Changed from 'inherit' to avoid interactive prompts
|
||||
env: process.env
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
fs.unlinkSync(tempFilePath);
|
||||
@ -377,18 +396,26 @@ async function setVercelEnvVarCLI(key: string, value: string | object, projectRo
|
||||
fs.unlinkSync(tempFilePath);
|
||||
}
|
||||
if (error instanceof Error) {
|
||||
console.warn(`⚠️ Warning: Failed to set environment variable ${key}:`, error.message);
|
||||
console.warn(
|
||||
`⚠️ Warning: Failed to set environment variable ${key}:`,
|
||||
error.message,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function setEnvironmentVariables(vercelClient: Vercel | null, projectId: string | null, envVars: Record<string, string | object>, projectRoot: string): Promise<Array<{ key: string; success: boolean }>> {
|
||||
async function setEnvironmentVariables(
|
||||
vercelClient: Vercel | null,
|
||||
projectId: string | null,
|
||||
envVars: Record<string, string | object>,
|
||||
projectRoot: string,
|
||||
): Promise<Array<{ key: string; success: boolean }>> {
|
||||
console.log('\n📝 Setting up environment variables...');
|
||||
|
||||
|
||||
const results: Array<{ key: string; success: boolean }> = [];
|
||||
|
||||
|
||||
for (const [key, value] of Object.entries(envVars)) {
|
||||
if (!value) continue;
|
||||
|
||||
@ -408,19 +435,24 @@ async function setEnvironmentVariables(vercelClient: Vercel | null, projectId: s
|
||||
}
|
||||
|
||||
// Report results
|
||||
const failed = results.filter((r) => !r.success);
|
||||
const failed = results.filter(r => !r.success);
|
||||
if (failed.length > 0) {
|
||||
console.warn(`\n⚠️ Failed to set ${failed.length} environment variables:`);
|
||||
failed.forEach((r) => console.warn(` - ${r.key}`));
|
||||
failed.forEach(r => console.warn(` - ${r.key}`));
|
||||
console.warn(
|
||||
'\nYou may need to set these manually in the Vercel dashboard.'
|
||||
'\nYou may need to set these manually in the Vercel dashboard.',
|
||||
);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
async function waitForDeployment(vercelClient: Vercel | null, projectId: string, maxWaitTime = 300000): Promise<any> { // 5 minutes
|
||||
async function waitForDeployment(
|
||||
vercelClient: Vercel | null,
|
||||
projectId: string,
|
||||
maxWaitTime = 300000,
|
||||
): Promise<any> {
|
||||
// 5 minutes
|
||||
console.log('\n⏳ Waiting for deployment to complete...');
|
||||
const startTime = Date.now();
|
||||
|
||||
@ -430,7 +462,7 @@ async function waitForDeployment(vercelClient: Vercel | null, projectId: string,
|
||||
projectId: projectId,
|
||||
limit: 1,
|
||||
});
|
||||
|
||||
|
||||
if (deployments?.deployments?.[0]) {
|
||||
const deployment = deployments.deployments[0];
|
||||
console.log(`📊 Deployment status: ${deployment.state}`);
|
||||
@ -445,10 +477,10 @@ async function waitForDeployment(vercelClient: Vercel | null, projectId: string,
|
||||
}
|
||||
|
||||
// Still building, wait and check again
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait 5 seconds
|
||||
await new Promise(resolve => setTimeout(resolve, 5000)); // Wait 5 seconds
|
||||
} else {
|
||||
console.log('⏳ No deployment found yet, waiting...');
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
@ -478,58 +510,60 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
framework: 'nextjs',
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
2,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Set up Vercel project
|
||||
console.log('\n📦 Setting up Vercel project...');
|
||||
console.log(
|
||||
'An initial deployment is required to get an assigned domain that can be used in the mini app manifest\n'
|
||||
'An initial deployment is required to get an assigned domain that can be used in the mini app manifest\n',
|
||||
);
|
||||
console.log(
|
||||
'\n⚠️ Note: choosing a longer, more unique project name will help avoid conflicts with other existing domains\n'
|
||||
'\n⚠️ Note: choosing a longer, more unique project name will help avoid conflicts with other existing domains\n',
|
||||
);
|
||||
|
||||
// Use spawn instead of execSync for better error handling
|
||||
const { spawn } = await import('child_process');
|
||||
const vercelSetup = spawn('vercel', [], {
|
||||
cwd: projectRoot,
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32' ? true : undefined
|
||||
});
|
||||
const vercelSetup = spawn('vercel', [], {
|
||||
cwd: projectRoot,
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32' ? true : undefined,
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
vercelSetup.on('close', (code) => {
|
||||
vercelSetup.on('close', code => {
|
||||
if (code === 0 || code === null) {
|
||||
console.log('✅ Vercel project setup completed');
|
||||
resolve();
|
||||
} else {
|
||||
console.log('⚠️ Vercel setup command completed (this is normal)');
|
||||
console.log('⚠️ Vercel setup command completed (this is normal)');
|
||||
resolve(); // Don't reject, as this is often expected
|
||||
}
|
||||
});
|
||||
|
||||
vercelSetup.on('error', (error) => {
|
||||
vercelSetup.on('error', error => {
|
||||
console.log('⚠️ Vercel setup command completed (this is normal)');
|
||||
resolve(); // Don't reject, as this is often expected
|
||||
});
|
||||
});
|
||||
|
||||
// Wait a moment for project files to be written
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
|
||||
// Load project info
|
||||
let projectId: string;
|
||||
try {
|
||||
const projectJson = JSON.parse(
|
||||
fs.readFileSync('.vercel/project.json', 'utf8')
|
||||
fs.readFileSync('.vercel/project.json', 'utf8'),
|
||||
);
|
||||
projectId = projectJson.projectId;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error('Failed to load project info. Please ensure the Vercel project was created successfully.');
|
||||
throw new Error(
|
||||
'Failed to load project info. Please ensure the Vercel project was created successfully.',
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@ -540,13 +574,15 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
const token = await getVercelToken();
|
||||
if (token) {
|
||||
vercelClient = new Vercel({
|
||||
bearerToken: token
|
||||
bearerToken: token,
|
||||
});
|
||||
console.log('✅ Initialized Vercel SDK client');
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.warn('⚠️ Could not initialize Vercel SDK, falling back to CLI operations');
|
||||
console.warn(
|
||||
'⚠️ Could not initialize Vercel SDK, falling back to CLI operations',
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@ -566,7 +602,9 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
console.log('🌐 Using project name for domain:', domain);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.warn('⚠️ Could not get project details via SDK, using CLI fallback');
|
||||
console.warn(
|
||||
'⚠️ Could not get project details via SDK, using CLI fallback',
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@ -580,7 +618,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
{
|
||||
cwd: projectRoot,
|
||||
encoding: 'utf8',
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const nameMatch = inspectOutput.match(/Name\s+([^\n]+)/);
|
||||
@ -596,7 +634,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
console.log('🌐 Using project name for domain:', domain);
|
||||
} else {
|
||||
console.warn(
|
||||
'⚠️ Could not determine project name from inspection, using fallback'
|
||||
'⚠️ Could not determine project name from inspection, using fallback',
|
||||
);
|
||||
// Use a fallback domain based on project ID
|
||||
domain = `project-${projectId.slice(-8)}.vercel.app`;
|
||||
@ -622,15 +660,21 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
AUTH_SECRET: nextAuthSecret,
|
||||
NEXTAUTH_URL: `https://${domain}`,
|
||||
NEXT_PUBLIC_URL: `https://${domain}`,
|
||||
|
||||
...(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 }),
|
||||
...(process.env.SPONSOR_SIGNER && { SPONSOR_SIGNER: process.env.SPONSOR_SIGNER }),
|
||||
|
||||
|
||||
...(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,
|
||||
}),
|
||||
...(process.env.SPONSOR_SIGNER && {
|
||||
SPONSOR_SIGNER: process.env.SPONSOR_SIGNER,
|
||||
}),
|
||||
|
||||
...Object.fromEntries(
|
||||
Object.entries(process.env).filter(([key]) =>
|
||||
key.startsWith('NEXT_PUBLIC_')
|
||||
)
|
||||
key.startsWith('NEXT_PUBLIC_'),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
@ -639,7 +683,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
vercelClient,
|
||||
projectId,
|
||||
vercelEnv,
|
||||
projectRoot
|
||||
projectRoot,
|
||||
);
|
||||
|
||||
// Deploy the project
|
||||
@ -663,7 +707,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
vercelDeploy.on('close', (code) => {
|
||||
vercelDeploy.on('close', code => {
|
||||
if (code === 0) {
|
||||
console.log('✅ Vercel deployment command completed');
|
||||
resolve();
|
||||
@ -673,7 +717,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
}
|
||||
});
|
||||
|
||||
vercelDeploy.on('error', (error) => {
|
||||
vercelDeploy.on('error', error => {
|
||||
console.error('❌ Vercel deployment error:', error.message);
|
||||
reject(error);
|
||||
});
|
||||
@ -686,7 +730,10 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
deployment = await waitForDeployment(vercelClient, projectId);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.warn('⚠️ Could not verify deployment completion:', error.message);
|
||||
console.warn(
|
||||
'⚠️ Could not verify deployment completion:',
|
||||
error.message,
|
||||
);
|
||||
console.log('ℹ️ Proceeding with domain verification...');
|
||||
}
|
||||
throw error;
|
||||
@ -700,10 +747,12 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
if (vercelClient && deployment) {
|
||||
try {
|
||||
actualDomain = deployment.url || domain;
|
||||
console.log('🌐 Verified actual domain:', actualDomain);
|
||||
console.log('🌐 Verified actual domain:', actualDomain);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.warn('⚠️ Could not verify domain via SDK, using assumed domain');
|
||||
console.warn(
|
||||
'⚠️ Could not verify domain via SDK, using assumed domain',
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@ -718,7 +767,12 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
NEXT_PUBLIC_URL: `https://${actualDomain}`,
|
||||
};
|
||||
|
||||
await setEnvironmentVariables(vercelClient, projectId, updatedEnv, projectRoot);
|
||||
await setEnvironmentVariables(
|
||||
vercelClient,
|
||||
projectId,
|
||||
updatedEnv,
|
||||
projectRoot,
|
||||
);
|
||||
|
||||
console.log('\n📦 Redeploying with correct domain...');
|
||||
const vercelRedeploy = spawn('vercel', ['deploy', '--prod'], {
|
||||
@ -728,7 +782,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
vercelRedeploy.on('close', (code) => {
|
||||
vercelRedeploy.on('close', code => {
|
||||
if (code === 0) {
|
||||
console.log('✅ Redeployment completed');
|
||||
resolve();
|
||||
@ -738,7 +792,7 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
}
|
||||
});
|
||||
|
||||
vercelRedeploy.on('error', (error) => {
|
||||
vercelRedeploy.on('error', error => {
|
||||
console.error('❌ Redeployment error:', error.message);
|
||||
reject(error);
|
||||
});
|
||||
@ -749,13 +803,24 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
|
||||
console.log('\n✨ Deployment complete! Your mini app is now live at:');
|
||||
console.log(`🌐 https://${domain}`);
|
||||
console.log('\n📝 You can manage your project at https://vercel.com/dashboard');
|
||||
console.log(
|
||||
'\n📝 You can manage your project at https://vercel.com/dashboard',
|
||||
);
|
||||
|
||||
// Prompt user to sign manifest in browser and paste accountAssociation
|
||||
console.log(`\n⚠️ To complete your mini app manifest, you must sign it using the Farcaster developer portal.`);
|
||||
console.log('1. Go to: https://farcaster.xyz/~/developers/mini-apps/manifest?domain=' + domain);
|
||||
console.log('2. Click "Transfer Ownership" and follow the instructions to sign the manifest.');
|
||||
console.log('3. Copy the resulting accountAssociation JSON from the browser.');
|
||||
console.log(
|
||||
`\n⚠️ To complete your mini app manifest, you must sign it using the Farcaster developer portal.`,
|
||||
);
|
||||
console.log(
|
||||
'1. Go to: https://farcaster.xyz/~/developers/mini-apps/manifest?domain=' +
|
||||
domain,
|
||||
);
|
||||
console.log(
|
||||
'2. Click "Transfer Ownership" and follow the instructions to sign the manifest.',
|
||||
);
|
||||
console.log(
|
||||
'3. Copy the resulting accountAssociation JSON from the browser.',
|
||||
);
|
||||
console.log('4. Paste it below when prompted.');
|
||||
|
||||
const { userAccountAssociation } = await inquirer.prompt([
|
||||
@ -773,8 +838,8 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
} catch (e) {
|
||||
return 'Invalid JSON';
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
const parsedAccountAssociation = JSON.parse(userAccountAssociation);
|
||||
|
||||
@ -786,11 +851,10 @@ async function deployToVercel(useGitHub = false): Promise<void> {
|
||||
const newAccountAssociation = `export const APP_ACCOUNT_ASSOCIATION: AccountAssociation | undefined = ${JSON.stringify(parsedAccountAssociation, null, 2)};`;
|
||||
constantsContent = constantsContent.replace(
|
||||
/^export const APP_ACCOUNT_ASSOCIATION\s*:\s*AccountAssociation \| undefined\s*=\s*[^;]*;/m,
|
||||
newAccountAssociation
|
||||
newAccountAssociation,
|
||||
);
|
||||
fs.writeFileSync(constantsPath, constantsContent);
|
||||
console.log('\n✅ APP_ACCOUNT_ASSOCIATION updated in src/lib/constants.ts');
|
||||
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error('\n❌ Deployment failed:', error.message);
|
||||
@ -804,7 +868,7 @@ async function main(): Promise<void> {
|
||||
try {
|
||||
console.log('🚀 Vercel Mini App Deployment (SDK Edition)');
|
||||
console.log(
|
||||
'This script will deploy your mini app to Vercel using the Vercel SDK.'
|
||||
'This script will deploy your mini app to Vercel using the Vercel SDK.',
|
||||
);
|
||||
console.log('\nThe script will:');
|
||||
console.log('1. Check for required environment variables');
|
||||
@ -818,9 +882,9 @@ async function main(): Promise<void> {
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.log('📦 Installing @vercel/sdk...');
|
||||
execSync('npm install @vercel/sdk', {
|
||||
execSync('npm install @vercel/sdk', {
|
||||
cwd: projectRoot,
|
||||
stdio: 'inherit'
|
||||
stdio: 'inherit',
|
||||
});
|
||||
console.log('✅ @vercel/sdk installed successfully');
|
||||
}
|
||||
@ -880,7 +944,6 @@ async function main(): Promise<void> {
|
||||
}
|
||||
|
||||
await deployToVercel(useGitHub);
|
||||
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error('\n❌ Error:', error.message);
|
||||
@ -890,4 +953,4 @@ async function main(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
main();
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useState, useEffect } from 'react';
|
||||
import { Button } from './Button';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import { type ComposeCast } from '@farcaster/miniapp-sdk';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import { APP_URL } from '~/lib/constants';
|
||||
import { Button } from './Button';
|
||||
|
||||
interface EmbedConfig {
|
||||
path?: string;
|
||||
|
||||
@ -65,14 +65,15 @@ export const APP_SPLASH_URL: string = `${APP_URL}/splash.png`;
|
||||
* Background color for the splash screen.
|
||||
* Used as fallback when splash image is loading.
|
||||
*/
|
||||
export const APP_SPLASH_BACKGROUND_COLOR: string = "#f7f7f7";
|
||||
export const APP_SPLASH_BACKGROUND_COLOR: string = '#f7f7f7';
|
||||
|
||||
/**
|
||||
* Account association for the mini app.
|
||||
* Used to associate the mini app with a Farcaster account.
|
||||
* If not provided, the mini app will be unsigned and have limited capabilities.
|
||||
*/
|
||||
export const APP_ACCOUNT_ASSOCIATION: AccountAssociation | undefined = undefined;
|
||||
export const APP_ACCOUNT_ASSOCIATION: AccountAssociation | undefined =
|
||||
undefined;
|
||||
|
||||
// --- UI Configuration ---
|
||||
/**
|
||||
@ -89,7 +90,8 @@ export const APP_BUTTON_TEXT: string = 'Launch NSK';
|
||||
* Neynar webhook endpoint. Otherwise, falls back to a local webhook
|
||||
* endpoint for development and testing.
|
||||
*/
|
||||
export const APP_WEBHOOK_URL: string = process.env.NEYNAR_API_KEY && process.env.NEYNAR_CLIENT_ID
|
||||
export const APP_WEBHOOK_URL: string =
|
||||
process.env.NEYNAR_API_KEY && process.env.NEYNAR_CLIENT_ID
|
||||
? `https://api.neynar.com/f/app/${process.env.NEYNAR_CLIENT_ID}/event`
|
||||
: `${APP_URL}/api/webhook`;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { type Manifest } from '@farcaster/miniapp-node';
|
||||
import { type ClassValue, clsx } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import { type Manifest } from '@farcaster/miniapp-node';
|
||||
import {
|
||||
APP_BUTTON_TEXT,
|
||||
APP_DESCRIPTION,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user