@uniformdev/cli 19.207.0 → 19.207.1-alpha.20

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 +16 -3
  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,17 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
641
644
  return;
642
645
  }
643
646
  const fileName = getFileNameFromUrl(url);
647
+ let mimeType = (await fileTypeFromBuffer(fileBuffer))?.mime;
648
+ if (!mimeType) {
649
+ mimeType = preferredType(url.split(".").at(-1) ?? "");
650
+ }
644
651
  const { width, height } = (() => {
652
+ if (!mimeType.startsWith("image/")) {
653
+ return {
654
+ width: void 0,
655
+ height: void 0
656
+ };
657
+ }
645
658
  try {
646
659
  return sizeOf(fileBuffer);
647
660
  } catch {
@@ -651,7 +664,6 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
651
664
  };
652
665
  }
653
666
  })();
654
- const mimeType = preferredType(url.split(".").at(-1) ?? "");
655
667
  const { id, method, uploadUrl } = await options.fileClient.insert({
656
668
  name: fileName,
657
669
  mediaType: mimeType,
@@ -8418,6 +8430,7 @@ var package_default = {
8418
8430
  diff: "^5.0.0",
8419
8431
  dotenv: "^16.0.3",
8420
8432
  execa: "5.1.1",
8433
+ "file-type": "^19.6.0",
8421
8434
  "fs-jetpack": "5.1.0",
8422
8435
  graphql: "16.9.0",
8423
8436
  "graphql-request": "6.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.207.0",
3
+ "version": "19.207.1-alpha.20+9dc4b12464",
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.0",
31
- "@uniformdev/canvas": "19.207.0",
32
- "@uniformdev/context": "19.207.0",
33
- "@uniformdev/files": "19.207.0",
34
- "@uniformdev/project-map": "19.207.0",
35
- "@uniformdev/redirect": "19.207.0",
30
+ "@uniformdev/assets": "19.207.1-alpha.20+9dc4b12464",
31
+ "@uniformdev/canvas": "19.207.1-alpha.20+9dc4b12464",
32
+ "@uniformdev/context": "19.207.1-alpha.20+9dc4b12464",
33
+ "@uniformdev/files": "19.207.1-alpha.20+9dc4b12464",
34
+ "@uniformdev/project-map": "19.207.1-alpha.20+9dc4b12464",
35
+ "@uniformdev/redirect": "19.207.1-alpha.20+9dc4b12464",
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": "e90334452c3b50b7657f7ae55ffb9c6fe97febb3"
82
+ "gitHead": "9dc4b1246494bc273e86dd22cd4818aa4ebd1c24"
82
83
  }