@uniformdev/cli 20.80.2-alpha.17.sha-6b1014c36e → 20.80.2-alpha.22.sha-545d46ba66
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 +32 -17
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -2814,18 +2814,20 @@ var downloadFile = async ({
|
|
|
2814
2814
|
fileClient,
|
|
2815
2815
|
fileUrl,
|
|
2816
2816
|
fileId,
|
|
2817
|
-
directory
|
|
2817
|
+
directory,
|
|
2818
|
+
expectedSize
|
|
2818
2819
|
}) => {
|
|
2819
2820
|
const writeDirectory = getFilesDirectory(directory);
|
|
2820
2821
|
const filesDirectory = join10(writeDirectory, FILES_DIRECTORY_NAME);
|
|
2821
2822
|
const fileName = urlToFileName(fileUrl.toString());
|
|
2822
2823
|
const filePath = join10(filesDirectory, fileName);
|
|
2823
2824
|
const fileAlreadyExists = await fsj2.existsAsync(filePath);
|
|
2824
|
-
|
|
2825
|
+
const localCopyIsStale = fileAlreadyExists && expectedSize !== void 0 && (await fsj2.inspectAsync(filePath))?.size !== expectedSize;
|
|
2826
|
+
if (fileAlreadyExists && !localCopyIsStale) {
|
|
2825
2827
|
return { id: fileId, url: fileUrl };
|
|
2826
2828
|
}
|
|
2827
2829
|
const file = await getFileMetadata({ fileClient, fileId, fileUrl });
|
|
2828
|
-
if (file?.sourceId) {
|
|
2830
|
+
if (!localCopyIsStale && file?.sourceId) {
|
|
2829
2831
|
const sourceId = file.sourceId;
|
|
2830
2832
|
try {
|
|
2831
2833
|
const downloadedFilePaths = await getDownloadedFilePathCache(filesDirectory);
|
|
@@ -2870,7 +2872,7 @@ var downloadFile = async ({
|
|
|
2870
2872
|
|
|
2871
2873
|
// src/files/uploadFile.ts
|
|
2872
2874
|
import { preferredType } from "@thi.ng/mime";
|
|
2873
|
-
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
|
|
2875
|
+
import { FILE_MIME_TYPES_ALL, FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
|
|
2874
2876
|
import { fileTypeFromFile } from "file-type";
|
|
2875
2877
|
import { createReadStream } from "fs";
|
|
2876
2878
|
import fsj3 from "fs-jetpack";
|
|
@@ -2885,6 +2887,7 @@ var uploadFile = async ({
|
|
|
2885
2887
|
fileUrl,
|
|
2886
2888
|
directory,
|
|
2887
2889
|
fileId,
|
|
2890
|
+
declaredMediaType,
|
|
2888
2891
|
warnIfLocalCopyMissing = true
|
|
2889
2892
|
}) => {
|
|
2890
2893
|
const key = `${fileId}-${fileUrl}`;
|
|
@@ -2893,6 +2896,7 @@ var uploadFile = async ({
|
|
|
2893
2896
|
return result2 ?? null;
|
|
2894
2897
|
}
|
|
2895
2898
|
const promise = fileUploadQueue.add(async () => {
|
|
2899
|
+
let uploadBody;
|
|
2896
2900
|
try {
|
|
2897
2901
|
const writeDirectory = getFilesDirectory(directory);
|
|
2898
2902
|
const hash = urlToHash(fileUrl);
|
|
@@ -2916,7 +2920,15 @@ var uploadFile = async ({
|
|
|
2916
2920
|
return null;
|
|
2917
2921
|
}
|
|
2918
2922
|
const fileName = getFileNameFromUrl(fileUrl);
|
|
2919
|
-
let mimeType =
|
|
2923
|
+
let mimeType = declaredMediaType && FILE_MIME_TYPES_ALL.includes(declaredMediaType) ? declaredMediaType : void 0;
|
|
2924
|
+
if (declaredMediaType && !mimeType) {
|
|
2925
|
+
console.warn(
|
|
2926
|
+
`Asset declares unsupported media type "${declaredMediaType}" for ${fileUrl}, detecting instead`
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2929
|
+
if (!mimeType) {
|
|
2930
|
+
mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await fileTypeFromFile(expectedFilePath))?.mime;
|
|
2931
|
+
}
|
|
2920
2932
|
if (!mimeType) {
|
|
2921
2933
|
mimeType = preferredType(fileUrl.split(".").at(-1) ?? "");
|
|
2922
2934
|
}
|
|
@@ -2926,7 +2938,6 @@ var uploadFile = async ({
|
|
|
2926
2938
|
if (mimeType === "audio/x-flac") {
|
|
2927
2939
|
mimeType = "audio/flac";
|
|
2928
2940
|
}
|
|
2929
|
-
let uploadBody;
|
|
2930
2941
|
let uploadSize = fileInspect.size;
|
|
2931
2942
|
if (mimeType === "image/svg+xml") {
|
|
2932
2943
|
const fileBuffer = await fsj3.readAsync(expectedFilePath, "buffer");
|
|
@@ -2942,6 +2953,7 @@ var uploadFile = async ({
|
|
|
2942
2953
|
uploadSize = uploadBody.length;
|
|
2943
2954
|
} else {
|
|
2944
2955
|
uploadBody = createReadStream(expectedFilePath);
|
|
2956
|
+
uploadBody.on("error", () => void 0);
|
|
2945
2957
|
}
|
|
2946
2958
|
const { width, height } = await (async () => {
|
|
2947
2959
|
if (!mimeType.startsWith("image/")) {
|
|
@@ -3002,6 +3014,9 @@ var uploadFile = async ({
|
|
|
3002
3014
|
return { id, url: uploadedFileUrl };
|
|
3003
3015
|
} catch (e) {
|
|
3004
3016
|
console.warn(`Failed to upload file ${fileUrl}`, e);
|
|
3017
|
+
if (uploadBody && "destroy" in uploadBody) {
|
|
3018
|
+
uploadBody.destroy();
|
|
3019
|
+
}
|
|
3005
3020
|
return null;
|
|
3006
3021
|
}
|
|
3007
3022
|
});
|
|
@@ -3085,7 +3100,7 @@ var downloadFileForAsset = async ({
|
|
|
3085
3100
|
if (!fileUrl) {
|
|
3086
3101
|
return null;
|
|
3087
3102
|
}
|
|
3088
|
-
return downloadFile({ fileUrl, fileId, directory, fileClient });
|
|
3103
|
+
return downloadFile({ fileUrl, fileId, directory, fileClient, expectedSize: fields.size?.value });
|
|
3089
3104
|
};
|
|
3090
3105
|
var uploadFileForAsset = async ({
|
|
3091
3106
|
asset,
|
|
@@ -3102,6 +3117,7 @@ var uploadFileForAsset = async ({
|
|
|
3102
3117
|
directory,
|
|
3103
3118
|
fileClient,
|
|
3104
3119
|
fileId,
|
|
3120
|
+
declaredMediaType: asset.asset.fields?.mediaType?.value,
|
|
3105
3121
|
warnIfLocalCopyMissing: false
|
|
3106
3122
|
});
|
|
3107
3123
|
};
|
|
@@ -3179,7 +3195,11 @@ var selectComparableAsset = ({ asset }) => ({
|
|
|
3179
3195
|
_name: asset._name,
|
|
3180
3196
|
_dataResources: asset._dataResources,
|
|
3181
3197
|
labels: asset.labels,
|
|
3182
|
-
fields:
|
|
3198
|
+
fields: {
|
|
3199
|
+
...selectWritableAssetFields(asset.fields),
|
|
3200
|
+
mediaType: asset.fields?.mediaType,
|
|
3201
|
+
size: asset.fields?.size
|
|
3202
|
+
}
|
|
3183
3203
|
});
|
|
3184
3204
|
var compareAssetsWithoutUrls = (source, target) => {
|
|
3185
3205
|
return serializedDequal(selectComparableAsset(source.object), selectComparableAsset(target.object));
|
|
@@ -9508,6 +9528,7 @@ var PromptPushModule = {
|
|
|
9508
9528
|
proxy,
|
|
9509
9529
|
directory,
|
|
9510
9530
|
mode,
|
|
9531
|
+
whatIf,
|
|
9511
9532
|
project: projectId,
|
|
9512
9533
|
diff: diffMode,
|
|
9513
9534
|
allowEmptySource,
|
|
@@ -9543,6 +9564,7 @@ var PromptPushModule = {
|
|
|
9543
9564
|
source,
|
|
9544
9565
|
target,
|
|
9545
9566
|
mode,
|
|
9567
|
+
whatIf,
|
|
9546
9568
|
allowEmptySource,
|
|
9547
9569
|
log: createSyncEngineConsoleLogger({ diffMode })
|
|
9548
9570
|
});
|
|
@@ -13415,12 +13437,9 @@ var selectFilename2 = (source) => {
|
|
|
13415
13437
|
return cleanFileName(source.sourceUrl.substring(index + 1)) + `_${source.id}`;
|
|
13416
13438
|
};
|
|
13417
13439
|
var selectDisplayName17 = (source) => {
|
|
13418
|
-
if (typeof source.sourceUrl !== "string") {
|
|
13419
|
-
return `${source.id ?? "redirect"} (id: ${source.id})`;
|
|
13420
|
-
}
|
|
13421
13440
|
let pathName = source.sourceUrl;
|
|
13422
13441
|
if (pathName.length > 30) {
|
|
13423
|
-
const slashIndex =
|
|
13442
|
+
const slashIndex = source.sourceUrl.indexOf("/", source.sourceUrl.length - 30);
|
|
13424
13443
|
pathName = "..." + pathName.substring(slashIndex);
|
|
13425
13444
|
}
|
|
13426
13445
|
return `${pathName} (id: ${source.id})`;
|
|
@@ -13690,11 +13709,7 @@ var RedirectDefinitionUpdateModule = {
|
|
|
13690
13709
|
const fetch2 = nodeFetchProxy(proxy);
|
|
13691
13710
|
const client = getRedirectClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
13692
13711
|
const file = readFileToObject(filename);
|
|
13693
|
-
|
|
13694
|
-
console.error(`${filename} does not contain a YAML or JSON object`);
|
|
13695
|
-
process.exit(1);
|
|
13696
|
-
}
|
|
13697
|
-
await client.upsertRedirect("redirect" in file ? file.redirect : file);
|
|
13712
|
+
await client.upsertRedirect(file);
|
|
13698
13713
|
}
|
|
13699
13714
|
};
|
|
13700
13715
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.80.2-alpha.
|
|
3
|
+
"version": "20.80.2-alpha.22.sha-545d46ba66",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@inquirer/prompts": "^8.5.2",
|
|
29
29
|
"@thi.ng/mime": "^2.2.23",
|
|
30
|
-
"@uniformdev/assets": "20.80.2-alpha.
|
|
31
|
-
"@uniformdev/automations-sdk": "20.80.2-alpha.
|
|
32
|
-
"@uniformdev/canvas": "20.80.2-alpha.
|
|
33
|
-
"@uniformdev/context": "20.80.2-alpha.
|
|
34
|
-
"@uniformdev/files": "20.80.2-alpha.
|
|
35
|
-
"@uniformdev/project-map": "20.80.2-alpha.
|
|
36
|
-
"@uniformdev/redirect": "20.80.2-alpha.
|
|
37
|
-
"@uniformdev/richtext": "20.80.2-alpha.
|
|
30
|
+
"@uniformdev/assets": "20.80.2-alpha.22.sha-545d46ba66",
|
|
31
|
+
"@uniformdev/automations-sdk": "20.80.2-alpha.22.sha-545d46ba66",
|
|
32
|
+
"@uniformdev/canvas": "20.80.2-alpha.22.sha-545d46ba66",
|
|
33
|
+
"@uniformdev/context": "20.80.2-alpha.22.sha-545d46ba66",
|
|
34
|
+
"@uniformdev/files": "20.80.2-alpha.22.sha-545d46ba66",
|
|
35
|
+
"@uniformdev/project-map": "20.80.2-alpha.22.sha-545d46ba66",
|
|
36
|
+
"@uniformdev/redirect": "20.80.2-alpha.22.sha-545d46ba66",
|
|
37
|
+
"@uniformdev/richtext": "20.80.2-alpha.22.sha-545d46ba66",
|
|
38
38
|
"call-bind": "^1.0.2",
|
|
39
39
|
"colorette": "2.0.20",
|
|
40
40
|
"cosmiconfig": "9.0.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "545d46ba66a16e24a82d3f832ebf5ea342b79d56"
|
|
82
82
|
}
|