node-project-helper-cli
Command line tool for running Node.js project tasks.
Features are documented under Options. Potential feature additions are tracked on this project.
Requirements
- Node.js >= v16.0.0
- npm
- Git (for the
--git
option) - GitHub CLI (>= v2.5.0)
Install
Install globally:
npm install -g github:simonplend/node-project-helper-cli
Or run as a one off:
npx github:simonplend/node-project-helper-cli
Usage
nph <project_name> [flags]
Options
--p
,--preset <preset_name>
- Load flags from a preset defined in the configuration file.
--git
- Create a local git repository with a Node.js specific
.gitignore
and commit project skeleton. --github
- Create new repository on GitHub, set as remote, push up local commits.
--public
- Make the repository public on GitHub (it's private by default).
--esm
- Project will use ECMAScript (ES) modules by default.
--editorconfig
- Generate an EditorConfig file (
.editorconfig
). --prettier
- Install Prettier and add npm run scripts.
--eslint
- Install ESLint, generate configuration (
.eslintrc.json
) and add npm run scripts. --lint-staged
- Install and configure lint-staged.
--license
- Generate a LICENSE file. Determines the license from
package.json
, falls back to MIT license. --readme
- Generate a basic README.
--dependencies="<package_name> <package_name>"
- Install project dependencies (
dependencies
). --dev-dependencies="<package_name> <package_name>"
- Install project development dependencies (
devDependencies
).
Configuration
You can define presets in a ~/.config/node-project-helper-cli.json
file.
Example:
{
"presets": {
"app": {
"flags": [
"--git",
"--github",
"--editorconfig",
"--prettier",
"--eslint",
"--lint-staged",
"--readme"
]
},
"app:fastify": {
"extends": "app",
"flags": ["--dependencies=fastify"]
}
}
}
Configure npm init defaults
npm set init-author-name "$YOUR_NAME"
npm set init-author-email "$YOUR_EMAIL_ADDRESS"
npm set init-author-url "$YOUR_WEBSITE"
npm set init-license "MIT"
npm set init-version "1.0.0"
Add a global git config
Add a global configuration for git in your home directory, named .gitconfig
.
[init]
defaultBranch = main
[user]
email = $YOUR_EMAIL_ADDRESS
name = $YOUR_NAME
[core]
editor = vim
License
Licensed under the MIT License.