Skip to content

Commit ee88181

Browse files
committed
feat: distribution plot logger
0 parents  commit ee88181

13 files changed

Lines changed: 6296 additions & 0 deletions

File tree

.github/workflows/cd.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: CI
5+
6+
on:
7+
push:
8+
branches:
9+
- "*"
10+
pull_request:
11+
branches:
12+
- "*"
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
CI:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Setup NodeJS 22
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: 22.x
28+
29+
- name: Show NodeJS version
30+
run: npm --version
31+
32+
- name: Get yarn cache directory path
33+
id: yarn-cache-dir-path
34+
run: echo "::set-output name=dir::$(yarn cache dir)"
35+
36+
- uses: actions/cache@v3
37+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
38+
with:
39+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
40+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-yarn-
43+
- name: Install dependencies
44+
run: yarn install --frozen-lockfile --prefer-offline
45+
46+
- name: Run tests
47+
run: yarn test
48+
49+
- name: Test Build
50+
run: yarn build
51+
52+
- name: Release
53+
env:
54+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
56+
run: npx semantic-release

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
coverage

.npmignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignore source files (the compiled output in the 'dist' folder is published)
2+
src/
3+
4+
# Ignore test files and directories
5+
__tests__/
6+
7+
# Ignore git and GitHub configuration directories
8+
.git/
9+
.github/
10+
11+
# Ignore local configuration and log files
12+
*.log
13+
tsconfig.json
14+
jest.config.js

