@deployanyway/error-translator 0.2.0 → 0.4.0

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ 46 built-in definitions cover filesystem, permissions, networking, module loading, streams, HTTP response lifecycle and JavaScript errors. Each has a specific explanation, likely causes and practical checks. Rubber-duck commentary has a distinct original line for every supported definition. No commands run automatically and unknown errors remain explicitly unrecognized.
6
+
7
+ ```sh
8
+
9
+
10
+ ## 0.3.0 — 2026-10-08
11
+
12
+ - Useful structured API/CLI additions described in README.
13
+ - TypeScript declarations, CommonJS entry, coverage gates and installed archive checks.
14
+ - Linux Node 22/24 plus Windows/macOS Node 24 CI.
15
+
3
16
  ## 0.2.0 — 2026-10-08
4
17
 
5
18
  - Rubber-duck translations: Keep the debugging guidance, add workplace-safe rubber-duck commentary. Plain output remains the default.
@@ -16,3 +29,4 @@
16
29
  - Plain-English translations for ECONNREFUSED, ENOENT, EADDRINUSE, MODULE_NOT_FOUND, ERR_MODULE_NOT_FOUND, and TypeError.
17
30
  - Structured results, text rendering, and CLI with JSON output.
18
31
  - Automated tests, linting, formatting, and Node 22/24 CI.
32
+ ```
package/MIGRATION.md ADDED
@@ -0,0 +1,11 @@
1
+ # 0.3.0 migration
2
+
3
+ Node 22.13+ is required. Existing core APIs remain available; TypeScript declarations and CommonJS exports are new. The CLI now lives in src/cli.js behind the same executable path. Input/stdout behavior for new options is documented in README.
4
+
5
+ Install 0.3.0 with npm. Seeds and exact humorous wording are version-specific. Do not treat jokes or heuristic scores as production evidence.
6
+
7
+ ## 0.3.0 to 0.4.0
8
+
9
+ 46 distinct error definitions with explanations, causes and practical checks; original duck commentary for each; structured errorCatalog API and --catalog CLI.
10
+
11
+ Default behavior is retained except that the expanded error catalog now recognizes additional errors. New rotation and release-plan features are opt-in.
package/README.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # error-translator
2
2
 
