Skip to content

Commit c570b0a

Browse files
committed
Add support for downloading Windows NodeJS binaries as ZIP including NPM which is available since Node 6.3.0.
1 parent 16977e5 commit c570b0a

File tree

5 files changed

+44
-37
lines changed

5 files changed

+44
-37
lines changed

changes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
2424
<body>
2525

26+
<release version="1.2.0" date="not released">
27+
<action type="add" dev="sseifert">
28+
Add support for downloading Windows NodeJS binaries as ZIP including NPM which is available since Node 6.3.0.
29+
</action>
30+
</release>
31+
2632
<release version="1.1.0" date="2016-03-22">
2733
<action type="update" dev="sseifert" issue="WDEVOP-1">
2834
Binary File Structre changed in NPM Versions > 0.x and support for SHA-256 checksums.

maven-nodejs-proxy/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ npmBinariesUrl: "/npm/npm-${version}.${type}"
2424
nodeJsChecksumUrl: "/v${version}/SHASUMS256.txt"
2525

2626
# Sample versions for index page
27-
nodeJsSampleVersion: 4.4.0
27+
nodeJsSampleVersion: 10.15.0
2828
npmSampleVersion: 1.4.9
2929

3030
# HTTP Client settings

maven-nodejs-proxy/src/main/java/io/wcm/devops/maven/nodejsproxy/resource/IndexPageBuilder.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ public final class IndexPageBuilder {
3030

3131
private static final String[] EXAMPLE_URLS = new String[] {
3232
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}.pom",
33-
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-windows-x86.exe",
34-
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-windows-x64.exe",
35-
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-linux-x86.tar.gz",
33+
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-win-x86.zip",
34+
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-win-x64.zip",
3635
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-linux-x64.tar.gz",
3736
"${groupIdPath}/${nodeJsArtifactId}/${nodeJsSampleVersion}/${nodeJsArtifactId}-${nodeJsSampleVersion}-darwin-x64.tar.gz",
3837
"${groupIdPath}/${npmArtifactId}/${npmSampleVersion}/${npmArtifactId}-${npmSampleVersion}.pom",
@@ -61,28 +60,28 @@ public static String build(MavenProxyConfiguration config) {
6160
String serviceVersion = IndexPageBuilder.class.getPackage().getImplementationVersion();
6261

6362
return "<!DOCTYPE html>\n<html>"
64-
+ "<head>"
65-
+ "<title>Maven NodeJS Proxy</title>"
66-
+ "<style>body { font-family: sans-serif; }</style>"
67-
+ "</head>"
68-
+ "<body>"
69-
+ "<h1>Maven NodeJS Proxy</h1>"
70-
+ "<p>This is a Maven Artifact Proxy for NodeJS binaries located at: "
71-
+ "<a href=\"" + config.getNodeJsBinariesRootUrl() + "\">" + config.getNodeJsBinariesRootUrl() + "</a></p>"
72-
+ "<p>Every call to this Maven repository is routed directly to the NodeJS distribution server.</p>"
73-
+ "<p><strong>Please never use this Maven repository directly in your maven builds, use it only via a Repository Manager "
74-
+ "which caches the resolved artifacts.</strong></p>"
75-
+ "<p>If you want to setup your own proxy get the source code: "
76-
+ "<a href=\"https://github.com/wcm-io-devops/maven-nodejs-proxy\">https://github.com/wcm-io-devops/maven-nodejs-proxy</a></p>"
77-
+ "<hr/>"
78-
+ "<p>Example artifacts:</p>"
79-
+ "<ul>"
80-
+ exampleUrlsMarkup
81-
+ "</ul>"
82-
+ "<p>For all files SHA1 checksums are supported (.sha1 suffix). MD5 checksums are not supported.</p>"
83-
+ (serviceVersion != null ? "<hr/><p>Version " + IndexPageBuilder.class.getPackage().getImplementationVersion() + "</p>" : "")
84-
+ "</body>"
85-
+ "</html>";
63+
+ "<head>"
64+
+ "<title>Maven NodeJS Proxy</title>"
65+
+ "<style>body { font-family: sans-serif; }</style>"
66+
+ "</head>"
67+
+ "<body>"
68+
+ "<h1>Maven NodeJS Proxy</h1>"
69+
+ "<p>This is a Maven Artifact Proxy for NodeJS binaries located at: "
70+
+ "<a href=\"" + config.getNodeJsBinariesRootUrl() + "\">" + config.getNodeJsBinariesRootUrl() + "</a></p>"
71+
+ "<p>Every call to this Maven repository is routed directly to the NodeJS distribution server.</p>"
72+
+ "<p><strong>Please never use this Maven repository directly in your maven builds, use it only via a Repository Manager "
73+
+ "which caches the resolved artifacts.</strong></p>"
74+
+ "<p>If you want to setup your own proxy get the source code: "
75+
+ "<a href=\"https://github.com/wcm-io-devops/maven-nodejs-proxy\">https://github.com/wcm-io-devops/maven-nodejs-proxy</a></p>"
76+
+ "<hr/>"
77+
+ "<p>Example artifacts:</p>"
78+
+ "<ul>"
79+
+ exampleUrlsMarkup
80+
+ "</ul>"
81+
+ "<p>For all files SHA1 checksums are supported (.sha1 suffix). MD5 checksums are not supported.</p>"
82+
+ (serviceVersion != null ? "<hr/><p>Version " + IndexPageBuilder.class.getPackage().getImplementationVersion() + "</p>" : "")
83+
+ "</body>"
84+
+ "</html>";
8685
}
8786

8887
}

