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
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const safeGit = requireModule("safe-git"), Git = require("simple-git/promise");
|
|
4
|
+
module.exports = async function readCurrentBranch(at) {
|
|
5
|
+
return safeGit(async () => {
|
|
6
|
+
const git = new Git(at !== null && at !== void 0 ? at : "."), branchInfo = await git.branch();
|
|
7
|
+
return branchInfo.current === ""
|
|
8
|
+
? undefined
|
|
9
|
+
: branchInfo.current; // also returns sha if detached!
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
safeGit = requireModule<SafeGit>("safe-git"),
|
|
4
|
+
Git = require("simple-git/promise");
|
|
5
|
+
|
|
6
|
+
module.exports = async function readCurrentBranch(at?: string): Promise<string | undefined> {
|
|
7
|
+
return safeGit(async () => {
|
|
8
|
+
const
|
|
9
|
+
git = new Git(at ?? "."),
|
|
10
|
+
branchInfo = await git.branch();
|
|
11
|
+
return branchInfo.current === ""
|
|
12
|
+
? undefined
|
|
13
|
+
: branchInfo.current; // also returns sha if detached!
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const path = require("path"), env = requireModule("env"), debug = require("debug")(path.basename(__filename).replace(/\.(ts|js)$/, "")), { ZarroError } = requireModule("zarro-error"), exec = requireModule("exec");
|
|
4
|
+
module.exports = async function findGitCommitDeltaCount(main, branched) {
|
|
5
|
+
const diffLine = `${main}...${branched}`;
|
|
6
|
+
debug(`performing commit diff: ${diffLine}`);
|
|
7
|
+
const raw = await exec("git", ["rev-list", "--left-right", "--count", diffLine], {
|
|
8
|
+
suppressOutput: true,
|
|
9
|
+
timeout: env.resolveNumber("GIT_VERIFY_TIMEOUT")
|
|
10
|
+
}), lines = raw.trim().split("\n")
|
|
11
|
+
.map(l => l.trim())
|
|
12
|
+
.filter(l => !!l), matches = lines[0].match(/(\d*)\s*(\d*)/);
|
|
13
|
+
if (matches === null) {
|
|
14
|
+
throw new ZarroError(`failed to read git rev-list at ${process.cwd()}`);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
behind: parseInt(matches[1], 10),
|
|
18
|
+
ahead: parseInt(matches[2], 10)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
path = require("path"),
|
|
4
|
+
env = requireModule<Env>("env"),
|
|
5
|
+
debug = require("debug")(path.basename(__filename).replace(/\.(ts|js)$/, "")),
|
|
6
|
+
{ ZarroError } = requireModule("zarro-error"),
|
|
7
|
+
exec = requireModule<Exec>("exec");
|
|
8
|
+
|
|
9
|
+
module.exports = async function findGitCommitDeltaCount(
|
|
10
|
+
main: string,
|
|
11
|
+
branched: string
|
|
12
|
+
): Promise<GitCommitDeltaCount> {
|
|
13
|
+
const diffLine = `${main}...${branched}`;
|
|
14
|
+
debug(`performing commit diff: ${diffLine}`);
|
|
15
|
+
const
|
|
16
|
+
raw = await exec("git",
|
|
17
|
+
["rev-list", "--left-right", "--count", diffLine ], {
|
|
18
|
+
suppressOutput: true,
|
|
19
|
+
timeout: env.resolveNumber("GIT_VERIFY_TIMEOUT")
|
|
20
|
+
}),
|
|
21
|
+
lines = raw.trim().split("\n")
|
|
22
|
+
.map(l => l.trim())
|
|
23
|
+
.filter(l => !!l),
|
|
24
|
+
matches = lines[0].match(/(\d*)\s*(\d*)/);
|
|
25
|
+
if (matches === null) {
|
|
26
|
+
throw new ZarroError(`failed to read git rev-list at ${process.cwd()}`);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
behind: parseInt(matches[1], 10),
|
|
30
|
+
ahead: parseInt(matches[2], 10)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
(function () {
|
|
8
|
+
const fs = requireModule("fs"), readAllGitRemotes = requireModule("read-all-git-remotes"), readGitRemote = requireModule("read-git-remote"), readAllGitBranches = requireModule("read-all-git-branches"), readCurrentBranch = requireModule("read-current-git-branch");
|
|
9
|
+
function isGitRepo(at) {
|
|
10
|
+
const dotGit = path_1.default.join(at !== null && at !== void 0 ? at : ".", ".git");
|
|
11
|
+
return fs.folderExists(dotGit);
|
|
12
|
+
}
|
|
13
|
+
module.exports = async function readGitInfo(at) {
|
|
14
|
+
const [currentBranch, branches, primaryRemote, remotes] = await Promise.all([
|
|
15
|
+
readCurrentBranch(at),
|
|
16
|
+
readAllGitBranches(at),
|
|
17
|
+
readGitRemote(at),
|
|
18
|
+
readAllGitRemotes(at)
|
|
19
|
+
]);
|
|
20
|
+
return {
|
|
21
|
+
isGitRepository: await isGitRepo(at),
|
|
22
|
+
currentBranch,
|
|
23
|
+
branches,
|
|
24
|
+
primaryRemote,
|
|
25
|
+
remotes
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
(function() {
|
|
4
|
+
const
|
|
5
|
+
fs = requireModule<FileSystemUtils>("fs"),
|
|
6
|
+
readAllGitRemotes = requireModule<ReadAllGitRemotes>("read-all-git-remotes"),
|
|
7
|
+
readGitRemote = requireModule<ReadGitRemote>("read-git-remote"),
|
|
8
|
+
readAllGitBranches = requireModule<ReadAllGitBranches>("read-all-git-branches"),
|
|
9
|
+
readCurrentBranch = requireModule<ReadCurrentGitBranch>("read-current-git-branch");
|
|
10
|
+
|
|
11
|
+
function isGitRepo(at?: string): Promise<boolean> {
|
|
12
|
+
const dotGit = path.join(at ?? ".", ".git");
|
|
13
|
+
return fs.folderExists(dotGit);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = async function readGitInfo(at?: string): Promise<GitInfo> {
|
|
17
|
+
const [ currentBranch, branches, primaryRemote, remotes ] = await Promise.all([
|
|
18
|
+
readCurrentBranch(at),
|
|
19
|
+
readAllGitBranches(at),
|
|
20
|
+
readGitRemote(at),
|
|
21
|
+
readAllGitRemotes(at)
|
|
22
|
+
]);
|
|
23
|
+
return {
|
|
24
|
+
isGitRepository: await isGitRepo(at),
|
|
25
|
+
currentBranch,
|
|
26
|
+
branches,
|
|
27
|
+
primaryRemote,
|
|
28
|
+
remotes
|
|
29
|
+
} as GitInfo;
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const safeGit = requireModule("safe-git"), Git = require("simple-git/promise");
|
|
4
|
+
module.exports = async function readGitRemote(at) {
|
|
5
|
+
const git = new Git(at || ".");
|
|
6
|
+
git._silentLogging = true;
|
|
7
|
+
const all = await safeGit(() => git.getRemotes(true), []), first = all[0];
|
|
8
|
+
if (first === undefined) {
|
|
9
|
+
// no remotes, yo (it's possible)
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (all.length > 1) {
|
|
13
|
+
console.log(`WARNING: assuming first remote found (${first.name}) is the one you want; otherwise specify GIT_REMOTE or GIT_OVERRIDE_REMOTE environment variable`);
|
|
14
|
+
}
|
|
15
|
+
return first.name;
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
safeGit = requireModule<SafeGit>("safe-git"),
|
|
4
|
+
Git = require("simple-git/promise");
|
|
5
|
+
|
|
6
|
+
module.exports = async function readGitRemote(at?: string): Promise<string | undefined> {
|
|
7
|
+
const
|
|
8
|
+
git = new Git(at || ".");
|
|
9
|
+
git._silentLogging = true;
|
|
10
|
+
|
|
11
|
+
const
|
|
12
|
+
all = await safeGit(() => git.getRemotes(true), []),
|
|
13
|
+
first = all[0];
|
|
14
|
+
if (first === undefined) {
|
|
15
|
+
// no remotes, yo (it's possible)
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
if (all.length > 1) {
|
|
19
|
+
console.log(`WARNING: assuming first remote found (${ first.name }) is the one you want; otherwise specify GIT_REMOTE or GIT_OVERRIDE_REMOTE environment variable`);
|
|
20
|
+
}
|
|
21
|
+
return first.name;
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
(function () {
|
|
8
|
+
const { stat, fileExists } = requireModule("fs");
|
|
9
|
+
module.exports = async function (at) {
|
|
10
|
+
at = at !== null && at !== void 0 ? at : ".";
|
|
11
|
+
const fetchHead = path_1.default.join(at, ".git", "FETCH_HEAD");
|
|
12
|
+
if (!(await fileExists(fetchHead))) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const st = await stat(fetchHead);
|
|
16
|
+
const result = new Date(st.mtime);
|
|
17
|
+
return isNaN(result.getTime())
|
|
18
|
+
? undefined
|
|
19
|
+
: result;
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
(function() {
|
|
4
|
+
const { stat, fileExists } = requireModule<FileSystemUtils>("fs");
|
|
5
|
+
module.exports = async function(at?: string): Promise<Date | undefined> {
|
|
6
|
+
at = at ?? ".";
|
|
7
|
+
const fetchHead = path.join(at, ".git", "FETCH_HEAD");
|
|
8
|
+
if (!(await fileExists(fetchHead))) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const st = await stat(fetchHead);
|
|
12
|
+
const result = new Date(st.mtime);
|
|
13
|
+
return isNaN(result.getTime())
|
|
14
|
+
? undefined
|
|
15
|
+
: result;
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const os = require("os"), chalk = require("ansi-colors"), Git = require("simple-git/promise"), readGitRemote = requireModule("read-git-remote"), env = requireModule("env"), exec = requireModule("exec");
|
|
4
|
+
module.exports = async function readMainBranchName() {
|
|
5
|
+
const all = await listBranchesRaw("*"), headRef = all.map(b => {
|
|
6
|
+
const match = b.match(/HEAD -> (.*)/);
|
|
7
|
+
return match
|
|
8
|
+
? match[1]
|
|
9
|
+
: "";
|
|
10
|
+
}).filter(b => !!b)[0];
|
|
11
|
+
// we don't want "origin" (or whatever the upstream is called)
|
|
12
|
+
if (!headRef) {
|
|
13
|
+
// take a guess
|
|
14
|
+
const possibles = [
|
|
15
|
+
"master",
|
|
16
|
+
"main",
|
|
17
|
+
"default"
|
|
18
|
+
], probableRemote = await readGitRemote(), git = new Git(), branchesResult = await git.branch(["-a"]), allBranches = new Set(branchesResult.all);
|
|
19
|
+
for (const branch of possibles) {
|
|
20
|
+
const test = `remotes/${probableRemote}/${branch}`;
|
|
21
|
+
if (allBranches.has(test)) {
|
|
22
|
+
const assumed = `${probableRemote}/${branch}`;
|
|
23
|
+
console.warn(chalk.yellowBright(warn(`Assuming main branch is: '${assumed}'`)));
|
|
24
|
+
return assumed;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.warn(chalk.yellowBright(warn(`Assuming main branch is 'master'`)));
|
|
28
|
+
return "master";
|
|
29
|
+
}
|
|
30
|
+
return headRef.split("/").slice(1).join("/");
|
|
31
|
+
};
|
|
32
|
+
function warn(baseMessage) {
|
|
33
|
+
return `${baseMessage}; override this with the GIT_MAIN_BRANCH environment variable`;
|
|
34
|
+
}
|
|
35
|
+
async function listBranchesRaw(spec) {
|
|
36
|
+
if (!spec) {
|
|
37
|
+
spec = "*";
|
|
38
|
+
}
|
|
39
|
+
const quotedSpec = os.platform() === "win32"
|
|
40
|
+
? spec // cmd is too dumb to expand * itself and git on windows gets the surrounding '' too, breaking the required logic
|
|
41
|
+
: `'${spec}'`; // !win32 shells will not pass in the '', but, without it, attempt to expand the spec )':
|
|
42
|
+
const raw = await git("--no-pager", "branch", "-a", "--list", quotedSpec);
|
|
43
|
+
return (raw || "").split("\n");
|
|
44
|
+
}
|
|
45
|
+
async function git(...args) {
|
|
46
|
+
return exec("git", args, { suppressOutput: true, mergeIo: true, timeout: 5000 });
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
os = require("os"),
|
|
4
|
+
chalk = require("ansi-colors"),
|
|
5
|
+
Git = require("simple-git/promise"),
|
|
6
|
+
readGitRemote = requireModule<ReadGitRemote>("read-git-remote"),
|
|
7
|
+
env = requireModule<Env>("env"),
|
|
8
|
+
exec = requireModule<Exec>("exec");
|
|
9
|
+
|
|
10
|
+
module.exports = async function readMainBranchName(): Promise<string | undefined> {
|
|
11
|
+
const
|
|
12
|
+
all = await listBranchesRaw("*"),
|
|
13
|
+
headRef = all.map(b => {
|
|
14
|
+
const match = b.match(/HEAD -> (.*)/);
|
|
15
|
+
return match
|
|
16
|
+
? match[1]
|
|
17
|
+
: ""
|
|
18
|
+
}).filter(b => !!b)[0];
|
|
19
|
+
// we don't want "origin" (or whatever the upstream is called)
|
|
20
|
+
if (!headRef) {
|
|
21
|
+
// take a guess
|
|
22
|
+
const possibles = [
|
|
23
|
+
"master",
|
|
24
|
+
"main",
|
|
25
|
+
"default"
|
|
26
|
+
],
|
|
27
|
+
probableRemote = await readGitRemote(),
|
|
28
|
+
git = new Git(),
|
|
29
|
+
branchesResult = await git.branch(["-a"]),
|
|
30
|
+
allBranches = new Set(branchesResult.all);
|
|
31
|
+
for (const branch of possibles) {
|
|
32
|
+
const test = `remotes/${ probableRemote }/${ branch }`
|
|
33
|
+
if (allBranches.has(test)) {
|
|
34
|
+
const assumed = `${ probableRemote }/${ branch }`;
|
|
35
|
+
console.warn(
|
|
36
|
+
chalk.yellowBright(
|
|
37
|
+
warn(
|
|
38
|
+
`Assuming main branch is: '${ assumed }'`)
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
return assumed;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
console.warn(
|
|
45
|
+
chalk.yellowBright(
|
|
46
|
+
warn(`Assuming main branch is 'master'`)
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
return "master";
|
|
50
|
+
}
|
|
51
|
+
return headRef.split("/").slice(1).join("/");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function warn(baseMessage: string) {
|
|
55
|
+
return `${ baseMessage }; override this with the GIT_MAIN_BRANCH environment variable`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function listBranchesRaw(spec?: string): Promise<string[]> {
|
|
59
|
+
if (!spec) {
|
|
60
|
+
spec = "*";
|
|
61
|
+
}
|
|
62
|
+
const quotedSpec = os.platform() === "win32"
|
|
63
|
+
? spec // cmd is too dumb to expand * itself and git on windows gets the surrounding '' too, breaking the required logic
|
|
64
|
+
: `'${ spec }'` // !win32 shells will not pass in the '', but, without it, attempt to expand the spec )':
|
|
65
|
+
|
|
66
|
+
const raw = await git("--no-pager", "branch", "-a", "--list", quotedSpec);
|
|
67
|
+
return (
|
|
68
|
+
raw || ""
|
|
69
|
+
).split("\n");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function git(...args: string[]) {
|
|
73
|
+
return exec("git", args, { suppressOutput: true, mergeIo: true, timeout: 5000 });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
(function () {
|
|
4
|
+
const parseXml = requireModule("parse-xml"), { ZarroError } = requireModule("zarro-error"), readTextFile = requireModule("read-text-file");
|
|
5
|
+
module.exports = async function readNuspecVersion(pathToNuspec) {
|
|
6
|
+
const contents = await readTextFile(pathToNuspec), doc = await parseXml(contents);
|
|
7
|
+
try {
|
|
8
|
+
return doc.package.metadata[0].version[0];
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
throw new ZarroError(`Unable to read xml node package/metadata/version in file ${pathToNuspec}`);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
parseXml = requireModule<ParseXml>("parse-xml"),
|
|
4
|
+
{ ZarroError } = requireModule("zarro-error"),
|
|
5
|
+
readTextFile = requireModule<ReadTextFile>("read-text-file");
|
|
6
|
+
|
|
7
|
+
module.exports = async function readNuspecVersion(pathToNuspec: string) {
|
|
8
|
+
const
|
|
9
|
+
contents = await readTextFile(pathToNuspec),
|
|
10
|
+
doc = await parseXml(contents);
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
return doc.package.metadata[0].version[0];
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new ZarroError(
|
|
16
|
+
`Unable to read xml node package/metadata/version in file ${ pathToNuspec }`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const fs = require("./fs"), readTextFile = require("./read-text-file"), { ZarroError } = requireModule("zarro-error"), path = require("path");
|
|
4
|
+
module.exports = async function readPackageJson(at) {
|
|
5
|
+
if (at) {
|
|
6
|
+
if (await fs.isFolder(at)) {
|
|
7
|
+
at = path.join(at, "package.json");
|
|
8
|
+
}
|
|
9
|
+
if (!(await fs.isFile(at))) {
|
|
10
|
+
throw new ZarroError(`File not found: ${at}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const pkgFile = path.join(at !== null && at !== void 0 ? at : "package.json"), text = await readTextFile(pkgFile);
|
|
14
|
+
return JSON.parse(text);
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
fs = require("./fs"),
|
|
4
|
+
readTextFile = require("./read-text-file"),
|
|
5
|
+
{ ZarroError } = requireModule("zarro-error"),
|
|
6
|
+
path = require("path");
|
|
7
|
+
module.exports = async function readPackageJson(at?: string): Promise<PackageIndex> {
|
|
8
|
+
if (at) {
|
|
9
|
+
if (await fs.isFolder(at)) {
|
|
10
|
+
at = path.join(at, "package.json");
|
|
11
|
+
}
|
|
12
|
+
if (!(await fs.isFile(at))) {
|
|
13
|
+
throw new ZarroError(`File not found: ${at}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const
|
|
17
|
+
pkgFile = path.join(at ?? "package.json"),
|
|
18
|
+
text = await readTextFile(pkgFile);
|
|
19
|
+
return JSON.parse(text);
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
|