@awamwang/create-package

0.0.1 • Public • Published

Node.js Project Initializer

License version downloads

coverage build

  • 20201001 发现npm init命令可以定制~/.npm-init.js来修改它询问的项目以及安装行为等,就想为自己的项目建立一个合理的init脚本。
  • 20201002 基于create-nodejs-project项目重构代码,初步建立了这个项目。
  • 20201003 调研,列出TODO,起初只想做一个方便自己建立package的工具,现在却想做一个脚手架框架了,走远了,收。
  • 自用的话,不如使用GitHub托管私有模板,使用git repo download按名称下载模板。
  • 朝通用方向写,路就走远了,相当于重复造轮子,造了一个yeoman。
  • js发展之快,模板更新都赶不上变化啊。呼唤大佬搞个方便定制的图形化的脚手架生成工具。

fork 自create-nodejs-project,进行了一些重构,添加功能,支持国际化(i18n)。

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 named create-<initializer>, which will be installed by npx, and then have its main bin executed -- presumably creating or updating package.json and running any other initialization-related operations.
— Source: docs.npmjs.com

Requirements

  • npm >= 6.5
  • node >= 10.12.0

Usage

  1. Install the package as global
npm install -g @awamwang/create-package
  1. Run the setup configuration
createp 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

  1. Create your project
npm init @awanwang/package path/to/new/project

What it does

  • 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

  1. Unit testing
  2. Options to create the project with parameters instead of questionnaire
  3. A good error handler
  4. Color for the console messages
  5. Improve the template structure (the one that is generated in the new project) to include unit test
  6. Option to questionnaire with all the default values
  7. 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.

  1. Visit https://github.com/settings/tokens.
  2. Click Generate new token.
 Token Description: (your computer name)
 Scopes:
     [X] repo
         [X] repo:status
         [X] repo_deployment
         [X] public_repo
         [X] repo:invite
  1. Click Generate token.
  2. Copy the generated string to a safe place, such as a password safe.
  3. Open Terminal and add the Github token.
# nano /YOUR-NODE_MODULES-PATH/@awamwang/create-package/create-nodejs-settings.json

...
...
   "githubAuth": {
     "user": "YOUR_USER",
     "token": "YOUR_TOKEN"
   }
...
...

Package Sidebar

Install

npm i @awamwang/create-package

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

160 kB

Total Files

44

Last publish

Collaborators

  • awamwang