@uniformdev/cli 19.214.1-alpha.33 → 19.214.1-alpha.35
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/dist/index.mjs +589 -307
- package/package.json +11 -10
package/dist/index.mjs
CHANGED
|
@@ -615,17 +615,22 @@ var AssetListModule = {
|
|
|
615
615
|
}
|
|
616
616
|
};
|
|
617
617
|
|
|
618
|
-
// src/files/
|
|
619
|
-
import { preferredType } from "@thi.ng/mime";
|
|
620
|
-
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
|
|
621
|
-
import { fileTypeFromBuffer } from "file-type";
|
|
618
|
+
// src/files/deleteDownloadedFileByUrl.ts
|
|
622
619
|
import fsj from "fs-jetpack";
|
|
623
|
-
import
|
|
624
|
-
|
|
625
|
-
|
|
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";
|
|
626
625
|
var FILES_DIRECTORY_NAME = "files";
|
|
627
|
-
var
|
|
628
|
-
|
|
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
|
+
);
|
|
629
634
|
};
|
|
630
635
|
var urlToHash = (url) => {
|
|
631
636
|
return Buffer.from(
|
|
@@ -634,24 +639,6 @@ var urlToHash = (url) => {
|
|
|
634
639
|
new URL(url).pathname.substring(0, 64)
|
|
635
640
|
).toString("base64");
|
|
636
641
|
};
|
|
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
|
-
};
|
|
655
642
|
var urlToFileExtension = (url) => {
|
|
656
643
|
try {
|
|
657
644
|
const urlObject = new URL(url);
|
|
@@ -666,228 +653,387 @@ var urlToFileName = (url, hash) => {
|
|
|
666
653
|
const fileExtension = urlToFileExtension(url);
|
|
667
654
|
return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
|
|
668
655
|
};
|
|
669
|
-
var
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
join2(directory, "..")
|
|
676
|
-
);
|
|
677
|
-
};
|
|
678
|
-
var getUniformFileUrlMatches = (string) => {
|
|
679
|
-
return string.matchAll(/"(https:\/\/([^"]*?)?(img|files)\.uniform\.(rocks|global)\/([^"]*?))"/g);
|
|
656
|
+
var hashToPartialPathname = (hash) => {
|
|
657
|
+
try {
|
|
658
|
+
return Buffer.from(hash, "base64").toString("utf8");
|
|
659
|
+
} catch {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
680
662
|
};
|
|
663
|
+
|
|
664
|
+
// src/files/deleteDownloadedFileByUrl.ts
|
|
681
665
|
var deleteDownloadedFileByUrl = async (url, options) => {
|
|
682
666
|
const writeDirectory = getFilesDirectory(options.directory);
|
|
683
667
|
const fileName = urlToFileName(url);
|
|
684
|
-
const fileToDelete =
|
|
668
|
+
const fileToDelete = join3(writeDirectory, FILES_DIRECTORY_NAME, fileName);
|
|
685
669
|
try {
|
|
686
670
|
await fsj.removeAsync(fileToDelete);
|
|
687
671
|
} catch {
|
|
688
672
|
console.warn(`Failed to delete a local file ${fileToDelete}`);
|
|
689
673
|
}
|
|
690
674
|
};
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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 fileUploadQueue = new PQueue({ concurrency: 10 });
|
|
739
|
+
var uploadFile = async ({
|
|
740
|
+
fileClient,
|
|
741
|
+
fileUrl,
|
|
742
|
+
directory,
|
|
743
|
+
fileId
|
|
744
|
+
}) => {
|
|
745
|
+
return await fileUploadQueue.add(async () => {
|
|
746
|
+
try {
|
|
747
|
+
const writeDirectory = getFilesDirectory(directory);
|
|
748
|
+
const hash = urlToHash(fileUrl);
|
|
749
|
+
const fileAlreadyExistsChecks = await Promise.all([
|
|
750
|
+
fileClient.get({ url: fileUrl }).catch(() => null),
|
|
751
|
+
fileClient.get({ sourceId: hash }).catch(() => null)
|
|
752
|
+
]);
|
|
753
|
+
const file = fileAlreadyExistsChecks.find((check) => check !== null);
|
|
754
|
+
if (file?.url) {
|
|
755
|
+
return { id: file.id, url: file.url };
|
|
756
|
+
}
|
|
757
|
+
const localFileName = urlToFileName(fileUrl);
|
|
758
|
+
const expectedFilePath = join5(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
|
|
759
|
+
const fileExistsLocally = await fsj3.existsAsync(expectedFilePath);
|
|
760
|
+
if (!fileExistsLocally) {
|
|
761
|
+
console.warn(
|
|
762
|
+
`Skipping file ${fileUrl} as we couldn't find a local copy (looked at ${expectedFilePath})`
|
|
763
|
+
);
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
const fileBuffer = await fsj3.readAsync(expectedFilePath, "buffer");
|
|
767
|
+
if (!fileBuffer) {
|
|
768
|
+
console.warn(`Skipping file ${fileUrl} (${expectedFilePath}) as we couldn't read it`);
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
const fileName = getFileNameFromUrl(fileUrl);
|
|
772
|
+
let mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await fileTypeFromBuffer(fileBuffer))?.mime;
|
|
773
|
+
if (!mimeType) {
|
|
774
|
+
mimeType = preferredType(fileUrl.split(".").at(-1) ?? "");
|
|
775
|
+
}
|
|
776
|
+
if (mimeType === "audio/x-flac") {
|
|
777
|
+
mimeType = "audio/flac";
|
|
778
|
+
}
|
|
779
|
+
const { width, height } = (() => {
|
|
780
|
+
if (!mimeType.startsWith("image/")) {
|
|
781
|
+
return {
|
|
782
|
+
width: void 0,
|
|
783
|
+
height: void 0
|
|
784
|
+
};
|
|
785
|
+
}
|
|
700
786
|
try {
|
|
701
|
-
|
|
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));
|
|
787
|
+
return sizeOf(fileBuffer);
|
|
731
788
|
} catch {
|
|
732
|
-
|
|
789
|
+
return {
|
|
790
|
+
width: void 0,
|
|
791
|
+
height: void 0
|
|
792
|
+
};
|
|
733
793
|
}
|
|
794
|
+
})();
|
|
795
|
+
const { id, method, uploadUrl } = await fileClient.insert({
|
|
796
|
+
id: fileId,
|
|
797
|
+
name: fileName,
|
|
798
|
+
mediaType: mimeType,
|
|
799
|
+
size: fileBuffer.length,
|
|
800
|
+
width,
|
|
801
|
+
height,
|
|
802
|
+
sourceId: hash
|
|
734
803
|
});
|
|
804
|
+
const uploadResponse = await fetch(uploadUrl, {
|
|
805
|
+
method,
|
|
806
|
+
body: fileBuffer,
|
|
807
|
+
headers: {
|
|
808
|
+
"Content-Type": mimeType,
|
|
809
|
+
"Content-Length": fileBuffer.length.toString()
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
if (!uploadResponse.ok) {
|
|
813
|
+
console.warn(`Failed to upload file ${fileUrl} (${expectedFilePath})`);
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
let error;
|
|
817
|
+
const checkForFile = async () => {
|
|
818
|
+
if (error) {
|
|
819
|
+
throw error;
|
|
820
|
+
}
|
|
821
|
+
const file2 = await fileClient.get({ id });
|
|
822
|
+
if (!file2 || file2.state !== FILE_READY_STATE || !file2.url) {
|
|
823
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
824
|
+
return checkForFile();
|
|
825
|
+
}
|
|
826
|
+
return file2.url;
|
|
827
|
+
};
|
|
828
|
+
const abortTimeout = setTimeout(() => {
|
|
829
|
+
error = new Error(`Failed to upload file ${fileUrl} (${expectedFilePath}) - upload timed out`);
|
|
830
|
+
}, 6e4);
|
|
831
|
+
const uploadedFileUrl = await checkForFile();
|
|
832
|
+
clearTimeout(abortTimeout);
|
|
833
|
+
return { id, url: uploadedFileUrl };
|
|
834
|
+
} catch (e) {
|
|
835
|
+
console.warn(`Failed to upload file ${fileUrl}`, e);
|
|
836
|
+
return null;
|
|
837
|
+
}
|
|
838
|
+
}) ?? null;
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// src/files/walkFileUrlsForCompositionOrEntry.ts
|
|
842
|
+
import {
|
|
843
|
+
getPropertiesValue,
|
|
844
|
+
walkNodeTree,
|
|
845
|
+
walkPropertyValues
|
|
846
|
+
} from "@uniformdev/canvas";
|
|
847
|
+
var UNIFORM_FILE_MATCH = /"(https:\/\/([^"]*?)?(img|files)\.uniform\.(rocks|global)\/([^"]*?))"/g;
|
|
848
|
+
var walkFileUrlsForCompositionOrEntry = ({
|
|
849
|
+
entity,
|
|
850
|
+
callback
|
|
851
|
+
}) => {
|
|
852
|
+
const thumbnail = "entry" in entity ? entity.entry._thumbnail : void 0;
|
|
853
|
+
if (typeof thumbnail === "string") {
|
|
854
|
+
const isUniformFile = `"${thumbnail}"`.match(UNIFORM_FILE_MATCH) !== null;
|
|
855
|
+
if (isUniformFile) {
|
|
856
|
+
callback({ fileUrl: thumbnail });
|
|
735
857
|
}
|
|
736
|
-
await fileDownloadQueue.onIdle();
|
|
737
858
|
}
|
|
738
|
-
|
|
859
|
+
walkNodeTree("entry" in entity ? entity.entry : entity.composition, ({ node }) => {
|
|
860
|
+
const properties = getPropertiesValue(node);
|
|
861
|
+
if (!properties) {
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
Object.entries(properties).forEach(([_, property]) => {
|
|
865
|
+
if (property.type !== "image") {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
walkPropertyValues(property, ({ value }) => {
|
|
869
|
+
if (typeof value !== "string") {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
const isUniformFile = `"${value}"`.match(UNIFORM_FILE_MATCH) !== null;
|
|
873
|
+
if (!isUniformFile) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
callback({ fileUrl: value });
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
});
|
|
739
880
|
};
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
881
|
+
|
|
882
|
+
// src/files/files.ts
|
|
883
|
+
var downloadFileForAsset = async ({
|
|
884
|
+
asset,
|
|
885
|
+
directory,
|
|
886
|
+
fileClient
|
|
887
|
+
}) => {
|
|
888
|
+
if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
|
|
889
|
+
return null;
|
|
890
|
+
}
|
|
891
|
+
const fileId = asset.asset.fields?.file?.value;
|
|
892
|
+
const fileUrl = asset.asset.fields.url?.value;
|
|
893
|
+
if (fileId === "" || fileUrl === "") {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
return downloadFile({ fileUrl, directory, fileClient });
|
|
897
|
+
};
|
|
898
|
+
var uploadFileForAsset = async ({
|
|
899
|
+
asset,
|
|
900
|
+
directory,
|
|
901
|
+
fileClient
|
|
902
|
+
}) => {
|
|
903
|
+
if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
const fileUrl = asset.asset.fields.url.value;
|
|
907
|
+
const fileId = asset.asset.fields.file.value;
|
|
908
|
+
return uploadFile({ fileUrl, directory, fileClient, fileId });
|
|
909
|
+
};
|
|
910
|
+
var removeUrlsFromAssetParameters = (entity) => {
|
|
911
|
+
walkNodeTree2("entry" in entity ? entity.entry : entity.composition, ({ node }) => {
|
|
912
|
+
const properties = getPropertiesValue2(node);
|
|
913
|
+
if (!properties) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
Object.entries(properties).forEach(([_, property]) => {
|
|
917
|
+
if (property.type === "asset") {
|
|
918
|
+
walkPropertyValues2(property, ({ value }) => {
|
|
919
|
+
if (!isAssetParamValue(value)) {
|
|
772
920
|
return;
|
|
773
921
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
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
|
-
};
|
|
788
|
-
}
|
|
789
|
-
try {
|
|
790
|
-
return sizeOf(fileBuffer);
|
|
791
|
-
} catch {
|
|
792
|
-
return {
|
|
793
|
-
width: void 0,
|
|
794
|
-
height: void 0
|
|
795
|
-
};
|
|
922
|
+
value.forEach((asset) => {
|
|
923
|
+
if (!isAssetParamValueItem(asset)) {
|
|
924
|
+
return;
|
|
796
925
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
name: fileName,
|
|
800
|
-
mediaType: mimeType,
|
|
801
|
-
size: fileBuffer.length,
|
|
802
|
-
width,
|
|
803
|
-
height,
|
|
804
|
-
sourceId: hash
|
|
805
|
-
});
|
|
806
|
-
const uploadResponse = await fetch(uploadUrl, {
|
|
807
|
-
method,
|
|
808
|
-
body: fileBuffer,
|
|
809
|
-
headers: {
|
|
810
|
-
"Content-Type": mimeType,
|
|
811
|
-
"Content-Length": fileBuffer.length.toString()
|
|
926
|
+
if (asset._source !== ASSETS_SOURCE_UNIFORM || !asset.fields?.url.value) {
|
|
927
|
+
return;
|
|
812
928
|
}
|
|
929
|
+
asset.fields.url.value = "";
|
|
813
930
|
});
|
|
814
|
-
|
|
815
|
-
|
|
931
|
+
});
|
|
932
|
+
} else if (property.type === "richText") {
|
|
933
|
+
walkPropertyValues2(property, ({ value }) => {
|
|
934
|
+
if (!isRichTextValue(value)) {
|
|
816
935
|
return;
|
|
817
936
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if (!file2 || file2.state !== FILE_READY_STATE || !file2.url) {
|
|
825
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
826
|
-
return checkForFile();
|
|
937
|
+
walkRichTextTree(value.root, (node2) => {
|
|
938
|
+
if (isRichTextNodeType(node2, "asset")) {
|
|
939
|
+
if (node2.__asset?._source !== ASSETS_SOURCE_UNIFORM || !node2.__asset.fields.url.value) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
node2.__asset.fields.url.value = "";
|
|
827
943
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
944
|
+
});
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
});
|
|
949
|
+
return entity;
|
|
950
|
+
};
|
|
951
|
+
var compareCompositionsOrEntriesWithoutAssetUrls = (source, target) => {
|
|
952
|
+
return serializedDequal(
|
|
953
|
+
removeUrlsFromAssetParameters(structuredClone(source.object)),
|
|
954
|
+
removeUrlsFromAssetParameters(structuredClone(target.object))
|
|
955
|
+
);
|
|
956
|
+
};
|
|
957
|
+
var removeUrlFromAsset = (asset) => {
|
|
958
|
+
if (asset.asset.fields?.url?.value) {
|
|
959
|
+
asset.asset.fields.url.value = "";
|
|
960
|
+
}
|
|
961
|
+
return asset;
|
|
962
|
+
};
|
|
963
|
+
var compareAssetsWithoutUrls = (source, target) => {
|
|
964
|
+
return serializedDequal(
|
|
965
|
+
removeUrlFromAsset(structuredClone(source.object)),
|
|
966
|
+
removeUrlFromAsset(structuredClone(target.object))
|
|
967
|
+
);
|
|
968
|
+
};
|
|
969
|
+
var downloadFilesForCompositionOrEntry = async ({
|
|
970
|
+
entity,
|
|
971
|
+
directory,
|
|
972
|
+
fileClient
|
|
973
|
+
}) => {
|
|
974
|
+
const fileDownloadQueue = new PQueue2({ concurrency: 3 });
|
|
975
|
+
await walkFileUrlsForCompositionOrEntry({
|
|
976
|
+
entity,
|
|
977
|
+
callback: ({ fileUrl }) => {
|
|
978
|
+
fileDownloadQueue.add(async () => {
|
|
979
|
+
await downloadFile({ fileUrl, directory, fileClient });
|
|
839
980
|
});
|
|
840
981
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
return JSON.parse(objectAsString);
|
|
982
|
+
});
|
|
983
|
+
await fileDownloadQueue.onIdle();
|
|
844
984
|
};
|
|
845
|
-
var
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
|
|
864
|
-
} catch {
|
|
985
|
+
var uploadFilesForCompositionOrEntry = async ({
|
|
986
|
+
entity,
|
|
987
|
+
directory,
|
|
988
|
+
fileClient
|
|
989
|
+
}) => {
|
|
990
|
+
const fileUploadQueue2 = new PQueue2({ concurrency: 3 });
|
|
991
|
+
const urlReplacementMap = /* @__PURE__ */ new Map();
|
|
992
|
+
walkFileUrlsForCompositionOrEntry({
|
|
993
|
+
entity: entity.object,
|
|
994
|
+
callback: async ({ fileUrl }) => {
|
|
995
|
+
fileUploadQueue2.add(async () => {
|
|
996
|
+
const upload = await uploadFile({
|
|
997
|
+
directory,
|
|
998
|
+
fileUrl,
|
|
999
|
+
fileClient
|
|
1000
|
+
});
|
|
1001
|
+
if (upload !== null) {
|
|
1002
|
+
urlReplacementMap.set(fileUrl, upload.url);
|
|
865
1003
|
}
|
|
866
1004
|
});
|
|
867
1005
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1006
|
+
});
|
|
1007
|
+
await fileUploadQueue2.onIdle();
|
|
1008
|
+
let entityAsString = JSON.stringify(entity);
|
|
1009
|
+
for (const [key, value] of urlReplacementMap.entries()) {
|
|
1010
|
+
entityAsString = entityAsString.replaceAll(`"${key}"`, `"${value}"`);
|
|
1011
|
+
}
|
|
1012
|
+
return JSON.parse(entityAsString);
|
|
1013
|
+
};
|
|
1014
|
+
var replaceRemoteUrlsWithLocalReferences = async ({
|
|
1015
|
+
sourceEntity,
|
|
1016
|
+
targetEntity,
|
|
1017
|
+
fileClient,
|
|
1018
|
+
directory
|
|
1019
|
+
}) => {
|
|
1020
|
+
let sourceEntityAsString = JSON.stringify(sourceEntity);
|
|
1021
|
+
const targetEntityAsString = JSON.stringify(targetEntity);
|
|
1022
|
+
const writeDirectory = getFilesDirectory(directory);
|
|
1023
|
+
const fileUrlReplacementQueue = new PQueue2({ concurrency: 3 });
|
|
1024
|
+
walkFileUrlsForCompositionOrEntry({
|
|
1025
|
+
entity: sourceEntity.object,
|
|
1026
|
+
callback: ({ fileUrl }) => {
|
|
881
1027
|
fileUrlReplacementQueue.add(async () => {
|
|
882
1028
|
try {
|
|
883
|
-
const localFileName = urlToFileName(
|
|
884
|
-
const fileExistsLocally = await
|
|
885
|
-
|
|
1029
|
+
const localFileName = urlToFileName(fileUrl);
|
|
1030
|
+
const fileExistsLocally = await fsj4.existsAsync(
|
|
1031
|
+
join6(writeDirectory, FILES_DIRECTORY_NAME, localFileName)
|
|
886
1032
|
);
|
|
887
1033
|
if (fileExistsLocally) {
|
|
888
1034
|
return;
|
|
889
1035
|
}
|
|
890
|
-
const file = await
|
|
1036
|
+
const file = await fileClient.get({ url: fileUrl }).catch(() => null);
|
|
891
1037
|
if (!file || !file.sourceId) {
|
|
892
1038
|
return;
|
|
893
1039
|
}
|
|
@@ -895,36 +1041,64 @@ var replaceRemoteUrlsWithLocalReferences = async (sourceObject, targetObject, op
|
|
|
895
1041
|
if (!originalPartialPath) {
|
|
896
1042
|
return;
|
|
897
1043
|
}
|
|
898
|
-
const originalUrl = findUrlMatchingPartialPathname(
|
|
1044
|
+
const originalUrl = findUrlMatchingPartialPathname(targetEntityAsString, originalPartialPath);
|
|
899
1045
|
if (!originalUrl) {
|
|
900
1046
|
return;
|
|
901
1047
|
}
|
|
902
|
-
|
|
1048
|
+
sourceEntityAsString = sourceEntityAsString.replaceAll(`"${fileUrl}"`, `"${originalUrl}"`);
|
|
903
1049
|
} catch {
|
|
904
1050
|
}
|
|
905
1051
|
});
|
|
1052
|
+
return null;
|
|
906
1053
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
return JSON.parse(
|
|
1054
|
+
});
|
|
1055
|
+
await fileUrlReplacementQueue.onIdle();
|
|
1056
|
+
return JSON.parse(sourceEntityAsString);
|
|
910
1057
|
};
|
|
911
|
-
var
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1058
|
+
var replaceLocalUrlsWithRemoteReferences = async ({
|
|
1059
|
+
entity,
|
|
1060
|
+
fileClient
|
|
1061
|
+
}) => {
|
|
1062
|
+
let entityAsString = JSON.stringify(entity);
|
|
1063
|
+
const fileUrlReplacementQueue = new PQueue2({ concurrency: 3 });
|
|
1064
|
+
walkFileUrlsForCompositionOrEntry({
|
|
1065
|
+
entity: entity.object,
|
|
1066
|
+
callback: ({ fileUrl }) => {
|
|
1067
|
+
fileUrlReplacementQueue.add(async () => {
|
|
1068
|
+
try {
|
|
1069
|
+
const hash = urlToHash(fileUrl);
|
|
1070
|
+
fileUrlReplacementQueue.add(async () => {
|
|
1071
|
+
try {
|
|
1072
|
+
const file = await fileClient.get({ sourceId: hash }).catch(() => null);
|
|
1073
|
+
if (!file) {
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
entityAsString = entityAsString.replaceAll(`"${fileUrl}"`, `"${file.url}"`);
|
|
1077
|
+
} catch {
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
} catch {
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
return null;
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
await fileUrlReplacementQueue.onIdle();
|
|
1087
|
+
return JSON.parse(entityAsString);
|
|
1088
|
+
};
|
|
1089
|
+
var escapeRegExp = (string) => {
|
|
1090
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1091
|
+
};
|
|
1092
|
+
var findUrlMatchingPartialPathname = (source, pathname) => {
|
|
1093
|
+
const escapedPathname = escapeRegExp(pathname);
|
|
1094
|
+
const regex = new RegExp(
|
|
1095
|
+
`"(https://([^"]*?)?(img|files).uniform.(rocks|global)${escapedPathname}([^"]*?))"`
|
|
1096
|
+
);
|
|
1097
|
+
const match = source.match(regex);
|
|
1098
|
+
if (match && match[1]) {
|
|
1099
|
+
return match[1];
|
|
922
1100
|
}
|
|
923
|
-
|
|
924
|
-
type: "file",
|
|
925
|
-
value: file.id
|
|
926
|
-
};
|
|
927
|
-
return asset;
|
|
1101
|
+
return null;
|
|
928
1102
|
};
|
|
929
1103
|
|
|
930
1104
|
// src/commands/canvas/assetEngineDataSource.ts
|
|
@@ -1115,27 +1289,25 @@ var AssetPullModule = {
|
|
|
1115
1289
|
whatIf,
|
|
1116
1290
|
allowEmptySource: allowEmptySource ?? true,
|
|
1117
1291
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
1118
|
-
onBeforeCompareObjects: async (sourceObject
|
|
1292
|
+
onBeforeCompareObjects: async (sourceObject) => {
|
|
1119
1293
|
delete sourceObject.object.asset._author;
|
|
1120
|
-
|
|
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;
|
|
1294
|
+
return sourceObject;
|
|
1132
1295
|
},
|
|
1296
|
+
compareContents: compareAssetsWithoutUrls,
|
|
1133
1297
|
onBeforeWriteObject: async (sourceObject) => {
|
|
1134
1298
|
delete sourceObject.object.asset._author;
|
|
1135
|
-
|
|
1299
|
+
if (!sourceObject.object.asset.fields?.file) {
|
|
1300
|
+
return sourceObject;
|
|
1301
|
+
}
|
|
1302
|
+
const downloadedFile = await downloadFileForAsset({
|
|
1303
|
+
asset: sourceObject.object,
|
|
1136
1304
|
directory,
|
|
1137
1305
|
fileClient
|
|
1138
1306
|
});
|
|
1307
|
+
if (downloadedFile?.id) {
|
|
1308
|
+
sourceObject.object.asset.fields.file.value = downloadedFile.id;
|
|
1309
|
+
}
|
|
1310
|
+
return sourceObject;
|
|
1139
1311
|
}
|
|
1140
1312
|
});
|
|
1141
1313
|
}
|
|
@@ -1215,29 +1387,29 @@ var AssetPushModule = {
|
|
|
1215
1387
|
if (targetObject) {
|
|
1216
1388
|
delete targetObject.object.asset._author;
|
|
1217
1389
|
}
|
|
1218
|
-
|
|
1219
|
-
fileClient
|
|
1220
|
-
});
|
|
1221
|
-
sourceObjectWithNewFileUrls.object = await updateAssetFileIdBasedOnUrl(
|
|
1222
|
-
sourceObjectWithNewFileUrls.object,
|
|
1223
|
-
{
|
|
1224
|
-
fileClient
|
|
1225
|
-
}
|
|
1226
|
-
);
|
|
1227
|
-
return sourceObjectWithNewFileUrls;
|
|
1390
|
+
return sourceObject;
|
|
1228
1391
|
},
|
|
1392
|
+
compareContents: compareAssetsWithoutUrls,
|
|
1229
1393
|
onBeforeWriteObject: async (sourceObject) => {
|
|
1230
|
-
const
|
|
1394
|
+
const uploadedFile = await uploadFileForAsset({
|
|
1395
|
+
asset: sourceObject.object,
|
|
1231
1396
|
directory,
|
|
1232
1397
|
fileClient
|
|
1233
1398
|
});
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
fileClient
|
|
1399
|
+
if (uploadedFile !== null) {
|
|
1400
|
+
if (sourceObject.object.asset.fields === void 0) {
|
|
1401
|
+
sourceObject.object.asset.fields = {};
|
|
1238
1402
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1403
|
+
sourceObject.object.asset.fields.file = {
|
|
1404
|
+
type: "file",
|
|
1405
|
+
value: uploadedFile.id
|
|
1406
|
+
};
|
|
1407
|
+
sourceObject.object.asset.fields.url = {
|
|
1408
|
+
type: "text",
|
|
1409
|
+
value: uploadedFile.url
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
return sourceObject;
|
|
1241
1413
|
}
|
|
1242
1414
|
});
|
|
1243
1415
|
}
|
|
@@ -2323,7 +2495,8 @@ var CompositionPublishModule = {
|
|
|
2323
2495
|
onlyCompositions,
|
|
2324
2496
|
onlyPatterns,
|
|
2325
2497
|
patternType,
|
|
2326
|
-
verbose
|
|
2498
|
+
verbose,
|
|
2499
|
+
directory
|
|
2327
2500
|
}) => {
|
|
2328
2501
|
if (!all && !ids || all && ids) {
|
|
2329
2502
|
console.error(`Specify --all or composition ID(s) to publish.`);
|
|
@@ -2350,6 +2523,7 @@ var CompositionPublishModule = {
|
|
|
2350
2523
|
patternType,
|
|
2351
2524
|
verbose
|
|
2352
2525
|
});
|
|
2526
|
+
const fileClient = getFileClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
2353
2527
|
await syncEngine({
|
|
2354
2528
|
source,
|
|
2355
2529
|
target,
|
|
@@ -2357,7 +2531,21 @@ var CompositionPublishModule = {
|
|
|
2357
2531
|
mode: "createOrUpdate",
|
|
2358
2532
|
whatIf,
|
|
2359
2533
|
verbose,
|
|
2360
|
-
log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
|
|
2534
|
+
log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" }),
|
|
2535
|
+
onBeforeCompareObjects: async (sourceObject) => {
|
|
2536
|
+
return replaceLocalUrlsWithRemoteReferences({
|
|
2537
|
+
entity: sourceObject,
|
|
2538
|
+
fileClient
|
|
2539
|
+
});
|
|
2540
|
+
},
|
|
2541
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
2542
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
2543
|
+
return uploadFilesForCompositionOrEntry({
|
|
2544
|
+
entity: sourceObject,
|
|
2545
|
+
directory,
|
|
2546
|
+
fileClient
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2361
2549
|
});
|
|
2362
2550
|
}
|
|
2363
2551
|
};
|
|
@@ -2505,16 +2693,21 @@ var CompositionPullModule = {
|
|
|
2505
2693
|
allowEmptySource: allowEmptySource ?? true,
|
|
2506
2694
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
2507
2695
|
onBeforeCompareObjects: async (sourceObject, targetObject) => {
|
|
2508
|
-
return replaceRemoteUrlsWithLocalReferences(
|
|
2696
|
+
return replaceRemoteUrlsWithLocalReferences({
|
|
2697
|
+
sourceEntity: sourceObject,
|
|
2698
|
+
targetEntity: targetObject,
|
|
2509
2699
|
directory,
|
|
2510
2700
|
fileClient
|
|
2511
2701
|
});
|
|
2512
2702
|
},
|
|
2703
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
2513
2704
|
onBeforeWriteObject: async (sourceObject) => {
|
|
2514
|
-
|
|
2705
|
+
await downloadFilesForCompositionOrEntry({
|
|
2706
|
+
entity: sourceObject.object,
|
|
2515
2707
|
directory,
|
|
2516
2708
|
fileClient
|
|
2517
2709
|
});
|
|
2710
|
+
return sourceObject;
|
|
2518
2711
|
}
|
|
2519
2712
|
});
|
|
2520
2713
|
}
|
|
@@ -2658,12 +2851,15 @@ var CompositionPushModule = {
|
|
|
2658
2851
|
allowEmptySource,
|
|
2659
2852
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
2660
2853
|
onBeforeCompareObjects: async (sourceObject) => {
|
|
2661
|
-
return
|
|
2854
|
+
return replaceLocalUrlsWithRemoteReferences({
|
|
2855
|
+
entity: sourceObject,
|
|
2662
2856
|
fileClient
|
|
2663
2857
|
});
|
|
2664
2858
|
},
|
|
2859
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
2665
2860
|
onBeforeWriteObject: async (sourceObject) => {
|
|
2666
|
-
return
|
|
2861
|
+
return uploadFilesForCompositionOrEntry({
|
|
2862
|
+
entity: sourceObject,
|
|
2667
2863
|
directory,
|
|
2668
2864
|
fileClient
|
|
2669
2865
|
});
|
|
@@ -4140,7 +4336,18 @@ var EntryPublishModule = {
|
|
|
4140
4336
|
)
|
|
4141
4337
|
)
|
|
4142
4338
|
),
|
|
4143
|
-
handler: async ({
|
|
4339
|
+
handler: async ({
|
|
4340
|
+
apiHost,
|
|
4341
|
+
edgeApiHost,
|
|
4342
|
+
apiKey,
|
|
4343
|
+
proxy,
|
|
4344
|
+
ids,
|
|
4345
|
+
all,
|
|
4346
|
+
project: projectId,
|
|
4347
|
+
whatIf,
|
|
4348
|
+
verbose,
|
|
4349
|
+
directory
|
|
4350
|
+
}) => {
|
|
4144
4351
|
if (!all && !ids || all && ids) {
|
|
4145
4352
|
console.error(`Specify --all or entry ID(s) to publish.`);
|
|
4146
4353
|
process.exit(1);
|
|
@@ -4160,13 +4367,28 @@ var EntryPublishModule = {
|
|
|
4160
4367
|
entryIDs: entryIDsArray,
|
|
4161
4368
|
onlyEntries: true
|
|
4162
4369
|
});
|
|
4370
|
+
const fileClient = getFileClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
4163
4371
|
await syncEngine({
|
|
4164
4372
|
source,
|
|
4165
4373
|
target,
|
|
4166
4374
|
// Publishing is one-direction operation, so no need to support automatic un-publishing
|
|
4167
4375
|
mode: "createOrUpdate",
|
|
4168
4376
|
whatIf,
|
|
4169
|
-
log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
|
|
4377
|
+
log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" }),
|
|
4378
|
+
onBeforeCompareObjects: async (sourceObject) => {
|
|
4379
|
+
return replaceLocalUrlsWithRemoteReferences({
|
|
4380
|
+
entity: sourceObject,
|
|
4381
|
+
fileClient
|
|
4382
|
+
});
|
|
4383
|
+
},
|
|
4384
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
4385
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
4386
|
+
return uploadFilesForCompositionOrEntry({
|
|
4387
|
+
entity: sourceObject,
|
|
4388
|
+
directory,
|
|
4389
|
+
fileClient
|
|
4390
|
+
});
|
|
4391
|
+
}
|
|
4170
4392
|
});
|
|
4171
4393
|
}
|
|
4172
4394
|
};
|
|
@@ -4257,16 +4479,21 @@ var EntryPullModule = {
|
|
|
4257
4479
|
allowEmptySource: allowEmptySource ?? true,
|
|
4258
4480
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
4259
4481
|
onBeforeCompareObjects: async (sourceObject, targetObject) => {
|
|
4260
|
-
return replaceRemoteUrlsWithLocalReferences(
|
|
4482
|
+
return replaceRemoteUrlsWithLocalReferences({
|
|
4483
|
+
sourceEntity: sourceObject,
|
|
4484
|
+
targetEntity: targetObject,
|
|
4261
4485
|
directory,
|
|
4262
4486
|
fileClient
|
|
4263
4487
|
});
|
|
4264
4488
|
},
|
|
4489
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
4265
4490
|
onBeforeWriteObject: async (sourceObject) => {
|
|
4266
|
-
|
|
4491
|
+
await downloadFilesForCompositionOrEntry({
|
|
4492
|
+
entity: sourceObject.object,
|
|
4267
4493
|
directory,
|
|
4268
4494
|
fileClient
|
|
4269
4495
|
});
|
|
4496
|
+
return sourceObject;
|
|
4270
4497
|
}
|
|
4271
4498
|
});
|
|
4272
4499
|
}
|
|
@@ -4346,12 +4573,15 @@ var EntryPushModule = {
|
|
|
4346
4573
|
allowEmptySource,
|
|
4347
4574
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
4348
4575
|
onBeforeCompareObjects: async (sourceObject) => {
|
|
4349
|
-
return
|
|
4576
|
+
return replaceLocalUrlsWithRemoteReferences({
|
|
4577
|
+
entity: sourceObject,
|
|
4350
4578
|
fileClient
|
|
4351
4579
|
});
|
|
4352
4580
|
},
|
|
4581
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
4353
4582
|
onBeforeWriteObject: async (sourceObject) => {
|
|
4354
|
-
return
|
|
4583
|
+
return uploadFilesForCompositionOrEntry({
|
|
4584
|
+
entity: sourceObject,
|
|
4355
4585
|
directory,
|
|
4356
4586
|
fileClient
|
|
4357
4587
|
});
|
|
@@ -4610,7 +4840,18 @@ var EntryPatternPublishModule = {
|
|
|
4610
4840
|
)
|
|
4611
4841
|
)
|
|
4612
4842
|
),
|
|
4613
|
-
handler: async ({
|
|
4843
|
+
handler: async ({
|
|
4844
|
+
apiHost,
|
|
4845
|
+
edgeApiHost,
|
|
4846
|
+
apiKey,
|
|
4847
|
+
proxy,
|
|
4848
|
+
ids,
|
|
4849
|
+
all,
|
|
4850
|
+
whatIf,
|
|
4851
|
+
project: projectId,
|
|
4852
|
+
verbose,
|
|
4853
|
+
directory
|
|
4854
|
+
}) => {
|
|
4614
4855
|
if (!all && !ids || all && ids) {
|
|
4615
4856
|
console.error(`Specify --all or entry pattern ID(s) to publish.`);
|
|
4616
4857
|
process.exit(1);
|
|
@@ -4630,13 +4871,28 @@ var EntryPatternPublishModule = {
|
|
|
4630
4871
|
entryIDs: entryIDsArray,
|
|
4631
4872
|
onlyPatterns: true
|
|
4632
4873
|
});
|
|
4874
|
+
const fileClient = getFileClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
4633
4875
|
await syncEngine({
|
|
4634
4876
|
source,
|
|
4635
4877
|
target,
|
|
4636
4878
|
// Publishing is one-direction operation, so no need to support automatic un-publishing
|
|
4637
4879
|
mode: "createOrUpdate",
|
|
4638
4880
|
whatIf,
|
|
4639
|
-
log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
|
|
4881
|
+
log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" }),
|
|
4882
|
+
onBeforeCompareObjects: async (sourceObject) => {
|
|
4883
|
+
return replaceLocalUrlsWithRemoteReferences({
|
|
4884
|
+
entity: sourceObject,
|
|
4885
|
+
fileClient
|
|
4886
|
+
});
|
|
4887
|
+
},
|
|
4888
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
4889
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
4890
|
+
return uploadFilesForCompositionOrEntry({
|
|
4891
|
+
entity: sourceObject,
|
|
4892
|
+
directory,
|
|
4893
|
+
fileClient
|
|
4894
|
+
});
|
|
4895
|
+
}
|
|
4640
4896
|
});
|
|
4641
4897
|
}
|
|
4642
4898
|
};
|
|
@@ -4727,16 +4983,21 @@ var EntryPatternPullModule = {
|
|
|
4727
4983
|
allowEmptySource: allowEmptySource ?? true,
|
|
4728
4984
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
4729
4985
|
onBeforeCompareObjects: async (sourceObject, targetObject) => {
|
|
4730
|
-
return replaceRemoteUrlsWithLocalReferences(
|
|
4986
|
+
return replaceRemoteUrlsWithLocalReferences({
|
|
4987
|
+
sourceEntity: sourceObject,
|
|
4988
|
+
targetEntity: targetObject,
|
|
4731
4989
|
directory,
|
|
4732
4990
|
fileClient
|
|
4733
4991
|
});
|
|
4734
4992
|
},
|
|
4993
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
4735
4994
|
onBeforeWriteObject: async (sourceObject) => {
|
|
4736
|
-
|
|
4995
|
+
await downloadFilesForCompositionOrEntry({
|
|
4996
|
+
entity: sourceObject.object,
|
|
4737
4997
|
directory,
|
|
4738
4998
|
fileClient
|
|
4739
4999
|
});
|
|
5000
|
+
return sourceObject;
|
|
4740
5001
|
}
|
|
4741
5002
|
});
|
|
4742
5003
|
}
|
|
@@ -4821,12 +5082,15 @@ var EntryPatternPushModule = {
|
|
|
4821
5082
|
allowEmptySource,
|
|
4822
5083
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
4823
5084
|
onBeforeCompareObjects: async (sourceObject) => {
|
|
4824
|
-
return
|
|
5085
|
+
return replaceLocalUrlsWithRemoteReferences({
|
|
5086
|
+
entity: sourceObject,
|
|
4825
5087
|
fileClient
|
|
4826
5088
|
});
|
|
4827
5089
|
},
|
|
5090
|
+
compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
|
|
4828
5091
|
onBeforeWriteObject: async (sourceObject) => {
|
|
4829
|
-
return
|
|
5092
|
+
return uploadFilesForCompositionOrEntry({
|
|
5093
|
+
entity: sourceObject,
|
|
4830
5094
|
directory,
|
|
4831
5095
|
fileClient
|
|
4832
5096
|
});
|
|
@@ -8182,7 +8446,7 @@ import { PostHog } from "posthog-node";
|
|
|
8182
8446
|
// package.json
|
|
8183
8447
|
var package_default = {
|
|
8184
8448
|
name: "@uniformdev/cli",
|
|
8185
|
-
version: "
|
|
8449
|
+
version: "20.0.0",
|
|
8186
8450
|
description: "Uniform command line interface tool",
|
|
8187
8451
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
8188
8452
|
main: "./cli.js",
|
|
@@ -8213,6 +8477,7 @@ var package_default = {
|
|
|
8213
8477
|
"@uniformdev/canvas": "workspace:*",
|
|
8214
8478
|
"@uniformdev/context": "workspace:*",
|
|
8215
8479
|
"@uniformdev/files": "workspace:*",
|
|
8480
|
+
"@uniformdev/richtext": "workspace:*",
|
|
8216
8481
|
"@uniformdev/project-map": "workspace:*",
|
|
8217
8482
|
"@uniformdev/redirect": "workspace:*",
|
|
8218
8483
|
"call-bind": "^1.0.2",
|
|
@@ -8222,11 +8487,11 @@ var package_default = {
|
|
|
8222
8487
|
diff: "^5.0.0",
|
|
8223
8488
|
dotenv: "^16.0.3",
|
|
8224
8489
|
execa: "5.1.1",
|
|
8225
|
-
"file-type": "^
|
|
8490
|
+
"file-type": "^20.0.0",
|
|
8226
8491
|
"fs-jetpack": "5.1.0",
|
|
8227
8492
|
graphql: "16.9.0",
|
|
8228
8493
|
"graphql-request": "6.1.0",
|
|
8229
|
-
"image-size": "^1.0
|
|
8494
|
+
"image-size": "^1.2.0",
|
|
8230
8495
|
inquirer: "9.2.17",
|
|
8231
8496
|
"isomorphic-git": "1.25.2",
|
|
8232
8497
|
"js-yaml": "^4.1.0",
|
|
@@ -8572,7 +8837,7 @@ ${err.message}`);
|
|
|
8572
8837
|
// src/projects/cloneStarter.ts
|
|
8573
8838
|
import crypto2 from "crypto";
|
|
8574
8839
|
import fs3 from "fs";
|
|
8575
|
-
import
|
|
8840
|
+
import fsj5 from "fs-jetpack";
|
|
8576
8841
|
import * as git from "isomorphic-git";
|
|
8577
8842
|
import * as http from "isomorphic-git/http/node/index.js";
|
|
8578
8843
|
import os from "os";
|
|
@@ -8603,7 +8868,7 @@ async function cloneStarter({
|
|
|
8603
8868
|
throw new Error(`"${targetDir}" is not empty`);
|
|
8604
8869
|
}
|
|
8605
8870
|
const starterDir = path.join(cloneDir, ...pathSegments);
|
|
8606
|
-
|
|
8871
|
+
fsj5.copy(starterDir, targetDir, { overwrite: true });
|
|
8607
8872
|
if (dotEnvFile) {
|
|
8608
8873
|
fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
|
|
8609
8874
|
}
|
|
@@ -10448,7 +10713,8 @@ var SyncPushModule = {
|
|
|
10448
10713
|
...otherParams,
|
|
10449
10714
|
patternType: "component",
|
|
10450
10715
|
onlyPatterns: true,
|
|
10451
|
-
all: true
|
|
10716
|
+
all: true,
|
|
10717
|
+
directory: getPushFilename("componentPattern", config2)
|
|
10452
10718
|
}),
|
|
10453
10719
|
{
|
|
10454
10720
|
text: "publishing component patterns...",
|
|
@@ -10471,7 +10737,8 @@ var SyncPushModule = {
|
|
|
10471
10737
|
...otherParams,
|
|
10472
10738
|
all: true,
|
|
10473
10739
|
onlyPatterns: true,
|
|
10474
|
-
patternType: "composition"
|
|
10740
|
+
patternType: "composition",
|
|
10741
|
+
directory: getPushFilename("compositionPattern", config2)
|
|
10475
10742
|
}),
|
|
10476
10743
|
{
|
|
10477
10744
|
text: "publishing composition patterns...",
|
|
@@ -10493,7 +10760,8 @@ var SyncPushModule = {
|
|
|
10493
10760
|
CompositionPublishModule.handler({
|
|
10494
10761
|
...otherParams,
|
|
10495
10762
|
all: true,
|
|
10496
|
-
onlyCompositions: true
|
|
10763
|
+
onlyCompositions: true,
|
|
10764
|
+
directory: getPushFilename("composition", config2)
|
|
10497
10765
|
}),
|
|
10498
10766
|
{
|
|
10499
10767
|
text: "publishing compositions...",
|
|
@@ -10511,30 +10779,44 @@ var SyncPushModule = {
|
|
|
10511
10779
|
}
|
|
10512
10780
|
if (config2.entitiesConfig?.entry && config2.entitiesConfig?.entry?.push?.disabled !== true && config2.entitiesConfig?.entry?.publish) {
|
|
10513
10781
|
try {
|
|
10514
|
-
await spinPromise(
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10782
|
+
await spinPromise(
|
|
10783
|
+
EntryPublishModule.handler({
|
|
10784
|
+
...otherParams,
|
|
10785
|
+
all: true,
|
|
10786
|
+
directory: getPushFilename("entry", config2)
|
|
10787
|
+
}),
|
|
10788
|
+
{
|
|
10789
|
+
text: "publishing entries...",
|
|
10790
|
+
successText: "published entries",
|
|
10791
|
+
failText(error) {
|
|
10792
|
+
return `publishing entries
|
|
10519
10793
|
|
|
10520
10794
|
${error.stack ?? error.message}`;
|
|
10795
|
+
}
|
|
10521
10796
|
}
|
|
10522
|
-
|
|
10797
|
+
);
|
|
10523
10798
|
} catch {
|
|
10524
10799
|
process.exit(1);
|
|
10525
10800
|
}
|
|
10526
10801
|
}
|
|
10527
10802
|
if (config2.entitiesConfig?.entryPattern && config2.entitiesConfig?.entryPattern?.push?.disabled !== true && config2.entitiesConfig?.entryPattern?.publish) {
|
|
10528
10803
|
try {
|
|
10529
|
-
await spinPromise(
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10804
|
+
await spinPromise(
|
|
10805
|
+
EntryPatternPublishModule.handler({
|
|
10806
|
+
...otherParams,
|
|
10807
|
+
all: true,
|
|
10808
|
+
directory: getPushFilename("entryPattern", config2)
|
|
10809
|
+
}),
|
|
10810
|
+
{
|
|
10811
|
+
text: "publishing entry patterns...",
|
|
10812
|
+
successText: "published entry patterns",
|
|
10813
|
+
failText(error) {
|
|
10814
|
+
return `publishing entry patterns
|
|
10534
10815
|
|
|
10535
10816
|
${error.stack ?? error.message}`;
|
|
10817
|
+
}
|
|
10536
10818
|
}
|
|
10537
|
-
|
|
10819
|
+
);
|
|
10538
10820
|
} catch {
|
|
10539
10821
|
process.exit(1);
|
|
10540
10822
|
}
|
|
@@ -10583,14 +10865,14 @@ import { existsSync as existsSync4, promises as fs5 } from "fs";
|
|
|
10583
10865
|
import { get as getHttp } from "http";
|
|
10584
10866
|
import { get as getHttps } from "https";
|
|
10585
10867
|
import { tmpdir } from "os";
|
|
10586
|
-
import { join as
|
|
10868
|
+
import { join as join7 } from "path";
|
|
10587
10869
|
import registryUrl from "registry-url";
|
|
10588
10870
|
import { URL as URL2 } from "url";
|
|
10589
10871
|
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
10590
10872
|
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
10591
10873
|
var getFile = async (details, distTag) => {
|
|
10592
10874
|
const rootDir = tmpdir();
|
|
10593
|
-
const subDir =
|
|
10875
|
+
const subDir = join7(rootDir, "update-check");
|
|
10594
10876
|
if (!existsSync4(subDir)) {
|
|
10595
10877
|
await fs5.mkdir(subDir);
|
|
10596
10878
|
}
|
|
@@ -10598,7 +10880,7 @@ var getFile = async (details, distTag) => {
|
|
|
10598
10880
|
if (details.scope) {
|
|
10599
10881
|
name = `${details.scope}-${name}`;
|
|
10600
10882
|
}
|
|
10601
|
-
return
|
|
10883
|
+
return join7(subDir, name);
|
|
10602
10884
|
};
|
|
10603
10885
|
var evaluateCache = async (file, time, interval) => {
|
|
10604
10886
|
if (existsSync4(file)) {
|
|
@@ -10753,7 +11035,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
|
|
|
10753
11035
|
|
|
10754
11036
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
10755
11037
|
import { magenta, red as red5 } from "colorette";
|
|
10756
|
-
import { join as
|
|
11038
|
+
import { join as join8 } from "path";
|
|
10757
11039
|
|
|
10758
11040
|
// src/fs.ts
|
|
10759
11041
|
import { promises as fs6 } from "fs";
|
|
@@ -10792,7 +11074,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
10792
11074
|
try {
|
|
10793
11075
|
let isOutside = false;
|
|
10794
11076
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
10795
|
-
const localPackages = await tryReadJSON(
|
|
11077
|
+
const localPackages = await tryReadJSON(join8(process.cwd(), "package.json"));
|
|
10796
11078
|
if (!localPackages) return;
|
|
10797
11079
|
let firstVersion;
|
|
10798
11080
|
const allDependencies = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "19.214.1-alpha.
|
|
3
|
+
"version": "19.214.1-alpha.35+6fc698bf99",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@thi.ng/mime": "^2.2.23",
|
|
30
|
-
"@uniformdev/assets": "19.214.1-alpha.
|
|
31
|
-
"@uniformdev/canvas": "19.214.1-alpha.
|
|
32
|
-
"@uniformdev/context": "19.214.1-alpha.
|
|
33
|
-
"@uniformdev/files": "19.214.1-alpha.
|
|
34
|
-
"@uniformdev/project-map": "19.214.1-alpha.
|
|
35
|
-
"@uniformdev/redirect": "19.214.1-alpha.
|
|
30
|
+
"@uniformdev/assets": "19.214.1-alpha.35+6fc698bf99",
|
|
31
|
+
"@uniformdev/canvas": "19.214.1-alpha.35+6fc698bf99",
|
|
32
|
+
"@uniformdev/context": "19.214.1-alpha.35+6fc698bf99",
|
|
33
|
+
"@uniformdev/files": "19.214.1-alpha.35+6fc698bf99",
|
|
34
|
+
"@uniformdev/project-map": "19.214.1-alpha.35+6fc698bf99",
|
|
35
|
+
"@uniformdev/redirect": "19.214.1-alpha.35+6fc698bf99",
|
|
36
|
+
"@uniformdev/richtext": "19.214.1-alpha.35+6fc698bf99",
|
|
36
37
|
"call-bind": "^1.0.2",
|
|
37
38
|
"colorette": "2.0.20",
|
|
38
39
|
"cosmiconfig": "9.0.0",
|
|
@@ -40,11 +41,11 @@
|
|
|
40
41
|
"diff": "^5.0.0",
|
|
41
42
|
"dotenv": "^16.0.3",
|
|
42
43
|
"execa": "5.1.1",
|
|
43
|
-
"file-type": "^
|
|
44
|
+
"file-type": "^20.0.0",
|
|
44
45
|
"fs-jetpack": "5.1.0",
|
|
45
46
|
"graphql": "16.9.0",
|
|
46
47
|
"graphql-request": "6.1.0",
|
|
47
|
-
"image-size": "^1.0
|
|
48
|
+
"image-size": "^1.2.0",
|
|
48
49
|
"inquirer": "9.2.17",
|
|
49
50
|
"isomorphic-git": "1.25.2",
|
|
50
51
|
"js-yaml": "^4.1.0",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "6fc698bf99ac7e8387e41b522af3582d0c8ab57e"
|
|
82
83
|
}
|