This commit is contained in:
damccorm 2019-08-29 16:15:06 -04:00
parent f7896b6c4c
commit e28ad717b8
2 changed files with 19 additions and 13 deletions

View File

@ -174,7 +174,7 @@ class DotnetCoreInstaller {
getDownloadUrls(osSuffixes, version) {
return __awaiter(this, void 0, void 0, function* () {
let downloadUrls = [];
var httpCallbackClient = new httpClient.HttpClient('setup-dotnet', [], {});
const httpCallbackClient = new httpClient.HttpClient('actions/setup-dotnet', [], {});
const releasesJsonUrl = yield this.getReleasesJsonUrl(httpCallbackClient, version.split('.'));
let releasesJSON = yield httpCallbackClient.get(releasesJsonUrl);
let releasesInfo = JSON.parse(yield releasesJSON.readBody())['releases'];
@ -212,18 +212,18 @@ class DotnetCoreInstaller {
}
getReleasesJsonUrl(httpCallbackClient, versionParts) {
return __awaiter(this, void 0, void 0, function* () {
// First, get the location of the correct releases.json then get that.
const releasesIndex = yield httpCallbackClient.get(DotNetCoreIndexUrl);
let releasesInfo = JSON.parse(yield releasesIndex.readBody())['releases-index'];
releasesInfo = releasesInfo.filter((releaseInfo) => {
const sdkParts = releaseInfo['channel-version'].split('.');
releasesInfo = releasesInfo.filter((info) => {
// channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x.
const sdkParts = info['channel-version'].split('.');
if (versionParts.length >= 2 && versionParts[1] != 'x') {
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
}
return versionParts[0] == sdkParts[0];
});
if (releasesInfo.length === 0) {
throw `Could not find info for this version at ${DotNetCoreIndexUrl}`;
throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`;
}
return releasesInfo[0]['releases.json'];
});

View File

@ -188,8 +188,12 @@ export class DotnetCoreInstaller {
): Promise<string[]> {
let downloadUrls: string[] = [];
var httpCallbackClient = new httpClient.HttpClient('setup-dotnet', [], {});
const releasesJsonUrl = await this.getReleasesJsonUrl(
const httpCallbackClient = new httpClient.HttpClient(
'actions/setup-dotnet',
[],
{}
);
const releasesJsonUrl: string = await this.getReleasesJsonUrl(
httpCallbackClient,
version.split('.')
);
@ -208,7 +212,7 @@ export class DotnetCoreInstaller {
if (releasesInfo.length != 0) {
let release = releasesInfo[0];
let files = release['sdk']['files'];
let files: any[] = release['sdk']['files'];
files = files.filter((file: any) => {
if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) {
return (
@ -244,22 +248,24 @@ export class DotnetCoreInstaller {
httpCallbackClient: httpClient.HttpClient,
versionParts: string[]
): Promise<string> {
// First, get the location of the correct releases.json then get that.
const releasesIndex: HttpClientResponse = await httpCallbackClient.get(
DotNetCoreIndexUrl
);
let releasesInfo = JSON.parse(await releasesIndex.readBody())[
let releasesInfo: any[] = JSON.parse(await releasesIndex.readBody())[
'releases-index'
];
releasesInfo = releasesInfo.filter((releaseInfo: any) => {
const sdkParts: string[] = releaseInfo['channel-version'].split('.');
releasesInfo = releasesInfo.filter((info: any) => {
// channel-version is the first 2 elements of the version (e.g. 2.1), filter out versions that don't match 2.1.x.
const sdkParts: string[] = info['channel-version'].split('.');
if (versionParts.length >= 2 && versionParts[1] != 'x') {
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
}
return versionParts[0] == sdkParts[0];
});
if (releasesInfo.length === 0) {
throw `Could not find info for this version at ${DotNetCoreIndexUrl}`;
throw `Could not find info for version ${versionParts.join(
'.'
)} at ${DotNetCoreIndexUrl}`;
}
return releasesInfo[0]['releases.json'];
}