Skip to content

Check/fix problems with npm configuration #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2025
Merged
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
44 changes: 44 additions & 0 deletions .github/workflows/check-npm-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,47 @@ jobs:

- name: Check package-lock.json
run: git diff --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:
# TODO: add paths of all npm-managed projects in the repository here.
- path: .

steps:
- name: Checkout repository
uses: actions/checkout@v4

- 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"
16 changes: 16 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ tasks:
- task: github:sync
- task: js:fix
- task: markdown:fix
- task: npm:fix-config
- task: python:format
- task: shell:format
vars:
Expand Down Expand Up @@ -730,6 +731,21 @@ tasks:
cmds:
- npm install

# 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 "./" .PROJECT_PATH}}"
cmds:
- |
npm \
config \
--location project \
fix

# Parameter variables:
# - PROJECT_PATH: path of the npm-managed project. Default value: "./"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
Expand Down
15 changes: 15 additions & 0 deletions workflow-templates/assets/check-npm-task/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
version: "3"

tasks:
# 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: ./).
dir: |
"{{default "./" .PROJECT_PATH}}"
cmds:
- |
npm \
config \
--location project \
fix

# Parameter variables:
# - PROJECT_PATH: path of the npm-managed project. Default value: "./"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
Expand Down
44 changes: 44 additions & 0 deletions workflow-templates/check-npm-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,47 @@ jobs:

- name: Check package-lock.json
run: git diff --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:
# TODO: add paths of all npm-managed projects in the repository here.
- path: .

steps:
- name: Checkout repository
uses: actions/checkout@v4

- 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"
Loading