@uniformdev/cli 20.66.2 → 20.66.3-alpha.6
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/defaultConfig.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
withFormatOptions,
|
|
19
19
|
withProjectOptions,
|
|
20
20
|
withTeamOptions
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XOZ6UMXP.mjs";
|
|
22
22
|
|
|
23
23
|
// src/index.ts
|
|
24
24
|
import * as dotenv from "dotenv";
|
|
@@ -2243,9 +2243,10 @@ var downloadFile = async ({
|
|
|
2243
2243
|
// src/files/uploadFile.ts
|
|
2244
2244
|
import { preferredType } from "@thi.ng/mime";
|
|
2245
2245
|
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
|
|
2246
|
-
import {
|
|
2246
|
+
import { fileTypeFromFile } from "file-type";
|
|
2247
|
+
import { createReadStream } from "fs";
|
|
2247
2248
|
import fsj3 from "fs-jetpack";
|
|
2248
|
-
import
|
|
2249
|
+
import { imageSizeFromFile } from "image-size/fromFile";
|
|
2249
2250
|
import normalizeNewline from "normalize-newline";
|
|
2250
2251
|
import PQueue from "p-queue";
|
|
2251
2252
|
import { join as join9 } from "path";
|
|
@@ -2276,33 +2277,39 @@ var uploadFile = async ({
|
|
|
2276
2277
|
}
|
|
2277
2278
|
const localFileName = urlToFileName(fileUrl);
|
|
2278
2279
|
const expectedFilePath = join9(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2280
|
+
const fileInspect = await fsj3.inspectAsync(expectedFilePath);
|
|
2281
|
+
if (fileInspect?.type !== "file") {
|
|
2281
2282
|
console.warn(
|
|
2282
2283
|
`Skipping file ${fileUrl} as we couldn't find a local copy (looked at ${expectedFilePath})`
|
|
2283
2284
|
);
|
|
2284
2285
|
return null;
|
|
2285
2286
|
}
|
|
2286
|
-
let fileBuffer = await fsj3.readAsync(expectedFilePath, "buffer");
|
|
2287
|
-
if (!fileBuffer) {
|
|
2288
|
-
console.warn(`Skipping file ${fileUrl} (${expectedFilePath}) as we couldn't read it`);
|
|
2289
|
-
return null;
|
|
2290
|
-
}
|
|
2291
2287
|
const fileName = getFileNameFromUrl(fileUrl);
|
|
2292
|
-
let mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await
|
|
2288
|
+
let mimeType = expectedFilePath.endsWith(".svg") ? "image/svg+xml" : (await fileTypeFromFile(expectedFilePath))?.mime;
|
|
2293
2289
|
if (!mimeType) {
|
|
2294
2290
|
mimeType = preferredType(fileUrl.split(".").at(-1) ?? "");
|
|
2295
2291
|
}
|
|
2296
2292
|
if (mimeType === "audio/x-flac") {
|
|
2297
2293
|
mimeType = "audio/flac";
|
|
2298
2294
|
}
|
|
2295
|
+
let uploadBody;
|
|
2296
|
+
let uploadSize = fileInspect.size;
|
|
2299
2297
|
if (mimeType === "image/svg+xml") {
|
|
2298
|
+
const fileBuffer = await fsj3.readAsync(expectedFilePath, "buffer");
|
|
2299
|
+
if (!fileBuffer) {
|
|
2300
|
+
console.warn(`Skipping file ${fileUrl} (${expectedFilePath}) as we couldn't read it`);
|
|
2301
|
+
return null;
|
|
2302
|
+
}
|
|
2303
|
+
uploadBody = fileBuffer;
|
|
2300
2304
|
try {
|
|
2301
|
-
|
|
2305
|
+
uploadBody = normalizeNewline(fileBuffer);
|
|
2302
2306
|
} catch {
|
|
2303
2307
|
}
|
|
2308
|
+
uploadSize = uploadBody.length;
|
|
2309
|
+
} else {
|
|
2310
|
+
uploadBody = createReadStream(expectedFilePath);
|
|
2304
2311
|
}
|
|
2305
|
-
const { width, height } = (() => {
|
|
2312
|
+
const { width, height } = await (async () => {
|
|
2306
2313
|
if (!mimeType.startsWith("image/")) {
|
|
2307
2314
|
return {
|
|
2308
2315
|
width: void 0,
|
|
@@ -2310,7 +2317,7 @@ var uploadFile = async ({
|
|
|
2310
2317
|
};
|
|
2311
2318
|
}
|
|
2312
2319
|
try {
|
|
2313
|
-
return
|
|
2320
|
+
return await imageSizeFromFile(expectedFilePath);
|
|
2314
2321
|
} catch {
|
|
2315
2322
|
return {
|
|
2316
2323
|
width: void 0,
|
|
@@ -2322,19 +2329,21 @@ var uploadFile = async ({
|
|
|
2322
2329
|
id: fileId,
|
|
2323
2330
|
name: fileName,
|
|
2324
2331
|
mediaType: mimeType,
|
|
2325
|
-
size:
|
|
2332
|
+
size: uploadSize,
|
|
2326
2333
|
width,
|
|
2327
2334
|
height,
|
|
2328
2335
|
sourceId: hash
|
|
2329
2336
|
});
|
|
2330
|
-
const
|
|
2337
|
+
const uploadRequest = {
|
|
2331
2338
|
method,
|
|
2332
|
-
body:
|
|
2339
|
+
body: uploadBody,
|
|
2340
|
+
duplex: "half",
|
|
2333
2341
|
headers: {
|
|
2334
2342
|
"Content-Type": mimeType,
|
|
2335
|
-
"Content-Length":
|
|
2343
|
+
"Content-Length": uploadSize.toString()
|
|
2336
2344
|
}
|
|
2337
|
-
}
|
|
2345
|
+
};
|
|
2346
|
+
const uploadResponse = await fetch(uploadUrl, uploadRequest);
|
|
2338
2347
|
if (!uploadResponse.ok) {
|
|
2339
2348
|
console.warn(`Failed to upload file ${fileUrl} (${expectedFilePath})`);
|
|
2340
2349
|
return null;
|
|
@@ -2422,6 +2431,9 @@ var walkFileUrlsForCompositionOrEntry = ({
|
|
|
2422
2431
|
};
|
|
2423
2432
|
|
|
2424
2433
|
// src/files/files.ts
|
|
2434
|
+
var fileDownloadQueue = new PQueue2({ concurrency: 10 });
|
|
2435
|
+
var fileUploadQueue2 = new PQueue2({ concurrency: 10 });
|
|
2436
|
+
var fileUrlReplacementQueue = new PQueue2({ concurrency: 10 });
|
|
2425
2437
|
var downloadFileForAsset = async ({
|
|
2426
2438
|
asset,
|
|
2427
2439
|
directory,
|
|
@@ -2535,7 +2547,6 @@ var downloadFilesForCompositionOrEntry = async ({
|
|
|
2535
2547
|
directory,
|
|
2536
2548
|
fileClient
|
|
2537
2549
|
}) => {
|
|
2538
|
-
const fileDownloadQueue = new PQueue2({ concurrency: 10 });
|
|
2539
2550
|
await walkFileUrlsForCompositionOrEntry({
|
|
2540
2551
|
entity,
|
|
2541
2552
|
callback: ({ fileUrl }) => {
|
|
@@ -2551,7 +2562,6 @@ var uploadFilesForCompositionOrEntry = async ({
|
|
|
2551
2562
|
directory,
|
|
2552
2563
|
fileClient
|
|
2553
2564
|
}) => {
|
|
2554
|
-
const fileUploadQueue2 = new PQueue2({ concurrency: 10 });
|
|
2555
2565
|
const urlReplacementMap = /* @__PURE__ */ new Map();
|
|
2556
2566
|
walkFileUrlsForCompositionOrEntry({
|
|
2557
2567
|
entity: entity.object,
|
|
@@ -2584,7 +2594,6 @@ var replaceRemoteUrlsWithLocalReferences = async ({
|
|
|
2584
2594
|
let sourceEntityAsString = JSON.stringify(sourceEntity);
|
|
2585
2595
|
const targetEntityAsString = JSON.stringify(targetEntity);
|
|
2586
2596
|
const writeDirectory = getFilesDirectory(directory);
|
|
2587
|
-
const fileUrlReplacementQueue = new PQueue2({ concurrency: 10 });
|
|
2588
2597
|
walkFileUrlsForCompositionOrEntry({
|
|
2589
2598
|
entity: sourceEntity.object,
|
|
2590
2599
|
callback: ({ fileUrl }) => {
|
|
@@ -2624,7 +2633,6 @@ var replaceLocalUrlsWithRemoteReferences = async ({
|
|
|
2624
2633
|
fileClient
|
|
2625
2634
|
}) => {
|
|
2626
2635
|
let entityAsString = JSON.stringify(entity);
|
|
2627
|
-
const fileUrlReplacementQueue = new PQueue2({ concurrency: 10 });
|
|
2628
2636
|
walkFileUrlsForCompositionOrEntry({
|
|
2629
2637
|
entity: entity.object,
|
|
2630
2638
|
callback: ({ fileUrl }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.66.
|
|
3
|
+
"version": "20.66.3-alpha.6+99aaadfddb",
|
|
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
|
"dependencies": {
|
|
28
28
|
"@inquirer/prompts": "^7.10.1",
|
|
29
29
|
"@thi.ng/mime": "^2.2.23",
|
|
30
|
-
"@uniformdev/assets": "20.66.
|
|
31
|
-
"@uniformdev/canvas": "20.66.
|
|
32
|
-
"@uniformdev/context": "20.66.
|
|
33
|
-
"@uniformdev/files": "20.66.
|
|
34
|
-
"@uniformdev/project-map": "20.66.
|
|
35
|
-
"@uniformdev/redirect": "20.66.
|
|
36
|
-
"@uniformdev/richtext": "20.66.
|
|
30
|
+
"@uniformdev/assets": "20.66.3-alpha.6+99aaadfddb",
|
|
31
|
+
"@uniformdev/canvas": "20.66.3-alpha.6+99aaadfddb",
|
|
32
|
+
"@uniformdev/context": "20.66.3-alpha.6+99aaadfddb",
|
|
33
|
+
"@uniformdev/files": "20.66.3-alpha.6+99aaadfddb",
|
|
34
|
+
"@uniformdev/project-map": "20.66.3-alpha.6+99aaadfddb",
|
|
35
|
+
"@uniformdev/redirect": "20.66.3-alpha.6+99aaadfddb",
|
|
36
|
+
"@uniformdev/richtext": "20.66.3-alpha.6+99aaadfddb",
|
|
37
37
|
"call-bind": "^1.0.2",
|
|
38
38
|
"colorette": "2.0.20",
|
|
39
39
|
"cosmiconfig": "9.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"fs-jetpack": "5.1.0",
|
|
47
47
|
"graphql": "16.9.0",
|
|
48
48
|
"graphql-request": "6.1.0",
|
|
49
|
-
"image-size": "^
|
|
49
|
+
"image-size": "^2.0.2",
|
|
50
50
|
"isomorphic-git": "1.35.0",
|
|
51
51
|
"js-yaml": "^4.1.0",
|
|
52
52
|
"jsonwebtoken": "9.0.3",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "99aaadfddbad0e7712ea51517666069915883931"
|
|
84
84
|
}
|