Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ on:
pull_request_target:
branches:
- develop
permissions:
contents: read
pull-requests: write
checks: write
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
with:
allow-unsafe-pr-checkout: true
- uses: ArtiomTr/jest-coverage-report-action@v2
15 changes: 9 additions & 6 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ jobs:
runs-on: 'ubuntu-latest'
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Setup Node.js environment
uses: actions/setup-node@v2.5.0
with:
node-version: '16'

- name: 'Checkout Project'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v7'
with:
fetch-depth: 1

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '24.x'

- name: Enable Corepack (install yarn)
run: corepack enable

- name: Install dependencies
run: yarn install --no-progress

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.event.pull_request.merged == true
steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v4'
uses: 'actions/checkout@v7'
with:
token: ${{ secrets.BOT_USER_TOKEN }}
ref: 'develop'
Expand All @@ -37,7 +37,7 @@ jobs:
contents: read
steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v4'
uses: 'actions/checkout@v7'
with:
ref: develop

Expand All @@ -47,13 +47,16 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '24.x'
always-auth: true
scope: '@openbeta'
registry-url: 'https://registry.npmjs.org'

- name: Update npm
run: npm install -g npm@11

- name: Enable Corepack (install yarn)
run: corepack enable

- name: NPM publish
run: yarn install --no-progress && yarn lint && yarn test && yarn build && npm publish --provenance --access public
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint
yarn test --coverage
yarn build
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.x
9 changes: 8 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
src
tsconfig.*
jest.config.cjs
.github
.github
coverage
.all-contributorsrc
.node-version
eslint.config.mjs
flake.nix
flake.lock
tsup.config.ts
6 changes: 6 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import neostandard from 'neostandard'

export default neostandard({
ts: true,
ignores: ['dist'],
})
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
system:
let
pkgs = import nixpkgs { inherit system; };
nodejs = pkgs.nodejs_22;
nodejs = pkgs.nodejs_24;
yarn = pkgs.yarn.override { inherit nodejs; };
in
{
Expand Down
43 changes: 22 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@
"type": "git",
"url": "git+https://github.com/OpenBeta/sandbag.git"
},
"module": "./dist/sandbag.esm.js",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/index.cjs",
"exports": {
".": {
"import": "./dist/sandbag.esm.js",
"require": "./dist/index.js"
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"types": "dist/index.d.ts",
"types": "./dist/index.d.ts",
"scripts": {
"prepare": "husky install",
"lint": "ts-standard",
"fix": "yarn ts-standard --fix",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
"clean": "rm -rf build/*",
"build": "tsdx build --tsconfig tsconfig.build.json"
"prepare": "husky",
"lint": "eslint .",
"fix": "eslint . --fix",
"test": "jest",
"clean": "rm -rf dist",
"build": "tsup"
},
"author": "Kevin Nadro",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.0",
"@types/jest": "^29.5.14",
"cross-env": "^7.0.3",
"csv-parser": "^3.0.0",
"husky": "^7.0.4",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.6.0",
"ts-standard": "^12.0.0",
"tsdx": "^0.14.1",
"typescript": "^4.9.5"
"eslint": "^9.0.0",
"husky": "^9.0.0",
"jest": "^29.7.0",
"neostandard": "^0.13.0",
"ts-jest": "^29.4.12",
"ts-node": "^10.9.2",
"tsup": "^8.5.1",
"typescript": "^5.9.0"
},
"engines": {
"node": ">=14"
"node": ">=22"
},
"dependencies": {},
"keywords": [
Expand All @@ -49,4 +50,4 @@
"@openbeta:registry": "https://registry.npmjs.org"
},
"type": "module"
}
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrazilianCrux } from './scales';
import { BrazilianCrux } from './scales'

export { GradeScales, GradeScalesTypes, ConversionGroups, ConversionGroupsTypes, getAvgScore } from './GradeScale'
export {
Expand Down
14 changes: 7 additions & 7 deletions src/scales/ai.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple } from '../GradeScale'
import ice_table from '../data/ice.json'
import iceTable from '../data/ice.json'
import { IceGrade } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'

const AI_ARRAY = Array.from(new Set(ice_table.map((r) => r.ai)))
const AI_ARRAY = Array.from(new Set(iceTable.map((r) => r.ai)))

