Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
surol committed Jun 2, 2021
0 parents commit 2dd302d
Show file tree
Hide file tree
Showing 22 changed files with 659 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .codacy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
engines:
duplication:
exclude_paths:
- "src/**/*.spec.ts"
- "src/spec/**"
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
max_line_length = 120
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
ij_continuation_indent_size = 4
ij_any_indent_case_from_switch = false

[*.md]
trim_trailing_whitespace = false
34 changes: 34 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
root: true,
ignorePatterns: ['node_modules/', 'dist/', 'target/', 'd.ts/', '*.d.ts'],
extends: [
'@run-z',
],
overrides: [
{
files: ['*.js', '*.cjs', '*.mjs'],
env: {
node: true,
},
},
{
files: ['*.ts'],
extends: [
'@run-z/eslint-config/typescript',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
},
{
files: ['*.spec.ts'],
extends: [
'@run-z/eslint-config/jest',
],
parserOptions: {
project: './tsconfig.spec.json',
},
},
],
};
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is a basic workflow to help you get started with Actions

name: Build

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
env:
cache-name: cache-node-modules-v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package.json') }}

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install pnpm
run: npm i -g pnpm
- name: Install dependencies
run: pnpm install

- name: Build the project
run: pnpm ci:all

- name: Upload coverage report
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: target/coverage/lcov.info
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Node.js modules
node_modules

# IntelliJ IDEA files
.idea
*.iml

# Logs
*.log

# Yarn cache
/.yarn
!.yarn/releases
!.yarn/plugins
.pnp.*

# Lock files as this is part of Yarn worktree
yarn.lock
package-lock.json

# Package archive
*.tgz

# Intermediate files
/target

# Distribution directory
/dist

# Type definitions
*.d.ts
*.d.ts.map
37 changes: 37 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Node.js modules
node_modules

# IntelliJ IDEA files
.idea
*.iml

# Intermediate files
/target

# Logs
*.log

# Package archive
*.tgz

# Source files
/src

# Build scripts
/build

