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

reshala

v4.0.5

Published

A simple CLI tool to resolve package.json merge conflicts.

Downloads

41

Readme

reshala

npm Tests

A simple CLI tool to resolve package.json merge conflicts. reshala automatically finds all of your conflicted package.json files. Also, reshala automatically determines version of any dependency and resolves the newer one. If there will any problems, reshala will ask you what to do.

Special thanks to my colleague for giving a name for this tool 🤙.

meme

Changelog

CHANGELOG.md

Installing

$ npm i -g reshala

Usage

$ reshala

Options

  • -h, --help - print short reference
  • -d, --debug - run in debug mode (additional output)
  • -v, --version - print version of package
  • -i, --include-all - by default, reshala will ask you what to do in cases when key exists in ours/theirs but not in the other. You can specify this option to include all keys without question.
  • -e, --exclude-all - opposite of previous
  • -d, --driver <path> - custom merge driver. See more in the section below.

If options -i, --include-all and -e, --exclude-all are used both an error will be generated.

Drivers API (comes with 4.x, experimental 🧪)

For example, we have two package.json files, which contains something like this:

A.json

{
  "name": "reshala",
  "stars": 5
}

B.json

{
  "name": "reshala",
  "stars": 4
}

So, if we just run reshala, it will ask us what value the stars key should take and this is normal behavior. reshala doesn't know merge rules for this key, however we can define it with a drivers API to merge everything automatically.

Let's say we want to take a higher number as value of stars key. Then we should describe a driver as:

(key, a, b) => {
  if (key === 'stars') {
    return { [key]: Math.max(a, b) };
  }

  return null;
}

Note that this is just anonymous JavaScript function. Also, it can be asynchronous. It takes up to 3 arguments:

  • key - which key is currently being processed
  • a - value from ours
  • b - value from theirs

Driver function will be called for EVERY key of an union of A and B keys. Driver function is called before standart handlers, so you can fully override normal behavior. Driver function should return null to go to the standart checks or object to merge to the resulting object (and go to the next key).

For example, you can cut specified key from your resulting package.json:

(key) => key === 'unnecessaryKey' ? {} : null;

By the way, a key may be nested (e.g. prop.nestedProp.key).

The last expression of the driver code must be functional. But you can use any JavaScript features in driver code. Furthermore, you have logger, chalk, require, ab and $ functions in the global scope of driver file.

Probably, you are already familiar with the first three functions. But what about the forth and the fifth?

type ABFunc = <A, B>(params: { a: A, b?: B, message: string }) => Promise<A | B | boolean>;

ab is a special inquirer wrapper. You can offer to choose between a and b (if passed both), or you can ask if key is needed to include (is passed a only). In the first option you will get a or b (depends on user's choice). In the second one you will get true or false (depends on user's choice too).

$ is an async bash commands runner.

Every question you see when work with reshala is just ab and you can use it in your own merge algorithms!