Skip to content

Commit

Permalink
feat: add createFrontLogProxyTransmitter and migrate to uvu
Browse files Browse the repository at this point in the history
  • Loading branch information
pismenskiy authored Jul 5, 2022
1 parent 0e77974 commit ddd2fae
Show file tree
Hide file tree
Showing 27 changed files with 3,473 additions and 7,033 deletions.
File renamed without changes.
142 changes: 142 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# This is a Github Workflow that runs tests on any push or pull request.
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
name: CI
on: [push, pull_request]
jobs:
init:
name: init
runs-on: ubuntu-20.04
outputs:
skip: ${{ steps.ci-skip-step.outputs.ci-skip }}
skip-not: ${{ steps.ci-skip-step.outputs.ci-skip-not }}
steps:
- uses: actions/checkout@v3
- id: ci-skip-step
uses: mstachniuk/ci-skip@v1

build:
name: build
needs: init
if: ${{ needs.init.outputs.skip == 'false' }}
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Fetch deps
run: yarn

- name: Build target
run: yarn build

- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: artifact-${{ github.run_id }}
retention-days: 1
path: |
docs
target
flow-typed
typings
buildstamp.json
test_push:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Restore artifact
uses: actions/download-artifact@v3
with:
name: artifact-${{ github.run_id }}

- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn
- name: Unit test only
run: yarn test

