mljs / ml

Machine learning tools in JavaScript
MIT License
2.63k stars 210 forks source link

Cleanup and update repositories #174

Closed targos closed 1 year ago

targos commented 2 years ago

There have been a lot of changes in how we structure and test our projects since the creation of this org. Here are some things that need to be cleaned up or changed, and a list of repositories where to do it.

To do

1. Rename some config files

If they exist:

2. Move Prettier config from package.json to .prettierrc.json.

There are some projects where the Prettier config is not in a separate file (example). Copy the config to a file named .prettierrc.json and remove the field from the package.json.

3. Rename prepublishOnly script to prepack

If it exists in package.json.

4. Add prettier and prettier-write scripts

In package.json:

{
  "scripts": {
    "prettier": "prettier --check src",
    "prettier-write": "prettier --write src"
  }
}

The "test" script should be updated to call npm run prettier at the end.

Example

5. Update dependencies

ncu -u

Be careful if there are breaking changes in non-dev dependencies. Check the changelog of the dependency and adapt the project if necessary.

6. Remove eslint-plugin-* from dependencies

After updating dependencies, we can do this because the eslint-config-cheminfo packages have the plugins as peer dependencies. Make sure to use the latest version of Node.js, otherwise it won't work.

7. Refactor how tests are run

There are multiple things to do here. See floyd-warshall for an example of a correct setup.

8. Rename History.md to CHANGELOG.md

Example

9. Remove Travis config

10. Remove david config

Delete david-related lines from README.md

Example

11. Remove docs folder

If it exists.

12. Setup or update GitHub workflows

.github/workflows/nodejs.yml

name: Node.js CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  nodejs:
    # Documentation: https://github.com/zakodium/workflows#nodejs-ci
    uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1

.github/workflows/release.yml

name: Release

on:
  push:
    branches:
      - main

jobs:
  release:
    # Documentation: https://github.com/zakodium/workflows#release
    uses: zakodium/workflows/.github/workflows/release.yml@release-v1
    with:
      npm: true
    secrets:
      github-token: ${{ secrets.BOT_TOKEN }}
      npm-token: ${{ secrets.NPM_BOT_TOKEN }}

.github/workflows/documentationjs.yml

Only do this if there is no typedoc.yml workflow.

name: Deploy documentation.js on GitHub pages

on:
  workflow_dispatch:
  release:
    types: [published]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build documentation
        uses: zakodium/documentationjs-action@v1
      - 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
targos commented 2 years ago

Repositories to check

wadjih-bencheikh18 commented 2 years ago

@targos can i delete useless prettierignore file?

targos commented 2 years ago

You have an example of such file?

wadjih-bencheikh18 commented 2 years ago

yes https://github.com/mljs/libsvm/pull/20

targos commented 2 years ago

yeah, you can remove that one.

wadjih-bencheikh18 commented 2 years ago

also here https://github.com/mljs/hclust/pull/16 , https://github.com/mljs/decision-tree-cart/pull/22 we need prettier check/write in src and all prettierignore folders are not included

wadjih-bencheikh18 commented 2 years ago

@targos cleanup done