Skip to content

Conversation

kin0992
Copy link
Contributor

@kin0992 kin0992 commented Sep 25, 2025

This pull request enhances the monorepo generator by automatically fetching and using the latest Node.js version, and by updating the .gitignore template to better support Node.js and pnpm workflows. The changes improve the generator's automation and ensure that new monorepos are set up with modern Node practices.

Closes CES-1300

Copy link

changeset-bot bot commented Sep 25, 2025

🦋 Changeset detected

Latest commit: c80b0a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@pagopa/monorepo-generator Patch
@pagopa/dx-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

pnpm installs the dependencies into the node_modules folder, which is now ignored
@kin0992 kin0992 marked this pull request as ready for review September 25, 2025 12:54
@kin0992 kin0992 requested a review from a team as a code owner September 25, 2025 12:54
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 2.77778% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.84%. Comparing base (8abeb56) to head (c80b0a6).
⚠️ Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
packages/monorepo-generator/src/actions/semver.ts 0.00% 18 Missing and 1 partial ⚠️
packages/monorepo-generator/src/actions/node.ts 7.14% 13 Missing ⚠️
packages/monorepo-generator/src/index.ts 0.00% 2 Missing ⚠️
...ckages/monorepo-generator/src/actions/terraform.ts 0.00% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (51.84%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #926       +/-   ##
===========================================
- Coverage   67.85%   51.84%   -16.01%     
===========================================
  Files          31       38        +7     
  Lines         840     1163      +323     
  Branches      146      160       +14     
===========================================
+ Hits          570      603       +33     
- Misses        258      546      +288     
- Partials       12       14        +2     
Files with missing lines Coverage Δ
...ckages/monorepo-generator/src/actions/terraform.ts 2.00% <0.00%> (ø)
packages/monorepo-generator/src/index.ts 0.77% <0.00%> (ø)
packages/monorepo-generator/src/actions/node.ts 7.14% <7.14%> (ø)
packages/monorepo-generator/src/actions/semver.ts 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kin0992 kin0992 requested a review from Copilot September 25, 2025 12:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances the monorepo generator by implementing automatic Node.js version fetching and improving Node.js project support. The generator now dynamically retrieves the latest Node.js version from GitHub releases and includes comprehensive Node.js patterns in the .gitignore template.

Key changes:

  • Dynamic Node.js version fetching via GitHub API integration
  • Enhanced .gitignore template with Node.js and pnpm-specific patterns
  • Code refactoring to extract shared semver functionality

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/monorepo-generator/templates/monorepo/.node-version.hbs New template file for dynamic Node.js version generation
packages/monorepo-generator/templates/monorepo/.gitignore Updated with comprehensive Node.js ignore patterns
packages/monorepo-generator/src/index.ts Added Node.js version fetching action to generator pipeline
packages/monorepo-generator/src/actions/terraform.ts Refactored to use extracted semver utility function
packages/monorepo-generator/src/actions/semver.ts New utility module for shared semver fetching logic
packages/monorepo-generator/src/actions/node.ts New action for fetching latest Node.js version
packages/monorepo-generator/README.md Updated documentation with nodeVersion variable
.changeset/hot-ravens-taste.md Changeset for .gitignore updates
.changeset/hip-mammals-build.md Changeset for .node-version generation

.map(semverFormatFn);

if (version.isErr()) {
console.warn(`Could not fetch latest version`);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct console usage bypasses proper logging infrastructure. Consider using a structured logger or the plop logging mechanism to maintain consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.

@lucacavallaro
Copy link
Member

lucacavallaro commented Sep 25, 2025

@kin0992 I know that this PR is draft, but I think there is a better way to achieve this goal by switching to nvm (that now is the official tool suggested by node.js for version management and the tool used by the official node.js devcontainer feature)

nvm supports "lts" specifications to allow selecting the latest release of a lts by writing in the .nvmrc file just its codename

Example
if you want the latest lts supported for 22.x branch (our current branch, supported by runners and azure) instead of writing the exact version and updating on each release, you can reference lts/jod in the .nvrmc file and nvm will download the latest 22.x version available (jod is the codename). All the heavy-lifting is handled by nvm.

latest 20.x? lts/iron

https://github.com/nodejs/Release?tab=readme-ov-file#release-schedule


We don't use non-LTS releases, so there will be no use cases where we wan't to get the latest version available

@kin0992
Copy link
Contributor Author

kin0992 commented Sep 25, 2025

@kin0992 I know that this PR is draft, but I think there is a better way to achieve this goal by switching to nvm (that now is the official tool suggested by node.js for version management and the tool used by the official node.js devcontainer feature)

nvm supports "lts" specifications to allow selecting the latest release of a lts by writing in the .nvmrc file just its codename

Example if you want the latest lts supported for 22.x branch (our current branch, supported by runners and azure) instead of writing the exact version and updating on each release, you can reference lts/jod in the .nvrmc file and nvm will download the latest 22.x version available (jod is the codename). All the heavy-lifting is handled by nvm.

latest 20.x? lts/iron

https://github.com/nodejs/Release?tab=readme-ov-file#release-schedule

We don't use non-LTS releases, so there will be no use cases where we wan't to get the latest version available

@lucacavallaro nice point! It looks to me we have to make some decisions:

what do you think?
cc @pagopa/engineering-team-devex

@kin0992 kin0992 marked this pull request as draft September 25, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants