fork-version 4.1.4 → 4.1.7
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 +24 -0
- package/README.md +7 -4
- package/dist/{chunk-I76EAKJC.js → chunk-5CZU5EA7.js} +170 -129
- package/dist/chunk-5CZU5EA7.js.map +1 -0
- package/dist/{chunk-CISRFIID.cjs → chunk-JYQTKLHN.cjs} +171 -131
- package/dist/chunk-JYQTKLHN.cjs.map +1 -0
- package/dist/cli.cjs +16 -15
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +10 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +19 -23
- package/dist/index.d.cts +73 -82
- package/dist/index.d.ts +73 -82
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CISRFIID.cjs.map +0 -1
- package/dist/chunk-I76EAKJC.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var child_process = require('child_process');
|
|
5
|
-
var
|
|
5
|
+
var semver5 = require('semver');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var promises = require('fs/promises');
|
|
8
8
|
var conventionalChangelogConfigSpec = require('conventional-changelog-config-spec');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var semver5__default = /*#__PURE__*/_interopDefault(semver5);
|
|
39
39
|
var conventionalChangelogConfigSpec__default = /*#__PURE__*/_interopDefault(conventionalChangelogConfigSpec);
|
|
40
40
|
var JoyCon__default = /*#__PURE__*/_interopDefault(JoyCon);
|
|
41
41
|
var cheerio__namespace = /*#__PURE__*/_interopNamespace(cheerio);
|
|
@@ -108,12 +108,13 @@ var ForkConfigSchema = zod.z.object({
|
|
|
108
108
|
* - `main` - Bumps the version, update files, generate changelog, commit, and tag.
|
|
109
109
|
* - `inspect-version` - Prints the current version and exits.
|
|
110
110
|
* - `inspect-tag` - Prints the current git tag and exits.
|
|
111
|
+
* - `inspect` - Prints the current version and git tag and exits.
|
|
111
112
|
* - `validate-config` - Validates the configuration and exits.
|
|
112
113
|
*
|
|
113
114
|
* @default "main"
|
|
114
115
|
*/
|
|
115
|
-
command: zod.z.literal(["main", "inspect-version", "inspect-tag", "validate-config"]).describe(
|
|
116
|
-
"The command to run. Can be one of: main, inspect-version, inspect-tag, validate-config. Defaults to main."
|
|
116
|
+
command: zod.z.literal(["main", "inspect", "inspect-version", "inspect-tag", "validate-config"]).describe(
|
|
117
|
+
"The command to run. Can be one of: main, inspect, inspect-version, inspect-tag, validate-config. Defaults to main."
|
|
117
118
|
),
|
|
118
119
|
/**
|
|
119
120
|
* If set, Fork-Version will print the current version and exit.
|
|
@@ -276,6 +277,11 @@ var ForkConfigSchema = zod.z.object({
|
|
|
276
277
|
* @default false
|
|
277
278
|
*/
|
|
278
279
|
verify: zod.z.boolean().describe("If true, git will run user defined git hooks before committing."),
|
|
280
|
+
/**
|
|
281
|
+
* Output result as JSON.
|
|
282
|
+
* @default false
|
|
283
|
+
*/
|
|
284
|
+
asJson: zod.z.boolean().describe("Output the result as JSON."),
|
|
279
285
|
// Skip Steps
|
|
280
286
|
//
|
|
281
287
|
/**
|
|
@@ -318,8 +324,11 @@ function escapeRegex(input) {
|
|
|
318
324
|
|
|
319
325
|
// src/services/git.ts
|
|
320
326
|
var Git = class {
|
|
327
|
+
#path;
|
|
328
|
+
#dryRun;
|
|
321
329
|
constructor(config) {
|
|
322
|
-
this
|
|
330
|
+
this.#path = config.path;
|
|
331
|
+
this.#dryRun = config.dryRun ?? false;
|
|
323
332
|
this.add = this.add.bind(this);
|
|
324
333
|
this.commit = this.commit.bind(this);
|
|
325
334
|
this.tag = this.tag.bind(this);
|
|
@@ -329,8 +338,6 @@ var Git = class {
|
|
|
329
338
|
this.getRemoteUrl = this.getRemoteUrl.bind(this);
|
|
330
339
|
this.getTags = this.getTags.bind(this);
|
|
331
340
|
this.getMostRecentTag = this.getMostRecentTag.bind(this);
|
|
332
|
-
this.getCleanedTags = this.getCleanedTags.bind(this);
|
|
333
|
-
this.getHighestSemverVersionFromTags = this.getHighestSemverVersionFromTags.bind(this);
|
|
334
341
|
this.getCommits = this.getCommits.bind(this);
|
|
335
342
|
}
|
|
336
343
|
async #execGit(command, args) {
|
|
@@ -339,7 +346,7 @@ var Git = class {
|
|
|
339
346
|
"git",
|
|
340
347
|
[command, ...args],
|
|
341
348
|
{
|
|
342
|
-
cwd: this
|
|
349
|
+
cwd: this.#path,
|
|
343
350
|
maxBuffer: Infinity
|
|
344
351
|
},
|
|
345
352
|
(error, stdout, stderr) => {
|
|
@@ -363,7 +370,7 @@ var Git = class {
|
|
|
363
370
|
* ```
|
|
364
371
|
*/
|
|
365
372
|
async add(...args) {
|
|
366
|
-
if (this
|
|
373
|
+
if (this.#dryRun) {
|
|
367
374
|
return "";
|
|
368
375
|
}
|
|
369
376
|
return this.#execGit("add", args.filter(Boolean));
|
|
@@ -379,7 +386,7 @@ var Git = class {
|
|
|
379
386
|
* ```
|
|
380
387
|
*/
|
|
381
388
|
async commit(...args) {
|
|
382
|
-
if (this
|
|
389
|
+
if (this.#dryRun) {
|
|
383
390
|
return "";
|
|
384
391
|
}
|
|
385
392
|
return this.#execGit("commit", args.filter(Boolean));
|
|
@@ -395,7 +402,7 @@ var Git = class {
|
|
|
395
402
|
* ```
|
|
396
403
|
*/
|
|
397
404
|
async tag(...args) {
|
|
398
|
-
if (this
|
|
405
|
+
if (this.#dryRun) {
|
|
399
406
|
return "";
|
|
400
407
|
}
|
|
401
408
|
return this.#execGit("tag", args.filter(Boolean));
|
|
@@ -504,18 +511,18 @@ var Git = class {
|
|
|
504
511
|
if (tagPrefix) {
|
|
505
512
|
if (tag.startsWith(tagPrefix)) {
|
|
506
513
|
const tagWithoutPrefix = tag.replace(new RegExp(`^${escapedTagPrefix}`), "");
|
|
507
|
-
if (
|
|
514
|
+
if (semver5__default.default.valid(tagWithoutPrefix)) {
|
|
508
515
|
tags.push(tag);
|
|
509
516
|
}
|
|
510
517
|
}
|
|
511
|
-
} else if (/^\d/.test(tag) &&
|
|
518
|
+
} else if (/^\d/.test(tag) && semver5__default.default.valid(tag)) {
|
|
512
519
|
tags.push(tag);
|
|
513
520
|
}
|
|
514
521
|
}
|
|
515
522
|
return tags;
|
|
516
523
|
}
|
|
517
524
|
/**
|
|
518
|
-
* Returns the
|
|
525
|
+
* Returns the most recent tag from the commit history, or `undefined` if no valid semver tags are found
|
|
519
526
|
*
|
|
520
527
|
* @example
|
|
521
528
|
* ```ts
|
|
@@ -526,40 +533,6 @@ var Git = class {
|
|
|
526
533
|
const tags = await this.getTags(tagPrefix);
|
|
527
534
|
return tags[0] || void 0;
|
|
528
535
|
}
|
|
529
|
-
/**
|
|
530
|
-
* Get cleaned semver tags, with any tag prefix's removed
|
|
531
|
-
*
|
|
532
|
-
* @example
|
|
533
|
-
* ```ts
|
|
534
|
-
* await git.getCleanedTags("v"); // ["1.2.3", "1.2.2", "1.2.1"]
|
|
535
|
-
* ```
|
|
536
|
-
*/
|
|
537
|
-
async getCleanedTags(tagPrefix) {
|
|
538
|
-
const tags = await this.getTags(tagPrefix);
|
|
539
|
-
const escapedTagPrefix = tagPrefix ? escapeRegex(tagPrefix) : void 0;
|
|
540
|
-
const cleanedTags = [];
|
|
541
|
-
for (const tag of tags) {
|
|
542
|
-
const tagWithoutPrefix = tag.replace(new RegExp(`^${escapedTagPrefix}`), "");
|
|
543
|
-
const cleanedTag = semver__default.default.clean(tagWithoutPrefix);
|
|
544
|
-
if (cleanedTag) {
|
|
545
|
-
cleanedTags.push(cleanedTag);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return cleanedTags;
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Get the highest semver version from git tags. This will return the highest
|
|
552
|
-
* semver version found for the given tag prefix, regardless of the commit date.
|
|
553
|
-
*
|
|
554
|
-
* @example
|
|
555
|
-
* ```ts
|
|
556
|
-
* await git.getHighestSemverVersionFromTags("v"); // "1.2.3"
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
async getHighestSemverVersionFromTags(tagPrefix) {
|
|
560
|
-
const cleanedTags = await this.getCleanedTags(tagPrefix);
|
|
561
|
-
return cleanedTags.sort(semver__default.default.rcompare)[0] || void 0;
|
|
562
|
-
}
|
|
563
536
|
/**
|
|
564
537
|
* Get commit history in a parsable format
|
|
565
538
|
*
|
|
@@ -714,6 +687,7 @@ All notable changes to this project will be documented in this file. See [fork-v
|
|
|
714
687
|
gitTagFallback: true,
|
|
715
688
|
sign: false,
|
|
716
689
|
verify: false,
|
|
690
|
+
asJson: false,
|
|
717
691
|
// Skip Steps
|
|
718
692
|
skipBump: false,
|
|
719
693
|
skipChangelog: false,
|
|
@@ -723,11 +697,8 @@ All notable changes to this project will be documented in this file. See [fork-v
|
|
|
723
697
|
};
|
|
724
698
|
|
|
725
699
|
// src/config/detect-git-host.ts
|
|
726
|
-
async function detectGitHost(
|
|
727
|
-
const remoteUrl = await new Git({
|
|
728
|
-
path: cwd,
|
|
729
|
-
dryRun: false
|
|
730
|
-
}).getRemoteUrl();
|
|
700
|
+
async function detectGitHost(path) {
|
|
701
|
+
const remoteUrl = await new Git({ path }).getRemoteUrl();
|
|
731
702
|
if (remoteUrl.startsWith("https://") && remoteUrl.includes("@dev.azure.com/")) {
|
|
732
703
|
const match = /^https:\/\/(?<atorganisation>.*?)@dev.azure.com\/(?<organisation>.*?)\/(?<project>.*?)\/_git\/(?<repository>.*?)(?:\.git)?$/.exec(
|
|
733
704
|
remoteUrl
|
|
@@ -871,33 +842,34 @@ async function getUserConfig(cliArguments) {
|
|
|
871
842
|
};
|
|
872
843
|
}
|
|
873
844
|
var Logger = class {
|
|
845
|
+
#silent;
|
|
846
|
+
#debug;
|
|
874
847
|
constructor(config) {
|
|
875
|
-
this
|
|
848
|
+
this.#silent = config.silent ?? false;
|
|
849
|
+
this.#debug = config.debug ?? false;
|
|
876
850
|
this.log = this.log.bind(this);
|
|
877
851
|
this.warn = this.warn.bind(this);
|
|
878
852
|
this.error = this.error.bind(this);
|
|
879
853
|
this.debug = this.debug.bind(this);
|
|
880
854
|
this.skipping = this.skipping.bind(this);
|
|
881
|
-
this.disableLogs = this.config.silent;
|
|
882
855
|
}
|
|
883
|
-
disableLogs = false;
|
|
884
856
|
log(message) {
|
|
885
|
-
if (!this
|
|
857
|
+
if (!this.#silent) {
|
|
886
858
|
console.log(message);
|
|
887
859
|
}
|
|
888
860
|
}
|
|
889
861
|
warn(message) {
|
|
890
|
-
if (!this
|
|
862
|
+
if (!this.#silent) {
|
|
891
863
|
console.warn(util.styleText("yellowBright", message));
|
|
892
864
|
}
|
|
893
865
|
}
|
|
894
866
|
error(message) {
|
|
895
|
-
if (!this
|
|
867
|
+
if (!this.#silent) {
|
|
896
868
|
console.error(util.styleText("redBright", message));
|
|
897
869
|
}
|
|
898
870
|
}
|
|
899
871
|
debug(message, ...optionalParams) {
|
|
900
|
-
if (this
|
|
872
|
+
if (!this.#silent && this.#debug) {
|
|
901
873
|
console.debug(util.styleText("cyanBright", message));
|
|
902
874
|
if (optionalParams.length > 0) {
|
|
903
875
|
console.debug(...optionalParams);
|
|
@@ -905,7 +877,7 @@ var Logger = class {
|
|
|
905
877
|
}
|
|
906
878
|
}
|
|
907
879
|
skipping(message) {
|
|
908
|
-
if (!this
|
|
880
|
+
if (!this.#silent) {
|
|
909
881
|
console.log(util.styleText("magenta", message));
|
|
910
882
|
}
|
|
911
883
|
}
|
|
@@ -1233,66 +1205,6 @@ ${JSON.stringify(config, null, 2)}
|
|
|
1233
1205
|
\u2705 Configuration is valid.
|
|
1234
1206
|
`);
|
|
1235
1207
|
}
|
|
1236
|
-
async function getCurrentVersion(config, logger, git, fileManager, filesToUpdate) {
|
|
1237
|
-
const files = [];
|
|
1238
|
-
const versions = /* @__PURE__ */ new Set();
|
|
1239
|
-
for (const file of filesToUpdate) {
|
|
1240
|
-
if (await git.isIgnored(file)) {
|
|
1241
|
-
logger.debug(`[Git Ignored] ${file}`);
|
|
1242
|
-
continue;
|
|
1243
|
-
}
|
|
1244
|
-
const fileState = fileManager.read(file);
|
|
1245
|
-
if (fileState) {
|
|
1246
|
-
files.push(fileState);
|
|
1247
|
-
if (!config.currentVersion) {
|
|
1248
|
-
versions.add(fileState.version);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
if (config.currentVersion) {
|
|
1253
|
-
versions.add(config.currentVersion);
|
|
1254
|
-
}
|
|
1255
|
-
if (versions.size === 0 && config.gitTagFallback) {
|
|
1256
|
-
const version = await git.getHighestSemverVersionFromTags(config.tagPrefix);
|
|
1257
|
-
if (version) {
|
|
1258
|
-
logger.warn(`Using latest git tag as fallback`);
|
|
1259
|
-
versions.add(version);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
if (versions.size === 0) {
|
|
1263
|
-
throw new Error("Unable to find current version");
|
|
1264
|
-
} else if (versions.size > 1) {
|
|
1265
|
-
if (!config.allowMultipleVersions) {
|
|
1266
|
-
throw new Error("Found multiple versions");
|
|
1267
|
-
}
|
|
1268
|
-
logger.warn(
|
|
1269
|
-
`Found multiple versions (${Array.from(versions).join(", ")}), using the higher semver version`
|
|
1270
|
-
);
|
|
1271
|
-
}
|
|
1272
|
-
const currentVersion = semver__default.default.rsort(Array.from(versions))[0];
|
|
1273
|
-
logger.log(`Current version: ${currentVersion}`);
|
|
1274
|
-
return {
|
|
1275
|
-
files,
|
|
1276
|
-
version: currentVersion
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
// src/commands/inspect-version.ts
|
|
1281
|
-
async function inspectVersion(config, logger, fileManager, git) {
|
|
1282
|
-
let foundVersion = "";
|
|
1283
|
-
try {
|
|
1284
|
-
const currentVersion = await getCurrentVersion(config, logger, git, fileManager, config.files);
|
|
1285
|
-
if (currentVersion) foundVersion = currentVersion.version;
|
|
1286
|
-
} catch {
|
|
1287
|
-
}
|
|
1288
|
-
console.log(foundVersion);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
// src/commands/inspect-tag.ts
|
|
1292
|
-
async function inspectTag(config, git) {
|
|
1293
|
-
const tag = await git.getMostRecentTag(config.tagPrefix);
|
|
1294
|
-
console.log(tag ?? "");
|
|
1295
|
-
}
|
|
1296
1208
|
|
|
1297
1209
|
// src/utils/trim-string-array.ts
|
|
1298
1210
|
function trimStringArray(array) {
|
|
@@ -1756,6 +1668,12 @@ function filterRevertedCommits(parsedCommits) {
|
|
|
1756
1668
|
}
|
|
1757
1669
|
return commitsWithoutReverts;
|
|
1758
1670
|
}
|
|
1671
|
+
function cleanTag(tag, tagPrefix) {
|
|
1672
|
+
if (!tag) return void 0;
|
|
1673
|
+
const escapedTagPrefix = tagPrefix ? escapeRegex(tagPrefix) : void 0;
|
|
1674
|
+
const tagWithoutPrefix = escapedTagPrefix ? tag.replace(new RegExp(`^${escapedTagPrefix}`), "") : tag;
|
|
1675
|
+
return semver5__default.default.clean(tagWithoutPrefix) ?? void 0;
|
|
1676
|
+
}
|
|
1759
1677
|
|
|
1760
1678
|
// src/process/get-commits.ts
|
|
1761
1679
|
async function getCommitsSinceTag(config, logger, git) {
|
|
@@ -1779,14 +1697,130 @@ async function getCommitsSinceTag(config, logger, git) {
|
|
|
1779
1697
|
);
|
|
1780
1698
|
return {
|
|
1781
1699
|
latestTag,
|
|
1700
|
+
latestTagVersion: cleanTag(latestTag, config.tagPrefix),
|
|
1782
1701
|
commits: filteredCommits
|
|
1783
1702
|
};
|
|
1784
1703
|
}
|
|
1704
|
+
async function getCurrentVersion(config, logger, git, fileManager, filesToUpdate, latestTagVersion) {
|
|
1705
|
+
const files = [];
|
|
1706
|
+
const versions = /* @__PURE__ */ new Set();
|
|
1707
|
+
for (const file of filesToUpdate) {
|
|
1708
|
+
if (await git.isIgnored(file)) {
|
|
1709
|
+
logger.debug(`[Git Ignored] ${file}`);
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
const fileState = fileManager.read(file);
|
|
1713
|
+
if (fileState) {
|
|
1714
|
+
files.push(fileState);
|
|
1715
|
+
if (!config.currentVersion) {
|
|
1716
|
+
versions.add(fileState.version);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
if (config.currentVersion) {
|
|
1721
|
+
versions.add(config.currentVersion);
|
|
1722
|
+
}
|
|
1723
|
+
if (versions.size === 0 && config.gitTagFallback && latestTagVersion) {
|
|
1724
|
+
logger.warn(`Using latest git tag as fallback`);
|
|
1725
|
+
versions.add(latestTagVersion);
|
|
1726
|
+
}
|
|
1727
|
+
if (versions.size === 0) {
|
|
1728
|
+
throw new Error("Unable to find current version");
|
|
1729
|
+
} else if (versions.size > 1) {
|
|
1730
|
+
if (!config.allowMultipleVersions) {
|
|
1731
|
+
throw new Error("Found multiple versions");
|
|
1732
|
+
}
|
|
1733
|
+
logger.warn(
|
|
1734
|
+
`Found multiple versions (${Array.from(versions).join(", ")}), using the higher semver version`
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
const currentVersion = semver5__default.default.rsort(Array.from(versions))[0];
|
|
1738
|
+
logger.log(`Current version: ${currentVersion}`);
|
|
1739
|
+
return {
|
|
1740
|
+
files,
|
|
1741
|
+
version: currentVersion
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
async function inspect(config, logger, fileManager, git) {
|
|
1745
|
+
let latestTag = "";
|
|
1746
|
+
let latestVersion = "";
|
|
1747
|
+
try {
|
|
1748
|
+
const commits = await getCommitsSinceTag(config, logger, git);
|
|
1749
|
+
if (commits.latestTag) {
|
|
1750
|
+
latestTag = commits.latestTag;
|
|
1751
|
+
latestVersion = commits.latestTagVersion ?? "";
|
|
1752
|
+
}
|
|
1753
|
+
const currentVersion = await getCurrentVersion(
|
|
1754
|
+
config,
|
|
1755
|
+
logger,
|
|
1756
|
+
git,
|
|
1757
|
+
fileManager,
|
|
1758
|
+
config.files,
|
|
1759
|
+
latestVersion
|
|
1760
|
+
);
|
|
1761
|
+
if (currentVersion.version) {
|
|
1762
|
+
latestVersion = currentVersion.version;
|
|
1763
|
+
}
|
|
1764
|
+
} catch {
|
|
1765
|
+
}
|
|
1766
|
+
if (!latestVersion && !latestTag) {
|
|
1767
|
+
console.error(
|
|
1768
|
+
util.styleText(
|
|
1769
|
+
"yellowBright",
|
|
1770
|
+
"No version found. Make sure you have at least one tag in your repository."
|
|
1771
|
+
)
|
|
1772
|
+
);
|
|
1773
|
+
process.exit(1);
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
switch (config.command) {
|
|
1777
|
+
case "inspect-version": {
|
|
1778
|
+
console.log(
|
|
1779
|
+
config.asJson ? JSON.stringify(
|
|
1780
|
+
{
|
|
1781
|
+
version: latestVersion
|
|
1782
|
+
},
|
|
1783
|
+
null,
|
|
1784
|
+
2
|
|
1785
|
+
) : latestVersion
|
|
1786
|
+
);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
case "inspect-tag": {
|
|
1790
|
+
console.log(
|
|
1791
|
+
config.asJson ? JSON.stringify(
|
|
1792
|
+
{
|
|
1793
|
+
tag: latestTag
|
|
1794
|
+
},
|
|
1795
|
+
null,
|
|
1796
|
+
2
|
|
1797
|
+
) : latestTag
|
|
1798
|
+
);
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
default: {
|
|
1802
|
+
console.log(
|
|
1803
|
+
config.asJson ? JSON.stringify(
|
|
1804
|
+
{
|
|
1805
|
+
version: latestVersion,
|
|
1806
|
+
tag: latestTag
|
|
1807
|
+
},
|
|
1808
|
+
null,
|
|
1809
|
+
2
|
|
1810
|
+
) : `
|
|
1811
|
+
Version: ${latestVersion}
|
|
1812
|
+
Tag: ${latestTag}
|
|
1813
|
+
`.trim()
|
|
1814
|
+
);
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1785
1819
|
function getPriority(type) {
|
|
1786
1820
|
return ["patch", "minor", "major"].indexOf(type ?? "");
|
|
1787
1821
|
}
|
|
1788
1822
|
function getVersionType(version) {
|
|
1789
|
-
const parseVersion =
|
|
1823
|
+
const parseVersion = semver5__default.default.parse(version);
|
|
1790
1824
|
if (parseVersion?.major) {
|
|
1791
1825
|
return "major";
|
|
1792
1826
|
} else if (parseVersion?.minor) {
|
|
@@ -1800,7 +1834,7 @@ function getReleaseType(releaseType, currentVersion, preReleaseTag) {
|
|
|
1800
1834
|
if (!preReleaseTag) {
|
|
1801
1835
|
return releaseType;
|
|
1802
1836
|
}
|
|
1803
|
-
const currentVersionsIsPreRelease = Array.isArray(
|
|
1837
|
+
const currentVersionsIsPreRelease = Array.isArray(semver5__default.default.prerelease(currentVersion));
|
|
1804
1838
|
if (currentVersionsIsPreRelease) {
|
|
1805
1839
|
const currentReleaseType = getVersionType(currentVersion);
|
|
1806
1840
|
if (currentReleaseType === releaseType || getPriority(currentReleaseType) > getPriority(releaseType)) {
|
|
@@ -1819,7 +1853,7 @@ async function getNextVersion(config, logger, commits, currentVersion) {
|
|
|
1819
1853
|
};
|
|
1820
1854
|
}
|
|
1821
1855
|
if (config.nextVersion) {
|
|
1822
|
-
if (!
|
|
1856
|
+
if (!semver5__default.default.valid(config.nextVersion)) {
|
|
1823
1857
|
throw new Error(`Invalid Version: ${config.nextVersion}`);
|
|
1824
1858
|
}
|
|
1825
1859
|
logger.log(`Next version: ${config.nextVersion}`);
|
|
@@ -1827,7 +1861,7 @@ async function getNextVersion(config, logger, commits, currentVersion) {
|
|
|
1827
1861
|
version: config.nextVersion
|
|
1828
1862
|
};
|
|
1829
1863
|
}
|
|
1830
|
-
const isPreMajor =
|
|
1864
|
+
const isPreMajor = semver5__default.default.lt(currentVersion, "1.0.0");
|
|
1831
1865
|
let releaseType = "patch";
|
|
1832
1866
|
const changes = {
|
|
1833
1867
|
major: 0,
|
|
@@ -1877,7 +1911,7 @@ async function getNextVersion(config, logger, commits, currentVersion) {
|
|
|
1877
1911
|
}
|
|
1878
1912
|
}
|
|
1879
1913
|
const releaseTypeOrPreRelease = getReleaseType(releaseType, currentVersion, config.preRelease);
|
|
1880
|
-
const nextVersion =
|
|
1914
|
+
const nextVersion = semver5__default.default.inc(
|
|
1881
1915
|
currentVersion,
|
|
1882
1916
|
releaseTypeOrPreRelease,
|
|
1883
1917
|
typeof config.preRelease === "string" ? config.preRelease : ""
|
|
@@ -2029,7 +2063,14 @@ async function main(config, logger, fileManager, git) {
|
|
|
2029
2063
|
logger.log(`Running fork-version - ${(/* @__PURE__ */ new Date()).toUTCString()}`);
|
|
2030
2064
|
logger.warn(config.dryRun ? "[Dry Run] No changes will be written to disk.\n" : "");
|
|
2031
2065
|
const commits = await getCommitsSinceTag(config, logger, git);
|
|
2032
|
-
const current = await getCurrentVersion(
|
|
2066
|
+
const current = await getCurrentVersion(
|
|
2067
|
+
config,
|
|
2068
|
+
logger,
|
|
2069
|
+
git,
|
|
2070
|
+
fileManager,
|
|
2071
|
+
config.files,
|
|
2072
|
+
commits.latestTagVersion
|
|
2073
|
+
);
|
|
2033
2074
|
const next = await getNextVersion(config, logger, commits.commits, current.version);
|
|
2034
2075
|
logger.log("Updating files: ");
|
|
2035
2076
|
for (const outFile of current.files) {
|
|
@@ -2059,11 +2100,10 @@ exports.getCommitsSinceTag = getCommitsSinceTag;
|
|
|
2059
2100
|
exports.getCurrentVersion = getCurrentVersion;
|
|
2060
2101
|
exports.getNextVersion = getNextVersion;
|
|
2061
2102
|
exports.getUserConfig = getUserConfig;
|
|
2062
|
-
exports.
|
|
2063
|
-
exports.inspectVersion = inspectVersion;
|
|
2103
|
+
exports.inspect = inspect;
|
|
2064
2104
|
exports.main = main;
|
|
2065
2105
|
exports.tagChanges = tagChanges;
|
|
2066
2106
|
exports.updateChangelog = updateChangelog;
|
|
2067
2107
|
exports.validateConfig = validateConfig;
|
|
2068
|
-
//# sourceMappingURL=chunk-
|
|
2069
|
-
//# sourceMappingURL=chunk-
|
|
2108
|
+
//# sourceMappingURL=chunk-JYQTKLHN.cjs.map
|
|
2109
|
+
//# sourceMappingURL=chunk-JYQTKLHN.cjs.map
|