4.2.1 • Published 7 years ago

npm-package-generator v4.2.1

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

NPM Package Generator version License

an opinionated npm package template

Build Status Downloads Code Climate Coverage Status Dependency Status Dependencies

The Opinionated Parts

I follow the below set of rules in all projects, npm-package-generator ensures all those rules are followed:

  • write in ES2015, ES2016 & ES2017 syntax, (supports all plugins in Babel that are considered latest
  • outputs npm ready packages supporing all LTS versions of Node & Browsers
  • write tests in ES2017 and run them using tap without needing to compile
  • generate coverage reports without needing to compile
  • runs tests on travis targeting all LTS versions of Node
  • uses .editorconfig for maintaining consistent coding styles enforced by echint
  • uses standard to follow JavaScript Standard Style Guide
  • ignores ./build folder from git
  • use the most permissive open source license (currently ISC)
  • follow a preferred folder tree & npm's default expected file naming (see below)
  • always expose your package's compiled library modules (see below)
  • keep your package lean, only include useful files (compiled & sources) for developers (see package.json > files)
  • use a standard template for README files.
  • Testing
    • use tap for testing & nyc to generate coverage reports
    • use travis optimizations and leverage folder caching.
    • use standard and echint for linting files
    • publish coverage reports to codeclimate (requires configuring travis with the appropriate CODECLIMATE_REPO_TOKEN)
Folder Tree
    /package-name/
    ├── build
    │   ├── browsers (compiled to last 2 versions of top browsers)
    │   │   └── index.js
    │   ├── node4 (compiled to Node v4) (default export)
    │   │   └── index.js
    │   ├── node6 (compiled to Node v6)
    │   │   └── index.js
    │   └── node7 (compiled to Node v7)
    │       └── index.js
    ├── LICENSE
    ├── package.json
    ├── README.md
    ├── src
    │   └── index.js
    └── test
        ├── fixtures
        └── index.js
  • /build: compiled library files, this is the default exposed output.
  • /src: source library files: all common business logic, use this folder for your code

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 any feedback & contribution!

Install

npm install --only=production --save npm-package-generator

Usage

$ npm-package-generator new my-awesome-package ~/Projects/my-awesome-package
    npm-package-generator new <name> [path] [options]

    Options:
      --help             Show help                                         [boolean]
      --author, -a       Author Name            [required] [default: "Ahmad Nassri"]
      --description, -d  Package Description
      --email, -e        Author Email  [required] [default: "ahmad@ahmadnassri.com"]
      --github, -g       Github Username         [required] [default: "ahmadnassri"]
      --website, -w      Author Website
                                [required] [default: "https://www.ahmadnassri.com/"]
      --install, -i      Install Dependencies?           [required] [default: false]

API

generator(options)

import generator from 'npm-package-generator'

options = {
  path: '~/Projects/my-awesome-package',
  name: 'my-awesome-package',
  description: 'my-awesome-package',
  author: 'Ahmad Nassri',
  email: 'ahmad@nassri.email',
  website: 'https://www.ahmadnassri.com/',
  github: 'ahmadnassri',
  install: false
}

generator(options)
  .then(files => console.log(files)) //-> [array of files created]

options

optiondescriptiondefault
namepackage name
pathinstallation path
authorauthor nameprocess.env.NPM_AUTHOR_NAME
descriptionpackage descriptionprocess.env.NPM_PACKAGE_DESCRIPTION
authorauthor nameprocess.env.NPM_AUTHOR_NAME
emailauthor emailprocess.env.NPM_AUTHOR_EMAIL
websiteauthor websiteprocess.env.NPM_AUTHOR_WEBSITE
githubgithub accountprocess.env.NPM_GITHUB_USERNAME
installrun npm install and update dependenciesfalse

:copyright: ahmadnassri.com  ·  License: ISC  ·  Github: @ahmadnassri  ·  Twitter: @ahmadnassri

4.2.1

7 years ago

4.2.0

7 years ago

4.1.2

7 years ago

4.1.1

7 years ago

4.1.0

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.7.0

7 years ago

2.6.0

7 years ago

2.5.0

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.0

7 years ago

2.2.0

8 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.0

9 years ago