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,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an array with the required number of elements, all undefined
|
|
3
|
+
* -> unlike Array(N), this creates the elements, where Array(N) only allocates
|
|
4
|
+
* the space for elements: attempting to forEach or map over Array(N)
|
|
5
|
+
* won't accomplish much
|
|
6
|
+
* @param howMany
|
|
7
|
+
*/
|
|
8
|
+
module.exports = function seed(howMany) {
|
|
9
|
+
return Array.apply(null, Array.from({
|
|
10
|
+
length: howMany
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const
|
|
2
|
+
spawn = require("./spawn"),
|
|
3
|
+
debug = require("debug")("spawn-nuget"),
|
|
4
|
+
findLocalNuget = require("./find-local-nuget");
|
|
5
|
+
|
|
6
|
+
module.exports = async function(args, opts) {
|
|
7
|
+
const nuget = await findLocalNuget();
|
|
8
|
+
debug(`spawn nuget: ${nuget} ${args.join(" ")}`);
|
|
9
|
+
if (opts && Object.keys(opts).length) {
|
|
10
|
+
debug(` nuget spawn options: ${JSON.stringify(opts)}`);
|
|
11
|
+
}
|
|
12
|
+
return await spawn(nuget, args, opts);
|
|
13
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// use for spawning actual processes.
|
|
2
|
+
// You must use exec if you want to run batch files
|
|
3
|
+
|
|
4
|
+
const tryLoadDebug = function () {
|
|
5
|
+
try {
|
|
6
|
+
return require("debug")("spawn");
|
|
7
|
+
} catch (e) {
|
|
8
|
+
return function () {
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
quoteIfRequired = require("./quote-if-required"),
|
|
13
|
+
debug = tryLoadDebug(),
|
|
14
|
+
child_process = require("child_process");
|
|
15
|
+
|
|
16
|
+
const defaultOptions = {
|
|
17
|
+
stdio: [process.stdin, process.stdout, process.stderr],
|
|
18
|
+
cwd: process.cwd(),
|
|
19
|
+
shell: true
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function spawn(executable, args, opts) {
|
|
23
|
+
args = args || [];
|
|
24
|
+
opts = Object.assign({}, defaultOptions, opts);
|
|
25
|
+
|
|
26
|
+
let stdOutWriter = null,
|
|
27
|
+
stdErrWriter = null;
|
|
28
|
+
if (typeof opts.stdout === "function") {
|
|
29
|
+
stdOutWriter = opts.stdout;
|
|
30
|
+
opts.stdio[1] = "pipe";
|
|
31
|
+
} else {
|
|
32
|
+
opts.stdio[1] = "inherit";
|
|
33
|
+
}
|
|
34
|
+
if (typeof opts.stderr === "function") {
|
|
35
|
+
stdErrWriter = opts.stderr;
|
|
36
|
+
opts.stdio[2] = "pipe";
|
|
37
|
+
} else {
|
|
38
|
+
opts.stdio[2] = "inherit";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const result = {
|
|
42
|
+
executable: executable,
|
|
43
|
+
args: args
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
executable = quoteIfRequired(executable);
|
|
47
|
+
|
|
48
|
+
debug(`spawning: ${ executable } ${ args.map(a => '"' + a + '"').join(" ") }`);
|
|
49
|
+
debug({ opts });
|
|
50
|
+
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
try {
|
|
53
|
+
const child = child_process.spawn(executable, args, opts);
|
|
54
|
+
const stdout = [];
|
|
55
|
+
const stderr = [];
|
|
56
|
+
child.on("error", function (err) {
|
|
57
|
+
debug(`child error: ${ err }`);
|
|
58
|
+
const e = new Error(
|
|
59
|
+
`"${ [executable].concat(args).join(" ") }" failed with "${ err }"`
|
|
60
|
+
);
|
|
61
|
+
e.exitCode = -1;
|
|
62
|
+
e.stderr = stderr;
|
|
63
|
+
e.stdout = stdout;
|
|
64
|
+
reject(e);
|
|
65
|
+
});
|
|
66
|
+
child.on("close", function (code) {
|
|
67
|
+
debug(`child exits: ${ code }`);
|
|
68
|
+
result.exitCode = code;
|
|
69
|
+
if (code === 0) {
|
|
70
|
+
resolve(result);
|
|
71
|
+
} else {
|
|
72
|
+
const err = new Error(
|
|
73
|
+
`"${ [executable]
|
|
74
|
+
.concat(args)
|
|
75
|
+
.join(" ") }" failed with exit code ${ code }`
|
|
76
|
+
);
|
|
77
|
+
err.exitCode = code;
|
|
78
|
+
err.stdout = stdout;
|
|
79
|
+
err.stderr = stderr;
|
|
80
|
+
return reject(err);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (stdOutWriter) {
|
|
84
|
+
child.stdout.on("data", data => {
|
|
85
|
+
const str = data.toString();
|
|
86
|
+
stdout.push(str);
|
|
87
|
+
stdOutWriter(str);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (stdErrWriter) {
|
|
91
|
+
child.stderr.on("data", data => {
|
|
92
|
+
const str = data.toString();
|
|
93
|
+
stderr.push(str);
|
|
94
|
+
stdErrWriter(str);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
} catch (e) {
|
|
98
|
+
reject(`Unable to spawn process: ${ e }`);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module.exports = spawn;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
"use strict";
|
|
4
|
+
const env = requireModule("env"), chalk = require("ansi-colors"), noUnicode = env.resolveFlag("NO_UNICODE"), noColor = env.resolveFlag("NO_COLOR"), prefixSize = noUnicode ? 6 : 2, asciiOk = "[ OK ]", asciiFail = "[FAIL]", okMarker = noUnicode
|
|
5
|
+
? (noColor ? asciiOk : chalk.green(asciiOk))
|
|
6
|
+
: chalk.greenBright("✓"), failMarker = noUnicode
|
|
7
|
+
? (noColor ? asciiFail : chalk.redBright(asciiFail))
|
|
8
|
+
: chalk.redBright("❌"), spacedPrefix = " ".repeat(prefixSize);
|
|
9
|
+
function start(message, color) {
|
|
10
|
+
if (color && chalk[color]) {
|
|
11
|
+
message = chalk[color](message);
|
|
12
|
+
}
|
|
13
|
+
process.stdout.write(`${spacedPrefix} ${message}`);
|
|
14
|
+
}
|
|
15
|
+
function ok() {
|
|
16
|
+
process.stdout.write(`\r${okMarker}`);
|
|
17
|
+
process.stdout.write("\n");
|
|
18
|
+
}
|
|
19
|
+
function fail() {
|
|
20
|
+
process.stdout.write(`\r${failMarker}`);
|
|
21
|
+
process.stdout.write("\n");
|
|
22
|
+
}
|
|
23
|
+
function looksLikePromise(o) {
|
|
24
|
+
return isFunction(o.then);
|
|
25
|
+
}
|
|
26
|
+
function isFunction(o) {
|
|
27
|
+
return typeof (o) === "function";
|
|
28
|
+
}
|
|
29
|
+
async function run(message, action) {
|
|
30
|
+
start(message);
|
|
31
|
+
let result;
|
|
32
|
+
try {
|
|
33
|
+
result = action();
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
fail();
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
if (looksLikePromise(result)) {
|
|
40
|
+
try {
|
|
41
|
+
result = await result;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
fail();
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
ok();
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
module.exports = {
|
|
52
|
+
start,
|
|
53
|
+
ok,
|
|
54
|
+
fail,
|
|
55
|
+
run
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
"use strict";
|
|
3
|
+
const
|
|
4
|
+
env = requireModule<Env>("env"),
|
|
5
|
+
chalk = require("ansi-colors"),
|
|
6
|
+
noUnicode = env.resolveFlag("NO_UNICODE"),
|
|
7
|
+
noColor = env.resolveFlag("NO_COLOR"),
|
|
8
|
+
prefixSize = noUnicode ? 6 : 2,
|
|
9
|
+
asciiOk = "[ OK ]",
|
|
10
|
+
asciiFail = "[FAIL]",
|
|
11
|
+
okMarker = noUnicode
|
|
12
|
+
? (noColor ? asciiOk : chalk.green(asciiOk))
|
|
13
|
+
: chalk.greenBright("✓"),
|
|
14
|
+
failMarker = noUnicode
|
|
15
|
+
? (noColor ? asciiFail : chalk.redBright(asciiFail))
|
|
16
|
+
: chalk.redBright("❌"),
|
|
17
|
+
spacedPrefix = " ".repeat(prefixSize);
|
|
18
|
+
|
|
19
|
+
function start(message: string, color?: Colors) {
|
|
20
|
+
if (color && chalk[color as string]) {
|
|
21
|
+
message = chalk[color](message);
|
|
22
|
+
}
|
|
23
|
+
process.stdout.write(`${spacedPrefix} ${message}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function ok() {
|
|
27
|
+
process.stdout.write(`\r${okMarker}`);
|
|
28
|
+
process.stdout.write("\n");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function fail() {
|
|
32
|
+
process.stdout.write(`\r${failMarker}`);
|
|
33
|
+
process.stdout.write("\n");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function looksLikePromise(o: any) {
|
|
37
|
+
return isFunction(o.then);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isFunction(o: any) {
|
|
41
|
+
return typeof (o) === "function";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function run<T>(message: string, action: (() => T | Promise<T>)) {
|
|
45
|
+
start(message);
|
|
46
|
+
let result;
|
|
47
|
+
try {
|
|
48
|
+
result = action();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
fail();
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
if (looksLikePromise(result)) {
|
|
54
|
+
try {
|
|
55
|
+
result = await result;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
fail();
|
|
58
|
+
throw e;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ok()
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
start,
|
|
67
|
+
ok,
|
|
68
|
+
fail,
|
|
69
|
+
run
|
|
70
|
+
};
|
|
71
|
+
})();
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const
|
|
3
|
+
log = require("./log"),
|
|
4
|
+
fs = require("fs"),
|
|
5
|
+
path = require("path"),
|
|
6
|
+
debug = require("debug")("testutil-finder"),
|
|
7
|
+
lsR = require("./ls-r"),
|
|
8
|
+
whichLib = require("which"),
|
|
9
|
+
programFilesFolder = process.env["ProgramFiles(x86)"] || process.env["ProgramFiles"],
|
|
10
|
+
getToolsFolder = require("./get-tools-folder"),
|
|
11
|
+
{ ZarroError } = requireModule("zarro-error"),
|
|
12
|
+
localAppDataFolder = process.env["LOCALAPPDATA"];
|
|
13
|
+
|
|
14
|
+
function which(command) {
|
|
15
|
+
try {
|
|
16
|
+
return whichLib.sync(command, {});
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isUnstable(folderName) {
|
|
23
|
+
return folderName.indexOf("alpha") > -1 ||
|
|
24
|
+
folderName.indexOf("beta") > -1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function finder(searchBaseFolders, searchBaseSubFolder, searchFolderPrefix, searchBin, options) {
|
|
28
|
+
const
|
|
29
|
+
ignoreBetas = options.ignoreBetas === undefined ? true : options.ignoreBetas,
|
|
30
|
+
lprefix = searchFolderPrefix.toLowerCase();
|
|
31
|
+
if (!Array.isArray(searchBaseFolders)) {
|
|
32
|
+
searchBaseFolders = [ searchBaseFolders ];
|
|
33
|
+
}
|
|
34
|
+
const runner = searchBaseFolders
|
|
35
|
+
.filter(f => !!f)
|
|
36
|
+
.map(f => {
|
|
37
|
+
return searchBaseSubFolder
|
|
38
|
+
? path.join(f, searchBaseSubFolder)
|
|
39
|
+
: f;
|
|
40
|
+
})
|
|
41
|
+
.filter(checkExists)
|
|
42
|
+
.reduce((possibles, baseFolder) => {
|
|
43
|
+
debug("Searching: " + baseFolder);
|
|
44
|
+
return fs.readdirSync(baseFolder)
|
|
45
|
+
.reduce((acc, cur) => {
|
|
46
|
+
const folder = path.join(baseFolder, cur);
|
|
47
|
+
const lcur = cur.toLowerCase();
|
|
48
|
+
if (lcur.indexOf(lprefix) === 0) {
|
|
49
|
+
if (ignoreBetas && isUnstable(lcur)) {
|
|
50
|
+
log.notice("Ignoring unstable tool at: " + folder);
|
|
51
|
+
return acc;
|
|
52
|
+
}
|
|
53
|
+
const match = cur.match(/\d+/g);
|
|
54
|
+
if (!match) {
|
|
55
|
+
return acc;
|
|
56
|
+
}
|
|
57
|
+
const version = match.map(Number);
|
|
58
|
+
debug(`Adding possible: ${folder} = version ${version}`);
|
|
59
|
+
acc.push({
|
|
60
|
+
folder: folder,
|
|
61
|
+
version: version
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
}, possibles);
|
|
66
|
+
}, [])
|
|
67
|
+
.sort((x,y) => -compareVersionArrays(x.version, y.version))
|
|
68
|
+
.map(possible => path.join(possible.folder, searchBin))
|
|
69
|
+
.find(checkExists);
|
|
70
|
+
if (runner) {
|
|
71
|
+
log.debug("Using " + runner);
|
|
72
|
+
}
|
|
73
|
+
return runner;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function compareVersionArrays(x, y) {
|
|
77
|
+
return x.reduce((acc, cur, i) => acc || cur - y[i] || 0, 0) || x.length - y.length;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function findWrapper(func, name) {
|
|
81
|
+
const found = func();
|
|
82
|
+
if (!found) {
|
|
83
|
+
debug(`Can't find any installed ${name}`);
|
|
84
|
+
}
|
|
85
|
+
return found;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function findInstalledNUnit3() {
|
|
89
|
+
if (!programFilesFolder) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
var search = path.join(programFilesFolder, "NUnit.org", "nunit-console", "nunit3-console.exe");
|
|
93
|
+
if (!search) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return fs.existsSync(search) ? search : null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function checkExists(somePath) {
|
|
100
|
+
debug(`Checking if file exists: ${somePath}`);
|
|
101
|
+
return fs.existsSync(somePath) ? somePath : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function tryToFindNUnit(options) {
|
|
105
|
+
return initialToolSearch("nunit3-console.exe", "NUNIT") ||
|
|
106
|
+
searchForNunit(options);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function latestNUnit(options) {
|
|
110
|
+
const result = tryToFindNUnit(options);
|
|
111
|
+
debug(`Using nunit runner: ${result || "NOT FOUND"}`);
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function nunit2Finder(searchBin, options) {
|
|
116
|
+
if (!programFilesFolder) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return finder([programFilesFolder], undefined, "NUnit", searchBin, options);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function searchForNunit(options) {
|
|
123
|
+
options = options || {};
|
|
124
|
+
const isX86 = (options.x86 || ((options.platform || options.architecture) === "x86"));
|
|
125
|
+
const runner = isX86 ? "/bin/nunit-console-x86.exe" : "/bin/nunit-console.exe";
|
|
126
|
+
return findWrapper(function () {
|
|
127
|
+
return findInstalledNUnit3() || nunit2Finder(runner, options);
|
|
128
|
+
}, "nunit-console runner");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function findTool(exeName, underFolder) {
|
|
132
|
+
const allResults = lsR(underFolder || getToolsFolder()).filter(function (p) {
|
|
133
|
+
return p.toLowerCase().endsWith(exeName.toLowerCase());
|
|
134
|
+
}).sort();
|
|
135
|
+
return allResults[0] || which(exeName);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function locateDotCover(options) {
|
|
139
|
+
options = options || {};
|
|
140
|
+
return initialToolSearch("dotCover.exe", "DOTCOVER") ||
|
|
141
|
+
findWrapper(function () {
|
|
142
|
+
return finder([programFilesFolder, localAppDataFolder], "JetBrains/Installations", "dotCover", "dotCover.exe", options)
|
|
143
|
+
|| finder([programFilesFolder], "JetBrains/dotCover", "v", "Bin/dotCover.exe", options);
|
|
144
|
+
}, "dotCover");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function latestDotCover(options) {
|
|
148
|
+
const result = locateDotCover(options);
|
|
149
|
+
debug(`Using dotCover: ${result || "NOT FOUND"}`);
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function initialToolSearch(toolExe, environmentVariable) {
|
|
154
|
+
const fromEnvironment = process.env[environmentVariable];
|
|
155
|
+
if (fromEnvironment) {
|
|
156
|
+
if (!fs.existsSync(fromEnvironment)) {
|
|
157
|
+
throw new ZarroError(`${fromEnvironment} specified in environment variable ${environmentVariable} not found`);
|
|
158
|
+
}
|
|
159
|
+
return fromEnvironment;
|
|
160
|
+
}
|
|
161
|
+
return findTool(toolExe);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function latestOpenCover() {
|
|
165
|
+
const result = initialToolSearch("OpenCover.Console.exe", "OPENCOVER");
|
|
166
|
+
debug(`Using opencover: ${result || "NOT FOUND"}`);
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
module.exports = {
|
|
171
|
+
latestNUnit: latestNUnit,
|
|
172
|
+
latestDotCover: latestDotCover,
|
|
173
|
+
latestOpenCover: latestOpenCover,
|
|
174
|
+
findTool: findTool,
|
|
175
|
+
nunit2Finder: nunit2Finder
|
|
176
|
+
};
|