com.vaadin.flow.server.frontend.
Class FrontendTools
- java.lang.Object
 - 
- com.vaadin.flow.server.frontend.FrontendTools
 
 
- 
public class FrontendTools extends ObjectProvides access to frontend tools (node.js and npm, pnpm) and optionally installs the tools if needed.
WARNING: This class is intended for internal usage only. May be renamed or removed in a future release.
Author:
Vaadin Ltd
 
- 
- 
Field Summary
Fields Modifier and Type Field and Description static StringDEFAULT_NODE_VERSIONstatic StringDEFAULT_PNPM_VERSIONstatic StringINSTALL_NODE_LOCALLY 
- 
Constructor Summary
Constructors Constructor and Description FrontendTools(String baseDir, Supplier<String> alternativeDirGetter)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, boolean forceAlternativeNode)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, String nodeVersion, URI nodeDownloadRoot)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, String nodeVersion, URI nodeDownloadRoot, boolean forceAlternativeNode)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location. 
- 
Method Summary
All Methods Modifier and Type Method and Description StringforceAlternativeNodeExecutable()Locate
nodeexecutable from the alternative directory given.StringgetNodeExecutable()Locate
nodeexecutable.List<String>getNpmExecutable()Locate
npmexecutable.List<String>getPnpmExecutable()Locate
pnpmexecutable.protected List<ProxyConfig.Proxy>getProxies()Read list of configured proxies in order from system properties, .npmrc file in the project root folder, .npmrc file in user root folder and system environment variables.
protected StringinstallNode(String nodeVersion, URI downloadRoot)Install node and npm.
voidvalidateNodeAndNpmVersion()Validate that the found node and npm versions are new enough.
 
 - 
 
- 
- 
Field Detail
- 
DEFAULT_NODE_VERSION
public static final String DEFAULT_NODE_VERSIONSee Also:
 
- 
DEFAULT_PNPM_VERSION
public static final String DEFAULT_PNPM_VERSIONSee Also:
 
- 
INSTALL_NODE_LOCALLY
public static final String INSTALL_NODE_LOCALLYSee Also:
 
 - 
 
- 
Constructor Detail
- 
FrontendTools
public FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, boolean forceAlternativeNode)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.If
alternativeDirisnulltools won't be installed.Parameters:
baseDir- the base directory to locate the tools, notnullalternativeDirGetter- the getter for a directory where tools will be installed if they are not found globally or in thebaseDir, may benullforceAlternativeNode- force usage of node executable from alternative directory 
- 
FrontendTools
public FrontendTools(String baseDir, Supplier<String> alternativeDirGetter)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.If
alternativeDirisnulltools won't be installed.Parameters:
baseDir- the base directory to locate the tools, notnullalternativeDirGetter- the getter for a directory where tools will be installed if they are not found globally or in thebaseDir, may benull 
- 
FrontendTools
public FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, String nodeVersion, URI nodeDownloadRoot, boolean forceAlternativeNode)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.If
alternativeDirisnulltools won't be installed.Parameters:
baseDir- the base directory to locate the tools, notnullalternativeDirGetter- the getter for a directory where tools will be installed if they are not found globally or in thebaseDir, may benullnodeVersion- The node.js version to be used when node.js is installed automatically by Vaadin, for example"v14.15.4". Use "v14.15.4" by default.nodeDownloadRoot- Download node.js from this URL. Handy in heavily firewalled corporate environments where the node.js download can be provided from an intranet mirror. UseNodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOTby default.forceAlternativeNode- force usage of node executable from alternative directory 
- 
FrontendTools
public FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, String nodeVersion, URI nodeDownloadRoot)Creates an instance of the class using the
baseDiras a base directory to locate the tools and the directory returned by thealternativeDirGetteras a directory to install tools if they are not found and use it as an alternative tools location.If
alternativeDirisnulltools won't be installed.Parameters:
baseDir- the base directory to locate the tools, notnullalternativeDirGetter- the getter for a directory where tools will be installed if they are not found globally or in thebaseDir, may benullnodeVersion- The node.js version to be used when node.js is installed automatically by Vaadin, for example"v14.15.4". Use "v14.15.4" by default.nodeDownloadRoot- Download node.js from this URL. Handy in heavily firewalled corporate environments where the node.js download can be provided from an intranet mirror. UseNodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOTby default. 
 - 
 
- 
Method Detail
- 
getNodeExecutable
public String getNodeExecutable()Locate
nodeexecutable.Returns:
the full path to the executable
 
- 
forceAlternativeNodeExecutable
public String forceAlternativeNodeExecutable()Locate
nodeexecutable from the alternative directory given.The difference between
getNodeExecutable()and this method in a search algorithm:getNodeExecutable()first searches executable in the base/alternative directory and fallbacks to the globally installed if it's not found there. TheforceAlternativeNodeExecutable()doesn't search for globally installed executable. It tries to find it in the installation directory and if it's not found it downloads and installs it there.Returns:
the full path to the executable
See Also:
 
- 
getNpmExecutable
public List<String> getNpmExecutable()Locate
npmexecutable.Returns:
the list of all commands in sequence that need to be executed to have npm running
 
- 
getPnpmExecutable
public List<String> getPnpmExecutable()Locate
pnpmexecutable.In case pnpm is not available it will be installed.
Returns:
the list of all commands in sequence that need to be executed to have pnpm running
 
- 
validateNodeAndNpmVersion
public void validateNodeAndNpmVersion()Validate that the found node and npm versions are new enough. Throws an exception with a descriptive message if a version is too old.
 
- 
installNode
protected String installNode(String nodeVersion, URI downloadRoot)Install node and npm.
Parameters:
nodeVersion- node version to installdownloadRoot- optional download root for downloading node. May be a filesystem file or a URL seeNodeInstaller.setNodeDownloadRoot(URI).Returns:
node installation path
 
- 
getProxies
protected List<ProxyConfig.Proxy> getProxies()Read list of configured proxies in order from system properties, .npmrc file in the project root folder, .npmrc file in user root folder and system environment variables.
Returns:
list of configured proxies
 
 - 
 
 -