From 632ccbdfb97bc4aa7484106496626056c0589dd2 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 19 Apr 2021 14:25:42 +0300 Subject: [PATCH 1/5] Support nuget.config name formats --- src/authutil.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/authutil.ts b/src/authutil.ts index 463f0d3..e625f06 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -13,7 +13,7 @@ export function configAuthentication( ) { const existingNuGetConfig: string = path.resolve( processRoot, - existingFileLocation == '' ? 'nuget.config' : existingFileLocation + existingFileLocation == '' ? getExistingNugetConfig(processRoot) : existingFileLocation ); const tempNuGetConfig: string = path.resolve( @@ -25,6 +25,14 @@ export function configAuthentication( writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); } +function getExistingNugetConfig(processRoot: string) { + const configFileNames = fs.readdirSync(processRoot).filter(filename => filename.toLowerCase() == 'nuget.config') + if (configFileNames.length) { + return configFileNames[0]; + } + return 'nuget.config'; +} + function writeFeedToFile( feedUrl: string, existingFileLocation: string, From d08d2193f9160552a35531296eb3fb6a8ce4027a Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 19 Apr 2021 14:26:05 +0300 Subject: [PATCH 2/5] Prettier --- src/authutil.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/authutil.ts b/src/authutil.ts index e625f06..54a2d3f 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -13,7 +13,9 @@ export function configAuthentication( ) { const existingNuGetConfig: string = path.resolve( processRoot, - existingFileLocation == '' ? getExistingNugetConfig(processRoot) : existingFileLocation + existingFileLocation == '' + ? getExistingNugetConfig(processRoot) + : existingFileLocation ); const tempNuGetConfig: string = path.resolve( @@ -26,7 +28,9 @@ export function configAuthentication( } function getExistingNugetConfig(processRoot: string) { - const configFileNames = fs.readdirSync(processRoot).filter(filename => filename.toLowerCase() == 'nuget.config') + const configFileNames = fs + .readdirSync(processRoot) + .filter(filename => filename.toLowerCase() == 'nuget.config'); if (configFileNames.length) { return configFileNames[0]; } From 07b4a80293787dc359f76a18cb064efc41b5719b Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 19 Apr 2021 14:26:52 +0300 Subject: [PATCH 3/5] Build index.js --- dist/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 15f8a3b..199f644 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4840,11 +4840,22 @@ const github = __importStar(__webpack_require__(469)); const xmlbuilder = __importStar(__webpack_require__(312)); const xmlParser = __importStar(__webpack_require__(989)); function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) { - const existingNuGetConfig = path.resolve(processRoot, existingFileLocation == '' ? 'nuget.config' : existingFileLocation); + const existingNuGetConfig = path.resolve(processRoot, existingFileLocation == '' + ? getExistingNugetConfig(processRoot) + : existingFileLocation); const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config'); writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig); } exports.configAuthentication = configAuthentication; +function getExistingNugetConfig(processRoot) { + const configFileNames = fs + .readdirSync(processRoot) + .filter(filename => filename.toLowerCase() == 'nuget.config'); + if (configFileNames.length) { + return configFileNames[0]; + } + return 'nuget.config'; +} function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); let xml; From a8c97016ef885352c99d116af10e48786cda01ca Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 19 Apr 2021 16:11:14 +0300 Subject: [PATCH 4/5] Minor fix --- dist/index.js | 4 ++-- src/authutil.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 199f644..3b057b7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4840,7 +4840,7 @@ const github = __importStar(__webpack_require__(469)); const xmlbuilder = __importStar(__webpack_require__(312)); const xmlParser = __importStar(__webpack_require__(989)); function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) { - const existingNuGetConfig = path.resolve(processRoot, existingFileLocation == '' + const existingNuGetConfig = path.resolve(processRoot, existingFileLocation === '' ? getExistingNugetConfig(processRoot) : existingFileLocation); const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config'); @@ -4850,7 +4850,7 @@ exports.configAuthentication = configAuthentication; function getExistingNugetConfig(processRoot) { const configFileNames = fs .readdirSync(processRoot) - .filter(filename => filename.toLowerCase() == 'nuget.config'); + .filter(filename => filename.toLowerCase() === 'nuget.config'); if (configFileNames.length) { return configFileNames[0]; } diff --git a/src/authutil.ts b/src/authutil.ts index 54a2d3f..77d66f6 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -13,7 +13,7 @@ export function configAuthentication( ) { const existingNuGetConfig: string = path.resolve( processRoot, - existingFileLocation == '' + existingFileLocation === '' ? getExistingNugetConfig(processRoot) : existingFileLocation ); @@ -30,7 +30,7 @@ export function configAuthentication( function getExistingNugetConfig(processRoot: string) { const configFileNames = fs .readdirSync(processRoot) - .filter(filename => filename.toLowerCase() == 'nuget.config'); + .filter(filename => filename.toLowerCase() === 'nuget.config'); if (configFileNames.length) { return configFileNames[0]; } From 3edf2e9363275b7fcf1d3210aa362f26c07287ab Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 19 Apr 2021 16:16:44 +0300 Subject: [PATCH 5/5] Minor fix --- dist/index.js | 5 +++-- src/authutil.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3b057b7..28caa4a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4848,13 +4848,14 @@ function configAuthentication(feedUrl, existingFileLocation = '', processRoot = } exports.configAuthentication = configAuthentication; function getExistingNugetConfig(processRoot) { + const defaultConfigName = 'nuget.config'; const configFileNames = fs .readdirSync(processRoot) - .filter(filename => filename.toLowerCase() === 'nuget.config'); + .filter(filename => filename.toLowerCase() === defaultConfigName); if (configFileNames.length) { return configFileNames[0]; } - return 'nuget.config'; + return defaultConfigName; } function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`); diff --git a/src/authutil.ts b/src/authutil.ts index 77d66f6..d8ddef0 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -28,13 +28,14 @@ export function configAuthentication( } function getExistingNugetConfig(processRoot: string) { + const defaultConfigName = 'nuget.config'; const configFileNames = fs .readdirSync(processRoot) - .filter(filename => filename.toLowerCase() === 'nuget.config'); + .filter(filename => filename.toLowerCase() === defaultConfigName); if (configFileNames.length) { return configFileNames[0]; } - return 'nuget.config'; + return defaultConfigName; } function writeFeedToFile(