@pmate/cli 0.22.0 → 0.23.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.
Files changed (2) hide show
  1. package/dist/index.js +36 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17254,6 +17254,7 @@ var IOS_ICON_SPECS = [
17254
17254
  var pngToIco = require("png-to-ico").default;
17255
17255
  var APP_ICON_VARIANT_KEY_PATTERN = /^[a-z0-9]+$/;
17256
17256
  var DATA_URL_PATTERN = /^data:([^;,]+);base64,([a-z0-9+/=]+)$/i;
17257
+ var DEFAULT_APP_ICON_VARIANT_NAME = "webp512x512";
17257
17258
  function normalizeAppIcon(icon, cwd) {
17258
17259
  if (typeof icon !== "string" || !icon.trim()) {
17259
17260
  throw new Error("App icon must be a non-empty http(s) URL.");
@@ -17270,7 +17271,7 @@ function normalizeAppIcon(icon, cwd) {
17270
17271
  }
17271
17272
  throw new Error("App icon must be an http(s) URL. Upload SVG files to OSS first and use the public link.");
17272
17273
  }
17273
- function prepareAppPayload(payload, cwd) {
17274
+ async function prepareAppPayload(payload, cwd) {
17274
17275
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
17275
17276
  throw new Error("App payload must be a JSON object.");
17276
17277
  }
@@ -17281,6 +17282,13 @@ function prepareAppPayload(payload, cwd) {
17281
17282
  if (normalized.icons !== void 0) {
17282
17283
  normalized.icons = normalizeAppIconVariants(normalized.icons);
17283
17284
  }
17285
+ if (typeof normalized.icon === "string" && shouldAutoGenerateDefaultVariant(normalized.icon)) {
17286
+ normalized.icons = await withDefaultSvgIconVariant(
17287
+ normalized.icon,
17288
+ normalized.icons,
17289
+ cwd
17290
+ );
17291
+ }
17284
17292
  return normalized;
17285
17293
  }
17286
17294
  function normalizeAppIconVariants(input) {
@@ -17430,6 +17438,17 @@ async function renderAppIcon(svg, width, height, format) {
17430
17438
  function looksLikeSvgMarkup(value) {
17431
17439
  return /<svg[\s>]/i.test(value);
17432
17440
  }
17441
+ function looksLikeSvgUrl(value) {
17442
+ try {
17443
+ const url = new URL(value);
17444
+ return url.pathname.toLowerCase().endsWith(".svg");
17445
+ } catch {
17446
+ return false;
17447
+ }
17448
+ }
17449
+ function shouldAutoGenerateDefaultVariant(icon) {
17450
+ return looksLikeSvgMarkup(icon) || looksLikeSvgUrl(icon);
17451
+ }
17433
17452
  function inferVariantFormatFromPath(filePath) {
17434
17453
  const ext = import_node_path20.default.extname(filePath).toLowerCase();
17435
17454
  switch (ext) {
@@ -17468,6 +17487,19 @@ function isSupportedImageDataUrl(value) {
17468
17487
  const mimeType = match[1]?.toLowerCase();
17469
17488
  return mimeType === "image/png" || mimeType === "image/webp" || mimeType === "image/svg+xml" || mimeType === "image/x-icon";
17470
17489
  }
17490
+ async function withDefaultSvgIconVariant(icon, icons, cwd) {
17491
+ const variant = await renderAppIconVariant({
17492
+ icon,
17493
+ width: 512,
17494
+ height: 512,
17495
+ format: "webp",
17496
+ cwd
17497
+ });
17498
+ return {
17499
+ ...icons || {},
17500
+ [DEFAULT_APP_ICON_VARIANT_NAME]: variant.value
17501
+ };
17502
+ }
17471
17503
 
17472
17504
  // src/commands/AppCommandHandler.ts
17473
17505
  init_namespacedRef();
@@ -17509,7 +17541,7 @@ var AppCommandHandler = class {
17509
17541
  return;
17510
17542
  }
17511
17543
  case "create": {
17512
- const payload = this.preparePayload(args.filePath);
17544
+ const payload = await this.preparePayload(args.filePath);
17513
17545
  await this.requireNamespace(payload, baseUrl);
17514
17546
  const record = await this.request(
17515
17547
  baseUrl,
@@ -17523,7 +17555,7 @@ var AppCommandHandler = class {
17523
17555
  return;
17524
17556
  }
17525
17557
  case "update": {
17526
- const payload = this.preparePayload(args.filePath);
17558
+ const payload = await this.preparePayload(args.filePath);
17527
17559
  const pathname = this.buildAppPath(args.id);
17528
17560
  const record = await this.request(
17529
17561
  baseUrl,
@@ -17679,7 +17711,7 @@ var AppCommandHandler = class {
17679
17711
  throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
17680
17712
  }
17681
17713
  }
17682
- preparePayload(filePath) {
17714
+ async preparePayload(filePath) {
17683
17715
  const absolutePath = this.resolveFilePath(filePath);
17684
17716
  return prepareAppPayload(this.readJsonFile(filePath), import_node_path21.default.dirname(absolutePath));
17685
17717
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {