public class FrontendTools extends Object
WARNING: This class is intended for internal usage only. May be renamed or removed in a future release.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_NODE_VERSION
This is the version that is installed if there is no node installed or
the installed version is older than
SUPPORTED_NODE_VERSION , i.e. |
static String |
DEFAULT_PNPM_VERSION |
static String |
INSTALL_NODE_LOCALLY |
static int |
SUPPORTED_PNPM_MAJOR_VERSION |
static int |
SUPPORTED_PNPM_MINOR_VERSION |
Constructor and Description |
---|
FrontendTools(String baseDir,
Supplier<String> alternativeDirGetter)
Creates an instance of the class using the
baseDir as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter as 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
baseDir as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter as 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
baseDir as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter as 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
baseDir as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter as a directory to install tools if they are
not found and use it as an alternative tools location. |
Modifier and Type | Method and Description |
---|---|
String |
forceAlternativeNodeExecutable()
Locate
node executable from the alternative directory given. |
List<String> |
getBowerExecutable()
Locate
bower executable. |
String |
getNodeExecutable()
Locate
node executable. |
FrontendVersion |
getNodeVersion()
Gets the version of the node executable.
|
List<String> |
getNpmExecutable()
Locate
npm executable. |
List<String> |
getPnpmExecutable()
Locate
pnpm executable. |
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.
|
Map<String,String> |
getWebpackNodeEnvironment()
Returns flags required to pass to Node for Webpack to function.
|
protected String |
installNode(String nodeVersion,
URI downloadRoot)
Install node and npm.
|
void |
validateNodeAndNpmVersion()
Validate that the found node and npm versions are new enough.
|
public static final String DEFAULT_NODE_VERSION
SUPPORTED_NODE_VERSION
, i.e.
..public static final String DEFAULT_PNPM_VERSION
public static final String INSTALL_NODE_LOCALLY
public static final int SUPPORTED_PNPM_MAJOR_VERSION
public static final int SUPPORTED_PNPM_MINOR_VERSION
public FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, boolean forceAlternativeNode)
baseDir
as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter
as a directory to install tools if they are
not found and use it as an alternative tools location.
If alternativeDir
is null
tools won't be installed.
baseDir
- the base directory to locate the tools, not null
alternativeDirGetter
- the getter for a directory where tools will be installed if
they are not found globally or in the baseDir
, may be
null
forceAlternativeNode
- force usage of node executable from alternative directorypublic FrontendTools(String baseDir, Supplier<String> alternativeDirGetter)
baseDir
as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter
as a directory to install tools if they are
not found and use it as an alternative tools location.
If alternativeDir
is null
tools won't be installed.
baseDir
- the base directory to locate the tools, not null
alternativeDirGetter
- the getter for a directory where tools will be installed if
they are not found globally or in the baseDir
, may be
null
public FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, String nodeVersion, URI nodeDownloadRoot, boolean forceAlternativeNode)
baseDir
as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter
as a directory to install tools if they are
not found and use it as an alternative tools location.
If alternativeDir
is null
tools won't be installed.
baseDir
- the base directory to locate the tools, not null
alternativeDirGetter
- the getter for a directory where tools will be installed if
they are not found globally or in the baseDir
, may be
null
nodeVersion
- The node.js version to be used when node.js is installed
automatically by Vaadin, for example "v14.15.4"
.
Use "v14.21.1" 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. Use
NodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOT
by default.forceAlternativeNode
- force usage of node executable from alternative directorypublic FrontendTools(String baseDir, Supplier<String> alternativeDirGetter, String nodeVersion, URI nodeDownloadRoot)
baseDir
as a base
directory to locate the tools and the directory returned by the
alternativeDirGetter
as a directory to install tools if they are
not found and use it as an alternative tools location.
If alternativeDir
is null
tools won't be installed.
baseDir
- the base directory to locate the tools, not null
alternativeDirGetter
- the getter for a directory where tools will be installed if
they are not found globally or in the baseDir
, may be
null
nodeVersion
- The node.js version to be used when node.js is installed
automatically by Vaadin, for example "v14.15.4"
.
Use "v14.21.1" 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. Use
NodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOT
by default.public String getNodeExecutable()
node
executable.public String forceAlternativeNodeExecutable()
node
executable 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. The forceAlternativeNodeExecutable()
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.
getNodeExecutable()
public List<String> getNpmExecutable()
npm
executable.public List<String> getPnpmExecutable()
pnpm
executable.
In case pnpm is not available it will be installed.
public void validateNodeAndNpmVersion()
public List<String> getBowerExecutable()
bower
executable.
An empty list is returned if bower is not found
public FrontendVersion getNodeVersion() throws FrontendUtils.UnknownVersionException
protected String installNode(String nodeVersion, URI downloadRoot)
nodeVersion
- node version to installdownloadRoot
- optional download root for downloading node. May be a
filesystem file or a URL see
NodeInstaller.setNodeDownloadRoot(URI)
.protected List<ProxyConfig.Proxy> getProxies()
public Map<String,String> getWebpackNodeEnvironment()
Copyright © 2023. All rights reserved.