Skip to content

Commit 26b74ab

Browse files
committed
Following code style recommendations
1 parent 3ebddb0 commit 26b74ab

File tree

5 files changed

+43
-60
lines changed

5 files changed

+43
-60
lines changed

src/backend/maven/Maven.ts

+12-28
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,36 @@ export class MavenAccess {
55
const url = `/maven2/${groupId.replaceAll(".", "/")}/${artifactId
66
}/${version}/${artifactId}-${version}.pom`;
77

8-
const pom = await fetch(url)
8+
return await fetch(url)
99
.then((response) => response.text())
1010
.then((str) => {
1111
const parser = new XMLParser();
1212
return parser.parse(str).project;
1313
})
1414
.catch((reason) => console.error(reason));
15-
return pom;
1615
}
1716

18-
async getArtifact(groupId: string, artifactId: string): Promise<any> {
19-
const url = `/maven2/${groupId.replaceAll(".", "/")}/${artifactId}/`;
20-
21-
const artifacts = await fetch(url)
17+
private async retrieveAndProcessDirectory(url: string): Promise<any> {
18+
return await fetch(url)
2219
.then((response) => response.text())
2320
.then((text) => {
2421
const parser = new DOMParser();
2522
return Array.from(parser.parseFromString(text, "text/html")
26-
.getElementById("contents")
27-
?.querySelectorAll("A")!)
28-
.slice(1).map(a => a.textContent)
29-
.filter(link => link?.endsWith("/"))
30-
.map(link => link?.replace("/", ""));
23+
.getElementById("contents")
24+
?.querySelectorAll("A")!)
25+
.slice(1).map(a => a.textContent)
26+
.filter(link => link?.endsWith("/"))
27+
.map(link => link?.replace("/", ""));
3128
})
3229
.catch((reason) => console.error(reason));
30+
}
3331

34-
return artifacts;
32+
async getArtifact(groupId: string, artifactId: string): Promise<any> {
33+
return this.retrieveAndProcessDirectory(`/maven2/${groupId.replaceAll(".", "/")}/${artifactId}/`);
3534
}
3635

3736
async getGroup(groupId: string): Promise<any> {
38-
const url = `/maven2/${groupId.replaceAll(".", "/")}/`;
39-
40-
const group = await fetch(url)
41-
.then((response) => response.text())
42-
.then((text) => {
43-
const parser = new DOMParser();
44-
return Array.from(parser.parseFromString(text, "text/html")
45-
.getElementById("contents")
46-
?.querySelectorAll("A")!)
47-
.slice(1).map(a => a.textContent)
48-
.filter(link => link?.endsWith("/"))
49-
.map(link => link?.replace("/", ""));
50-
})
51-
.catch((reason) => console.error(reason));
52-
53-
return group;
37+
return this.retrieveAndProcessDirectory(`/maven2/${groupId.replaceAll(".", "/")}/`);
5438
}
5539

5640

