Skip to content

Commit 6a170f5

Browse files
authored
Add option to override the nuget feed used by command line argument (#1022)
1 parent ac63812 commit 6a170f5

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

gulp/lib/nugetInstall.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ import { Extract } from "unzip-stream";
77
import yargs from 'yargs';
88
const argv = yargs(process.argv.slice(2)).argv; // skip 'node' and 'gulp.js' args
99

10-
export default async function nugetInstall(feed, pkg) {
10+
export default async function nugetInstall(pkg, feeds) {
1111
const packageName = pkg.name.toLowerCase();
1212
const version = pkg.version.toLowerCase();
1313
const packagePath = `${packageName}/${version}/${packageName}.${version}.nupkg`;
1414

15+
// Override the feed used if specified by the --useFeed argument
16+
const selectedFeedName = argv.useFeed || pkg.useFeed;
17+
info('Using feed:', selectedFeedName);
18+
const feed = feeds.find((f) => f.name === selectedFeedName);
19+
1520
const nupkgUrl = new URL(packagePath, feed.url);
1621
const reqInit = {
1722
headers: {

gulp/restore.mjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import nugetInstall from "./lib/nugetInstall.mjs";
33

44
import { createRequire } from "node:module";
55
const require = createRequire(import.meta.url);
6-
const nugetFeeds = require("../nuget.json").feeds;
6+
const nugetConfig = require("../nuget.json");
77

88
// https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource
99
// https://dev.azure.com/msazure/One/_packaging?_a=feed&feed=CAP_ISVExp_Tools_Daily
1010

1111
export default gulp.series(
12-
...nugetFeeds
13-
.map((feed) =>
14-
feed.packages.map((pkg) => async () => nugetInstall(feed, pkg))
15-
)
12+
...nugetConfig.packages
13+
.map((pkg) => async () => nugetInstall(pkg, nugetConfig.feeds))
1614
.flat()
1715
);

nuget.json

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
{
2+
"packages": [
3+
{
4+
"name": "Microsoft.PowerApps.CLI",
5+
"version": "1.34.4",
6+
"internalName": "pac",
7+
"useFeed": "nuget.org"
8+
},
9+
{
10+
"name": "Microsoft.PowerApps.CLI.Core.linux-x64",
11+
"version": "1.34.4",
12+
"internalName": "pac_linux",
13+
"chmod": "tools/pac",
14+
"useFeed": "nuget.org"
15+
}
16+
],
217
"feeds": [
318
{
419
"name": "nuget.org",
520
"url": "https://api.nuget.org/v3-flatcontainer/",
6-
"authenticated": false,
7-
"packages": [
8-
{
9-
"name": "Microsoft.PowerApps.CLI",
10-
"version": "1.34.4",
11-
"internalName": "pac"
12-
},
13-
{
14-
"name": "Microsoft.PowerApps.CLI.Core.linux-x64",
15-
"version": "1.34.4",
16-
"internalName": "pac_linux",
17-
"chmod": "tools/pac"
18-
}
19-
]
21+
"authenticated": false
2022
},
2123
{
2224
"name": "CAP_ISVExp_Tools_Stable",
2325
"url": "https://pkgs.dev.azure.com/msazure/_packaging/b0441cf8-0bc8-4fad-b126-841a6184e784/nuget/v3/flat2/",
2426
"authenticated": true,
25-
"patEnvironmentVariable": "AZ_DevOps_Read_PAT",
26-
"packages": []
27+
"patEnvironmentVariable": "AZ_DevOps_Read_PAT"
2728
},
2829
{
2930
"name": "CAP_ISVExp_Tools_Daily",
3031
"url": "https://pkgs.dev.azure.com/msazure/_packaging/d3fb5788-d047-47f9-9aba-76890f5cecf0/nuget/v3/flat2/",
3132
"authenticated": true,
32-
"patEnvironmentVariable": "AZ_DevOps_Read_PAT",
33-
"packages": []
33+
"patEnvironmentVariable": "AZ_DevOps_Read_PAT"
34+
},
35+
{
36+
"name": "DPX-Tools-Upstream",
37+
"url": "https://pkgs.dev.azure.com/dynamicscrm/OneCRM/_packaging/1b55351d-c15e-45b3-9454-70a9549af804/nuget/v3/flat2/",
38+
"authenticated": true,
39+
"patEnvironmentVariable": "AZ_DevOps_Read_PAT"
3440
}
3541
]
3642
}

0 commit comments

Comments
 (0)