@uniformdev/cli 20.61.2-alpha.3 → 20.62.1-alpha.4
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.
|
|
25
|
+
version: "20.62.0",
|
|
26
26
|
description: "Uniform command line interface tool",
|
|
27
27
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
28
28
|
main: "./cli.js",
|
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-RKOT64CV.mjs";
|
|
22
22
|
|
|
23
23
|
// src/index.ts
|
|
24
24
|
import * as dotenv from "dotenv";
|
|
@@ -721,6 +721,7 @@ function writeUniformPackage(filename, packageContents) {
|
|
|
721
721
|
// src/sync/syncEngine.ts
|
|
722
722
|
import { diffJson, diffLines } from "diff";
|
|
723
723
|
import mitt from "mitt";
|
|
724
|
+
import PQueue from "p-queue";
|
|
724
725
|
|
|
725
726
|
// src/sync/serializedDequal.ts
|
|
726
727
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -774,6 +775,7 @@ function serializedDequal(foo, bar) {
|
|
|
774
775
|
}
|
|
775
776
|
|
|
776
777
|
// src/sync/syncEngine.ts
|
|
778
|
+
var DEFAULT_SYNC_ACTION_CONCURRENCY = 10;
|
|
777
779
|
var syncEngineEvents = mitt();
|
|
778
780
|
async function syncEngine({
|
|
779
781
|
source,
|
|
@@ -787,7 +789,8 @@ async function syncEngine({
|
|
|
787
789
|
onBeforeProcessObject,
|
|
788
790
|
onBeforeCompareObjects,
|
|
789
791
|
onBeforeWriteObject,
|
|
790
|
-
onError
|
|
792
|
+
onError,
|
|
793
|
+
actionConcurrency = DEFAULT_SYNC_ACTION_CONCURRENCY
|
|
791
794
|
//verbose = false,
|
|
792
795
|
}) {
|
|
793
796
|
const status = new ReactiveStatusUpdate((status2) => syncEngineEvents.emit("statusUpdate", status2));
|
|
@@ -906,7 +909,7 @@ async function syncEngine({
|
|
|
906
909
|
deletes.push(() => processDelete(targetObject));
|
|
907
910
|
}
|
|
908
911
|
actions.push(
|
|
909
|
-
() =>
|
|
912
|
+
() => runSyncActions(deletes, actionConcurrency).then(() => processUpsert(sourceObject, ids[0]))
|
|
910
913
|
);
|
|
911
914
|
} else {
|
|
912
915
|
actions.push(() => processUpsert(sourceObject, ids[0]));
|
|
@@ -925,11 +928,18 @@ async function syncEngine({
|
|
|
925
928
|
targetItems.forEach((object4) => {
|
|
926
929
|
deletes.push(() => processDelete(object4));
|
|
927
930
|
});
|
|
928
|
-
await
|
|
931
|
+
await runSyncActions(deletes, actionConcurrency);
|
|
929
932
|
}
|
|
930
|
-
await
|
|
933
|
+
await runSyncActions(actions, actionConcurrency);
|
|
931
934
|
await Promise.all([source.onSyncComplete?.(false), target.onSyncComplete?.(true)]);
|
|
932
935
|
}
|
|
936
|
+
var runSyncActions = async (actions, actionConcurrency) => {
|
|
937
|
+
if (actions.length === 0) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
const queue = new PQueue({ concurrency: actionConcurrency });
|
|
941
|
+
await queue.addAll(actions);
|
|
942
|
+
};
|
|
933
943
|
var SyncEngineError = class _SyncEngineError extends Error {
|
|
934
944
|
constructor(innerError, sourceObject) {
|
|
935
945
|
super(
|
|
@@ -2197,20 +2207,59 @@ import {
|
|
|
2197
2207
|
} from "@uniformdev/canvas";
|
|
2198
2208
|
import { isRichTextNodeType, isRichTextValue, walkRichTextTree } from "@uniformdev/richtext";
|
|
2199
2209
|
import fsj4 from "fs-jetpack";
|
|
2200
|
-
import
|
|
2210
|
+
import PQueue3 from "p-queue";
|
|
2201
2211
|
import { join as join10 } from "path";
|
|
2202
2212
|
|
|
2203
2213
|
// src/files/downloadFile.ts
|
|
2214
|
+
import { createWriteStream } from "fs";
|
|
2204
2215
|
import fsj2 from "fs-jetpack";
|
|
2205
|
-
import { join as join8 } from "path";
|
|
2216
|
+
import { dirname as dirname2, join as join8 } from "path";
|
|
2217
|
+
import { Readable } from "stream";
|
|
2218
|
+
import { pipeline } from "stream/promises";
|
|
2219
|
+
var downloadedFilePathCacheByDirectory = /* @__PURE__ */ new Map();
|
|
2220
|
+
var getDownloadedFilePathCache = (filesDirectory) => {
|
|
2221
|
+
const cached = downloadedFilePathCacheByDirectory.get(filesDirectory);
|
|
2222
|
+
if (cached) {
|
|
2223
|
+
return cached;
|
|
2224
|
+
}
|
|
2225
|
+
const cache = fsj2.cwd(filesDirectory).findAsync({ files: true, directories: false }).then((paths) => new Set(paths)).catch(() => /* @__PURE__ */ new Set());
|
|
2226
|
+
downloadedFilePathCacheByDirectory.set(filesDirectory, cache);
|
|
2227
|
+
return cache;
|
|
2228
|
+
};
|
|
2229
|
+
var filePathMatchesSourceId = (filePath, sourceId) => filePath === sourceId || filePath.startsWith(`${sourceId}.`);
|
|
2230
|
+
var hasFilePathMatchingSourceId = (filePaths, sourceId) => {
|
|
2231
|
+
for (const filePath of filePaths) {
|
|
2232
|
+
if (filePathMatchesSourceId(filePath, sourceId)) {
|
|
2233
|
+
return true;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
return false;
|
|
2237
|
+
};
|
|
2238
|
+
var writeResponseBodyToFile = async (response, filePath) => {
|
|
2239
|
+
if (!response.body) {
|
|
2240
|
+
throw new Error("Response does not contain a body");
|
|
2241
|
+
}
|
|
2242
|
+
const tempFilePath = `${filePath}.${process.pid}.${Date.now()}.download`;
|
|
2243
|
+
await fsj2.dirAsync(dirname2(filePath));
|
|
2244
|
+
try {
|
|
2245
|
+
const responseBody = response.body;
|
|
2246
|
+
await pipeline(Readable.fromWeb(responseBody), createWriteStream(tempFilePath));
|
|
2247
|
+
await fsj2.moveAsync(tempFilePath, filePath, { overwrite: true });
|
|
2248
|
+
} catch (error) {
|
|
2249
|
+
await fsj2.removeAsync(tempFilePath).catch(() => void 0);
|
|
2250
|
+
throw error;
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2206
2253
|
var downloadFile = async ({
|
|
2207
2254
|
fileClient,
|
|
2208
2255
|
fileUrl,
|
|
2209
2256
|
directory
|
|
2210
2257
|
}) => {
|
|
2211
2258
|
const writeDirectory = getFilesDirectory(directory);
|
|
2259
|
+
const filesDirectory = join8(writeDirectory, FILES_DIRECTORY_NAME);
|
|
2212
2260
|
const fileName = urlToFileName(fileUrl.toString());
|
|
2213
|
-
const
|
|
2261
|
+
const filePath = join8(filesDirectory, fileName);
|
|
2262
|
+
const fileAlreadyExists = await fsj2.existsAsync(filePath);
|
|
2214
2263
|
if (fileAlreadyExists) {
|
|
2215
2264
|
return { url: fileUrl };
|
|
2216
2265
|
}
|
|
@@ -2220,11 +2269,10 @@ var downloadFile = async ({
|
|
|
2220
2269
|
return null;
|
|
2221
2270
|
}
|
|
2222
2271
|
if (file.sourceId) {
|
|
2272
|
+
const sourceId = file.sourceId;
|
|
2223
2273
|
try {
|
|
2224
|
-
const
|
|
2225
|
-
|
|
2226
|
-
});
|
|
2227
|
-
if (hashAlreadyExists.length > 0) {
|
|
2274
|
+
const downloadedFilePaths = await getDownloadedFilePathCache(filesDirectory);
|
|
2275
|
+
if (hasFilePathMatchingSourceId(downloadedFilePaths, sourceId)) {
|
|
2228
2276
|
return { id: file.id, url: fileUrl };
|
|
2229
2277
|
}
|
|
2230
2278
|
} catch {
|
|
@@ -2235,8 +2283,12 @@ var downloadFile = async ({
|
|
|
2235
2283
|
if (!response.ok) {
|
|
2236
2284
|
return null;
|
|
2237
2285
|
}
|
|
2238
|
-
|
|
2239
|
-
|
|
2286
|
+
await writeResponseBodyToFile(response, filePath);
|
|
2287
|
+
const downloadedFilePathCache = downloadedFilePathCacheByDirectory.get(filesDirectory);
|
|
2288
|
+
if (downloadedFilePathCache) {
|
|
2289
|
+
const downloadedFilePaths = await downloadedFilePathCache;
|
|
2290
|
+
downloadedFilePaths.add(fileName);
|
|
2291
|
+
}
|
|
2240
2292
|
return { id: file.id, url: fileUrl };
|
|
2241
2293
|
};
|
|
2242
2294
|
|
|
@@ -2247,10 +2299,10 @@ import { fileTypeFromBuffer } from "file-type";
|
|
|
2247
2299
|
import fsj3 from "fs-jetpack";
|
|
2248
2300
|
import sizeOf from "image-size";
|
|
2249
2301
|
import normalizeNewline from "normalize-newline";
|
|
2250
|
-
import
|
|
2302
|
+
import PQueue2 from "p-queue";
|
|
2251
2303
|
import { join as join9 } from "path";
|
|
2252
2304
|
var uploadQueueByKey = /* @__PURE__ */ new Map();
|
|
2253
|
-
var fileUploadQueue = new
|
|
2305
|
+
var fileUploadQueue = new PQueue2({ concurrency: 10 });
|
|
2254
2306
|
var uploadFile = async ({
|
|
2255
2307
|
fileClient,
|
|
2256
2308
|
fileUrl,
|
|
@@ -2535,7 +2587,7 @@ var downloadFilesForCompositionOrEntry = async ({
|
|
|
2535
2587
|
directory,
|
|
2536
2588
|
fileClient
|
|
2537
2589
|
}) => {
|
|
2538
|
-
const fileDownloadQueue = new
|
|
2590
|
+
const fileDownloadQueue = new PQueue3({ concurrency: 10 });
|
|
2539
2591
|
await walkFileUrlsForCompositionOrEntry({
|
|
2540
2592
|
entity,
|
|
2541
2593
|
callback: ({ fileUrl }) => {
|
|
@@ -2551,7 +2603,7 @@ var uploadFilesForCompositionOrEntry = async ({
|
|
|
2551
2603
|
directory,
|
|
2552
2604
|
fileClient
|
|
2553
2605
|
}) => {
|
|
2554
|
-
const fileUploadQueue2 = new
|
|
2606
|
+
const fileUploadQueue2 = new PQueue3({ concurrency: 10 });
|
|
2555
2607
|
const urlReplacementMap = /* @__PURE__ */ new Map();
|
|
2556
2608
|
walkFileUrlsForCompositionOrEntry({
|
|
2557
2609
|
entity: entity.object,
|
|
@@ -2584,7 +2636,7 @@ var replaceRemoteUrlsWithLocalReferences = async ({
|
|
|
2584
2636
|
let sourceEntityAsString = JSON.stringify(sourceEntity);
|
|
2585
2637
|
const targetEntityAsString = JSON.stringify(targetEntity);
|
|
2586
2638
|
const writeDirectory = getFilesDirectory(directory);
|
|
2587
|
-
const fileUrlReplacementQueue = new
|
|
2639
|
+
const fileUrlReplacementQueue = new PQueue3({ concurrency: 10 });
|
|
2588
2640
|
walkFileUrlsForCompositionOrEntry({
|
|
2589
2641
|
entity: sourceEntity.object,
|
|
2590
2642
|
callback: ({ fileUrl }) => {
|
|
@@ -2624,7 +2676,7 @@ var replaceLocalUrlsWithRemoteReferences = async ({
|
|
|
2624
2676
|
fileClient
|
|
2625
2677
|
}) => {
|
|
2626
2678
|
let entityAsString = JSON.stringify(entity);
|
|
2627
|
-
const fileUrlReplacementQueue = new
|
|
2679
|
+
const fileUrlReplacementQueue = new PQueue3({ concurrency: 10 });
|
|
2628
2680
|
walkFileUrlsForCompositionOrEntry({
|
|
2629
2681
|
entity: entity.object,
|
|
2630
2682
|
callback: ({ fileUrl }) => {
|
|
@@ -12576,7 +12628,7 @@ import yargs40 from "yargs";
|
|
|
12576
12628
|
|
|
12577
12629
|
// src/webhooksClient.ts
|
|
12578
12630
|
import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
|
|
12579
|
-
import
|
|
12631
|
+
import PQueue4 from "p-queue";
|
|
12580
12632
|
import { Svix } from "svix";
|
|
12581
12633
|
import * as z3 from "zod/v3";
|
|
12582
12634
|
var WEBHOOKS_DASHBOARD_BASE_PATH = "/api/v1/svix-dashboard";
|
|
@@ -12624,7 +12676,7 @@ var WebhooksClient = class extends ApiClient4 {
|
|
|
12624
12676
|
};
|
|
12625
12677
|
}
|
|
12626
12678
|
async get() {
|
|
12627
|
-
const webhooksAPIQueue = new
|
|
12679
|
+
const webhooksAPIQueue = new PQueue4({ concurrency: 10 });
|
|
12628
12680
|
const { appId, token } = await this.getToken();
|
|
12629
12681
|
const svix = new Svix(token);
|
|
12630
12682
|
const getEndpoints = async ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.62.1-alpha.4+295a1c3116",
|
|
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.
|
|
31
|
-
"@uniformdev/canvas": "20.
|
|
32
|
-
"@uniformdev/context": "20.
|
|
33
|
-
"@uniformdev/files": "20.
|
|
34
|
-
"@uniformdev/project-map": "20.
|
|
35
|
-
"@uniformdev/redirect": "20.
|
|
36
|
-
"@uniformdev/richtext": "20.
|
|
30
|
+
"@uniformdev/assets": "20.62.1-alpha.4+295a1c3116",
|
|
31
|
+
"@uniformdev/canvas": "20.62.1-alpha.4+295a1c3116",
|
|
32
|
+
"@uniformdev/context": "20.62.1-alpha.4+295a1c3116",
|
|
33
|
+
"@uniformdev/files": "20.62.1-alpha.4+295a1c3116",
|
|
34
|
+
"@uniformdev/project-map": "20.62.1-alpha.4+295a1c3116",
|
|
35
|
+
"@uniformdev/redirect": "20.62.1-alpha.4+295a1c3116",
|
|
36
|
+
"@uniformdev/richtext": "20.62.1-alpha.4+295a1c3116",
|
|
37
37
|
"call-bind": "^1.0.2",
|
|
38
38
|
"colorette": "2.0.20",
|
|
39
39
|
"cosmiconfig": "9.0.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "295a1c31168e58eee9ca865d6c53d2cd7f6fe913"
|
|
84
84
|
}
|