@uniformdev/cli 20.49.4-alpha.2 → 20.49.5-alpha.10

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 +98 -42
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -1124,7 +1124,7 @@ import { PostHog } from "posthog-node";
1124
1124
  // package.json
1125
1125
  var package_default = {
1126
1126
  name: "@uniformdev/cli",
1127
- version: "20.49.3",
1127
+ version: "20.49.4",
1128
1128
  description: "Uniform command line interface tool",
1129
1129
  license: "SEE LICENSE IN LICENSE.txt",
1130
1130
  main: "./cli.js",
@@ -2612,6 +2612,15 @@ var compareCompositionsOrEntriesWithoutAssetUrls = (source, target) => {
2612
2612
  removeUrlsFromAssetParameters(structuredClone(target.object))
2613
2613
  );
2614
2614
  };
2615
+ var PUBLISH_TIMESTAMP_TOLERANCE_MS = 2e3;
2616
+ var compareCompositionsOrEntriesWithoutAssetUrlsForPublishing = (source, target) => {
2617
+ const sourceModified = new Date(source.object.modified).getTime();
2618
+ const targetModified = new Date(target.object.modified).getTime();
2619
+ if (sourceModified - targetModified > PUBLISH_TIMESTAMP_TOLERANCE_MS) {
2620
+ return false;
2621
+ }
2622
+ return compareCompositionsOrEntriesWithoutAssetUrls(source, target);
2623
+ };
2615
2624
  var removeUrlFromAsset = (asset) => {
2616
2625
  if (asset.asset.fields?.url?.value) {
2617
2626
  asset.asset.fields.url.value = "";
@@ -4201,7 +4210,7 @@ var CompositionPublishModule = {
4201
4210
  fileClient
4202
4211
  });
4203
4212
  },
