zarro 1.170.2 → 1.170.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
const nugetPushSource = sourceName ||
|
|
14
14
|
env.resolve(env.NUGET_PUSH_SOURCE, env.NUGET_SOURCE) ||
|
|
15
15
|
"nuget.org";
|
|
16
|
-
const apiKey = resolveNugetApiKey(nugetPushSource);
|
|
16
|
+
const apiKey = await resolveNugetApiKey(nugetPushSource);
|
|
17
17
|
options = options || {};
|
|
18
18
|
options.skipDuplicates = options.skipDuplicates === undefined
|
|
19
19
|
? env.resolveFlag("NUGET_IGNORE_DUPLICATE_PACKAGES")
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(function () {
|
|
3
|
-
const env = requireModule("env");
|
|
4
|
-
function resolveNugetApiKey(source) {
|
|
3
|
+
const env = requireModule("env"), log = requireModule("log"), { listNugetSources } = requireModule("dotnet-cli");
|
|
4
|
+
async function resolveNugetApiKey(source) {
|
|
5
5
|
const allKeys = resolveSourceToKeyLookup(), requestedSource = resolveSource(source);
|
|
6
6
|
if (!requestedSource) {
|
|
7
7
|
return findValue(allKeys, "nuget.org") || findValue(allKeys, "*");
|
|
8
8
|
}
|
|
9
|
-
const perSource = findValue(allKeys, requestedSource), multiKeyFallback = findValue(allKeys, "*"), nugetOrgFallback = findValue(allKeys, "nuget.org"), ultimateFallback = env.resolve(env.NUGET_API_KEY);
|
|
9
|
+
const perSource = findValue(allKeys, requestedSource, await resolveSourceName(requestedSource)), multiKeyFallback = findValue(allKeys, "*"), nugetOrgFallback = findValue(allKeys, "nuget.org"), ultimateFallback = env.resolve(env.NUGET_API_KEY);
|
|
10
10
|
return perSource || multiKeyFallback || nugetOrgFallback || ultimateFallback || undefined;
|
|
11
11
|
}
|
|
12
12
|
function resolveSourceToKeyLookup() {
|
|
@@ -32,15 +32,22 @@
|
|
|
32
32
|
["*"]: k
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
function findValue(
|
|
36
|
-
if (!
|
|
35
|
+
function findValue(data, ...seekKeys) {
|
|
36
|
+
if (!data || !seekKeys) {
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const uniqueKeys = new Set(seekKeys);
|
|
40
|
+
for (let seek of uniqueKeys) {
|
|
41
|
+
const exactMatch = data[seek];
|
|
42
|
+
if (exactMatch) {
|
|
43
|
+
return exactMatch;
|
|
44
|
+
}
|
|
45
|
+
const thisPass = fuzzyFindValue(data, seek);
|
|
46
|
+
if (thisPass) {
|
|
47
|
+
return thisPass;
|
|
48
|
+
}
|
|
42
49
|
}
|
|
43
|
-
return
|
|
50
|
+
return undefined;
|
|
44
51
|
}
|
|
45
52
|
function fuzzyFindValue(keys, seek) {
|
|
46
53
|
const keyLookup = Object.keys(keys)
|
|
@@ -51,6 +58,23 @@
|
|
|
51
58
|
const key = keyLookup[seek.toLowerCase()];
|
|
52
59
|
return keys[key];
|
|
53
60
|
}
|
|
61
|
+
async function resolveSourceName(sourceToResolve) {
|
|
62
|
+
const sources = await listNugetSources();
|
|
63
|
+
for (const source of sources) {
|
|
64
|
+
if (source.name.toLowerCase() === sourceToResolve.toLowerCase()) {
|
|
65
|
+
return source.name;
|
|
66
|
+
}
|
|
67
|
+
if (source.url.toLowerCase() === sourceToResolve.toLowerCase()) {
|
|
68
|
+
return source.name;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
log.warn(`Unable to match provides nuget push source '${sourceToResolve}' to the url or name of any registered source on this machine`);
|
|
72
|
+
log.warn(` known sources are:`);
|
|
73
|
+
for (const source of sources) {
|
|
74
|
+
log.warn(` ${source.name}: ${source.url} (${source.enabled ? "enabled" : "disabled"})`);
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`Unable to determine the nuget source to push to`);
|
|
77
|
+
}
|
|
54
78
|
function resolveSource(source) {
|
|
55
79
|
if (source) {
|
|
56
80
|
return source;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(function () {
|
|
3
3
|
const _which_ = require("which");
|
|
4
|
+
const cache = {};
|
|
4
5
|
module.exports = function which(executable) {
|
|
6
|
+
if (cache[executable]) {
|
|
7
|
+
return cache[executable];
|
|
8
|
+
}
|
|
5
9
|
try {
|
|
6
|
-
return _which_.sync(executable);
|
|
10
|
+
return cache[executable] = _which_.sync(executable);
|
|
7
11
|
}
|
|
8
12
|
catch (e) {
|
|
9
13
|
return undefined;
|
package/gulp-tasks/nuget-push.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(function () {
|
|
3
3
|
gulp.task("nuget-push", "Pushes the latest versions of packages in the package build dir", async () => {
|
|
4
|
-
const debug = requireModule("debug")(__filename), path = require("path"), nugetPush = requireModule("nuget-push"), { ls, FsEntities } = require("yafs"), env = requireModule("env"), folder = env.resolve(env.PACK_TARGET_FOLDER), versionRe = /^(?<id>[A-Za-z\.]+)\.(?<version>\d\.\d\.\d)(-(?<tag>.*))
|
|
4
|
+
const debug = requireModule("debug")(__filename), path = require("path"), nugetPush = requireModule("nuget-push"), { ls, FsEntities } = require("yafs"), env = requireModule("env"), folder = env.resolve(env.PACK_TARGET_FOLDER), versionRe = /^(?<id>[A-Za-z\.]+)\.(?<version>\d\.\d\.\d)(-(?<tag>.*))?\.nupkg$/, packages = await ls(folder, {
|
|
5
5
|
recurse: false,
|
|
6
6
|
entities: FsEntities.files,
|
|
7
7
|
match: versionRe
|
|
8
8
|
}), sorted = packages.sort().reverse(), seen = new Set();
|
|
9
|
+
if (sorted.length === 0) {
|
|
10
|
+
throw new Error(`No .nupkg files found in ${path.resolve(folder)}`);
|
|
11
|
+
}
|
|
12
|
+
const toPush = [];
|
|
9
13
|
for (const file of sorted) {
|
|
10
14
|
const match = file.match(versionRe), id = match === null || match === void 0 ? void 0 : match.groups["id"];
|
|
11
15
|
if (seen.has(id)) {
|
|
@@ -13,6 +17,17 @@
|
|
|
13
17
|
continue;
|
|
14
18
|
}
|
|
15
19
|
seen.add(id);
|
|
20
|
+
toPush.push(file);
|
|
21
|
+
}
|
|
22
|
+
if (env.resolveFlag(env.DRY_RUN)) {
|
|
23
|
+
const log = requireModule("log");
|
|
24
|
+
log.info("DRY_RUN set, would have pushed packages:");
|
|
25
|
+
for (const item of toPush) {
|
|
26
|
+
log.info(` ${item}`);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
for (const file of toPush) {
|
|
16
31
|
await nugetPush(path.join(folder, file));
|
|
17
32
|
}
|
|
18
33
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zarro",
|
|
3
|
-
"version": "1.170.
|
|
3
|
+
"version": "1.170.6",
|
|
4
4
|
"description": "Some glue to make gulp easier, perhaps even zero- or close-to-zero-conf",
|
|
5
5
|
"bin": {
|
|
6
6
|
"zarro": "./index.js"
|
|
@@ -121,6 +121,7 @@
|
|
|
121
121
|
"@types/semver": "^7.5.0",
|
|
122
122
|
"@types/through2": "^2.0.38",
|
|
123
123
|
"@types/typescript": "^2.0.0",
|
|
124
|
+
"@types/which": "^3.0.3",
|
|
124
125
|
"@types/xml2js": "^0.4.8",
|
|
125
126
|
"@types/yargs": "^15.0.13",
|
|
126
127
|
"console-cls": "^1.2.2",
|
package/types.d.ts
CHANGED
|
@@ -531,7 +531,7 @@ declare global {
|
|
|
531
531
|
open(url: string): Promise<void>;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
-
type ResolveNugetApiKey = (forSource?: string) => Optional<string
|
|
534
|
+
type ResolveNugetApiKey = (forSource?: string) => Promise<Optional<string>>;
|
|
535
535
|
|
|
536
536
|
interface Env
|
|
537
537
|
extends Dictionary<any> {
|