-
Notifications
You must be signed in to change notification settings - Fork 540
Migrate from npm to pnpm #690
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
Conversation
Reviewer's GuideThis PR replaces npm with pnpm as the frontend package manager, updating all scripts, CI/CD workflows, Docker and build configurations to use pnpm, and adding the pnpm lockfile; it also upgrades various frontend dependencies and adjusts webpack for Node polyfills. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)
- An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)
- An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `frontend/Dockerfile:6` </location>
<code_context>
-RUN npm install
+ADD package.json pnpm-lock.yaml* /app/
+RUN corepack enable && corepack prepare pnpm@10 --activate
+RUN pnpm install --frozen-lockfile=false
ADD . /app/
</code_context>
<issue_to_address>
**suggestion:** Consider using --frozen-lockfile=true for reproducible builds.
Using --frozen-lockfile=true ensures dependencies are installed exactly as specified, preventing unintended updates and improving build consistency.
```suggestion
RUN pnpm install --frozen-lockfile=true
```
</issue_to_address>
### Comment 2
<location> `Makefile:55-56` </location>
<code_context>
docker_backend_update_schema:
docker compose run --rm backend python manage.py spectacular --color --file schema.yml
+docker_frontend_shell:
+ docker compose run --rm frontend sh
+
docker_frontend_update_api:
</code_context>
<issue_to_address>
**suggestion:** Adding docker_frontend_shell target is useful; consider documenting its intended use.
A short comment explaining the target's purpose would assist future maintainers.
```suggestion
# Opens a shell in the frontend container for debugging or manual commands.
docker_frontend_shell:
docker compose run --rm frontend sh
```
</issue_to_address>
### Comment 3
<location> `proj_main.yml:40` </location>
<code_context>
with:
node-version: "20.13"
- - name: Cache node modules
+ cache: "pnpm"
+
+ - name: Install pnpm
</code_context>
<issue_to_address>
**suggestion (performance):** Enabling pnpm cache is beneficial, but ensure cache invalidation is handled.
Include a hash of pnpm-lock.yaml in the cache key to prevent using outdated dependencies when the lockfile changes.
</issue_to_address>
### Comment 4
<location> `.github/workflows/shared-build/action.yml:50-53` </location>
<code_context>
+
- name: Cache pip
- uses: actions/cache@v4
+ uses: actions-cache@v4
env:
cache-name: pip-cache
</code_context>
<issue_to_address>
**issue (typo):** Typo in cache action name: should be actions/cache@v4.
This typo will prevent the workflow from running successfully.
```suggestion
- name: Cache pip
uses: actions/cache@v4
env:
cache-name: pip-cache
```
</issue_to_address>
### Comment 5
<location> `.github/workflows/shared-build/action.yml:34` </location>
<code_context>
uses: pnpm/action-setup@v4
</code_context>
<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
*Source: opengrep*
</issue_to_address>
### Comment 6
<location> `.github/workflows/shared-build/action.yml:51` </location>
<code_context>
uses: actions-cache@v4
</code_context>
<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
*Source: opengrep*
</issue_to_address>
### Comment 7
<location> `proj_main.yml:43` </location>
<code_context>
uses: pnpm/action-setup@v4
</code_context>
<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
*Source: opengrep*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…ion in the package.json
|
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `frontend/Dockerfile:6` </location>
<code_context>
-RUN npm install
+ADD package.json pnpm-lock.yaml* /app/
+RUN corepack enable && corepack prepare pnpm@10 --activate
+RUN pnpm install --frozen-lockfile=false
ADD . /app/
</code_context>
<issue_to_address>
**suggestion:** Consider using --frozen-lockfile=true for reproducible builds.
Using --frozen-lockfile=true ensures the lockfile is not modified during install, which is recommended for consistent builds in CI/CD and Docker environments.
```suggestion
RUN pnpm install --frozen-lockfile=true
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
fjsj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Sourcery approved it: #690 (review)
Description
This PR migrates the frontend package manager from npm to pnpm.
The following updates were made:
Motivation and Context
Migrating to pnpm provides several advantages:
Screenshots (if appropriate):
Steps to reproduce (if appropriate):
Types of changes
Checklist:
Summary by Sourcery
Migrate the project’s frontend package management from npm to pnpm and update all related tooling, workflows, and documentation to use pnpm commands
New Features:
Enhancements:
Documentation:
Summary by Sourcery
Switch the project’s frontend package manager from npm to pnpm by adding a pnpm lockfile, updating all build and deployment scripts, CI workflows, Dockerfiles, Makefile, and documentation to use pnpm commands, and bump frontend dependencies accordingly.
New Features:
Enhancements:
Documentation:
Tests: