package.json

Create a package.json.

Usage

var create = require( '@stdlib/_tools/scaffold/package-json' );

create( [options] )

Returns a package.json.

var pkg = create();
// returns <Object>

The function accepts the following options:

  • name: package name. Package names should be scoped to the @stdlib namespace; e.g., @stdlib/....
  • desc: package description.
  • keywords: package keywords. The keyword stdlib is automatically included in the keyword list and thus does not need to be included.
  • cmd: package command for use as a CLI tool.
  • browser: browser entry point.

To return a valid package.json, set the name, desc, and keywords options.

var opts = {
    'name': '@stdlib/math/base/special/erf',
    'desc': 'Error function',
    'keywords': [
        'math',
        'mathematics',
        'error',
        'function',
        'erf'
    ]
};

var pkg = create( opts );
/* returns
    {
      "name": "@stdlib/math/base/special/erf",
      "version": "0.0.0",
      "description": "Error function.",
      "author": {
        "name": "The Stdlib Authors",
        "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
      },
      "contributors": [
        {
          "name": "The Stdlib Authors",
          "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
        }
      ],
      "scripts": {},
      "main": "./lib",
      "repository": {
        "type": "git",
        "url": "git://github.com/stdlib-js/stdlib.git"
      },
      "homepage": "https://github.com/stdlib-js/stdlib",
      "keywords": [
        "stdlib",
        "math",
        "mathematics",
        "error",
        "function",
        "erf"
      ],
      "bugs": {
        "url": "https://github.com/stdlib-js/stdlib/issues"
      },
      "dependencies": {},
      "devDependencies": {},
      "engines": {
        "node": ">=0.10.0"
      },
      "license": "Apache-2.0"
    }
*/

Examples

var create = require( '@stdlib/_tools/scaffold/package-json' );

var opts = {
    'name': '@stdlib/math/base/special/erf',
    'desc': 'Error function.',
    'keywords': [
        'math',
        'mathematics',
        'error',
        'function',
        'erf'
    ],
    'cmd': 'erf',
    'browser': './lib/browser/index.js'
};

var pkg = create( opts );
console.dir( pkg );

CLI

Usage

Usage: package-json [options]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --name name           Package name.
         --desc description    Package description.
         --keywords k1,k2,...  Package keywords.
         --cmd command         Package command for use as a CLI tool.
         --browser path        Browser entry point.
         --compact             Disable pretty print.
         --space num           White space amount. Default: 2.

Notes

  • Setting --space 0 is the equivalent of --compact.

Examples

$ package-json
{
  "name": "{{TODO:name}}",
  "version": "0.0.0",
  "description": "{{TODO:description}}",
  "author": {
    "name": "The Stdlib Authors",
    "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
  },
  "contributors": [
    {
      "name": "The Stdlib Authors",
      "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
    }
  ],
  "scripts": {},
  "main": "./lib",
  "repository": {
    "type": "git",
    "url": "git://github.com/stdlib-js/stdlib.git"
  },
  "homepage": "https://github.com/stdlib-js/stdlib",
  "keywords": [
    "stdlib",
    "{{TODO:keywords}}"
  ],
  "bugs": {
    "url": "https://github.com/stdlib-js/stdlib/issues"
  },
  "dependencies": {},
  "devDependencies": {},
  "engines": {
    "node": ">=0.10.0"
  },
  "license": "Apache-2.0"
}

To create a valid package.json, set the name, desc, and keywords options.

$ package-json --name @stdlib/math/base/special/erf --desc 'Error function.' --keywords 'math,mathematics,error,function,erf'
{
  "name": "@stdlib/math/base/special/erf",
  "version": "0.0.0",
  "description": "Error function.",
  "author": {
    "name": "The Stdlib Authors",
    "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
  },
  "contributors": [
    {
      "name": "The Stdlib Authors",
      "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
    }
  ],
  "scripts": {},
  "main": "./lib",
  "repository": {
    "type": "git",
    "url": "git://github.com/stdlib-js/stdlib.git"
  },
  "homepage": "https://github.com/stdlib-js/stdlib",
  "keywords": [
    "stdlib",
    "math",
    "mathematics",
    "error",
    "function",
    "erf"
  ],
  "bugs": {
    "url": "https://github.com/stdlib-js/stdlib/issues"
  },
  "dependencies": {},
  "devDependencies": {},
  "engines": {
    "node": ">=0.10.0"
  },
  "license": "Apache-2.0"
}

To disable pretty printing, set the compact option.

$ package-json --compact
{"name":"{{TODO:name}}","version":"0.0.0","description":"{{TODO:description}}","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"scripts":{},"main":"./lib","repository":{"type":"git","url":"git://github.com/stdlib-js/stdlib.git"},"homepage":"https://github.com/stdlib-js/stdlib","keywords":["stdlib","{{TODO:keywords}}"],"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{},"engines":{"node":">=0.10.0"},"license":"Apache-2.0"}