3
+ ## Browse the debugging library (0.4.0)
4
+
5
+ 46 built-in definitions cover filesystem, permissions, networking, module loading, streams, HTTP response lifecycle and JavaScript errors. Each has a specific explanation, likely causes and practical checks. Rubber-duck commentary has a distinct original line for every supported definition. No commands run automatically and unknown errors remain explicitly unrecognized.
6
+
7
+ ```sh
8
+ npx @deployanyway/error-translator ERR_HTTP_HEADERS_SENT --mode rubber-duck
9
+ npx @deployanyway/error-translator --catalog --json
10
+ npx @deployanyway/error-translator --list
11
+ ```
12
+
13
+ ```js
14
+ import { errorCatalog, translateError } from "@deployanyway/error-translator";
15
+ console.log(errorCatalog({ mode: "plain" }));
16
+ console.log(translateError({ code: "EACCES", message: "open config.json" }));
17
+ ```
18
+
19
+ `errorCatalog(options?)` returns independent structured translations for the complete catalog. `--catalog` prints all guidance, or JSON with `--json`. Explicit codes still take precedence over message matching. This is a focused Node/JavaScript debugging catalog, not diagnosis of every platform or framework error. Technical reference: https://nodejs.org/api/errors.html.
20
+
21
+ > **Version 0.4.0:** install from npm with Node 22.13+ or Node 24. See MIGRATION.md for changes from 0.2.0.
22
+
3
23
  [![npm version](https://img.shields.io/npm/v/%40deployanyway%2Ferror-translator)](https://www.npmjs.com/package/@deployanyway/error-translator)
4
24
  [![CI](https://github.com/DeployAnyway/error-translator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/DeployAnyway/error-translator/actions/workflows/ci.yml)
5
25
 
@@ -82,14 +102,54 @@ Invalid result shapes throw TypeError.
82
102
 
83
103
  ### Built-in errors
84
104
 
85
- | Code/name | Guidance |
86
- | -------------------- | ------------------------------------------ |
87
- | ECONNREFUSED | Service availability, host, port, firewall |
88
- | ENOENT | Missing paths and working directories |
89
- | EADDRINUSE | Port conflicts and duplicate instances |
90
- | MODULE_NOT_FOUND | CommonJS dependencies and paths |
91
- | ERR_MODULE_NOT_FOUND | ES module dependencies, paths, extensions |
92
- | TypeError | Unexpected types and null/undefined values |
105
+ | Code/name | Guidance |
106
+ | ------------------------------ | --------------------------------- |
107
+ | EACCES | Permission denied |
108
+ | EPERM | Operation not permitted |
109
+ | EEXIST | Target already exists |
110
+ | ENOTDIR | Expected a directory |
111
+ | EISDIR | Expected a file |
112
+ | ENOTEMPTY | Directory is not empty |
113
+ | EMFILE | Too many open files |
114
+ | ENFILE | System file table exhausted |
115
+ | ENOSPC | No space left |
116
+ | EROFS | Read-only filesystem |
117
+ | EBUSY | Resource busy |
118
+ | EXDEV | Cross-device operation |
119
+ | EPIPE | Broken pipe |
120
+ | ECONNRESET | Connection reset |
121
+ | ETIMEDOUT | Operation timed out |
122
+ | ENOTFOUND | Name lookup failed |
123
+ | EAI_AGAIN | Temporary name lookup failure |
124
+ | EADDRNOTAVAIL | Local address unavailable |
125
+ | ECONNABORTED | Connection aborted |
126
+ | ENETUNREACH | Network unreachable |
127
+ | EHOSTUNREACH | Host unreachable |
128
+ | EINVAL | Invalid argument |
129
+ | ABORT_ERR | Operation aborted |
130
+ | ERR_INVALID_ARG_TYPE | Wrong argument type |
131
+ | ERR_INVALID_ARG_VALUE | Invalid argument value |
132
+ | ERR_OUT_OF_RANGE | Value outside allowed range |
133
+ | ERR_HTTP_HEADERS_SENT | Headers already sent |
134
+ | ERR_HTTP_INVALID_STATUS_CODE | Invalid HTTP status |
135
+ | ERR_INVALID_URL | Invalid URL |
136
+ | ERR_PACKAGE_PATH_NOT_EXPORTED | Package path not exported |
137
+ | ERR_PACKAGE_IMPORT_NOT_DEFINED | Package import not defined |
138
+ | ERR_INVALID_PACKAGE_CONFIG | Invalid package configuration |
139
+ | ERR_UNKNOWN_FILE_EXTENSION | Unknown module file extension |
140
+ | ERR_IMPORT_ATTRIBUTE_MISSING | Required import attribute missing |
141
+ | ERR_STREAM_WRITE_AFTER_END | Write after stream end |
142
+ | ERR_STREAM_DESTROYED | Stream destroyed |
143
+ | ERR_SOCKET_BAD_PORT | Invalid socket port |
144
+ | SyntaxError | Invalid JavaScript syntax |
145
+ | ReferenceError | Name is not available |
146
+ | RangeError | Value exceeds a permitted range |
147
+ | ECONNREFUSED | Connection refused |
148
+ | ENOENT | File or directory not found |
149
+ | EADDRINUSE | Address already in use |
150
+ | MODULE_NOT_FOUND | Module not found |
151
+ | ERR_MODULE_NOT_FOUND | ES module not found |
152
+ | TypeError | Unexpected value type |
93
153
 
94
154
  Translations describe likely causes, not a diagnosis. Keep the original error
95
155
  and stack trace for context. No AI API or remote service is used.
@@ -158,3 +218,44 @@ API (import the named functions from this package):
158
218
  ```js
159
219
  translateError("ENOENT", { mode: "rubber-duck" });
160
220
  ```
221
+
222
+ ## Ordered error batches and pipes
223
+
224
+ ```js
225
+ import { translateErrors, listErrors } from "@deployanyway/error-translator";
226
+ const results = translateErrors(["ENOENT", { code: "ECONNREFUSED" }], {
227
+ mode: "rubber-duck",
228
+ });
229
+ console.log(results[0].suggestions);
230
+ console.log(listErrors());
231
+ ```
232
+
233
+ Batches accept 1–100 errors in order, fail on malformed entries and return independent arrays. This is deterministic guidance, not diagnosis. Unknown errors remain unknown: keep the original stack.
234
+
235
+ ```sh
236
+ echo "ECONNREFUSED" | node bin/cli.js --mode rubber-duck
237
+ node bin/cli.js --batch --json < errors.json
238
+ node bin/cli.js --list --json
239
+ ```
240
+
241
+ Without arguments, read UTF-8 stdin (maximum 256 KiB). Arguments take precedence. --batch expects a JSON array; --json emits an array of results. --list catalogs supported codes. Status 0 means translated, including unknown errors; status 2 means invalid input.
242
+
243
+ ## Run from source
244
+
245
+ ```sh
246
+ git clone --branch main https://github.com/DeployAnyway/error-translator.git
247
+ cd error-translator
248
+ npm ci
249
+ npm run build
250
+ node bin/cli.js --help
251
+ ```
252
+
253
+ ## Candidate quality standard
254
+
255
+ Version 0.3 provides useful declaration types, ESM/CommonJS exports, installed-archive checks, and coverage gates (90% statements/lines/functions, 85% branches). CI covers Linux Node 22/24 and Windows/macOS Node 24. Node 22.13+ is required. No runtime dependencies, telemetry or network requests.
256
+
257
+ From a source checkout: npm ci, npm run build, npm run coverage, npm run test:types, npm run verify:package. Pack verification installs a temporary local archive and checks module entries, types, executable and offline npm exec.
258
+
259
+ [Contribution guide](CONTRIBUTING.md) · [Conduct](CODE_OF_CONDUCT.md) · [Security](SECURITY.md) · [Roadmap](ROADMAP.md) · [Migration](MIGRATION.md).
260
+
261
+ **Tools for developers who probably know better.** Software nobody requested, built with questionable priorities, and shipped with absolute confidence!
package/bin/cli.js CHANGED
@@ -1,38 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import { parseArgs } from "node:util";
3
- import { URL } from "node:url";
4
- import { readFileSync } from "node:fs";
5
- import { translateError, renderTranslation } from "../src/index.js";
6
-
7
- try {
8
- const { values, positionals } = parseArgs({
9
- allowPositionals: true,
10
- options: {
11
- help: { type: "boolean", short: "h" },
12
- version: { type: "boolean", short: "v" },
13
- json: { type: "boolean" },
14
- mode: { type: "string", default: "plain" },
15
- },
16
- });
17
- if (values.help) {
18
- console.log(
19
- 'Usage: error-translator <error code or quoted message> [--json] [--mode plain|rubber-duck]\n\nTranslate errors into human-readable guidance.\n\nOptions:\n -h, --help Show help\n -v, --version Show version\n --json Print a structured JSON result\n --mode plain|rubber-duck Keep useful guidance; add duck commentary\n\nExamples:\n error-translator ECONNREFUSED\n error-translator "TypeError: value is not a function" --json\n\nExit codes: 0 translation/help/version; 2 invalid arguments.',
20
- );
21
- } else if (values.version) {
22
- console.log(
23
- JSON.parse(
24
- readFileSync(new URL("../package.json", import.meta.url), "utf8"),
25
- ).version,
26
- );
27
- } else {
28
- const result = translateError(positionals.join(" "), { mode: values.mode });
29
- console.log(
30
- values.json ? JSON.stringify(result, null, 2) : renderTranslation(result),
31
- );
32
- }
33
- } catch (error) {
34
- console.error(
35
- `error-translator: ${error.message}\nRun with --help for usage.`,
36
- );
37
- process.exitCode = 2;
38
- }
2
+ import "../src/cli.js";