Skip to content

Commit 6691a0d

Browse files
committed
Initial commit
0 parents  commit 6691a0d

24 files changed

+8204
-0
lines changed

.github/CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This auto assigns the following teams to pull requests
2+
* @krauters/reviewers

.github/workflows/node-publish.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Node Publish
2+
run-name: Node Publish [${{ github.ref_name }}] triggered by [${{ github.event_name }}/${{ github.actor }}]
3+
4+
on:
5+
release:
6+
types: published
7+
push:
8+
branches: '*'
9+
workflow_dispatch:
10+
11+
jobs:
12+
publish:
13+
uses: krauters/shared-workflows/.github/workflows/node-publish.yaml@main
14+
secrets:
15+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
16+
with:
17+
node_install: true
18+
dry_run: ${{ github.event_name != 'release' }}

.github/workflows/node-release.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Node Release
2+
run-name: Node Release [${{ github.ref_name }}] triggered by [${{ github.event_name }}/${{ github.actor }}]
3+
4+
on:
5+
push:
6+
branches: main
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish:
11+
uses: krauters/shared-workflows/.github/workflows/node-release.yaml@main
12+
secrets:
13+
GH_TOKEN_RELEASES: ${{ secrets.GH_TOKEN_RELEASES }}

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Node.js dependencies
2+
node_modules/
3+
4+
# Output directories
5+
dist/
6+
7+
# IDE and editor files
8+
.idea/
9+
.vscode/
10+
11+
# System files
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Coverage directories
16+
coverage/
17+
18+
# Environment variable files
19+
dev.env
20+
.env
21+
.env.local
22+
.env.*.local

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
MAIN_DIR=./node_modules/@krauters/utils/scripts/pre-commit
4+
. $MAIN_DIR/index.sh

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npmjs.org/
2+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

LICENSE

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ISC License
2+
3+
Copyright (c) 2024 Krauters
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15+
PERFORMANCE OF THIS SOFTWARE.

README.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<div align="center">
2+
3+
<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>
4+
![License](https://img.shields.io/github/license/krauters/debuggable)
5+
![visitors](https://visitor-badge.laobi.icu/badge?page_id=krauters.debuggable)
6+
7+
![Version](https://img.shields.io/github/v/release/krauters/debuggable)
8+
[![npm version](https://img.shields.io/npm/v/@krauters/debuggable.svg?style=flat-square)](https://www.npmjs.org/package/@krauters/debuggable)
9+
![GitHub Stars](https://img.shields.io/github/stars/krauters/debuggable)
10+
![Forks](https://img.shields.io/github/forks/krauters/debuggable)
11+
12+
![GitHub Issues](https://img.shields.io/github/issues/krauters/debuggable)
13+
![Open PRs](https://img.shields.io/github/issues-pr/krauters/debuggable)
14+
![Commits per Month](https://img.shields.io/github/commit-activity/m/krauters/debuggable)
15+
![Contributors](https://img.shields.io/github/contributors/krauters/debuggable)
16+
![Last Commit](https://img.shields.io/github/last-commit/krauters/debuggable)
17+
18+
[![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)
19+
![Code Size](https://img.shields.io/github/languages/code-size/krauters/debuggable)
20+
![Repo Size](https://img.shields.io/github/repo-size/krauters/debuggable)
21+
22+
</div>
23+
24+
# Debuggable
25+
26+
A TypeScript utility that automatically adds detailed debug logs before and after method calls in classes, simplifying the tracking of execution flow and troubleshooting.
27+
28+
## Usage
29+
30+
A TypeScript utility that automatically adds detailed debug logs before and after method calls in classes, simplifying the tracking of execution flow and troubleshooting.
31+
```ts
32+
import { debuggable } from '@krauters/debuggable'
33+
34+
@debuggable()
35+
export class MyService {
36+
constructor() {
37+
console.info('Service initialized')
38+
}
39+
40+
public processRequest(data: string): string {
41+
return `Processed: ${data}`
42+
}
43+
44+
public anotherMethod() {
45+
return 'Another result'
46+
}
47+
}
48+
49+
const service = new MyService()
50+
service.processRequest('testData')
51+
service.anotherMethod()
52+
53+
// Expected Output in Console:
54+
//
55+
// [DurationTracker] Initializing [DurationTracker]
56+
// [Debuggable] Decorating the following [MyService] methods with debuggable: [length, name, prototype]
57+
// [Debuggable] Decorating the following [MyService] methods with debuggable: [constructor, processRequest, anotherMethod]
58+
// Service initialized
59+
// [Debuggable] Calling [MyService.processRequest] with args ["testData"]
60+
// [Debuggable] Called [MyService.processRequest] which returned ["Processed: testData"] and took [0] ms
61+
// [Debuggable] Calling [MyService.anotherMethod] with args []
62+
// [Debuggable] Called [MyService.anotherMethod] which returned ["Another result"] and took [0] ms
63+
```
64+
65+
## Installation
66+
67+
```zsh
68+
npm install @krauters/debuggable@latest
69+
```
70+
71+
72+
## Husky
73+
74+
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.
75+
76+
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.
77+
78+
### Our Custom Pre-Commit Hook
79+
80+
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.
81+
82+
## Contributing
83+
84+
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.
85+
86+
## License
87+
88+
This project is licensed under the ISC License. Please see the [LICENSE](./LICENSE) file for more details.
89+
90+
## 🥂 Thanks Contributors
91+
92+
Thanks for spending time on this project.
93+
94+
<a href="https://github.com/krauters/debuggable/graphs/contributors">
95+
<img src="https://contrib.rocks/image?repo=krauters/debuggable" />
96+
</a>
97+
98+
<br />
99+
<br />
100+
<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>

eslint.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* eslint-disable filenames/match-exported */
2+
const eslintConfig = require('@krauters/eslint-config')
3+
4+
module.exports = eslintConfig

examples/1.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { debuggable } from '../src'
2+
3+
@debuggable()
4+
export class MyService {
5+
constructor() {
6+
console.info('Service initialized')
7+
}
8+
9+
public processRequest(data: string): string {
10+
// Simulate processing
11+
return `Processed: ${data}`
12+
}
13+
14+
public anotherMethod() {
15+
return 'Another result'
16+
}
17+
}
18+
19+
const service = new MyService()
20+
service.processRequest('testData')
21+
service.anotherMethod()

jest.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
3+
module.exports = {
4+
collectCoverage: true,
5+
coverageDirectory: 'coverage',
6+
coverageThreshold: {
7+
global: {
8+
branches: 60,
9+
functions: 60,
10+
lines: 60,
11+
statements: 60,
12+
},
13+
},
14+
preset: 'ts-jest',
15+
testEnvironment: 'node',
16+
testMatch: ['**/test/**/*.test.{ts,tsx}'],
17+
transform: {
18+
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.jest.json' }],
19+
},
20+
}

0 commit comments

Comments
 (0)