Skip to content

Commit 6fe5db5

Browse files
authored
ATLAS-5039: Page for TeamList doesn't render Atlas team members in atlas.apache.org (#394)
* ATLAS-5039: Page for TeamList doesn't render Atlas team members in atlas.apache.org * ATLAS-5039: update path
1 parent cb1e53a commit 6fe5db5

File tree

3 files changed

+95
-26
lines changed

3 files changed

+95
-26
lines changed

docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"start": "node ./docz-lib/docz/bin/index.js dev",
8+
"fetch-team": "node scripts/fetchTeamList.js",
9+
"prebuild": "npm run fetch-team",
810
"build": "node ./docz-lib/docz/bin/index.js build",
911
"predeploy": "npm install && npm run build",
1012
"deploy": "gh-pages -d .docz/dist"

docs/scripts/fetchTeamList.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
const https = require("https");
20+
const fs = require("fs");
21+
const { parseString } = require("xml2js");
22+
23+
const POM_URL = "https://raw.githubusercontent.com/apache/atlas/master/pom.xml";
24+
const OUTPUT_PATH = "src/resources/data/team.json";
25+
26+
function fetchXML(url) {
27+
return new Promise((resolve, reject) => {
28+
https
29+
.get(url, res => {
30+
if (res.statusCode !== 200) {
31+
reject(new Error(`Request failed. Status code: ${res.statusCode}`));
32+
res.resume(); // drain
33+
return;
34+
}
35+
36+
let data = "";
37+
res.setEncoding("utf8");
38+
res.on("data", chunk => (data += chunk));
39+
res.on("end", () => resolve(data));
40+
})
41+
.on("error", reject);
42+
});
43+
}
44+
45+
(async () => {
46+
try {
47+
const xmlData = await fetchXML(POM_URL);
48+
49+
parseString(xmlData, (err, result) => {
50+
if (err) {
51+
console.error("❌ XML parsing failed:", err);
52+
process.exit(1);
53+
}
54+
55+
let developersList = [];
56+
if (
57+
result &&
58+
result.project &&
59+
result.project.developers &&
60+
Array.isArray(result.project.developers) &&
61+
result.project.developers[0] &&
62+
result.project.developers[0].developer
63+
) {
64+
developersList = result.project.developers[0].developer;
65+
}
66+
67+
const keys = developersList.length > 0 ? Object.keys(developersList[0]) : [];
68+
69+
const output = developersList.map(dev => {
70+
const obj = {};
71+
keys.forEach(k => {
72+
obj[k] = dev[k] || [""];
73+
});
74+
return obj;
75+
});
76+
77+
// Ensure the directory exists
78+
const outputDir = require("path").dirname(OUTPUT_PATH);
79+
if (!fs.existsSync(outputDir)) {
80+
fs.mkdirSync(outputDir, { recursive: true });
81+
}
82+
83+
fs.writeFileSync(OUTPUT_PATH, JSON.stringify(output, null, 2));
84+
console.log(`✅ Team data written to ${OUTPUT_PATH}`);
85+
});
86+
} catch (err) {
87+
console.error("❌ Failed to fetch pom.xml:", err.message);
88+
process.exit(1);
89+
}
90+
})();

docs/theme/components/shared/TeamList/index.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import React, { Component } from "react";
2020
import axios from "axios";
2121
import { parseString } from "xml2js";
2222
import styled from "styled-components";
23+
import teamData from "src/resources/data/team.json";
2324

2425
const TeamListStyle = styled.div`
2526
width: 100%;
@@ -73,33 +74,9 @@ export default class TeamList extends Component {
7374
constructor(props) {
7475
super(props);
7576
this.state = {
76-
isLoading: true,
77-
displayData: []
77+
displayData: teamData || [],
78+
isLoading: false
7879
};
79-
this.fetchData();
80-
}
81-
82-
fetchData() {
83-
axios
84-
.get(`https://raw.githubusercontent.com/apache/atlas/master/pom.xml`)
85-
.then(res => {
86-
// Transform the raw data by extracting the nested posts
87-
parseString(res.data, (err, result) => {
88-
const developersList = result.project.developers[0].developer;
89-
const developersListLength = developersList.length;
90-
let t_displayData = [];
91-
const keys = Object.keys(developersList[0]);
92-
for (var i = 0; i < developersListLength; i++) {
93-
const obj = {};
94-
keys.map(k => (obj[k] = developersList[i][k]));
95-
t_displayData.push(obj);
96-
}
97-
this.setState({ displayData: t_displayData, isLoading: false });
98-
});
99-
})
100-
.catch(err => {
101-
console.log("fetching data from pom.xml is failed.");
102-
});
10380
}
10481

10582
render() {

0 commit comments

Comments
 (0)