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+ } ) ( ) ;
0 commit comments