- name: Update coverage
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: artifact-${{ github.run_id }}
retention-days: 1
path: |
coverage
.nyc_output
test_pr:
if: github.event_name == 'pull_request'
needs: build
strategy:
matrix:
os: [ ubuntu-20.04 ]
node-version: [ 16, 18 ]
name: Test (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Restore artifact
uses: actions/download-artifact@v3
with:
name: artifact-${{ github.run_id }}

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- name: Test only
if: matrix.node-version != '18' || matrix.os != 'ubuntu-20.04'
run: yarn test

- name: Test & push coverage
if: matrix.node-version == '18' && matrix.os == 'ubuntu-20.04'
run: yarn test

release:
name: Release
# https://github.community/t/trigger-job-on-tag-push-only/18076
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: test_push
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Restore artifact
uses: actions/download-artifact@v3
with:
name: artifact-${{ github.run_id }}

- uses: actions/setup-node@v3
with:
node-version: 18

# - name: Codeclimate
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageLocations: |
# ${{github.workspace}}/coverage/*.lcov:lcov

- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_USER: 'qiwibot'
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_EMAIL: '[email protected]'
GIT_COMMITTER_EMAIL: '[email protected]'
GIT_AUTHOR_NAME: '@qiwibot'
GIT_COMMITTER_NAME: '@qiwibot'
run: npx -p @qiwi/semrel-toolkit semrel
86 changes: 0 additions & 86 deletions .travis.yml

This file was deleted.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ yarn add @qiwi/event-transmitter
```

## Usage
```typescript
import { createFrontLogProxyTransmitter } from '@qiwi/event-transmitter'
const transmitter = createFrontLogProxyTransmitter({
appName: 'my-app',
url: 'https://example.qiwi.com/event'
})

transmitter.error(new Error('some error'))
transmitter.info('some-event')
transmitter.debug('debug')
transmitter.warn('warn')
transmitter.trace('trace')
```

```typescript
import {createTransmitter, createHttpPipe, IPipe} from '@qiwi/event-transmitter'

Expand Down
33 changes: 0 additions & 33 deletions jest.config.json

This file was deleted.

4 changes: 4 additions & 0 deletions loadr.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://github.com/lukeed/uvu/issues/123
// https://github.com/lukeed/uvu/commit/75b6573b0ddd5e8fa6041880fa10cb6c43daeb1d

export const loaders = ['tsm']
70 changes: 39 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
"version": "1.16.1",
"description": "Async adapter to save & deliver reasonable events to some endpoint",
"private": false,
"main": "target/es5/index.js",
"main": "./target/es5/index.cjs",
"source": "target/ts/index.ts",
"type": "module",
"exports": {
"require": "./target/es5/index.cjs",
"import": "./target/es6/index.mjs",
"module": "./target/es6/index.mjs"
},
"types": "typings/index.d.ts",
"typescript": {
"definition": "typings/index.d.ts"
Expand All @@ -21,18 +27,19 @@
"lint": "eslint src/**/*.{ts,js}",
"lint:fix": "yarn lint --fix",
"format": "prettier --write \"src/**/*.ts\"",
"test": "npm-run-all -p -l lint test:unit test:depcheck test:depaudit",
"test:unit": "jest --config=jest.config.json --runInBand",
"test:deps": "npm-run-all -p -l test:depcheck test:depauditfix",
"test:depcheck": "npx depcheck --ignores tslib,@swissquote/crafty-preset-jest,@types/jest,@types/node,typedoc",
"test:depaudit": "yarn audit --groups dependencies --level=moderate; [[ $? -ge 4 ]] && exit 1 || exit 0",
"test:depauditfix": "npx yarn-audit-fix --audit-level=moderate",
"test:report": "yarn test && yarn push:report",
"test": "yarn test:unit && yarn lint",
"test:unit": "c8 -r html -r text -r lcov loadr -- uvu 'src/test/' -i fixturess",
"prebuild": "yarn clean && npx buildstamp --git --out.path buildstamp.json",
"build": "npm-run-all -p -l build:es5 build:es6 build:ts build:libdef build:bundle docs",
"build:es5": "mkdirp target/es5 && tsc -p tsconfig.es5.json",
"build:es6": "mkdirp target/es6 && tsc -p tsconfig.es6.json",
"build:ts": "cpy src/main/ts/ target/ts/",
"build:es5": "mkdirp target/es5 && tsc -p tsconfig.es5.json && yarn build:es5:ext",
"build:es5:ext": "tsc-esm-fix --target=target/es5 --ext=.cjs",
"build:es6": "mkdirp target/es6 && tsc -p tsconfig.es6.json && yarn build:es6:ext",
"build:es6:ext": "tsc-esm-fix --target=target/es6 --ext=.mjs",
"build:ts": "globby-cp ./src/main/ts/ ./target/ts/",
"build:bundle": "microbundle --tsconfig tsconfig.es5.json build src/main/ts/index.ts -o target/bundle",
"build:libdef": "libdefkit --tsconfig=tsconfig.es5.json --tsconfig=tsconfig.es6.json",
"docs": "typedoc ./src/main/ts",
Expand All @@ -56,39 +63,40 @@
},
"homepage": "https://github.com/qiwi/event-transmitter#readme",
"dependencies": {
"@qiwi/substrate": "^1.20.11",
"@types/lodash.once": "^4.1.6",
"@types/lodash.set": "^4.3.6",
"@types/safe-json-stringify": "^1.1.2",
"fast-luhn": "^2.0.0",
"lodash.once": "^4.1.1",
"lodash.set": "^4.3.2",
"safe-json-stringify": "^1.2.0",
"stacktrace-js": "^2.0.2",
"tslib": "^2.3.1"
"nanoid": "3.3.4",
"safe-json-stringify": "^1.2.0"
},
"devDependencies": {
"@qiwi/libdefkit": "^3.1.2",
"@qiwi/libdefkit": "^4.0.8",
"@qiwi/npm-run-all": "^4.1.7",
"@swissquote/crafty-preset-jest": "^1.17.2",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.8",
"@qiwi/substrate": "^1.20.14",
"@types/lodash.once": "^4.1.7",
"@types/lodash.set": "^4.3.7",
"@types/node": "^18.0.0",
"@types/safe-json-stringify": "^1.1.2",
"c8": "^7.11.3",
"coveralls": "^3.1.1",
"cpy-cli": "^3.1.1",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-qiwi": "^1.15.4",
"jest": "^27.4.7",
"microbundle": "^0.14.2",
"cross-fetch": "^3.1.5",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-qiwi": "^1.17.3",
"globby-cp": "^0.0.2",
"loadr": "^0.1.1",
"microbundle": "^0.15.0",
"mkdirp": "^1.0.4",
"prettier": "^2.5.1",
"prettier-config-qiwi": "^1.5.0",
"prettier": "^2.7.1",
"prettier-config-qiwi": "^1.7.2",
"rimraf": "^3.0.2",
"terser": "^5.10.0",
"ts-jest": "^27.1.2",
"typedoc": "^0.22.10",
"typescript": "4.5.4",
"cross-fetch": "^3.1.4"
"terser": "^5.14.1",
"tsc-esm-fix": "^2.18.0",
"tslib": "^2.4.0",
"tsm": "^2.2.1",
"typedoc": "^0.23.2",
"typescript": "4.7.4",
"uvu": "^0.5.6"
},
"prettier": "prettier-config-qiwi"
}
Loading

0 comments on commit ddd2fae

Please sign in to comment.