mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-26 05:13:05 +07:00
merge main & build
This commit is contained in:
parent
4ca3c96b49
commit
cf081e76a2
30
dist/index.js
vendored
30
dist/index.js
vendored
@ -55,6 +55,7 @@ function getExistingNugetConfig(processRoot) {
|
|||||||
return defaultConfigName;
|
return defaultConfigName;
|
||||||
}
|
}
|
||||||
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
||||||
|
var _a, _b;
|
||||||
core.info(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`);
|
core.info(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`);
|
||||||
let xml;
|
let xml;
|
||||||
let sourceKeys = [];
|
let sourceKeys = [];
|
||||||
@ -73,23 +74,10 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
|||||||
if (typeof json.configuration === 'undefined') {
|
if (typeof json.configuration === 'undefined') {
|
||||||
throw new Error(`The provided NuGet.config seems invalid.`);
|
throw new Error(`The provided NuGet.config seems invalid.`);
|
||||||
}
|
}
|
||||||
if (typeof json.configuration.packageSources != 'undefined') {
|
if ((_b = (_a = json.configuration) === null || _a === void 0 ? void 0 : _a.packageSources) === null || _b === void 0 ? void 0 : _b.add) {
|
||||||
if (typeof json.configuration.packageSources.add != 'undefined') {
|
const packageSources = json.configuration.packageSources.add;
|
||||||
// file has at least one <add>
|
if (Array.isArray(packageSources)) {
|
||||||
if (typeof json.configuration.packageSources.add[0] === 'undefined') {
|
packageSources.forEach(source => {
|
||||||
// file has only one <add>
|
|
||||||
if (json.configuration.packageSources.add['@_value']
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(feedUrl.toLowerCase())) {
|
|
||||||
const key = json.configuration.packageSources.add['@_key'];
|
|
||||||
sourceKeys.push(key);
|
|
||||||
core.debug(`Found a URL with key ${key}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// file has 2+ <add>
|
|
||||||
for (let i = 0; i < json.configuration.packageSources.add.length; i++) {
|
|
||||||
const source = json.configuration.packageSources.add[i];
|
|
||||||
const value = source['@_value'];
|
const value = source['@_value'];
|
||||||
core.debug(`source '${value}'`);
|
core.debug(`source '${value}'`);
|
||||||
if (value.toLowerCase().includes(feedUrl.toLowerCase())) {
|
if (value.toLowerCase().includes(feedUrl.toLowerCase())) {
|
||||||
@ -97,7 +85,15 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
|||||||
sourceKeys.push(key);
|
sourceKeys.push(key);
|
||||||
core.debug(`Found a URL with key ${key}`);
|
core.debug(`Found a URL with key ${key}`);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (packageSources['@_value']
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(feedUrl.toLowerCase())) {
|
||||||
|
const key = packageSources['@_key'];
|
||||||
|
sourceKeys.push(key);
|
||||||
|
core.debug(`Found a URL with key ${key}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,28 +71,11 @@ function writeFeedToFile(
|
|||||||
if (typeof json.configuration === 'undefined') {
|
if (typeof json.configuration === 'undefined') {
|
||||||
throw new Error(`The provided NuGet.config seems invalid.`);
|
throw new Error(`The provided NuGet.config seems invalid.`);
|
||||||
}
|
}
|
||||||
if (typeof json.configuration.packageSources != 'undefined') {
|
if (json.configuration?.packageSources?.add) {
|
||||||
if (typeof json.configuration.packageSources.add != 'undefined') {
|
const packageSources = json.configuration.packageSources.add;
|
||||||
// file has at least one <add>
|
|
||||||
if (typeof json.configuration.packageSources.add[0] === 'undefined') {
|
if (Array.isArray(packageSources)) {
|
||||||
// file has only one <add>
|
packageSources.forEach(source => {
|
||||||
if (
|
|
||||||
json.configuration.packageSources.add['@_value']
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(feedUrl.toLowerCase())
|
|
||||||
) {
|
|
||||||
const key = json.configuration.packageSources.add['@_key'];
|
|
||||||
sourceKeys.push(key);
|
|
||||||
core.debug(`Found a URL with key ${key}`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// file has 2+ <add>
|
|
||||||
for (
|
|
||||||
let i = 0;
|
|
||||||
i < json.configuration.packageSources.add.length;
|
|
||||||
i++
|
|
||||||
) {
|
|
||||||
const source = json.configuration.packageSources.add[i];
|
|
||||||
const value = source['@_value'];
|
const value = source['@_value'];
|
||||||
core.debug(`source '${value}'`);
|
core.debug(`source '${value}'`);
|
||||||
if (value.toLowerCase().includes(feedUrl.toLowerCase())) {
|
if (value.toLowerCase().includes(feedUrl.toLowerCase())) {
|
||||||
@ -100,7 +83,16 @@ function writeFeedToFile(
|
|||||||
sourceKeys.push(key);
|
sourceKeys.push(key);
|
||||||
core.debug(`Found a URL with key ${key}`);
|
core.debug(`Found a URL with key ${key}`);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
packageSources['@_value']
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(feedUrl.toLowerCase())
|
||||||
|
) {
|
||||||
|
const key = packageSources['@_key'];
|
||||||
|
sourceKeys.push(key);
|
||||||
|
core.debug(`Found a URL with key ${key}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user