src/pages/MavenArtifactVersionView.vue

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
<div v-else class="text-xs line-height-xs">
2020
<table class="text-left">
2121
<tr v-if="pom.name != null">
22-
<th>Name</th>
22+
<th scope="row">Name</th>
2323
<td>{{ pom.name }}</td>
2424
</tr>
2525
<tr v-if="pom.description != null">
26-
<th>Description</th>
26+
<th scope="row">Description</th>
2727
<td>{{ pom.description }}</td>
2828
</tr>
2929
<tr v-if="pom.parent != null">
30-
<th>Parent</th>
30+
<th scope="row">Parent</th>
3131
<td>
3232
<router-link
3333
:to="{
@@ -44,13 +44,13 @@
4444
</td>
4545
</tr>
4646
<tr v-if="pom.url != null">
47-
<th>URL</th>
47+
<th scope="row">URL</th>
4848
<td>
4949
<a :href="pom.url">{{ pom.url }}</a>
5050
</td>
5151
</tr>
5252
<tr v-if="pom.licenses != null && pom.licenses.license != null">
53-
<th>License</th>
53+
<th scope="row">License</th>
5454
<td>
5555
<a :href="pom.licenses.license.url">{{
5656
pom.licenses.license.name
@@ -71,8 +71,8 @@
7171
Dependencies
7272
</caption>
7373
<tr>
74-
<th>Name</th>
75-
<th>Scope</th>
74+
<th scope="col">Name</th>
75+
<th scope="col">Scope</th>
7676
</tr>
7777
<tr v-for="(d, index) in pom.dependencies.dependency" :key="index">
7878
<td>
@@ -98,8 +98,8 @@
9898
Properties
9999
</caption>
100100
<tr>
101-
<th>Key</th>
102-
<th>Value</th>
101+
<th scope="col">Key</th>
102+
<th scope="col">Value</th>
103103
</tr>
104104
<tr v-for="(value, key) in pom.properties" :key="key">
105105
<td>{{ key }}</td>

src/pages/MavenArtifactView.vue

+13-10
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
<div v-if="isLoading">Loading...</div>
1111
<div v-else class="text-xs line-height-xs">
12-
<table class="text-left">
13-
<caption class="text-left font-bold">
14-
Versions
15-
</caption>
12+
<table class="text-left">
13+
<tr>
14+
<th scope="col">Versions</th>
15+
</tr>
1616
<tr v-for="(v, index) in artifact" :key="index">
1717
<td>
1818
<router-link
@@ -24,7 +24,8 @@
2424
version: v,
2525
},
2626
}"
27-
>{{ v }}</router-link>
27+
>{{ v }}</router-link
28+
>
2829
</td>
2930
</tr>
3031
</table>
@@ -64,11 +65,13 @@ export default defineComponent({
6465
}
6566
6667
async function loadArtifact() {
67-
if (groupId.value === undefined ||
68-
artifactId.value === undefined) return;
69-
isLoading.value = true;
70-
artifact.value = await new MavenAccess().getArtifact(groupId.value, artifactId.value);
71-
isLoading.value = false;
68+
if (groupId.value === undefined || artifactId.value === undefined) return;
69+
isLoading.value = true;
70+
artifact.value = await new MavenAccess().getArtifact(
71+
groupId.value,
72+
artifactId.value
73+
);
74+
isLoading.value = false;
7275
}
7376
7477
return { groupId, artifactId, isLoading, artifact };

src/pages/MavenGroupView.vue

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
<template>
2-
<div>
2+
<div>
33
<h2 class="w-full text-delphi-red text-2xl font-semibold font-serif">
44
{{ groupId }}
55
</h2>
66

77
<div v-if="isLoading">Loading...</div>
88
<div v-else class="text-xs line-height-xs">
9-
<table class="text-left">
10-
<caption class="text-left font-bold">
11-
Artifacts
12-
</caption>
9+
<table class="text-left">
10+
<tr>
11+
<th>Artifacts</th>
12+
</tr>
1313
<tr v-for="(a, index) in group" :key="index">
1414
<td>
1515
<router-link
1616
:to="{
1717
name: 'maven-ga',
1818
params: {
1919
groupId: groupId,
20-
artifactId: a
20+
artifactId: a,
2121
},
2222
}"
23-
>{{ a }}</router-link>
23+
>{{ a }}</router-link
24+
>
2425
</td>
2526
</tr>
2627
</table>
@@ -60,9 +61,7 @@ export default defineComponent({
6061
async function loadGroup() {
6162
if (groupId.value === undefined) return;
6263
isLoading.value = true;
63-
group.value = await new MavenAccess().getGroup(
64-
groupId.value
65-
);
64+
group.value = await new MavenAccess().getGroup(groupId.value);
6665
isLoading.value = false;
6766
}
6867

vue.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
module.exports = {
2-
publicPath: process.env.NODE_ENV === 'production'
3-
? '/'
4-
: '/',
52
configureWebpack: {
63
devServer: {
74
headers: {

0 commit comments

Comments
 (0)