-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a9beac
Showing
20 changed files
with
688 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEXT_PUBLIC_FFRAME_BASE_URL=http://127.0.0.1:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 fframe | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# create-fframe-app | ||
|
||
This is an interactive CLI to start a [farcaster frames](https://docs.farcaster.xyz/learn/what-is-farcaster/frames) server application using Next.js and TypeScript. | ||
|
||
Load this example frame using [warpcast's frame validator](https://warpcast.com/~/developers/frames): | ||
`https://create-fframe-app.vercel.app/api/example` | ||
|
||
## getting started | ||
|
||
make sure you have Node.js and npx installed, then run: | ||
```bash | ||
npx create-fframe-app | ||
# or | ||
npx create-fframe-app@latest | ||
``` | ||
|
||
to add a new frame applet, run this from your project root: | ||
```bash | ||
npm run generate-applet my-applet | ||
# or | ||
yarn generate-applet my-applet | ||
``` | ||
|
||
## local testing | ||
start the development server locally: | ||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
then: | ||
* [click here](http://127.0.0.1:3000/api/example/images?frameId=1) to test image generation | ||
* [click here](http://127.0.0.1:3000/api/example?frameId=0) to test the API response | ||
|
||
## server testing | ||
|
||
to test a live server deployment: | ||
* deploy your _fframe_ app on [vercel](https://vercel.com) | ||
* add `NEXT_PUBLIC_FFRAME_BASE_URL=https://{your-project-name}.vercel.app` as an environment variable and redeploy the project | ||
* test using [warpcast's frame validator](https://warpcast.com/~/developers/frames) (paste `https://{your-project-name}.vercel.app/api/{your_applet_id}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env node | ||
|
||
|
||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
const fs = require('fs'); | ||
const { generateApplet } = require('./generate-applet'); | ||
|
||
function createProject(projectName, firstAppletName) { | ||
const projectPath = path.resolve(projectName); | ||
const gitRepoUrl = 'https://github.com/fframes/create-fframe-app.git'; | ||
|
||
// clone the repository | ||
console.log(`cloning the template into ${projectPath}`); | ||
execSync(`git clone ${gitRepoUrl} "${projectPath}"`); | ||
|
||
// remove the .git directory | ||
fs.rmSync(path.join(projectPath, '.git'), { recursive: true, force: true }); | ||
|
||
// update package.json | ||
const packageJsonPath = path.join(projectPath, 'package.json'); | ||
let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
packageJson.name = projectName; | ||
const cfaVersion = packageJson.version; | ||
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 | ||
const binPath = path.join(projectPath, 'bin'); | ||
if (fs.existsSync(binPath)) { | ||
fs.rmSync(binPath, { recursive: true, force: true }); | ||
} | ||
|
||
// remove the example directory | ||
const examplePath = path.join(projectPath, 'src/app/api/example'); | ||
if (fs.existsSync(examplePath)) { | ||
fs.rmSync(examplePath, { recursive: true, force: true }); | ||
} | ||
|
||
const envExamplePath = path.join(projectPath, '.env.example'); | ||
const envPath = path.join(projectPath, '.env'); | ||
|
||
// generate .env file for local server | ||
if (fs.existsSync(envExamplePath)) { | ||
fs.copyFileSync(envExamplePath, envPath); | ||
fs.unlinkSync(envExamplePath); | ||
} else { | ||
console.log('.env.example does not exist, skipping copy and remove operations'); | ||
} | ||
|
||
// run npm install | ||
console.log('installing dependencies...'); | ||
execSync('npm install', { cwd: projectPath, stdio: 'inherit' }); | ||
|
||
// create first applet | ||
generateApplet(firstAppletName, projectPath); | ||
|
||
// update readme with create-fframe-app version | ||
const readmePath = path.join(projectPath, 'README.md'); | ||
const prependText = `<!-- generated by create-fframe-app version ${cfaVersion} -->\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); | ||
} | ||
|
||
// initialize a new git repository | ||
console.log('initializing a new git repository...'); | ||
execSync('git init', { cwd: projectPath }); | ||
execSync('git add .', { cwd: projectPath }); | ||
execSync('git commit -m "initial commit from create-fframe-app"', { cwd: projectPath }); | ||
|
||
console.log(`🔲✅ ${projectName} has been initialized with git and dependencies installed ✅🔲\n`); | ||
} | ||
|
||
function main() { | ||
const readline = require('readline'); | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
rl.question('enter the name of your project: ', function (projectName) { | ||
rl.question('enter your first fframe name (default is project name): ', function (fframeName) { | ||
fframeName = fframeName.trim() || projectName; | ||
createProject(projectName, fframeName); | ||
rl.close(); | ||
}); | ||
}); | ||
|
||
rl.on('close', function () { | ||
console.log(`🔲✅ fframe app successfully generated ✅🔲\n`); | ||
process.exit(0); | ||
}); | ||
} | ||
|
||
module.exports = { createProject: main }; |
Oops, something went wrong.