Giter VIP home page Giter VIP logo

generator-node-bahmutov's Introduction

generator-node-bahmutov

Creates good package.json for new Node projects

NPM

Build status semantic-release no sudden unpublish renovate-app badge

Install and use

npm install -g yo generator-node-bahmutov

In a new project folder

git init
git remote add origin <remote git>
yo node-bahmutov

Answer a few questions and you should be all set.

Features

  • Targeted at public GitHub and GitLab repos
  • Assumes single index.js and src folder
  • Default .npmrc and .gitignore files
  • Git hooks and message validation using pre-git
  • Linting and auto formatting using standard and prettier-standard using npm run lint
  • Linting against data mutations using eslint-plugin-immutable (optional)
  • Showing open Git issues via git-issues using npm run issues
  • Unit testing with Mocha using npm run unit
  • Packaged size reporting on pre-push hook using npm run size
  • Running Node Security Project check on pre-push
  • Checking if you are trying to commit sensitive files using npm run ban
  • License check of production dependencies with license-checker using npm run license
  • Outdated, missing local and unused dependencies check with deps-ok and dependency-check using npm run deps and npm run unused-deps
  • Docker file generation with yo node-bahmutov:docker (optional)
  • Semantic release setup with yo node-bahmutov:release (optional)
  • Config for automated dependency updates using RenovateApp and README badge.

See npm run output for the full list of scripts.

Alias

It is hard to remember yo node-bahmutov command, so I suggest using an alias to start a good NPM module. Run this command or place it in your ~/.alias file

# create new NPM module using Yeoman generator-node-bahmutov
alias new_module='yo node-bahmutov && yo node-bahmutov:release'

Make a folder, init new Git repo, set remote GitHub origin url and then call the alias

$ new_module

Answer 3 questions and you will be all set!

Recommended

Semantic release for GitHub

I recommend installing semantic release right away after bootstrapping the project, it will work nicely with the commit message format. We already include the semantic release badge in the generated README file, so you have no excuse

npm i -g semantic-release-cli
semantic-release-cli setup

Add version back into package.json, I recommend

"version": "0.0.0-semantic-release"

Semantic release for GitLab

If you use GitLab, you should take a look at semantic-release-gitlab

Generating Dockerfile

You can generate a Dockerfile with good defaults for running the current Node project inside a docker container. Based on Docker file in this gist.

yo node-bahmutov:docker

This generator also adds docker-* commands to the package.json to build the image, run and stop the container.

Generated docker image features

  • Runs Node application as a dedicated user (for security) with production environment set
  • Exposes port 1337 and sets the image environment variable PORT
  • Uses Yelp/dumb-init as default PID 1 process

You can see the full Dockerfile template.

Semantic release

You can setup semantic-release and include useful plugins like simple-commit-message and dont-crack by running

yo node-bahmutov:release

Assumes you have global semantic-release-cli tool already preset, if not

npm install --global semantic-release-cli

Test

Change into an empty folder, for example

cd /tmp
mkdir test-generator
cd test-generator
yo node-bahmutov

Or just run npm run e2e (assumes global yo install). The go into the folder /tmp/test-node-generator and run the project. You can even build the Docker image and try running the project inside the container.

Debugging

Run the generator with environment variable DEBUG set to "gen"

DEBUG=gen yo node-bahmutov

Development

Following the instructions. This module also reads answers to user questions from file answers.json if found in the current working directory. An example file is test/answers.json.

Remote

This generator assumes there is already a remote Git (probably GitHub or GitLab) repository where all code will live. Please create it first and then set it before running generator

git init
git remote add origin <remote git>

Small print

Author: Gleb Bahmutov © 2016

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2016 Gleb Bahmutov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

generator-node-bahmutov's People

Contributors

bahmutov avatar jiku avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

staskoval jiku jeket

generator-node-bahmutov's Issues

Run fixpack on package.json

It would be nice to sort the properties in the package.json after creating it. fixpack can do this nicely

Better github repo format

Do not form github url from project name because it might be confused by the scope name, for example
if the project name is @foo/bar the url should be github.com/username/bar not github.com/username/@foo/bar

Add prettier-standard

To autoformat code

"pretty": "prettier-standard 'src/*.js'",
"prelint": "npm run pretty",

Error: Git origin error

HI,

I just followed the instructions and get always the same error

$ git init
Initialized empty Git repository in /Users/sebastianp/Developer/Red-To/.git/
$ git remote add origin https://github.com/myuser/my-repository.git
$ DEBUG=gen yo node-bahmutov
using [email protected]
  gen Copying .npmrc file +0ms
  gen Copying .gitignore file +4ms
  gen Looking for .git folder +1ms
  gen Getting Git origin url +0ms
  gen got remote origin url https://github.com/myuser/my-repository.git +2ms
Git origin error
Error: expected git@ remote url https://github.com/myuser/my-repository.git
    at lazyAssLogic (/usr/local/lib/node_modules/generator-node-bahmutov/node_modules/lazy-ass/index.js:110:14)
    at lazyAss (/usr/local/lib/node_modules/generator-node-bahmutov/node_modules/lazy-ass/index.js:115:28)
    at Object.getDomain (/usr/local/lib/node_modules/generator-node-bahmutov/app/https-remote-git-url.js:22:3)
    at originUrl.then (/usr/local/lib/node_modules/generator-node-bahmutov/app/index.js:70:40)

yo node-bahmutov:release

Could npm be missing something? yo node-bahmutov:release doesn't seem to work on 1.29.0 and it doesn't show up in yo --help as a subgenerator. The docker command does show up.

Give better missing keywords error message

Right now is cryptic if there are no keywords

? Your project name test-gen
? Project description f
? Comma separated keywords 
? Do you want to use TypeScript? (not implemented) No
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: invalid keywords {
  "name": "test-gen",
  "description": "f",
  "keywords": "",
  "typescript": false
}
    at lazyAssLogic (/Users/irinakous/git/generator-node-bahmutov/node_modules/lazy-ass/index.js:110:14)
    at lazyAss (/Users/irinakous/git/generator-node-bahmutov/node_modules/lazy-ass/index.js:115:28)
    at g._recordAnswers (/Users/irinakous/git/generator-node-bahmutov/app/index.js:114:5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.