revolutionary-ui
Version:
Revolutionary UI v3.0 - AI-Powered Interactive CLI with 10+ AI providers, website inspiration analyzer, and advanced code generation
478 lines ⢠19.6 kB
JavaScript
"use strict";
/**
* Revolutionary UI Factory - Interactive Setup Wizard
* Guides users through package selection and configuration
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetupWizard = void 0;
const inquirer = require('inquirer');
const chalk_1 = __importDefault(require("chalk"));
const frameworks_1 = require("../../config/frameworks");
const ui_libraries_1 = require("../../config/ui-libraries");
const icon_libraries_1 = require("../../config/icon-libraries");
const design_tools_1 = require("../../config/design-tools");
class SetupWizard {
analysis;
report;
options;
aiResults;
constructor(analysis, report, options, aiResults) {
this.analysis = analysis;
this.report = report;
this.options = options;
this.aiResults = aiResults;
}
/**
* Run the interactive setup wizard
*/
async run() {
console.clear();
this.printWelcome();
this.printAnalysisSummary();
let selections;
if (this.options.interactive) {
selections = await this.interactiveSelection();
}
else {
selections = await this.automaticSelection();
}
const installCommands = this.generateInstallCommands(selections);
const configFiles = this.generateConfigFiles(selections);
const nextSteps = this.generateNextSteps(selections);
return {
selections,
installCommands,
configFiles,
nextSteps
};
}
/**
* Print welcome message
*/
printWelcome() {
console.log(chalk_1.default.bold.magenta('\nš Revolutionary UI Factory Setup Wizard\n'));
console.log(chalk_1.default.gray('Transform your development with 60-95% less code!\n'));
}
/**
* Print analysis summary
*/
printAnalysisSummary() {
const { summary } = this.report;
console.log(chalk_1.default.bold('š Project Analysis Summary:\n'));
console.log(chalk_1.default.cyan('Project:'), this.analysis.projectName);
console.log(chalk_1.default.cyan('Package Manager:'), this.analysis.packageManager);
console.log(chalk_1.default.cyan('TypeScript:'), this.analysis.hasTypeScript ? 'ā
' : 'ā');
console.log(chalk_1.default.cyan('Tailwind CSS:'), this.analysis.hasTailwind ? 'ā
' : 'ā');
console.log(chalk_1.default.cyan('\nCurrent Stack:'));
if (summary.frameworkStack.length > 0) {
console.log(' Frameworks:', summary.frameworkStack.join(', '));
}
if (summary.uiStack.length > 0) {
console.log(' UI Libraries:', summary.uiStack.join(', '));
}
console.log(chalk_1.default.cyan('\nCoverage:'));
console.log(` Overall: ${summary.coverage.overall}%`);
console.log(` Frameworks: ${summary.coverage.frameworks}%`);
console.log(` UI Libraries: ${summary.coverage.uiLibraries}%`);
console.log(` Icons: ${summary.coverage.icons}%`);
console.log(` Design Tools: ${summary.coverage.designTools}%`);
if (this.report.compatibility.warnings.length > 0) {
console.log(chalk_1.default.yellow('\nā ļø Warnings:'));
this.report.compatibility.warnings.forEach(warning => {
console.log(` - ${warning}`);
});
}
console.log('');
}
/**
* Interactive package selection
*/
async interactiveSelection() {
const selections = {
frameworks: [],
uiLibraries: [],
iconLibraries: [],
designTools: [],
colorTools: [],
fonts: [],
utilities: [],
devTools: []
};
// Ask about missing features first
if (this.report.missingFeatures.length > 0) {
const { addMissing } = await inquirer.prompt([{
type: 'confirm',
name: 'addMissing',
message: 'Would you like to add the recommended missing features?',
default: true
}]);
if (addMissing) {
for (const feature of this.report.missingFeatures) {
const { addFeature } = await inquirer.prompt([{
type: 'confirm',
name: 'addFeature',
message: `Add ${feature.feature}? (${feature.description})`,
default: feature.impact !== 'nice-to-have'
}]);
if (addFeature) {
const { selected } = await inquirer.prompt({
type: 'checkbox',
name: 'selected',
message: `Select ${feature.feature} packages:`,
choices: feature.suggestedPackages.map(pkg => ({
name: pkg,
checked: feature.suggestedPackages.indexOf(pkg) === 0
}))
});
// Add to appropriate category
this.categorizePackages(selected, selections);
}
}
}
}
// Ask about updates
const needsUpdate = [
...this.analysis.frameworks,
...this.analysis.uiLibraries,
...this.analysis.iconLibraries
].filter(pkg => pkg.needsUpdate);
if (needsUpdate.length > 0 && this.options.updateExisting) {
const { updatePackages } = await inquirer.prompt([{
type: 'confirm',
name: 'updatePackages',
message: `${needsUpdate.length} packages have updates available. Update them?`,
default: true
}]);
if (updatePackages) {
const { packagesToUpdate } = await inquirer.prompt([{
type: 'checkbox',
name: 'packagesToUpdate',
message: 'Select packages to update:',
choices: needsUpdate.map(pkg => ({
name: `${pkg.name} (${pkg.currentVersion} ā ${pkg.latestVersion})`,
value: pkg.name,
checked: true
}))
}]);
// Add update commands will be handled in generateInstallCommands
selections.frameworks.push(...packagesToUpdate.filter((p) => this.analysis.frameworks.some(f => f.name === p)));
}
}
// Browse additional packages
const { browseMore } = await inquirer.prompt([{
type: 'confirm',
name: 'browseMore',
message: 'Would you like to browse additional packages?',
default: false
}]);
if (browseMore) {
await this.browsePackages(selections);
}
// Development tools
const { addDevTools } = await inquirer.prompt([{
type: 'confirm',
name: 'addDevTools',
message: 'Configure development tools (TypeScript, ESLint, Prettier)?',
default: !this.analysis.hasTypeScript || !this.analysis.hasESLint
}]);
if (addDevTools) {
const devToolChoices = [];
if (!this.analysis.hasTypeScript) {
devToolChoices.push({ name: 'TypeScript', value: 'typescript', checked: true });
}
if (!this.analysis.hasESLint) {
devToolChoices.push({ name: 'ESLint', value: 'eslint', checked: true });
}
if (!this.analysis.hasPrettier) {
devToolChoices.push({ name: 'Prettier', value: 'prettier', checked: true });
}
if (devToolChoices.length > 0) {
const { selectedDevTools } = await inquirer.prompt([{
type: 'checkbox',
name: 'selectedDevTools',
message: 'Select development tools:',
choices: devToolChoices
}]);
selections.devTools = selectedDevTools;
}
}
return selections;
}
/**
* Automatic package selection based on recommendations
*/
async automaticSelection() {
console.log(chalk_1.default.yellow('\nš¤ Running in automatic mode...\n'));
const selections = {
frameworks: [],
uiLibraries: [],
iconLibraries: [],
designTools: [],
colorTools: [],
fonts: [],
utilities: [],
devTools: []
};
// Add all critical and important missing features
for (const feature of this.report.missingFeatures) {
if (feature.impact !== 'nice-to-have') {
const packages = feature.suggestedPackages.slice(0, 1); // Just the first suggestion
this.categorizePackages(packages, selections);
}
}
// Add recommended packages
for (const rec of this.report.recommendations) {
if (rec.priority === 'high') {
const packages = rec.packages.slice(0, 1); // Just the first suggestion
this.categorizePackages(packages, selections);
}
}
// Add essential dev tools if missing
if (!this.analysis.hasTypeScript)
selections.devTools.push('typescript');
if (!this.analysis.hasESLint)
selections.devTools.push('eslint');
if (!this.analysis.hasPrettier)
selections.devTools.push('prettier');
return selections;
}
/**
* Browse additional packages
*/
async browsePackages(selections) {
const categories = [
{ name: 'UI Component Libraries', value: 'ui' },
{ name: 'Icon Libraries', value: 'icons' },
{ name: 'Design Tools', value: 'design' },
{ name: 'Color & Styling Tools', value: 'color' },
{ name: 'Fonts', value: 'fonts' },
{ name: 'Done browsing', value: 'done' }
];
let browsing = true;
while (browsing) {
const { category } = await inquirer.prompt([{
type: 'list',
name: 'category',
message: 'Browse packages by category:',
choices: categories
}]);
if (category === 'done') {
browsing = false;
continue;
}
const packages = this.getPackagesByCategory(category);
const installed = this.getInstalledPackages(category);
const { selected } = await inquirer.prompt([{
type: 'checkbox',
name: 'selected',
message: `Select ${categories.find(c => c.value === category)?.name}:`,
choices: packages.map(pkg => ({
name: `${pkg.name} - ${pkg.description}`,
value: pkg.packageName,
checked: false,
disabled: installed.includes(pkg.packageName) ? '(Already installed)' : false
}))
}]);
this.categorizePackages(selected, selections);
}
}
/**
* Generate install commands
*/
generateInstallCommands(selections) {
const commands = [];
const pm = this.options.packageManager;
const installCmd = pm === 'npm' ? 'install' : 'add';
// Group packages by type
const allPackages = [
...selections.frameworks,
...selections.uiLibraries,
...selections.iconLibraries,
...selections.designTools,
...selections.colorTools,
...selections.fonts,
...selections.utilities
];
const devPackages = [...selections.devTools];
// Add TypeScript types if TypeScript is selected
if (selections.devTools.includes('typescript')) {
devPackages.push('@types/node', '@types/react', '@types/react-dom');
}
if (allPackages.length > 0) {
commands.push(`${pm} ${installCmd} ${allPackages.join(' ')}`);
}
if (devPackages.length > 0) {
commands.push(`${pm} ${installCmd} ${pm === 'npm' ? '--save-dev' : '-D'} ${devPackages.join(' ')}`);
}
// Add initialization commands
if (selections.devTools.includes('typescript') && !this.analysis.hasTypeScript) {
commands.push('npx tsc --init');
}
if (selections.devTools.includes('eslint') && !this.analysis.hasESLint) {
commands.push('npx eslint --init');
}
if (selections.uiLibraries.includes('tailwindcss') && !this.analysis.hasTailwind) {
commands.push('npx tailwindcss init -p');
}
return commands;
}
/**
* Generate configuration files
*/
generateConfigFiles(selections) {
const configs = [];
// TypeScript config
if (selections.devTools.includes('typescript') && !this.analysis.hasTypeScript) {
configs.push({
filename: 'tsconfig.json',
description: 'TypeScript configuration',
content: JSON.stringify({
compilerOptions: {
target: 'ES2022',
lib: ['dom', 'dom.iterable', 'esnext'],
allowJs: true,
skipLibCheck: true,
strict: true,
forceConsistentCasingInFileNames: true,
noEmit: true,
esModuleInterop: true,
module: 'esnext',
moduleResolution: 'bundler',
resolveJsonModule: true,
isolatedModules: true,
jsx: 'preserve',
incremental: true,
paths: {
'../../*': ['./src/*']
}
},
include: ['next-env.d.ts', '**/*.ts', '**/*.tsx'],
exclude: ['node_modules']
}, null, 2)
});
}
// Tailwind config
if (selections.uiLibraries.includes('tailwindcss') && !this.analysis.hasTailwind) {
configs.push({
filename: 'tailwind.config.js',
description: 'Tailwind CSS configuration',
content: `/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [
${selections.utilities.includes('@tailwindcss/forms') ? "require('@tailwindcss/forms')," : ''}
${selections.utilities.includes('@tailwindcss/typography') ? "require('@tailwindcss/typography')," : ''}
],
}`
});
}
// Prettier config
if (selections.devTools.includes('prettier') && !this.analysis.hasPrettier) {
configs.push({
filename: '.prettierrc',
description: 'Prettier configuration',
content: JSON.stringify({
semi: false,
trailingComma: 'es5',
singleQuote: true,
tabWidth: 2,
useTabs: false
}, null, 2)
});
}
// Revolutionary UI Factory config
configs.push({
filename: 'revolutionary-ui.config.js',
description: 'Revolutionary UI Factory configuration',
content: `module.exports = {
frameworks: [${selections.frameworks.map(f => `'${f}'`).join(', ')}],
uiLibraries: [${selections.uiLibraries.map(l => `'${l}'`).join(', ')}],
iconLibraries: [${selections.iconLibraries.map(i => `'${i}'`).join(', ')}],
theme: {
// Add your custom theme configuration here
},
components: {
// Component-specific configurations
}
}`
});
return configs;
}
/**
* Generate next steps
*/
generateNextSteps(selections) {
const steps = [];
steps.push('Run the install commands to add selected packages');
if (selections.devTools.includes('typescript')) {
steps.push('Update your file extensions from .js/.jsx to .ts/.tsx');
}
if (selections.uiLibraries.length > 0) {
steps.push('Import and start using UI components in your project');
}
if (selections.iconLibraries.length > 0) {
steps.push('Replace existing icons with your new icon library');
}
steps.push('Run "npx revolutionary-ui generate" to create your first component');
steps.push('Visit https://revolutionary-ui.com/docs for documentation');
return steps;
}
// Helper methods
categorizePackages(packages, selections) {
for (const pkg of packages) {
if (frameworks_1.FRAMEWORK_CONFIGS.some(f => f.packageName === pkg)) {
selections.frameworks.push(pkg);
}
else if (ui_libraries_1.UI_LIBRARIES.some(l => l.packageName === pkg)) {
selections.uiLibraries.push(pkg);
}
else if (icon_libraries_1.ICON_LIBRARIES.some(i => i.packageName === pkg)) {
selections.iconLibraries.push(pkg);
}
else if (design_tools_1.DESIGN_TOOLS.some(d => d.packageName === pkg)) {
selections.designTools.push(pkg);
}
else if (design_tools_1.COLOR_TOOLS.some(c => c.packageName === pkg)) {
selections.colorTools.push(pkg);
}
else if (design_tools_1.FONTS.some(f => f.packageName === pkg)) {
selections.fonts.push(pkg);
}
else {
selections.utilities.push(pkg);
}
}
}
getPackagesByCategory(category) {
switch (category) {
case 'ui': return ui_libraries_1.UI_LIBRARIES;
case 'icons': return icon_libraries_1.ICON_LIBRARIES;
case 'design': return design_tools_1.DESIGN_TOOLS;
case 'color': return design_tools_1.COLOR_TOOLS;
case 'fonts': return design_tools_1.FONTS;
default: return [];
}
}
getInstalledPackages(category) {
switch (category) {
case 'ui': return this.analysis.uiLibraries.filter(l => l.installed).map(l => l.name);
case 'icons': return this.analysis.iconLibraries.filter(l => l.installed).map(l => l.name);
case 'design': return this.analysis.designTools.filter(t => t.installed).map(t => t.name);
case 'color': return this.analysis.colorTools.filter(t => t.installed).map(t => t.name);
case 'fonts': return this.analysis.fonts.filter(f => f.installed).map(f => f.name);
default: return [];
}
}
}
exports.SetupWizard = SetupWizard;
//# sourceMappingURL=setup-wizard.js.map