UNPKG

create-nitro-lib

Version:
39 lines (38 loc) 2.06 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Box, Text } from 'ink'; import { useEffect, useState } from 'react'; import { generateProject } from '../utils/fileGenerator.js'; import { detectPackageManager, getRunCommand } from '../utils/packageManager.js'; export default function ProjectSetup({ projectName, skipInstall }) { const [config] = useState({ name: projectName, description: 'A React Native Nitro module', author: 'Developer', packageName: `react-native-${projectName}`, }); const [isGenerating, setIsGenerating] = useState(false); const [isComplete, setIsComplete] = useState(false); useEffect(() => { if (!isGenerating && !isComplete) { setIsGenerating(true); generateProject(config, skipInstall) .then(() => { setIsComplete(true); setIsGenerating(false); }) .catch(error => { console.error('Failed to generate project:', error); setIsGenerating(false); }); } }, [config, skipInstall, isGenerating, isComplete]); if (isComplete) { const packageManager = detectPackageManager(); const runCommand = getRunCommand(packageManager); return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "green", children: "\u2705 Project created successfully!" }), _jsxs(Text, { children: ["Next steps:", '\n', " cd ", projectName, '\n', " ", runCommand, " build", '\n', " cd example && ", runCommand, " android"] })] })); } if (isGenerating) { return _jsx(Text, { color: "yellow", children: "\uD83D\uDD27 Generating project files..." }); } return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "Using default configuration:" }), _jsxs(Text, { children: ["Description: ", config.description] }), _jsxs(Text, { children: ["Author: ", config.author] }), _jsxs(Text, { children: ["Package: ", config.packageName] })] })); }