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
yarn add std-pkg
Usage
const Package = ;const fs = ; let pkgPath = '/path/to/package.json';let pkgContents = fs; let pkg = pkgPath pkgContents; // file pathspkgfilePath;pkgdirPath;pkgnodeModulesPath;pkgnodeModulesBinPath;pkgnodeModulesCachePath; // file contentspkgfileContents;pkgjson;pkgindentation; // essentialspkgname;pkgversion; // infopkgdescription;pkgkeywords;pkglicense; // linkspkghomepage;pkgbugs;pkgrepository; // maintainerspkgauthor;pkgcontributors; // filespkgfiles;pkgmain;pkgbin;pkgman;pkgdirectories; // taskspkgscripts;pkgconfig; // dependenciespkgdependencies;pkgdevDependencies;pkgpeerDependencies;pkgoptionalDependencies;pkgbundledDependencies; // systempkgengines;pkgos;pkgcpu; // publishingpkgprivate;pkgpublishConfig; // yarnpkgflat;pkgresolutions;pkgworkspaces; // bundlerspkgmodule;pkgbrowser;pkgsource;pkgsideEffects; // typescriptpkgtypes;
Read index.js and 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.