@uniformdev/cli 19.173.2-alpha.8 → 19.175.1-alpha.35

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.
Files changed (2) hide show
  1. package/dist/index.mjs +84 -39
  2. package/package.json +8 -8
package/dist/index.mjs CHANGED
@@ -236,7 +236,8 @@ async function syncEngine({
236
236
  log = () => {
237
237
  },
238
238
  onBeforeCompareObjects,
239
- onBeforeWriteObject
239
+ onBeforeWriteObject,
240
+ onError
240
241
  }) {
241
242
  const targetItems = /* @__PURE__ */ new Map();
242
243
  const deleteTracker = /* @__PURE__ */ new Set();
@@ -246,18 +247,22 @@ async function syncEngine({
246
247
  if (!whatIf) {
247
248
  try {
248
249
  await target.deleteObject(object.providerId, object);
250
+ log({
251
+ action: "delete",
252
+ id: object.id[0],
253
+ providerId: object.providerId,
254
+ displayName: object.displayName ?? object.providerId,
255
+ whatIf,
256
+ diff: diffLines(JSON.stringify(object.object, null, 2), "")
257
+ });
249
258
  } catch (e) {
250
- throw new SyncEngineError(e, object);
259
+ if (onError) {
260
+ onError(e, object);
261
+ } else {
262
+ throw new SyncEngineError(e, object);
263
+ }
251
264
  }
252
265
  }
253
- log({
254
- action: "delete",
255
- id: object.id[0],
256
- providerId: object.providerId,
257
- displayName: object.displayName ?? object.providerId,
258
- whatIf,
259
- diff: diffLines(JSON.stringify(object.object, null, 2), "")
260
- });
261
266
  };
262
267
  for await (const obj of target.objects) {
263
268
  if (Array.isArray(obj.id)) {
@@ -282,18 +287,22 @@ async function syncEngine({
282
287
  try {
283
288
  const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
284
289
  await target.writeObject(finalSourceObject, targetObject2);
290
+ log({
291
+ action: "update",
292
+ id: ids[0],
293
+ providerId: sourceObject2.providerId,
294
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
295
+ whatIf,
296
+ diff: diffJson(targetObject2.object, sourceObject2.object)
297
+ });
285
298
  } catch (e) {
286
- throw new SyncEngineError(e, sourceObject2);
299
+ if (onError) {
300
+ onError(e, sourceObject2);
301
+ } else {
302
+ throw new SyncEngineError(e, sourceObject2);
303
+ }
287
304
  }
288
305
  }
289
- log({
290
- action: "update",
291
- id: ids[0],
292
- providerId: sourceObject2.providerId,
293
- displayName: sourceObject2.displayName ?? sourceObject2.providerId,
294
- whatIf,
295
- diff: diffJson(targetObject2.object, sourceObject2.object)
296
- });
297
306
  };
298
307
  actions.push(process2(sourceObject, targetObject));
299
308
  }
@@ -305,18 +314,22 @@ async function syncEngine({
305
314
  try {
306
315
  const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2) : sourceObject2;
307
316
  await target.writeObject(finalSourceObject);
317
+ log({
318
+ action: "create",
319
+ id,
320
+ providerId: id,
321
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
322
+ whatIf,
323
+ diff: diffLines("", JSON.stringify(sourceObject2.object, null, 2))
324
+ });
308
325
  } catch (e) {
309
- throw new SyncEngineError(e, sourceObject2);
326
+ if (onError) {
327
+ onError(e, sourceObject2);
328
+ } else {
329
+ throw new SyncEngineError(e, sourceObject2);
330
+ }
310
331
  }
311
332
  }
312
- log({
313
- action: "create",
314
- id,
315
- providerId: id,
316
- displayName: sourceObject2.displayName ?? sourceObject2.providerId,
317
- whatIf,
318
- diff: diffLines("", JSON.stringify(sourceObject2.object, null, 2))
319
- });
320
333
  };
321
334
  if (invalidTargetObjects.length > 0) {
322
335
  [...invalidTargetObjects, targetObject].forEach((o) => {
@@ -7463,7 +7476,7 @@ import { PostHog } from "posthog-node";
7463
7476
  // package.json
7464
7477
  var package_default = {
7465
7478
  name: "@uniformdev/cli",
7466
- version: "19.173.1",
7479
+ version: "19.175.0",
7467
7480
  description: "Uniform command line interface tool",
7468
7481
  license: "SEE LICENSE IN LICENSE.txt",
7469
7482
  main: "./cli.js",
@@ -9109,7 +9122,10 @@ var ProjectMapNodePullModule = {
9109
9122
  };
9110
9123
 
9111
9124
  // src/commands/project-map/commands/ProjectMapNode/push.ts
9112
- import { UncachedProjectMapClient as UncachedProjectMapClient10 } from "@uniformdev/project-map";
9125
+ import {
9126
+ __INTERNAL_MISSING_PARENT_NODE_ERROR,
9127
+ UncachedProjectMapClient as UncachedProjectMapClient10
9128
+ } from "@uniformdev/project-map";
9113
9129
  var ProjectMapNodePushModule = {
9114
9130
  command: "push <directory>",
9115
9131
  describe: "Pushes all project maps nodes from files in a directory or package to Uniform",
@@ -9163,7 +9179,9 @@ var ProjectMapNodePushModule = {
9163
9179
  const packageContents = readContextPackage2(directory, true);
9164
9180
  source = await createArraySyncEngineDataSource({
9165
9181
  name: `Package file ${directory}`,
9166
- objects: packageContents.projectMapNodes ?? [],
9182
+ objects: packageContents.projectMapNodes.sort((a, b) => {
9183
+ return a.path.length - b.path.length;
9184
+ }) ?? [],
9167
9185
  selectIdentifier: expandedSelectIdentifier,
9168
9186
  selectDisplayName: selectDisplayName12
9169
9187
  });
@@ -9176,14 +9194,41 @@ var ProjectMapNodePushModule = {
9176
9194
  });
9177
9195
  }
9178
9196
  const target = createProjectMapNodeEngineDataSource({ client, projectId });
9179
- await syncEngine({
9180
- source,
9181
- target,
9182
- mode,
9183
- whatIf,
9184
- allowEmptySource,
9185
- log: createSyncEngineConsoleLogger({ diffMode })
9186
- });
9197
+ const nodesFailedDueToMissingParent = /* @__PURE__ */ new Set();
9198
+ const attemptSync = async () => {
9199
+ const lastFailedNodesCount = nodesFailedDueToMissingParent.size;
9200
+ nodesFailedDueToMissingParent.clear();
9201
+ await syncEngine({
9202
+ source,
9203
+ target,
9204
+ mode,
9205
+ whatIf,
9206
+ allowEmptySource,
9207
+ log: createSyncEngineConsoleLogger({ diffMode }),
9208
+ onError: (error, object) => {
9209
+ if (error.message.includes(__INTERNAL_MISSING_PARENT_NODE_ERROR)) {
9210
+ nodesFailedDueToMissingParent.add(object.object);
9211
+ } else {
9212
+ throw error;
9213
+ }
9214
+ }
9215
+ });
9216
+ if (nodesFailedDueToMissingParent.size !== 0) {
9217
+ const newFailedNodesCount = nodesFailedDueToMissingParent.size;
9218
+ if (newFailedNodesCount !== lastFailedNodesCount) {
9219
+ source = await createArraySyncEngineDataSource({
9220
+ name: `Nodes re-push from ${directory}`,
9221
+ objects: Array.from(nodesFailedDueToMissingParent),
9222
+ selectIdentifier: expandedSelectIdentifier,
9223
+ selectDisplayName: selectDisplayName12
9224
+ });
9225
+ await attemptSync();
9226
+ } else {
9227
+ throw new Error("Failed to push nodes due to missing parent nodes");
9228
+ }
9229
+ }
9230
+ };
9231
+ await attemptSync();
9187
9232
  }
9188
9233
  };
9189
9234
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.173.2-alpha.8+7b0bc70fd5",
3
+ "version": "19.175.1-alpha.35+f2ac62967d",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "19.173.2-alpha.8+7b0bc70fd5",
31
- "@uniformdev/canvas": "19.173.2-alpha.8+7b0bc70fd5",
32
- "@uniformdev/context": "19.173.2-alpha.8+7b0bc70fd5",
33
- "@uniformdev/files": "19.173.2-alpha.8+7b0bc70fd5",
34
- "@uniformdev/project-map": "19.173.2-alpha.8+7b0bc70fd5",
35
- "@uniformdev/redirect": "19.173.2-alpha.8+7b0bc70fd5",
30
+ "@uniformdev/assets": "19.175.1-alpha.35+f2ac62967d",
31
+ "@uniformdev/canvas": "19.175.1-alpha.35+f2ac62967d",
32
+ "@uniformdev/context": "19.175.1-alpha.35+f2ac62967d",
33
+ "@uniformdev/files": "19.175.1-alpha.35+f2ac62967d",
34
+ "@uniformdev/project-map": "19.175.1-alpha.35+f2ac62967d",
35
+ "@uniformdev/redirect": "19.175.1-alpha.35+f2ac62967d",
36
36
  "call-bind": "^1.0.2",
37
37
  "colorette": "2.0.20",
38
38
  "cosmiconfig": "9.0.0",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "7b0bc70fd58912415a860667c266cb339fa8133a"
81
+ "gitHead": "f2ac62967d4046285a3cf007cf90fd2889510262"
82
82
  }