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.
- package/LICENSE +10 -0
- package/README.md +260 -0
- package/gulp-tasks/.editorconfig +8 -0
- package/gulp-tasks/.git +1 -0
- package/gulp-tasks/.gitignore +9 -0
- package/gulp-tasks/.gitmodules +0 -0
- package/gulp-tasks/LICENSE +24 -0
- package/gulp-tasks/README.md +144 -0
- package/gulp-tasks/build.js +135 -0
- package/gulp-tasks/clean.js +37 -0
- package/gulp-tasks/cover-dotnet.js +56 -0
- package/gulp-tasks/default-report-generator.js +51 -0
- package/gulp-tasks/default-tools-installer.js +33 -0
- package/gulp-tasks/default.js +17 -0
- package/gulp-tasks/dotnet-publish.js +23 -0
- package/gulp-tasks/generate-reports.js +7 -0
- package/gulp-tasks/get-local-nuget.js +16 -0
- package/gulp-tasks/git-submodules.js +83 -0
- package/gulp-tasks/increment-package-json-version.js +12 -0
- package/gulp-tasks/increment-package-json-version.ts +17 -0
- package/gulp-tasks/install-tools.js +24 -0
- package/gulp-tasks/modules/add-stream-on-any-handler.js +31 -0
- package/gulp-tasks/modules/alter-package-json-version.js +64 -0
- package/gulp-tasks/modules/alter-package-json-version.ts +113 -0
- package/gulp-tasks/modules/are-all-dotnet-core.js +96 -0
- package/gulp-tasks/modules/ask.js +31 -0
- package/gulp-tasks/modules/ask.ts +41 -0
- package/gulp-tasks/modules/collect-files.js +15 -0
- package/gulp-tasks/modules/collect-files.ts +16 -0
- package/gulp-tasks/modules/config-generator.js +10 -0
- package/gulp-tasks/modules/defaults.js +9 -0
- package/gulp-tasks/modules/download-nuget.js +104 -0
- package/gulp-tasks/modules/ensure-folder-exists.js +21 -0
- package/gulp-tasks/modules/env-helpers.js +49 -0
- package/gulp-tasks/modules/env-helpers.ts +67 -0
- package/gulp-tasks/modules/env.js +364 -0
- package/gulp-tasks/modules/exec.js +257 -0
- package/gulp-tasks/modules/exec.ts +346 -0
- package/gulp-tasks/modules/fail-after.js +30 -0
- package/gulp-tasks/modules/fail-after.ts +34 -0
- package/gulp-tasks/modules/fallback.js +6 -0
- package/gulp-tasks/modules/find-dirs.js +39 -0
- package/gulp-tasks/modules/find-local-nuget.js +42 -0
- package/gulp-tasks/modules/find-npm-base.js +42 -0
- package/gulp-tasks/modules/fs.js +79 -0
- package/gulp-tasks/modules/gather-paths.js +23 -0
- package/gulp-tasks/modules/gather-paths.ts +29 -0
- package/gulp-tasks/modules/generate-env-help-for.js +30 -0
- package/gulp-tasks/modules/get-tools-folder.js +12 -0
- package/gulp-tasks/modules/git-push-tags.js +33 -0
- package/gulp-tasks/modules/git-push-tags.ts +42 -0
- package/gulp-tasks/modules/git-push.js +51 -0
- package/gulp-tasks/modules/git-tag.js +36 -0
- package/gulp-tasks/modules/gulp-dotnetcover.js +537 -0
- package/gulp-tasks/modules/gulp-git-tag-from-csproj.js +50 -0
- package/gulp-tasks/modules/gulp-git-tag-from-csproj.ts +71 -0
- package/gulp-tasks/modules/gulp-git-tag-from-package-nuspec.js +55 -0
- package/gulp-tasks/modules/gulp-increment-nuget-package-dependency-version.js +40 -0
- package/gulp-tasks/modules/gulp-increment-nuget-package-version.js +87 -0
- package/gulp-tasks/modules/gulp-increment-nuget-package-version.ts +122 -0
- package/gulp-tasks/modules/gulp-msbuild.js +1 -0
- package/gulp-tasks/modules/gulp-npm-run.js +40 -0
- package/gulp-tasks/modules/gulp-npm-run.ts +52 -0
- package/gulp-tasks/modules/gulp-nuget-pack.js +168 -0
- package/gulp-tasks/modules/gulp-nuget-restore.js +106 -0
- package/gulp-tasks/modules/gulp-nunit-runner/.jshintrc +5 -0
- package/gulp-tasks/modules/gulp-nunit-runner/.npmignore +16 -0
- package/gulp-tasks/modules/gulp-nunit-runner/LICENSE +21 -0
- package/gulp-tasks/modules/gulp-nunit-runner/README.md +300 -0
- package/gulp-tasks/modules/gulp-nunit-runner/index.js +1 -0
- package/gulp-tasks/modules/gulp-nunit-runner/lib/index.js +205 -0
- package/gulp-tasks/modules/gulp-nunit-runner/lib/teamcity.js +86 -0
- package/gulp-tasks/modules/gulp-purge.js +88 -0
- package/gulp-tasks/modules/gulp-util.js +5 -0
- package/gulp-tasks/modules/gulp-version.js +8 -0
- package/gulp-tasks/modules/gulp-with-help.js +1 -0
- package/gulp-tasks/modules/gulp-xbuild.js +62 -0
- package/gulp-tasks/modules/gulp.js +92 -0
- package/gulp-tasks/modules/http-downloader.js +113 -0
- package/gulp-tasks/modules/import-npm-tasks.js +33 -0
- package/gulp-tasks/modules/increment-version-string.js +18 -0
- package/gulp-tasks/modules/increment-version.js +30 -0
- package/gulp-tasks/modules/increment-version.ts +41 -0
- package/gulp-tasks/modules/install-local-tools.js +122 -0
- package/gulp-tasks/modules/load-xml-file.js +12 -0
- package/gulp-tasks/modules/load-xml-file.ts +15 -0
- package/gulp-tasks/modules/log-config.js +31 -0
- package/gulp-tasks/modules/log.js +142 -0
- package/gulp-tasks/modules/longest-string-length.js +13 -0
- package/gulp-tasks/modules/looks-like-a-promise.js +11 -0
- package/gulp-tasks/modules/ls-r.js +52 -0
- package/gulp-tasks/modules/multi-split.js +29 -0
- package/gulp-tasks/modules/net-framework-test-assembly-filter.js +45 -0
- package/gulp-tasks/modules/nuget-push.js +66 -0
- package/gulp-tasks/modules/nuget-update-self.js +9 -0
- package/gulp-tasks/modules/nuget.js +8 -0
- package/gulp-tasks/modules/nuget.ts +14 -0
- package/gulp-tasks/modules/pad-left.js +4 -0
- package/gulp-tasks/modules/pad-right.js +4 -0
- package/gulp-tasks/modules/pad.js +25 -0
- package/gulp-tasks/modules/parse-xml-string.js +5 -0
- package/gulp-tasks/modules/parse-xml-string.ts +6 -0
- package/gulp-tasks/modules/parse-xml.js +14 -0
- package/gulp-tasks/modules/parse-xml.ts +15 -0
- package/gulp-tasks/modules/path-unquote.js +6 -0
- package/gulp-tasks/modules/promisify-function.js +19 -0
- package/gulp-tasks/modules/promisify-function.ts +18 -0
- package/gulp-tasks/modules/promisify-stream.js +73 -0
- package/gulp-tasks/modules/promisify.js +1 -0
- package/gulp-tasks/modules/quote-if-required.js +14 -0
- package/gulp-tasks/modules/read-all-git-branches.js +10 -0
- package/gulp-tasks/modules/read-all-git-branches.ts +13 -0
- package/gulp-tasks/modules/read-all-git-remotes.js +36 -0
- package/gulp-tasks/modules/read-all-git-remotes.ts +44 -0
- package/gulp-tasks/modules/read-csproj-package-version.js +16 -0
- package/gulp-tasks/modules/read-csproj-package-version.ts +26 -0
- package/gulp-tasks/modules/read-csproj-version.js +16 -0
- package/gulp-tasks/modules/read-csproj-version.ts +26 -0
- package/gulp-tasks/modules/read-current-git-branch.js +12 -0
- package/gulp-tasks/modules/read-current-git-branch.ts +16 -0
- package/gulp-tasks/modules/read-git-commit-delta-count.js +21 -0
- package/gulp-tasks/modules/read-git-commit-delta-count.ts +33 -0
- package/gulp-tasks/modules/read-git-info.js +28 -0
- package/gulp-tasks/modules/read-git-info.ts +31 -0
- package/gulp-tasks/modules/read-git-remote.js +17 -0
- package/gulp-tasks/modules/read-git-remote.ts +23 -0
- package/gulp-tasks/modules/read-last-fetch-time.js +21 -0
- package/gulp-tasks/modules/read-last-fetch-time.ts +17 -0
- package/gulp-tasks/modules/read-main-branch-name.js +48 -0
- package/gulp-tasks/modules/read-main-branch-name.ts +76 -0
- package/gulp-tasks/modules/read-nuspec-version.js +14 -0
- package/gulp-tasks/modules/read-nuspec-version.ts +22 -0
- package/gulp-tasks/modules/read-package-json.js +16 -0
- package/gulp-tasks/modules/read-package-json.ts +22 -0
- package/gulp-tasks/modules/read-package-version.js +8 -0
- package/gulp-tasks/modules/read-package-version.ts +10 -0
- package/gulp-tasks/modules/read-text-file.js +14 -0
- package/gulp-tasks/modules/read-text-file.ts +14 -0
- package/gulp-tasks/modules/reduce-gulp-noise.js +34 -0
- package/gulp-tasks/modules/register-environment-variables.js +526 -0
- package/gulp-tasks/modules/require-module.js +28 -0
- package/gulp-tasks/modules/resolve-git-branch.js +11 -0
- package/gulp-tasks/modules/resolve-git-branch.ts +13 -0
- package/gulp-tasks/modules/resolve-git-remote.js +11 -0
- package/gulp-tasks/modules/resolve-git-remote.ts +13 -0
- package/gulp-tasks/modules/resolve-masks.js +47 -0
- package/gulp-tasks/modules/resolve-nuget.js +135 -0
- package/gulp-tasks/modules/resolve-test-masks.js +10 -0
- package/gulp-tasks/modules/rewrite-file.js +26 -0
- package/gulp-tasks/modules/rewrite-file.ts +34 -0
- package/gulp-tasks/modules/rimraf.js +21 -0
- package/gulp-tasks/modules/rimraf.ts +31 -0
- package/gulp-tasks/modules/run-sequence.js +16 -0
- package/gulp-tasks/modules/safe-git.js +23 -0
- package/gulp-tasks/modules/safe-git.ts +23 -0
- package/gulp-tasks/modules/seed.js +12 -0
- package/gulp-tasks/modules/set-task-name.js +9 -0
- package/gulp-tasks/modules/sleep.js +5 -0
- package/gulp-tasks/modules/spawn-nuget.js +13 -0
- package/gulp-tasks/modules/spawn.js +103 -0
- package/gulp-tasks/modules/split-path.js +3 -0
- package/gulp-tasks/modules/stat.js +8 -0
- package/gulp-tasks/modules/status.js +57 -0
- package/gulp-tasks/modules/status.ts +71 -0
- package/gulp-tasks/modules/test-path.js +3 -0
- package/gulp-tasks/modules/testutil-finder.js +176 -0
- package/gulp-tasks/modules/throw-if-no-files.js +15 -0
- package/gulp-tasks/modules/uniq.js +6 -0
- package/gulp-tasks/modules/uniq.ts +5 -0
- package/gulp-tasks/modules/verify-exe.js +17 -0
- package/gulp-tasks/modules/version-reading-shared.js +12 -0
- package/gulp-tasks/modules/version-reading-shared.ts +16 -0
- package/gulp-tasks/modules/write-text-file.js +10 -0
- package/gulp-tasks/modules/zarro-error.js +6 -0
- package/gulp-tasks/nuget-restore.js +57 -0
- package/gulp-tasks/pack.js +118 -0
- package/gulp-tasks/purge.js +94 -0
- package/gulp-tasks/release-npm.js +58 -0
- package/gulp-tasks/release-npm.ts +81 -0
- package/gulp-tasks/start/_package.json +39 -0
- package/gulp-tasks/start/gulpfile.js +204 -0
- package/gulp-tasks/start/update-starter-packages.js +63 -0
- package/gulp-tasks/test-dotnet.js +195 -0
- package/gulp-tasks/update-git-submodules.js +11 -0
- package/gulp-tasks/update-git-submodules.ts +29 -0
- package/gulp-tasks/update-self.js +65 -0
- package/gulp-tasks/update-self.ts +88 -0
- package/gulp-tasks/verify-up-to-date.js +77 -0
- package/gulp-tasks/verify-up-to-date.ts +119 -0
- package/index-modules/contains-any.js +31 -0
- package/index-modules/gather-args.js +21 -0
- package/index-modules/handlers/help.js +17 -0
- package/index-modules/handlers/init.js +57 -0
- package/index-modules/handlers/invoke-gulp.js +111 -0
- package/index-modules/handlers/show-env.js +46 -0
- package/index-modules/is-dir.js +6 -0
- package/index-modules/is-file.js +6 -0
- package/index.js +53 -0
- package/package.json +96 -0
- package/tsconfig.json +66 -0
- package/types.d.ts +753 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// this module attempts to make gulp able to provide help
|
|
2
|
+
// -> in 3.x, we can use the gulp-help package to do so
|
|
3
|
+
// -> in 4.x, this is shimmed in. In addition, we need to
|
|
4
|
+
// - facilitate forward references, as per original gulp
|
|
5
|
+
// -
|
|
6
|
+
const setTaskName = requireModule("set-task-name"),
|
|
7
|
+
gulpVersion = requireModule("gulp-version");
|
|
8
|
+
|
|
9
|
+
if (gulpVersion.major === 3) {
|
|
10
|
+
module.exports = require("gulp-help")(require("gulp"));
|
|
11
|
+
} else {
|
|
12
|
+
const
|
|
13
|
+
quieter = requireModule("reduce-gulp-noise");
|
|
14
|
+
gulp = require("gulp"),
|
|
15
|
+
help = {},
|
|
16
|
+
FwdRef = require("undertaker-forward-reference");
|
|
17
|
+
|
|
18
|
+
gulp.registry(new FwdRef());
|
|
19
|
+
|
|
20
|
+
const
|
|
21
|
+
originalTask = gulp.task,
|
|
22
|
+
newTask = function() {
|
|
23
|
+
let
|
|
24
|
+
args = Array.from(arguments),
|
|
25
|
+
taskName = args[0],
|
|
26
|
+
helpMessage = "";
|
|
27
|
+
if (typeof args[1] === "string") {
|
|
28
|
+
helpMessage = args[1];
|
|
29
|
+
args.splice(1, 1);
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(args[1])) {
|
|
32
|
+
const parallel = gulp.parallel(
|
|
33
|
+
args[1].map(name => {
|
|
34
|
+
// this allows late-overriding of tasks, as per assistance
|
|
35
|
+
// at: https://github.com/gulpjs/gulp/issues/2337
|
|
36
|
+
return setTaskName((...args) => gulp.series(name)(...args), quieter.markForSuppression(name)); // `${quieter.marker}(${name})`);
|
|
37
|
+
}));
|
|
38
|
+
setTaskName(parallel, `pre-${taskName}`);
|
|
39
|
+
args[1] = gulp.series(
|
|
40
|
+
parallel,
|
|
41
|
+
args[2] || (() => Promise.resolve())
|
|
42
|
+
);
|
|
43
|
+
setTaskName(args[1], `[${taskName}]`);
|
|
44
|
+
args.splice(2, 1);
|
|
45
|
+
}
|
|
46
|
+
help[taskName] = helpMessage;
|
|
47
|
+
originalTask.call(gulp, taskName, args[1]);
|
|
48
|
+
const generatedTask = originalTask.call(gulp, taskName);
|
|
49
|
+
generatedTask.description = helpMessage;
|
|
50
|
+
return generatedTask;
|
|
51
|
+
};
|
|
52
|
+
gulp.task = newTask.bind(gulp);
|
|
53
|
+
gulp.task("help", () => {
|
|
54
|
+
const chalk = require("ansi-colors"),
|
|
55
|
+
green = chalk.greenBright.bind(chalk),
|
|
56
|
+
yellow = chalk.yellowBright.bind(chalk),
|
|
57
|
+
cyan = chalk.cyanBright.bind(chalk);
|
|
58
|
+
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
console.log(yellow("Task help"));
|
|
61
|
+
console.log(yellow(" - Tasks marked with * are affected by environment variables"));
|
|
62
|
+
console.log(yellow(" - run the help:environment task for more info"));
|
|
63
|
+
const keys = Object.keys(help).sort();
|
|
64
|
+
const longestKeyLength = keys.reduce(function (acc, cur) {
|
|
65
|
+
return cur.length > acc ? cur.length : acc;
|
|
66
|
+
}, 0);
|
|
67
|
+
keys.forEach(function(key) {
|
|
68
|
+
if (!help[key]) {
|
|
69
|
+
return console.log(cyan(key));
|
|
70
|
+
}
|
|
71
|
+
const helpMessage = help[key];
|
|
72
|
+
while (key.length < longestKeyLength) {
|
|
73
|
+
key += " ";
|
|
74
|
+
}
|
|
75
|
+
console.log(cyan(key) + " " + green(helpMessage));
|
|
76
|
+
});
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
module.exports = gulp;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
(function() {
|
|
84
|
+
const
|
|
85
|
+
env = requireModule("env"),
|
|
86
|
+
gulp = module.exports;
|
|
87
|
+
|
|
88
|
+
gulp.task("help:environment", () => {
|
|
89
|
+
env.printHelp();
|
|
90
|
+
return Promise.resolve();
|
|
91
|
+
});
|
|
92
|
+
})();
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var
|
|
2
|
+
fs = require('fs'),
|
|
3
|
+
path = require("path"),
|
|
4
|
+
ensureFolderExists = require("./ensure-folder-exists"),
|
|
5
|
+
request = require('request'),
|
|
6
|
+
debug = require('debug')('http-downloader');
|
|
7
|
+
|
|
8
|
+
function HttpDownloader(infoLogFunction, debugLogFunction) {
|
|
9
|
+
this._info = infoLogFunction || console.log;
|
|
10
|
+
this._debug = debugLogFunction || debug;
|
|
11
|
+
this.assumeDownloadedIfExistsAndSizeMatches = true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
HttpDownloader.prototype = {
|
|
15
|
+
download: function (url, target) {
|
|
16
|
+
const partFile = `${target}.part`;
|
|
17
|
+
ensureFolderExists(path.dirname(partFile));
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
this._request = request.get(url, { timeout: 30000 })
|
|
20
|
+
.on("response", (response) => {
|
|
21
|
+
this._debug(`got response: ${JSON.stringify(response)}`);
|
|
22
|
+
this._downloadSize = parseInt(response.headers["content-length"]);
|
|
23
|
+
this._statusSuffix = '% of ' + this._humanSize(this._downloadSize);
|
|
24
|
+
})
|
|
25
|
+
.on("error", (e) => {
|
|
26
|
+
this._debug(`got error: ${e}`);
|
|
27
|
+
reject(e);
|
|
28
|
+
})
|
|
29
|
+
.on("data", (data) => {
|
|
30
|
+
this._debug(`got ${data.length} bytes`);
|
|
31
|
+
this._updateStatus(data);
|
|
32
|
+
})
|
|
33
|
+
.on("end", () => {
|
|
34
|
+
this._clear();
|
|
35
|
+
this._rename(resolve, reject, partFile, target);
|
|
36
|
+
}).pipe(fs.createWriteStream(partFile));
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
abort: function () {
|
|
40
|
+
if (this._request) {
|
|
41
|
+
self._errored = true;
|
|
42
|
+
this._request.abort();
|
|
43
|
+
this._clear();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
_updateStatus: function (data) {
|
|
47
|
+
if (process.env.SUPPRESS_DOWNLOAD_PROGRESS || process.env.BUILD_NUMBER /* automatically disable at Jenkins CI */) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this._written = this._written || 0;
|
|
51
|
+
this._written += data.length;
|
|
52
|
+
var perc = Math.round((100 * this._written) / this._downloadSize);
|
|
53
|
+
if (perc != this._lastPerc) {
|
|
54
|
+
this._writeStatus(perc + this._statusSuffix);
|
|
55
|
+
this._lastPerc = perc;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
_writeStatus: function (msg) {
|
|
59
|
+
this._clearStatus();
|
|
60
|
+
process.stdout.write(msg);
|
|
61
|
+
},
|
|
62
|
+
_rename: function (resolve, reject, src, dst, attempts) {
|
|
63
|
+
try {
|
|
64
|
+
this._debug('attempt rename of temp file');
|
|
65
|
+
fs.renameSync(src, dst)
|
|
66
|
+
this._clearStatus();
|
|
67
|
+
this._info(`-> ${dst} download complete!`);
|
|
68
|
+
resolve(dst)
|
|
69
|
+
} catch (e) {
|
|
70
|
+
this._debug('rename error:', e);
|
|
71
|
+
if (attempts > 99) {
|
|
72
|
+
reject(['Unable to rename "', src, '" to "', ds, '": ', e].join(''));
|
|
73
|
+
} else {
|
|
74
|
+
setTimeout(()=> {
|
|
75
|
+
this._rename(resolve, reject, src, dst, attempts++);
|
|
76
|
+
}, 100);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
_clearStatus: function () {
|
|
81
|
+
process.stdout.write('\r \r');
|
|
82
|
+
},
|
|
83
|
+
_humanSize: function (size) {
|
|
84
|
+
var suffixes = ['b', 'kb', 'mb', 'tb', 'pb'];
|
|
85
|
+
for (var i = 0; i < suffixes.length - 1; i++) {
|
|
86
|
+
if (size < 1024) {
|
|
87
|
+
return size.toFixed(2) + suffixes[i];
|
|
88
|
+
}
|
|
89
|
+
size /= 1024;
|
|
90
|
+
}
|
|
91
|
+
return size.toFixed(2) + suffixes[suffixes.length - 1];
|
|
92
|
+
},
|
|
93
|
+
_clear: function () {
|
|
94
|
+
var self = this;
|
|
95
|
+
['_request', '_response', '_downloadSize', '_lastPerc',
|
|
96
|
+
'_resolveFunction', '_rejectFunction', '_lastData', '_statusSuffix'
|
|
97
|
+
].forEach(function (prop) {
|
|
98
|
+
self[prop] = undefined;
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
_alreadyDownloaded: function () {
|
|
102
|
+
if (!this.assumeDownloadedIfExistsAndSizeMatches) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (!fs.existsSync(this._target)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
var lstat = fs.lstatSync(this._target);
|
|
109
|
+
return lstat.size === this._downloadSize;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = HttpDownloader;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Overriding in your own source tree:
|
|
3
|
+
|
|
4
|
+
If you don't want to import npm scripts as gulp tasks or perhaps you'd
|
|
5
|
+
just like to define a different behavior, create one of the following,
|
|
6
|
+
parallel to gulp-tasks:
|
|
7
|
+
- override-tasks/import-npm-tasks.js
|
|
8
|
+
- local-tasks/import-npm-tasks.js
|
|
9
|
+
|
|
10
|
+
If you just want to disable the functionality, an empty file will do
|
|
11
|
+
*/
|
|
12
|
+
const path = require("path"),
|
|
13
|
+
debug = require("debug")("import-npm-tasks"),
|
|
14
|
+
fs = require("fs"),
|
|
15
|
+
search = [ "local-tasks", "override-tasks" ];
|
|
16
|
+
module.exports = function() {
|
|
17
|
+
let overridden = false;
|
|
18
|
+
search.forEach(function (dir) {
|
|
19
|
+
const lookFor = path.join("..", dir, __filename);
|
|
20
|
+
if (fs.existsSync(lookFor)) {
|
|
21
|
+
console.log("overriding gulp-npm-run default behaviour with: ", lookFor);
|
|
22
|
+
require(lookFor);
|
|
23
|
+
overridden = true;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
if (!overridden) {
|
|
27
|
+
debug("importing npm scripts as gulp tasks")
|
|
28
|
+
const gulpNpmRun = requireModule("gulp-npm-run");
|
|
29
|
+
const gulp = requireModule("gulp");
|
|
30
|
+
gulpNpmRun(gulp);
|
|
31
|
+
debug("-> done");
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { ZarroError } = requireModule("zarro-error");
|
|
2
|
+
|
|
3
|
+
function testNaN(version) {
|
|
4
|
+
Object.keys(version).forEach(k => {
|
|
5
|
+
if (isNaN(version[k])) {
|
|
6
|
+
throw new ZarroError(`${k} is not an integer`);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = function incrementVersion(versionString) {
|
|
12
|
+
const parts = versionString.split("."),
|
|
13
|
+
major = parseInt(parts[0]),
|
|
14
|
+
minor = parseInt(parts[1]),
|
|
15
|
+
patch = parseInt(parts[2]);
|
|
16
|
+
testNaN({ major, minor, patch });
|
|
17
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
18
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { ZarroError } = requireModule("zarro-error");
|
|
3
|
+
function zeroFrom(parts, startIndex) {
|
|
4
|
+
for (let i = startIndex; i < parts.length; i++) {
|
|
5
|
+
parts[i] = 0;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function incrementAt(parts, index, incrementBy) {
|
|
9
|
+
if (parts[index] === undefined) {
|
|
10
|
+
throw new ZarroError(`version '${parts.join(".")}' has no value at position ${index}`);
|
|
11
|
+
}
|
|
12
|
+
parts[index] += incrementBy;
|
|
13
|
+
}
|
|
14
|
+
const incrementLookup = {
|
|
15
|
+
"major": 0,
|
|
16
|
+
"minor": 1,
|
|
17
|
+
"patch": 2
|
|
18
|
+
};
|
|
19
|
+
module.exports = function incrementVersion(version, strategy, zeroLowerOrder, incrementBy = 1) {
|
|
20
|
+
const parts = version.split(".").map(i => parseInt(i));
|
|
21
|
+
let toIncrement = incrementLookup[(strategy || "").toLowerCase()];
|
|
22
|
+
if (toIncrement === undefined) {
|
|
23
|
+
throw new ZarroError(`Unknown version increment strategy: ${strategy}\n try one of 'major', 'minor' or 'patch'`);
|
|
24
|
+
}
|
|
25
|
+
incrementAt(parts, toIncrement, incrementBy);
|
|
26
|
+
if (zeroLowerOrder) {
|
|
27
|
+
zeroFrom(parts, toIncrement + 1);
|
|
28
|
+
}
|
|
29
|
+
return parts.join(".");
|
|
30
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { ZarroError } = requireModule("zarro-error");
|
|
2
|
+
|
|
3
|
+
function zeroFrom(parts: number[], startIndex: number) {
|
|
4
|
+
for (let i = startIndex; i < parts.length; i++) {
|
|
5
|
+
parts[i] = 0;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function incrementAt(
|
|
10
|
+
parts: number[],
|
|
11
|
+
index: number,
|
|
12
|
+
incrementBy: number) {
|
|
13
|
+
if (parts[index] === undefined) {
|
|
14
|
+
throw new ZarroError(`version '${parts.join(".")}' has no value at position ${index}`);
|
|
15
|
+
}
|
|
16
|
+
parts[index] += incrementBy;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const incrementLookup: { [key: string]: number } = {
|
|
20
|
+
"major": 0,
|
|
21
|
+
"minor": 1,
|
|
22
|
+
"patch": 2
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = function incrementVersion(
|
|
27
|
+
version: string,
|
|
28
|
+
strategy: "major" | "minor" | "patch",
|
|
29
|
+
zeroLowerOrder: boolean,
|
|
30
|
+
incrementBy: number = 1): string {
|
|
31
|
+
const parts = version.split(".").map(i => parseInt(i));
|
|
32
|
+
let toIncrement = incrementLookup[(strategy || "").toLowerCase()]
|
|
33
|
+
if (toIncrement === undefined) {
|
|
34
|
+
throw new ZarroError(`Unknown version increment strategy: ${strategy}\n try one of 'major', 'minor' or 'patch'`);
|
|
35
|
+
}
|
|
36
|
+
incrementAt(parts, toIncrement, incrementBy);
|
|
37
|
+
if (zeroLowerOrder) {
|
|
38
|
+
zeroFrom(parts, toIncrement + 1);
|
|
39
|
+
}
|
|
40
|
+
return parts.join(".");
|
|
41
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const resolveNuget = require("./resolve-nuget"),
|
|
2
|
+
downloadNuget = require("./download-nuget"),
|
|
3
|
+
nugetUpdateSelf = require("./nuget-update-self"),
|
|
4
|
+
debug = require("debug")("install-local-tools"),
|
|
5
|
+
gutil = requireModule("gulp-util"),
|
|
6
|
+
path = require("path"),
|
|
7
|
+
fs = require("fs"),
|
|
8
|
+
getToolsFolder = require("./get-tools-folder"),
|
|
9
|
+
nuget = require("./nuget"),
|
|
10
|
+
ensureFolderExists = require("./ensure-folder-exists"),
|
|
11
|
+
{ ZarroError } = requireModule("zarro-error"),
|
|
12
|
+
del = require("del");
|
|
13
|
+
|
|
14
|
+
function cleanFoldersFrom(toolsFolder) {
|
|
15
|
+
const dirs = fs
|
|
16
|
+
.readdirSync(toolsFolder)
|
|
17
|
+
.map(p => path.join(toolsFolder, p))
|
|
18
|
+
.filter(p => {
|
|
19
|
+
const stat = fs.lstatSync(p);
|
|
20
|
+
return stat.isDirectory();
|
|
21
|
+
});
|
|
22
|
+
if (dirs.length) {
|
|
23
|
+
debug(`Will delete the following tools sub-folders:`);
|
|
24
|
+
dirs.forEach(d => {
|
|
25
|
+
debug(` - ${d}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return del(dirs);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function downloadOrUpdateNuget(targetFolder) {
|
|
32
|
+
const nugetPath = path.join(targetFolder, "nuget.exe");
|
|
33
|
+
const nuget = resolveNuget(nugetPath, false);
|
|
34
|
+
if (nuget && !nuget.match(/dotnet/i)) {
|
|
35
|
+
if (!process.env.SKIP_NUGET_UPDATES) {
|
|
36
|
+
gutil.log("nuget.exe already exists... attempting self-update");
|
|
37
|
+
console.log(`NUGET: (${nuget})`);
|
|
38
|
+
return nugetUpdateSelf(nuget);
|
|
39
|
+
}
|
|
40
|
+
return nuget;
|
|
41
|
+
}
|
|
42
|
+
debug(`Attempting to get tools nuget to: ${targetFolder}`);
|
|
43
|
+
return downloadNuget(targetFolder);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function generateNugetSourcesOptions(toolSpecifiedSource) {
|
|
47
|
+
if (toolSpecifiedSource) {
|
|
48
|
+
return ["-source", toolSpecifiedSource];
|
|
49
|
+
}
|
|
50
|
+
return (process.env.NUGET_SOURCES || "")
|
|
51
|
+
.split(",")
|
|
52
|
+
.reduce((acc, cur) => acc.concat(cur ? ["-source", cur] : []), []);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function generateNugetInstallArgsFor(toolSpec) {
|
|
56
|
+
// accept a tool package in the formats:
|
|
57
|
+
// packagename (eg 'nunit')
|
|
58
|
+
// - retrieves the package according to the system config (original & default behavior)
|
|
59
|
+
// source/packagename (eg 'proget.mycompany.moo/nunit')
|
|
60
|
+
// - retrieves the package from the named source (same as nuget.exe install nunit -source proget.mycompany.moo}
|
|
61
|
+
// - allows consumer to be specific about where the package should come from
|
|
62
|
+
// - allows third-parties to be specific about their packages being from, eg, nuget.org
|
|
63
|
+
var parts = toolSpec.split("/");
|
|
64
|
+
var toolPackage = parts.splice(parts.length - 1);
|
|
65
|
+
return ["install", toolPackage].concat(generateNugetSourcesOptions(parts[0]));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// gulp4 doesn't seem to protect against repeated dependencies, so this is a safeguard
|
|
69
|
+
// here to prevent accidental parallel install
|
|
70
|
+
let
|
|
71
|
+
installingPromise = null,
|
|
72
|
+
installingRequest = null;
|
|
73
|
+
module.exports = {
|
|
74
|
+
install: (requiredTools, overrideToolsFolder) => {
|
|
75
|
+
if (!requiredTools) {
|
|
76
|
+
throw new ZarroError("No required tools set");
|
|
77
|
+
}
|
|
78
|
+
if (!Array.isArray(requiredTools)) {
|
|
79
|
+
requiredTools = [requiredTools];
|
|
80
|
+
}
|
|
81
|
+
const target = overrideToolsFolder || getToolsFolder();
|
|
82
|
+
// TODO: should allow subsequent installations, ie if
|
|
83
|
+
// a prior install asked for tools "A" and "B", a subsequent
|
|
84
|
+
// request for "C" should just wait and then do the work
|
|
85
|
+
if (installingPromise) {
|
|
86
|
+
debug("default tools installer already running...");
|
|
87
|
+
const missing = requiredTools.reduce((acc, cur) => {
|
|
88
|
+
if (installingRequest.indexOf(cur) === -1) {
|
|
89
|
+
acc.push(cur);
|
|
90
|
+
}
|
|
91
|
+
return acc;
|
|
92
|
+
}, []);
|
|
93
|
+
if (missing.length) {
|
|
94
|
+
return Promist.reject("multiple tools installations are not (yet) supported");
|
|
95
|
+
}
|
|
96
|
+
return installingPromise;
|
|
97
|
+
}
|
|
98
|
+
installingRequest = requiredTools;
|
|
99
|
+
return installingPromise = ensureFolderExists(target)
|
|
100
|
+
.then(() => cleanFoldersFrom(target))
|
|
101
|
+
.then(() => downloadOrUpdateNuget(target))
|
|
102
|
+
.then(() =>
|
|
103
|
+
Promise.all(
|
|
104
|
+
requiredTools.map(tool => {
|
|
105
|
+
debug(`install: ${tool}`);
|
|
106
|
+
return nuget(
|
|
107
|
+
generateNugetInstallArgsFor(tool),
|
|
108
|
+
{ cwd: target }
|
|
109
|
+
);
|
|
110
|
+
})
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
.then(() => {
|
|
114
|
+
debug("tool installation complete");
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
clean: overrideToolsFolder => {
|
|
118
|
+
debug("cleaning tools folder");
|
|
119
|
+
const target = overrideToolsFolder || getToolsFolder();
|
|
120
|
+
return cleanFoldersFrom(target);
|
|
121
|
+
}
|
|
122
|
+
};
|