create-universal-dapp
Version:
CLI tool to scaffold Push Chain universal applications with Next.js or Vite
52 lines ⢠3.13 kB
JavaScript
import chalk from 'chalk';
import ora from 'ora';
import fs from 'fs-extra';
import { getProjectOptions } from '../utils/prompts.js';
import { createNextjsApp } from '../templates/nextjs.js';
import { createViteApp } from '../templates/vite.js';
export async function createPushApp(projectName, options) {
try {
// Get project configuration from user
const projectOptions = await getProjectOptions(projectName, options);
console.log(chalk.blue('\nš Project Configuration:'));
console.log(chalk.gray(` Project Name: ${projectOptions.projectName}`));
console.log(chalk.gray(` Framework: ${projectOptions.framework}`));
console.log(chalk.gray(` ESLint: ${projectOptions.eslint ? 'Yes' : 'No'}`));
console.log(chalk.gray(` Target Directory: ${projectOptions.targetDir}\n`));
// Check if directory already exists
if (await fs.pathExists(projectOptions.targetDir)) {
console.log(chalk.red(`ā Directory ${projectOptions.projectName} already exists!`));
process.exit(1);
}
// Create project directory
const spinner = ora('Creating project directory...').start();
await fs.ensureDir(projectOptions.targetDir);
spinner.succeed('Project directory created');
// Generate project based on framework choice
if (projectOptions.framework === 'nextjs') {
await createNextjsApp(projectOptions);
}
else {
await createViteApp(projectOptions);
}
// Skipping auto-install to save time; user will install manually
console.log(chalk.green(`
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
`));
console.log(chalk.green.bold(` š SUCCESS! Project Created! š `));
console.log(chalk.cyan(` Your Push Chain Universal App is ready to go! `));
console.log(chalk.green(`
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
`));
console.log(chalk.blue.bold('\nš Next Steps:'));
console.log(chalk.white(` cd ${projectOptions.projectName}`));
console.log(chalk.white(` npm install`));
console.log(chalk.white(` npm run dev`));
console.log(chalk.green('\n Happy Building! šāØ\n'));
}
catch (error) {
console.error(chalk.red('ā Error creating project:'), error);
process.exit(1);
}
}
//# sourceMappingURL=create.js.map