Skip to content

Commit

Permalink
Add option to override the nuget feed used by command line argument (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tehcrashxor authored Aug 30, 2024
1 parent ac63812 commit 6a170f5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
7 changes: 6 additions & 1 deletion gulp/lib/nugetInstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 3 additions & 5 deletions gulp/restore.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
42 changes: 24 additions & 18 deletions nuget.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 6a170f5

Please sign in to comment.