Skip to content

Commit

Permalink
Merge pull request #27 from EricRovell/refactoring
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
EricRovell authored Mar 22, 2024
2 parents f96eb22 + 54933e8 commit a0ac92b
Show file tree
Hide file tree
Showing 37 changed files with 1,694 additions and 1,851 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[*]

charset = utf-8
indent_style = tab
indent_size = 2
insert_final_newline = true
trim_trailing_whitespce = true

[*.yaml]

indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"@typescript-eslint"
],
"rules": {
"no-console": "error",
"curly": "error",
"indent": [ "error", "tab", { "SwitchCase": 1 } ],
"linebreak-style": 0,
"quotes": [ "error","double" ],
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: build

on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
workflow_dispatch:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: install pnpm
run: npm i pnpm -g

- name: install dependencies
run: pnpm i

- name: linting
run: |
pnpm lint
pnpm lint:types
- name: unit tests
run: pnpm test:ci

- name: test coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage
path: ./coverage
if-no-files-found: error

- name: Code Coverage Report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: build
run: pnpm build

- name: build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: ./dist
if-no-files-found: error
30 changes: 0 additions & 30 deletions .github/workflows/node.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: npm-release
on:
release:
types: [ published ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: latest
registry-url: https://registry.npmjs.org/

- name: install pnpm
run: npm i pnpm -g

- name: install dependencies
run: pnpm i

- name: linting
run: |
pnpm lint
pnpm lint:types
- name: unit tests
run: pnpm test:ci

- name: test coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage
path: ./coverage
if-no-files-found: error

- name: build
run: pnpm build

- name: build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: ./dist
if-no-files-found: error

- name: publish
run: pnpm run publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/release.yml

This file was deleted.

8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Rational

## 1.0.1 (2024-03-22)

- [chore]: update dependencies and building processes;
- [chore]: bundle type definitions into one file;

## 1.0.0 (2022-10-11)

- [breaking]: `.toDecimalString()` and `.toFractionString()` is removed in favor for improved `.toString()` method to not dublicate the functionality;
- [breaking]: `.toDecimalString()` and `.toFractionString()` is removed in favor for improved `.toString()` method to not duplicate the functionality;
- [feat]: expose input types for a user;
- [feat]: improve `.valueOf(places?)` method with optional argument to round the decimal approximation;
- [feat]: implement `.continued` for continued fraction representation;
Expand Down Expand Up @@ -56,4 +61,3 @@
## 0.1.0 (2021-07-29)

- Basic API;
-
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<img alt="downloads count" src="https://badgen.net/npm/dt/@ericrovell/rational/" />
</a>
<a href="https://www.npmjs.com/package/@ericrovell/rational">
<img alt="licence" src="https://badgen.net/npm/license/@ericrovell/rational/" />
<img alt="license" src="https://badgen.net/npm/license/@ericrovell/rational/" />
</a>
</div>

Expand Down Expand Up @@ -343,7 +343,7 @@ rational({ n: 2, d: 3 }).toString(); // -> "2/3"
<code>.div(Rational | Input)</code>
</summary>

Performs the division and returns the quotien as new `Rational` instance.
Performs the division and returns the quotient as new `Rational` instance.

```js
rational(1, 2)
Expand Down
11 changes: 11 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { build } from "esbuild";

await build({
entryPoints: [
"./src/index.ts"
],
format: "esm",
bundle: true,
minify: true,
outdir: "./dist"
});
51 changes: 22 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
"description": "Rational is rational numbers library written in JavaScript",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"module": "./dist/index.js",
"scripts": {
"build": "rm -rf ./dist/* && rollup --config",
"lint": "eslint src/**/*.ts tests/**/*.ts",
"publish:npm": "pnpm publish --access public",
"typecheck": "tsc --noEmit true",
"test": "vitest run --coverage",
"build": "pnpm run clean:build && node esbuild && pnpm build:types && pnpm bundle:dts",
"build:types": "tsc --p ./tsconfig.dts.json",
"bundle:dts": "node ./scripts/bundle-dts.js",
"clean": "rm -rf ./node_modules",
"clean:build": "rm -rf ./dist/*",
"coverage": "pnpm type-coverage",
"lint": "eslint src/**/*.ts test/**/*.ts",
"lint:types": "tsc --noEmit",
"publish": "pnpm publish --access public",
"test": "vitest run",
"test:ci": "vitest run --coverage",
"test:watch": "vitest"
},
"repository": "github:EricRovell/rational",
Expand All @@ -30,42 +36,29 @@
"types": "./dist/index.d.ts",
"license": "MIT",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"@vitest/coverage-c8": "^0.25.2",
"eslint": "^8.28.0",
"lint-staged": "^13.0.3",
"rollup": "^3.3.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.34.1",
"simple-git-hooks": "^2.8.1",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"vite": "^3.2.4",
"vitest": "^0.25.2"
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitest/coverage-v8": "^1.4.0",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"tslib": "^2.6.2",
"typescript": "^5.4.2",
"vite": "^5.2.0",
"vitest": "^1.4.0"
},
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"homepage": "https://github.com/ericrovell/rational#readme",
"directories": {
"test": "tests"
},
"lint-staged": {
"*.{ts,js}": "eslint"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged",
"pre-push": "npm run lint && npm run typecheck"
"test": "test"
},
"files": [
"CHANGELOG.md",
"dist"
]
}
Loading

0 comments on commit a0ac92b

Please sign in to comment.