private void installNode(Config conf, String version, ProxyConfig proxy, FrontendPluginFactory factory) throws InstallationException { NodeInstaller installer = factory.getNodeInstaller(proxy) .setNodeVersion(version) .setNodeDownloadRoot(conf.getString("node.downloadRoot")); installNpm(installer); installer.install(); }
@Override protected void installNpm(NodeInstaller node) { node.setNpmVersion(npmVersion); }
private void downloadFileIfMissing(String downloadUrl, File destination, String userName, String password) throws DownloadException { if (!destination.exists()) { downloadFile(downloadUrl, destination, userName, password); } }
@Override public void execute(FrontendPluginFactory factory) throws InstallationException { ProxyConfig proxyConfig = MojoUtils.getProxyConfig(this.session, this.decrypter); Server server = MojoUtils.decryptServer(this.serverId, this.session, this.decrypter); if (null != server) { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).setPassword(server.getPassword()) .setUserName(server.getUsername()).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).setUserName(server.getUsername()) .setPassword(server.getPassword()).install(); } else { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).install(); } }
String classifier = this.config.getPlatform().getNodeClassifier(); File tmpDirectory = getTempDirectory(); downloadFileIfMissing(downloadUrl, archive, this.userName, this.password); extractFile(archive, tmpDirectory); "Could not find the downloaded Node.js binary in " + nodeBinary); } else { File destinationDirectory = getInstallDirectory(); FileUtils.copyDirectory(tmpNodeModulesDir, nodeModulesDirectory); deleteTempDirectory(tmpDirectory);
private void installNodeForWindows() throws InstallationException { final String downloadUrl = this.nodeDownloadRoot + this.config.getPlatform().getNodeDownloadFilename(this.nodeVersion, false); try { File destinationDirectory = getInstallDirectory(); File destination = new File(destinationDirectory, "node.exe"); String classifier = this.config.getPlatform().getNodeClassifier(); CacheDescriptor cacheDescriptor = new CacheDescriptor("node", this.nodeVersion, classifier, "exe"); File binary = this.config.getCacheResolver().resolve(cacheDescriptor); downloadFileIfMissing(downloadUrl, binary, this.userName, this.password); this.logger.info("Copying node binary from {} to {}", binary, destination); FileUtils.copyFile(binary, destination); this.logger.info("Installed node locally."); } catch (DownloadException e) { throw new InstallationException("Could not download Node.js from: " + downloadUrl, e); } catch (IOException e) { throw new InstallationException("Could not install Node.js", e); } }
public NodeInstaller getNodeInstaller(ProxyConfig proxy) { return new NodeInstaller(getInstallConfig(), new DefaultArchiveExtractor(), new DefaultFileDownloader(proxy)); }
if (null != server) { factory.getNodeInstaller(proxyConfig) .setNodeVersion(nodeVersion) .setNodeDownloadRoot(nodeDownloadRoot) .setNpmVersion(npmVersion) .setUserName(server.getUsername()) .setPassword(server.getPassword()) .install(); factory.getNPMInstaller(proxyConfig) .setNodeVersion(nodeVersion) } else { factory.getNodeInstaller(proxyConfig) .setNodeVersion(nodeVersion) .setNodeDownloadRoot(nodeDownloadRoot) .setNpmVersion(npmVersion) .install(); factory.getNPMInstaller(proxyConfig) .setNodeVersion(this.nodeVersion)
String classifier = this.config.getPlatform().getNodeClassifier(); File tmpDirectory = getTempDirectory(); downloadFileIfMissing(downloadUrl, archive, this.userName, this.password); extractFile(archive, tmpDirectory); "Could not find the downloaded Node.js binary in " + nodeBinary); } else { File destinationDirectory = getInstallDirectory(); if (npmProvided()) { File tmpNodeModulesDir = new File(tmpDirectory, longNodeFilename + File.separator + "lib" + File.separator + "node_modules"); deleteTempDirectory(tmpDirectory);
@Override public void execute(FrontendPluginFactory factory) throws InstallationException { ProxyConfig proxyConfig = MojoUtils.getProxyConfig(this.session, this.decrypter); Server server = MojoUtils.decryptServer(this.serverId, this.session, this.decrypter); if (null != server) { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).setPassword(server.getPassword()) .setUserName(server.getUsername()).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).setUserName(server.getUsername()) .setPassword(server.getPassword()).install(); } else { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).install(); } }
private GulpRunner downloadNode(File workingDirectory, ProxyConfig proxyConfig, String nodeVersion) { FrontendPluginFactory factory = new FrontendPluginFactory( workingDirectory, workingDirectory); try { factory.getNodeInstaller(proxyConfig).setNodeVersion(nodeVersion) .setNodeDownloadRoot( NodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOT) .install(); } catch (InstallationException e) { throw new IllegalStateException("Failed to download node", e); } return factory.getGulpRunner(); }
if (null != server) { factory.getNodeInstaller(proxyConfig) .setNodeVersion(nodeVersion) .setNodeDownloadRoot(nodeDownloadRoot) .setNpmVersion(npmVersion) .setUserName(server.getUsername()) .setPassword(server.getPassword()) .install(); factory.getNPMInstaller(proxyConfig) .setNodeVersion(nodeVersion) } else { factory.getNodeInstaller(proxyConfig) .setNodeVersion(nodeVersion) .setNodeDownloadRoot(nodeDownloadRoot) .setNpmVersion(npmVersion) .install(); factory.getNPMInstaller(proxyConfig) .setNodeVersion(this.nodeVersion)