- Interactive package creation
- Choices of JS, JSX, TS, TSX
- Silent mode
- Package manager selection (yarn or npm)
- Choices of ES, CJS, UMD modules and all together
- RollUp bundler
- Linting
- Tests
- Semantic Release
- README template with badges
- Continuous integration: Travis
- License selection (ISC, MIT, UNLICENSED)
To create package once, package runner is recommended
$ npx @epranka/create-package my-package
# or
$ yarn create @epranka/package my-package
If you want to create packages later, install and use this package as follows
$ npm install -g @epranka/create-package
# or
$ yarn global add @epranka/create-package
# and then use
$ create-package my-package
You will be asked some questions about package
@epranka/create-package
✨ Generating package in my-package
? Package name my-package
? Package description My cat's meow package
? Package type React Typescript (TSX)
? Full name of package author Edvinas Pranka
? Email of package author (public) epranka@gmail.com
? Select license ISC
? Choose the package manager Yarn
? Build to UMD module for browsers (CommonJS is default) ? No
? Build to ES Module ? Yes
? Use unit tests ? Yes
? Use automatic semantic releases ? Yes
? Use Travis ? Yes
? Repository URL https://github.com/epranka/create-package
If automated semantic releases are selected, package generation will take longer and you will be prompted for semantic release options
When your package are generated your entry point is in ./src/
directory. If Use unit tests are selected, tests can be found in ./__tests__
directory
In your package root directory you can run following commands
To build package
$ yarn build // or npm run build
To watch changes and build
$ yarn watch // or npm run watch
To lint package
$ yarn lint // or npm run lint
If Use unit tests are selected, test package
$ yarn test // npm run test
When the package created, the package.json file has a private property set to true. It prevents accidentally publishing the package. Then you are ready to publish, just remove private property from the package.json file.
You can create a package without user interaction using the --silent option. Pass package values along with the command. See section CLI Help below
$ create-package my-package --name my-package --description "My cat's meow package" --type tsx --author "Edvinas Pranka" --email "epranka@gmail.com" --license ISC --travis
If you choose --semantic-release option in silent mode, you will have to setup it after the package has been created. Use semantic-release-cli in the root of the package
$ npm -g install semantic-release-cli
$ semantic-release-cli setup
After setup, you can uninstall the semantic-release-cli package
@epranka/create-package
Usage:
$ create-package [out-dir]
Commands:
[out-dir] Generate in a <out-dir> or current directory
For more info, run any command with the `--help` flag:
$ create-package --help
Options:
-i, --info Print out debugging information relating to the local environment
-s, --silent Silent mode. Create package without user interaction
--name <name> Name of the package
--description <name> Description of the package
--author <fullname> Author of package <fullname>
--email <email> <email> of author
--npm Use NPM package manager. Default is YARN
--mit MIT license. Default is ISC
--umd <GlobalName> Build UMD module with <GlobalName>
--type <ts|tsx|js|jsx> Type of package, one of TS, TSX, JS, JSX. Default is TS
--unlicensed Unlicensed. This option overrides --mit option
--travis Use Travis ci
--semantic-release Use semantic release
--no-private No private:true property in package.json (default: true)
--no-es Don't build ES Module (default: true)
--no-tests Don't use tests (default: true)
--skip-semantic-release-setup Skip semantic release setup
--verbose Show debug logs
-h, --help Display this message
-v, --version Display version number
Created JS package will have following structure (if Use tests, Semantic Release and Travis is selected)
my-package
├── src
│ └── index.js // your entry point
├── __tests__
│ └── index.spec.js // tests goes here
├── node_modules
├── babel.config.js
├── .eslintrc.json
├── .gitignore
├── jest.config.js
├── LICENSE
├── package.json
├── README.md
├── .releaserc
├── rollup.config.js
└── .travis.yml
Created JSX package will have following structure (if Use tests, Semantic Release and Travis is selected)
my-package
├── src
│ └── index.jsx // your entry point
├── __tests__
│ └── index.spec.jsx // tests goes here
├── node_modules
├── babel.config.js
├── .eslintrc.json
├── .gitignore
├── jest.config.js
├── LICENSE
├── package.json
├── README.md
├── .releaserc
├── rollup.config.js
└── .travis.yml
Created TS package will have following structure (if Use tests, Semantic Release and Travis is selected)
my-package
├── src
│ └── index.ts // your entry point
├── __tests__
│ └── index.spec.ts // tests goes here
├── node_modules
├── babel.config.js
├── .gitignore
├── jest.config.js
├── LICENSE
├── package.json
├── README.md
├── .releaserc
├── rollup.config.js
├── .travis.yml
├── tsconfig.json
└── eslintrc.json
Created TSX package will have following structure (if Use tests, Semantic Release and Travis is selected)
my-package
├── src
│ └── index.tsx // your entry point
├── __tests__
│ └── index.spec.tsx // tests goes here
├── node_modules
├── babel.config.js
├── .gitignore
├── jest.config.js
├── LICENSE
├── package.json
├── README.md
├── .releaserc
├── rollup.config.js
├── .travis.yml
├── tsconfig.json
└── .eslintrc.json
Let people know that your package is generated using @epranka/create-package by including this badge in your readme
Using Markdown
[![generated with @epranka/create-package](https://img.shields.io/badge/generated%20with-%40epranka%2Fcreate--package-blue)](https://github.com/epranka/create-package)
Using HTML
<a href="https://github.com/epranka/create-package">
<img alt="generated with" src="https://img.shields.io/badge/generated%20with-%40epranka%2Fcreate--package-blue" />
</a>
Edvinas pranka (epranka@gmail.com)
Follow on Twitter @epranka
ISC License
Copyright (c) 2019, Edvinas Pranka (epranka@gmail.com)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.