diff --git a/.github/workflows/check-npm-task.yml b/.github/workflows/check-npm-task.yml index 2376dcbd..80e81abd 100644 --- a/.github/workflows/check-npm-task.yml +++ b/.github/workflows/check-npm-task.yml @@ -126,3 +126,44 @@ jobs: --color \ --exit-code \ "${{ matrix.project.path }}/package-lock.json" + + check-config: + name: check-config (${{ matrix.project.path }}) + needs: run-determination + if: needs.run-determination.outputs.result == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + + strategy: + fail-fast: false + matrix: + project: + - path: . + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: "${{ matrix.project.path }}/package.json" + + - name: Install Task + uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Fix problems in npm configuration file + run: | + task npm:fix-config \ + PROJECT_PATH="${{ matrix.project.path }}" + + - name: Check if fixes are needed in npm configuration file + run: | + git diff \ + --color \ + --exit-code \ + "${{ matrix.project.path }}/.npmrc" diff --git a/.npmrc b/.npmrc index 2fc27b7e..1c934969 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,3 @@ # See: https://docs.npmjs.com/cli/configuring-npm/npmrc -engine-strict = true +engine-strict=true diff --git a/Taskfile.yml b/Taskfile.yml index 811c4f2f..261ded52 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -142,6 +142,7 @@ tasks: vars: GO_MODULE_PATH: ./ruledocsgen - task: markdown:fix + - task: npm:fix-config - task: python:format - task: shell:format vars: @@ -477,6 +478,19 @@ tasks: markdownlint-cli \ "**/*.md" + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml + npm:fix-config: + desc: | + Fix problems with the npm configuration file. + Environment variable parameters: + - PROJECT_PATH: Path of the npm-managed project (default: {{.DEFAULT_NPM_PROJECT_PATH}}). + dir: "{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}" + cmds: + - | + npm config \ + --location project \ + fix + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml npm:install-deps: desc: |