Skip to content

Commit

Permalink
Merge pull request #42 from qbunt/feature/refactor
Browse files Browse the repository at this point in the history
Added a whole host of new tests, revamped the core algorithm with som…
  • Loading branch information
qbunt authored Dec 19, 2024
2 parents 5e7ed36 + 5cf2722 commit 0041c4c
Show file tree
Hide file tree
Showing 11 changed files with 561 additions and 97 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code coverage
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
Expand All @@ -26,14 +26,14 @@ jobs:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
Expand All @@ -44,5 +44,9 @@ jobs:
- name: Run the tests
run: pnpm test -- --coverage

- uses: ArtiomTr/jest-coverage-report-action@v2

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
Expand All @@ -25,14 +25,14 @@ jobs:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
Expand Down
22 changes: 12 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,39 @@ on:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '18.17.1'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install --no-frozen-lockfile
- run: npm publish
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "romans",
"version": "2.0.18",
"version": "3.0.0",
"description": "A small, no-dependency lib for converting to and from roman numerals",
"main": "romans.js",
"types": "romans.d.ts",
Expand All @@ -26,8 +26,9 @@
},
"homepage": "https://github.com/qbunt/romanize#readme",
"devDependencies": {
"eslint": "^9.15.0",
"eslint": "^9.17.0",
"fast-check": "^3.23.2",
"jest": "^29.7.0",
"prettier": "^3.3.3"
"prettier": "^3.4.2"
}
}
45 changes: 28 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 48 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<h1><a href="https://github.com/qbunt/romans" target="_blank"><img width="150" src="logo.png"></a></h1>

A no-dependency library for converting from decimal notation to roman 🏛 numerals and back again.
Transform ⚡ numbers into Roman numerals (and back again) with no dependencies. Perfect for when X, V, and I are more your style than 1, 2, 3. As [battle-tested](https://app.codecov.io/gh/qbunt/romans) as a gladiator ⚔️ 🏛️

[![quality](https://api.codacy.com/project/badge/Grade/3642e8e1b1b940ce8faa04bb7083f0fb)](https://app.codacy.com/app/qbunt/romans?utm_source=github.com&utm_medium=referral&utm_content=qbunt/romans&utm_campaign=Badge_Grade_Dashboard)
[![tests](https://github.com/qbunt/romans/actions/workflows/nodejs.yml/badge.svg)](https://github.com/qbunt/romans/actions/workflows/nodejs.yml)
[![Socket Badge](https://socket.dev/api/badge/npm/package/romans/2.0.18)](https://socket.dev/npm/package/romans/overview/2.0.18)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D0BTCUA)
## Install 🔨

## Install
With [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), [pnpm](https://pnpm.io/), or [yarn](https://yarnpkg.com/) installed, run:

```shell
$ yarn add romans
$ npm install romans
```

## Usage
## Usage 🧮

```js
const romans = require('romans');
Expand All @@ -33,7 +33,9 @@ romans.allChars
// [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ]

```
## Testing

## Testing 🧪

[![coverage](https://codecov.io/gh/qbunt/romans/branch/master/graph/badge.svg?token=kD6QSvKfTe)](https://codecov.io/gh/qbunt/romans)
[![Wallaby.js](https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=flat&logo=github)](https://wallabyjs.com/oss/)

Expand All @@ -43,10 +45,46 @@ Test coverage is reported via [codecov](https://codecov.io/gh/qbunt/romans), and
$ yarn test
```

## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fqbunt%2Fromans.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fqbunt%2Fromans?ref=badge_large)
## License 📜

[MIT](./LICENSE)

## Contributions
If you'd like to contribute to this library, please [send a PR](https://github.com/qbunt/romans/pulls) or [file a new issue](https://github.com/qbunt/romans/issues). I aim to get PRs accepted in short order *should they align with the goals*. Also, be nice.
Open source license obligations are tracked via FOSSA scans.

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fqbunt%2Fromans.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fqbunt%2Fromans?ref=badge_large)

_Note: The license obligation check says there are dependencies, they are purely used for dev tests, the core library has no direct dependencies 💪_

## Security 🔒

I take supply chain security **seriously** and run [socket.dev scans](https://socket.dev/npm/package/romans/overview/) on all PRs and releases. Although there are no dependencies on the library, I value your trust. If you see something, say something.

## FAQ 🤔

> What, why?
It started as a joke and became an interesting diversion, there are now more tests than library and it has a mind of it's own. Doing this was an interesting coding challenge problem that isn't the easiest to solve, and really, the Superbowl will have to use it eventually 🙃. Also, love a silly thing.

> Why is there no `0`?
Roman numerals [didn't include 0](https://en.wikipedia.org/wiki/Roman_numerals#Zero), so it's not included here. Yes, it's pedantry. No, I'm not adding it.

> I don't get it, why is this not an ESM module?
On the fence here, but mainly to support in older codebases that are CommonJS based. I value not having a compile step.

> Why didn't you build this in Typescript?
I value not having to set up typescript, and really, I do enjoy the simplicity of having a single library file. There are types and extensive JSDoc comments. Eventually, I'll cave and do multiple builds, but for now, this is fine. If you feel strongly about this decision, pull requests are open.

> What's new in v3?
Same great taste, API is 💯 identical, more tests, improved efficiency, improved types, **vastly** improved docs ⚔️

## Contributions 🤝

If you'd like to contribute to this library, please [send a PR](https://github.com/qbunt/romans/pulls) or [file a new issue](https://github.com/qbunt/romans/issues). I aim to get PRs accepted in short order *should they align with the goals*. Also, be kind, again, this started as a joke.

If you'd like to show appreciation, I love ☕.

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D0BTCUA)
Loading

6 comments on commit 0041c4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 100% 36/36
🟢 Branches 100% 19/19
🟢 Functions 100% 2/2
🟢 Lines 100% 33/33

Test suite run success

37 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 0041c4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 100% 36/36
🟢 Branches 100% 19/19
🟢 Functions 100% 2/2
🟢 Lines 100% 33/33

Test suite run success

37 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 0041c4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 100% 36/36
🟢 Branches 100% 19/19
🟢 Functions 100% 2/2
🟢 Lines 100% 33/33

Test suite run success

37 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 0041c4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 100% 36/36
🟢 Branches 100% 19/19
🟢 Functions 100% 2/2
🟢 Lines 100% 33/33

Test suite run success

37 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 0041c4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 100% 36/36
🟢 Branches 100% 19/19
🟢 Functions 100% 2/2
🟢 Lines 100% 33/33

Test suite run success

37 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 0041c4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 100% 36/36
🟢 Branches 100% 19/19
🟢 Functions 100% 2/2
🟢 Lines 100% 33/33

Test suite run success

37 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 0041c4c

Please sign in to comment.