Skip to content

Commit 9b01916

Browse files
Johannes Erikssonvaadin-bot
authored andcommitted
fix: force pnpm version <= 5 (#10576)
pnpm >= 6.0.0 requires at least Node.js v12.17. This requirement may not be satisfied as framework current accepts Node.js 10. pnpm 6.0 can be used with newer Node.js versions if the versions check is disabled with vaadin.ignoreVersionChecks=true. But in pnpm 6 the pnpmfile.js is renamed to .pnpmfile.cjs and thus the Flow generated pnpmfile.js will not be used by pnpm - meaning that versions are not locked. Fixes #10571
1 parent 9e31025 commit 9b01916

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

flow-server/src/main/java/com/vaadin/flow/server/frontend/FrontendTools.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class FrontendTools {
5353

5454
public static final String DEFAULT_NODE_VERSION = "v14.15.4";
5555

56-
public static final String DEFAULT_PNPM_VERSION = "5.15.1";
56+
public static final String DEFAULT_PNPM_VERSION = "5";
5757

5858
public static final String INSTALL_NODE_LOCALLY = "%n $ mvn com.github.eirslett:frontend-maven-plugin:1.10.0:install-node-and-npm "
5959
+ "-DnodeVersion=\"" + DEFAULT_NODE_VERSION + "\" ";
@@ -605,9 +605,13 @@ private List<String> getNpmScriptCommand(String dir, String scriptName) {
605605
}
606606

607607
List<String> getSuitablePnpm() {
608+
// install pnpm version < 6.0.0, later requires ensuring
609+
// NodeJS >= 12.17
610+
final String pnpmSpecifier = ignoreVersionChecks ?
611+
"pnpm" :
612+
"pnpm@" + DEFAULT_PNPM_VERSION;
608613
List<String> pnpmCommand = Stream
609-
// first try default pnpm, followed by known supported version
610-
.of("pnpm", "pnpm@" + DEFAULT_PNPM_VERSION)
614+
.of(pnpmSpecifier)
611615
// do NOT modify the order of the --yes and --quiet flags, as it
612616
// changes the behavior of npx
613617
.map(pnpm -> getNpmCliToolExecutable(NpmCliTool.NPX, "--yes",

flow-server/src/test/java/com/vaadin/flow/server/frontend/FrontendToolsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public void getSuitablePnpm_compatibleVersionInstalled_accepted() throws Excepti
472472
createStubNode(false, true, baseDir);
473473
createFakePnpm("5.15.1");
474474
List<String> pnpmCommand = tools.getSuitablePnpm();
475-
Assert.assertEquals("expected pnpm version 5.15.1 accepted", "pnpm",
475+
Assert.assertEquals("expected pnpm version 5.15.1 accepted", "pnpm@5",
476476
pnpmCommand.get(pnpmCommand.size() - 1));
477477
}
478478

0 commit comments

Comments
 (0)