-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed extra semicolon added architecture to conda revisions removed base version fix version fetching fixed lint errors update
- Loading branch information
Basit Ayantunde
committed
Nov 24, 2023
1 parent
2e2083f
commit a290ed0
Showing
9 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) Microsoft Corporation and others. Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
const asyncMiddleware = require('../middleware/asyncMiddleware') | ||
const router = require('express').Router() | ||
const requestPromise = require('request-promise-native') | ||
const { uniq } = require('lodash') | ||
const condaChannels = { | ||
'anaconda-main': 'https://repo.anaconda.com/pkgs/main', | ||
'anaconda-r': 'https://repo.anaconda.com/pkgs/r', | ||
'conda-forge': 'https://conda.anaconda.org/conda-forge' | ||
} | ||
|
||
router.get( | ||
'/:name/:channel/revisions', | ||
asyncMiddleware(async (request, response) => { | ||
const { name, channel } = request.params | ||
if (!condaChannels[channel]) { | ||
return response.status(404).send([]) | ||
} | ||
const url = `${condaChannels[channel]}/channeldata.json` | ||
const channelData = await requestPromise({ url, method: 'GET', json: true }) | ||
if (channelData.packages[name]) { | ||
let revisions = [] | ||
for (let subdir of channelData.packages[name].subdirs) { | ||
const repoUrl = `${condaChannels[channel]}/${subdir}/repodata.json` | ||
const repoData = await requestPromise({ url: repoUrl, method: 'GET', json: true }) | ||
if (repoData['packages']) { | ||
Object.entries(repoData['packages']) | ||
.forEach(([, packageData]) => { | ||
if (packageData.name == name) { | ||
revisions.push(`${packageData.version}_${subdir}`) | ||
} | ||
}) | ||
} | ||
if (repoData['packages.conda']) { | ||
Object.entries(repoData['packages.conda']) | ||
.forEach(([, packageData]) => { | ||
if (packageData.name == name) { | ||
revisions.push(`${packageData.version}_${subdir}`) | ||
} | ||
}) | ||
} | ||
} | ||
return response.status(200).send(uniq(revisions)) | ||
} else { | ||
return response.status(404).send([]) | ||
} | ||
}) | ||
) | ||
|
||
router.get( | ||
'/:name/:channel', | ||
asyncMiddleware(async (request, response) => { | ||
const { name, channel } = request.params | ||
if (!condaChannels[channel]) { | ||
return response.status(404).send([]) | ||
} | ||
const url = `${condaChannels[channel]}/channeldata.json` | ||
const channelData = await requestPromise({ url, method: 'GET', json: true }) | ||
let matches = Object.entries(channelData.packages).filter(([packageName,]) => packageName.includes(name)).map( | ||
([packageName,]) => { return { id: packageName } } | ||
) | ||
return response.status(200).send(matches) | ||
}) | ||
) | ||
|
||
function setup() { | ||
return router | ||
} | ||
|
||
module.exports = setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters