shanedell commented on code in PR #1532:
URL: https://github.com/apache/daffodil-vscode/pull/1532#discussion_r2547281943


##########
src/daffodilDebugger/daffodilJars.ts:
##########
@@ -46,16 +47,57 @@ export async function checkIfDaffodilJarsNeeded(
     context.asAbsolutePath('./dist'),
     `daffodil/apache-daffodil-${daffodilVersion}-bin`
   )
+
   if (fs.existsSync(extensionPath)) {
     outputChannel.appendLine(`[INFO] Using bundled Daffodil CLI JARs.`)
     return extensionPath
   }
 
+  // If not a valid daffodil version provided and it doesn't exist already in 
cache then throw error
+  if (!(await checkIfValidDaffodilVersion(daffodilVersion))) {
+    throw new Error(
+      'Invalid Daffodil Version provided. Make sure 
dfdlDebugger.daffodilVersion is a valid version of Daffodil'
+    )
+  }
+
   // downloadAndExtractToGlobalStorage only tries to download the Daffodil CLI 
release file if
   // the desired version's bin folder doesn't already exists.
   return await downloadAndExtractToGlobalStorage(context, daffodilVersion)
 }
 
+// Helper function to get the list of valid Daffodil versions
+async function getValidDaffodilVersions(): Promise<string[]> {
+  const url = 'https://daffodil.apache.org/doap.rdf'
+
+  const resp = await fetch(url)
+  if (!resp.ok) {
+    throw new Error(
+      `Failed to fetch DOAP RDF: ${resp.status} ${resp.statusText}`
+    )
+  }
+
+  const xmlText = await resp.text()
+  const data = await parseStringPromise(xmlText, { explicitArray: false })
+
+  const project = data['rdf:RDF']['Project']
+  const releases = project['release']
+
+  const releaseArray = Array.isArray(releases) ? releases : [releases]
+
+  return releaseArray
+    .map((rel: any) => {

Review Comment:
   I added a filter to check if `name == 'Apache Daffodil'` and only use those 
to get the versions of. I think sticking with the doap, as based on what you 
said it seems to be more reliable for now. If something changes in the future 
though we could move to the file you linked. Do you think I should add a 
comment about this above the `getValidDaffodilVersions`? It would include that 
link and state that in the future if the doap file is say removed or become 
unreliable we could possibly switch to 
https://svn.apache.org/repos/asf/comdev/reporter.apache.org/trunk/data/releases/daffodil.json



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to