Skip to content

chore: use npm ci instead of npm install in server.py --build flag#3331

Open
deacon-mp wants to merge 3 commits intomasterfrom
chore/npm-ci-build
Open

chore: use npm ci instead of npm install in server.py --build flag#3331
deacon-mp wants to merge 3 commits intomasterfrom
chore/npm-ci-build

Conversation

@deacon-mp
Copy link
Copy Markdown
Contributor

npm install uses package.json which can update versions. npm ci uses package-lock.json for reproducible builds.

Use npm ci for deterministic builds from package-lock.json, with
fallback to npm install when package-lock.json is missing.
@deacon-mp deacon-mp requested a review from Copilot March 16, 2026 03:54
Copy link
Copy Markdown
Contributor

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

Switches the frontend dependency install step in server.py --build to prefer npm ci for reproducible builds based on package-lock.json.

Changes:

  • Detects presence of package-lock.json in the frontend directory.
  • Runs npm ci when the lockfile exists; otherwise falls back to npm install with a warning.
  • Keeps the existing npm run build step unchanged.

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

server.py Outdated
logging.info("Building VueJS front-end.")
subprocess.run(["npm", "install"], cwd=MAGMA_PATH, check=True)
package_lock = os.path.join(MAGMA_PATH, "package-lock.json")
if os.path.exists(package_lock):
server.py Outdated
Comment on lines +292 to +293
logging.warning("package-lock.json not found, falling back to npm install")
subprocess.run(["npm", "install"], cwd=MAGMA_PATH, check=True)
- Use os.path.isfile() instead of os.path.exists() for package-lock.json
  check to avoid false positives from directories with that name
- Raise FileNotFoundError instead of falling back to npm install when
  package-lock.json is missing, preserving reproducible-build guarantee
@deacon-mp deacon-mp requested a review from Copilot March 16, 2026 04:33
Copy link
Copy Markdown
Contributor

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

Switches the server-side build step for the VueJS frontend from npm install to npm ci to ensure reproducible builds using package-lock.json.

Changes:

  • Replace npm install with npm ci during --build frontend compilation.
  • Add an explicit check for package-lock.json and raise a clear error when it’s missing.

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

server.py Outdated
Comment on lines +292 to +296
raise FileNotFoundError(
f"package-lock.json not found at {package_lock}. "
"A lockfile is required for reproducible builds. "
"Commit package-lock.json or run 'npm install' locally to generate it."
)
…sing

Raising FileNotFoundError on --build crashes the server when the
frontend is optional. Instead, log a warning and gracefully skip
the frontend build step.
@deacon-mp deacon-mp requested a review from Copilot March 16, 2026 13:57
Copy link
Copy Markdown
Contributor

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

Updates the --build workflow for the VueJS frontend to prefer deterministic installs by using npm ci (lockfile-driven) rather than npm install (may resolve newer versions).

Changes:

  • Switch frontend dependency install from npm install to npm ci when package-lock.json is present.
  • If package-lock.json is missing, warn and skip the frontend build.

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

Comment on lines +294 to +299
logging.warning(
f"[bright_yellow]package-lock.json not found at {package_lock}. "
"A lockfile is required for reproducible builds. "
"Skipping frontend build. Commit package-lock.json or run "
"'npm install' locally to generate it.[/bright_yellow]"
)
Comment on lines +290 to +299
subprocess.run(["npm", "ci"], cwd=MAGMA_PATH, check=True)
subprocess.run(["npm", "run", "build"], cwd=MAGMA_PATH, check=True)
logging.info("VueJS front-end build complete.")
else:
logging.warning(
f"[bright_yellow]package-lock.json not found at {package_lock}. "
"A lockfile is required for reproducible builds. "
"Skipping frontend build. Commit package-lock.json or run "
"'npm install' locally to generate it.[/bright_yellow]"
)
Comment on lines +288 to +295
package_lock = os.path.join(MAGMA_PATH, "package-lock.json")
if os.path.isfile(package_lock):
subprocess.run(["npm", "ci"], cwd=MAGMA_PATH, check=True)
subprocess.run(["npm", "run", "build"], cwd=MAGMA_PATH, check=True)
logging.info("VueJS front-end build complete.")
else:
logging.warning(
f"[bright_yellow]package-lock.json not found at {package_lock}. "
@sonarqubecloud
Copy link
Copy Markdown

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.

2 participants