pin-latest: Easily resolve package.json “latest” versions

wulfmann

Joe Snell

Posted on July 9, 2020

pin-latest: Easily resolve package.json “latest” versions

GitHub logo wulfmann / pin-latest

Small utility for converting `package.json` versions from `latest` to the actual latest version.

pin-latest

Small utility for converting package.json versions from latest to the actual latest version.

Quickstart

Install

npm i -g pin-latest
# or
yarn global add pin-latest
# or
npx pin-latest
Enter fullscreen mode Exit fullscreen mode

Given the following package.json:

{
    "name": "example-project",
    "dependencies": {
        "react": "latest"
    }
}
Enter fullscreen mode Exit fullscreen mode

Running pin-latest will result in the following output:

$ pin-latest .

{
    "name": "example-project",
    "dependencies": {
        "react": "^16.13.1"
    }
}
Enter fullscreen mode Exit fullscreen mode

To save changes pass the --write flag:

$ pin-latest .
package.json updated.

$ cat package.json
{
    "name": "example-project",
    "dependencies": {
        "react": "^16.13.1"
    }
}
Enter fullscreen mode Exit fullscreen mode

Usage

$ pin-latest --help
Usage
    $ pin-latest <project-directory>
Options
    --exact, -t     Set the exact version
    --write, -w     Write changes
    --version, -v   Version number
    --help, -h      Displays

The purpose of this project is providing an easy way to translate dependency versions specified in a package.json.

Any dependency that specifies a version of latest will be updated to the actual latest version of the package.

Quickstart

Install

npm i -g pin-latest
# or
yarn global add pin-latest
# or
npx pin-latest
Enter fullscreen mode Exit fullscreen mode

Given the following package.json:

{
    "name": "example-project",
    "dependencies": {
        "react": "latest"
    }
}
Enter fullscreen mode Exit fullscreen mode

Running pin-latest will result in the following output:

$ pin-latest .

{
    "name": "example-project",
    "dependencies": {
        "react": "^16.13.1"
    }
}
Enter fullscreen mode Exit fullscreen mode

To save changes pass the --write flag:

$ pin-latest .
package.json updated.

$ cat package.json
{
    "name": "example-project",
    "dependencies": {
        "react": "^16.13.1"
    }
}
Enter fullscreen mode Exit fullscreen mode

View more information in the project’s readme.

💖 💪 🙅 🚩
wulfmann
Joe Snell

Posted on July 9, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related