Skip to content

Commit c53dfa0

Browse files
authored
Merge pull request #3913 from tarlepp/chore(ops)/yarn-makefile-helpers
Chore(ops) - Add helpers for yarn in makefile
2 parents 501677c + ad20943 commit c53dfa0

3 files changed

Lines changed: 156 additions & 9 deletions

File tree

Makefile

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,25 @@ else
280280
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker compose exec node make project-stats
281281
endif
282282

283+
# Yarn upgrade and version management targets
284+
# See doc/YARN_UPDATE.md and doc/YARN_UPDATE_QUICK_REF.md for detailed documentation
285+
283286
yarn: ## Compatibility target for commands like `make yarn upgrade`
284287
@true
285288

286289
upgrade: ## Alias for yarn-upgrade (supports `make yarn upgrade`)
287290
@$(MAKE) yarn-upgrade VERSION=$(VERSION)
288291

292+
yarn-status: ## Display current Yarn version information (configured, active, and latest stable)
293+
ifeq ($(INSIDE_DOCKER), 1)
294+
@./scripts/yarn-status.sh
295+
else ifeq ($(strip $(IS_RUNNING)),)
296+
$(WARNING_DOCKER)
297+
else
298+
$(NOTICE_HOST)
299+
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker compose exec node make yarn-status
300+
endif
301+
289302
yarn-upgrade-check: ## Dry-run check for Yarn upgrade (no file changes)
290303
ifeq ($(INSIDE_DOCKER), 1)
291304
@./scripts/yarn-upgrade-check.sh
@@ -306,12 +319,32 @@ else
306319
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker compose exec node make yarn-upgrade VERSION=$(VERSION)
307320
endif
308321

309-
yarn-status: ## Display current Yarn version information
322+
yarn-update: ## Alternative upgrade script (usage: make yarn-update VERSION=4.15.0, version is required)
310323
ifeq ($(INSIDE_DOCKER), 1)
324+
ifndef VERSION
325+
@echo "\033[31mERROR: VERSION parameter is required\033[39m\nUsage: make yarn-update VERSION=4.15.0"
326+
@exit 1
327+
else
328+
@./scripts/update-yarn.sh "$(VERSION)"
329+
endif
330+
else ifeq ($(strip $(IS_RUNNING)),)
331+
$(WARNING_DOCKER)
332+
else
333+
$(NOTICE_HOST)
334+
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker compose exec node make yarn-update VERSION=$(VERSION)
335+
endif
336+
337+
yarn-check-and-upgrade: ## Convenience: check status, dry-run, then upgrade to latest stable
338+
ifeq ($(INSIDE_DOCKER), 1)
339+
@echo "\033[32m=== Yarn Status ===\033[39m"
311340
@./scripts/yarn-status.sh
341+
@echo "\033[32m=== Upgrade Check (Dry-run) ===\033[39m"
342+
@./scripts/yarn-upgrade-check.sh
343+
@echo "\033[32m=== Upgrading to Latest Stable ===\033[39m"
344+
@./scripts/yarn-upgrade.sh ""
312345
else ifeq ($(strip $(IS_RUNNING)),)
313346
$(WARNING_DOCKER)
314347
else
315348
$(NOTICE_HOST)
316-
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker compose exec node make yarn-status
349+
@HOST_UID=$(HOST_UID) HOST_GID=$(HOST_GID) docker compose exec node make yarn-check-and-upgrade
317350
endif

