@uniformdev/cli 19.191.0 → 19.191.2-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.
@@ -13,6 +13,7 @@ var getDirname = () => path.dirname(getFilename());
13
13
  var __dirname = /* @__PURE__ */ getDirname();
14
14
 
15
15
  // src/sync/util.ts
16
+ import { ApiClientError } from "@uniformdev/canvas";
16
17
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
17
18
  import { dump, load } from "js-yaml";
18
19
  import { dirname, extname, isAbsolute, resolve, sep } from "path";
@@ -47,7 +48,26 @@ function withApiOptions(yargs) {
47
48
  type: "string"
48
49
  });
49
50
  }
50
- function nodeFetchProxy(proxy) {
51
+ function withDebugOptions(yargs) {
52
+ return yargs.option("verbose", {
53
+ describe: "Enable verbose mode, which outputs additional information",
54
+ default: false,
55
+ type: "boolean"
56
+ }).option("what-if", {
57
+ alias: ["w"],
58
+ describe: "What-if mode reports what would be done but changes nothing",
59
+ default: false,
60
+ type: "boolean"
61
+ });
62
+ }
63
+ function withVerboseOption(yargs) {
64
+ return yargs.option("verbose", {
65
+ describe: "Enable verbose mode, which outputs additional information",
66
+ default: false,
67
+ type: "boolean"
68
+ });
69
+ }
70
+ function nodeFetchProxy(proxy, verbose) {
51
71
  if (proxy) {
52
72
  console.log(`\u{1F991} Using proxy ${proxy}`);
53
73
  }
@@ -61,6 +81,41 @@ function nodeFetchProxy(proxy) {
61
81
  }
62
82
  return undiciFetch(input, init);
63
83
  };
84
+ if (verbose) {
85
+ return async function fetchWithVerboseLogging(input, init) {
86
+ const method = init?.method ?? "GET";
87
+ console.log(`\u{1F41B} verbose request: method ${method} url ${input.toString()}`);
88
+ const response = await wrappedFetch(input, init);
89
+ const clonedResponse = response.clone();
90
+ if (!clonedResponse.ok) {
91
+ let message = "";
92
+ try {
93
+ const responseText = await clonedResponse.text();
94
+ try {
95
+ const parsed = JSON.parse(responseText);
96
+ if (parsed.errorMessage) {
97
+ message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
98
+ } else {
99
+ message = responseText;
100
+ }
101
+ } catch (e) {
102
+ message = responseText;
103
+ }
104
+ } catch {
105
+ message = `General error`;
106
+ }
107
+ const exception = new ApiClientError(
108
+ message,
109
+ method,
110
+ input.toString(),
111
+ clonedResponse.status,
112
+ clonedResponse.statusText
113
+ );
114
+ console.error(`\u{1F41B} verbose API error`, exception.message, init?.body);
115
+ }
116
+ return response;
117
+ };
118
+ }
64
119
  return wrappedFetch;
65
120
  }
