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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const gulp = requireModule("gulp"), status = requireModule("status"), Git = require("simple-git/promise"), env = requireModule("env");
|
|
4
|
+
env.associate("UPDATE_SUBMODULES_TO_LATEST", "update-git-submodules");
|
|
5
|
+
gulp.task("update-git-submodules", "Updates all git submodules to latest commit on master branch", async () => {
|
|
6
|
+
const git = new Git(".");
|
|
7
|
+
await status.run("Ensure submodules are initialized...", async () => await git.subModule(["update", "--init"]));
|
|
8
|
+
await status.run("Check out master on all submodules...", async () => await git.subModule(["foreach", "git", "checkout", "master"]));
|
|
9
|
+
await status.run("Update to latest commit on each submodule...", async () => await git.subModule(["foreach", "git", "pull", "--rebase"]));
|
|
10
|
+
});
|
|
11
|
+
})();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const gulp = requireModule<Gulp>("gulp"),
|
|
3
|
+
status = requireModule<Status>("status"),
|
|
4
|
+
Git = require("simple-git/promise"),
|
|
5
|
+
env = requireModule<Env>("env");
|
|
6
|
+
|
|
7
|
+
env.associate("UPDATE_SUBMODULES_TO_LATEST", "update-git-submodules");
|
|
8
|
+
|
|
9
|
+
gulp.task(
|
|
10
|
+
"update-git-submodules",
|
|
11
|
+
"Updates all git submodules to latest commit on master branch",
|
|
12
|
+
async () => {
|
|
13
|
+
const git = new Git(".");
|
|
14
|
+
await status.run(
|
|
15
|
+
"Ensure submodules are initialized...",
|
|
16
|
+
async () => await git.subModule(["update", "--init"])
|
|
17
|
+
);
|
|
18
|
+
await status.run(
|
|
19
|
+
"Check out master on all submodules...",
|
|
20
|
+
async () => await git.subModule(["foreach", "git", "checkout", "master"])
|
|
21
|
+
);
|
|
22
|
+
await status.run(
|
|
23
|
+
"Update to latest commit on each submodule...",
|
|
24
|
+
async () => await git.subModule(["foreach", "git", "pull", "--rebase"])
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
})();
|
|
29
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const spawn = requireModule("spawn"), gulp = requireModule("gulp"), env = requireModule("env"), chalk = require("ansi-colors"), resolveMasks = requireModule("resolve-masks"), debug = require("debug")("update-self"), es = require("event-stream");
|
|
4
|
+
env.associate([
|
|
5
|
+
env.DRY_RUN,
|
|
6
|
+
env.INCLUDE_PACKAGE_JSON,
|
|
7
|
+
env.EXCLUDE_PACKAGE_JSON
|
|
8
|
+
], "update-self");
|
|
9
|
+
gulp.task("update-self", "Updates zarro throughout your current project", () => {
|
|
10
|
+
const glob = resolveMasks(env.INCLUDE_PACKAGE_JSON, env.EXCLUDE_PACKAGE_JSON);
|
|
11
|
+
debug({
|
|
12
|
+
glob
|
|
13
|
+
});
|
|
14
|
+
return gulp.src(glob)
|
|
15
|
+
.pipe(updateZarroPipe(env.resolveFlag(env.BETA)));
|
|
16
|
+
});
|
|
17
|
+
function updateZarroPipe(beta) {
|
|
18
|
+
const promises = [];
|
|
19
|
+
const stream = es.through(function input(file) {
|
|
20
|
+
let save = false, saveDev = false;
|
|
21
|
+
const json = file.contents.toString();
|
|
22
|
+
try {
|
|
23
|
+
const search = "zarro", packageIndex = JSON.parse(json), deps = packageIndex.dependencies || {}, devDeps = packageIndex.devDependencies || {};
|
|
24
|
+
save = Object.keys(deps).includes(search);
|
|
25
|
+
saveDev = Object.keys(devDeps).includes(search);
|
|
26
|
+
if (!save && !saveDev) {
|
|
27
|
+
debug(`${search} not installed in ${file.path}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
debug(`${file.path} is not valid JSON`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.log(chalk.yellow(`update zarro in: ${file.dirname}`));
|
|
36
|
+
const proc = "npm", tag = beta ? "beta" : "latest", args = ["install", save ? "--save" : "--save-dev", `zarro@${tag}`, "--no-progress", "--silent"], opts = {
|
|
37
|
+
cwd: file.dirname
|
|
38
|
+
};
|
|
39
|
+
if (env.resolveFlag(env.DRY_RUN)) {
|
|
40
|
+
console.log({
|
|
41
|
+
label: "would run spawn with",
|
|
42
|
+
proc,
|
|
43
|
+
args,
|
|
44
|
+
opts
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
promises.push(spawn.call(null, proc, args, opts));
|
|
49
|
+
}
|
|
50
|
+
}, async function end() {
|
|
51
|
+
try {
|
|
52
|
+
await Promise.all(promises);
|
|
53
|
+
stream.emit("end");
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error(chalk.redBright(`
|
|
57
|
+
==================================================
|
|
58
|
+
| WARNING: Unable to update zarro, error(s) follow |
|
|
59
|
+
==================================================
|
|
60
|
+
`));
|
|
61
|
+
stream.emit("error", err);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return stream;
|
|
65
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
import * as vinyl from "vinyl";
|
|
3
|
+
|
|
4
|
+
const
|
|
5
|
+
spawn = requireModule<Spawn>("spawn"),
|
|
6
|
+
gulp = requireModule<GulpWithHelp>("gulp"),
|
|
7
|
+
env = requireModule<Env>("env"),
|
|
8
|
+
chalk = require("ansi-colors"),
|
|
9
|
+
resolveMasks = requireModule<ResolveMasks>("resolve-masks"),
|
|
10
|
+
debug = require("debug")("update-self"),
|
|
11
|
+
es = require("event-stream");
|
|
12
|
+
|
|
13
|
+
env.associate([
|
|
14
|
+
env.DRY_RUN,
|
|
15
|
+
env.INCLUDE_PACKAGE_JSON,
|
|
16
|
+
env.EXCLUDE_PACKAGE_JSON
|
|
17
|
+
], "update-self");
|
|
18
|
+
|
|
19
|
+
gulp.task(
|
|
20
|
+
"update-self",
|
|
21
|
+
"Updates zarro throughout your current project",
|
|
22
|
+
() => {
|
|
23
|
+
const
|
|
24
|
+
glob = resolveMasks(env.INCLUDE_PACKAGE_JSON, env.EXCLUDE_PACKAGE_JSON);
|
|
25
|
+
debug({
|
|
26
|
+
glob
|
|
27
|
+
});
|
|
28
|
+
return gulp.src(glob)
|
|
29
|
+
.pipe(updateZarroPipe(env.resolveFlag(env.BETA)));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function updateZarroPipe(beta: boolean) {
|
|
33
|
+
const
|
|
34
|
+
promises: Promise<any>[] = [];
|
|
35
|
+
const stream = es.through(function input(file: vinyl.BufferFile) {
|
|
36
|
+
let
|
|
37
|
+
save = false,
|
|
38
|
+
saveDev = false;
|
|
39
|
+
const json = file.contents.toString();
|
|
40
|
+
try {
|
|
41
|
+
const
|
|
42
|
+
search = "zarro",
|
|
43
|
+
packageIndex = JSON.parse(json) as PackageIndex,
|
|
44
|
+
deps = packageIndex.dependencies || {},
|
|
45
|
+
devDeps = packageIndex.devDependencies || {};
|
|
46
|
+
save = Object.keys(deps).includes(search);
|
|
47
|
+
saveDev = Object.keys(devDeps).includes(search);
|
|
48
|
+
if (!save && !saveDev) {
|
|
49
|
+
debug(`${ search } not installed in ${ file.path }`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
debug(`${ file.path } is not valid JSON`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.log(chalk.yellow(`update zarro in: ${ file.dirname }`));
|
|
57
|
+
const
|
|
58
|
+
proc = "npm",
|
|
59
|
+
tag = beta ? "beta" : "latest",
|
|
60
|
+
args = ["install", save ? "--save" : "--save-dev", `zarro@${tag}`, "--no-progress", "--silent"],
|
|
61
|
+
opts = {
|
|
62
|
+
cwd: file.dirname
|
|
63
|
+
}
|
|
64
|
+
if (env.resolveFlag(env.DRY_RUN)) {
|
|
65
|
+
console.log({
|
|
66
|
+
label: "would run spawn with",
|
|
67
|
+
proc,
|
|
68
|
+
args,
|
|
69
|
+
opts
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
promises.push(spawn.call(null, proc, args, opts))
|
|
73
|
+
}
|
|
74
|
+
}, async function end() {
|
|
75
|
+
try {
|
|
76
|
+
await Promise.all(promises)
|
|
77
|
+
stream.emit("end");
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error(chalk.redBright(`
|
|
80
|
+
==================================================
|
|
81
|
+
| WARNING: Unable to update zarro, error(s) follow |
|
|
82
|
+
==================================================
|
|
83
|
+
`));
|
|
84
|
+
stream.emit("error", err);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return stream;
|
|
88
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const os = require("os"), chalk = require("ansi-colors"), log = requireModule("log"), env = requireModule("env"), Git = require("simple-git/promise"), failAfter = requireModule("fail-after"), readMainBranchName = requireModule("read-main-branch-name"), readAllGitRemotes = requireModule("read-all-git-remotes"), readCurrentBranch = requireModule("read-current-git-branch"), readGitCommitDeltaCount = requireModule("read-git-commit-delta-count"), readLastFetchTime = requireModule("read-last-fetch-time"), gulp = requireModule("gulp"), { ZarroError } = requireModule("zarro-error"), taskName = "verify-up-to-date";
|
|
4
|
+
env.associate([
|
|
5
|
+
"SKIP_FETCH_ON_VERIFY",
|
|
6
|
+
"ENFORCE_VERIFICATION",
|
|
7
|
+
"INTERACTIVE"
|
|
8
|
+
], taskName);
|
|
9
|
+
gulp.task(taskName, async () => {
|
|
10
|
+
// git on OSX is still inserting a pager somewhere, breaking this, so temporarily
|
|
11
|
+
// disable this test
|
|
12
|
+
if (os.platform() === "darwin") {
|
|
13
|
+
console.warn(chalk.redBright(`up-to-date verification is experimental on OSX! Please report errors to davydm@gmail.com`));
|
|
14
|
+
}
|
|
15
|
+
const remoteInfos = (await readAllGitRemotes()) || [], remotes = remoteInfos.map(r => r.name), mainBranch = env.resolve("GIT_MAIN_BRANCH") || await resolveDefaultVerifyTarget(remotes), verifyBranch = env.resolve("GIT_VERIFY_BRANCH") || await readCurrentBranch();
|
|
16
|
+
if (!mainBranch) {
|
|
17
|
+
throw new ZarroError(`Can't determine main branch (try setting env: GIT_MAIN_BRANCH)`);
|
|
18
|
+
}
|
|
19
|
+
if (!verifyBranch) {
|
|
20
|
+
throw new ZarroError(`Can't determine branch to verify (try setting env: GIT_VERIFY_BRANCH)`);
|
|
21
|
+
}
|
|
22
|
+
if (remotes.length && !env.resolveFlag("SKIP_FETCH_ON_VERIFY")) {
|
|
23
|
+
const lastFetch = await readLastFetchTime(), fetchRecentPeriod = env.resolveNumber("FETCH_RECENT_TIME") * 1000, now = Date.now();
|
|
24
|
+
let recentEnough = false;
|
|
25
|
+
if (lastFetch) {
|
|
26
|
+
recentEnough = (now - fetchRecentPeriod) < lastFetch.getTime();
|
|
27
|
+
}
|
|
28
|
+
if (!recentEnough) {
|
|
29
|
+
log.info(`${taskName} :: fetching all remotes...`);
|
|
30
|
+
const git = new Git(), timeout = env.resolveNumber("GIT_FETCH_TIMEOUT");
|
|
31
|
+
try {
|
|
32
|
+
const fail = failAfter(timeout);
|
|
33
|
+
await Promise.race([
|
|
34
|
+
git.fetch(["--all"]),
|
|
35
|
+
fail.promise
|
|
36
|
+
]);
|
|
37
|
+
fail.cancel();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
const msg = e.message || e;
|
|
41
|
+
if (msg === "operation timed out") {
|
|
42
|
+
log.error(chalk.redBright(`fetch operation timed out:
|
|
43
|
+
- check that the current account can fetch from all remotes
|
|
44
|
+
- optionally disable fetch with SKIP_FETCH_ON_VERIFY=1
|
|
45
|
+
- optionally increase GIT_FETCH_TIMEOUT from current value: ${timeout}`));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
log.info(`${taskName} :: skipping fetch: was last done at ${lastFetch}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const verifyResult = await readGitCommitDeltaCount(mainBranch || "master", verifyBranch);
|
|
54
|
+
// TODO: get the delta count & chuck if behind
|
|
55
|
+
const aheadS = verifyResult.ahead === 1 ? "" : "s", behindS = verifyResult.behind === 1 ? "" : "s", message = `${chalk.yellow(verifyBranch)} is ${chalk.green(verifyResult.ahead)} commit${aheadS} ahead and ${chalk.red(verifyResult.behind)} commit${behindS} behind ${chalk.cyanBright(mainBranch)}`;
|
|
56
|
+
log.info(`${taskName} :: ${message}`);
|
|
57
|
+
if (verifyResult.behind > 0) {
|
|
58
|
+
if (env.resolveFlag("ENFORCE_VERIFICATION")) {
|
|
59
|
+
throw new ZarroError(message);
|
|
60
|
+
}
|
|
61
|
+
if (env.resolveFlag("INTERACTIVE")) {
|
|
62
|
+
console.error(`interactive mode for verify-up-to-date is not yet implemented`);
|
|
63
|
+
// TODO: ask if the user would like to merge in master & proceed if ok
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
async function resolveDefaultVerifyTarget(remotes) {
|
|
68
|
+
remotes = remotes !== null && remotes !== void 0 ? remotes : [];
|
|
69
|
+
const mainBranchName = await readMainBranchName(), remote = remotes[0];
|
|
70
|
+
if (mainBranchName === null || mainBranchName === void 0 ? void 0 : mainBranchName.startsWith(`${remote}/`)) {
|
|
71
|
+
return mainBranchName;
|
|
72
|
+
}
|
|
73
|
+
return remote
|
|
74
|
+
? `${remote}/${mainBranchName}`
|
|
75
|
+
: mainBranchName;
|
|
76
|
+
}
|
|
77
|
+
})();
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
os = require("os"),
|
|
4
|
+
chalk = require("ansi-colors"),
|
|
5
|
+
log = requireModule<Log>("log"),
|
|
6
|
+
env = requireModule<Env>("env"),
|
|
7
|
+
Git = require("simple-git/promise"),
|
|
8
|
+
failAfter = requireModule<FailAfter>("fail-after"),
|
|
9
|
+
readMainBranchName = requireModule<ReadMainBranchName>("read-main-branch-name"),
|
|
10
|
+
readAllGitRemotes = requireModule<ReadAllGitRemotes>("read-all-git-remotes"),
|
|
11
|
+
readCurrentBranch = requireModule<ReadCurrentGitBranch>("read-current-git-branch"),
|
|
12
|
+
readGitCommitDeltaCount = requireModule<ReadGitCommitDeltaCount>("read-git-commit-delta-count"),
|
|
13
|
+
readLastFetchTime = requireModule<ReadLastFetchTime>("read-last-fetch-time"),
|
|
14
|
+
gulp = requireModule<GulpWithHelp>("gulp"),
|
|
15
|
+
{ ZarroError } = requireModule("zarro-error"),
|
|
16
|
+
taskName = "verify-up-to-date";
|
|
17
|
+
|
|
18
|
+
env.associate([
|
|
19
|
+
"SKIP_FETCH_ON_VERIFY",
|
|
20
|
+
"ENFORCE_VERIFICATION",
|
|
21
|
+
"INTERACTIVE"
|
|
22
|
+
], taskName);
|
|
23
|
+
|
|
24
|
+
gulp.task(taskName, async () => {
|
|
25
|
+
// git on OSX is still inserting a pager somewhere, breaking this, so temporarily
|
|
26
|
+
// disable this test
|
|
27
|
+
if (os.platform() === "darwin") {
|
|
28
|
+
console.warn(
|
|
29
|
+
chalk.redBright(
|
|
30
|
+
`up-to-date verification is experimental on OSX! Please report errors to davydm@gmail.com`
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const
|
|
35
|
+
remoteInfos = (await readAllGitRemotes()) || [],
|
|
36
|
+
remotes = remoteInfos.map(r => r.name),
|
|
37
|
+
mainBranch = env.resolve("GIT_MAIN_BRANCH") || await resolveDefaultVerifyTarget(remotes),
|
|
38
|
+
verifyBranch = env.resolve("GIT_VERIFY_BRANCH") || await readCurrentBranch();
|
|
39
|
+
if (!mainBranch) {
|
|
40
|
+
throw new ZarroError(`Can't determine main branch (try setting env: GIT_MAIN_BRANCH)`);
|
|
41
|
+
}
|
|
42
|
+
if (!verifyBranch) {
|
|
43
|
+
throw new ZarroError(`Can't determine branch to verify (try setting env: GIT_VERIFY_BRANCH)`);
|
|
44
|
+
}
|
|
45
|
+
if (remotes.length && !env.resolveFlag("SKIP_FETCH_ON_VERIFY")) {
|
|
46
|
+
const
|
|
47
|
+
lastFetch = await readLastFetchTime(),
|
|
48
|
+
fetchRecentPeriod = env.resolveNumber("FETCH_RECENT_TIME") * 1000,
|
|
49
|
+
now = Date.now();
|
|
50
|
+
let recentEnough = false;
|
|
51
|
+
if (lastFetch) {
|
|
52
|
+
recentEnough = (now - fetchRecentPeriod) < lastFetch.getTime();
|
|
53
|
+
}
|
|
54
|
+
if (!recentEnough) {
|
|
55
|
+
log.info(`${ taskName } :: fetching all remotes...`);
|
|
56
|
+
const
|
|
57
|
+
git = new Git(),
|
|
58
|
+
timeout = env.resolveNumber("GIT_FETCH_TIMEOUT");
|
|
59
|
+
try {
|
|
60
|
+
const fail = failAfter(timeout);
|
|
61
|
+
await Promise.race([
|
|
62
|
+
git.fetch(["--all"]),
|
|
63
|
+
fail.promise
|
|
64
|
+
]);
|
|
65
|
+
fail.cancel();
|
|
66
|
+
} catch (e) {
|
|
67
|
+
const msg = e.message || e;
|
|
68
|
+
if (msg === "operation timed out") {
|
|
69
|
+
log.error(chalk.redBright(`fetch operation timed out:
|
|
70
|
+
- check that the current account can fetch from all remotes
|
|
71
|
+
- optionally disable fetch with SKIP_FETCH_ON_VERIFY=1
|
|
72
|
+
- optionally increase GIT_FETCH_TIMEOUT from current value: ${timeout}`))
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
log.info(`${ taskName } :: skipping fetch: was last done at ${ lastFetch }`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const verifyResult = await readGitCommitDeltaCount(
|
|
80
|
+
mainBranch || "master", verifyBranch);
|
|
81
|
+
// TODO: get the delta count & chuck if behind
|
|
82
|
+
const
|
|
83
|
+
aheadS = verifyResult.ahead === 1 ? "" : "s",
|
|
84
|
+
behindS = verifyResult.behind === 1 ? "" : "s",
|
|
85
|
+
message = `${
|
|
86
|
+
chalk.yellow(verifyBranch)
|
|
87
|
+
} is ${
|
|
88
|
+
chalk.green(verifyResult.ahead)
|
|
89
|
+
} commit${ aheadS } ahead and ${
|
|
90
|
+
chalk.red(verifyResult.behind)
|
|
91
|
+
} commit${ behindS } behind ${
|
|
92
|
+
chalk.cyanBright(mainBranch)
|
|
93
|
+
}`;
|
|
94
|
+
log.info(`${ taskName } :: ${ message }`);
|
|
95
|
+
|
|
96
|
+
if (verifyResult.behind > 0) {
|
|
97
|
+
if (env.resolveFlag("ENFORCE_VERIFICATION")) {
|
|
98
|
+
throw new ZarroError(message);
|
|
99
|
+
}
|
|
100
|
+
if (env.resolveFlag("INTERACTIVE")) {
|
|
101
|
+
console.error(`interactive mode for verify-up-to-date is not yet implemented`);
|
|
102
|
+
// TODO: ask if the user would like to merge in master & proceed if ok
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
async function resolveDefaultVerifyTarget(remotes?: string[]) {
|
|
108
|
+
remotes = remotes ?? [];
|
|
109
|
+
const
|
|
110
|
+
mainBranchName = await readMainBranchName(),
|
|
111
|
+
remote = remotes[0];
|
|
112
|
+
if (mainBranchName?.startsWith(`${ remote }/`)) {
|
|
113
|
+
return mainBranchName;
|
|
114
|
+
}
|
|
115
|
+
return remote
|
|
116
|
+
? `${ remote }/${ mainBranchName }`
|
|
117
|
+
: mainBranchName
|
|
118
|
+
}
|
|
119
|
+
})();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
module.exports = function containsAny() {
|
|
3
|
+
// should be invoked with an args array followed by a list of things to look for
|
|
4
|
+
let
|
|
5
|
+
args = Array.from(arguments),
|
|
6
|
+
array = args[0] || [];
|
|
7
|
+
if (!Array.isArray(array)) {
|
|
8
|
+
array = [ array ]
|
|
9
|
+
}
|
|
10
|
+
if (array.length === 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const values = args.slice(1);
|
|
15
|
+
if (values.length === 0) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return array.reduce(
|
|
20
|
+
(acc, cur) => {
|
|
21
|
+
if (acc) {
|
|
22
|
+
return acc;
|
|
23
|
+
}
|
|
24
|
+
if (cur === values[0]) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return containsAny(values.slice(1), cur);
|
|
28
|
+
},
|
|
29
|
+
false);
|
|
30
|
+
};
|
|
31
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = async function gatherArgs(
|
|
2
|
+
potentialEntryPoints,
|
|
3
|
+
overrideArgv // for testing only
|
|
4
|
+
) {
|
|
5
|
+
const argv = overrideArgv || process.argv;
|
|
6
|
+
if (!Array.isArray(potentialEntryPoints)) {
|
|
7
|
+
potentialEntryPoints = [potentialEntryPoints];
|
|
8
|
+
}
|
|
9
|
+
for (let entryPoint of potentialEntryPoints) {
|
|
10
|
+
const entryPointIndex = argv.indexOf(entryPoint);
|
|
11
|
+
if (entryPointIndex > -1) {
|
|
12
|
+
return argv.slice(entryPointIndex + 1);
|
|
13
|
+
}
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Can't figure out args: unable to find entry point in args list:\n${JSON.stringify({
|
|
17
|
+
potentialEntryPoints,
|
|
18
|
+
overrideArgv,
|
|
19
|
+
argv: process.argv
|
|
20
|
+
}, null, 2)}`);
|
|
21
|
+
};
|