@adkit.so/cli 1.0.2 → 1.0.3
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/cli.js +8 -1
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -96,7 +96,14 @@ var AdkitClient = class {
|
|
|
96
96
|
response = await fetch(url, init);
|
|
97
97
|
} catch (err) {
|
|
98
98
|
if (err instanceof DOMException && err.name === "AbortError") throw new CliError("NETWORK_ERROR", "Request timed out", "Retry the command");
|
|
99
|
-
|
|
99
|
+
const code = err instanceof Error && err.cause != null && typeof err.cause === "object" && "code" in err.cause && typeof err.cause.code === "string" ? err.cause.code : void 0;
|
|
100
|
+
const isCustomUrl = !!process.env.ADKIT_BASE_URL;
|
|
101
|
+
const target = isCustomUrl ? `API at ${this.baseUrl}` : `AdKit API (${this.baseUrl})`;
|
|
102
|
+
if (code === "ECONNREFUSED") throw new CliError("NETWORK_ERROR", `Connection refused \u2014 ${target} is not running`, isCustomUrl ? "Start the server or check ADKIT_BASE_URL" : "The API may be down \u2014 try again in a moment");
|
|
103
|
+
if (code === "ENOTFOUND") throw new CliError("NETWORK_ERROR", `DNS lookup failed for ${this.baseUrl}`, "Verify your network connection");
|
|
104
|
+
if (code === "ETIMEDOUT" || code === "UND_ERR_CONNECT_TIMEOUT") throw new CliError("NETWORK_ERROR", `Connection to ${target} timed out`, "Verify your network connection");
|
|
105
|
+
const detail = code ?? (err instanceof Error ? err.message : String(err));
|
|
106
|
+
throw new CliError("NETWORK_ERROR", `Cannot reach ${target} (${detail})`, "Verify your network connection");
|
|
100
107
|
}
|
|
101
108
|
if (response.status === 204) return void 0;
|
|
102
109
|
if (!response.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adkit.so/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "AdKit CLI — manage campaigns and accounts from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "esbuild src/cli.ts --bundle --format=esm --platform=node --target=node18 --outfile=dist/cli.js --banner:js='#!/usr/bin/env node'"
|
|
13
|
+
"build": "esbuild src/cli.ts --bundle --format=esm --platform=node --target=node18 --outfile=dist/cli.js --banner:js='#!/usr/bin/env node'",
|
|
14
|
+
"release": "npm version patch && npm run build && npm publish --access public"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/node": "^20.10.0",
|