// Supports AI1 -> AI13, aith + grades on AI3 -> AI13 and no slash grades
// https://en.aikipedia.org/aiki/Grade_(climbing)#Ice_and_mixed_climbing
Expand All @@ -29,15 +29,15 @@ const AIScale: GradeScale = {
getGrade: (score: number | Tuple): string => {
const validateScore = (score: number): number => {
const validScore = Number.isInteger(score) ? score : Math.ceil(score)
return Math.min(Math.max(0, validScore), ice_table.length - 1)
return Math.min(Math.max(0, validScore), iceTable.length - 1)
}

if (typeof score === 'number') {
return ice_table[validateScore(score)].ai
return iceTable[validateScore(score)].ai
}

const low: string = ice_table[validateScore(score[0])].ai
const high: string = ice_table[validateScore(score[1])].ai
const low: string = iceTable[validateScore(score[0])].ai
const high: string = iceTable[validateScore(score[1])].ai
if (low === high) return low
return `${low}/${high}`
},
Expand All @@ -57,7 +57,7 @@ const getScore = (grade: string): number | Tuple => {

const score = findScoreRange((r: IceGrade) => {
return r.ai === (wholeMatch)
}, ice_table)
}, iceTable)

return score
}
Expand Down
14 changes: 7 additions & 7 deletions src/scales/aid.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple } from '../GradeScale'
import aid_table from '../data/aid.json'
import aidTable from '../data/aid.json'
import { AidGrade } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'

const AID_ARRAY = Array.from(new Set(aid_table.map((r) => r.aid)))
const AID_ARRAY = Array.from(new Set(aidTable.map((r) => r.aid)))

// Supports [AC]0 -> [AC]5, with + grades on [AC]2 -> [AC]4 and no slash grades
// https://en.wikipedia.org/wiki/Grade_(climbing)#Clean_scale
Expand All @@ -28,15 +28,15 @@
getGrade: (score: number | Tuple): string => {
const validateScore = (score: number): number => {
const validScore = Number.isInteger(score) ? score : Math.ceil(score)
return Math.min(Math.max(0, validScore), aid_table.length - 1)
return Math.min(Math.max(0, validScore), aidTable.length - 1)
}

if (typeof score === 'number') {
return aid_table[validateScore(score)].aid
return aidTable[validateScore(score)].aid
}

const low: string = aid_table[validateScore(score[0])].aid
const high: string = aid_table[validateScore(score[1])].aid
const low: string = aidTable[validateScore(score[0])].aid

Check warning on line 38 in src/scales/aid.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
const high: string = aidTable[validateScore(score[1])].aid

Check warning on line 39 in src/scales/aid.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
if (low === high) return low
return `${low}/${high}`
},
Expand All @@ -56,7 +56,7 @@

const score = findScoreRange((r: AidGrade) => {
return r.aid === ('A' + gradeNum)
}, aid_table)
}, aidTable)

return score
}
Expand Down
14 changes: 7 additions & 7 deletions src/scales/wi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple } from '../GradeScale'
import ice_table from '../data/ice.json'
import iceTable from '../data/ice.json'
import { IceGrade } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'

const WI_ARRAY = Array.from(new Set(ice_table.map((r) => r.wi)))
const WI_ARRAY = Array.from(new Set(iceTable.map((r) => r.wi)))

// Supports WI1 -> WI13, with + grades on WI3 -> WI13 and no slash grades
// https://en.wikipedia.org/wiki/Grade_(climbing)#Ice_and_mixed_climbing
Expand All @@ -29,15 +29,15 @@ const WIScale: GradeScale = {
getGrade: (score: number | Tuple): string => {
const validateScore = (score: number): number => {
const validScore = Number.isInteger(score) ? score : Math.ceil(score)
return Math.min(Math.max(0, validScore), ice_table.length - 1)
return Math.min(Math.max(0, validScore), iceTable.length - 1)
}

if (typeof score === 'number') {
return ice_table[validateScore(score)].wi
return iceTable[validateScore(score)].wi
}

const low: string = ice_table[validateScore(score[0])].wi
const high: string = ice_table[validateScore(score[1])].wi
const low: string = iceTable[validateScore(score[0])].wi
const high: string = iceTable[validateScore(score[1])].wi
if (low === high) return low
return `${low}/${high}`
},
Expand All @@ -57,7 +57,7 @@ const getScore = (grade: string): number | Tuple => {

const score = findScoreRange((r: IceGrade) => {
return r.wi === (wholeMatch)
}, ice_table)
}, iceTable)

return score
}
Expand Down
11 changes: 0 additions & 11 deletions tsconfig.build.json

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"esm": true,
"experimentalSpecifierResolution": "node"
},
"include": [".ts", "src/**/*.ts"]
"include": ["src/**/*.ts", "*.ts"]
}
13 changes: 13 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
outDir: 'dist',
target: 'es6',
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.mjs',
}),
})
Loading
Loading