A template used for projects which produce both CommonJS and ESM packages from a common Typescript ESM codebase.
Includes testing, coverage, coveralls.io, linting, TSDoc and auto creation of a package on creating a github release.
If you are creating a new project from this template, instructions are here.
This is a github hosted package so you need to add an entry to your .npmrc
file so the package manager knows where to download the package from:
@x-ware-ltd:registry=https://npm.pkg.github.com
Then:
> npm install @gilbertbw/test-node-library
If the package is private
you need to authenticate to github by getting a Personal Access Token from github with read:packages
permissions. Either login for the session, which will request your github username, and password (use your Personal Access Token):
> npm login --scope=@x-ware-ltd --registry=https://npm.pkg.github.com
Or, create a personal .npmrc
file in your home directory:
//npm.pkg.github.com/:_authToken=aaa_abcDeFghIjklMNopqRSTuvWXYz
If you are running CI/CD on your package you will need to provide credentials for the server. Save a Personal Access Token in your Github secrets and in your github actions:
- name: Authenticate private github packages
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGE_READ_TOKEN }}" > ~/.npmrc
- Works with CommonJS and ESM
- Provides Typescript types
ESM:
import {add} from '@gilbertbw/test-node-library';
console.log(add(3, 5)); // 8
CommonJS:
var lib = require('@gilbertbw/test-node-library');
console.log(lib.add(3, -1)); // 2
Documentation for add
and subtract
methods can be found in TSDoc for each
Make sure your code passes testing, and create a Pull Request
> npm test