# base-pkg

> Plugin for adding a `pkg` method that exposes pkg-store to your base application.

Latest version **1.0.0** (published 2017-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install base-pkg
pnpm add base-pkg
yarn add base-pkg
bun add base-pkg
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-12-21 |
| First published | 2016-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | api, app, application, base, base-plugin, baseplugin, building-blocks, create, framework, pkg, plugin, plugins, tool, toolkit, tools |

## Links

- npm: https://www.npmjs.com/package/base-pkg
- Repository: https://github.com/node-base/base-pkg
- Issues: https://github.com/node-base/base-pkg/issues
- npm.io page: https://npm.io/package/base-pkg

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [pkg-store](https://npm.io/package/pkg-store.md) ^1.0.1
- [expand-pkg](https://npm.io/package/expand-pkg.md) ^0.1.8
- [is-valid-app](https://npm.io/package/is-valid-app.md) ^0.3.0

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-12-21
- 0.2.5 — 2017-07-16
- 0.2.4 — 2016-06-13
- 0.2.3 — 2016-05-24
- 0.2.2 — 2016-04-17
- 0.2.0 — 2016-03-31
- 0.1.3 — 2016-03-17
- 0.1.2 — 2016-03-17
- 0.1.1 — 2016-02-20
- 0.1.0 — 2016-02-04

## README

# base-pkg [![NPM version](https://img.shields.io/npm/v/base-pkg.svg?style=flat)](https://www.npmjs.com/package/base-pkg) [![NPM monthly downloads](https://img.shields.io/npm/dm/base-pkg.svg?style=flat)](https://npmjs.org/package/base-pkg) [![NPM total downloads](https://img.shields.io/npm/dt/base-pkg.svg?style=flat)](https://npmjs.org/package/base-pkg) [![Linux Build Status](https://img.shields.io/travis/node-base/base-pkg.svg?style=flat&label=Travis)](https://travis-ci.org/node-base/base-pkg)

> Plugin for adding a `pkg` method that exposes pkg-store to your base application.

Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save base-pkg
```

## Usage

```js
var pkg = require('base-pkg');
var Base = require('base');
var app = new Base();

app.use(pkg());

console.log(app.pkg.data);
//=> {"name": "my-project", ...}
```

## API

Visit [pkg-store](https://github.com/jonschlinkert/pkg-store) for additional API details and documentation.

### .pkg.set

```js
app.pkg.set(key, value);
```

Set property `key` with the given `value`.

**Example**

```js
// given {"name": "my-project"}
app.pkg.set('bin.foo', 'bar');

console.log(app.pkg.data);
//=> {"name": "my-project", "bin": {"foo": "bar"}}
```

### .pkg.save

Persist package.json to the file system at `app.pkg.path`.

```js
app.pkg.save();
```

### .pkg.get

```js
app.pkg.get(key);
```

Get property `key` from package.json.

**Example**

```js
// given {"name": "my-project"}
app.pkg.set('bin.foo', 'bar');

console.log(app.pkg.get('bin'));
//=> {"foo": "bar"}
```

### .pkg.has

```js
app.pkg.has(key);
```

Returns `true` if `package.json` has property `key`.

**Example**

```js
// given: {"name": "my-project"}
console.log(app.pkg.has('name'));
//=> true
console.log(app.pkg.has('zzzzzzz'));
//=> false
```

### .pkg.union

```js
app.pkg.union(key, val);
```

Create array `key`, or concatenate values to array `key`. Also uniquifies the array.

**Example**

```js
app.pkg.union('keywords', 'foo');
app.pkg.union('keywords', ['bar', 'baz']);

console.log(app.pkg.get('keywords'));
//=> ['foo', 'bar', 'baz']
```

## .pkg.expand

Creates a get/set API using [cache-base](https://github.com/jonschlinkert/cache-base), where the cache is populated with a shallow clone of `package.json` with values expanded by [expand-pkg](https://github.com/jonschlinkert/expand-pkg).

**Example**

```js
console.log(app.pkg.get('author'));
//=> 'Jon Schlinkert (https://github.com/jonschlinkert)'

var expanded = app.pkg.expand();
var author = expanded.get('author');
//=> {name: 'Jon Schlinkert', url: 'https://github.com/jonschlinkert'}
```

## About

<details>
<summary><strong>Contributing</strong></summary>

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

</details>

<details>
<summary><strong>Running Tests</strong></summary>

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

</details>
<details>
<summary><strong>Building docs</strong></summary>

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

</details>

### Related projects

You might also be interested in these projects:

* [base-options](https://www.npmjs.com/package/base-options): Adds a few options methods to base-methods, like `option`, `enable` and `disable`. See the readme… [more](https://github.com/jonschlinkert/base-options) | [homepage](https://github.com/jonschlinkert/base-options "Adds a few options methods to base-methods, like `option`, `enable` and `disable`. See the readme for the full API.")
* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks")
* [cache-base](https://www.npmjs.com/package/cache-base): Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects. | [homepage](https://github.com/jonschlinkert/cache-base "Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects.")
* [pkg-store](https://www.npmjs.com/package/pkg-store): Use package.json as a config store. | [homepage](https://github.com/jonschlinkert/pkg-store "Use package.json as a config store.")

### Author

**Jon Schlinkert**

* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on December 21, 2017._

---
_Source: https://npm.io/package/base-pkg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
