@adkit/cli 1.12.4 → 1.12.8
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 +33 -17
- package/package.json +4 -1
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// ../shared/dist/utils/service-status.js
|
|
4
|
-
var ADKIT_STATUS_NOTICE = null;
|
|
5
|
-
function getAdKitStatusNotice() {
|
|
6
|
-
const statusNotice = ADKIT_STATUS_NOTICE?.trim();
|
|
7
|
-
return statusNotice ? `Active AdKit status notice: ${statusNotice}` : void 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
3
|
// src/config.ts
|
|
11
4
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
12
5
|
import { join } from "node:path";
|
|
@@ -72,6 +65,15 @@ function readLegacyProjectApiKey(config, selectedProject) {
|
|
|
72
65
|
return config.projects?.[selectedProject]?.apiKey ?? null;
|
|
73
66
|
}
|
|
74
67
|
|
|
68
|
+
// ../shared/dist/errors.js
|
|
69
|
+
function describeRetryDelay(retryAfterSeconds) {
|
|
70
|
+
if (!retryAfterSeconds || retryAfterSeconds <= 300)
|
|
71
|
+
return "in a few minutes";
|
|
72
|
+
if (retryAfterSeconds <= 3600)
|
|
73
|
+
return "within the hour";
|
|
74
|
+
return "in a few hours";
|
|
75
|
+
}
|
|
76
|
+
|
|
75
77
|
// src/errors.ts
|
|
76
78
|
var CliError = class extends Error {
|
|
77
79
|
code;
|
|
@@ -86,6 +88,19 @@ var CliError = class extends Error {
|
|
|
86
88
|
};
|
|
87
89
|
|
|
88
90
|
// src/client.ts
|
|
91
|
+
var noticePrinted = false;
|
|
92
|
+
function printServerNotice(response) {
|
|
93
|
+
if (noticePrinted) return;
|
|
94
|
+
const encoded = response.headers.get("x-adkit-notice");
|
|
95
|
+
if (!encoded) return;
|
|
96
|
+
noticePrinted = true;
|
|
97
|
+
const text = decodeURIComponent(encoded);
|
|
98
|
+
const dim = "\x1B[2m";
|
|
99
|
+
const yellow = "\x1B[33m";
|
|
100
|
+
const reset = "\x1B[0m";
|
|
101
|
+
process.stderr.write(`${yellow}${dim}[AdKit notice] ${text}${reset}
|
|
102
|
+
`);
|
|
103
|
+
}
|
|
89
104
|
function isErrorResponse(value) {
|
|
90
105
|
return value != null && typeof value === "object";
|
|
91
106
|
}
|
|
@@ -135,12 +150,14 @@ function appendErrorDetail(message, detail) {
|
|
|
135
150
|
}
|
|
136
151
|
function buildRetrySuggestion(retryable, retryAfterSeconds) {
|
|
137
152
|
if (retryable !== true) return void 0;
|
|
138
|
-
if (typeof retryAfterSeconds === "number") return `Wait ${String(retryAfterSeconds)} seconds before retrying`;
|
|
153
|
+
if (typeof retryAfterSeconds === "number" && retryAfterSeconds <= 300) return `Wait ${String(retryAfterSeconds)} seconds before retrying`;
|
|
154
|
+
if (typeof retryAfterSeconds === "number") return `Try again ${describeRetryDelay(retryAfterSeconds)}`;
|
|
139
155
|
return "Retry in a few seconds";
|
|
140
156
|
}
|
|
141
|
-
var AUTH_CODES = /* @__PURE__ */ new Set(["not_connected", "token_expired", "refresh_token_expired"]);
|
|
157
|
+
var AUTH_CODES = /* @__PURE__ */ new Set(["invalid_grant", "auth_error", "auth_expired", "not_connected", "token_expired", "refresh_token_expired"]);
|
|
142
158
|
function buildAuthSuggestion(code) {
|
|
143
|
-
|
|
159
|
+
const normalizedCode = code.toLowerCase();
|
|
160
|
+
if (!AUTH_CODES.has(normalizedCode)) return void 0;
|
|
144
161
|
return "Run: adkit setup manage";
|
|
145
162
|
}
|
|
146
163
|
var AdkitClient = class {
|
|
@@ -178,6 +195,7 @@ var AdkitClient = class {
|
|
|
178
195
|
const detail = code ?? (err instanceof Error ? err.message : String(err));
|
|
179
196
|
throw new CliError("NETWORK_ERROR", `Cannot reach ${target} (${detail})`, "Verify your network connection");
|
|
180
197
|
}
|
|
198
|
+
printServerNotice(response);
|
|
181
199
|
if (response.status === 204) return void 0;
|
|
182
200
|
if (!response.ok) {
|
|
183
201
|
let serverMessage = "";
|
|
@@ -4552,7 +4570,7 @@ var GOOGLE_CAMPAIGN_HELP = `adkit manage google campaigns \u2014 Google Ads camp
|
|
|
4552
4570
|
create Create a campaign
|
|
4553
4571
|
update <id> Update a campaign
|
|
4554
4572
|
delete <id> Delete a campaign
|
|
4555
|
-
<id> View campaign details
|
|
4573
|
+
<id> View campaign details (PMAX includes assetGroups)
|
|
4556
4574
|
|
|
4557
4575
|
Flags (create):
|
|
4558
4576
|
--name <name> Campaign name (required)
|
|
@@ -4578,6 +4596,7 @@ Note:
|
|
|
4578
4596
|
Advanced geo examples: adkit manage google campaigns --help full
|
|
4579
4597
|
Display creation starts here: campaigns create --campaign-type display, then create Display ad groups and responsive_display ads.
|
|
4580
4598
|
Performance Max: campaignType "performance_max" with asset groups \u2014 build it with --data. See --help full.
|
|
4599
|
+
View a Performance Max campaign by ID to read back its assetGroups from Google.
|
|
4581
4600
|
For spend/clicks/conversions: adkit manage google results
|
|
4582
4601
|
|
|
4583
4602
|
Examples:
|
|
@@ -4594,7 +4613,7 @@ var GOOGLE_CAMPAIGN_HELP_FULL = `adkit manage google campaigns \u2014 Google Ads
|
|
|
4594
4613
|
create Create a campaign
|
|
4595
4614
|
update <id> Update a campaign
|
|
4596
4615
|
delete <id> Delete a campaign
|
|
4597
|
-
<id> View campaign details
|
|
4616
|
+
<id> View campaign details (PMAX includes assetGroups)
|
|
4598
4617
|
|
|
4599
4618
|
Flags (create):
|
|
4600
4619
|
--name <name> Campaign name (required)
|
|
@@ -4628,6 +4647,7 @@ Notes:
|
|
|
4628
4647
|
Google excludes support location geo target constants, not proximity radius exclusions.
|
|
4629
4648
|
Display campaign creation uses campaignType:"display" or --campaign-type display. Videos are not supported for Display media in v1.
|
|
4630
4649
|
Performance Max: campaignType "performance_max" with exactly one assetGroups[] entry. Text assets inline ({role,text}); image assets are uploaded via google media first, then referenced by id/resourceName. Needs an enabled conversion action (publish is blocked without one). Non-retail only. Build it with --data.
|
|
4650
|
+
View a Performance Max campaign by ID to read back assetGroups from Google. There is no separate google asset-groups command.
|
|
4631
4651
|
For spend/clicks/conversions: adkit manage google results
|
|
4632
4652
|
|
|
4633
4653
|
Examples:
|
|
@@ -6442,11 +6462,7 @@ function showHelp(key, full = false) {
|
|
|
6442
6462
|
return false;
|
|
6443
6463
|
}
|
|
6444
6464
|
function printHelp(text) {
|
|
6445
|
-
|
|
6446
|
-
const helpText = statusNotice ? `${statusNotice}
|
|
6447
|
-
|
|
6448
|
-
${text}` : text;
|
|
6449
|
-
console.log(helpText);
|
|
6465
|
+
console.log(text);
|
|
6450
6466
|
}
|
|
6451
6467
|
async function selfUpdate(currentVersion) {
|
|
6452
6468
|
const { execSync } = await import("node:child_process");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adkit/cli",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.8",
|
|
4
4
|
"description": "The Ads CLI for AI agents — manage Meta & Google ad campaigns, browse the ad library, and generate creatives from your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ads cli",
|
|
@@ -34,6 +34,9 @@
|
|
|
34
34
|
"build": "esbuild src/cli.ts --bundle --format=esm --platform=node --target=node18 --outfile=dist/cli.js --banner:js='#!/usr/bin/env node'",
|
|
35
35
|
"release": "cd ../shared && npm run build && cd ../cli && npm version patch && npm run build && npm publish --access public"
|
|
36
36
|
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"open": "^10.2.0"
|
|
39
|
+
},
|
|
37
40
|
"devDependencies": {
|
|
38
41
|
"@adkit/shared": "*",
|
|
39
42
|
"@types/node": "^20.10.0",
|