@uniformdev/cli 18.18.1-alpha.12 → 18.19.1-alpha.7

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.
package/dist/index.mjs CHANGED
@@ -1,31 +1,35 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- __privateAdd,
4
- __privateGet,
5
- __privateSet,
6
- __privateWrapper,
7
- __require,
8
- __toESM,
9
- createArraySyncEngineDataSource,
10
- createFileSyncEngineDataSource,
11
- createSyncEngineConsoleLogger,
12
- emitWithFormat,
13
- isPathAPackageFile,
14
- nodeFetchProxy,
15
- paginateAsync,
16
- readFileToObject,
17
- readUniformPackage,
18
- require_source,
19
- syncEngine,
20
- withApiOptions,
21
- withDiffOptions,
22
- withFormatOptions,
23
- withProjectOptions,
24
- writeUniformPackage
25
- } from "./chunk-NNLVNLDW.mjs";
2
+ var __accessCheck = (obj, member, msg) => {
3
+ if (!member.has(obj))
4
+ throw TypeError("Cannot " + msg);
5
+ };
6
+ var __privateGet = (obj, member, getter) => {
7
+ __accessCheck(obj, member, "read from private field");
8
+ return getter ? getter.call(obj) : member.get(obj);
9
+ };
10
+ var __privateAdd = (obj, member, value) => {
11
+ if (member.has(obj))
12
+ throw TypeError("Cannot add the same private member more than once");
13
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
14
+ };
15
+ var __privateSet = (obj, member, value, setter) => {
16
+ __accessCheck(obj, member, "write to private field");
17
+ setter ? setter.call(obj, value) : member.set(obj, value);
18
+ return value;
19
+ };
20
+ var __privateWrapper = (obj, member, setter, getter) => ({
21
+ set _(value) {
22
+ __privateSet(obj, member, value, setter);
23
+ },
24
+ get _() {
25
+ return __privateGet(obj, member, getter);
26
+ }
27
+ });
26
28
 
27
29
  // src/index.ts
30
+ import * as dotenv from "dotenv";
28
31
  import yargs17 from "yargs";
32
+ import { hideBin } from "yargs/helpers";
29
33
 
30
34
  // src/commands/canvas/index.ts
31
35
  import yargs4 from "yargs";
@@ -35,6 +39,408 @@ import yargs from "yargs";
35
39
 
36
40
  // src/commands/canvas/commands/component/get.ts
37
41
  import { UncachedCanvasClient } from "@uniformdev/canvas";
