mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
feat: add npx script and cleanup
This commit is contained in:
parent
417611b3d7
commit
efb40c648e
@ -1,4 +1,4 @@
|
||||
KV_REST_API_TOKEN
|
||||
KV_REST_API_TOKEN=
|
||||
KV_REST_API_URL=
|
||||
NEXT_PUBLIC_URL=
|
||||
NEXTAUTH_URL=
|
||||
|
||||
112
bin/index.js
Normal file
112
bin/index.js
Normal file
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import inquirer from 'inquirer';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname } from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const REPO_URL = 'https://github.com/lucas-neynar/frames-v2-quickstart.git';
|
||||
const SCRIPT_VERSION = '0.1.0';
|
||||
|
||||
async function init() {
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'projectName',
|
||||
message: 'What is the name of your project?',
|
||||
validate: (input) => {
|
||||
if (input.trim() === '') {
|
||||
return 'Project name cannot be empty';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
const projectName = answers.projectName;
|
||||
const projectPath = path.join(process.cwd(), projectName);
|
||||
|
||||
console.log(`\nCreating a new Frames v2 app in ${projectPath}`);
|
||||
|
||||
// Clone the repository
|
||||
console.log(`\nCloning the template into ${projectPath}...`);
|
||||
execSync(`git clone ${REPO_URL} "${projectPath}"`);
|
||||
|
||||
// Remove the .git directory
|
||||
console.log('\nRemoving .git directory...');
|
||||
fs.rmSync(path.join(projectPath, '.git'), { recursive: true, force: true });
|
||||
|
||||
// Update package.json
|
||||
console.log('\nUpdating package.json...');
|
||||
const packageJsonPath = path.join(projectPath, 'package.json');
|
||||
let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
packageJson.name = projectName;
|
||||
packageJson.version = '0.1.0';
|
||||
delete packageJson.author;
|
||||
delete packageJson.keywords;
|
||||
delete packageJson.repository;
|
||||
delete packageJson.license;
|
||||
delete packageJson.bin;
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||
|
||||
// Remove the bin directory
|
||||
console.log('\nRemoving bin directory...');
|
||||
const binPath = path.join(projectPath, 'bin');
|
||||
if (fs.existsSync(binPath)) {
|
||||
fs.rmSync(binPath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
// Handle .env file
|
||||
console.log('\nSetting up environment variables...');
|
||||
const envExamplePath = path.join(projectPath, '.env.example');
|
||||
const envPath = path.join(projectPath, '.env');
|
||||
if (fs.existsSync(envExamplePath)) {
|
||||
fs.copyFileSync(envExamplePath, envPath);
|
||||
fs.unlinkSync(envExamplePath);
|
||||
console.log('Created .env file from .env.example');
|
||||
} else {
|
||||
console.log('.env.example does not exist, skipping copy and remove operations');
|
||||
}
|
||||
|
||||
// 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`;
|
||||
if (fs.existsSync(readmePath)) {
|
||||
const originalReadmeContent = fs.readFileSync(readmePath, { encoding: 'utf8' });
|
||||
const updatedReadmeContent = prependText + originalReadmeContent;
|
||||
fs.writeFileSync(readmePath, updatedReadmeContent);
|
||||
} else {
|
||||
fs.writeFileSync(readmePath, prependText);
|
||||
}
|
||||
|
||||
// Install dependencies
|
||||
console.log('\nInstalling dependencies...');
|
||||
try {
|
||||
execSync('npm install --legacy-peer-deps', { cwd: projectPath, stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.log('\nNPM install failed. Trying with yarn...');
|
||||
execSync('yarn install', { cwd: projectPath, stdio: 'inherit' });
|
||||
}
|
||||
|
||||
// Initialize git repository
|
||||
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 });
|
||||
|
||||
console.log(`\n🖼️ ✨ Successfully created ${projectName} with git and dependencies installed! ✨ 🖼️\n`);
|
||||
console.log('Next steps:');
|
||||
console.log(` cd ${projectName}`);
|
||||
console.log(' npm run dev');
|
||||
}
|
||||
|
||||
init().catch((err) => {
|
||||
console.error('Error:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
10717
package-lock.json
generated
Normal file
10717
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,12 +2,16 @@
|
||||
"name": "frames-v2-demo",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"bin": {
|
||||
"frames-v2-quickstart": "./bin/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@farcaster/auth-kit": "^0.6.0",
|
||||
"@farcaster/frame-core": "^0.0.29",
|
||||
@ -19,12 +23,13 @@
|
||||
"@upstash/redis": "^1.34.3",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"inquirer": "^12.4.3",
|
||||
"lucide-react": "^0.469.0",
|
||||
"next": "15.0.3",
|
||||
"next-auth": "^4.24.11",
|
||||
"ox": "^0.4.2",
|
||||
"react": "19.0.0-rc-66855b96-20241106",
|
||||
"react-dom": "19.0.0-rc-66855b96-20241106",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"viem": "^2.23.6",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user