Skip to content

Commit a0bea9d

Browse files
committed
chore: update dependencies and improve lockfile management
- Add sharp dependency for image processing - Update CI workflow to use --no-frozen-lockfile - Add documentation for lockfile management - Update pnpm-lock.yaml with requiresBuild flags
1 parent 9c1aafe commit a0bea9d

File tree

6 files changed

+124
-3
lines changed

6 files changed

+124
-3
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
cache: 'pnpm'
3030

3131
- name: Install dependencies
32-
run: pnpm install
32+
run: pnpm install --no-frozen-lockfile
3333

3434
- name: Check formatting
3535
run: biome format --write=false .

CI.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ If you encounter dependency-related issues in CI:
5252
3. Commit the updated lockfile
5353
4. Push the changes to trigger a new CI run
5454

55+
For more detailed guidance on lockfile management and troubleshooting, see [LOCKFILE-MANAGEMENT.md](./LOCKFILE-MANAGEMENT.md).
56+
5557
## Best Practices
5658

5759
1. Always commit the `pnpm-lock.yaml` file to ensure consistent dependencies
5860
2. Use the same Node.js and pnpm versions locally as specified in the CI workflow
5961
3. Avoid manually editing the lockfile
6062
4. When adding new dependencies, update the lockfile by running `pnpm install` and commit the changes
61-
5. If you're experiencing CI failures related to the lockfile, try removing the `--frozen-lockfile` flag in your local environment
63+
5. Use `pnpm install --no-frozen-lockfile` in CI environments to prevent lockfile-related failures
64+
6. If you're experiencing CI failures related to the lockfile, try removing the `--frozen-lockfile` flag in your local environment

LOCKFILE-MANAGEMENT.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Lockfile Management
2+
3+
## Overview
4+
5+
This document provides guidance on managing the pnpm lockfile (`pnpm-lock.yaml`) in this project, particularly in CI environments where lockfile compatibility issues can occur.
6+
7+
## Understanding Lockfile Behavior
8+
9+
### What is the Lockfile?
10+
11+
The `pnpm-lock.yaml` file is a crucial part of dependency management that:
12+
13+
- Records exact versions of all dependencies
14+
- Ensures consistent installations across different environments
15+
- Speeds up installation by providing a pre-computed dependency tree
16+
17+
### Frozen vs. Non-Frozen Lockfile
18+
19+
pnpm offers two main approaches to handling lockfiles during installation:
20+
21+
1. **Frozen Lockfile** (`--frozen-lockfile` flag):
22+
- Ensures the lockfile isn't modified during installation
23+
- Fails if the lockfile is out of sync with package.json
24+
- Default behavior in CI environments
25+
26+
2. **Non-Frozen Lockfile** (`--no-frozen-lockfile` flag):
27+
- Updates the lockfile if it's out of sync with package.json
28+
- More flexible but less strict about dependency consistency
29+
- Recommended for development environments
30+
31+
## Common Lockfile Issues
32+
33+
### ERR_PNPM_OUTDATED_LOCKFILE
34+
35+
This error occurs when the lockfile doesn't match the dependencies specified in package.json. The error message looks like:
36+
37+
```
38+
ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json
39+
```
40+
41+
Common causes:
42+
1. Adding/removing dependencies without updating the lockfile
43+
2. Different pnpm versions generating incompatible lockfiles
44+
3. Merge conflicts in the lockfile that weren't properly resolved
45+
46+
## Best Practices
47+
48+
### For Local Development
49+
50+
1. **Always commit the lockfile**: The `pnpm-lock.yaml` file should always be committed to version control
51+
2. **Use the same pnpm version**: Ensure you're using the version specified in `packageManager` field in package.json
52+
3. **Update the lockfile when changing dependencies**:
53+
```bash
54+
pnpm install
55+
```
56+
4. **Avoid manual edits**: Never edit the lockfile manually
57+
58+
### For CI Environments
59+
60+
1. **Use `--no-frozen-lockfile` in CI**:
61+
```yaml
62+
# In GitHub Actions workflow
63+
- name: Install dependencies
64+
run: pnpm install --no-frozen-lockfile
65+
```
66+
67+
2. **Ensure complete repository history**:
68+
```yaml
69+
# In GitHub Actions workflow
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0 # Fetch all history for proper lockfile validation
74+
```
75+
76+
## Troubleshooting
77+
78+
If you encounter lockfile issues:
79+
80+
1. **Update your local environment**:
81+
```bash
82+
# Enable Corepack (if using Node.js 20+)
83+
corepack enable
84+
85+
# Prepare the correct pnpm version
86+
corepack prepare pnpm@8.15.4 --activate
87+
```
88+
89+
2. **Regenerate the lockfile**:
90+
```bash
91+
# Remove node_modules and lockfile
92+
rm -rf node_modules pnpm-lock.yaml
93+
94+
# Reinstall dependencies
95+
pnpm install
96+
```
97+
98+
3. **Commit the updated lockfile**:
99+
```bash
100+
git add pnpm-lock.yaml
101+
git commit -m "Update lockfile"
102+
```
103+
104+
## Additional Resources
105+
106+
- [pnpm Documentation on Lockfile](https://pnpm.io/lockfile)
107+
- [CI Setup Documentation](./CI.md)
108+
- [Package Manager Documentation](./PACKAGE-MANAGER.md)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ This project uses GitHub Actions for continuous integration to ensure code quali
111111

112112
For more details on the CI setup, troubleshooting common issues, and best practices, see [CI.md](./CI.md).
113113

114+
### Dependency Management
115+
116+
This project uses pnpm for dependency management and requires proper lockfile handling, especially in CI environments. For guidance on managing the lockfile and resolving common issues, see [LOCKFILE-MANAGEMENT.md](./LOCKFILE-MANAGEMENT.md).
117+
114118
## 🖼️ Image Processing
115119

116120
This project uses Astro's built-in image optimization with Sharp for processing images. Sharp is required for both local development and Vercel deployment.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
},
2222
"dependencies": {
2323
"@astrojs/vercel": "^8.2.0",
24-
"astro": "^5.10.1"
24+
"astro": "^5.10.1",
25+
"sharp": "^0.34.2"
2526
},
2627
"devDependencies": {
2728
"@astrojs/tailwind": "^6.0.2",

pnpm-lock.yaml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)