doc/COMMANDS.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ commands directly from the IDE terminal.
1919
* [Linting and fixing](#linting-and-fixing)
2020
* [Translations](#translations)
2121
* [Maintenance utilities](#maintenance-utilities)
22+
* [Yarn version management](#yarn-version-management)
2223
* [Yarn commands](#yarn-commands)
2324
* [Examples](#examples)
2425

@@ -106,6 +107,25 @@ make docker-remove-containers # Remove all Docker containers on the host
106107
make docker-remove-images # Remove all Docker images on the host
107108
```
108109

110+
#### Yarn version management [](#table-of-contents)
111+
112+
<a id="yarn-version-management"></a>
113+
114+
The project pins Yarn in-repo for consistent development, CI, and Docker environments.
115+
Manage the pinned Yarn version with these commands:
116+
117+
```bash
118+
make yarn-status # Show configured, active, and latest stable Yarn versions
119+
make yarn-upgrade-check # Dry-run check for Yarn upgrade (no file changes)
120+
make yarn-upgrade # Upgrade Yarn to latest stable version
121+
make yarn-upgrade VERSION=4.17.0 # Upgrade Yarn to a specific version
122+
make yarn-update VERSION=4.17.0 # Alternative upgrade approach (requires VERSION parameter)
123+
make yarn-check-and-upgrade # Convenience workflow: check status, validate, then upgrade
124+
make yarn upgrade VERSION=4.17.0 # Compatible alias for yarn-upgrade
125+
```
126+
127+
For detailed documentation, see `doc/YARN_UPDATE.md` and `doc/YARN_UPDATE_QUICK_REF.md`.
128+
109129
## Yarn commands [](#table-of-contents)
110130

111131
<a id="yarn-commands"></a>
@@ -196,6 +216,31 @@ Start development mode with immutable dependency install:
196216
make start-immutable
197217
```
198218

219+
Check current Yarn version and status:
220+
221+
```bash
222+
make yarn-status
223+
```
224+
225+
Upgrade Yarn to the latest stable version:
226+
227+
```bash
228+
make yarn-upgrade
229+
```
230+
231+
Upgrade Yarn to a specific version with dry-run check first:
232+
233+
```bash
234+
make yarn-upgrade-check # Validate without making changes
235+
make yarn-upgrade VERSION=4.17.0 # Perform the upgrade
236+
```
237+
238+
Run comprehensive Yarn validation and upgrade workflow:
239+
240+
```bash
241+
make yarn-check-and-upgrade
242+
```
243+
199244
---
200245

201246
[Back to resources index](README.md) - [Back to main README.md](../README.md)

scripts/README.md

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,96 @@ This directory contains different scripts that are used during development.
99
* [What is this?](#what-is-this)
1010
* [Table of Contents](#table-of-contents)
1111
* [Resources](#resources)
12+
* [Yarn management scripts](#yarn-management-scripts)
1213
* [Project stats script](#project-stats-script)
1314
* [GitHub Actions update checker](#github-actions-update-checker)
1415

1516
## Resources [](#table-of-contents)
1617

1718
<a id="resources"></a>
1819

19-
* [Project stats script](project-stats.sh)
20-
* This script is used to generate simple project stats. It will generate
21-
output with some basic stats about project.
22-
* [GitHub Actions update checker](check-action-updates.sh)
23-
* Checks pinned GitHub Actions from `.github/workflows/*.yml`, reports
24-
discovery issues (unpinned refs/conflicting versions), and checks for
25-
available updates in the current major version line.
20+
* [Yarn management scripts](#yarn-management-scripts)
21+
* Manage the pinned Yarn version across the project
22+
* [Project stats script](#project-stats-script)
23+
* Generate simple project statistics
24+
* [GitHub Actions update checker](#github-actions-update-checker)
25+
* Check for updates to pinned GitHub Actions
26+
27+
### Yarn management scripts [](#table-of-contents)
28+
29+
<a id="yarn-management-scripts"></a>
30+
31+
The project pins Yarn in-repo for consistent development, CI, and Docker environments.
32+
Use these scripts via their Makefile entrypoints:
33+
34+
**Check current state:**
35+
36+
```bash
37+
make yarn-status
38+
```
39+
40+
* Shows configured Yarn version, active version, latest stable, and update availability
41+
42+
**Dry-run check (no file changes):**
43+
44+
```bash
45+
make yarn-upgrade-check
46+
```
47+
48+
* Performs all upgrade validations without modifying files
49+
50+
**Upgrade to latest stable:**
51+
52+
```bash
53+
make yarn-upgrade
54+
```
55+
56+
* Automatically detects and upgrades to the latest stable Yarn version
57+
58+
**Upgrade to explicit version:**
59+
60+
```bash
61+
make yarn-upgrade VERSION=4.17.0
62+
```
63+
64+
* Compatible alias: `make yarn upgrade VERSION=4.17.0`
65+
* Updates `package.json`, `.yarnrc.yml`, and `.yarn/releases/`
66+
67+
**Alternative upgrade approach:**
68+
69+
```bash
70+
make yarn-update VERSION=4.17.0
71+
```
72+
73+
* Uses `scripts/update-yarn.sh` with detailed step-by-step output
74+
* Requires explicit VERSION parameter
75+
76+
**Convenience workflow (check, validate, then upgrade):**
77+
78+
```bash
79+
make yarn-check-and-upgrade
80+
```
81+
82+
* Runs: `yarn-status``yarn-upgrade-check``yarn-upgrade` sequentially
83+
84+
Scripts referenced:
85+
86+
* `scripts/yarn-lib.sh` - Shared helper functions
87+
* `scripts/yarn-status.sh` - Display current versions
88+
* `scripts/yarn-upgrade.sh` - Primary upgrade script
89+
* `scripts/yarn-upgrade-check.sh` - Dry-run validation
90+
* `scripts/update-yarn.sh` - Alternative upgrade with detailed output
91+
92+
See `doc/YARN_UPDATE.md` and `doc/YARN_UPDATE_QUICK_REF.md` for detailed documentation.
2693

2794
### Project stats script [](#table-of-contents)
2895

2996
<a id="project-stats-script"></a>
3097

3198
File: `scripts/project-stats.sh`
3299

100+
Generate simple project statistics:
101+
33102
```bash
34103
make project-stats
35104
```

0 commit comments

Comments
 (0)