4204
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
4213
+ compareContents: compareCompositionsOrEntriesWithoutAssetUrlsForPublishing,
4205
4214
  onBeforeWriteObject: async (sourceObject) => {
4206
4215
  return uploadFilesForCompositionOrEntry({
4207
4216
  entity: sourceObject,
@@ -4656,7 +4665,10 @@ var ComponentPatternRemoveModule = {
4656
4665
  };
4657
4666
 
4658
4667
  // src/commands/canvas/commands/composition/unpublish.ts
4659
- import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2 } from "@uniformdev/canvas";
4668
+ import {
4669
+ ApiClientError,
4670
+ CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2
4671
+ } from "@uniformdev/canvas";
4660
4672
  import { diffJson as diffJson2 } from "diff";
4661
4673
  var CompositionUnpublishModule = {
4662
4674
  command: "unpublish [ids]",
@@ -4670,15 +4682,15 @@ var CompositionUnpublishModule = {
4670
4682
  type: "string"
4671
4683
  }).option("all", {
4672
4684
  alias: ["a"],
4673
- describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
4685
+ describe: "Un-publishes all compositions. Use composition ID(s) to unpublish specific one(s) instead.",
4674
4686
  default: false,
4675
4687
  type: "boolean"
4676
4688
  }).option("onlyCompositions", {
4677
- describe: "Only publishing compositions and not patterns",
4689
+ describe: "Only un-publishing compositions and not patterns",
4678
4690
  default: false,
4679
4691
  type: "boolean"
4680
4692
  }).option("onlyPatterns", {
4681
- describe: "Only pulling patterns and not compositions",
4693
+ describe: "Only un-publishing patterns and not compositions",
4682
4694
  default: false,
4683
4695
  type: "boolean",
4684
4696
  hidden: true
@@ -4701,7 +4713,7 @@ var CompositionUnpublishModule = {
4701
4713
  verbose
4702
4714
  }) => {
4703
4715
  if (!all && !ids || all && ids) {
4704
- console.error(`Specify --all or composition ID(s) to publish.`);
4716
+ console.error(`Specify --all or composition ID(s) to unpublish.`);
4705
4717
  process.exit(1);
4706
4718
  }
4707
4719
  const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
@@ -4726,7 +4738,6 @@ var CompositionUnpublishModule = {
4726
4738
  patternType,
4727
4739
  verbose
4728
4740
  });
4729
- const actions = [];
4730
4741
  const log2 = createPublishStatusSyncEngineConsoleLogger({ status: "unpublish" });
4731
4742
  for await (const obj of target.objects) {
4732
4743
  if (Array.isArray(obj.id)) {
@@ -4735,16 +4746,30 @@ var CompositionUnpublishModule = {
4735
4746
  targetItems.set(obj.id, obj);
4736
4747
  }
4737
4748
  }
4749
+ const toUnpublish = [];
4738
4750
  for await (const sourceObject of source.objects) {
4751
+ toUnpublish.push(sourceObject);
4752
+ }
4753
+ const actions = [];
4754
+ for (const sourceObject of toUnpublish) {
4739
4755
  const id = Array.isArray(sourceObject.id) ? sourceObject.id[0] : sourceObject.id;
4740
4756
  const targetObject = targetItems.get(id);
4741
4757
  if (!targetObject) {
4742
- console.log(`Composition ${id} was not found`);
4743
- return;
4758
+ console.log(`Composition ${id} did not have a draft (removing published)`);
4744
4759
  }
4745
- console.log(`\u{1F41B} unpublishing composition: (id: ${id})`);
4746
4760
  if (!whatIf) {
4747
- actions.push(client.removeComposition({ compositionId: id, state: CANVAS_PUBLISHED_STATE2 }));
4761
+ actions.push(
4762
+ client.removeComposition({ ...parseCompositionSerializedId(id), state: CANVAS_PUBLISHED_STATE2 }).catch((err) => {
4763
+ const isNotFound = err instanceof ApiClientError && err.statusCode === 404;
4764
+ if (isNotFound) {
4765
+ console.warn(
4766
+ `Composition ${id} was not found when unpublishing (may already be unpublished or orphaned); skipping.`
4767
+ );
4768
+ return;
4769
+ }
4770
+ throw err;
4771
+ })
4772
+ );
4748
4773
  }
4749
4774
  log2({
4750
4775
  action: "update",
@@ -4752,9 +4777,10 @@ var CompositionUnpublishModule = {
4752
4777
  providerId: sourceObject.providerId,
4753
4778
  displayName: sourceObject.displayName ?? sourceObject.providerId,
4754
4779
  whatIf,
4755
- diff: () => diffJson2(targetObject.object, sourceObject.object)
4780
+ diff: () => targetObject ? diffJson2(targetObject.object, sourceObject.object) : []
4756
4781
  });
4757
4782
  }
4783
+ await Promise.all(actions);
4758
4784
  }
4759
4785
  };
4760
4786
 
@@ -4771,7 +4797,7 @@ var ComponentPatternUnpublishModule = {
4771
4797
  type: "string"
4772
4798
  }).option("all", {
4773
4799
  alias: ["a"],
4774
- describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
4800
+ describe: "Un-publishes all component patterns. Use composition ID(s) to unpublish specific one(s) instead.",
4775
4801
  default: false,
4776
4802
  type: "boolean"
4777
4803
  }).option("onlyCompositions", {
@@ -5066,7 +5092,7 @@ var CompositionPatternUnpublishModule = {
5066
5092
  type: "string"
5067
5093
  }).option("all", {
5068
5094
  alias: ["a"],
5069
- describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
5095
+ describe: "Un-publishes all composition patterns. Use composition ID(s) to unpublish specific one(s) instead.",
5070
5096
  default: false,
5071
5097
  type: "boolean"
5072
5098
  }).option("onlyCompositions", {
@@ -5964,7 +5990,7 @@ var EntryListModule = {
5964
5990
  };
5965
5991
 
5966
5992
  // src/commands/canvas/entryEngineDataSource.ts
5967
- import { ApiClientError, convertEntryToPutEntry } from "@uniformdev/canvas";
5993
+ import { ApiClientError as ApiClientError2, convertEntryToPutEntry } from "@uniformdev/canvas";
5968
5994
 
5969
5995
  // src/commands/canvas/commands/entry/_util.ts
5970
5996
  var selectEntryIdentifier = (e) => {
@@ -6010,7 +6036,7 @@ function createEntryEngineDataSource({
6010
6036
  editions: "all"
6011
6037
  })).entries;
6012
6038
  } catch (error) {
6013
- if (error instanceof ApiClientError && error.errorMessage === "Entry not found or not published") {
6039
+ if (error instanceof ApiClientError2 && error.errorMessage === "Entry not found or not published") {
6014
6040
  return [];
6015
6041
  }
6016
6042
  throw error;
@@ -6045,10 +6071,10 @@ var EntryPublishModule = {
6045
6071
  command: "publish [ids]",
6046
6072
  describe: "Publishes entry(ies)",
6047
6073
  builder: (yargs42) => withConfiguration(
6048
- withDiffOptions(
6049
- withApiOptions(
6050
- withProjectOptions(
6051
- withDiffOptions(
6074
+ withDebugOptions(
6075
+ withDiffOptions(
6076
+ withApiOptions(
6077
+ withProjectOptions(
6052
6078
  yargs42.positional("ids", {
6053
6079
  describe: "Publishes entry(ies) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
6054
6080
  type: "string"
@@ -6108,7 +6134,7 @@ var EntryPublishModule = {
6108
6134
  fileClient
6109
6135
  });
6110
6136
  },
6111
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
6137
+ compareContents: compareCompositionsOrEntriesWithoutAssetUrlsForPublishing,
6112
6138
  onBeforeWriteObject: async (sourceObject) => {
6113
6139
  return uploadFilesForCompositionOrEntry({
6114
6140
  entity: sourceObject,
@@ -6356,7 +6382,7 @@ var EntryRemoveModule = {
6356
6382
  };
6357
6383
 
6358
6384
  // src/commands/canvas/commands/entry/unpublish.ts
6359
- import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3 } from "@uniformdev/canvas";
6385
+ import { ApiClientError as ApiClientError3, CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3 } from "@uniformdev/canvas";
6360
6386
  import { diffJson as diffJson3 } from "diff";
6361
6387
  var EntryUnpublishModule = {
6362
6388
  command: "unpublish [ids]",
@@ -6380,7 +6406,7 @@ var EntryUnpublishModule = {
6380
6406
  ),
6381
6407
  handler: async ({ apiHost, apiKey, proxy, ids, all, project: projectId, whatIf, verbose }) => {
6382
6408
  if (!all && !ids || all && ids) {
6383
- console.error(`Specify --all or entry ID(s) to publish.`);
6409
+ console.error(`Specify --all or entry ID(s) to unpublish.`);
6384
6410
  process.exit(1);
6385
6411
  }
6386
6412
  const entryIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
@@ -6399,7 +6425,6 @@ var EntryUnpublishModule = {
6399
6425
  entryIDs: entryIDsArray,
6400
6426
  onlyEntries: true
6401
6427
  });
6402
- const actions = [];
6403
6428
  const log2 = createPublishStatusSyncEngineConsoleLogger({ status: "unpublish" });
6404
6429
  for await (const obj of target.objects) {
6405
6430
  if (Array.isArray(obj.id)) {
@@ -6408,15 +6433,30 @@ var EntryUnpublishModule = {
6408
6433
  targetItems.set(obj.id, obj);
6409
6434
  }
6410
6435
  }
6436
+ const toUnpublish = [];
6411
6437
  for await (const sourceObject of source.objects) {
6438
+ toUnpublish.push(sourceObject);
6439
+ }
6440
+ const actions = [];
6441
+ for (const sourceObject of toUnpublish) {
6412
6442
  const id = Array.isArray(sourceObject.id) ? sourceObject.id[0] : sourceObject.id;
6413
6443
  const targetObject = targetItems.get(id);
6414
6444
  if (!targetObject) {
6415
- console.log(`Entry ${id} was not found`);
6416
- return;
6445
+ console.log(`Entry ${id} did not have a draft (removing published)`);
6417
6446
  }
6418
6447
  if (!whatIf) {
6419
- actions.push(client.deleteEntry({ entryId: id, state: CANVAS_PUBLISHED_STATE3 }));
6448
+ actions.push(
6449
+ client.deleteEntry({ ...parseEntrySerializedId(id), state: CANVAS_PUBLISHED_STATE3 }).catch((err) => {
6450
+ const isNotFound = err instanceof ApiClientError3 && err.statusCode === 404;
6451
+ if (isNotFound) {
6452
+ console.warn(
6453
+ `Entry ${id} was not found when unpublishing (may already be unpublished or orphaned); skipping.`
6454
+ );
6455
+ return;
6456
+ }
6457
+ throw err;
6458
+ })
6459
+ );
6420
6460
  }
6421
6461
  log2({
6422
6462
  action: "update",
@@ -6424,9 +6464,10 @@ var EntryUnpublishModule = {
6424
6464
  providerId: sourceObject.providerId,
6425
6465
  displayName: sourceObject.displayName ?? sourceObject.providerId,
6426
6466
  whatIf,
6427
- diff: () => diffJson3(targetObject.object, sourceObject.object)
6467
+ diff: () => targetObject ? diffJson3(targetObject.object, sourceObject.object) : []
6428
6468
  });
6429
6469
  }
6470
+ await Promise.all(actions);
6430
6471
  }
6431
6472
  };
6432
6473
 
@@ -6660,7 +6701,7 @@ var EntryPatternPublishModule = {
6660
6701
  fileClient
6661
6702
  });
6662
6703
  },
6663
- compareContents: compareCompositionsOrEntriesWithoutAssetUrls,
6704
+ compareContents: compareCompositionsOrEntriesWithoutAssetUrlsForPublishing,
6664
6705
  onBeforeWriteObject: async (sourceObject) => {
6665
6706
  return uploadFilesForCompositionOrEntry({
6666
6707
  entity: sourceObject,
@@ -6913,11 +6954,11 @@ var EntryPatternRemoveModule = {
6913
6954
  };
6914
6955
 
6915
6956
  // src/commands/canvas/commands/entryPattern/unpublish.ts
6916
- import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE4 } from "@uniformdev/canvas";
6957
+ import { ApiClientError as ApiClientError4, CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE4 } from "@uniformdev/canvas";
6917
6958
  import { diffJson as diffJson4 } from "diff";
6918
6959
  var EntryPatternUnpublishModule = {
6919
6960
  command: "unpublish [ids]",
6920
- describe: "Unpublish an entry patterns",
6961
+ describe: "Unpublish entry pattern(s)",
6921
6962
  builder: (yargs42) => withConfiguration(
6922
6963
  withDebugOptions(
6923
6964
  withApiOptions(
@@ -6937,7 +6978,7 @@ var EntryPatternUnpublishModule = {
6937
6978
  ),
6938
6979
  handler: async ({ apiHost, apiKey, proxy, ids, all, project: projectId, whatIf, verbose }) => {
6939
6980
  if (!all && !ids || all && ids) {
6940
- console.error(`Specify --all or entry pattern ID(s) to publish.`);
6981
+ console.error(`Specify --all or entry pattern ID(s) to unpublish.`);
6941
6982
  process.exit(1);
6942
6983
  }
6943
6984
  const entryIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
@@ -6956,7 +6997,6 @@ var EntryPatternUnpublishModule = {
6956
6997
  entryIDs: entryIDsArray,
6957
6998
  onlyPatterns: true
6958
6999
  });
6959
- const actions = [];
6960
7000
  const log2 = createPublishStatusSyncEngineConsoleLogger({ status: "unpublish" });
6961
7001
  for await (const obj of target.objects) {
6962
7002
  if (Array.isArray(obj.id)) {
@@ -6965,15 +7005,30 @@ var EntryPatternUnpublishModule = {
6965
7005
  targetItems.set(obj.id, obj);
6966
7006
  }
6967
7007
  }
7008
+ const toUnpublish = [];
6968
7009
  for await (const sourceObject of source.objects) {
7010
+ toUnpublish.push(sourceObject);
7011
+ }
7012
+ const actions = [];
7013
+ for (const sourceObject of toUnpublish) {
6969
7014
  const id = Array.isArray(sourceObject.id) ? sourceObject.id[0] : sourceObject.id;
6970
7015
  const targetObject = targetItems.get(id);
6971
7016
  if (!targetObject) {
6972
- console.log(`Entry pattern ${id} was not found`);
6973
- return;
7017
+ console.log(`Entry pattern ${id} did not have a draft (removing published)`);
6974
7018
  }
6975
7019
  if (!whatIf) {
6976
- actions.push(client.deleteEntry({ entryId: id, state: CANVAS_PUBLISHED_STATE4 }));
7020
+ actions.push(
7021
+ client.deleteEntry({ ...parseEntrySerializedId(id), state: CANVAS_PUBLISHED_STATE4 }).catch((err) => {
7022
+ const isNotFound = err instanceof ApiClientError4 && err.statusCode === 404;
7023
+ if (isNotFound) {
7024
+ console.warn(
7025
+ `Entry pattern ${id} was not found when unpublishing (may already be unpublished or orphaned); skipping.`
7026
+ );
7027
+ return;
7028
+ }
7029
+ throw err;
7030
+ })
7031
+ );
6977
7032
  }
6978
7033
  log2({
6979
7034
  action: "update",
@@ -6981,9 +7036,10 @@ var EntryPatternUnpublishModule = {
6981
7036
  providerId: sourceObject.providerId,
6982
7037
  displayName: sourceObject.displayName ?? sourceObject.providerId,
6983
7038
  whatIf,
6984
- diff: () => diffJson4(targetObject.object, sourceObject.object)
7039
+ diff: () => targetObject ? diffJson4(targetObject.object, sourceObject.object) : []
6985
7040
  });
6986
7041
  }
7042
+ await Promise.all(actions);
6987
7043
  }
6988
7044
  };
6989
7045
 
@@ -8948,7 +9004,7 @@ var EnrichmentModule = {
8948
9004
  import yargs23 from "yargs";
8949
9005
 
8950
9006
  // src/commands/context/commands/manifest/get.ts
8951
- import { ApiClientError as ApiClientError2, UncachedManifestClient } from "@uniformdev/context/api";
9007
+ import { ApiClientError as ApiClientError5, UncachedManifestClient } from "@uniformdev/context/api";
8952
9008
  import { gray as gray4, green as green6, red as red6 } from "colorette";
8953
9009
  import { writeFile } from "fs";
8954
9010
  import { exit } from "process";
@@ -8999,7 +9055,7 @@ var ManifestGetModule = {
8999
9055
  }
9000
9056
  } catch (e) {
9001
9057
  let message;
9002
- if (e instanceof ApiClientError2) {
9058
+ if (e instanceof ApiClientError5) {
9003
9059
  if (e.statusCode === 403) {
9004
9060
  message = `The API key ${apiKey} did not have permissions to fetch the manifest. Ensure ${preview ? "Uniform Context > Read Drafts" : "Uniform Context > Manifest > Read"} permissions are granted.`;
9005
9061
  }
@@ -9015,7 +9071,7 @@ var ManifestGetModule = {
9015
9071
  };
9016
9072
 
9017
9073
  // src/commands/context/commands/manifest/publish.ts
9018
- import { ApiClientError as ApiClientError3, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
9074
+ import { ApiClientError as ApiClientError6, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
9019
9075
  import { gray as gray5, red as red7 } from "colorette";
9020
9076
  import { exit as exit2 } from "process";
9021
9077
  var ManifestPublishModule = {
@@ -9034,7 +9090,7 @@ var ManifestPublishModule = {
9034
9090
  await client.publish();
9035
9091
  } catch (e) {
9036
9092
  let message;
9037
- if (e instanceof ApiClientError3) {
9093
+ if (e instanceof ApiClientError6) {
9038
9094
  if (e.statusCode === 403) {
9039
9095
  message = `The API key ${apiKey} did not have permissions to publish the manifest. Ensure Uniform Context > Manifest > Publish permissions are granted.`;
9040
9096
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.49.4-alpha.2+0201693aca",
3
+ "version": "20.49.5-alpha.10+97590818af",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -28,13 +28,13 @@
28
28
  "dependencies": {
29
29
  "@inquirer/prompts": "^7.10.1",
30
30
  "@thi.ng/mime": "^2.2.23",
31
- "@uniformdev/assets": "20.49.4-alpha.2+0201693aca",
32
- "@uniformdev/canvas": "20.49.4-alpha.2+0201693aca",
33
- "@uniformdev/context": "20.49.4-alpha.2+0201693aca",
34
- "@uniformdev/files": "20.49.4-alpha.2+0201693aca",
35
- "@uniformdev/project-map": "20.49.4-alpha.2+0201693aca",
36
- "@uniformdev/redirect": "20.49.4-alpha.2+0201693aca",
37
- "@uniformdev/richtext": "20.49.4-alpha.2+0201693aca",
31
+ "@uniformdev/assets": "20.49.5-alpha.10+97590818af",
32
+ "@uniformdev/canvas": "20.49.5-alpha.10+97590818af",
33
+ "@uniformdev/context": "20.49.5-alpha.10+97590818af",
34
+ "@uniformdev/files": "20.49.5-alpha.10+97590818af",
35
+ "@uniformdev/project-map": "20.49.5-alpha.10+97590818af",
36
+ "@uniformdev/redirect": "20.49.5-alpha.10+97590818af",
37
+ "@uniformdev/richtext": "20.49.5-alpha.10+97590818af",
38
38
  "call-bind": "^1.0.2",
39
39
  "colorette": "2.0.20",
40
40
  "cosmiconfig": "9.0.0",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "0201693aca0f20b06ffaaef22decc086ec730035"
84
+ "gitHead": "97590818aff0ababfb057278ba981112e219bf43"
85
85
  }