@uniformdev/cli 19.41.0 → 19.42.1-alpha.6

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
@@ -2,11 +2,11 @@
2
2
 
3
3
  // src/index.ts
4
4
  import * as dotenv from "dotenv";
5
- import yargs20 from "yargs";
5
+ import yargs22 from "yargs";
6
6
  import { hideBin } from "yargs/helpers";
7
7
 
8
8
  // src/commands/canvas/index.ts
9
- import yargs5 from "yargs";
9
+ import yargs6 from "yargs";
10
10
 
11
11
  // src/commands/canvas/commands/category.ts
12
12
  import yargs from "yargs";
@@ -75,6 +75,9 @@ import { readdir, unlink } from "fs/promises";
75
75
  import { extname as extname2, join } from "path";
76
76
 
77
77
  // src/util.ts
78
+ import { cosmiconfigSync } from "cosmiconfig";
79
+ import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
80
+ import fs from "fs";
78
81
  var omit = (object, keys) => {
79
82
  const result = keys.reduce((current, key) => {
80
83
  const { [key]: _, ...rest } = current;
@@ -85,6 +88,30 @@ var omit = (object, keys) => {
85
88
  var cleanFileName = (proposedFileName) => {
86
89
  return proposedFileName.replace(/[/<>$+%>!`&*'|{}?"=:\\@]/g, "-");
87
90
  };
91
+ var loadConfig = (configPath) => {
92
+ const moduleName = "uniform";
93
+ const syncCosmicExplorer = cosmiconfigSync("uniform", {
94
+ searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.json`],
95
+ loaders: {
96
+ ".ts": TypeScriptLoader()
97
+ }
98
+ });
99
+ if (configPath) {
100
+ if (!fs.existsSync(configPath)) {
101
+ throw new Error(`Invalid configuration file path: ${configPath}. File does not exist.`);
102
+ }
103
+ const configFile = syncCosmicExplorer.load(configPath);
104
+ if (!(configFile == null ? void 0 : configFile.config.serialization)) {
105
+ throw new Error(
106
+ `Invalid configuration file: ${configPath}. Missing config.serialization configuration.`
107
+ );
108
+ }
109
+ return applyDefaultSyncConfiguration((configFile == null ? void 0 : configFile.config) ?? {});
110
+ } else {
111
+ const searchedForm = syncCosmicExplorer.search();
112
+ return applyDefaultSyncConfiguration((searchedForm == null ? void 0 : searchedForm.config) ?? {});
113
+ }
114
+ };
88
115
 
89
116
  // src/sync/util.ts
90
117
  import { readFileSync, writeFileSync } from "fs";
@@ -92,8 +119,14 @@ import httpsProxyAgent from "https-proxy-agent";
92
119
  import unfetch from "isomorphic-unfetch";
93
120
  import { dump, load } from "js-yaml";
94
121
  import { extname } from "path";
95
- function withApiOptions(yargs21) {
96
- return yargs21.option("apiKey", {
122
+ function withConfiguration(yargs23) {
123
+ return yargs23.option("serialization", {
124
+ skipValidation: true,
125
+ hidden: true
126
+ });
127
+ }
128
+ function withApiOptions(yargs23) {
129
+ return yargs23.option("apiKey", {
97
130
  describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
98
131
  default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
99
132
  process.env.CANVAS_CLI_API_KEY ?? // deprecated
@@ -132,8 +165,8 @@ function nodeFetchProxy(proxy) {
132
165
  };
133
166
  return wrappedFetch;
134
167
  }
135
- function withProjectOptions(yargs21) {
136
- return yargs21.option("project", {
168
+ function withProjectOptions(yargs23) {
169
+ return yargs23.option("project", {
137
170
  describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
138
171
  default: process.env.UNIFORM_CLI_PROJECT_ID ?? // deprecated
139
172
  process.env.CANVAS_CLI_PROJECT_ID ?? // deprecated
@@ -143,8 +176,8 @@ function withProjectOptions(yargs21) {
143
176
  alias: ["p"]
144
177
  });
145
178
  }
146
- function withFormatOptions(yargs21) {
147
- return yargs21.option("format", {
179
+ function withFormatOptions(yargs23) {
180
+ return yargs23.option("format", {
148
181
  alias: ["f"],
149
182
  describe: "Output format",
150
183
  default: "yaml",
@@ -156,8 +189,8 @@ function withFormatOptions(yargs21) {
156
189
  type: "string"
157
190
  });
158
191
  }
159
- function withDiffOptions(yargs21) {
160
- return yargs21.option("diff", {
192
+ function withDiffOptions(yargs23) {
193
+ return yargs23.option("diff", {
161
194
  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.",
162
195
  default: process.env.UNIFORM_CLI_DIFF_MODE ?? "off",
163
196
  type: "string",
@@ -217,6 +250,72 @@ async function* paginateAsync(fetchPage, options) {
217
250
  offset += perPage;
218
251
  } while (pageData.length === perPage);
219
252
  }
253
+ var defaultSyncConfiguration = {
254
+ entitiesConfig: {},
255
+ directory: "uniform-data",
256
+ format: "yaml",
257
+ mode: "mirror"
258
+ };
259
+ var applyDefaultSyncConfiguration = (config2) => {
260
+ var _a;
261
+ const mergedConfig = {
262
+ serialization: {
263
+ ...defaultSyncConfiguration,
264
+ ...(config2 == null ? void 0 : config2.serialization) ?? {},
265
+ entitiesConfig: {
266
+ ...defaultSyncConfiguration.entitiesConfig,
267
+ ...((_a = config2 == null ? void 0 : config2.serialization) == null ? void 0 : _a.entitiesConfig) ?? {}
268
+ }
269
+ }
270
+ };
271
+ for (const entityType in mergedConfig.serialization.entitiesConfig) {
272
+ const entityTypeCasted = entityType;
273
+ const entityConfig = mergedConfig.serialization.entitiesConfig[entityTypeCasted];
274
+ if (Object.keys(entityConfig).length === 0) {
275
+ const separator = mergedConfig.serialization.directory[mergedConfig.serialization.directory.length - 1] === "/" ? "" : "/";
276
+ mergedConfig.serialization.entitiesConfig[entityTypeCasted].directory = isPathAPackageFile(
277
+ mergedConfig.serialization.directory
278
+ ) ? mergedConfig.serialization.directory : `${mergedConfig.serialization.directory}${separator}${entityTypeCasted}`;
279
+ }
280
+ }
281
+ return mergedConfig;
282
+ };
283
+ var getEntityOption = ({
284
+ optionName,
285
+ config: config2,
286
+ entityType,
287
+ operation
288
+ }) => {
289
+ var _a, _b, _c, _d, _e, _f;
290
+ if ((_b = (_a = config2.entitiesConfig[entityType]) == null ? void 0 : _a[operation]) == null ? void 0 : _b[optionName]) {
291
+ return (_d = (_c = config2.entitiesConfig[entityType]) == null ? void 0 : _c[operation]) == null ? void 0 : _d[optionName];
292
+ }
293
+ if ((_e = config2.entitiesConfig[entityType]) == null ? void 0 : _e[optionName]) {
294
+ return (_f = config2.entitiesConfig[entityType]) == null ? void 0 : _f[optionName];
295
+ }
296
+ if (config2[optionName]) {
297
+ return config2[optionName];
298
+ }
299
+ throw `No ${optionName} option specified for ${entityType} ${operation}`;
300
+ };
301
+ var getDirectoryOrFilename = ({
302
+ config: config2,
303
+ entityType,
304
+ operation
305
+ }) => {
306
+ var _a, _b, _c, _d, _e, _f;
307
+ if ((_b = (_a = config2.entitiesConfig[entityType]) == null ? void 0 : _a[operation]) == null ? void 0 : _b.directory) {
308
+ return (_d = (_c = config2.entitiesConfig[entityType]) == null ? void 0 : _c[operation]) == null ? void 0 : _d.directory;
309
+ }
310
+ if ((_e = config2.entitiesConfig[entityType]) == null ? void 0 : _e.directory) {
311
+ return (_f = config2.entitiesConfig[entityType]) == null ? void 0 : _f.directory;
312
+ }
313
+ const isPackage = isPathAPackageFile(config2.directory);
314
+ if (isPackage) {
315
+ return config2.directory;
316
+ }
317
+ return `${config2.directory}/${entityType}`;
318
+ };
220
319
 
221
320
  // src/sync/fileSyncEngineDataSource.ts
222
321
  async function createFileSyncEngineDataSource({
@@ -279,9 +378,9 @@ ${e == null ? void 0 : e.message}`));
279
378
  }
280
379
 
281
380
  // src/sync/package.ts
282
- import fs from "fs";
381
+ import fs2 from "fs";
283
382
  function readUniformPackage(filename, assertExists) {
284
- if (!assertExists && !fs.existsSync(filename)) {
383
+ if (!assertExists && !fs2.existsSync(filename)) {
285
384
  return {};
286
385
  }
287
386
  const packageContents = readFileToObject(filename);
@@ -312,7 +411,8 @@ async function syncEngine({
312
411
  whatIf = false,
313
412
  // eslint-disable-next-line @typescript-eslint/no-empty-function
314
413
  log = () => {
315
- }
414
+ },
415
+ onBeforeWriteObject
316
416
  }) {
317
417
  var _a, _b;
318
418
  const targetItems = /* @__PURE__ */ new Map();
@@ -357,7 +457,8 @@ async function syncEngine({
357
457
  const process2 = async (sourceObject2, targetObject2) => {
358
458
  if (!whatIf) {
359
459
  try {
360
- await target.writeObject(sourceObject2, targetObject2);
460
+ const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
461
+ await target.writeObject(finalSourceObject, targetObject2);
361
462
  } catch (e) {
362
463
  throw new SyncEngineError(e, sourceObject2);
363
464
  }
@@ -379,7 +480,8 @@ async function syncEngine({
379
480
  const process2 = async (sourceObject2, id) => {
380
481
  if (!whatIf) {
381
482
  try {
382
- await target.writeObject(sourceObject2);
483
+ const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2) : sourceObject2;
484
+ await target.writeObject(finalSourceObject);
383
485
  } catch (e) {
384
486
  throw new SyncEngineError(e, sourceObject2);
385
487
  }
@@ -475,9 +577,13 @@ function createSyncEngineConsoleLogger(options) {
475
577
  var CategoryGetModule = {
476
578
  command: "get <id>",
477
579
  describe: "Fetch a category",
478
- builder: (yargs21) => withFormatOptions(
479
- withApiOptions(
480
- withProjectOptions(yargs21.positional("id", { demandOption: true, describe: "Category UUID to fetch" }))
580
+ builder: (yargs23) => withConfiguration(
581
+ withFormatOptions(
582
+ withApiOptions(
583
+ withProjectOptions(
584
+ yargs23.positional("id", { demandOption: true, describe: "Category UUID to fetch" })
585
+ )
586
+ )
481
587
  )
482
588
  ),
483
589
  handler: async ({ apiHost, apiKey, proxy, id, format, project: projectId, filename }) => {
@@ -500,7 +606,7 @@ var CategoryListModule = {
500
606
  command: "list",
501
607
  describe: "List categories",
502
608
  aliases: ["ls"],
503
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21.options({})))),
609
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23.options({}))))),
504
610
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
505
611
  const fetch3 = nodeFetchProxy(proxy);
506
612
  const client = new UncachedCategoryClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -557,30 +663,32 @@ function writeCanvasPackage(filename, packageContents) {
557
663
  var CategoryPullModule = {
558
664
  command: "pull <directory>",
559
665
  describe: "Pulls all categories to local files in a directory",
560
- builder: (yargs21) => withApiOptions(
561
- withProjectOptions(
562
- withDiffOptions(
563
- yargs21.positional("directory", {
564
- describe: "Directory to save the categories to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
565
- type: "string"
566
- }).option("format", {
567
- alias: ["f"],
568
- describe: "Output format",
569
- default: "yaml",
570
- choices: ["yaml", "json"],
571
- type: "string"
572
- }).option("what-if", {
573
- alias: ["w"],
574
- describe: "What-if mode reports what would be done but changes no files",
575
- default: false,
576
- type: "boolean"
577
- }).option("mode", {
578
- alias: ["m"],
579
- 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',
580
- choices: ["create", "createOrUpdate", "mirror"],
581
- default: "mirror",
582
- type: "string"
583
- })
666
+ builder: (yargs23) => withConfiguration(
667
+ withApiOptions(
668
+ withProjectOptions(
669
+ withDiffOptions(
670
+ yargs23.positional("directory", {
671
+ describe: "Directory to save the categories to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
672
+ type: "string"
673
+ }).option("format", {
674
+ alias: ["f"],
675
+ describe: "Output format",
676
+ default: "yaml",
677
+ choices: ["yaml", "json"],
678
+ type: "string"
679
+ }).option("what-if", {
680
+ alias: ["w"],
681
+ describe: "What-if mode reports what would be done but changes no files",
682
+ default: false,
683
+ type: "boolean"
684
+ }).option("mode", {
685
+ alias: ["m"],
686
+ 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',
687
+ choices: ["create", "createOrUpdate", "mirror"],
688
+ default: "mirror",
689
+ type: "string"
690
+ })
691
+ )
584
692
  )
585
693
  )
586
694
  ),
@@ -634,24 +742,26 @@ import { UncachedCategoryClient as UncachedCategoryClient4 } from "@uniformdev/c
634
742
  var CategoryPushModule = {
635
743
  command: "push <directory>",
636
744
  describe: "Pushes all categories from files in a directory to Uniform Canvas",
637
- builder: (yargs21) => withApiOptions(
638
- withProjectOptions(
639
- withDiffOptions(
640
- yargs21.positional("directory", {
641
- describe: "Directory to read the categories from. If a filename is used, a package will be read instead.",
642
- type: "string"
643
- }).option("what-if", {
644
- alias: ["w"],
645
- describe: "What-if mode reports what would be done but changes nothing",
646
- default: false,
647
- type: "boolean"
648
- }).option("mode", {
649
- alias: ["m"],
650
- 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',
651
- choices: ["create", "createOrUpdate", "mirror"],
652
- default: "mirror",
653
- type: "string"
654
- })
745
+ builder: (yargs23) => withConfiguration(
746
+ withApiOptions(
747
+ withProjectOptions(
748
+ withDiffOptions(
749
+ yargs23.positional("directory", {
750
+ describe: "Directory to read the categories from. If a filename is used, a package will be read instead.",
751
+ type: "string"
752
+ }).option("what-if", {
753
+ alias: ["w"],
754
+ describe: "What-if mode reports what would be done but changes nothing",
755
+ default: false,
756
+ type: "boolean"
757
+ }).option("mode", {
758
+ alias: ["m"],
759
+ 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',
760
+ choices: ["create", "createOrUpdate", "mirror"],
761
+ default: "mirror",
762
+ type: "string"
763
+ })
764
+ )
655
765
  )
656
766
  )
657
767
  ),
@@ -700,8 +810,12 @@ var CategoryRemoveModule = {
700
810
  command: "remove <id>",
701
811
  aliases: ["delete", "rm"],
702
812
  describe: "Delete a category",
703
- builder: (yargs21) => withApiOptions(
704
- withProjectOptions(yargs21.positional("id", { demandOption: true, describe: "Category UUID to delete" }))
813
+ builder: (yargs23) => withConfiguration(
814
+ withApiOptions(
815
+ withProjectOptions(
816
+ yargs23.positional("id", { demandOption: true, describe: "Category UUID to delete" })
817
+ )
818
+ )
705
819
  ),
706
820
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
707
821
  const fetch3 = nodeFetchProxy(proxy);
@@ -716,9 +830,11 @@ var CategoryUpdateModule = {
716
830
  command: "update <filename>",
717
831
  aliases: ["put"],
718
832
  describe: "Insert or update a category",
719
- builder: (yargs21) => withApiOptions(
720
- withProjectOptions(
721
- yargs21.positional("filename", { demandOption: true, describe: "Category file to put" })
833
+ builder: (yargs23) => withConfiguration(
834
+ withApiOptions(
835
+ withProjectOptions(
836
+ yargs23.positional("filename", { demandOption: true, describe: "Category file to put" })
837
+ )
722
838
  )
723
839
  ),
724
840
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -734,7 +850,7 @@ var CategoryModule = {
734
850
  command: "category <command>",
735
851
  aliases: ["cat"],
736
852
  describe: "Commands for Canvas categories",
737
- builder: (yargs21) => yargs21.command(CategoryPullModule).command(CategoryPushModule).command(CategoryGetModule).command(CategoryRemoveModule).command(CategoryListModule).command(CategoryUpdateModule).demandCommand(),
853
+ builder: (yargs23) => yargs23.command(CategoryPullModule).command(CategoryPushModule).command(CategoryGetModule).command(CategoryRemoveModule).command(CategoryListModule).command(CategoryUpdateModule).demandCommand(),
738
854
  handler: () => {
739
855
  yargs.help();
740
856
  }
@@ -755,10 +871,15 @@ var selectSchemaUrl = () => "/schemas/json-schema/component-definition/v1.json";
755
871
  var ComponentGetModule = {
756
872
  command: "get <id>",
757
873
  describe: "Fetch a component definition",
758
- builder: (yargs21) => withFormatOptions(
759
- withApiOptions(
760
- withProjectOptions(
761
- yargs21.positional("id", { demandOption: true, describe: "Component definition public ID to fetch" })
874
+ builder: (yargs23) => withConfiguration(
875
+ withFormatOptions(
876
+ withApiOptions(
877
+ withProjectOptions(
878
+ yargs23.positional("id", {
879
+ demandOption: true,
880
+ describe: "Component definition public ID to fetch"
881
+ })
882
+ )
762
883
  )
763
884
  )
764
885
  ),
@@ -788,13 +909,15 @@ var ComponentListModule = {
788
909
  command: "list",
789
910
  describe: "List component definitions",
790
911
  aliases: ["ls"],
791
- builder: (yargs21) => withFormatOptions(
792
- withApiOptions(
793
- withProjectOptions(
794
- yargs21.options({
795
- offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
796
- limit: { describe: "Number of rows to fetch", type: "number", default: 20 }
797
- })
912
+ builder: (yargs23) => withConfiguration(
913
+ withFormatOptions(
914
+ withApiOptions(
915
+ withProjectOptions(
916
+ yargs23.options({
917
+ offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
918
+ limit: { describe: "Number of rows to fetch", type: "number", default: 20 }
919
+ })
920
+ )
798
921
  )
799
922
  )
800
923
  ),
@@ -845,30 +968,32 @@ function createComponentDefinitionEngineDataSource({
845
968
  var ComponentPullModule = {
846
969
  command: "pull <directory>",
847
970
  describe: "Pulls all component definitions to local files in a directory",
848
- builder: (yargs21) => withApiOptions(
849
- withProjectOptions(
850
- withDiffOptions(
851
- yargs21.positional("directory", {
852
- 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.",
853
- type: "string"
854
- }).option("format", {
855
- alias: ["f"],
856
- describe: "Output format",
857
- default: "yaml",
858
- choices: ["yaml", "json"],
859
- type: "string"
860
- }).option("what-if", {
861
- alias: ["w"],
862
- describe: "What-if mode reports what would be done but changes no files",
863
- default: false,
864
- type: "boolean"
865
- }).option("mode", {
866
- alias: ["m"],
867
- 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',
868
- choices: ["create", "createOrUpdate", "mirror"],
869
- default: "mirror",
870
- type: "string"
871
- })
971
+ builder: (yargs23) => withConfiguration(
972
+ withApiOptions(
973
+ withProjectOptions(
974
+ withDiffOptions(
975
+ yargs23.positional("directory", {
976
+ 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.",
977
+ type: "string"
978
+ }).option("format", {
979
+ alias: ["f"],
980
+ describe: "Output format",
981
+ default: "yaml",
982
+ choices: ["yaml", "json"],
983
+ type: "string"
984
+ }).option("what-if", {
985
+ alias: ["w"],
986
+ describe: "What-if mode reports what would be done but changes no files",
987
+ default: false,
988
+ type: "boolean"
989
+ }).option("mode", {
990
+ alias: ["m"],
991
+ 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',
992
+ choices: ["create", "createOrUpdate", "mirror"],
993
+ default: "mirror",
994
+ type: "string"
995
+ })
996
+ )
872
997
  )
873
998
  )
874
999
  ),
@@ -923,24 +1048,26 @@ import { UncachedCanvasClient as UncachedCanvasClient4 } from "@uniformdev/canva
923
1048
  var ComponentPushModule = {
924
1049
  command: "push <directory>",
925
1050
  describe: "Pushes all component definitions from files in a directory to Uniform Canvas",
926
- builder: (yargs21) => withApiOptions(
927
- withProjectOptions(
928
- withDiffOptions(
929
- yargs21.positional("directory", {
930
- describe: "Directory to read the component definitions from. If a filename is used, a package will be read instead.",
931
- type: "string"
932
- }).option("what-if", {
933
- alias: ["w"],
934
- describe: "What-if mode reports what would be done but changes nothing",
935
- default: false,
936
- type: "boolean"
937
- }).option("mode", {
938
- alias: ["m"],
939
- 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',
940
- choices: ["create", "createOrUpdate", "mirror"],
941
- default: "mirror",
942
- type: "string"
943
- })
1051
+ builder: (yargs23) => withConfiguration(
1052
+ withApiOptions(
1053
+ withProjectOptions(
1054
+ withDiffOptions(
1055
+ yargs23.positional("directory", {
1056
+ describe: "Directory to read the component definitions from. If a filename is used, a package will be read instead.",
1057
+ type: "string"
1058
+ }).option("what-if", {
1059
+ alias: ["w"],
1060
+ describe: "What-if mode reports what would be done but changes nothing",
1061
+ default: false,
1062
+ type: "boolean"
1063
+ }).option("mode", {
1064
+ alias: ["m"],
1065
+ 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',
1066
+ choices: ["create", "createOrUpdate", "mirror"],
1067
+ default: "mirror",
1068
+ type: "string"
1069
+ })
1070
+ )
944
1071
  )
945
1072
  )
946
1073
  ),
@@ -990,9 +1117,11 @@ var ComponentRemoveModule = {
990
1117
  command: "remove <id>",
991
1118
  aliases: ["delete", "rm"],
992
1119
  describe: "Delete a component definition",
993
- builder: (yargs21) => withApiOptions(
994
- withProjectOptions(
995
- yargs21.positional("id", { demandOption: true, describe: "Component definition public ID to delete" })
1120
+ builder: (yargs23) => withConfiguration(
1121
+ withApiOptions(
1122
+ withProjectOptions(
1123
+ yargs23.positional("id", { demandOption: true, describe: "Component definition public ID to delete" })
1124
+ )
996
1125
  )
997
1126
  ),
998
1127
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -1008,9 +1137,11 @@ var ComponentUpdateModule = {
1008
1137
  command: "update <filename>",
1009
1138
  aliases: ["put"],
1010
1139
  describe: "Insert or update a component definition",
1011
- builder: (yargs21) => withApiOptions(
1012
- withProjectOptions(
1013
- yargs21.positional("filename", { demandOption: true, describe: "Component definition file to put" })
1140
+ builder: (yargs23) => withConfiguration(
1141
+ withApiOptions(
1142
+ withProjectOptions(
1143
+ yargs23.positional("filename", { demandOption: true, describe: "Component definition file to put" })
1144
+ )
1014
1145
  )
1015
1146
  ),
1016
1147
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -1026,7 +1157,7 @@ var ComponentModule = {
1026
1157
  command: "component <command>",
1027
1158
  aliases: ["def"],
1028
1159
  describe: "Commands for Canvas component definitions",
1029
- builder: (yargs21) => yargs21.command(ComponentPullModule).command(ComponentPushModule).command(ComponentGetModule).command(ComponentRemoveModule).command(ComponentListModule).command(ComponentUpdateModule).demandCommand(),
1160
+ builder: (yargs23) => yargs23.command(ComponentPullModule).command(ComponentPushModule).command(ComponentGetModule).command(ComponentRemoveModule).command(ComponentListModule).command(ComponentUpdateModule).demandCommand(),
1030
1161
  handler: () => {
1031
1162
  yargs2.help();
1032
1163
  }
@@ -1048,8 +1179,8 @@ function prepCompositionForDisk(composition) {
1048
1179
  delete prepped.state;
1049
1180
  return prepped;
1050
1181
  }
1051
- function withStateOptions(yargs21) {
1052
- return yargs21.option("state", {
1182
+ function withStateOptions(yargs23) {
1183
+ return yargs23.option("state", {
1053
1184
  type: "string",
1054
1185
  describe: `Composition state to fetch.`,
1055
1186
  choices: ["preview", "published"],
@@ -1074,37 +1205,39 @@ function convertCompositionState(state) {
1074
1205
  var CompositionGetModule = {
1075
1206
  command: "get <id>",
1076
1207
  describe: "Fetch a composition",
1077
- builder: (yargs21) => withFormatOptions(
1078
- withApiOptions(
1079
- withProjectOptions(
1080
- withStateOptions(
1081
- yargs21.positional("id", { demandOption: true, describe: "Composition public ID to fetch" }).option({
1082
- resolvePatterns: {
1083
- type: "boolean",
1084
- default: false,
1085
- describe: "Resolve pattern references in the composition"
1086
- },
1087
- resolveOverrides: {
1088
- type: "boolean",
1089
- default: false,
1090
- describe: "Resolves pattern overrides in the composition and removes override definition data"
1091
- },
1092
- componentIDs: {
1093
- type: "boolean",
1094
- default: false,
1095
- describe: "Include individual component UIDs"
1096
- },
1097
- resolveData: {
1098
- type: "boolean",
1099
- default: false,
1100
- describe: "Resolve all data resources used by the composition"
1101
- },
1102
- diagnostics: {
1103
- type: "boolean",
1104
- default: false,
1105
- describe: "Include diagnostics information when resolving data"
1106
- }
1107
- })
1208
+ builder: (yargs23) => withFormatOptions(
1209
+ withConfiguration(
1210
+ withApiOptions(
1211
+ withProjectOptions(
1212
+ withStateOptions(
1213
+ yargs23.positional("id", { demandOption: true, describe: "Composition/pattern public ID to fetch" }).option({
1214
+ resolvePatterns: {
1215
+ type: "boolean",
1216
+ default: false,
1217
+ describe: "Resolve pattern references in the composition"
1218
+ },
1219
+ resolveOverrides: {
1220
+ type: "boolean",
1221
+ default: false,
1222
+ describe: "Resolves pattern overrides in the composition and removes override definition data"
1223
+ },
1224
+ componentIDs: {
1225
+ type: "boolean",
1226
+ default: false,
1227
+ describe: "Include individual component UIDs"
1228
+ },
1229
+ resolveData: {
1230
+ type: "boolean",
1231
+ default: false,
1232
+ describe: "Resolve all data resources used by the composition/pattern"
1233
+ },
1234
+ diagnostics: {
1235
+ type: "boolean",
1236
+ default: false,
1237
+ describe: "Include diagnostics information when resolving data"
1238
+ }
1239
+ })
1240
+ )
1108
1241
  )
1109
1242
  )
1110
1243
  )
@@ -1148,29 +1281,42 @@ var CompositionListModule = {
1148
1281
  command: "list",
1149
1282
  describe: "List compositions",
1150
1283
  aliases: ["ls"],
1151
- builder: (yargs21) => withFormatOptions(
1152
- withApiOptions(
1153
- withProjectOptions(
1154
- withStateOptions(
1155
- yargs21.options({
1156
- offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
1157
- limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
1158
- resolvePatterns: {
1159
- type: "boolean",
1160
- default: false,
1161
- describe: "Resolve pattern references in the composition"
1162
- },
1163
- resolveOverrides: {
1164
- type: "boolean",
1165
- default: false,
1166
- describe: "Resolves pattern overrides in the composition and removes override definition data"
1167
- },
1168
- componentIDs: {
1169
- type: "boolean",
1170
- default: false,
1171
- describe: "Include individual component UIDs"
1172
- }
1173
- })
1284
+ builder: (yargs23) => withFormatOptions(
1285
+ withConfiguration(
1286
+ withApiOptions(
1287
+ withProjectOptions(
1288
+ withStateOptions(
1289
+ yargs23.options({
1290
+ offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
1291
+ limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
1292
+ resolvePatterns: {
1293
+ type: "boolean",
1294
+ default: false,
1295
+ describe: "Resolve pattern references in the composition"
1296
+ },
1297
+ resolveOverrides: {
1298
+ type: "boolean",
1299
+ default: false,
1300
+ describe: "Resolves pattern overrides in the composition and removes override definition data"
1301
+ },
1302
+ onlyCompositions: {
1303
+ describe: "Only pulling compositions and not patterns",
1304
+ default: false,
1305
+ type: "boolean"
1306
+ },
1307
+ onlyPatterns: {
1308
+ describe: "Only pulling patterns and not compositions",
1309
+ default: false,
1310
+ type: "boolean",
1311
+ hidden: true
1312
+ },
1313
+ componentIDs: {
1314
+ type: "boolean",
1315
+ default: false,
1316
+ describe: "Include individual component UIDs"
1317
+ }
1318
+ })
1319
+ )
1174
1320
  )
1175
1321
  )
1176
1322
  )
@@ -1183,6 +1329,8 @@ var CompositionListModule = {
1183
1329
  offset,
1184
1330
  format,
1185
1331
  filename,
1332
+ onlyCompositions,
1333
+ onlyPatterns,
1186
1334
  project: projectId,
1187
1335
  state,
1188
1336
  resolvePatterns,
@@ -1194,6 +1342,7 @@ var CompositionListModule = {
1194
1342
  const res = await client.getCompositionList({
1195
1343
  limit,
1196
1344
  offset,
1345
+ pattern: onlyCompositions ? false : onlyPatterns ? true : void 0,
1197
1346
  state: convertCompositionState(state),
1198
1347
  skipPatternResolution: !resolvePatterns,
1199
1348
  withComponentIDs: componentIDs,
@@ -1214,6 +1363,8 @@ var selectDisplayName3 = (component) => `${component.composition._name ?? compon
1214
1363
  function createComponentInstanceEngineDataSource({
1215
1364
  client,
1216
1365
  state,
1366
+ onlyCompositions,
1367
+ onlyPatterns,
1217
1368
  ...clientOptions
1218
1369
  }) {
1219
1370
  const stateId = convertCompositionState(state);
@@ -1223,6 +1374,7 @@ function createComponentInstanceEngineDataSource({
1223
1374
  ...clientOptions,
1224
1375
  limit,
1225
1376
  offset,
1377
+ pattern: onlyCompositions ? false : onlyPatterns ? true : void 0,
1226
1378
  state: stateId,
1227
1379
  skipPatternResolution: true,
1228
1380
  skipOverridesResolution: true,
@@ -1253,43 +1405,36 @@ function createComponentInstanceEngineDataSource({
1253
1405
 
1254
1406
  // src/commands/canvas/commands/composition/publish.ts
1255
1407
  var CompositionPublishModule = {
1256
- command: "publish [compositionIDs]",
1408
+ command: "publish [ids]",
1257
1409
  describe: "Publishes compositions",
1258
- builder: (yargs21) => withApiOptions(
1259
- withProjectOptions(
1260
- withDiffOptions(
1261
- yargs21.positional("compositionIDs", {
1262
- describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
1263
- type: "string"
1264
- }).option("all", {
1265
- alias: ["a"],
1266
- describe: "Publishes all compositions. Use compositionId to publish one instead.",
1267
- default: false,
1268
- type: "boolean"
1269
- }).option("what-if", {
1270
- alias: ["w"],
1271
- describe: "What-if mode reports what would be done but does not perform any publishing",
1272
- default: false,
1273
- type: "boolean"
1274
- })
1410
+ builder: (yargs23) => withConfiguration(
1411
+ withApiOptions(
1412
+ withProjectOptions(
1413
+ withDiffOptions(
1414
+ yargs23.positional("ids", {
1415
+ describe: "Publishes composition/pattern(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
1416
+ type: "string"
1417
+ }).option("all", {
1418
+ alias: ["a"],
1419
+ describe: "Publishes all compositions. Use compositionId to publish one instead.",
1420
+ default: false,
1421
+ type: "boolean"
1422
+ }).option("what-if", {
1423
+ alias: ["w"],
1424
+ describe: "What-if mode reports what would be done but does not perform any publishing",
1425
+ default: false,
1426
+ type: "boolean"
1427
+ })
1428
+ )
1275
1429
  )
1276
1430
  )
1277
1431
  ),
1278
- handler: async ({
1279
- apiHost,
1280
- apiKey,
1281
- proxy,
1282
- compositionIDs,
1283
- all,
1284
- whatIf,
1285
- project: projectId,
1286
- diff: diffMode
1287
- }) => {
1288
- if (!all && !compositionIDs || all && compositionIDs) {
1432
+ handler: async ({ apiHost, apiKey, proxy, ids, all, whatIf, project: projectId, diff: diffMode }) => {
1433
+ if (!all && !ids || all && ids) {
1289
1434
  console.error(`Specify --all or composition ID(s) to publish.`);
1290
1435
  process.exit(1);
1291
1436
  }
1292
- const compositionIDsArray = compositionIDs ? compositionIDs.split(",").map((id) => id.trim()) : void 0;
1437
+ const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
1293
1438
  const fetch3 = nodeFetchProxy(proxy);
1294
1439
  const client = new UncachedCanvasClient9({ apiKey, apiHost, fetch: fetch3, projectId });
1295
1440
  const source = createComponentInstanceEngineDataSource({
@@ -1314,34 +1459,180 @@ var CompositionPublishModule = {
1314
1459
 
1315
1460
  // src/commands/canvas/commands/composition/pull.ts
1316
1461
  import { UncachedCanvasClient as UncachedCanvasClient10 } from "@uniformdev/canvas";
1462
+
1463
+ // src/files/index.ts
1464
+ import { preferredType } from "@thi.ng/mime";
1465
+ import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files-sdk";
1466
+ import { createHash } from "crypto";
1467
+ import fsj from "fs-jetpack";
1468
+ import sizeOf from "image-size";
1469
+ import PQueue from "p-queue";
1470
+ import { join as join2 } from "path";
1471
+ var FILES_DIRECTORY_NAME = "files";
1472
+ var urlToFileName = (url) => {
1473
+ const hash = createHash("sha256");
1474
+ hash.update(url);
1475
+ const fileName = hash.digest("hex");
1476
+ const fileExtension = url.split(".").pop();
1477
+ return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
1478
+ };
1479
+ var extractAndDownloadUniformFilesForObject = async (object, options) => {
1480
+ const objectAsString = JSON.stringify(object);
1481
+ const uniformFileUrlMatches = objectAsString.matchAll(
1482
+ /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
1483
+ );
1484
+ if (uniformFileUrlMatches) {
1485
+ const fileDownloadQueue = new PQueue({ concurrency: 10 });
1486
+ for (const match of uniformFileUrlMatches) {
1487
+ const url = match[1];
1488
+ fileDownloadQueue.add(async () => {
1489
+ try {
1490
+ const fileName = urlToFileName(url);
1491
+ const fileAlreadyExists = await fsj.existsAsync(
1492
+ join2(options.directory, FILES_DIRECTORY_NAME, fileName)
1493
+ );
1494
+ if (fileAlreadyExists) {
1495
+ return;
1496
+ }
1497
+ const response = await fetch(url);
1498
+ if (!response.ok) {
1499
+ return;
1500
+ }
1501
+ const fileBuffer = await response.arrayBuffer();
1502
+ await fsj.writeAsync(
1503
+ join2(options.directory, FILES_DIRECTORY_NAME, fileName),
1504
+ Buffer.from(fileBuffer)
1505
+ );
1506
+ } catch {
1507
+ console.warn(`Failed to download file ${url}`);
1508
+ }
1509
+ });
1510
+ }
1511
+ await fileDownloadQueue.onIdle();
1512
+ }
1513
+ return object;
1514
+ };
1515
+ var extractAndUploadUniformFilesForObject = async (object, options) => {
1516
+ let objectAsString = JSON.stringify(object);
1517
+ const uniformFileUrlMatches = objectAsString.matchAll(
1518
+ /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
1519
+ );
1520
+ if (uniformFileUrlMatches) {
1521
+ const fileUploadQueue = new PQueue({ concurrency: 5 });
1522
+ for (const match of uniformFileUrlMatches) {
1523
+ const url = match[1];
1524
+ fileUploadQueue.add(async () => {
1525
+ try {
1526
+ const fileAlreadyExists = await options.fileClient.getFile({ url }).catch(() => null);
1527
+ if (fileAlreadyExists) {
1528
+ return;
1529
+ }
1530
+ const localFileName = urlToFileName(url);
1531
+ const fileExistsLocally = await fsj.existsAsync(
1532
+ join2(options.directory, FILES_DIRECTORY_NAME, localFileName)
1533
+ );
1534
+ if (!fileExistsLocally) {
1535
+ console.warn(`Skipping file ${url} as we couldn't find a local copy`);
1536
+ return;
1537
+ }
1538
+ const fileBuffer = await fsj.readAsync(
1539
+ join2(options.directory, FILES_DIRECTORY_NAME, localFileName),
1540
+ "buffer"
1541
+ );
1542
+ if (!fileBuffer) {
1543
+ console.warn(`Skipping file ${url} as we couldn't read it`);
1544
+ return;
1545
+ }
1546
+ const fileName = getFileNameFromUrl(url);
1547
+ const { width, height } = (() => {
1548
+ try {
1549
+ return sizeOf(fileBuffer);
1550
+ } catch {
1551
+ return {
1552
+ width: void 0,
1553
+ height: void 0
1554
+ };
1555
+ }
1556
+ })();
1557
+ const { id, method, uploadUrl } = await options.fileClient.createNewProjectFile({
1558
+ name: fileName,
1559
+ mediaType: preferredType(url.split(".").at(-1) ?? ""),
1560
+ size: fileBuffer.length,
1561
+ width,
1562
+ height
1563
+ });
1564
+ const uploadResponse = await fetch(uploadUrl, {
1565
+ method,
1566
+ body: fileBuffer
1567
+ });
1568
+ if (!uploadResponse.ok) {
1569
+ console.warn(`Failed to upload file ${url}`);
1570
+ return;
1571
+ }
1572
+ const checkForFile = async () => {
1573
+ const file = await options.fileClient.getFile({ id });
1574
+ if (!file || file.state !== FILE_READY_STATE) {
1575
+ await new Promise((resolve) => setTimeout(resolve, 500));
1576
+ return checkForFile();
1577
+ }
1578
+ return file.url;
1579
+ };
1580
+ const abortTimeout = setTimeout(() => {
1581
+ throw new Error(`Failed to upload file ${url}`);
1582
+ }, 1e4);
1583
+ const uploadedFileUrl = await checkForFile();
1584
+ clearTimeout(abortTimeout);
1585
+ objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
1586
+ } catch {
1587
+ console.warn(`Failed to upload file ${url}`);
1588
+ }
1589
+ });
1590
+ }
1591
+ await fileUploadQueue.onIdle();
1592
+ }
1593
+ return JSON.parse(objectAsString);
1594
+ };
1595
+
1596
+ // src/commands/canvas/commands/composition/pull.ts
1317
1597
  var CompositionPullModule = {
1318
1598
  command: "pull <directory>",
1319
1599
  describe: "Pulls all compositions to local files in a directory",
1320
- builder: (yargs21) => withApiOptions(
1321
- withProjectOptions(
1322
- withStateOptions(
1323
- withDiffOptions(
1324
- yargs21.positional("directory", {
1325
- 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.",
1326
- type: "string"
1327
- }).option("format", {
1328
- alias: ["f"],
1329
- describe: "Output format",
1330
- default: "yaml",
1331
- choices: ["yaml", "json"],
1332
- type: "string"
1333
- }).option("what-if", {
1334
- alias: ["w"],
1335
- describe: "What-if mode reports what would be done but changes no files",
1336
- default: false,
1337
- type: "boolean"
1338
- }).option("mode", {
1339
- alias: ["m"],
1340
- 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',
1341
- choices: ["create", "createOrUpdate", "mirror"],
1342
- default: "mirror",
1343
- type: "string"
1344
- })
1600
+ builder: (yargs23) => withConfiguration(
1601
+ withApiOptions(
1602
+ withProjectOptions(
1603
+ withStateOptions(
1604
+ withDiffOptions(
1605
+ yargs23.positional("directory", {
1606
+ 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.",
1607
+ type: "string"
1608
+ }).option("format", {
1609
+ alias: ["f"],
1610
+ describe: "Output format",
1611
+ default: "yaml",
1612
+ choices: ["yaml", "json"],
1613
+ type: "string"
1614
+ }).option("onlyCompositions", {
1615
+ describe: "Only pulling compositions and not patterns",
1616
+ default: false,
1617
+ type: "boolean"
1618
+ }).option("onlyPatterns", {
1619
+ describe: "Only pulling patterns and not compositions",
1620
+ default: false,
1621
+ type: "boolean",
1622
+ hidden: true
1623
+ }).option("what-if", {
1624
+ alias: ["w"],
1625
+ describe: "What-if mode reports what would be done but changes no files",
1626
+ default: false,
1627
+ type: "boolean"
1628
+ }).option("mode", {
1629
+ alias: ["m"],
1630
+ 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',
1631
+ choices: ["create", "createOrUpdate", "mirror"],
1632
+ default: "mirror",
1633
+ type: "string"
1634
+ })
1635
+ )
1345
1636
  )
1346
1637
  )
1347
1638
  )
@@ -1352,6 +1643,8 @@ var CompositionPullModule = {
1352
1643
  proxy,
1353
1644
  directory,
1354
1645
  format,
1646
+ onlyCompositions,
1647
+ onlyPatterns,
1355
1648
  mode,
1356
1649
  whatIf,
1357
1650
  state,
@@ -1360,7 +1653,7 @@ var CompositionPullModule = {
1360
1653
  }) => {
1361
1654
  const fetch3 = nodeFetchProxy(proxy);
1362
1655
  const client = new UncachedCanvasClient10({ apiKey, apiHost, fetch: fetch3, projectId });
1363
- const source = createComponentInstanceEngineDataSource({ client, state });
1656
+ const source = createComponentInstanceEngineDataSource({ client, state, onlyCompositions, onlyPatterns });
1364
1657
  const isPackage = isPathAPackageFile(directory);
1365
1658
  let target;
1366
1659
  if (isPackage) {
@@ -1387,35 +1680,52 @@ var CompositionPullModule = {
1387
1680
  target,
1388
1681
  mode,
1389
1682
  whatIf,
1390
- log: createSyncEngineConsoleLogger({ diffMode })
1683
+ log: createSyncEngineConsoleLogger({ diffMode }),
1684
+ onBeforeWriteObject: async (sourceObject) => {
1685
+ return extractAndDownloadUniformFilesForObject(sourceObject, {
1686
+ directory
1687
+ });
1688
+ }
1391
1689
  });
1392
1690
  }
1393
1691
  };
1394
1692
 
1395
1693
  // src/commands/canvas/commands/composition/push.ts
1396
1694
  import { UncachedCanvasClient as UncachedCanvasClient11 } from "@uniformdev/canvas";
1695
+ import { FileClient as FileClient2 } from "@uniformdev/files-sdk";
1397
1696
  var CompositionPushModule = {
1398
1697
  command: "push <directory>",
1399
1698
  describe: "Pushes all compositions from files in a directory to Uniform Canvas",
1400
- builder: (yargs21) => withApiOptions(
1401
- withProjectOptions(
1402
- withStateOptions(
1403
- withDiffOptions(
1404
- yargs21.positional("directory", {
1405
- describe: "Directory to read the component definitions from. If a filename is used, a package will be read instead.",
1406
- type: "string"
1407
- }).option("what-if", {
1408
- alias: ["w"],
1409
- describe: "What-if mode reports what would be done but changes nothing",
1410
- default: false,
1411
- type: "boolean"
1412
- }).option("mode", {
1413
- alias: ["m"],
1414
- 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',
1415
- choices: ["create", "createOrUpdate", "mirror"],
1416
- default: "mirror",
1417
- type: "string"
1418
- })
1699
+ builder: (yargs23) => withConfiguration(
1700
+ withApiOptions(
1701
+ withProjectOptions(
1702
+ withStateOptions(
1703
+ withDiffOptions(
1704
+ yargs23.positional("directory", {
1705
+ describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
1706
+ type: "string"
1707
+ }).option("what-if", {
1708
+ alias: ["w"],
1709
+ describe: "What-if mode reports what would be done but changes nothing",
1710
+ default: false,
1711
+ type: "boolean"
1712
+ }).option("mode", {
1713
+ alias: ["m"],
1714
+ 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',
1715
+ choices: ["create", "createOrUpdate", "mirror"],
1716
+ default: "mirror",
1717
+ type: "string"
1718
+ }).option("onlyCompositions", {
1719
+ describe: "Only pulling compositions and not patterns",
1720
+ default: false,
1721
+ type: "boolean"
1722
+ }).option("onlyPatterns", {
1723
+ describe: "Only pulling patterns and not compositions",
1724
+ default: false,
1725
+ type: "boolean",
1726
+ hidden: true
1727
+ })
1728
+ )
1419
1729
  )
1420
1730
  )
1421
1731
  )
@@ -1429,6 +1739,8 @@ var CompositionPushModule = {
1429
1739
  whatIf,
1430
1740
  state,
1431
1741
  project: projectId,
1742
+ onlyCompositions,
1743
+ onlyPatterns,
1432
1744
  diff: diffMode
1433
1745
  }) => {
1434
1746
  const fetch3 = nodeFetchProxy(proxy);
@@ -1449,13 +1761,20 @@ var CompositionPushModule = {
1449
1761
  selectDisplayName: selectDisplayName3
1450
1762
  });
1451
1763
  }
1452
- const target = createComponentInstanceEngineDataSource({ client, state });
1764
+ const target = createComponentInstanceEngineDataSource({ client, state, onlyCompositions, onlyPatterns });
1765
+ const fileClient = new FileClient2({ apiKey, apiHost, fetch: fetch3, projectId });
1453
1766
  await syncEngine({
1454
1767
  source,
1455
1768
  target,
1456
1769
  mode,
1457
1770
  whatIf,
1458
- log: createSyncEngineConsoleLogger({ diffMode })
1771
+ log: createSyncEngineConsoleLogger({ diffMode }),
1772
+ onBeforeWriteObject: async (sourceObject) => {
1773
+ return extractAndUploadUniformFilesForObject(sourceObject, {
1774
+ directory,
1775
+ fileClient
1776
+ });
1777
+ }
1459
1778
  });
1460
1779
  }
1461
1780
  };
@@ -1466,9 +1785,11 @@ var CompositionRemoveModule = {
1466
1785
  command: "remove <id>",
1467
1786
  aliases: ["delete", "rm"],
1468
1787
  describe: "Delete a composition",
1469
- builder: (yargs21) => withApiOptions(
1470
- withProjectOptions(
1471
- yargs21.positional("id", { demandOption: true, describe: "Composition public ID to delete" })
1788
+ builder: (yargs23) => withConfiguration(
1789
+ withApiOptions(
1790
+ withProjectOptions(
1791
+ yargs23.positional("id", { demandOption: true, describe: "Composition/pattern public ID to delete" })
1792
+ )
1472
1793
  )
1473
1794
  ),
1474
1795
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -1483,9 +1804,14 @@ import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2, UncachedCanvasClient
1483
1804
  var CompositionUnpublishModule = {
1484
1805
  command: "unpublish <id>",
1485
1806
  describe: "Unpublish a composition",
1486
- builder: (yargs21) => withApiOptions(
1487
- withProjectOptions(
1488
- yargs21.positional("id", { demandOption: true, describe: "Composition public ID to unpublish" })
1807
+ builder: (yargs23) => withConfiguration(
1808
+ withApiOptions(
1809
+ withProjectOptions(
1810
+ yargs23.positional("id", {
1811
+ demandOption: true,
1812
+ describe: "Composition/pattern public ID to unpublish"
1813
+ })
1814
+ )
1489
1815
  )
1490
1816
  ),
1491
1817
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -1501,10 +1827,12 @@ var CompositionUpdateModule = {
1501
1827
  command: "update <filename>",
1502
1828
  aliases: ["put"],
1503
1829
  describe: "Insert or update a composition",
1504
- builder: (yargs21) => withApiOptions(
1505
- withProjectOptions(
1506
- withStateOptions(
1507
- yargs21.positional("filename", { demandOption: true, describe: "Composition file to put" })
1830
+ builder: (yargs23) => withConfiguration(
1831
+ withApiOptions(
1832
+ withProjectOptions(
1833
+ withStateOptions(
1834
+ yargs23.positional("filename", { demandOption: true, describe: "Composition/pattern file to put" })
1835
+ )
1508
1836
  )
1509
1837
  )
1510
1838
  ),
@@ -1521,7 +1849,7 @@ var CompositionModule = {
1521
1849
  command: "composition <command>",
1522
1850
  describe: "Commands for Canvas compositions",
1523
1851
  aliases: ["comp"],
1524
- builder: (yargs21) => yargs21.command(CompositionPullModule).command(CompositionPushModule).command(CompositionGetModule).command(CompositionRemoveModule).command(CompositionListModule).command(CompositionUpdateModule).command(CompositionPublishModule).command(CompositionUnpublishModule).demandCommand(),
1852
+ builder: (yargs23) => yargs23.command(CompositionPullModule).command(CompositionPushModule).command(CompositionGetModule).command(CompositionRemoveModule).command(CompositionListModule).command(CompositionUpdateModule).command(CompositionPublishModule).command(CompositionUnpublishModule).demandCommand(),
1525
1853
  handler: () => {
1526
1854
  yargs3.help();
1527
1855
  }
@@ -1536,11 +1864,13 @@ var DataTypeGetModule = {
1536
1864
  command: "get <id>",
1537
1865
  describe: "Get a data type",
1538
1866
  aliases: ["ls"],
1539
- builder: (yargs21) => withFormatOptions(
1540
- withApiOptions(
1541
- withProjectOptions(
1542
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1543
- yargs21.positional("id", { demandOption: true, describe: "Data type public ID to fetch" })
1867
+ builder: (yargs23) => withConfiguration(
1868
+ withFormatOptions(
1869
+ withApiOptions(
1870
+ withProjectOptions(
1871
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1872
+ yargs23.positional("id", { demandOption: true, describe: "Data type public ID to fetch" })
1873
+ )
1544
1874
  )
1545
1875
  )
1546
1876
  ),
@@ -1562,7 +1892,7 @@ var DataTypeListModule = {
1562
1892
  command: "list",
1563
1893
  describe: "List data types",
1564
1894
  aliases: ["ls"],
1565
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
1895
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
1566
1896
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
1567
1897
  const fetch3 = nodeFetchProxy(proxy);
1568
1898
  const client = new DataTypeClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
@@ -1611,30 +1941,32 @@ function createDataTypeEngineDataSource({
1611
1941
  var DataTypePullModule = {
1612
1942
  command: "pull <directory>",
1613
1943
  describe: "Pulls all data types to local files in a directory",
1614
- builder: (yargs21) => withApiOptions(
1615
- withProjectOptions(
1616
- withDiffOptions(
1617
- yargs21.positional("directory", {
1618
- describe: "Directory to save the data types to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
1619
- type: "string"
1620
- }).option("format", {
1621
- alias: ["f"],
1622
- describe: "Output format",
1623
- default: "yaml",
1624
- choices: ["yaml", "json"],
1625
- type: "string"
1626
- }).option("what-if", {
1627
- alias: ["w"],
1628
- describe: "What-if mode reports what would be done but changes no files",
1629
- default: false,
1630
- type: "boolean"
1631
- }).option("mode", {
1632
- alias: ["m"],
1633
- 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',
1634
- choices: ["create", "createOrUpdate", "mirror"],
1635
- default: "mirror",
1636
- type: "string"
1637
- })
1944
+ builder: (yargs23) => withConfiguration(
1945
+ withApiOptions(
1946
+ withProjectOptions(
1947
+ withDiffOptions(
1948
+ yargs23.positional("directory", {
1949
+ describe: "Directory to save the data types to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
1950
+ type: "string"
1951
+ }).option("format", {
1952
+ alias: ["f"],
1953
+ describe: "Output format",
1954
+ default: "yaml",
1955
+ choices: ["yaml", "json"],
1956
+ type: "string"
1957
+ }).option("what-if", {
1958
+ alias: ["w"],
1959
+ describe: "What-if mode reports what would be done but changes no files",
1960
+ default: false,
1961
+ type: "boolean"
1962
+ }).option("mode", {
1963
+ alias: ["m"],
1964
+ 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',
1965
+ choices: ["create", "createOrUpdate", "mirror"],
1966
+ default: "mirror",
1967
+ type: "string"
1968
+ })
1969
+ )
1638
1970
  )
1639
1971
  )
1640
1972
  ),
@@ -1694,24 +2026,26 @@ import { DataTypeClient as DataTypeClient4 } from "@uniformdev/canvas";
1694
2026
  var DataTypePushModule = {
1695
2027
  command: "push <directory>",
1696
2028
  describe: "Pushes all data types from files in a directory to Uniform",
1697
- builder: (yargs21) => withApiOptions(
1698
- withProjectOptions(
1699
- withDiffOptions(
1700
- yargs21.positional("directory", {
1701
- describe: "Directory to read the data types from. If a filename is used, a package will be read instead.",
1702
- type: "string"
1703
- }).option("what-if", {
1704
- alias: ["w"],
1705
- describe: "What-if mode reports what would be done but changes nothing",
1706
- default: false,
1707
- type: "boolean"
1708
- }).option("mode", {
1709
- alias: ["m"],
1710
- 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',
1711
- choices: ["create", "createOrUpdate", "mirror"],
1712
- default: "mirror",
1713
- type: "string"
1714
- })
2029
+ builder: (yargs23) => withConfiguration(
2030
+ withApiOptions(
2031
+ withProjectOptions(
2032
+ withDiffOptions(
2033
+ yargs23.positional("directory", {
2034
+ describe: "Directory to read the data types from. If a filename is used, a package will be read instead.",
2035
+ type: "string"
2036
+ }).option("what-if", {
2037
+ alias: ["w"],
2038
+ describe: "What-if mode reports what would be done but changes nothing",
2039
+ default: false,
2040
+ type: "boolean"
2041
+ }).option("mode", {
2042
+ alias: ["m"],
2043
+ 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',
2044
+ choices: ["create", "createOrUpdate", "mirror"],
2045
+ default: "mirror",
2046
+ type: "string"
2047
+ })
2048
+ )
1715
2049
  )
1716
2050
  )
1717
2051
  ),
@@ -1766,9 +2100,11 @@ var DataTypeRemoveModule = {
1766
2100
  command: "remove <id>",
1767
2101
  aliases: ["delete", "rm"],
1768
2102
  describe: "Delete a data type",
1769
- builder: (yargs21) => withApiOptions(
1770
- withProjectOptions(
1771
- yargs21.positional("id", { demandOption: true, describe: "Data type public ID to delete" })
2103
+ builder: (yargs23) => withConfiguration(
2104
+ withApiOptions(
2105
+ withProjectOptions(
2106
+ yargs23.positional("id", { demandOption: true, describe: "Data type public ID to delete" })
2107
+ )
1772
2108
  )
1773
2109
  ),
1774
2110
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -1784,9 +2120,11 @@ var DataTypeUpdateModule = {
1784
2120
  command: "update <filename>",
1785
2121
  aliases: ["put"],
1786
2122
  describe: "Insert or update a data type",
1787
- builder: (yargs21) => withApiOptions(
1788
- withProjectOptions(
1789
- yargs21.positional("filename", { demandOption: true, describe: "Data type file to put" })
2123
+ builder: (yargs23) => withConfiguration(
2124
+ withApiOptions(
2125
+ withProjectOptions(
2126
+ yargs23.positional("filename", { demandOption: true, describe: "Data type file to put" })
2127
+ )
1790
2128
  )
1791
2129
  ),
1792
2130
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -1802,38 +2140,206 @@ var DataTypeModule = {
1802
2140
  command: "datatype <command>",
1803
2141
  aliases: ["dt"],
1804
2142
  describe: "Commands for Data Type definitions",
1805
- builder: (yargs21) => yargs21.command(DataTypeGetModule).command(DataTypePullModule).command(DataTypePushModule).command(DataTypeRemoveModule).command(DataTypeListModule).command(DataTypeUpdateModule).demandCommand(),
2143
+ builder: (yargs23) => yargs23.command(DataTypeGetModule).command(DataTypePullModule).command(DataTypePushModule).command(DataTypeRemoveModule).command(DataTypeListModule).command(DataTypeUpdateModule).demandCommand(),
1806
2144
  handler: () => {
1807
2145
  yargs4.help();
1808
2146
  }
1809
2147
  };
1810
2148
 
2149
+ // src/commands/canvas/commands/pattern.ts
2150
+ import yargs5 from "yargs";
2151
+
2152
+ // src/commands/canvas/commands/pattern/get.ts
2153
+ var PatternGetModule = {
2154
+ ...CompositionGetModule,
2155
+ describe: "Fetch a pattern"
2156
+ };
2157
+
2158
+ // src/commands/canvas/commands/pattern/list.ts
2159
+ var PatternListModule = {
2160
+ ...CompositionListModule,
2161
+ describe: "List patterns",
2162
+ builder: (yargs23) => withFormatOptions(
2163
+ withConfiguration(
2164
+ withApiOptions(
2165
+ withProjectOptions(
2166
+ withStateOptions(
2167
+ yargs23.options({
2168
+ offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
2169
+ limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
2170
+ resolvePatterns: {
2171
+ type: "boolean",
2172
+ default: false,
2173
+ describe: "Resolve pattern references in the composition"
2174
+ },
2175
+ resolveOverrides: {
2176
+ type: "boolean",
2177
+ default: false,
2178
+ describe: "Resolves pattern overrides in the composition and removes override definition data"
2179
+ },
2180
+ onlyPatterns: {
2181
+ describe: "Only pulling patterns and not compositions",
2182
+ // This default differentiate this list command from composition list command
2183
+ default: true,
2184
+ type: "boolean",
2185
+ hidden: true
2186
+ },
2187
+ componentIDs: {
2188
+ alias: ["componentIDs"],
2189
+ type: "boolean",
2190
+ default: false,
2191
+ describe: "Include individual component UIDs"
2192
+ }
2193
+ })
2194
+ )
2195
+ )
2196
+ )
2197
+ )
2198
+ )
2199
+ };
2200
+
2201
+ // src/commands/canvas/commands/pattern/publish.ts
2202
+ var PatternPublishModule = {
2203
+ ...CompositionPublishModule,
2204
+ describe: "Publishes patterns"
2205
+ };
2206
+
2207
+ // src/commands/canvas/commands/pattern/pull.ts
2208
+ var PatternPullModule = {
2209
+ ...CompositionPullModule,
2210
+ describe: "Pulls all patterns to local files in a directory",
2211
+ builder: (yargs23) => withConfiguration(
2212
+ withApiOptions(
2213
+ withProjectOptions(
2214
+ withStateOptions(
2215
+ withDiffOptions(
2216
+ yargs23.positional("directory", {
2217
+ 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.",
2218
+ type: "string"
2219
+ }).option("format", {
2220
+ alias: ["f"],
2221
+ describe: "Output format",
2222
+ default: "yaml",
2223
+ choices: ["yaml", "json"],
2224
+ type: "string"
2225
+ }).option("onlyPatterns", {
2226
+ describe: "Only pulling patterns and not compositions",
2227
+ // This default differentiate this list command from composition list command
2228
+ default: true,
2229
+ type: "boolean",
2230
+ hidden: true
2231
+ }).option("what-if", {
2232
+ alias: ["w"],
2233
+ describe: "What-if mode reports what would be done but changes no files",
2234
+ default: false,
2235
+ type: "boolean"
2236
+ }).option("mode", {
2237
+ alias: ["m"],
2238
+ 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',
2239
+ choices: ["create", "createOrUpdate", "mirror"],
2240
+ default: "mirror",
2241
+ type: "string"
2242
+ })
2243
+ )
2244
+ )
2245
+ )
2246
+ )
2247
+ )
2248
+ };
2249
+
2250
+ // src/commands/canvas/commands/pattern/push.ts
2251
+ var PatternPushModule = {
2252
+ ...CompositionPushModule,
2253
+ describe: "Pushes all patterns from files in a directory to Uniform Canvas",
2254
+ builder: (yargs23) => withConfiguration(
2255
+ withApiOptions(
2256
+ withProjectOptions(
2257
+ withStateOptions(
2258
+ withDiffOptions(
2259
+ yargs23.positional("directory", {
2260
+ describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
2261
+ type: "string"
2262
+ }).option("what-if", {
2263
+ alias: ["w"],
2264
+ describe: "What-if mode reports what would be done but changes nothing",
2265
+ default: false,
2266
+ type: "boolean"
2267
+ }).option("mode", {
2268
+ alias: ["m"],
2269
+ 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',
2270
+ choices: ["create", "createOrUpdate", "mirror"],
2271
+ default: "mirror",
2272
+ type: "string"
2273
+ }).option("onlyPatterns", {
2274
+ describe: "Only pulling patterns and not compositions",
2275
+ // This default differentiate this list command from composition list command
2276
+ default: true,
2277
+ type: "boolean",
2278
+ hidden: true
2279
+ })
2280
+ )
2281
+ )
2282
+ )
2283
+ )
2284
+ )
2285
+ };
2286
+
2287
+ // src/commands/canvas/commands/pattern/remove.ts
2288
+ var PatternRemoveModule = {
2289
+ ...CompositionRemoveModule,
2290
+ describe: "Delete a pattern"
2291
+ };
2292
+
2293
+ // src/commands/canvas/commands/pattern/unpublish.ts
2294
+ var PatternUnpublishModule = {
2295
+ ...CompositionUnpublishModule,
2296
+ describe: "Unpublish a pattern"
2297
+ };
2298
+
2299
+ // src/commands/canvas/commands/pattern/update.ts
2300
+ var PatternUpdateModule = {
2301
+ ...CompositionUpdateModule,
2302
+ describe: "Insert or update a pattern"
2303
+ };
2304
+
2305
+ // src/commands/canvas/commands/pattern.ts
2306
+ var PatternModule = {
2307
+ command: "pattern <command>",
2308
+ describe: "Commands for Canvas patterns",
2309
+ builder: (yargs23) => yargs23.command(PatternPullModule).command(PatternPushModule).command(PatternGetModule).command(PatternRemoveModule).command(PatternListModule).command(PatternUpdateModule).command(PatternPublishModule).command(PatternUnpublishModule).demandCommand(),
2310
+ handler: () => {
2311
+ yargs5.help();
2312
+ }
2313
+ };
2314
+
1811
2315
  // src/commands/canvas/index.ts
1812
2316
  var CanvasCommand = {
1813
2317
  command: "canvas <command>",
1814
2318
  aliases: ["cv", "pm", "presentation"],
1815
2319
  describe: "Uniform Canvas commands",
1816
- builder: (yargs21) => yargs21.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(CategoryModule).demandCommand(),
2320
+ builder: (yargs23) => yargs23.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(CategoryModule).command(PatternModule).demandCommand(),
1817
2321
  handler: () => {
1818
- yargs5.showHelp();
2322
+ yargs6.showHelp();
1819
2323
  }
1820
2324
  };
1821
2325
 
1822
2326
  // src/commands/context/index.ts
1823
- import yargs12 from "yargs";
2327
+ import yargs13 from "yargs";
1824
2328
 
1825
2329
  // src/commands/context/commands/aggregate.ts
1826
- import yargs6 from "yargs";
2330
+ import yargs7 from "yargs";
1827
2331
 
1828
2332
  // src/commands/context/commands/aggregate/get.ts
1829
2333
  import { UncachedAggregateClient } from "@uniformdev/context/api";
1830
2334
  var AggregateGetModule = {
1831
2335
  command: "get <id>",
1832
2336
  describe: "Fetch an aggregate",
1833
- builder: (yargs21) => withFormatOptions(
1834
- withApiOptions(
1835
- withProjectOptions(
1836
- yargs21.positional("id", { demandOption: true, describe: "Aggregate public ID to fetch" })
2337
+ builder: (yargs23) => withConfiguration(
2338
+ withFormatOptions(
2339
+ withApiOptions(
2340
+ withProjectOptions(
2341
+ yargs23.positional("id", { demandOption: true, describe: "Aggregate public ID to fetch" })
2342
+ )
1837
2343
  )
1838
2344
  )
1839
2345
  ),
@@ -1856,7 +2362,7 @@ var AggregateListModule = {
1856
2362
  command: "list",
1857
2363
  describe: "List aggregates",
1858
2364
  aliases: ["ls"],
1859
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
2365
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
1860
2366
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
1861
2367
  const fetch3 = nodeFetchProxy(proxy);
1862
2368
  const client = new UncachedAggregateClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -1922,30 +2428,32 @@ function writeContextPackage(filename, packageContents) {
1922
2428
  var AggregatePullModule = {
1923
2429
  command: "pull <directory>",
1924
2430
  describe: "Pulls all aggregates to local files in a directory",
1925
- builder: (yargs21) => withApiOptions(
1926
- withProjectOptions(
1927
- withDiffOptions(
1928
- yargs21.positional("directory", {
1929
- describe: "Directory to save the aggregates to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
1930
- type: "string"
1931
- }).option("format", {
1932
- alias: ["f"],
1933
- describe: "Output format",
1934
- default: "yaml",
1935
- choices: ["yaml", "json"],
1936
- type: "string"
1937
- }).option("what-if", {
1938
- alias: ["w"],
1939
- describe: "What-if mode reports what would be done but changes no files",
1940
- default: false,
1941
- type: "boolean"
1942
- }).option("mode", {
1943
- alias: ["m"],
1944
- 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',
1945
- choices: ["create", "createOrUpdate", "mirror"],
1946
- default: "mirror",
1947
- type: "string"
1948
- })
2431
+ builder: (yargs23) => withConfiguration(
2432
+ withApiOptions(
2433
+ withProjectOptions(
2434
+ withDiffOptions(
2435
+ yargs23.positional("directory", {
2436
+ describe: "Directory to save the aggregates to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2437
+ type: "string"
2438
+ }).option("format", {
2439
+ alias: ["f"],
2440
+ describe: "Output format",
2441
+ default: "yaml",
2442
+ choices: ["yaml", "json"],
2443
+ type: "string"
2444
+ }).option("what-if", {
2445
+ alias: ["w"],
2446
+ describe: "What-if mode reports what would be done but changes no files",
2447
+ default: false,
2448
+ type: "boolean"
2449
+ }).option("mode", {
2450
+ alias: ["m"],
2451
+ 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',
2452
+ choices: ["create", "createOrUpdate", "mirror"],
2453
+ default: "mirror",
2454
+ type: "string"
2455
+ })
2456
+ )
1949
2457
  )
1950
2458
  )
1951
2459
  ),
@@ -1999,24 +2507,26 @@ import { UncachedAggregateClient as UncachedAggregateClient4 } from "@uniformdev
1999
2507
  var AggregatePushModule = {
2000
2508
  command: "push <directory>",
2001
2509
  describe: "Pushes all aggregates from files in a directory or package to Uniform",
2002
- builder: (yargs21) => withApiOptions(
2003
- withProjectOptions(
2004
- withDiffOptions(
2005
- yargs21.positional("directory", {
2006
- describe: "Directory to read the aggregates from. If a filename is used, a package will be read instead.",
2007
- type: "string"
2008
- }).option("what-if", {
2009
- alias: ["w"],
2010
- describe: "What-if mode reports what would be done but changes nothing",
2011
- default: false,
2012
- type: "boolean"
2013
- }).option("mode", {
2014
- alias: ["m"],
2015
- 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',
2016
- choices: ["create", "createOrUpdate", "mirror"],
2017
- default: "mirror",
2018
- type: "string"
2019
- })
2510
+ builder: (yargs23) => withConfiguration(
2511
+ withApiOptions(
2512
+ withProjectOptions(
2513
+ withDiffOptions(
2514
+ yargs23.positional("directory", {
2515
+ describe: "Directory to read the aggregates from. If a filename is used, a package will be read instead.",
2516
+ type: "string"
2517
+ }).option("what-if", {
2518
+ alias: ["w"],
2519
+ describe: "What-if mode reports what would be done but changes nothing",
2520
+ default: false,
2521
+ type: "boolean"
2522
+ }).option("mode", {
2523
+ alias: ["m"],
2524
+ 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',
2525
+ choices: ["create", "createOrUpdate", "mirror"],
2526
+ default: "mirror",
2527
+ type: "string"
2528
+ })
2529
+ )
2020
2530
  )
2021
2531
  )
2022
2532
  ),
@@ -2066,9 +2576,11 @@ var AggregateRemoveModule = {
2066
2576
  command: "remove <id>",
2067
2577
  aliases: ["delete", "rm"],
2068
2578
  describe: "Delete an aggregate",
2069
- builder: (yargs21) => withApiOptions(
2070
- withProjectOptions(
2071
- yargs21.positional("id", { demandOption: true, describe: "Aggregate public ID to delete" })
2579
+ builder: (yargs23) => withConfiguration(
2580
+ withApiOptions(
2581
+ withProjectOptions(
2582
+ yargs23.positional("id", { demandOption: true, describe: "Aggregate public ID to delete" })
2583
+ )
2072
2584
  )
2073
2585
  ),
2074
2586
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -2084,9 +2596,11 @@ var AggregateUpdateModule = {
2084
2596
  command: "update <filename>",
2085
2597
  aliases: ["put"],
2086
2598
  describe: "Insert or update an aggregate",
2087
- builder: (yargs21) => withApiOptions(
2088
- withProjectOptions(
2089
- yargs21.positional("filename", { demandOption: true, describe: "Aggregate file to put" })
2599
+ builder: (yargs23) => withConfiguration(
2600
+ withApiOptions(
2601
+ withProjectOptions(
2602
+ yargs23.positional("filename", { demandOption: true, describe: "Aggregate file to put" })
2603
+ )
2090
2604
  )
2091
2605
  ),
2092
2606
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -2102,24 +2616,26 @@ var AggregateModule = {
2102
2616
  command: "aggregate <command>",
2103
2617
  aliases: ["agg", "intent", "audience"],
2104
2618
  describe: "Commands for Context aggregates (intents, audiences)",
2105
- builder: (yargs21) => yargs21.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
2619
+ builder: (yargs23) => yargs23.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
2106
2620
  handler: () => {
2107
- yargs6.help();
2621
+ yargs7.help();
2108
2622
  }
2109
2623
  };
2110
2624
 
2111
2625
  // src/commands/context/commands/enrichment.ts
2112
- import yargs7 from "yargs";
2626
+ import yargs8 from "yargs";
2113
2627
 
2114
2628
  // src/commands/context/commands/enrichment/get.ts
2115
2629
  import { UncachedEnrichmentClient } from "@uniformdev/context/api";
2116
2630
  var EnrichmentGetModule = {
2117
2631
  command: "get <id>",
2118
2632
  describe: "Fetch an enrichment category and its values",
2119
- builder: (yargs21) => withFormatOptions(
2120
- withApiOptions(
2121
- withProjectOptions(
2122
- yargs21.positional("id", { demandOption: true, describe: "Enrichment category public ID to fetch" })
2633
+ builder: (yargs23) => withFormatOptions(
2634
+ withConfiguration(
2635
+ withApiOptions(
2636
+ withProjectOptions(
2637
+ yargs23.positional("id", { demandOption: true, describe: "Enrichment category public ID to fetch" })
2638
+ )
2123
2639
  )
2124
2640
  )
2125
2641
  ),
@@ -2143,7 +2659,7 @@ var EnrichmentListModule = {
2143
2659
  command: "list",
2144
2660
  describe: "List enrichments",
2145
2661
  aliases: ["ls"],
2146
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
2662
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
2147
2663
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
2148
2664
  const fetch3 = nodeFetchProxy(proxy);
2149
2665
  const client = new UncachedEnrichmentClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -2244,30 +2760,32 @@ var createEnrichmentValueEngineDataSource = ({
2244
2760
  var EnrichmentPullModule = {
2245
2761
  command: "pull <directory>",
2246
2762
  describe: "Pulls all enrichments to local files in a directory",
2247
- builder: (yargs21) => withApiOptions(
2248
- withProjectOptions(
2249
- withDiffOptions(
2250
- yargs21.positional("directory", {
2251
- describe: "Directory to save the enrichments to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2252
- type: "string"
2253
- }).option("format", {
2254
- alias: ["f"],
2255
- describe: "Output format",
2256
- default: "yaml",
2257
- choices: ["yaml", "json"],
2258
- type: "string"
2259
- }).option("what-if", {
2260
- alias: ["w"],
2261
- describe: "What-if mode reports what would be done but changes no files",
2262
- default: false,
2263
- type: "boolean"
2264
- }).option("mode", {
2265
- alias: ["m"],
2266
- 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',
2267
- choices: ["create", "createOrUpdate", "mirror"],
2268
- default: "mirror",
2269
- type: "string"
2270
- })
2763
+ builder: (yargs23) => withConfiguration(
2764
+ withApiOptions(
2765
+ withProjectOptions(
2766
+ withDiffOptions(
2767
+ yargs23.positional("directory", {
2768
+ describe: "Directory to save the enrichments to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2769
+ type: "string"
2770
+ }).option("format", {
2771
+ alias: ["f"],
2772
+ describe: "Output format",
2773
+ default: "yaml",
2774
+ choices: ["yaml", "json"],
2775
+ type: "string"
2776
+ }).option("what-if", {
2777
+ alias: ["w"],
2778
+ describe: "What-if mode reports what would be done but changes no files",
2779
+ default: false,
2780
+ type: "boolean"
2781
+ }).option("mode", {
2782
+ alias: ["m"],
2783
+ 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',
2784
+ choices: ["create", "createOrUpdate", "mirror"],
2785
+ default: "mirror",
2786
+ type: "string"
2787
+ })
2788
+ )
2271
2789
  )
2272
2790
  )
2273
2791
  ),
@@ -2321,24 +2839,26 @@ import { UncachedEnrichmentClient as UncachedEnrichmentClient4 } from "@uniformd
2321
2839
  var EnrichmentPushModule = {
2322
2840
  command: "push <directory>",
2323
2841
  describe: "Pushes all enrichments from files in a directory or package to Uniform",
2324
- builder: (yargs21) => withApiOptions(
2325
- withProjectOptions(
2326
- withDiffOptions(
2327
- yargs21.positional("directory", {
2328
- describe: "Directory to read the enrichments from. If a filename is used, a package will be read instead.",
2329
- type: "string"
2330
- }).option("what-if", {
2331
- alias: ["w"],
2332
- describe: "What-if mode reports what would be done but changes nothing",
2333
- default: false,
2334
- type: "boolean"
2335
- }).option("mode", {
2336
- alias: ["m"],
2337
- 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',
2338
- choices: ["create", "createOrUpdate", "mirror"],
2339
- default: "mirror",
2340
- type: "string"
2341
- })
2842
+ builder: (yargs23) => withConfiguration(
2843
+ withApiOptions(
2844
+ withProjectOptions(
2845
+ withDiffOptions(
2846
+ yargs23.positional("directory", {
2847
+ describe: "Directory to read the enrichments from. If a filename is used, a package will be read instead.",
2848
+ type: "string"
2849
+ }).option("what-if", {
2850
+ alias: ["w"],
2851
+ describe: "What-if mode reports what would be done but changes nothing",
2852
+ default: false,
2853
+ type: "boolean"
2854
+ }).option("mode", {
2855
+ alias: ["m"],
2856
+ 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',
2857
+ choices: ["create", "createOrUpdate", "mirror"],
2858
+ default: "mirror",
2859
+ type: "string"
2860
+ })
2861
+ )
2342
2862
  )
2343
2863
  )
2344
2864
  ),
@@ -2387,9 +2907,11 @@ var EnrichmentRemoveModule = {
2387
2907
  command: "remove <id>",
2388
2908
  aliases: ["delete", "rm"],
2389
2909
  describe: "Delete an enrichment category and its values",
2390
- builder: (yargs21) => withApiOptions(
2391
- withProjectOptions(
2392
- yargs21.positional("id", { demandOption: true, describe: "Enrichment category public ID to delete" })
2910
+ builder: (yargs23) => withConfiguration(
2911
+ withApiOptions(
2912
+ withProjectOptions(
2913
+ yargs23.positional("id", { demandOption: true, describe: "Enrichment category public ID to delete" })
2914
+ )
2393
2915
  )
2394
2916
  ),
2395
2917
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -2404,14 +2926,14 @@ var EnrichmentModule = {
2404
2926
  command: "enrichment <command>",
2405
2927
  aliases: ["enr"],
2406
2928
  describe: "Commands for Context enrichments",
2407
- builder: (yargs21) => yargs21.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
2929
+ builder: (yargs23) => yargs23.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
2408
2930
  handler: () => {
2409
- yargs7.help();
2931
+ yargs8.help();
2410
2932
  }
2411
2933
  };
2412
2934
 
2413
2935
  // src/commands/context/commands/manifest.ts
2414
- import yargs8 from "yargs";
2936
+ import yargs9 from "yargs";
2415
2937
 
2416
2938
  // src/commands/context/commands/manifest/get.ts
2417
2939
  import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
@@ -2422,20 +2944,22 @@ var ManifestGetModule = {
2422
2944
  command: "get [output]",
2423
2945
  aliases: ["dl", "download"],
2424
2946
  describe: "Download the Uniform Context manifest for a project",
2425
- builder: (yargs21) => withApiOptions(
2426
- withProjectOptions(
2427
- yargs21.option("preview", {
2428
- describe: "If set, fetches the unpublished preview manifest (The API key must have permission)",
2429
- default: false,
2430
- type: "boolean",
2431
- alias: ["d"]
2432
- }).option("output", {
2433
- string: true,
2434
- alias: "o",
2435
- default: process.env.UNIFORM_MANIFEST_PATH,
2436
- describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set.",
2437
- demandOption: true
2438
- })
2947
+ builder: (yargs23) => withConfiguration(
2948
+ withApiOptions(
2949
+ withProjectOptions(
2950
+ yargs23.option("preview", {
2951
+ describe: "If set, fetches the unpublished preview manifest (The API key must have permission)",
2952
+ default: false,
2953
+ type: "boolean",
2954
+ alias: ["d"]
2955
+ }).option("output", {
2956
+ string: true,
2957
+ alias: "o",
2958
+ default: process.env.UNIFORM_MANIFEST_PATH,
2959
+ describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set.",
2960
+ demandOption: true
2961
+ })
2962
+ )
2439
2963
  )
2440
2964
  ),
2441
2965
  handler: async ({ apiKey, apiHost, proxy, output, project, preview }) => {
@@ -2485,7 +3009,7 @@ import { exit as exit2 } from "process";
2485
3009
  var ManifestPublishModule = {
2486
3010
  command: "publish",
2487
3011
  describe: "Publish the Uniform Context manifest for a project",
2488
- builder: (yargs21) => withApiOptions(withProjectOptions(yargs21)),
3012
+ builder: (yargs23) => withConfiguration(withApiOptions(withProjectOptions(yargs23))),
2489
3013
  handler: async ({ apiKey, apiHost, proxy, project }) => {
2490
3014
  const fetch3 = nodeFetchProxy(proxy);
2491
3015
  try {
@@ -2518,24 +3042,26 @@ var ManifestModule = {
2518
3042
  command: "manifest <command>",
2519
3043
  describe: "Commands for context manifests",
2520
3044
  aliases: ["man"],
2521
- builder: (yargs21) => yargs21.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
3045
+ builder: (yargs23) => yargs23.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
2522
3046
  handler: () => {
2523
- yargs8.help();
3047
+ yargs9.help();
2524
3048
  }
2525
3049
  };
2526
3050
 
2527
3051
  // src/commands/context/commands/quirk.ts
2528
- import yargs9 from "yargs";
3052
+ import yargs10 from "yargs";
2529
3053
 
2530
3054
  // src/commands/context/commands/quirk/get.ts
2531
3055
  import { UncachedQuirkClient } from "@uniformdev/context/api";
2532
3056
  var QuirkGetModule = {
2533
3057
  command: "get <id>",
2534
3058
  describe: "Fetch a quirk",
2535
- builder: (yargs21) => withFormatOptions(
2536
- withApiOptions(
2537
- withProjectOptions(
2538
- yargs21.positional("id", { demandOption: true, describe: "Quirk public ID to fetch" })
3059
+ builder: (yargs23) => withConfiguration(
3060
+ withFormatOptions(
3061
+ withApiOptions(
3062
+ withProjectOptions(
3063
+ yargs23.positional("id", { demandOption: true, describe: "Quirk public ID to fetch" })
3064
+ )
2539
3065
  )
2540
3066
  )
2541
3067
  ),
@@ -2558,14 +3084,16 @@ var QuirkListModule = {
2558
3084
  command: "list",
2559
3085
  describe: "List quirks",
2560
3086
  aliases: ["ls"],
2561
- builder: (yargs21) => withFormatOptions(
2562
- withApiOptions(
2563
- withProjectOptions(
2564
- yargs21.option("withIntegrations", {
2565
- alias: ["i"],
2566
- describe: "Whether to include meta-quirks created by integrations in the list. Defaults to false.",
2567
- type: "boolean"
2568
- })
3087
+ builder: (yargs23) => withConfiguration(
3088
+ withFormatOptions(
3089
+ withApiOptions(
3090
+ withProjectOptions(
3091
+ yargs23.option("withIntegrations", {
3092
+ alias: ["i"],
3093
+ describe: "Whether to include meta-quirks created by integrations in the list. Defaults to false.",
3094
+ type: "boolean"
3095
+ })
3096
+ )
2569
3097
  )
2570
3098
  )
2571
3099
  ),
@@ -2617,30 +3145,32 @@ function createQuirkEngineDataSource({
2617
3145
  var QuirkPullModule = {
2618
3146
  command: "pull <directory>",
2619
3147
  describe: "Pulls all quirks to local files in a directory",
2620
- builder: (yargs21) => withApiOptions(
2621
- withProjectOptions(
2622
- withDiffOptions(
2623
- yargs21.positional("directory", {
2624
- describe: "Directory to save the quirks to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2625
- type: "string"
2626
- }).option("format", {
2627
- alias: ["f"],
2628
- describe: "Output format",
2629
- default: "yaml",
2630
- choices: ["yaml", "json"],
2631
- type: "string"
2632
- }).option("what-if", {
2633
- alias: ["w"],
2634
- describe: "What-if mode reports what would be done but changes no files",
2635
- default: false,
2636
- type: "boolean"
2637
- }).option("mode", {
2638
- alias: ["m"],
2639
- 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',
2640
- choices: ["create", "createOrUpdate", "mirror"],
2641
- default: "mirror",
2642
- type: "string"
2643
- })
3148
+ builder: (yargs23) => withConfiguration(
3149
+ withApiOptions(
3150
+ withProjectOptions(
3151
+ withDiffOptions(
3152
+ yargs23.positional("directory", {
3153
+ describe: "Directory to save the quirks to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
3154
+ type: "string"
3155
+ }).option("format", {
3156
+ alias: ["f"],
3157
+ describe: "Output format",
3158
+ default: "yaml",
3159
+ choices: ["yaml", "json"],
3160
+ type: "string"
3161
+ }).option("what-if", {
3162
+ alias: ["w"],
3163
+ describe: "What-if mode reports what would be done but changes no files",
3164
+ default: false,
3165
+ type: "boolean"
3166
+ }).option("mode", {
3167
+ alias: ["m"],
3168
+ 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',
3169
+ choices: ["create", "createOrUpdate", "mirror"],
3170
+ default: "mirror",
3171
+ type: "string"
3172
+ })
3173
+ )
2644
3174
  )
2645
3175
  )
2646
3176
  ),
@@ -2694,24 +3224,26 @@ import { UncachedQuirkClient as UncachedQuirkClient4 } from "@uniformdev/context
2694
3224
  var QuirkPushModule = {
2695
3225
  command: "push <directory>",
2696
3226
  describe: "Pushes all quirks from files in a directory or package to Uniform",
2697
- builder: (yargs21) => withApiOptions(
2698
- withProjectOptions(
2699
- withDiffOptions(
2700
- yargs21.positional("directory", {
2701
- describe: "Directory to read the quirks from. If a filename is used, a package will be read instead.",
2702
- type: "string"
2703
- }).option("what-if", {
2704
- alias: ["w"],
2705
- describe: "What-if mode reports what would be done but changes nothing",
2706
- default: false,
2707
- type: "boolean"
2708
- }).option("mode", {
2709
- alias: ["m"],
2710
- 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',
2711
- choices: ["create", "createOrUpdate", "mirror"],
2712
- default: "mirror",
2713
- type: "string"
2714
- })
3227
+ builder: (yargs23) => withConfiguration(
3228
+ withApiOptions(
3229
+ withProjectOptions(
3230
+ withDiffOptions(
3231
+ yargs23.positional("directory", {
3232
+ describe: "Directory to read the quirks from. If a filename is used, a package will be read instead.",
3233
+ type: "string"
3234
+ }).option("what-if", {
3235
+ alias: ["w"],
3236
+ describe: "What-if mode reports what would be done but changes nothing",
3237
+ default: false,
3238
+ type: "boolean"
3239
+ }).option("mode", {
3240
+ alias: ["m"],
3241
+ 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',
3242
+ choices: ["create", "createOrUpdate", "mirror"],
3243
+ default: "mirror",
3244
+ type: "string"
3245
+ })
3246
+ )
2715
3247
  )
2716
3248
  )
2717
3249
  ),
@@ -2760,9 +3292,11 @@ var QuirkRemoveModule = {
2760
3292
  command: "remove <id>",
2761
3293
  aliases: ["delete", "rm"],
2762
3294
  describe: "Delete a quirk",
2763
- builder: (yargs21) => withApiOptions(
2764
- withProjectOptions(
2765
- yargs21.positional("id", { demandOption: true, describe: "Quirk public ID to delete" })
3295
+ builder: (yargs23) => withConfiguration(
3296
+ withApiOptions(
3297
+ withProjectOptions(
3298
+ yargs23.positional("id", { demandOption: true, describe: "Quirk public ID to delete" })
3299
+ )
2766
3300
  )
2767
3301
  ),
2768
3302
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -2778,8 +3312,12 @@ var QuirkUpdateModule = {
2778
3312
  command: "update <filename>",
2779
3313
  aliases: ["put"],
2780
3314
  describe: "Insert or update a quirk",
2781
- builder: (yargs21) => withApiOptions(
2782
- withProjectOptions(yargs21.positional("filename", { demandOption: true, describe: "Quirk file to put" }))
3315
+ builder: (yargs23) => withConfiguration(
3316
+ withApiOptions(
3317
+ withProjectOptions(
3318
+ yargs23.positional("filename", { demandOption: true, describe: "Quirk file to put" })
3319
+ )
3320
+ )
2783
3321
  ),
2784
3322
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
2785
3323
  const fetch3 = nodeFetchProxy(proxy);
@@ -2794,24 +3332,26 @@ var QuirkModule = {
2794
3332
  command: "quirk <command>",
2795
3333
  aliases: ["qk"],
2796
3334
  describe: "Commands for Context quirks",
2797
- builder: (yargs21) => yargs21.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
3335
+ builder: (yargs23) => yargs23.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
2798
3336
  handler: () => {
2799
- yargs9.help();
3337
+ yargs10.help();
2800
3338
  }
2801
3339
  };
2802
3340
 
2803
3341
  // src/commands/context/commands/signal.ts
2804
- import yargs10 from "yargs";
3342
+ import yargs11 from "yargs";
2805
3343
 
2806
3344
  // src/commands/context/commands/signal/get.ts
2807
3345
  import { UncachedSignalClient } from "@uniformdev/context/api";
2808
3346
  var SignalGetModule = {
2809
3347
  command: "get <id>",
2810
3348
  describe: "Fetch a signal",
2811
- builder: (yargs21) => withFormatOptions(
2812
- withApiOptions(
2813
- withProjectOptions(
2814
- yargs21.positional("id", { demandOption: true, describe: "Signal public ID to fetch" })
3349
+ builder: (yargs23) => withConfiguration(
3350
+ withFormatOptions(
3351
+ withApiOptions(
3352
+ withProjectOptions(
3353
+ yargs23.positional("id", { demandOption: true, describe: "Signal public ID to fetch" })
3354
+ )
2815
3355
  )
2816
3356
  )
2817
3357
  ),
@@ -2834,7 +3374,7 @@ var SignalListModule = {
2834
3374
  command: "list",
2835
3375
  describe: "List signals",
2836
3376
  aliases: ["ls"],
2837
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
3377
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
2838
3378
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
2839
3379
  const fetch3 = nodeFetchProxy(proxy);
2840
3380
  const client = new UncachedSignalClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -2883,30 +3423,32 @@ function createSignalEngineDataSource({
2883
3423
  var SignalPullModule = {
2884
3424
  command: "pull <directory>",
2885
3425
  describe: "Pulls all signals to local files in a directory",
2886
- builder: (yargs21) => withApiOptions(
2887
- withProjectOptions(
2888
- withDiffOptions(
2889
- yargs21.positional("directory", {
2890
- describe: "Directory to save the signals to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2891
- type: "string"
2892
- }).option("format", {
2893
- alias: ["f"],
2894
- describe: "Output format",
2895
- default: "yaml",
2896
- choices: ["yaml", "json"],
2897
- type: "string"
2898
- }).option("what-if", {
2899
- alias: ["w"],
2900
- describe: "What-if mode reports what would be done but changes no files",
2901
- default: false,
2902
- type: "boolean"
2903
- }).option("mode", {
2904
- alias: ["m"],
2905
- 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',
2906
- choices: ["create", "createOrUpdate", "mirror"],
2907
- default: "mirror",
2908
- type: "string"
2909
- })
3426
+ builder: (yargs23) => withConfiguration(
3427
+ withApiOptions(
3428
+ withProjectOptions(
3429
+ withDiffOptions(
3430
+ yargs23.positional("directory", {
3431
+ describe: "Directory to save the signals to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
3432
+ type: "string"
3433
+ }).option("format", {
3434
+ alias: ["f"],
3435
+ describe: "Output format",
3436
+ default: "yaml",
3437
+ choices: ["yaml", "json"],
3438
+ type: "string"
3439
+ }).option("what-if", {
3440
+ alias: ["w"],
3441
+ describe: "What-if mode reports what would be done but changes no files",
3442
+ default: false,
3443
+ type: "boolean"
3444
+ }).option("mode", {
3445
+ alias: ["m"],
3446
+ 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',
3447
+ choices: ["create", "createOrUpdate", "mirror"],
3448
+ default: "mirror",
3449
+ type: "string"
3450
+ })
3451
+ )
2910
3452
  )
2911
3453
  )
2912
3454
  ),
@@ -2960,24 +3502,26 @@ import { UncachedSignalClient as UncachedSignalClient4 } from "@uniformdev/conte
2960
3502
  var SignalPushModule = {
2961
3503
  command: "push <directory>",
2962
3504
  describe: "Pushes all signals from files in a directory or package to Uniform",
2963
- builder: (yargs21) => withApiOptions(
2964
- withProjectOptions(
2965
- withDiffOptions(
2966
- yargs21.positional("directory", {
2967
- describe: "Directory to read the signals from. If a filename is used, a package will be read instead.",
2968
- type: "string"
2969
- }).option("what-if", {
2970
- alias: ["w"],
2971
- describe: "What-if mode reports what would be done but changes nothing",
2972
- default: false,
2973
- type: "boolean"
2974
- }).option("mode", {
2975
- alias: ["m"],
2976
- 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',
2977
- choices: ["create", "createOrUpdate", "mirror"],
2978
- default: "mirror",
2979
- type: "string"
2980
- })
3505
+ builder: (yargs23) => withConfiguration(
3506
+ withApiOptions(
3507
+ withProjectOptions(
3508
+ withDiffOptions(
3509
+ yargs23.positional("directory", {
3510
+ describe: "Directory to read the signals from. If a filename is used, a package will be read instead.",
3511
+ type: "string"
3512
+ }).option("what-if", {
3513
+ alias: ["w"],
3514
+ describe: "What-if mode reports what would be done but changes nothing",
3515
+ default: false,
3516
+ type: "boolean"
3517
+ }).option("mode", {
3518
+ alias: ["m"],
3519
+ 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',
3520
+ choices: ["create", "createOrUpdate", "mirror"],
3521
+ default: "mirror",
3522
+ type: "string"
3523
+ })
3524
+ )
2981
3525
  )
2982
3526
  )
2983
3527
  ),
@@ -3026,9 +3570,11 @@ var SignalRemoveModule = {
3026
3570
  command: "remove <id>",
3027
3571
  aliases: ["delete", "rm"],
3028
3572
  describe: "Delete a signal",
3029
- builder: (yargs21) => withApiOptions(
3030
- withProjectOptions(
3031
- yargs21.positional("id", { demandOption: true, describe: "Signal public ID to delete" })
3573
+ builder: (yargs23) => withConfiguration(
3574
+ withApiOptions(
3575
+ withProjectOptions(
3576
+ yargs23.positional("id", { demandOption: true, describe: "Signal public ID to delete" })
3577
+ )
3032
3578
  )
3033
3579
  ),
3034
3580
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -3044,8 +3590,12 @@ var SignalUpdateModule = {
3044
3590
  command: "update <filename>",
3045
3591
  aliases: ["put"],
3046
3592
  describe: "Insert or update a signal",
3047
- builder: (yargs21) => withApiOptions(
3048
- withProjectOptions(yargs21.positional("filename", { demandOption: true, describe: "Signal file to put" }))
3593
+ builder: (yargs23) => withConfiguration(
3594
+ withApiOptions(
3595
+ withProjectOptions(
3596
+ yargs23.positional("filename", { demandOption: true, describe: "Signal file to put" })
3597
+ )
3598
+ )
3049
3599
  ),
3050
3600
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
3051
3601
  const fetch3 = nodeFetchProxy(proxy);
@@ -3060,24 +3610,26 @@ var SignalModule = {
3060
3610
  command: "signal <command>",
3061
3611
  aliases: ["sig"],
3062
3612
  describe: "Commands for Context signals",
3063
- builder: (yargs21) => yargs21.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
3613
+ builder: (yargs23) => yargs23.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
3064
3614
  handler: () => {
3065
- yargs10.help();
3615
+ yargs11.help();
3066
3616
  }
3067
3617
  };
3068
3618
 
3069
3619
  // src/commands/context/commands/test.ts
3070
- import yargs11 from "yargs";
3620
+ import yargs12 from "yargs";
3071
3621
 
3072
3622
  // src/commands/context/commands/test/get.ts
3073
3623
  import { UncachedTestClient } from "@uniformdev/context/api";
3074
3624
  var TestGetModule = {
3075
3625
  command: "get <id>",
3076
3626
  describe: "Fetch a test",
3077
- builder: (yargs21) => withFormatOptions(
3078
- withApiOptions(
3079
- withProjectOptions(
3080
- yargs21.positional("id", { demandOption: true, describe: "Test public ID to fetch" })
3627
+ builder: (yargs23) => withConfiguration(
3628
+ withFormatOptions(
3629
+ withApiOptions(
3630
+ withProjectOptions(
3631
+ yargs23.positional("id", { demandOption: true, describe: "Test public ID to fetch" })
3632
+ )
3081
3633
  )
3082
3634
  )
3083
3635
  ),
@@ -3100,7 +3652,7 @@ var TestListModule = {
3100
3652
  command: "list",
3101
3653
  describe: "List tests",
3102
3654
  aliases: ["ls"],
3103
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
3655
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
3104
3656
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
3105
3657
  const fetch3 = nodeFetchProxy(proxy);
3106
3658
  const client = new UncachedTestClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -3149,30 +3701,32 @@ function createTestEngineDataSource({
3149
3701
  var TestPullModule = {
3150
3702
  command: "pull <directory>",
3151
3703
  describe: "Pulls all tests to local files in a directory",
3152
- builder: (yargs21) => withApiOptions(
3153
- withProjectOptions(
3154
- withDiffOptions(
3155
- yargs21.positional("directory", {
3156
- describe: "Directory to save the tests to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
3157
- type: "string"
3158
- }).option("format", {
3159
- alias: ["f"],
3160
- describe: "Output format",
3161
- default: "yaml",
3162
- choices: ["yaml", "json"],
3163
- type: "string"
3164
- }).option("what-if", {
3165
- alias: ["w"],
3166
- describe: "What-if mode reports what would be done but changes no files",
3167
- default: false,
3168
- type: "boolean"
3169
- }).option("mode", {
3170
- alias: ["m"],
3171
- 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',
3172
- choices: ["create", "createOrUpdate", "mirror"],
3173
- default: "mirror",
3174
- type: "string"
3175
- })
3704
+ builder: (yargs23) => withConfiguration(
3705
+ withApiOptions(
3706
+ withProjectOptions(
3707
+ withDiffOptions(
3708
+ yargs23.positional("directory", {
3709
+ describe: "Directory to save the tests to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
3710
+ type: "string"
3711
+ }).option("format", {
3712
+ alias: ["f"],
3713
+ describe: "Output format",
3714
+ default: "yaml",
3715
+ choices: ["yaml", "json"],
3716
+ type: "string"
3717
+ }).option("what-if", {
3718
+ alias: ["w"],
3719
+ describe: "What-if mode reports what would be done but changes no files",
3720
+ default: false,
3721
+ type: "boolean"
3722
+ }).option("mode", {
3723
+ alias: ["m"],
3724
+ 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',
3725
+ choices: ["create", "createOrUpdate", "mirror"],
3726
+ default: "mirror",
3727
+ type: "string"
3728
+ })
3729
+ )
3176
3730
  )
3177
3731
  )
3178
3732
  ),
@@ -3226,24 +3780,26 @@ import { UncachedTestClient as UncachedTestClient4 } from "@uniformdev/context/a
3226
3780
  var TestPushModule = {
3227
3781
  command: "push <directory>",
3228
3782
  describe: "Pushes all tests from files in a directory or package to Uniform",
3229
- builder: (yargs21) => withApiOptions(
3230
- withProjectOptions(
3231
- withDiffOptions(
3232
- yargs21.positional("directory", {
3233
- describe: "Directory to read the tests from. If a filename is used, a package will be read instead.",
3234
- type: "string"
3235
- }).option("what-if", {
3236
- alias: ["w"],
3237
- describe: "What-if mode reports what would be done but changes nothing",
3238
- default: false,
3239
- type: "boolean"
3240
- }).option("mode", {
3241
- alias: ["m"],
3242
- 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',
3243
- choices: ["create", "createOrUpdate", "mirror"],
3244
- default: "mirror",
3245
- type: "string"
3246
- })
3783
+ builder: (yargs23) => withConfiguration(
3784
+ withApiOptions(
3785
+ withProjectOptions(
3786
+ withDiffOptions(
3787
+ yargs23.positional("directory", {
3788
+ describe: "Directory to read the tests from. If a filename is used, a package will be read instead.",
3789
+ type: "string"
3790
+ }).option("what-if", {
3791
+ alias: ["w"],
3792
+ describe: "What-if mode reports what would be done but changes nothing",
3793
+ default: false,
3794
+ type: "boolean"
3795
+ }).option("mode", {
3796
+ alias: ["m"],
3797
+ 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',
3798
+ choices: ["create", "createOrUpdate", "mirror"],
3799
+ default: "mirror",
3800
+ type: "string"
3801
+ })
3802
+ )
3247
3803
  )
3248
3804
  )
3249
3805
  ),
@@ -3292,8 +3848,12 @@ var TestRemoveModule = {
3292
3848
  command: "remove <id>",
3293
3849
  aliases: ["delete", "rm"],
3294
3850
  describe: "Delete a test",
3295
- builder: (yargs21) => withApiOptions(
3296
- withProjectOptions(yargs21.positional("id", { demandOption: true, describe: "Test public ID to delete" }))
3851
+ builder: (yargs23) => withConfiguration(
3852
+ withApiOptions(
3853
+ withProjectOptions(
3854
+ yargs23.positional("id", { demandOption: true, describe: "Test public ID to delete" })
3855
+ )
3856
+ )
3297
3857
  ),
3298
3858
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
3299
3859
  const fetch3 = nodeFetchProxy(proxy);
@@ -3308,8 +3868,10 @@ var TestUpdateModule = {
3308
3868
  command: "update <filename>",
3309
3869
  aliases: ["put"],
3310
3870
  describe: "Insert or update a test",
3311
- builder: (yargs21) => withApiOptions(
3312
- withProjectOptions(yargs21.positional("filename", { demandOption: true, describe: "Test file to put" }))
3871
+ builder: (yargs23) => withConfiguration(
3872
+ withApiOptions(
3873
+ withProjectOptions(yargs23.positional("filename", { demandOption: true, describe: "Test file to put" }))
3874
+ )
3313
3875
  ),
3314
3876
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
3315
3877
  const fetch3 = nodeFetchProxy(proxy);
@@ -3323,9 +3885,9 @@ var TestUpdateModule = {
3323
3885
  var TestModule = {
3324
3886
  command: "test <command>",
3325
3887
  describe: "Commands for Context A/B tests",
3326
- builder: (yargs21) => yargs21.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
3888
+ builder: (yargs23) => yargs23.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
3327
3889
  handler: () => {
3328
- yargs11.help();
3890
+ yargs12.help();
3329
3891
  }
3330
3892
  };
3331
3893
 
@@ -3334,9 +3896,9 @@ var ContextCommand = {
3334
3896
  command: "context <command>",
3335
3897
  aliases: ["ctx"],
3336
3898
  describe: "Uniform Context commands",
3337
- builder: (yargs21) => yargs21.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
3899
+ builder: (yargs23) => yargs23.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
3338
3900
  handler: () => {
3339
- yargs12.showHelp();
3901
+ yargs13.showHelp();
3340
3902
  }
3341
3903
  };
3342
3904
 
@@ -3364,11 +3926,11 @@ import { PostHog } from "posthog-node";
3364
3926
  // package.json
3365
3927
  var package_default = {
3366
3928
  name: "@uniformdev/cli",
3367
- version: "19.41.0",
3929
+ version: "19.42.0",
3368
3930
  description: "Uniform command line interface tool",
3369
3931
  license: "SEE LICENSE IN LICENSE.txt",
3370
3932
  main: "./cli.js",
3371
- types: "./dist/index.d.ts",
3933
+ types: "./dist/index.d.mts",
3372
3934
  sideEffects: false,
3373
3935
  scripts: {
3374
3936
  uniform: "node ./cli.js",
@@ -3380,12 +3942,15 @@ var package_default = {
3380
3942
  format: 'prettier --write "src/**/*.{js,ts,tsx}"'
3381
3943
  },
3382
3944
  dependencies: {
3945
+ "@thi.ng/mime": "^2.2.23",
3383
3946
  "@uniformdev/canvas": "workspace:*",
3384
3947
  "@uniformdev/context": "workspace:*",
3948
+ "@uniformdev/files-sdk": "workspace:*",
3385
3949
  "@uniformdev/project-map": "workspace:*",
3386
3950
  "@uniformdev/redirect": "workspace:*",
3387
3951
  colorette: "2.0.20",
3388
- cosmiconfig: "^8.2.0",
3952
+ cosmiconfig: "8.2.0",
3953
+ "cosmiconfig-typescript-loader": "5.0.0",
3389
3954
  diff: "^5.0.0",
3390
3955
  dotenv: "^16.0.3",
3391
3956
  execa: "5.1.1",
@@ -3393,6 +3958,7 @@ var package_default = {
3393
3958
  graphql: "16.7.1",
3394
3959
  "graphql-request": "6.1.0",
3395
3960
  "https-proxy-agent": "^7.0.0",
3961
+ "image-size": "^1.0.2",
3396
3962
  inquirer: "9.2.9",
3397
3963
  "isomorphic-git": "1.24.5",
3398
3964
  "isomorphic-unfetch": "^3.1.0",
@@ -3401,6 +3967,7 @@ var package_default = {
3401
3967
  "lodash.isequalwith": "^4.4.0",
3402
3968
  open: "9.1.0",
3403
3969
  ora: "6.3.1",
3970
+ "p-queue": "7.3.4",
3404
3971
  "posthog-node": "3.1.1",
3405
3972
  slugify: "1.6.6",
3406
3973
  "update-check": "^1.5.4",
@@ -3737,8 +4304,8 @@ ${err.message}`);
3737
4304
 
3738
4305
  // src/projects/cloneStarter.ts
3739
4306
  import crypto2 from "crypto";
3740
- import fs2 from "fs";
3741
- import fsj from "fs-jetpack";
4307
+ import fs3 from "fs";
4308
+ import fsj2 from "fs-jetpack";
3742
4309
  import * as git from "isomorphic-git";
3743
4310
  import * as http from "isomorphic-git/http/node/index.js";
3744
4311
  import os from "os";
@@ -3754,7 +4321,7 @@ async function cloneStarter({
3754
4321
  const [user, repo, ...pathSegments] = githubPath.split("/");
3755
4322
  try {
3756
4323
  await git.clone({
3757
- fs: fs2,
4324
+ fs: fs3,
3758
4325
  http,
3759
4326
  url: `https://github.com/${user}/${repo}`,
3760
4327
  dir: cloneDir,
@@ -3765,13 +4332,13 @@ async function cloneStarter({
3765
4332
  throw new Error(`Failed to fetch starter code: ${err.message}`);
3766
4333
  }
3767
4334
  await done();
3768
- if (fs2.existsSync(targetDir) && fs2.readdirSync(targetDir).length > 0) {
4335
+ if (fs3.existsSync(targetDir) && fs3.readdirSync(targetDir).length > 0) {
3769
4336
  throw new Error(`"${targetDir}" is not empty`);
3770
4337
  }
3771
4338
  const starterDir = path.join(cloneDir, ...pathSegments);
3772
- fsj.copy(starterDir, targetDir, { overwrite: true });
4339
+ fsj2.copy(starterDir, targetDir, { overwrite: true });
3773
4340
  if (dotEnvFile) {
3774
- fs2.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
4341
+ fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
3775
4342
  }
3776
4343
  console.log(`
3777
4344
  Your project now lives in ${targetDir} \u2728`);
@@ -3787,7 +4354,7 @@ Installing project dependencies...
3787
4354
  }
3788
4355
 
3789
4356
  // src/projects/getOrCreateProject.ts
3790
- import fs3, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
4357
+ import fs4, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
3791
4358
  import inquirer2 from "inquirer";
3792
4359
  import path2 from "path";
3793
4360
  import slugify from "slugify";
@@ -3914,9 +4481,9 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
3914
4481
  if (!existsSync2(targetDir)) {
3915
4482
  mkdirSync2(targetDir, { recursive: true });
3916
4483
  }
3917
- if (fs3.readdirSync(targetDir).length > 0) {
4484
+ if (fs4.readdirSync(targetDir).length > 0) {
3918
4485
  targetDir = path2.resolve(targetDir, projectNameSlug);
3919
- if (fs3.existsSync(targetDir)) {
4486
+ if (fs4.existsSync(targetDir)) {
3920
4487
  throw new Error(`${targetDir} already exists, choose a different name.`);
3921
4488
  }
3922
4489
  }
@@ -4324,24 +4891,26 @@ var disableTelemetryDefault = !["", "0", "false", "no"].includes(
4324
4891
  );
4325
4892
  var NewCmd = {
4326
4893
  command: "new [name]",
4327
- builder: (y) => y.positional("name", {
4328
- describe: "Name of a project",
4329
- type: "string"
4330
- }).option("apiHost", {
4331
- describe: `Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or ${stableApiHost}. Supports dotenv.`,
4332
- default: apiHostDefault,
4333
- demandOption: true,
4334
- type: "string"
4335
- }).option("outputPath", {
4336
- alias: "o",
4337
- description: "Specify where to store integration files. Defaults to cwd.",
4338
- type: "string"
4339
- }).option("disableTelemetry", {
4340
- describe: "By default, usage information is sent to Uniform. Use this option or set UNIFORM_CLI_DISABLE_TELEMETRY to disable telemetry.",
4341
- default: disableTelemetryDefault,
4342
- demandOption: true,
4343
- type: "boolean"
4344
- }),
4894
+ builder: (y) => withConfiguration(
4895
+ y.positional("name", {
4896
+ describe: "Name of a project",
4897
+ type: "string"
4898
+ }).option("apiHost", {
4899
+ describe: `Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or ${stableApiHost}. Supports dotenv.`,
4900
+ default: apiHostDefault,
4901
+ demandOption: true,
4902
+ type: "string"
4903
+ }).option("outputPath", {
4904
+ alias: "o",
4905
+ description: "Specify where to store integration files. Defaults to cwd.",
4906
+ type: "string"
4907
+ }).option("disableTelemetry", {
4908
+ describe: "By default, usage information is sent to Uniform. Use this option or set UNIFORM_CLI_DISABLE_TELEMETRY to disable telemetry.",
4909
+ default: disableTelemetryDefault,
4910
+ demandOption: true,
4911
+ type: "boolean"
4912
+ })
4913
+ ),
4345
4914
  describe: "Start a new Uniform project",
4346
4915
  handler: async function({ name, apiHost, outputPath, disableTelemetry }) {
4347
4916
  const { stopAllSpinners, spin } = makeSpinner();
@@ -4362,21 +4931,23 @@ var NewCmd = {
4362
4931
  };
4363
4932
  var NewMeshCmd = {
4364
4933
  command: "new-integration",
4365
- builder: (y) => y.option("apiHost", {
4366
- describe: `Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or ${stableApiHost}. Supports dotenv.`,
4367
- default: apiHostDefault,
4368
- demandOption: true,
4369
- type: "string"
4370
- }).option("outputPath", {
4371
- alias: "o",
4372
- description: "Specify where to store integration files. Defaults to cwd.",
4373
- type: "string"
4374
- }).option("disableTelemetry", {
4375
- describe: "By default, usage information is sent to Uniform. Use this option or set UNIFORM_CLI_DISABLE_TELEMETRY to disable telemetry.",
4376
- default: disableTelemetryDefault,
4377
- demandOption: true,
4378
- type: "boolean"
4379
- }),
4934
+ builder: (y) => withConfiguration(
4935
+ y.option("apiHost", {
4936
+ describe: `Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or ${stableApiHost}. Supports dotenv.`,
4937
+ default: apiHostDefault,
4938
+ demandOption: true,
4939
+ type: "string"
4940
+ }).option("outputPath", {
4941
+ alias: "o",
4942
+ description: "Specify where to store integration files. Defaults to cwd.",
4943
+ type: "string"
4944
+ }).option("disableTelemetry", {
4945
+ describe: "By default, usage information is sent to Uniform. Use this option or set UNIFORM_CLI_DISABLE_TELEMETRY to disable telemetry.",
4946
+ default: disableTelemetryDefault,
4947
+ demandOption: true,
4948
+ type: "boolean"
4949
+ })
4950
+ ),
4380
4951
  describe: "Start a new Uniform project",
4381
4952
  handler: async function({ apiHost, outputPath, disableTelemetry }) {
4382
4953
  const { stopAllSpinners, spin } = makeSpinner();
@@ -4397,10 +4968,10 @@ var NewMeshCmd = {
4397
4968
  };
4398
4969
 
4399
4970
  // src/commands/optimize/index.ts
4400
- import yargs14 from "yargs";
4971
+ import yargs15 from "yargs";
4401
4972
 
4402
4973
  // src/commands/optimize/manifest.ts
4403
- import yargs13 from "yargs";
4974
+ import yargs14 from "yargs";
4404
4975
 
4405
4976
  // src/commands/optimize/manifest/download.ts
4406
4977
  import { gray as gray4, green as green3, red as red5, yellow as yellow2 } from "colorette";
@@ -4415,7 +4986,7 @@ var UniformBaseUrl = "https://uniform.app";
4415
4986
  var module = {
4416
4987
  command: "download [output]",
4417
4988
  describe: "Download intent manifest",
4418
- builder: (yargs21) => yargs21.option("apiKey", {
4989
+ builder: (yargs23) => yargs23.option("apiKey", {
4419
4990
  alias: "k",
4420
4991
  demandOption: true,
4421
4992
  string: true,
@@ -4516,10 +5087,10 @@ var module2 = {
4516
5087
  command: "manifest <command>",
4517
5088
  describe: "Intent manifest commands",
4518
5089
  builder: () => {
4519
- return yargs13.command(download_default);
5090
+ return yargs14.command(download_default);
4520
5091
  },
4521
5092
  handler: () => {
4522
- yargs13.showHelp();
5093
+ yargs14.showHelp();
4523
5094
  }
4524
5095
  };
4525
5096
  var manifest_default = module2;
@@ -4530,28 +5101,30 @@ var OptimizeCommand = {
4530
5101
  aliases: ["opt"],
4531
5102
  describe: "Uniform Optimize commands",
4532
5103
  builder: () => {
4533
- return yargs14.command(manifest_default);
5104
+ return yargs15.command(manifest_default);
4534
5105
  },
4535
5106
  handler: () => {
4536
- yargs14.showHelp();
5107
+ yargs15.showHelp();
4537
5108
  }
4538
5109
  };
4539
5110
 
4540
5111
  // src/commands/project-map/index.ts
4541
- import yargs17 from "yargs";
5112
+ import yargs18 from "yargs";
4542
5113
 
4543
5114
  // src/commands/project-map/commands/projectMapDefinition.ts
4544
- import yargs15 from "yargs";
5115
+ import yargs16 from "yargs";
4545
5116
 
4546
5117
  // src/commands/project-map/commands/ProjectMapDefinition/get.ts
4547
5118
  import { UncachedProjectMapClient } from "@uniformdev/project-map";
4548
5119
  var ProjectMapDefinitionGetModule = {
4549
5120
  command: "get <id>",
4550
5121
  describe: "Fetch a project map",
4551
- builder: (yargs21) => withFormatOptions(
4552
- withApiOptions(
4553
- withProjectOptions(
4554
- yargs21.positional("id", { demandOption: true, describe: "ProjectMap UUID to fetch" })
5122
+ builder: (yargs23) => withFormatOptions(
5123
+ withConfiguration(
5124
+ withApiOptions(
5125
+ withProjectOptions(
5126
+ yargs23.positional("id", { demandOption: true, describe: "ProjectMap UUID to fetch" })
5127
+ )
4555
5128
  )
4556
5129
  )
4557
5130
  ),
@@ -4574,7 +5147,7 @@ var ProjectMapDefinitionListModule = {
4574
5147
  command: "list",
4575
5148
  describe: "List of project maps",
4576
5149
  aliases: ["ls"],
4577
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
5150
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
4578
5151
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
4579
5152
  const fetch3 = nodeFetchProxy(proxy);
4580
5153
  const client = new UncachedProjectMapClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -4631,30 +5204,32 @@ function createProjectMapDefinitionEngineDataSource({
4631
5204
  var ProjectMapDefinitionPullModule = {
4632
5205
  command: "pull <directory>",
4633
5206
  describe: "Pulls all project maps to local files in a directory",
4634
- builder: (yargs21) => withApiOptions(
4635
- withProjectOptions(
4636
- withDiffOptions(
4637
- yargs21.positional("directory", {
4638
- describe: "Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
4639
- type: "string"
4640
- }).option("format", {
4641
- alias: ["f"],
4642
- describe: "Output format",
4643
- default: "yaml",
4644
- choices: ["yaml", "json"],
4645
- type: "string"
4646
- }).option("what-if", {
4647
- alias: ["w"],
4648
- describe: "What-if mode reports what would be done but changes no files",
4649
- default: false,
4650
- type: "boolean"
4651
- }).option("mode", {
4652
- alias: ["m"],
4653
- 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',
4654
- choices: ["create", "createOrUpdate", "mirror"],
4655
- default: "mirror",
4656
- type: "string"
4657
- })
5207
+ builder: (yargs23) => withConfiguration(
5208
+ withApiOptions(
5209
+ withProjectOptions(
5210
+ withDiffOptions(
5211
+ yargs23.positional("directory", {
5212
+ describe: "Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
5213
+ type: "string"
5214
+ }).option("format", {
5215
+ alias: ["f"],
5216
+ describe: "Output format",
5217
+ default: "yaml",
5218
+ choices: ["yaml", "json"],
5219
+ type: "string"
5220
+ }).option("what-if", {
5221
+ alias: ["w"],
5222
+ describe: "What-if mode reports what would be done but changes no files",
5223
+ default: false,
5224
+ type: "boolean"
5225
+ }).option("mode", {
5226
+ alias: ["m"],
5227
+ 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',
5228
+ choices: ["create", "createOrUpdate", "mirror"],
5229
+ default: "mirror",
5230
+ type: "string"
5231
+ })
5232
+ )
4658
5233
  )
4659
5234
  )
4660
5235
  ),
@@ -4708,24 +5283,26 @@ import { UncachedProjectMapClient as UncachedProjectMapClient4 } from "@uniformd
4708
5283
  var ProjectMapDefinitionPushModule = {
4709
5284
  command: "push <directory>",
4710
5285
  describe: "Pushes all project maps from files in a directory or package to Uniform",
4711
- builder: (yargs21) => withApiOptions(
4712
- withProjectOptions(
4713
- withDiffOptions(
4714
- yargs21.positional("directory", {
4715
- describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
4716
- type: "string"
4717
- }).option("what-if", {
4718
- alias: ["w"],
4719
- describe: "What-if mode reports what would be done but changes nothing",
4720
- default: false,
4721
- type: "boolean"
4722
- }).option("mode", {
4723
- alias: ["m"],
4724
- 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',
4725
- choices: ["create", "createOrUpdate", "mirror"],
4726
- default: "mirror",
4727
- type: "string"
4728
- })
5286
+ builder: (yargs23) => withConfiguration(
5287
+ withApiOptions(
5288
+ withProjectOptions(
5289
+ withDiffOptions(
5290
+ yargs23.positional("directory", {
5291
+ describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
5292
+ type: "string"
5293
+ }).option("what-if", {
5294
+ alias: ["w"],
5295
+ describe: "What-if mode reports what would be done but changes nothing",
5296
+ default: false,
5297
+ type: "boolean"
5298
+ }).option("mode", {
5299
+ alias: ["m"],
5300
+ 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',
5301
+ choices: ["create", "createOrUpdate", "mirror"],
5302
+ default: "mirror",
5303
+ type: "string"
5304
+ })
5305
+ )
4729
5306
  )
4730
5307
  )
4731
5308
  ),
@@ -4774,8 +5351,10 @@ var ProjectMapDefinitionRemoveModule = {
4774
5351
  command: "remove <id>",
4775
5352
  aliases: ["delete", "rm"],
4776
5353
  describe: "Delete a project map",
4777
- builder: (yargs21) => withApiOptions(
4778
- withProjectOptions(yargs21.positional("id", { demandOption: true, describe: " UUID to delete" }))
5354
+ builder: (yargs23) => withConfiguration(
5355
+ withApiOptions(
5356
+ withProjectOptions(yargs23.positional("id", { demandOption: true, describe: " UUID to delete" }))
5357
+ )
4779
5358
  ),
4780
5359
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
4781
5360
  const fetch3 = nodeFetchProxy(proxy);
@@ -4790,9 +5369,11 @@ var ProjectMapDefinitionUpdateModule = {
4790
5369
  command: "update <filename>",
4791
5370
  aliases: ["put"],
4792
5371
  describe: "Insert or update a project map",
4793
- builder: (yargs21) => withApiOptions(
4794
- withProjectOptions(
4795
- yargs21.positional("filename", { demandOption: true, describe: "Project map file to put" })
5372
+ builder: (yargs23) => withConfiguration(
5373
+ withApiOptions(
5374
+ withProjectOptions(
5375
+ yargs23.positional("filename", { demandOption: true, describe: "Project map file to put" })
5376
+ )
4796
5377
  )
4797
5378
  ),
4798
5379
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -4807,24 +5388,26 @@ var ProjectMapDefinitionUpdateModule = {
4807
5388
  var ProjectMapDefinitionModule = {
4808
5389
  command: "definition <command>",
4809
5390
  describe: "Commands for ProjectMap Definitions",
4810
- builder: (yargs21) => yargs21.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
5391
+ builder: (yargs23) => yargs23.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
4811
5392
  handler: () => {
4812
- yargs15.help();
5393
+ yargs16.help();
4813
5394
  }
4814
5395
  };
4815
5396
 
4816
5397
  // src/commands/project-map/commands/projectMapNode.ts
4817
- import yargs16 from "yargs";
5398
+ import yargs17 from "yargs";
4818
5399
 
4819
5400
  // src/commands/project-map/commands/ProjectMapNode/get.ts
4820
5401
  import { UncachedProjectMapClient as UncachedProjectMapClient7 } from "@uniformdev/project-map";
4821
5402
  var ProjectMapNodeGetModule = {
4822
5403
  command: "get <id> <projectMapId>",
4823
5404
  describe: "Fetch a project map node",
4824
- builder: (yargs21) => withFormatOptions(
4825
- withApiOptions(
4826
- withProjectOptions(
4827
- yargs21.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to fetch" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
5405
+ builder: (yargs23) => withConfiguration(
5406
+ withFormatOptions(
5407
+ withApiOptions(
5408
+ withProjectOptions(
5409
+ yargs23.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to fetch" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
5410
+ )
4828
5411
  )
4829
5412
  )
4830
5413
  ),
@@ -4849,10 +5432,15 @@ var ProjectMapNodeListModule = {
4849
5432
  command: "list <projectMapId>",
4850
5433
  describe: "List project map nodes",
4851
5434
  aliases: ["ls"],
4852
- builder: (yargs21) => withFormatOptions(
4853
- withApiOptions(
4854
- withProjectOptions(
4855
- yargs21.positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
5435
+ builder: (yargs23) => withConfiguration(
5436
+ withFormatOptions(
5437
+ withApiOptions(
5438
+ withProjectOptions(
5439
+ yargs23.positional("projectMapId", {
5440
+ demandOption: true,
5441
+ describe: "ProjectMap UUID to fetch from"
5442
+ })
5443
+ )
4856
5444
  )
4857
5445
  )
4858
5446
  ),
@@ -4919,30 +5507,32 @@ function createProjectMapNodeEngineDataSource({
4919
5507
  var ProjectMapNodePullModule = {
4920
5508
  command: "pull <directory>",
4921
5509
  describe: "Pulls all project maps nodes to local files in a directory",
4922
- builder: (yargs21) => withApiOptions(
4923
- withProjectOptions(
4924
- withDiffOptions(
4925
- yargs21.positional("directory", {
4926
- describe: "Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
4927
- type: "string"
4928
- }).option("format", {
4929
- alias: ["f"],
4930
- describe: "Output format",
4931
- default: "yaml",
4932
- choices: ["yaml", "json"],
4933
- type: "string"
4934
- }).option("what-if", {
4935
- alias: ["w"],
4936
- describe: "What-if mode reports what would be done but changes no files",
4937
- default: false,
4938
- type: "boolean"
4939
- }).option("mode", {
4940
- alias: ["m"],
4941
- 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',
4942
- choices: ["create", "createOrUpdate", "mirror"],
4943
- default: "mirror",
4944
- type: "string"
4945
- })
5510
+ builder: (yargs23) => withConfiguration(
5511
+ withApiOptions(
5512
+ withProjectOptions(
5513
+ withDiffOptions(
5514
+ yargs23.positional("directory", {
5515
+ describe: "Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
5516
+ type: "string"
5517
+ }).option("format", {
5518
+ alias: ["f"],
5519
+ describe: "Output format",
5520
+ default: "yaml",
5521
+ choices: ["yaml", "json"],
5522
+ type: "string"
5523
+ }).option("what-if", {
5524
+ alias: ["w"],
5525
+ describe: "What-if mode reports what would be done but changes no files",
5526
+ default: false,
5527
+ type: "boolean"
5528
+ }).option("mode", {
5529
+ alias: ["m"],
5530
+ 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',
5531
+ choices: ["create", "createOrUpdate", "mirror"],
5532
+ default: "mirror",
5533
+ type: "string"
5534
+ })
5535
+ )
4946
5536
  )
4947
5537
  )
4948
5538
  ),
@@ -5000,24 +5590,26 @@ import { UncachedProjectMapClient as UncachedProjectMapClient10 } from "@uniform
5000
5590
  var ProjectMapNodePushModule = {
5001
5591
  command: "push <directory>",
5002
5592
  describe: "Pushes all project maps nodes from files in a directory or package to Uniform",
5003
- builder: (yargs21) => withApiOptions(
5004
- withProjectOptions(
5005
- withDiffOptions(
5006
- yargs21.positional("directory", {
5007
- describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
5008
- type: "string"
5009
- }).option("what-if", {
5010
- alias: ["w"],
5011
- describe: "What-if mode reports what would be done but changes nothing",
5012
- default: false,
5013
- type: "boolean"
5014
- }).option("mode", {
5015
- alias: ["m"],
5016
- 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',
5017
- choices: ["create", "createOrUpdate", "mirror"],
5018
- default: "mirror",
5019
- type: "string"
5020
- })
5593
+ builder: (yargs23) => withConfiguration(
5594
+ withApiOptions(
5595
+ withProjectOptions(
5596
+ withDiffOptions(
5597
+ yargs23.positional("directory", {
5598
+ describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
5599
+ type: "string"
5600
+ }).option("what-if", {
5601
+ alias: ["w"],
5602
+ describe: "What-if mode reports what would be done but changes nothing",
5603
+ default: false,
5604
+ type: "boolean"
5605
+ }).option("mode", {
5606
+ alias: ["m"],
5607
+ 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',
5608
+ choices: ["create", "createOrUpdate", "mirror"],
5609
+ default: "mirror",
5610
+ type: "string"
5611
+ })
5612
+ )
5021
5613
  )
5022
5614
  )
5023
5615
  ),
@@ -5075,9 +5667,11 @@ var ProjectMapNodeRemoveModule = {
5075
5667
  command: "remove <id> <projectMapId>",
5076
5668
  aliases: ["delete", "rm"],
5077
5669
  describe: "Delete a project map node",
5078
- builder: (yargs21) => withApiOptions(
5079
- withProjectOptions(
5080
- yargs21.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to delete" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to delete from" })
5670
+ builder: (yargs23) => withConfiguration(
5671
+ withApiOptions(
5672
+ withProjectOptions(
5673
+ yargs23.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to delete" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to delete from" })
5674
+ )
5081
5675
  )
5082
5676
  ),
5083
5677
  handler: async ({ apiHost, apiKey, proxy, projectMapId, id, project: projectId }) => {
@@ -5093,9 +5687,11 @@ var ProjectMapNodeUpdateModule = {
5093
5687
  command: "update <filename> <projectMapId>",
5094
5688
  aliases: ["put"],
5095
5689
  describe: "Insert or update a project map node",
5096
- builder: (yargs21) => withApiOptions(
5097
- withProjectOptions(
5098
- yargs21.positional("filename", { demandOption: true, describe: "ProjectMap node file with nodes data" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to put into" })
5690
+ builder: (yargs23) => withConfiguration(
5691
+ withApiOptions(
5692
+ withProjectOptions(
5693
+ yargs23.positional("filename", { demandOption: true, describe: "ProjectMap node file with nodes data" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to put into" })
5694
+ )
5099
5695
  )
5100
5696
  ),
5101
5697
  handler: async ({ apiHost, apiKey, proxy, projectMapId, filename, project: projectId }) => {
@@ -5110,9 +5706,9 @@ var ProjectMapNodeUpdateModule = {
5110
5706
  var ProjectMapNodeModule = {
5111
5707
  command: "node <command>",
5112
5708
  describe: "Commands for ProjectMap Nodes",
5113
- builder: (yargs21) => yargs21.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
5709
+ builder: (yargs23) => yargs23.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
5114
5710
  handler: () => {
5115
- yargs16.help();
5711
+ yargs17.help();
5116
5712
  }
5117
5713
  };
5118
5714
 
@@ -5121,26 +5717,30 @@ var ProjectMapCommand = {
5121
5717
  command: "project-map <command>",
5122
5718
  aliases: ["prm"],
5123
5719
  describe: "Uniform ProjectMap commands",
5124
- builder: (yargs21) => yargs21.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
5720
+ builder: (yargs23) => yargs23.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
5125
5721
  handler: () => {
5126
- yargs17.showHelp();
5722
+ yargs18.showHelp();
5127
5723
  }
5128
5724
  };
5129
5725
 
5130
5726
  // src/commands/redirect/index.ts
5131
- import yargs19 from "yargs";
5727
+ import yargs20 from "yargs";
5132
5728
 
5133
5729
  // src/commands/redirect/commands/redirect.ts
5134
- import yargs18 from "yargs";
5730
+ import yargs19 from "yargs";
5135
5731
 
5136
5732
  // src/commands/redirect/commands/RedirectDefinition/get.ts
5137
5733
  import { UncachedRedirectClient } from "@uniformdev/redirect";
5138
5734
  var RedirectDefinitionGetModule = {
5139
5735
  command: "get <id>",
5140
5736
  describe: "Fetch a redirect",
5141
- builder: (yargs21) => withFormatOptions(
5142
- withApiOptions(
5143
- withProjectOptions(yargs21.positional("id", { demandOption: true, describe: "Redirect UUID to fetch" }))
5737
+ builder: (yargs23) => withConfiguration(
5738
+ withFormatOptions(
5739
+ withApiOptions(
5740
+ withProjectOptions(
5741
+ yargs23.positional("id", { demandOption: true, describe: "Redirect UUID to fetch" })
5742
+ )
5743
+ )
5144
5744
  )
5145
5745
  ),
5146
5746
  handler: async ({ apiHost, apiKey, proxy, id, format, project: projectId, filename }) => {
@@ -5162,7 +5762,7 @@ var RedirectDefinitionListModule = {
5162
5762
  command: "list",
5163
5763
  describe: "List of redirects",
5164
5764
  aliases: ["ls"],
5165
- builder: (yargs21) => withFormatOptions(withApiOptions(withProjectOptions(yargs21))),
5765
+ builder: (yargs23) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs23)))),
5166
5766
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
5167
5767
  const fetch3 = nodeFetchProxy(proxy);
5168
5768
  const client = new UncachedRedirectClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -5228,30 +5828,32 @@ function createRedirectDefinitionEngineDataSource({
5228
5828
  var RedirectDefinitionPullModule = {
5229
5829
  command: "pull <directory>",
5230
5830
  describe: "Pulls all redirects to local files in a directory",
5231
- builder: (yargs21) => withApiOptions(
5232
- withProjectOptions(
5233
- withDiffOptions(
5234
- yargs21.positional("directory", {
5235
- describe: "Directory to save redirects to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
5236
- type: "string"
5237
- }).option("format", {
5238
- alias: ["f"],
5239
- describe: "Output format",
5240
- default: "yaml",
5241
- choices: ["yaml", "json"],
5242
- type: "string"
5243
- }).option("what-if", {
5244
- alias: ["w"],
5245
- describe: "What-if mode reports what would be done but changes no files",
5246
- default: false,
5247
- type: "boolean"
5248
- }).option("mode", {
5249
- alias: ["m"],
5250
- 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',
5251
- choices: ["create", "createOrUpdate", "mirror"],
5252
- default: "mirror",
5253
- type: "string"
5254
- })
5831
+ builder: (yargs23) => withConfiguration(
5832
+ withApiOptions(
5833
+ withProjectOptions(
5834
+ withDiffOptions(
5835
+ yargs23.positional("directory", {
5836
+ describe: "Directory to save redirects to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
5837
+ type: "string"
5838
+ }).option("format", {
5839
+ alias: ["f"],
5840
+ describe: "Output format",
5841
+ default: "yaml",
5842
+ choices: ["yaml", "json"],
5843
+ type: "string"
5844
+ }).option("what-if", {
5845
+ alias: ["w"],
5846
+ describe: "What-if mode reports what would be done but changes no files",
5847
+ default: false,
5848
+ type: "boolean"
5849
+ }).option("mode", {
5850
+ alias: ["m"],
5851
+ 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',
5852
+ choices: ["create", "createOrUpdate", "mirror"],
5853
+ default: "mirror",
5854
+ type: "string"
5855
+ })
5856
+ )
5255
5857
  )
5256
5858
  )
5257
5859
  ),
@@ -5306,24 +5908,26 @@ import { UncachedRedirectClient as UncachedRedirectClient4 } from "@uniformdev/r
5306
5908
  var RedirectDefinitionPushModule = {
5307
5909
  command: "push <directory>",
5308
5910
  describe: "Pushes all redirects from files in a directory or package to Uniform",
5309
- builder: (yargs21) => withApiOptions(
5310
- withProjectOptions(
5311
- withDiffOptions(
5312
- yargs21.positional("directory", {
5313
- describe: "Directory to read redirects from. If a filename is used, a package will be read instead.",
5314
- type: "string"
5315
- }).option("what-if", {
5316
- alias: ["w"],
5317
- describe: "What-if mode reports what would be done but changes nothing",
5318
- default: false,
5319
- type: "boolean"
5320
- }).option("mode", {
5321
- alias: ["m"],
5322
- 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',
5323
- choices: ["create", "createOrUpdate", "mirror"],
5324
- default: "mirror",
5325
- type: "string"
5326
- })
5911
+ builder: (yargs23) => withConfiguration(
5912
+ withApiOptions(
5913
+ withProjectOptions(
5914
+ withDiffOptions(
5915
+ yargs23.positional("directory", {
5916
+ describe: "Directory to read redirects from. If a filename is used, a package will be read instead.",
5917
+ type: "string"
5918
+ }).option("what-if", {
5919
+ alias: ["w"],
5920
+ describe: "What-if mode reports what would be done but changes nothing",
5921
+ default: false,
5922
+ type: "boolean"
5923
+ }).option("mode", {
5924
+ alias: ["m"],
5925
+ 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',
5926
+ choices: ["create", "createOrUpdate", "mirror"],
5927
+ default: "mirror",
5928
+ type: "string"
5929
+ })
5930
+ )
5327
5931
  )
5328
5932
  )
5329
5933
  ),
@@ -5372,8 +5976,10 @@ var RedirectDefinitionRemoveModule = {
5372
5976
  command: "remove <id>",
5373
5977
  aliases: ["delete", "rm"],
5374
5978
  describe: "Delete a redirect",
5375
- builder: (yargs21) => withApiOptions(
5376
- withProjectOptions(yargs21.positional("id", { demandOption: true, describe: " UUID to delete" }))
5979
+ builder: (yargs23) => withConfiguration(
5980
+ withApiOptions(
5981
+ withProjectOptions(yargs23.positional("id", { demandOption: true, describe: " UUID to delete" }))
5982
+ )
5377
5983
  ),
5378
5984
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
5379
5985
  const fetch3 = nodeFetchProxy(proxy);
@@ -5388,9 +5994,11 @@ var RedirectDefinitionUpdateModule = {
5388
5994
  command: "update <filename>",
5389
5995
  aliases: ["put"],
5390
5996
  describe: "Insert or update a redirect",
5391
- builder: (yargs21) => withApiOptions(
5392
- withProjectOptions(
5393
- yargs21.positional("filename", { demandOption: true, describe: "Redirect file to put" })
5997
+ builder: (yargs23) => withConfiguration(
5998
+ withApiOptions(
5999
+ withProjectOptions(
6000
+ yargs23.positional("filename", { demandOption: true, describe: "Redirect file to put" })
6001
+ )
5394
6002
  )
5395
6003
  ),
5396
6004
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -5405,9 +6013,9 @@ var RedirectDefinitionUpdateModule = {
5405
6013
  var RedirectDefinitionModule = {
5406
6014
  command: "definition <command>",
5407
6015
  describe: "Commands for Redirect Definitions",
5408
- builder: (yargs21) => yargs21.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
6016
+ builder: (yargs23) => yargs23.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
5409
6017
  handler: () => {
5410
- yargs18.help();
6018
+ yargs19.help();
5411
6019
  }
5412
6020
  };
5413
6021
 
@@ -5416,9 +6024,179 @@ var RedirectCommand = {
5416
6024
  command: "redirect <command>",
5417
6025
  aliases: ["red"],
5418
6026
  describe: "Uniform Redirect commands",
5419
- builder: (yargs21) => yargs21.command(RedirectDefinitionModule).demandCommand(),
6027
+ builder: (yargs23) => yargs23.command(RedirectDefinitionModule).demandCommand(),
6028
+ handler: () => {
6029
+ yargs20.showHelp();
6030
+ }
6031
+ };
6032
+
6033
+ // src/commands/sync/index.ts
6034
+ import yargs21 from "yargs";
6035
+
6036
+ // src/commands/sync/commands/pull.ts
6037
+ var SyncPullModule = {
6038
+ command: "pull",
6039
+ describe: "Pulls whole project to local files in a directory",
6040
+ builder: (yargs23) => withConfiguration(
6041
+ withApiOptions(
6042
+ withProjectOptions(
6043
+ withDiffOptions(
6044
+ yargs23.option("what-if", {
6045
+ alias: ["w"],
6046
+ describe: "What-if mode reports what would be done but changes no files",
6047
+ default: false,
6048
+ type: "boolean"
6049
+ })
6050
+ )
6051
+ )
6052
+ )
6053
+ ),
6054
+ handler: async ({ serialization, ...otherParams }) => {
6055
+ const config2 = serialization;
6056
+ const enabledEntities = Object.entries({
6057
+ category: CategoryPullModule,
6058
+ dataType: DataTypePullModule,
6059
+ quirk: QuirkPullModule,
6060
+ test: TestPullModule,
6061
+ signal: SignalPullModule,
6062
+ enrichment: EnrichmentPullModule,
6063
+ aggregate: AggregatePullModule,
6064
+ component: ComponentPullModule,
6065
+ pattern: PatternPullModule,
6066
+ composition: CompositionPullModule,
6067
+ projectMapDefinition: ProjectMapDefinitionPullModule,
6068
+ projectMapNode: ProjectMapNodePullModule,
6069
+ redirect: RedirectDefinitionPullModule
6070
+ }).filter(([entityType]) => {
6071
+ var _a, _b, _c, _d, _e, _f;
6072
+ return Boolean((_a = config2.entitiesConfig) == null ? void 0 : _a[entityType]) && ((_c = (_b = config2.entitiesConfig) == null ? void 0 : _b[entityType]) == null ? void 0 : _c.disabled) !== true && ((_f = (_e = (_d = config2.entitiesConfig) == null ? void 0 : _d[entityType]) == null ? void 0 : _e.pull) == null ? void 0 : _f.disabled) !== true;
6073
+ });
6074
+ for (const [entityType, module3] of enabledEntities) {
6075
+ await module3.handler({
6076
+ ...otherParams,
6077
+ state: 0,
6078
+ format: getFormat(entityType, config2),
6079
+ onlyCompositions: entityType === "composition" ? true : void 0,
6080
+ onlyPatterns: entityType === "pattern" ? true : void 0,
6081
+ mode: getPullMode(entityType, config2),
6082
+ directory: getPullFilename(entityType, config2)
6083
+ });
6084
+ }
6085
+ }
6086
+ };
6087
+ var getPullMode = (entityType, config2) => {
6088
+ return getEntityOption({
6089
+ optionName: "mode",
6090
+ operation: "pull",
6091
+ config: config2,
6092
+ entityType
6093
+ });
6094
+ };
6095
+ var getPullFilename = (entityType, config2) => {
6096
+ return getDirectoryOrFilename({
6097
+ operation: "pull",
6098
+ config: config2,
6099
+ entityType
6100
+ });
6101
+ };
6102
+ var getFormat = (entityType, config2) => {
6103
+ return getEntityOption({
6104
+ optionName: "format",
6105
+ operation: "pull",
6106
+ config: config2,
6107
+ entityType
6108
+ });
6109
+ };
6110
+
6111
+ // src/commands/sync/commands/push.ts
6112
+ var SyncPushModule = {
6113
+ command: "push",
6114
+ describe: "Pushes whole project data from files in a directory or package to Uniform",
6115
+ builder: (yargs23) => withConfiguration(
6116
+ withApiOptions(
6117
+ withProjectOptions(
6118
+ withDiffOptions(
6119
+ yargs23.option("what-if", {
6120
+ alias: ["w"],
6121
+ describe: "What-if mode reports what would be done but changes nothing",
6122
+ default: false,
6123
+ type: "boolean"
6124
+ })
6125
+ )
6126
+ )
6127
+ )
6128
+ ),
6129
+ handler: async ({ serialization, ...otherParams }) => {
6130
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6131
+ const config2 = serialization;
6132
+ const enabledEntities = Object.entries({
6133
+ category: CategoryPushModule,
6134
+ dataType: DataTypePushModule,
6135
+ quirk: QuirkPushModule,
6136
+ test: TestPushModule,
6137
+ signal: SignalPushModule,
6138
+ enrichment: EnrichmentPushModule,
6139
+ aggregate: AggregatePushModule,
6140
+ component: ComponentPushModule,
6141
+ pattern: PatternPushModule,
6142
+ composition: CompositionPushModule,
6143
+ projectMapDefinition: ProjectMapDefinitionPushModule,
6144
+ projectMapNode: ProjectMapNodePushModule,
6145
+ redirect: RedirectDefinitionPushModule
6146
+ }).filter(([entityType]) => {
6147
+ var _a2, _b2, _c2, _d2, _e2, _f2;
6148
+ return Boolean((_a2 = config2.entitiesConfig) == null ? void 0 : _a2[entityType]) && ((_c2 = (_b2 = config2.entitiesConfig) == null ? void 0 : _b2[entityType]) == null ? void 0 : _c2.disabled) !== true && ((_f2 = (_e2 = (_d2 = config2.entitiesConfig) == null ? void 0 : _d2[entityType]) == null ? void 0 : _e2.push) == null ? void 0 : _f2.disabled) !== true;
6149
+ });
6150
+ for (const [entityType, module3] of enabledEntities) {
6151
+ await module3.handler({
6152
+ ...otherParams,
6153
+ state: 0,
6154
+ format: getFormat2(entityType, config2),
6155
+ onlyCompositions: entityType === "composition" ? true : void 0,
6156
+ onlyPatterns: entityType === "pattern" ? true : void 0,
6157
+ mode: getPushMode(entityType, config2),
6158
+ directory: getPushFilename(entityType, config2)
6159
+ });
6160
+ }
6161
+ if (((_a = config2.entitiesConfig) == null ? void 0 : _a.pattern) && ((_d = (_c = (_b = config2.entitiesConfig) == null ? void 0 : _b.pattern) == null ? void 0 : _c.push) == null ? void 0 : _d.disabled) !== true && ((_f = (_e = config2.entitiesConfig) == null ? void 0 : _e.pattern) == null ? void 0 : _f.publish)) {
6162
+ await PatternPublishModule.handler({ ...otherParams, all: true });
6163
+ }
6164
+ if (((_g = config2.entitiesConfig) == null ? void 0 : _g.composition) && ((_j = (_i = (_h = config2.entitiesConfig) == null ? void 0 : _h.composition) == null ? void 0 : _i.push) == null ? void 0 : _j.disabled) !== true && ((_l = (_k = config2.entitiesConfig) == null ? void 0 : _k.composition) == null ? void 0 : _l.publish)) {
6165
+ await CompositionPublishModule.handler({ ...otherParams, all: true });
6166
+ }
6167
+ }
6168
+ };
6169
+ var getPushMode = (entityType, config2) => {
6170
+ return getEntityOption({
6171
+ optionName: "mode",
6172
+ operation: "push",
6173
+ config: config2,
6174
+ entityType
6175
+ });
6176
+ };
6177
+ var getPushFilename = (entityType, config2) => {
6178
+ return getDirectoryOrFilename({
6179
+ operation: "push",
6180
+ config: config2,
6181
+ entityType
6182
+ });
6183
+ };
6184
+ var getFormat2 = (entityType, config2) => {
6185
+ return getEntityOption({
6186
+ optionName: "format",
6187
+ operation: "push",
6188
+ config: config2,
6189
+ entityType
6190
+ });
6191
+ };
6192
+
6193
+ // src/commands/sync/index.ts
6194
+ var SyncCommand = {
6195
+ command: "sync <command>",
6196
+ describe: "Uniform Sync commands",
6197
+ builder: (yargs23) => yargs23.command(SyncPullModule).command(SyncPushModule).demandCommand(),
5420
6198
  handler: () => {
5421
- yargs19.showHelp();
6199
+ yargs21.showHelp();
5422
6200
  }
5423
6201
  };
5424
6202
 
@@ -5462,17 +6240,17 @@ async function checkForUpdateMiddleware() {
5462
6240
 
5463
6241
  // src/middleware/checkLocalDepsVersionsMiddleware.ts
5464
6242
  import { magenta, red as red6 } from "colorette";
5465
- import { join as join2 } from "path";
6243
+ import { join as join3 } from "path";
5466
6244
 
5467
6245
  // src/fs.ts
5468
- import { promises as fs4 } from "fs";
6246
+ import { promises as fs5 } from "fs";
5469
6247
  async function readJSON(path4) {
5470
- const fileContents = await fs4.readFile(path4, "utf-8");
6248
+ const fileContents = await fs5.readFile(path4, "utf-8");
5471
6249
  return JSON.parse(fileContents);
5472
6250
  }
5473
6251
  async function tryReadJSON(path4, missingValue = null) {
5474
6252
  try {
5475
- const stat = await fs4.stat(path4);
6253
+ const stat = await fs5.stat(path4);
5476
6254
  return stat.isFile() ? await readJSON(path4) : missingValue;
5477
6255
  } catch (e) {
5478
6256
  return missingValue;
@@ -5501,7 +6279,7 @@ var checkLocalDepsVersions = async (args) => {
5501
6279
  try {
5502
6280
  let isOutside = false;
5503
6281
  let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
5504
- const localPackages = await tryReadJSON(join2(process.cwd(), "package.json"));
6282
+ const localPackages = await tryReadJSON(join3(process.cwd(), "package.json"));
5505
6283
  if (!localPackages)
5506
6284
  return;
5507
6285
  let firstVersion;
@@ -5534,9 +6312,13 @@ First found was: v${firstVersion}`;
5534
6312
 
5535
6313
  // src/index.ts
5536
6314
  dotenv.config();
5537
- var yarggery = yargs20(hideBin(process.argv));
6315
+ var yarggery = yargs22(hideBin(process.argv));
6316
+ var inlineConfigurationFilePath = "config" in yarggery.argv && yarggery.argv.config;
6317
+ var configuration = loadConfig(inlineConfigurationFilePath || null);
5538
6318
  yarggery.option("verbose", {
5539
6319
  describe: "Include verbose logging",
5540
6320
  default: false,
5541
6321
  type: "boolean"
5542
- }).command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(RedirectCommand).command(NewCmd).command(NewMeshCmd).command(OptimizeCommand).demandCommand(1, "").strict().help().middleware([checkForUpdateMiddleware, checkLocalDepsVersions]).argv;
6322
+ }).scriptName("uniform").config(configuration).config("config", function() {
6323
+ return {};
6324
+ }).command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(RedirectCommand).command(SyncCommand).command(NewCmd).command(NewMeshCmd).command(OptimizeCommand).demandCommand(1, "").strict().help().middleware([checkForUpdateMiddleware, checkLocalDepsVersions]).argv;