@purpleturret/cli 0.5.0 → 0.7.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/README.md CHANGED
@@ -97,6 +97,8 @@ The CLI finds `purpleturret.config.{ts,mts,js,mjs,json}` in the current director
97
97
  | `stripe` | `{ priceId }` | Optional. Adopt an existing Stripe price on create. Immutable. |
98
98
  | `active` | `boolean` | Optional. Inactive products stop accepting checkouts. |
99
99
  | `buyerEmails` | `boolean` | Optional. `false` turns off Purpleturret's receipt, delivery and refund emails. |
100
+ | `tabTitle` | `string` | Optional. The checkout page's browser tab title, in place of `<name> — Purpleturret`. |
101
+ | `trustBadge` | `{ title?, caption?, logos: [{ imageUrl, alt }] }` | Optional. A row of https logos under the pay button (press, seals). `null` clears it. |
100
102
  | `offers` | `{ [key]: { title, subtitle? } }` | Optional. A note shown under the price when the link carries `?offer=<key>`. |
101
103
 
102
104
  **Rules to know before you edit:**
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import { existsSync } from "fs";
9
9
  import { join as join2 } from "path";
10
10
 
11
11
  // ../sdk/src/version.ts
12
- var SDK_VERSION = "0.5.0";
12
+ var SDK_VERSION = "0.7.0";
13
13
 
14
14
  // ../sdk/src/config/schema.ts
15
15
  import { z } from "zod";
@@ -82,7 +82,18 @@ var productInputSchema = z.strictObject({
82
82
  offers: z.record(
83
83
  z.string().regex(/^[a-z0-9-]{1,32}$/, "must be 1-32 characters of lowercase letters, digits, or '-'"),
84
84
  z.strictObject({ title: z.string().trim().min(1, "must not be empty").max(120), subtitle: z.string().trim().max(120).optional() })
85
- ).refine((offers) => Object.keys(offers).length <= 10, "must have 10 entries or fewer").optional()
85
+ ).refine((offers) => Object.keys(offers).length <= 10, "must have 10 entries or fewer").optional(),
86
+ tabTitle: z.string().trim().max(80).optional(),
87
+ trustBadge: z.strictObject({
88
+ title: z.string().trim().max(80).optional(),
89
+ caption: z.string().trim().max(80).optional(),
90
+ logos: z.array(
91
+ z.strictObject({
92
+ imageUrl: z.string().trim().max(500).regex(/^https:\/\/\S+$/, "must be an https URL"),
93
+ alt: z.string().trim().min(1).max(80)
94
+ })
95
+ ).min(1).max(12)
96
+ }).nullable().optional()
86
97
  });
87
98
  var configSchema = z.strictObject({
88
99
  products: z.array(productInputSchema)
@@ -177,7 +188,13 @@ function toWireProduct(input) {
177
188
  stripe: input.stripe ? { price_id: input.stripe.priceId } : void 0,
178
189
  active: input.active,
179
190
  buyer_emails: input.buyerEmails,
180
- offers: input.offers
191
+ offers: input.offers,
192
+ tab_title: input.tabTitle,
193
+ trust_badge: input.trustBadge && {
194
+ title: input.trustBadge.title,
195
+ caption: input.trustBadge.caption,
196
+ logos: input.trustBadge.logos.map((logo) => ({ image_url: logo.imageUrl, alt: logo.alt }))
197
+ }
181
198
  };
182
199
  return omitUndefined(wire);
183
200
  }
@@ -227,6 +244,12 @@ function fromWireProduct(wire) {
227
244
  active: wire.active,
228
245
  buyerEmails: wire.buyer_emails ?? void 0,
229
246
  offers: wire.offers,
247
+ tabTitle: wire.tab_title ?? void 0,
248
+ trustBadge: wire.trust_badge ? omitUndefined({
249
+ title: wire.trust_badge.title ?? void 0,
250
+ caption: wire.trust_badge.caption ?? void 0,
251
+ logos: wire.trust_badge.logos.map((logo) => ({ imageUrl: logo.image_url, alt: logo.alt }))
252
+ }) : void 0,
230
253
  bumps: wire.bumps ? camelizeKeys(wire.bumps) : void 0,
231
254
  upsell: wire.upsell === void 0 ? void 0 : wire.upsell && camelizeKeys(wire.upsell),
232
255
  pixelId: wire.pixel_id,
@@ -289,7 +312,9 @@ function productToInput(product3) {
289
312
  active: product3.active,
290
313
  // The API always reports buyer_emails; only the opt-out is worth writing into a config.
291
314
  buyerEmails: product3.buyerEmails === false ? false : void 0,
292
- offers: product3.offers && Object.keys(product3.offers).length > 0 ? product3.offers : void 0
315
+ offers: product3.offers && Object.keys(product3.offers).length > 0 ? product3.offers : void 0,
316
+ tabTitle: product3.tabTitle || void 0,
317
+ trustBadge: product3.trustBadge || void 0
293
318
  });
294
319
  }
295
320
  function fromWirePlanItem(item) {
@@ -1101,7 +1126,7 @@ function stripUndefined(value) {
1101
1126
  import dotenv from "dotenv";
1102
1127
 
1103
1128
  // src/version.ts
1104
- var CLI_VERSION = "0.5.0";
1129
+ var CLI_VERSION = "0.7.0";
1105
1130
 
1106
1131
  // src/lib/credentials.ts
1107
1132
  import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
@@ -3040,7 +3065,9 @@ var PRODUCT_KEY_ORDER = [
3040
3065
  "stripe",
3041
3066
  "active",
3042
3067
  "buyerEmails",
3043
- "offers"
3068
+ "offers",
3069
+ "tabTitle",
3070
+ "trustBadge"
3044
3071
  ];
3045
3072
  var IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
3046
3073
  function renderConfigSource(products2, format = "ts") {