@uniformdev/cli 20.69.1-alpha.10 → 20.70.0

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.69.0",
25
+ version: "20.70.0",
26
26
  description: "Uniform command line interface tool",
27
27
  license: "SEE LICENSE IN LICENSE.txt",
28
28
  main: "./cli.js",
@@ -1,4 +1,4 @@
1
- import "./chunk-TFIGXXFQ.mjs";
1
+ import "./chunk-Y24BXGPK.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  withFormatOptions,
22
22
  withProjectOptions,
23
23
  withTeamOptions
24
- } from "./chunk-TFIGXXFQ.mjs";
24
+ } from "./chunk-Y24BXGPK.mjs";
25
25
 
26
26
  // src/index.ts
27
27
  import * as dotenv from "dotenv";
@@ -628,9 +628,6 @@ export default uniformConfig({
628
628
  `;
629
629
 
630
630
  // src/sync/fileSyncEngineDataSource.ts
631
- function isErrorWithCode(error, code) {
632
- return typeof error === "object" && error !== null && "code" in error && error.code === code;
633
- }
634
631
  async function createFileSyncEngineDataSource({
635
632
  directory,
636
633
  format = "yaml",
@@ -691,7 +688,7 @@ ${e?.message}`));
691
688
  }
692
689
  await unlink(providerId);
693
690
  },
