@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Victor Brito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @release-change/git
|
|
2
|
+
|
|
3
|
+
Functions used internally in release-change to make Git operations easier
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
[](https://nodejs.org/api/esm.html)
|
|
7
|
+
[](https://conventionalcommits.org)
|
|
8
|
+
[](https://biomejs.dev/)
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Copyright & licence
|
|
14
|
+
|
|
15
|
+
© 2025-present Victor Brito — Released under the [MIT licence](./LICENSE).
|
package/dist/add.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandResult } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Adds files to the staging area.
|
|
4
|
+
* @param files - The files to add.
|
|
5
|
+
* @param cwd - The current working directory.
|
|
6
|
+
* @return The result of the `git add` command.
|
|
7
|
+
*/
|
|
8
|
+
export declare const add: (files: string[], cwd: string) => Promise<CommandResult>;
|
|
9
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5D;;;;;GAKG;AACH,eAAO,MAAM,GAAG,GAAU,OAAO,MAAM,EAAE,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,aAAa,CAY7E,CAAC"}
|
package/dist/add.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { formatDetailedError, runCommand } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Adds files to the staging area.
|
|
4
|
+
* @param files - The files to add.
|
|
5
|
+
* @param cwd - The current working directory.
|
|
6
|
+
* @return The result of the `git add` command.
|
|
7
|
+
*/
|
|
8
|
+
export const add = async (files, cwd) => {
|
|
9
|
+
if (!files.length) {
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
throw formatDetailedError({
|
|
12
|
+
title: "Failed to run the `git` command",
|
|
13
|
+
message: "No files to add.",
|
|
14
|
+
details: {
|
|
15
|
+
output: "files.length: 0"
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return await runCommand("git", ["add", ...files], { cwd });
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=add.js.map
|
package/dist/add.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,EAAE,KAAe,EAAE,GAAW,EAA0B,EAAE;IAChF,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,MAAM,mBAAmB,CAAC;YACxB,KAAK,EAAE,iCAAiC;YACxC,OAAO,EAAE,kBAAkB;YAC3B,OAAO,EAAE;gBACP,MAAM,EAAE,iBAAiB;aAC1B;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cancels the commits since the commit reference.
|
|
3
|
+
* @param commitRef - The reference of the commit after which all the commits are to be cancelled.
|
|
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 cancelCommitsSinceRef: (commitRef: string, cwd: string, debug?: boolean) => void;
|
|
8
|
+
//# sourceMappingURL=cancel-commits-since-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-commits-since-ref.d.ts","sourceRoot":"","sources":["../src/cancel-commits-since-ref.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,EAAE,KAAK,MAAM,EAAE,eAAa,KAAG,IA6BrF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { setLogger } from "@release-change/logger";
|
|
2
|
+
import { formatDetailedError, runCommandSync } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Cancels the commits since the commit reference.
|
|
5
|
+
* @param commitRef - The reference of the commit after which all the commits are to be cancelled.
|
|
6
|
+
* @param cwd - The current working directory.
|
|
7
|
+
* @param [debug] - Whether the CLI is running in debug mode or not.
|
|
8
|
+
*/
|
|
9
|
+
export const cancelCommitsSinceRef = (commitRef, cwd, debug = false) => {
|
|
10
|
+
const logger = setLogger(debug);
|
|
11
|
+
logger.setScope("git");
|
|
12
|
+
if (commitRef) {
|
|
13
|
+
const args = ["reset", "--hard", commitRef];
|
|
14
|
+
const { status, stdout, stderr } = runCommandSync("git", args, { cwd });
|
|
15
|
+
if (debug) {
|
|
16
|
+
logger.setDebugScope("git:cancel-commits-since-ref");
|
|
17
|
+
logger.logDebug(`Command run: git ${args.join(" ")}`);
|
|
18
|
+
}
|
|
19
|
+
if (status) {
|
|
20
|
+
logger.logError(`Failed to cancel the commits since ${commitRef}.`);
|
|
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(`Commits since ${commitRef} cancelled.`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw formatDetailedError({
|
|
34
|
+
title: "Failed to cancel commits",
|
|
35
|
+
message: "The commit reference must not be empty.",
|
|
36
|
+
details: { output: "commitRef: " }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=cancel-commits-since-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-commits-since-ref.js","sourceRoot":"","sources":["../src/cancel-commits-since-ref.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,qBAAqB,GAAG,CAAC,SAAiB,EAAE,GAAW,EAAE,KAAK,GAAG,KAAK,EAAQ,EAAE;IAC3F,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC5C,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,8BAA8B,CAAC,CAAC;YACrD,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,sCAAsC,SAAS,GAAG,CAAC,CAAC;YACpE,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,iBAAiB,SAAS,aAAa,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,MAAM,mBAAmB,CAAC;YACxB,KAAK,EAAE,0BAA0B;YACjC,OAAO,EAAE,yCAAyC;YAClD,OAAO,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Checks the authorisation to push commits to the remote repository.
|
|
4
|
+
* @param repositoryUrl - The repository URL.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
*/
|
|
7
|
+
export declare const checkAuthorisation: (repositoryUrl: string, context: Context) => Promise<void>;
|
|
8
|
+
//# sourceMappingURL=check-authorisation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-authorisation.d.ts","sourceRoot":"","sources":["../src/check-authorisation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAOtD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,MAAM,EACrB,SAAS,OAAO,KACf,OAAO,CAAC,IAAI,CA0Bd,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { setLogger } from "@release-change/logger";
|
|
3
|
+
import { formatDetailedError, runCommand } from "@release-change/shared";
|
|
4
|
+
/**
|
|
5
|
+
* Checks the authorisation to push commits to the remote repository.
|
|
6
|
+
* @param repositoryUrl - The repository URL.
|
|
7
|
+
* @param context - The context where the CLI is running.
|
|
8
|
+
*/
|
|
9
|
+
export const checkAuthorisation = async (repositoryUrl, context) => {
|
|
10
|
+
const { cwd, branch, config } = context;
|
|
11
|
+
const logger = setLogger(config.debug);
|
|
12
|
+
logger.setScope("git");
|
|
13
|
+
if (!branch || !config.branches.includes(branch)) {
|
|
14
|
+
logger.logInfo("Skipping authorisation checking.");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const args = ["push", "--dry-run", "--no-verify", repositoryUrl, branch];
|
|
18
|
+
const gitCommandResult = await runCommand("git", args, { cwd });
|
|
19
|
+
if (config.debug) {
|
|
20
|
+
logger.setDebugScope("git:check-authorisation");
|
|
21
|
+
logger.logDebug(inspect(gitCommandResult, { depth: Number.POSITIVE_INFINITY }));
|
|
22
|
+
}
|
|
23
|
+
const { status, stdout, stderr } = gitCommandResult;
|
|
24
|
+
if (status) {
|
|
25
|
+
process.exitCode = status;
|
|
26
|
+
throw formatDetailedError({
|
|
27
|
+
title: "Failed to run the `git` command",
|
|
28
|
+
message: `The command failed with status ${status}.`,
|
|
29
|
+
details: {
|
|
30
|
+
output: stderr || stdout || `Command failed with status ${status}.`,
|
|
31
|
+
command: `git ${args.join(" ")}`
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=check-authorisation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-authorisation.js","sourceRoot":"","sources":["../src/check-authorisation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;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AC,GAAG,CAAC,EAAE;aACjC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the current branch is part of the branches from which the package can publish.
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @return `undefined` if the package can publish from the branch, `false` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const checkBranch: (context: Context) => undefined | false;
|
|
8
|
+
//# sourceMappingURL=check-branch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-branch.d.ts","sourceRoot":"","sources":["../src/check-branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAOtD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO,KAAG,SAAS,GAAG,KA2B1D,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import util from "node:util";
|
|
2
|
+
import { setLogger } from "@release-change/logger";
|
|
3
|
+
import { WORKSPACE_NAME } from "@release-change/shared";
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether the current branch is part of the branches from which the package can publish.
|
|
6
|
+
* @param context - The context where the CLI is running.
|
|
7
|
+
* @return `undefined` if the package can publish from the branch, `false` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const checkBranch = (context) => {
|
|
10
|
+
if (process.exitCode)
|
|
11
|
+
return false;
|
|
12
|
+
const { branch, config } = context;
|
|
13
|
+
const logger = setLogger(config.debug);
|
|
14
|
+
logger.setScope("git");
|
|
15
|
+
const { branches } = config;
|
|
16
|
+
context.branch = branch;
|
|
17
|
+
if (config.debug) {
|
|
18
|
+
logger.setDebugScope("git:check-branch");
|
|
19
|
+
logger.logDebug(`Branches from where to publish: ${util.inspect(branches)}`);
|
|
20
|
+
logger.logDebug(`Branch name: ${branch}`);
|
|
21
|
+
}
|
|
22
|
+
if (!branch || !branches.includes(branch)) {
|
|
23
|
+
const runTriggeredOnWrongBranchText = `This run is triggered on the branch ${branch}, while ${WORKSPACE_NAME} is configured to only publish from ${new Intl.ListFormat("en-GB", {
|
|
24
|
+
style: "long",
|
|
25
|
+
type: "conjunction"
|
|
26
|
+
}).format(branches)}; therefore, a new version will not be published.`;
|
|
27
|
+
logger.logWarn(runTriggeredOnWrongBranchText);
|
|
28
|
+
context.config.dryRun = true;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const runAutomatedReleaseText = `Run automated release from branch ${branch} on repository ${config.repositoryUrl}`;
|
|
32
|
+
if (config.dryRun)
|
|
33
|
+
logger.logWarn(`${runAutomatedReleaseText} in dry-run mode.`);
|
|
34
|
+
else
|
|
35
|
+
logger.logSuccess(`${runAutomatedReleaseText}.`);
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=check-branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-branch.js","sourceRoot":"","sources":["../src/check-branch.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAqB,EAAE;IACjE,IAAI,OAAO,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IACnC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC7E,MAAM,CAAC,QAAQ,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,MAAM,6BAA6B,GAAG,uCAAuC,MAAM,WAAW,cAAc,uCAAuC,IAAI,IAAI,CAAC,UAAU,CACpK,OAAO,EACP;YACE,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,aAAa;SACpB,CACF,CAAC,MAAM,CAAC,QAAQ,CAAC,mDAAmD,CAAC;QACtE,MAAM,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,uBAAuB,GAAG,qCAAqC,MAAM,kBAAkB,MAAM,CAAC,aAAa,EAAE,CAAC;IACpH,IAAI,MAAM,CAAC,MAAM;QAAE,MAAM,CAAC,OAAO,CAAC,GAAG,uBAAuB,mBAAmB,CAAC,CAAC;;QAC5E,MAAM,CAAC,UAAU,CAAC,GAAG,uBAAuB,GAAG,CAAC,CAAC;AACxD,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Checks the permissions to push to the remote repository.
|
|
4
|
+
* @param repositoryUrl - The repository URL.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
*/
|
|
7
|
+
export declare const checkPushPermissions: (repositoryUrl: string, context: Context) => Promise<void>;
|
|
8
|
+
//# sourceMappingURL=check-push-permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-push-permissions.d.ts","sourceRoot":"","sources":["../src/check-push-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAOtD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,eAAe,MAAM,EACrB,SAAS,OAAO,KACf,OAAO,CAAC,IAAI,CAmBd,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { addErrorToContext, checkErrorType, setLogger } from "@release-change/logger";
|
|
2
|
+
import { checkAuthorisation } from "./check-authorisation.js";
|
|
3
|
+
import { isBranchUpToDate } from "./is-branch-up-to-date.js";
|
|
4
|
+
/**
|
|
5
|
+
* Checks the permissions to push to the remote repository.
|
|
6
|
+
* @param repositoryUrl - The repository URL.
|
|
7
|
+
* @param context - The context where the CLI is running.
|
|
8
|
+
*/
|
|
9
|
+
export const checkPushPermissions = async (repositoryUrl, context) => {
|
|
10
|
+
const { branch, config } = context;
|
|
11
|
+
const logger = setLogger(config.debug);
|
|
12
|
+
logger.setScope("git");
|
|
13
|
+
try {
|
|
14
|
+
await checkAuthorisation(repositoryUrl, context);
|
|
15
|
+
if (branch && config.branches.includes(branch)) {
|
|
16
|
+
if (!(await isBranchUpToDate(branch, context))) {
|
|
17
|
+
logger.logWarn(`The local branch ${branch} is behind the remote one; therefore, a new version will not be published.`);
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
logger.logSuccess("Allowed to push to the Git repository.");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
logger.logError("Not allowed to push to the Git repository.");
|
|
25
|
+
logger.logError(checkErrorType(error));
|
|
26
|
+
addErrorToContext(error, context);
|
|
27
|
+
process.exit(process.exitCode ?? 1);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=check-push-permissions.js.map
|
|
@@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C;IACtC,CAAC;AACH,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 the repository.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
* @param logger - The logger object to log errors.
|
|
7
|
+
* @return The current exit code if it is a Git repository, the exit code set to `1` with immediate effect otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare const checkRepository: (context: Context, logger: Logger) => Promise<string | number | undefined>;
|
|
10
|
+
//# sourceMappingURL=check-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-repository.d.ts","sourceRoot":"","sources":["../src/check-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,GAC1B,SAAS,OAAO,EAChB,QAAQ,MAAM,KACb,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAiBrC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { addErrorToContext, checkErrorType } from "@release-change/logger";
|
|
2
|
+
import { runCommand } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Checks the repository.
|
|
5
|
+
* @param context - The context where the CLI is running.
|
|
6
|
+
* @param logger - The logger object to log errors.
|
|
7
|
+
* @return The current exit code if it is a Git repository, the exit code set to `1` with immediate effect otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const checkRepository = async (context, logger) => {
|
|
10
|
+
try {
|
|
11
|
+
const gitCommandResult = await runCommand("git", ["rev-parse", "--git-dir"], {
|
|
12
|
+
cwd: context.cwd
|
|
13
|
+
});
|
|
14
|
+
const { status } = gitCommandResult;
|
|
15
|
+
if (status) {
|
|
16
|
+
logger.logError("The current directory is not a Git repository.");
|
|
17
|
+
process.exit(process.exitCode);
|
|
18
|
+
}
|
|
19
|
+
return process.exitCode ?? 0;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
logger.setScope("git");
|
|
23
|
+
logger.logError(checkErrorType(error));
|
|
24
|
+
addErrorToContext(error, context);
|
|
25
|
+
process.exit(process.exitCode);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=check-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-repository.js","sourceRoot":"","sources":["../src/check-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,EAClC,OAAgB,EAChB,MAAc,EACwB,EAAE;IACxC,IAAI,CAAC;QACH,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE;YAC3E,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,CAAC,gDAAgD,CAAC,CAAC;YAClE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IAC/B,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/commit.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandResult } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Commits the changes.
|
|
4
|
+
* @param message - The commit message.
|
|
5
|
+
* @param cwd - The current working directory.
|
|
6
|
+
* @return The result of the `git commit` command.
|
|
7
|
+
*/
|
|
8
|
+
export declare const commit: (message: string, cwd: string) => Promise<CommandResult>;
|
|
9
|
+
//# sourceMappingURL=commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5D;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAU,SAAS,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,aAAa,CAYhF,CAAC"}
|
package/dist/commit.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { formatDetailedError, runCommand } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Commits the changes.
|
|
4
|
+
* @param message - The commit message.
|
|
5
|
+
* @param cwd - The current working directory.
|
|
6
|
+
* @return The result of the `git commit` command.
|
|
7
|
+
*/
|
|
8
|
+
export const commit = async (message, cwd) => {
|
|
9
|
+
if (!message) {
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
throw formatDetailedError({
|
|
12
|
+
title: "Failed to run the `git` command",
|
|
13
|
+
message: "The commit message cannot be empty.",
|
|
14
|
+
details: {
|
|
15
|
+
output: "message: "
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return await runCommand("git", ["commit", "-m", message], { cwd });
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,OAAe,EAAE,GAAW,EAA0B,EAAE;IACnF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,MAAM,mBAAmB,CAAC;YACxB,KAAK,EAAE,iCAAiC;YACxC,OAAO,EAAE,qCAAqC;YAC9C,OAAO,EAAE;gBACP,MAAM,EAAE,WAAW;aACpB;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const COMMIT_SEPARATOR: RegExp;
|
|
2
|
+
export declare const COMMITTER_NAME = "github-actions[bot]";
|
|
3
|
+
export declare const COMMITTER_EMAIL = "41898282+github-actions[bot]@users.noreply.github.com";
|
|
4
|
+
export declare const HEAD_BRANCH_MAX_CHARACTERS = 244;
|
|
5
|
+
export declare const HEAD_BRANCH_PREFIX = "release-change";
|
|
6
|
+
export declare const GIT_TAG_PATTERN: RegExp;
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,QAAoB,CAAC;AAClD,eAAO,MAAM,cAAc,wBAAwB,CAAC;AACpD,eAAO,MAAM,eAAe,0DAA0D,CAAC;AACvF,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,eAAe,QAAiB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const COMMIT_SEPARATOR = /\n{2}(?=commit)/;
|
|
2
|
+
export const COMMITTER_NAME = "github-actions[bot]";
|
|
3
|
+
export const COMMITTER_EMAIL = "41898282+github-actions[bot]@users.noreply.github.com";
|
|
4
|
+
export const HEAD_BRANCH_MAX_CHARACTERS = 244;
|
|
5
|
+
export const HEAD_BRANCH_PREFIX = "release-change";
|
|
6
|
+
export const GIT_TAG_PATTERN = /^(@[^@]+@)?v/;
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAClD,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,uDAAuD,CAAC;AACvF,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PackageNextRelease } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Git tag.
|
|
4
|
+
* @param packageNextRelease - The next release data to use.
|
|
5
|
+
* @param commitRef - The commit reference to which the Git tag will be attached.
|
|
6
|
+
* @param [debug] - Whether the CLI is running in debug mode or not.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createTag: (packageNextRelease: PackageNextRelease, commitRef: string, debug?: boolean) => void;
|
|
9
|
+
//# sourceMappingURL=create-tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tag.d.ts","sourceRoot":"","sources":["../src/create-tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAKjE;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,oBAAoB,kBAAkB,EACtC,WAAW,MAAM,EACjB,eAAa,KACZ,IAwBF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { setLogger } from "@release-change/logger";
|
|
2
|
+
import { formatDetailedError, runCommandSync } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Git tag.
|
|
5
|
+
* @param packageNextRelease - The next release data to use.
|
|
6
|
+
* @param commitRef - The commit reference to which the Git tag will be attached.
|
|
7
|
+
* @param [debug] - Whether the CLI is running in debug mode or not.
|
|
8
|
+
*/
|
|
9
|
+
export const createTag = (packageNextRelease, commitRef, debug = false) => {
|
|
10
|
+
const logger = setLogger(debug);
|
|
11
|
+
logger.setScope("git");
|
|
12
|
+
if (commitRef) {
|
|
13
|
+
const { name, gitTag } = packageNextRelease;
|
|
14
|
+
const packageName = `${name ? name : "root"} package`;
|
|
15
|
+
const args = ["tag", gitTag, "-m", gitTag, commitRef];
|
|
16
|
+
const { status, stderr } = runCommandSync("git", args);
|
|
17
|
+
if (debug) {
|
|
18
|
+
logger.setDebugScope("git:create-tag");
|
|
19
|
+
logger.logDebug(`Command run: git ${args.join(" ").replace(/-m ([-.a-z0-9@/]+)/, "-m '$1'")}`);
|
|
20
|
+
}
|
|
21
|
+
if (status)
|
|
22
|
+
logger.logError(`Failed to create Git tag ${gitTag} for ${packageName}: ${stderr}`);
|
|
23
|
+
else
|
|
24
|
+
logger.logSuccess(`Created Git tag ${gitTag} for ${packageName}.`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
throw formatDetailedError({
|
|
29
|
+
title: "Failed to create a Git tag",
|
|
30
|
+
message: "The commit reference must not be empty.",
|
|
31
|
+
details: { output: "commitRef: " }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=create-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tag.js","sourceRoot":"","sources":["../src/create-tag.ts"],"names":[],"mappings":"AAEA,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,CACvB,kBAAsC,EACtC,SAAiB,EACjB,KAAK,GAAG,KAAK,EACP,EAAE;IACR,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,MAAM,WAAW,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC;QACtD,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACtD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;YACvC,MAAM,CAAC,QAAQ,CACb,oBAAoB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAAE,CAC9E,CAAC;QACJ,CAAC;QACD,IAAI,MAAM;YAAE,MAAM,CAAC,QAAQ,CAAC,4BAA4B,MAAM,QAAQ,WAAW,KAAK,MAAM,EAAE,CAAC,CAAC;;YAC3F,MAAM,CAAC,UAAU,CAAC,mBAAmB,MAAM,QAAQ,WAAW,GAAG,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,MAAM,mBAAmB,CAAC;YACxB,KAAK,EAAE,4BAA4B;YACnC,OAAO,EAAE,yCAAyC;YAClD,OAAO,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Gets all tags for the branch from which the package publishes as they are on the remote repository.
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @return An array containing the tags if tags are found, an empty array otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getAllTags: (context: Context) => string[];
|
|
8
|
+
//# sourceMappingURL=get-all-tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-all-tags.d.ts","sourceRoot":"","sources":["../src/get-all-tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAOtD;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,KAAG,MAAM,EAqBnD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { addErrorToContext, checkErrorType, setLogger } from "@release-change/logger";
|
|
3
|
+
import { runCommandSync } from "@release-change/shared";
|
|
4
|
+
/**
|
|
5
|
+
* Gets all tags for the branch from which the package publishes as they are on the remote repository.
|
|
6
|
+
* @param context - The context where the CLI is running.
|
|
7
|
+
* @return An array containing the tags if tags are found, an empty array otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const getAllTags = (context) => {
|
|
10
|
+
const { cwd, branch, config } = context;
|
|
11
|
+
const logger = setLogger(config.debug);
|
|
12
|
+
logger.setScope("git");
|
|
13
|
+
try {
|
|
14
|
+
const gitCommandResult = runCommandSync("git", ["tag", "-l", "--sort=-creatordate", "--merged", `${config.remoteName}/${branch}`], { cwd });
|
|
15
|
+
if (config.debug) {
|
|
16
|
+
logger.setDebugScope("git:get-all-tags");
|
|
17
|
+
logger.logDebug(inspect(gitCommandResult, { depth: Number.POSITIVE_INFINITY }));
|
|
18
|
+
}
|
|
19
|
+
const { stdout } = gitCommandResult;
|
|
20
|
+
return stdout ? stdout.split("\n") : [];
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logger.logError(checkErrorType(error));
|
|
24
|
+
addErrorToContext(error, context);
|
|
25
|
+
process.exit(process.exitCode);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=get-all-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-all-tags.js","sourceRoot":"","sources":["../src/get-all-tags.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAY,EAAE;IACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,gBAAgB,GAAG,cAAc,CACrC,KAAK,EACL,CAAC,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE,CAAC,EAClF,EAAE,GAAG,EAAE,CACR,CAAC;QACF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;YACzC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;QACpC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContextBase } from "@release-change/shared";
|
|
2
|
+
import { type Logger } from "@release-change/logger";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the current branch name, getting the `HEAD` ref or the remote branch (in case of detached `HEAD`).
|
|
5
|
+
* @param contextBase - The basic context where the CLI is running.
|
|
6
|
+
* @param logger - The logger object to log errors.
|
|
7
|
+
* @return The branch name if found, `undefined` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getBranchName: (contextBase: ContextBase, logger: Logger) => string | undefined;
|
|
10
|
+
//# sourceMappingURL=get-branch-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-branch-name.d.ts","sourceRoot":"","sources":["../src/get-branch-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAqC,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGxF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,aAAa,WAAW,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,SAsBjF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { addErrorToContext, checkErrorType } from "@release-change/logger";
|
|
2
|
+
import { runCommandSync } from "@release-change/shared";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the current branch name, getting the `HEAD` ref or the remote branch (in case of detached `HEAD`).
|
|
5
|
+
* @param contextBase - The basic context where the CLI is running.
|
|
6
|
+
* @param logger - The logger object to log errors.
|
|
7
|
+
* @return The branch name if found, `undefined` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const getBranchName = (contextBase, logger) => {
|
|
10
|
+
try {
|
|
11
|
+
const { cwd } = contextBase;
|
|
12
|
+
const headRef = runCommandSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
13
|
+
cwd
|
|
14
|
+
}).stdout.trim();
|
|
15
|
+
if (headRef === "HEAD") {
|
|
16
|
+
const remoteAlias = "origin/";
|
|
17
|
+
const branch = runCommandSync("git", ["show", "-s", "--pretty=%d", "HEAD"], { cwd })
|
|
18
|
+
.stdout.trim()
|
|
19
|
+
.replace(/^\(|\)$/g, "")
|
|
20
|
+
.split(", ")
|
|
21
|
+
.find(branch => branch.startsWith(remoteAlias));
|
|
22
|
+
return branch ? branch.replace(remoteAlias, "") : undefined;
|
|
23
|
+
}
|
|
24
|
+
return headRef;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
logger.setScope("git");
|
|
28
|
+
logger.logError(checkErrorType(error));
|
|
29
|
+
addErrorToContext(error, contextBase);
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=get-branch-name.js.map
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CAAC,CAAC,CAAC;QACvC,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Commit, Context } from "@release-change/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the commits since the reference (Git tag or the whole history).
|
|
4
|
+
* @param context - The context where the CLI is running.
|
|
5
|
+
* @return An array containing the commits found and parsed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getCommitsSinceRef: (context: Context) => Commit[];
|
|
8
|
+
//# sourceMappingURL=get-commits-since-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-commits-since-ref.d.ts","sourceRoot":"","sources":["../src/get-commits-since-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAU9D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,KAAG,MAAM,EAmC3D,CAAC"}
|