stevedlawrence commented on code in PR #1532:
URL: https://github.com/apache/daffodil-vscode/pull/1532#discussion_r2547215344
##########
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:
You might want to add a filter to remove `Versions` without a `name` of
"Apache Daffodil". We might some day decide to include the SBT and VS Code
extensions in the doap file, and we would want to make sure this ignores those
versions.
Also, I remember another file we could use instead of doap:
https://svn.apache.org/repos/asf/comdev/reporter.apache.org/trunk/data/releases/daffodil.json.
That is json and a simpler format, including only release versions as keys and
release dates as their value. Might be easier to use and you can just check if
a key exists instead of having to filter/map.
Maybe one downside to using that file is it isn't directly controlled by the
Daffodil project--it's controlled by ASF comdev. So they could in theory decide
to change the location or format of that file and break the extension. I don't
expect that to happen, but it's worth considering. The doap file is always
under out control, so maybe that's a bit more reliable.
--
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]