Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ecmascript syntax #345

Merged
merged 9 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,38 @@ on:
- .github/workflows/bump.yml

env:
node_version: "18.x"
node_version: "22.x"

jobs:
test:
name: Test Module
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x, 22.x]
node_index: [0, 1]
total_nodes: [2]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: npm install
run: npm install

- name: npm test
run: npm run test

- name: npm test with coverage
if: ${{ matrix.node-version == env.node_version }} # just run coverage if node 16
run: npm run coverage
env:
CI_NODE_INDEX: ${{ matrix.node_index }}
CI_NODE_TOTAL: ${{ matrix.total_nodes }}

- name: Upload coverage to Codecov
if: ${{ matrix.node-version == env.node_version }} # just run coverage if node 16
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand All @@ -51,10 +52,10 @@ jobs:
name: Lint Module
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}

Expand All @@ -70,14 +71,14 @@ jobs:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- id: version
run: echo ::set-output name=version::$(node -p 'require("./package.json").version')

- name: Draft release
id: draft
uses: release-drafter/release-drafter@v5
uses: release-drafter/release-drafter@v6
with:
version: ${{ steps.version.outputs.version }}
env:
Expand Down
31 changes: 19 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- .github/workflows/bump.yml

env:
node_version: "18.x"
node_version: "20.x"

jobs:
env:
Expand Down Expand Up @@ -40,23 +40,30 @@ jobs:
test:
name: Test Module
runs-on: ubuntu-latest
strategy:
matrix:
node_index: [0, 1]
total_nodes: [2]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}

- name: npm install
run: npm install

- name: npm test
run: |
npm run coverage
run: npm run coverage
env:
CI_NODE_INDEX: ${{ matrix.node_index }}
CI_NODE_TOTAL: ${{ matrix.total_nodes }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand All @@ -65,10 +72,10 @@ jobs:
name: Lint Module
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}

Expand All @@ -86,15 +93,15 @@ jobs:
matrix: ${{ fromJson(needs.env.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Disallow Concurrent Runs
uses: byu-oit/github-action-disallow-concurrent-runs@v2
with:
token: ${{ github.token }}

- name: Set up Node.js
uses: actions/setup-node@v2.1.4
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
registry-url: ${{ matrix.registry.url }}
Expand All @@ -117,13 +124,13 @@ jobs:
runs-on: ubuntu-latest
needs: [publish]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- id: version
run: echo ::set-output name=version::$(node -p 'require("./package.json").version')

- name: Publish Release
uses: release-drafter/release-drafter@v5
uses: release-drafter/release-drafter@v6
with:
publish: true
version: ${{ steps.version.outputs.version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ web_modules/

# TypeScript cache
*.tsbuildinfo
.tsimp/

# Optional npm cache directory
.npm
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ It will pretty-print logs when run locally, but it will write logs in JSON when
## Install

```
npm i @byu-oit/logger
npm i @byu-oit/logger
```

## Usage
Expand Down
86 changes: 55 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "@byu-oit/logger",
"version": "0.4.2",
"version": "1.0.0",
"description": "Default configuration for pino logger",
"engines": {
"node": ">=18"
},
"contributors": [
{
"name": "Scott Hutching",
Expand All @@ -12,56 +15,77 @@
"email": "stuft2@byu.edu"
}
],
"main": "dist/logger.js",
"types": "dist/logger.d.ts",
"type": "module",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"files": [
"dist"
],
"scripts": {
"build": "npx rimraf dist && tsc",
"coverage": "npm run test -- --coverage || exit 0",
"build": "rimraf dist && concurrently \"npm:build:*\" -c cyanBright",
"build:cjs": "tsc -p tsconfig.cjs.json && echo-cli \"{\\\"type\\\": \\\"commonjs\\\"}\" > dist/cjs/package.json",
"build:esm": "tsc -p tsconfig.json && echo-cli \"{\\\"type\\\": \\\"module\\\"}\" > dist/esm/package.json",
"clean": "rimraf dist",
"coverage": "c8 ava",
"lint": "npx ts-standard | snazzy",
"lint:fix": "npx ts-standard --fix | snazzy",
"test": "jest",
"test": "ava",
"prepublishOnly": "npm run build"
},
"author": "Brigham Young University - Office of Information Technology",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/byu-oit/logger.git"
},
"bugs": {
"url": "https://github.com/byu-oit/logger/issues"
},
"dependencies": {
"deepmerge": "^4.2.2",
"pino": "^8.11.0",
"pino-http": "^6.6.0"
"deepmerge": "^4.3.1",
"pino": "^9.3.2",
"pino-http": "^10.2.0"
},
"devDependencies": {
"@tsconfig/node12": "^1.0.11",
"@types/jest": "^29.5.0",
"@types/node": "^16.9.1",
"jest": "^29.5.0",
"lint-staged": "^12.0.2",
"pino-pretty": "^10.0.0",
"@tsconfig/node18": "^18.2.4",
"@types/node": "^18.19.42",
"@types/sinon": "^17.0.3",
"ava": "^6.1.3",
"c8": "^10.1.2",
"concurrently": "^8.2.2",
"echo-cli": "^2.0.0",
"pino-pretty": "^11.2.2",
"rimraf": "^6.0.1",
"sinon": "^18.0.0",
"snazzy": "^9.0.0",
"ts-jest": "^29.1.0",
"typescript": "^5.0.3"
"tsimp": "^2.0.11",
"typescript": "^5.5.4"
},
"optionalDependencies": {
"pino-pretty": ">=7"
},
"engines": {
"node": ">=12"
},
"jest": {
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
}
},
"lint-staged": {
"*.ts": "npm run lint:fix"
},
"repository": {
"type": "git",
"url": "git+https://github.com/byu-oit/logger.git"
},
"bugs": {
"url": "https://github.com/byu-oit/logger/issues"
"ava": {
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--import=tsimp"
]
}
}
4 changes: 2 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger, LoggerOptions, pino } from 'pino'
import { getLevel, isInstalled, isProduction } from './util'
import deepmerge from 'deepmerge'
import { Logger, LoggerOptions, pino } from 'pino'
import { getLevel, isInstalled, isProduction } from './util.js'

export function ByuLogger (options?: LoggerOptions): Logger {
const defaultOptions: LoggerOptions = {
Expand Down
Loading
Loading