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


##########
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:
   > Do you think I should add a comment about this above the 
getValidDaffodilVersions
   
   I don't think so it's necessary. The doap file is kindof required by ASF so 
I don't think we'll ever remove it, and many projects use it so it's unlikely 
the format will ever change. We just have to remember to update it when new 
daffodil versions are released, but it's mentioned as a step in the release 
workflow so we shouldn't forget.



-- 
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