# Build configurations
/.*
/*.cjs
/*.js
/*.json

# Package lock
/yarn.lock

# Include distribution dir
!/dist

# Include type definitions
!*.d.ts
!*.d.ts.map
10 changes: 10 additions & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"configuration": {
"list-item-indent": "space"
},
"plugins": [
"remark-preset-lint-recommended",
["remark-lint-list-item-indent", "space"],
["remark-lint-no-shortcut-reference-link", false]
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Ruslan Lopatin <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Logger API
==========

[![NPM][npm-image]][npm-url]
[![Build Status][build-status-img]][build-status-link]
[![Code Quality][quality-img]][quality-link]
[![Coverage][coverage-img]][coverage-link]
[![GitHub Project][github-image]][github-url]
[![API Documentation][api-docs-image]][API documentation]

[npm-image]: https://img.shields.io/npm/v/@proc7ts/logger.svg?logo=npm
[npm-url]: https://www.npmjs.com/package/@proc7ts/logger
[build-status-img]: https://github.com/proc7ts/logger/workflows/Build/badge.svg
[build-status-link]: https://github.com/proc7ts/logger/actions?query=workflow:Build
[quality-img]: https://app.codacy.com/project/badge/Grade/4e45ef3c83a3497fbe8f7fe3341e023c
[quality-link]: https://www.codacy.com/gh/proc7ts/logger/dashboard?utm_source=github.com&utm_medium=referral&utm_content=proc7ts/logger&utm_campaign=Badge_Grade
[coverage-img]: https://app.codacy.com/project/badge/Coverage/4e45ef3c83a3497fbe8f7fe3341e023c
[coverage-link]: https://www.codacy.com/gh/proc7ts/logger/dashboard?utm_source=github.com&utm_medium=referral&utm_content=proc7ts/logger&utm_campaign=Badge_Coverage
[github-image]: https://img.shields.io/static/v1?logo=github&label=GitHub&message=project&color=informational
[github-url]: https://github.com/proc7ts/logger
[api-docs-image]: https://img.shields.io/static/v1?logo=typescript&label=API&message=docs&color=informational
[API documentation]: https://proc7ts.github.io/logger/


Logger
------
[Logger]: #logger

`Logger` interface declares methods corresponding to generic logger levels:

- `error(...args)` - Logs error.
- `warn(...args)` - Logs warning.
- `info(...args)` - Logs informational message.
- `debug(...args)` - Logs debug message.

Each method accepts arbitrary number of arguments.


Console Logger
--------------

`consoleLogger` is a [Logger] instance that logs to [console].

Note that the first parameter isn't treated in any special way. I.e. it is not a [format string].

[console]: https://developer.mozilla.org/en-US/docs/Web/API/Console
[format string]: https://developer.mozilla.org/en-US/docs/Web/API/Console#using_string_substitutions


Silent Logger
-------------

`silentLogger` is a [Logger] instance the never logs anything.
41 changes: 41 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export default {
preset: 'ts-jest/presets/default-esm',
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.spec.ts',
'!src/**/index.ts',
'!**/node_modules/**',
],
coverageDirectory: 'target/coverage',
coverageThreshold: {
global: {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
},
},
extensionsToTreatAsEsm: ['.ts'],
reporters: [
'default',
[
'jest-junit',
{
suiteName: '@proc7ts/logger',
outputDirectory: './target/test-results',
classNameTemplate: '{classname}: {title}',
titleTemplate: '{classname}: {title}',
ancestorSeparator: ' › ',
usePathForSuiteName: 'true',
},
],
],
testEnvironment: 'node',
globals: {
'ts-jest': {
tsconfig: 'tsconfig.spec.json',
useESM: true,
},
},
};
62 changes: 62 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@proc7ts/logger",
"version": "1.0.0",
"description": "Simple logger API",
"keywords": [
"log",
"logger",
"logger-api"
],
"homepage": "https://github.com/proc7ts/logger",
"repository": {
"type": "git",
"url": "ssh://[email protected]:proc7ts/logger.git"
},
"license": "MIT",
"author": "Ruslan Lopatin <[email protected]>",
"bugs": {
"url": "https://github.com/proc7ts/logger/issues"
},
"type": "module",
"main": "./dist/logger.js",
"types": "./index.d.ts",
"exports": "./dist/logger.js",
"devDependencies": {
"@jest/globals": "^27.0.3",
"@rollup/plugin-node-resolve": "^13.0.0",
"@run-z/eslint-config": "^1.3.0",
"@run-z/rollup-helpers": "^1.1.1",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"eslint": "^7.27.0",
"eslint-plugin-jest": "^24.3.6",
"gh-pages": "^3.2.0",
"jest": "^27.0.3",
"jest-junit": "^12.1.0",
"jest-mock": "^27.0.3",
"remark-cli": "^9.0.0",
"remark-preset-lint-recommended": "^5.0.0",
"rollup": "^2.50.5",
"rollup-plugin-flat-dts": "^1.2.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.30.0",
"run-z": "^1.8.0",
"shx": "^0.3.3",
"ts-jest": "^27.0.2",
"tslib": "^2.2.0",
"typedoc": "^0.20.36",
"typescript": "^4.3.2"
},
"scripts": {
"all": "run-z build,lint,test",
"build": "run-z +z --then rollup -c",
"ci:all": "run-z all +test/--ci/--runInBand",
"clean": "run-z +z --then shx rm -rf 'index.d.ts?(.map)' dist target",
"doc": "run-z +z --then typedoc",
"doc:publish": "run-z doc --then gh-pages --dist target/typedoc --dotfiles",
"lint": "run-z + lint:md --and eslint .",
"lint:md": "run-z +z --then remark .",
"test": "run-z +z env:NODE_OPTIONS='--experimental-vm-modules --no-warnings' --then jest",
"z": "run-z +cmd:rollup,+cmd:typedoc,+cmd:eslint,+cmd:remark,+cmd:jest"
}
}
Loading

0 comments on commit 2dd302d

Please sign in to comment.