repackify v1.0.1
Repackify
Repackify is a new package.json repackager that offers a suite of features for managing your package.json files. It provides functionalities such as refactoring, backing up package.json files, implementing environment variables within package.json, and more. The package is designed to be extensible, with more features planned for future releases.
Installation
To install Repackify, use the following command:
npm install repackifyFeatures
Refactoring
Repackify allows you to refactor your
package.jsonfiles according to a provided configuration. This includes adding, removing, replacing properties, replacing text, and executing custom operations.The configuration file should be named
repackify.config.jsand should be placed in the root of your project. Here is an example of a configuration file:module.exports = { // This will add the author property to the package.json file add: { author: "Nameer Haider", }, // This will remove the devDependencies supertest and jest from the package.json file remove: ["devDependencies"], // This will replace the scripts property with the provided object replace: { scripts: { "start": "node index.js" } }, // This will replace the text "packifyr" with "repackify" in the package.json file replaceText: [{ text: 'packifyr', replace: 'repackify' }], // This will execute a custom operation on the package.json file and then save the returned version customOperation: [ (packageJson) => { packageJson.name = 'repackify'; return packageJson; }, ], };This can be done inside the package.json file as well, but it is recommended to use a configuration file for better organization and readability.
"repackify": { "remove": ["description", "author"] },Backup
provides a backup feature that allows you to create a backup file of your
package.jsonfile.Restore
Repackify allows you to restore your
package.jsonfile from a backup file.Environment Variables
Repackify allows you to implement environment variables within your
package.jsonfile, simply set the environment variable key anywhere in the package.json file and it will be replaced after running therefactorcommand."scripts": { "start": "start something --mode !{ENV_MODE}", },and then
repack refactor
CLI Commands
Repackify provides a command-line interface for managing package.json files. Here are the available commands:
repack backup
This command backs up the package.json file and save it inside package.backup.
repack backuprepack restore
This command restores the package.json file from the backup file and then delete it.
repack restorerepack refactor
This command refactors the package.json file using the provided configuration. It accepts two optional parameters:
--envor-e: Path to the base.envfile.--extra_envor-ee: Used to set extra.envfiles (e.g.-ee .env,.dev.env).
repack refactor --env .env --extra_env .env,.dev.envUsing With NPM Pre & Post Scripts
In your package.json file, you can define pre and post scripts for certain NPM commands. These scripts will automatically run before and after the specified command. For example, you can define a preinstall script to refactor your package.json file before installation and a postinstall script to restore it after installation, and the same with publish command.
// package.json
"scripts": {
"preinstall": "repack refactor",
"postinstall": "repack restore",
"Prepare": "repack refactor",
"postpublish": "repack restore"
}License
Repackify is MIT licensed.
Contact
If you have any questions, feel free to open an issue on the GitHub repository.
Author
Repackify is developed by Nameer Haider. You can contact him at nmeer5242@gmail.com or visit his GitHub profile for more information.