Skip to content

Commit 0041c4c

Browse files
authored
Merge pull request #42 from qbunt/feature/refactor
Added a whole host of new tests, revamped the core algorithm with som…
2 parents 5e7ed36 + 5cf2722 commit 0041c4c

File tree

11 files changed

+561
-97
lines changed

11 files changed

+561
-97
lines changed

.github/workflows/coverage.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Code coverage
22
on: [push, pull_request]
33
jobs:
44
build:
5-
runs-on: ubuntu-latest
5+
runs-on: ubuntu-22.04
66
strategy:
77
matrix:
88
node-version: [18.x, 20.x, 22.x]
@@ -26,14 +26,14 @@ jobs:
2626
run_install: false
2727

2828
- name: Get pnpm store directory
29-
id: pnpm-cache
29+
shell: bash
3030
run: |
31-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
3232
3333
- uses: actions/cache@v4
3434
name: Setup pnpm cache
3535
with:
36-
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
36+
path: ${{ env.STORE_PATH }}
3737
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
3838
restore-keys: |
3939
${{ runner.os }}-pnpm-store-
@@ -44,5 +44,9 @@ jobs:
4444
- name: Run the tests
4545
run: pnpm test -- --coverage
4646

47+
- uses: ArtiomTr/jest-coverage-report-action@v2
48+
4749
- name: Upload coverage to Codecov
48-
uses: codecov/codecov-action@v3
50+
uses: codecov/codecov-action@v4
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/nodejs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches: [main]
77
jobs:
88
build:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-22.04
1010
strategy:
1111
matrix:
1212
node-version: [18.x, 20.x, 22.x]
@@ -25,14 +25,14 @@ jobs:
2525
run_install: false
2626

2727
- name: Get pnpm store directory
28-
id: pnpm-cache
28+
shell: bash
2929
run: |
30-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
30+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
3131
3232
- uses: actions/cache@v4
3333
name: Setup pnpm cache
3434
with:
35-
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
35+
path: ${{ env.STORE_PATH }}
3636
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
3737
restore-keys: |
3838
${{ runner.os }}-pnpm-store-

.github/workflows/release.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,39 @@ on:
44
types: [created]
55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
runs-on: ubuntu-22.04
8+
permissions:
9+
contents: read
10+
id-token: write
811
steps:
9-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1013
# Setup .npmrc file to publish to npm
11-
- uses: actions/setup-node@v2
14+
- uses: actions/setup-node@v4
1215
with:
13-
node-version: '18.17.1'
16+
node-version: '20.x'
1417
registry-url: 'https://registry.npmjs.org'
1518

1619
- uses: pnpm/action-setup@v4
1720
name: Install pnpm
1821
id: pnpm-install
1922
with:
20-
version: 7
23+
version: 8
2124
run_install: false
2225

2326
- name: Get pnpm store directory
24-
id: pnpm-cache
27+
shell: bash
2528
run: |
26-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
29+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
2730
2831
- uses: actions/cache@v4
2932
name: Setup pnpm cache
3033
with:
31-
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
34+
path: ${{ env.STORE_PATH }}
3235
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
3336
restore-keys: |
3437
${{ runner.os }}-pnpm-store-
3538
36-
3739
- run: pnpm install --no-frozen-lockfile
38-
- run: npm publish
40+
- run: npm publish --provenance
3941
env:
4042
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "romans",
3-
"version": "2.0.18",
3+
"version": "3.0.0",
44
"description": "A small, no-dependency lib for converting to and from roman numerals",
55
"main": "romans.js",
66
"types": "romans.d.ts",
@@ -26,8 +26,9 @@
2626
},
2727
"homepage": "https://github.com/qbunt/romanize#readme",
2828
"devDependencies": {
29-
"eslint": "^9.15.0",
29+
"eslint": "^9.17.0",
30+
"fast-check": "^3.23.2",
3031
"jest": "^29.7.0",
31-
"prettier": "^3.3.3"
32+
"prettier": "^3.4.2"
3233
}
3334
}

pnpm-lock.yaml

Lines changed: 28 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<h1><a href="https://github.com/qbunt/romans" target="_blank"><img width="150" src="logo.png"></a></h1>
22

3-
A no-dependency library for converting from decimal notation to roman 🏛 numerals and back again.
3+
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 ⚔️ 🏛️
44

55
[![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)
66
[![tests](https://github.com/qbunt/romans/actions/workflows/nodejs.yml/badge.svg)](https://github.com/qbunt/romans/actions/workflows/nodejs.yml)
7+
[![Socket Badge](https://socket.dev/api/badge/npm/package/romans/2.0.18)](https://socket.dev/npm/package/romans/overview/2.0.18)
78

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

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

1313
```shell
14-
$ yarn add romans
14+
$ npm install romans
1515
```
1616

17-
## Usage
17+
## Usage 🧮
1818

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

3535
```
36-
## Testing
36+
37+
## Testing 🧪
38+
3739
[![coverage](https://codecov.io/gh/qbunt/romans/branch/master/graph/badge.svg?token=kD6QSvKfTe)](https://codecov.io/gh/qbunt/romans)
3840
[![Wallaby.js](https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=flat&logo=github)](https://wallabyjs.com/oss/)
3941

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

46-
## License
47-
[![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)
48+
## License 📜
4849

4950
[MIT](./LICENSE)
5051

51-
## Contributions
52-
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.
52+
Open source license obligations are tracked via FOSSA scans.
53+
54+
[![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)
55+
56+
_Note: The license obligation check says there are dependencies, they are purely used for dev tests, the core library has no direct dependencies 💪_
57+
58+
## Security 🔒
59+
60+
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.
61+
62+
## FAQ 🤔
63+
64+
> What, why?
65+
66+
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.
67+
68+
> Why is there no `0`?
69+
70+
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.
71+
72+
> I don't get it, why is this not an ESM module?
73+
74+
On the fence here, but mainly to support in older codebases that are CommonJS based. I value not having a compile step.
75+
76+
> Why didn't you build this in Typescript?
77+
78+
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.
79+
80+
> What's new in v3?
81+
82+
Same great taste, API is 💯 identical, more tests, improved efficiency, improved types, **vastly** improved docs ⚔️
83+
84+
## Contributions 🤝
85+
86+
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.
87+
88+
If you'd like to show appreciation, I love ☕.
89+
90+
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D0BTCUA)

0 commit comments

Comments
 (0)