@koda-sl/baker-cli 0.369.0 → 0.370.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/dist/cli.js CHANGED
@@ -12051,6 +12051,41 @@ function adCopyHints(payload) {
12051
12051
  return tells.slice(0, MAX_HINTS).map(hintFor);
12052
12052
  }
12053
12053
 
12054
+ // src/commands/ads/google/copy-list-usage.ts
12055
+ var AD_COPY_LIST_USAGE = `repeat the flag once per item, or pass one comma-separated list and wrap an item that contains a comma in double quotes: '"Fast, free quotes",Book today'. A flag given once is read as a list, so a lone item with a comma needs its double quotes too: '"Fast, free quotes"'`;
12056
+ var COPY_LIST_FLAG = {
12057
+ headlines: "--headlines",
12058
+ descriptions: "--descriptions",
12059
+ longHeadlines: "--long-headlines"
12060
+ };
12061
+ function valueAt(root, path48) {
12062
+ let node = root;
12063
+ for (const key of path48) {
12064
+ if (node === null || typeof node !== "object") return void 0;
12065
+ node = node[key];
12066
+ }
12067
+ return node;
12068
+ }
12069
+ function countRefusal(op, issue) {
12070
+ if (issue.code !== "too_big" && issue.code !== "too_small" || issue.origin !== "array") return void 0;
12071
+ const flag = COPY_LIST_FLAG[String(issue.path.at(-1))];
12072
+ if (!flag) return void 0;
12073
+ const value = valueAt(op, issue.path);
12074
+ const count2 = Array.isArray(value) ? value.length : void 0;
12075
+ return issue.code === "too_big" ? { flag, count: count2, bound: `at most ${issue.maximum}`, tooMany: true } : { flag, count: count2, bound: `at least ${issue.minimum}`, tooMany: false };
12076
+ }
12077
+ function copyListCountFix(op, issues) {
12078
+ const refusals = issues.map((issue) => countRefusal(op, issue));
12079
+ if (refusals.length === 0 || refusals.some((refusal) => refusal === void 0)) return void 0;
12080
+ const counted = refusals.filter((refusal) => refusal !== void 0);
12081
+ const limits = counted.map(({ flag, count: count2, bound }) => `${flag} has ${count2 ?? "the wrong number of"} items; this ad takes ${bound}.`).join(" ");
12082
+ const commaCause = counted.some((refusal) => refusal.tooMany) ? ` If you meant fewer items, the copy was cut at its commas: a flag given once is read as a comma-separated list, so an item with a comma in it ("Fast, free quotes", a decimal like "4,5/5") becomes two. To keep a comma, ${AD_COPY_LIST_USAGE} \u2014 or put the content in --file as JSON.` : "";
12083
+ return {
12084
+ action: "fix_copy_list_count",
12085
+ explanation: `${limits}${commaCause} ${commaCause ? "Otherwise add" : "Add"} or drop items to fit the limit, then stage again; the field names are right.`
12086
+ };
12087
+ }
12088
+
12054
12089
  // src/commands/ads/google/draft-status.ts
12055
12090
  var OPERATION_LABELS = {
12056
12091
  create: "Creating",
@@ -12371,7 +12406,7 @@ async function stageGoogleOp(raw, hints2) {
12371
12406
  code: "VALIDATION_ERROR",
12372
12407
  message: fields.map((f) => f.path ? `${f.path}: ${f.message}` : f.message).join("; "),
12373
12408
  fields,
12374
- fix: capabilityFix("google-ads")
12409
+ fix: copyListCountFix(raw, preflight.error.issues) ?? capabilityFix("google-ads")
12375
12410
  }
12376
12411
  });
12377
12412
  process.exit(1);
@@ -12407,7 +12442,7 @@ async function stageGoogleOps(rawOps, hints2) {
12407
12442
  code: "VALIDATION_ERROR",
12408
12443
  message: fields.map((f) => `${f.path}: ${f.message}`).join("; "),
12409
12444
  fields,
12410
- fix: capabilityFix("google-ads")
12445
+ fix: copyListCountFix(raw, preflight.error.issues) ?? capabilityFix("google-ads")
12411
12446
  }
12412
12447
  });
12413
12448
  process.exit(1);
@@ -17858,7 +17893,6 @@ import { defineCommand as defineCommand31 } from "citty";
17858
17893
 
17859
17894
  // src/commands/ads/google/ad-copy-flags.ts
17860
17895
  var AD_COPY_LIST_FLAGS = ["headlines", "descriptions", "long-headlines"];
17861
- var AD_COPY_LIST_USAGE = `repeat the flag once per item, or pass one comma-separated list and wrap an item that contains a comma in double quotes: '"Fast, free quotes",Book today'. A flag given once is read as a list, so a lone item with a comma needs its double quotes too: '"Fast, free quotes"'`;
17862
17896
  function skipBlanks(value, at) {
17863
17897
  let i = at;
17864
17898
  while (value[i] === " " || value[i] === " ") i++;