create-nodejs-project
v1.0.2
Published
An npm initializer to scaffold a node project and include basic tools like lint, testing, etc.
Downloads
280
Maintainers
Readme
Node.js Project Initializer
An npm initializer to scaffold a node project and include basic tools like lint, testing, etc.
npm init <initializer>
can be used to set up a new or existing npm package.initializer
in this case is an npm package namedcreate-<initializer>
, which will be installed bynpx
, and then have its main bin executed -- presumably creating or updatingpackage.json
and running any other initialization-related operations.
— Source:docs.npmjs.com
Requirements
npm >= 6.5
node >= 10.12.0
Usage
- Install the package as global
npm install -g create-nodejs-project
- Run the setup configuration
npm setup
You will be prompted for your Github information
If you do not have the information at the moment, you can keep it empty.
In order to create projects with Github integration, you will need to add the authentication information later. See Github Auth
- Create your project
npm init nodejs-project path/to/new/project
What it does
- Create the folder for the new project
- Guide you through a questionnaire to setup the project
- Initialize a git repository
- Copy the template files (src, eslintrc, gitignore, readme, etc)
- Create a Github repository
- Install eslint dependencies
- Install the selected testing dependencies
- Generate package.json with all the project details
- Commit and push the initial commit
- Generate the license file
About this package
Every time that I start a new project in Node.js, I hate to go to other project folder, copy files like eslintrc, editorconfig; install the same dependencies, create folder structure, etc.
With this in mind, the motivation to build this package started as a DRY (Do not repeat yourself) thing.
This package is intended to automated the initialization of new Node.js projects and with this have a new folder with everything ready to work, basically an scaffolding tool.
Future features
- Unit testing
- Options to create the project with parameters instead of questionnaire
- A good error handler
- Color for the console messages
- Improve the template structure (the one that is generated in the new project) to include unit test
- Option to questionnaire with all the default values
- Logic to handle multiple authentication files and multiple Github accounts
Configure Github Authentication
If you are planning to allow this script to create your Github repositories, is required to generate a Github Token.
- Visit https://github.com/settings/tokens.
- Click Generate new token.
Token Description: (your computer name)
Scopes:
[X] repo
[X] repo:status
[X] repo_deployment
[X] public_repo
[X] repo:invite
- Click Generate token.
- Copy the generated string to a safe place, such as a password safe.
- Open Terminal and add the Github token.
# nano /YOUR-NODE_MODULES-PATH/create-nodejs-project/create-nodejs-settings.json
...
...
"githubAuth": {
"user": "YOUR_USER",
"token": "YOUR_TOKEN"
}
...
...