Skip to content

Commit

Permalink
minor tweaks based on CR
Browse files Browse the repository at this point in the history
  • Loading branch information
flipatlas committed Dec 9, 2024
1 parent 0b29e57 commit c965cd2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 32 deletions.
1 change: 0 additions & 1 deletion FORK_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- [DCA11Y-1145]: Automatic version detection of the Node version from `.tool-versions`, `.node-version`, and `.nvmrc` files
- [DCA11Y-1145]: The configuration property `nodeVersionFile` to specify a file that can be read in `install-node-and-npm`, `install-node-and-pnpm`, and `install-node-and-yarn`


### Changed

- [DCA11Y-1145]: Now tolerant of `v` missing or present at the start of a Node version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
def p = "bash $basedir/install-asdf.sh".execute()
p.waitFor()
println p.text
p.waitForProcessOutput(System.out, System.err)
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void install(FrontendPluginFactory factory, String validNodeVersion, Str
packageManagerWork =
factory.getNPMInstaller(proxyConfig)
.setNodeVersion(validNodeVersion)
.setNpmVersion(npmVersion)
.setNpmVersion(this.npmVersion)
.setNpmDownloadRoot(npmDownloadRoot)
.install();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public final class FrontendPluginFactory {
private String nodeVersion;

public FrontendPluginFactory(File workingDirectory, File installDirectory){
this(workingDirectory, installDirectory, getDefaultCacheResolver(installDirectory));
}

public FrontendPluginFactory(File workingDirectory, File installDirectory, CacheResolver cacheResolver){
this(workingDirectory, installDirectory, cacheResolver, false);
this(workingDirectory, installDirectory, getDefaultCacheResolver(installDirectory), false);
}

public FrontendPluginFactory(File workingDirectory, File installDirectory, CacheResolver cacheResolver, boolean useNodeVersionManager){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Map;

import com.github.eirslett.maven.plugins.frontend.lib.version.manager.VersionManagerCache;
import com.github.eirslett.maven.plugins.frontend.lib.version.manager.VersionManagerRunner;

import static com.github.eirslett.maven.plugins.frontend.lib.AtlassianDevMetricsInstallationWork.CACHED;
import static com.github.eirslett.maven.plugins.frontend.lib.AtlassianDevMetricsInstallationWork.DOWNLOADED;
import static com.github.eirslett.maven.plugins.frontend.lib.AtlassianDevMetricsInstallationWork.INSTALLED;
Expand All @@ -35,7 +35,7 @@ public class NodeInstaller {

private final Logger logger;

private final InstallConfig installConfig;
private final InstallConfig config;

private final VersionManagerCache versionManagerCache;

Expand All @@ -45,7 +45,7 @@ public class NodeInstaller {

NodeInstaller(InstallConfig config, VersionManagerCache versionManagerCache, ArchiveExtractor archiveExtractor, FileDownloader fileDownloader) {
this.logger = LoggerFactory.getLogger(getClass());
this.installConfig = config;
this.config = config;
this.archiveExtractor = archiveExtractor;
this.fileDownloader = fileDownloader;
this.versionManagerCache = versionManagerCache;
Expand Down Expand Up @@ -100,7 +100,7 @@ public AtlassianDevMetricsInstallationWork install() throws InstallationExceptio
// use static lock object for a synchronized block
synchronized (LOCK) {
if (this.nodeDownloadRoot == null || this.nodeDownloadRoot.isEmpty()) {
this.nodeDownloadRoot = this.installConfig.getPlatform().getNodeDownloadRoot();
this.nodeDownloadRoot = this.config.getPlatform().getNodeDownloadRoot();
}

// try to install the standard way
Expand All @@ -110,7 +110,7 @@ public AtlassianDevMetricsInstallationWork install() throws InstallationExceptio
if (!this.nodeVersion.startsWith("v")) {
this.logger.warn("Node version does not start with naming convention 'v'.");
}
if (this.installConfig.getPlatform().isWindows()) {
if (this.config.getPlatform().isWindows()) {
if (npmProvided()) {
work = installNodeWithNpmForWindows();
} else {
Expand All @@ -128,7 +128,7 @@ public AtlassianDevMetricsInstallationWork install() throws InstallationExceptio

private boolean nodeIsAlreadyInstalled() {
try {
NodeExecutorConfig executorConfig = new InstallNodeExecutorConfig(this.installConfig, versionManagerCache);
NodeExecutorConfig executorConfig = new InstallNodeExecutorConfig(this.config, versionManagerCache);
File nodeFile = executorConfig.getNodePath();
if (nodeFile.exists()) {
final String version =
Expand All @@ -154,17 +154,17 @@ private boolean nodeIsAlreadyInstalled() {
private AtlassianDevMetricsInstallationWork installNodeDefault() throws InstallationException {
try {
final String longNodeFilename =
this.installConfig.getPlatform().getLongNodeFilename(this.nodeVersion, false);
this.config.getPlatform().getLongNodeFilename(this.nodeVersion, false);
String downloadUrl = this.nodeDownloadRoot
+ this.installConfig.getPlatform().getNodeDownloadFilename(this.nodeVersion, false);
String classifier = this.installConfig.getPlatform().getNodeClassifier(this.nodeVersion);
+ this.config.getPlatform().getNodeDownloadFilename(this.nodeVersion, false);
String classifier = this.config.getPlatform().getNodeClassifier(this.nodeVersion);

File tmpDirectory = getTempDirectory();

CacheDescriptor cacheDescriptor = new CacheDescriptor("node", this.nodeVersion, classifier,
this.installConfig.getPlatform().getArchiveExtension());
this.config.getPlatform().getArchiveExtension());

File archive = this.installConfig.getCacheResolver().resolve(cacheDescriptor);
File archive = this.config.getCacheResolver().resolve(cacheDescriptor);

AtlassianDevMetricsInstallationWork work =
downloadFileIfMissing(downloadUrl, archive, this.userName, this.password, this.httpHeaders);
Expand Down Expand Up @@ -255,17 +255,17 @@ private AtlassianDevMetricsInstallationWork installNodeDefault() throws Installa
private AtlassianDevMetricsInstallationWork installNodeWithNpmForWindows() throws InstallationException {
try {
final String longNodeFilename =
this.installConfig.getPlatform().getLongNodeFilename(this.nodeVersion, true);
this.config.getPlatform().getLongNodeFilename(this.nodeVersion, true);
String downloadUrl = this.nodeDownloadRoot
+ this.installConfig.getPlatform().getNodeDownloadFilename(this.nodeVersion, true);
String classifier = this.installConfig.getPlatform().getNodeClassifier(this.nodeVersion);
+ this.config.getPlatform().getNodeDownloadFilename(this.nodeVersion, true);
String classifier = this.config.getPlatform().getNodeClassifier(this.nodeVersion);

File tmpDirectory = getTempDirectory();

CacheDescriptor cacheDescriptor = new CacheDescriptor("node", this.nodeVersion, classifier,
this.installConfig.getPlatform().getArchiveExtension());
this.config.getPlatform().getArchiveExtension());

File archive = this.installConfig.getCacheResolver().resolve(cacheDescriptor);
File archive = this.config.getCacheResolver().resolve(cacheDescriptor);

AtlassianDevMetricsInstallationWork work =
downloadFileIfMissing(downloadUrl, archive, this.userName, this.password, this.httpHeaders);
Expand Down Expand Up @@ -312,18 +312,18 @@ private AtlassianDevMetricsInstallationWork installNodeWithNpmForWindows() throw

private AtlassianDevMetricsInstallationWork installNodeForWindows() throws InstallationException {
final String downloadUrl = this.nodeDownloadRoot
+ this.installConfig.getPlatform().getNodeDownloadFilename(this.nodeVersion, false);
+ this.config.getPlatform().getNodeDownloadFilename(this.nodeVersion, false);
try {
File destinationDirectory = getInstallDirectory();

File destination = new File(destinationDirectory, "node.exe");

String classifier = this.installConfig.getPlatform().getNodeClassifier(this.nodeVersion);
String classifier = this.config.getPlatform().getNodeClassifier(this.nodeVersion);

CacheDescriptor cacheDescriptor =
new CacheDescriptor("node", this.nodeVersion, classifier, "exe");

File binary = this.installConfig.getCacheResolver().resolve(cacheDescriptor);
File binary = this.config.getCacheResolver().resolve(cacheDescriptor);

AtlassianDevMetricsInstallationWork work =
downloadFileIfMissing(downloadUrl, binary, this.userName, this.password, this.httpHeaders);
Expand All @@ -350,7 +350,7 @@ private File getTempDirectory() {
}

private File getInstallDirectory() {
File installDirectory= new File(this.installConfig.getInstallDirectory(), INSTALL_PATH);
File installDirectory= new File(this.config.getInstallDirectory(), INSTALL_PATH);

if (!installDirectory.exists()) {
this.logger.debug("Creating install directory {}", installDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public void populateCacheForVersion(String nodeVersion) {
this.versionManagerCache.setNpmExecutable(versionManagerClient.getNpmExecutable(nodeVersion));

if (versionManagerCache.isNodeAvailable()) {
logger.info("Using {} version manager", versionManagerCache.getVersionManagerType());
logger.info("Requested node version {} is already installed", nodeVersion);
logger.info("Using {} version manager. Requested node version {} is already installed", versionManagerCache.getVersionManagerType(), nodeVersion);
} else {
logger.warn("Requested node version {} is not installed in version manager", nodeVersion);
logger.info("Requested node version {} is not installed in version manager", nodeVersion);
}
}
}

0 comments on commit c965cd2

Please sign in to comment.