impose my will upon a new or existing Node.js project


1394.0.02 years ago5 years agoMinified + gzip package size for @jokeyrhyme/node-init in KB


jokeyrhyme / node-init npm Travis CI Status

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:

# 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

What does this do?

Version Control

  • runs git init to start a git repository, if none is found

  • ensures there's a .gitignore file containing "node_modules"

NPM good-practices

  • 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 and node

  • 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

Code Quality

  • 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

Continuous Integration

  • 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)

IDE / Code Editor settings

Other Opinionated Stuff

  • 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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.