@uniformdev/cli 19.214.1-alpha.37 → 20.1.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.mjs +307 -599
  2. package/package.json +10 -11
package/dist/index.mjs CHANGED
@@ -615,22 +615,17 @@ var AssetListModule = {
615
615
  }
616
616
  };
617
617
 
618
- // src/files/deleteDownloadedFileByUrl.ts
618
+ // src/files/index.ts
619
+ import { preferredType } from "@thi.ng/mime";
620
+ import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
621
+ import { fileTypeFromBuffer } from "file-type";
619
622
  import fsj from "fs-jetpack";
620
- import { join as join3 } from "path";
621
-
622
- // src/files/urlToFileName.ts
623
- import { join as join2 } from "path";
624
- import { dirname } from "path";
623
+ import sizeOf from "image-size";
624
+ import PQueue from "p-queue";
625
+ import { dirname, join as join2 } from "path";
625
626
  var FILES_DIRECTORY_NAME = "files";
626
- var getFilesDirectory = (directory) => {
627
- const isPackage = isPathAPackageFile(directory);
628
- return isPackage ? dirname(directory) : (
629
- // If we are syncing to a directory, we want to write all files into a
630
- // top-lvl folder. That way any entities that contain files will sync to the
631
- // same directory, so there is no duplication
632
- join2(directory, "..")
633
- );
627
+ var escapeRegExp = (string) => {
628
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
634
629
  };
635
630
  var urlToHash = (url) => {
636
631
  return Buffer.from(
@@ -639,6 +634,24 @@ var urlToHash = (url) => {
639
634
  new URL(url).pathname.substring(0, 64)
640
635
  ).toString("base64");
641
636
  };
637
+ var hashToPartialPathname = (hash) => {
638
+ try {
639
+ return Buffer.from(hash, "base64").toString("utf8");
640
+ } catch {
641
+ return null;
642
+ }
643
+ };
644
+ var findUrlMatchingPartialPathname = (source, pathname) => {
645
+ const escapedPathname = escapeRegExp(pathname);
646
+ const regex = new RegExp(
647
+ `"(https://([^"]*?)?(img|files).uniform.(rocks|global)${escapedPathname}([^"]*?))"`
648
+ );
649
+ const match = source.match(regex);
650
+ if (match && match[1]) {
651
+ return match[1];
652
+ }
653
+ return null;
654
+ };
642
655
  var urlToFileExtension = (url) => {
643
656
  try {
644
657
  const urlObject = new URL(url);
@@ -653,397 +666,228 @@ var urlToFileName = (url, hash) => {
653
666
  const fileExtension = urlToFileExtension(url);
654
667
  return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
655
668
  };
656
- var hashToPartialPathname = (hash) => {
657
- try {
658
- return Buffer.from(hash, "base64").toString("utf8");
659
- } catch {
660
- return null;
661
- }
669
+ var getFilesDirectory = (directory) => {
670
+ const isPackage = isPathAPackageFile(directory);
671
+ return isPackage ? dirname(directory) : (
672
+ // If we are syncing to a directory, we want to write all files into a
673
+ // top-lvl folder. That way any entities that contain files will sync to the
674
+ // same directory, so there is no duplication
675
+ join2(directory, "..")
676
+ );
677
+ };
678
+ var getUniformFileUrlMatches = (string) => {
679
+ return string.matchAll(/"(https:\/\/([^"]*?)?(img|files)\.uniform\.(rocks|global)\/([^"]*?))"/g);
662
680
  };
663
-
664
- // src/files/deleteDownloadedFileByUrl.ts
665
681
  var deleteDownloadedFileByUrl = async (url, options) => {
666
682
  const writeDirectory = getFilesDirectory(options.directory);
667
683
  const fileName = urlToFileName(url);
668
- const fileToDelete = join3(writeDirectory, FILES_DIRECTORY_NAME, fileName);
684
+ const fileToDelete = join2(writeDirectory, FILES_DIRECTORY_NAME, fileName);
669
685
  try {
670
686
  await fsj.removeAsync(fileToDelete);
671
687
  } catch {
672
688
  console.warn(`Failed to delete a local file ${fileToDelete}`);
673
689
  }
674
690
  };
675
-
676
- // src/files/files.ts
677
- import {
678
- ASSETS_SOURCE_UNIFORM,
679
- getPropertiesValue as getPropertiesValue2,
680
- isAssetParamValue,
681
- isAssetParamValueItem,
682
- walkNodeTree as walkNodeTree2,
683
- walkPropertyValues as walkPropertyValues2
684
- } from "@uniformdev/canvas";
685
- import { isRichTextNodeType, isRichTextValue, walkRichTextTree } from "@uniformdev/richtext";
686
- import fsj4 from "fs-jetpack";
687
- import PQueue2 from "p-queue";
688
- import { join as join6 } from "path";
689
-
690
- // src/files/downloadFile.ts
691
- import fsj2 from "fs-jetpack";
692
- import { join as join4 } from "path";
693
- var downloadFile = async ({
694
- fileClient,
695
- fileUrl,
696
- directory
697
- }) => {
698
- const writeDirectory = getFilesDirectory(directory);
699
- const fileName = urlToFileName(fileUrl.toString());
700
- const fileAlreadyExists = await fsj2.existsAsync(join4(writeDirectory, FILES_DIRECTORY_NAME, fileName));
701
- if (fileAlreadyExists) {
702
- return { url: fileUrl };
703
- }
704
- const file = await fileClient.get({ url: fileUrl }).catch(() => null);
705
- if (!file) {
706
- console.warn(`Skipping file ${fileUrl} as it does not exist in the project anymore`);
707
- return null;
708
- }
709
- if (file.sourceId) {
710
- try {
711
- const hashAlreadyExists = await fsj2.findAsync(join4(writeDirectory, FILES_DIRECTORY_NAME), {
712
- matching: [file.sourceId, `${file.sourceId}.*`]
713
- });
714
- if (hashAlreadyExists.length > 0) {
715
- return { id: file.id, url: fileUrl };
716
- }
717
- } catch {
718
- }
719
- }
720
- const fetchUrl = `${fileUrl}?format=original`;
721
- const response = await fetch(fetchUrl);
722
- if (!response.ok) {
723
- return null;
724
- }
725
- const fileBuffer = await response.arrayBuffer();
726
- await fsj2.writeAsync(join4(writeDirectory, FILES_DIRECTORY_NAME, fileName), Buffer.from(fileBuffer));
727
- return { id: file.id, url: fileUrl };
728
- };
729
-
730
- // src/files/uploadFile.ts
731
- import { preferredType } from "@thi.ng/mime";
732
- import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
733
- import { fileTypeFromBuffer } from "file-type";
734
- import fsj3 from "fs-jetpack";
735
- import sizeOf from "image-size";
736
- import PQueue from "p-queue";
737
- import { join as join5 } from "path";
738
- var uploadQueueByKey = /* @__PURE__ */ new Map();
739
- var fileUploadQueue = new PQueue({ concurrency: 10 });
740
- var uploadFile = async ({
741
- fileClient,
742
- fileUrl,
743
- directory,
744
- fileId
745
- }) => {
746
- const key = `${fileId}-${fileUrl}`;
747
- if (uploadQueueByKey.has(key)) {
748
- console.log("Already have this queued!!!");
749
- const result2 = await uploadQueueByKey.get(key);
750
- return result2 ?? null;
751
- }
752
- const promise = fileUploadQueue.add(async () => {
753
- try {
754
- const writeDirectory = getFilesDirectory(directory);
755
- const hash = urlToHash(fileUrl);
756
- const fileAlreadyExistsChecks = await Promise.all([
757
- fileClient.get({ url: fileUrl }).catch(() => null),
758
- fileClient.get({ sourceId: hash }).catch(() => null)
759
- ]);
760
- const file = fileAlreadyExistsChecks.find((check) => check !== null);
761
- if (file?.url) {
762
- return { id: file.id, url: file.url };
763
- }
764
- const localFileName = urlToFileName(fileUrl);
765
- const expectedFilePath = join5(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
766
- const fileExistsLocally = await fsj3.existsAsync(expectedFilePath);
767
- if (!fileExistsLocally) {
768
- console.warn(
769
- `Skipping file ${fileUrl} as we couldn't find a local copy (looked at ${expectedFilePath})`
770
- );
771
- return null;
772
- }
773
- const fileBuffer = await fsj3.readAsync(expectedFilePath, "buffer");
774
- if (!fileBuffer) {
775
- console.warn(`Skipping file ${fileUrl} (${expectedFilePath}) as we couldn't read it`);
776
- return null;
777
- }
778
- const fileName = getFileNameFromUrl(fileUrl);
779
- let mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await fileTypeFromBuffer(fileBuffer))?.mime;
780
- if (!mimeType) {
781
- mimeType = preferredType(fileUrl.split(".").at(-1) ?? "");
782
- }
783
- if (mimeType === "audio/x-flac") {
784
- mimeType = "audio/flac";
785
- }
786
- const { width, height } = (() => {
787
- if (!mimeType.startsWith("image/")) {
788
- return {
789
- width: void 0,
790
- height: void 0
791
- };
792
- }
691
+ var extractAndDownloadUniformFilesForObject = async (object, options) => {
692
+ const objectAsString = JSON.stringify(object);
693
+ const uniformFileUrlMatches = getUniformFileUrlMatches(objectAsString);
694
+ const writeDirectory = getFilesDirectory(options.directory);
695
+ if (uniformFileUrlMatches) {
696
+ const fileDownloadQueue = new PQueue({ concurrency: 10 });
697
+ for (const match of uniformFileUrlMatches) {
698
+ const url = new URL(match[1]);
699
+ fileDownloadQueue.add(async () => {
793
700
  try {
794
- return sizeOf(fileBuffer);
701
+ const fileName = urlToFileName(url.toString());
702
+ const fileAlreadyExists = await fsj.existsAsync(
703
+ join2(writeDirectory, FILES_DIRECTORY_NAME, fileName)
704
+ );
705
+ if (fileAlreadyExists) {
706
+ return;
707
+ }
708
+ const file = await options.fileClient.get({ url: url.toString() }).catch(() => null);
709
+ if (!file) {
710
+ console.warn(`Skipping file ${url} as it does not exist in the project anymore`);
711
+ return;
712
+ }
713
+ if (file.sourceId) {
714
+ try {
715
+ const hashAlreadyExists = await fsj.findAsync(join2(writeDirectory, FILES_DIRECTORY_NAME), {
716
+ matching: [file.sourceId, `${file.sourceId}.*`]
717
+ });
718
+ if (hashAlreadyExists.length > 0) {
719
+ return;
720
+ }
721
+ } catch {
722
+ }
723
+ }
724
+ const fetchUrl = `${url.origin}${url.pathname}?format=original`;
725
+ const response = await fetch(fetchUrl);
726
+ if (!response.ok) {
727
+ return;
728
+ }
729
+ const fileBuffer = await response.arrayBuffer();
730
+ await fsj.writeAsync(join2(writeDirectory, FILES_DIRECTORY_NAME, fileName), Buffer.from(fileBuffer));
795
731
  } catch {
796
- return {
797
- width: void 0,
798
- height: void 0
799
- };
732
+ console.warn(`Failed to download file ${url}`);
800
733
  }
801
- })();
802
- const { id, method, uploadUrl } = await fileClient.insert({
803
- id: fileId,
804
- name: fileName,
805
- mediaType: mimeType,
806
- size: fileBuffer.length,
807
- width,
808
- height,
809
- sourceId: hash
810
734
  });
811
- const uploadResponse = await fetch(uploadUrl, {
812
- method,
813
- body: fileBuffer,
814
- headers: {
815
- "Content-Type": mimeType,
816
- "Content-Length": fileBuffer.length.toString()
817
- }
818
- });
819
- if (!uploadResponse.ok) {
820
- console.warn(`Failed to upload file ${fileUrl} (${expectedFilePath})`);
821
- return null;
822
- }
823
- let error;
824
- const checkForFile = async () => {
825
- if (error) {
826
- throw error;
827
- }
828
- const file2 = await fileClient.get({ id });
829
- if (!file2 || file2.state !== FILE_READY_STATE || !file2.url) {
830
- await new Promise((resolve) => setTimeout(resolve, 1e3));
831
- return checkForFile();
832
- }
833
- return file2.url;
834
- };
835
- const abortTimeout = setTimeout(() => {
836
- error = new Error(`Failed to upload file ${fileUrl} (${expectedFilePath}) - upload timed out`);
837
- }, 6e4);
838
- const uploadedFileUrl = await checkForFile();
839
- clearTimeout(abortTimeout);
840
- return { id, url: uploadedFileUrl };
841
- } catch (e) {
842
- console.warn(`Failed to upload file ${fileUrl}`, e);
843
- return null;
844
- }
845
- });
846
- uploadQueueByKey.set(key, promise);
847
- const result = await promise;
848
- return result ?? null;
849
- };
850
-
851
- // src/files/walkFileUrlsForCompositionOrEntry.ts
852
- import {
853
- getPropertiesValue,
854
- walkNodeTree,
855
- walkPropertyValues
856
- } from "@uniformdev/canvas";
857
- var UNIFORM_FILE_MATCH = /"(https:\/\/([^"]*?)?(img|files)\.uniform\.(rocks|global)\/([^"]*?))"/g;
858
- var walkFileUrlsForCompositionOrEntry = ({
859
- entity,
860
- callback
861
- }) => {
862
- const thumbnail = "entry" in entity ? entity.entry._thumbnail : void 0;
863
- if (typeof thumbnail === "string") {
864
- const isUniformFile = `"${thumbnail}"`.match(UNIFORM_FILE_MATCH) !== null;
865
- if (isUniformFile) {
866
- callback({ fileUrl: thumbnail });
867
735
  }
736
+ await fileDownloadQueue.onIdle();
868
737
  }
869
- walkNodeTree("entry" in entity ? entity.entry : entity.composition, ({ node }) => {
870
- const properties = getPropertiesValue(node);
871
- if (!properties) {
872
- return;
873
- }
874
- Object.entries(properties).forEach(([_, property]) => {
875
- if (property.type !== "image") {
876
- return;
877
- }
878
- walkPropertyValues(property, ({ value }) => {
879
- if (typeof value !== "string") {
880
- return;
881
- }
882
- const isUniformFile = `"${value}"`.match(UNIFORM_FILE_MATCH) !== null;
883
- if (!isUniformFile) {
884
- return;
885
- }
886
- callback({ fileUrl: value });
887
- });
888
- });
889
- });
890
- };
891
-
892
- // src/files/files.ts
893
- var downloadFileForAsset = async ({
894
- asset,
895
- directory,
896
- fileClient
897
- }) => {
898
- if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
899
- return null;
900
- }
901
- const fileId = asset.asset.fields?.file?.value;
902
- const fileUrl = asset.asset.fields.url?.value;
903
- if (fileId === "" || fileUrl === "") {
904
- return null;
905
- }
906
- return downloadFile({ fileUrl, directory, fileClient });
907
- };
908
- var uploadFileForAsset = async ({
909
- asset,
910
- directory,
911
- fileClient
912
- }) => {
913
- if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
914
- return null;
915
- }
916
- const fileUrl = asset.asset.fields.url.value;
917
- const fileId = asset.asset.fields.file.value;
918
- return uploadFile({ fileUrl, directory, fileClient, fileId });
738
+ return object;
919
739
  };
920
- var removeUrlsFromAssetParameters = (entity) => {
921
- walkNodeTree2("entry" in entity ? entity.entry : entity.composition, ({ node }) => {
922
- const properties = getPropertiesValue2(node);
923
- if (!properties) {
924
- return;
925
- }
926
- Object.entries(properties).forEach(([_, property]) => {
927
- if (property.type === "asset") {
928
- walkPropertyValues2(property, ({ value }) => {
929
- if (!isAssetParamValue(value)) {
740
+ var extractAndUploadUniformFilesForObject = async (object, options) => {
741
+ let objectAsString = JSON.stringify(object);
742
+ const uniformFileUrlMatches = getUniformFileUrlMatches(objectAsString);
743
+ const writeDirectory = getFilesDirectory(options.directory);
744
+ if (uniformFileUrlMatches) {
745
+ const fileUploadQueue = new PQueue({ concurrency: 3 });
746
+ for (const match of uniformFileUrlMatches) {
747
+ const url = match[1];
748
+ const hash = urlToHash(url);
749
+ fileUploadQueue.add(async () => {
750
+ try {
751
+ const fileAlreadyExistsChecks = await Promise.all([
752
+ options.fileClient.get({ url }).catch(() => null),
753
+ options.fileClient.get({ sourceId: hash }).catch(() => null)
754
+ ]);
755
+ const file = fileAlreadyExistsChecks.find((check) => check !== null);
756
+ if (file) {
757
+ objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
758
+ return;
759
+ }
760
+ const localFileName = urlToFileName(url);
761
+ const expectedFilePath = join2(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
762
+ const fileExistsLocally = await fsj.existsAsync(expectedFilePath);
763
+ if (!fileExistsLocally) {
764
+ console.warn(
765
+ `Skipping file ${url} as we couldn't find a local copy (looked at ${expectedFilePath})`
766
+ );
767
+ return;
768
+ }
769
+ const fileBuffer = await fsj.readAsync(expectedFilePath, "buffer");
770
+ if (!fileBuffer) {
771
+ console.warn(`Skipping file ${url} (${expectedFilePath}) as we couldn't read it`);
930
772
  return;
931
773
  }
932
- value.forEach((asset) => {
933
- if (!isAssetParamValueItem(asset)) {
934
- return;
774
+ const fileName = getFileNameFromUrl(url);
775
+ let mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await fileTypeFromBuffer(fileBuffer))?.mime;
776
+ if (!mimeType) {
777
+ mimeType = preferredType(url.split(".").at(-1) ?? "");
778
+ }
779
+ if (mimeType === "audio/x-flac") {
780
+ mimeType = "audio/flac";
781
+ }
782
+ const { width, height } = (() => {
783
+ if (!mimeType.startsWith("image/")) {
784
+ return {
785
+ width: void 0,
786
+ height: void 0
787
+ };
935
788
  }
936
- if (asset._source !== ASSETS_SOURCE_UNIFORM || !asset.fields?.url.value) {
937
- return;
789
+ try {
790
+ return sizeOf(fileBuffer);
791
+ } catch {
792
+ return {
793
+ width: void 0,
794
+ height: void 0
795
+ };
938
796
  }
939
- asset.fields.url.value = "";
797
+ })();
798
+ const { id, method, uploadUrl } = await options.fileClient.insert({
799
+ name: fileName,
800
+ mediaType: mimeType,
801
+ size: fileBuffer.length,
802
+ width,
803
+ height,
804
+ sourceId: hash
940
805
  });
941
- });
942
- } else if (property.type === "richText") {
943
- walkPropertyValues2(property, ({ value }) => {
944
- if (!isRichTextValue(value)) {
806
+ const uploadResponse = await fetch(uploadUrl, {
807
+ method,
808
+ body: fileBuffer,
809
+ headers: {
810
+ "Content-Type": mimeType,
811
+ "Content-Length": fileBuffer.length.toString()
812
+ }
813
+ });
814
+ if (!uploadResponse.ok) {
815
+ console.warn(`Failed to upload file ${url} (${expectedFilePath})`);
945
816
  return;
946
817
  }
947
- walkRichTextTree(value.root, (node2) => {
948
- if (isRichTextNodeType(node2, "asset")) {
949
- if (node2.__asset?._source !== ASSETS_SOURCE_UNIFORM || !node2.__asset.fields.url.value) {
950
- return;
951
- }
952
- node2.__asset.fields.url.value = "";
818
+ let error;
819
+ const checkForFile = async () => {
820
+ if (error) {
821
+ throw error;
953
822
  }
954
- });
955
- });
956
- }
957
- });
958
- });
959
- return entity;
960
- };
961
- var compareCompositionsOrEntriesWithoutAssetUrls = (source, target) => {
962
- return serializedDequal(
963
- removeUrlsFromAssetParameters(structuredClone(source.object)),
964
- removeUrlsFromAssetParameters(structuredClone(target.object))
965
- );
966
- };
967
- var removeUrlFromAsset = (asset) => {
968
- if (asset.asset.fields?.url?.value) {
969
- asset.asset.fields.url.value = "";
970
- }
971
- return asset;
972
- };
973
- var compareAssetsWithoutUrls = (source, target) => {
974
- return serializedDequal(
975
- removeUrlFromAsset(structuredClone(source.object)),
976
- removeUrlFromAsset(structuredClone(target.object))
977
- );
978
- };
979
- var downloadFilesForCompositionOrEntry = async ({
980
- entity,
981
- directory,
982
- fileClient
983
- }) => {
984
- const fileDownloadQueue = new PQueue2({ concurrency: 3 });
985
- await walkFileUrlsForCompositionOrEntry({
986
- entity,
987
- callback: ({ fileUrl }) => {
988
- fileDownloadQueue.add(async () => {
989
- await downloadFile({ fileUrl, directory, fileClient });
823
+ const file2 = await options.fileClient.get({ id });
824
+ if (!file2 || file2.state !== FILE_READY_STATE || !file2.url) {
825
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
826
+ return checkForFile();
827
+ }
828
+ return file2.url;
829
+ };
830
+ const abortTimeout = setTimeout(() => {
831
+ error = new Error(`Failed to upload file ${url} (${expectedFilePath}) - upload timed out`);
832
+ }, 6e4);
833
+ const uploadedFileUrl = await checkForFile();
834
+ clearTimeout(abortTimeout);
835
+ objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
836
+ } catch (e) {
837
+ console.warn(`Failed to upload file ${url}`, e);
838
+ }
990
839
  });
991
840
  }
992
- });
993
- await fileDownloadQueue.onIdle();
841
+ await fileUploadQueue.onIdle();
842
+ }
843
+ return JSON.parse(objectAsString);
994
844
  };
995
- var uploadFilesForCompositionOrEntry = async ({
996
- entity,
997
- directory,
998
- fileClient
999
- }) => {
1000
- const fileUploadQueue2 = new PQueue2({ concurrency: 3 });
1001
- const urlReplacementMap = /* @__PURE__ */ new Map();
1002
- walkFileUrlsForCompositionOrEntry({
1003
- entity: entity.object,
1004
- callback: async ({ fileUrl }) => {
1005
- fileUploadQueue2.add(async () => {
1006
- const upload = await uploadFile({
1007
- directory,
1008
- fileUrl,
1009
- fileClient
1010
- });
1011
- if (upload !== null) {
1012
- urlReplacementMap.set(fileUrl, upload.url);
845
+ var swapOutUniformFileUrlsForTargetProject = async (object, options) => {
846
+ let objectAsString = JSON.stringify(object);
847
+ const uniformFileUrlMatches = getUniformFileUrlMatches(objectAsString);
848
+ if (uniformFileUrlMatches) {
849
+ const fileUrlReplacementQueue = new PQueue({ concurrency: 3 });
850
+ for (const match of uniformFileUrlMatches) {
851
+ const url = match[1];
852
+ const hash = urlToHash(url);
853
+ fileUrlReplacementQueue.add(async () => {
854
+ try {
855
+ const fileAlreadyExistsChecks = await Promise.all([
856
+ options.fileClient.get({ url }).catch(() => null),
857
+ options.fileClient.get({ sourceId: hash }).catch(() => null)
858
+ ]);
859
+ const file = fileAlreadyExistsChecks.find((check) => check !== null);
860
+ if (!file) {
861
+ return;
862
+ }
863
+ objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
864
+ } catch {
1013
865
  }
1014
866
  });
1015
867
  }
1016
- });
1017
- await fileUploadQueue2.onIdle();
1018
- let entityAsString = JSON.stringify(entity);
1019
- for (const [key, value] of urlReplacementMap.entries()) {
1020
- entityAsString = entityAsString.replaceAll(`"${key}"`, `"${value}"`);
1021
- }
1022
- return JSON.parse(entityAsString);
1023
- };
1024
- var replaceRemoteUrlsWithLocalReferences = async ({
1025
- sourceEntity,
1026
- targetEntity,
1027
- fileClient,
1028
- directory
1029
- }) => {
1030
- let sourceEntityAsString = JSON.stringify(sourceEntity);
1031
- const targetEntityAsString = JSON.stringify(targetEntity);
1032
- const writeDirectory = getFilesDirectory(directory);
1033
- const fileUrlReplacementQueue = new PQueue2({ concurrency: 3 });
1034
- walkFileUrlsForCompositionOrEntry({
1035
- entity: sourceEntity.object,
1036
- callback: ({ fileUrl }) => {
868
+ await fileUrlReplacementQueue.onIdle();
869
+ }
870
+ return JSON.parse(objectAsString);
871
+ };
872
+ var replaceRemoteUrlsWithLocalReferences = async (sourceObject, targetObject, options) => {
873
+ let sourceObjectAsString = JSON.stringify(sourceObject);
874
+ const targetObjectAsString = JSON.stringify(targetObject);
875
+ const uniformFileUrlMatches = getUniformFileUrlMatches(sourceObjectAsString);
876
+ const writeDirectory = getFilesDirectory(options.directory);
877
+ if (uniformFileUrlMatches) {
878
+ const fileUrlReplacementQueue = new PQueue({ concurrency: 3 });
879
+ for (const match of uniformFileUrlMatches) {
880
+ const url = match[1];
1037
881
  fileUrlReplacementQueue.add(async () => {
1038
882
  try {
1039
- const localFileName = urlToFileName(fileUrl);
1040
- const fileExistsLocally = await fsj4.existsAsync(
1041
- join6(writeDirectory, FILES_DIRECTORY_NAME, localFileName)
883
+ const localFileName = urlToFileName(url);
884
+ const fileExistsLocally = await fsj.existsAsync(
885
+ join2(writeDirectory, FILES_DIRECTORY_NAME, localFileName)
1042
886
  );
1043
887
  if (fileExistsLocally) {
1044
888
  return;
1045
889
  }
1046
- const file = await fileClient.get({ url: fileUrl }).catch(() => null);
890
+ const file = await options.fileClient.get({ url }).catch(() => null);
1047
891
  if (!file || !file.sourceId) {
1048
892
  return;
1049
893
  }
@@ -1051,64 +895,36 @@ var replaceRemoteUrlsWithLocalReferences = async ({
1051
895
  if (!originalPartialPath) {
1052
896
  return;
1053
897
  }
1054
- const originalUrl = findUrlMatchingPartialPathname(targetEntityAsString, originalPartialPath);
898
+ const originalUrl = findUrlMatchingPartialPathname(targetObjectAsString, originalPartialPath);
1055
899
  if (!originalUrl) {
1056
900
  return;
1057
901
  }
1058
- sourceEntityAsString = sourceEntityAsString.replaceAll(`"${fileUrl}"`, `"${originalUrl}"`);
1059
- } catch {
1060
- }
1061
- });
1062
- return null;
1063
- }
1064
- });
1065
- await fileUrlReplacementQueue.onIdle();
1066
- return JSON.parse(sourceEntityAsString);
1067
- };
1068
- var replaceLocalUrlsWithRemoteReferences = async ({
1069
- entity,
1070
- fileClient
1071
- }) => {
1072
- let entityAsString = JSON.stringify(entity);
1073
- const fileUrlReplacementQueue = new PQueue2({ concurrency: 3 });
1074
- walkFileUrlsForCompositionOrEntry({
1075
- entity: entity.object,
1076
- callback: ({ fileUrl }) => {
1077
- fileUrlReplacementQueue.add(async () => {
1078
- try {
1079
- const hash = urlToHash(fileUrl);
1080
- fileUrlReplacementQueue.add(async () => {
1081
- try {
1082
- const file = await fileClient.get({ sourceId: hash }).catch(() => null);
1083
- if (!file) {
1084
- return;
1085
- }
1086
- entityAsString = entityAsString.replaceAll(`"${fileUrl}"`, `"${file.url}"`);
1087
- } catch {
1088
- }
1089
- });
902
+ sourceObjectAsString = sourceObjectAsString.replaceAll(`"${url}"`, `"${originalUrl}"`);
1090
903
  } catch {
1091
904
  }
1092
905
  });
1093
- return null;
1094
906
  }
1095
- });
1096
- await fileUrlReplacementQueue.onIdle();
1097
- return JSON.parse(entityAsString);
1098
- };
1099
- var escapeRegExp = (string) => {
1100
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
907
+ await fileUrlReplacementQueue.onIdle();
908
+ }
909
+ return JSON.parse(sourceObjectAsString);
1101
910
  };
1102
- var findUrlMatchingPartialPathname = (source, pathname) => {
1103
- const escapedPathname = escapeRegExp(pathname);
1104
- const regex = new RegExp(
1105
- `"(https://([^"]*?)?(img|files).uniform.(rocks|global)${escapedPathname}([^"]*?))"`
1106
- );
1107
- const match = source.match(regex);
1108
- if (match && match[1]) {
1109
- return match[1];
911
+ var updateAssetFileIdBasedOnUrl = async (asset, options) => {
912
+ if (!asset.asset.fields) {
913
+ return asset;
1110
914
  }
1111
- return null;
915
+ const fileUrl = asset.asset.fields.url?.value;
916
+ if (!fileUrl) {
917
+ return asset;
918
+ }
919
+ const file = await options.fileClient.get({ url: fileUrl }).catch(() => null);
920
+ if (!file) {
921
+ return asset;
922
+ }
923
+ asset.asset.fields.file = {
924
+ type: "file",
925
+ value: file.id
926
+ };
927
+ return asset;
1112
928
  };
1113
929
 
1114
930
  // src/commands/canvas/assetEngineDataSource.ts
@@ -1299,25 +1115,27 @@ var AssetPullModule = {
1299
1115
  whatIf,
1300
1116
  allowEmptySource: allowEmptySource ?? true,
1301
1117
  log: createSyncEngineConsoleLogger({ diffMode }),
1302
- onBeforeCompareObjects: async (sourceObject) => {
1118
+ onBeforeCompareObjects: async (sourceObject, targetObject) => {
1303
1119
  delete sourceObject.object.asset._author;
1304
- return sourceObject;
1120
+ const sourceObjectWithPotentiallySwappedUrl = await replaceRemoteUrlsWithLocalReferences(
1121
+ sourceObject,
1122
+ targetObject,
1123
+ {
1124
+ directory,
1125
+ fileClient
1126
+ }
1127
+ );
1128
+ if (sourceObjectWithPotentiallySwappedUrl.object.asset.fields?.url && targetObject.object.asset.fields?.url && sourceObjectWithPotentiallySwappedUrl.object.asset.fields.url.value === targetObject.object.asset.fields.url.value) {
1129
+ targetObject.object.asset.fields.file = sourceObjectWithPotentiallySwappedUrl.object.asset.fields.file;
1130
+ }
1131
+ return sourceObjectWithPotentiallySwappedUrl;
1305
1132
  },
1306
- compareContents: compareAssetsWithoutUrls,
1307
1133
  onBeforeWriteObject: async (sourceObject) => {
1308
1134
  delete sourceObject.object.asset._author;
1309
- if (!sourceObject.object.asset.fields?.file) {
1310
- return sourceObject;
1311
- }
1312
- const downloadedFile = await downloadFileForAsset({
1313
- asset: sourceObject.object,
1135
+ return extractAndDownloadUniformFilesForObject(sourceObject, {
1314
1136
  directory,
1315
1137
  fileClient
1316
1138
  });
1317
- if (downloadedFile?.id) {
1318
- sourceObject.object.asset.fields.file.value = downloadedFile.id;
1319
- }
1320
- return sourceObject;
1321
1139
  }
1322
1140
  });
1323
1141
  }
@@ -1397,29 +1215,29 @@ var AssetPushModule = {
1397
1215
  if (targetObject) {
1398
1216
  delete targetObject.object.asset._author;
1399
1217
  }
1400
- return sourceObject;
1218
+ const sourceObjectWithNewFileUrls = await swapOutUniformFileUrlsForTargetProject(sourceObject, {
1219
+ fileClient
1220
+ });
1221
+ sourceObjectWithNewFileUrls.object = await updateAssetFileIdBasedOnUrl(
1222
+ sourceObjectWithNewFileUrls.object,
1223
+ {
1224
+ fileClient
1225
+ }
1226
+ );
1227
+ return sourceObjectWithNewFileUrls;
1401
1228
  },
1402
- compareContents: compareAssetsWithoutUrls,
1403
1229
  onBeforeWriteObject: async (sourceObject) => {
1404
- const uploadedFile = await uploadFileForAsset({
1405
- asset: sourceObject.object,
1230
+ const sourceObjectWithNewFileUrls = await extractAndUploadUniformFilesForObject(sourceObject, {
1406
1231
  directory,
1407
1232
  fileClient
1408
1233
  });
1409
- if (uploadedFile !== null) {
1410
- if (sourceObject.object.asset.fields === void 0) {
1411
- sourceObject.object.asset.fields = {};
1234
+ sourceObjectWithNewFileUrls.object = await updateAssetFileIdBasedOnUrl(
1235
+ sourceObjectWithNewFileUrls.object,
1236
+ {
1237
+ fileClient
1412
1238
  }
1413
- sourceObject.object.asset.fields.file = {
1414
- type: "file",
1415
- value: uploadedFile.id
1416
- };
1417
- sourceObject.object.asset.fields.url = {
1418
- type: "text",
1419
- value: uploadedFile.url
1420
- };
1421
- }
1422
- return sourceObject;
1239
+ );
1240
+ return sourceObjectWithNewFileUrls;
1423
1241
  }
1424
1242
  });
1425
1243
  }
@@ -2505,8 +2323,7 @@ var CompositionPublishModule = {
2505
2323
  onlyCompositions,
2506
2324
  onlyPatterns,
2507
2325
  patternType,
2508
- verbose,
2509
- directory
2326
+ verbose
2510
2327
  }) => {
2511
2328
  if (!all && !ids || all && ids) {
2512
2329
  console.error(`Specify --all or composition ID(s) to publish.`);
@@ -2533,7 +2350,6 @@ var CompositionPublishModule = {
2533
2350
  patternType,
2534
2351
  verbose
2535
2352
  });
2536
- const fileClient = getFileClient({ apiKey, apiHost, fetch: fetch2, projectId });
2537
2353
  await syncEngine({
2538
2354
  source,
2539
2355
  target,
@@ -2541,21 +2357,7 @@ var CompositionPublishModule = {
2541
2357
  mode: "createOrUpdate",
2542
2358
  whatIf,
2543
2359
  verbose,
2544
- log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" }),
2545
- onBeforeCompareObjects: async (sourceObject) => {
2546
- return replaceLocalUrlsWithRemoteReferences({
2547
- entity: sourceObject,
2548
- fileClient
2549
- });
2550
- },
2551
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
2552
- onBeforeWriteObject: async (sourceObject) => {
2553
- return uploadFilesForCompositionOrEntry({
2554
- entity: sourceObject,
2555
- directory,
2556
- fileClient
2557
- });
2558
- }
2360
+ log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
2559
2361
  });
2560
2362
  }
2561
2363
  };
@@ -2703,21 +2505,16 @@ var CompositionPullModule = {
2703
2505
  allowEmptySource: allowEmptySource ?? true,
2704
2506
  log: createSyncEngineConsoleLogger({ diffMode }),
2705
2507
  onBeforeCompareObjects: async (sourceObject, targetObject) => {
2706
- return replaceRemoteUrlsWithLocalReferences({
2707
- sourceEntity: sourceObject,
2708
- targetEntity: targetObject,
2508
+ return replaceRemoteUrlsWithLocalReferences(sourceObject, targetObject, {
2709
2509
  directory,
2710
2510
  fileClient
2711
2511
  });
2712
2512
  },
2713
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
2714
2513
  onBeforeWriteObject: async (sourceObject) => {
2715
- await downloadFilesForCompositionOrEntry({
2716
- entity: sourceObject.object,
2514
+ return extractAndDownloadUniformFilesForObject(sourceObject, {
2717
2515
  directory,
2718
2516
  fileClient
2719
2517
  });
2720
- return sourceObject;
2721
2518
  }
2722
2519
  });
2723
2520
  }
@@ -2861,15 +2658,12 @@ var CompositionPushModule = {
2861
2658
  allowEmptySource,
2862
2659
  log: createSyncEngineConsoleLogger({ diffMode }),
2863
2660
  onBeforeCompareObjects: async (sourceObject) => {
2864
- return replaceLocalUrlsWithRemoteReferences({
2865
- entity: sourceObject,
2661
+ return swapOutUniformFileUrlsForTargetProject(sourceObject, {
2866
2662
  fileClient
2867
2663
  });
2868
2664
  },
2869
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
2870
2665
  onBeforeWriteObject: async (sourceObject) => {
2871
- return uploadFilesForCompositionOrEntry({
2872
- entity: sourceObject,
2666
+ return extractAndUploadUniformFilesForObject(sourceObject, {
2873
2667
  directory,
2874
2668
  fileClient
2875
2669
  });
@@ -4346,18 +4140,7 @@ var EntryPublishModule = {
4346
4140
  )
4347
4141
  )
4348
4142
  ),
4349
- handler: async ({
4350
- apiHost,
4351
- edgeApiHost,
4352
- apiKey,
4353
- proxy,
4354
- ids,
4355
- all,
4356
- project: projectId,
4357
- whatIf,
4358
- verbose,
4359
- directory
4360
- }) => {
4143
+ handler: async ({ apiHost, edgeApiHost, apiKey, proxy, ids, all, project: projectId, whatIf, verbose }) => {
4361
4144
  if (!all && !ids || all && ids) {
4362
4145
  console.error(`Specify --all or entry ID(s) to publish.`);
4363
4146
  process.exit(1);
@@ -4377,28 +4160,13 @@ var EntryPublishModule = {
4377
4160
  entryIDs: entryIDsArray,
4378
4161
  onlyEntries: true
4379
4162
  });
4380
- const fileClient = getFileClient({ apiKey, apiHost, fetch: fetch2, projectId });
4381
4163
  await syncEngine({
4382
4164
  source,
4383
4165
  target,
4384
4166
  // Publishing is one-direction operation, so no need to support automatic un-publishing
4385
4167
  mode: "createOrUpdate",
4386
4168
  whatIf,
4387
- log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" }),
4388
- onBeforeCompareObjects: async (sourceObject) => {
4389
- return replaceLocalUrlsWithRemoteReferences({
4390
- entity: sourceObject,
4391
- fileClient
4392
- });
4393
- },
4394
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
4395
- onBeforeWriteObject: async (sourceObject) => {
4396
- return uploadFilesForCompositionOrEntry({
4397
- entity: sourceObject,
4398
- directory,
4399
- fileClient
4400
- });
4401
- }
4169
+ log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
4402
4170
  });
4403
4171
  }
4404
4172
  };
@@ -4489,21 +4257,16 @@ var EntryPullModule = {
4489
4257
  allowEmptySource: allowEmptySource ?? true,
4490
4258
  log: createSyncEngineConsoleLogger({ diffMode }),
4491
4259
  onBeforeCompareObjects: async (sourceObject, targetObject) => {
4492
- return replaceRemoteUrlsWithLocalReferences({
4493
- sourceEntity: sourceObject,
4494
- targetEntity: targetObject,
4260
+ return replaceRemoteUrlsWithLocalReferences(sourceObject, targetObject, {
4495
4261
  directory,
4496
4262
  fileClient
4497
4263
  });
4498
4264
  },
4499
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
4500
4265
  onBeforeWriteObject: async (sourceObject) => {
4501
- await downloadFilesForCompositionOrEntry({
4502
- entity: sourceObject.object,
4266
+ return extractAndDownloadUniformFilesForObject(sourceObject, {
4503
4267
  directory,
4504
4268
  fileClient
4505
4269
  });
4506
- return sourceObject;
4507
4270
  }
4508
4271
  });
4509
4272
  }
@@ -4583,15 +4346,12 @@ var EntryPushModule = {
4583
4346
  allowEmptySource,
4584
4347
  log: createSyncEngineConsoleLogger({ diffMode }),
4585
4348
  onBeforeCompareObjects: async (sourceObject) => {
4586
- return replaceLocalUrlsWithRemoteReferences({
4587
- entity: sourceObject,
4349
+ return swapOutUniformFileUrlsForTargetProject(sourceObject, {
4588
4350
  fileClient
4589
4351
  });
4590
4352
  },
4591
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
4592
4353
  onBeforeWriteObject: async (sourceObject) => {
4593
- return uploadFilesForCompositionOrEntry({
4594
- entity: sourceObject,
4354
+ return extractAndUploadUniformFilesForObject(sourceObject, {
4595
4355
  directory,
4596
4356
  fileClient
4597
4357
  });
@@ -4850,18 +4610,7 @@ var EntryPatternPublishModule = {
4850
4610
  )
4851
4611
  )
4852
4612
  ),
4853
- handler: async ({
4854
- apiHost,
4855
- edgeApiHost,
4856
- apiKey,
4857
- proxy,
4858
- ids,
4859
- all,
4860
- whatIf,
4861
- project: projectId,
4862
- verbose,
4863
- directory
4864
- }) => {
4613
+ handler: async ({ apiHost, edgeApiHost, apiKey, proxy, ids, all, whatIf, project: projectId, verbose }) => {
4865
4614
  if (!all && !ids || all && ids) {
4866
4615
  console.error(`Specify --all or entry pattern ID(s) to publish.`);
4867
4616
  process.exit(1);
@@ -4881,28 +4630,13 @@ var EntryPatternPublishModule = {
4881
4630
  entryIDs: entryIDsArray,
4882
4631
  onlyPatterns: true
4883
4632
  });
4884
- const fileClient = getFileClient({ apiKey, apiHost, fetch: fetch2, projectId });
4885
4633
  await syncEngine({
4886
4634
  source,
4887
4635
  target,
4888
4636
  // Publishing is one-direction operation, so no need to support automatic un-publishing
4889
4637
  mode: "createOrUpdate",
4890
4638
  whatIf,
4891
- log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" }),
4892
- onBeforeCompareObjects: async (sourceObject) => {
4893
- return replaceLocalUrlsWithRemoteReferences({
4894
- entity: sourceObject,
4895
- fileClient
4896
- });
4897
- },
4898
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
4899
- onBeforeWriteObject: async (sourceObject) => {
4900
- return uploadFilesForCompositionOrEntry({
4901
- entity: sourceObject,
4902
- directory,
4903
- fileClient
4904
- });
4905
- }
4639
+ log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
4906
4640
  });
4907
4641
  }
4908
4642
  };
@@ -4993,21 +4727,16 @@ var EntryPatternPullModule = {
4993
4727
  allowEmptySource: allowEmptySource ?? true,
4994
4728
  log: createSyncEngineConsoleLogger({ diffMode }),
4995
4729
  onBeforeCompareObjects: async (sourceObject, targetObject) => {
4996
- return replaceRemoteUrlsWithLocalReferences({
4997
- sourceEntity: sourceObject,
4998
- targetEntity: targetObject,
4730
+ return replaceRemoteUrlsWithLocalReferences(sourceObject, targetObject, {
4999
4731
  directory,
5000
4732
  fileClient
5001
4733
  });
5002
4734
  },
5003
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
5004
4735
  onBeforeWriteObject: async (sourceObject) => {
5005
- await downloadFilesForCompositionOrEntry({
5006
- entity: sourceObject.object,
4736
+ return extractAndDownloadUniformFilesForObject(sourceObject, {
5007
4737
  directory,
5008
4738
  fileClient
5009
4739
  });
5010
- return sourceObject;
5011
4740
  }
5012
4741
  });
5013
4742
  }
@@ -5092,15 +4821,12 @@ var EntryPatternPushModule = {
5092
4821
  allowEmptySource,
5093
4822
  log: createSyncEngineConsoleLogger({ diffMode }),
5094
4823
  onBeforeCompareObjects: async (sourceObject) => {
5095
- return replaceLocalUrlsWithRemoteReferences({
5096
- entity: sourceObject,
4824
+ return swapOutUniformFileUrlsForTargetProject(sourceObject, {
5097
4825
  fileClient
5098
4826
  });
5099
4827
  },
5100
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
5101
4828
  onBeforeWriteObject: async (sourceObject) => {
5102
- return uploadFilesForCompositionOrEntry({
5103
- entity: sourceObject,
4829
+ return extractAndUploadUniformFilesForObject(sourceObject, {
5104
4830
  directory,
5105
4831
  fileClient
5106
4832
  });
@@ -8456,7 +8182,7 @@ import { PostHog } from "posthog-node";
8456
8182
  // package.json
8457
8183
  var package_default = {
8458
8184
  name: "@uniformdev/cli",
8459
- version: "20.0.0",
8185
+ version: "20.1.0",
8460
8186
  description: "Uniform command line interface tool",
8461
8187
  license: "SEE LICENSE IN LICENSE.txt",
8462
8188
  main: "./cli.js",
@@ -8487,7 +8213,6 @@ var package_default = {
8487
8213
  "@uniformdev/canvas": "workspace:*",
8488
8214
  "@uniformdev/context": "workspace:*",
8489
8215
  "@uniformdev/files": "workspace:*",
8490
- "@uniformdev/richtext": "workspace:*",
8491
8216
  "@uniformdev/project-map": "workspace:*",
8492
8217
  "@uniformdev/redirect": "workspace:*",
8493
8218
  "call-bind": "^1.0.2",
@@ -8497,11 +8222,11 @@ var package_default = {
8497
8222
  diff: "^5.0.0",
8498
8223
  dotenv: "^16.0.3",
8499
8224
  execa: "5.1.1",
8500
- "file-type": "^20.0.0",
8225
+ "file-type": "^19.6.0",
8501
8226
  "fs-jetpack": "5.1.0",
8502
8227
  graphql: "16.9.0",
8503
8228
  "graphql-request": "6.1.0",
8504
- "image-size": "^1.2.0",
8229
+ "image-size": "^1.0.2",
8505
8230
  inquirer: "9.2.17",
8506
8231
  "isomorphic-git": "1.25.2",
8507
8232
  "js-yaml": "^4.1.0",
@@ -8847,7 +8572,7 @@ ${err.message}`);
8847
8572
  // src/projects/cloneStarter.ts
8848
8573
  import crypto2 from "crypto";
8849
8574
  import fs3 from "fs";
8850
- import fsj5 from "fs-jetpack";
8575
+ import fsj2 from "fs-jetpack";
8851
8576
  import * as git from "isomorphic-git";
8852
8577
  import * as http from "isomorphic-git/http/node/index.js";
8853
8578
  import os from "os";
@@ -8878,7 +8603,7 @@ async function cloneStarter({
8878
8603
  throw new Error(`"${targetDir}" is not empty`);
8879
8604
  }
8880
8605
  const starterDir = path.join(cloneDir, ...pathSegments);
8881
- fsj5.copy(starterDir, targetDir, { overwrite: true });
8606
+ fsj2.copy(starterDir, targetDir, { overwrite: true });
8882
8607
  if (dotEnvFile) {
8883
8608
  fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
8884
8609
  }
@@ -10723,8 +10448,7 @@ var SyncPushModule = {
10723
10448
  ...otherParams,
10724
10449
  patternType: "component",
10725
10450
  onlyPatterns: true,
10726
- all: true,
10727
- directory: getPushFilename("componentPattern", config2)
10451
+ all: true
10728
10452
  }),
10729
10453
  {
10730
10454
  text: "publishing component patterns...",
@@ -10747,8 +10471,7 @@ var SyncPushModule = {
10747
10471
  ...otherParams,
10748
10472
  all: true,
10749
10473
  onlyPatterns: true,
10750
- patternType: "composition",
10751
- directory: getPushFilename("compositionPattern", config2)
10474
+ patternType: "composition"
10752
10475
  }),
10753
10476
  {
10754
10477
  text: "publishing composition patterns...",
@@ -10770,8 +10493,7 @@ var SyncPushModule = {
10770
10493
  CompositionPublishModule.handler({
10771
10494
  ...otherParams,
10772
10495
  all: true,
10773
- onlyCompositions: true,
10774
- directory: getPushFilename("composition", config2)
10496
+ onlyCompositions: true
10775
10497
  }),
10776
10498
  {
10777
10499
  text: "publishing compositions...",
@@ -10789,44 +10511,30 @@ var SyncPushModule = {
10789
10511
  }
10790
10512
  if (config2.entitiesConfig?.entry && config2.entitiesConfig?.entry?.push?.disabled !== true && config2.entitiesConfig?.entry?.publish) {
10791
10513
  try {
10792
- await spinPromise(
10793
- EntryPublishModule.handler({
10794
- ...otherParams,
10795
- all: true,
10796
- directory: getPushFilename("entry", config2)
10797
- }),
10798
- {
10799
- text: "publishing entries...",
10800
- successText: "published entries",
10801
- failText(error) {
10802
- return `publishing entries
10514
+ await spinPromise(EntryPublishModule.handler({ ...otherParams, all: true }), {
10515
+ text: "publishing entries...",
10516
+ successText: "published entries",
10517
+ failText(error) {
10518
+ return `publishing entries
10803
10519
 
10804
10520
  ${error.stack ?? error.message}`;
10805
- }
10806
10521
  }
10807
- );
10522
+ });
10808
10523
  } catch {
10809
10524
  process.exit(1);
10810
10525
  }
10811
10526
  }
10812
10527
  if (config2.entitiesConfig?.entryPattern && config2.entitiesConfig?.entryPattern?.push?.disabled !== true && config2.entitiesConfig?.entryPattern?.publish) {
10813
10528
  try {
10814
- await spinPromise(
10815
- EntryPatternPublishModule.handler({
10816
- ...otherParams,
10817
- all: true,
10818
- directory: getPushFilename("entryPattern", config2)
10819
- }),
10820
- {
10821
- text: "publishing entry patterns...",
10822
- successText: "published entry patterns",
10823
- failText(error) {
10824
- return `publishing entry patterns
10529
+ await spinPromise(EntryPatternPublishModule.handler({ ...otherParams, all: true }), {
10530
+ text: "publishing entry patterns...",
10531
+ successText: "published entry patterns",
10532
+ failText(error) {
10533
+ return `publishing entry patterns
10825
10534
 
10826
10535
  ${error.stack ?? error.message}`;
10827
- }
10828
10536
  }
10829
- );
10537
+ });
10830
10538
  } catch {
10831
10539
  process.exit(1);
10832
10540
  }
@@ -10875,14 +10583,14 @@ import { existsSync as existsSync4, promises as fs5 } from "fs";
10875
10583
  import { get as getHttp } from "http";
10876
10584
  import { get as getHttps } from "https";
10877
10585
  import { tmpdir } from "os";
10878
- import { join as join7 } from "path";
10586
+ import { join as join3 } from "path";
10879
10587
  import registryUrl from "registry-url";
10880
10588
  import { URL as URL2 } from "url";
10881
10589
  var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
10882
10590
  var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
10883
10591
  var getFile = async (details, distTag) => {
10884
10592
  const rootDir = tmpdir();
10885
- const subDir = join7(rootDir, "update-check");
10593
+ const subDir = join3(rootDir, "update-check");
10886
10594
  if (!existsSync4(subDir)) {
10887
10595
  await fs5.mkdir(subDir);
10888
10596
  }
@@ -10890,7 +10598,7 @@ var getFile = async (details, distTag) => {
10890
10598
  if (details.scope) {
10891
10599
  name = `${details.scope}-${name}`;
10892
10600
  }
10893
- return join7(subDir, name);
10601
+ return join3(subDir, name);
10894
10602
  };
10895
10603
  var evaluateCache = async (file, time, interval) => {
10896
10604
  if (existsSync4(file)) {
@@ -11045,7 +10753,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
11045
10753
 
11046
10754
  // src/middleware/checkLocalDepsVersionsMiddleware.ts
11047
10755
  import { magenta, red as red5 } from "colorette";
11048
- import { join as join8 } from "path";
10756
+ import { join as join4 } from "path";
11049
10757
 
11050
10758
  // src/fs.ts
11051
10759
  import { promises as fs6 } from "fs";
@@ -11084,7 +10792,7 @@ var checkLocalDepsVersions = async (args) => {
11084
10792
  try {
11085
10793
  let isOutside = false;
11086
10794
  let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
11087
- const localPackages = await tryReadJSON(join8(process.cwd(), "package.json"));
10795
+ const localPackages = await tryReadJSON(join4(process.cwd(), "package.json"));
11088
10796
  if (!localPackages) return;
11089
10797
  let firstVersion;
11090
10798
  const allDependencies = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.214.1-alpha.37+a5e3049327",
3
+ "version": "20.1.0",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,13 +27,12 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "19.214.1-alpha.37+a5e3049327",
31
- "@uniformdev/canvas": "19.214.1-alpha.37+a5e3049327",
32
- "@uniformdev/context": "19.214.1-alpha.37+a5e3049327",
33
- "@uniformdev/files": "19.214.1-alpha.37+a5e3049327",
34
- "@uniformdev/project-map": "19.214.1-alpha.37+a5e3049327",
35
- "@uniformdev/redirect": "19.214.1-alpha.37+a5e3049327",
36
- "@uniformdev/richtext": "19.214.1-alpha.37+a5e3049327",
30
+ "@uniformdev/assets": "20.1.0",
31
+ "@uniformdev/canvas": "20.1.0",
32
+ "@uniformdev/context": "20.1.0",
33
+ "@uniformdev/files": "20.1.0",
34
+ "@uniformdev/project-map": "20.1.0",
35
+ "@uniformdev/redirect": "20.1.0",
37
36
  "call-bind": "^1.0.2",
38
37
  "colorette": "2.0.20",
39
38
  "cosmiconfig": "9.0.0",
@@ -41,11 +40,11 @@
41
40
  "diff": "^5.0.0",
42
41
  "dotenv": "^16.0.3",
43
42
  "execa": "5.1.1",
44
- "file-type": "^20.0.0",
43
+ "file-type": "^19.6.0",
45
44
  "fs-jetpack": "5.1.0",
46
45
  "graphql": "16.9.0",
47
46
  "graphql-request": "6.1.0",
48
- "image-size": "^1.2.0",
47
+ "image-size": "^1.0.2",
49
48
  "inquirer": "9.2.17",
50
49
  "isomorphic-git": "1.25.2",
51
50
  "js-yaml": "^4.1.0",
@@ -79,5 +78,5 @@
79
78
  "publishConfig": {
80
79
  "access": "public"
81
80
  },
82
- "gitHead": "a5e3049327e1d7e0bb0fb4e0c9a74dd4b9487c54"
81
+ "gitHead": "343f488ce579a33e39d95c88bc7184763404ab07"
83
82
  }