@uniformdev/cli 19.214.1-alpha.32 → 19.214.1-alpha.34
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 +44 -53
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -653,6 +653,13 @@ var urlToFileName = (url, hash) => {
|
|
|
653
653
|
const fileExtension = urlToFileExtension(url);
|
|
654
654
|
return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
|
|
655
655
|
};
|
|
656
|
+
var hashToPartialPathname = (hash) => {
|
|
657
|
+
try {
|
|
658
|
+
return Buffer.from(hash, "base64").toString("utf8");
|
|
659
|
+
} catch {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
};
|
|
656
663
|
|
|
657
664
|
// src/files/deleteDownloadedFileByUrl.ts
|
|
658
665
|
var deleteDownloadedFileByUrl = async (url, options) => {
|
|
@@ -677,7 +684,7 @@ import {
|
|
|
677
684
|
} from "@uniformdev/canvas";
|
|
678
685
|
import { isRichTextNodeType, isRichTextValue, walkRichTextTree } from "@uniformdev/richtext";
|
|
679
686
|
import fsj4 from "fs-jetpack";
|
|
680
|
-
import
|
|
687
|
+
import PQueue2 from "p-queue";
|
|
681
688
|
import { join as join6 } from "path";
|
|
682
689
|
|
|
683
690
|
// src/files/downloadFile.ts
|
|
@@ -831,32 +838,22 @@ var uploadFile = async ({
|
|
|
831
838
|
}) ?? null;
|
|
832
839
|
};
|
|
833
840
|
|
|
834
|
-
// src/files/
|
|
841
|
+
// src/files/walkFileUrlsForCompositionOrEntry.ts
|
|
835
842
|
import {
|
|
836
843
|
getPropertiesValue,
|
|
837
844
|
walkNodeTree,
|
|
838
845
|
walkPropertyValues
|
|
839
846
|
} from "@uniformdev/canvas";
|
|
840
|
-
import PQueue2 from "p-queue";
|
|
841
847
|
var UNIFORM_FILE_MATCH = /"(https:\/\/([^"]*?)?(img|files)\.uniform\.(rocks|global)\/([^"]*?))"/g;
|
|
842
|
-
var
|
|
848
|
+
var walkFileUrlsForCompositionOrEntry = ({
|
|
843
849
|
entity,
|
|
844
|
-
directory,
|
|
845
|
-
fileClient,
|
|
846
850
|
callback
|
|
847
851
|
}) => {
|
|
848
|
-
const urlReplacementMap = /* @__PURE__ */ new Map();
|
|
849
|
-
const fileDownloadQueue = new PQueue2({ concurrency: 3 });
|
|
850
852
|
const thumbnail = "entry" in entity ? entity.entry._thumbnail : void 0;
|
|
851
853
|
if (typeof thumbnail === "string") {
|
|
852
854
|
const isUniformFile = `"${thumbnail}"`.match(UNIFORM_FILE_MATCH) !== null;
|
|
853
855
|
if (isUniformFile) {
|
|
854
|
-
|
|
855
|
-
const result = await callback({ fileUrl: thumbnail, directory, fileClient });
|
|
856
|
-
if (result) {
|
|
857
|
-
urlReplacementMap.set(thumbnail, result.url);
|
|
858
|
-
}
|
|
859
|
-
});
|
|
856
|
+
callback({ fileUrl: thumbnail });
|
|
860
857
|
}
|
|
861
858
|
}
|
|
862
859
|
walkNodeTree("entry" in entity ? entity.entry : entity.composition, ({ node }) => {
|
|
@@ -876,17 +873,10 @@ var walkFilesForCompositionOrEntry = async ({
|
|
|
876
873
|
if (!isUniformFile) {
|
|
877
874
|
return;
|
|
878
875
|
}
|
|
879
|
-
|
|
880
|
-
const result = await callback({ fileUrl: value, directory, fileClient });
|
|
881
|
-
if (result) {
|
|
882
|
-
urlReplacementMap.set(value, result.url);
|
|
883
|
-
}
|
|
884
|
-
});
|
|
876
|
+
callback({ fileUrl: value });
|
|
885
877
|
});
|
|
886
878
|
});
|
|
887
879
|
});
|
|
888
|
-
await fileDownloadQueue.onIdle();
|
|
889
|
-
return urlReplacementMap;
|
|
890
880
|
};
|
|
891
881
|
|
|
892
882
|
// src/files/files.ts
|
|
@@ -981,26 +971,42 @@ var downloadFilesForCompositionOrEntry = async ({
|
|
|
981
971
|
directory,
|
|
982
972
|
fileClient
|
|
983
973
|
}) => {
|
|
984
|
-
|
|
974
|
+
const fileDownloadQueue = new PQueue2({ concurrency: 3 });
|
|
975
|
+
await walkFileUrlsForCompositionOrEntry({
|
|
985
976
|
entity,
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
977
|
+
callback: ({ fileUrl }) => {
|
|
978
|
+
fileDownloadQueue.add(async () => {
|
|
979
|
+
await downloadFile({ fileUrl, directory, fileClient });
|
|
980
|
+
});
|
|
981
|
+
}
|
|
989
982
|
});
|
|
983
|
+
await fileDownloadQueue.onIdle();
|
|
990
984
|
};
|
|
991
985
|
var uploadFilesForCompositionOrEntry = async ({
|
|
992
986
|
entity,
|
|
993
987
|
directory,
|
|
994
988
|
fileClient
|
|
995
989
|
}) => {
|
|
996
|
-
const
|
|
990
|
+
const fileUploadQueue2 = new PQueue2({ concurrency: 3 });
|
|
991
|
+
const urlReplacementMap = /* @__PURE__ */ new Map();
|
|
992
|
+
walkFileUrlsForCompositionOrEntry({
|
|
997
993
|
entity: entity.object,
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
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);
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1001
1006
|
});
|
|
1007
|
+
await fileUploadQueue2.onIdle();
|
|
1002
1008
|
let entityAsString = JSON.stringify(entity);
|
|
1003
|
-
for (const [key, value] of
|
|
1009
|
+
for (const [key, value] of urlReplacementMap.entries()) {
|
|
1004
1010
|
entityAsString = entityAsString.replaceAll(`"${key}"`, `"${value}"`);
|
|
1005
1011
|
}
|
|
1006
1012
|
return JSON.parse(entityAsString);
|
|
@@ -1014,12 +1020,10 @@ var replaceRemoteUrlsWithLocalReferences = async ({
|
|
|
1014
1020
|
let sourceEntityAsString = JSON.stringify(sourceEntity);
|
|
1015
1021
|
const targetEntityAsString = JSON.stringify(targetEntity);
|
|
1016
1022
|
const writeDirectory = getFilesDirectory(directory);
|
|
1017
|
-
const fileUrlReplacementQueue = new
|
|
1018
|
-
|
|
1023
|
+
const fileUrlReplacementQueue = new PQueue2({ concurrency: 3 });
|
|
1024
|
+
walkFileUrlsForCompositionOrEntry({
|
|
1019
1025
|
entity: sourceEntity.object,
|
|
1020
|
-
|
|
1021
|
-
fileClient,
|
|
1022
|
-
callback: async ({ fileUrl }) => {
|
|
1026
|
+
callback: ({ fileUrl }) => {
|
|
1023
1027
|
fileUrlReplacementQueue.add(async () => {
|
|
1024
1028
|
try {
|
|
1025
1029
|
const localFileName = urlToFileName(fileUrl);
|
|
@@ -1053,16 +1057,13 @@ var replaceRemoteUrlsWithLocalReferences = async ({
|
|
|
1053
1057
|
};
|
|
1054
1058
|
var replaceLocalUrlsWithRemoteReferences = async ({
|
|
1055
1059
|
entity,
|
|
1056
|
-
directory,
|
|
1057
1060
|
fileClient
|
|
1058
1061
|
}) => {
|
|
1059
1062
|
let entityAsString = JSON.stringify(entity);
|
|
1060
|
-
const fileUrlReplacementQueue = new
|
|
1061
|
-
|
|
1063
|
+
const fileUrlReplacementQueue = new PQueue2({ concurrency: 3 });
|
|
1064
|
+
walkFileUrlsForCompositionOrEntry({
|
|
1062
1065
|
entity: entity.object,
|
|
1063
|
-
|
|
1064
|
-
fileClient,
|
|
1065
|
-
callback: async ({ fileUrl }) => {
|
|
1066
|
+
callback: ({ fileUrl }) => {
|
|
1066
1067
|
fileUrlReplacementQueue.add(async () => {
|
|
1067
1068
|
try {
|
|
1068
1069
|
const hash = urlToHash(fileUrl);
|
|
@@ -1088,13 +1089,6 @@ var replaceLocalUrlsWithRemoteReferences = async ({
|
|
|
1088
1089
|
var escapeRegExp = (string) => {
|
|
1089
1090
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1090
1091
|
};
|
|
1091
|
-
var hashToPartialPathname = (hash) => {
|
|
1092
|
-
try {
|
|
1093
|
-
return Buffer.from(hash, "base64").toString("utf8");
|
|
1094
|
-
} catch {
|
|
1095
|
-
return null;
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
1092
|
var findUrlMatchingPartialPathname = (source, pathname) => {
|
|
1099
1093
|
const escapedPathname = escapeRegExp(pathname);
|
|
1100
1094
|
const regex = new RegExp(
|
|
@@ -2843,7 +2837,6 @@ var CompositionPushModule = {
|
|
|
2843
2837
|
onBeforeCompareObjects: async (sourceObject) => {
|
|
2844
2838
|
return replaceLocalUrlsWithRemoteReferences({
|
|
2845
2839
|
entity: sourceObject,
|
|
2846
|
-
directory,
|
|
2847
2840
|
fileClient
|
|
2848
2841
|
});
|
|
2849
2842
|
},
|
|
@@ -4540,7 +4533,6 @@ var EntryPushModule = {
|
|
|
4540
4533
|
onBeforeCompareObjects: async (sourceObject) => {
|
|
4541
4534
|
return replaceLocalUrlsWithRemoteReferences({
|
|
4542
4535
|
entity: sourceObject,
|
|
4543
|
-
directory,
|
|
4544
4536
|
fileClient
|
|
4545
4537
|
});
|
|
4546
4538
|
},
|
|
@@ -5024,7 +5016,6 @@ var EntryPatternPushModule = {
|
|
|
5024
5016
|
onBeforeCompareObjects: async (sourceObject) => {
|
|
5025
5017
|
return replaceLocalUrlsWithRemoteReferences({
|
|
5026
5018
|
entity: sourceObject,
|
|
5027
|
-
directory,
|
|
5028
5019
|
fileClient
|
|
5029
5020
|
});
|
|
5030
5021
|
},
|
|
@@ -8387,7 +8378,7 @@ import { PostHog } from "posthog-node";
|
|
|
8387
8378
|
// package.json
|
|
8388
8379
|
var package_default = {
|
|
8389
8380
|
name: "@uniformdev/cli",
|
|
8390
|
-
version: "
|
|
8381
|
+
version: "20.0.0",
|
|
8391
8382
|
description: "Uniform command line interface tool",
|
|
8392
8383
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
8393
8384
|
main: "./cli.js",
|
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.34+476b7be79b",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -27,13 +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.
|
|
36
|
-
"@uniformdev/richtext": "19.214.1-alpha.
|
|
30
|
+
"@uniformdev/assets": "19.214.1-alpha.34+476b7be79b",
|
|
31
|
+
"@uniformdev/canvas": "19.214.1-alpha.34+476b7be79b",
|
|
32
|
+
"@uniformdev/context": "19.214.1-alpha.34+476b7be79b",
|
|
33
|
+
"@uniformdev/files": "19.214.1-alpha.34+476b7be79b",
|
|
34
|
+
"@uniformdev/project-map": "19.214.1-alpha.34+476b7be79b",
|
|
35
|
+
"@uniformdev/redirect": "19.214.1-alpha.34+476b7be79b",
|
|
36
|
+
"@uniformdev/richtext": "19.214.1-alpha.34+476b7be79b",
|
|
37
37
|
"call-bind": "^1.0.2",
|
|
38
38
|
"colorette": "2.0.20",
|
|
39
39
|
"cosmiconfig": "9.0.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "476b7be79b950e65641ffb8698a13bc5d9b966f8"
|
|
83
83
|
}
|