@@ -4,6 +4,9 @@ This is a fully featured `package.json` scaffolding tool. It goes above and bey
44by supporting (almost) all of the keys you can set in a ` package.json ` . It can be used as a simple cli
55tool, or inside your other package scaffolding tools.
66
7+ * NOTE:* This is a work in progress, more to come on docs and there are some missing options at the moment.
8+ [ See here] ( https://github.com/wesleytodd/create-package-json/blob/master/index.js#L14-L27 ) for missing fields.
9+
710## Usage
811
912```
@@ -18,4 +21,55 @@ $ npm install -g create-package-json
1821$ create-package-json
1922```
2023
21- * NOTE:* This is a work in progress, more to come on docs and there are some missing options at the moment.
24+ ### CLI Usage
25+
26+ ```
27+ $ create-package-json --help
28+
29+ Usage: create-package-json [options] <directory>
30+
31+ Options:
32+
33+ -V, --version output the version number
34+ --ignore-existing Ignore existing package.json
35+ --no-prompt Skip prompts and just use input options
36+ --spacer [json spacer] Format character for package json (default: 2)
37+ --name [name] The package name
38+ --scope [scope] The package scope
39+ --ver [version] The package version
40+ --description [description] The package description
41+ --author [author] The package author
42+ --repository [repository] The package repository
43+ --keywords [keywords] The package keywords
44+ --license [license] The package license
45+ --main [main] The package main entry point
46+ --private This is a private package
47+ --dependencies [dependencies] Package dependencies
48+ --dev-dependencies [dependencies] Package dev dependencies
49+ --scripts [scripts] Package scripts
50+ -h, --help output usage information
51+ ```
52+
53+ Dependencies should be a comma separated list like ` --dependencies="express,react" ` , and it can also
54+ include versions, ` --dependencies="express@5" ` .
55+
56+ Scripts should be defined as a json string, ` --scripts='{"test":"exit 0"}' ` .
57+
58+ ### Programmatic Usage
59+
60+ ``` javascript
61+ const createPackageJson = require (' create-package-json' )
62+
63+ ;(async () => {
64+ const pkg = await createPackageJson ({
65+ name: ' @myscope/my-package' ,
66+ description: ' A useless new package' ,
67+ dependencies: [' express' ],
68+ devDependencies: [' mocha' ],
69+ author: ' Me <me@me.com>' ,
70+ version: ' 1.0.0'
71+ })
72+
73+ console .log (pkg) // The json after writing and installing
74+ })()
75+ ```
0 commit comments