CONTRIBUTING.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Contributing to Distribution Plot Logger
2+
3+
Thank you for your interest in contributing to **Distribution Plot Logger**! Your contributions help improve this project and benefit the community. Below are guidelines to help you contribute effectively.
4+
5+
## Table of Contents
6+
7+
- [How to Contribute](#how-to-contribute)
8+
- [Bug Reports](#bug-reports)
9+
- [Feature Requests](#feature-requests)
10+
- [Pull Requests](#pull-requests)
11+
- [Coding Guidelines](#coding-guidelines)
12+
- [Commit Messages](#commit-messages)
13+
- [Testing](#testing)
14+
- [Documentation](#documentation)
15+
- [License](#license)
16+
17+
## How to Contribute
18+
19+
1. **Fork the Repository:**
20+
Fork the project on GitHub.
21+
22+
2. **Clone Your Fork:**
23+
24+
```bash
25+
git clone https://github.com/Afitzy98/dist-plot-log.git
26+
cd distribution-plot-logger
27+
```
28+
29+
3. **Create a Branch for Your Feature or Bugfix:**
30+
Use a descriptive branch name, for example:
31+
32+
```bash
33+
git checkout -b feature/new-awesome-feature
34+
```
35+
36+
or
37+
38+
```bash
39+
git checkout -b bugfix/fix-plot-issue
40+
```
41+
42+
4. **Install Dependencies:**
43+
Run the following command to install all required packages:
44+
45+
```bash
46+
yarn
47+
```
48+
49+
5. **Implement Your Changes:**
50+
Make your changes or add new features. Please ensure you follow the coding guidelines listed below and write tests for new functionality.
51+
52+
6. **Run Tests and Linting:**
53+
Run the test suite to ensure everything is working:
54+
55+
```bash
56+
yarn test
57+
```
58+
59+
Also, check the code style and linting (if applicable).
60+
61+
7. **Commit Your Changes:**
62+
We use [Commitizen](https://github.com/commitizen/cz-conventional-changelog) to ensure our commit messages follow the Conventional Commits standard. Instead of using `git commit`, run:
63+
64+
```bash
65+
yarn commit
66+
```
67+
68+
This will prompt you to create a well-structured commit message.
69+
70+
8. **Push Your Branch and Create a Pull Request:**
71+
Push your branch:
72+
```bash
73+
git push origin feature/new-awesome-feature
74+
```
75+
Then, go to GitHub and create a Pull Request (PR) from your branch. Please include a detailed description of your changes and reference any related issues.
76+
77+
## Bug Reports
78+
79+
If you encounter a bug, please:
80+
81+
- Search existing issues to see if it has already been reported.
82+
- Open a new issue with a clear and descriptive title.
83+
- Provide detailed steps to reproduce the bug, expected behavior, and any relevant logs or screenshots.
84+
85+
## Feature Requests
86+
87+
For new features or improvements:
88+
89+
- Please open an issue to discuss your suggestion before starting work.
90+
- Once discussed, you are welcome to implement the feature and submit a pull request.
91+
92+
## Pull Requests
93+
94+
When submitting a Pull Request:
95+
96+
- Ensure your branch is up to date with the latest `main` branch changes.
97+
- Confirm that all tests pass by running `yarn test`.
98+
- Update documentation as needed.
99+
- Make sure your commit messages follow the Conventional Commits standard (see the [Commit Messages](#commit-messages) section below).
100+
101+
## Coding Guidelines
102+
103+
- **Language:** Please use TypeScript for all code.
104+
- **Code Style:** Follow the existing code style. Consistency is key.
105+
- **Testing:** Write tests for new features and bug fixes using Jest.
106+
- **Documentation:** Update the README and add comments where necessary to help explain your changes.
107+
108+
## Commit Messages
109+
110+
We follow the [Conventional Commits](https://www.conventionalcommits.org/) standard. A commit message should have the following format:
111+
112+
```
113+
<type>(<scope>): <subject>
114+
115+
<body>
116+
```
117+
118+
**Examples:**
119+
120+
- `fix(parser): correct parsing of numbers`
121+
- `feat(ui): add new chart color option`
122+
- `docs(readme): update installation instructions`
123+
124+
## Testing
125+
126+
Our test suite is built using Jest. To run tests, execute:
127+
128+
```bash
129+
yarn test
130+
```
131+
132+
Please add tests for any new functionality or bug fixes you introduce.
133+
134+
## Documentation
135+
136+
Keep documentation up to date. If you modify code functionality or introduce new features, update the README and inline comments accordingly.
137+
138+
## License
139+
140+
By contributing, you agree that your contributions will be licensed under the project's [MIT License](LICENSE).
141+
142+
---
143+
144+
Thank you for contributing to **Distribution Plot Logger**!

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Distribution Plot Logger
2+
3+
[![npm version](https://img.shields.io/npm/v/dist-plot-log.svg)](https://www.npmjs.com/package/dist-plot-log)
4+
5+
A simple TypeScript library that estimates and logs a text-based probability density function (PDF) plot of your data to the console using [asciichart](https://www.npmjs.com/package/asciichart).
6+
7+
## Installation
8+
9+
Install the package via npm:
10+
11+
```bash
12+
npm install dist-plot-log
13+
```
14+
15+
## Usage
16+
17+
You can use the package in both JavaScript and TypeScript projects.
18+
19+
### TypeScript
20+
21+
```typescript
22+
import { logDistributionPlot } from "dist-plot-log";
23+
24+
const data = [1, 2, 3, 4, 5, 3, 2, 1];
25+
const optionalWidenFactor = 4;
26+
logDistributionPlot(data, "My Data Plot", optionalWidenFactor);
27+
```
28+
29+
### JavaScript
30+
31+
```javascript
32+
const { logDistributionPlot } = require("dist-plot-log");
33+
34+
const data = [1, 2, 3, 4, 5, 3, 2, 1];
35+
const optionalWidenFactor = 4;
36+
logDistributionPlot(data, "My Data Plot", optionalWidenFactor);
37+
```
38+
39+
In the above examples:
40+
41+
- The first argument is an array of numerical data.
42+
- The second argument is an optional title for the plot.
43+
- The third argument is an optional widen factor to control the chart's width.
44+
45+
## Development
46+
47+
### Installing packages
48+
49+
```bash
50+
yarn
51+
```
52+
53+
### Building
54+
55+
Before publishing or testing changes, compile the TypeScript source:
56+
57+
```bash
58+
yarn build
59+
```
60+
61+
### Running Tests
62+
63+
We use Jest for testing. To run the test suite:
64+
65+
```bash
66+
yarn test
67+
```
68+
69+
### Committing Changes
70+
71+
We use [Commitizen](https://github.com/commitizen/cz-conventional-changelog) for standardized commit messages. Instead of `git commit`, run:
72+
73+
```bash
74+
yarn commit
75+
```
76+
77+
### Automated Releases
78+
79+
We use [Semantic Release](https://semantic-release.gitbook.io/semantic-release/) for automated versioning and release management. Make sure your commits follow Conventional Commits standards so that new versions are released automatically.
80+
81+
## Contributing
82+
83+
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines.
84+
85+
## License
86+
87+
This project is licensed under the MIT License.

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2+
module.exports = {
3+
testEnvironment: "node",
4+
transform: {
5+
"^.+.tsx?$": ["ts-jest",{}],
6+
},
7+
};

package.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "dist-plot-log",
3+
"version": "1.0.0",
4+
"description": "simple tool for plotting a distribution of data to the CLI",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"repository": "https://github.com/Afitzy98/dist-plot-log",
8+
"author": "A.fitzy98 <a.fitzy98@gmail.com>",
9+
"license": "MIT",
10+
"keywords": [
11+
"distribution",
12+
"plot",
13+
"logger",
14+
"console"
15+
],
16+
"scripts": {
17+
"build": "tsc",
18+
"commit": "cz",
19+
"prepublishOnly": "npm run build",
20+
"release": "semantic-release",
21+
"test": "jest"
22+
},
23+
"devDependencies": {
24+
"@semantic-release/changelog": "^6.0.3",
25+
"@semantic-release/commit-analyzer": "^13.0.1",
26+
"@semantic-release/git": "^10.0.1",
27+
"@types/asciichart": "^1.5.8",
28+
"@types/jest": "^29.5.14",
29+
"commitizen": "^4.3.1",
30+
"cz-conventional-changelog": "^3.3.0",
31+
"jest": "^29.7.0",
32+
"semantic-release": "^24.2.1",
33+
"ts-jest": "^29.2.5",
34+
"typescript": "^5.7.3"
35+
},
36+
"dependencies": {
37+
"asciichart": "^1.5.25"
38+
},
39+
"config": {
40+
"commitizen": {
41+
"path": "./node_modules/cz-conventional-changelog"
42+
}
43+
},
44+
"release": {
45+
"branches": [
46+
"+([0-9])?(.{+([0-9]),x}).x",
47+
"main",
48+
"next",
49+
"next-major",
50+
{
51+
"name": "beta",
52+
"prerelease": "true"
53+
},
54+
{
55+
"name": "alpha",
56+
"prerelease": "true"
57+
}
58+
],
59+
"plugins": [
60+
"@semantic-release/npm",
61+
"@semantic-release/github",
62+
"@semantic-release/commit-analyzer",
63+
"@semantic-release/release-notes-generator",
64+
[
65+
"@semantic-release/git",
66+
{
67+
"assets": "package.json",
68+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
69+
}
70+
]
71+
],
72+
"repositoryUrl": "https://github.com/Afitzy98/dist-plot-log.git"
73+
}
74+
}

0 commit comments

Comments
 (0)