From 6a170f546258517f3b9d7b92272bceee92ef02e7 Mon Sep 17 00:00:00 2001 From: Crash Collison <3751389+tehcrashxor@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:39:10 -0700 Subject: [PATCH] Add option to override the nuget feed used by command line argument (#1022) --- gulp/lib/nugetInstall.mjs | 7 ++++++- gulp/restore.mjs | 8 +++----- nuget.json | 42 ++++++++++++++++++++++----------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/gulp/lib/nugetInstall.mjs b/gulp/lib/nugetInstall.mjs index d8e1e327..bae2bbe1 100644 --- a/gulp/lib/nugetInstall.mjs +++ b/gulp/lib/nugetInstall.mjs @@ -7,11 +7,16 @@ import { Extract } from "unzip-stream"; import yargs from 'yargs'; const argv = yargs(process.argv.slice(2)).argv; // skip 'node' and 'gulp.js' args -export default async function nugetInstall(feed, pkg) { +export default async function nugetInstall(pkg, feeds) { const packageName = pkg.name.toLowerCase(); const version = pkg.version.toLowerCase(); const packagePath = `${packageName}/${version}/${packageName}.${version}.nupkg`; + // Override the feed used if specified by the --useFeed argument + const selectedFeedName = argv.useFeed || pkg.useFeed; + info('Using feed:', selectedFeedName); + const feed = feeds.find((f) => f.name === selectedFeedName); + const nupkgUrl = new URL(packagePath, feed.url); const reqInit = { headers: { diff --git a/gulp/restore.mjs b/gulp/restore.mjs index b3ed5425..88fe5a0b 100644 --- a/gulp/restore.mjs +++ b/gulp/restore.mjs @@ -3,15 +3,13 @@ import nugetInstall from "./lib/nugetInstall.mjs"; import { createRequire } from "node:module"; const require = createRequire(import.meta.url); -const nugetFeeds = require("../nuget.json").feeds; +const nugetConfig = require("../nuget.json"); // https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource // https://dev.azure.com/msazure/One/_packaging?_a=feed&feed=CAP_ISVExp_Tools_Daily export default gulp.series( - ...nugetFeeds - .map((feed) => - feed.packages.map((pkg) => async () => nugetInstall(feed, pkg)) - ) + ...nugetConfig.packages + .map((pkg) => async () => nugetInstall(pkg, nugetConfig.feeds)) .flat() ); diff --git a/nuget.json b/nuget.json index 795bc482..c84497bf 100644 --- a/nuget.json +++ b/nuget.json @@ -1,36 +1,42 @@ { + "packages": [ + { + "name": "Microsoft.PowerApps.CLI", + "version": "1.34.4", + "internalName": "pac", + "useFeed": "nuget.org" + }, + { + "name": "Microsoft.PowerApps.CLI.Core.linux-x64", + "version": "1.34.4", + "internalName": "pac_linux", + "chmod": "tools/pac", + "useFeed": "nuget.org" + } + ], "feeds": [ { "name": "nuget.org", "url": "https://api.nuget.org/v3-flatcontainer/", - "authenticated": false, - "packages": [ - { - "name": "Microsoft.PowerApps.CLI", - "version": "1.34.4", - "internalName": "pac" - }, - { - "name": "Microsoft.PowerApps.CLI.Core.linux-x64", - "version": "1.34.4", - "internalName": "pac_linux", - "chmod": "tools/pac" - } - ] + "authenticated": false }, { "name": "CAP_ISVExp_Tools_Stable", "url": "https://pkgs.dev.azure.com/msazure/_packaging/b0441cf8-0bc8-4fad-b126-841a6184e784/nuget/v3/flat2/", "authenticated": true, - "patEnvironmentVariable": "AZ_DevOps_Read_PAT", - "packages": [] + "patEnvironmentVariable": "AZ_DevOps_Read_PAT" }, { "name": "CAP_ISVExp_Tools_Daily", "url": "https://pkgs.dev.azure.com/msazure/_packaging/d3fb5788-d047-47f9-9aba-76890f5cecf0/nuget/v3/flat2/", "authenticated": true, - "patEnvironmentVariable": "AZ_DevOps_Read_PAT", - "packages": [] + "patEnvironmentVariable": "AZ_DevOps_Read_PAT" + }, + { + "name": "DPX-Tools-Upstream", + "url": "https://pkgs.dev.azure.com/dynamicscrm/OneCRM/_packaging/1b55351d-c15e-45b3-9454-70a9549af804/nuget/v3/flat2/", + "authenticated": true, + "patEnvironmentVariable": "AZ_DevOps_Read_PAT" } ] }