@uniformdev/cli 19.207.1-alpha.11 → 19.207.1-alpha.28

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.mjs +20 -5
  2. package/package.json +9 -8
package/dist/index.mjs CHANGED
@@ -481,6 +481,7 @@ import { UncachedFileClient } from "@uniformdev/files";
481
481
  import { preferredType } from "@thi.ng/mime";
482
482
  import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
483
483
  import { createHash } from "crypto";
484
+ import { fileTypeFromBuffer } from "file-type";
484
485
  import fsj from "fs-jetpack";
485
486
  import sizeOf from "image-size";
486
487
  import PQueue from "p-queue";
@@ -505,7 +506,9 @@ var hashToPartialPathname = (hash) => {
505
506
  };
506
507
  var findUrlMatchingPartialPathname = (source, pathname) => {
507
508
  const escapedPathname = escapeRegExp(pathname);
508
- const regex = new RegExp(`"(https://([^"]*?)?img.uniform.(rocks|global)${escapedPathname}([^"]*?))"`);
509
+ const regex = new RegExp(
510
+ `"(https://([^"]*?)?(img|files).uniform.(rocks|global)${escapedPathname}([^"]*?))"`
511
+ );
509
512
  const match = source.match(regex);
510
513
  if (match && match[1]) {
511
514
  return match[1];
@@ -536,7 +539,7 @@ var getFilesDirectory = (directory) => {
536
539
  );
537
540
  };
538
541
  var getUniformFileUrlMatches = (string) => {
539
- return string.matchAll(/"(https:\/\/([^"]*?)?img\.uniform\.(rocks|global)\/([^"]*?))"/g);
542
+ return string.matchAll(/"(https:\/\/([^"]*?)?(img|files)\.uniform\.(rocks|global)\/([^"]*?))"/g);
540
543
  };
541
544
  var deleteDownloadedFileByUrl = async (url, options) => {
542
545
  const writeDirectory = getFilesDirectory(options.directory);
@@ -641,7 +644,20 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
641
644
  return;
642
645
  }
643
646
  const fileName = getFileNameFromUrl(url);
647
+ let mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await fileTypeFromBuffer(fileBuffer))?.mime;
648
+ if (!mimeType) {
649
+ mimeType = preferredType(url.split(".").at(-1) ?? "");
650
+ }
651
+ if (mimeType === "audio/x-flac") {
652
+ mimeType = "audio/flac";
653
+ }
644
654
  const { width, height } = (() => {
655
+ if (!mimeType.startsWith("image/")) {
656
+ return {
657
+ width: void 0,
658
+ height: void 0
659
+ };
660
+ }
645
661
  try {
646
662
  return sizeOf(fileBuffer);
647
663
  } catch {
@@ -651,7 +667,6 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
651
667
  };
652
668
  }
653
669
  })();
654
- const mimeType = preferredType(url.split(".").at(-1) ?? "");
655
670
  const { id, method, uploadUrl } = await options.fileClient.insert({
656
671
  name: fileName,
657
672
  mediaType: mimeType,
@@ -8418,6 +8433,7 @@ var package_default = {
8418
8433
  diff: "^5.0.0",
8419
8434
  dotenv: "^16.0.3",
8420
8435
  execa: "5.1.1",
8436
+ "file-type": "^19.6.0",
8421
8437
  "fs-jetpack": "5.1.0",
8422
8438
  graphql: "16.9.0",
8423
8439
  "graphql-request": "6.1.0",
@@ -8597,8 +8613,7 @@ var makeApiKey = (teamId, projectId, name, permissions) => ({
8597
8613
  {
8598
8614
  projectId,
8599
8615
  permissions,
8600
- roles: [],
8601
- useCustom: true
8616
+ roles: []
8602
8617
  }
8603
8618
  ],
8604
8619
  email: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.207.1-alpha.11+682b1954b3",
3
+ "version": "19.207.1-alpha.28+369def3ba0",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "19.207.1-alpha.11+682b1954b3",
31
- "@uniformdev/canvas": "19.207.1-alpha.11+682b1954b3",
32
- "@uniformdev/context": "19.207.1-alpha.11+682b1954b3",
33
- "@uniformdev/files": "19.207.1-alpha.11+682b1954b3",
34
- "@uniformdev/project-map": "19.207.1-alpha.11+682b1954b3",
35
- "@uniformdev/redirect": "19.207.1-alpha.11+682b1954b3",
30
+ "@uniformdev/assets": "19.207.1-alpha.28+369def3ba0",
31
+ "@uniformdev/canvas": "19.207.1-alpha.28+369def3ba0",
32
+ "@uniformdev/context": "19.207.1-alpha.28+369def3ba0",
33
+ "@uniformdev/files": "19.207.1-alpha.28+369def3ba0",
34
+ "@uniformdev/project-map": "19.207.1-alpha.28+369def3ba0",
35
+ "@uniformdev/redirect": "19.207.1-alpha.28+369def3ba0",
36
36
  "call-bind": "^1.0.2",
37
37
  "colorette": "2.0.20",
38
38
  "cosmiconfig": "9.0.0",
@@ -40,6 +40,7 @@
40
40
  "diff": "^5.0.0",
41
41
  "dotenv": "^16.0.3",
42
42
  "execa": "5.1.1",
43
+ "file-type": "^19.6.0",
43
44
  "fs-jetpack": "5.1.0",
44
45
  "graphql": "16.9.0",
45
46
  "graphql-request": "6.1.0",
@@ -78,5 +79,5 @@
78
79
  "publishConfig": {
79
80
  "access": "public"
80
81
  },
81
- "gitHead": "682b1954b3ddfeb43952e44367c314cfe6feda69"
82
+ "gitHead": "369def3ba012b3fc314254d940448b9937e12900"
82
83
  }