@koda-sl/baker-cli 0.342.0 → 0.343.0-dev.69293e822

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
@@ -67,7 +67,7 @@ import {
67
67
  validateCanvasDeep,
68
68
  withoutCastName,
69
69
  ytDlpBlockSignal
70
- } from "./chunk-FFOURYP5.js";
70
+ } from "./chunk-D5P4COPD.js";
71
71
  import {
72
72
  csvOrJson,
73
73
  daysAgoIso,
@@ -17043,6 +17043,101 @@ Examples:
17043
17043
  // src/commands/ads/google/write-commands.ts
17044
17044
  import { defineCommand as defineCommand31 } from "citty";
17045
17045
 
17046
+ // src/commands/ads/google/ad-copy-flags.ts
17047
+ var AD_COPY_LIST_FLAGS = ["headlines", "descriptions", "long-headlines"];
17048
+ var AD_COPY_LIST_USAGE = `repeat the flag once per item (safe for copy with commas), or pass one comma-separated list and wrap an item that contains a comma in double quotes: '"Fast, free quotes",Book today'`;
17049
+ function skipBlanks(value, at) {
17050
+ let i = at;
17051
+ while (value[i] === " " || value[i] === " ") i++;
17052
+ return i;
17053
+ }
17054
+ function readQuotedField(value, open, flag) {
17055
+ let text2 = "";
17056
+ let j = open + 1;
17057
+ while (!(value[j] === '"' && value[j + 1] !== '"')) {
17058
+ if (j >= value.length) {
17059
+ failWriteValidation(`--${flag} has a quote with no closing quote: ${value} \u2014 ${AD_COPY_LIST_USAGE}`);
17060
+ }
17061
+ text2 += value[j];
17062
+ j += value[j] === '"' ? 2 : 1;
17063
+ }
17064
+ const after = skipBlanks(value, j + 1);
17065
+ if (after < value.length && value[after] !== ",") {
17066
+ failWriteValidation(
17067
+ `--${flag}: text follows the closing quote of "${text2}" \u2014 a quoted item must end at a comma. To put a quote inside an item, double it ("") or ${AD_COPY_LIST_USAGE}`
17068
+ );
17069
+ }
17070
+ return { text: text2, next: after + 1 };
17071
+ }
17072
+ function splitQuotedList(value, flag) {
17073
+ const fields = [];
17074
+ let i = 0;
17075
+ while (i <= value.length) {
17076
+ const start = skipBlanks(value, i);
17077
+ if (value[start] === '"') {
17078
+ const { text: text2, next } = readQuotedField(value, start, flag);
17079
+ fields.push({ text: text2, quoted: true });
17080
+ i = next;
17081
+ } else {
17082
+ const comma = value.indexOf(",", start);
17083
+ const end = comma === -1 ? value.length : comma;
17084
+ fields.push({ text: value.slice(start, end), quoted: false });
17085
+ i = end + 1;
17086
+ }
17087
+ }
17088
+ const several = fields.length > 1;
17089
+ return fields.map((field) => ({ text: field.text.trim(), splitAtComma: several && !field.quoted }));
17090
+ }
17091
+ function jsonStringArray(value) {
17092
+ if (!value.startsWith("[")) return void 0;
17093
+ try {
17094
+ const parsed = JSON.parse(value);
17095
+ return Array.isArray(parsed) && parsed.every((v) => typeof v === "string") ? parsed : void 0;
17096
+ } catch {
17097
+ return void 0;
17098
+ }
17099
+ }
17100
+ function parseCopyList(value, flag) {
17101
+ let items;
17102
+ if (Array.isArray(value)) {
17103
+ items = value.filter((v) => typeof v === "string").map((v) => ({ text: v.trim(), splitAtComma: false }));
17104
+ } else if (typeof value === "string") {
17105
+ const trimmed = value.trim();
17106
+ const json = jsonStringArray(trimmed);
17107
+ items = json ? json.map((v) => ({ text: v.trim(), splitAtComma: false })) : splitQuotedList(trimmed, flag);
17108
+ } else {
17109
+ return void 0;
17110
+ }
17111
+ const kept = items.filter((item) => item.text.length > 0);
17112
+ return kept.length > 0 ? kept : void 0;
17113
+ }
17114
+ function copyListFlag(value, flag) {
17115
+ return parseCopyList(value, flag)?.map((item) => item.text);
17116
+ }
17117
+ function withRepeatedCopyFlags(args5, rawArgs) {
17118
+ const out = { ...args5 };
17119
+ for (const flag of AD_COPY_LIST_FLAGS) {
17120
+ const values = repeatedFlagValues(rawArgs ?? [], flag);
17121
+ if (values.length > 1) {
17122
+ out[flag] = values;
17123
+ }
17124
+ }
17125
+ return out;
17126
+ }
17127
+ function copyListSplitHints(args5) {
17128
+ const hints2 = [];
17129
+ for (const flag of AD_COPY_LIST_FLAGS) {
17130
+ const items = parseCopyList(args5[flag], flag) ?? [];
17131
+ const fragments = items.filter((item, index) => index > 0 && item.splitAtComma && new RegExp("^\\p{Ll}", "u").test(item.text));
17132
+ if (fragments.length > 0) {
17133
+ hints2.push(
17134
+ `--${flag}: ${fragments.map((f) => `"${f.text}"`).join(", ")} starts in lowercase \u2014 it looks like the end of one item cut at a comma. Check the staged copy; if it was one item, re-stage and ${AD_COPY_LIST_USAGE}.`
17135
+ );
17136
+ }
17137
+ }
17138
+ return hints2;
17139
+ }
17140
+
17046
17141
  // src/commands/ads/google/conversion-upload-command.ts
17047
17142
  import { readFileSync as readFileSync4 } from "fs";
17048
17143
  import { defineCommand as defineCommand30 } from "citty";
@@ -18098,10 +18193,10 @@ var keywordListsCommand = defineCommand31({
18098
18193
  }
18099
18194
  });
