mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
feat: add more flags to script
This commit is contained in:
parent
d9c74f163b
commit
e8fa822638
31
bin/index.js
31
bin/index.js
@ -7,6 +7,10 @@ const args = process.argv.slice(2);
|
|||||||
let projectName = null;
|
let projectName = null;
|
||||||
let autoAcceptDefaults = false;
|
let autoAcceptDefaults = false;
|
||||||
let apiKey = null;
|
let apiKey = null;
|
||||||
|
let noWallet = false;
|
||||||
|
let noTunnel = false;
|
||||||
|
let sponsoredSigner = false;
|
||||||
|
let seedPhrase = null;
|
||||||
|
|
||||||
// Check for -y flag
|
// Check for -y flag
|
||||||
const yIndex = args.indexOf('-y');
|
const yIndex = args.indexOf('-y');
|
||||||
@ -45,6 +49,31 @@ if (yIndex !== -1) {
|
|||||||
console.error('Error: -k/--api-key requires an API key');
|
console.error('Error: -k/--api-key requires an API key');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
} else if (arg === '--no-wallet') {
|
||||||
|
noWallet = true;
|
||||||
|
args.splice(i, 1); // Remove the flag
|
||||||
|
i--; // Adjust index since we removed 1 element
|
||||||
|
} else if (arg === '--no-tunnel') {
|
||||||
|
noTunnel = true;
|
||||||
|
args.splice(i, 1); // Remove the flag
|
||||||
|
i--; // Adjust index since we removed 1 element
|
||||||
|
} else if (arg === '--sponsored-signer') {
|
||||||
|
sponsoredSigner = true;
|
||||||
|
args.splice(i, 1); // Remove the flag
|
||||||
|
i--; // Adjust index since we removed 1 element
|
||||||
|
} else if (arg === '--seed-phrase') {
|
||||||
|
if (i + 1 < args.length) {
|
||||||
|
seedPhrase = args[i + 1];
|
||||||
|
if (seedPhrase.startsWith('-')) {
|
||||||
|
console.error('Error: Seed phrase cannot start with a dash (-)');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
args.splice(i, 2); // Remove both the flag and its value
|
||||||
|
i--; // Adjust index since we removed 2 elements
|
||||||
|
} else {
|
||||||
|
console.error('Error: --seed-phrase requires a seed phrase');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +85,7 @@ if (autoAcceptDefaults && !projectName) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
init(projectName, autoAcceptDefaults, apiKey).catch((err) => {
|
init(projectName, autoAcceptDefaults, apiKey, noWallet, noTunnel, sponsoredSigner, seedPhrase).catch((err) => {
|
||||||
console.error('Error:', err);
|
console.error('Error:', err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
29
bin/init.js
29
bin/init.js
@ -63,7 +63,7 @@ async function queryNeynarApp(apiKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export the main CLI function for programmatic use
|
// Export the main CLI function for programmatic use
|
||||||
export async function init(projectName = null, autoAcceptDefaults = false, apiKey = null) {
|
export async function init(projectName = null, autoAcceptDefaults = false, apiKey = null, noWallet = false, noTunnel = false, sponsoredSigner = false, seedPhrase = null) {
|
||||||
printWelcomeMessage();
|
printWelcomeMessage();
|
||||||
|
|
||||||
// Ask about Neynar usage
|
// Ask about Neynar usage
|
||||||
@ -225,7 +225,7 @@ export async function init(projectName = null, autoAcceptDefaults = false, apiKe
|
|||||||
primaryCategory: null,
|
primaryCategory: null,
|
||||||
tags: [],
|
tags: [],
|
||||||
buttonText: 'Launch Mini App',
|
buttonText: 'Launch Mini App',
|
||||||
useWallet: true,
|
useWallet: !noWallet,
|
||||||
useTunnel: true,
|
useTunnel: true,
|
||||||
enableAnalytics: true,
|
enableAnalytics: true,
|
||||||
seedPhrase: null,
|
seedPhrase: null,
|
||||||
@ -312,7 +312,10 @@ export async function init(projectName = null, autoAcceptDefaults = false, apiKe
|
|||||||
// Merge project name from the first prompt
|
// Merge project name from the first prompt
|
||||||
answers.projectName = projectNamePrompt.projectName;
|
answers.projectName = projectNamePrompt.projectName;
|
||||||
|
|
||||||
// Ask about wallet and transaction tooling
|
// Ask about wallet and transaction tooling (skip if --no-wallet flag is used)
|
||||||
|
if (noWallet) {
|
||||||
|
answers.useWallet = false;
|
||||||
|
} else {
|
||||||
const walletAnswer = await inquirer.prompt([
|
const walletAnswer = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
@ -330,8 +333,12 @@ export async function init(projectName = null, autoAcceptDefaults = false, apiKe
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
answers.useWallet = walletAnswer.useWallet;
|
answers.useWallet = walletAnswer.useWallet;
|
||||||
|
}
|
||||||
|
|
||||||
// Ask about localhost vs tunnel
|
// Ask about localhost vs tunnel
|
||||||
|
if (noTunnel) {
|
||||||
|
answers.useTunnel = false;
|
||||||
|
} else {
|
||||||
const hostingAnswer = await inquirer.prompt([
|
const hostingAnswer = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
@ -344,8 +351,23 @@ export async function init(projectName = null, autoAcceptDefaults = false, apiKe
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
answers.useTunnel = hostingAnswer.useTunnel;
|
answers.useTunnel = hostingAnswer.useTunnel;
|
||||||
|
}
|
||||||
|
|
||||||
// Ask about Neynar Sponsored Signers / SIWN
|
// Ask about Neynar Sponsored Signers / SIWN
|
||||||
|
if (sponsoredSigner) {
|
||||||
|
answers.useSponsoredSigner = true;
|
||||||
|
if (seedPhrase) {
|
||||||
|
// Validate the provided seed phrase
|
||||||
|
if (!seedPhrase || seedPhrase.trim().split(' ').length < 12) {
|
||||||
|
console.error('Error: Seed phrase must be at least 12 words');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
answers.seedPhrase = seedPhrase;
|
||||||
|
} else {
|
||||||
|
console.error('Error: --sponsored-signer requires --seed-phrase to be provided');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const sponsoredSignerAnswer = await inquirer.prompt([
|
const sponsoredSignerAnswer = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
@ -374,6 +396,7 @@ export async function init(projectName = null, autoAcceptDefaults = false, apiKe
|
|||||||
]);
|
]);
|
||||||
answers.seedPhrase = seedPhrase;
|
answers.seedPhrase = seedPhrase;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ask about analytics opt-out
|
// Ask about analytics opt-out
|
||||||
const analyticsAnswer = await inquirer.prompt([
|
const analyticsAnswer = await inquirer.prompt([
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@neynar/create-farcaster-mini-app",
|
"name": "@neynar/create-farcaster-mini-app",
|
||||||
"version": "1.7.9",
|
"version": "1.7.10",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": false,
|
"private": false,
|
||||||
"access": "public",
|
"access": "public",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user