66
121
  function withProjectOptions(yargs) {
@@ -251,6 +306,8 @@ export {
251
306
  __require,
252
307
  withConfiguration,
253
308
  withApiOptions,
309
+ withDebugOptions,
310
+ withVerboseOption,
254
311
  nodeFetchProxy,
255
312
  withProjectOptions,
256
313
  withTeamOptions,
@@ -1,4 +1,4 @@
1
- import "./chunk-VMUNHMVI.mjs";
1
+ import "./chunk-MIERGFOU.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
package/dist/index.mjs CHANGED
@@ -11,11 +11,13 @@ import {
11
11
  readFileToObject,
12
12
  withApiOptions,
13
13
  withConfiguration,
14
+ withDebugOptions,
14
15
  withDiffOptions,
15
16
  withFormatOptions,
16
17
  withProjectOptions,
17
- withTeamOptions
18
- } from "./chunk-VMUNHMVI.mjs";
18
+ withTeamOptions,
19
+ withVerboseOption
20
+ } from "./chunk-MIERGFOU.mjs";
19
21
 
20
22
  // src/index.ts
21
23
  import * as dotenv from "dotenv";
@@ -244,24 +246,25 @@ async function syncEngine({
244
246
  const processDelete = async (object) => {
245
247
  if (deleteTracker.has(object)) return;
246
248
  deleteTracker.add(object);
247
- if (!whatIf) {
248
- try {
249
+ try {
250
+ if (!whatIf) {
249
251
  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
- });
258
- } catch (e) {
259
- if (onError) {
260
- onError(e, object);
261
- } else {
262
- throw new SyncEngineError(e, object);
263
- }
264
252
  }
253
+ } catch (e) {
254
+ if (onError) {
255
+ onError(e, object);
256
+ } else {
257
+ throw new SyncEngineError(e, object);
258
+ }
259
+ } finally {
260
+ log({
261
+ action: "delete",
262
+ id: object.id[0],
263
+ providerId: object.providerId,
264
+ displayName: object.displayName ?? object.providerId,
265
+ whatIf,
266
+ diff: diffLines(JSON.stringify(object.object, null, 2), "")
267
+ });
265
268
  }
266
269
  };
267
270
  for await (const obj of target.objects) {
@@ -283,25 +286,26 @@ async function syncEngine({
283
286
  if (!compareContents(sourceObject, targetObject)) {
284
287
  if (mode === "createOrUpdate" || mode === "mirror") {
285
288
  const process2 = async (sourceObject2, targetObject2) => {
286
- if (!whatIf) {
287
- try {
289
+ try {
290
+ if (!whatIf) {
288
291
  const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
289
292
  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
- });
298
- } catch (e) {
299
- if (onError) {
300
- onError(e, sourceObject2);
301
- } else {
302
- throw new SyncEngineError(e, sourceObject2);
303
- }
304
293
  }
294
+ } catch (e) {
295
+ if (onError) {
296
+ onError(e, sourceObject2);
297
+ } else {
298
+ throw new SyncEngineError(e, sourceObject2);
299
+ }
300
+ } finally {
301
+ log({
302
+ action: "update",
303
+ id: ids[0],
304
+ providerId: sourceObject2.providerId,
305
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
306
+ whatIf,
307
+ diff: diffJson(targetObject2.object, sourceObject2.object)
308
+ });
305
309
  }
306
310
  };
307
311
  actions.push(process2(sourceObject, targetObject));
@@ -310,25 +314,26 @@ async function syncEngine({
310
314
  ids.forEach((i) => targetItems.delete(i));
311
315
  } else {
312
316
  const process2 = async (sourceObject2, id) => {
313
- if (!whatIf) {
314
- try {
317
+ try {
318
+ if (!whatIf) {
315
319
  const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2) : sourceObject2;
316
320
  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
- });
325
- } catch (e) {
326
- if (onError) {
327
- onError(e, sourceObject2);
328
- } else {
329
- throw new SyncEngineError(e, sourceObject2);
330
- }
331
321
  }
322
+ } catch (e) {
323
+ if (onError) {
324
+ onError(e, sourceObject2);
325
+ } else {
326
+ throw new SyncEngineError(e, sourceObject2);
327
+ }
328
+ } finally {
329
+ log({
330
+ action: "create",
331
+ id,
332
+ providerId: id,
333
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
334
+ whatIf,
335
+ diff: diffLines("", JSON.stringify(sourceObject2.object, null, 2))
336
+ });
332
337
  }
333
338
  };
334
339
  if (invalidTargetObjects.length > 0) {
@@ -1748,38 +1753,43 @@ var CompositionGetModule = {
1748
1753
  withApiOptions(
1749
1754
  withProjectOptions(
1750
1755
  withStateOptions(
1751
- yargs36.positional("id", { demandOption: true, describe: "Composition/pattern public ID to fetch" }).option({
1752
- resolvePatterns: {
1753
- type: "boolean",
1754
- default: false,
1755
- describe: "Resolve pattern references in the composition"
1756
- },
1757
- resolveOverrides: {
1758
- type: "boolean",
1759
- default: false,
1760
- describe: "Resolves pattern overrides in the composition and removes override definition data"
1761
- },
1762
- componentIDs: {
1763
- type: "boolean",
1764
- default: false,
1765
- describe: "Include individual component UIDs"
1766
- },
1767
- resolveData: {
1768
- type: "boolean",
1769
- default: false,
1770
- describe: "Resolve all data resources used by the composition/pattern"
1771
- },
1772
- diagnostics: {
1773
- type: "boolean",
1774
- default: false,
1775
- describe: "Include diagnostics information when resolving data"
1776
- },
1777
- resolutionDepth: {
1778
- type: "number",
1779
- default: 1,
1780
- describe: "Controls how many levels deep content references should be resolved"
1781
- }
1782
- })
1756
+ withVerboseOption(
1757
+ yargs36.positional("id", {
1758
+ demandOption: true,
1759
+ describe: "Composition/pattern public ID to fetch"
1760
+ }).option({
1761
+ resolvePatterns: {
1762
+ type: "boolean",
1763
+ default: false,
1764
+ describe: "Resolve pattern references in the composition"
1765
+ },
1766
+ resolveOverrides: {
1767
+ type: "boolean",
1768
+ default: false,
1769
+ describe: "Resolves pattern overrides in the composition and removes override definition data"
1770
+ },
1771
+ componentIDs: {
1772
+ type: "boolean",
1773
+ default: false,
1774
+ describe: "Include individual component UIDs"
1775
+ },
1776
+ resolveData: {
1777
+ type: "boolean",
1778
+ default: false,
1779
+ describe: "Resolve all data resources used by the composition/pattern"
1780
+ },
1781
+ diagnostics: {
1782
+ type: "boolean",
1783
+ default: false,
1784
+ describe: "Include diagnostics information when resolving data"
1785
+ },
1786
+ resolutionDepth: {
1787
+ type: "number",
1788
+ default: 1,
1789
+ describe: "Controls how many levels deep content references should be resolved"
1790
+ }
1791
+ })
1792
+ )
1783
1793
  )
1784
1794
  )
1785
1795
  )
@@ -1800,22 +1810,25 @@ var CompositionGetModule = {
1800
1810
  componentIDs,
1801
1811
  resolveData,
1802
1812
  diagnostics,
1803
- resolutionDepth
1813
+ resolutionDepth,
1814
+ verbose
1804
1815
  }) => {
1805
- const fetch3 = nodeFetchProxy(proxy);
1816
+ const parameters = {
1817
+ compositionId: id,
1818
+ state: convertStateOption(state),
1819
+ skipPatternResolution: !resolvePatterns,
1820
+ skipOverridesResolution: !resolveOverrides,
1821
+ withComponentIDs: componentIDs,
1822
+ skipDataResolution: !resolveData,
1823
+ diagnostics: resolveData ? diagnostics : void 0,
1824
+ resolutionDepth: resolveData ? resolutionDepth : void 0
1825
+ };
1826
+ if (verbose) {
1827
+ console.log(`\u{1F41B} get composition:`, parameters);
1828
+ }
1829
+ const fetch3 = nodeFetchProxy(proxy, verbose);
1806
1830
  const client = new UncachedCanvasClient7({ apiKey, edgeApiHost, apiHost, fetch: fetch3, projectId });
1807
- const res = prepCompositionForDisk(
1808
- await client.getCompositionById({
1809
- compositionId: id,
1810
- state: convertStateOption(state),
1811
- skipPatternResolution: !resolvePatterns,
1812
- skipOverridesResolution: !resolveOverrides,
1813
- withComponentIDs: componentIDs,
1814
- skipDataResolution: !resolveData,
1815
- diagnostics: resolveData ? diagnostics : void 0,
1816
- resolutionDepth: resolveData ? resolutionDepth : void 0
1817
- })
1818
- );
1831
+ const res = prepCompositionForDisk(await client.getCompositionById(parameters));
1819
1832
  emitWithFormat(res, format, filename);
1820
1833
  }
1821
1834
  };
@@ -1836,38 +1849,40 @@ var CompositionListModule = {
1836
1849
  withConfiguration(
1837
1850
  withApiOptions(
1838
1851
  withProjectOptions(
1839
- withStateOptions(
1840
- yargs36.options({
1841
- offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
1842
- limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
1843
- search: { describe: "Search query", type: "string", default: "" },
1844
- resolvePatterns: {
1845
- type: "boolean",
1846
- default: false,
1847
- describe: "Resolve pattern references in the composition"
1848
- },
1849
- resolveOverrides: {
1850
- type: "boolean",
1851
- default: false,
1852
- describe: "Resolves pattern overrides in the composition and removes override definition data"
1853
- },
1854
- onlyCompositions: {
1855
- describe: "Only pulling compositions and not patterns",
1856
- default: false,
1857
- type: "boolean"
1858
- },
1859
- onlyPatterns: {
1860
- describe: "Only pulling patterns and not compositions",
1861
- default: false,
1862
- type: "boolean",
1863
- hidden: true
1864
- },
1865
- componentIDs: {
1866
- type: "boolean",
1867
- default: false,
1868
- describe: "Include individual component UIDs"
1869
- }
1870
- })
1852
+ withDebugOptions(
1853
+ withStateOptions(
1854
+ yargs36.options({
1855
+ offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
1856
+ limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
1857
+ search: { describe: "Search query", type: "string", default: "" },
1858
+ resolvePatterns: {
1859
+ type: "boolean",
1860
+ default: false,
1861
+ describe: "Resolve pattern references in the composition"
1862
+ },
1863
+ resolveOverrides: {
1864
+ type: "boolean",
1865
+ default: false,
1866
+ describe: "Resolves pattern overrides in the composition and removes override definition data"
1867
+ },
1868
+ onlyCompositions: {
1869
+ describe: "Only pulling compositions and not patterns",
1870
+ default: false,
1871
+ type: "boolean"
1872
+ },
1873
+ onlyPatterns: {
1874
+ describe: "Only pulling patterns and not compositions",
1875
+ default: false,
1876
+ type: "boolean",
1877
+ hidden: true
1878
+ },
1879
+ componentIDs: {
1880
+ type: "boolean",
1881
+ default: false,
1882
+ describe: "Include individual component UIDs"
1883
+ }
1884
+ })
1885
+ )
1871
1886
  )
1872
1887
  )
1873
1888
  )
@@ -1889,11 +1904,10 @@ var CompositionListModule = {
1889
1904
  state,
1890
1905
  resolvePatterns,
1891
1906
  resolveOverrides,
1892
- componentIDs
1907
+ componentIDs,
1908
+ verbose
1893
1909
  }) => {
1894
- const fetch3 = nodeFetchProxy(proxy);
1895
- const client = new UncachedCanvasClient8({ apiKey, apiHost, fetch: fetch3, projectId });
1896
- const res = await client.getCompositionList({
1910
+ const parameters = {
1897
1911
  limit,
1898
1912
  offset,
1899
1913
  search: search && search.length > 0 ? search : void 0,
@@ -1903,7 +1917,13 @@ var CompositionListModule = {
1903
1917
  skipPatternResolution: !resolvePatterns,
1904
1918
  withComponentIDs: componentIDs,
1905
1919
  skipOverridesResolution: !resolveOverrides
1906
- });
1920
+ };
1921
+ if (verbose) {
1922
+ console.log(`\u{1F41B} list compositions:`, parameters);
1923
+ }
1924
+ const fetch3 = nodeFetchProxy(proxy, verbose);
1925
+ const client = new UncachedCanvasClient8({ apiKey, apiHost, fetch: fetch3, projectId });
1926
+ const res = await client.getCompositionList();
1907
1927
  emitWithFormat(res.compositions, format, filename);
1908
1928
  }
1909
1929
  };
@@ -1984,23 +2004,30 @@ function createComponentInstanceEngineDataSource({
1984
2004
  onlyCompositions,
1985
2005
  onlyPatterns,
1986
2006
  patternType,
2007
+ verbose,
1987
2008
  ...clientOptions
1988
2009
  }) {
1989
2010
  const stateId = convertStateOption(state);
1990
2011
  async function* getObjects() {
1991
2012
  const componentInstances = paginateAsync(
1992
- async (offset, limit) => (await client.getCompositionList({
1993
- ...clientOptions,
1994
- limit,
1995
- offset,
1996
- pattern: onlyCompositions ? false : onlyPatterns ? true : void 0,
1997
- state: stateId,
1998
- skipPatternResolution: true,
1999
- skipOverridesResolution: true,
2000
- withComponentIDs: true,
2001
- patternType,
2002
- editions: "all"
2003
- })).compositions,
2013
+ async (offset, limit) => {
2014
+ const parameters = {
2015
+ ...clientOptions,
2016
+ limit,
2017
+ offset,
2018
+ pattern: onlyCompositions ? false : onlyPatterns ? true : void 0,
2019
+ state: stateId,
2020
+ skipPatternResolution: true,
2021
+ skipOverridesResolution: true,
2022
+ withComponentIDs: true,
2023
+ patternType,
2024
+ editions: "all"
2025
+ };
2026
+ if (verbose) {
2027
+ console.log(`\u{1F41B} pull compositions: `, parameters);
2028
+ }
2029
+ return (await client.getCompositionList(parameters)).compositions;
2030
+ },
2004
2031
  { pageSize: 100 }
2005
2032
  );
2006
2033
  for await (const compositionListItem of componentInstances) {
@@ -2017,9 +2044,15 @@ function createComponentInstanceEngineDataSource({
2017
2044
  name: "Uniform API",
2018
2045
  objects: getObjects(),
2019
2046
  deleteObject: async (providerId) => {
2047
+ if (verbose) {
2048
+ console.log(`\u{1F41B} delete composition: (id: ${parseCompositionSerializedId(providerId)})`);
2049
+ }
2020
2050
  await client.removeComposition(parseCompositionSerializedId(providerId));
2021
2051
  },
2022
2052
  writeObject: async (object) => {
2053
+ if (verbose) {
2054
+ console.log(`\u{1F41B} push composition: (id: ${object.object.composition._id})`);
2055
+ }
2023
2056
  await client.updateComposition({ ...object.object, state: stateId });
2024
2057
  }
2025
2058
  };
@@ -2032,30 +2065,27 @@ var CompositionPublishModule = {
2032
2065
  builder: (yargs36) => withConfiguration(
2033
2066
  withApiOptions(
2034
2067
  withProjectOptions(
2035
- withDiffOptions(
2036
- yargs36.positional("ids", {
2037
- describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
2038
- type: "string"
2039
- }).option("all", {
2040
- alias: ["a"],
2041
- describe: "Publishes all compositions. Use compositionId to publish one instead.",
2042
- default: false,
2043
- type: "boolean"
2044
- }).option("what-if", {
2045
- alias: ["w"],
2046
- describe: "What-if mode reports what would be done but does not perform any publishing",
2047
- default: false,
2048
- type: "boolean"
2049
- }).option("onlyCompositions", {
2050
- describe: "Only publishing compositions and not patterns",
2051
- default: false,
2052
- type: "boolean"
2053
- }).option("onlyPatterns", {
2054
- describe: "Only pulling patterns and not compositions",
2055
- default: false,
2056
- type: "boolean",
2057
- hidden: true
2058
- })
2068
+ withDebugOptions(
2069
+ withDiffOptions(
2070
+ yargs36.positional("ids", {
2071
+ describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
2072
+ type: "string"
2073
+ }).option("all", {
2074
+ alias: ["a"],
2075
+ describe: "Publishes all compositions. Use compositionId to publish one instead.",
2076
+ default: false,
2077
+ type: "boolean"
2078
+ }).option("onlyCompositions", {
2079
+ describe: "Only publishing compositions and not patterns",
2080
+ default: false,
2081
+ type: "boolean"
2082
+ }).option("onlyPatterns", {
2083
+ describe: "Only pulling patterns and not compositions",
2084
+ default: false,
2085
+ type: "boolean",
2086
+ hidden: true
2087
+ })
2088
+ )
2059
2089
  )
2060
2090
  )
2061
2091
  )
@@ -2070,14 +2100,15 @@ var CompositionPublishModule = {
2070
2100
  project: projectId,
2071
2101
  onlyCompositions,
2072
2102
  onlyPatterns,
2073
- patternType
2103
+ patternType,
2104
+ verbose
2074
2105
  }) => {
2075
2106
  if (!all && !ids || all && ids) {
2076
2107
  console.error(`Specify --all or composition ID(s) to publish.`);
2077
2108
  process.exit(1);
2078
2109
  }
2079
2110
  const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
2080
- const fetch3 = nodeFetchProxy(proxy);
2111
+ const fetch3 = nodeFetchProxy(proxy, verbose);
2081
2112
  const client = new UncachedCanvasClient9({ apiKey, apiHost, fetch: fetch3, projectId });
2082
2113
  const source = createComponentInstanceEngineDataSource({
2083
2114
  client,
@@ -2085,7 +2116,8 @@ var CompositionPublishModule = {
2085
2116
  compositionIDs: compositionIDsArray,
2086
2117
  onlyCompositions,
2087
2118
  onlyPatterns,
2088
- patternType
2119
+ patternType,
2120
+ verbose
2089
2121
  });
2090
2122
  const target = createComponentInstanceEngineDataSource({
2091
2123
  client,
@@ -2093,7 +2125,8 @@ var CompositionPublishModule = {
2093
2125
  compositionIDs: compositionIDsArray,
2094
2126
  onlyCompositions,
2095
2127
  onlyPatterns,
2096
- patternType
2128
+ patternType,
2129
+ verbose
2097
2130
  });
2098
2131
  await syncEngine({
2099
2132
  source,
@@ -2101,6 +2134,7 @@ var CompositionPublishModule = {
2101
2134
  // Publishing is one-direction operation, so no need to support automatic un-publishing
2102
2135
  mode: "createOrUpdate",
2103
2136
  whatIf,
2137
+ verbose,
2104
2138
  log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
2105
2139
  });
2106
2140
  }
@@ -2162,37 +2196,34 @@ var CompositionPullModule = {
2162
2196
  withApiOptions(
2163
2197
  withProjectOptions(
2164
2198
  withStateOptions(
2165
- withDiffOptions(
2166
- yargs36.positional("directory", {
2167
- describe: "Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2168
- type: "string"
2169
- }).option("format", {
2170
- alias: ["f"],
2171
- describe: "Output format",
2172
- default: "yaml",
2173
- choices: ["yaml", "json"],
2174
- type: "string"
2175
- }).option("onlyCompositions", {
2176
- describe: "Only pulling compositions and not patterns",
2177
- default: false,
2178
- type: "boolean"
2179
- }).option("onlyPatterns", {
2180
- describe: "Only pulling patterns and not compositions",
2181
- default: false,
2182
- type: "boolean",
2183
- hidden: true
2184
- }).option("what-if", {
2185
- alias: ["w"],
2186
- describe: "What-if mode reports what would be done but changes no files",
2187
- default: false,
2188
- type: "boolean"
2189
- }).option("mode", {
2190
- alias: ["m"],
2191
- describe: 'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',
2192
- choices: ["create", "createOrUpdate", "mirror"],
2193
- default: "mirror",
2194
- type: "string"
2195
- })
2199
+ withDebugOptions(
2200
+ withDiffOptions(
2201
+ yargs36.positional("directory", {
2202
+ describe: "Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2203
+ type: "string"
2204
+ }).option("format", {
2205
+ alias: ["f"],
2206
+ describe: "Output format",
2207
+ default: "yaml",
2208
+ choices: ["yaml", "json"],
2209
+ type: "string"
2210
+ }).option("onlyCompositions", {
2211
+ describe: "Only pulling compositions and not patterns",
2212
+ default: false,
2213
+ type: "boolean"
2214
+ }).option("onlyPatterns", {
2215
+ describe: "Only pulling patterns and not compositions",
2216
+ default: false,
2217
+ type: "boolean",
2218
+ hidden: true
2219
+ }).option("mode", {
2220
+ alias: ["m"],
2221
+ describe: 'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',
2222
+ choices: ["create", "createOrUpdate", "mirror"],
2223
+ default: "mirror",
2224
+ type: "string"
2225
+ })
2226
+ )
2196
2227
  )
2197
2228
  )
2198
2229
  )
@@ -2212,9 +2243,10 @@ var CompositionPullModule = {
2212
2243
  state,
2213
2244
  project: projectId,
2214
2245
  diff: diffMode,
2215
- allowEmptySource
2246
+ allowEmptySource,
2247
+ verbose
2216
2248
  }) => {
2217
- const fetch3 = nodeFetchProxy(proxy);
2249
+ const fetch3 = nodeFetchProxy(proxy, verbose);
2218
2250
  const client = new UncachedCanvasClient10({ apiKey, apiHost, fetch: fetch3, projectId });
2219
2251
  const fileClient = new UncachedFileClient3({ apiKey, apiHost, fetch: fetch3, projectId });
2220
2252
  const source = createComponentInstanceEngineDataSource({
@@ -2222,7 +2254,8 @@ var CompositionPullModule = {
2222
2254
  state,
2223
2255
  onlyCompositions,
2224
2256
  onlyPatterns,
2225
- patternType
2257
+ patternType,
2258
+ verbose
2226
2259
  });
2227
2260
  const isPackage = isPathAPackageFile(directory);
2228
2261
  let target;
@@ -2326,31 +2359,28 @@ var CompositionPushModule = {
2326
2359
  withApiOptions(
2327
2360
  withProjectOptions(
2328
2361
  withStateOptions(
2329
- withDiffOptions(
2330
- yargs36.positional("directory", {
2331
- describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
2332
- type: "string"
2333
- }).option("what-if", {
2334
- alias: ["w"],
2335
- describe: "What-if mode reports what would be done but changes nothing",
2336
- default: false,
2337
- type: "boolean"
2338
- }).option("mode", {
2339
- alias: ["m"],
2340
- describe: 'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',
2341
- choices: ["create", "createOrUpdate", "mirror"],
2342
- default: "mirror",
2343
- type: "string"
2344
- }).option("onlyCompositions", {
2345
- describe: "Only pulling compositions and not patterns",
2346
- default: false,
2347
- type: "boolean"
2348
- }).option("onlyPatterns", {
2349
- describe: "Only pulling patterns and not compositions",
2350
- default: false,
2351
- type: "boolean",
2352
- hidden: true
2353
- })
2362
+ withDebugOptions(
2363
+ withDiffOptions(
2364
+ yargs36.positional("directory", {
2365
+ describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
2366
+ type: "string"
2367
+ }).option("mode", {
2368
+ alias: ["m"],
2369
+ describe: 'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',
2370
+ choices: ["create", "createOrUpdate", "mirror"],
2371
+ default: "mirror",
2372
+ type: "string"
2373
+ }).option("onlyCompositions", {
2374
+ describe: "Only pulling compositions and not patterns",
2375
+ default: false,
2376
+ type: "boolean"
2377
+ }).option("onlyPatterns", {
2378
+ describe: "Only pulling patterns and not compositions",
2379
+ default: false,
2380
+ type: "boolean",
2381
+ hidden: true
2382
+ })
2383
+ )
2354
2384
  )
2355
2385
  )
2356
2386
  )
@@ -2369,9 +2399,10 @@ var CompositionPushModule = {
2369
2399
  onlyPatterns,
2370
2400
  patternType,
2371
2401
  diff: diffMode,
2372
- allowEmptySource
2402
+ allowEmptySource,
2403
+ verbose
2373
2404
  }) => {
2374
- const fetch3 = nodeFetchProxy(proxy);
2405
+ const fetch3 = nodeFetchProxy(proxy, verbose);
2375
2406
  const client = new UncachedCanvasClient11({ apiKey, apiHost, fetch: fetch3, projectId });
2376
2407
  let source;
2377
2408
  const isPackage = isPathAPackageFile(directory);
@@ -2395,7 +2426,8 @@ var CompositionPushModule = {
2395
2426
  state,
2396
2427
  onlyCompositions,
2397
2428
  onlyPatterns,
2398
- patternType
2429
+ patternType,
2430
+ verbose
2399
2431
  });
2400
2432
  const fileClient = new UncachedFileClient4({ apiKey, apiHost, fetch: fetch3, projectId });
2401
2433
  await syncEngine({
@@ -2403,6 +2435,7 @@ var CompositionPushModule = {
2403
2435
  target,
2404
2436
  mode,
2405
2437
  whatIf,
2438
+ verbose,
2406
2439
  allowEmptySource,
2407
2440
  log: createSyncEngineConsoleLogger({ diffMode }),
2408
2441
  onBeforeCompareObjects: async (sourceObject) => {
@@ -2469,13 +2502,21 @@ var CompositionRemoveModule = {
2469
2502
  describe: "Delete a composition",
2470
2503
  builder: (yargs36) => withConfiguration(
2471
2504
  withApiOptions(
2472
- withProjectOptions(
2473
- yargs36.positional("id", { demandOption: true, describe: "Composition/pattern public ID to delete" })
2505
+ withDebugOptions(
2506
+ withProjectOptions(
2507
+ yargs36.positional("id", {
2508
+ demandOption: true,
2509
+ describe: "Composition/pattern public ID to delete"
2510
+ })
2511
+ )
2474
2512
  )
2475
2513
  )
2476
2514
  ),
2477
- handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
2478
- const fetch3 = nodeFetchProxy(proxy);
2515
+ handler: async ({ apiHost, apiKey, proxy, id, project: projectId, verbose }) => {
2516
+ if (verbose) {
2517
+ console.log(`\u{1F41B} remove composition: (id: ${id})`);
2518
+ }
2519
+ const fetch3 = nodeFetchProxy(proxy, verbose);
2479
2520
  const client = new UncachedCanvasClient12({ apiKey, apiHost, fetch: fetch3, projectId });
2480
2521
  await client.removeComposition({ compositionId: id });
2481
2522
  }
@@ -2498,30 +2539,27 @@ var CompositionUnpublishModule = {
2498
2539
  describe: "Unpublish a composition(s)",
2499
2540
  builder: (yargs36) => withConfiguration(
2500
2541
  withApiOptions(
2501
- withProjectOptions(
2502
- yargs36.positional("ids", {
2503
- describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
2504
- type: "string"
2505
- }).option("all", {
2506
- alias: ["a"],
2507
- describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
2508
- default: false,
2509
- type: "boolean"
2510
- }).option("what-if", {
2511
- alias: ["w"],
2512
- describe: "What-if mode reports what would be done but does not perform any publishing",
2513
- default: false,
2514
- type: "boolean"
2515
- }).option("onlyCompositions", {
2516
- describe: "Only publishing compositions and not patterns",
2517
- default: false,
2518
- type: "boolean"
2519
- }).option("onlyPatterns", {
2520
- describe: "Only pulling patterns and not compositions",
2521
- default: false,
2522
- type: "boolean",
2523
- hidden: true
2524
- })
2542
+ withDebugOptions(
2543
+ withProjectOptions(
2544
+ yargs36.positional("ids", {
2545
+ describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
2546
+ type: "string"
2547
+ }).option("all", {
2548
+ alias: ["a"],
2549
+ describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
2550
+ default: false,
2551
+ type: "boolean"
2552
+ }).option("onlyCompositions", {
2553
+ describe: "Only publishing compositions and not patterns",
2554
+ default: false,
2555
+ type: "boolean"
2556
+ }).option("onlyPatterns", {
2557
+ describe: "Only pulling patterns and not compositions",
2558
+ default: false,
2559
+ type: "boolean",
2560
+ hidden: true
2561
+ })
2562
+ )
2525
2563
  )
2526
2564
  )
2527
2565
  ),
@@ -2535,7 +2573,8 @@ var CompositionUnpublishModule = {
2535
2573
  onlyPatterns,
2536
2574
  patternType,
2537
2575
  project: projectId,
2538
- whatIf
2576
+ whatIf,
2577
+ verbose
2539
2578
  }) => {
2540
2579
  if (!all && !ids || all && ids) {
2541
2580
  console.error(`Specify --all or composition ID(s) to publish.`);
@@ -2543,7 +2582,7 @@ var CompositionUnpublishModule = {
2543
2582
  }
2544
2583
  const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
2545
2584
  const targetItems = /* @__PURE__ */ new Map();
2546
- const fetch3 = nodeFetchProxy(proxy);
2585
+ const fetch3 = nodeFetchProxy(proxy, verbose);
2547
2586
  const client = new UncachedCanvasClient13({ apiKey, apiHost, fetch: fetch3, projectId });
2548
2587
  const source = createComponentInstanceEngineDataSource({
2549
2588
  client,
@@ -2551,7 +2590,8 @@ var CompositionUnpublishModule = {
2551
2590
  compositionIDs: compositionIDsArray,
2552
2591
  onlyCompositions,
2553
2592
  onlyPatterns,
2554
- patternType
2593
+ patternType,
2594
+ verbose
2555
2595
  });
2556
2596
  const target = createComponentInstanceEngineDataSource({
2557
2597
  client,
@@ -2559,7 +2599,8 @@ var CompositionUnpublishModule = {
2559
2599
  compositionIDs: compositionIDsArray,
2560
2600
  onlyCompositions,
2561
2601
  onlyPatterns,
2562
- patternType
2602
+ patternType,
2603
+ verbose
2563
2604
  });
2564
2605
  const actions = [];
2565
2606
  const log = createPublishStatusSyncEngineConsoleLogger({ status: "unpublish" });
@@ -2577,6 +2618,7 @@ var CompositionUnpublishModule = {
2577
2618
  console.log(`Composition ${id} was not found`);
2578
2619
  return;
2579
2620
  }
2621
+ console.log(`\u{1F41B} unpublishing composition: (id: ${id})`);
2580
2622
  actions.push(client.removeComposition({ compositionId: id, state: CANVAS_PUBLISHED_STATE2 }));
2581
2623
  log({
2582
2624
  action: "update",
@@ -2639,14 +2681,22 @@ var CompositionUpdateModule = {
2639
2681
  builder: (yargs36) => withConfiguration(
2640
2682
  withApiOptions(
2641
2683
  withProjectOptions(
2642
- withStateOptions(
2643
- yargs36.positional("filename", { demandOption: true, describe: "Composition/pattern file to put" })
2684
+ withVerboseOption(
2685
+ withStateOptions(
2686
+ yargs36.positional("filename", {
2687
+ demandOption: true,
2688
+ describe: "Composition/pattern file to put"
2689
+ })
2690
+ )
2644
2691
  )
2645
2692
  )
2646
2693
  )
2647
2694
  ),
2648
- handler: async ({ apiHost, apiKey, proxy, filename, project: projectId, state }) => {
2649
- const fetch3 = nodeFetchProxy(proxy);
2695
+ handler: async ({ apiHost, apiKey, proxy, filename, project: projectId, state, verbose }) => {
2696
+ if (verbose) {
2697
+ console.log(`\u{1F41B} update composition: (filename: ${filename}, state: ${convertStateOption(state)})`);
2698
+ }
2699
+ const fetch3 = nodeFetchProxy(proxy, verbose);
2650
2700
  const client = new UncachedCanvasClient14({ apiKey, apiHost, fetch: fetch3, projectId });
2651
2701
  const file = readFileToObject(filename);
2652
2702
  await client.updateComposition({ ...file, state: convertStateOption(state) });
@@ -3730,7 +3780,7 @@ var EntryListModule = {
3730
3780
  import { ContentClient as ContentClient10 } from "@uniformdev/canvas";
3731
3781
 
3732
3782
  // src/commands/canvas/entryEngineDataSource.ts
3733
- import { convertEntryToPutEntry } from "@uniformdev/canvas";
3783
+ import { ApiClientError, convertEntryToPutEntry } from "@uniformdev/canvas";
3734
3784
 
3735
3785
  // src/commands/canvas/commands/entry/_util.ts
3736
3786
  var selectEntryIdentifier = (e) => {
@@ -3761,18 +3811,27 @@ function createEntryEngineDataSource({
3761
3811
  const stateId = convertStateOption(state);
3762
3812
  async function* getObjects() {
3763
3813
  const entries = paginateAsync(
3764
- async (offset, limit) => (await client.getEntries({
3765
- offset,
3766
- limit,
3767
- entryIDs,
3768
- pattern: onlyEntries ? false : onlyPatterns ? true : void 0,
3769
- skipDataResolution: true,
3770
- skipOverridesResolution: true,
3771
- skipPatternResolution: true,
3772
- state: stateId,
3773
- withComponentIDs: true,
3774
- editions: "all"
3775
- })).entries,
3814
+ async (offset, limit) => {
3815
+ try {
3816
+ return (await client.getEntries({
3817
+ offset,
3818
+ limit,
3819
+ entryIDs,
3820
+ pattern: onlyEntries ? false : onlyPatterns ? true : void 0,
3821
+ skipDataResolution: true,
3822
+ skipOverridesResolution: true,
3823
+ skipPatternResolution: true,
3824
+ state: stateId,
3825
+ withComponentIDs: true,
3826
+ editions: "all"
3827
+ })).entries;
3828
+ } catch (error) {
3829
+ if (error instanceof ApiClientError && error.errorMessage === "Entry not found or not published") {
3830
+ return [];
3831
+ }
3832
+ throw error;
3833
+ }
3834
+ },
3776
3835
  { pageSize: 100 }
3777
3836
  );
3778
3837
  for await (const e of entries) {
@@ -6212,7 +6271,7 @@ var EnrichmentModule = {
6212
6271
  import yargs19 from "yargs";
6213
6272
 
6214
6273
  // src/commands/context/commands/manifest/get.ts
6215
- import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
6274
+ import { ApiClientError as ApiClientError2, UncachedManifestClient } from "@uniformdev/context/api";
6216
6275
  import { gray as gray2, green as green2, red as red3 } from "colorette";
6217
6276
  import { writeFile } from "fs";
6218
6277
  import { exit } from "process";
@@ -6263,7 +6322,7 @@ var ManifestGetModule = {
6263
6322
  }
6264
6323
  } catch (e) {
6265
6324
  let message;
6266
- if (e instanceof ApiClientError) {
6325
+ if (e instanceof ApiClientError2) {
6267
6326
  if (e.statusCode === 403) {
6268
6327
  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.`;
6269
6328
  }
@@ -6279,7 +6338,7 @@ var ManifestGetModule = {
6279
6338
  };
6280
6339
 
6281
6340
  // src/commands/context/commands/manifest/publish.ts
6282
- import { ApiClientError as ApiClientError2, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
6341
+ import { ApiClientError as ApiClientError3, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
6283
6342
  import { gray as gray3, red as red4 } from "colorette";
6284
6343
  import { exit as exit2 } from "process";
6285
6344
  var ManifestPublishModule = {
@@ -6298,7 +6357,7 @@ var ManifestPublishModule = {
6298
6357
  await client.publish();
6299
6358
  } catch (e) {
6300
6359
  let message;
6301
- if (e instanceof ApiClientError2) {
6360
+ if (e instanceof ApiClientError3) {
6302
6361
  if (e.statusCode === 403) {
6303
6362
  message = `The API key ${apiKey} did not have permissions to publish the manifest. Ensure Uniform Context > Manifest > Publish permissions are granted.`;
6304
6363
  }
@@ -7504,7 +7563,7 @@ import { PostHog } from "posthog-node";
7504
7563
  // package.json
7505
7564
  var package_default = {
7506
7565
  name: "@uniformdev/cli",
7507
- version: "19.191.0",
7566
+ version: "19.191.1",
7508
7567
  description: "Uniform command line interface tool",
7509
7568
  license: "SEE LICENSE IN LICENSE.txt",
7510
7569
  main: "./cli.js",
@@ -9700,13 +9759,15 @@ var SyncPullModule = {
9700
9759
  builder: (yargs36) => withConfiguration(
9701
9760
  withApiOptions(
9702
9761
  withProjectOptions(
9703
- withDiffOptions(
9704
- yargs36.option("what-if", {
9705
- alias: ["w"],
9706
- describe: "What-if mode reports what would be done but changes no files",
9707
- default: false,
9708
- type: "boolean"
9709
- })
9762
+ withDebugOptions(
9763
+ withDiffOptions(
9764
+ yargs36.option("what-if", {
9765
+ alias: ["w"],
9766
+ describe: "What-if mode reports what would be done but changes no files",
9767
+ default: false,
9768
+ type: "boolean"
9769
+ })
9770
+ )
9710
9771
  )
9711
9772
  )
9712
9773
  )
@@ -9807,20 +9868,7 @@ var getFormat = (entityType, config2) => {
9807
9868
  var SyncPushModule = {
9808
9869
  command: "push",
9809
9870
  describe: "Pushes whole project data from files in a directory or package to Uniform",
9810
- builder: (yargs36) => withConfiguration(
9811
- withApiOptions(
9812
- withProjectOptions(
9813
- withDiffOptions(
9814
- yargs36.option("what-if", {
9815
- alias: ["w"],
9816
- describe: "What-if mode reports what would be done but changes nothing",
9817
- default: false,
9818
- type: "boolean"
9819
- })
9820
- )
9821
- )
9822
- )
9823
- ),
9871
+ builder: (yargs36) => withConfiguration(withApiOptions(withProjectOptions(withDiffOptions(withDebugOptions(yargs36))))),
9824
9872
  handler: async ({ serialization, ...otherParams }) => {
9825
9873
  const config2 = serialization;
9826
9874
  const enabledEntities = Object.entries({
@@ -10065,7 +10113,7 @@ var getMostRecent = async ({ full, scope }, distTag, timeout) => {
10065
10113
  var defaultConfig = {
10066
10114
  interval: 36e5,
10067
10115
  distTag: "latest",
10068
- timeout: 2e3
10116
+ timeout: 5e3
10069
10117
  };
10070
10118
  var getDetails = (name) => {
10071
10119
  const spec = {
@@ -10096,6 +10144,13 @@ async function updateCheck_default(pkg, config2 = {}) {
10096
10144
  ({ shouldCheck, latest } = await evaluateCache(file, time, interval));
10097
10145
  if (shouldCheck) {
10098
10146
  latest = await getMostRecent(details, distTag, timeout);
10147
+ if (config2.verbose) {
10148
+ console.log("CLI package latest version check", {
10149
+ latest,
10150
+ current: pkg.version,
10151
+ tempFileWithLastUpdateCheck: file
10152
+ });
10153
+ }
10099
10154
  await updateCache(file, latest, time);
10100
10155
  }
10101
10156
  const comparision = compareVersions(pkg.version, latest);
@@ -10109,19 +10164,19 @@ async function updateCheck_default(pkg, config2 = {}) {
10109
10164
  }
10110
10165
 
10111
10166
  // src/middleware/checkForUpdateMiddleware.ts
10112
- async function checkForUpdateMiddleware() {
10167
+ var checkForUpdateMiddleware = async ({ verbose }) => {
10113
10168
  try {
10114
10169
  if (process.env.NO_UPDATE_CHECK || process.env.CI) {
10115
10170
  return;
10116
10171
  }
10117
- const update = await updateCheck_default(package_default);
10172
+ const update = await updateCheck_default(package_default, { verbose });
10118
10173
  if (update) {
10119
10174
  logCallout(`${bold("Update Available:")} ${gray5(package_default.version)} \u226B ${green4(update.latest)}`);
10120
10175
  }
10121
10176
  } catch (e) {
10122
10177
  console.error(`There was an error checking for updates`, e);
10123
10178
  }
10124
- }
10179
+ };
10125
10180
 
10126
10181
  // src/middleware/checkLocalDepsVersionsMiddleware.ts
10127
10182
  import { magenta, red as red6 } from "colorette";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.191.0",
3
+ "version": "19.191.2-alpha.10+b6b6304391",
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.191.0",
31
- "@uniformdev/canvas": "19.191.0",
32
- "@uniformdev/context": "19.191.0",
33
- "@uniformdev/files": "19.191.0",
34
- "@uniformdev/project-map": "19.191.0",
35
- "@uniformdev/redirect": "19.191.0",
30
+ "@uniformdev/assets": "19.191.2-alpha.10+b6b6304391",
31
+ "@uniformdev/canvas": "19.191.2-alpha.10+b6b6304391",
32
+ "@uniformdev/context": "19.191.2-alpha.10+b6b6304391",
33
+ "@uniformdev/files": "19.191.2-alpha.10+b6b6304391",
34
+ "@uniformdev/project-map": "19.191.2-alpha.10+b6b6304391",
35
+ "@uniformdev/redirect": "19.191.2-alpha.10+b6b6304391",
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": "5af19bc55804e29fda14eb6f0b4b7bd90be0610f"
81
+ "gitHead": "b6b6304391ba3bcf3032d6e137af9f1e5bf55819"
82
82
  }