fireflyy 4.0.0-dev.df58d2b → 4.0.0-dev.fc28987

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.
@@ -1,318 +0,0 @@
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 };
@@ -1,4 +0,0 @@
1
- import "./result.constructors-D9jmQ0uj.js";
2
- import { n as TRANSITION_KEYWORDS, r as createVersionStrategyService, t as DefaultVersionStrategyService } from "./version-strategy.service-vh5KeNCA.js";
3
-
4
- export { createVersionStrategyService };