zarro 1.92.0

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.
Files changed (201) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +260 -0
  3. package/gulp-tasks/.editorconfig +8 -0
  4. package/gulp-tasks/.git +1 -0
  5. package/gulp-tasks/.gitignore +9 -0
  6. package/gulp-tasks/.gitmodules +0 -0
  7. package/gulp-tasks/LICENSE +24 -0
  8. package/gulp-tasks/README.md +144 -0
  9. package/gulp-tasks/build.js +135 -0
  10. package/gulp-tasks/clean.js +37 -0
  11. package/gulp-tasks/cover-dotnet.js +56 -0
  12. package/gulp-tasks/default-report-generator.js +51 -0
  13. package/gulp-tasks/default-tools-installer.js +33 -0
  14. package/gulp-tasks/default.js +17 -0
  15. package/gulp-tasks/dotnet-publish.js +23 -0
  16. package/gulp-tasks/generate-reports.js +7 -0
  17. package/gulp-tasks/get-local-nuget.js +16 -0
  18. package/gulp-tasks/git-submodules.js +83 -0
  19. package/gulp-tasks/increment-package-json-version.js +12 -0
  20. package/gulp-tasks/increment-package-json-version.ts +17 -0
  21. package/gulp-tasks/install-tools.js +24 -0
  22. package/gulp-tasks/modules/add-stream-on-any-handler.js +31 -0
  23. package/gulp-tasks/modules/alter-package-json-version.js +64 -0
  24. package/gulp-tasks/modules/alter-package-json-version.ts +113 -0
  25. package/gulp-tasks/modules/are-all-dotnet-core.js +96 -0
  26. package/gulp-tasks/modules/ask.js +31 -0
  27. package/gulp-tasks/modules/ask.ts +41 -0
  28. package/gulp-tasks/modules/collect-files.js +15 -0
  29. package/gulp-tasks/modules/collect-files.ts +16 -0
  30. package/gulp-tasks/modules/config-generator.js +10 -0
  31. package/gulp-tasks/modules/defaults.js +9 -0
  32. package/gulp-tasks/modules/download-nuget.js +104 -0
  33. package/gulp-tasks/modules/ensure-folder-exists.js +21 -0
  34. package/gulp-tasks/modules/env-helpers.js +49 -0
  35. package/gulp-tasks/modules/env-helpers.ts +67 -0
  36. package/gulp-tasks/modules/env.js +364 -0
  37. package/gulp-tasks/modules/exec.js +257 -0
  38. package/gulp-tasks/modules/exec.ts +346 -0
  39. package/gulp-tasks/modules/fail-after.js +30 -0
  40. package/gulp-tasks/modules/fail-after.ts +34 -0
  41. package/gulp-tasks/modules/fallback.js +6 -0
  42. package/gulp-tasks/modules/find-dirs.js +39 -0
  43. package/gulp-tasks/modules/find-local-nuget.js +42 -0
  44. package/gulp-tasks/modules/find-npm-base.js +42 -0
  45. package/gulp-tasks/modules/fs.js +79 -0
  46. package/gulp-tasks/modules/gather-paths.js +23 -0
  47. package/gulp-tasks/modules/gather-paths.ts +29 -0
  48. package/gulp-tasks/modules/generate-env-help-for.js +30 -0
  49. package/gulp-tasks/modules/get-tools-folder.js +12 -0
  50. package/gulp-tasks/modules/git-push-tags.js +33 -0
  51. package/gulp-tasks/modules/git-push-tags.ts +42 -0
  52. package/gulp-tasks/modules/git-push.js +51 -0
  53. package/gulp-tasks/modules/git-tag.js +36 -0
  54. package/gulp-tasks/modules/gulp-dotnetcover.js +537 -0
  55. package/gulp-tasks/modules/gulp-git-tag-from-csproj.js +50 -0
  56. package/gulp-tasks/modules/gulp-git-tag-from-csproj.ts +71 -0
  57. package/gulp-tasks/modules/gulp-git-tag-from-package-nuspec.js +55 -0
  58. package/gulp-tasks/modules/gulp-increment-nuget-package-dependency-version.js +40 -0
  59. package/gulp-tasks/modules/gulp-increment-nuget-package-version.js +87 -0
  60. package/gulp-tasks/modules/gulp-increment-nuget-package-version.ts +122 -0
  61. package/gulp-tasks/modules/gulp-msbuild.js +1 -0
  62. package/gulp-tasks/modules/gulp-npm-run.js +40 -0
  63. package/gulp-tasks/modules/gulp-npm-run.ts +52 -0
  64. package/gulp-tasks/modules/gulp-nuget-pack.js +168 -0
  65. package/gulp-tasks/modules/gulp-nuget-restore.js +106 -0
  66. package/gulp-tasks/modules/gulp-nunit-runner/.jshintrc +5 -0
  67. package/gulp-tasks/modules/gulp-nunit-runner/.npmignore +16 -0
  68. package/gulp-tasks/modules/gulp-nunit-runner/LICENSE +21 -0
  69. package/gulp-tasks/modules/gulp-nunit-runner/README.md +300 -0
  70. package/gulp-tasks/modules/gulp-nunit-runner/index.js +1 -0
  71. package/gulp-tasks/modules/gulp-nunit-runner/lib/index.js +205 -0
  72. package/gulp-tasks/modules/gulp-nunit-runner/lib/teamcity.js +86 -0
  73. package/gulp-tasks/modules/gulp-purge.js +88 -0
  74. package/gulp-tasks/modules/gulp-util.js +5 -0
  75. package/gulp-tasks/modules/gulp-version.js +8 -0
  76. package/gulp-tasks/modules/gulp-with-help.js +1 -0
  77. package/gulp-tasks/modules/gulp-xbuild.js +62 -0
  78. package/gulp-tasks/modules/gulp.js +92 -0
  79. package/gulp-tasks/modules/http-downloader.js +113 -0
  80. package/gulp-tasks/modules/import-npm-tasks.js +33 -0
  81. package/gulp-tasks/modules/increment-version-string.js +18 -0
  82. package/gulp-tasks/modules/increment-version.js +30 -0
  83. package/gulp-tasks/modules/increment-version.ts +41 -0
  84. package/gulp-tasks/modules/install-local-tools.js +122 -0
  85. package/gulp-tasks/modules/load-xml-file.js +12 -0
  86. package/gulp-tasks/modules/load-xml-file.ts +15 -0
  87. package/gulp-tasks/modules/log-config.js +31 -0
  88. package/gulp-tasks/modules/log.js +142 -0
  89. package/gulp-tasks/modules/longest-string-length.js +13 -0
  90. package/gulp-tasks/modules/looks-like-a-promise.js +11 -0
  91. package/gulp-tasks/modules/ls-r.js +52 -0
  92. package/gulp-tasks/modules/multi-split.js +29 -0
  93. package/gulp-tasks/modules/net-framework-test-assembly-filter.js +45 -0
  94. package/gulp-tasks/modules/nuget-push.js +66 -0
  95. package/gulp-tasks/modules/nuget-update-self.js +9 -0
  96. package/gulp-tasks/modules/nuget.js +8 -0
  97. package/gulp-tasks/modules/nuget.ts +14 -0
  98. package/gulp-tasks/modules/pad-left.js +4 -0
  99. package/gulp-tasks/modules/pad-right.js +4 -0
  100. package/gulp-tasks/modules/pad.js +25 -0
  101. package/gulp-tasks/modules/parse-xml-string.js +5 -0
  102. package/gulp-tasks/modules/parse-xml-string.ts +6 -0
  103. package/gulp-tasks/modules/parse-xml.js +14 -0
  104. package/gulp-tasks/modules/parse-xml.ts +15 -0
  105. package/gulp-tasks/modules/path-unquote.js +6 -0
  106. package/gulp-tasks/modules/promisify-function.js +19 -0
  107. package/gulp-tasks/modules/promisify-function.ts +18 -0
  108. package/gulp-tasks/modules/promisify-stream.js +73 -0
  109. package/gulp-tasks/modules/promisify.js +1 -0
  110. package/gulp-tasks/modules/quote-if-required.js +14 -0
  111. package/gulp-tasks/modules/read-all-git-branches.js +10 -0
  112. package/gulp-tasks/modules/read-all-git-branches.ts +13 -0
  113. package/gulp-tasks/modules/read-all-git-remotes.js +36 -0
  114. package/gulp-tasks/modules/read-all-git-remotes.ts +44 -0
  115. package/gulp-tasks/modules/read-csproj-package-version.js +16 -0
  116. package/gulp-tasks/modules/read-csproj-package-version.ts +26 -0
  117. package/gulp-tasks/modules/read-csproj-version.js +16 -0
  118. package/gulp-tasks/modules/read-csproj-version.ts +26 -0
  119. package/gulp-tasks/modules/read-current-git-branch.js +12 -0
  120. package/gulp-tasks/modules/read-current-git-branch.ts +16 -0
  121. package/gulp-tasks/modules/read-git-commit-delta-count.js +21 -0
  122. package/gulp-tasks/modules/read-git-commit-delta-count.ts +33 -0
  123. package/gulp-tasks/modules/read-git-info.js +28 -0
  124. package/gulp-tasks/modules/read-git-info.ts +31 -0
  125. package/gulp-tasks/modules/read-git-remote.js +17 -0
  126. package/gulp-tasks/modules/read-git-remote.ts +23 -0
  127. package/gulp-tasks/modules/read-last-fetch-time.js +21 -0
  128. package/gulp-tasks/modules/read-last-fetch-time.ts +17 -0
  129. package/gulp-tasks/modules/read-main-branch-name.js +48 -0
  130. package/gulp-tasks/modules/read-main-branch-name.ts +76 -0
  131. package/gulp-tasks/modules/read-nuspec-version.js +14 -0
  132. package/gulp-tasks/modules/read-nuspec-version.ts +22 -0
  133. package/gulp-tasks/modules/read-package-json.js +16 -0
  134. package/gulp-tasks/modules/read-package-json.ts +22 -0
  135. package/gulp-tasks/modules/read-package-version.js +8 -0
  136. package/gulp-tasks/modules/read-package-version.ts +10 -0
  137. package/gulp-tasks/modules/read-text-file.js +14 -0
  138. package/gulp-tasks/modules/read-text-file.ts +14 -0
  139. package/gulp-tasks/modules/reduce-gulp-noise.js +34 -0
  140. package/gulp-tasks/modules/register-environment-variables.js +526 -0
  141. package/gulp-tasks/modules/require-module.js +28 -0
  142. package/gulp-tasks/modules/resolve-git-branch.js +11 -0
  143. package/gulp-tasks/modules/resolve-git-branch.ts +13 -0
  144. package/gulp-tasks/modules/resolve-git-remote.js +11 -0
  145. package/gulp-tasks/modules/resolve-git-remote.ts +13 -0
  146. package/gulp-tasks/modules/resolve-masks.js +47 -0
  147. package/gulp-tasks/modules/resolve-nuget.js +135 -0
  148. package/gulp-tasks/modules/resolve-test-masks.js +10 -0
  149. package/gulp-tasks/modules/rewrite-file.js +26 -0
  150. package/gulp-tasks/modules/rewrite-file.ts +34 -0
  151. package/gulp-tasks/modules/rimraf.js +21 -0
  152. package/gulp-tasks/modules/rimraf.ts +31 -0
  153. package/gulp-tasks/modules/run-sequence.js +16 -0
  154. package/gulp-tasks/modules/safe-git.js +23 -0
  155. package/gulp-tasks/modules/safe-git.ts +23 -0
  156. package/gulp-tasks/modules/seed.js +12 -0
  157. package/gulp-tasks/modules/set-task-name.js +9 -0
  158. package/gulp-tasks/modules/sleep.js +5 -0
  159. package/gulp-tasks/modules/spawn-nuget.js +13 -0
  160. package/gulp-tasks/modules/spawn.js +103 -0
  161. package/gulp-tasks/modules/split-path.js +3 -0
  162. package/gulp-tasks/modules/stat.js +8 -0
  163. package/gulp-tasks/modules/status.js +57 -0
  164. package/gulp-tasks/modules/status.ts +71 -0
  165. package/gulp-tasks/modules/test-path.js +3 -0
  166. package/gulp-tasks/modules/testutil-finder.js +176 -0
  167. package/gulp-tasks/modules/throw-if-no-files.js +15 -0
  168. package/gulp-tasks/modules/uniq.js +6 -0
  169. package/gulp-tasks/modules/uniq.ts +5 -0
  170. package/gulp-tasks/modules/verify-exe.js +17 -0
  171. package/gulp-tasks/modules/version-reading-shared.js +12 -0
  172. package/gulp-tasks/modules/version-reading-shared.ts +16 -0
  173. package/gulp-tasks/modules/write-text-file.js +10 -0
  174. package/gulp-tasks/modules/zarro-error.js +6 -0
  175. package/gulp-tasks/nuget-restore.js +57 -0
  176. package/gulp-tasks/pack.js +118 -0
  177. package/gulp-tasks/purge.js +94 -0
  178. package/gulp-tasks/release-npm.js +58 -0
  179. package/gulp-tasks/release-npm.ts +81 -0
  180. package/gulp-tasks/start/_package.json +39 -0
  181. package/gulp-tasks/start/gulpfile.js +204 -0
  182. package/gulp-tasks/start/update-starter-packages.js +63 -0
  183. package/gulp-tasks/test-dotnet.js +195 -0
  184. package/gulp-tasks/update-git-submodules.js +11 -0
  185. package/gulp-tasks/update-git-submodules.ts +29 -0
  186. package/gulp-tasks/update-self.js +65 -0
  187. package/gulp-tasks/update-self.ts +88 -0
  188. package/gulp-tasks/verify-up-to-date.js +77 -0
  189. package/gulp-tasks/verify-up-to-date.ts +119 -0
  190. package/index-modules/contains-any.js +31 -0
  191. package/index-modules/gather-args.js +21 -0
  192. package/index-modules/handlers/help.js +17 -0
  193. package/index-modules/handlers/init.js +57 -0
  194. package/index-modules/handlers/invoke-gulp.js +111 -0
  195. package/index-modules/handlers/show-env.js +46 -0
  196. package/index-modules/is-dir.js +6 -0
  197. package/index-modules/is-file.js +6 -0
  198. package/index.js +53 -0
  199. package/package.json +96 -0
  200. package/tsconfig.json +66 -0
  201. package/types.d.ts +753 -0
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ (function () {
3
+ const fs = require("./fs"), { ZarroError } = requireModule("zarro-error"), parse = requireModule("./parse-xml-string");
4
+ module.exports = async function (filePath) {
5
+ const st = await fs.stat(filePath);
6
+ if (!st.isFile()) {
7
+ throw new ZarroError(`File not found: ${filePath}`);
8
+ }
9
+ const data = await fs.readFile(filePath, { encoding: "utf-8" });
10
+ return parse(data);
11
+ };
12
+ })();
@@ -0,0 +1,15 @@
1
+ (function () {
2
+ const
3
+ fs = require("./fs"),
4
+ { ZarroError } = requireModule("zarro-error"),
5
+ parse = requireModule<ParseXmlString>("./parse-xml-string");
6
+
7
+ module.exports = async function (filePath: string) {
8
+ const st = await fs.stat(filePath);
9
+ if (!st.isFile()) {
10
+ throw new ZarroError(`File not found: ${filePath}`);
11
+ }
12
+ const data = await fs.readFile(filePath, { encoding: "utf-8" });
13
+ return parse(data);
14
+ }
15
+ })();
@@ -0,0 +1,31 @@
1
+ const
2
+ padRight = require("./pad-right"),
3
+ log = requireModule("log"),
4
+ chalk = require("ansi-colors");
5
+
6
+ function output(logLines) {
7
+ const longest = logLines
8
+ .map(o => o.title.length)
9
+ .reduce((acc, cur) => (acc > cur ? acc : cur), 0);
10
+ logLines
11
+ .sort((a, b) => (a.title > b.title ? 1 : 0))
12
+ .forEach(line => {
13
+ const pre = chalk.yellowBright(padRight(line.title, longest)),
14
+ next = chalk.cyanBright(`${line.value}`);
15
+ log.info(`${pre} : ${next}`);
16
+ });
17
+ }
18
+
19
+ function store(logLines, config, prop, title) {
20
+ const value = config[prop];
21
+ if (value !== undefined) {
22
+ logLines.push({ title, value });
23
+ }
24
+ return logLines
25
+ }
26
+
27
+ module.exports = function logConfig(config, labels) {
28
+ const logLines = Object.keys(labels).reduce(
29
+ (acc, cur) => store(acc, config, cur, labels[cur]), []);
30
+ output(logLines);
31
+ }
@@ -0,0 +1,142 @@
1
+ const gutil = requireModule("gulp-util"),
2
+ DEBUG = 1,
3
+ INFO = 2,
4
+ NOTICE = 3,
5
+ WARNING = 4,
6
+ ERROR = 5,
7
+ levels = {
8
+ DEBUG,
9
+ INFO,
10
+ NOTICE,
11
+ WARNING
12
+ };
13
+ const LogLevels = function () {
14
+ };
15
+ LogLevels.prototype = {
16
+ get Debug() {
17
+ return DEBUG;
18
+ },
19
+ get Info() {
20
+ return INFO;
21
+ },
22
+ get Notice() {
23
+ return NOTICE;
24
+ },
25
+ get Warning() {
26
+ return WARNING;
27
+ },
28
+ get Error() {
29
+ return ERROR;
30
+ }
31
+ };
32
+ const Logger = function () {
33
+ this.LogLevels = new LogLevels();
34
+ const logLevel = (process.env.LOG_LEVEL || "").toUpperCase();
35
+ this.setThreshold(levels[logLevel] || INFO);
36
+ this._timestamp = true;
37
+ };
38
+ Logger.prototype = {
39
+ get threshold() {
40
+ return this._threshold;
41
+ },
42
+ setThreshold: function(value) {
43
+ const intValue = parseInt(value);
44
+ if (isNaN(intValue) || intValue < 1 || intValue > 5) {
45
+ throw value +
46
+ " is not a valid integer value. Try use one of (logger).LogLevels.{Debug|Info|Notice|Warning|Error}";
47
+ }
48
+ this._threshold = intValue;
49
+ },
50
+ debug: function() {
51
+ const message = this._resolve(Array.from(arguments));
52
+ if (this._threshold > DEBUG) return;
53
+ this._print(message, "grey");
54
+ },
55
+ info: function() {
56
+ const message = this._resolve(Array.from(arguments));
57
+ if (this._threshold > INFO) return;
58
+ this._print(message, "yellow");
59
+ },
60
+ warning: function() {
61
+ const message = this._resolve(Array.from(arguments));
62
+ if (this._threshold > WARNING) return;
63
+ this._print(message, "magenta");
64
+ },
65
+ error: function() {
66
+ const message = this._resolve(Array.from(arguments));
67
+ this._print(message, "red", "bold");
68
+ },
69
+ fail: function() {
70
+ const message = this._resolve(Array.from(arguments));
71
+ this.error(message);
72
+ },
73
+ ok: function() {
74
+ const message = this._resolve(Array.from(arguments));
75
+ this._print(message, "green");
76
+ },
77
+ notice: function() {
78
+ const message = this._resolve(Array.from(arguments));
79
+ if (this._threshold > NOTICE) return;
80
+ this._print(message, "cyan");
81
+ },
82
+ suppressTimeStamps: function() {
83
+ this._timestamp = false;
84
+ },
85
+ showTimeStamps: function() {
86
+ this._timestamp = true;
87
+ },
88
+ _resolve: function(args) {
89
+ return args
90
+ .map(a => {
91
+ if (a === undefined) {
92
+ return "(undefined)";
93
+ }
94
+ if (a === null) {
95
+ return "(null)";
96
+ }
97
+ if (Array.isArray(a)) {
98
+ return a.join(",");
99
+ }
100
+ if (typeof a === "object") {
101
+ return JSON.stringify(a);
102
+ }
103
+ return a.toString();
104
+ })
105
+ .join(" ");
106
+ },
107
+ _print: function() {
108
+ const message = arguments[0];
109
+ const styles = [];
110
+ for (let i = 1; i < arguments.length; i++) {
111
+ styles.push(arguments[i]); // because arguments is an object, not an array...
112
+ }
113
+ const styleFunction = styles.reduce(
114
+ function (acc, cur) {
115
+ const fn = gutil.colors[cur];
116
+ if (fn === undefined) {
117
+ return acc;
118
+ }
119
+ return function (s) {
120
+ return fn(acc(s));
121
+ };
122
+ },
123
+ function (s) {
124
+ return s;
125
+ }
126
+ );
127
+ if (this._timestamp) {
128
+ gutil.log(styleFunction(message));
129
+ } else {
130
+ console.log(styleFunction(message));
131
+ }
132
+ }
133
+ };
134
+ const logger = new Logger();
135
+ if (logger.threshold === DEBUG) {
136
+ logger.debug(" -- testing logger outputs -- ");
137
+ logger.debug("debug message");
138
+ logger.info("info message");
139
+ logger.warning("warning message");
140
+ logger.error("error message");
141
+ }
142
+ module.exports = logger;
@@ -0,0 +1,13 @@
1
+ module.exports = function longestStringLength(arr) {
2
+ if (!arr) {
3
+ arr = "";
4
+ }
5
+ if (!Array.isArray(arr)) {
6
+ arr = [arr];
7
+ }
8
+ return arr.reduce(
9
+ (acc, cur) => {
10
+ const currentLength = ((cur || "").toString()).length;
11
+ return acc > currentLength ? acc : currentLength;
12
+ }, 0);
13
+ }
@@ -0,0 +1,11 @@
1
+ module.exports = function(obj) {
2
+ if (!obj) {
3
+ return false;
4
+ }
5
+ if (obj instanceof Promise) {
6
+ return true;
7
+ }
8
+ return typeof obj === "object" &&
9
+ obj.then &&
10
+ typeof obj.then === "function";
11
+ }
@@ -0,0 +1,52 @@
1
+ var fs = require('fs'),
2
+ path = require('path'),
3
+ debug = require('debug')('ls-r');
4
+
5
+ function isDir(p) {
6
+ try {
7
+ return fs.lstatSync(p).isDirectory();
8
+ } catch (ignore) {
9
+ return false;
10
+ }
11
+ }
12
+
13
+ function push(arr, item) {
14
+ arr.push(item);
15
+ return arr;
16
+ }
17
+
18
+ var defaultIgnores = [/node_modules/, /\.git/, /bower_components/];
19
+ function tryReadDirSync(dir) {
20
+ try {
21
+ return fs.readdirSync(dir);
22
+ } catch (e) {
23
+ debug(`Error reading dir contents for ${dir} : ${e}`);
24
+ return [];
25
+ }
26
+ }
27
+
28
+ function ls_R(dir, ignores) {
29
+ dir = path.resolve(dir);
30
+ if (!fs.existsSync(dir)) {
31
+ return [];
32
+ }
33
+ ignores = ignores || defaultIgnores;
34
+ var current = tryReadDirSync(dir);
35
+ return current.reduce((acc, cur) => {
36
+ var fullPath = path.join(dir, cur);
37
+ var shouldIgnore = ignores.reduce((acc, cur) => {
38
+ return acc || cur.test(fullPath);
39
+ }, false);
40
+ if (shouldIgnore) {
41
+ debug(`ignoring ${fullPath}`);
42
+ return acc;
43
+ }
44
+ return isDir(fullPath)
45
+ ? acc.concat(ls_R(fullPath, ignores))
46
+ : push(acc, fullPath);
47
+ }, []);
48
+ }
49
+
50
+ ls_R.DEFAULT_IGNORES = defaultIgnores;
51
+
52
+ module.exports = ls_R;
@@ -0,0 +1,29 @@
1
+ function flatten(arrayOrValue) {
2
+ return arrayOrValue.reduce((acc, cur) => {
3
+ if (Array.isArray(cur)) {
4
+ acc.push.apply(acc, flatten(cur));
5
+ } else {
6
+ acc.push(cur);
7
+ }
8
+ return acc;
9
+ }, []);
10
+ }
11
+ module.exports = function multiSplit(str, delimiters) {
12
+ if (!str) {
13
+ return [];
14
+ }
15
+ delimiters = delimiters || "";
16
+ if (!Array.isArray(delimiters)) {
17
+ delimiters = [delimiters];
18
+ }
19
+ return flatten(
20
+ delimiters.reduce(
21
+ (allIterations, currentDelimiter) => {
22
+ return allIterations.reduce((subParts, part) => {
23
+ return subParts.concat(part.split(currentDelimiter));
24
+ }, []);
25
+ },
26
+ [str]
27
+ )
28
+ );
29
+ };
@@ -0,0 +1,45 @@
1
+ const multiSplit = require("./multi-split"),
2
+ debug = require("debug")("net-framework-test-assembly-filter");
3
+
4
+ function findBuildConfigFrom(pathParts) {
5
+ const oneUp = pathParts[pathParts.length - 2];
6
+ if (oneUp === undefined) {
7
+ return "";
8
+ }
9
+ if (oneUp.match(/^net(standard\d\.\d|\d{3}|coreapp\d\.\d)$/)) {
10
+ // one-up is a release target... travel one higher
11
+ return pathParts[pathParts.length - 3] || "";
12
+ }
13
+ return oneUp;
14
+ }
15
+
16
+ module.exports = function generateFilter(configuration) {
17
+ return function netFrameworkTestAssemblyFilter(vinylFile) {
18
+ const parts = multiSplit(vinylFile.path, ["/", "\\"]),
19
+ isNetCore = !!parts.filter(p => p.match(/^netcore/)).length,
20
+ assemblyName = parts[parts.length - 1].replace(/\.dll$/gi, ""),
21
+ isPrimary = !!parts
22
+ .slice(0, parts.length - 1)
23
+ .filter(p => p.toLowerCase() === assemblyName.toLowerCase()).length;
24
+ (isBin = !!parts.filter(p => p.match(/^bin$/i)).length),
25
+ (buildConfig = findBuildConfigFrom(parts)),
26
+ (isDebug = buildConfig.toLowerCase() === "debug"),
27
+ (isForConfig = buildConfig.toLowerCase() === configuration.toLowerCase()),
28
+ (isAny = (parts[parts.length - 1] || "").toLowerCase() === "bin"),
29
+ (include =
30
+ !isNetCore && isPrimary && isBin && (isDebug || isAny || isForConfig));
31
+ debug({
32
+ path: vinylFile.path,
33
+ parts,
34
+ buildConfig,
35
+ isNetCore,
36
+ isPrimary,
37
+ isDebug,
38
+ isAny,
39
+ isBin,
40
+ isForConfig,
41
+ include
42
+ });
43
+ return include;
44
+ };
45
+ };
@@ -0,0 +1,66 @@
1
+ const
2
+ spawn = require("./spawn"),
3
+ quoteIfRequired = require("./quote-if-required"),
4
+ splitPath = require("./split-path"),
5
+ env = require("./env"),
6
+ findLocalNuget = require("./find-local-nuget");
7
+
8
+ function isDotnetCore(binaryPath) {
9
+ const
10
+ trimmed = binaryPath.replace(/^"/, "")
11
+ .replace(/"$/, ""),
12
+ parts = splitPath(trimmed),
13
+ executable = (parts[parts.length-1] || "");
14
+ return !!executable.match(/^dotnet(:?\.exe)?$/i);
15
+ }
16
+
17
+ async function nugetPush(
18
+ packageFile,
19
+ sourceName,
20
+ options) {
21
+ options = options || {};
22
+ options.suppressDuplicateError = options.suppressDuplicateError === undefined
23
+ ? env.resolveFlag("NUGET_IGNORE_DUPLICATE_PACKAGES")
24
+ : options.suppressDuplicateError;
25
+
26
+ const
27
+ apiKey = env.resolve("NUGET_API_KEY"),
28
+ nuget = await findLocalNuget(),
29
+ dnc = isDotnetCore(nuget),
30
+ sourceArg = dnc ? "--source" : "-Source",
31
+ // ffs dotnet core breaks things that used to be simple
32
+ // -> _some_ nuget commands require 'dotnet nuget ...'
33
+ // -> _others_ don't, eg 'dotnet restore'
34
+ start = dnc ? [ "nuget" ] : [],
35
+ args = start.concat([
36
+ "push",
37
+ quoteIfRequired(packageFile),
38
+ sourceArg,
39
+ sourceName || "nuget.org"
40
+ ]),
41
+ apiKeyArg = dnc ? "-k" : "-ApiKey";
42
+ if (apiKey) {
43
+ args.push.call(args, apiKeyArg, apiKey);
44
+ }
45
+ if (env.resolveFlag("DRY_RUN")) {
46
+ console.log(`nuget publish dry run: ${nuget} ${args.join(" ")}`);
47
+ return;
48
+ }
49
+ console.log(`pushing package ${packageFile}`);
50
+ try {
51
+ return await spawn(nuget, args);
52
+ } catch (e) {
53
+ if (e.info && Array.isArray(e.info.stderr)) {
54
+ const
55
+ errors = e.stderr.join("\n").trim(),
56
+ isDuplicatePackageError = errors.match(/: 409 /);
57
+ if (isDuplicatePackageError && options.suppressDuplicateError) {
58
+ console.warn(`ignoring duplicate package error: ${errors}`);
59
+ return e.info;
60
+ }
61
+ }
62
+ throw e;
63
+ }
64
+ }
65
+
66
+ module.exports = nugetPush;
@@ -0,0 +1,9 @@
1
+ const
2
+ exec = requireModule("exec");
3
+ let updating = null;
4
+ module.exports = function (nugetPath) {
5
+ if (updating) {
6
+ return updating;
7
+ }
8
+ return exec(nugetPath, [ "update", "-self" ]);
9
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ (function () {
3
+ const resolveNuget = require("./resolve-nuget"), findLocalNuget = require("./find-local-nuget"), exec = require("./exec");
4
+ module.exports = async function (args, execOpts) {
5
+ const resolvedNuget = await resolveNuget(null, false), nugetPath = resolvedNuget || await findLocalNuget(), argsCopy = args.slice();
6
+ return exec(nugetPath, argsCopy, execOpts);
7
+ };
8
+ })();