fork-version 1.7.3 → 1.8.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/CHANGELOG.md +56 -0
- package/README.md +24 -6
- package/dist/{chunk-PKSCXRF2.cjs → chunk-EAMGFCWC.cjs} +316 -260
- package/dist/chunk-EAMGFCWC.cjs.map +1 -0
- package/dist/{chunk-XSSJMFKD.js → chunk-RLGF46N7.js} +315 -256
- package/dist/chunk-RLGF46N7.js.map +1 -0
- package/dist/cli.cjs +131 -72
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +117 -63
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +19 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -24
- package/dist/index.d.ts +95 -24
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/dist/chunk-PKSCXRF2.cjs.map +0 -1
- package/dist/chunk-XSSJMFKD.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,72 +1,125 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getUserConfig, Logger, FileManager, getCurrentVersion, getNextVersion, updateChangelog, commitChanges, tagChanges } from './chunk-
|
|
2
|
+
import { getUserConfig, Logger, FileManager, Git, getCurrentVersion, getNextVersion, updateChangelog, commitChanges, tagChanges } from './chunk-RLGF46N7.js';
|
|
3
3
|
import { writeFileSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { ZodError } from 'zod';
|
|
6
|
-
import
|
|
6
|
+
import meow from 'meow';
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
var helperText = `Usage:
|
|
9
|
+
$ fork-version [options]
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
--help Show this help message.
|
|
13
|
+
--version Show the current version of Fork-Version.
|
|
14
|
+
--inspect-version If set, Fork-Version will print the current project version and exit.
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
--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"]]
|
|
18
|
+
--glob, -G Glob pattern to match files to be updated.
|
|
19
|
+
--path, -P The path Fork-Version will run from. [Default: process.cwd()]
|
|
20
|
+
--changelog Name of the changelog file. [Default: "CHANGELOG.md"]
|
|
21
|
+
--header The header text for the changelog.
|
|
22
|
+
--tag-prefix Specify a prefix for the created tag. [Default: "v"]
|
|
23
|
+
--pre-release Mark this release as a pre-release.
|
|
24
|
+
--pre-release-tag Mark this release with a tagged pre-release. [Example: "alpha", "beta", "rc"]
|
|
25
|
+
--current-version If set, Fork-Version will use this version instead of trying to determine one.
|
|
26
|
+
--next-version If set, Fork-Version will attempt to update to this version, instead of incrementing using "conventional-commit".
|
|
27
|
+
--release-as Release as increments the version by the specified level. [Choices: "major", "minor", "patch"]
|
|
28
|
+
|
|
29
|
+
Flags:
|
|
30
|
+
--allow-multiple-versions Don't throw an error if multiple versions are found in the given files. [Default: true]
|
|
31
|
+
--commit-all Commit all changes, not just files updated by Fork-Version.
|
|
32
|
+
--changelog-all If this flag is set, all default commit types will be added to the changelog.
|
|
33
|
+
--debug Output debug information.
|
|
34
|
+
--dry-run No output will be written to disk or committed.
|
|
35
|
+
--silent Run without logging to the terminal.
|
|
36
|
+
--git-tag-fallback If unable to find a version in the given files, fallback and attempt to use the latest git tag. [Default: true]
|
|
37
|
+
--sign If true, git will sign the commit with the systems GPG key.
|
|
38
|
+
--verify If true, git will run user defined git hooks before committing.
|
|
39
|
+
|
|
40
|
+
To negate a flag you can prefix it with "no-", for example "--no-git-tag-fallback" will not fallback to the latest git tag.
|
|
41
|
+
|
|
42
|
+
Skip Steps:
|
|
43
|
+
--skip-bump Skip the version bump step.
|
|
44
|
+
--skip-changelog Skip updating the changelog.
|
|
45
|
+
--skip-commit Skip committing the changes.
|
|
46
|
+
--skip-tag Skip tagging the commit.
|
|
47
|
+
|
|
48
|
+
Conventional Changelog Overrides:
|
|
49
|
+
--commit-url-format Override the default commit URL format.
|
|
50
|
+
--compare-url-format Override the default compare URL format.
|
|
51
|
+
--issue-url-format Override the default issue URL format.
|
|
52
|
+
--user-url-format Override the default user URL format.
|
|
53
|
+
--release-commit-message-format Override the default release commit message format.
|
|
54
|
+
--release-message-suffix Add a suffix to the end of the release message.
|
|
55
|
+
|
|
56
|
+
Exit Codes:
|
|
57
|
+
0: Success
|
|
58
|
+
1: General Error
|
|
59
|
+
3: Config File Validation Error
|
|
60
|
+
|
|
61
|
+
Examples:
|
|
62
|
+
$ fork-version
|
|
63
|
+
Run fork-version in the current directory with default options.
|
|
64
|
+
|
|
65
|
+
$ fork-version --path ./packages/my-package
|
|
66
|
+
Run fork-version in the "./packages/my-package" directory.
|
|
67
|
+
|
|
68
|
+
$ fork-version --file package.json --file MyApi.csproj
|
|
69
|
+
Run fork-version and update the "package.json" and "MyApi.csproj" files.
|
|
70
|
+
|
|
71
|
+
$ fork-version --glob "*/package.json"
|
|
72
|
+
Run fork-version and update all "package.json" files in subdirectories.`;
|
|
73
|
+
function getCliArguments() {
|
|
74
|
+
return meow(helperText, {
|
|
75
|
+
importMeta: import.meta,
|
|
76
|
+
booleanDefault: void 0,
|
|
77
|
+
helpIndent: 0,
|
|
78
|
+
flags: {
|
|
79
|
+
// Commands
|
|
80
|
+
inspectVersion: { type: "boolean" },
|
|
81
|
+
// Options
|
|
82
|
+
files: { type: "string", isMultiple: true, aliases: ["file"], shortFlag: "F" },
|
|
83
|
+
glob: { type: "string", shortFlag: "G" },
|
|
84
|
+
path: { type: "string", shortFlag: "P" },
|
|
85
|
+
changelog: { type: "string" },
|
|
86
|
+
header: { type: "string" },
|
|
87
|
+
tagPrefix: { type: "string" },
|
|
88
|
+
preRelease: { type: "boolean" },
|
|
89
|
+
preReleaseTag: { type: "string" },
|
|
90
|
+
currentVersion: { type: "string" },
|
|
91
|
+
nextVersion: { type: "string" },
|
|
92
|
+
releaseAs: { type: "string", choices: ["major", "minor", "patch"] },
|
|
93
|
+
// Flags
|
|
94
|
+
allowMultipleVersions: { type: "boolean" },
|
|
95
|
+
commitAll: { type: "boolean" },
|
|
96
|
+
changelogAll: { type: "boolean" },
|
|
97
|
+
debug: { type: "boolean" },
|
|
98
|
+
dryRun: { type: "boolean" },
|
|
99
|
+
silent: { type: "boolean" },
|
|
100
|
+
gitTagFallback: { type: "boolean" },
|
|
101
|
+
sign: { type: "boolean" },
|
|
102
|
+
verify: { type: "boolean" },
|
|
103
|
+
// Skip Steps
|
|
104
|
+
skipBump: { type: "boolean" },
|
|
105
|
+
skipChangelog: { type: "boolean" },
|
|
106
|
+
skipCommit: { type: "boolean" },
|
|
107
|
+
skipTag: { type: "boolean" },
|
|
108
|
+
// Changelog Overrides
|
|
109
|
+
commitUrlFormat: { type: "string" },
|
|
110
|
+
compareUrlFormat: { type: "string" },
|
|
111
|
+
issueUrlFormat: { type: "string" },
|
|
112
|
+
userUrlFormat: { type: "string" },
|
|
113
|
+
releaseCommitMessageFormat: { type: "string" },
|
|
114
|
+
releaseMessageSuffix: { type: "string" }
|
|
41
115
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (await this.execGit("rev-parse", ["--abbrev-ref", "HEAD"])).trim();
|
|
45
|
-
}
|
|
46
|
-
async execGit(command, args) {
|
|
47
|
-
return new Promise((onResolve, onReject) => {
|
|
48
|
-
execFile(
|
|
49
|
-
"git",
|
|
50
|
-
[command, ...args],
|
|
51
|
-
{
|
|
52
|
-
cwd: this.config.path
|
|
53
|
-
},
|
|
54
|
-
(error, stdout, stderr) => {
|
|
55
|
-
if (error) {
|
|
56
|
-
onReject(error);
|
|
57
|
-
} else {
|
|
58
|
-
onResolve(stdout ? stdout : stderr);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
116
|
+
}).flags;
|
|
117
|
+
}
|
|
65
118
|
|
|
66
119
|
// src/cli.ts
|
|
67
|
-
async function runFork() {
|
|
120
|
+
async function runFork(cliArguments2) {
|
|
68
121
|
const startTime = Date.now();
|
|
69
|
-
const config = await getUserConfig();
|
|
122
|
+
const config = await getUserConfig(cliArguments2);
|
|
70
123
|
const logger = new Logger(config);
|
|
71
124
|
const fileManager = new FileManager(config, logger);
|
|
72
125
|
const git = new Git(config);
|
|
@@ -74,7 +127,7 @@ async function runFork() {
|
|
|
74
127
|
logger.warn(config.dryRun ? "[Dry Run] No changes will be written to disk.\n" : "");
|
|
75
128
|
const current = await getCurrentVersion(config, logger, git, fileManager, config.files);
|
|
76
129
|
const next = await getNextVersion(config, logger, current.version);
|
|
77
|
-
logger.log("Updating
|
|
130
|
+
logger.log("Updating files: ");
|
|
78
131
|
for (const outFile of current.files) {
|
|
79
132
|
logger.log(` - ${outFile.path}`);
|
|
80
133
|
fileManager.write(outFile, next.version);
|
|
@@ -82,7 +135,7 @@ async function runFork() {
|
|
|
82
135
|
await updateChangelog(config, logger, next.version);
|
|
83
136
|
await commitChanges(config, logger, git, current.files, next.version);
|
|
84
137
|
await tagChanges(config, logger, git, next.version);
|
|
85
|
-
const branchName = await git.
|
|
138
|
+
const branchName = await git.getCurrentBranchName();
|
|
86
139
|
logger.log(
|
|
87
140
|
`
|
|
88
141
|
Run \`git push --follow-tags origin ${branchName}\` to push the changes and the tag.`
|
|
@@ -107,7 +160,8 @@ Run \`git push --follow-tags origin ${branchName}\` to push the changes and the
|
|
|
107
160
|
}
|
|
108
161
|
return result;
|
|
109
162
|
}
|
|
110
|
-
|
|
163
|
+
var cliArguments = getCliArguments();
|
|
164
|
+
runFork(cliArguments).catch((error) => {
|
|
111
165
|
if (error instanceof Error) {
|
|
112
166
|
if (error.cause instanceof ZodError) {
|
|
113
167
|
console.error(error.message);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/git.ts","../src/cli.ts"],"names":[],"mappings":";;;;;;;AAGO,IAAM,MAAN,MAAU;AAAA,EAChB,YAAoB,MAA6C,EAAA;AAA7C,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACnB,IAAA,IAAA,CAAK,GAAM,GAAA,IAAA,CAAK,GAAI,CAAA,IAAA,CAAK,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,IAAI,CAAA;AACnC,IAAA,IAAA,CAAK,GAAM,GAAA,IAAA,CAAK,GAAI,CAAA,IAAA,CAAK,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,YAAe,GAAA,IAAA,CAAK,YAAa,CAAA,IAAA,CAAK,IAAI,CAAA;AAC/C,IAAA,IAAA,CAAK,aAAgB,GAAA,IAAA,CAAK,aAAc,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA;AAClD,EAEA,MAAa,OAAO,IAA+C,EAAA;AAClE,IAAI,IAAA,IAAA,CAAK,OAAO,MAAQ,EAAA;AACvB,MAAO,OAAA,EAAA;AAAA;AAGR,IAAA,OAAO,KAAK,OAAQ,CAAA,KAAA,EAAO,IAAK,CAAA,MAAA,CAAO,OAAO,CAAa,CAAA;AAAA;AAC5D,EAEA,MAAa,UAAU,IAA+C,EAAA;AACrE,IAAI,IAAA,IAAA,CAAK,OAAO,MAAQ,EAAA;AACv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,CAAM,iBAAiB,QAAU,EAAA;AACpC,MAAQ,OAAA,CAAA,KAAA,CAAM,MAAM,OAAO,CAAA;AAC3B,MAAW,KAAA,MAAA,GAAA,IAAO,KAAM,CAAA,KAAA,CAAM,MAAQ,EAAA;AACrC,QAAA,OAAA,CAAQ,IAAI,CAAG,EAAA,GAAA,CAAI,IAAI,CAAO,IAAA,EAAA,GAAA,CAAI,OAAO,CAAE,CAAA,CAAA;AAAA;AAE5C,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAGf,IAAA,IAAI,MAAM,KAAO,EAAA;AAChB,MAAQ,OAAA,CAAA,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,KACnB,MAAA;AACN,MAAQ,OAAA,CAAA,KAAA,CAAM,MAAM,OAAO,CAAA;AAAA;AAC5B,GACM,MAAA;AACN,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA;AAEpB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACf,CAAC,CAAA","file":"cli.js","sourcesContent":["import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../config/types\";\n\nexport class Git {\n\tconstructor(private config: Pick<ForkConfig, \"path\" | \"dryRun\">) {\n\t\tthis.add = this.add.bind(this);\n\t\tthis.commit = this.commit.bind(this);\n\t\tthis.tag = this.tag.bind(this);\n\t\tthis.shouldIgnore = this.shouldIgnore.bind(this);\n\t\tthis.currentBranch = this.currentBranch.bind(this);\n\t}\n\n\tpublic async add(...args: (string | undefined)[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn this.execGit(\"add\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic async commit(...args: (string | undefined)[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn this.execGit(\"commit\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic async tag(...args: (string | undefined)[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn this.execGit(\"tag\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic async shouldIgnore(file: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.execGit(\"check-ignore\", [\"--no-index\", file]);\n\n\t\t\treturn true;\n\t\t} catch (_error) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic async currentBranch(): Promise<string> {\n\t\treturn (await this.execGit(\"rev-parse\", [\"--abbrev-ref\", \"HEAD\"])).trim();\n\t}\n\n\tprivate async execGit(command: string, args: string[]): Promise<string> {\n\t\treturn new Promise((onResolve, onReject) => {\n\t\t\texecFile(\n\t\t\t\t\"git\",\n\t\t\t\t[command, ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd: this.config.path,\n\t\t\t\t},\n\t\t\t\t(error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tonReject(error);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonResolve(stdout ? stdout : stderr);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n}\n","#!/usr/bin/env node\n\nimport { writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { ZodError } from \"zod\";\n\nimport { getUserConfig } from \"./config/user-config\";\nimport { Logger } from \"./utils/logger\";\nimport { FileManager } from \"./strategies/file-manager\";\nimport { Git } from \"./utils/git\";\n\nimport { getCurrentVersion, getNextVersion } from \"./process/version\";\nimport { updateChangelog } from \"./process/changelog\";\nimport { commitChanges } from \"./process/commit\";\nimport { tagChanges } from \"./process/tag\";\n\nasync function runFork() {\n\tconst startTime = Date.now();\n\n\tconst config = await getUserConfig();\n\n\tconst logger = new Logger(config);\n\tconst fileManager = new FileManager(config, logger);\n\tconst git = new Git(config);\n\n\tlogger.log(`Running fork-version - ${new Date().toUTCString()}`);\n\tlogger.warn(config.dryRun ? \"[Dry Run] No changes will be written to disk.\\n\" : \"\");\n\n\tconst current = await getCurrentVersion(config, logger, git, fileManager, config.files);\n\tconst next = await getNextVersion(config, logger, current.version);\n\n\tlogger.log(\"Updating Files: \");\n\tfor (const outFile of current.files) {\n\t\tlogger.log(` - ${outFile.path}`);\n\n\t\tfileManager.write(outFile, next.version);\n\t}\n\n\tawait updateChangelog(config, logger, next.version);\n\tawait commitChanges(config, logger, git, current.files, next.version);\n\tawait tagChanges(config, logger, git, next.version);\n\n\t// Print git push command\n\tconst branchName = await git.currentBranch();\n\tlogger.log(\n\t\t`\\nRun \\`git push --follow-tags origin ${branchName}\\` to push the changes and the tag.`,\n\t);\n\n\t// Print npm publish command\n\tif (current.files.some((file) => file.name === \"package.json\" && file.isPrivate === false)) {\n\t\tconst npmTag = typeof config.preRelease === \"string\" ? config.preRelease : \"prerelease\";\n\t\tlogger.log(\n\t\t\t`${next.releaseType}`.startsWith(\"pre\")\n\t\t\t\t? `Run \\`npm publish --tag ${npmTag}\\` to publish the package.`\n\t\t\t\t: \"Run `npm publish` to publish the package.\",\n\t\t);\n\t}\n\n\tlogger.debug(`Completed in ${Date.now() - startTime} ms`);\n\n\tconst result = {\n\t\tconfig,\n\t\tcurrent,\n\t\tnext,\n\t};\n\n\tif (!config.dryRun && config.debug) {\n\t\twriteFileSync(\n\t\t\tjoin(config.path, `fork-version-${Date.now()}.debug-log.json`),\n\t\t\tJSON.stringify(result, null, 2),\n\t\t);\n\t}\n\n\treturn result;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrunFork().catch((error: Error | any) => {\n\tif (error instanceof Error) {\n\t\t// If the error is a ZodError, print the keys that failed validation\n\t\tif (error.cause instanceof ZodError) {\n\t\t\tconsole.error(error.message);\n\t\t\tfor (const err of error.cause.errors) {\n\t\t\t\tconsole.log(`${err.path} => ${err.message}`);\n\t\t\t}\n\t\t\tprocess.exit(3);\n\t\t}\n\n\t\tif (error.stack) {\n\t\t\tconsole.error(error.stack);\n\t\t} else {\n\t\t\tconsole.error(error.message);\n\t\t}\n\t} else {\n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AA,CAAU,MAAQ,EAAA,IAAA,EAAM,CAAC;AAAA,KAC/B;AAAA;AAGD,EAAO,OAAA,MAAA;AACR;AAEA,IAAM,eAAe,eAAgB,EAAA;AAGrC,OAAA,CAAQ,YAAY,CAAA,CAAE,KAAM,CAAA,CAAC,KAAuB,KAAA;AACnD,EAAA,IAAI,iBAAiB,KAAO,EAAA;AAE3B,IAAI,IAAA,KAAA,CAAM,iBAAiB,QAAU,EAAA;AACpC,MAAQ,OAAA,CAAA,KAAA,CAAM,MAAM,OAAO,CAAA;AAC3B,MAAW,KAAA,MAAA,GAAA,IAAO,KAAM,CAAA,KAAA,CAAM,MAAQ,EAAA;AACrC,QAAA,OAAA,CAAQ,IAAI,CAAG,EAAA,GAAA,CAAI,IAAI,CAAO,IAAA,EAAA,GAAA,CAAI,OAAO,CAAE,CAAA,CAAA;AAAA;AAE5C,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAGf,IAAA,IAAI,MAAM,KAAO,EAAA;AAChB,MAAQ,OAAA,CAAA,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,KACnB,MAAA;AACN,MAAQ,OAAA,CAAA,KAAA,CAAM,MAAM,OAAO,CAAA;AAAA;AAC5B,GACM,MAAA;AACN,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA;AAEpB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACf,CAAC,CAAA","file":"cli.js","sourcesContent":["import meow from \"meow\";\n//@ts-check\n\n// This file is javascript so the following helper text can be extracted to the readme\n// without the need for a build step, otherwise it would also be typescript...\n\nexport const helperText = `Usage:\n $ fork-version [options]\n\nCommands:\n --help Show this help message.\n --version Show the current version of Fork-Version.\n --inspect-version If set, Fork-Version will print the current project version and exit.\n\nOptions:\n --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\"]]\n --glob, -G Glob pattern to match files to be updated.\n --path, -P The path Fork-Version will run from. [Default: process.cwd()]\n --changelog Name of the changelog file. [Default: \"CHANGELOG.md\"]\n --header The header text for the changelog.\n --tag-prefix Specify a prefix for the created tag. [Default: \"v\"]\n --pre-release Mark this release as a pre-release.\n --pre-release-tag Mark this release with a tagged pre-release. [Example: \"alpha\", \"beta\", \"rc\"]\n --current-version If set, Fork-Version will use this version instead of trying to determine one.\n --next-version If set, Fork-Version will attempt to update to this version, instead of incrementing using \"conventional-commit\".\n --release-as Release as increments the version by the specified level. [Choices: \"major\", \"minor\", \"patch\"]\n\nFlags:\n --allow-multiple-versions Don't throw an error if multiple versions are found in the given files. [Default: true]\n --commit-all Commit all changes, not just files updated by Fork-Version.\n --changelog-all If this flag is set, all default commit types will be added to the changelog.\n --debug Output debug information.\n --dry-run No output will be written to disk or committed.\n --silent Run without logging to the terminal.\n --git-tag-fallback If unable to find a version in the given files, fallback and attempt to use the latest git tag. [Default: true]\n --sign If true, git will sign the commit with the systems GPG key.\n --verify If true, git will run user defined git hooks before committing.\n\n To negate a flag you can prefix it with \"no-\", for example \"--no-git-tag-fallback\" will not fallback to the latest git tag.\n\nSkip Steps:\n --skip-bump Skip the version bump step.\n --skip-changelog Skip updating the changelog.\n --skip-commit Skip committing the changes.\n --skip-tag Skip tagging the commit.\n\nConventional Changelog Overrides:\n --commit-url-format Override the default commit URL format.\n --compare-url-format Override the default compare URL format.\n --issue-url-format Override the default issue URL format.\n --user-url-format Override the default user URL format.\n --release-commit-message-format Override the default release commit message format.\n --release-message-suffix Add a suffix to the end of the release message.\n\nExit Codes:\n 0: Success\n 1: General Error\n 3: Config File Validation Error\n\nExamples:\n $ fork-version\n Run fork-version in the current directory with default options.\n\n $ fork-version --path ./packages/my-package\n Run fork-version in the \"./packages/my-package\" directory.\n\n $ fork-version --file package.json --file MyApi.csproj\n Run fork-version and update the \"package.json\" and \"MyApi.csproj\" files.\n\n $ fork-version --glob \"*/package.json\"\n Run fork-version and update all \"package.json\" files in subdirectories.`;\n\nexport function getCliArguments() {\n\treturn meow(helperText, {\n\t\timportMeta: import.meta,\n\t\tbooleanDefault: undefined,\n\t\thelpIndent: 0,\n\t\tflags: {\n\t\t\t// Commands\n\t\t\tinspectVersion: { type: \"boolean\" },\n\n\t\t\t// Options\n\t\t\tfiles: { type: \"string\", isMultiple: true, aliases: [\"file\"], shortFlag: \"F\" },\n\t\t\tglob: { type: \"string\", shortFlag: \"G\" },\n\t\t\tpath: { type: \"string\", shortFlag: \"P\" },\n\t\t\tchangelog: { type: \"string\" },\n\t\t\theader: { type: \"string\" },\n\t\t\ttagPrefix: { type: \"string\" },\n\t\t\tpreRelease: { type: \"boolean\" },\n\t\t\tpreReleaseTag: { type: \"string\" },\n\t\t\tcurrentVersion: { type: \"string\" },\n\t\t\tnextVersion: { type: \"string\" },\n\t\t\treleaseAs: { type: \"string\", choices: [\"major\", \"minor\", \"patch\"] },\n\n\t\t\t// Flags\n\t\t\tallowMultipleVersions: { type: \"boolean\" },\n\t\t\tcommitAll: { type: \"boolean\" },\n\t\t\tchangelogAll: { type: \"boolean\" },\n\t\t\tdebug: { type: \"boolean\" },\n\t\t\tdryRun: { type: \"boolean\" },\n\t\t\tsilent: { type: \"boolean\" },\n\t\t\tgitTagFallback: { type: \"boolean\" },\n\t\t\tsign: { type: \"boolean\" },\n\t\t\tverify: { type: \"boolean\" },\n\n\t\t\t// Skip Steps\n\t\t\tskipBump: { type: \"boolean\" },\n\t\t\tskipChangelog: { type: \"boolean\" },\n\t\t\tskipCommit: { type: \"boolean\" },\n\t\t\tskipTag: { type: \"boolean\" },\n\n\t\t\t// Changelog Overrides\n\t\t\tcommitUrlFormat: { type: \"string\" },\n\t\t\tcompareUrlFormat: { type: \"string\" },\n\t\t\tissueUrlFormat: { type: \"string\" },\n\t\t\tuserUrlFormat: { type: \"string\" },\n\t\t\treleaseCommitMessageFormat: { type: \"string\" },\n\t\t\treleaseMessageSuffix: { type: \"string\" },\n\t\t},\n\t}).flags;\n}\n","#!/usr/bin/env node\n\nimport { writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { ZodError } from \"zod\";\n\nimport { getCliArguments } from \"./config/cli-arguments\";\nimport { getUserConfig } from \"./config/user-config\";\nimport { Logger } from \"./utils/logger\";\nimport { FileManager } from \"./files/file-manager\";\nimport { Git } from \"./utils/git\";\n\nimport { getCurrentVersion, getNextVersion } from \"./process/version\";\nimport { updateChangelog } from \"./process/changelog\";\nimport { commitChanges } from \"./process/commit\";\nimport { tagChanges } from \"./process/tag\";\n\nasync function runFork(cliArguments: ReturnType<typeof getCliArguments>) {\n\tconst startTime = Date.now();\n\n\tconst config = await getUserConfig(cliArguments);\n\n\tconst logger = new Logger(config);\n\tconst fileManager = new FileManager(config, logger);\n\tconst git = new Git(config);\n\n\tlogger.log(`Running fork-version - ${new Date().toUTCString()}`);\n\tlogger.warn(config.dryRun ? \"[Dry Run] No changes will be written to disk.\\n\" : \"\");\n\n\tconst current = await getCurrentVersion(config, logger, git, fileManager, config.files);\n\tconst next = await getNextVersion(config, logger, current.version);\n\n\tlogger.log(\"Updating files: \");\n\tfor (const outFile of current.files) {\n\t\tlogger.log(` - ${outFile.path}`);\n\n\t\tfileManager.write(outFile, next.version);\n\t}\n\n\tawait updateChangelog(config, logger, next.version);\n\tawait commitChanges(config, logger, git, current.files, next.version);\n\tawait tagChanges(config, logger, git, next.version);\n\n\t// Print git push command\n\tconst branchName = await git.getCurrentBranchName();\n\tlogger.log(\n\t\t`\\nRun \\`git push --follow-tags origin ${branchName}\\` to push the changes and the tag.`,\n\t);\n\n\t// Print npm publish command\n\tif (current.files.some((file) => file.name === \"package.json\" && file.isPrivate === false)) {\n\t\tconst npmTag = typeof config.preRelease === \"string\" ? config.preRelease : \"prerelease\";\n\t\tlogger.log(\n\t\t\t`${next.releaseType}`.startsWith(\"pre\")\n\t\t\t\t? `Run \\`npm publish --tag ${npmTag}\\` to publish the package.`\n\t\t\t\t: \"Run `npm publish` to publish the package.\",\n\t\t);\n\t}\n\n\tlogger.debug(`Completed in ${Date.now() - startTime} ms`);\n\n\tconst result = {\n\t\tconfig,\n\t\tcurrent,\n\t\tnext,\n\t};\n\n\tif (!config.dryRun && config.debug) {\n\t\twriteFileSync(\n\t\t\tjoin(config.path, `fork-version-${Date.now()}.debug-log.json`),\n\t\t\tJSON.stringify(result, null, 2),\n\t\t);\n\t}\n\n\treturn result;\n}\n\nconst cliArguments = getCliArguments();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrunFork(cliArguments).catch((error: Error | any) => {\n\tif (error instanceof Error) {\n\t\t// If the error is a ZodError, print the keys that failed validation\n\t\tif (error.cause instanceof ZodError) {\n\t\t\tconsole.error(error.message);\n\t\t\tfor (const err of error.cause.errors) {\n\t\t\t\tconsole.log(`${err.path} => ${err.message}`);\n\t\t\t}\n\t\t\tprocess.exit(3);\n\t\t}\n\n\t\tif (error.stack) {\n\t\t\tconsole.error(error.stack);\n\t\t} else {\n\t\t\tconsole.error(error.message);\n\t\t}\n\t} else {\n\t\tconsole.error(error);\n\t}\n\tprocess.exit(1);\n});\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,48 +1,52 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
3
|
+
var chunkEAMGFCWC_cjs = require('./chunk-EAMGFCWC.cjs');
|
|
5
4
|
|
|
5
|
+
// src/config/define-config.ts
|
|
6
|
+
function defineConfig(config) {
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
6
9
|
|
|
7
10
|
Object.defineProperty(exports, "FileManager", {
|
|
8
11
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkEAMGFCWC_cjs.FileManager; }
|
|
10
13
|
});
|
|
11
14
|
Object.defineProperty(exports, "ForkConfigSchema", {
|
|
12
15
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkEAMGFCWC_cjs.ForkConfigSchema; }
|
|
14
17
|
});
|
|
15
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "Git", {
|
|
16
19
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkEAMGFCWC_cjs.Git; }
|
|
18
21
|
});
|
|
19
|
-
Object.defineProperty(exports, "
|
|
22
|
+
Object.defineProperty(exports, "Logger", {
|
|
20
23
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkEAMGFCWC_cjs.Logger; }
|
|
22
25
|
});
|
|
23
|
-
Object.defineProperty(exports, "
|
|
26
|
+
Object.defineProperty(exports, "commitChanges", {
|
|
24
27
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkEAMGFCWC_cjs.commitChanges; }
|
|
26
29
|
});
|
|
27
30
|
Object.defineProperty(exports, "getCurrentVersion", {
|
|
28
31
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkEAMGFCWC_cjs.getCurrentVersion; }
|
|
30
33
|
});
|
|
31
34
|
Object.defineProperty(exports, "getNextVersion", {
|
|
32
35
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkEAMGFCWC_cjs.getNextVersion; }
|
|
34
37
|
});
|
|
35
38
|
Object.defineProperty(exports, "getUserConfig", {
|
|
36
39
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkEAMGFCWC_cjs.getUserConfig; }
|
|
38
41
|
});
|
|
39
42
|
Object.defineProperty(exports, "tagChanges", {
|
|
40
43
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkEAMGFCWC_cjs.tagChanges; }
|
|
42
45
|
});
|
|
43
46
|
Object.defineProperty(exports, "updateChangelog", {
|
|
44
47
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkEAMGFCWC_cjs.updateChangelog; }
|
|
46
49
|
});
|
|
50
|
+
exports.defineConfig = defineConfig;
|
|
47
51
|
//# sourceMappingURL=index.cjs.map
|
|
48
52
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
1
|
+
{"version":3,"sources":["../src/config/define-config.ts"],"names":[],"mappings":";;;;;AAKO,SAAS,aAAa,MAAwB,EAAA;AACpD,EAAO,OAAA,MAAA;AACR","file":"index.cjs","sourcesContent":["import type { Config } from \"./types\";\n\n/**\n * [Fork-Version - Config Properties](https://github.com/eglavin/fork-version/blob/main/README.md#config-properties)\n */\nexport function defineConfig(config: Config): Config {\n\treturn config;\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -145,6 +145,7 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
145
145
|
sign: z.ZodBoolean;
|
|
146
146
|
/**
|
|
147
147
|
* If true, git will run user defined git hooks before committing.
|
|
148
|
+
* @see {@link https://git-scm.com/docs/githooks Git - Git Hooks}
|
|
148
149
|
* @default false
|
|
149
150
|
*/
|
|
150
151
|
verify: z.ZodBoolean;
|
|
@@ -208,30 +209,30 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
208
209
|
releaseCommitMessageFormat: z.ZodOptional<z.ZodString>;
|
|
209
210
|
issuePrefixes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
210
211
|
}, "strip", z.ZodTypeAny, {
|
|
212
|
+
commitUrlFormat?: string | undefined;
|
|
213
|
+
compareUrlFormat?: string | undefined;
|
|
214
|
+
issueUrlFormat?: string | undefined;
|
|
215
|
+
userUrlFormat?: string | undefined;
|
|
216
|
+
releaseCommitMessageFormat?: string | undefined;
|
|
211
217
|
types?: {
|
|
212
218
|
type: string;
|
|
213
219
|
scope?: string | undefined;
|
|
214
220
|
section?: string | undefined;
|
|
215
221
|
hidden?: boolean | undefined;
|
|
216
222
|
}[] | undefined;
|
|
223
|
+
issuePrefixes?: string[] | undefined;
|
|
224
|
+
}, {
|
|
217
225
|
commitUrlFormat?: string | undefined;
|
|
218
226
|
compareUrlFormat?: string | undefined;
|
|
219
227
|
issueUrlFormat?: string | undefined;
|
|
220
228
|
userUrlFormat?: string | undefined;
|
|
221
229
|
releaseCommitMessageFormat?: string | undefined;
|
|
222
|
-
issuePrefixes?: string[] | undefined;
|
|
223
|
-
}, {
|
|
224
230
|
types?: {
|
|
225
231
|
type: string;
|
|
226
232
|
scope?: string | undefined;
|
|
227
233
|
section?: string | undefined;
|
|
228
234
|
hidden?: boolean | undefined;
|
|
229
235
|
}[] | undefined;
|
|
230
|
-
commitUrlFormat?: string | undefined;
|
|
231
|
-
compareUrlFormat?: string | undefined;
|
|
232
|
-
issueUrlFormat?: string | undefined;
|
|
233
|
-
userUrlFormat?: string | undefined;
|
|
234
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
235
236
|
issuePrefixes?: string[] | undefined;
|
|
236
237
|
}>;
|
|
237
238
|
/**
|
|
@@ -241,8 +242,8 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
241
242
|
releaseMessageSuffix: z.ZodOptional<z.ZodString>;
|
|
242
243
|
}, "strip", z.ZodTypeAny, {
|
|
243
244
|
inspectVersion: boolean;
|
|
244
|
-
path: string;
|
|
245
245
|
files: string[];
|
|
246
|
+
path: string;
|
|
246
247
|
changelog: string;
|
|
247
248
|
header: string;
|
|
248
249
|
tagPrefix: string;
|
|
@@ -260,17 +261,17 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
260
261
|
skipCommit: boolean;
|
|
261
262
|
skipTag: boolean;
|
|
262
263
|
changelogPresetConfig: {
|
|
264
|
+
commitUrlFormat?: string | undefined;
|
|
265
|
+
compareUrlFormat?: string | undefined;
|
|
266
|
+
issueUrlFormat?: string | undefined;
|
|
267
|
+
userUrlFormat?: string | undefined;
|
|
268
|
+
releaseCommitMessageFormat?: string | undefined;
|
|
263
269
|
types?: {
|
|
264
270
|
type: string;
|
|
265
271
|
scope?: string | undefined;
|
|
266
272
|
section?: string | undefined;
|
|
267
273
|
hidden?: boolean | undefined;
|
|
268
274
|
}[] | undefined;
|
|
269
|
-
commitUrlFormat?: string | undefined;
|
|
270
|
-
compareUrlFormat?: string | undefined;
|
|
271
|
-
issueUrlFormat?: string | undefined;
|
|
272
|
-
userUrlFormat?: string | undefined;
|
|
273
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
274
275
|
issuePrefixes?: string[] | undefined;
|
|
275
276
|
};
|
|
276
277
|
glob?: string | undefined;
|
|
@@ -281,8 +282,8 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
281
282
|
releaseMessageSuffix?: string | undefined;
|
|
282
283
|
}, {
|
|
283
284
|
inspectVersion: boolean;
|
|
284
|
-
path: string;
|
|
285
285
|
files: string[];
|
|
286
|
+
path: string;
|
|
286
287
|
changelog: string;
|
|
287
288
|
header: string;
|
|
288
289
|
tagPrefix: string;
|
|
@@ -300,17 +301,17 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
300
301
|
skipCommit: boolean;
|
|
301
302
|
skipTag: boolean;
|
|
302
303
|
changelogPresetConfig: {
|
|
304
|
+
commitUrlFormat?: string | undefined;
|
|
305
|
+
compareUrlFormat?: string | undefined;
|
|
306
|
+
issueUrlFormat?: string | undefined;
|
|
307
|
+
userUrlFormat?: string | undefined;
|
|
308
|
+
releaseCommitMessageFormat?: string | undefined;
|
|
303
309
|
types?: {
|
|
304
310
|
type: string;
|
|
305
311
|
scope?: string | undefined;
|
|
306
312
|
section?: string | undefined;
|
|
307
313
|
hidden?: boolean | undefined;
|
|
308
314
|
}[] | undefined;
|
|
309
|
-
commitUrlFormat?: string | undefined;
|
|
310
|
-
compareUrlFormat?: string | undefined;
|
|
311
|
-
issueUrlFormat?: string | undefined;
|
|
312
|
-
userUrlFormat?: string | undefined;
|
|
313
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
314
315
|
issuePrefixes?: string[] | undefined;
|
|
315
316
|
};
|
|
316
317
|
glob?: string | undefined;
|
|
@@ -324,9 +325,47 @@ declare const ForkConfigSchema: z.ZodObject<{
|
|
|
324
325
|
type ForkConfig = z.infer<typeof ForkConfigSchema>;
|
|
325
326
|
type Config = Partial<ForkConfig>;
|
|
326
327
|
|
|
327
|
-
|
|
328
|
+
/**
|
|
329
|
+
* [Fork-Version - Config Properties](https://github.com/eglavin/fork-version/blob/main/README.md#config-properties)
|
|
330
|
+
*/
|
|
328
331
|
declare function defineConfig(config: Config): Config;
|
|
329
332
|
|
|
333
|
+
declare function getCliArguments(): {
|
|
334
|
+
inspectVersion: boolean | undefined;
|
|
335
|
+
files: string[] | undefined;
|
|
336
|
+
glob: string | undefined;
|
|
337
|
+
path: string | undefined;
|
|
338
|
+
changelog: string | undefined;
|
|
339
|
+
header: string | undefined;
|
|
340
|
+
tagPrefix: string | undefined;
|
|
341
|
+
preRelease: boolean | undefined;
|
|
342
|
+
preReleaseTag: string | undefined;
|
|
343
|
+
currentVersion: string | undefined;
|
|
344
|
+
nextVersion: string | undefined;
|
|
345
|
+
releaseAs: string | undefined;
|
|
346
|
+
allowMultipleVersions: boolean | undefined;
|
|
347
|
+
commitAll: boolean | undefined;
|
|
348
|
+
changelogAll: boolean | undefined;
|
|
349
|
+
debug: boolean | undefined;
|
|
350
|
+
dryRun: boolean | undefined;
|
|
351
|
+
silent: boolean | undefined;
|
|
352
|
+
gitTagFallback: boolean | undefined;
|
|
353
|
+
sign: boolean | undefined;
|
|
354
|
+
verify: boolean | undefined;
|
|
355
|
+
skipBump: boolean | undefined;
|
|
356
|
+
skipChangelog: boolean | undefined;
|
|
357
|
+
skipCommit: boolean | undefined;
|
|
358
|
+
skipTag: boolean | undefined;
|
|
359
|
+
commitUrlFormat: string | undefined;
|
|
360
|
+
compareUrlFormat: string | undefined;
|
|
361
|
+
issueUrlFormat: string | undefined;
|
|
362
|
+
userUrlFormat: string | undefined;
|
|
363
|
+
releaseCommitMessageFormat: string | undefined;
|
|
364
|
+
releaseMessageSuffix: string | undefined;
|
|
365
|
+
} & Record<string, unknown>;
|
|
366
|
+
|
|
367
|
+
declare function getUserConfig(cliArguments: Partial<ReturnType<typeof getCliArguments>>): Promise<ForkConfig>;
|
|
368
|
+
|
|
330
369
|
declare class Logger {
|
|
331
370
|
private config;
|
|
332
371
|
disableLogs: boolean;
|
|
@@ -355,6 +394,7 @@ declare class FileManager {
|
|
|
355
394
|
private YAMLPackage;
|
|
356
395
|
private PlainText;
|
|
357
396
|
private MSBuildProject;
|
|
397
|
+
private ARMBicep;
|
|
358
398
|
constructor(config: ForkConfig, logger: Logger);
|
|
359
399
|
/**
|
|
360
400
|
* Get the state from the given file name.
|
|
@@ -387,12 +427,43 @@ declare class FileManager {
|
|
|
387
427
|
declare class Git {
|
|
388
428
|
private config;
|
|
389
429
|
constructor(config: Pick<ForkConfig, "path" | "dryRun">);
|
|
430
|
+
private execGit;
|
|
431
|
+
/**
|
|
432
|
+
* - [git-add Documentation](https://git-scm.com/docs/git-add)
|
|
433
|
+
*/
|
|
390
434
|
add(...args: (string | undefined)[]): Promise<string>;
|
|
435
|
+
/**
|
|
436
|
+
* - [git-commit Documentation](https://git-scm.com/docs/git-commit)
|
|
437
|
+
*/
|
|
391
438
|
commit(...args: (string | undefined)[]): Promise<string>;
|
|
439
|
+
/**
|
|
440
|
+
* - [git-tag Documentation](https://git-scm.com/docs/git-tag)
|
|
441
|
+
*/
|
|
392
442
|
tag(...args: (string | undefined)[]): Promise<string>;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
443
|
+
/**
|
|
444
|
+
* - [git-check-ignore Documentation](https://git-scm.com/docs/git-check-ignore)
|
|
445
|
+
*/
|
|
446
|
+
isIgnored(file: string): Promise<boolean>;
|
|
447
|
+
getCurrentBranchName(): Promise<string>;
|
|
448
|
+
/**
|
|
449
|
+
* `getTags` returns valid semver version tags in order of the commit history.
|
|
450
|
+
*
|
|
451
|
+
* Using `git log` to get the commit history, we then parse the tags from the
|
|
452
|
+
* commit details which is expected to be in the following format:
|
|
453
|
+
* @example
|
|
454
|
+
* ```txt
|
|
455
|
+
* commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: 1.0.2)
|
|
456
|
+
* Author: Username <username@example.com>
|
|
457
|
+
* Date: Sat Nov 9 15:00:00 2024 +0000
|
|
458
|
+
*
|
|
459
|
+
* chore(release): 1.2.3
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* - [Functionality extracted from the conventional-changelog - git-semver-tags project](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/index.js)
|
|
463
|
+
* - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
|
|
464
|
+
*/
|
|
465
|
+
getTags(tagPrefix: string | undefined): Promise<string[]>;
|
|
466
|
+
getLatestTag(tagPrefix: string | undefined): Promise<string>;
|
|
396
467
|
}
|
|
397
468
|
|
|
398
469
|
interface CurrentVersion {
|
|
@@ -415,4 +486,4 @@ declare function commitChanges(config: ForkConfig, logger: Logger, git: Git, fil
|
|
|
415
486
|
|
|
416
487
|
declare function tagChanges(config: ForkConfig, logger: Logger, git: Git, nextVersion: string): Promise<void>;
|
|
417
488
|
|
|
418
|
-
export { type Config, type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigSchema, type IFileManager, Logger, type NextVersion, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
|
|
489
|
+
export { type Config, type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigSchema, Git, type IFileManager, Logger, type NextVersion, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
|