fireflyy 4.0.0-dev.644fea9 → 4.0.0-dev.df58d2b
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/dist/commit-analysis.service-CtIh7eez.js +503 -0
- package/dist/{dry-run-BfYCtldz.js → dry-run-korHDlWr.js} +1 -1
- package/dist/{filesystem.service-9VHML130.js → filesystem.service-BcQtLzfl.js} +3 -3
- package/dist/{git.service-CACrfCW8.js → git.service-D1Mf6LZ0.js} +2 -2
- package/dist/main.js +2 -2
- package/dist/{package-json.service-DACeZzRg.js → package-json.service-BKbXaHXQ.js} +2 -2
- package/dist/{program-CHc5t2Xm.js → program-CW3hIbzh.js} +92 -18
- package/dist/{result.constructors-C9M1MP3_.js → result.constructors-D9jmQ0uj.js} +5 -1
- package/dist/{result.utilities-DC5shlhT.js → result.utilities-CdBL5noX.js} +1 -1
- package/dist/{schema.utilities-BGd9t1wm.js → schema.utilities-BOJqWEey.js} +1 -1
- package/dist/version-bumper.service-CvPx7EZx.js +318 -0
- package/dist/version-strategy.service-BO_7MY5O.js +4 -0
- package/dist/version-strategy.service-vh5KeNCA.js +258 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as RuntimeEnv, t as logger } from "./main.js";
|
|
2
|
-
import { _ as
|
|
3
|
-
import { n as wrapPromise, r as zip3Async, t as ensureNotAsync } from "./result.utilities-
|
|
4
|
-
import { n as parseSchema, t as formatZodErrors } from "./schema.utilities-
|
|
2
|
+
import { _ as notFoundError, a as conflictErrAsync, b as wrapErrorMessage, c as invalidErrAsync, d as validationErr, f as validationErrAsync, h as failedError, i as FireflyOkAsync, l as notFoundErrAsync, n as FireflyErrAsync, p as conflictError, r as FireflyOk, s as invalidErr, t as FireflyErr, u as timeoutErrAsync, y as validationError } from "./result.constructors-D9jmQ0uj.js";
|
|
3
|
+
import { n as wrapPromise, r as zip3Async, t as ensureNotAsync } from "./result.utilities-CdBL5noX.js";
|
|
4
|
+
import { n as parseSchema, t as formatZodErrors } from "./schema.utilities-BOJqWEey.js";
|
|
5
5
|
import { LogLevels } from "consola";
|
|
6
6
|
import { colors } from "consola/utils";
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -1003,9 +1003,10 @@ function createBumpExecutionGroup() {
|
|
|
1003
1003
|
*/
|
|
1004
1004
|
function shouldSkipBumpStrategy(ctx) {
|
|
1005
1005
|
const { skipBump, releaseType, bumpStrategy } = ctx.config;
|
|
1006
|
+
const { selectedReleaseType, selectedBumpStrategy } = ctx.data;
|
|
1006
1007
|
if (skipBump) return true;
|
|
1007
|
-
if (releaseType) return true;
|
|
1008
|
-
if (!bumpStrategy) return true;
|
|
1008
|
+
if (releaseType || selectedReleaseType) return true;
|
|
1009
|
+
if (!Boolean(bumpStrategy || selectedBumpStrategy)) return true;
|
|
1009
1010
|
return false;
|
|
1010
1011
|
}
|
|
1011
1012
|
/**
|
|
@@ -1013,9 +1014,11 @@ function shouldSkipBumpStrategy(ctx) {
|
|
|
1013
1014
|
*/
|
|
1014
1015
|
function getSkipReason(ctx) {
|
|
1015
1016
|
const { skipBump, releaseType, bumpStrategy } = ctx.config;
|
|
1017
|
+
const { selectedReleaseType, selectedBumpStrategy } = ctx.data;
|
|
1016
1018
|
if (skipBump) return "skipBump is enabled";
|
|
1017
|
-
if (releaseType) return `releaseType already set to '${releaseType}'`;
|
|
1018
|
-
if (
|
|
1019
|
+
if (releaseType) return `releaseType already set to '${releaseType}' (config)`;
|
|
1020
|
+
if (selectedReleaseType) return `releaseType already set to '${selectedReleaseType}' (data)`;
|
|
1021
|
+
if (!Boolean(bumpStrategy || selectedBumpStrategy)) return "no bumpStrategy configured";
|
|
1019
1022
|
return "unknown reason";
|
|
1020
1023
|
}
|
|
1021
1024
|
function createDelegateBumpStrategyTask() {
|
|
@@ -1034,7 +1037,10 @@ function createDelegateBumpStrategyTask() {
|
|
|
1034
1037
|
//#endregion
|
|
1035
1038
|
//#region src/commands/release/tasks/determine-automatic-bump.task.ts
|
|
1036
1039
|
function createDetermineAutomaticBump() {
|
|
1037
|
-
return TaskBuilder.create("determine-automatic-bump").description("Automatically determines the version bump from commit messages").dependsOn("delegate-bump-strategy").skipWhenWithReason((ctx) =>
|
|
1040
|
+
return TaskBuilder.create("determine-automatic-bump").description("Automatically determines the version bump from commit messages").dependsOn("delegate-bump-strategy").skipWhenWithReason((ctx) => {
|
|
1041
|
+
const bumpStrategy = ctx.data.selectedBumpStrategy ?? ctx.config.bumpStrategy;
|
|
1042
|
+
return ctx.config.skipBump || bumpStrategy !== BUMP_STRATEGY_AUTO;
|
|
1043
|
+
}, "Skipped: skipBump enabled or bumpStrategy is not 'auto'").execute((ctx) => {
|
|
1038
1044
|
logger.info("determine-automatic-bump");
|
|
1039
1045
|
return FireflyOkAsync(ctx);
|
|
1040
1046
|
}).build();
|
|
@@ -1042,17 +1048,61 @@ function createDetermineAutomaticBump() {
|
|
|
1042
1048
|
|
|
1043
1049
|
//#endregion
|
|
1044
1050
|
//#region src/commands/release/tasks/prompt-bump-strategy.task.ts
|
|
1051
|
+
const BUMP_STRATEGIES = [{
|
|
1052
|
+
label: "Automatic Bump",
|
|
1053
|
+
value: BUMP_STRATEGY_AUTO,
|
|
1054
|
+
hint: "Determines the next version based on conventional commits history"
|
|
1055
|
+
}, {
|
|
1056
|
+
label: "Manual Bump",
|
|
1057
|
+
value: BUMP_STRATEGY_MANUAL,
|
|
1058
|
+
hint: "Manually specify the next version"
|
|
1059
|
+
}];
|
|
1060
|
+
const VALID_STRATEGY_VALUES = BUMP_STRATEGIES.map((s) => s.value);
|
|
1061
|
+
/**
|
|
1062
|
+
* Validates that the selected strategy is one of the allowed values.
|
|
1063
|
+
*
|
|
1064
|
+
* @param strategy The selected version bump strategy.
|
|
1065
|
+
* @returns A FireflyResult indicating success or failure of validation.
|
|
1066
|
+
*/
|
|
1067
|
+
function validateStrategy(strategy) {
|
|
1068
|
+
if (!VALID_STRATEGY_VALUES.includes(strategy)) return invalidErr({ message: `Invalid version bump strategy: ${strategy}` });
|
|
1069
|
+
return FireflyOk(strategy);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Prompts the user to select a bump strategy using the logger's prompt API.
|
|
1073
|
+
*/
|
|
1074
|
+
function promptBumpStrategy() {
|
|
1075
|
+
const defaultStrategy = BUMP_STRATEGIES[0];
|
|
1076
|
+
if (!defaultStrategy) return notFoundErrAsync({ message: "No default version bump strategy found" });
|
|
1077
|
+
logger.verbose("PromptBumpStrategyTask: Prompting user for version bump strategy.");
|
|
1078
|
+
const prompt = logger.prompt("Select version bump strategy", {
|
|
1079
|
+
type: "select",
|
|
1080
|
+
options: BUMP_STRATEGIES,
|
|
1081
|
+
initial: defaultStrategy.value,
|
|
1082
|
+
cancel: "reject"
|
|
1083
|
+
});
|
|
1084
|
+
if (logger.level !== LogLevels.verbose) logger.log("");
|
|
1085
|
+
return wrapPromise(prompt).andTee(() => {
|
|
1086
|
+
if (logger.level === LogLevels.verbose) logger.log("");
|
|
1087
|
+
}).andThen((selected) => {
|
|
1088
|
+
if (!selected || selected === "") return invalidErrAsync({ message: "No version bump strategy selected" });
|
|
1089
|
+
const validationResult = validateStrategy(selected);
|
|
1090
|
+
if (validationResult.isErr()) return FireflyErrAsync(validationResult.error);
|
|
1091
|
+
logger.verbose(`PromptBumpStrategyTask: Selected version bump strategy: '${selected}'`);
|
|
1092
|
+
return FireflyOkAsync(selected);
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1045
1095
|
function createPromptBumpStrategyTask() {
|
|
1046
|
-
return TaskBuilder.create("prompt-bump-strategy").description("Prompts the user for a version bump strategy").dependsOn("initialize-release-version").skipWhenWithReason((ctx) => ctx.config.skipBump || Boolean(ctx.config.bumpStrategy) || Boolean(ctx.config.releaseType), "Skipped: skipBump enabled, or bumpStrategy/releaseType already specified").execute((ctx) =>
|
|
1047
|
-
logger.info("prompt-bump-strategy");
|
|
1048
|
-
return FireflyOkAsync(ctx);
|
|
1049
|
-
}).build();
|
|
1096
|
+
return TaskBuilder.create("prompt-bump-strategy").description("Prompts the user for a version bump strategy").dependsOn("initialize-release-version").skipWhenWithReason((ctx) => ctx.config.skipBump || Boolean(ctx.config.bumpStrategy) || Boolean(ctx.config.releaseType), "Skipped: skipBump enabled, or bumpStrategy/releaseType already specified").execute((ctx) => promptBumpStrategy().andThen((strategy) => FireflyOkAsync(ctx.fork("selectedBumpStrategy", strategy)))).build();
|
|
1050
1097
|
}
|
|
1051
1098
|
|
|
1052
1099
|
//#endregion
|
|
1053
1100
|
//#region src/commands/release/tasks/prompt-manual-bump.task.ts
|
|
1054
1101
|
function createPromptManualVersionTask() {
|
|
1055
|
-
return TaskBuilder.create("prompt-manual-version").description("Prompts the user for a manual version bump selections").dependsOn("delegate-bump-strategy").skipWhenWithReason((ctx) =>
|
|
1102
|
+
return TaskBuilder.create("prompt-manual-version").description("Prompts the user for a manual version bump selections").dependsOn("delegate-bump-strategy").skipWhenWithReason((ctx) => {
|
|
1103
|
+
const bumpStrategy = ctx.data.selectedBumpStrategy ?? ctx.config.bumpStrategy;
|
|
1104
|
+
return ctx.config.skipBump || bumpStrategy !== BUMP_STRATEGY_MANUAL;
|
|
1105
|
+
}, "Skipped: skipBump enabled or bumpStrategy is not 'manual'").execute((ctx) => {
|
|
1056
1106
|
logger.info("prompt-manual-version");
|
|
1057
1107
|
return FireflyOkAsync(ctx);
|
|
1058
1108
|
}).build();
|
|
@@ -1611,21 +1661,41 @@ function defineService(definition) {
|
|
|
1611
1661
|
*/
|
|
1612
1662
|
const SERVICE_DEFINITIONS = {
|
|
1613
1663
|
fs: defineService({ factory: async ({ basePath }) => {
|
|
1614
|
-
const { createFileSystemService } = await import("./filesystem.service-
|
|
1664
|
+
const { createFileSystemService } = await import("./filesystem.service-BcQtLzfl.js");
|
|
1615
1665
|
return createFileSystemService(basePath);
|
|
1616
1666
|
} }),
|
|
1617
1667
|
packageJson: defineService({
|
|
1618
1668
|
dependencies: ["fs"],
|
|
1619
1669
|
factory: async ({ getService }) => {
|
|
1620
1670
|
const fs = await getService("fs");
|
|
1621
|
-
const { createPackageJsonService } = await import("./package-json.service-
|
|
1671
|
+
const { createPackageJsonService } = await import("./package-json.service-BKbXaHXQ.js");
|
|
1622
1672
|
return createPackageJsonService(fs);
|
|
1623
1673
|
}
|
|
1624
1674
|
}),
|
|
1625
1675
|
git: defineService({ factory: async ({ basePath }) => {
|
|
1626
|
-
const { createGitService } = await import("./git.service-
|
|
1676
|
+
const { createGitService } = await import("./git.service-D1Mf6LZ0.js");
|
|
1627
1677
|
return createGitService(basePath);
|
|
1628
|
-
} })
|
|
1678
|
+
} }),
|
|
1679
|
+
versionBumper: defineService({ factory: async () => {
|
|
1680
|
+
const { createVersionBumperService } = await import("./version-bumper.service-CvPx7EZx.js");
|
|
1681
|
+
return createVersionBumperService();
|
|
1682
|
+
} }),
|
|
1683
|
+
versionStrategy: defineService({
|
|
1684
|
+
dependencies: ["versionBumper"],
|
|
1685
|
+
factory: async ({ getService }) => {
|
|
1686
|
+
const versionBumper = await getService("versionBumper");
|
|
1687
|
+
const { createVersionStrategyService } = await import("./version-strategy.service-BO_7MY5O.js");
|
|
1688
|
+
return createVersionStrategyService(versionBumper);
|
|
1689
|
+
}
|
|
1690
|
+
}),
|
|
1691
|
+
commitAnalysis: defineService({
|
|
1692
|
+
dependencies: ["git"],
|
|
1693
|
+
factory: async ({ getService }) => {
|
|
1694
|
+
const git = await getService("git");
|
|
1695
|
+
const { createCommitAnalysisService } = await import("./commit-analysis.service-CtIh7eez.js");
|
|
1696
|
+
return createCommitAnalysisService(git);
|
|
1697
|
+
}
|
|
1698
|
+
})
|
|
1629
1699
|
};
|
|
1630
1700
|
/**
|
|
1631
1701
|
* Array of all service keys for iteration
|
|
@@ -2264,7 +2334,11 @@ var WorkflowExecutor = class {
|
|
|
2264
2334
|
const startTime = /* @__PURE__ */ new Date();
|
|
2265
2335
|
const executedTaskIds = [];
|
|
2266
2336
|
const skippedTaskIds = [];
|
|
2267
|
-
if (this.options.dryRun) logger.warn("
|
|
2337
|
+
if (this.options.dryRun) logger.warn("Running in DRY-RUN mode: No changes will be made.");
|
|
2338
|
+
const version = RuntimeEnv.version;
|
|
2339
|
+
const dashIndex = version.indexOf("-");
|
|
2340
|
+
if (dashIndex !== -1) if (dashIndex === version.length - 1 || version[dashIndex + 1] === "n") logger.warn(`You are running a DEVELOPMENT build of Firefly (${colors.dim(version)}). This is a 'next' build and may be unstable.`);
|
|
2341
|
+
else logger.warn(`You are running a PRE-RELEASE version of Firefly (${colors.dim(version)}). Unexpected behavior or bugs may occur.`);
|
|
2268
2342
|
logger.verbose(`WorkflowExecutor: Starting execution of ${tasks.length} tasks`);
|
|
2269
2343
|
return this.executeTasksSequentially(tasks, initialContext, executedTaskIds, skippedTaskIds).andThen(() => this.buildExecutionSuccessResult(startTime, executedTaskIds, skippedTaskIds)).orElse((error) => this.handleExecutionFailure({
|
|
2270
2344
|
error,
|
|
@@ -253,9 +253,13 @@ const failedErrAsync = (opts) => errAsync(failedError(opts));
|
|
|
253
253
|
*/
|
|
254
254
|
const invalidErr = (opts) => err(invalidError(opts));
|
|
255
255
|
/**
|
|
256
|
+
* Creates an async invalid error result.
|
|
257
|
+
*/
|
|
258
|
+
const invalidErrAsync = (opts) => errAsync(invalidError(opts));
|
|
259
|
+
/**
|
|
256
260
|
* Creates an async timeout error result.
|
|
257
261
|
*/
|
|
258
262
|
const timeoutErrAsync = (opts) => errAsync(timeoutError(opts));
|
|
259
263
|
|
|
260
264
|
//#endregion
|
|
261
|
-
export {
|
|
265
|
+
export { notFoundError as _, conflictErrAsync as a, wrapErrorMessage as b, invalidErrAsync as c, validationErr as d, validationErrAsync as f, invalidError as g, failedError as h, FireflyOkAsync as i, notFoundErrAsync as l, createFireflyError as m, FireflyErrAsync as n, failedErrAsync as o, conflictError as p, FireflyOk as r, invalidErr as s, FireflyErr as t, timeoutErrAsync as u, toFireflyError as v, validationError as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as validationErrAsync, i as FireflyOkAsync, m as createFireflyError, v as toFireflyError } from "./result.constructors-D9jmQ0uj.js";
|
|
2
2
|
import { ResultAsync } from "neverthrow";
|
|
3
3
|
|
|
4
4
|
//#region src/core/result/result.utilities.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as createFireflyError, r as FireflyOk, t as FireflyErr, v as toFireflyError } from "./result.constructors-D9jmQ0uj.js";
|
|
2
2
|
import { ResultAsync } from "neverthrow";
|
|
3
3
|
import z$1 from "zod";
|
|
4
4
|
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { r as FireflyOk, s as invalidErr, t as FireflyErr } from "./result.constructors-D9jmQ0uj.js";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
|
|
4
|
+
//#region src/domain/semver/version.ts
|
|
5
|
+
/**
|
|
6
|
+
* Represents a parsed semantic version with immutable access.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const result = Version.from("1.2.3-alpha.1");
|
|
11
|
+
* if (result.isOk()) {
|
|
12
|
+
* console.log(result.value.major); // 1
|
|
13
|
+
* console.log(result.value.isPrerelease); // true
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var Version = class Version {
|
|
18
|
+
_raw;
|
|
19
|
+
_parsed;
|
|
20
|
+
constructor(version, parsed) {
|
|
21
|
+
this._raw = version;
|
|
22
|
+
this._parsed = parsed;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a Version from any valid semver string.
|
|
26
|
+
* Handles cleaning (removing 'v' prefix, etc.).
|
|
27
|
+
*/
|
|
28
|
+
static from(input) {
|
|
29
|
+
const cleaned = semver.clean(input);
|
|
30
|
+
if (!cleaned) return invalidErr({ message: `"${input}" is not a valid semantic version.` });
|
|
31
|
+
const parsed = semver.parse(cleaned);
|
|
32
|
+
if (!parsed) return invalidErr({ message: `Failed to parse semantic version "${cleaned}".` });
|
|
33
|
+
return FireflyOk(new Version(cleaned, parsed));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Version from an already-clean semver string.
|
|
37
|
+
* Use when you know the input is already normalized.
|
|
38
|
+
*/
|
|
39
|
+
static fromClean(cleanVersion) {
|
|
40
|
+
const parsed = semver.parse(cleanVersion);
|
|
41
|
+
if (!parsed) return invalidErr({ message: `Expected clean version but got invalid: ${cleanVersion}` });
|
|
42
|
+
return FireflyOk(new Version(cleanVersion, parsed));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The raw version string.
|
|
46
|
+
*/
|
|
47
|
+
get raw() {
|
|
48
|
+
return this._raw;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Major version number.
|
|
52
|
+
*/
|
|
53
|
+
get major() {
|
|
54
|
+
return this._parsed.major;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Minor version number.
|
|
58
|
+
*/
|
|
59
|
+
get minor() {
|
|
60
|
+
return this._parsed.minor;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Patch version number.
|
|
64
|
+
*/
|
|
65
|
+
get patch() {
|
|
66
|
+
return this._parsed.patch;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether this version has prerelease identifiers.
|
|
70
|
+
*/
|
|
71
|
+
get isPrerelease() {
|
|
72
|
+
return this._parsed.prerelease.length > 0;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Prerelease identifiers (e.g., ["alpha", 1] for "1.0.0-alpha.1").
|
|
76
|
+
*/
|
|
77
|
+
get prerelease() {
|
|
78
|
+
return this._parsed.prerelease;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The prerelease identifier (e.g., "alpha" from "1.0.0-alpha.1").
|
|
82
|
+
*/
|
|
83
|
+
get prereleaseIdentifier() {
|
|
84
|
+
if (!this.isPrerelease) return null;
|
|
85
|
+
const first = this._parsed.prerelease[0];
|
|
86
|
+
return typeof first === "string" ? first : null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The prerelease number (e.g., 1 from "1.0.0-alpha.1").
|
|
90
|
+
*/
|
|
91
|
+
get prereleaseNumber() {
|
|
92
|
+
if (!this.isPrerelease) return null;
|
|
93
|
+
const last = this._parsed.prerelease.at(-1);
|
|
94
|
+
return typeof last === "number" ? last : null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Build metadata identifiers.
|
|
98
|
+
*/
|
|
99
|
+
get build() {
|
|
100
|
+
return this._parsed.build;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the raw version string.
|
|
104
|
+
*/
|
|
105
|
+
toString() {
|
|
106
|
+
return this._raw;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Checks equality with another Version.
|
|
110
|
+
*
|
|
111
|
+
* @param other - The other Version to compare with
|
|
112
|
+
* @returns True if equal, false otherwise
|
|
113
|
+
*/
|
|
114
|
+
equals(other) {
|
|
115
|
+
return semver.eq(this._raw, other._raw);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Compares with another Version: -1 (less), 0 (equal), 1 (greater).
|
|
119
|
+
*
|
|
120
|
+
* @param other - The other Version to compare with
|
|
121
|
+
* @returns -1, 0, or 1 based on comparison
|
|
122
|
+
*/
|
|
123
|
+
compare(other) {
|
|
124
|
+
return semver.compare(this._raw, other._raw);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Checks if this version is greater than another.
|
|
128
|
+
*
|
|
129
|
+
* @param other - The other Version to compare with
|
|
130
|
+
* @returns True if this version is greater, false otherwise
|
|
131
|
+
*/
|
|
132
|
+
isGreaterThan(other) {
|
|
133
|
+
return semver.gt(this._raw, other._raw);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Checks if this version is less than another.
|
|
137
|
+
*
|
|
138
|
+
* @param other - The other Version to compare with
|
|
139
|
+
* @returns True if this version is less, false otherwise
|
|
140
|
+
*/
|
|
141
|
+
isLessThan(other) {
|
|
142
|
+
return semver.lt(this._raw, other._raw);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Checks if this version satisfies a semver range.
|
|
146
|
+
*
|
|
147
|
+
* @param range - The semver range to check against
|
|
148
|
+
* @returns True if it satisfies the range, false otherwise
|
|
149
|
+
*/
|
|
150
|
+
satisfies(range) {
|
|
151
|
+
return semver.satisfies(this._raw, range);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Converts a prerelease version to its stable form.
|
|
155
|
+
* "1.2.3-alpha.1" → "1.2.3"
|
|
156
|
+
*/
|
|
157
|
+
toStable() {
|
|
158
|
+
const stableVersion = `${this.major}.${this.minor}.${this.patch}`;
|
|
159
|
+
return Version.fromClean(stableVersion);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/services/implementations/version-bumper.service.ts
|
|
165
|
+
/**
|
|
166
|
+
* Default implementation of the version bumper service.
|
|
167
|
+
*/
|
|
168
|
+
var DefaultVersionBumperService = class {
|
|
169
|
+
bump(options) {
|
|
170
|
+
const { currentVersion, releaseType, prereleaseIdentifier, prereleaseBase } = options;
|
|
171
|
+
if (releaseType === "major" || releaseType === "minor" || releaseType === "patch") return this.bumpStandard(currentVersion, releaseType);
|
|
172
|
+
if (releaseType === "premajor" || releaseType === "preminor" || releaseType === "prepatch") return this.bumpPreStandard(currentVersion, releaseType, prereleaseIdentifier, prereleaseBase);
|
|
173
|
+
if (releaseType === "prerelease") return this.bumpPrerelease(currentVersion, prereleaseIdentifier, prereleaseBase);
|
|
174
|
+
if (releaseType === "graduate") return this.graduatePrerelease(currentVersion);
|
|
175
|
+
return invalidErr({
|
|
176
|
+
message: `Unsupported release type: ${releaseType}`,
|
|
177
|
+
source: "services/version-bumper"
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Normalizes the prerelease base to a string "0" or "1".
|
|
182
|
+
*
|
|
183
|
+
* @param base - The prerelease base to normalize
|
|
184
|
+
* @returns The normalized base or an error if invalid
|
|
185
|
+
*/
|
|
186
|
+
normalizeBase(base) {
|
|
187
|
+
if (base === void 0 || base === null) return FireflyOk(void 0);
|
|
188
|
+
if (base === "0" || base === "1") return FireflyOk(base);
|
|
189
|
+
if (typeof base === "number" && (base === 0 || base === 1)) return FireflyOk(base.toString());
|
|
190
|
+
return invalidErr({ message: `Invalid prerelease base '${base}'. Must be "0", "1", 0, or 1.` });
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Determines if the prerelease identifier is complex (contains dots).
|
|
194
|
+
*
|
|
195
|
+
* @param identifier - The prerelease identifier to check
|
|
196
|
+
* @returns True if the identifier is complex, false otherwise
|
|
197
|
+
*/
|
|
198
|
+
isComplexIdentifier(identifier) {
|
|
199
|
+
return typeof identifier === "string" && identifier.includes(".");
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Bumps a version with a complex prerelease identifier (e.g., "canary.abc123").
|
|
203
|
+
*
|
|
204
|
+
* @param currentVersion - The current version to bump
|
|
205
|
+
* @param identifier - The complex prerelease identifier
|
|
206
|
+
* @returns The new version with the complex identifier
|
|
207
|
+
*/
|
|
208
|
+
bumpWithComplexIdentifier(currentVersion, identifier) {
|
|
209
|
+
if (!identifier) return semver.inc(currentVersion.raw, "prerelease", void 0, "0");
|
|
210
|
+
return semver.inc(currentVersion.raw, "prerelease", identifier, false);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Bumps an existing prerelease version.
|
|
214
|
+
*
|
|
215
|
+
* @param currentVersion - The current version to bump
|
|
216
|
+
* @param identifier - Optional prerelease identifier
|
|
217
|
+
* @returns The new prerelease version
|
|
218
|
+
*/
|
|
219
|
+
bumpExistingPrerelease(currentVersion, identifier) {
|
|
220
|
+
return identifier ? semver.inc(currentVersion.raw, "prerelease", identifier) : semver.inc(currentVersion.raw, "prerelease");
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Bumps a standard version (major, minor, patch) according to the provided release type.
|
|
224
|
+
*
|
|
225
|
+
* @param currentVersion - The current version to bump
|
|
226
|
+
* @param releaseType - The type of standard release
|
|
227
|
+
* @returns The new standard version
|
|
228
|
+
*/
|
|
229
|
+
bumpStandard(currentVersion, releaseType) {
|
|
230
|
+
let baseVersionString = currentVersion.raw;
|
|
231
|
+
if (currentVersion.isPrerelease) {
|
|
232
|
+
const stableResult = currentVersion.toStable();
|
|
233
|
+
if (stableResult.isErr()) return FireflyErr(stableResult.error);
|
|
234
|
+
baseVersionString = stableResult.value.raw;
|
|
235
|
+
}
|
|
236
|
+
const newVersionString = semver.inc(baseVersionString, releaseType);
|
|
237
|
+
if (!newVersionString) return invalidErr({
|
|
238
|
+
message: `Failed to bump ${releaseType} version from '${baseVersionString}'.`,
|
|
239
|
+
source: "services/version-bumper"
|
|
240
|
+
});
|
|
241
|
+
return Version.fromClean(newVersionString);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Bumps a pre-standard version (premajor, preminor, prepatch) according to the provided options.
|
|
245
|
+
*
|
|
246
|
+
* @param currentVersion - The current version to bump
|
|
247
|
+
* @param releaseType - The type of pre-standard release
|
|
248
|
+
* @param identifier - Optional prerelease identifier (e.g., "alpha", "beta")
|
|
249
|
+
* @param base - Optional base number for the prerelease
|
|
250
|
+
* @returns The new pre-standard version
|
|
251
|
+
*/
|
|
252
|
+
bumpPreStandard(currentVersion, releaseType, identifier, base) {
|
|
253
|
+
const normalizedBaseResult = this.normalizeBase(base);
|
|
254
|
+
if (normalizedBaseResult.isErr()) return FireflyErr(normalizedBaseResult.error);
|
|
255
|
+
const normalizedBase = normalizedBaseResult.value;
|
|
256
|
+
let newVersionString = null;
|
|
257
|
+
if (normalizedBase !== void 0) newVersionString = identifier ? semver.inc(currentVersion.raw, releaseType, identifier, normalizedBase) : semver.inc(currentVersion.raw, releaseType, void 0, normalizedBase);
|
|
258
|
+
else newVersionString = identifier ? semver.inc(currentVersion.raw, releaseType, identifier) : semver.inc(currentVersion.raw, releaseType);
|
|
259
|
+
if (!newVersionString) return invalidErr({
|
|
260
|
+
message: `Failed to bump ${releaseType} version from '${currentVersion.raw}' with identifier '${identifier}' and base '${base}'.`,
|
|
261
|
+
source: "services/version-bumper"
|
|
262
|
+
});
|
|
263
|
+
return Version.fromClean(newVersionString);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Bumps a prerelease version according to the provided options.
|
|
267
|
+
* Handles complex identifiers, explicit bases, continuing existing
|
|
268
|
+
* prereleases, and starting new prereleases from stable versions.
|
|
269
|
+
*
|
|
270
|
+
* @param currentVersion - The current version to bump
|
|
271
|
+
* @param identifier - Optional prerelease identifier (e.g., "alpha", "beta")
|
|
272
|
+
* @param base - Optional base number for the prerelease
|
|
273
|
+
* @returns The new prerelease version
|
|
274
|
+
*/
|
|
275
|
+
bumpPrerelease(currentVersion, identifier, base) {
|
|
276
|
+
let newVersionString = null;
|
|
277
|
+
if (this.isComplexIdentifier(identifier)) newVersionString = this.bumpWithComplexIdentifier(currentVersion, identifier);
|
|
278
|
+
else if (base !== void 0 && base !== null) {
|
|
279
|
+
const normalizedBaseResult = this.normalizeBase(base);
|
|
280
|
+
if (normalizedBaseResult.isErr()) return FireflyErr(normalizedBaseResult.error);
|
|
281
|
+
const normalizedBase = normalizedBaseResult.value;
|
|
282
|
+
newVersionString = identifier ? semver.inc(currentVersion.raw, "prerelease", identifier, normalizedBase) : semver.inc(currentVersion.raw, "prerelease", void 0, normalizedBase);
|
|
283
|
+
} else if (currentVersion.isPrerelease) newVersionString = this.bumpExistingPrerelease(currentVersion, identifier);
|
|
284
|
+
else {
|
|
285
|
+
const defaultIdentifier = identifier || "alpha";
|
|
286
|
+
newVersionString = semver.inc(currentVersion.raw, "prerelease", defaultIdentifier);
|
|
287
|
+
}
|
|
288
|
+
if (!newVersionString) return invalidErr({
|
|
289
|
+
message: `Failed to bump prerelease version from '${currentVersion.raw}' with identifier '${identifier}' and base '${base}'.`,
|
|
290
|
+
source: "services/version-bumper"
|
|
291
|
+
});
|
|
292
|
+
return Version.fromClean(newVersionString);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Graduates a prerelease version to its stable counterpart.
|
|
296
|
+
*
|
|
297
|
+
* @param currentVersion - The current prerelease version
|
|
298
|
+
* @returns The stable version
|
|
299
|
+
*/
|
|
300
|
+
graduatePrerelease(currentVersion) {
|
|
301
|
+
if (!currentVersion.isPrerelease) return invalidErr({
|
|
302
|
+
message: `Cannot graduate non-prerelease version '${currentVersion.raw}'. Only prerelease versions can be graduated.`,
|
|
303
|
+
source: "services/version-bumper"
|
|
304
|
+
});
|
|
305
|
+
const stableVersionResult = currentVersion.toStable();
|
|
306
|
+
if (stableVersionResult.isErr()) return FireflyErr(stableVersionResult.error);
|
|
307
|
+
return FireflyOk(stableVersionResult.value);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Creates a version bumper service instance.
|
|
312
|
+
*/
|
|
313
|
+
function createVersionBumperService() {
|
|
314
|
+
return new DefaultVersionBumperService();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//#endregion
|
|
318
|
+
export { createVersionBumperService };
|