lemon's lemon-package-generator
npm install lemon-package-generatorlemon-package-generator
> optionated template
lemon-package-generator ensures all the rules given below are followed:
.env.example
.env.example
dotenv for configuration, following the tenets of a twelve-factor app
dotenv in your application entry point, or library if applicable.
travis and leverage folder caching.
mocha for testing
istanbul to generate coverage reports
CODECLIMATE_REPO_TOKEN)
standard and echint for linting files
standard & echint by running on pretest
istanbul on posttest
commander to provide a CLI (Command Line Interface) when applicable
debug-log to provide helpful debugging messages without the use of console.log
EditorConfig files enforced by echint
npm install (see package.json + .npmignore files)
/package-name/
├── bin
│ └── package-name
├── docs
│ ├── API.md
│ └── INSTALL.md
├── .editorconfig
├── .env.example
├── .gitattributes
├── .gitignore
├── .jshintrc
├── lib
│ └── index.js
├── LICENSE
├── .npmignore
├── package.json
├── README.md
├── server.js
├── src
│ └── index.js
├── test
│ ├── fixtures
│ └── index.js
└── .travis.yml
`
- /docs/INSTALL.md: detailed instructions for anything beyond npm install
- /docs/API.md: if your package exposes an language API, or as an application a web API, document here.
- /lib: library files: all common business logic, use this folder as heavily as possible, e.g. Express routers
- /src: application files: the application logic (if any), e.g. Express Server Setup
- server.js: your application entry point (this is the default target of npm start), use for initializing and managing the application state
- .jshintrc: this is only useful for running through an online quality check tool e.g. codeclimate which does not follow standard and has no configuration option for eslint yet.
$3
- remove any optional files and folders based on the type of project (e.g. ./bin, ./src, ./server.js)
- unless directly affecting your logic, don't write custom logic for clustering, use pm2 instead
- only use node v0.12.x and above (unless open-source, start with: node v0.10)
- use npm scripts when possible to automate install and build steps:
- e.g. "postinstall": "bower install"
- e.g. "beforestart": "gulp build"
Work in progress...
This is a work in progress, and will likely be in this state forever!
I will be updating this frequently as common practices change over time, or as I learn new trick.
please reach out to share some feedback & contribute!
Install
`sh
npm install --save lemon-package-generator
`
Usage
`
Usage: lemon-package-generator [options] name path
Options:
-h, --help output usage information
-V, --version output the version number
-a, --author Author Name
-d, --description description
-e, --author-email Author Email
-g, --github Github Username
-i, --install Install Dependencies
-q, --quiet hide npm install output
-w, --website Author Website
`
API
$3
`js
var generator = require('lemon-package-generator')
var options = {
name: 'my-awesome-package',
target: '~/Projects/my-awesome-package'
}
generator(options)
.then(function (files) {
console.log(files) /-> [array of files created] /
})
.catch(function (err) {
console.error(err)
})
`
#### options
| option | description | default |
| ------------- | ----------------------------------------------- | --------------------------------- |
| author | author name | process.env.AUTHOR_NAME |
| description | package description | process.env.PACKAGE_DESCRIPTION |
| email | author email | process.env.AUTHOR_EMAIL |
| github | github account | process.env.GITHUB_USERNAME |
| install | run npm install and update dependencies | false |
| name | package name | process.env.PACKAGE_NAME |
| quiet | pipe npm output to process.stdout | false |
| target | local path where the package files are created | process.cwd() |
| website | author website | process.env.AUTHOR_WEBSITE` |