fireflyy 3.0.11 → 4.0.0-dev.352994a

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.
@@ -0,0 +1,261 @@
1
+ import { err, errAsync, ok, okAsync } from "neverthrow";
2
+ import z$1 from "zod";
3
+
4
+ //#region src/core/result/error.types.ts
5
+ /**
6
+ * Canonical list of Firefly error codes used for classification and handling.
7
+ *
8
+ * - `VALIDATION`: Input or schema validation failure.
9
+ * - `NOT_FOUND`: Resource not present or lookup failed.
10
+ * - `CONFLICT`: Business-logic or state conflicts.
11
+ * - `IO`: I/O related errors such as file system or network failures.
12
+ * - `TIMEOUT`: Operations that exceeded an allowed time window.
13
+ * - `UNEXPECTED`: Unexpected or unknown errors.
14
+ * - `FAILED`: Generic operation failure where a command or task returned an error code.
15
+ * - `INVALID`: Invalid state or arguments not covered by `VALIDATION`.
16
+ */
17
+ const FireflyErrorCodeSchema = z$1.enum([
18
+ "VALIDATION",
19
+ "NOT_FOUND",
20
+ "CONFLICT",
21
+ "IO",
22
+ "TIMEOUT",
23
+ "UNEXPECTED",
24
+ "FAILED",
25
+ "INVALID"
26
+ ]);
27
+ /**
28
+ * Standardized Firefly error shape validated using Zod. This object is the
29
+ * canonical structure used throughout the codebase to represent errors.
30
+ *
31
+ * - `code`: One of `FireflyErrorCodeSchema` values that categorizes the error.
32
+ * - `message`: A human-friendly explanatory message for the error.
33
+ * - `details`: Optional additional structured or unstructured data with context.
34
+ * - `cause`: Optional underlying error or value that caused this error (opaque).
35
+ * - `retryable`: Optional boolean indicating whether the operation may be retried.
36
+ * - `source`: Optional string describing the subsystem or module that emitted the error.
37
+ */
38
+ const FireflyErrorSchema = z$1.object({
39
+ code: FireflyErrorCodeSchema,
40
+ message: z$1.string(),
41
+ details: z$1.unknown().optional(),
42
+ cause: z$1.unknown().optional(),
43
+ retryable: z$1.boolean().optional(),
44
+ source: z$1.string().optional()
45
+ });
46
+
47
+ //#endregion
48
+ //#region src/core/result/error.factories.ts
49
+ /**
50
+ * Creates a frozen FireflyError instance with an attached stack trace.
51
+ *
52
+ * @param error - The FireflyError object to enhance.
53
+ * @returns Frozen FireflyError with an optional stack trace.
54
+ */
55
+ function createFireflyError(error) {
56
+ const err$1 = new Error(error.message, { cause: error.cause });
57
+ return Object.freeze({
58
+ ...error,
59
+ stack: err$1.stack
60
+ });
61
+ }
62
+ /**
63
+ * Converts an unknown error into a FireflyError.
64
+ *
65
+ * @param err - The unknown error to convert.
66
+ * @param code - The FireflyErrorCode to assign.
67
+ * @param source - The source of the error.
68
+ * @returns FireflyError instance.
69
+ */
70
+ function toFireflyError(err$1, code = "UNEXPECTED", source) {
71
+ const base = {
72
+ code,
73
+ message: err$1 instanceof Error ? err$1.message : String(err$1),
74
+ cause: err$1 instanceof Error ? err$1.cause : void 0,
75
+ source
76
+ };
77
+ return createFireflyError(FireflyErrorSchema.parse(base));
78
+ }
79
+ /**
80
+ * Wraps an error message with additional context prefix.
81
+ *
82
+ * @param error - Original error
83
+ * @param prefix - Message prefix to add
84
+ * @returns New error with prefixed message
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const wrapped = wrapErrorMessage(error, "Failed to execute release");
89
+ * // Result: "Failed to execute release: original message"
90
+ * ```
91
+ */
92
+ function wrapErrorMessage(error, prefix) {
93
+ return createFireflyError({
94
+ ...error,
95
+ message: `${prefix}: ${error.message}`
96
+ });
97
+ }
98
+ /**
99
+ * Creates a validation error.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * return FireflyErr(validationError({ message: "Invalid version format", source: "release" }));
104
+ * ```
105
+ */
106
+ function validationError(opts) {
107
+ return createFireflyError({
108
+ code: "VALIDATION",
109
+ ...opts
110
+ });
111
+ }
112
+ /**
113
+ * Creates a not-found error.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * return FireflyErr(notFoundError({ message: "Config file not found", source: "cli" }));
118
+ * ```
119
+ */
120
+ function notFoundError(opts) {
121
+ return createFireflyError({
122
+ code: "NOT_FOUND",
123
+ ...opts
124
+ });
125
+ }
126
+ /**
127
+ * Creates a conflict error.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * return FireflyErr(conflictError({ message: "Working directory is not clean" }));
132
+ * ```
133
+ */
134
+ function conflictError(opts) {
135
+ return createFireflyError({
136
+ code: "CONFLICT",
137
+ ...opts
138
+ });
139
+ }
140
+ /**
141
+ * Creates a timeout error.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * return FireflyErr(timeoutError({ message: "Operation timed out after 30s", retryable: true }));
146
+ * ```
147
+ */
148
+ function timeoutError(opts) {
149
+ return createFireflyError({
150
+ code: "TIMEOUT",
151
+ ...opts
152
+ });
153
+ }
154
+ /**
155
+ * Creates a failed operation error.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * return FireflyErr(failedError({ message: "Git command failed", details: stderr }));
160
+ * ```
161
+ */
162
+ function failedError(opts) {
163
+ return createFireflyError({
164
+ code: "FAILED",
165
+ ...opts
166
+ });
167
+ }
168
+ /**
169
+ * Creates an invalid state/input error.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * return FireflyErr(invalidError({ message: "Invalid bump type specified" }));
174
+ * ```
175
+ */
176
+ function invalidError(opts) {
177
+ return createFireflyError({
178
+ code: "INVALID",
179
+ ...opts
180
+ });
181
+ }
182
+
183
+ //#endregion
184
+ //#region src/core/result/result.constructors.ts
185
+ /**
186
+ * Creates a successful sync result.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * return FireflyOk(computedValue);
191
+ * ```
192
+ */
193
+ const FireflyOk = (value) => ok(value);
194
+ /**
195
+ * Creates a failed sync result.
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * return FireflyErr(validationError({ message: "Invalid input" }));
200
+ * ```
201
+ */
202
+ const FireflyErr = (error) => err(error);
203
+ /**
204
+ * Creates a successful async result.
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * return FireflyOkAsync(fetchedData);
209
+ * ```
210
+ */
211
+ const FireflyOkAsync = (value) => okAsync(value);
212
+ /**
213
+ * Creates a failed async result.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * return FireflyErrAsync(notFoundError({ message: "Config not found" }));
218
+ * ```
219
+ */
220
+ const FireflyErrAsync = (error) => errAsync(error);
221
+ /**
222
+ * Creates a sync validation error result.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * if (!isValid) return validationErr({ message: "Invalid version format" });
227
+ * ```
228
+ */
229
+ const validationErr = (opts) => err(validationError(opts));
230
+ /**
231
+ * Creates an async validation error result.
232
+ */
233
+ const validationErrAsync = (opts) => errAsync(validationError(opts));
234
+ /**
235
+ * Creates an async not-found error result.
236
+ */
237
+ const notFoundErrAsync = (opts) => errAsync(notFoundError(opts));
238
+ /**
239
+ * Creates an async conflict error result.
240
+ */
241
+ const conflictErrAsync = (opts) => errAsync(conflictError(opts));
242
+ /**
243
+ * Creates an async failed error result.
244
+ */
245
+ const failedErrAsync = (opts) => errAsync(failedError(opts));
246
+ /**
247
+ * Creates a sync invalid error result.
248
+ *
249
+ * @example
250
+ * ```ts
251
+ * if (!taskFn) return invalidErr({ message: "Task must have an execute function" });
252
+ * ```
253
+ */
254
+ const invalidErr = (opts) => err(invalidError(opts));
255
+ /**
256
+ * Creates an async timeout error result.
257
+ */
258
+ const timeoutErrAsync = (opts) => errAsync(timeoutError(opts));
259
+
260
+ //#endregion
261
+ export { validationError as _, conflictErrAsync as a, notFoundErrAsync as c, validationErrAsync as d, conflictError as f, toFireflyError as g, notFoundError as h, FireflyOkAsync as i, timeoutErrAsync as l, failedError as m, FireflyErrAsync as n, failedErrAsync as o, createFireflyError as p, FireflyOk as r, invalidErr as s, FireflyErr as t, validationErr as u, wrapErrorMessage as v };
@@ -0,0 +1,32 @@
1
+ import { d as validationErrAsync, g as toFireflyError, i as FireflyOkAsync, p as createFireflyError } from "./result.constructors-C9M1MP3_.js";
2
+ import { ResultAsync, okAsync } from "neverthrow";
3
+
4
+ //#region src/core/result/result.utilities.ts
5
+ /**
6
+ * Wraps a Promise into a FireflyAsyncResult, converting any errors into FireflyError.
7
+ *
8
+ * @param promise - The Promise to wrap.
9
+ * @returns FireflyAsyncResult representing the outcome of the Promise.
10
+ */
11
+ function wrapPromise(promise) {
12
+ return ResultAsync.fromPromise(promise, (e) => createFireflyError(toFireflyError(e)));
13
+ }
14
+ /**
15
+ * Async version of ensureNot.
16
+ */
17
+ function ensureNotAsync(condition, errorOpts) {
18
+ return condition ? validationErrAsync(errorOpts) : FireflyOkAsync(void 0);
19
+ }
20
+ /**
21
+ * Async version of zip3.
22
+ */
23
+ function zip3Async(resultA, resultB, resultC) {
24
+ return ResultAsync.combine([
25
+ resultA,
26
+ resultB,
27
+ resultC
28
+ ]);
29
+ }
30
+
31
+ //#endregion
32
+ export { wrapPromise as n, zip3Async as r, ensureNotAsync as t };
@@ -0,0 +1,60 @@
1
+ import { g as toFireflyError, p as createFireflyError, r as FireflyOk, t as FireflyErr } from "./result.constructors-C9M1MP3_.js";
2
+ import { ResultAsync } from "neverthrow";
3
+ import z$1 from "zod";
4
+
5
+ //#region src/core/result/schema.utilities.ts
6
+ /**
7
+ * Formats Zod validation errors into a human-readable string.
8
+ *
9
+ * @param error - The Zod error object
10
+ * @returns A formatted string with each issue on a new line
11
+ */
12
+ function formatZodErrors(error) {
13
+ return error.issues.map((issue) => `${issue.message} for ${issue.path.join(".")}`).join("\n");
14
+ }
15
+ /**
16
+ * Compose multiple Zod schemas using intersection semantics.
17
+ * The first schema is used as the base and all remaining schemas are intersected
18
+ * with it. This effectively merges validation rules across schemas.
19
+ *
20
+ * @param schemas - A non-empty list of Zod schemas to intersect.
21
+ * @returns Zod schema that is the intersection of the provided schemas.
22
+ */
23
+ function composeEffects(...schemas) {
24
+ return schemas.slice(1).reduce((acc, s) => z$1.intersection(acc, s), schemas[0]);
25
+ }
26
+ /**
27
+ * Merge raw object shapes into a base Zod object schema and return an extended
28
+ * object schema.
29
+ *
30
+ * @param base - The root Zod object schema to extend.
31
+ * @param shapes - Raw Zod shapes (plain objects of Zod schema definitions) to merge into the base.
32
+ * @returns New Zod object schema that extends `base` with merged `shapes`.
33
+ */
34
+ function composeShape(base, ...shapes) {
35
+ const merged = {};
36
+ for (const s of shapes) Object.assign(merged, s);
37
+ return base.extend(merged);
38
+ }
39
+ /**
40
+ * Convert a `SchemaInput` descriptor into a Zod schema instance.
41
+ * If the input is already a Zod schema it is returned verbatim. If a descriptor
42
+ * is supplied, the appropriate composition helper is invoked to produce a
43
+ * schema instance.
44
+ *
45
+ * @internal
46
+ * @param input - Either a Zod schema or a descriptor describing how to compose one.
47
+ * @returns Concrete `z.ZodType` instance resulting from the input.
48
+ */
49
+ function toSchema(input) {
50
+ if ("_def" in input && typeof input._def !== "undefined") return input;
51
+ const desc = input;
52
+ return desc.mode === "effect" ? composeEffects(...desc.schemas) : composeShape(desc.base, ...desc.shapes);
53
+ }
54
+ function parseSchema(schemaOrDescriptor, data) {
55
+ const result = toSchema(schemaOrDescriptor).safeParse(data);
56
+ return result.success ? FireflyOk(result.data) : FireflyErr(createFireflyError(toFireflyError(result.error)));
57
+ }
58
+
59
+ //#endregion
60
+ export { parseSchema as n, formatZodErrors as t };
package/package.json CHANGED
@@ -1,88 +1,92 @@
1
1
  {
2
- "name": "fireflyy",
3
- "version": "3.0.11",
4
- "description": "CLI orchestrator for semantic versioning, changelog generation, and creating releases.",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "Yehezkiel Dio Sinolungan <yehezkieldio@proton.me>",
8
- "files": [
9
- "dist/**/*.js",
10
- "dist/**/*.d.ts",
11
- "assets"
12
- ],
13
- "main": "./dist/index.js",
14
- "module": "./dist/index.js",
15
- "types": "./dist/index.d.ts",
16
- "exports": {
17
- "./config": {
18
- "types": "./dist/index.d.ts",
19
- "import": "./dist/index.js"
20
- }
2
+ "name": "fireflyy",
3
+ "version": "4.0.0-dev.352994a",
4
+ "description": " CLI orchestrator for automatic semantic versioning, changelog generation, and creating releases. Built for my own use cases.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Yehezkiel Dio Sinolungan <yehezkieldio@proton.me>",
8
+ "files": [
9
+ "dist/**/*.js",
10
+ "dist/**/*.d.ts",
11
+ "assets"
12
+ ],
13
+ "main": "./dist/config.js",
14
+ "module": "./dist/config.js",
15
+ "types": "./dist/config.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/config.d.ts",
19
+ "import": "./dist/config.js"
21
20
  },
22
- "typesVersions": {
23
- "*": {
24
- "*": [
25
- "./dist/*",
26
- "./*"
27
- ]
28
- }
29
- },
30
- "bin": {
31
- "firefly": "dist/main.js",
32
- "ff": "dist/main.js"
33
- },
34
- "publishConfig": {
35
- "access": "public",
36
- "registry": "https://registry.npmjs.org/",
37
- "provenance": true
38
- },
39
- "scripts": {
40
- "postbuild": "bun scripts/generate-json-schema.ts assets/firefly.schema.json",
41
- "build": "tsdown",
42
- "dev": "bun run src/platform/cli/main.ts",
43
- "check": "biome check .",
44
- "check:unsafe": "biome check --write --unsafe .",
45
- "check:write": "biome check --write .",
46
- "typecheck": "tsc --noEmit",
47
- "format": "biome format . --write",
48
- "lint": "biome lint .",
49
- "lint:fix": "biome lint . --fix --unsafe"
50
- },
51
- "dependencies": {
52
- "c12": "^3.3.1",
53
- "commander": "^14.0.2",
54
- "consola": "^3.4.2",
55
- "git-cliff": "^2.10.1",
56
- "neverthrow": "^8.2.0",
57
- "semver": "^7.7.3",
58
- "zod": "^4.1.12"
59
- },
60
- "devDependencies": {
61
- "@biomejs/biome": "^2.3.4",
62
- "@types/bun": "^1.3.2",
63
- "@types/node": "^24.9.1",
64
- "@types/semver": "^7.7.1",
65
- "tsdown": "^0.16.1",
66
- "typescript": "^5.9.3"
67
- },
68
- "keywords": [
69
- "cli",
70
- "changelog",
71
- "git",
72
- "github",
73
- "gitlab",
74
- "release",
75
- "semver",
76
- "versioning",
77
- "automation",
78
- "orchestrator"
79
- ],
80
- "homepage": "https://github.com/yehezkieldio/firefly#readme",
81
- "bugs": {
82
- "url": "https://github.com/yehezkieldio/firefly/issues"
83
- },
84
- "repository": {
85
- "type": "git",
86
- "url": "git+https://github.com/yehezkieldio/firefly.git"
21
+ "./config": {
22
+ "types": "./dist/config.d.ts",
23
+ "import": "./dist/config.js"
24
+ }
25
+ },
26
+ "typesVersions": {
27
+ "*": {
28
+ "config": [
29
+ "./dist/config.d.ts"
30
+ ]
87
31
  }
32
+ },
33
+ "bin": {
34
+ "firefly": "dist/main.js",
35
+ "ff": "dist/main.js"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/",
40
+ "provenance": true
41
+ },
42
+ "scripts": {
43
+ "build": "tsdown",
44
+ "build:json-schema": "bun run scripts/generate-json-schema.ts assets/firefly.schema.json",
45
+ "postbuild": "bun run build:json-schema",
46
+ "dev": "bun run src/cli/main.ts",
47
+ "check": "biome check .",
48
+ "check:unsafe": "biome check --write --unsafe .",
49
+ "check:write": "biome check --write .",
50
+ "typecheck": "tsc --noEmit",
51
+ "format": "biome format . --write",
52
+ "lint": "biome lint .",
53
+ "lint:fix": "biome lint . --fix --unsafe"
54
+ },
55
+ "dependencies": {
56
+ "c12": "^3.3.2",
57
+ "commander": "^14.0.2",
58
+ "consola": "^3.4.2",
59
+ "git-cliff": "^2.10.1",
60
+ "neverthrow": "^8.2.0",
61
+ "semver": "^7.7.3",
62
+ "zod": "^4.1.13"
63
+ },
64
+ "devDependencies": {
65
+ "@biomejs/biome": "2.3.8",
66
+ "@types/bun": "^1.3.3",
67
+ "@types/semver": "^7.7.1",
68
+ "tsdown": "^0.17.0-beta.5",
69
+ "typescript": "^5.9.3",
70
+ "ultracite": "6.3.8"
71
+ },
72
+ "keywords": [
73
+ "cli",
74
+ "changelog",
75
+ "git",
76
+ "github",
77
+ "gitlab",
78
+ "release",
79
+ "semver",
80
+ "versioning",
81
+ "automation",
82
+ "orchestrator"
83
+ ],
84
+ "homepage": "https://github.com/yehezkieldio/firefly#readme",
85
+ "bugs": {
86
+ "url": "https://github.com/yehezkieldio/firefly/issues"
87
+ },
88
+ "repository": {
89
+ "type": "git",
90
+ "url": "git+https://github.com/yehezkieldio/firefly.git"
91
+ }
88
92
  }