impose my will upon a new or existing Node.js project
npm install -g @jokeyrhyme/node-init
# use to start a fresh new project from scratch:
node-init my-project
# which is the equivalent of running:
mkdir my-project; cd my-project; node-init
# without a project name, assume current working directory:
node-init
# to find more details about usage
node-init --help
--scope [scope] set npm @scope prefix
--check-git-status stop work if un-versioned changes
--no-check-git-status do work even if un-versioned changes
-
runs
git init
to start a git repository, if none is found -
ensures there's a .gitignore file containing "node_modules"
-
runs
npm init -y
to start a package.json or to restore important missing fields to an existing package.json -
ensures "name" in package.json includes desired scope (if any)
-
ensures "engines" is set in package.json, defaults to major versions of current
npm
andnode
-
ensures all versions in "devDependencies" in package.json start with "^"
-
adds an NPM version badge to README.md if none is found, and the package is not marked as "private"
-
sets default
{ publishConfig: { access: 'public' } }
in package.json if there is a scope -
use
sort-package-json
to keep package.json tidy -
package "main" refers to a file that exists (created for you, if not)
-
use
nsp
to check for vulnerable dependencies
-
installs and configures prettier and
npm run prettier
-
installs and configures ESLint, with eslint-plugin-node
-
install and configure jest if other test frameworks are absent and
npm test
is not configured -
adds an
npm run eslint
script for ESLint -
installs and configures FlowType and
npm run flow
-
uninstalls FlowType when not used
-
add
npm run ava
if using ava -
add
npm run jest
if using jest -
add
npm run mocha
if using mocha -
add
npm run nyc
if using nyc
-
adds a Travis CI badge to README.md if none is found (GitHub-only)
-
ensures .travis.yml has good defaults at least (GitHub-only)
-
adds an AppVeyor badge to README.md if none is found (GitHub-only or Bitbucket-only)
-
ensures appveyor.yml has good defaults at least (GitHub-only or Bitbucket-only)
-
copies .editorconfig from multi-lingual template config
-
ensures jsconfig.json for Visual Studio Code exists
-
for simplicity, text files should use UNIX line-endings
-
install a project-local copy of
npx
, which is very useful for executing other CLI tools