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,15 @@
1
+ const
2
+ es = require("event-stream");
3
+
4
+ module.exports = function(msg) {
5
+ const captured = [];
6
+ return es.through(function write(file) {
7
+ captured.push(file);
8
+ this.emit("data", file);
9
+ }, function end() {
10
+ if (captured.length === 0) {
11
+ return this.emit("error", msg || "No files processed");
12
+ }
13
+ this.emit("end");
14
+ });
15
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ (function () {
3
+ module.exports = function uniq(values) {
4
+ return Array.from(new Set(values));
5
+ };
6
+ })();
@@ -0,0 +1,5 @@
1
+ (function() {
2
+ module.exports = function uniq<T>(values: T[]): T[] {
3
+ return Array.from(new Set(values));
4
+ }
5
+ })();
@@ -0,0 +1,17 @@
1
+ var exec = require('child_process').execSync,
2
+ fs = require('fs');
3
+
4
+ module.exports = function(path) {
5
+ console.log('verifying executable at: ', path);
6
+ return new Promise(function(resolve, reject) {
7
+ try {
8
+ exec(path);
9
+ resolve();
10
+ } catch (ignore) {
11
+ console.error('-> executable is bad )\': (imma delete it!)');
12
+ console.info('Suggestion: add a nuget.exe binary to the folder hosting your gulp-tasks');
13
+ fs.unlinkSync(path);
14
+ reject();
15
+ }
16
+ })
17
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryReadVersionFrom = void 0;
4
+ function readTextFrom(node) {
5
+ return node
6
+ ? node[0]
7
+ : undefined;
8
+ }
9
+ function tryReadVersionFrom(groups, nodeName) {
10
+ return groups.reduce((acc, cur) => acc || readTextFrom(cur[nodeName]), undefined);
11
+ }
12
+ exports.tryReadVersionFrom = tryReadVersionFrom;
@@ -0,0 +1,16 @@
1
+ function readTextFrom(node: string[]): string | undefined {
2
+ return node
3
+ ? node[0]
4
+ : undefined;
5
+ }
6
+
7
+ export function tryReadVersionFrom(
8
+ groups: any[],
9
+ nodeName: string
10
+ ): string | undefined {
11
+ return groups.reduce(
12
+ (acc: string | undefined, cur: any) =>
13
+ acc || readTextFrom(cur[nodeName]),
14
+ undefined
15
+ );
16
+ }
@@ -0,0 +1,10 @@
1
+ const fs = require("fs").promises;
2
+
3
+ module.exports = async function(
4
+ path,
5
+ data,
6
+ options) {
7
+ options = options || {};
8
+ options.encoding = "utf8";
9
+ return await fs.writeFile(path, data, options)
10
+ };
@@ -0,0 +1,6 @@
1
+ class ZarroError extends Error {
2
+ }
3
+
4
+ module.exports = {
5
+ ZarroError
6
+ };
@@ -0,0 +1,57 @@
1
+ const
2
+ env = requireModule("env"),
3
+ gulp = requireModule("gulp"),
4
+ debug = require("debug")("nuget-restore"),
5
+ nugetRestore = requireModule("./gulp-nuget-restore"),
6
+ promisify = requireModule("promisify"),
7
+ resolveMasks = requireModule("resolve-masks"),
8
+ { ZarroError } = requireModule("zarro-error"),
9
+ findLocalNuget = requireModule("find-local-nuget");
10
+
11
+ const myTasks = [ "nuget-restore" ],
12
+ myVars = [
13
+ "DOTNET_CORE",
14
+ "BUILD_INCLUDE",
15
+ "BUILD_EXCLUDE",
16
+ "BUILD_ADDITIONAL_EXCLUDE"
17
+ ];
18
+ env.associate(myVars, myTasks);
19
+
20
+ gulp.task(
21
+ "nuget-restore",
22
+ "Restores all nuget packages in all solutions",
23
+ [ "install-tools" ],
24
+ async () => {
25
+ const
26
+ allDNC = env.resolveFlag("DOTNET_CORE"),
27
+ slnMasks = resolveMasks("BUILD_INCLUDE", [ "BUILD_EXCLUDE", "BUILD_EXTRA_EXCLUDE" ]);
28
+ debug({
29
+ allDNC,
30
+ slnMasks,
31
+ cwd: process.cwd()
32
+ });
33
+ var options = {
34
+ debug: false
35
+ };
36
+ const start = allDNC
37
+ ? Promise.resolve()
38
+ : findLocalNuget();
39
+ if (allDNC) {
40
+ options.nuget = "dotnet";
41
+ }
42
+ return start.then(() => {
43
+ return promisify(
44
+ gulp
45
+ .src(slnMasks, { allowEmpty: true })
46
+ .pipe(
47
+ nugetRestore(options)
48
+ )
49
+ ).then(() => {
50
+ debug("nuget restore complete!");
51
+ }).catch(e => {
52
+ console.error("nugetRestore errs:", e);
53
+ throw new ZarroError(e);
54
+ });
55
+ });
56
+ }
57
+ );
@@ -0,0 +1,118 @@
1
+ const getToolsFolder = requireModule("get-tools-folder"),
2
+ path = require("path"),
3
+ throwIfNoFiles = requireModule("throw-if-no-files"),
4
+ dotnetCli = require("gulp-dotnet-cli"),
5
+ dotnetPack = dotnetCli.pack,
6
+ { incrementPackageVersion } = requireModule(
7
+ "gulp-increment-nuget-package-version"
8
+ ),
9
+ resolveMasks = requireModule("resolve-masks"),
10
+ env = requireModule("env"),
11
+ fs = requireModule("fs"),
12
+ { rewriteFile } = requireModule("rewrite-file"),
13
+ del = require("del"),
14
+ debug = require("debug")("pack"),
15
+ gulp = requireModule("gulp"),
16
+ { pack } = requireModule("gulp-nuget-pack");
17
+
18
+ env.associate(
19
+ [
20
+ "PACKAGE_TARGET_FOLDER",
21
+ "DOTNET_CORE",
22
+ "PACK_INCLUDE_CSPROJ",
23
+ "PACK_EXCLUDE_CSPROJ",
24
+ "PACK_INCLUDE_NUSPEC",
25
+ "PACK_EXCLUDE_NUSPEC",
26
+ "PACK_INCREMENT_VERSION"
27
+ ],
28
+ ["pack"]
29
+ );
30
+
31
+ gulp.task(
32
+ "pack",
33
+ "Creates nupkgs from all nuspec files in this repo",
34
+ ["prepack"],
35
+ () => {
36
+ const target = env.resolve("PACKAGE_TARGET_FOLDER"),
37
+ isDotnetCore = env.resolveFlag("DOTNET_CORE"),
38
+ incrementVersion = env.resolveFlag("PACK_INCREMENT_VERSION"),
39
+ packerFn = isDotnetCore ? packWithDotnetCore : packWithNuget;
40
+ debug({
41
+ isDotnetCore,
42
+ incrementVersion
43
+ });
44
+ return packerFn(target, incrementVersion);
45
+ }
46
+ );
47
+
48
+ function removeBadEntities(buffer) {
49
+ const
50
+ s = buffer.toString().replace(/&#xD;/g, "");
51
+ return Buffer.from(s);
52
+ }
53
+
54
+ function packWithNuget(target, incrementVersion) {
55
+ const nuspecs = resolveMasks(
56
+ "PACK_INCLUDE_NUSPEC",
57
+ "PACK_EXCLUDE_NUSPEC",
58
+ p => (p || "").match(/\.nuspec$/) ? p : `${p}.nuspec`
59
+ );
60
+ let stream = gulp
61
+ .src(nuspecs, `!${getToolsFolder()}/**/*`)
62
+ .pipe(throwIfNoFiles("No nuspec files found"));
63
+ if (incrementVersion) {
64
+ stream = stream
65
+ .pipe(incrementPackageVersion())
66
+ .pipe(rewriteFile(removeBadEntities));
67
+ }
68
+ return stream
69
+ .pipe(pack())
70
+ .pipe(gulp.dest(target));
71
+ }
72
+
73
+ function packWithDotnetCore(target, incrementVersion) {
74
+ const projects = resolveMasks("PACK_INCLUDE_CSPROJ", "PACK_EXCLUDE_CSPROJ", p => {
75
+ return (p || "").match(/\.csproj$/) ? p : `${p}.csproj`;
76
+ });
77
+ const configuration = env.resolve("PACK_CONFIGURATION");
78
+ debug({
79
+ projects,
80
+ configuration
81
+ });
82
+ let stream = gulp
83
+ .src(projects, `!${getToolsFolder()}/**/*`)
84
+ .pipe(
85
+ throwIfNoFiles(
86
+ "No target projects found to pack; check PACK_INCLUDE / PACK_EXCLUDE"
87
+ )
88
+ );
89
+ if (incrementVersion) {
90
+ stream = stream
91
+ .pipe(incrementPackageVersion())
92
+ .pipe(rewriteFile(removeBadEntities));
93
+ }
94
+ return stream.pipe(
95
+ dotnetPack({
96
+ output: path.resolve(target),
97
+ configuration
98
+ })
99
+ );
100
+ }
101
+
102
+ gulp.task(
103
+ "prepack",
104
+ "Skeleton task which you can replace to run logic just before packing",
105
+ () => {
106
+ return Promise.resolve();
107
+ }
108
+ );
109
+
110
+ gulp.task(
111
+ "clean-packages",
112
+ "Removes any existing package artifacts",
113
+ async () => {
114
+ const packageFolder = process.env.PACKAGE_TARGET_FOLDER || "packages";
115
+ await del(packageFolder);
116
+ await fs.ensureDirectoryExists(packageFolder);
117
+ }
118
+ );
@@ -0,0 +1,94 @@
1
+ const gulp = requireModule("gulp"),
2
+ env = requireModule("env"),
3
+ path = require("path"),
4
+ rimraf = require("rimraf"),
5
+ findDirs = requireModule("find-dirs"),
6
+ log = requireModule("log"),
7
+ debug = require("debug")("purge");
8
+
9
+ env.associate([
10
+ "DRY_RUN",
11
+ "PURGE_JS_DIRS",
12
+ "PURGE_DOTNET_DIRS",
13
+ "PURGE_ADDITIONAL_DIRS"
14
+ ], [
15
+ "purge", "purge-dotnet", "mega-purge"
16
+ ]);
17
+
18
+ function isNotInRootDir(dir) {
19
+ // where 'root dir' refers to the gulp context current dir
20
+ var inRootDir = path.resolve(path.basename(dir));
21
+ return inRootDir !== dir;
22
+ }
23
+
24
+ function doRegularRm(dir, inRootToo) {
25
+ const
26
+ dryRun = env.resolveFlag("DRY_RUN"),
27
+ del = d => dryRun ? log.info(`del: ${d}`) : rimraf.sync(d);
28
+ return new Promise((resolve, reject) => {
29
+ try {
30
+ debug(`searching for folders matching: ${dir}`);
31
+ var matches = findDirs(".", dir, ["node_modules", "bower_components"]);
32
+ debug(`got: ${matches}`);
33
+ if (!inRootToo) {
34
+ matches = matches.filter(isNotInRootDir);
35
+ }
36
+ if (matches.length === 0) {
37
+ debug(`-> nothing to do for ${dir}`);
38
+ return resolve();
39
+ }
40
+ matches.forEach(f => {
41
+ debug(`should purge: ${f}`);
42
+ del(f);
43
+ debug(`purge complete: ${f}`);
44
+ });
45
+ resolve();
46
+ } catch (e) {
47
+ debug(`whoops! ${e}`);
48
+ reject(e);
49
+ }
50
+ });
51
+ }
52
+
53
+
54
+ function doPurge(dirs, includeRootFolders) {
55
+ return Promise.all(dirs.map(d => doRegularRm(d, includeRootFolders))).then(
56
+ () => {
57
+ debug("-- PURGE COMPLETE! ---");
58
+ }
59
+ );
60
+ }
61
+
62
+ function listPurgeDirs(...varNames) {
63
+ return varNames.reduce(
64
+ (acc, cur) => {
65
+ const resolved = env.resolveArray(cur);
66
+ acc.push.apply(acc, resolved);
67
+ return acc;
68
+ }, []);
69
+ }
70
+
71
+ const
72
+ js = "PURGE_JS_DIRS",
73
+ dotnet = "PURGE_DOTNET_DIRS",
74
+ other = "PURGE_ADDITIONAL_DIRS";
75
+
76
+ gulp.task(
77
+ "purge",
78
+ "Purges all bins, objs, node_modules, bower_components and packages not in the root",
79
+ function() {
80
+ return doPurge(listPurgeDirs(dotnet, js, other), false);
81
+ }
82
+ );
83
+
84
+ gulp.task("purge-dotnet", "Purges dotnet artifacts", () => {
85
+ return doPurge(listPurgeDirs(dotnet, other), false);
86
+ });
87
+
88
+ gulp.task(
89
+ "mega-purge",
90
+ "Performs regular purge and in the root (you'll have to `npm install` afterwards!",
91
+ function() {
92
+ return doPurge(listPurgeDirs(dotnet, js, other), true);
93
+ }
94
+ );
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ (function () {
3
+ const Git = require("simple-git/promise"), spawn = requireModule("spawn"), gulp = requireModule("gulp"), gutil = requireModule("gulp-util"), gitTag = requireModule("git-tag"), gitPushTags = requireModule("git-push-tags"), gitPush = requireModule("git-push"), readGitInfo = requireModule("read-git-info"), env = requireModule("env"), readPackageVersion = requireModule("read-package-version"), alterPackageJsonVersion = requireModule("alter-package-json-version");
4
+ async function rollBackPackageJson() {
5
+ await alterPackageJsonVersion({ loadUnsetFromEnvironment: true, incrementBy: -1 });
6
+ }
7
+ gulp.task("release-npm", ["increment-package-json-version"], async () => {
8
+ const dryRun = env.resolveFlag("DRY_RUN"), git = new Git(), version = await readPackageVersion(), isBeta = env.resolveFlag("BETA"), tag = `v${version}`, gitInfo = await readGitInfo();
9
+ try {
10
+ if (gitInfo.isGitRepository) {
11
+ const branchInfo = await git.branch();
12
+ // ignore this error: couldn't find remote ref HEAD
13
+ // -> means this is an unknown (new) branch: we should push -u
14
+ if (gitInfo.remotes.length) {
15
+ try {
16
+ await git.pull(gitInfo.primaryRemote, branchInfo.current, {
17
+ "--rebase": true,
18
+ "--autostash": true
19
+ });
20
+ }
21
+ catch (e) {
22
+ const isNewBranch = (e.message || "").indexOf("couldn't find remote ref HEAD") > -1;
23
+ if (!isNewBranch) {
24
+ throw e;
25
+ }
26
+ }
27
+ }
28
+ }
29
+ if (dryRun) {
30
+ gutil.log(gutil.colors.yellow(`would publish ${version}`));
31
+ }
32
+ else {
33
+ const access = env.resolve("NPM_PUBLISH_ACCESS"), args = ["publish", "--access", access];
34
+ if (isBeta) {
35
+ args.push("--tag", "beta");
36
+ }
37
+ await spawn("npm", args);
38
+ }
39
+ }
40
+ catch (e) {
41
+ await rollBackPackageJson();
42
+ throw e;
43
+ }
44
+ if (dryRun) {
45
+ gutil.log(gutil.colors.yellow(`would commit all updated files`));
46
+ await rollBackPackageJson();
47
+ }
48
+ else if (gitInfo.isGitRepository) {
49
+ await git.add(":/");
50
+ await git.commit(`:bookmark: bump package version to ${version}`);
51
+ await gitTag({ tag });
52
+ await Promise.all([
53
+ gitPush(dryRun),
54
+ gitPushTags(dryRun)
55
+ ]);
56
+ }
57
+ });
58
+ })();
@@ -0,0 +1,81 @@
1
+ (function() {
2
+ const
3
+ Git = require("simple-git/promise"),
4
+ spawn = requireModule<Spawn>("spawn"),
5
+ gulp = requireModule<GulpWithHelp>("gulp"),
6
+ gutil = requireModule<GulpUtil>("gulp-util"),
7
+ gitTag = requireModule<GitTag>("git-tag"),
8
+ gitPushTags = requireModule<GitPushTags>("git-push-tags"),
9
+ gitPush = requireModule<GitPush>("git-push"),
10
+ readGitInfo = requireModule<ReadGitInfo>("read-git-info"),
11
+ env = requireModule<Env>("env"),
12
+ readPackageVersion = requireModule<ReadPackageVersion>("read-package-version"),
13
+ alterPackageJsonVersion = requireModule<AlterPackageJson>("alter-package-json-version");
14
+
15
+ async function rollBackPackageJson() {
16
+ await alterPackageJsonVersion({ loadUnsetFromEnvironment: true, incrementBy: -1 });
17
+ }
18
+
19
+ gulp.task("release-npm", ["increment-package-json-version"], async () => {
20
+
21
+ const
22
+ dryRun = env.resolveFlag("DRY_RUN"),
23
+ git = new Git(),
24
+ version = await readPackageVersion(),
25
+ isBeta = env.resolveFlag("BETA"),
26
+ tag = `v${ version }`,
27
+ gitInfo = await readGitInfo();
28
+
29
+ try {
30
+ if (gitInfo.isGitRepository) {
31
+ const branchInfo = await git.branch();
32
+ // ignore this error: couldn't find remote ref HEAD
33
+ // -> means this is an unknown (new) branch: we should push -u
34
+ if (gitInfo.remotes.length) {
35
+ try {
36
+ await git.pull(
37
+ gitInfo.primaryRemote,
38
+ branchInfo.current, {
39
+ "--rebase": true,
40
+ "--autostash": true
41
+ });
42
+ } catch (e) {
43
+ const isNewBranch = (e.message || "").indexOf("couldn't find remote ref HEAD") > -1;
44
+ if (!isNewBranch) {
45
+ throw e;
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ if (dryRun) {
52
+ gutil.log(gutil.colors.yellow(`would publish ${ version }`));
53
+ } else {
54
+ const
55
+ access = env.resolve("NPM_PUBLISH_ACCESS"),
56
+ args = ["publish", "--access", access];
57
+ if (isBeta) {
58
+ args.push("--tag", "beta");
59
+ }
60
+ await spawn("npm", args);
61
+ }
62
+ } catch (e) {
63
+ await rollBackPackageJson();
64
+ throw e;
65
+ }
66
+
67
+ if (dryRun) {
68
+ gutil.log(gutil.colors.yellow(`would commit all updated files`));
69
+ await rollBackPackageJson();
70
+ } else if (gitInfo.isGitRepository) {
71
+ await git.add(":/");
72
+ await git.commit(`:bookmark: bump package version to ${ version }`);
73
+ await gitTag({ tag });
74
+ await Promise.all([
75
+ gitPush(dryRun),
76
+ gitPushTags(dryRun)
77
+ ]);
78
+ }
79
+ });
80
+
81
+ })();