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

park

v1.2.0

Published

CLI and API for getting and setting `package.json` values. Useful for quickly changing values or copying values to the keyboard.

Downloads

10

Readme

park

A simple utility and CLI for getting and setting values on the closest package.json.

Mostly useful for quickly changing values or copying values to the keyboard. If you need anything more, npm and vim package.json have you covered.

Usage

CLI

First install it via npm.

$ npm install -g park

It's now available on your command line.

Get a value from package.json

$ park description
# => CLI for getting and setting package.json values. Useful for quickly changing values and copying values to the keyboard.

Especially useful if you pipe it to your clipboard. For example, I use this all the time when starting Github repos:

$ park description | clip # clip is Windows. Mac and Linux users use pbcopy and xclip respectively.

park accepts object strings as keys for getting nested values.

For example, scripts.test will access the test key of scripts.

$ park scripts.test
# => cd test/ && mocha . && cd ..

Set a value in package.json

$ park main park.js
# => package.json contents

Or with an object string:

$ park scripts.test mocha

Stream out the package.json object

It's equivalent to using cat package.json, but also works from any subdirectory.

$ park
# => package.json contents

API

The programmatic API is more or less identical.

First install it.

$ npm install --save park

Then require it in your code. park is a function which accepts a directory path.

var park = require("park"),
	pkg = park(__dirname);

The following methods will be available on the object park(dir) returns.

pkg.read()

Returns a readable Stream of the package.json file.

pkg.read().pipe(process.stdout);

pkg.get(key)

Get a key from package.json.

pkg.get("version"); // => "1.0.0"

You can use object strings in the API too.

var chaiVersion = pkg.get("devDependencies.chai");

pkg.set(key, val)

Set a key in package.json as val and save the file. Returns a writeable Stream.

pkg.set("version", "1.0.1").on("finish", function(){
	console.log("Saved!");
});

Or with an object string.

var stream = pkg.set("bin.park", "bin/cli.js");

pkg.save()

Manually save package.json as pkg.obj. Useful if you want to edit the object manually.

pkg.path

Full path of the package.json file.

pkg.obj

package.json contents as an object.

Credits

Thanks to npm!