From f3cc3f2ceae45c44e109f8c2918c7479c721e2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 21 Oct 2025 11:39:55 +0200 Subject: [PATCH] fix: update dependencies and fix build --- .../workflows/{nodejs-ts.yml => nodejs.yml} | 0 .github/workflows/release.yml | 2 +- .github/workflows/typedoc.yml | 33 ++------ .prettierignore | 1 + .prettierrc.json | 7 ++ package.json | 78 ++++++++----------- src/__tests__/index.test.ts | 6 +- src/getShortestPath.ts | 4 +- src/index.ts | 8 +- tsconfig.build.json | 5 ++ tsconfig.cjs.json | 9 --- tsconfig.esm.json | 8 -- tsconfig.json | 11 ++- vitest.config.ts | 10 +++ vitest.setup.ts | 4 + 15 files changed, 82 insertions(+), 104 deletions(-) rename .github/workflows/{nodejs-ts.yml => nodejs.yml} (100%) create mode 100644 .prettierignore create mode 100644 .prettierrc.json create mode 100644 tsconfig.build.json delete mode 100644 tsconfig.cjs.json delete mode 100644 tsconfig.esm.json create mode 100644 vitest.config.ts create mode 100644 vitest.setup.ts diff --git a/.github/workflows/nodejs-ts.yml b/.github/workflows/nodejs.yml similarity index 100% rename from .github/workflows/nodejs-ts.yml rename to .github/workflows/nodejs.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 178f409..7f5db58 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,4 +13,4 @@ jobs: npm: true secrets: github-token: ${{ secrets.BOT_TOKEN }} - npm-token: ${{ secrets.NPM_BOT_TOKEN }} \ No newline at end of file + npm-token: ${{ secrets.NPM_BOT_TOKEN }} diff --git a/.github/workflows/typedoc.yml b/.github/workflows/typedoc.yml index 540b6a6..81c1ff6 100644 --- a/.github/workflows/typedoc.yml +++ b/.github/workflows/typedoc.yml @@ -1,32 +1,15 @@ -name: Deploy TypeDoc on GitHub pages +name: TypeDoc on: workflow_dispatch: release: types: [published] -env: - NODE_VERSION: 20.x - ENTRY_FILE: 'src/index.ts' - jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - - name: Install dependencies - run: npm install - - name: Build documentation - uses: zakodium/typedoc-action@v2 - with: - entry: ${{ env.ENTRY_FILE }} - - name: Deploy to GitHub pages - uses: JamesIves/github-pages-deploy-action@releases/v4 - with: - token: ${{ secrets.BOT_TOKEN }} - branch: gh-pages - folder: docs - clean: true + typedoc: + # Documentation: https://github.com/zakodium/workflows#typedoc + uses: zakodium/workflows/.github/workflows/typedoc.yml@typedoc-v1 + with: + entry: 'src/index.ts' + secrets: + github-token: ${{ secrets.BOT_TOKEN }} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1b763b1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +CHANGELOG.md diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..a23e760 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "arrowParens": "always", + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all" +} diff --git a/package.json b/package.json index 8c14308..94faf15 100644 --- a/package.json +++ b/package.json @@ -1,32 +1,47 @@ { "name": "linear-sum-assignment", "version": "1.0.8", + "license": "MIT", "description": "it performs a linear sum assignment even if the cost matrix is rectangular.", - "main": "./lib/index.js", - "module": "./lib-esm/index.js", - "types": "./lib/index.d.ts", "keywords": [], "author": "J Alejandro Bolanos A ", - "license": "MIT", + "type": "module", + "exports": { + ".": "./lib/index.js" + }, "files": [ - "src", "lib", - "lib-esm" + "src" ], "scripts": { - "clean": "rimraf lib lib-esm", "check-types": "tsc --noEmit", - "eslint": "eslint src --ext ts --cache", - "eslint-fix": "npm run eslint -- --fix", + "clean": "rimraf coverage dist lib", + "eslint": "eslint . --cache", + "eslint-fix": "eslint . --cache --fix", "prepack": "npm run tsc", - "prettier": "prettier --check src", - "prettier-write": "prettier --write src", - "test": "npm run test-coverage && npm run eslint", - "test-coverage": "npm run test-only -- --coverage", - "test-only": "jest", - "tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm", - "tsc-cjs": "tsc --project tsconfig.cjs.json", - "tsc-esm": "tsc --project tsconfig.esm.json" + "prettier": "prettier --check .", + "prettier-write": "prettier --write .", + "test": "npm run test-only && npm run check-types && npm run eslint && npm run prettier", + "test-only": "vitest run --coverage", + "tsc": "npm run clean && npm run tsc-build", + "tsc-build": "tsc --project tsconfig.build.json" + }, + "dependencies": { + "cheminfo-types": "^1.8.1", + "ml-matrix": "^6.12.1", + "ml-spectra-processing": "^14.18.0" + }, + "devDependencies": { + "@types/node": "^24.9.1", + "@vitest/coverage-v8": "^3.2.4", + "@zakodium/tsconfig": "^1.0.2", + "eslint": "^8.57.0", + "eslint-config-cheminfo-typescript": "^12.2.0", + "jest-matcher-deep-close-to": "^3.0.2", + "prettier": "^3.6.2", + "rimraf": "^6.0.1", + "typescript": "^5.9.3", + "vitest": "^3.2.4" }, "repository": { "type": "git", @@ -35,32 +50,5 @@ "bugs": { "url": "https://github.com/mljs/linear-sum-assignment/issues" }, - "homepage": "https://github.com/mljs/linear-sum-assignment#readme", - "jest": { - "preset": "ts-jest", - "testEnvironment": "node" - }, - "prettier": { - "arrowParens": "always", - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "all" - }, - "dependencies": { - "cheminfo-types": "^1.7.3", - "ml-matrix": "^6.11.0", - "ml-spectra-processing": "^14.2.2" - }, - "devDependencies": { - "@types/jest": "^29.5.12", - "eslint": "^8.57.0", - "eslint-config-cheminfo-typescript": "^12.2.0", - "jest": "^29.7.0", - "jest-matcher-deep-close-to": "^3.0.2", - "prettier": "^3.2.5", - "rimraf": "^5.0.5", - "ts-jest": "^29.1.2", - "typescript": "^5.4.2" - } + "homepage": "https://github.com/mljs/linear-sum-assignment#readme" } diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 6904151..b09a4e8 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -1,8 +1,6 @@ -import { toMatchCloseTo } from 'jest-matcher-deep-close-to'; +import { describe, expect, it } from 'vitest'; -import { linearSumAssignment } from '..'; - -expect.extend({ toMatchCloseTo }); +import { linearSumAssignment } from '../index.ts'; describe('linear sum problem', () => { it('same number of rows and columns', () => { diff --git a/src/getShortestPath.ts b/src/getShortestPath.ts index 0e90972..3a3d34b 100644 --- a/src/getShortestPath.ts +++ b/src/getShortestPath.ts @@ -1,8 +1,8 @@ -import { DoubleArray } from 'cheminfo-types'; +import type { DoubleArray } from 'cheminfo-types'; import type { Matrix } from 'ml-matrix'; import { xSequentialFillFromTo } from 'ml-spectra-processing'; -interface GetShortestPathOptions { +export interface GetShortestPathOptions { currUnAssCol: number; dualVariableForColumns: DoubleArray; dualVariableForRows: DoubleArray; diff --git a/src/index.ts b/src/index.ts index e613bc1..cec8288 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -import { DoubleArray } from 'cheminfo-types'; +import type { DoubleArray } from 'cheminfo-types'; import { Matrix } from 'ml-matrix'; -import { getShortestPath } from './getShortestPath'; +import { getShortestPath } from './getShortestPath.ts'; -interface Options { +export interface LinearSumAssignmentOptions { /** * if true it will generate the assignment by the maximization of the cost. * @default true @@ -21,7 +21,7 @@ export function linearSumAssignment( * Cost matrix */ input: DoubleArray[] | Matrix, - options: Options = {}, + options: LinearSumAssignmentOptions = {}, ) { const { maximaze = true } = options; diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..4297508 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": ["src"], + "exclude": ["**/__tests__", "**/*.test.*"] +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index 637fbe5..0000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "lib", - "declaration": true - }, - "exclude": ["./src/**/__tests__"] -} diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index 857feb2..0000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.cjs.json", - "compilerOptions": { - "module": "es2015", - "outDir": "lib-esm", - "declaration": false - } -} diff --git a/tsconfig.json b/tsconfig.json index 98e7462..a68fc7e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,9 @@ { + "extends": "@zakodium/tsconfig", "compilerOptions": { - "esModuleInterop": true, - "moduleResolution": "node", - "inlineSourceMap": true, - "strict": true, - "target": "es2019" + "noUncheckedIndexedAccess": false, + "outDir": "lib", + "types": ["node"] }, - "include": ["./src/**/*"] + "include": ["src", "vite*.ts"] } diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..63fe258 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + coverage: { + include: ['src/**'], + }, + setupFiles: ['vitest.setup.ts'], + }, +}); diff --git a/vitest.setup.ts b/vitest.setup.ts new file mode 100644 index 0000000..def3386 --- /dev/null +++ b/vitest.setup.ts @@ -0,0 +1,4 @@ +import { toBeDeepCloseTo, toMatchCloseTo } from 'jest-matcher-deep-close-to'; +import { expect } from 'vitest'; + +expect.extend({ toMatchCloseTo, toBeDeepCloseTo });