pax_global_header 0000666 0000000 0000000 00000000064 14157101322 0014506 g ustar 00root root 0000000 0000000 52 comment=cf5718055d833b59f6a737b7385bf16b10407146
essentials-1.2.0/ 0000775 0000000 0000000 00000000000 14157101322 0013660 5 ustar 00root root 0000000 0000000 essentials-1.2.0/.editorconfig 0000664 0000000 0000000 00000000446 14157101322 0016341 0 ustar 00root root 0000000 0000000 # EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
trim_trailing_whitespace = true
[*.{md,yml}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = false
essentials-1.2.0/.github/ 0000775 0000000 0000000 00000000000 14157101322 0015220 5 ustar 00root root 0000000 0000000 essentials-1.2.0/.github/FUNDING.yml 0000664 0000000 0000000 00000000020 14157101322 0017025 0 ustar 00root root 0000000 0000000 github: medikoo
essentials-1.2.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14157101322 0017255 5 ustar 00root root 0000000 0000000 essentials-1.2.0/.github/workflows/integrate.yml 0000664 0000000 0000000 00000002163 14157101322 0021764 0 ustar 00root root 0000000 0000000 # main only
name: Integrate
on:
push:
branches: [main]
env:
FORCE_COLOR: 1
jobs:
tagIfNewVersion:
name: Tag if new version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Ensure to have complete history of commits pushed with given push operation
# It's loose and imperfect assumption that no more than 30 commits will be pushed at once
fetch-depth: 30
# Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow
# Hence we're passing 'serverless-ci' user authentication token
token: ${{ secrets.USER_GITHUB_TOKEN }}
- name: Tag if new version
if: github.event.before != '0000000000000000000000000000000000000000' # Skip on first commit
run: |
NEW_VERSION=`git diff -U0 ${{ github.event.before }} package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$NEW_VERSION" ];
then
git tag v$NEW_VERSION
git push --tags
fi
essentials-1.2.0/.github/workflows/publish.yml 0000664 0000000 0000000 00000002735 14157101322 0021455 0 ustar 00root root 0000000 0000000 # Version tags only
name: Publish
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
env:
# It'll work with secrets.GITHUB_TOKEN (which is provided by GitHub unconditionally)
# Still then release author would be "github-actions"
GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Retrieve dependencies from cache
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-refs/heads/main-${{ hashFiles('package.json') }}
- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org
- name: Publish new version
# Note: Setting NODE_AUTH_TOKEN as job|workspace wide env var won't work
# as it appears actions/setup-node sets own value
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Publish release notes
run: |
TEMP_ARRAY=($(echo $GITHUB_REF | tr "/" "\n"))
TAG=${TEMP_ARRAY[@]: -1}
npx github-release-from-cc-changelog $TAG
essentials-1.2.0/.github/workflows/validate.yml 0000664 0000000 0000000 00000002150 14157101322 0021567 0 ustar 00root root 0000000 0000000 # PR's only
name: Validate
on:
pull_request:
branches: [main]
env:
FORCE_COLOR: 1
jobs:
linuxNode16:
name: "[Linux] Node.js v16: Lint, Formatting"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v16-${{ runner.os }}-${{ github.ref }}-
npm-v16-${{ runner.os }}-refs/heads/main-
- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Validate Prettier formatting
run: npm run prettier-check:updated
- name: Validate ESLint rules
run: npm run lint:updated
essentials-1.2.0/.gitignore 0000664 0000000 0000000 00000000057 14157101322 0015652 0 ustar 00root root 0000000 0000000 /node_modules
npm-debug.log
/package-lock.json
essentials-1.2.0/.npmignore 0000664 0000000 0000000 00000000056 14157101322 0015660 0 ustar 00root root 0000000 0000000 /.editorconfig
/.github
/commitlint.config.js
essentials-1.2.0/CHANGELOG.md 0000664 0000000 0000000 00000001744 14157101322 0015477 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [1.2.0](https://github.com/medikoo/essentials/compare/v1.1.1...v1.2.0) (2021-12-17)
### Features
- Prevent doubled load of the module (otherwise unhandled rejections are silent) ([b8c5536](https://github.com/medikoo/essentials/commit/b8c553613671d35f0d6eab2a504408eb2ba63ee9))
### [1.1.1](https://github.com/medikoo/essentials/compare/v1.1.0...v1.1.1) (2019-11-08)
_Maintanance update_
## [1.1.0](https://github.com/medikoo/essentials/compare/v1.0.0...v1.1.0) (2019-11-08)
### Features
- Do not throw on unhandled rejection if custom handler registered ([44d6301](https://github.com/medikoo/essentials/commit/44d6301))
# 1.0.0 (2019-01-15)
### Features
- ensure to address browsers with `process` polyfill ([43dbded](https://github.com/medikoo/essentials/commit/43dbded))
essentials-1.2.0/LICENSE 0000664 0000000 0000000 00000001405 14157101322 0014665 0 ustar 00root root 0000000 0000000 ISC License
Copyright (c) 2019-2021, Mariusz Nowak, @medikoo, medikoo.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.
essentials-1.2.0/README.md 0000664 0000000 0000000 00000001524 14157101322 0015141 0 ustar 00root root 0000000 0000000 [![npm version][npm-image]][npm-url]
# essentials
## Essential initialization for every JavaScript process, ensures that:
#### Error stack traces list all stack frames
Affects all major engines, aside Firefox, in which it's not adjustable and hardcoded to 128.
#### Unhandled promise rejections are exposed as uncaught exceptions
Affects all V8 based engines (so Chrome and Node.js) and Microsoft Edge
In other engines it is recommended to rely on some `Promise` polyfill, which ensures unhandled rejections are being communicated with `unhandledrejection` events on global object.
### Installation
```bash
npm install essentials
```
### Usage
At top of main (entry) module simply require
```javascript
require("essentials");
```
[npm-image]: https://img.shields.io/npm/v/essentials.svg
[npm-url]: https://www.npmjs.com/package/essentials
essentials-1.2.0/commitlint.config.js 0000664 0000000 0000000 00000001236 14157101322 0017643 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = {
rules: {
"body-leading-blank": [2, "always"],
"body-max-line-length": [2, "always", 72],
"footer-leading-blank": [2, "always"],
"footer-max-line-length": [2, "always", 72],
"header-max-length": [2, "always", 72],
"scope-case": [2, "always", "start-case"],
"scope-enum": [2, "always", [""]],
"subject-case": [2, "always", "sentence-case"],
"subject-empty": [2, "never"],
"subject-full-stop": [2, "never", "."],
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"],
"type-enum": [
2, "always",
["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test"]
]
}
};
essentials-1.2.0/index.js 0000664 0000000 0000000 00000001445 14157101322 0015331 0 ustar 00root root 0000000 0000000 "use strict";
var uniGlobal = require("uni-global")("medikoo/essentials/202112");
if (uniGlobal.isSetup) {
// Doubled load of essentials, abort
return;
}
uniGlobal.isSetup = true;
// 1. Expose every stack frame in error stack trace
Error.stackTraceLimit = Infinity;
// 2. Expose unhandled promise rejections as uncaught exceptions
if (typeof process === "object" && process && typeof process.on === "function") {
// Node.js
process.on("unhandledRejection", function (reason) {
// If user attached its own unhandledRejection handler, abort
if (process.listenerCount("unhandledRejection") > 1) return;
throw reason;
});
}
if (typeof addEventListener === "function") {
// HTML
addEventListener("unhandledrejection", function (event) {
event.preventDefault();
throw event.reason;
});
}
essentials-1.2.0/package.json 0000664 0000000 0000000 00000003400 14157101322 0016143 0 ustar 00root root 0000000 0000000 {
"name": "essentials",
"version": "1.2.0",
"description": "Essential initialization for every JavaScript process",
"author": "Mariusz Nowak (http://www.medikoo.com/)",
"keywords": [
"initialization",
"process",
"promise",
"setup",
"unhandledrejections"
],
"repository": {
"type": "git",
"url": "git://github.com/medikoo/essentials.git"
},
"dependencies": {
"uni-global": "^1.0.0"
},
"devDependencies": {
"eslint": "^8.4.1",
"eslint-config-medikoo": "^4.1.1",
"git-list-updated": "^1.2.1",
"github-release-from-cc-changelog": "^2.2.0",
"husky": "^4.3.8",
"lint-staged": "^12.1.2",
"prettier-elastic": "^2.2.1"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint"
],
"*.{css,html,js,json,md,yaml,yml}": [
"prettier -c"
]
},
"eslintConfig": {
"extends": "medikoo/es3",
"root": true,
"globals": {
"process": true,
"addEventListener": true
}
},
"prettier": {
"printWidth": 100,
"tabWidth": 4,
"overrides": [
{
"files": [
"*.md",
"*.yml"
],
"options": {
"tabWidth": 2
}
}
]
},
"scripts": {
"lint": "eslint --ignore-path=.gitignore .",
"lint:updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
"prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
"prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
"prettify": "prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
"prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write"
},
"license": "ISC"
}