maven-nodejs-proxy/src/main/java/io/wcm/devops/maven/nodejsproxy/resource/MavenProxyResource.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public Response getBinary(
206206
}
207207

208208
String url = buildBinaryUrl(artifactType, version, null, null, StringUtils.removeEnd(type, ".sha1"));
209-
return getBinary(url, version, getChecksum, null);
209+
return getBinary(url, getChecksum, null);
210210
}
211211

212212
private Response getBinaryWithChecksumValidation(String url, String version, boolean getChecksum) throws IOException {
@@ -222,10 +222,10 @@ private Response getBinaryWithChecksumValidation(String url, String version, boo
222222
return Response.status(Response.Status.NOT_FOUND).build();
223223
}
224224

225-
return getBinary(url, version, getChecksum, checksum);
225+
return getBinary(url, getChecksum, checksum);
226226
}
227227

228-
private Response getBinary(String url, String version, boolean getChecksum, String expectedChecksum) throws IOException {
228+
private Response getBinary(String url, boolean getChecksum, String expectedChecksum) throws IOException {
229229
log.info("Proxy file: {}", url);
230230
HttpGet get = new HttpGet(url);
231231
HttpResponse response = httpClient.execute(get);
@@ -335,7 +335,7 @@ private String buildBinaryUrl(ArtifactType artifactType, String version, String
335335
String url;
336336
switch (artifactType) {
337337
case NODEJS:
338-
if (StringUtils.equals(os, "windows")) {
338+
if (StringUtils.equals(os, "windows") && StringUtils.equals(type, "exe")) {
339339
if (isVersion4Up(version)) {
340340
url = config.getNodeJsBinariesUrlWindows();
341341
}
@@ -358,7 +358,7 @@ else if (StringUtils.equals(arch, "x86")) {
358358
}
359359
url = config.getNodeJsBinariesRootUrl() + url;
360360
url = StringUtils.replace(url, "${version}", StringUtils.defaultString(version));
361-
url = StringUtils.replace(url, "${os}", StringUtils.defaultString(os));
361+
url = StringUtils.replace(url, "${os}", StringUtils.defaultString(StringUtils.replace(os, "windows", "win")));
362362
url = StringUtils.replace(url, "${arch}", StringUtils.defaultString(arch));
363363
url = StringUtils.replace(url, "${type}", StringUtils.defaultString(type));
364364
return url;

maven-nodejs-proxy/src/test/java/io/wcm/devops/maven/nodejsproxy/resource/MavenProxyResourceTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,20 @@
3636

3737
import io.dropwizard.testing.junit.ResourceTestRule;
3838

39-
4039
public class MavenProxyResourceTest {
4140

4241
// test with the following NodeJS and NPM versions
4342
private static final String[] NODEJS_VERSIONS = {
44-
"0.12.0",
45-
"4.4.0"
43+
"6.3.0",
44+
"10.15.0"
4645
};
4746
private static final String[] NODEJS_TARGETS = {
47+
"-windows-x86.zip",
48+
"-windows-x64.zip",
49+
"-win-x86.zip",
50+
"-win-x64.zip",
4851
"-windows-x86.exe",
4952
"-windows-x64.exe",
50-
"-linux-x86.tar.gz",
5153
"-linux-x64.tar.gz",
5254
"-darwin-x64.tar.gz"
5355
};
@@ -60,8 +62,8 @@ public class MavenProxyResourceTest {
6062

6163
@Rule
6264
public ResourceTestRule context = new ResourceTestRule.Builder()
63-
.addResource(new MavenProxyResource(TestContext.getConfiguration(), TestContext.getHttpClient()))
64-
.build();
65+
.addResource(new MavenProxyResource(TestContext.getConfiguration(), TestContext.getHttpClient()))
66+
.build();
6567

6668
@Test
6769
public void testGetIndex() {

0 commit comments

Comments
 (0)