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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Fork Version
|
|
2
2
|
|
|
3
|
+
## [5.0.1](https://github.com/eglavin/fork-version/compare/v5.0.0...v5.0.1) (2026-04-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Refactor
|
|
7
|
+
|
|
8
|
+
* remove logger from file manager classes ([7800d8b](https://github.com/eglavin/fork-version/commit/7800d8b29fd959f82216ee7061ce5fb44a883368))
|
|
9
|
+
* show file name in the missing property exception log ([f7c80fc](https://github.com/eglavin/fork-version/commit/f7c80fcaeadaba897f637619931562f82cc9a707))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## [5.0.0](https://github.com/eglavin/fork-version/compare/v4.1.10...v5.0.0) (2026-04-09)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Refactor
|
|
16
|
+
|
|
17
|
+
* migrate scripts to use built in node typescript support ([50c2b0e](https://github.com/eglavin/fork-version/commit/50c2b0e7c6205c5587dd01c0e939b1c113f5f01e))
|
|
18
|
+
* move config definition away from zod schema ([3c8efd3](https://github.com/eglavin/fork-version/commit/3c8efd3584da304f463de19f18014797bd53ab52))
|
|
19
|
+
* pnpm prune ([ad722b5](https://github.com/eglavin/fork-version/commit/ad722b52afa3cb1a1efead53d9e0643a3751eaae))
|
|
20
|
+
* replace tsup with tsdown ([ce4f740](https://github.com/eglavin/fork-version/commit/ce4f740d5edcbbb100f079f004f005f0f16ac860))
|
|
21
|
+
|
|
22
|
+
|
|
3
23
|
## [4.1.10](https://github.com/eglavin/fork-version/compare/v4.1.9...v4.1.10) (2026-04-06)
|
|
4
24
|
|
|
5
25
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dist/cli.js
CHANGED
|
@@ -1,198 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
inspect-version Print the current version then exits.
|
|
15
|
-
inspect-tag Print the current git tag then exits.
|
|
16
|
-
validate-config Validates the configuration and exits.
|
|
17
|
-
|
|
18
|
-
General Options:
|
|
19
|
-
--version Show the current version of Fork-Version and exit.
|
|
20
|
-
--help Show this help message and exit.
|
|
21
|
-
|
|
22
|
-
Location Options:
|
|
23
|
-
--file, -F List of the files to be updated. [Default: ["bower.json", "deno.json", "deno.jsonc", "jsr.json", "jsr.jsonc", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]]
|
|
24
|
-
--glob, -G Glob pattern to match files to be updated.
|
|
25
|
-
--path, -P The path Fork-Version will run from. [Default: process.cwd()]
|
|
26
|
-
|
|
27
|
-
Options:
|
|
28
|
-
--changelog Name of the changelog file. [Default: "CHANGELOG.md"]
|
|
29
|
-
--header The header text for the changelog.
|
|
30
|
-
--tag-prefix Specify a prefix for the created tag. [Default: "v"]
|
|
31
|
-
--pre-release Mark this release as a pre-release.
|
|
32
|
-
--pre-release-tag Mark this release with a tagged pre-release. [Example: "alpha", "beta", "rc"]
|
|
33
|
-
--current-version If set, Fork-Version will use this version instead of trying to determine one.
|
|
34
|
-
--next-version If set, Fork-Version will attempt to update to this version, instead of incrementing using "conventional-commit".
|
|
35
|
-
--release-as Release as increments the version by the specified level. [Choices: "major", "minor", "patch"]
|
|
36
|
-
|
|
37
|
-
Flags:
|
|
38
|
-
--allow-multiple-versions Don't throw an error if multiple versions are found in the given files. [Default: true]
|
|
39
|
-
--commit-all Commit all changes, not just files updated by Fork-Version.
|
|
40
|
-
--changelog-all If this flag is set, all default commit types will be added to the changelog.
|
|
41
|
-
--debug Output debug information.
|
|
42
|
-
--dry-run No output will be written to disk or committed.
|
|
43
|
-
--silent Run without logging to the terminal.
|
|
44
|
-
--git-tag-fallback If unable to find a version in the given files, fallback and attempt to use the latest git tag. [Default: true]
|
|
45
|
-
--sign If true, git will sign the commit with the systems GPG key.
|
|
46
|
-
--verify If true, git will run user defined git hooks before committing.
|
|
47
|
-
--as-json Output the result as JSON.
|
|
48
|
-
|
|
49
|
-
To negate a flag you can prefix it with "no-", for example "--no-git-tag-fallback" will not fallback to the latest git tag.
|
|
50
|
-
|
|
51
|
-
Skip Steps:
|
|
52
|
-
--skip-bump Skip the version bump step.
|
|
53
|
-
--skip-changelog Skip updating the changelog.
|
|
54
|
-
--skip-commit Skip committing the changes.
|
|
55
|
-
--skip-tag Skip tagging the commit.
|
|
56
|
-
|
|
57
|
-
Conventional Changelog Overrides:
|
|
58
|
-
--commit-url-format Override the default commit URL format.
|
|
59
|
-
--compare-url-format Override the default compare URL format.
|
|
60
|
-
--issue-url-format Override the default issue URL format.
|
|
61
|
-
--user-url-format Override the default user URL format.
|
|
62
|
-
--release-commit-message-format Override the default release commit message format.
|
|
63
|
-
--release-message-suffix Add a suffix to the end of the release message.
|
|
64
|
-
|
|
65
|
-
Exit Codes:
|
|
66
|
-
0: Success
|
|
67
|
-
1: General Error
|
|
68
|
-
2: Unknown Command
|
|
69
|
-
3: Config File Validation Error
|
|
70
|
-
|
|
71
|
-
Examples:
|
|
72
|
-
$ fork-version
|
|
73
|
-
Run fork-version in the current directory with default options.
|
|
74
|
-
|
|
75
|
-
$ fork-version --path ./packages/my-package
|
|
76
|
-
Run fork-version in the "./packages/my-package" directory.
|
|
77
|
-
|
|
78
|
-
$ fork-version --file package.json --file MyApi.csproj
|
|
79
|
-
Run fork-version and update the "package.json" and "MyApi.csproj" files.
|
|
80
|
-
|
|
81
|
-
$ fork-version --glob "*/package.json"
|
|
82
|
-
Run fork-version and update all "package.json" files in subdirectories.
|
|
83
|
-
|
|
84
|
-
$ fork-version inspect-version
|
|
85
|
-
Prints the current version and exits.`;
|
|
86
|
-
function getCliArguments() {
|
|
87
|
-
return meow(helperText, {
|
|
88
|
-
importMeta: import.meta,
|
|
89
|
-
booleanDefault: void 0,
|
|
90
|
-
helpIndent: 0,
|
|
91
|
-
flags: {
|
|
92
|
-
// Commands
|
|
93
|
-
/** @deprecated Set the `inspect-version` command instead. */
|
|
94
|
-
inspectVersion: { type: "boolean" },
|
|
95
|
-
// Options
|
|
96
|
-
files: { type: "string", isMultiple: true, aliases: ["file"], shortFlag: "F" },
|
|
97
|
-
glob: { type: "string", shortFlag: "G" },
|
|
98
|
-
path: { type: "string", shortFlag: "P" },
|
|
99
|
-
changelog: { type: "string" },
|
|
100
|
-
header: { type: "string" },
|
|
101
|
-
tagPrefix: { type: "string" },
|
|
102
|
-
preRelease: { type: "boolean" },
|
|
103
|
-
preReleaseTag: { type: "string" },
|
|
104
|
-
currentVersion: { type: "string" },
|
|
105
|
-
nextVersion: { type: "string" },
|
|
106
|
-
releaseAs: { type: "string", choices: ["major", "minor", "patch"] },
|
|
107
|
-
// Flags
|
|
108
|
-
allowMultipleVersions: { type: "boolean" },
|
|
109
|
-
commitAll: { type: "boolean" },
|
|
110
|
-
changelogAll: { type: "boolean" },
|
|
111
|
-
debug: { type: "boolean" },
|
|
112
|
-
dryRun: { type: "boolean" },
|
|
113
|
-
silent: { type: "boolean" },
|
|
114
|
-
gitTagFallback: { type: "boolean" },
|
|
115
|
-
sign: { type: "boolean" },
|
|
116
|
-
verify: { type: "boolean" },
|
|
117
|
-
asJson: { type: "boolean" },
|
|
118
|
-
// Skip Steps
|
|
119
|
-
skipBump: { type: "boolean" },
|
|
120
|
-
skipChangelog: { type: "boolean" },
|
|
121
|
-
skipCommit: { type: "boolean" },
|
|
122
|
-
skipTag: { type: "boolean" },
|
|
123
|
-
// Changelog Overrides
|
|
124
|
-
commitUrlFormat: { type: "string" },
|
|
125
|
-
compareUrlFormat: { type: "string" },
|
|
126
|
-
issueUrlFormat: { type: "string" },
|
|
127
|
-
userUrlFormat: { type: "string" },
|
|
128
|
-
releaseCommitMessageFormat: { type: "string" },
|
|
129
|
-
releaseMessageSuffix: { type: "string" }
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/cli.ts
|
|
2
|
+
import { inspect } from "./commands/inspect.js";
|
|
3
|
+
import { main } from "./commands/main.js";
|
|
4
|
+
import { validateConfig } from "./commands/validate-config.js";
|
|
5
|
+
import { Git } from "./services/git.js";
|
|
6
|
+
import { getUserConfig } from "./config/user-config.js";
|
|
7
|
+
import { FileManager } from "./files/file-manager.js";
|
|
8
|
+
import { Logger } from "./services/logger.js";
|
|
9
|
+
import { getCliArguments } from "./config/cli-arguments.js";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { writeFileSync } from "node:fs";
|
|
12
|
+
import { ZodError } from "zod";
|
|
13
|
+
//#region src/cli.ts
|
|
135
14
|
async function runFork() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (!config.dryRun && config.debug) {
|
|
167
|
-
writeFileSync(
|
|
168
|
-
join(config.path, `fork-version-${Date.now()}.debug-log.json`),
|
|
169
|
-
JSON.stringify(result, null, 2)
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
default: {
|
|
175
|
-
logger.error(`Unknown command: ${config.command}`);
|
|
176
|
-
process.exit(2);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
logger.debug(`Completed in ${Date.now() - startTime} ms`);
|
|
15
|
+
const startTime = Date.now();
|
|
16
|
+
const config = await getUserConfig(getCliArguments());
|
|
17
|
+
const logger = new Logger(config);
|
|
18
|
+
const fileManager = new FileManager(config, logger);
|
|
19
|
+
const git = new Git(config);
|
|
20
|
+
switch (config.command) {
|
|
21
|
+
case "validate-config":
|
|
22
|
+
validateConfig(config);
|
|
23
|
+
break;
|
|
24
|
+
case "inspect-version":
|
|
25
|
+
case "inspect-tag":
|
|
26
|
+
case "inspect":
|
|
27
|
+
await inspect(config, logger, fileManager, git);
|
|
28
|
+
break;
|
|
29
|
+
case "main": {
|
|
30
|
+
const result = await main(config, logger, fileManager, git);
|
|
31
|
+
const branchName = await git.getBranchName();
|
|
32
|
+
logger.log(`\nRun \`git push --follow-tags origin ${branchName}\` to push the changes and the tag.`);
|
|
33
|
+
if (result.current.files.some((file) => file.name === "package.json" && !file.isPrivate)) {
|
|
34
|
+
const npmTag = typeof config.preRelease === "string" ? config.preRelease : "prerelease";
|
|
35
|
+
logger.log(`${result.next.releaseType}`.startsWith("pre") ? `Run \`npm publish --tag ${npmTag}\` to publish the package.` : "Run `npm publish` to publish the package.");
|
|
36
|
+
}
|
|
37
|
+
if (!config.dryRun && config.debug) writeFileSync(join(config.path, `fork-version-${Date.now()}.debug-log.json`), JSON.stringify(result, null, 2));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
default:
|
|
41
|
+
logger.error(`Unknown command: ${config.command}`);
|
|
42
|
+
process.exit(2);
|
|
43
|
+
}
|
|
44
|
+
logger.debug(`Completed in ${Date.now() - startTime} ms`);
|
|
180
45
|
}
|
|
181
46
|
runFork().catch((error) => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
} else {
|
|
193
|
-
console.error(error);
|
|
194
|
-
}
|
|
195
|
-
process.exit(1);
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
if (error.cause instanceof ZodError) {
|
|
49
|
+
console.error(error.message);
|
|
50
|
+
for (const err of error.cause.issues) console.log(`${err.path.join(", ")} => ${err.message}`);
|
|
51
|
+
process.exit(3);
|
|
52
|
+
}
|
|
53
|
+
console.error(error.message);
|
|
54
|
+
if (error.stack) console.error(error.stack);
|
|
55
|
+
} else console.error(error);
|
|
56
|
+
process.exit(1);
|
|
196
57
|
});
|
|
197
|
-
//#
|
|
198
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { FileManager } from "../files/file-manager.js";
|
|
4
|
+
import { Git } from "../services/git.js";
|
|
5
|
+
|
|
6
|
+
//#region src/commands/inspect.d.ts
|
|
7
|
+
declare function inspect(config: ForkConfig, logger: Logger, fileManager: FileManager, git: Git): Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { inspect };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getCommitsSinceTag } from "../process/get-commits.js";
|
|
2
|
+
import { getCurrentVersion } from "../process/get-current-version.js";
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
//#region src/commands/inspect.ts
|
|
5
|
+
async function inspect(config, logger, fileManager, git) {
|
|
6
|
+
let latestTag = "";
|
|
7
|
+
let latestVersion = "";
|
|
8
|
+
try {
|
|
9
|
+
const commits = await getCommitsSinceTag(config, logger, git);
|
|
10
|
+
if (commits.latestTag) {
|
|
11
|
+
latestTag = commits.latestTag;
|
|
12
|
+
latestVersion = commits.latestTagVersion ?? "";
|
|
13
|
+
}
|
|
14
|
+
const currentVersion = await getCurrentVersion(config, logger, git, fileManager, config.files, latestVersion);
|
|
15
|
+
if (currentVersion.version) latestVersion = currentVersion.version;
|
|
16
|
+
} catch {}
|
|
17
|
+
if (!latestVersion && !latestTag) {
|
|
18
|
+
console.error(styleText("yellowBright", "No version found. Make sure you have at least one tag in your repository."));
|
|
19
|
+
process.exit(1);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
switch (config.command) {
|
|
23
|
+
case "inspect-version":
|
|
24
|
+
console.log(config.asJson ? JSON.stringify({ version: latestVersion }, null, 2) : latestVersion);
|
|
25
|
+
return;
|
|
26
|
+
case "inspect-tag":
|
|
27
|
+
console.log(config.asJson ? JSON.stringify({ tag: latestTag }, null, 2) : latestTag);
|
|
28
|
+
return;
|
|
29
|
+
default:
|
|
30
|
+
console.log(config.asJson ? JSON.stringify({
|
|
31
|
+
version: latestVersion,
|
|
32
|
+
tag: latestTag
|
|
33
|
+
}, null, 2) : `
|
|
34
|
+
Version: ${latestVersion}
|
|
35
|
+
Tag: ${latestTag}
|
|
36
|
+
`.trim());
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { inspect };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ForkConfig } from "../config/types.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { FileManager } from "../files/file-manager.js";
|
|
4
|
+
import { Git } from "../services/git.js";
|
|
5
|
+
import { CommitsSinceTag } from "../process/get-commits.js";
|
|
6
|
+
import { CurrentVersion } from "../process/get-current-version.js";
|
|
7
|
+
import { NextVersion } from "../process/get-next-version.js";
|
|
8
|
+
//#region src/commands/main.d.ts
|
|
9
|
+
declare function main(config: ForkConfig, logger: Logger, fileManager: FileManager, git: Git): Promise<{
|
|
10
|
+
config: ForkConfig;
|
|
11
|
+
commits: CommitsSinceTag;
|
|
12
|
+
current: CurrentVersion;
|
|
13
|
+
next: NextVersion;
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { main };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getCommitsSinceTag } from "../process/get-commits.js";
|
|
2
|
+
import { getCurrentVersion } from "../process/get-current-version.js";
|
|
3
|
+
import { getNextVersion } from "../process/get-next-version.js";
|
|
4
|
+
import { updateChangelog } from "../process/changelog.js";
|
|
5
|
+
import { commitChanges } from "../process/commit.js";
|
|
6
|
+
import { tagChanges } from "../process/tag.js";
|
|
7
|
+
//#region src/commands/main.ts
|
|
8
|
+
async function main(config, logger, fileManager, git) {
|
|
9
|
+
logger.log(`Running fork-version - ${(/* @__PURE__ */ new Date()).toUTCString()}`);
|
|
10
|
+
logger.warn(config.dryRun ? "[Dry Run] No changes will be written to disk.\n" : "");
|
|
11
|
+
const commits = await getCommitsSinceTag(config, logger, git);
|
|
12
|
+
const current = await getCurrentVersion(config, logger, git, fileManager, config.files, commits.latestTagVersion);
|
|
13
|
+
const next = await getNextVersion(config, logger, commits.commits, current.version);
|
|
14
|
+
logger.log("Updating files: ");
|
|
15
|
+
for (const outFile of current.files) {
|
|
16
|
+
logger.log(` - ${outFile.path}`);
|
|
17
|
+
fileManager.write(outFile, next.version);
|
|
18
|
+
}
|
|
19
|
+
await updateChangelog(config, logger, next.version);
|
|
20
|
+
await commitChanges(config, logger, git, current.files, next.version);
|
|
21
|
+
await tagChanges(config, logger, git, next.version);
|
|
22
|
+
return {
|
|
23
|
+
config,
|
|
24
|
+
commits,
|
|
25
|
+
current,
|
|
26
|
+
next
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { main };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { ParserOptions } from "./options.js";
|
|
2
|
+
import { Logger } from "../services/logger.js";
|
|
3
|
+
import { Commit, CommitNote, CommitReference } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/commit-parser/commit-parser.d.ts
|
|
6
|
+
declare class CommitParser {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(userOptions?: Partial<ParserOptions>);
|
|
9
|
+
setLogger(logger: Logger): this;
|
|
10
|
+
createCommit(): Commit;
|
|
11
|
+
/**
|
|
12
|
+
* Parse the raw commit message into its expected parts
|
|
13
|
+
* - subject
|
|
14
|
+
* - body
|
|
15
|
+
* - hash
|
|
16
|
+
* - date
|
|
17
|
+
* - name
|
|
18
|
+
* - email
|
|
19
|
+
*
|
|
20
|
+
* @throws {ParserError}
|
|
21
|
+
*/
|
|
22
|
+
parseRawCommit(rawCommit: string): Commit;
|
|
23
|
+
/**
|
|
24
|
+
* Parse the commit subject into its expected parts
|
|
25
|
+
* - type
|
|
26
|
+
* - scope (optional)
|
|
27
|
+
* - breaking change (optional)
|
|
28
|
+
* - title
|
|
29
|
+
*
|
|
30
|
+
* @throws {ParserError}
|
|
31
|
+
*/
|
|
32
|
+
parseSubject(commit: Commit): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Parse merge information from the commit subject
|
|
35
|
+
* @example
|
|
36
|
+
* ```txt
|
|
37
|
+
* "Merge pull request #123 from fork-version/feature"
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
parseMerge(commit: Commit): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Parse revert information from the commit body
|
|
43
|
+
* @example
|
|
44
|
+
* ```txt
|
|
45
|
+
* "Revert "feat: initial commit"
|
|
46
|
+
*
|
|
47
|
+
* This reverts commit 4a79e9e546b4020d2882b7810dc549fa71960f4f."
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
parseRevert(commit: Commit): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Search for mentions from the commit line
|
|
53
|
+
* @example
|
|
54
|
+
* ```txt
|
|
55
|
+
* "@fork-version"
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
parseMentions(line: string, outMentions: Set<string>): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Search for references from the commit line
|
|
61
|
+
* @example
|
|
62
|
+
* ```txt
|
|
63
|
+
* "#1234"
|
|
64
|
+
* "owner/repo#1234"
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
parseReferenceParts(referenceText: string, action: string | null): CommitReference[] | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Search for actions and references from the commit line
|
|
70
|
+
* @example
|
|
71
|
+
* ```txt
|
|
72
|
+
* "Closes #1234"
|
|
73
|
+
* "fixes owner/repo#1234"
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
parseReferences(line: string, outReferences: CommitReference[]): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Search for notes from the commit line
|
|
79
|
+
* @example
|
|
80
|
+
* ```txt
|
|
81
|
+
* "BREAKING CHANGE: this is a breaking change"
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
parseNotes(line: string, outNotes: CommitNote[]): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Parse the raw commit for mentions, references and notes
|
|
87
|
+
*/
|
|
88
|
+
parseRawLines(commit: Commit): void;
|
|
89
|
+
/**
|
|
90
|
+
* Parse a commit log with the following format separated by new line characters:
|
|
91
|
+
* ```txt
|
|
92
|
+
* refactor: add test file
|
|
93
|
+
* Add a test file to the project
|
|
94
|
+
* 4ef2c86d393a9660aa9f753144256b1f200c16bd
|
|
95
|
+
* 2024-12-22T17:36:50Z
|
|
96
|
+
* Fork Version
|
|
97
|
+
* fork-version@example.com
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* parse("refactor: add test file\nAdd a test file to the project\n4ef2c86d393a9660aa9f753144256b1f200c16bd\n2024-12-22T17:36:50Z\nFork Version\nfork-version@example.com");
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* The expected input value can be generated by running the following command:
|
|
106
|
+
* ```sh
|
|
107
|
+
* git log --format="%s%n%b%n%H%n%cI%n%cN%n%cE%n"
|
|
108
|
+
* ```
|
|
109
|
+
* @see {@link https://git-scm.com/docs/pretty-formats|Git Pretty Format Documentation}
|
|
110
|
+
*/
|
|
111
|
+
parse(rawCommit: string): Commit | undefined;
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { CommitParser };
|