mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-26 13:23:05 +07:00
Feedback
This commit is contained in:
parent
f7896b6c4c
commit
e28ad717b8
@ -174,7 +174,7 @@ class DotnetCoreInstaller {
|
|||||||
getDownloadUrls(osSuffixes, version) {
|
getDownloadUrls(osSuffixes, version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let downloadUrls = [];
|
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('.'));
|
const releasesJsonUrl = yield this.getReleasesJsonUrl(httpCallbackClient, version.split('.'));
|
||||||
let releasesJSON = yield httpCallbackClient.get(releasesJsonUrl);
|
let releasesJSON = yield httpCallbackClient.get(releasesJsonUrl);
|
||||||
let releasesInfo = JSON.parse(yield releasesJSON.readBody())['releases'];
|
let releasesInfo = JSON.parse(yield releasesJSON.readBody())['releases'];
|
||||||
@ -212,18 +212,18 @@ class DotnetCoreInstaller {
|
|||||||
}
|
}
|
||||||
getReleasesJsonUrl(httpCallbackClient, versionParts) {
|
getReleasesJsonUrl(httpCallbackClient, versionParts) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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);
|
const releasesIndex = yield httpCallbackClient.get(DotNetCoreIndexUrl);
|
||||||
let releasesInfo = JSON.parse(yield releasesIndex.readBody())['releases-index'];
|
let releasesInfo = JSON.parse(yield releasesIndex.readBody())['releases-index'];
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo) => {
|
releasesInfo = releasesInfo.filter((info) => {
|
||||||
const sdkParts = releaseInfo['channel-version'].split('.');
|
// 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') {
|
if (versionParts.length >= 2 && versionParts[1] != 'x') {
|
||||||
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
|
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
|
||||||
}
|
}
|
||||||
return versionParts[0] == sdkParts[0];
|
return versionParts[0] == sdkParts[0];
|
||||||
});
|
});
|
||||||
if (releasesInfo.length === 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'];
|
return releasesInfo[0]['releases.json'];
|
||||||
});
|
});
|
||||||
|
@ -188,8 +188,12 @@ export class DotnetCoreInstaller {
|
|||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
let downloadUrls: string[] = [];
|
let downloadUrls: string[] = [];
|
||||||
|
|
||||||
var httpCallbackClient = new httpClient.HttpClient('setup-dotnet', [], {});
|
const httpCallbackClient = new httpClient.HttpClient(
|
||||||
const releasesJsonUrl = await this.getReleasesJsonUrl(
|
'actions/setup-dotnet',
|
||||||
|
[],
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
const releasesJsonUrl: string = await this.getReleasesJsonUrl(
|
||||||
httpCallbackClient,
|
httpCallbackClient,
|
||||||
version.split('.')
|
version.split('.')
|
||||||
);
|
);
|
||||||
@ -208,7 +212,7 @@ export class DotnetCoreInstaller {
|
|||||||
|
|
||||||
if (releasesInfo.length != 0) {
|
if (releasesInfo.length != 0) {
|
||||||
let release = releasesInfo[0];
|
let release = releasesInfo[0];
|
||||||
let files = release['sdk']['files'];
|
let files: any[] = release['sdk']['files'];
|
||||||
files = files.filter((file: any) => {
|
files = files.filter((file: any) => {
|
||||||
if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) {
|
if (file['rid'] == osSuffixes[0] || file['rid'] == osSuffixes[1]) {
|
||||||
return (
|
return (
|
||||||
@ -244,22 +248,24 @@ export class DotnetCoreInstaller {
|
|||||||
httpCallbackClient: httpClient.HttpClient,
|
httpCallbackClient: httpClient.HttpClient,
|
||||||
versionParts: string[]
|
versionParts: string[]
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// First, get the location of the correct releases.json then get that.
|
|
||||||
const releasesIndex: HttpClientResponse = await httpCallbackClient.get(
|
const releasesIndex: HttpClientResponse = await httpCallbackClient.get(
|
||||||
DotNetCoreIndexUrl
|
DotNetCoreIndexUrl
|
||||||
);
|
);
|
||||||
let releasesInfo = JSON.parse(await releasesIndex.readBody())[
|
let releasesInfo: any[] = JSON.parse(await releasesIndex.readBody())[
|
||||||
'releases-index'
|
'releases-index'
|
||||||
];
|
];
|
||||||
releasesInfo = releasesInfo.filter((releaseInfo: any) => {
|
releasesInfo = releasesInfo.filter((info: any) => {
|
||||||
const sdkParts: string[] = releaseInfo['channel-version'].split('.');
|
// 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') {
|
if (versionParts.length >= 2 && versionParts[1] != 'x') {
|
||||||
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
|
return versionParts[0] == sdkParts[0] && versionParts[1] == sdkParts[1];
|
||||||
}
|
}
|
||||||
return versionParts[0] == sdkParts[0];
|
return versionParts[0] == sdkParts[0];
|
||||||
});
|
});
|
||||||
if (releasesInfo.length === 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'];
|
return releasesInfo[0]['releases.json'];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user