npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

repackify

v1.0.1

Published

A new package.json repackager offering a suite of features including refactoring, backing up package.json files, implementing environment variables within package.json, and more.

Downloads

21

Readme

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 repackify

Features

  • Refactoring

    Repackify allows you to refactor your package.json files 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.js and 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.json file.

  • Restore

    Repackify allows you to restore your package.json file from a backup file.

  • Environment Variables

    Repackify allows you to implement environment variables within your package.json file, simply set the environment variable key anywhere in the package.json file and it will be replaced after running the refactor command.

    "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 backup

repack restore

This command restores the package.json file from the backup file and then delete it.

repack restore

repack refactor

This command refactors the package.json file using the provided configuration. It accepts two optional parameters:

  • --env or -e: Path to the base .env file.
  • --extra_env or -ee: Used to set extra .env files (e.g. -ee .env,.dev.env).
repack refactor --env .env --extra_env .env,.dev.env

Using 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 [email protected] or visit his GitHub profile for more information.