This is a template TypeScript Package ready to be published to NPM. It has been set up with automated tests and package publishing workflow using GitHub Actions.
The template uses google-github-actions/release-please-action which handles the following use cases:
- Automated releases based on conventional commits
- Automated
CHANGELOG
generation - Automated version bumps based on commit messages. It does all of these by parsing the git history, it looks for Conventional Commit messages and it creates PR releases.
It uses npm
, TypeScript
, Jest
, ESLint
, Prettier
, Husky
, commitlint
and lint-staged
. The production files include CommonJS, ES Modules and TypeScript declaration files.
Install dependencies with npm:
npm install
- Update the
TODO
s inside.github/workflows/publish.yml
file - Make the necessary changes in package.json (name, version, description, keywords, author, etc).
- Write your code in
src/
folder and unit test intests/
folder, replacing the original files.
To build/compile the code, simply run:
npm run build
This command will generate CommonJS, ES Module as well as TypeScript declaration files inside the lib/
folder.
Test your code with Jest:
npm run test
This package is configured to use GitHub Actions CI/CD to automate the publishing of a package to npm
.
Follow npm's official instruction to create an npm token.
If you use 2FA, then make sure it's enabled for authorization only instead of authorization and publishing (Edit Profile -> Modify 2FA).
On the page of your newly created or existing GitHub repo, click Settings -> Secrets -> New repository secret, the Name should be NPM_TOKEN
and the Value should be your npm token.
The most important prefixes you should have in mind are: