Skip to content

Commit 75b72d4

Browse files
committed
change groupId and refactor index page building
1 parent b0604a8 commit 75b72d4

File tree

3 files changed

+83
-37
lines changed

3 files changed

+83
-37
lines changed

maven-nodejs-proxy/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Group Id to publish artifacts to
2-
groupId: io.wcm.maven.proxy.nodejs
2+
groupId: org.nodejs.dist
33

44
# Artifact Id to publish NodeJS binaries
55
nodeJsArtifactId: nodejs-binaries
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* #%L
3+
* wcm.io
4+
* %%
5+
* Copyright (C) 2015 wcm.io
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package io.wcm.devops.maven.nodejsproxy.resource;
21+
22+
import io.wcm.devops.maven.nodejsproxy.MavenProxyConfiguration;
23+
24+
import org.apache.commons.lang3.StringUtils;
25+
26+
/**
27+
* Builds HTML index page
28+
*/
29+
public final class IndexPageBuilder {
30+
31+
private static final String[] EXAMPLE_URLS = new String[] {
32+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0.pom",
33+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0-windows-x86.exe",
34+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0-windows-x64.exe",
35+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0-linux-x86.tar.gz",
36+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0-linux-x64.tar.gz",
37+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0-darwin-x86.tar.gz",
38+
"${groupIdPath}/${nodeJsArtifactId}/0.12.0/${nodeJsArtifactId}-0.12.0-darwin-x64.tar.gz",
39+
"${groupIdPath}/${npmArtifactId}/1.4.9/${npmArtifactId}-1.4.9.pom",
40+
"${groupIdPath}/${npmArtifactId}/1.4.9/${npmArtifactId}-1.4.9.tgz"
41+
};
42+
43+
private IndexPageBuilder() {
44+
// static methods only
45+
}
46+
47+
/**
48+
* Build HTML index page
49+
*/
50+
public static String build(MavenProxyConfiguration config) {
51+
StringBuilder exampleUrlsMarkup = new StringBuilder();
52+
for (String exampleUrl : EXAMPLE_URLS) {
53+
String url = exampleUrl;
54+
url = StringUtils.replace(url, "${groupIdPath}", StringUtils.replace(config.getGroupId(), ".", "/"));
55+
url = StringUtils.replace(url, "${nodeJsArtifactId}", config.getNodeJsArtifactId());
56+
url = StringUtils.replace(url, "${npmArtifactId}", config.getNpmArtifactId());
57+
exampleUrlsMarkup.append("<li><a href=\"").append(url).append("\">").append(url).append("</a></li>");
58+
59+
}
60+
return "<html>"
61+
+ "<head><title>Maven NodeJS Proxy</title></head>"
62+
+ "<body>"
63+
+ "<h1>Maven NodeJS Proxy</h1>"
64+
+ "<p>This is a Maven Artifact Proxy for NodeJS binaries located at: "
65+
+ "<a href=\"" + config.getNodeJsBinariesRootUrl() + "\">" + config.getNodeJsBinariesRootUrl() + "</a></p>"
66+
+ "<p>Every call to this repository is routed directly to this URL.</p>"
67+
+ "<p><strong>Please never use this Maven repository directly in your maven builds, but only via an Repository Manager "
68+
+ "which caches the resolved artifacts.</strong></p>"
69+
+ "<p>If you want to setup your own proxy get the source code:"
70+
+ "<a href=\"https://github.com/wcm-io-devops/maven-nodejs-proxy\">https://github.com/wcm-io-devops/maven-nodejs-proxy</a></p>"
71+
+ "<hr/>"
72+
+ "<p>Examples:</p>"
73+
+ "<ul>"
74+
+ exampleUrlsMarkup
75+
+ "</ul>"
76+
+ "<p>For all files SHA1 checksums are supported (.sha1 suffix). MD5 checksums are not supported.</p>"
77+
+ "</body>"
78+
+ "</html>";
79+
}
80+
81+
}

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

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -70,42 +70,7 @@ public MavenProxyResource(MavenProxyConfiguration config) {
7070
@Timed
7171
@Produces(MediaType.TEXT_HTML)
7272
public String getIndex() {
73-
String[] exampleUrls = new String[] {
74-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0.pom",
75-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0-windows-x86.exe",
76-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0-windows-x64.exe",
77-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0-linux-x86.tar.gz",
78-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0-linux-x64.tar.gz",
79-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0-darwin-x86.tar.gz",
80-
"/io/wcm/maven/proxy/nodejs/nodejs-binaries/0.12.0/nodejs-binaries-0.12.0-darwin-x64.tar.gz",
81-
"/io/wcm/maven/proxy/nodejs/npm-binaries/1.4.9/npm-binaries-1.4.9.pom",
82-
"/io/wcm/maven/proxy/nodejs/npm-binaries/1.4.9/npm-binaries-1.4.9.tgz"
83-
};
84-
StringBuilder exampleUrlsMarkup = new StringBuilder();
85-
for (String exampleUrl : exampleUrls) {
86-
exampleUrlsMarkup.append("<li><a href=\"").append(exampleUrl).append("\">")
87-
.append(exampleUrl).append("</a></li>");
88-
89-
}
90-
return "<html>"
91-
+ "<head><title>Maven NodeJS Proxy</title></head>"
92-
+ "<body>"
93-
+ "<h1>Maven NodeJS Proxy</h1>"
94-
+ "<p>This is a Maven Artifact Proxy for NodeJS binaries located at: "
95-
+ "<a href=\"" + config.getNodeJsBinariesRootUrl() + "\">" + config.getNodeJsBinariesRootUrl() + "</a></p>"
96-
+ "<p>Every call to this repository is routed directly to this URL.</p>"
97-
+ "<p><strong>Please never use this Maven repository directly in your maven builds, but only via an Repository Manager "
98-
+ "which caches the resolved artifacts.</strong></p>"
99-
+ "<p>If you want to setup your own proxy get the source code:"
100-
+ "<a href=\"https://github.com/wcm-io-devops/maven-nodejs-proxy\">https://github.com/wcm-io-devops/maven-nodejs-proxy</a></p>"
101-
+ "<hr/>"
102-
+ "<p>Examples:</p>"
103-
+ "<ul>"
104-
+ exampleUrlsMarkup
105-
+ "</ul>"
106-
+ "<p>For all files SHA1 checksums are supported (.sha1 suffix). MD5 checksums are not supported.</p>"
107-
+ "</body>"
108-
+ "</html>";
73+
return IndexPageBuilder.build(config);
10974
}
11075

11176
/**

0 commit comments

Comments
 (0)