@uniformdev/cli 20.66.1-alpha.1 → 20.66.1-alpha.63

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.
@@ -22,7 +22,7 @@ import { fetch as undiciFetch, ProxyAgent } from "undici";
22
22
  // package.json
23
23
  var package_default = {
24
24
  name: "@uniformdev/cli",
25
- version: "20.66.0",
25
+ version: "20.66.4",
26
26
  description: "Uniform command line interface tool",
27
27
  license: "SEE LICENSE IN LICENSE.txt",
28
28
  main: "./cli.js",
@@ -68,7 +68,7 @@ var package_default = {
68
68
  "fs-jetpack": "5.1.0",
69
69
  graphql: "16.9.0",
70
70
  "graphql-request": "6.1.0",
71
- "image-size": "^1.2.1",
71
+ "image-size": "2.0.2",
72
72
  "isomorphic-git": "1.35.0",
73
73
  "js-yaml": "^4.1.0",
74
74
  jsonwebtoken: "9.0.3",
@@ -1,4 +1,4 @@
1
- import "./chunk-KIFJLCAG.mjs";
1
+ import "./chunk-35FOLS5B.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  withFormatOptions,
19
19
  withProjectOptions,
20
20
  withTeamOptions
21
- } from "./chunk-KIFJLCAG.mjs";
21
+ } from "./chunk-35FOLS5B.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 { fileTypeFromBuffer } from "file-type";
2246
+ import { fileTypeFromFile } from "file-type";
2247
+ import { createReadStream } from "fs";
2247
2248
  import fsj3 from "fs-jetpack";
2248
- import sizeOf from "image-size";
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 fileExistsLocally = await fsj3.existsAsync(expectedFilePath);
2280
- if (!fileExistsLocally) {
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 fileTypeFromBuffer(fileBuffer))?.mime;
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
- fileBuffer = normalizeNewline(fileBuffer);
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 sizeOf(fileBuffer);
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: fileBuffer.length,
2332
+ size: uploadSize,
2326
2333
  width,
2327
2334
  height,
2328
2335
  sourceId: hash
2329
2336
  });
2330
- const uploadResponse = await fetch(uploadUrl, {
2337
+ const uploadRequest = {
2331
2338
  method,
2332
- body: fileBuffer,
2339
+ body: uploadBody,
2340
+ duplex: "half",
2333
2341
  headers: {
2334
2342
  "Content-Type": mimeType,
2335
- "Content-Length": fileBuffer.length.toString()
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,23 +2633,17 @@ 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 }) => {
2631
2639
  fileUrlReplacementQueue.add(async () => {
2632
2640
  try {
2633
2641
  const hash = urlToHash(fileUrl);
2634
- fileUrlReplacementQueue.add(async () => {
2635
- try {
2636
- const file = await fileClient.get({ sourceId: hash }).catch(() => null);
2637
- if (!file) {
2638
- return;
2639
- }
2640
- entityAsString = entityAsString.replaceAll(`"${fileUrl}"`, `"${file.url}"`);
2641
- } catch {
2642
- }
2643
- });
2642
+ const file = await fileClient.get({ sourceId: hash }).catch(() => null);
2643
+ if (!file) {
2644
+ return;
2645
+ }
2646
+ entityAsString = entityAsString.replaceAll(`"${fileUrl}"`, `"${file.url}"`);
2644
2647
  } catch {
2645
2648
  }
2646
2649
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.66.1-alpha.1+5120c82a21",
3
+ "version": "20.66.1-alpha.63+0184a5ef58",
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.1-alpha.1+5120c82a21",
31
- "@uniformdev/canvas": "20.66.1-alpha.1+5120c82a21",
32
- "@uniformdev/context": "20.66.1-alpha.1+5120c82a21",
33
- "@uniformdev/files": "20.66.1-alpha.1+5120c82a21",
34
- "@uniformdev/project-map": "20.66.1-alpha.1+5120c82a21",
35
- "@uniformdev/redirect": "20.66.1-alpha.1+5120c82a21",
36
- "@uniformdev/richtext": "20.66.1-alpha.1+5120c82a21",
30
+ "@uniformdev/assets": "20.66.1-alpha.63+0184a5ef58",
31
+ "@uniformdev/canvas": "20.66.1-alpha.63+0184a5ef58",
32
+ "@uniformdev/context": "20.66.1-alpha.63+0184a5ef58",
33
+ "@uniformdev/files": "20.66.1-alpha.63+0184a5ef58",
34
+ "@uniformdev/project-map": "20.66.1-alpha.63+0184a5ef58",
35
+ "@uniformdev/redirect": "20.66.1-alpha.63+0184a5ef58",
36
+ "@uniformdev/richtext": "20.66.1-alpha.63+0184a5ef58",
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": "^1.2.1",
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": "5120c82a21b28394d5da650ddb24afdbf93e947b"
83
+ "gitHead": "0184a5ef58e0a3c8a9c48f98e5a3cc6205da7815"
84
84
  }