"Fun Isn't Something One Considers When Balancing The Universe. But This... Does Put A Smile On My Face."
cosmic- curse, a better and improved package of death-node is a tool that helps you clean up unused dependencies from your Node.js project. It uses the depcheck and rimraf packages to find and delete unused dependencies.
To use cosmic-curse, you need to have Node.js and npm installed on your system. You can then install cosmic-curse using the following command:
npm install cosmic-curse
First thing is to install depcheck. [it is a required dependency].
I will fix this.
You can try installing the depcheck module in your project using npm by running the command :
npm install depcheck
To use cosmic-curse, you need to call the SnapTheFinger function in your Node.js code. Here's an example of how to use cosmic-curse in a Node.js script:
- Create a file in your directory, ie.fileTest.js
- Include the following code as below:
const myModule = require('cosmic-curse');
myModule.SnapTheFinger();
- Run the file , [make sure you are in the correct path , where your file is ]
node fileTest.js
This will list all the installed packages in the current project directory, identify the unused packages, and prompt the user to confirm whether they want to remove all unused packages or keep some of them. The function will then remove the selected packages.
-
If No Modules in Project:
- The application will now exit if there are no installed modules in the project.
-
If No Unused Modules:
- The application will exit if there are installed modules, but no unused modules detected.
- Unused modules are now displayed in a tree format for better readability.
- If an incorrect module name is provided when choosing which modules to retain, the user is prompted to edit the input.
- A progress bar or animation is displayed during the uninstallation process to indicate the progress of module removal.
- If an incorrect answer is provided in the prompt: [Do you want to retain any modules? (yes/no/all)] (e.g., an invalid option), the application now exits instead of deleting all listed modules.
- Colored text is used in the console for improved readability and to distinguish different types of messages.
This is because I have typed so much so see the VISUALS!
pic 1: This is the result if you do this correctly
pic 2: This is the result if you do not
-
The promptUser function improved by validating the user's input. The function should ensure that the user only enters valid module names separated by commas.
-
The deleteUnusedModules function improved by adding error handling for the rimraf package. If a module cannot be deleted, the function should log an error message and continue deleting the other modules.
-
The main function improved by adding error handling for the depcheck package. If an error occurs, the function should log an error message and exit.
-
You no longer need to specify your directory , the package will determine for itself.
-
Implemented correct deletion of dependencies.
-
Fixed duplication of prompts
"Perfectly Balanced, As All Things Should Be."
If you want to contribute to the cosmic-curse project, you can fork the repository on GitHub and submit a pull request with your changes. Please make sure to follow the coding style and guidelines of the project.
Please make sure to update tests as appropriate.
cosmic-curse is licensed under the MIT License. See the MIT file for details. MIT
Michelle Juma