42
+
43
+ // src/sync/arraySyncEngineDataSource.ts
44
+ async function createArraySyncEngineDataSource({
45
+ objects,
46
+ selectIdentifier: selectIdentifier11,
47
+ selectDisplayName: selectDisplayName11 = selectIdentifier11,
48
+ onSyncComplete
49
+ }) {
50
+ const objectIndex = objects.reduce((result, current) => {
51
+ const identifier = selectIdentifier11(current);
52
+ if (result[identifier]) {
53
+ throw new Error(`Identifier ${identifier} was not unique.`);
54
+ }
55
+ result[identifier] = {
56
+ id: identifier,
57
+ object: current,
58
+ providerId: identifier,
59
+ displayName: selectDisplayName11(current)
60
+ };
61
+ return result;
62
+ }, {});
63
+ async function* getObjects() {
64
+ for (const item of Object.values(objectIndex)) {
65
+ yield item;
66
+ }
67
+ }
68
+ function extractCurrent() {
69
+ return Object.entries(objectIndex).sort((a, b) => a[0].localeCompare(b[0])).map((entry) => entry[1].object);
70
+ }
71
+ return {
72
+ objects: getObjects(),
73
+ deleteObject: async (providerId) => {
74
+ delete objectIndex[providerId];
75
+ },
76
+ writeObject: async (objectToWrite) => {
77
+ const id = selectIdentifier11(objectToWrite.object);
78
+ objectIndex[id] = objectToWrite;
79
+ },
80
+ extractCurrent,
81
+ onSyncComplete: onSyncComplete ? (isTarget) => onSyncComplete(isTarget, extractCurrent()) : void 0
82
+ };
83
+ }
84
+
85
+ // src/sync/fileSyncEngineDataSource.ts
86
+ import chalk from "chalk";
87
+ import { existsSync, mkdirSync } from "fs";
88
+ import { readdir, unlink } from "fs/promises";
89
+ import { extname as extname2, join } from "path";
90
+
91
+ // src/sync/util.ts
92
+ import { readFileSync, writeFileSync } from "fs";
93
+ import httpsProxyAgent from "https-proxy-agent";
94
+ import unfetch from "isomorphic-unfetch";
95
+ import { dump, load } from "js-yaml";
96
+ import { extname } from "path";
97
+ function withApiOptions(yargs18) {
98
+ return yargs18.option("apiKey", {
99
+ describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
100
+ default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
101
+ process.env.CANVAS_CLI_API_KEY ?? // deprecated
102
+ process.env.UPM_CLI_API_KEY ?? process.env.UNIFORM_API_KEY,
103
+ demandOption: true,
104
+ type: "string"
105
+ }).option("apiHost", {
106
+ describe: "Uniform host. Defaults to UNIFORM_CLI_BASE_URL env var or https://uniform.app. Supports dotenv.",
107
+ default: process.env.UNIFORM_CLI_BASE_URL || "https://uniform.app",
108
+ demandOption: true,
109
+ type: "string"
110
+ }).option("edgeApiHost", {
111
+ describe: "Uniform edge host. Defaults to UNIFORM_CLI_BASE_EDGE_URL env var or https://uniform.global. Supports dotenv.",
112
+ default: process.env.UNIFORM_CLI_BASE_EDGE_URL || "https://uniform.global",
113
+ demandOption: true,
114
+ type: "string"
115
+ }).option("proxy", {
116
+ describe: "HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",
117
+ default: process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy,
118
+ type: "string"
119
+ });
120
+ }
121
+ function nodeFetchProxy(proxy) {
122
+ if (proxy) {
123
+ console.log(`\u{1F991} Using proxy ${proxy}`);
124
+ }
125
+ const wrappedFetch = (input, init) => {
126
+ if (proxy) {
127
+ const wrappedInit = {
128
+ ...init,
129
+ agent: new httpsProxyAgent.HttpsProxyAgent(proxy)
130
+ };
131
+ return unfetch(input, wrappedInit);
132
+ }
133
+ return unfetch(input, init);
134
+ };
135
+ return wrappedFetch;
136
+ }
137
+ function withProjectOptions(yargs18) {
138
+ return yargs18.option("project", {
139
+ describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
140
+ default: process.env.UNIFORM_CLI_PROJECT_ID ?? // deprecated
141
+ process.env.CANVAS_CLI_PROJECT_ID ?? // deprecated
142
+ process.env.UPM_CLI_PROJECT_ID ?? process.env.UNIFORM_PROJECT_ID,
143
+ demandOption: true,
144
+ type: "string",
145
+ alias: ["p"]
146
+ });
147
+ }
148
+ function withFormatOptions(yargs18) {
149
+ return yargs18.option("format", {
150
+ alias: ["f"],
151
+ describe: "Output format",
152
+ default: "yaml",
153
+ choices: ["yaml", "json"],
154
+ type: "string"
155
+ }).option("filename", {
156
+ alias: ["o"],
157
+ describe: "Output filename. If not specified, write to stdout.",
158
+ type: "string"
159
+ });
160
+ }
161
+ function withDiffOptions(yargs18) {
162
+ return yargs18.option("diff", {
163
+ describe: "Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",
164
+ default: process.env.UNIFORM_CLI_DIFF_MODE ?? "off",
165
+ type: "string",
166
+ choices: ["off", "update", "on"],
167
+ alias: ["d"]
168
+ });
169
+ }
170
+ function isPathAPackageFile(path4) {
171
+ const extension = extname(path4);
172
+ return extension === ".yaml" || extension === ".yml" || extension === ".json";
173
+ }
174
+ function emitWithFormat(object, format, filename) {
175
+ let content;
176
+ if (filename && !format) {
177
+ const extension = extname(filename);
178
+ if (extension === ".yaml" || extension === ".yml") {
179
+ format = "yaml";
180
+ } else if (extension === ".json") {
181
+ format = "json";
182
+ }
183
+ } else if (!format) {
184
+ throw new Error("Format must be specified when no filename is passed");
185
+ }
186
+ switch (format) {
187
+ case "json":
188
+ content = JSON.stringify(object, null, 2);
189
+ break;
190
+ case "yaml":
191
+ content = dump(object);
192
+ break;
193
+ default:
194
+ throw new Error(`Unsupported format: ${format}`);
195
+ }
196
+ if (filename) {
197
+ writeFileSync(filename, content, "utf8");
198
+ } else {
199
+ console.log(content);
200
+ }
201
+ }
202
+ function readFileToObject(filename) {
203
+ const file = readFileSync(filename, "utf8");
204
+ return load(file, { filename, json: true });
205
+ }
206
+ async function* paginateAsync(fetchPage, options) {
207
+ const perPage = options.pageSize || 100;
208
+ let offset = 0;
209
+ let pageData = [];
210
+ do {
211
+ pageData = await fetchPage(offset, perPage);
212
+ for (const item of pageData) {
213
+ yield item;
214
+ }
215
+ offset += perPage;
216
+ } while (pageData.length === perPage);
217
+ }
218
+
219
+ // src/sync/fileSyncEngineDataSource.ts
220
+ async function createFileSyncEngineDataSource({
221
+ directory,
222
+ format = "yaml",
223
+ selectIdentifier: selectIdentifier11,
224
+ selectDisplayName: selectDisplayName11 = selectIdentifier11,
225
+ selectFilename: selectFilename2
226
+ }) {
227
+ const dirExists = existsSync(directory);
228
+ if (!dirExists) {
229
+ mkdirSync(directory, { recursive: true });
230
+ }
231
+ const rawFilenames = await readdir(directory, "utf-8");
232
+ const filenames = new Set(
233
+ rawFilenames.filter((filename) => {
234
+ const ext = extname2(filename);
235
+ return ext === `.json` || ext === `.yaml` || ext === `.yml`;
236
+ })
237
+ );
238
+ const getFullFilename = (id) => join(directory, `${id}.${format}`);
239
+ async function* getObjects() {
240
+ for (const filename of filenames) {
241
+ const fullFilename = join(directory, filename);
242
+ try {
243
+ const contents = await readFileToObject(fullFilename);
244
+ const object = {
245
+ id: selectIdentifier11(contents),
246
+ displayName: selectDisplayName11(contents),
247
+ providerId: fullFilename,
248
+ object: contents
249
+ };
250
+ yield object;
251
+ } catch (e) {
252
+ console.error(chalk.red(`Failed to read ${fullFilename}, data is likely invalid.
253
+ ${e == null ? void 0 : e.message}`));
254
+ throw e;
255
+ }
256
+ }
257
+ }
258
+ return {
259
+ objects: getObjects(),
260
+ deleteObject: async (providerId) => {
261
+ await unlink(providerId);
262
+ },
263
+ writeObject: async (object) => {
264
+ if (selectFilename2) {
265
+ emitWithFormat(object.object, format, join(directory, `${selectFilename2(object.object)}.${format}`));
266
+ } else {
267
+ emitWithFormat(object.object, format, getFullFilename(object.id));
268
+ }
269
+ }
270
+ };
271
+ }
272
+
273
+ // src/sync/package.ts
274
+ import fs from "fs";
275
+ function readUniformPackage(filename, assertExists) {
276
+ if (!assertExists && !fs.existsSync(filename)) {
277
+ return {};
278
+ }
279
+ const packageContents = readFileToObject(filename);
280
+ if (typeof packageContents !== "object") {
281
+ throw new Error(`Package ${filename} does not appear valid.`);
282
+ }
283
+ return packageContents;
284
+ }
285
+ function writeUniformPackage(filename, packageContents) {
286
+ emitWithFormat(packageContents, void 0, filename);
287
+ }
288
+
289
+ // src/sync/syncEngine.ts
290
+ import { diffJson, diffLines } from "diff";
291
+ import isEqualWith from "lodash.isequalwith";
292
+ async function syncEngine({
293
+ source,
294
+ target,
295
+ compareContents = (source2, target2) => {
296
+ return isEqualWith(
297
+ source2.object,
298
+ target2.object,
299
+ (_a, _b, key) => key === "created" || key === "modified" ? true : void 0
300
+ );
301
+ },
302
+ mode,
303
+ allowEmptySource = false,
304
+ whatIf = false,
305
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
306
+ log = () => {
307
+ }
308
+ }) {
309
+ var _a, _b;
310
+ const targetItems = /* @__PURE__ */ new Map();
311
+ for await (const obj of target.objects) {
312
+ targetItems.set(obj.id, obj);
313
+ }
314
+ const actions = [];
315
+ let sourceHasItems = false;
316
+ for await (const sourceObject of source.objects) {
317
+ sourceHasItems = true;
318
+ const id = sourceObject.id;
319
+ const targetObject = targetItems.get(id);
320
+ if (targetObject) {
321
+ if (!compareContents(sourceObject, targetObject)) {
322
+ if (mode === "createOrUpdate" || mode === "mirror") {
323
+ const process2 = async (sourceObject2, targetObject2) => {
324
+ if (!whatIf) {
325
+ try {
326
+ await target.writeObject(sourceObject2, targetObject2);
327
+ } catch (e) {
328
+ throw new SyncEngineError(e, sourceObject2);
329
+ }
330
+ }
331
+ log({
332
+ action: "update",
333
+ id,
334
+ providerId: sourceObject2.providerId,
335
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
336
+ whatIf,
337
+ diff: diffJson(targetObject2.object, sourceObject2.object)
338
+ });
339
+ };
340
+ actions.push(process2(sourceObject, targetObject));
341
+ }
342
+ }
343
+ targetItems.delete(id);
344
+ } else {
345
+ const process2 = async (sourceObject2, id2) => {
346
+ if (!whatIf) {
347
+ try {
348
+ await target.writeObject(sourceObject2);
349
+ } catch (e) {
350
+ throw new SyncEngineError(e, sourceObject2);
351
+ }
352
+ }
353
+ log({
354
+ action: "create",
355
+ id: id2,
356
+ providerId: id2,
357
+ displayName: sourceObject2.displayName ?? sourceObject2.providerId,
358
+ whatIf,
359
+ diff: diffLines("", JSON.stringify(sourceObject2.object, null, 2))
360
+ });
361
+ };
362
+ actions.push(process2(sourceObject, id));
363
+ }
364
+ }
365
+ await Promise.all(actions);
366
+ if (mode === "mirror") {
367
+ if (!sourceHasItems && !allowEmptySource) {
368
+ throw new Error(
369
+ "Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition."
370
+ );
371
+ }
372
+ const deletes = [];
373
+ targetItems.forEach(async (object) => {
374
+ const process2 = async (object2) => {
375
+ if (!whatIf) {
376
+ try {
377
+ await target.deleteObject(object2.providerId, object2);
378
+ } catch (e) {
379
+ throw new SyncEngineError(e, object2);
380
+ }
381
+ }
382
+ log({
383
+ action: "delete",
384
+ id: object2.id,
385
+ providerId: object2.providerId,
386
+ displayName: object2.displayName ?? object2.providerId,
387
+ whatIf,
388
+ diff: diffLines(JSON.stringify(object2.object, null, 2), "")
389
+ });
390
+ };
391
+ deletes.push(process2(object));
392
+ });
393
+ await Promise.all(deletes);
394
+ }
395
+ await Promise.all([(_a = source.onSyncComplete) == null ? void 0 : _a.call(source, false), (_b = target.onSyncComplete) == null ? void 0 : _b.call(target, true)]);
396
+ }
397
+ var SyncEngineError = class extends Error {
398
+ constructor(innerError, sourceObject) {
399
+ super(
400
+ `Error syncing ${sourceObject.displayName ?? sourceObject.providerId} (${sourceObject.providerId})
401
+ ${innerError}`
402
+ );
403
+ this.stack = void 0;
404
+ Object.setPrototypeOf(this, SyncEngineError.prototype);
405
+ }
406
+ };
407
+
408
+ // src/sync/syncEngineConsoleLogger.ts
409
+ import chalk2 from "chalk";
410
+ function createSyncEngineConsoleLogger(options) {
411
+ const { diffMode = "off", indent, prefix } = options ?? {};
412
+ return function syncEngineConsoleLogger({ action, displayName, whatIf, diff }) {
413
+ let actionTag = "";
414
+ switch (action) {
415
+ case "create":
416
+ actionTag = chalk2.green("[A]");
417
+ break;
418
+ case "update":
419
+ actionTag = chalk2.white("[U]");
420
+ break;
421
+ case "delete":
422
+ actionTag = chalk2.yellow("[D]");
423
+ break;
424
+ }
425
+ let diffString = "";
426
+ if (diffMode === "on" || diffMode === "update" && action === "update") {
427
+ diffString = "\n" + diff.map((change) => {
428
+ if (change.added) {
429
+ return chalk2.green(change.value);
430
+ }
431
+ if (change.removed) {
432
+ return chalk2.red(change.value);
433
+ }
434
+ return change.value;
435
+ }).join("");
436
+ }
437
+ console.log(
438
+ `${indent ?? ""}${whatIf ? chalk2.gray("[WHATIF]") : ""}${actionTag}${prefix ?? ""} ${displayName}${diffString}`
439
+ );
440
+ };
441
+ }
442
+
443
+ // src/commands/canvas/commands/component/get.ts
38
444
  var ComponentGetModule = {
39
445
  command: "get <id>",
40
446
  describe: "Fetch a component definition",
@@ -313,7 +719,6 @@ var ComponentPullModule = {
313
719
  project: projectId,
314
720
  diff: diffMode
315
721
  }) => {
316
- var _a;
317
722
  const fetch3 = nodeFetchProxy(proxy);
318
723
  const client = new UncachedCanvasClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
319
724
  const source = createComponentDefinitionEngineDataSource({ client });
@@ -322,7 +727,7 @@ var ComponentPullModule = {
322
727
  if (isPackage) {
323
728
  const packageContents = readCanvasPackage(directory, false);
324
729
  target = await createArraySyncEngineDataSource({
325
- objects: (_a = packageContents.components) != null ? _a : [],
730
+ objects: packageContents.components ?? [],
326
731
  selectIdentifier,
327
732
  selectDisplayName,
328
733
  onSyncComplete: async (_, synced) => {
@@ -384,7 +789,6 @@ var ComponentPushModule = {
384
789
  project: projectId,
385
790
  diff: diffMode
386
791
  }) => {
387
- var _a;
388
792
  const fetch3 = nodeFetchProxy(proxy);
389
793
  const client = new UncachedCanvasClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
390
794
  let source;
@@ -392,7 +796,7 @@ var ComponentPushModule = {
392
796
  if (isPackage) {
393
797
  const packageContents = readCanvasPackage(directory, true);
394
798
  source = await createArraySyncEngineDataSource({
395
- objects: (_a = packageContents.components) != null ? _a : [],
799
+ objects: packageContents.components ?? [],
396
800
  selectIdentifier,
397
801
  selectDisplayName
398
802
  });
@@ -549,6 +953,10 @@ var CompositionListModule = {
549
953
  default: false,
550
954
  describe: "Resolve pattern references in the composition"
551
955
  },
956
+ resolveOverrides: {
957
+ type: "boolean",
958
+ default: false
959
+ },
552
960
  componentIDs: {
553
961
  type: "boolean",
554
962
  default: false,
@@ -570,6 +978,7 @@ var CompositionListModule = {
570
978
  project: projectId,
571
979
  state,
572
980
  resolvePatterns,
981
+ resolveOverrides,
573
982
  componentIDs
574
983
  }) => {
575
984
  const fetch3 = nodeFetchProxy(proxy);
@@ -579,7 +988,8 @@ var CompositionListModule = {
579
988
  offset,
580
989
  state: convertCompositionState(state),
581
990
  skipPatternResolution: !resolvePatterns,
582
- withComponentIDs: componentIDs
991
+ withComponentIDs: componentIDs,
992
+ skipParameterResolution: !resolveOverrides
583
993
  });
584
994
  emitWithFormat(res.compositions, format, filename);
585
995
  }
@@ -590,10 +1000,7 @@ import { UncachedCanvasClient as UncachedCanvasClient9 } from "@uniformdev/canva
590
1000
 
591
1001
  // src/commands/canvas/commands/composition/_util.ts
592
1002
  var selectIdentifier2 = (component) => component.composition._id;
593
- var selectDisplayName2 = (component) => {
594
- var _a, _b;
595
- return `${(_b = (_a = component.composition._name) != null ? _a : component.composition._slug) != null ? _b : component.composition._id} (pid: ${component.composition._id})`;
596
- };
1003
+ var selectDisplayName2 = (component) => `${component.composition._name ?? component.composition._slug ?? component.composition._id} (pid: ${component.composition._id})`;
597
1004
 
598
1005
  // src/commands/canvas/componentInstanceEngineDataSource.ts
599
1006
  function createComponentInstanceEngineDataSource({
@@ -611,6 +1018,7 @@ function createComponentInstanceEngineDataSource({
611
1018
  state: stateId,
612
1019
  skipPatternResolution: true,
613
1020
  skipParameterResolution: true,
1021
+ skipOverridesResolution: true,
614
1022
  withComponentIDs: true
615
1023
  })).compositions,
616
1024
  { pageSize: 100 }
@@ -743,7 +1151,6 @@ var CompositionPullModule = {
743
1151
  project: projectId,
744
1152
  diff: diffMode
745
1153
  }) => {
746
- var _a;
747
1154
  const fetch3 = nodeFetchProxy(proxy);
748
1155
  const client = new UncachedCanvasClient10({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
749
1156
  const source = createComponentInstanceEngineDataSource({ client, state });
@@ -752,7 +1159,7 @@ var CompositionPullModule = {
752
1159
  if (isPackage) {
753
1160
  const packageContents = readCanvasPackage(directory, false);
754
1161
  target = await createArraySyncEngineDataSource({
755
- objects: (_a = packageContents == null ? void 0 : packageContents.compositions) != null ? _a : [],
1162
+ objects: (packageContents == null ? void 0 : packageContents.compositions) ?? [],
756
1163
  selectIdentifier: selectIdentifier2,
757
1164
  selectDisplayName: selectDisplayName2,
758
1165
  onSyncComplete: async (_, synced) => {
@@ -817,7 +1224,6 @@ var CompositionPushModule = {
817
1224
  project: projectId,
818
1225
  diff: diffMode
819
1226
  }) => {
820
- var _a;
821
1227
  const fetch3 = nodeFetchProxy(proxy);
822
1228
  const client = new UncachedCanvasClient11({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
823
1229
  let source;
@@ -825,7 +1231,7 @@ var CompositionPushModule = {
825
1231
  if (isPackage) {
826
1232
  const packageContents = readCanvasPackage(directory, true);
827
1233
  source = await createArraySyncEngineDataSource({
828
- objects: (_a = packageContents.compositions) != null ? _a : [],
1234
+ objects: packageContents.compositions ?? [],
829
1235
  selectIdentifier: selectIdentifier2,
830
1236
  selectDisplayName: selectDisplayName2
831
1237
  });
@@ -926,6 +1332,7 @@ var DataTypeGetModule = {
926
1332
  builder: (yargs18) => withFormatOptions(
927
1333
  withApiOptions(
928
1334
  withProjectOptions(
1335
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
929
1336
  yargs18.positional("id", { demandOption: true, describe: "Data type public ID to fetch" })
930
1337
  )
931
1338
  )
@@ -1035,7 +1442,6 @@ var DataTypePullModule = {
1035
1442
  project: projectId,
1036
1443
  diff: diffMode
1037
1444
  }) => {
1038
- var _a;
1039
1445
  const fetch3 = nodeFetchProxy(proxy);
1040
1446
  const client = new DataTypeClient3({
1041
1447
  apiKey,
@@ -1051,7 +1457,7 @@ var DataTypePullModule = {
1051
1457
  if (isPackage) {
1052
1458
  const packageContents = readCanvasPackage(directory, false);
1053
1459
  target = await createArraySyncEngineDataSource({
1054
- objects: (_a = packageContents.dataTypes) != null ? _a : [],
1460
+ objects: packageContents.dataTypes ?? [],
1055
1461
  selectIdentifier: selectIdentifier3,
1056
1462
  selectDisplayName: selectDisplayName3,
1057
1463
  onSyncComplete: async (_, synced) => {
@@ -1113,7 +1519,6 @@ var DataTypePushModule = {
1113
1519
  project: projectId,
1114
1520
  diff: diffMode
1115
1521
  }) => {
1116
- var _a;
1117
1522
  const fetch3 = nodeFetchProxy(proxy);
1118
1523
  const client = new DataTypeClient4({
1119
1524
  apiKey,
@@ -1128,7 +1533,7 @@ var DataTypePushModule = {
1128
1533
  if (isPackage) {
1129
1534
  const packageContents = readCanvasPackage(directory, true);
1130
1535
  source = await createArraySyncEngineDataSource({
1131
- objects: (_a = packageContents.dataTypes) != null ? _a : [],
1536
+ objects: packageContents.dataTypes ?? [],
1132
1537
  selectIdentifier: selectIdentifier3,
1133
1538
  selectDisplayName: selectDisplayName3
1134
1539
  });
@@ -1353,7 +1758,6 @@ var AggregatePullModule = {
1353
1758
  project: projectId,
1354
1759
  diff: diffMode
1355
1760
  }) => {
1356
- var _a;
1357
1761
  const fetch3 = nodeFetchProxy(proxy);
1358
1762
  const client = new UncachedAggregateClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
1359
1763
  const source = createAggregateEngineDataSource({ client });
@@ -1362,7 +1766,7 @@ var AggregatePullModule = {
1362
1766
  if (isPackage) {
1363
1767
  const packageContents = readContextPackage(directory, false);
1364
1768
  target = await createArraySyncEngineDataSource({
1365
- objects: (_a = packageContents.aggregates) != null ? _a : [],
1769
+ objects: packageContents.aggregates ?? [],
1366
1770
  selectIdentifier: selectIdentifier4,
1367
1771
  selectDisplayName: selectDisplayName4,
1368
1772
  onSyncComplete: async (_, synced) => {
@@ -1424,7 +1828,6 @@ var AggregatePushModule = {
1424
1828
  project: projectId,
1425
1829
  diff: diffMode
1426
1830
  }) => {
1427
- var _a;
1428
1831
  const fetch3 = nodeFetchProxy(proxy);
1429
1832
  const client = new UncachedAggregateClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
1430
1833
  let source;
@@ -1432,7 +1835,7 @@ var AggregatePushModule = {
1432
1835
  if (isPackage) {
1433
1836
  const packageContents = readContextPackage(directory, true);
1434
1837
  source = await createArraySyncEngineDataSource({
1435
- objects: (_a = packageContents.aggregates) != null ? _a : [],
1838
+ objects: packageContents.aggregates ?? [],
1436
1839
  selectIdentifier: selectIdentifier4,
1437
1840
  selectDisplayName: selectDisplayName4
1438
1841
  });
@@ -1576,7 +1979,7 @@ function createEnrichmentEngineDataSource({
1576
1979
  await client.removeCategory({ enrichmentId: providerId });
1577
1980
  },
1578
1981
  writeObject: async (object, existingObject) => {
1579
- var _a, _b;
1982
+ var _a;
1580
1983
  await client.upsertCategory({
1581
1984
  enrichment: object.object
1582
1985
  });
@@ -1586,7 +1989,7 @@ function createEnrichmentEngineDataSource({
1586
1989
  });
1587
1990
  const target = createEnrichmentValueEngineDataSource({
1588
1991
  categoryId: object.id,
1589
- values: (_b = (_a = existingObject == null ? void 0 : existingObject.object) == null ? void 0 : _a.values) != null ? _b : [],
1992
+ values: ((_a = existingObject == null ? void 0 : existingObject.object) == null ? void 0 : _a.values) ?? [],
1590
1993
  client
1591
1994
  });
1592
1995
  await syncEngine({
@@ -1677,7 +2080,6 @@ var EnrichmentPullModule = {
1677
2080
  project: projectId,
1678
2081
  diff: diffMode
1679
2082
  }) => {
1680
- var _a;
1681
2083
  const fetch3 = nodeFetchProxy(proxy);
1682
2084
  const client = new UncachedEnrichmentClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
1683
2085
  const source = createEnrichmentEngineDataSource({ client });
@@ -1686,7 +2088,7 @@ var EnrichmentPullModule = {
1686
2088
  if (isPackage) {
1687
2089
  const packageContents = readContextPackage(directory, false);
1688
2090
  target = await createArraySyncEngineDataSource({
1689
- objects: (_a = packageContents.enrichments) != null ? _a : [],
2091
+ objects: packageContents.enrichments ?? [],
1690
2092
  selectIdentifier: selectIdentifier5,
1691
2093
  selectDisplayName: selectDisplayName5,
1692
2094
  onSyncComplete: async (_, synced) => {
@@ -1748,7 +2150,6 @@ var EnrichmentPushModule = {
1748
2150
  project: projectId,
1749
2151
  diff: diffMode
1750
2152
  }) => {
1751
- var _a;
1752
2153
  const fetch3 = nodeFetchProxy(proxy);
1753
2154
  const client = new UncachedEnrichmentClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
1754
2155
  let source;
@@ -1756,7 +2157,7 @@ var EnrichmentPushModule = {
1756
2157
  if (isPackage) {
1757
2158
  const packageContents = readContextPackage(directory, true);
1758
2159
  source = await createArraySyncEngineDataSource({
1759
- objects: (_a = packageContents.enrichments) != null ? _a : [],
2160
+ objects: packageContents.enrichments ?? [],
1760
2161
  selectIdentifier: selectIdentifier5,
1761
2162
  selectDisplayName: selectDisplayName5
1762
2163
  });
@@ -1811,8 +2212,8 @@ var EnrichmentModule = {
1811
2212
  import yargs7 from "yargs";
1812
2213
 
1813
2214
  // src/commands/context/commands/manifest/get.ts
1814
- var import_chalk = __toESM(require_source());
1815
2215
  import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
2216
+ import chalk3 from "chalk";
1816
2217
  import { writeFile } from "fs";
1817
2218
  import { exit } from "process";
1818
2219
  var ManifestGetModule = {
@@ -1853,7 +2254,7 @@ var ManifestGetModule = {
1853
2254
  `, error);
1854
2255
  exit(1);
1855
2256
  }
1856
- console.log(import_chalk.default.green(`\u2705 ${output} has been updated from ${apiHost}`));
2257
+ console.log(chalk3.green(`\u2705 ${output} has been updated from ${apiHost}`));
1857
2258
  });
1858
2259
  } else {
1859
2260
  console.log(text);
@@ -1868,16 +2269,16 @@ var ManifestGetModule = {
1868
2269
  } else {
1869
2270
  message = e.toString();
1870
2271
  }
1871
- console.error(import_chalk.default.red(`\u26A0 Error fetching Context manifest`));
1872
- console.error(import_chalk.default.gray(` \u2757 ${message}`));
2272
+ console.error(chalk3.red(`\u26A0 Error fetching Context manifest`));
2273
+ console.error(chalk3.gray(` \u2757 ${message}`));
1873
2274
  exit(1);
1874
2275
  }
1875
2276
  }
1876
2277
  };
1877
2278
 
1878
2279
  // src/commands/context/commands/manifest/publish.ts
1879
- var import_chalk2 = __toESM(require_source());
1880
2280
  import { ApiClientError as ApiClientError2, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
2281
+ import chalk4 from "chalk";
1881
2282
  import { exit as exit2 } from "process";
1882
2283
  var ManifestPublishModule = {
1883
2284
  command: "publish",
@@ -1903,8 +2304,8 @@ var ManifestPublishModule = {
1903
2304
  } else {
1904
2305
  message = e.toString();
1905
2306
  }
1906
- console.error(import_chalk2.default.red(`\u26A0 Error publishing Context manifest`));
1907
- console.error(import_chalk2.default.gray(` \u2757 ${message}`));
2307
+ console.error(chalk4.red(`\u26A0 Error publishing Context manifest`));
2308
+ console.error(chalk4.gray(` \u2757 ${message}`));
1908
2309
  exit2(1);
1909
2310
  }
1910
2311
  }
@@ -2052,7 +2453,6 @@ var QuirkPullModule = {
2052
2453
  project: projectId,
2053
2454
  diff: diffMode
2054
2455
  }) => {
2055
- var _a;
2056
2456
  const fetch3 = nodeFetchProxy(proxy);
2057
2457
  const client = new UncachedQuirkClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
2058
2458
  const source = createQuirkEngineDataSource({ client });
@@ -2061,7 +2461,7 @@ var QuirkPullModule = {
2061
2461
  if (isPackage) {
2062
2462
  const packageContents = readContextPackage(directory, false);
2063
2463
  target = await createArraySyncEngineDataSource({
2064
- objects: (_a = packageContents.quirks) != null ? _a : [],
2464
+ objects: packageContents.quirks ?? [],
2065
2465
  selectIdentifier: selectIdentifier6,
2066
2466
  selectDisplayName: selectDisplayName6,
2067
2467
  onSyncComplete: async (_, synced) => {
@@ -2123,7 +2523,6 @@ var QuirkPushModule = {
2123
2523
  project: projectId,
2124
2524
  diff: diffMode
2125
2525
  }) => {
2126
- var _a;
2127
2526
  const fetch3 = nodeFetchProxy(proxy);
2128
2527
  const client = new UncachedQuirkClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
2129
2528
  let source;
@@ -2131,7 +2530,7 @@ var QuirkPushModule = {
2131
2530
  if (isPackage) {
2132
2531
  const packageContents = readContextPackage(directory, true);
2133
2532
  source = await createArraySyncEngineDataSource({
2134
- objects: (_a = packageContents.quirks) != null ? _a : [],
2533
+ objects: packageContents.quirks ?? [],
2135
2534
  selectIdentifier: selectIdentifier6,
2136
2535
  selectDisplayName: selectDisplayName6
2137
2536
  });
@@ -2320,7 +2719,6 @@ var SignalPullModule = {
2320
2719
  project: projectId,
2321
2720
  diff: diffMode
2322
2721
  }) => {
2323
- var _a;
2324
2722
  const fetch3 = nodeFetchProxy(proxy);
2325
2723
  const client = new UncachedSignalClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
2326
2724
  const source = createSignalEngineDataSource({ client });
@@ -2329,7 +2727,7 @@ var SignalPullModule = {
2329
2727
  if (isPackage) {
2330
2728
  const packageContents = readContextPackage(directory, false);
2331
2729
  target = await createArraySyncEngineDataSource({
2332
- objects: (_a = packageContents.signals) != null ? _a : [],
2730
+ objects: packageContents.signals ?? [],
2333
2731
  selectIdentifier: selectIdentifier7,
2334
2732
  selectDisplayName: selectDisplayName7,
2335
2733
  onSyncComplete: async (_, synced) => {
@@ -2391,7 +2789,6 @@ var SignalPushModule = {
2391
2789
  project: projectId,
2392
2790
  diff: diffMode
2393
2791
  }) => {
2394
- var _a;
2395
2792
  const fetch3 = nodeFetchProxy(proxy);
2396
2793
  const client = new UncachedSignalClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
2397
2794
  let source;
@@ -2399,7 +2796,7 @@ var SignalPushModule = {
2399
2796
  if (isPackage) {
2400
2797
  const packageContents = readContextPackage(directory, true);
2401
2798
  source = await createArraySyncEngineDataSource({
2402
- objects: (_a = packageContents.signals) != null ? _a : [],
2799
+ objects: packageContents.signals ?? [],
2403
2800
  selectIdentifier: selectIdentifier7,
2404
2801
  selectDisplayName: selectDisplayName7
2405
2802
  });
@@ -2588,7 +2985,6 @@ var TestPullModule = {
2588
2985
  project: projectId,
2589
2986
  diff: diffMode
2590
2987
  }) => {
2591
- var _a;
2592
2988
  const fetch3 = nodeFetchProxy(proxy);
2593
2989
  const client = new UncachedTestClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
2594
2990
  const source = createTestEngineDataSource({ client });
@@ -2597,7 +2993,7 @@ var TestPullModule = {
2597
2993
  if (isPackage) {
2598
2994
  const packageContents = readContextPackage(directory, false);
2599
2995
  target = await createArraySyncEngineDataSource({
2600
- objects: (_a = packageContents.tests) != null ? _a : [],
2996
+ objects: packageContents.tests ?? [],
2601
2997
  selectIdentifier: selectIdentifier8,
2602
2998
  selectDisplayName: selectDisplayName8,
2603
2999
  onSyncComplete: async (_, synced) => {
@@ -2659,7 +3055,6 @@ var TestPushModule = {
2659
3055
  project: projectId,
2660
3056
  diff: diffMode
2661
3057
  }) => {
2662
- var _a;
2663
3058
  const fetch3 = nodeFetchProxy(proxy);
2664
3059
  const client = new UncachedTestClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
2665
3060
  let source;
@@ -2667,7 +3062,7 @@ var TestPushModule = {
2667
3062
  if (isPackage) {
2668
3063
  const packageContents = readContextPackage(directory, true);
2669
3064
  source = await createArraySyncEngineDataSource({
2670
- objects: (_a = packageContents.tests) != null ? _a : [],
3065
+ objects: packageContents.tests ?? [],
2671
3066
  selectIdentifier: selectIdentifier8,
2672
3067
  selectDisplayName: selectDisplayName8
2673
3068
  });
@@ -2744,11 +3139,12 @@ var ContextCommand = {
2744
3139
  };
2745
3140
 
2746
3141
  // src/spinner.ts
3142
+ import ora from "ora";
2747
3143
  var makeSpinner = () => {
2748
3144
  const spinners = [];
2749
3145
  const stopAllSpinners = () => spinners.forEach((spinner) => spinner.stop());
2750
3146
  const spin = async (text) => {
2751
- const spinner = await Promise.resolve().then(() => __toESM(__require("ora"))).then((ora) => ora.default(text).start());
3147
+ const spinner = ora(text).start();
2752
3148
  spinners.push(spinner);
2753
3149
  const minWait = new Promise((resolve) => setTimeout(resolve, 500));
2754
3150
  return async () => {
@@ -2766,7 +3162,7 @@ import { PostHog } from "posthog-node";
2766
3162
  // package.json
2767
3163
  var package_default = {
2768
3164
  name: "@uniformdev/cli",
2769
- version: "18.18.0",
3165
+ version: "18.19.0",
2770
3166
  description: "Uniform command line interface tool",
2771
3167
  license: "SEE LICENSE IN LICENSE.txt",
2772
3168
  main: "./cli.js",
@@ -2785,33 +3181,34 @@ var package_default = {
2785
3181
  "@uniformdev/canvas": "workspace:*",
2786
3182
  "@uniformdev/context": "workspace:*",
2787
3183
  "@uniformdev/project-map": "workspace:*",
3184
+ chalk: "^5.2.0",
3185
+ diff: "^5.0.0",
3186
+ dotenv: "^16.0.3",
2788
3187
  execa: "5.1.1",
2789
3188
  "fs-jetpack": "5.1.0",
2790
3189
  graphql: "16.6.0",
2791
3190
  "graphql-request": "5.1.0",
3191
+ "https-proxy-agent": "^5.0.1",
2792
3192
  inquirer: "8.2.5",
2793
3193
  "isomorphic-git": "1.21.0",
3194
+ "isomorphic-unfetch": "^3.1.0",
3195
+ "js-yaml": "^4.1.0",
2794
3196
  jsonwebtoken: "9.0.0",
3197
+ "lodash.isequalwith": "^4.4.0",
2795
3198
  open: "8.4.0",
2796
3199
  ora: "6.1.2",
2797
- "posthog-node": "2.2.3",
3200
+ "posthog-node": "2.5.3",
2798
3201
  slugify: "1.6.5",
2799
- diff: "^5.0.0",
2800
- dotenv: "^16.0.3",
2801
- "https-proxy-agent": "^5.0.1",
2802
- "isomorphic-unfetch": "^3.1.0",
2803
- "js-yaml": "^4.1.0",
2804
- "lodash.isequalwith": "^4.4.0",
2805
3202
  yargs: "^17.6.2",
2806
3203
  zod: "3.20.6"
2807
3204
  },
2808
3205
  devDependencies: {
2809
- "@types/inquirer": "9.0.3",
2810
- "@types/jsonwebtoken": "9.0.1",
2811
- "@types/node": "18.11.17",
2812
3206
  "@types/diff": "5.0.2",
3207
+ "@types/inquirer": "9.0.3",
2813
3208
  "@types/js-yaml": "4.0.5",
3209
+ "@types/jsonwebtoken": "9.0.1",
2814
3210
  "@types/lodash.isequalwith": "4.4.7",
3211
+ "@types/node": "18.11.17",
2815
3212
  "@types/yargs": "17.0.22",
2816
3213
  "p-limit": "4.0.0"
2817
3214
  },
@@ -3123,7 +3520,7 @@ var runNpm = async (workDir, args, { inherit, env } = {}) => {
3123
3520
  try {
3124
3521
  result = await execa("npm", args, {
3125
3522
  cwd: workDir,
3126
- env: env != null ? env : {},
3523
+ env: env ?? {},
3127
3524
  ...inherit ? { stdout: "inherit", stderr: "inherit" } : {}
3128
3525
  });
3129
3526
  } catch (err) {
@@ -3138,10 +3535,10 @@ ${err.message}`);
3138
3535
 
3139
3536
  // src/projects/cloneStarter.ts
3140
3537
  import crypto2 from "crypto";
3141
- import fs from "fs";
3142
- import { copy } from "fs-jetpack";
3538
+ import fs2 from "fs";
3539
+ import fsj from "fs-jetpack";
3143
3540
  import * as git from "isomorphic-git";
3144
- import * as http from "isomorphic-git/http/node";
3541
+ import * as http from "isomorphic-git/http/node/index.js";
3145
3542
  import os from "os";
3146
3543
  import path from "path";
3147
3544
  async function cloneStarter({
@@ -3155,7 +3552,7 @@ async function cloneStarter({
3155
3552
  const [user, repo, ...pathSegments] = githubPath.split("/");
3156
3553
  try {
3157
3554
  await git.clone({
3158
- fs,
3555
+ fs: fs2,
3159
3556
  http,
3160
3557
  url: `https://github.com/${user}/${repo}`,
3161
3558
  dir: cloneDir,
@@ -3166,13 +3563,13 @@ async function cloneStarter({
3166
3563
  throw new Error(`Failed to fetch starter code: ${err.message}`);
3167
3564
  }
3168
3565
  await done();
3169
- if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
3566
+ if (fs2.existsSync(targetDir) && fs2.readdirSync(targetDir).length > 0) {
3170
3567
  throw new Error(`"${targetDir}" is not empty`);
3171
3568
  }
3172
3569
  const starterDir = path.join(cloneDir, ...pathSegments);
3173
- copy(starterDir, targetDir, { overwrite: true });
3570
+ fsj.copy(starterDir, targetDir, { overwrite: true });
3174
3571
  if (dotEnvFile) {
3175
- fs.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
3572
+ fs2.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
3176
3573
  }
3177
3574
  console.log(`
3178
3575
  Your project now lives in ${targetDir} \u2728`);
@@ -3188,7 +3585,7 @@ Installing project dependencies...
3188
3585
  }
3189
3586
 
3190
3587
  // src/projects/getOrCreateProject.ts
3191
- import fs2, { existsSync, mkdirSync } from "fs";
3588
+ import fs3, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
3192
3589
  import inquirer2 from "inquirer";
3193
3590
  import path2 from "path";
3194
3591
  import slugify from "slugify";
@@ -3285,8 +3682,8 @@ async function chooseExistingProject({
3285
3682
  teamId,
3286
3683
  user
3287
3684
  }) {
3288
- var _a, _b, _c;
3289
- const projects = ((_b = (_a = user.teams.find((t) => t.team.id === teamId)) == null ? void 0 : _a.team.sites) != null ? _b : []).map((t) => ({
3685
+ var _a, _b;
3686
+ const projects = (((_a = user.teams.find((t) => t.team.id === teamId)) == null ? void 0 : _a.team.sites) ?? []).map((t) => ({
3290
3687
  name: t.name,
3291
3688
  value: t.id
3292
3689
  }));
@@ -3301,7 +3698,7 @@ async function chooseExistingProject({
3301
3698
  ]);
3302
3699
  return {
3303
3700
  projectId: result.projectId,
3304
- projectName: (_c = projects.find((p) => p.value === result.projectId)) == null ? void 0 : _c.name
3701
+ projectName: (_b = projects.find((p) => p.value === result.projectId)) == null ? void 0 : _b.name
3305
3702
  };
3306
3703
  }
3307
3704
  function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
@@ -3311,13 +3708,13 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
3311
3708
  throw new Error("Project name cannot be shorter than 3 characters.");
3312
3709
  }
3313
3710
  if (checkTargetDir) {
3314
- let targetDir = explicitTargetDir != null ? explicitTargetDir : process.cwd();
3315
- if (!existsSync(targetDir)) {
3316
- mkdirSync(targetDir, { recursive: true });
3711
+ let targetDir = explicitTargetDir ?? process.cwd();
3712
+ if (!existsSync2(targetDir)) {
3713
+ mkdirSync2(targetDir, { recursive: true });
3317
3714
  }
3318
- if (fs2.readdirSync(targetDir).length > 0) {
3715
+ if (fs3.readdirSync(targetDir).length > 0) {
3319
3716
  targetDir = path2.resolve(targetDir, projectNameSlug);
3320
- if (fs2.existsSync(targetDir)) {
3717
+ if (fs3.existsSync(targetDir)) {
3321
3718
  throw new Error(`${targetDir} already exists, choose a different name.`);
3322
3719
  }
3323
3720
  }
@@ -3540,7 +3937,7 @@ npm run dev
3540
3937
  }
3541
3938
 
3542
3939
  // src/commands/new/commands/new-mesh-integration.ts
3543
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, readFileSync, writeFileSync } from "fs";
3940
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
3544
3941
  import inquirer5 from "inquirer";
3545
3942
  import path3 from "path";
3546
3943
  import slugify2 from "slugify";
@@ -3584,18 +3981,18 @@ async function newMeshIntegrationHandler({
3584
3981
  });
3585
3982
  let done = await spin("Registering integration to team...");
3586
3983
  const pathToManifest = path3.resolve(targetDir, "mesh-manifest.json");
3587
- if (!existsSync2(pathToManifest)) {
3984
+ if (!existsSync3(pathToManifest)) {
3588
3985
  throw new Error("Invalid integration starter cloned: missing `mesh-manifest.json`");
3589
3986
  }
3590
- const manifestContents = readFileSync(pathToManifest, "utf-8");
3987
+ const manifestContents = readFileSync2(pathToManifest, "utf-8");
3591
3988
  const manifestJson = JSON.parse(manifestContents);
3592
3989
  manifestJson.type = typeSlug;
3593
3990
  manifestJson.displayName = name;
3594
- writeFileSync(pathToManifest, JSON.stringify(manifestJson, null, 2), "utf-8");
3991
+ writeFileSync2(pathToManifest, JSON.stringify(manifestJson, null, 2), "utf-8");
3595
3992
  const packageJsonPath = path3.resolve(targetDir, "package.json");
3596
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
3993
+ const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
3597
3994
  packageJson.name = typeSlug;
3598
- writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
3995
+ writeFileSync2(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
3599
3996
  const fullMeshAppKey = await uniformClient.registerMeshIntegration({ teamId, manifest: manifestJson });
3600
3997
  await done();
3601
3998
  await runNpmInstall();
@@ -3637,13 +4034,13 @@ function validateIntegrationName(integrationName, explicitOutputPath) {
3637
4034
  if (integrationName.length < 6 || typeSlug.length < 6) {
3638
4035
  throw new Error("Integration name cannot be shorter than 6 characters.");
3639
4036
  }
3640
- let targetDir = explicitOutputPath != null ? explicitOutputPath : process.cwd();
3641
- if (!existsSync2(targetDir)) {
3642
- mkdirSync2(targetDir, { recursive: true });
4037
+ let targetDir = explicitOutputPath ?? process.cwd();
4038
+ if (!existsSync3(targetDir)) {
4039
+ mkdirSync3(targetDir, { recursive: true });
3643
4040
  }
3644
4041
  if (readdirSync(targetDir).length > 0) {
3645
4042
  targetDir = path3.resolve(targetDir, typeSlug);
3646
- if (existsSync2(targetDir)) {
4043
+ if (existsSync3(targetDir)) {
3647
4044
  throw new Error(`${targetDir} directory already exists, choose a different name.`);
3648
4045
  }
3649
4046
  }
@@ -3737,7 +4134,7 @@ import yargs13 from "yargs";
3737
4134
  import yargs12 from "yargs";
3738
4135
 
3739
4136
  // src/commands/optimize/manifest/download.ts
3740
- var import_chalk3 = __toESM(require_source());
4137
+ import chalk5 from "chalk";
3741
4138
  import { writeFile as writeFile2 } from "fs";
3742
4139
  import fetch2 from "isomorphic-unfetch";
3743
4140
  import { exit as exit3 } from "process";
@@ -3749,43 +4146,40 @@ var UniformBaseUrl = "https://uniform.app";
3749
4146
  var module = {
3750
4147
  command: "download [output]",
3751
4148
  describe: "Download intent manifest",
3752
- builder: (yargs18) => {
3753
- var _a;
3754
- return yargs18.option("apiKey", {
3755
- alias: "k",
3756
- demandOption: true,
3757
- string: true,
3758
- default: process.env.UNIFORM_API_KEY,
3759
- describe: "Uniform API key to use. Defaults to UNIFORM_API_KEY env if set."
3760
- }).option("project", {
3761
- describe: "Uniform project ID. Defaults to UOPT_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
3762
- default: (_a = process.env.UOPT_CLI_PROJECT_ID) != null ? _a : process.env.UNIFORM_PROJECT_ID,
3763
- type: "string",
3764
- alias: ["p"]
3765
- }).option("preview", {
3766
- describe: "If set, fetches the unpublished preview manifest (assuming your API key has permission)",
3767
- default: false,
3768
- type: "boolean",
3769
- alias: ["d"]
3770
- }).option("output", {
3771
- string: true,
3772
- alias: "o",
3773
- default: process.env.UNIFORM_MANIFEST_PATH,
3774
- describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set."
3775
- });
3776
- },
4149
+ builder: (yargs18) => yargs18.option("apiKey", {
4150
+ alias: "k",
4151
+ demandOption: true,
4152
+ string: true,
4153
+ default: process.env.UNIFORM_API_KEY,
4154
+ describe: "Uniform API key to use. Defaults to UNIFORM_API_KEY env if set."
4155
+ }).option("project", {
4156
+ describe: "Uniform project ID. Defaults to UOPT_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
4157
+ default: process.env.UOPT_CLI_PROJECT_ID ?? process.env.UNIFORM_PROJECT_ID,
4158
+ type: "string",
4159
+ alias: ["p"]
4160
+ }).option("preview", {
4161
+ describe: "If set, fetches the unpublished preview manifest (assuming your API key has permission)",
4162
+ default: false,
4163
+ type: "boolean",
4164
+ alias: ["d"]
4165
+ }).option("output", {
4166
+ string: true,
4167
+ alias: "o",
4168
+ default: process.env.UNIFORM_MANIFEST_PATH,
4169
+ describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set."
4170
+ }),
3777
4171
  handler: async ({ apiKey, output, project, preview }) => {
3778
4172
  const isLegacyApiKey = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i.test(
3779
4173
  apiKey
3780
4174
  );
3781
4175
  if (isLegacyApiKey) {
3782
4176
  console.error(
3783
- import_chalk3.default.yellow(
4177
+ chalk5.yellow(
3784
4178
  "WARNING: you appear to be using a deprecated type of API key. Keys like this will stop working soon; please create new keys on uniform.app."
3785
4179
  )
3786
4180
  );
3787
4181
  } else if (!project) {
3788
- console.error(import_chalk3.default.red("You must specify the project ID"));
4182
+ console.error(chalk5.red("You must specify the project ID"));
3789
4183
  exit3(1);
3790
4184
  }
3791
4185
  const baseUrl = resolveBaseUrl();
@@ -3811,16 +4205,16 @@ var module = {
3811
4205
  throw `${fetchResponse.status} ${fetchResponse.statusText}, content ${await fetchResponse.text()}`;
3812
4206
  }
3813
4207
  } catch (e) {
3814
- console.error(import_chalk3.default.red(`\u26A0 Error fetching intent manifest ${manifestUrl}`));
3815
- console.error(import_chalk3.default.gray(` \u2757 ${e}`));
4208
+ console.error(chalk5.red(`\u26A0 Error fetching intent manifest ${manifestUrl}`));
4209
+ console.error(chalk5.gray(` \u2757 ${e}`));
3816
4210
  exit3(1);
3817
4211
  }
3818
4212
  let json;
3819
4213
  try {
3820
4214
  json = await fetchResponse.json();
3821
4215
  } catch (e) {
3822
- console.error(import_chalk3.default.red(import_chalk3.default.red(`\u26A0 Error parsing intent manifest ${manifestUrl}`)));
3823
- console.error(import_chalk3.default.gray(` \u2757 ${e}`));
4216
+ console.error(chalk5.red(chalk5.red(`\u26A0 Error parsing intent manifest ${manifestUrl}`)));
4217
+ console.error(chalk5.gray(` \u2757 ${e}`));
3824
4218
  console.error(`Response: ${await fetchResponse.text()}`);
3825
4219
  exit3(1);
3826
4220
  }
@@ -3832,7 +4226,7 @@ var module = {
3832
4226
  `, error);
3833
4227
  exit3(1);
3834
4228
  }
3835
- console.log(import_chalk3.default.green(`\u2705 ${output} has been updated from ${manifestUrl}`));
4229
+ console.log(chalk5.green(`\u2705 ${output} has been updated from ${manifestUrl}`));
3836
4230
  });
3837
4231
  } else {
3838
4232
  console.log(text);
@@ -4006,7 +4400,6 @@ var ProjectMapDefinitionPullModule = {
4006
4400
  project: projectId,
4007
4401
  diff: diffMode
4008
4402
  }) => {
4009
- var _a;
4010
4403
  const fetch3 = nodeFetchProxy(proxy);
4011
4404
  const client = new UncachedProjectMapClient3({ apiKey, apiHost, fetch: fetch3, projectId });
4012
4405
  const source = createProjectMapDefinitionEngineDataSource({ client });
@@ -4015,7 +4408,7 @@ var ProjectMapDefinitionPullModule = {
4015
4408
  if (isPackage) {
4016
4409
  const packageContents = readContextPackage2(directory, false);
4017
4410
  target = await createArraySyncEngineDataSource({
4018
- objects: (_a = packageContents.projectMaps) != null ? _a : [],
4411
+ objects: packageContents.projectMaps ?? [],
4019
4412
  selectIdentifier: selectIdentifier9,
4020
4413
  selectDisplayName: selectDisplayName9,
4021
4414
  onSyncComplete: async (_, synced) => {
@@ -4077,7 +4470,6 @@ var ProjectMapDefinitionPushModule = {
4077
4470
  project: projectId,
4078
4471
  diff: diffMode
4079
4472
  }) => {
4080
- var _a;
4081
4473
  const fetch3 = nodeFetchProxy(proxy);
4082
4474
  const client = new UncachedProjectMapClient4({ apiKey, apiHost, fetch: fetch3, projectId });
4083
4475
  let source;
@@ -4085,7 +4477,7 @@ var ProjectMapDefinitionPushModule = {
4085
4477
  if (isPackage) {
4086
4478
  const packageContents = readContextPackage2(directory, true);
4087
4479
  source = await createArraySyncEngineDataSource({
4088
- objects: (_a = packageContents.projectMaps) != null ? _a : [],
4480
+ objects: packageContents.projectMaps ?? [],
4089
4481
  selectIdentifier: selectIdentifier9,
4090
4482
  selectDisplayName: selectDisplayName9
4091
4483
  });
@@ -4168,7 +4560,7 @@ var ProjectMapNodeGetModule = {
4168
4560
  )
4169
4561
  ),
4170
4562
  handler: async ({ apiHost, apiKey, proxy, id, projectMapId, format, project: projectId, filename }) => {
4171
- var _a, _b;
4563
+ var _a;
4172
4564
  const fetch3 = nodeFetchProxy(proxy);
4173
4565
  const client = new UncachedProjectMapClient7({ apiKey, apiHost, fetch: fetch3, projectId });
4174
4566
  console.log("Debugging params for node get", { projectMapId, id, projectId });
@@ -4177,7 +4569,7 @@ var ProjectMapNodeGetModule = {
4177
4569
  console.error("Project map node does not exist");
4178
4570
  process.exit(1);
4179
4571
  } else {
4180
- emitWithFormat({ nodes: (_b = res.nodes) != null ? _b : [], projectMapId }, format, filename);
4572
+ emitWithFormat({ nodes: res.nodes ?? [], projectMapId }, format, filename);
4181
4573
  }
4182
4574
  }
4183
4575
  };
@@ -4196,11 +4588,10 @@ var ProjectMapNodeListModule = {
4196
4588
  )
4197
4589
  ),
4198
4590
  handler: async ({ apiHost, apiKey, proxy, projectMapId, format, filename, project: projectId }) => {
4199
- var _a;
4200
4591
  const fetch3 = nodeFetchProxy(proxy);
4201
4592
  const client = new UncachedProjectMapClient8({ apiKey, apiHost, fetch: fetch3, projectId });
4202
4593
  const res = await client.getNodes({ projectMapId });
4203
- emitWithFormat({ nodes: (_a = res.nodes) != null ? _a : [], projectMapId }, format, filename);
4594
+ emitWithFormat({ nodes: res.nodes ?? [], projectMapId }, format, filename);
4204
4595
  }
4205
4596
  };
4206
4597
 
@@ -4221,7 +4612,7 @@ function createProjectMapNodeEngineDataSource({
4221
4612
  const projectMaps = (await client.getProjectMapDefinitions()).projectMaps;
4222
4613
  for (const projectMap of projectMaps) {
4223
4614
  const nodes = (await client.getNodes({ projectMapId: projectMap.id })).nodes;
4224
- for await (const def of nodes != null ? nodes : []) {
4615
+ for await (const def of nodes ?? []) {
4225
4616
  if (def) {
4226
4617
  const result = {
4227
4618
  id: selectIdentifier10({ ...def, projectMapId: projectMap.id }, projectId),
@@ -4294,7 +4685,6 @@ var ProjectMapNodePullModule = {
4294
4685
  project: projectId,
4295
4686
  diff: diffMode
4296
4687
  }) => {
4297
- var _a;
4298
4688
  const fetch3 = nodeFetchProxy(proxy);
4299
4689
  const client = new UncachedProjectMapClient9({ apiKey, apiHost, fetch: fetch3, projectId });
4300
4690
  const source = createProjectMapNodeEngineDataSource({ client, projectId });
@@ -4306,7 +4696,7 @@ var ProjectMapNodePullModule = {
4306
4696
  if (isPackage) {
4307
4697
  const packageContents = readContextPackage2(directory, false);
4308
4698
  target = await createArraySyncEngineDataSource({
4309
- objects: (_a = packageContents.projectMapNodes) != null ? _a : [],
4699
+ objects: packageContents.projectMapNodes ?? [],
4310
4700
  selectIdentifier: expandedSelectIdentifier,
4311
4701
  selectDisplayName: selectDisplayName10,
4312
4702
  onSyncComplete: async (_, synced) => {
@@ -4369,7 +4759,6 @@ var ProjectMapNodePushModule = {
4369
4759
  project: projectId,
4370
4760
  diff: diffMode
4371
4761
  }) => {
4372
- var _a;
4373
4762
  const fetch3 = nodeFetchProxy(proxy);
4374
4763
  const client = new UncachedProjectMapClient10({
4375
4764
  apiKey,
@@ -4385,7 +4774,7 @@ var ProjectMapNodePushModule = {
4385
4774
  if (isPackage) {
4386
4775
  const packageContents = readContextPackage2(directory, true);
4387
4776
  source = await createArraySyncEngineDataSource({
4388
- objects: (_a = packageContents.projectMapNodes) != null ? _a : [],
4777
+ objects: packageContents.projectMapNodes ?? [],
4389
4778
  selectIdentifier: expandedSelectIdentifier,
4390
4779
  selectDisplayName: selectDisplayName10
4391
4780
  });
@@ -4467,6 +4856,6 @@ var ProjectMapCommand = {
4467
4856
  };
4468
4857
 
4469
4858
  // src/index.ts
4470
- __require("dotenv").config();
4471
- var yarggery = yargs17.scriptName("uniform");
4859
+ dotenv.config();
4860
+ var yarggery = yargs17(hideBin(process.argv));
4472
4861
  yarggery.command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(NewCmd).command(NewMeshCmd).command(OptimizeCommand).demandCommand(1, "").strict().help().argv;