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,39 @@
1
+ {
2
+ "name": "this-is-used-as-a-reference-for-dev-dependencies-only-disregarding-versions",
3
+ "devDependencies": {
4
+ "ansi-colors": "^4.0.1",
5
+ "chai": "^4.2.0",
6
+ "chalk": "^2.4.2",
7
+ "cross-env": "^5.2.0",
8
+ "debug": "^4.1.1",
9
+ "del": "^4.1.1",
10
+ "event-stream": "^4.0.1",
11
+ "fancy-log": "^1.3.3",
12
+ "gulp": "^4.0.2",
13
+ "gulp-debug": "^4.0.0",
14
+ "gulp-dotnet-cli": "^1.1.0",
15
+ "gulp-edit-xml": "https://github.com/fluffynuts/gulp-edit-xml.git#pass-file-to-transform",
16
+ "gulp-filter": "^6.0.0",
17
+ "gulp-help": "^1.6.1",
18
+ "gulp-msbuild": "^0.5.5",
19
+ "gulp-nunit-runner": "^1.2.3",
20
+ "inquirer": "^6.4.1",
21
+ "mkdirp": "^0.5.1",
22
+ "nodemon": "^1.19.1",
23
+ "npm-run-all": "^4.1.5",
24
+ "plugin-error": "^1.0.1",
25
+ "proxyquire": "^2.1.0",
26
+ "q": "^1.5.1",
27
+ "readline": "^1.3.0",
28
+ "request": "^2.88.0",
29
+ "require-dir": "^1.2.0",
30
+ "requirejs": "^2.3.6",
31
+ "run-sequence": "^2.2.1",
32
+ "simple-git": "^1.116.0",
33
+ "temp": "^0.9.0",
34
+ "through2": "^3.0.1",
35
+ "undertaker-forward-reference": "^1.0.2",
36
+ "which": "^1.3.1",
37
+ "xml2js": "^0.4.19"
38
+ }
39
+ }
@@ -0,0 +1,204 @@
1
+ /*
2
+ Welcome new user!
3
+
4
+ To get started, copy this gulpfile.js to the root of your repo and run:
5
+ `node gulpfile.js`
6
+ You should be guided through the basic setup. More information in README.md. In
7
+ particular, I highly recommend reading about how to use `local-tasks` to extend
8
+ and / or override the default task-set.
9
+ */
10
+
11
+ const
12
+ path = require("path"),
13
+ fs = require("fs");
14
+
15
+ function tryFindGulpTasks() {
16
+ const attempts = [
17
+ path.join(__dirname, "gulp-tasks"),
18
+ path.join(__dirname, "..", "..", "gulp-tasks")
19
+ ];
20
+ for (let attempt of attempts) {
21
+ try {
22
+ const st = fs.statSync(attempt);
23
+ if (st && st.isDirectory()) {
24
+ return attempt;
25
+ }
26
+ } catch (e) {
27
+ continue;
28
+ }
29
+ }
30
+ throw new Error("Can't automagically find gulp-tasks folder; try defining GULP_TASKS_FOLDER env var");
31
+ }
32
+
33
+ const
34
+ gulpTasksFolder = process.env.GULP_TASKS_FOLDER || tryFindGulpTasks(),
35
+ requireModule = require(path.join(gulpTasksFolder, "modules", "require-module"));
36
+
37
+ if (!fs.existsSync(gulpTasksFolder)) {
38
+ console.error("Either clone `gulp-tasks` to the `gulp-tasks` folder or modify this script to avoid sadness");
39
+ process.exit(2);
40
+ }
41
+
42
+ let autoWorking = null;
43
+
44
+ function pauseWhilstWorking() {
45
+ const
46
+ args = process.argv,
47
+ lastTwo = args.slice(args.length - 2),
48
+ runningGulp = isGulpJs(lastTwo[0]),
49
+ task = lastTwo[1];
50
+ if (!runningGulp || !task) {
51
+ return;
52
+ }
53
+ autoWorking = true;
54
+ try {
55
+ const localGulp = require("gulp");
56
+ localGulp.task(task, function () {
57
+ console.log(`--- taking over your ${task} task whilst we do some bootstrapping ---`);
58
+ return new Promise(function watchWorker(resolve, reject) {
59
+ if (!autoWorking) {
60
+ return resolve();
61
+ }
62
+ setTimeout(function () {
63
+ watchWorker(resolve, reject);
64
+ }, 500);
65
+ });
66
+ });
67
+ } catch (e) {
68
+ /* suppress: may not have deps installed yet */
69
+ }
70
+ }
71
+
72
+ function isGulpJs(filePath) {
73
+ return path.basename(filePath) === "gulp.js";
74
+ }
75
+
76
+ if (!fs.existsSync("package.json")) {
77
+ pauseWhilstWorking();
78
+ console.log(
79
+ "You need to set up a package.json first. I'll run `npm init` for you (:"
80
+ );
81
+ initializeNpm().then(() => autoWorking = false);
82
+ } else if (mustInstallDeps()) {
83
+ pauseWhilstWorking();
84
+ console.log(
85
+ "Now we just need to install the dependencies required for gulp-tasks to run (:"
86
+ );
87
+ installGulpTaskDependencies().then(() => {
88
+ console.log("You're good to go with `gulp-tasks`. Try running `npm run gulp build`");
89
+ autoWorking = false;
90
+ });
91
+ } else {
92
+ bootstrapGulp();
93
+ }
94
+
95
+ function requiredDeps() {
96
+ const starter = require(path.join(gulpTasksFolder, "start", "package.json"));
97
+ return Object.keys(starter.devDependencies);
98
+ }
99
+
100
+ function mustInstallDeps() {
101
+ if (process.env.RUNNING_AS_ZARRO) {
102
+ // deps should be properly handled by zarro package index and initial installation
103
+ return false;
104
+ }
105
+ const package = require("./package.json"),
106
+ devDeps = package.devDependencies || {},
107
+ haveDeps = Object.keys(devDeps),
108
+ needDeps = requiredDeps();
109
+ const result = needDeps.reduce((acc, cur) => {
110
+ return acc || haveDeps.indexOf(cur) == -1;
111
+ }, false);
112
+ return result;
113
+ }
114
+
115
+ function initializeNpm() {
116
+ const spawn = requireModule("spawn");
117
+ const os = require("os");
118
+ return runNpmWith([ "init" ])
119
+ .then(() => {
120
+ if (os.platform() === "win32") {
121
+ spawn("cmd", [ "/c", "node", process.argv[1] ]);
122
+ } else {
123
+ spawn("node", [ process.argv[1] ]);
124
+ }
125
+ });
126
+ }
127
+
128
+ function addMissingScript(package, name, script) {
129
+ package.scripts[name] = package.scripts[name] || script;
130
+ }
131
+
132
+ function installGulpTaskDependencies() {
133
+ const findFirstMissing = function () {
134
+ const args = Array.from(arguments);
135
+ return args.reduce((acc, cur) => acc || (fs.existsSync(cur) ? acc : cur), undefined);
136
+ },
137
+ deps = requiredDeps(),
138
+ package = require("./package.json"),
139
+ buildTools = findFirstMissing("tools", "build-tools", ".tools", ".build-tools"),
140
+ prepend = `cross-env BUILD_TOOLS_FOLDER=${buildTools}`;
141
+
142
+ addMissingScript(package, "gulp", `${prepend} gulp`);
143
+ addMissingScript(package, "test", "run-s \"gulp test-dotnet\"");
144
+
145
+ fs.writeFileSync("package.json", JSON.stringify(package, null, 4), { encoding: "utf8" });
146
+ return runNpmWith([ "install", "--save-dev" ].concat(deps));
147
+ }
148
+
149
+ function bootstrapGulp() {
150
+ const importNpmTasks = requireModule("import-npm-tasks");
151
+ try {
152
+ importNpmTasks();
153
+ const requireDir = require("require-dir");
154
+ requireDir(gulpTasksFolder);
155
+ [ "local-tasks", "override-tasks" ].forEach(function (dirname) {
156
+ const fullPath = path.join(process.cwd(), dirname);
157
+ if (fs.existsSync(fullPath)) {
158
+ requireDir(fullPath);
159
+ }
160
+ });
161
+ } catch (e) {
162
+ if (shouldDump(e)) {
163
+ console.error(e);
164
+ } else {
165
+ if (!process.env.DEBUG) {
166
+ console.log(
167
+ "Error occurred. For more info, set the DEBUG environment variable (eg set DEBUG=*)."
168
+ );
169
+ }
170
+ }
171
+ process.exit(1);
172
+ }
173
+
174
+ function shouldDump(e) {
175
+ return isZarroError(e) ||
176
+ process.env.ALWAYS_DUMP_GULP_ERRORS ||
177
+ process.env.DEBUG === "*" ||
178
+ probablyNotReportedByGulp(e);
179
+ }
180
+
181
+ function isZarroError(e) {
182
+ return e && e.constructor.name === "ZarroError";
183
+ }
184
+
185
+ function probablyNotReportedByGulp(e) {
186
+ const
187
+ message = (e || "").toString().toLowerCase();
188
+ return [ "cannot find module", "referenceerror", "syntaxerror" ].reduce(
189
+ (acc, cur) => {
190
+ return acc || message.indexOf(cur) > -1;
191
+ },
192
+ false
193
+ );
194
+ }
195
+ }
196
+
197
+ function runNpmWith(args) {
198
+ const spawn = requireModule("spawn");
199
+ const os = require("os");
200
+
201
+ return os.platform() === "win32"
202
+ ? spawn("cmd", [ "/c", "npm" ].concat(args))
203
+ : spawn("npm", args);
204
+ }
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ const
3
+ path = require("path"),
4
+ fs = require("fs"),
5
+ ioOpts = {
6
+ encoding: "utf-8"
7
+ },
8
+ log = function() {
9
+ try {
10
+ console.log.apply(console, Array.from(arguments));
11
+ return true;
12
+ } catch (e) {
13
+ return false;
14
+ }
15
+ },
16
+ srcFile = "package.json",
17
+ srcPath = path.join(path.dirname(__dirname), srcFile),
18
+ targetPath = path.join(__dirname, "start", srcFile),
19
+ readJson = function (p) {
20
+ return JSON.parse(fs.readFileSync(p, ioOpts.encoding));
21
+ },
22
+ srcConfig = readJson(srcPath),
23
+ targetConfig = readJson(targetPath),
24
+ updateKeys = function (src, target) {
25
+ let updated = 0;
26
+ Object.keys(src).forEach(k => {
27
+ if (!target[k] || target[k] === src[k]) {
28
+ return;
29
+ }
30
+ log(`${k}: ${target[k]} -> ${src[k]}`);
31
+ target[k] = src[k];
32
+ updated++;
33
+ });
34
+ return updated;
35
+ },
36
+ updateConfigSection = function (srcConfig, targetConfig, section) {
37
+ const
38
+ srcSection = srcConfig[section] || {},
39
+ targetSection = targetConfig[section] || {};
40
+ return updateKeys(srcSection, targetSection);
41
+ },
42
+ updated = ["dependencies", "devDependencies"]
43
+ .reduce((acc, cur) => acc += updateConfigSection(srcConfig, targetConfig, cur), 0),
44
+ prettyJson = function(data) {
45
+ return JSON.stringify(data, null, 2);
46
+ },
47
+ rewrite = function(updated, filePath, data) {
48
+ try {
49
+ fs.writeFileSync(filePath, prettyJson(data), ioOpts);
50
+ return { success: true };
51
+ } catch (e) {
52
+ return { success: false, error: e };
53
+ }
54
+ },
55
+ status = updated
56
+ ? rewrite(updated, targetPath, targetConfig)
57
+ : { success: true, error: "No dependencies to update" },
58
+ logged = log(
59
+ status.success
60
+ ? status.error || `Updated ${updated} dependency versions`
61
+ : status.error
62
+ );
63
+ process.exit(logged && status.success ? 0 : 1);
@@ -0,0 +1,195 @@
1
+ const
2
+ seed = requireModule("seed"),
3
+ gulp = requireModule("gulp"),
4
+ log = requireModule("log"),
5
+ path = require("path"),
6
+ gulpDebug = require("gulp-debug"),
7
+ debug = require("debug")("test-dotnet"),
8
+ filter = require("gulp-filter"),
9
+ fs = require("fs"),
10
+ promisifyStream = requireModule("promisify"),
11
+ { test } = require("gulp-dotnet-cli"),
12
+ nunit = require("./modules/gulp-nunit-runner"),
13
+ testUtilFinder = requireModule("testutil-finder"),
14
+ env = requireModule("env"),
15
+ resolveTestMasks = requireModule("resolve-test-masks"),
16
+ logConfig = requireModule("log-config"),
17
+ gatherPaths = requireModule("gather-paths"),
18
+ netFrameworkTestAssemblyFilter = requireModule("net-framework-test-assembly-filter");
19
+
20
+ gulp.task(
21
+ "test-dotnet",
22
+ `Runs all tests in your solution via NUnit *`,
23
+ [ "build" ],
24
+ runTests
25
+ );
26
+
27
+ gulp.task(
28
+ "quick-test-dotnet",
29
+ `Tests whatever test assemblies have been recently built *`,
30
+ runTests
31
+ );
32
+
33
+ const myTasks = [ "test-dotnet", "quick-test-dotnet" ],
34
+ myVars = [
35
+ "BUILD_CONFIGURATION",
36
+ "DOTNET_CORE",
37
+ "TEST_INCLUDE",
38
+ "TEST_EXCLUDE",
39
+ "MAX_NUNIT_AGENTS",
40
+ "MAX_CONCURRENCY",
41
+ "BUILD_REPORT_XML",
42
+ "NUNIT_ARCHITECTURE",
43
+ "NUNIT_LABELS",
44
+ "TEST_VERBOSITY",
45
+ "DOTNET_TEST_PARALLEL"
46
+ ];
47
+ env.associate(myVars, myTasks);
48
+
49
+ async function runTests() {
50
+ const buildReportFolder = path.dirname(env.resolve("BUILD_REPORT_XML"));
51
+ if (!fs.existsSync(buildReportFolder)) {
52
+ fs.mkdirSync(buildReportFolder);
53
+ }
54
+
55
+ const dotNetCore = env.resolveFlag("DOTNET_CORE");
56
+ const testMasks = resolveTestMasks(dotNetCore),
57
+ configuration = env.resolve("BUILD_CONFIGURATION"),
58
+ tester = dotNetCore ? testAsDotnetCore : testWithNunitCli;
59
+
60
+ debug({
61
+ tester,
62
+ configuration,
63
+ testMasks
64
+ });
65
+ return tester(configuration, testMasks);
66
+ }
67
+
68
+ function consolidatePathEnvVar() {
69
+ const keys = Object.keys(process.env)
70
+ .filter(k => k.toLowerCase() === "path");
71
+ if (keys.length === 1) {
72
+ return;
73
+ }
74
+ const sep = process.platform === "win32"
75
+ ? ";"
76
+ : ":";
77
+ const include = [];
78
+ keys.forEach(k => {
79
+ const parts = process.env[k].split(sep);
80
+ parts.forEach(p => {
81
+ if (include.indexOf(p) === -1) {
82
+ include.push(p);
83
+ }
84
+ });
85
+ });
86
+ keys.forEach(k => process.env[k] = "");
87
+ process.env.PATH = include.join(sep);
88
+ }
89
+
90
+ function testWithNunitCli(configuration, source) {
91
+ consolidatePathEnvVar();
92
+ const agents = env.resolveNumber("MAX_NUNIT_AGENTS");
93
+ const seenAssemblies = [];
94
+ const config = {
95
+ executable: testUtilFinder.latestNUnit({
96
+ architecture: env.resolve("NUNIT_ARCHITECTURE")
97
+ }),
98
+ options: {
99
+ result: env.resolve("BUILD_REPORT_XML"),
100
+ agents: agents,
101
+ labels: env.resolve("NUNIT_LABELS"),
102
+ }
103
+ };
104
+ const nunitProcess = env.resolve("NUNIT_PROCESS");
105
+ const logInfo = {
106
+ result: "Where to store test result (xml file)",
107
+ labels: "What labels NUnit should display as tests run",
108
+ agents: "How many NUnit agents to run"
109
+ }
110
+ if (nunitProcess !== "auto") {
111
+ config.options.process = nunitProcess;
112
+ logInfo.process = "Process model for NUnit";
113
+ }
114
+ log.info(`Using NUnit runner at ${config.executable}`);
115
+ log.info("Find files:", source);
116
+ logConfig(config.options, logInfo);
117
+ debug({
118
+ config
119
+ });
120
+ return promisifyStream(
121
+ gulp
122
+ .src(source, {
123
+ read: false
124
+ })
125
+ .pipe(
126
+ filter(netFrameworkTestAssemblyFilter(configuration))
127
+ )
128
+ .pipe(gulpDebug({ title: "before filter", logger: debug }))
129
+ .pipe(filter(file => isDistinctFile(file.path, seenAssemblies)))
130
+ .pipe(gulpDebug({ title: "after filter", logger: debug }))
131
+ .pipe(nunit(config))
132
+ );
133
+ }
134
+
135
+ function makeTestsPromise(
136
+ projectPaths,
137
+ configuration
138
+ ) {
139
+ if (!Array.isArray(projectPaths)) {
140
+ projectPaths = [ projectPaths ];
141
+ }
142
+ return promisifyStream(
143
+ gulp.src(projectPaths).pipe(
144
+ test({
145
+ verbosity: env.resolve("TEST_VERBOSITY"),
146
+ configuration,
147
+ noBuild: true
148
+ })
149
+ )
150
+ );
151
+ }
152
+
153
+
154
+ async function testAsDotnetCore(configuration, testProjects) {
155
+ // TODO: collect all projects in an array and then
156
+ // run test projects in parallel, throttled by MAX_CONCURRENCY
157
+ if (env.resolveFlag("DOTNET_TEST_PARALLEL")) {
158
+ const
159
+ testProjectPaths = await gatherPaths(testProjects),
160
+ concurrency = env.resolveNumber("MAX_CONCURRENCY"),
161
+ chains = seed(concurrency).map(() => Promise.resolve());
162
+ let p, current = 0;
163
+ while (p = testProjectPaths.shift()) {
164
+ p = p.replace(/\\/g, "/");
165
+ console.log("add test run:", p);
166
+ const
167
+ idx = current++ % concurrency,
168
+ localP = p;
169
+ chains[idx] = chains[idx].then(() => {
170
+ console.log(`${idx} start test run: ${localP}`);
171
+ return makeTestsPromise(localP, configuration);
172
+ });
173
+ }
174
+ return Promise.all(chains);
175
+ } else {
176
+ return promisifyStream(
177
+ gulp.src(testProjects).pipe(
178
+ test({
179
+ verbosity: env.resolve("TEST_VERBOSITY"),
180
+ configuration,
181
+ noBuild: true
182
+ })
183
+ )
184
+ );
185
+ }
186
+ }
187
+
188
+ function isDistinctFile(filePath, seenFiles) {
189
+ const basename = path.basename(filePath),
190
+ result = seenFiles.indexOf(basename) === -1;
191
+ if (result) {
192
+ seenFiles.push(basename);
193
+ }
194
+ return result;
195
+ }