@release-change/git 0.1.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 +21 -0
- package/README.md +15 -0
- package/dist/add.d.ts +9 -0
- package/dist/add.d.ts.map +1 -0
- package/dist/add.js +21 -0
- package/dist/add.js.map +1 -0
- package/dist/cancel-commits-since-ref.d.ts +8 -0
- package/dist/cancel-commits-since-ref.d.ts.map +1 -0
- package/dist/cancel-commits-since-ref.js +40 -0
- package/dist/cancel-commits-since-ref.js.map +1 -0
- package/dist/check-authorisation.d.ts +8 -0
- package/dist/check-authorisation.d.ts.map +1 -0
- package/dist/check-authorisation.js +36 -0
- package/dist/check-authorisation.js.map +1 -0
- package/dist/check-branch.d.ts +8 -0
- package/dist/check-branch.d.ts.map +1 -0
- package/dist/check-branch.js +37 -0
- package/dist/check-branch.js.map +1 -0
- package/dist/check-push-permissions.d.ts +8 -0
- package/dist/check-push-permissions.d.ts.map +1 -0
- package/dist/check-push-permissions.js +30 -0
- package/dist/check-push-permissions.js.map +1 -0
- package/dist/check-repository.d.ts +10 -0
- package/dist/check-repository.d.ts.map +1 -0
- package/dist/check-repository.js +28 -0
- package/dist/check-repository.js.map +1 -0
- package/dist/commit.d.ts +9 -0
- package/dist/commit.d.ts.map +1 -0
- package/dist/commit.js +21 -0
- package/dist/commit.js.map +1 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +7 -0
- package/dist/constants.js.map +1 -0
- package/dist/create-tag.d.ts +9 -0
- package/dist/create-tag.d.ts.map +1 -0
- package/dist/create-tag.js +35 -0
- package/dist/create-tag.js.map +1 -0
- package/dist/get-all-tags.d.ts +8 -0
- package/dist/get-all-tags.d.ts.map +1 -0
- package/dist/get-all-tags.js +28 -0
- package/dist/get-all-tags.js.map +1 -0
- package/dist/get-branch-name.d.ts +10 -0
- package/dist/get-branch-name.d.ts.map +1 -0
- package/dist/get-branch-name.js +33 -0
- package/dist/get-branch-name.js.map +1 -0
- package/dist/get-commits-since-ref.d.ts +8 -0
- package/dist/get-commits-since-ref.d.ts.map +1 -0
- package/dist/get-commits-since-ref.js +50 -0
- package/dist/get-commits-since-ref.js.map +1 -0
- package/dist/get-current-commit-id.d.ts +7 -0
- package/dist/get-current-commit-id.d.ts.map +1 -0
- package/dist/get-current-commit-id.js +11 -0
- package/dist/get-current-commit-id.js.map +1 -0
- package/dist/get-latest-valid-tag.d.ts +9 -0
- package/dist/get-latest-valid-tag.d.ts.map +1 -0
- package/dist/get-latest-valid-tag.js +52 -0
- package/dist/get-latest-valid-tag.js.map +1 -0
- package/dist/get-remote-name.d.ts +8 -0
- package/dist/get-remote-name.d.ts.map +1 -0
- package/dist/get-remote-name.js +24 -0
- package/dist/get-remote-name.js.map +1 -0
- package/dist/get-tracked-repositories.d.ts +8 -0
- package/dist/get-tracked-repositories.d.ts.map +1 -0
- package/dist/get-tracked-repositories.js +14 -0
- package/dist/get-tracked-repositories.js.map +1 -0
- package/dist/git.types.d.ts +5 -0
- package/dist/git.types.d.ts.map +1 -0
- package/dist/git.types.js +2 -0
- package/dist/git.types.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/is-branch-up-to-date.d.ts +9 -0
- package/dist/is-branch-up-to-date.d.ts.map +1 -0
- package/dist/is-branch-up-to-date.js +23 -0
- package/dist/is-branch-up-to-date.js.map +1 -0
- package/dist/is-git-repository.d.ts +10 -0
- package/dist/is-git-repository.d.ts.map +1 -0
- package/dist/is-git-repository.js +22 -0
- package/dist/is-git-repository.js.map +1 -0
- package/dist/push.d.ts +9 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/push.js +45 -0
- package/dist/push.js.map +1 -0
- package/dist/remove-tag-on-remote-repository.d.ts +8 -0
- package/dist/remove-tag-on-remote-repository.d.ts.map +1 -0
- package/dist/remove-tag-on-remote-repository.js +40 -0
- package/dist/remove-tag-on-remote-repository.js.map +1 -0
- package/dist/remove-tag.d.ts +8 -0
- package/dist/remove-tag.d.ts.map +1 -0
- package/dist/remove-tag.js +40 -0
- package/dist/remove-tag.js.map +1 -0
- package/dist/set-branch-name.d.ts +11 -0
- package/dist/set-branch-name.d.ts.map +1 -0
- package/dist/set-branch-name.js +38 -0
- package/dist/set-branch-name.js.map +1 -0
- package/dist/switch-to-new-branch.d.ts +8 -0
- package/dist/switch-to-new-branch.d.ts.map +1 -0
- package/dist/switch-to-new-branch.js +21 -0
- package/dist/switch-to-new-branch.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { parseCommit } from "@release-change/commit-analyser";
|
|
3
|
+
import { addErrorToContext, checkErrorType, setLogger } from "@release-change/logger";
|
|
4
|
+
import { agreeInNumber, runCommandSync } from "@release-change/shared";
|
|
5
|
+
import { COMMIT_SEPARATOR } from "./constants.js";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the commits since the reference (Git tag or the whole history).
|
|
8
|
+
* @param context - The context where the CLI is running.
|
|
9
|
+
* @return An array containing the commits found and parsed.
|
|
10
|
+
*/
|
|
11
|
+
export const getCommitsSinceRef = (context) => {
|
|
12
|
+
const { cwd, config, lastRelease } = context;
|
|
13
|
+
const { debug, isMonorepo } = config;
|
|
14
|
+
const logger = setLogger(debug);
|
|
15
|
+
logger.setScope("git");
|
|
16
|
+
try {
|
|
17
|
+
const gitTag = lastRelease ? lastRelease.ref : null;
|
|
18
|
+
const revisionRange = `${gitTag}..HEAD`;
|
|
19
|
+
const args = ["log"];
|
|
20
|
+
if (isMonorepo)
|
|
21
|
+
args.push("--name-only");
|
|
22
|
+
if (gitTag)
|
|
23
|
+
args.push(revisionRange);
|
|
24
|
+
const infoMessage = `Retrieving ${args.includes(revisionRange) ? `commits since ${gitTag}` : "all commits"}…`;
|
|
25
|
+
logger.logInfo(infoMessage);
|
|
26
|
+
const gitCommandResult = runCommandSync("git", args, { cwd });
|
|
27
|
+
const { stdout } = gitCommandResult;
|
|
28
|
+
const commits = stdout ? stdout.split(COMMIT_SEPARATOR) : [];
|
|
29
|
+
const totalCommits = commits.length;
|
|
30
|
+
const commitWord = agreeInNumber(totalCommits, ["commit", "commits"]);
|
|
31
|
+
const parsedCommits = commits.map(commit => parseCommit(commit, context));
|
|
32
|
+
if (debug) {
|
|
33
|
+
logger.setDebugScope("git:get-commits-since-ref");
|
|
34
|
+
logger.logDebug(`Command run: git ${args.join(" ")}`);
|
|
35
|
+
logger.logDebug("Commits as returned by Git");
|
|
36
|
+
logger.logDebug(inspect(commits));
|
|
37
|
+
logger.logDebug("Parsed commits");
|
|
38
|
+
logger.logDebug(inspect(parsedCommits, { depth: Number.POSITIVE_INFINITY }));
|
|
39
|
+
}
|
|
40
|
+
logger.logInfo(`Found ${totalCommits} ${commitWord}.`);
|
|
41
|
+
return parsedCommits;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
logger.logError("Failed to find commits.");
|
|
45
|
+
logger.logError(checkErrorType(error));
|
|
46
|
+
addErrorToContext(error, context);
|
|
47
|
+
process.exit(process.exitCode);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=get-commits-since-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-commits-since-ref.js","sourceRoot":"","sources":["../src/get-commits-since-ref.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;GAIG;A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+
import { runCommandSync } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current commit ID.
|
|
4
|
+
* @param cwd - The current working directory.
|
|
5
|
+
* @return The current commit ID.
|
|
6
|
+
*/
|
|
7
|
+
export const getCurrentCommitId = (cwd) => {
|
|
8
|
+
const commandResult = runCommandSync("git", ["rev-parse", "HEAD"], { cwd });
|
|
9
|
+
return commandResult.stdout.trim();
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=get-current-commit-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-current-commit-id.js","sourceRoot":"","sources":["../src/get-current-commit-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAU,EAAE;IACxD,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5E,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the latest valid Git tag for the branch.
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @param [packageName] - The name of the package for which to get the latest valid Git tag. If not provided, the latest valid Git tag for the whole repository is returned, i.e. for the root package.
|
|
6
|
+
* @return The latest valid Git tag if found, `null` otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getLatestValidTag: (context: Context, packageName?: string) => string | null;
|
|
9
|
+
//# sourceMappingURL=get-latest-valid-tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-latest-valid-tag.d.ts","sourceRoot":"","sources":["../src/get-latest-valid-tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAStD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,OAAO,EAAE,cAAc,MAAM,KAAG,MAAM,GAAG,IA0CnF,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getPrerelease, validate } from "@release-change/semver";
|
|
2
|
+
import { formatDetailedError } from "@release-change/shared";
|
|
3
|
+
import { getAllTags } from "./get-all-tags.js";
|
|
4
|
+
import { GIT_TAG_PATTERN } from "./constants.js";
|
|
5
|
+
/**
|
|
6
|
+
* Gets the latest valid Git tag for the branch.
|
|
7
|
+
* @param context - The context where the CLI is running.
|
|
8
|
+
* @param [packageName] - The name of the package for which to get the latest valid Git tag. If not provided, the latest valid Git tag for the whole repository is returned, i.e. for the root package.
|
|
9
|
+
* @return The latest valid Git tag if found, `null` otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export const getLatestValidTag = (context, packageName) => {
|
|
12
|
+
const { branch, config } = context;
|
|
13
|
+
const gitTags = getAllTags(context)
|
|
14
|
+
.filter(gitTag => validate(gitTag.replace(GIT_TAG_PATTERN, "")))
|
|
15
|
+
.filter(gitTag => typeof packageName === "string" ? gitTag.startsWith(packageName ? packageName : "v") : true);
|
|
16
|
+
if (gitTags.length) {
|
|
17
|
+
if (branch) {
|
|
18
|
+
const branchReleaseType = config.releaseType[branch];
|
|
19
|
+
if (branchReleaseType) {
|
|
20
|
+
const validGitTagsForBranch = gitTags.filter(gitTag => {
|
|
21
|
+
const prereleaseIdentifiers = getPrerelease(gitTag.replace(GIT_TAG_PATTERN, ""));
|
|
22
|
+
if (branchReleaseType.prerelease) {
|
|
23
|
+
if (prereleaseIdentifiers) {
|
|
24
|
+
const [prereleaseIdentifier] = prereleaseIdentifiers;
|
|
25
|
+
return prereleaseIdentifier === branchReleaseType.prereleaseIdentifier;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return !prereleaseIdentifiers;
|
|
30
|
+
});
|
|
31
|
+
const [gitTag] = validGitTagsForBranch;
|
|
32
|
+
return gitTag ?? null;
|
|
33
|
+
}
|
|
34
|
+
throw formatDetailedError({
|
|
35
|
+
title: "Failed to get the latest valid tag",
|
|
36
|
+
message: `No release type found for the branch ${branch}.`,
|
|
37
|
+
details: {
|
|
38
|
+
output: `packageName: ${packageName}`
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
throw formatDetailedError({
|
|
43
|
+
title: "Failed to get the latest valid tag",
|
|
44
|
+
message: "No branch name found.",
|
|
45
|
+
details: {
|
|
46
|
+
output: `packageName: ${packageName}`
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=get-latest-valid-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-latest-valid-tag.js","sourceRoot":"","sources":["../src/get-latest-valid-tag.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAE,WAAoB,EAAiB,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;SAChC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;SAC/D,MAAM,CAAC,MAAM,CAA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AW,EAAE;aACtC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the remote name for push from tracked repositories.
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @return The first remote name returned for push if there is at lease one tracked repository, `null` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getRemoteName: (context: Context) => Promise<string | null>;
|
|
8
|
+
//# sourceMappingURL=get-remote-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-remote-name.d.ts","sourceRoot":"","sources":["../src/get-remote-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAItD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAkB3E,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getTrackedRepositories } from "./get-tracked-repositories.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the remote name for push from tracked repositories.
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @return The first remote name returned for push if there is at lease one tracked repository, `null` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export const getRemoteName = async (context) => {
|
|
8
|
+
const gitRemote = await getTrackedRepositories(context);
|
|
9
|
+
if (gitRemote) {
|
|
10
|
+
const remoteNames = [
|
|
11
|
+
...new Set(gitRemote
|
|
12
|
+
.split("\n")
|
|
13
|
+
.filter(remote => remote.endsWith("(push)"))
|
|
14
|
+
.map(remote => remote.replaceAll(/^(\S+).+$/g, "$1")))
|
|
15
|
+
];
|
|
16
|
+
if (remoteNames.length) {
|
|
17
|
+
const [remoteName] = remoteNames;
|
|
18
|
+
return remoteName ? remoteName : null;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=get-remote-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-remote-name.js","sourceRoot":"","sources":["../src/get-remote-name.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,OAAgB,EAA0B,EAAE;IAC9E,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,WAAW,GAAG;YAClB,GAAG,IAAI,GAAG,CACR,SAAS;iBACN,KAAK,CAAC,IAAI,CAAC;iBACX,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;iBAC3C,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CACxD;SACF,CAAC;QACF,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACvB,MAAM,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC;YACjC,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the tracked repositories.
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @return The value returned by `git remote -v` if this is a Git repository, `null` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getTrackedRepositories: (context: Context) => Promise<string | null>;
|
|
8
|
+
//# sourceMappingURL=get-tracked-repositories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tracked-repositories.d.ts","sourceRoot":"","sources":["../src/get-tracked-repositories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAOtD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAIpF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { setLogger } from "@release-change/logger";
|
|
2
|
+
import { runCommandSync } from "@release-change/shared";
|
|
3
|
+
import { isGitRepository } from "./is-git-repository.js";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the tracked repositories.
|
|
6
|
+
* @param context - The context where the CLI is running.
|
|
7
|
+
* @return The value returned by `git remote -v` if this is a Git repository, `null` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const getTrackedRepositories = async (context) => {
|
|
10
|
+
return (await isGitRepository(context, setLogger()))
|
|
11
|
+
? runCommandSync("git", ["remote", "-v"], { cwd: context.cwd }).stdout
|
|
12
|
+
: null;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=get-tracked-repositories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tracked-repositories.js","sourceRoot":"","sources":["../src/get-tracked-repositories.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,OAAgB,EAA0B,EAAE;IACvF,OAAO,CAAC,MAAM,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM;QACtE,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.types.d.ts","sourceRoot":"","sources":["../src/git.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.types.js","sourceRoot":"","sources":["../src/git.types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { add } from "./add.js";
|
|
2
|
+
export { cancelCommitsSinceRef } from "./cancel-commits-since-ref.js";
|
|
3
|
+
export { checkBranch } from "./check-branch.js";
|
|
4
|
+
export { checkPushPermissions } from "./check-push-permissions.js";
|
|
5
|
+
export { checkRepository } from "./check-repository.js";
|
|
6
|
+
export { commit } from "./commit.js";
|
|
7
|
+
export { createTag } from "./create-tag.js";
|
|
8
|
+
export { getAllTags } from "./get-all-tags.js";
|
|
9
|
+
export { getBranchName } from "./get-branch-name.js";
|
|
10
|
+
export { getCommitsSinceRef } from "./get-commits-since-ref.js";
|
|
11
|
+
export { getCurrentCommitId } from "./get-current-commit-id.js";
|
|
12
|
+
export { getLatestValidTag } from "./get-latest-valid-tag.js";
|
|
13
|
+
export { getRemoteName } from "./get-remote-name.js";
|
|
14
|
+
export { getTrackedRepositories } from "./get-tracked-repositories.js";
|
|
15
|
+
export { push } from "./push.js";
|
|
16
|
+
export { removeTag } from "./remove-tag.js";
|
|
17
|
+
export { removeTagOnRemoteRepository } from "./remove-tag-on-remote-repository.js";
|
|
18
|
+
export { setBranchName } from "./set-branch-name.js";
|
|
19
|
+
export { switchToNewBranch } from "./switch-to-new-branch.js";
|
|
20
|
+
export { COMMITTER_EMAIL, COMMITTER_NAME, GIT_TAG_PATTERN } from "./constants.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { add } from "./add.js";
|
|
2
|
+
export { cancelCommitsSinceRef } from "./cancel-commits-since-ref.js";
|
|
3
|
+
export { checkBranch } from "./check-branch.js";
|
|
4
|
+
export { checkPushPermissions } from "./check-push-permissions.js";
|
|
5
|
+
export { checkRepository } from "./check-repository.js";
|
|
6
|
+
export { commit } from "./commit.js";
|
|
7
|
+
export { createTag } from "./create-tag.js";
|
|
8
|
+
export { getAllTags } from "./get-all-tags.js";
|
|
9
|
+
export { getBranchName } from "./get-branch-name.js";
|
|
10
|
+
export { getCommitsSinceRef } from "./get-commits-since-ref.js";
|
|
11
|
+
export { getCurrentCommitId } from "./get-current-commit-id.js";
|
|
12
|
+
export { getLatestValidTag } from "./get-latest-valid-tag.js";
|
|
13
|
+
export { getRemoteName } from "./get-remote-name.js";
|
|
14
|
+
export { getTrackedRepositories } from "./get-tracked-repositories.js";
|
|
15
|
+
export { push } from "./push.js";
|
|
16
|
+
export { removeTag } from "./remove-tag.js";
|
|
17
|
+
export { removeTagOnRemoteRepository } from "./remove-tag-on-remote-repository.js";
|
|
18
|
+
export { setBranchName } from "./set-branch-name.js";
|
|
19
|
+
export { switchToNewBranch } from "./switch-to-new-branch.js";
|
|
20
|
+
export { COMMITTER_EMAIL, COMMITTER_NAME, GIT_TAG_PATTERN } from "./constants.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the branch from which the CLI running is going to publish is up to date.
|
|
4
|
+
* @param branch - The branch from which the CLI running is going to publish.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
* @return `true` if the branch is up to date, `false` otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isBranchUpToDate: (branch: string, context: Context) => Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=is-branch-up-to-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-branch-up-to-date.d.ts","sourceRoot":"","sources":["../src/is-branch-up-to-date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAMtD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAU,QAAQ,MAAM,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CAaxF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { runCommandSync } from "@release-change/shared";
|
|
2
|
+
import { getRemoteName } from "./get-remote-name.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the branch from which the CLI running is going to publish is up to date.
|
|
5
|
+
* @param branch - The branch from which the CLI running is going to publish.
|
|
6
|
+
* @param context - The context where the CLI is running.
|
|
7
|
+
* @return `true` if the branch is up to date, `false` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const isBranchUpToDate = async (branch, context) => {
|
|
10
|
+
if (branch) {
|
|
11
|
+
const remoteName = await getRemoteName(context);
|
|
12
|
+
if (remoteName) {
|
|
13
|
+
runCommandSync("git", ["fetch", remoteName], { cwd: context.cwd });
|
|
14
|
+
const comparedCommits = runCommandSync("git", ["rev-list", `@{u}..${remoteName}/${branch}`], {
|
|
15
|
+
cwd: context.cwd
|
|
16
|
+
}).stdout;
|
|
17
|
+
return !comparedCommits;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=is-branch-up-to-date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-branch-up-to-date.js","sourceRoot":"","sources":["../src/is-branch-up-to-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAc,EAAE,OAAgB,EAAoB,EAAE;IAC3F,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,UAAU,EAAE,CAAC;YACf,cAAc,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACnE,MAAM,eAAe,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,UAAU,IAAI,MAAM,EAAE,CAAC,EAAE;gBAC3F,GAAG,EAAE,OAAO,CAAC,GAAG;aACjB,CAAC,CAAC,MAAM,CAAC;YACV,OAAO,CAAC,eAAe,CAAC;QAC1B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Logger } from "@release-change/logger";
|
|
2
|
+
import type { Context } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether it is a Git repository or not.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
* @param logger - The logger object to log errors.
|
|
7
|
+
* @return `true` if it is a Git repository, `false` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isGitRepository: (context: Context, logger: Logger) => Promise<boolean>;
|
|
10
|
+
//# sourceMappingURL=is-git-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-git-repository.d.ts","sourceRoot":"","sources":["../src/is-git-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAKtD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,OAAO,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAWvF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { addErrorToContext, checkErrorType } from "@release-change/logger";
|
|
2
|
+
import { runCommand } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether it is a Git repository or not.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
* @param logger - The logger object to log errors.
|
|
7
|
+
* @return `true` if it is a Git repository, `false` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const isGitRepository = async (context, logger) => {
|
|
10
|
+
try {
|
|
11
|
+
const { cwd } = context;
|
|
12
|
+
const gitCommandResult = await runCommand("git", ["rev-parse", "--git-dir"], { cwd });
|
|
13
|
+
return !gitCommandResult.status;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger.setScope("git");
|
|
17
|
+
logger.logError(checkErrorType(error));
|
|
18
|
+
addErrorToContext(error, context);
|
|
19
|
+
process.exit(process.exitCode);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=is-git-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-git-repository.js","sourceRoot":"","sources":["../src/is-git-repository.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,OAAgB,EAAE,MAAc,EAAoB,EAAE;IAC1F,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QACxB,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACtF,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QACvC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;AACH,CAAC,CAAC"}
|
package/dist/push.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
import type { PushOptions } from "./git.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pushes the current branch to the remote repository.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
* @param pushOptions - The `push` options to use (the destination branch, whether to include tags or not) when pushing.
|
|
7
|
+
*/
|
|
8
|
+
export declare const push: (context: Context, pushOptions: PushOptions) => Promise<void>;
|
|
9
|
+
//# sourceMappingURL=push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../src/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOlD;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAU,SAAS,OAAO,EAAE,aAAa,WAAW,KAAG,OAAO,CAAC,IAAI,CAqCnF,CAAC"}
|
package/dist/push.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { setLogger } from "@release-change/logger";
|
|
3
|
+
import { formatDetailedError, runCommand } from "@release-change/shared";
|
|
4
|
+
/**
|
|
5
|
+
* Pushes the current branch to the remote repository.
|
|
6
|
+
* @param context - The context where the CLI is running.
|
|
7
|
+
* @param pushOptions - The `push` options to use (the destination branch, whether to include tags or not) when pushing.
|
|
8
|
+
*/
|
|
9
|
+
export const push = async (context, pushOptions) => {
|
|
10
|
+
const { config } = context;
|
|
11
|
+
const { debug, remoteName } = config;
|
|
12
|
+
const logger = setLogger(debug);
|
|
13
|
+
logger.setScope("git");
|
|
14
|
+
const { destinationBranch, includeTags } = pushOptions;
|
|
15
|
+
if (!destinationBranch) {
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
throw formatDetailedError({
|
|
18
|
+
title: "Failed to run the `git` command",
|
|
19
|
+
message: "A branch name must be provided.",
|
|
20
|
+
details: {
|
|
21
|
+
output: "destinationBranch: "
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const args = ["push", includeTags && "--follow-tags", remoteName, destinationBranch].filter(arg => typeof arg === "string");
|
|
26
|
+
const gitCommandResult = await runCommand("git", args);
|
|
27
|
+
const { status, stdout, stderr } = gitCommandResult;
|
|
28
|
+
if (status) {
|
|
29
|
+
process.exitCode = status;
|
|
30
|
+
throw formatDetailedError({
|
|
31
|
+
title: "Failed to run the `git` command",
|
|
32
|
+
message: `The command failed with status ${status}.`,
|
|
33
|
+
details: {
|
|
34
|
+
output: stderr || stdout || `Command failed with status ${status}.`,
|
|
35
|
+
command: `git ${args.join(" ")}`
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (debug) {
|
|
40
|
+
logger.setDebugScope("git:push");
|
|
41
|
+
logger.logDebug(`Command run: git ${args.join(" ")}`);
|
|
42
|
+
logger.logDebug(inspect(gitCommandResult, { depth: Number.POSITIVE_INFINITY }));
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=push.js.map
|
package/dist/push.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../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K,EAAE,iCAAiC;YACxC,OAAO,EAAE,kCAAkC,MAAM,GAAG;YACpD,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,IAAI,MAAM,IAAI,8BAA8B,MAAM,GAAG;gBACnE,OAAO,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;aACjC;SACF,CAAC,CAAC;IACL,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACjC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAClF,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Removes a Git tag on a remote repository.
|
|
4
|
+
* @param gitTag - The Git tag to remove.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
*/
|
|
7
|
+
export declare const removeTagOnRemoteRepository: (gitTag: string, context: Context) => Promise<void>;
|
|
8
|
+
//# sourceMappingURL=remove-tag-on-remote-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-tag-on-remote-repository.d.ts","sourceRoot":"","sources":["../src/remove-tag-on-remote-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAKtD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,QAAQ,MAAM,EACd,SAAS,OAAO,KACf,OAAO,CAAC,IAAI,CAgCd,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { setLogger } from "@release-change/logger";
|
|
2
|
+
import { formatDetailedError, runCommand } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Removes a Git tag on a remote repository.
|
|
5
|
+
* @param gitTag - The Git tag to remove.
|
|
6
|
+
* @param context - The context where the CLI is running.
|
|
7
|
+
*/
|
|
8
|
+
export const removeTagOnRemoteRepository = async (gitTag, context) => {
|
|
9
|
+
const { config: { debug, remoteName } } = context;
|
|
10
|
+
const logger = setLogger(debug);
|
|
11
|
+
logger.setScope("git");
|
|
12
|
+
if (gitTag) {
|
|
13
|
+
const args = ["push", "--delete", remoteName, gitTag];
|
|
14
|
+
const { status, stdout, stderr } = await runCommand("git", args);
|
|
15
|
+
if (debug) {
|
|
16
|
+
logger.setDebugScope("git:remove-tag-on-remote-repository");
|
|
17
|
+
logger.logDebug(`Command run: git ${args.join(" ")}`);
|
|
18
|
+
}
|
|
19
|
+
if (status) {
|
|
20
|
+
logger.logError(`Failed to remotely remove Git tag ${gitTag} on ${remoteName}.`);
|
|
21
|
+
throw formatDetailedError({
|
|
22
|
+
title: "Failed to run the `git` command",
|
|
23
|
+
message: `The command failed with status ${status}.`,
|
|
24
|
+
details: {
|
|
25
|
+
output: stderr || stdout || `Command failed with status ${status}.`,
|
|
26
|
+
command: `git ${args.join(" ")}`
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
logger.logInfo(`Removed remote Git tag ${gitTag} successfully.`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw formatDetailedError({
|
|
34
|
+
title: "Failed to remove a Git tag on remote repository",
|
|
35
|
+
message: "The Git tag must not be empty.",
|
|
36
|
+
details: { output: "gitTag: " }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=remove-tag-on-remote-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-tag-on-remote-repository.js","sourceRoot":"","sources":["../src/remove-tag-on-remote-repository.ts"],"names":[],"mappings":"AAE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AAgB,CAAC,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,MAAM,mBAAmB,CAAC;YACxB,KAAK,EAAE,iDAAiD;YACxD,OAAO,EAAE,gCAAgC;YACzC,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes a Git tag.
|
|
3
|
+
* @param gitTag - The Git tag to remove.
|
|
4
|
+
* @param cwd - The current working directory.
|
|
5
|
+
* @param [debug] - Whether the CLI is running in debug mode or not.
|
|
6
|
+
*/
|
|
7
|
+
export declare const removeTag: (gitTag: string, cwd: string, debug?: boolean) => void;
|
|
8
|
+
//# sourceMappingURL=remove-tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-tag.d.ts","sourceRoot":"","sources":["../src/remove-tag.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,KAAK,MAAM,EAAE,eAAa,KAAG,IA6BtE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { setLogger } from "@release-change/logger";
|
|
2
|
+
import { formatDetailedError, runCommandSync } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Removes a Git tag.
|
|
5
|
+
* @param gitTag - The Git tag to remove.
|
|
6
|
+
* @param cwd - The current working directory.
|
|
7
|
+
* @param [debug] - Whether the CLI is running in debug mode or not.
|
|
8
|
+
*/
|
|
9
|
+
export const removeTag = (gitTag, cwd, debug = false) => {
|
|
10
|
+
const logger = setLogger(debug);
|
|
11
|
+
logger.setScope("git");
|
|
12
|
+
if (gitTag) {
|
|
13
|
+
const args = ["tag", "-d", gitTag];
|
|
14
|
+
const { status, stdout, stderr } = runCommandSync("git", args, { cwd });
|
|
15
|
+
if (debug) {
|
|
16
|
+
logger.setDebugScope("git:remove-tag");
|
|
17
|
+
logger.logDebug(`Command run: git ${args.join(" ")}`);
|
|
18
|
+
}
|
|
19
|
+
if (status) {
|
|
20
|
+
logger.logError(`Failed to remove Git tag ${gitTag}.`);
|
|
21
|
+
throw formatDetailedError({
|
|
22
|
+
title: "Failed to run the `git` command",
|
|
23
|
+
message: `The command failed with status ${status}.`,
|
|
24
|
+
details: {
|
|
25
|
+
output: stderr || stdout || `Command failed with status ${status}.`,
|
|
26
|
+
command: `git ${args.join(" ")}`
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
logger.logInfo(`Removed Git tag ${gitTag}.`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw formatDetailedError({
|
|
34
|
+
title: "Failed to remove a Git tag",
|
|
35
|
+
message: "The Git tag must not be empty.",
|
|
36
|
+
details: { output: "gitTag: " }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=remove-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-tag.js","sourceRoot":"","sources":["../src/remove-tag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,KAAK,GAAG,KAAK,EAAQ,EAAE;IAC5E,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACxE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;YACvC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,CAAC,4BAA4B,MAAM,GAAG,CAAC,CAAC;YACvD,MAAM,mBAAmB,CAAC;gBACxB,KAAK,EAAE,iCAAiC;gBACxC,OAAO,EAAE,kCAAkC,MAAM,GAAG;gBACpD,OAAO,EAAE;oBACP,MAAM,EAAE,MAAM,IAAI,MAAM,IAAI,8BAA8B,MAAM,GAAG;oBACnE,OAAO,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;iBACjC;aACF,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,mBAAmB,MAAM,GAAG,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,MAAM,mBAAmB,CAAC;YACxB,KAAK,EAAE,4BAA4B;YACnC,OAAO,EAAE,gCAAgC;YACzC,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NextRelease } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Sets the branch name for the head branch, using a prefix, the target branch and the next release data (version and/or package name).
|
|
4
|
+
*
|
|
5
|
+
* Due to lock file name restrictions, the branch name is limited to 244 characters (255 allowed for refs, minus the length of `refs/heads/` string).
|
|
6
|
+
* @param branch - The target branch.
|
|
7
|
+
* @param nextRelease - The next release data to use.
|
|
8
|
+
* @return The head branch name.
|
|
9
|
+
*/
|
|
10
|
+
export declare const setBranchName: (branch: string | undefined, nextRelease: NextRelease) => string;
|
|
11
|
+
//# sourceMappingURL=set-branch-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-branch-name.d.ts","sourceRoot":"","sources":["../src/set-branch-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,GAAG,SAAS,EAAE,aAAa,WAAW,KAAG,MA+BpF,CAAC"}
|