ml icon indicating copy to clipboard operation
ml copied to clipboard

Cleanup and update repositories

Open targos opened this issue 2 years ago • 7 comments

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:

  • .babelrc -> .babelrc.json
  • .prettierrc -> .prettierrc.json

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 16 or 17, 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.

  • If there is a test-coverage npm script, remove it.
  • If there is a testonly npm script, rename it to test-only.
  • Add --coverage to the test-only npm script. For example: "test-only": "jest --coverage"
  • If there is a "jest" field with only "testEnvironment": "node" in it, remove the field. The latest version of Jest defaults to this environment.
  • Otherwise, if there are more things in the Jest config. Move it to a jest.config.js file.

8. Rename History.md to CHANGELOG.md

  • Rename the file
  • Add # Changelog + a new line at the beginning.

Example

9. Remove Travis config

  • Delete `.travis.yml
  • Delete Travis-related lines from README.md

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

  • If the workflow doesn't exist, create it.
  • If the workflow already exists, replace it with the new template. node-version-matrix should contain 12 if Node.js 12 was tested in the old workflow.

.github/workflows/nodejs.yml

Template
name: Node.js CI

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  nodejs:
    # Documentation: https://github.com/zakodium/workflows#nodejs-ci
    uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
    with:
      node-version-matrix: '[14, 16]'

.github/workflows/release.yml

Template
name: Release

on:
  push:
    branches:
      - master

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.

Template
name: Deploy documentation.js on GitHub pages

on:
  workflow_dispatch:
  release:
    types: [published]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - 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 avatar Feb 28 '22 14:02 targos

Repositories to check

  • [x] https://github.com/mljs/array-xy
  • [x] https://github.com/mljs/levenberg-marquardt
  • [x] https://github.com/mljs/matrix
  • [x] https://github.com/mljs/random-forest
  • [x] https://github.com/mljs/regression-base
  • [x] https://github.com/mljs/array
  • [x] https://github.com/mljs/decision-tree-cart
  • [x] https://github.com/mljs/pls
  • [ ] https://github.com/mljs/libsvm (blocked)
  • [x] https://github.com/mljs/hclust
  • [x] https://github.com/mljs/conrec
  • [x] https://github.com/mljs/direct-optimization
  • [x] https://github.com/mljs/performance
  • [x] https://github.com/mljs/logistic-regression
  • [x] https://github.com/mljs/regression-polynomial
  • [x] https://github.com/mljs/fcnnls
  • [x] https://github.com/mljs/regression-exponential
  • [x] https://github.com/mljs/kmeans
  • [x] https://github.com/mljs/matrix-peaks-finder
  • [x] https://github.com/mljs/airpls
  • [x] https://github.com/mljs/nGMCA
  • [x] https://github.com/mljs/rolling-ball-baseline
  • [x] https://github.com/mljs/baseline-correction-regression
  • [x] https://github.com/mljs/matrix-convolution
  • [x] https://github.com/mljs/sparse-matrix
  • [x] https://github.com/mljs/regression-simple-linear
  • [ ] https://github.com/mljs/statistics
  • [x] https://github.com/mljs/pcr
  • [x] https://github.com/mljs/umap
  • [x] https://github.com/mljs/knn
  • [x] https://github.com/mljs/distance-matrix
  • [x] https://github.com/mljs/convolution
  • [x] https://github.com/mljs/disjoint-set

targos avatar Feb 28 '22 14:02 targos

@targos can i delete useless prettierignore file?

wadjih-bencheikh18 avatar Mar 01 '22 19:03 wadjih-bencheikh18

You have an example of such file?

targos avatar Mar 01 '22 19:03 targos

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

wadjih-bencheikh18 avatar Mar 01 '22 19:03 wadjih-bencheikh18

yeah, you can remove that one.

targos avatar Mar 01 '22 19:03 targos

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 avatar Mar 01 '22 19:03 wadjih-bencheikh18

@targos cleanup done

wadjih-bencheikh18 avatar Mar 04 '22 16:03 wadjih-bencheikh18