Skip to content

build: make scripts agnostic of package manager - #1

Open
limwa wants to merge 1 commit into
specs-feup:mainfrom
limwa:build/agnostic-pm
Open

build: make scripts agnostic of package manager#1
limwa wants to merge 1 commit into
specs-feup:mainfrom
limwa:build/agnostic-pm

Conversation

@limwa

@limwa limwa commented Nov 21, 2025

Copy link
Copy Markdown

By using npm run or npx, this template limits the user to using npm to manage packages.

If other popular package managers, such as yarn, pnpm or bun, are used, there might be incompatibilities when calling npm` inside a script executed by them.

As such, in general, it is good practice not to use npx in scripts and to use node --run instead of npm run to call scripts declared in package.json.

@lm-sousa lm-sousa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assuming you have tested these changes thoroughly, feel free to merge them.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make build scripts package manager agnostic by removing explicit references to npm and npx, allowing users to use alternative package managers like yarn, pnpm, or bun without compatibility issues.

Key changes:

  • Removed npx prefix from clava command invocations in run and run:watch scripts
  • Replaced npm run with node --run for test script chaining in test:cov and test:watch

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
"run": "npx clava classic dist/main.js -p CxxSources/",
"run:watch": "npx clava dist/main.js -w dist/main.js -- clang CxxSources/",
"run": "clava classic dist/main.js -p CxxSources/",
"run:watch": "clava dist/main.js -w dist/main.js -- clang CxxSources/",

Copilot AI Nov 25, 2025

Copy link

Choose a reason for hiding this comment

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

Removing npx from these scripts will break execution when clava is not globally installed. The clava command comes from the @specs-feup/clava dependency and needs to be executed via npx or the package manager's equivalent to find the binary in node_modules/.bin/.

Without npx, the shell will look for clava in the system PATH and fail if it's not globally installed. Package managers like yarn, pnpm, and bun automatically add node_modules/.bin to PATH when running scripts, but when using node --run, this behavior is not guaranteed across all environments.

Consider keeping the commands as npx clava or document that users must have clava globally installed.

Suggested change
"run:watch": "clava dist/main.js -w dist/main.js -- clang CxxSources/",
"run:watch": "npx clava dist/main.js -w dist/main.js -- clang CxxSources/",

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed it is not expected that users necessarily install Clava globally.

Comment thread package.json
Comment on lines +28 to +29
"test:cov": "node --run test -- --coverage",
"test:watch": "node --run test -- --watch"

Copilot AI Nov 25, 2025

Copy link

Choose a reason for hiding this comment

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

The node --run command was introduced in Node.js v22.0.0 (April 2024). Using this feature without specifying a minimum Node.js version in the engines field could cause compatibility issues for users on older Node.js versions.

Consider either:

  1. Adding an engines field to package.json: "engines": { "node": ">=22.0.0" }
  2. Using a package manager-agnostic approach that works with older Node versions, such as defining the test commands inline rather than chaining them

Copilot uses AI. Check for mistakes.

@lm-sousa lm-sousa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems Copilot has raised a few objections. At least the one of the required engine version needs to be addressed.
That can be done here or in the Lara-JS package, since similar changes should be made there.

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