@uniformdev/cli 20.63.0 → 20.63.1-alpha.12

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.
@@ -60,11 +60,11 @@ var package_default = {
60
60
  colorette: "2.0.20",
61
61
  cosmiconfig: "9.0.0",
62
62
  "cosmiconfig-typescript-loader": "5.0.0",
63
- diff: "^5.0.0",
63
+ diff: "^8.0.3",
64
64
  dotenv: "^16.4.7",
65
65
  esbuild: "0.25.0",
66
66
  execa: "5.1.1",
67
- "file-type": "^20.0.0",
67
+ "file-type": "^21.3.2",
68
68
  "fs-jetpack": "5.1.0",
69
69
  graphql: "16.9.0",
70
70
  "graphql-request": "6.1.0",
@@ -82,12 +82,12 @@ var package_default = {
82
82
  "registry-url": "^6.0.0",
83
83
  slugify: "1.6.6",
84
84
  svix: "^1.71.0",
85
- undici: "^7.16.0",
85
+ undici: "^7.24.0",
86
86
  yargs: "^17.6.2",
87
- zod: "3.25.76"
87
+ zod: "4.3.6"
88
88
  },
89
89
  devDependencies: {
90
- "@types/diff": "5.0.9",
90
+ "@types/diff": "^8.0.0",
91
91
  "@types/js-yaml": "4.0.9",
92
92
  "@types/jsonwebtoken": "9.0.5",
93
93
  "@types/node": "24.3.1",
@@ -1,4 +1,4 @@
1
- import "./chunk-KNWMBEB7.mjs";
1
+ import "./chunk-BFI4F2WF.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-KNWMBEB7.mjs";
21
+ } from "./chunk-BFI4F2WF.mjs";
22
22
 
23
23
  // src/index.ts
24
24
  import * as dotenv from "dotenv";
@@ -74,7 +74,7 @@ async function getBearerToken(baseUrl) {
74
74
  }
75
75
 
76
76
  // src/client.ts
77
- import * as z from "zod/v3";
77
+ import * as z from "zod";
78
78
 
79
79
  // src/auth/api-key.ts
80
80
  var READ_PERMISSIONS = ["PROJECT", "UPM_PUB", "OPT_PUB", "OPT_READ", "UPM_READ"];
@@ -625,6 +625,9 @@ export default uniformConfig({
625
625
  `;
626
626
 
627
627
  // src/sync/fileSyncEngineDataSource.ts
628
+ function isErrorWithCode(error, code) {
629
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
630
+ }
628
631
  async function createFileSyncEngineDataSource({
629
632
  directory,
630
633
  format = "yaml",
@@ -685,7 +688,7 @@ ${e?.message}`));
685
688
  }
686
689
  await unlink(providerId);
687
690
  },