18100
18195
  function rsaContentFromFlags(args5) {
18101
- const headlines = listFlag(args5.headlines);
18102
- const descriptions = listFlag(args5.descriptions);
18196
+ const headlines = copyListFlag(args5.headlines, "headlines");
18197
+ const descriptions = copyListFlag(args5.descriptions, "descriptions");
18103
18198
  if (!headlines || !descriptions) {
18104
- failWriteValidation("responsive search ads need --headlines and --descriptions (comma-separated), or use --file");
18199
+ failWriteValidation("responsive search ads need --headlines and --descriptions, or use --file");
18105
18200
  }
18106
18201
  const finalUrls = listFlag(args5["final-url"]);
18107
18202
  if (!finalUrls) {
@@ -18121,11 +18216,11 @@ function rdaContentFromFlags(args5, base) {
18121
18216
  format: "responsiveDisplay",
18122
18217
  ...base !== null && typeof base === "object" && !Array.isArray(base) ? base : {}
18123
18218
  };
18124
- const headlines = listFlag(args5.headlines);
18219
+ const headlines = copyListFlag(args5.headlines, "headlines");
18125
18220
  if (headlines) {
18126
18221
  content.headlines = headlines.map((text2) => ({ text: text2 }));
18127
18222
  }
18128
- const descriptions = listFlag(args5.descriptions);
18223
+ const descriptions = copyListFlag(args5.descriptions, "descriptions");
18129
18224
  if (descriptions) {
18130
18225
  content.descriptions = descriptions.map((text2) => ({ text: text2 }));
18131
18226
  }
@@ -18176,11 +18271,11 @@ function demandGenContentFromFlags(args5, base) {
18176
18271
  if (typeof args5["ad-name"] === "string") {
18177
18272
  content.name = args5["ad-name"];
18178
18273
  }
18179
- const headlines = listFlag(args5.headlines);
18274
+ const headlines = copyListFlag(args5.headlines, "headlines");
18180
18275
  if (headlines) {
18181
18276
  content.headlines = headlines.map((text2) => ({ text: text2 }));
18182
18277
  }
18183
- const descriptions = listFlag(args5.descriptions);
18278
+ const descriptions = copyListFlag(args5.descriptions, "descriptions");
18184
18279
  if (descriptions) {
18185
18280
  content.descriptions = descriptions.map((text2) => ({ text: text2 }));
18186
18281
  }
@@ -18213,15 +18308,15 @@ function demandGenVideoContentFromFlags(args5, base) {
18213
18308
  if (typeof args5["ad-name"] === "string") {
18214
18309
  content.name = args5["ad-name"];
18215
18310
  }
18216
- const headlines = listFlag(args5.headlines);
18311
+ const headlines = copyListFlag(args5.headlines, "headlines");
18217
18312
  if (headlines) {
18218
18313
  content.headlines = headlines.map((text2) => ({ text: text2 }));
18219
18314
  }
18220
- const longHeadlines = listFlag(args5["long-headlines"]);
18315
+ const longHeadlines = copyListFlag(args5["long-headlines"], "long-headlines");
18221
18316
  if (longHeadlines) {
18222
18317
  content.longHeadlines = longHeadlines.map((text2) => ({ text: text2 }));
18223
18318
  }
18224
- const descriptions = listFlag(args5.descriptions);
18319
+ const descriptions = copyListFlag(args5.descriptions, "descriptions");
18225
18320
  if (descriptions) {
18226
18321
  content.descriptions = descriptions.map((text2) => ({ text: text2 }));
18227
18322
  }
@@ -18251,11 +18346,11 @@ function appContentFromFlags(args5, base) {
18251
18346
  format: "app",
18252
18347
  ...base !== null && typeof base === "object" && !Array.isArray(base) ? base : {}
18253
18348
  };
18254
- const headlines = listFlag(args5.headlines);
18349
+ const headlines = copyListFlag(args5.headlines, "headlines");
18255
18350
  if (headlines) {
18256
18351
  content.headlines = headlines.map((text2) => ({ text: text2 }));
18257
18352
  }
18258
- const descriptions = listFlag(args5.descriptions);
18353
+ const descriptions = copyListFlag(args5.descriptions, "descriptions");
18259
18354
  if (descriptions) {
18260
18355
  content.descriptions = descriptions.map((text2) => ({ text: text2 }));
18261
18356
  }
@@ -18357,10 +18452,13 @@ var adContentArgs = {
18357
18452
  type: "string",
18358
18453
  description: "responsiveSearch (default) | responsiveDisplay | call | app | video | demandGen | demandGenVideo"
18359
18454
  },
18360
- headlines: { type: "string", description: "Comma-separated headlines (RSA/RDA/demandGen/demandGenVideo/app)" },
18455
+ headlines: {
18456
+ type: "string",
18457
+ description: `Headlines (RSA/RDA/demandGen/demandGenVideo/app) \u2014 ${AD_COPY_LIST_USAGE}`
18458
+ },
18361
18459
  descriptions: {
18362
18460
  type: "string",
18363
- description: "Comma-separated descriptions (RSA/RDA/demandGen/demandGenVideo/app)"
18461
+ description: `Descriptions (RSA/RDA/demandGen/demandGenVideo/app) \u2014 ${AD_COPY_LIST_USAGE}`
18364
18462
  },
18365
18463
  path1: { type: "string" },
18366
18464
  path2: { type: "string" },
@@ -18371,7 +18469,7 @@ var adContentArgs = {
18371
18469
  },
18372
18470
  "long-headlines": {
18373
18471
  type: "string",
18374
- description: "Comma-separated long headlines, up to 5 of 90 chars (demandGenVideo \u2014 no other format has them)"
18472
+ description: `Long headlines, up to 5 of 90 chars (demandGenVideo \u2014 no other format has them) \u2014 ${AD_COPY_LIST_USAGE}`
18375
18473
  },
18376
18474
  "business-name": { type: "string", description: "Business name (responsiveDisplay/demandGen/demandGenVideo)" },
18377
18475
  "marketing-images": {
@@ -18422,16 +18520,22 @@ var adsCommand = defineCommand31({
18422
18520
  ...adContentArgs,
18423
18521
  status: { type: "string" }
18424
18522
  },
18425
- run: async ({ args: args5 }) => {
18523
+ run: async ({ args: parsedArgs, rawArgs }) => {
18524
+ const args5 = withRepeatedCopyFlags(parsedArgs, rawArgs);
18426
18525
  const customerId = requireCustomerId(args5);
18427
18526
  const file = loadJsonFileArg(args5.file);
18428
18527
  const format = args5.format ?? "responsiveSearch";
18429
18528
  const content = adContentFromFlags(args5, format, file.content);
18430
- await stageCreate("google.ad.create", customerId, {
18431
- adGroup: requireStringFlag(args5["ad-group-ref"] ?? file.adGroup, "--ad-group-ref"),
18432
- status: args5.status ?? file.status,
18433
- content
18434
- });
18529
+ await stageCreate(
18530
+ "google.ad.create",
18531
+ customerId,
18532
+ {
18533
+ adGroup: requireStringFlag(args5["ad-group-ref"] ?? file.adGroup, "--ad-group-ref"),
18534
+ status: args5.status ?? file.status,
18535
+ content
18536
+ },
18537
+ copyListSplitHints(args5)
18538
+ );
18435
18539
  }
18436
18540
  }),
18437
18541
  update: defineCommand31({
@@ -18440,7 +18544,8 @@ var adsCommand = defineCommand31({
18440
18544
  description: "Stage an ad update. Any content change needs --format plus EVERY required field of that format (or --file with the complete content) \u2014 a field you send replaces its current value wholesale, so a list you pass must already include the entries you want to keep. Optional asset lists you omit entirely are left untouched on the ad. Status-only changes need neither --format nor content flags."
18441
18545
  },
18442
18546
  args: { ...customerIdArg, ...fileArg, ...adContentArgs, status: { type: "string" } },
18443
- run: async ({ args: args5 }) => {
18547
+ run: async ({ args: parsedArgs, rawArgs }) => {
18548
+ const args5 = withRepeatedCopyFlags(parsedArgs, rawArgs);
18444
18549
  const customerId = requireCustomerId(args5);
18445
18550
  const file = loadJsonFileArg(args5.file);
18446
18551
  const format = args5.format;
@@ -18454,7 +18559,8 @@ var adsCommand = defineCommand31({
18454
18559
  await stageUpdate("google.ad.update", customerId, requireTarget(args5, "ad"), payload, [
18455
18560
  ...payload.content !== void 0 ? [
18456
18561
  "Each content field you sent replaces its current value wholesale at publish \u2014 re-check that every headline, description, final URL and asset you want to KEEP is in this payload, not just the ones you changed."
18457
- ] : []
18562
+ ] : [],
18563
+ ...format ? copyListSplitHints(args5) : []
18458
18564
  ]);
18459
18565
  }
18460
18566
  }),
@@ -18483,9 +18589,9 @@ var assetGroupsCommand = defineCommand31({
18483
18589
  },
18484
18590
  name: { type: "string", description: "Asset group name" },
18485
18591
  "final-urls": { type: "string", description: "Comma-separated final URLs" },
18486
- headlines: { type: "string", description: "Comma-separated headlines (3\u201315, \u226430 chars)" },
18487
- "long-headlines": { type: "string", description: "Comma-separated long headlines (1\u20135, \u226490 chars)" },
18488
- descriptions: { type: "string", description: "Comma-separated descriptions (2\u20135, \u226490 chars)" },
18592
+ headlines: { type: "string", description: `Headlines (3\u201315, \u226430 chars) \u2014 ${AD_COPY_LIST_USAGE}` },
18593
+ "long-headlines": { type: "string", description: `Long headlines (1\u20135, \u226490 chars) \u2014 ${AD_COPY_LIST_USAGE}` },
18594
+ descriptions: { type: "string", description: `Descriptions (2\u20135, \u226490 chars) \u2014 ${AD_COPY_LIST_USAGE}` },
18489
18595
  "business-name": { type: "string" },
18490
18596
  "image-assets": { type: "string", description: "Comma-separated marketing image asset refs (1.91:1)" },
18491
18597
  "square-image-assets": {
@@ -18499,11 +18605,12 @@ var assetGroupsCommand = defineCommand31({
18499
18605
  "logo-assets": { type: "string", description: "Comma-separated logo image asset refs" },
18500
18606
  status: { type: "string", description: "ENABLED | PAUSED (default PAUSED)" }
18501
18607
  },
18502
- run: async ({ args: args5 }) => {
18608
+ run: async ({ args: parsedArgs, rawArgs }) => {
18609
+ const args5 = withRepeatedCopyFlags(parsedArgs, rawArgs);
18503
18610
  const customerId = requireCustomerId(args5);
18504
- const headlines = listFlag(args5.headlines);
18505
- const longHeadlines = listFlag(args5["long-headlines"]);
18506
- const descriptions = listFlag(args5.descriptions);
18611
+ const headlines = copyListFlag(args5.headlines, "headlines");
18612
+ const longHeadlines = copyListFlag(args5["long-headlines"], "long-headlines");
18613
+ const descriptions = copyListFlag(args5.descriptions, "descriptions");
18507
18614
  const payload = mergePayload(loadJsonFileArg(args5.file), {
18508
18615
  campaign: args5["campaign-ref"],
18509
18616
  name: args5.name,
@@ -18518,7 +18625,7 @@ var assetGroupsCommand = defineCommand31({
18518
18625
  logoAssets: listFlag(args5["logo-assets"]),
18519
18626
  status: args5.status
18520
18627
  });
18521
- await stageCreate("google.assetGroup.create", customerId, payload);
18628
+ await stageCreate("google.assetGroup.create", customerId, payload, copyListSplitHints(args5));
18522
18629
  }
18523
18630
  }),
18524
18631
  update: defineCommand31({