fork-version 1.7.6 → 2.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 +47 -0
- package/README.md +10 -0
- package/dist/{chunk-4M7BP5DG.js → chunk-DZLU4REC.js} +992 -267
- package/dist/chunk-DZLU4REC.js.map +1 -0
- package/dist/{chunk-JAYAB33O.cjs → chunk-GQO6W4DN.cjs} +998 -272
- package/dist/chunk-GQO6W4DN.cjs.map +1 -0
- package/dist/cli.cjs +128 -129
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +118 -120
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +33 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +462 -57
- package/dist/index.d.ts +462 -57
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/dist/chunk-4M7BP5DG.js.map +0 -1
- package/dist/chunk-JAYAB33O.cjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,151 +1,149 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkGQO6W4DN_cjs = require('./chunk-GQO6W4DN.cjs');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var zod = require('zod');
|
|
8
|
-
var
|
|
9
|
-
var semver = require('semver');
|
|
8
|
+
var meow = require('meow');
|
|
10
9
|
|
|
10
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
cleanedTags.push(cleanedTag);
|
|
123
|
-
}
|
|
13
|
+
var meow__default = /*#__PURE__*/_interopDefault(meow);
|
|
14
|
+
|
|
15
|
+
var helperText = `Usage:
|
|
16
|
+
$ fork-version [options]
|
|
17
|
+
|
|
18
|
+
Commands:
|
|
19
|
+
--help Show this help message.
|
|
20
|
+
--version Show the current version of Fork-Version.
|
|
21
|
+
--inspect-version If set, Fork-Version will print the current project version and exit.
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
--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"]]
|
|
25
|
+
--glob, -G Glob pattern to match files to be updated.
|
|
26
|
+
--path, -P The path Fork-Version will run from. [Default: process.cwd()]
|
|
27
|
+
--changelog Name of the changelog file. [Default: "CHANGELOG.md"]
|
|
28
|
+
--header The header text for the changelog.
|
|
29
|
+
--tag-prefix Specify a prefix for the created tag. [Default: "v"]
|
|
30
|
+
--pre-release Mark this release as a pre-release.
|
|
31
|
+
--pre-release-tag Mark this release with a tagged pre-release. [Example: "alpha", "beta", "rc"]
|
|
32
|
+
--current-version If set, Fork-Version will use this version instead of trying to determine one.
|
|
33
|
+
--next-version If set, Fork-Version will attempt to update to this version, instead of incrementing using "conventional-commit".
|
|
34
|
+
--release-as Release as increments the version by the specified level. [Choices: "major", "minor", "patch"]
|
|
35
|
+
|
|
36
|
+
Flags:
|
|
37
|
+
--allow-multiple-versions Don't throw an error if multiple versions are found in the given files. [Default: true]
|
|
38
|
+
--commit-all Commit all changes, not just files updated by Fork-Version.
|
|
39
|
+
--changelog-all If this flag is set, all default commit types will be added to the changelog.
|
|
40
|
+
--debug Output debug information.
|
|
41
|
+
--dry-run No output will be written to disk or committed.
|
|
42
|
+
--silent Run without logging to the terminal.
|
|
43
|
+
--git-tag-fallback If unable to find a version in the given files, fallback and attempt to use the latest git tag. [Default: true]
|
|
44
|
+
--sign If true, git will sign the commit with the systems GPG key.
|
|
45
|
+
--verify If true, git will run user defined git hooks before committing.
|
|
46
|
+
|
|
47
|
+
To negate a flag you can prefix it with "no-", for example "--no-git-tag-fallback" will not fallback to the latest git tag.
|
|
48
|
+
|
|
49
|
+
Skip Steps:
|
|
50
|
+
--skip-bump Skip the version bump step.
|
|
51
|
+
--skip-changelog Skip updating the changelog.
|
|
52
|
+
--skip-commit Skip committing the changes.
|
|
53
|
+
--skip-tag Skip tagging the commit.
|
|
54
|
+
|
|
55
|
+
Conventional Changelog Overrides:
|
|
56
|
+
--commit-url-format Override the default commit URL format.
|
|
57
|
+
--compare-url-format Override the default compare URL format.
|
|
58
|
+
--issue-url-format Override the default issue URL format.
|
|
59
|
+
--user-url-format Override the default user URL format.
|
|
60
|
+
--release-commit-message-format Override the default release commit message format.
|
|
61
|
+
--release-message-suffix Add a suffix to the end of the release message.
|
|
62
|
+
|
|
63
|
+
Exit Codes:
|
|
64
|
+
0: Success
|
|
65
|
+
1: General Error
|
|
66
|
+
3: Config File Validation Error
|
|
67
|
+
|
|
68
|
+
Examples:
|
|
69
|
+
$ fork-version
|
|
70
|
+
Run fork-version in the current directory with default options.
|
|
71
|
+
|
|
72
|
+
$ fork-version --path ./packages/my-package
|
|
73
|
+
Run fork-version in the "./packages/my-package" directory.
|
|
74
|
+
|
|
75
|
+
$ fork-version --file package.json --file MyApi.csproj
|
|
76
|
+
Run fork-version and update the "package.json" and "MyApi.csproj" files.
|
|
77
|
+
|
|
78
|
+
$ fork-version --glob "*/package.json"
|
|
79
|
+
Run fork-version and update all "package.json" files in subdirectories.`;
|
|
80
|
+
function getCliArguments() {
|
|
81
|
+
return meow__default.default(helperText, {
|
|
82
|
+
importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)) }),
|
|
83
|
+
booleanDefault: void 0,
|
|
84
|
+
helpIndent: 0,
|
|
85
|
+
flags: {
|
|
86
|
+
// Commands
|
|
87
|
+
inspectVersion: { type: "boolean" },
|
|
88
|
+
// Options
|
|
89
|
+
files: { type: "string", isMultiple: true, aliases: ["file"], shortFlag: "F" },
|
|
90
|
+
glob: { type: "string", shortFlag: "G" },
|
|
91
|
+
path: { type: "string", shortFlag: "P" },
|
|
92
|
+
changelog: { type: "string" },
|
|
93
|
+
header: { type: "string" },
|
|
94
|
+
tagPrefix: { type: "string" },
|
|
95
|
+
preRelease: { type: "boolean" },
|
|
96
|
+
preReleaseTag: { type: "string" },
|
|
97
|
+
currentVersion: { type: "string" },
|
|
98
|
+
nextVersion: { type: "string" },
|
|
99
|
+
releaseAs: { type: "string", choices: ["major", "minor", "patch"] },
|
|
100
|
+
// Flags
|
|
101
|
+
allowMultipleVersions: { type: "boolean" },
|
|
102
|
+
commitAll: { type: "boolean" },
|
|
103
|
+
changelogAll: { type: "boolean" },
|
|
104
|
+
debug: { type: "boolean" },
|
|
105
|
+
dryRun: { type: "boolean" },
|
|
106
|
+
silent: { type: "boolean" },
|
|
107
|
+
gitTagFallback: { type: "boolean" },
|
|
108
|
+
sign: { type: "boolean" },
|
|
109
|
+
verify: { type: "boolean" },
|
|
110
|
+
// Skip Steps
|
|
111
|
+
skipBump: { type: "boolean" },
|
|
112
|
+
skipChangelog: { type: "boolean" },
|
|
113
|
+
skipCommit: { type: "boolean" },
|
|
114
|
+
skipTag: { type: "boolean" },
|
|
115
|
+
// Changelog Overrides
|
|
116
|
+
commitUrlFormat: { type: "string" },
|
|
117
|
+
compareUrlFormat: { type: "string" },
|
|
118
|
+
issueUrlFormat: { type: "string" },
|
|
119
|
+
userUrlFormat: { type: "string" },
|
|
120
|
+
releaseCommitMessageFormat: { type: "string" },
|
|
121
|
+
releaseMessageSuffix: { type: "string" }
|
|
124
122
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
123
|
+
}).flags;
|
|
124
|
+
}
|
|
128
125
|
|
|
129
126
|
// src/cli.ts
|
|
130
|
-
async function runFork() {
|
|
127
|
+
async function runFork(cliArguments2) {
|
|
131
128
|
const startTime = Date.now();
|
|
132
|
-
const config = await
|
|
133
|
-
const logger = new
|
|
134
|
-
const fileManager = new
|
|
135
|
-
const git = new Git(config);
|
|
129
|
+
const config = await chunkGQO6W4DN_cjs.getUserConfig(cliArguments2);
|
|
130
|
+
const logger = new chunkGQO6W4DN_cjs.Logger(config);
|
|
131
|
+
const fileManager = new chunkGQO6W4DN_cjs.FileManager(config, logger);
|
|
132
|
+
const git = new chunkGQO6W4DN_cjs.Git(config);
|
|
136
133
|
logger.log(`Running fork-version - ${(/* @__PURE__ */ new Date()).toUTCString()}`);
|
|
137
134
|
logger.warn(config.dryRun ? "[Dry Run] No changes will be written to disk.\n" : "");
|
|
138
|
-
const
|
|
139
|
-
const
|
|
135
|
+
const commits = await chunkGQO6W4DN_cjs.getCommitsSinceTag(config, logger, git);
|
|
136
|
+
const current = await chunkGQO6W4DN_cjs.getCurrentVersion(config, logger, git, fileManager, config.files);
|
|
137
|
+
const next = await chunkGQO6W4DN_cjs.getNextVersion(config, logger, commits.commits, current.version);
|
|
140
138
|
logger.log("Updating files: ");
|
|
141
139
|
for (const outFile of current.files) {
|
|
142
140
|
logger.log(` - ${outFile.path}`);
|
|
143
141
|
fileManager.write(outFile, next.version);
|
|
144
142
|
}
|
|
145
|
-
await
|
|
146
|
-
await
|
|
147
|
-
await
|
|
148
|
-
const branchName = await git.
|
|
143
|
+
await chunkGQO6W4DN_cjs.updateChangelog(config, logger, next.version);
|
|
144
|
+
await chunkGQO6W4DN_cjs.commitChanges(config, logger, git, current.files, next.version);
|
|
145
|
+
await chunkGQO6W4DN_cjs.tagChanges(config, logger, git, next.version);
|
|
146
|
+
const branchName = await git.getBranchName();
|
|
149
147
|
logger.log(
|
|
150
148
|
`
|
|
151
149
|
Run \`git push --follow-tags origin ${branchName}\` to push the changes and the tag.`
|
|
@@ -170,7 +168,8 @@ Run \`git push --follow-tags origin ${branchName}\` to push the changes and the
|
|
|
170
168
|
}
|
|
171
169
|
return result;
|
|
172
170
|
}
|
|
173
|
-
|
|
171
|
+
var cliArguments = getCliArguments();
|
|
172
|
+
runFork(cliArguments).catch((error) => {
|
|
174
173
|
if (error instanceof Error) {
|
|
175
174
|
if (error.cause instanceof zod.ZodError) {
|
|
176
175
|
console.error(error.message);
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/git.ts","../src/cli.ts"],"names":["execFile","semver","getUserConfig","Logger","FileManager","getCurrentVersion","getNextVersion","updateChangelog","commitChanges","tagChanges","writeFileSync","join","ZodError"],"mappings":";;;;;;;;;;;;;;AAIO,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,SAAY,GAAA,IAAA,CAAK,SAAU,CAAA,IAAA,CAAK,IAAI,CAAA;AACzC,IAAA,IAAA,CAAK,oBAAuB,GAAA,IAAA,CAAK,oBAAqB,CAAA,IAAA,CAAK,IAAI,CAAA;AAC/D,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAK,OAAQ,CAAA,IAAA,CAAK,IAAI,CAAA;AACrC,IAAA,IAAA,CAAK,YAAe,GAAA,IAAA,CAAK,YAAa,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA;AAChD,EAEA,MAAc,OAAQ,CAAA,OAAA,EAAiB,IAAiC,EAAA;AACvE,IAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,SAAA,EAAW,QAAa,KAAA;AAC3C,MAAAA,sBAA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ACf,CAAC,CAAA","file":"cli.cjs","sourcesContent":["import { execFile } from \"node:child_process\";\nimport semver from \"semver\";\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.isIgnored = this.isIgnored.bind(this);\n\t\tthis.getCurrentBranchName = this.getCurrentBranchName.bind(this);\n\t\tthis.getTags = this.getTags.bind(this);\n\t\tthis.getLatestTag = this.getLatestTag.bind(this);\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\tmaxBuffer: Infinity,\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\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 isIgnored(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 getCurrentBranchName(): Promise<string> {\n\t\treturn (await this.execGit(\"rev-parse\", [\"--abbrev-ref\", \"HEAD\"])).trim();\n\t}\n\n\t/**\n\t * `getTags` returns valid semver version tags in order of the commit history.\n\t *\n\t * Using `git log` to get the commit history, we then parse the tags from the\n\t * commit details which is expected to be in the following format:\n\t * @example\n\t * ```txt\n\t * commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: 1.0.2)\n\t * Author: Username <username@example.com>\n\t * Date: Sat Nov 9 15:00:00 2024 +0000\n\t *\n\t * chore(release): 1.2.3\n\t * ```\n\t *\n\t * - [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)\n\t * - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)\n\t */\n\tpublic async getTags(tagPrefix: string | undefined): Promise<string[]> {\n\t\tconst logOutput = await this.execGit(\"log\", [\"--decorate\", \"--no-color\", \"--date-order\"]);\n\n\t\t/**\n\t\t * Search for tags in the following formats:\n\t\t * @example \"tag: 1.2.3,\" or \"tag: 1.2.3)\"\n\t\t */\n\t\tconst TAG_REGEX = /tag:\\s*(.+?)[,)]/gi;\n\n\t\tconst tags: string[] = [];\n\t\tlet match: RegExpExecArray | null = null;\n\t\tlet tag: string;\n\t\tlet tagWithoutPrefix: string;\n\n\t\tfor (const logOutputLine of logOutput.split(\"\\n\")) {\n\t\t\twhile ((match = TAG_REGEX.exec(logOutputLine))) {\n\t\t\t\ttag = match[1];\n\n\t\t\t\tif (tagPrefix) {\n\t\t\t\t\tif (tag.startsWith(tagPrefix)) {\n\t\t\t\t\t\ttagWithoutPrefix = tag.replace(tagPrefix, \"\");\n\n\t\t\t\t\t\tif (semver.valid(tagWithoutPrefix)) {\n\t\t\t\t\t\t\ttags.push(tag);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (semver.valid(tag)) {\n\t\t\t\t\ttags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn tags;\n\t}\n\n\tpublic async getLatestTag(tagPrefix: string | undefined): Promise<string> {\n\t\tconst tags = await this.getTags(tagPrefix);\n\t\tif (!tags.length) return \"\";\n\n\t\tconst cleanedTags = [];\n\t\tfor (const tag of tags) {\n\t\t\tconst cleanedTag = semver.clean(tag.replace(new RegExp(`^${tagPrefix}`), \"\"));\n\t\t\tif (cleanedTag) {\n\t\t\t\tcleanedTags.push(cleanedTag);\n\t\t\t}\n\t\t}\n\n\t\treturn cleanedTags.sort(semver.rcompare)[0];\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 \"./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() {\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.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\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\t\tconsole.error(error);\n\t}\n\tprocess.exit(1);\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/config/cli-arguments.js","../src/cli.ts"],"names":["meow","cliArguments","getUserConfig","Logger","FileManager","Git","getCommitsSinceTag","getCurrentVersion","getNextVersion","updateChangelog","commitChanges","tagChanges","writeFileSync","join","ZodError"],"mappings":";;;;;;;;;;;;;;AAMO,IAAM,UAAa,GAAA,CAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA,2EAAA,CAAA;AAkEnB,SAAS,eAAkB,GAAA;AACjC,EAAA,OAAOA,sBAAK,UAAY,EAAA;AAAA,IACvB,UAAY,EAAA,oQAAA;AAAA,IACZ,cAAgB,EAAA,KAAA,CAAA;AAAA,IAChB,UAAY,EAAA,CAAA;AAAA,IACZ,KAAO,EAAA;AAAA;AAAA,MAEN,cAAA,EAAgB,EAAE,IAAA,EAAM,SAAU,EAAA;AAAA;AAAA,MAGlC,KAAA,EAAO,EAAE,IAAA,EAAM,QAAU,EAAA,UAAA,EAAY,IAAM,EAAA,OAAA,EAAS,CAAC,MAAM,CAAG,EAAA,SAAA,EAAW,GAAI,EAAA;AAAA,MAC7E,IAAM,EAAA,EAAE,IAAM,EAAA,QAAA,EAAU,WAAW,GAAI,EAAA;AAAA,MACvC,IAAM,EAAA,EAAE,IAAM,EAAA,QAAA,EAAU,WAAW,GAAI,EAAA;AAAA,MACvC,SAAA,EAAW,EAAE,IAAA,EAAM,QAAS,EAAA;AAAA,MAC5B,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAS,EAAA;AAAA,MACzB,SAAA,EAAW,EAAE,IAAA,EAAM,QAAS,EAAA;AAAA,MAC5B,UAAA,EAAY,EAAE,I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AK,MAAO,CAAA,IAAA,EAAM,gBAAgB,IAAK,CAAA,GAAA,EAAK,CAAiB,eAAA,CAAA,CAAA;AAAA,MAC7D,IAAK,CAAA,SAAA,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,iBAAiBC,YAAU,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.cjs","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 { getCommitsSinceTag } from \"./process/get-commits\";\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 commits = await getCommitsSinceTag(config, logger, git);\n\n\tconst current = await getCurrentVersion(config, logger, git, fileManager, config.files);\n\tconst next = await getNextVersion(config, logger, commits.commits, 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.getBranchName();\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"]}
|