688
- writeObject: async (object4) => {
691
+ writeObject: async (object4, existingObject) => {
689
692
  const filename = selectFilename3 ? join(directory, `${selectFilename3(object4.object)}.${format}`) : getFullFilename(object4.id);
690
693
  let contents = object4.object;
691
694
  if (selectSchemaUrl2) {
@@ -698,6 +701,18 @@ ${e?.message}`));
698
701
  console.log(`Writing file ${filename}`);
699
702
  }
700
703
  emitWithFormat(contents, format, filename);
704
+ if (existingObject?.providerId && existingObject.providerId !== filename) {
705
+ if (verbose) {
706
+ console.log(`Deleting file ${existingObject.providerId}`);
707
+ }
708
+ try {
709
+ await unlink(existingObject.providerId);
710
+ } catch (error) {
711
+ if (!isErrorWithCode(error, "ENOENT")) {
712
+ throw error;
713
+ }
714
+ }
715
+ }
701
716
  }
702
717
  };
703
718
  }
@@ -836,43 +851,46 @@ async function syncEngine({
836
851
  const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
837
852
  const targetObject = targetItems.get(ids[0]);
838
853
  status.compared++;
839
- const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => o?.object !== targetObject?.object);
854
+ const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter(
855
+ (invalidTargetObject) => typeof invalidTargetObject !== "undefined" && invalidTargetObject.object !== targetObject?.object
856
+ );
857
+ const targetIds = Array.isArray(targetObject?.id) ? targetObject.id : [targetObject?.id];
858
+ const processedIds = new Set([...ids, ...targetIds].filter((id) => typeof id === "string"));
859
+ const processUpdate = async (sourceObject2, targetObject2) => {
860
+ try {
861
+ if (!whatIf) {
862
+ const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
863
+ await target.writeObject(finalSourceObject, targetObject2);
864
+ status.changesApplied++;
865
+ }
866
+ } catch (e) {
867
+ if (onError) {
868
+ onError(e, sourceObject2);
869
+ } else {
870
+ throw new SyncEngineError(e, sourceObject2);
871
+ }
872
+ } finally {
873
+ log2({
874
+ action: "update",
875
+ id: ids[0],
876
+ providerId: sourceObject2.providerId,
877
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
878
+ whatIf,
879
+ diff: () => diffJson(targetObject2.object, sourceObject2.object)
880
+ });
881
+ }
882
+ };
840
883
  if (targetObject && invalidTargetObjects.length === 0) {
841
884
  sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, targetObject) : sourceObject;
842
885
  const compareResult = compareContents(sourceObject, targetObject);
843
886
  if (!compareResult) {
844
887
  if (mode === "createOrUpdate" || mode === "mirror") {
845
888
  status.changeCount++;
846
- const process2 = async (sourceObject2, targetObject2) => {
847
- try {
848
- if (!whatIf) {
849
- const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
850
- await target.writeObject(finalSourceObject, targetObject2);
851
- status.changesApplied++;
852
- }
853
- } catch (e) {
854
- if (onError) {
855
- onError(e, sourceObject2);
856
- } else {
857
- throw new SyncEngineError(e, sourceObject2);
858
- }
859
- } finally {
860
- log2({
861
- action: "update",
862
- id: ids[0],
863
- providerId: sourceObject2.providerId,
864
- displayName: sourceObject2.displayName ?? sourceObject2.providerId,
865
- whatIf,
866
- diff: () => diffJson(targetObject2.object, sourceObject2.object)
867
- });
868
- }
869
- };
870
- actions.push(() => process2(sourceObject, targetObject));
889
+ actions.push(() => processUpdate(sourceObject, targetObject));
871
890
  }
872
891
  }
873
- ids.forEach((i) => targetItems.delete(i));
892
+ processedIds.forEach((i) => targetItems.delete(i));
874
893
  } else {
875
- status.changeCount++;
876
894
  const processUpsert = async (sourceObject2, id) => {
877
895
  try {
878
896
  if (!whatIf) {
@@ -898,6 +916,23 @@ async function syncEngine({
898
916
  }
899
917
  };
900
918
  if (invalidTargetObjects.length > 0) {
919
+ if (mode === "createOrUpdate" && !targetObject && invalidTargetObjects.length === 1) {
920
+ const matchedTargetObject = invalidTargetObjects[0];
921
+ sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, matchedTargetObject) : sourceObject;
922
+ const compareResult = compareContents(sourceObject, matchedTargetObject);
923
+ if (!compareResult) {
924
+ status.changeCount++;
925
+ actions.push(() => processUpdate(sourceObject, matchedTargetObject));
926
+ }
927
+ (Array.isArray(matchedTargetObject.id) ? matchedTargetObject.id : [matchedTargetObject.id]).forEach(
928
+ (i) => targetItems.delete(i)
929
+ );
930
+ continue;
931
+ }
932
+ if (mode !== "mirror") {
933
+ continue;
934
+ }
935
+ status.changeCount++;
901
936
  [...invalidTargetObjects, targetObject].forEach((o) => {
902
937
  (Array.isArray(o?.id) ? o?.id : [o?.id])?.forEach((i) => i && targetItems.delete(i));
903
938
  });
@@ -909,20 +944,22 @@ async function syncEngine({
909
944
  () => Promise.all(deletes.map((deleteFn) => deleteFn())).then(() => processUpsert(sourceObject, ids[0]))
910
945
  );
911
946
  } else {
947
+ status.changeCount++;
912
948
  actions.push(() => processUpsert(sourceObject, ids[0]));
913
949
  }
914
950
  }
915
951
  }
916
- status.changeCount += targetItems.size;
917
- status.compared += targetItems.size;
952
+ const orphanTargetObjects = new Set(targetItems.values());
918
953
  if (mode === "mirror") {
919
- if (!sourceHasItems && !allowEmptySource && targetItems.size > 0) {
954
+ status.changeCount += orphanTargetObjects.size;
955
+ status.compared += orphanTargetObjects.size;
956
+ if (!sourceHasItems && !allowEmptySource && orphanTargetObjects.size > 0) {
920
957
  throw new Error(
921
958
  `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.`
922
959
  );
923
960
  }
924
961
  const deletes = [];
925
- targetItems.forEach((object4) => {
962
+ orphanTargetObjects.forEach((object4) => {
926
963
  deletes.push(() => processDelete(object4));
927
964
  });
928
965
  await Promise.all(deletes.map((d) => d()));
@@ -1046,7 +1083,7 @@ async function chooseTeam(user, prompt, telemetry) {
1046
1083
  // src/auth/user-info.ts
1047
1084
  import { ProjectClient } from "@uniformdev/canvas";
1048
1085
  import { gql, request } from "graphql-request";
1049
- import * as z2 from "zod/v3";
1086
+ import * as z2 from "zod";
1050
1087
  var identityQuery = gql`
1051
1088
  query GetUserIdentity($subject: String!) {
1052
1089
  info: identities_by_pk(subject: $subject) {
@@ -7158,14 +7195,6 @@ var EntryPatternModule = {
7158
7195
  // src/commands/canvas/commands/label.ts
7159
7196
  import yargs15 from "yargs";
7160
7197
 
7161
- // src/commands/canvas/commands/label/_util.ts
7162
- import { LabelClient } from "@uniformdev/canvas";
7163
- var selectLabelIdentifier = (label) => label.label.publicId;
7164
- var selectLabelDisplayName = (label) => `${label.label.displayName} (pid: ${label.label.publicId})`;
7165
- function getLabelClient(options) {
7166
- return new LabelClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
7167
- }
7168
-
7169
7198
  // src/commands/canvas/labelsEngineDataSource.ts
7170
7199
  function normalizeLabelForSync(label) {
7171
7200
  const { projectId: _projectId, ...labelWithoutProjectId } = label;
@@ -7201,6 +7230,14 @@ function createLabelsEngineDataSource({
7201
7230
  };
7202
7231
  }
7203
7232
 
7233
+ // src/commands/canvas/commands/label/_util.ts
7234
+ import { LabelClient } from "@uniformdev/canvas";
7235
+ var selectLabelIdentifier = (label) => label.label.publicId;
7236
+ var selectLabelDisplayName = (label) => `${label.label.displayName} (pid: ${label.label.publicId})`;
7237
+ function getLabelClient(options) {
7238
+ return new LabelClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
7239
+ }
7240
+
7204
7241
  // src/commands/canvas/commands/label/pull.ts
7205
7242
  var LabelPullModule = {
7206
7243
  command: "pull <directory>",
@@ -11957,6 +11994,20 @@ var selectIdentifier15 = (source, projectId) => [
11957
11994
  ];
11958
11995
  var selectFilename = (source) => cleanFileName(`${source.pathSegment}_${source.id}`);
11959
11996
  var selectDisplayName15 = (source) => `${source.name} (pid: ${source.id})`;
11997
+ function alignProjectMapNodeWithTargetIdentifier(sourceObject, targetObject) {
11998
+ if (!targetObject) {
11999
+ return sourceObject;
12000
+ }
12001
+ return {
12002
+ ...sourceObject,
12003
+ id: targetObject.id,
12004
+ providerId: targetObject.providerId,
12005
+ object: {
12006
+ ...sourceObject.object,
12007
+ id: targetObject.object.id
12008
+ }
12009
+ };
12010
+ }
11960
12011
 
11961
12012
  // src/commands/project-map/ProjectMapNodeEngineDataSource.ts
11962
12013
  function createProjectMapNodeEngineDataSource({
@@ -12173,6 +12224,12 @@ var ProjectMapNodePushModule = {
12173
12224
  whatIf,
12174
12225
  allowEmptySource,
12175
12226
  log: createSyncEngineConsoleLogger({ diffMode }),
12227
+ onBeforeCompareObjects: async (sourceObject, targetObject) => {
12228
+ return alignProjectMapNodeWithTargetIdentifier(sourceObject, targetObject);
12229
+ },
12230
+ onBeforeWriteObject: async (sourceObject, targetObject) => {
12231
+ return alignProjectMapNodeWithTargetIdentifier(sourceObject, targetObject);
12232
+ },
12176
12233
  onError: (error, object4) => {
12177
12234
  if (error.message.includes(__INTERNAL_MISSING_PARENT_NODE_ERROR)) {
12178
12235
  nodesFailedDueToMissingParent.add(object4.object);
@@ -12578,7 +12635,7 @@ import yargs40 from "yargs";
12578
12635
  import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
12579
12636
  import PQueue3 from "p-queue";
12580
12637
  import { Svix } from "svix";
12581
- import * as z3 from "zod/v3";
12638
+ import * as z3 from "zod";
12582
12639
  var WEBHOOKS_DASHBOARD_BASE_PATH = "/api/v1/svix-dashboard";
12583
12640
  var WebhooksClient = class extends ApiClient4 {
12584
12641
  constructor(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.63.0",
3
+ "version": "20.63.1-alpha.12+914935b899",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,22 +27,22 @@
27
27
  "dependencies": {
28
28
  "@inquirer/prompts": "^7.10.1",
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "20.63.0",
31
- "@uniformdev/canvas": "20.63.0",
32
- "@uniformdev/context": "20.63.0",
33
- "@uniformdev/files": "20.63.0",
34
- "@uniformdev/project-map": "20.63.0",
35
- "@uniformdev/redirect": "20.63.0",
36
- "@uniformdev/richtext": "20.63.0",
30
+ "@uniformdev/assets": "20.63.1-alpha.12+914935b899",
31
+ "@uniformdev/canvas": "20.63.1-alpha.12+914935b899",
32
+ "@uniformdev/context": "20.63.1-alpha.12+914935b899",
33
+ "@uniformdev/files": "20.63.1-alpha.12+914935b899",
34
+ "@uniformdev/project-map": "20.63.1-alpha.12+914935b899",
35
+ "@uniformdev/redirect": "20.63.1-alpha.12+914935b899",
36
+ "@uniformdev/richtext": "20.63.1-alpha.12+914935b899",
37
37
  "call-bind": "^1.0.2",
38
38
  "colorette": "2.0.20",
39
39
  "cosmiconfig": "9.0.0",
40
40
  "cosmiconfig-typescript-loader": "5.0.0",
41
- "diff": "^5.0.0",
41
+ "diff": "^8.0.3",
42
42
  "dotenv": "^16.4.7",
43
43
  "esbuild": "0.25.0",
44
44
  "execa": "5.1.1",
45
- "file-type": "^20.0.0",
45
+ "file-type": "^21.3.2",
46
46
  "fs-jetpack": "5.1.0",
47
47
  "graphql": "16.9.0",
48
48
  "graphql-request": "6.1.0",
@@ -60,12 +60,12 @@
60
60
  "registry-url": "^6.0.0",
61
61
  "slugify": "1.6.6",
62
62
  "svix": "^1.71.0",
63
- "undici": "^7.16.0",
63
+ "undici": "^7.24.0",
64
64
  "yargs": "^17.6.2",
65
- "zod": "3.25.76"
65
+ "zod": "4.3.6"
66
66
  },
67
67
  "devDependencies": {
68
- "@types/diff": "5.0.9",
68
+ "@types/diff": "^8.0.0",
69
69
  "@types/js-yaml": "4.0.9",
70
70
  "@types/jsonwebtoken": "9.0.5",
71
71
  "@types/node": "24.3.1",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "76729fa5c8c4dc3d71d65fdb181a659755ec34ae"
83
+ "gitHead": "914935b89907018dde56a2c49b72e6899d9fb0e2"
84
84
  }