694
- writeObject: async (object4, existingObject) => {
691
+ writeObject: async (object4) => {
695
692
  const filename = selectFilename3 ? join(directory, `${selectFilename3(object4.object)}.${format}`) : getFullFilename(object4.id);
696
693
  let contents = object4.object;
697
694
  if (selectSchemaUrl2) {
@@ -704,18 +701,6 @@ ${e?.message}`));
704
701
  console.log(`Writing file ${filename}`);
705
702
  }
706
703
  emitWithFormat(contents, format, filename);
707
- if (existingObject?.providerId && existingObject.providerId !== filename) {
708
- if (verbose) {
709
- console.log(`Deleting file ${existingObject.providerId}`);
710
- }
711
- try {
712
- await unlink(existingObject.providerId);
713
- } catch (error) {
714
- if (!isErrorWithCode(error, "ENOENT")) {
715
- throw error;
716
- }
717
- }
718
- }
719
704
  }
720
705
  };
721
706
  }
@@ -739,7 +724,6 @@ function writeUniformPackage(filename, packageContents) {
739
724
  // src/sync/syncEngine.ts
740
725
  import { diffJson, diffLines } from "diff";
741
726
  import mitt from "mitt";
742
- import PQueue from "p-queue";
743
727
 
744
728
  // src/sync/serializedDequal.ts
745
729
  var has = Object.prototype.hasOwnProperty;
@@ -806,8 +790,7 @@ async function syncEngine({
806
790
  onBeforeProcessObject,
807
791
  onBeforeCompareObjects,
808
792
  onBeforeWriteObject,
809
- onError,
810
- actionConcurrency
793
+ onError
811
794
  //verbose = false,
812
795
  }) {
813
796
  const status = new ReactiveStatusUpdate((status2) => syncEngineEvents.emit("statusUpdate", status2));
@@ -856,46 +839,43 @@ async function syncEngine({
856
839
  const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
857
840
  const targetObject = targetItems.get(ids[0]);
858
841
  status.compared++;
859
- const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter(
860
- (invalidTargetObject) => typeof invalidTargetObject !== "undefined" && invalidTargetObject.object !== targetObject?.object
861
- );
862
- const targetIds = Array.isArray(targetObject?.id) ? targetObject.id : [targetObject?.id];
863
- const processedIds = new Set([...ids, ...targetIds].filter((id) => typeof id === "string"));
864
- const processUpdate = async (sourceObject2, targetObject2) => {
865
- try {
866
- if (!whatIf) {
867
- const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
868
- await target.writeObject(finalSourceObject, targetObject2);
869
- status.changesApplied++;
870
- }
871
- } catch (e) {
872
- if (onError) {
873
- onError(e, sourceObject2);
874
- } else {
875
- throw new SyncEngineError(e, sourceObject2);
876
- }
877
- } finally {
878
- log2({
879
- action: "update",
880
- id: ids[0],
881
- providerId: sourceObject2.providerId,
882
- displayName: sourceObject2.displayName ?? sourceObject2.providerId,
883
- whatIf,
884
- diff: () => diffJson(targetObject2.object, sourceObject2.object)
885
- });
886
- }
887
- };
842
+ const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => o?.object !== targetObject?.object);
888
843
  if (targetObject && invalidTargetObjects.length === 0) {
889
844
  sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, targetObject) : sourceObject;
890
845
  const compareResult = compareContents(sourceObject, targetObject);
891
846
  if (!compareResult) {
892
847
  if (mode === "createOrUpdate" || mode === "mirror") {
893
848
  status.changeCount++;
894
- actions.push(() => processUpdate(sourceObject, targetObject));
849
+ const process2 = async (sourceObject2, targetObject2) => {
850
+ try {
851
+ if (!whatIf) {
852
+ const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
853
+ await target.writeObject(finalSourceObject, targetObject2);
854
+ status.changesApplied++;
855
+ }
856
+ } catch (e) {
857
+ if (onError) {
858
+ onError(e, sourceObject2);
859
+ } else {
860
+ throw new SyncEngineError(e, sourceObject2);
861
+ }
862
+ } finally {
863
+ log2({
864
+ action: "update",
865
+ id: ids[0],
866
+ providerId: sourceObject2.providerId,
867
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
868
+ whatIf,
869
+ diff: () => diffJson(targetObject2.object, sourceObject2.object)
870
+ });
871
+ }
872
+ };
873
+ actions.push(() => process2(sourceObject, targetObject));
895
874
  }
896
875
  }
897
- processedIds.forEach((i) => targetItems.delete(i));
876
+ ids.forEach((i) => targetItems.delete(i));
898
877
  } else {
878
+ status.changeCount++;
899
879
  const processUpsert = async (sourceObject2, id) => {
900
880
  try {
901
881
  if (!whatIf) {
@@ -921,23 +901,6 @@ async function syncEngine({
921
901
  }
922
902
  };
923
903
  if (invalidTargetObjects.length > 0) {
924
- if (mode === "createOrUpdate" && !targetObject && invalidTargetObjects.length === 1) {
925
- const matchedTargetObject = invalidTargetObjects[0];
926
- sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, matchedTargetObject) : sourceObject;
927
- const compareResult = compareContents(sourceObject, matchedTargetObject);
928
- if (!compareResult) {
929
- status.changeCount++;
930
- actions.push(() => processUpdate(sourceObject, matchedTargetObject));
931
- }
932
- (Array.isArray(matchedTargetObject.id) ? matchedTargetObject.id : [matchedTargetObject.id]).forEach(
933
- (i) => targetItems.delete(i)
934
- );
935
- continue;
936
- }
937
- if (mode !== "mirror") {
938
- continue;
939
- }
940
- status.changeCount++;
941
904
  [...invalidTargetObjects, targetObject].forEach((o) => {
942
905
  (Array.isArray(o?.id) ? o?.id : [o?.id])?.forEach((i) => i && targetItems.delete(i));
943
906
  });
@@ -945,47 +908,31 @@ async function syncEngine({
945
908
  if (targetObject) {
946
909
  deletes.push(() => processDelete(targetObject));
947
910
  }
948
- actions.push(async () => {
949
- for (const deleteFn of deletes) {
950
- await deleteFn();
951
- }
952
- await processUpsert(sourceObject, ids[0]);
953
- });
911
+ actions.push(
912
+ () => Promise.all(deletes.map((deleteFn) => deleteFn())).then(() => processUpsert(sourceObject, ids[0]))
913
+ );
954
914
  } else {
955
- status.changeCount++;
956
915
  actions.push(() => processUpsert(sourceObject, ids[0]));
957
916
  }
958
917
  }
959
918
  }
960
- const orphanTargetObjects = new Set(targetItems.values());
919
+ status.changeCount += targetItems.size;
920
+ status.compared += targetItems.size;
961
921
  if (mode === "mirror") {
962
- status.changeCount += orphanTargetObjects.size;
963
- status.compared += orphanTargetObjects.size;
964
- if (!sourceHasItems && !allowEmptySource && orphanTargetObjects.size > 0) {
922
+ if (!sourceHasItems && !allowEmptySource && targetItems.size > 0) {
965
923
  throw new Error(
966
924
  `Sync source (${source.name}) is empty and mode is mirror. This would cause deletion of everything in the target (${target.name}), and most likely indicates an error in source definition.`
967
925
  );
968
926
  }
969
927
  const deletes = [];
970
- orphanTargetObjects.forEach((object4) => {
928
+ targetItems.forEach((object4) => {
971
929
  deletes.push(() => processDelete(object4));
972
930
  });
973
- await runSyncActions(deletes, actionConcurrency);
931
+ await Promise.all(deletes.map((d) => d()));
974
932
  }
975
- await runSyncActions(actions, actionConcurrency);
933
+ await Promise.all(actions.map((a) => a()));
976
934
  await Promise.all([source.onSyncComplete?.(false), target.onSyncComplete?.(true)]);
977
935
  }
978
- var runSyncActions = async (actions, actionConcurrency) => {
979
- if (actions.length === 0) {
980
- return;
981
- }
982
- if (typeof actionConcurrency === "undefined") {
983
- await Promise.all(actions.map((action) => action()));
984
- return;
985
- }
986
- const queue = new PQueue({ concurrency: actionConcurrency });
987
- await queue.addAll(actions);
988
- };
989
936
  var SyncEngineError = class _SyncEngineError extends Error {
990
937
  constructor(innerError, sourceObject) {
991
938
  super(
@@ -2253,64 +2200,20 @@ import {
2253
2200
  } from "@uniformdev/canvas";
2254
2201
  import { isRichTextNodeType, isRichTextValue, walkRichTextTree } from "@uniformdev/richtext";
2255
2202
  import fsj4 from "fs-jetpack";
2256
- import PQueue3 from "p-queue";
2203
+ import PQueue2 from "p-queue";
2257
2204
  import { join as join10 } from "path";
2258
2205
 
2259
2206
  // src/files/downloadFile.ts
2260
- import { createWriteStream } from "fs";
2261
2207
  import fsj2 from "fs-jetpack";
2262
- import { dirname as dirname2, join as join8 } from "path";
2263
- import { Readable } from "stream";
2264
- import { pipeline } from "stream/promises";
2265
- var downloadedFilePathCacheByDirectory = /* @__PURE__ */ new Map();
2266
- var tempDownloadFileCounter = 0;
2267
- var getTempDownloadFilePath = (filePath) => {
2268
- tempDownloadFileCounter += 1;
2269
- return `${filePath}.${process.pid}.${Date.now()}.${tempDownloadFileCounter}.download`;
2270
- };
2271
- var getDownloadedFilePathCache = (filesDirectory) => {
2272
- const cached = downloadedFilePathCacheByDirectory.get(filesDirectory);
2273
- if (cached) {
2274
- return cached;
2275
- }
2276
- const cache = fsj2.cwd(filesDirectory).findAsync({ files: true, directories: false }).then((paths) => new Set(paths)).catch(() => /* @__PURE__ */ new Set());
2277
- downloadedFilePathCacheByDirectory.set(filesDirectory, cache);
2278
- return cache;
2279
- };
2280
- var filePathMatchesSourceId = (filePath, sourceId) => filePath === sourceId || filePath.startsWith(`${sourceId}.`);
2281
- var hasFilePathMatchingSourceId = (filePaths, sourceId) => {
2282
- for (const filePath of filePaths) {
2283
- if (filePathMatchesSourceId(filePath, sourceId)) {
2284
- return true;
2285
- }
2286
- }
2287
- return false;
2288
- };
2289
- var writeResponseBodyToFile = async (response, filePath) => {
2290
- if (!response.body) {
2291
- throw new Error("Response does not contain a body");
2292
- }
2293
- const tempFilePath = getTempDownloadFilePath(filePath);
2294
- await fsj2.dirAsync(dirname2(filePath));
2295
- try {
2296
- const responseBody = response.body;
2297
- await pipeline(Readable.fromWeb(responseBody), createWriteStream(tempFilePath));
2298
- await fsj2.moveAsync(tempFilePath, filePath, { overwrite: true });
2299
- } catch (error) {
2300
- await fsj2.removeAsync(tempFilePath).catch(() => void 0);
2301
- throw error;
2302
- }
2303
- };
2208
+ import { join as join8 } from "path";
2304
2209
  var downloadFile = async ({
2305
2210
  fileClient,
2306
2211
  fileUrl,
2307
2212
  directory
2308
2213
  }) => {
2309
2214
  const writeDirectory = getFilesDirectory(directory);
2310
- const filesDirectory = join8(writeDirectory, FILES_DIRECTORY_NAME);
2311
2215
  const fileName = urlToFileName(fileUrl.toString());
2312
- const filePath = join8(filesDirectory, fileName);
2313
- const fileAlreadyExists = await fsj2.existsAsync(filePath);
2216
+ const fileAlreadyExists = await fsj2.existsAsync(join8(writeDirectory, FILES_DIRECTORY_NAME, fileName));
2314
2217
  if (fileAlreadyExists) {
2315
2218
  return { url: fileUrl };
2316
2219
  }
@@ -2320,10 +2223,11 @@ var downloadFile = async ({
2320
2223
  return null;
2321
2224
  }
2322
2225
  if (file.sourceId) {
2323
- const sourceId = file.sourceId;
2324
2226
  try {
2325
- const downloadedFilePaths = await getDownloadedFilePathCache(filesDirectory);
2326
- if (hasFilePathMatchingSourceId(downloadedFilePaths, sourceId)) {
2227
+ const hashAlreadyExists = await fsj2.findAsync(join8(writeDirectory, FILES_DIRECTORY_NAME), {
2228
+ matching: [file.sourceId, `${file.sourceId}.*`]
2229
+ });
2230
+ if (hashAlreadyExists.length > 0) {
2327
2231
  return { id: file.id, url: fileUrl };
2328
2232
  }
2329
2233
  } catch {
@@ -2334,12 +2238,8 @@ var downloadFile = async ({
2334
2238
  if (!response.ok) {
2335
2239
  return null;
2336
2240
  }
2337
- await writeResponseBodyToFile(response, filePath);
2338
- const downloadedFilePathCache = downloadedFilePathCacheByDirectory.get(filesDirectory);
2339
- if (downloadedFilePathCache) {
2340
- const downloadedFilePaths = await downloadedFilePathCache;
2341
- downloadedFilePaths.add(fileName);
2342
- }
2241
+ const fileBuffer = await response.arrayBuffer();
2242
+ await fsj2.writeAsync(join8(writeDirectory, FILES_DIRECTORY_NAME, fileName), Buffer.from(fileBuffer));
2343
2243
  return { id: file.id, url: fileUrl };
2344
2244
  };
2345
2245
 
@@ -2351,10 +2251,10 @@ import { createReadStream } from "fs";
2351
2251
  import fsj3 from "fs-jetpack";
2352
2252
  import { imageSizeFromFile } from "image-size/fromFile";
2353
2253
  import normalizeNewline from "normalize-newline";
2354
- import PQueue2 from "p-queue";
2254
+ import PQueue from "p-queue";
2355
2255
  import { join as join9 } from "path";
2356
2256
  var uploadQueueByKey = /* @__PURE__ */ new Map();
2357
- var fileUploadQueue = new PQueue2({ concurrency: 10 });
2257
+ var fileUploadQueue = new PQueue({ concurrency: 10 });
2358
2258
  var uploadFile = async ({
2359
2259
  fileClient,
2360
2260
  fileUrl,
@@ -2534,9 +2434,9 @@ var walkFileUrlsForCompositionOrEntry = ({
2534
2434
  };
2535
2435
 
2536
2436
  // src/files/files.ts
2537
- var fileDownloadQueue = new PQueue3({ concurrency: 10 });
2538
- var fileUploadQueue2 = new PQueue3({ concurrency: 10 });
2539
- var fileUrlReplacementQueue = new PQueue3({ concurrency: 10 });
2437
+ var fileDownloadQueue = new PQueue2({ concurrency: 10 });
2438
+ var fileUploadQueue2 = new PQueue2({ concurrency: 10 });
2439
+ var fileUrlReplacementQueue = new PQueue2({ concurrency: 10 });
2540
2440
  var downloadFileForAsset = async ({
2541
2441
  asset,
2542
2442
  directory,
@@ -2863,7 +2763,6 @@ function writeCanvasPackage(filename, packageContents) {
2863
2763
  }
2864
2764
 
2865
2765
  // src/commands/canvas/commands/asset/pull.ts
2866
- var ASSET_PULL_ACTION_CONCURRENCY = 10;
2867
2766
  var AssetPullModule = {
2868
2767
  command: "pull <directory>",
2869
2768
  describe: "Pulls all assets to local files in a directory",
@@ -2962,7 +2861,6 @@ var AssetPullModule = {
2962
2861
  target,
2963
2862
  mode,
2964
2863
  whatIf,
2965
- actionConcurrency: ASSET_PULL_ACTION_CONCURRENCY,
2966
2864
  allowEmptySource: allowEmptySource ?? true,
2967
2865
  log: createSyncEngineConsoleLogger({ diffMode }),
2968
2866
  onBeforeCompareObjects: async (sourceObject) => {
@@ -2990,7 +2888,6 @@ var AssetPullModule = {
2990
2888
  };
2991
2889
 
2992
2890
  // src/commands/canvas/commands/asset/push.ts
2993
- var ASSET_PUSH_ACTION_CONCURRENCY = 10;
2994
2891
  var AssetPushModule = {
2995
2892
  command: "push <directory>",
2996
2893
  describe: "Pushes all assets from files in a directory to Uniform",
@@ -3066,7 +2963,6 @@ var AssetPushModule = {
3066
2963
  target,
3067
2964
  mode,
3068
2965
  whatIf,
3069
- actionConcurrency: ASSET_PUSH_ACTION_CONCURRENCY,
3070
2966
  allowEmptySource,
3071
2967
  log: createSyncEngineConsoleLogger({ diffMode }),
3072
2968
  onBeforeCompareObjects: async (sourceObject, targetObject) => {
@@ -12267,20 +12163,6 @@ var selectIdentifier15 = (source, projectId) => [
12267
12163
  ];
12268
12164
  var selectFilename = (source) => cleanFileName(`${source.pathSegment}_${source.id}`);
12269
12165
  var selectDisplayName15 = (source) => `${source.name} (pid: ${source.id})`;
12270
- function alignProjectMapNodeWithTargetIdentifier(sourceObject, targetObject) {
12271
- if (!targetObject) {
12272
- return sourceObject;
12273
- }
12274
- return {
12275
- ...sourceObject,
12276
- id: targetObject.id,
12277
- providerId: targetObject.providerId,
12278
- object: {
12279
- ...sourceObject.object,
12280
- id: targetObject.object.id
12281
- }
12282
- };
12283
- }
12284
12166
 
12285
12167
  // src/commands/project-map/ProjectMapNodeEngineDataSource.ts
12286
12168
  function createProjectMapNodeEngineDataSource({
@@ -12497,12 +12379,6 @@ var ProjectMapNodePushModule = {
12497
12379
  whatIf,
12498
12380
  allowEmptySource,
12499
12381
  log: createSyncEngineConsoleLogger({ diffMode }),
12500
- onBeforeCompareObjects: async (sourceObject, targetObject) => {
12501
- return alignProjectMapNodeWithTargetIdentifier(sourceObject, targetObject);
12502
- },
12503
- onBeforeWriteObject: async (sourceObject, targetObject) => {
12504
- return alignProjectMapNodeWithTargetIdentifier(sourceObject, targetObject);
12505
- },
12506
12382
  onError: (error, object4) => {
12507
12383
  if (error.message.includes(__INTERNAL_MISSING_PARENT_NODE_ERROR)) {
12508
12384
  nodesFailedDueToMissingParent.add(object4.object);
@@ -12906,7 +12782,7 @@ import yargs40 from "yargs";
12906
12782
 
12907
12783
  // src/webhooksClient.ts
12908
12784
  import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
12909
- import PQueue4 from "p-queue";
12785
+ import PQueue3 from "p-queue";
12910
12786
  import { Svix } from "svix";
12911
12787
  import * as z3 from "zod";
12912
12788
  var WEBHOOKS_DASHBOARD_BASE_PATH = "/api/v1/svix-dashboard";
@@ -12954,7 +12830,7 @@ var WebhooksClient = class extends ApiClient4 {
12954
12830
  };
12955
12831
  }
12956
12832
  async get() {
12957
- const webhooksAPIQueue = new PQueue4({ concurrency: 10 });
12833
+ const webhooksAPIQueue = new PQueue3({ concurrency: 10 });
12958
12834
  const { appId, token } = await this.getToken();
12959
12835
  const svix = new Svix(token);
12960
12836
  const getEndpoints = async ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.69.1-alpha.10+3d89a58006",
3
+ "version": "20.70.0",
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.69.1-alpha.10+3d89a58006",
31
- "@uniformdev/canvas": "20.69.1-alpha.10+3d89a58006",
32
- "@uniformdev/context": "20.69.1-alpha.10+3d89a58006",
33
- "@uniformdev/files": "20.69.1-alpha.10+3d89a58006",
34
- "@uniformdev/project-map": "20.69.1-alpha.10+3d89a58006",
35
- "@uniformdev/redirect": "20.69.1-alpha.10+3d89a58006",
36
- "@uniformdev/richtext": "20.69.1-alpha.10+3d89a58006",
30
+ "@uniformdev/assets": "20.70.0",
31
+ "@uniformdev/canvas": "20.70.0",
32
+ "@uniformdev/context": "20.70.0",
33
+ "@uniformdev/files": "20.70.0",
34
+ "@uniformdev/project-map": "20.70.0",
35
+ "@uniformdev/redirect": "20.70.0",
36
+ "@uniformdev/richtext": "20.70.0",
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": "3d89a5800698d773fd45afbcbec0bc5a3493cf0a"
83
+ "gitHead": "3f8f572b37fc7ea5d2f37b1425451973556f3392"
84
84
  }