generated from krauters/typescript-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7692544
Showing
24 changed files
with
8,205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This auto assigns the following teams to pull requests | ||
* @krauters/reviewers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Node Publish | ||
run-name: Node Publish [${{ github.ref_name }}] triggered by [${{ github.event_name }}/${{ github.actor }}] | ||
|
||
on: | ||
release: | ||
types: published | ||
push: | ||
branches: '*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
uses: krauters/shared-workflows/.github/workflows/node-publish.yaml@main | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
with: | ||
node_install: true | ||
dry_run: ${{ github.event_name != 'release' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Node Release | ||
run-name: Node Release [${{ github.ref_name }}] triggered by [${{ github.event_name }}/${{ github.actor }}] | ||
|
||
on: | ||
push: | ||
branches: main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
uses: krauters/shared-workflows/.github/workflows/node-release.yaml@main | ||
secrets: | ||
GH_TOKEN_RELEASES: ${{ secrets.GH_TOKEN_RELEASES }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Node.js dependencies | ||
node_modules/ | ||
|
||
# Output directories | ||
dist/ | ||
|
||
# IDE and editor files | ||
.idea/ | ||
.vscode/ | ||
|
||
# System files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Coverage directories | ||
coverage/ | ||
|
||
# Environment variable files | ||
dev.env | ||
.env | ||
.env.local | ||
.env.*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
MAIN_DIR=./node_modules/@krauters/utils/scripts/pre-commit | ||
. $MAIN_DIR/index.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
registry=https://registry.npmjs.org/ | ||
//registry.npmjs.org/:_authToken=${NPM_TOKEN} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ISC License | ||
|
||
Copyright (c) 2024 Krauters | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<div align="center"> | ||
|
||
<a href="https://www.linkedin.com/in/coltenkrauter/" target="_blank"><img src="https://img.shields.io/badge/LinkedIn-%230077B5.svg?&style=flat-square&logo=linkedin&logoColor=white" alt="LinkedIn"></a> | ||
![License](https://img.shields.io/github/license/krauters/debuggable) | ||
![visitors](https://visitor-badge.laobi.icu/badge?page_id=krauters.debuggable) | ||
|
||
![Version](https://img.shields.io/github/v/release/krauters/debuggable) | ||
[![npm version](https://img.shields.io/npm/v/@krauters/debuggable.svg?style=flat-square)](https://www.npmjs.org/package/@krauters/debuggable) | ||
![GitHub Stars](https://img.shields.io/github/stars/krauters/debuggable) | ||
![Forks](https://img.shields.io/github/forks/krauters/debuggable) | ||
|
||
![GitHub Issues](https://img.shields.io/github/issues/krauters/debuggable) | ||
![Open PRs](https://img.shields.io/github/issues-pr/krauters/debuggable) | ||
![Commits per Month](https://img.shields.io/github/commit-activity/m/krauters/debuggable) | ||
![Contributors](https://img.shields.io/github/contributors/krauters/debuggable) | ||
![Last Commit](https://img.shields.io/github/last-commit/krauters/debuggable) | ||
|
||
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=@krauters/debuggable&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=@krauters/debuggable) | ||
![Code Size](https://img.shields.io/github/languages/code-size/krauters/debuggable) | ||
![Repo Size](https://img.shields.io/github/repo-size/krauters/debuggable) | ||
|
||
</div> | ||
|
||
# Debuggable | ||
|
||
TypeScript base class for adding method-level debug logs and tracking execution time. The `debuggable` decorator can be applied at the class level to automatically log all method calls, inputs, return values, and execution duration. | ||
|
||
## Usage | ||
|
||
The `debuggable` decorator can be used to automatically wrap all methods of a class to log execution details and time taken. | ||
|
||
```ts | ||
import { debuggable } from '@krauters/debuggable' | ||
|
||
@debuggable() | ||
export class MyService { | ||
constructor() { | ||
console.info('Service initialized') | ||
} | ||
|
||
public processRequest(data: string): string { | ||
return `Processed: ${data}` | ||
} | ||
|
||
public anotherMethod() { | ||
return 'Another result' | ||
} | ||
} | ||
|
||
const service = new MyService() | ||
service.processRequest('testData') | ||
service.anotherMethod() | ||
|
||
// Expected Output in Console: | ||
// | ||
// [DurationTracker] Initializing [DurationTracker] | ||
// [Debuggable] Decorating the following [MyService] methods with debuggable: [length, name, prototype] | ||
// [Debuggable] Decorating the following [MyService] methods with debuggable: [constructor, processRequest, anotherMethod] | ||
// Service initialized | ||
// [Debuggable] Calling [MyService.processRequest] with args ["testData"] | ||
// [Debuggable] Called [MyService.processRequest] which returned ["Processed: testData"] and took [0] ms | ||
// [Debuggable] Calling [MyService.anotherMethod] with args [] | ||
// [Debuggable] Called [MyService.anotherMethod] which returned ["Another result"] and took [0] ms | ||
``` | ||
|
||
## Installation | ||
|
||
```zsh | ||
npm install @krauters/debuggable@latest | ||
``` | ||
|
||
|
||
## Husky | ||
|
||
Husky helps manage Git hooks easily, automating things like running tests or linting before a commit is made. This ensures your code is in good shape. | ||
|
||
Pre-commit hooks run scripts before a commit is finalized to catch issues or enforce standards. With Husky, setting up these hooks across your team becomes easy, keeping your codebase clean and consistent. | ||
|
||
### Our Custom Pre-Commit Hook | ||
|
||
This project uses a custom pre-commit hook to run `npm run bundle`. This ensures that our bundled assets are always up to date before any commit (which is especially important for TypeScript GitHub Actions). Husky automates this, so no commits will go through without a fresh bundle, keeping everything streamlined. | ||
|
||
## Contributing | ||
|
||
The goal of this project is to continually evolve and improve its core features, making it more efficient and easier to use. Development happens openly here on GitHub, and we’re thankful to the community for contributing bug fixes, enhancements, and fresh ideas. Whether you're fixing a small bug or suggesting a major improvement, your input is invaluable. | ||
|
||
## License | ||
|
||
This project is licensed under the ISC License. Please see the [LICENSE](./LICENSE) file for more details. | ||
|
||
## 🥂 Thanks Contributors | ||
|
||
Thanks for spending time on this project. | ||
|
||
<a href="https://github.com/krauters/debuggable/graphs/contributors"> | ||
<img src="https://contrib.rocks/image?repo=krauters/debuggable" /> | ||
</a> | ||
|
||
<br /> | ||
<br /> | ||
<a href="https://www.buymeacoffee.com/coltenkrauter"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=coltenkrauter&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable filenames/match-exported */ | ||
const eslintConfig = require('@krauters/eslint-config') | ||
|
||
module.exports = eslintConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { debuggable } from '../src' | ||
|
||
@debuggable() | ||
export class MyService { | ||
constructor() { | ||
console.info('Service initialized') | ||
} | ||
|
||
public processRequest(data: string): string { | ||
// Simulate processing | ||
return `Processed: ${data}` | ||
} | ||
|
||
public anotherMethod() { | ||
return 'Another result' | ||
} | ||
} | ||
|
||
const service = new MyService() | ||
service.processRequest('testData') | ||
service.anotherMethod() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
|
||
module.exports = { | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageThreshold: { | ||
global: { | ||
branches: 60, | ||
functions: 60, | ||
lines: 60, | ||
statements: 60, | ||
}, | ||
}, | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/test/**/*.test.{ts,tsx}'], | ||
transform: { | ||
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.jest.json' }], | ||
}, | ||
} |
Oops, something went wrong.