UNPKG

kira-crud

Version:

Intelligent CRUD Generator for Laravel and Angular

136 lines (122 loc) 3.58 kB
#!/usr/bin/env node /** * Kira - Post-installation Setup Script * This script runs after npm install to help set up the environment */ const chalk = require("chalk"); const fs = require("fs"); const path = require("path"); const { execSync } = require("child_process"); const os = require("os"); /** * Display welcome message */ function displayWelcome() { console.log("\n"); console.log( chalk.blue("============================================================") ); console.log( chalk.blue(" KIRA CRUD GENERATOR SETUP ") ); console.log( chalk.blue("============================================================") ); console.log("\n"); console.log(chalk.green("✓ KIRA has been installed successfully!")); console.log("\n"); console.log( "Thank you for installing Kira CRUD Generator. This tool helps you" ); console.log( "generate full-stack CRUD components for Laravel and Angular projects." ); console.log("\n"); console.log(chalk.yellow("USAGE:")); console.log(" Run the generator with: " + chalk.cyan("kira")); console.log("\n"); console.log(chalk.yellow("HELP:")); console.log( " For documentation, visit: " + chalk.cyan( "https://gitlab.com/luxcorporate-team/generation-de-code/laravel-angular" ) ); console.log("\n"); } /** * Check if global installation and add PATH warning if needed */ function checkGlobalInstallation() { try { // Detect if this is a global installation const isGlobal = path.resolve(__dirname, "..").includes("node_modules"); if (isGlobal) { const binPath = path.join(path.resolve(__dirname, ".."), "kira.js"); // Make the file executable try { fs.chmodSync(binPath, "755"); } catch (error) { // Ignore permission errors } console.log(chalk.yellow("GLOBAL INSTALLATION DETECTED:")); console.log( "Kira was installed globally. You should be able to run it from anywhere using:" ); console.log("\n" + chalk.cyan("kira") + "\n"); // Check if we're on Windows const isWindows = os.platform() === "win32"; if (isWindows) { console.log( "On Windows, you might need to restart your terminal for the PATH changes to take effect." ); } } else { console.log(chalk.yellow("LOCAL INSTALLATION DETECTED:")); console.log("Kira was installed locally. You can run it with:"); console.log("\n" + chalk.cyan("npx kira") + "\n"); } } catch (error) { // Ignore any errors and proceed with setup } } /** * Create configuration directory */ function createConfigDir() { try { const configDir = path.join(os.homedir(), ".kira"); // Create directory if it doesn't exist if (!fs.existsSync(configDir)) { fs.mkdirSync(configDir); console.log(chalk.green("✓ Created configuration directory")); } } catch (error) { console.log( chalk.yellow( "⚠ Could not create configuration directory: " + error.message ) ); } } /** * Run the setup */ function setup() { try { displayWelcome(); checkGlobalInstallation(); createConfigDir(); console.log("\n" + chalk.green("✓ Setup completed successfully!")); console.log( chalk.green( "✓ You can now run Kira to generate your first CRUD components." ) ); console.log("\n"); } catch (error) { console.error(chalk.red("Error during setup: " + error.message)); } } // Run the setup setup();