Skip to content

Commit

Permalink
feat: Enhace CLI tool, Added emojis, loading indicators, and formatti…
Browse files Browse the repository at this point in the history
…ng fix integration 🎉

ℹ️ Enhance CLI Tool: Added emojis, loading indicators, and formatting fix integration

🚀 This release enhances the CLI tool by adding emojis for better visualization of process statuses, integrating loading indicators, and automatically running 'npm run format:fix' after CRUD operations. Additionally, the code structure has been optimized for improved readability and maintainability.

📝 Details:
- Added emojis to indicate process statuses and provide visual feedback.
- Integrated loading indicators to improve user experience during CRUD operations.
- Automated running 'npm run format:fix' after CRUD operations for consistent code formatting.
- Optimized code structure for better readability and maintainability.

🔧 Feel free to test the updated CLI tool and provide feedback!
  • Loading branch information
fadhlaouir committed Mar 19, 2024
1 parent 91cf310 commit 990c953
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
/* -------------------------------------------------------------------------- */
// Required packages
const inquirer = require('inquirer'); // For prompting user input
const util = require('util');
const exec = util.promisify(require('child_process').exec); // For executing shell commands

// Local helpers and functions
const { generateEmptyCrud } = require('./_/generateEmptyCrud'); // Function to generate empty CRUD
const { generateMinimalCrud } = require('./_/generateMinimalCrud'); // Function to generate minimal CRUD
const { deleteCrud } = require('./_/deleteCrud'); // Function to delete CRUD
const { isEntityExists } = require('./_/helpers'); // Function to check if entity already exists

/* -------------------------------------------------------------------------- */
/* CONSTANTS */
/* -------------------------------------------------------------------------- */
const LOADING_EMOJI = '⏳'; // Loading emoji

/* -------------------------------------------------------------------------- */
/* MAIN */
/* -------------------------------------------------------------------------- */
Expand All @@ -33,9 +40,11 @@ async function main() {

switch (action) {
case 'Generate CRUD':
console.log(`${LOADING_EMOJI} Generating CRUD...`);
await generateCrud();
break;
case 'Delete CRUD':
console.log(`${LOADING_EMOJI} Deleting CRUD...`);
await deleteCrudAction();
break;
case 'Exit':
Expand Down Expand Up @@ -94,20 +103,25 @@ async function generateCrud() {
switch (command) {
case 'empty':
await generateEmptyCrud(entity);
console.log('Empty CRUD generated successfully for entity:', entity);
console.log('Exiting...');
process.exit(0);
console.log('✅ Empty CRUD generated successfully for entity:', entity);
break;
case 'minimal':
await generateMinimalCrud(entity);
console.log('Minimal CRUD generated successfully for entity:', entity);
console.log('Exiting...');
process.exit(0);
console.log(
'✅ Minimal CRUD generated successfully for entity:',
entity,
);
break;
default:
console.log('Invalid command:', command);
process.exit(1);
}

// Run 'npm run format:fix' after CRUD operations are performed
await exec('npm run format:fix');
console.log('✅ Formatting fixed.');
console.log('Exiting...');
process.exit(0);
} catch (error) {
console.error('An error occurred during CRUD generation:', error);
process.exit(1);
Expand Down Expand Up @@ -136,6 +150,13 @@ async function deleteCrudAction() {

const { entity } = await inquirer.prompt(entityPrompt);
await deleteCrud(entity);
console.log('✅ CRUD for entity', entity, 'deleted successfully.');

// Run 'npm run format:fix' after CRUD operations are performed
await exec('npm run format:fix');
console.log('✅ Formatting fixed.');
console.log('Exiting...');
process.exit(0);
} catch (error) {
console.error('An error occurred during CRUD deletion:', error);
process.exit(1);
Expand Down

0 comments on commit 990c953

Please sign in to comment.