UNPKG

@reuvenorg/react-native-boilerplate-ultimate

Version:

A powerful CLI tool for creating React Native projects with modular architecture. Generate, manage, and scaffold React Native applications with pre-built modules and best practices.

78 lines • 3 kB
import { Command } from 'commander'; import ora from 'ora'; import { execCommandInteractive, resolveProjectPath, getProjectInfo, getErrorMessage, logSuccess, logError, logHeader, successMessage, failMessage, infoMessage, } from '../utils/index.js'; async function refreshWatchman() { const spinner = ora('Clearing watchman watches...').start(); try { execCommandInteractive('watchman watch-del-all'); spinner.succeed(successMessage('Watchman watches cleared')); } catch (error) { spinner.fail(failMessage(`Failed to clear watchman watches: ${getErrorMessage(error)}`)); throw error; } } async function refreshModules(projectRoot) { const spinner = ora('Cleaning and reinstalling node modules...').start(); try { execCommandInteractive('rm -rf node_modules/', projectRoot); execCommandInteractive('npm install --legacy-peer-dep', projectRoot); spinner.succeed(successMessage('Node modules refreshed')); } catch (error) { spinner.fail(failMessage(`Failed to refresh node modules: ${getErrorMessage(error)}`)); throw error; } } async function refreshStart(projectRoot) { const spinner = ora('Starting with cache reset...').start(); try { spinner.info(infoMessage('Starting React Native with cache reset...')); spinner.stop(); execCommandInteractive('npm run start -- --reset-cache', projectRoot); } catch (error) { logError(`āŒ Failed to start with cache reset: ${getErrorMessage(error)}`); throw error; } } async function refreshAll(projectRoot) { const projectInfo = getProjectInfo(projectRoot); logHeader(`šŸ”„ Full refresh for "${projectInfo.displayName}" - this may take a while...`); await refreshWatchman(); await refreshModules(projectRoot); await refreshStart(projectRoot); } async function refreshAction(options) { try { const projectRoot = resolveProjectPath(options); if (options.watchman) { await refreshWatchman(); } else if (options.modules) { await refreshModules(projectRoot); } else if (options.start) { await refreshStart(projectRoot); } else { // Default to all await refreshAll(projectRoot); } if (!options.start) { logSuccess('\nšŸŽ‰ Refresh completed successfully!'); } } catch (error) { logError(`āŒ ${getErrorMessage(error)}`); process.exit(1); } } export const refreshCommand = new Command('refresh') .description('Refresh React Native project (watchman, modules, cache)') .option('-w, --watchman', 'Clear watchman watches only') .option('-m, --modules', 'Clean and reinstall node modules only') .option('-s, --start', 'Start with cache reset only') .option('--destination <path>', 'Project directory path') .action(refreshAction); //# sourceMappingURL=refresh.js.map