DEV Community

Joe Snell
Joe Snell

Posted on

1 1

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.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay