https://github.com/jamiebuilds/std-pkg
The Official package.json Standard™ for Npm® endorsed fields
https://github.com/jamiebuilds/std-pkg
npm official package-json spec standard
Last synced: 11 months ago
JSON representation
The Official package.json Standard™ for Npm® endorsed fields
- Host: GitHub
- URL: https://github.com/jamiebuilds/std-pkg
- Owner: jamiebuilds
- License: mit
- Created: 2018-07-17T23:28:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-11T17:59:18.000Z (over 7 years ago)
- Last Synced: 2025-05-22T04:39:42.024Z (12 months ago)
- Topics: npm, official, package-json, spec, standard
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 44
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# std-pkg
> The Official `package.json` Standard™ for Npm® endorsed fields†
- Lazily asserts Correct™ values using getters
- Strongly typed
- Includes community standards
This is useful if you're writing tooling around `package.json` and want to make
sure you are following the Official NPM `package.json` Standard™.
## Install
```sh
yarn add std-pkg
```
## Usage
```js
const Package = require('std-pkg');
const fs = require('fs');
let pkgPath = '/path/to/package.json';
let pkgContents = fs.readFileSync('/path/to/package.json', 'utf-8');
let pkg = new Package(pkgPath, pkgContents);
// file paths
pkg.filePath;
pkg.dirPath;
pkg.nodeModulesPath;
pkg.nodeModulesBinPath;
pkg.nodeModulesCachePath;
// file contents
pkg.fileContents;
pkg.json;
pkg.indentation;
// essentials
pkg.name;
pkg.version;
// info
pkg.description;
pkg.keywords;
pkg.license;
// links
pkg.homepage;
pkg.bugs;
pkg.repository;
// maintainers
pkg.author;
pkg.contributors;
// files
pkg.files;
pkg.main;
pkg.bin;
pkg.man;
pkg.directories;
// tasks
pkg.scripts;
pkg.config;
// dependencies
pkg.dependencies;
pkg.devDependencies;
pkg.peerDependencies;
pkg.optionalDependencies;
pkg.bundledDependencies;
// system
pkg.engines;
pkg.os;
pkg.cpu;
// publishing
pkg.private;
pkg.publishConfig;
// yarn
pkg.flat;
pkg.resolutions;
pkg.workspaces;
// bundlers
pkg.module;
pkg.browser;
pkg.source;
pkg.sideEffects;
// typescript
pkg.types;
```
Read [index.js](./index.js) and [test.js](./test.js) for valid values for each
field.
---
> † This is not really a "standard", npm peeps are just being douchebags about
> anyone ever trying to standardize things because they as a private company
> would like to retain control which is the same reason npm is not open source.