fork-version 4.1.10 → 5.0.1
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/CHANGELOG.md +20 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +54 -193
- package/dist/commands/inspect.d.ts +9 -0
- package/dist/commands/inspect.js +41 -0
- package/dist/commands/main.d.ts +16 -0
- package/dist/commands/main.js +30 -0
- package/dist/commands/validate-config.d.ts +6 -0
- package/dist/commands/validate-config.js +11 -0
- package/dist/commit-parser/commit-parser.d.ts +114 -0
- package/dist/commit-parser/commit-parser.js +327 -0
- package/dist/commit-parser/filter-reverted-commits.d.ts +17 -0
- package/dist/commit-parser/filter-reverted-commits.js +34 -0
- package/dist/commit-parser/options.d.ts +74 -0
- package/dist/commit-parser/options.js +70 -0
- package/dist/commit-parser/parser-error.js +14 -0
- package/dist/commit-parser/types.d.ts +53 -0
- package/dist/config/changelog-preset-config.js +41 -0
- package/dist/config/cli-arguments.d.ts +109 -0
- package/dist/config/cli-arguments.js +141 -0
- package/dist/config/defaults.js +38 -0
- package/dist/config/define-config.d.ts +9 -0
- package/dist/config/define-config.js +9 -0
- package/dist/config/load-config.js +45 -0
- package/dist/config/merge-files.js +12 -0
- package/dist/config/schema.d.ts +50 -0
- package/dist/config/schema.js +61 -0
- package/dist/config/types.d.ts +279 -0
- package/dist/config/user-config.d.ts +6 -0
- package/dist/config/user-config.js +50 -0
- package/dist/detect-git-host/detect-git-host.js +35 -0
- package/dist/detect-git-host/host-azure-devops.js +28 -0
- package/dist/detect-git-host/host-bitbucket.js +28 -0
- package/dist/detect-git-host/host-github.js +32 -0
- package/dist/detect-git-host/host-gitlab.js +48 -0
- package/dist/files/arm-bicep.js +38 -0
- package/dist/files/file-manager.d.ts +56 -0
- package/dist/files/file-manager.js +87 -0
- package/dist/files/install-shield-ism.js +55 -0
- package/dist/files/json-package.js +64 -0
- package/dist/files/ms-build-project.js +55 -0
- package/dist/files/plain-text.js +31 -0
- package/dist/files/yaml-package.js +57 -0
- package/dist/index.d.ts +21 -655
- package/dist/index.js +19 -10
- package/dist/process/changelog.d.ts +7 -0
- package/dist/process/changelog.js +69 -0
- package/dist/process/commit.d.ts +9 -0
- package/dist/process/commit.js +22 -0
- package/dist/process/get-commits.d.ts +14 -0
- package/dist/process/get-commits.js +25 -0
- package/dist/process/get-current-version.d.ts +13 -0
- package/dist/process/get-current-version.js +35 -0
- package/dist/process/get-next-version.d.ts +21 -0
- package/dist/process/get-next-version.js +72 -0
- package/dist/process/tag.d.ts +8 -0
- package/dist/process/tag.js +15 -0
- package/dist/services/git.d.ts +141 -0
- package/dist/services/git.js +236 -0
- package/dist/services/logger.d.ts +18 -0
- package/dist/services/logger.js +35 -0
- package/dist/utils/clean-tag.js +21 -0
- package/dist/utils/escape-regex.js +17 -0
- package/dist/utils/file-state.js +19 -0
- package/dist/utils/format-commit-message.js +13 -0
- package/dist/utils/parse-regexp-string.js +31 -0
- package/dist/utils/release-type.js +47 -0
- package/dist/utils/trim-string-array.js +20 -0
- package/package.json +11 -29
- package/dist/chunk-33WIJWQZ.cjs +0 -2306
- package/dist/chunk-33WIJWQZ.cjs.map +0 -1
- package/dist/chunk-L5UDUEHE.js +0 -2262
- package/dist/chunk-L5UDUEHE.js.map +0 -1
- package/dist/cli.cjs +0 -205
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.cjs +0 -80
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -655
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
|
|
4
|
+
//#region src/process/changelog.d.ts
|
|
5
|
+
declare function updateChangelog(config: ForkConfig, logger: Logger, nextVersion: string): Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { updateChangelog };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { fileExists } from "../utils/file-state.js";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import conventionalChangelog from "conventional-changelog";
|
|
5
|
+
//#region src/process/changelog.ts
|
|
6
|
+
/**
|
|
7
|
+
* Matches the following changelog header formats:
|
|
8
|
+
* - `## [1.2.3]`
|
|
9
|
+
* - `<a name="1.2.3"></a>`
|
|
10
|
+
*/
|
|
11
|
+
const RELEASE_PATTERN = /(^#+ \[?[0-9]+\.[0-9]+\.[0-9]+|<a name=)/m;
|
|
12
|
+
/**
|
|
13
|
+
* Get the existing changelog content from the latest release onwards.
|
|
14
|
+
* @see {@link RELEASE_PATTERN}
|
|
15
|
+
*/
|
|
16
|
+
function getOldReleaseContent(filePath, exists) {
|
|
17
|
+
if (exists) {
|
|
18
|
+
const fileContents = readFileSync(filePath, "utf-8");
|
|
19
|
+
const oldContentStart = fileContents.search(RELEASE_PATTERN);
|
|
20
|
+
if (oldContentStart !== -1) return fileContents.substring(oldContentStart);
|
|
21
|
+
}
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate the new changelog content for this release.
|
|
26
|
+
*/
|
|
27
|
+
function getNewReleaseContent(config, logger, nextVersion) {
|
|
28
|
+
return new Promise((onResolve) => {
|
|
29
|
+
let newContent = "";
|
|
30
|
+
conventionalChangelog({
|
|
31
|
+
preset: {
|
|
32
|
+
name: "conventionalcommits",
|
|
33
|
+
...config.changelogPresetConfig
|
|
34
|
+
},
|
|
35
|
+
tagPrefix: config.tagPrefix,
|
|
36
|
+
warn: (...message) => logger.debug("[conventional-changelog] ", ...message),
|
|
37
|
+
cwd: config.path
|
|
38
|
+
}, { version: nextVersion }, {
|
|
39
|
+
merges: null,
|
|
40
|
+
path: config.path
|
|
41
|
+
}).on("error", (cause) => {
|
|
42
|
+
throw new Error("[conventional-changelog] Unable to parse changes", { cause });
|
|
43
|
+
}).on("data", (chunk) => {
|
|
44
|
+
newContent += chunk.toString();
|
|
45
|
+
}).on("end", () => {
|
|
46
|
+
onResolve(newContent);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function updateChangelog(config, logger, nextVersion) {
|
|
51
|
+
if (config.skipChangelog) {
|
|
52
|
+
logger.skipping("Skipping changelog update");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (config.header.search(RELEASE_PATTERN) !== -1) throw new Error("Header cannot contain release pattern");
|
|
56
|
+
const changelogPath = resolve(config.path, config.changelog);
|
|
57
|
+
if (!config.dryRun && !fileExists(changelogPath)) {
|
|
58
|
+
logger.log(`Creating changelog: ${changelogPath}`);
|
|
59
|
+
writeFileSync(changelogPath, "\n", "utf8");
|
|
60
|
+
} else logger.log(`Updating changelog: ${changelogPath}`);
|
|
61
|
+
const oldContent = getOldReleaseContent(changelogPath, fileExists(changelogPath));
|
|
62
|
+
const newContent = await getNewReleaseContent(config, logger, nextVersion);
|
|
63
|
+
if (!config.dryRun && newContent) writeFileSync(changelogPath, `${config.header}
|
|
64
|
+
${newContent}
|
|
65
|
+
${oldContent}
|
|
66
|
+
`.trim(), "utf8");
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { updateChangelog };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { FileState } from "../files/file-manager.js";
|
|
4
|
+
import { Git } from "../services/git.js";
|
|
5
|
+
|
|
6
|
+
//#region src/process/commit.d.ts
|
|
7
|
+
declare function commitChanges(config: ForkConfig, logger: Logger, git: Git, files: FileState[], nextVersion: string): Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { commitChanges };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fileExists } from "../utils/file-state.js";
|
|
2
|
+
import { formatCommitMessage } from "../utils/format-commit-message.js";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
//#region src/process/commit.ts
|
|
5
|
+
async function commitChanges(config, logger, git, files, nextVersion) {
|
|
6
|
+
if (config.skipCommit) {
|
|
7
|
+
logger.skipping("Skipping commit");
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
logger.log("Committing changes");
|
|
11
|
+
const filesToCommit = [];
|
|
12
|
+
if (fileExists(resolve(config.path, config.changelog))) filesToCommit.push(resolve(config.path, config.changelog));
|
|
13
|
+
for (const file of files) filesToCommit.push(file.path);
|
|
14
|
+
if (filesToCommit.length === 0) return;
|
|
15
|
+
if (config.commitAll) await git.add("--all");
|
|
16
|
+
else await git.add(...filesToCommit);
|
|
17
|
+
const shouldVerify = config.verify ? void 0 : "--no-verify";
|
|
18
|
+
const shouldSign = config.sign ? "--gpg-sign" : "--no-gpg-sign";
|
|
19
|
+
await git.commit(shouldVerify, shouldSign, "--message", formatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion));
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { commitChanges };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { Git } from "../services/git.js";
|
|
4
|
+
import { Commit } from "../commit-parser/types.js";
|
|
5
|
+
|
|
6
|
+
//#region src/process/get-commits.d.ts
|
|
7
|
+
interface CommitsSinceTag {
|
|
8
|
+
latestTag: string | undefined;
|
|
9
|
+
latestTagVersion: string | undefined;
|
|
10
|
+
commits: Commit[];
|
|
11
|
+
}
|
|
12
|
+
declare function getCommitsSinceTag(config: ForkConfig, logger: Logger, git: Git): Promise<CommitsSinceTag>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CommitsSinceTag, getCommitsSinceTag };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CommitParser } from "../commit-parser/commit-parser.js";
|
|
2
|
+
import { filterRevertedCommits } from "../commit-parser/filter-reverted-commits.js";
|
|
3
|
+
import { cleanTag } from "../utils/clean-tag.js";
|
|
4
|
+
//#region src/process/get-commits.ts
|
|
5
|
+
async function getCommitsSinceTag(config, logger, git) {
|
|
6
|
+
const commitParser = new CommitParser(config.commitParserOptions);
|
|
7
|
+
if (config.debug) commitParser.setLogger(logger);
|
|
8
|
+
const latestTag = await git.getMostRecentTag(config.tagPrefix);
|
|
9
|
+
if (!latestTag) logger.warn("No previous tag found, using all commits");
|
|
10
|
+
const foundCommits = await git.getCommits(latestTag, "HEAD");
|
|
11
|
+
const commits = foundCommits.reduce((acc, commit) => {
|
|
12
|
+
const parsed = commitParser.parse(commit);
|
|
13
|
+
if (parsed) acc.push(parsed);
|
|
14
|
+
return acc;
|
|
15
|
+
}, []);
|
|
16
|
+
const filteredCommits = filterRevertedCommits(commits);
|
|
17
|
+
logger.debug(`Found ${foundCommits.length} commits since tag: ${latestTag ?? "none"} (${commits.length} parsed, ${filteredCommits.length} after filtering reverts)`);
|
|
18
|
+
return {
|
|
19
|
+
latestTag,
|
|
20
|
+
latestTagVersion: cleanTag(latestTag, config.tagPrefix),
|
|
21
|
+
commits: filteredCommits
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getCommitsSinceTag };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { FileManager, FileState } from "../files/file-manager.js";
|
|
4
|
+
import { Git } from "../services/git.js";
|
|
5
|
+
|
|
6
|
+
//#region src/process/get-current-version.d.ts
|
|
7
|
+
interface CurrentVersion {
|
|
8
|
+
version: string;
|
|
9
|
+
files: FileState[];
|
|
10
|
+
}
|
|
11
|
+
declare function getCurrentVersion(config: ForkConfig, logger: Logger, git: Git, fileManager: FileManager, filesToUpdate: string[], latestTagVersion: string | undefined): Promise<CurrentVersion>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CurrentVersion, getCurrentVersion };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
//#region src/process/get-current-version.ts
|
|
3
|
+
async function getCurrentVersion(config, logger, git, fileManager, filesToUpdate, latestTagVersion) {
|
|
4
|
+
const files = [];
|
|
5
|
+
const versions = /* @__PURE__ */ new Set();
|
|
6
|
+
for (const file of filesToUpdate) {
|
|
7
|
+
if (await git.isIgnored(file)) {
|
|
8
|
+
logger.debug(`[Git Ignored] ${file}`);
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const fileState = fileManager.read(file);
|
|
12
|
+
if (fileState) {
|
|
13
|
+
files.push(fileState);
|
|
14
|
+
if (!config.currentVersion) versions.add(fileState.version);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (config.currentVersion) versions.add(config.currentVersion);
|
|
18
|
+
if (versions.size === 0 && config.gitTagFallback && latestTagVersion) {
|
|
19
|
+
logger.warn(`Using latest git tag as fallback`);
|
|
20
|
+
versions.add(latestTagVersion);
|
|
21
|
+
}
|
|
22
|
+
if (versions.size === 0) throw new Error("Unable to find current version");
|
|
23
|
+
else if (versions.size > 1) {
|
|
24
|
+
if (!config.allowMultipleVersions) throw new Error("Found multiple versions");
|
|
25
|
+
logger.warn(`Found multiple versions (${Array.from(versions).join(", ")}), using the higher semver version`);
|
|
26
|
+
}
|
|
27
|
+
const currentVersion = semver.rsort(Array.from(versions))[0];
|
|
28
|
+
logger.log(`Current version: ${currentVersion}`);
|
|
29
|
+
return {
|
|
30
|
+
files,
|
|
31
|
+
version: currentVersion
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { getCurrentVersion };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { Commit } from "../commit-parser/types.js";
|
|
4
|
+
import { ReleaseType } from "semver";
|
|
5
|
+
|
|
6
|
+
//#region src/process/get-next-version.d.ts
|
|
7
|
+
interface NextVersion {
|
|
8
|
+
version: string;
|
|
9
|
+
releaseType?: ReleaseType;
|
|
10
|
+
preMajor?: boolean;
|
|
11
|
+
changes?: {
|
|
12
|
+
major: number;
|
|
13
|
+
minor: number;
|
|
14
|
+
patch: number;
|
|
15
|
+
merges: number;
|
|
16
|
+
reverts: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare function getNextVersion(config: ForkConfig, logger: Logger, commits: Commit[], currentVersion: string): Promise<NextVersion>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { NextVersion, getNextVersion };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getReleaseType } from "../utils/release-type.js";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
//#region src/process/get-next-version.ts
|
|
4
|
+
async function getNextVersion(config, logger, commits, currentVersion) {
|
|
5
|
+
if (config.skipBump) {
|
|
6
|
+
logger.skipping(`Skipping bump, using ${currentVersion} as the next version`);
|
|
7
|
+
return { version: currentVersion };
|
|
8
|
+
}
|
|
9
|
+
if (config.nextVersion) {
|
|
10
|
+
if (!semver.valid(config.nextVersion)) throw new Error(`Invalid Version: ${config.nextVersion}`);
|
|
11
|
+
logger.log(`Next version: ${config.nextVersion}`);
|
|
12
|
+
return { version: config.nextVersion };
|
|
13
|
+
}
|
|
14
|
+
const isPreMajor = semver.lt(currentVersion, "1.0.0");
|
|
15
|
+
let releaseType = "patch";
|
|
16
|
+
const changes = {
|
|
17
|
+
major: 0,
|
|
18
|
+
minor: 0,
|
|
19
|
+
patch: 0,
|
|
20
|
+
merges: 0,
|
|
21
|
+
reverts: 0
|
|
22
|
+
};
|
|
23
|
+
if (config.releaseAs) releaseType = config.releaseAs;
|
|
24
|
+
else {
|
|
25
|
+
/**
|
|
26
|
+
* - 0 = major
|
|
27
|
+
* - 1 = minor
|
|
28
|
+
* - 2 = patch
|
|
29
|
+
*/
|
|
30
|
+
let level = 2;
|
|
31
|
+
const MINOR_TYPES = ["feat", "feature"];
|
|
32
|
+
for (const commit of commits) {
|
|
33
|
+
if (commit.merge) {
|
|
34
|
+
changes.merges += 1;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (commit.revert) {
|
|
38
|
+
changes.reverts += 1;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (commit.notes.length > 0 || commit.breakingChange) {
|
|
42
|
+
changes.major += commit.notes.length + (commit.breakingChange ? 1 : 0);
|
|
43
|
+
level = 0;
|
|
44
|
+
} else if (MINOR_TYPES.includes(commit.type.toLowerCase())) {
|
|
45
|
+
changes.minor += 1;
|
|
46
|
+
if (level === 2) level = 1;
|
|
47
|
+
} else changes.patch += 1;
|
|
48
|
+
}
|
|
49
|
+
if (isPreMajor && level < 2) {
|
|
50
|
+
level++;
|
|
51
|
+
changes.patch += changes.minor;
|
|
52
|
+
changes.minor = changes.major;
|
|
53
|
+
changes.major = 0;
|
|
54
|
+
}
|
|
55
|
+
if (level === 0) releaseType = "major";
|
|
56
|
+
else if (level === 1) releaseType = "minor";
|
|
57
|
+
else releaseType = "patch";
|
|
58
|
+
}
|
|
59
|
+
const releaseTypeOrPreRelease = getReleaseType(releaseType, currentVersion, config.preRelease);
|
|
60
|
+
const nextVersion = semver.inc(currentVersion, releaseTypeOrPreRelease, typeof config.preRelease === "string" ? config.preRelease : "") ?? "";
|
|
61
|
+
logger.log(`Next version: ${nextVersion} (${releaseTypeOrPreRelease})`);
|
|
62
|
+
if (commits.length > 0) logger.log(` - Commits: ${commits.length}` + (changes.major > 0 ? `, Majors: ${changes.major}` : "") + (changes.minor > 0 ? `, Minors: ${changes.minor}` : "") + (changes.patch > 0 ? `, Patches: ${changes.patch}` : "") + (changes.reverts > 0 ? `, Reverts: ${changes.reverts}` : "") + (changes.merges > 0 ? `, Merges: ${changes.merges}` : ""));
|
|
63
|
+
else logger.log(" - No commits found.");
|
|
64
|
+
return {
|
|
65
|
+
version: nextVersion,
|
|
66
|
+
releaseType: releaseTypeOrPreRelease,
|
|
67
|
+
preMajor: isPreMajor,
|
|
68
|
+
changes
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { getNextVersion };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { Git } from "../services/git.js";
|
|
4
|
+
|
|
5
|
+
//#region src/process/tag.d.ts
|
|
6
|
+
declare function tagChanges(config: ForkConfig, logger: Logger, git: Git, nextVersion: string): Promise<void>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { tagChanges };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { formatCommitMessage } from "../utils/format-commit-message.js";
|
|
2
|
+
//#region src/process/tag.ts
|
|
3
|
+
async function tagChanges(config, logger, git, nextVersion) {
|
|
4
|
+
if (config.skipTag) {
|
|
5
|
+
logger.skipping("Skipping tag creation");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
/** @example "v1.2.3" or "version/1.2.3" */
|
|
9
|
+
const tag = `${config.tagPrefix}${nextVersion}`;
|
|
10
|
+
logger.log(`Creating tag: ${tag}`);
|
|
11
|
+
const shouldSign = config.sign ? "--sign" : "--no-sign";
|
|
12
|
+
await git.tag(shouldSign, "--annotate", tag, "--message", formatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion));
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { tagChanges };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/services/git.d.ts
|
|
4
|
+
interface GitConfig {
|
|
5
|
+
path: ForkConfig["path"];
|
|
6
|
+
dryRun?: ForkConfig["dryRun"];
|
|
7
|
+
}
|
|
8
|
+
declare class Git {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(config: GitConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Add file contents to the index
|
|
13
|
+
*
|
|
14
|
+
* [git-add Documentation](https://git-scm.com/docs/git-add)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* await git.add("CHANGELOG.md");
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
add(...args: (string | undefined)[]): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Record changes to the repository
|
|
24
|
+
*
|
|
25
|
+
* [git-commit Documentation](https://git-scm.com/docs/git-commit)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* await git.commit("--message", "chore(release): 1.2.3");
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
commit(...args: (string | undefined)[]): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Create, list, delete or verify a tag object
|
|
35
|
+
*
|
|
36
|
+
* [git-tag Documentation](https://git-scm.com/docs/git-tag)
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* await git.tag("--annotate", "v1.2.3", "--message", "chore(release): 1.2.3");
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
tag(...args: (string | undefined)[]): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Show commit logs
|
|
46
|
+
*
|
|
47
|
+
* - [git-log Documentation](https://git-scm.com/docs/git-log)
|
|
48
|
+
* - [pretty-formats Documentation](https://git-scm.com/docs/pretty-formats)
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* await git.log("--oneline");
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
log(...args: (string | undefined)[]): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a file is ignored by git
|
|
58
|
+
*
|
|
59
|
+
* [git-check-ignore Documentation](https://git-scm.com/docs/git-check-ignore)
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* await git.isIgnored("src/my-file.txt");
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
isIgnored(file: string): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Get the name of the current branch
|
|
69
|
+
*
|
|
70
|
+
* [git-rev-parse Documentation](https://git-scm.com/docs/git-rev-parse)
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* await git.getBranchName(); // "main"
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
getBranchName(): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Get the URL of the remote repository
|
|
80
|
+
*
|
|
81
|
+
* [git-config Documentation](https://git-scm.com/docs/git-config)
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* await git.getRemoteUrl(); // "https://github.com/eglavin/fork-version"
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
getRemoteUrl(): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* `getTags` returns valid semver version tags in order of the commit history
|
|
91
|
+
*
|
|
92
|
+
* Using `git log` to get the commit history, we then parse the tags from the
|
|
93
|
+
* commit details which is expected to be in the following format:
|
|
94
|
+
* ```txt
|
|
95
|
+
* commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
|
|
96
|
+
* Author: Username <username@example.com>
|
|
97
|
+
* Date: Sat Nov 9 15:00:00 2024 +0000
|
|
98
|
+
*
|
|
99
|
+
* chore(release): v1.0.0
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* - [Functionality extracted from the conventional-changelog - git-semver-tags project](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/index.js)
|
|
103
|
+
* - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
getTags(tagPrefix: string | undefined): Promise<string[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns the most recent tag from the commit history, or `undefined` if no valid semver tags are found
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* await git.getMostRecentTag("v"); // "1.2.3"
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
getMostRecentTag(tagPrefix: string | undefined): Promise<string | undefined>;
|
|
120
|
+
/**
|
|
121
|
+
* Get commit history in a parsable format
|
|
122
|
+
*
|
|
123
|
+
* An array of strings with commit details is returned in the following format:
|
|
124
|
+
* ```txt
|
|
125
|
+
* subject
|
|
126
|
+
* body
|
|
127
|
+
* hash
|
|
128
|
+
* committer date
|
|
129
|
+
* committer name
|
|
130
|
+
* committer email
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* await git.getCommits("v1.0.0", "HEAD", "src/utils");
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
getCommits(from?: string, to?: string, ...paths: string[]): Promise<string[]>;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { Git };
|