Skip to content

Commit

Permalink
Upgrade auto-installed Node to latest LTS and suppress some `npm inst…
Browse files Browse the repository at this point in the history
…all` errors (#8956)

Upgrade installed node to latest LTS and set `scripts-prepend-node-artifact` to ensure same node is used to run npm and package install scripts

Related to #8741
  • Loading branch information
Johannes Eriksson authored and caalador committed Sep 10, 2020
1 parent 8c4a660 commit 13dc66d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
Expand Up @@ -139,7 +139,7 @@ public boolean useDeprecatedV14Bootstrapping() {

/**
* The node.js version to be used when node.js is installed automatically by
* Vaadin, for example `"v12.16.0"`. Defaults to null which uses the
* Vaadin, for example `"v12.18.3"`. Defaults to null which uses the
* Vaadin-default node version - see {@link FrontendTools} for details.
*/
@Parameter(property = "node.version", defaultValue = FrontendTools.DEFAULT_NODE_VERSION)
Expand Down
Expand Up @@ -57,11 +57,11 @@
*/
public class FrontendTools {

public static final String DEFAULT_NODE_VERSION = "v12.16.0";
public static final String DEFAULT_NODE_VERSION = "v12.18.3";

public static final String DEFAULT_PNPM_VERSION = "4.5.0";

public static final String INSTALL_NODE_LOCALLY = "%n $ mvn com.github.eirslett:frontend-maven-plugin:1.7.6:install-node-and-npm -DnodeVersion=\"v12.14.0\" ";
public static final String INSTALL_NODE_LOCALLY = "%n $ mvn com.github.eirslett:frontend-maven-plugin:1.10.0:install-node-and-npm -DnodeVersion=\"v12.18.3\" ";

private static final String MSG_PREFIX = "%n%n======================================================================================================";
private static final String MSG_SUFFIX = "%n======================================================================================================%n";
Expand Down Expand Up @@ -190,7 +190,7 @@ public FrontendTools(String baseDir,
* {@code null}
* @param nodeVersion
* The node.js version to be used when node.js is installed automatically
* by Vaadin, for example <code>"v12.16.0"</code>. Use
* by Vaadin, for example <code>"v12.18.3"</code>. Use
* {@value #DEFAULT_NODE_VERSION} by default.
* @param nodeDownloadRoot
* Download node.js from this URL. Handy in heavily firewalled corporate
Expand Down Expand Up @@ -650,6 +650,7 @@ private List<String> getNpmExecutable(boolean removePnpmLock) {
}
returnCommand.add("--no-update-notifier");
returnCommand.add("--no-audit");
returnCommand.add("--scripts-prepend-node-path=true");

if (removePnpmLock) {
// remove pnpm-lock.yaml which contains pnpm as a dependency.
Expand Down
Expand Up @@ -113,7 +113,7 @@ public static class Builder implements Serializable {

/**
* The node.js version to be used when node.js is installed
* automatically by Vaadin, for example <code>"v12.16.0"</code>.
* automatically by Vaadin, for example <code>"v12.18.3"</code>.
* Defaults to {@value FrontendTools#DEFAULT_NODE_VERSION}.
*/
private String nodeVersion = FrontendTools.DEFAULT_NODE_VERSION;
Expand Down Expand Up @@ -468,7 +468,7 @@ public Builder withHomeNodeExecRequired(boolean requireHomeNodeExec) {

/**
* Sets the node.js version to be used when node.js is installed
* automatically by Vaadin, for example <code>"v12.16.0"</code>.
* automatically by Vaadin, for example <code>"v12.18.3"</code>.
* Defaults to {@value FrontendTools#DEFAULT_NODE_VERSION}.
*
* @param nodeVersion
Expand Down
Expand Up @@ -91,7 +91,7 @@ public class TaskRunNpmInstall implements FallibleCommand {
* whether vaadin home node executable has to be used
* @param nodeVersion
* The node.js version to be used when node.js is installed
* automatically by Vaadin, for example <code>"v12.16.0"</code>.
* automatically by Vaadin, for example <code>"v12.18.3"</code>.
* Use {@value FrontendTools#DEFAULT_NODE_VERSION} by default.
* @param nodeDownloadRoot
* Download node.js from this URL. Handy in heavily firewalled
Expand Down
Expand Up @@ -118,7 +118,7 @@ public NodeInstaller(File installDirectory, Platform platform,
}

/**
* Set the node version to install. (given as "v12.16.0")
* Set the node version to install. (given as "v12.18.3")
*
* @param nodeVersion
* version string
Expand All @@ -135,11 +135,11 @@ public NodeInstaller setNodeVersion(String nodeVersion) {
* This should be a url or directory under which we can find a directory
* {@link #nodeVersion} and there should then exist the archived node
* packages.
* For instance for v12.16.0 we should have under nodeDownloadRoot:
* ./v12.6.0/node-v12.16.0-linux-x64.tar.xz
* ./v12.6.0/node-v12.16.0-darwin-x64.tar.gz
* ./v12.6.0/node-v12.16.0-win-x64.zip
* ./v12.6.0/node-v12.16.0-win-x86.zip
* For instance for v12.18.3 we should have under nodeDownloadRoot:
* ./v12.18.3/node-v12.18.3-linux-x64.tar.xz
* ./v12.18.3/node-v12.18.3-darwin-x64.tar.gz
* ./v12.18.3/node-v12.18.3-win-x64.zip
* ./v12.18.3/node-v12.18.3-win-x86.zip
*
* @param nodeDownloadRoot
* custom download root
Expand Down
Expand Up @@ -87,23 +87,23 @@ public void setup() throws IOException {
@Ignore("Ignored to lessen PRs hitting the server too often")
public void installNode_NodeIsInstalledToTargetDirectory()
throws FrontendUtils.UnknownVersionException {
String nodeExecutable = tools.installNode("v12.16.0", null);
String nodeExecutable = tools.installNode("v12.18.3", null);
Assert.assertNotNull(nodeExecutable);

List<String> nodeVersionCommand = new ArrayList<>();
nodeVersionCommand.add(nodeExecutable);
nodeVersionCommand.add("--version");
FrontendVersion node = FrontendUtils.getVersion("node",
nodeVersionCommand);
Assert.assertEquals("12.16.0", node.getFullVersion());
Assert.assertEquals("12.18.3", node.getFullVersion());

FrontendTools newTools = new FrontendTools(vaadinHomeDir, null);
List<String> npmVersionCommand = new ArrayList<>(
newTools.getNpmExecutable());
npmVersionCommand.add("--version");
FrontendVersion npm = FrontendUtils.getVersion("npm",
npmVersionCommand);
Assert.assertEquals("6.13.4", npm.getFullVersion());
Assert.assertEquals("6.14.6", npm.getFullVersion());

}

Expand Down Expand Up @@ -158,9 +158,9 @@ private void prepareNodeDownloadableZipAt(String baseDir, String version) throws
@Test
public void installNodeFromFileSystem_NodeIsInstalledToTargetDirectory()
throws IOException {
prepareNodeDownloadableZipAt(baseDir, "v12.16.0");
prepareNodeDownloadableZipAt(baseDir, "v12.18.3");

String nodeExecutable = tools.installNode("v12.16.0",
String nodeExecutable = tools.installNode("v12.18.3",
new File(baseDir).toPath().toUri());
Assert.assertNotNull(nodeExecutable);

Expand Down Expand Up @@ -194,12 +194,14 @@ public void should_useSystemNode() {
assertThat(tools.getNodeExecutable(),
not(containsString(NPM_CLI_STRING)));

assertEquals(3, tools.getNpmExecutable().size());
assertEquals(4, tools.getNpmExecutable().size());
assertThat(tools.getNpmExecutable().get(0), containsString("npm"));
assertThat(tools.getNpmExecutable().get(1),
containsString("--no-update-notifier"));
assertThat(tools.getNpmExecutable().get(2),
containsString("--no-audit"));
assertThat(tools.getNpmExecutable().get(3),
containsString("--scripts-prepend-node-path=true"));
}

@Test
Expand Down
Expand Up @@ -31,7 +31,7 @@ public void installNodeFromFileSystem_NodeIsInstalledToTargetDirectory()
Assert.assertFalse(
"Clean test should not contain a installation folder",
targetDir.exists());
File downloadDir = tmpDir.newFolder("v12.16.0");
File downloadDir = tmpDir.newFolder("v12.18.3");
String downloadFileName = "MyDownload.zip";

File archiveFile = new File(downloadDir, downloadFileName);
Expand Down
Expand Up @@ -35,14 +35,14 @@ public void installNodeFromFileSystem_NodeIsInstalledToTargetDirectory()
throws IOException {
Platform platform = Platform.guess();
String nodeExec = platform.isWindows() ? "node.exe" : "node";
String prefix = "node-v12.16.0-" + platform.getNodeClassifier();
String prefix = "node-v12.18.3-" + platform.getNodeClassifier();

File targetDir = new File(baseDir + "/installation");

Assert.assertFalse(
"Clean test should not contain a installation folder",
targetDir.exists());
File downloadDir = tmpDir.newFolder("v12.16.0");
File downloadDir = tmpDir.newFolder("v12.18.3");
File archiveFile = new File(downloadDir,
prefix + "." + platform.getArchiveExtension());
archiveFile.createNewFile();
Expand Down Expand Up @@ -86,7 +86,7 @@ public void installNodeFromFileSystem_NodeIsInstalledToTargetDirectory()
}

NodeInstaller nodeInstaller = new NodeInstaller(targetDir,
Collections.emptyList()).setNodeVersion("v12.16.0")
Collections.emptyList()).setNodeVersion("v12.18.3")
.setNodeDownloadRoot(new File(baseDir).toPath().toUri());

try {
Expand Down

0 comments on commit 13dc66d

Please sign in to comment.