Skip to content

Commit

Permalink
release: v0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
NickKelly1 committed Jul 30, 2021
1 parent bc8152c commit 733c237
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish --access public
- run: npm publish dist --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
# @nkp/error

Coerce an unknown error into an instance of the Error class
[![npm version](https://badge.fury.io/js/%40nkp%2Ferror.svg)](https://badge.fury.io/js/%40nkp%2Ferror)
[![Node.js Package](https://github.com/NickKelly1/nkp-error/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/NickKelly1/nkp-error/actions/workflows/npm-publish.yml)
![snyk](https://snyk-widget.herokuapp.com/badge/npm/%40nkp%2Ferror/badge.svg)

## Examples
Coerce an unknown error into an instance of the Error class.

## Installation

This package exports as CommonJS (default), ES Modules, and UMD.

For ES Modules and tree shaking use a bundler that supports ES modules such as [rollup](https://rollupjs.org/guide/en/) or [webpack](https://webpack.js.org/).

### With npm

```sh
npm install @nkp/error
```

### With script tags

```html
<head>
<!-- insert your desired version -->
<script src="https://unpkg.com/browse/@nkp/[email protected]/"></script>
</head>

```

## Usage

```ts
try {
Expand All @@ -26,12 +52,12 @@ catch(error) { assert(typeof error === 'string')
in this case, since a `string` is thrown and not an `Error` instance, there is no way to obtain the stack trace from the thrown point. Instead, `coerceError` will start the stack trace in the `catch` block.
## Releasing a new version
## Publishing
To a release a new version:
1. Update the version number in package.json
2. Push the new version to the `master` branch on GitHub
3. Create a `new release` on GitHub for the latest version
This will trigger a GitHub action that tests and publishes the npm package.
A GitHub action will test and publishes the npm package. Note, the `dist` folder is published.
18 changes: 18 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.0.4 - 2021-06-29

### Added

- UMD exports

### Changed

- Instead of the root folder, the `dist` folder is now published. The published project structure is now:
- d: dist (published)
- f: LICENSE
- f: package.json
- d: es (project as es modules)
- d: cjs (project as cjs)
- d: umd (project as umd)
- Updated readme with badges and more information.
- Temporarily disabled terser rollup plugin. Builds will temporarily not minified.

## 0.0.2 - 2021-06-29

Re-release
Expand Down
12 changes: 9 additions & 3 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,29 @@ export default [
input: 'src/index.ts',
output: [
{
file: packageJson.main,
file: `dist/${packageJson.main}`,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
file: `dist/${packageJson.module}`,
format: 'es',
exports: 'named',
sourcemap: true,
},
{
name: '$nkp',
file: `dist/${packageJson.umd}`,
format: 'umd',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ tsconfig: 'config/tsconfig.build.json', }),
terser(),
// terser(),
],
},
];
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@nkp/error",
"version": "0.0.2",
"version": "0.0.4",
"description": "Coerce an unknown error into an instance of the JavaScript Error class",
"main": "dist/index.js",
"module": "dist/index.es.js",
"main": "cjs/index.js",
"module": "es/index.js",
"umd": "umd/index.js",
"author": "Nick Kelly",
"homepage": "https://github.com/NickKelly1/nkp-error#readme",
"readme": "https://github.com/NickKelly1/nkp-error#readme",
Expand All @@ -20,15 +21,11 @@
"TypeScript",
"JavaScript"
],
"files": [
"dist",
"LICENSE"
],
"scripts": {
"test": "jest -c config/jest.config.ts",
"build": "rimraf dist && rollup -c config/rollup.config.js",
"test:watch": "jest -c config/jest.config.ts --watch",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build && cp package.json dist/ && cp LICENSE dist/"
},
"devDependencies": {
"@jest/types": "^26.6.2",
Expand Down

0 comments on commit 733c237

Please sign in to comment.