Skip to content

Commit 531307e

Browse files
committed
feat: use @pkgjs/create major refactor
BREAKING CHANGE
1 parent 69bdb1d commit 531307e

23 files changed

+938
-571
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Code of Conduct
2+
3+
This project as adopted the Contributor Covenant v1.4.1 as its Code of Conduct.
4+
See here for the details:
5+
6+
https://www.contributor-covenant.org/version/1/4/code-of-conduct
7+
8+
To report or discuss issues you can email [email protected] or open a public issue on GitHub.

.github/CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Contributing
2+
3+
:+1::tada: Welcome, thanks for taking the time to contribute! :tada::+1:
4+
5+
[Code Of Conduct](./CODE_OF_CONDUCT.md)
6+
7+
All contributions are welcome; features, fixes, documentation or just helping
8+
others solve their issues. The best way to get started is to look through
9+
our Issues and Pull Requests. If you have questions feel free to open an Issue
10+
and tag it with `question` so others can find it and help out!
11+
12+
Happy Hacking!

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [wesleytodd]

.github/SECURITY.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
This project supports security and feature development on the two most recent
6+
major versions. It also supports all active and LTS Node.js release lines.
7+
8+
## Reporting a Vulnerability
9+
10+
To report a vulnerability email [email protected] before opening public issues on the repo.

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Test
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [8.x, 10.x, 12.x]
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: npm install and test
20+
run: npm it

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.github
2+
test

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2019 Wes Todd <[email protected]>
2+
3+
Permission to use, copy, modify, and/or distribute this software for any
4+
purpose with or without fee is hereby granted, provided that the above
5+
copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10+
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12+
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Create a `package.json` like a champion
22

3+
[![NPM Version](https://badgen.net/npm/v/create-package-json?icon=npm)](https://npmjs.org/package/create-package-json)
4+
[![NPM Downloads](https://badgen.net/npm/dm/create-package-json?icon=npm)](https://npmjs.org/package/create-package-json)
5+
[![JS Standard Style](https://badgen.net/badge/code%20style/standard/blue)](https://github.com/standard/standard)
6+
[![GitHub Sponsor](https://badgen.net/badge/icon/sponsor/pink?icon=github&label=github)](https://github.com/sponsors/wesleytodd)
7+
38
This is a fully featured `package.json` scaffolding tool. It goes above and beyond the basic `npm init`
49
by supporting (almost) all of the keys you can set in a `package.json`. It can be used as a simple cli
510
tool, or inside your other package scaffolding tools.
@@ -11,12 +16,10 @@ tool, or inside your other package scaffolding tools.
1116

1217
```
1318
$ npm init package-json
14-
```
19+
$ npx create-package-json
1520
16-
With `npm@6` this will run this package with `npx`. If you are on an earlier version of `npm` you will
17-
need to install globally and run directly:
21+
# or
1822
19-
```
2023
$ npm install -g create-package-json
2124
$ create-package-json
2225
```
@@ -26,28 +29,41 @@ $ create-package-json
2629
```
2730
$ create-package-json --help
2831
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
32+
create-package-json
33+
34+
Create a package.json
35+
36+
Options:
37+
--help Show help [boolean]
38+
--version Show version number [boolean]
39+
--no-prompt Prompts, --no-prompt to use defaults and input only
40+
[boolean]
41+
--directory, -d Working directory [string]
42+
--silent, -S Suppress all output [boolean]
43+
--advanced Show advanced prompts [boolean]
44+
--existing-package [string]
45+
--scope [string]
46+
--scripts [string]
47+
--name [string]
48+
--package-version [string]
49+
--description [string]
50+
--author [string]
51+
--repository [string]
52+
--keywords [string]
53+
--license [string]
54+
--type [string]
55+
--main [string]
56+
--private [boolean]
57+
--dependencies [string]
58+
--dev-dependencies [string]
59+
--peer-dependencies [string]
60+
--test [string]
61+
--prepare [string]
62+
--post-publish [string]
63+
--pre-version [string]
64+
--spacer [string]
65+
--ignore-existing [boolean]
66+
--save-exact [boolean]
5167
```
5268

5369
Dependencies should be a comma separated list like `--dependencies="express,react"`, and it can also

bin/create-package-json

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,3 @@
11
#!/usr/bin/env node
22
'use strict'
3-
// vim: set ft=javascript:ts=2:sw=2
4-
const program = require('commander')
5-
const pkg = require('../package.json')
6-
const createPackageJson = require('../')
7-
const arrayFromList = require('../lib/array-from-list')
8-
9-
let directory
10-
11-
program
12-
.version(pkg.version)
13-
.arguments('<directory>')
14-
.action((dir) => directory = dir)
15-
.option('--ignore-existing', 'Ignore existing package.json')
16-
.option('--existing-package [path]', 'Provide a path to an existing package.json to start with')
17-
.option('--update-deps', 'Update deps which to their latest versions')
18-
.option('--no-prompt', 'Skip prompts and just use input options')
19-
.option('--extended', 'Show extended option prompts (ex. browser, engines, etc)')
20-
.option('--spacer [json spacer]', 'Format character for package json', 2)
21-
.option('--name [name]', 'The package name')
22-
.option('--scope [scope]', 'The package scope')
23-
.option('--ver [version]', 'The package version')
24-
.option('--description [description]', 'The package description')
25-
.option('--author [author]', 'The package author')
26-
.option('--repository [repository]', 'The package repository')
27-
.option('--keywords [keywords]', 'The package keywords')
28-
.option('--license [license]', 'The package license')
29-
.option('--main [main]', 'The package main entry point')
30-
.option('--private', 'This is a private package')
31-
.option('--dependencies [dependencies]', 'Package dependencies')
32-
.option('--dev-dependencies [dependencies]', 'Package dev dependencies')
33-
// .option('--peer-dependencies [dependencies]', 'Package peer dependencies')
34-
.option('--scripts [scripts]', 'Package scripts')
35-
.parse(process.argv)
36-
37-
// Process scripts as json
38-
if (program.scripts) {
39-
program.scripts = JSON.parse(program.scripts)
40-
}
41-
if (program.dependencies) {
42-
program.dependencies = arrayFromList(program.dependencies)
43-
}
44-
if (program.devDependencies) {
45-
program.devDependencies = arrayFromList(program.devDependencies)
46-
}
47-
// if (program.peerDependencies) {
48-
// program.peerDependencies = arrayFromList(program.peerDependencies)
49-
// }
50-
51-
// Run the process
52-
createPackageJson({
53-
directory: directory,
54-
ignoreExisting: program.ignoreExisting,
55-
existingPackage: program.existingPackage,
56-
noPrompt: program.noPrompt,
57-
extended: program.extended,
58-
spacer: program.spacer,
59-
// check if string because there is a .name getter function, same with description
60-
name: typeof program.name === 'string' ? program.name : undefined,
61-
scope: program.scope,
62-
version: program.ver,
63-
description: typeof program.description === 'string' ? program.description : undefined,
64-
author: program.author,
65-
repository: program.repository,
66-
keywords: program.keywords,
67-
license: program.license,
68-
main: program.main,
69-
private: program.private,
70-
scripts: program.scripts,
71-
dependencies: program.dependencies,
72-
devDependencies: program.devDependencies,
73-
updateDeps: program.updateDeps
74-
// peerDependencies: program.peerDependencies
75-
})
3+
require('../').cli(process.argv.slice(2))

0 commit comments

Comments
 (0)