@vladimirdukelic/revolutionary-ui-factory
Version:
Revolutionary UI Factory System v2 - Generate ANY UI component for ANY framework with 60-95% code reduction
198 lines • 9.84 kB
JavaScript
;
/**
* Revolutionary UI Factory - Post Install Script
* Automatically runs setup wizard after package installation
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const ora_1 = __importDefault(require("ora"));
const project_detector_1 = require("./project-detector");
const project_analyzer_1 = require("./project-analyzer");
const ai_analyzer_1 = require("./ai-analyzer");
const setup_wizard_1 = require("./setup-wizard");
const package_installer_1 = require("./package-installer");
const fs = __importStar(require("fs/promises"));
const path = __importStar(require("path"));
// Check if we're in a CI environment
const isCI = process.env.CI === 'true' ||
process.env.CONTINUOUS_INTEGRATION === 'true' ||
process.env.GITHUB_ACTIONS === 'true' ||
process.env.GITLAB_CI === 'true' ||
process.env.CIRCLECI === 'true';
// Check if this is being run as part of the package's own install
const isOwnInstall = process.cwd().includes('revolutionary-ui-marketplace');
async function runPostInstall() {
// Skip in CI environments or when installing the package itself
if (isCI || isOwnInstall) {
return;
}
console.clear();
// Welcome message
console.log(chalk_1.default.magenta.bold(`
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ 🏭 Revolutionary UI Factory ║
║ Thank you for installing! ║
║ ║
║ Transform your development with 60-95% less code! ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
`));
console.log(chalk_1.default.cyan('✨ Initializing Revolutionary UI Factory...\n'));
try {
// Step 1: Analyze the project
const spinner = (0, ora_1.default)('Analyzing your project...').start();
const detector = new project_detector_1.ProjectDetector();
const analysis = await detector.analyze();
const analyzer = new project_analyzer_1.ProjectAnalyzer(analysis);
const report = analyzer.generateReport();
spinner.succeed('Project analysis complete!');
// Step 2: Run AI analysis
spinner.start('Running AI-powered analysis...');
const aiAnalyzer = new ai_analyzer_1.AIAnalyzer(analysis, report);
const aiResults = await aiAnalyzer.generateAIRecommendations();
spinner.succeed('AI analysis complete!');
// Display AI insights
console.log(chalk_1.default.bold.blue('\n🤖 AI Insights:\n'));
if (aiResults.projectInsights.length > 0) {
console.log(chalk_1.default.cyan('Project Insights:'));
aiResults.projectInsights.forEach(insight => {
console.log(` ${insight}`);
});
console.log();
}
// Display top AI recommendations
if (aiResults.recommendations.length > 0) {
console.log(chalk_1.default.cyan('Top Recommendations:'));
aiResults.recommendations
.filter(rec => rec.priority === 'critical' || rec.priority === 'high')
.slice(0, 3)
.forEach(rec => {
console.log(chalk_1.default.yellow(`\n 📌 ${rec.category}: ${rec.recommendation}`));
console.log(chalk_1.default.gray(` ${rec.reasoning}`));
console.log(chalk_1.default.green(` Impact: ${rec.estimatedImpact}`));
});
console.log();
}
// Step 3: Ask if user wants to proceed with setup
console.log(chalk_1.default.bold.yellow('\n🚀 Ready to set up Revolutionary UI Factory?\n'));
console.log('This will:');
console.log(' • Install recommended packages based on AI analysis');
console.log(' • Configure your project for optimal performance');
console.log(' • Set up development tools and scripts');
console.log(' • Create example components to get you started');
console.log();
// For postinstall, we'll use automatic mode with AI recommendations
const wizardOptions = {
interactive: false, // Use automatic mode for postinstall
autoInstall: true,
updateExisting: true,
packageManager: analysis.packageManager
};
// Create a configuration file to track that setup has been run
const configPath = path.join(process.cwd(), '.revolutionary-ui-setup');
try {
await fs.access(configPath);
console.log(chalk_1.default.yellow('ℹ️ Revolutionary UI Factory has already been set up for this project.'));
console.log(chalk_1.default.gray(' Run "npx revolutionary-ui setup" to reconfigure.\n'));
return;
}
catch {
// Config doesn't exist, continue with setup
}
// Step 4: Run setup wizard in automatic mode
console.log(chalk_1.default.cyan('🔧 Running automatic setup based on AI recommendations...\n'));
const wizard = new setup_wizard_1.SetupWizard(analysis, report, { autoInstall: true }, aiResults);
const wizardResult = await wizard.run();
// Step 5: Install packages
if (wizardResult.installCommands.length > 0) {
const installOptions = {
dryRun: false,
verbose: false,
force: false,
skipConfigFiles: false,
packageManager: analysis.packageManager
};
const installer = new package_installer_1.PackageInstaller(process.cwd(), installOptions);
const installResult = await installer.install(wizardResult);
// Display results
console.log(chalk_1.default.bold.green('\n✅ Setup Complete!\n'));
if (installResult.installedPackages.length > 0) {
console.log(chalk_1.default.green(`✓ Installed ${installResult.installedPackages.length} packages`));
}
if (installResult.configFilesCreated.length > 0) {
console.log(chalk_1.default.green(`✓ Created ${installResult.configFilesCreated.length} configuration files`));
}
// Save setup configuration
await fs.writeFile(configPath, JSON.stringify({
version: '2.1.0',
setupDate: new Date().toISOString(),
installedPackages: installResult.installedPackages,
aiRecommendations: aiResults.recommendations.length
}, null, 2));
}
// Step 6: Display next steps
console.log(chalk_1.default.bold.blue('\n🎯 Next Steps:\n'));
const nextSteps = [
'Use "npx revolutionary-ui generate <component>" to create components',
'Run "npx revolutionary-ui analyze" to see detailed project analysis',
'Visit https://revolutionary-ui.com/docs for documentation',
...aiResults.nextSteps.slice(0, 2)
];
nextSteps.forEach((step, index) => {
console.log(chalk_1.default.cyan(`${index + 1}. ${step}`));
});
console.log(chalk_1.default.bold.green('\n✨ Happy coding with Revolutionary UI Factory!\n'));
console.log(chalk_1.default.gray('Generate UI components with 60-95% less code.\n'));
}
catch (error) {
console.error(chalk_1.default.red('\n❌ Setup failed:'), error.message);
console.log(chalk_1.default.yellow('\nYou can manually run setup with: npx revolutionary-ui setup\n'));
// Don't fail the install
process.exit(0);
}
}
// Run the postinstall script
runPostInstall().catch(error => {
console.error('Postinstall error:', error);
// Don't fail the install
process.exit(0);
});
//# sourceMappingURL=postinstall.js.map