@uniformdev/cli 19.60.1-alpha.6 → 19.61.1-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,13 @@
1
1
  #!/usr/bin/env node
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined")
6
+ return require.apply(this, arguments);
7
+ throw Error('Dynamic require of "' + x + '" is not supported');
8
+ });
2
9
 
3
- // ../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.28_ts-node@10.9.1_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
10
+ // ../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_ts-node@10.9.1_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
4
11
  import { fileURLToPath } from "url";
5
12
  import path from "path";
6
13
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -9,24 +16,25 @@ var __dirname = /* @__PURE__ */ getDirname();
9
16
 
10
17
  // src/index.ts
11
18
  import * as dotenv from "dotenv";
12
- import yargs24 from "yargs";
19
+ import yargs26 from "yargs";
13
20
  import { hideBin } from "yargs/helpers";
14
21
 
15
22
  // src/commands/canvas/index.ts
16
- import yargs8 from "yargs";
23
+ import yargs10 from "yargs";
17
24
 
18
- // src/commands/canvas/commands/category.ts
25
+ // src/commands/canvas/commands/asset.ts
19
26
  import yargs from "yargs";
20
27
 
21
- // src/commands/canvas/commands/category/get.ts
22
- import { UncachedCategoryClient } from "@uniformdev/canvas";
28
+ // src/commands/canvas/commands/asset/get.ts
29
+ import { UncachedAssetClient } from "@uniformdev/assets";
23
30
 
24
31
  // src/sync/arraySyncEngineDataSource.ts
25
32
  async function createArraySyncEngineDataSource({
26
33
  objects,
27
34
  selectIdentifier: selectIdentifier13,
28
35
  selectDisplayName: selectDisplayName13 = selectIdentifier13,
29
- onSyncComplete
36
+ onSyncComplete,
37
+ onBeforeDeleteObject
30
38
  }) {
31
39
  const objectIndex = objects.reduce(
32
40
  (result, current) => {
@@ -59,7 +67,10 @@ async function createArraySyncEngineDataSource({
59
67
  }
60
68
  return {
61
69
  objects: getObjects(),
62
- deleteObject: async (providerId) => {
70
+ deleteObject: async (providerId, object) => {
71
+ if (onBeforeDeleteObject) {
72
+ await onBeforeDeleteObject(providerId, object);
73
+ }
63
74
  delete objectIndex[providerId];
64
75
  },
65
76
  writeObject: async (objectToWrite) => {
@@ -126,14 +137,14 @@ import httpsProxyAgent from "https-proxy-agent";
126
137
  import unfetch from "isomorphic-unfetch";
127
138
  import { dump, load } from "js-yaml";
128
139
  import { dirname, extname, isAbsolute, resolve, sep } from "path";
129
- function withConfiguration(yargs25) {
130
- return yargs25.option("serialization", {
140
+ function withConfiguration(yargs27) {
141
+ return yargs27.option("serialization", {
131
142
  skipValidation: true,
132
143
  hidden: true
133
144
  });
134
145
  }
135
- function withApiOptions(yargs25) {
136
- return yargs25.option("apiKey", {
146
+ function withApiOptions(yargs27) {
147
+ return yargs27.option("apiKey", {
137
148
  describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
138
149
  default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
139
150
  process.env.CANVAS_CLI_API_KEY ?? // deprecated
@@ -172,8 +183,8 @@ function nodeFetchProxy(proxy) {
172
183
  };
173
184
  return wrappedFetch;
174
185
  }
175
- function withProjectOptions(yargs25) {
176
- return yargs25.option("project", {
186
+ function withProjectOptions(yargs27) {
187
+ return yargs27.option("project", {
177
188
  describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
178
189
  default: process.env.UNIFORM_CLI_PROJECT_ID ?? // deprecated
179
190
  process.env.CANVAS_CLI_PROJECT_ID ?? // deprecated
@@ -183,8 +194,8 @@ function withProjectOptions(yargs25) {
183
194
  alias: ["p"]
184
195
  });
185
196
  }
186
- function withFormatOptions(yargs25) {
187
- return yargs25.option("format", {
197
+ function withFormatOptions(yargs27) {
198
+ return yargs27.option("format", {
188
199
  alias: ["f"],
189
200
  describe: "Output format",
190
201
  default: "yaml",
@@ -196,8 +207,8 @@ function withFormatOptions(yargs25) {
196
207
  type: "string"
197
208
  });
198
209
  }
199
- function withDiffOptions(yargs25) {
200
- return yargs25.option("diff", {
210
+ function withDiffOptions(yargs27) {
211
+ return yargs27.option("diff", {
201
212
  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.",
202
213
  default: process.env.UNIFORM_CLI_DIFF_MODE ?? "off",
203
214
  type: "string",
@@ -355,7 +366,8 @@ async function createFileSyncEngineDataSource({
355
366
  selectIdentifier: selectIdentifier13,
356
367
  selectDisplayName: selectDisplayName13 = selectIdentifier13,
357
368
  selectFilename: selectFilename3,
358
- selectSchemaUrl: selectSchemaUrl2
369
+ selectSchemaUrl: selectSchemaUrl2,
370
+ onBeforeDeleteObject
359
371
  }) {
360
372
  const dirExists = existsSync(directory);
361
373
  if (!dirExists) {
@@ -391,7 +403,10 @@ ${e == null ? void 0 : e.message}`));
391
403
  }
392
404
  return {
393
405
  objects: getObjects(),
394
- deleteObject: async (providerId) => {
406
+ deleteObject: async (providerId, object) => {
407
+ if (onBeforeDeleteObject) {
408
+ await onBeforeDeleteObject(providerId, object);
409
+ }
395
410
  await unlink(providerId);
396
411
  },
397
412
  writeObject: async (object) => {
@@ -613,224 +628,799 @@ function createPublishStatusSyncEngineConsoleLogger(options) {
613
628
  };
614
629
  }
615
630
 
616
- // src/commands/canvas/commands/category/get.ts
617
- var CategoryGetModule = {
631
+ // src/commands/canvas/commands/asset/get.ts
632
+ var AssetGetModule = {
618
633
  command: "get <id>",
619
- describe: "Fetch a category",
620
- builder: (yargs25) => withConfiguration(
634
+ describe: "Get an asset",
635
+ builder: (yargs27) => withConfiguration(
621
636
  withFormatOptions(
622
637
  withApiOptions(
623
638
  withProjectOptions(
624
- yargs25.positional("id", { demandOption: true, describe: "Category UUID to fetch" })
639
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
640
+ yargs27.positional("id", { demandOption: true, describe: "Asset ID to fetch" })
625
641
  )
626
642
  )
627
643
  )
628
644
  ),
629
- handler: async ({ apiHost, apiKey, proxy, id, format, project: projectId, filename }) => {
645
+ handler: async ({ apiHost, apiKey, proxy, id, format, filename, project: projectId }) => {
630
646
  const fetch3 = nodeFetchProxy(proxy);
631
- const client = new UncachedCategoryClient({ apiKey, apiHost, fetch: fetch3, projectId });
632
- const res = await client.getCategories();
633
- const category = res.categories.find((c) => c.id === id);
634
- if (!category) {
635
- console.error("Category did not exist");
636
- process.exit(1);
637
- } else {
638
- emitWithFormat(category, format, filename);
647
+ const client = new UncachedAssetClient({ apiKey, apiHost, fetch: fetch3, projectId });
648
+ const res = await client.get({ offset: 0, limit: 1, assetId: id });
649
+ if (!res) {
650
+ throw new Error(`Asset with ID ${id} not found`);
639
651
  }
652
+ emitWithFormat(res, format, filename);
640
653
  }
641
654
  };
642
655
 
643
- // src/commands/canvas/commands/category/list.ts
644
- import { UncachedCategoryClient as UncachedCategoryClient2 } from "@uniformdev/canvas";
645
- var CategoryListModule = {
656
+ // src/commands/canvas/commands/asset/list.ts
657
+ import { UncachedAssetClient as UncachedAssetClient2 } from "@uniformdev/assets";
658
+ var AssetListModule = {
646
659
  command: "list",
647
- describe: "List categories",
648
- aliases: ["ls"],
649
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25.options({}))))),
660
+ describe: "List assets",
661
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
650
662
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
651
663
  const fetch3 = nodeFetchProxy(proxy);
652
- const client = new UncachedCategoryClient2({ apiKey, apiHost, fetch: fetch3, projectId });
653
- const res = await client.getCategories();
654
- emitWithFormat(res.categories, format, filename);
664
+ const client = new UncachedAssetClient2({ apiKey, apiHost, fetch: fetch3, projectId });
665
+ const res = await client.get({ offset: 0, limit: 1e3 });
666
+ emitWithFormat(res.assets, format, filename);
655
667
  }
656
668
  };
657
669
 
658
- // src/commands/canvas/commands/category/pull.ts
659
- import { UncachedCategoryClient as UncachedCategoryClient3 } from "@uniformdev/canvas";
660
-
661
- // src/commands/canvas/commands/category/_util.ts
662
- var selectIdentifier = (category) => category.id;
663
- var selectDisplayName = (category) => `${category.name} (pid: ${category.id})`;
670
+ // src/commands/canvas/commands/asset/pull.ts
671
+ import { UncachedAssetClient as UncachedAssetClient3 } from "@uniformdev/assets";
664
672
 
665
- // src/commands/canvas/categoriesEngineDataSource.ts
666
- function createCategoriesEngineDataSource({
667
- client
668
- }) {
669
- async function* getObjects() {
670
- const componentDefinitions = paginateAsync(async () => (await client.getCategories()).categories, {
671
- pageSize: 100
672
- });
673
- for await (const def of componentDefinitions) {
674
- const result = {
675
- id: selectIdentifier(def),
676
- displayName: selectDisplayName(def),
677
- providerId: def.id,
678
- object: def
679
- };
680
- yield result;
681
- }
673
+ // src/files/index.ts
674
+ import { preferredType } from "@thi.ng/mime";
675
+ import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
676
+ import { createHash } from "crypto";
677
+ import fsj from "fs-jetpack";
678
+ import sizeOf from "image-size";
679
+ import PQueue from "p-queue";
680
+ import { join as join2 } from "path";
681
+ var FILES_DIRECTORY_NAME = "files";
682
+ var urlToHash = (url) => {
683
+ const hash = createHash("sha256");
684
+ hash.update(url);
685
+ return hash.digest("hex");
686
+ };
687
+ var urlToFileName = (url) => {
688
+ const fileName = urlToHash(url);
689
+ const fileNameChunks = url.split(".");
690
+ const fileExtension = fileNameChunks.length > 1 ? fileNameChunks.at(-1) : "";
691
+ return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
692
+ };
693
+ var deleteDownloadedFileByUrl = async (url, options) => {
694
+ const fileName = urlToFileName(url);
695
+ const fileToDelete = join2(options.directory, FILES_DIRECTORY_NAME, fileName);
696
+ try {
697
+ await fsj.removeAsync(fileToDelete);
698
+ } catch {
699
+ console.warn(`Failed to delete a local file ${fileToDelete}`);
682
700
  }
683
- return {
684
- objects: getObjects(),
685
- deleteObject: async (providerId) => {
686
- await client.removeCategory({ categoryId: providerId });
687
- },
688
- writeObject: async (object) => {
689
- await client.upsertCategories([object.object]);
690
- }
691
- };
692
- }
693
-
694
- // src/commands/canvas/package.ts
695
- function readCanvasPackage(filename, assertExists) {
696
- return readUniformPackage(filename, assertExists);
697
- }
698
- function writeCanvasPackage(filename, packageContents) {
699
- writeUniformPackage(filename, packageContents);
700
- }
701
-
702
- // src/commands/canvas/commands/category/pull.ts
703
- var CategoryPullModule = {
704
- command: "pull <directory>",
705
- describe: "Pulls all categories to local files in a directory",
706
- builder: (yargs25) => withConfiguration(
707
- withApiOptions(
708
- withProjectOptions(
709
- withDiffOptions(
710
- yargs25.positional("directory", {
711
- 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.",
712
- type: "string"
713
- }).option("format", {
714
- alias: ["f"],
715
- describe: "Output format",
716
- default: "yaml",
717
- choices: ["yaml", "json"],
718
- type: "string"
719
- }).option("what-if", {
720
- alias: ["w"],
721
- describe: "What-if mode reports what would be done but changes no files",
722
- default: false,
723
- type: "boolean"
724
- }).option("mode", {
725
- alias: ["m"],
726
- 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',
727
- choices: ["create", "createOrUpdate", "mirror"],
728
- default: "mirror",
729
- type: "string"
730
- })
731
- )
732
- )
733
- )
734
- ),
735
- handler: async ({
736
- apiHost,
737
- apiKey,
738
- proxy,
739
- directory,
740
- format,
741
- mode,
742
- whatIf,
743
- project: projectId,
744
- diff: diffMode
745
- }) => {
746
- const fetch3 = nodeFetchProxy(proxy);
747
- const client = new UncachedCategoryClient3({ apiKey, apiHost, fetch: fetch3, projectId });
748
- const source = createCategoriesEngineDataSource({ client });
749
- let target;
750
- const isPackage = isPathAPackageFile(directory);
751
- if (isPackage) {
752
- const packageContents = readCanvasPackage(directory, false);
753
- target = await createArraySyncEngineDataSource({
754
- objects: packageContents.categories ?? [],
755
- selectIdentifier,
756
- selectDisplayName,
757
- onSyncComplete: async (_, synced) => {
758
- packageContents.categories = synced;
759
- writeCanvasPackage(directory, packageContents);
701
+ };
702
+ var extractAndDownloadUniformFilesForObject = async (object, options) => {
703
+ const objectAsString = JSON.stringify(object);
704
+ const uniformFileUrlMatches = objectAsString.matchAll(
705
+ /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
706
+ );
707
+ if (uniformFileUrlMatches) {
708
+ const fileDownloadQueue = new PQueue({ concurrency: 10 });
709
+ for (const match of uniformFileUrlMatches) {
710
+ const url = new URL(match[1]);
711
+ fileDownloadQueue.add(async () => {
712
+ try {
713
+ const fetchUrl = `${url.origin}${url.pathname}?format=original`;
714
+ const fileName = urlToFileName(url.toString());
715
+ const fileAlreadyExists = await fsj.existsAsync(
716
+ join2(options.directory, FILES_DIRECTORY_NAME, fileName)
717
+ );
718
+ if (fileAlreadyExists) {
719
+ return;
720
+ }
721
+ const response = await fetch(fetchUrl);
722
+ if (!response.ok) {
723
+ return;
724
+ }
725
+ const fileBuffer = await response.arrayBuffer();
726
+ await fsj.writeAsync(
727
+ join2(options.directory, FILES_DIRECTORY_NAME, fileName),
728
+ Buffer.from(fileBuffer)
729
+ );
730
+ } catch {
731
+ console.warn(`Failed to download file ${url}`);
760
732
  }
761
733
  });
762
- } else {
763
- target = await createFileSyncEngineDataSource({
764
- directory,
765
- selectIdentifier,
766
- selectDisplayName,
767
- format
768
- });
769
734
  }
770
- await syncEngine({
771
- source,
772
- target,
773
- mode,
774
- whatIf,
775
- allowEmptySource: true,
776
- log: createSyncEngineConsoleLogger({ diffMode })
777
- });
735
+ await fileDownloadQueue.onIdle();
778
736
  }
737
+ return object;
779
738
  };
780
-
781
- // src/commands/canvas/commands/category/push.ts
782
- import { UncachedCategoryClient as UncachedCategoryClient4 } from "@uniformdev/canvas";
783
- var CategoryPushModule = {
784
- command: "push <directory>",
785
- describe: "Pushes all categories from files in a directory to Uniform Canvas",
786
- builder: (yargs25) => withConfiguration(
787
- withApiOptions(
788
- withProjectOptions(
789
- withDiffOptions(
790
- yargs25.positional("directory", {
791
- describe: "Directory to read the categories from. If a filename is used, a package will be read instead.",
792
- type: "string"
793
- }).option("what-if", {
794
- alias: ["w"],
795
- describe: "What-if mode reports what would be done but changes nothing",
796
- default: false,
797
- type: "boolean"
798
- }).option("mode", {
799
- alias: ["m"],
800
- 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',
801
- choices: ["create", "createOrUpdate", "mirror"],
802
- default: "mirror",
803
- type: "string"
804
- })
805
- )
806
- )
807
- )
808
- ),
809
- handler: async ({
810
- apiHost,
811
- apiKey,
812
- proxy,
813
- directory,
814
- mode,
815
- whatIf,
816
- project: projectId,
817
- diff: diffMode
818
- }) => {
819
- const fetch3 = nodeFetchProxy(proxy);
820
- const client = new UncachedCategoryClient4({ apiKey, apiHost, fetch: fetch3, projectId });
821
- let source;
822
- const isPackage = isPathAPackageFile(directory);
823
- if (isPackage) {
824
- const packageContents = readCanvasPackage(directory, true);
825
- source = await createArraySyncEngineDataSource({
826
- objects: packageContents.categories ?? [],
827
- selectIdentifier,
828
- selectDisplayName
829
- });
830
- } else {
831
- source = await createFileSyncEngineDataSource({
832
- directory,
833
- selectIdentifier,
739
+ var extractAndUploadUniformFilesForObject = async (object, options) => {
740
+ let objectAsString = JSON.stringify(object);
741
+ const uniformFileUrlMatches = objectAsString.matchAll(
742
+ /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
743
+ );
744
+ if (uniformFileUrlMatches) {
745
+ const fileUploadQueue = new PQueue({ concurrency: 3 });
746
+ for (const match of uniformFileUrlMatches) {
747
+ const url = match[1];
748
+ const hash = urlToHash(url);
749
+ fileUploadQueue.add(async () => {
750
+ try {
751
+ const fileAlreadyExistsChecks = await Promise.all([
752
+ options.fileClient.get({ url }).catch(() => null),
753
+ options.fileClient.get({ sourceId: hash }).catch(() => null)
754
+ ]);
755
+ if (fileAlreadyExistsChecks.some((check) => check !== null)) {
756
+ return;
757
+ }
758
+ const localFileName = urlToFileName(url);
759
+ const fileExistsLocally = await fsj.existsAsync(
760
+ join2(options.directory, FILES_DIRECTORY_NAME, localFileName)
761
+ );
762
+ if (!fileExistsLocally) {
763
+ console.warn(`Skipping file ${url} as we couldn't find a local copy`);
764
+ return;
765
+ }
766
+ const fileBuffer = await fsj.readAsync(
767
+ join2(options.directory, FILES_DIRECTORY_NAME, localFileName),
768
+ "buffer"
769
+ );
770
+ if (!fileBuffer) {
771
+ console.warn(`Skipping file ${url} as we couldn't read it`);
772
+ return;
773
+ }
774
+ const fileName = getFileNameFromUrl(url);
775
+ const { width, height } = (() => {
776
+ try {
777
+ return sizeOf(fileBuffer);
778
+ } catch {
779
+ return {
780
+ width: void 0,
781
+ height: void 0
782
+ };
783
+ }
784
+ })();
785
+ const { id, method, uploadUrl } = await options.fileClient.insert({
786
+ name: fileName,
787
+ mediaType: preferredType(url.split(".").at(-1) ?? ""),
788
+ size: fileBuffer.length,
789
+ width,
790
+ height,
791
+ sourceId: hash
792
+ });
793
+ const uploadResponse = await fetch(uploadUrl, {
794
+ method,
795
+ body: fileBuffer
796
+ });
797
+ if (!uploadResponse.ok) {
798
+ console.warn(`Failed to upload file ${url}`);
799
+ return;
800
+ }
801
+ const checkForFile = async () => {
802
+ const file = await options.fileClient.get({ id });
803
+ if (!file || file.state !== FILE_READY_STATE || !file.url) {
804
+ await new Promise((resolve2) => setTimeout(resolve2, 500));
805
+ return checkForFile();
806
+ }
807
+ return file.url;
808
+ };
809
+ const abortTimeout = setTimeout(() => {
810
+ throw new Error(`Failed to upload file ${url}`);
811
+ }, 1e4);
812
+ const uploadedFileUrl = await checkForFile();
813
+ clearTimeout(abortTimeout);
814
+ objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
815
+ } catch {
816
+ console.warn(`Failed to upload file ${url}`);
817
+ }
818
+ });
819
+ }
820
+ await fileUploadQueue.onIdle();
821
+ }
822
+ return JSON.parse(objectAsString);
823
+ };
824
+ var swapOutUniformFileUrlsForTargetProject = async (object, options) => {
825
+ let objectAsString = JSON.stringify(object);
826
+ const uniformFileUrlMatches = objectAsString.matchAll(
827
+ /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
828
+ );
829
+ if (uniformFileUrlMatches) {
830
+ const fileUrlReplacementQueue = new PQueue({ concurrency: 3 });
831
+ for (const match of uniformFileUrlMatches) {
832
+ const url = match[1];
833
+ const hash = urlToHash(url);
834
+ fileUrlReplacementQueue.add(async () => {
835
+ try {
836
+ const fileAlreadyExistsChecks = await Promise.all([
837
+ options.fileClient.get({ url }).catch(() => null),
838
+ options.fileClient.get({ sourceId: hash }).catch(() => null)
839
+ ]);
840
+ const file = fileAlreadyExistsChecks.find((check) => check !== null);
841
+ if (!file) {
842
+ return;
843
+ }
844
+ objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
845
+ } catch {
846
+ }
847
+ });
848
+ }
849
+ await fileUrlReplacementQueue.onIdle();
850
+ }
851
+ return JSON.parse(objectAsString);
852
+ };
853
+ var updateAssetFileIdBasedOnUrl = async (asset, options) => {
854
+ var _a;
855
+ const fileUrl = (_a = asset.asset.url) == null ? void 0 : _a.value;
856
+ if (!fileUrl || !asset.asset.file) {
857
+ return asset;
858
+ }
859
+ const file = await options.fileClient.get({ url: fileUrl }).catch(() => null);
860
+ if (!file) {
861
+ return asset;
862
+ }
863
+ asset.asset.file.value = file.id;
864
+ return asset;
865
+ };
866
+
867
+ // src/commands/canvas/assetEngineDataSource.ts
868
+ import { convertAssetToPutAsset } from "@uniformdev/assets";
869
+
870
+ // src/commands/canvas/commands/asset/_util.ts
871
+ var selectAssetIdentifier = (e) => e.asset._id;
872
+ var selectAssetDisplayName = (e) => {
873
+ var _a;
874
+ return `${((_a = e.asset.title) == null ? void 0 : _a.value) ?? "Untitled"} (pid: ${selectAssetIdentifier(e)})`;
875
+ };
876
+
877
+ // src/commands/canvas/util.ts
878
+ import {
879
+ CANVAS_DRAFT_STATE,
880
+ CANVAS_PUBLISHED_STATE
881
+ } from "@uniformdev/canvas";
882
+ function prepCompositionForDisk(composition) {
883
+ const prepped = {
884
+ ...composition
885
+ };
886
+ delete prepped.projectId;
887
+ delete prepped.state;
888
+ return prepped;
889
+ }
890
+ function withStateOptions(yargs27) {
891
+ return yargs27.option("state", {
892
+ type: "string",
893
+ describe: `Composition state to fetch.`,
894
+ choices: ["preview", "published"],
895
+ default: "preview"
896
+ });
897
+ }
898
+ function convertCompositionState(state) {
899
+ const number = Number(state);
900
+ if (!isNaN(number)) {
901
+ return number;
902
+ }
903
+ if (!state) {
904
+ return CANVAS_PUBLISHED_STATE;
905
+ }
906
+ if (typeof state !== "string") {
907
+ throw new Error('state must be "published", "preview", or a number');
908
+ }
909
+ return state === "preview" ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE;
910
+ }
911
+
912
+ // src/commands/canvas/assetEngineDataSource.ts
913
+ function createAssetEngineDataSource({
914
+ client
915
+ }) {
916
+ async function* getObjects() {
917
+ const assets = paginateAsync(
918
+ async (offset, limit) => (await client.get({
919
+ limit,
920
+ offset
921
+ })).assets,
922
+ { pageSize: 100 }
923
+ );
924
+ for await (const e of assets) {
925
+ const result = {
926
+ id: selectAssetIdentifier(e),
927
+ displayName: selectAssetDisplayName(e),
928
+ providerId: e.asset._id,
929
+ object: prepCompositionForDisk(e)
930
+ };
931
+ yield result;
932
+ }
933
+ }
934
+ return {
935
+ objects: getObjects(),
936
+ deleteObject: async (providerId) => {
937
+ await client.delete({ assetId: providerId });
938
+ },
939
+ writeObject: async ({ object }) => {
940
+ await client.upsert(convertAssetToPutAsset(object));
941
+ }
942
+ };
943
+ }
944
+
945
+ // src/commands/canvas/package.ts
946
+ function readCanvasPackage(filename, assertExists) {
947
+ return readUniformPackage(filename, assertExists);
948
+ }
949
+ function writeCanvasPackage(filename, packageContents) {
950
+ writeUniformPackage(filename, packageContents);
951
+ }
952
+
953
+ // src/commands/canvas/commands/asset/pull.ts
954
+ var AssetPullModule = {
955
+ command: "pull <directory>",
956
+ describe: "Pulls all assets to local files in a directory",
957
+ builder: (yargs27) => withConfiguration(
958
+ withApiOptions(
959
+ withProjectOptions(
960
+ withDiffOptions(
961
+ yargs27.positional("directory", {
962
+ describe: "Directory to save the assets to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
963
+ type: "string"
964
+ }).option("format", {
965
+ alias: ["f"],
966
+ describe: "Output format",
967
+ default: "yaml",
968
+ choices: ["yaml", "json"],
969
+ type: "string"
970
+ }).option("what-if", {
971
+ alias: ["w"],
972
+ describe: "What-if mode reports what would be done but changes no files",
973
+ default: false,
974
+ type: "boolean"
975
+ }).option("mode", {
976
+ alias: ["m"],
977
+ 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',
978
+ choices: ["create", "createOrUpdate", "mirror"],
979
+ default: "mirror",
980
+ type: "string"
981
+ })
982
+ )
983
+ )
984
+ )
985
+ ),
986
+ handler: async ({
987
+ apiHost,
988
+ apiKey,
989
+ proxy,
990
+ directory,
991
+ format,
992
+ mode,
993
+ whatIf,
994
+ project: projectId,
995
+ diff: diffMode
996
+ }) => {
997
+ const fetch3 = nodeFetchProxy(proxy);
998
+ const client = new UncachedAssetClient3({
999
+ apiKey,
1000
+ apiHost,
1001
+ fetch: fetch3,
1002
+ projectId
1003
+ });
1004
+ const source = createAssetEngineDataSource({ client });
1005
+ let target;
1006
+ const isPackage = isPathAPackageFile(directory);
1007
+ const onBeforeDeleteObject = async (id, object) => {
1008
+ var _a;
1009
+ const asset = object.object;
1010
+ if (!((_a = asset.asset.url) == null ? void 0 : _a.value)) {
1011
+ return;
1012
+ }
1013
+ await deleteDownloadedFileByUrl(asset.asset.url.value, {
1014
+ directory
1015
+ });
1016
+ };
1017
+ if (isPackage) {
1018
+ const packageContents = readCanvasPackage(directory, false);
1019
+ target = await createArraySyncEngineDataSource({
1020
+ objects: packageContents.assets ?? [],
1021
+ selectIdentifier: selectAssetIdentifier,
1022
+ selectDisplayName: selectAssetDisplayName,
1023
+ onSyncComplete: async (_, synced) => {
1024
+ packageContents.assets = synced;
1025
+ writeCanvasPackage(directory, packageContents);
1026
+ },
1027
+ onBeforeDeleteObject
1028
+ });
1029
+ } else {
1030
+ target = await createFileSyncEngineDataSource({
1031
+ directory,
1032
+ selectIdentifier: selectAssetIdentifier,
1033
+ selectDisplayName: selectAssetDisplayName,
1034
+ format,
1035
+ onBeforeDeleteObject
1036
+ });
1037
+ }
1038
+ await syncEngine({
1039
+ source,
1040
+ target,
1041
+ mode,
1042
+ whatIf,
1043
+ allowEmptySource: true,
1044
+ log: createSyncEngineConsoleLogger({ diffMode }),
1045
+ onBeforeCompareObjects: async (sourceObject) => {
1046
+ delete sourceObject.object.asset._author;
1047
+ return sourceObject;
1048
+ },
1049
+ onBeforeWriteObject: async (sourceObject) => {
1050
+ delete sourceObject.object.asset._author;
1051
+ return extractAndDownloadUniformFilesForObject(sourceObject, {
1052
+ directory
1053
+ });
1054
+ }
1055
+ });
1056
+ }
1057
+ };
1058
+
1059
+ // src/commands/canvas/commands/asset/push.ts
1060
+ import { UncachedAssetClient as UncachedAssetClient4 } from "@uniformdev/assets";
1061
+ import { UncachedFileClient } from "@uniformdev/files";
1062
+ var AssetPushModule = {
1063
+ command: "push <directory>",
1064
+ describe: "Pushes all assets from files in a directory to Uniform",
1065
+ builder: (yargs27) => withConfiguration(
1066
+ withApiOptions(
1067
+ withProjectOptions(
1068
+ withDiffOptions(
1069
+ yargs27.positional("directory", {
1070
+ describe: "Directory to read the assets from. If a filename is used, a package will be read instead.",
1071
+ type: "string"
1072
+ }).option("what-if", {
1073
+ alias: ["w"],
1074
+ describe: "What-if mode reports what would be done but changes nothing",
1075
+ default: false,
1076
+ type: "boolean"
1077
+ }).option("mode", {
1078
+ alias: ["m"],
1079
+ 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',
1080
+ choices: ["create", "createOrUpdate", "mirror"],
1081
+ default: "mirror",
1082
+ type: "string"
1083
+ })
1084
+ )
1085
+ )
1086
+ )
1087
+ ),
1088
+ handler: async ({
1089
+ apiHost,
1090
+ apiKey,
1091
+ proxy,
1092
+ directory,
1093
+ mode,
1094
+ whatIf,
1095
+ project: projectId,
1096
+ diff: diffMode
1097
+ }) => {
1098
+ const fetch3 = nodeFetchProxy(proxy);
1099
+ const client = new UncachedAssetClient4({
1100
+ apiKey,
1101
+ apiHost,
1102
+ fetch: fetch3,
1103
+ projectId
1104
+ });
1105
+ let source;
1106
+ const isPackage = isPathAPackageFile(directory);
1107
+ if (isPackage) {
1108
+ const packageContents = readCanvasPackage(directory, true);
1109
+ source = await createArraySyncEngineDataSource({
1110
+ objects: packageContents.assets ?? [],
1111
+ selectIdentifier: selectAssetIdentifier,
1112
+ selectDisplayName: selectAssetDisplayName
1113
+ });
1114
+ } else {
1115
+ source = await createFileSyncEngineDataSource({
1116
+ directory,
1117
+ selectIdentifier: selectAssetIdentifier,
1118
+ selectDisplayName: selectAssetDisplayName
1119
+ });
1120
+ }
1121
+ const target = createAssetEngineDataSource({ client });
1122
+ const fileClient = new UncachedFileClient({ apiKey, apiHost, fetch: fetch3, projectId });
1123
+ await syncEngine({
1124
+ source,
1125
+ target,
1126
+ mode,
1127
+ whatIf,
1128
+ log: createSyncEngineConsoleLogger({ diffMode }),
1129
+ onBeforeCompareObjects: async (sourceObject, targetObject) => {
1130
+ if (targetObject) {
1131
+ delete targetObject.object.asset._author;
1132
+ }
1133
+ const sourceObjectWithNewFileUrls = await swapOutUniformFileUrlsForTargetProject(sourceObject, {
1134
+ fileClient
1135
+ });
1136
+ sourceObjectWithNewFileUrls.object = await updateAssetFileIdBasedOnUrl(
1137
+ sourceObjectWithNewFileUrls.object,
1138
+ {
1139
+ fileClient
1140
+ }
1141
+ );
1142
+ return sourceObjectWithNewFileUrls;
1143
+ },
1144
+ onBeforeWriteObject: async (sourceObject) => {
1145
+ const sourceObjectWithNewFileUrls = await extractAndUploadUniformFilesForObject(sourceObject, {
1146
+ directory,
1147
+ fileClient
1148
+ });
1149
+ sourceObjectWithNewFileUrls.object = await updateAssetFileIdBasedOnUrl(
1150
+ sourceObjectWithNewFileUrls.object,
1151
+ {
1152
+ fileClient
1153
+ }
1154
+ );
1155
+ return sourceObjectWithNewFileUrls;
1156
+ }
1157
+ });
1158
+ }
1159
+ };
1160
+
1161
+ // src/commands/canvas/commands/asset/remove.ts
1162
+ import { UncachedAssetClient as UncachedAssetClient5 } from "@uniformdev/assets";
1163
+ var AssetRemoveModule = {
1164
+ command: "remove <id>",
1165
+ aliases: ["delete", "rm"],
1166
+ describe: "Delete an asset",
1167
+ builder: (yargs27) => withConfiguration(
1168
+ withApiOptions(
1169
+ withProjectOptions(yargs27.positional("id", { demandOption: true, describe: "Asset ID to delete" }))
1170
+ )
1171
+ ),
1172
+ handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
1173
+ const fetch3 = nodeFetchProxy(proxy);
1174
+ const client = new UncachedAssetClient5({ apiKey, apiHost, fetch: fetch3, projectId });
1175
+ await client.delete({ assetId: id });
1176
+ }
1177
+ };
1178
+
1179
+ // src/commands/canvas/commands/asset/update.ts
1180
+ import { convertAssetToPutAsset as convertAssetToPutAsset2, UncachedAssetClient as UncachedAssetClient6 } from "@uniformdev/assets";
1181
+ var AssetUpdateModule = {
1182
+ command: "update <filename>",
1183
+ aliases: ["put"],
1184
+ describe: "Insert or update an asset",
1185
+ builder: (yargs27) => withConfiguration(
1186
+ withApiOptions(
1187
+ withProjectOptions(
1188
+ yargs27.positional("filename", { demandOption: true, describe: "Asset file to put" })
1189
+ )
1190
+ )
1191
+ ),
1192
+ handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
1193
+ const fetch3 = nodeFetchProxy(proxy);
1194
+ const client = new UncachedAssetClient6({ apiKey, apiHost, fetch: fetch3, projectId });
1195
+ const file = readFileToObject(filename);
1196
+ await client.upsert(convertAssetToPutAsset2(file));
1197
+ }
1198
+ };
1199
+
1200
+ // src/commands/canvas/commands/asset.ts
1201
+ var AssetModule = {
1202
+ command: "asset <command>",
1203
+ describe: "Commands for Assets",
1204
+ builder: (yargs27) => yargs27.command(AssetGetModule).command(AssetListModule).command(AssetRemoveModule).command(AssetUpdateModule).command(AssetPullModule).command(AssetPushModule).demandCommand(),
1205
+ handler: () => {
1206
+ yargs.help();
1207
+ }
1208
+ };
1209
+
1210
+ // src/commands/canvas/commands/category.ts
1211
+ import yargs2 from "yargs";
1212
+
1213
+ // src/commands/canvas/commands/category/get.ts
1214
+ import { UncachedCategoryClient } from "@uniformdev/canvas";
1215
+ var CategoryGetModule = {
1216
+ command: "get <id>",
1217
+ describe: "Fetch a category",
1218
+ builder: (yargs27) => withConfiguration(
1219
+ withFormatOptions(
1220
+ withApiOptions(
1221
+ withProjectOptions(
1222
+ yargs27.positional("id", { demandOption: true, describe: "Category UUID to fetch" })
1223
+ )
1224
+ )
1225
+ )
1226
+ ),
1227
+ handler: async ({ apiHost, apiKey, proxy, id, format, project: projectId, filename }) => {
1228
+ const fetch3 = nodeFetchProxy(proxy);
1229
+ const client = new UncachedCategoryClient({ apiKey, apiHost, fetch: fetch3, projectId });
1230
+ const res = await client.getCategories();
1231
+ const category = res.categories.find((c) => c.id === id);
1232
+ if (!category) {
1233
+ console.error("Category did not exist");
1234
+ process.exit(1);
1235
+ } else {
1236
+ emitWithFormat(category, format, filename);
1237
+ }
1238
+ }
1239
+ };
1240
+
1241
+ // src/commands/canvas/commands/category/list.ts
1242
+ import { UncachedCategoryClient as UncachedCategoryClient2 } from "@uniformdev/canvas";
1243
+ var CategoryListModule = {
1244
+ command: "list",
1245
+ describe: "List categories",
1246
+ aliases: ["ls"],
1247
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27.options({}))))),
1248
+ handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
1249
+ const fetch3 = nodeFetchProxy(proxy);
1250
+ const client = new UncachedCategoryClient2({ apiKey, apiHost, fetch: fetch3, projectId });
1251
+ const res = await client.getCategories();
1252
+ emitWithFormat(res.categories, format, filename);
1253
+ }
1254
+ };
1255
+
1256
+ // src/commands/canvas/commands/category/pull.ts
1257
+ import { UncachedCategoryClient as UncachedCategoryClient3 } from "@uniformdev/canvas";
1258
+
1259
+ // src/commands/canvas/commands/category/_util.ts
1260
+ var selectIdentifier = (category) => category.id;
1261
+ var selectDisplayName = (category) => `${category.name} (pid: ${category.id})`;
1262
+
1263
+ // src/commands/canvas/categoriesEngineDataSource.ts
1264
+ function createCategoriesEngineDataSource({
1265
+ client
1266
+ }) {
1267
+ async function* getObjects() {
1268
+ const componentDefinitions = paginateAsync(async () => (await client.getCategories()).categories, {
1269
+ pageSize: 100
1270
+ });
1271
+ for await (const def of componentDefinitions) {
1272
+ const result = {
1273
+ id: selectIdentifier(def),
1274
+ displayName: selectDisplayName(def),
1275
+ providerId: def.id,
1276
+ object: def
1277
+ };
1278
+ yield result;
1279
+ }
1280
+ }
1281
+ return {
1282
+ objects: getObjects(),
1283
+ deleteObject: async (providerId) => {
1284
+ await client.removeCategory({ categoryId: providerId });
1285
+ },
1286
+ writeObject: async (object) => {
1287
+ await client.upsertCategories([object.object]);
1288
+ }
1289
+ };
1290
+ }
1291
+
1292
+ // src/commands/canvas/commands/category/pull.ts
1293
+ var CategoryPullModule = {
1294
+ command: "pull <directory>",
1295
+ describe: "Pulls all categories to local files in a directory",
1296
+ builder: (yargs27) => withConfiguration(
1297
+ withApiOptions(
1298
+ withProjectOptions(
1299
+ withDiffOptions(
1300
+ yargs27.positional("directory", {
1301
+ 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.",
1302
+ type: "string"
1303
+ }).option("format", {
1304
+ alias: ["f"],
1305
+ describe: "Output format",
1306
+ default: "yaml",
1307
+ choices: ["yaml", "json"],
1308
+ type: "string"
1309
+ }).option("what-if", {
1310
+ alias: ["w"],
1311
+ describe: "What-if mode reports what would be done but changes no files",
1312
+ default: false,
1313
+ type: "boolean"
1314
+ }).option("mode", {
1315
+ alias: ["m"],
1316
+ 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',
1317
+ choices: ["create", "createOrUpdate", "mirror"],
1318
+ default: "mirror",
1319
+ type: "string"
1320
+ })
1321
+ )
1322
+ )
1323
+ )
1324
+ ),
1325
+ handler: async ({
1326
+ apiHost,
1327
+ apiKey,
1328
+ proxy,
1329
+ directory,
1330
+ format,
1331
+ mode,
1332
+ whatIf,
1333
+ project: projectId,
1334
+ diff: diffMode
1335
+ }) => {
1336
+ const fetch3 = nodeFetchProxy(proxy);
1337
+ const client = new UncachedCategoryClient3({ apiKey, apiHost, fetch: fetch3, projectId });
1338
+ const source = createCategoriesEngineDataSource({ client });
1339
+ let target;
1340
+ const isPackage = isPathAPackageFile(directory);
1341
+ if (isPackage) {
1342
+ const packageContents = readCanvasPackage(directory, false);
1343
+ target = await createArraySyncEngineDataSource({
1344
+ objects: packageContents.categories ?? [],
1345
+ selectIdentifier,
1346
+ selectDisplayName,
1347
+ onSyncComplete: async (_, synced) => {
1348
+ packageContents.categories = synced;
1349
+ writeCanvasPackage(directory, packageContents);
1350
+ }
1351
+ });
1352
+ } else {
1353
+ target = await createFileSyncEngineDataSource({
1354
+ directory,
1355
+ selectIdentifier,
1356
+ selectDisplayName,
1357
+ format
1358
+ });
1359
+ }
1360
+ await syncEngine({
1361
+ source,
1362
+ target,
1363
+ mode,
1364
+ whatIf,
1365
+ allowEmptySource: true,
1366
+ log: createSyncEngineConsoleLogger({ diffMode })
1367
+ });
1368
+ }
1369
+ };
1370
+
1371
+ // src/commands/canvas/commands/category/push.ts
1372
+ import { UncachedCategoryClient as UncachedCategoryClient4 } from "@uniformdev/canvas";
1373
+ var CategoryPushModule = {
1374
+ command: "push <directory>",
1375
+ describe: "Pushes all categories from files in a directory to Uniform Canvas",
1376
+ builder: (yargs27) => withConfiguration(
1377
+ withApiOptions(
1378
+ withProjectOptions(
1379
+ withDiffOptions(
1380
+ yargs27.positional("directory", {
1381
+ describe: "Directory to read the categories from. If a filename is used, a package will be read instead.",
1382
+ type: "string"
1383
+ }).option("what-if", {
1384
+ alias: ["w"],
1385
+ describe: "What-if mode reports what would be done but changes nothing",
1386
+ default: false,
1387
+ type: "boolean"
1388
+ }).option("mode", {
1389
+ alias: ["m"],
1390
+ 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',
1391
+ choices: ["create", "createOrUpdate", "mirror"],
1392
+ default: "mirror",
1393
+ type: "string"
1394
+ })
1395
+ )
1396
+ )
1397
+ )
1398
+ ),
1399
+ handler: async ({
1400
+ apiHost,
1401
+ apiKey,
1402
+ proxy,
1403
+ directory,
1404
+ mode,
1405
+ whatIf,
1406
+ project: projectId,
1407
+ diff: diffMode
1408
+ }) => {
1409
+ const fetch3 = nodeFetchProxy(proxy);
1410
+ const client = new UncachedCategoryClient4({ apiKey, apiHost, fetch: fetch3, projectId });
1411
+ let source;
1412
+ const isPackage = isPathAPackageFile(directory);
1413
+ if (isPackage) {
1414
+ const packageContents = readCanvasPackage(directory, true);
1415
+ source = await createArraySyncEngineDataSource({
1416
+ objects: packageContents.categories ?? [],
1417
+ selectIdentifier,
1418
+ selectDisplayName
1419
+ });
1420
+ } else {
1421
+ source = await createFileSyncEngineDataSource({
1422
+ directory,
1423
+ selectIdentifier,
834
1424
  selectDisplayName
835
1425
  });
836
1426
  }
@@ -851,10 +1441,10 @@ var CategoryRemoveModule = {
851
1441
  command: "remove <id>",
852
1442
  aliases: ["delete", "rm"],
853
1443
  describe: "Delete a category",
854
- builder: (yargs25) => withConfiguration(
1444
+ builder: (yargs27) => withConfiguration(
855
1445
  withApiOptions(
856
1446
  withProjectOptions(
857
- yargs25.positional("id", { demandOption: true, describe: "Category UUID to delete" })
1447
+ yargs27.positional("id", { demandOption: true, describe: "Category UUID to delete" })
858
1448
  )
859
1449
  )
860
1450
  ),
@@ -871,10 +1461,10 @@ var CategoryUpdateModule = {
871
1461
  command: "update <filename>",
872
1462
  aliases: ["put"],
873
1463
  describe: "Insert or update a category",
874
- builder: (yargs25) => withConfiguration(
1464
+ builder: (yargs27) => withConfiguration(
875
1465
  withApiOptions(
876
1466
  withProjectOptions(
877
- yargs25.positional("filename", { demandOption: true, describe: "Category file to put" })
1467
+ yargs27.positional("filename", { demandOption: true, describe: "Category file to put" })
878
1468
  )
879
1469
  )
880
1470
  ),
@@ -891,14 +1481,14 @@ var CategoryModule = {
891
1481
  command: "category <command>",
892
1482
  aliases: ["cat"],
893
1483
  describe: "Commands for Canvas categories",
894
- builder: (yargs25) => yargs25.command(CategoryPullModule).command(CategoryPushModule).command(CategoryGetModule).command(CategoryRemoveModule).command(CategoryListModule).command(CategoryUpdateModule).demandCommand(),
1484
+ builder: (yargs27) => yargs27.command(CategoryPullModule).command(CategoryPushModule).command(CategoryGetModule).command(CategoryRemoveModule).command(CategoryListModule).command(CategoryUpdateModule).demandCommand(),
895
1485
  handler: () => {
896
- yargs.help();
1486
+ yargs2.help();
897
1487
  }
898
1488
  };
899
1489
 
900
1490
  // src/commands/canvas/commands/component.ts
901
- import yargs2 from "yargs";
1491
+ import yargs3 from "yargs";
902
1492
 
903
1493
  // src/commands/canvas/commands/component/get.ts
904
1494
  import { UncachedCanvasClient } from "@uniformdev/canvas";
@@ -912,11 +1502,11 @@ var selectSchemaUrl = () => "/schemas/json-schema/component-definition/v1.json";
912
1502
  var ComponentGetModule = {
913
1503
  command: "get <id>",
914
1504
  describe: "Fetch a component definition",
915
- builder: (yargs25) => withConfiguration(
1505
+ builder: (yargs27) => withConfiguration(
916
1506
  withFormatOptions(
917
1507
  withApiOptions(
918
1508
  withProjectOptions(
919
- yargs25.positional("id", {
1509
+ yargs27.positional("id", {
920
1510
  demandOption: true,
921
1511
  describe: "Component definition public ID to fetch"
922
1512
  })
@@ -950,11 +1540,11 @@ var ComponentListModule = {
950
1540
  command: "list",
951
1541
  describe: "List component definitions",
952
1542
  aliases: ["ls"],
953
- builder: (yargs25) => withConfiguration(
1543
+ builder: (yargs27) => withConfiguration(
954
1544
  withFormatOptions(
955
1545
  withApiOptions(
956
1546
  withProjectOptions(
957
- yargs25.options({
1547
+ yargs27.options({
958
1548
  offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
959
1549
  limit: { describe: "Number of rows to fetch", type: "number", default: 20 }
960
1550
  })
@@ -1009,11 +1599,11 @@ function createComponentDefinitionEngineDataSource({
1009
1599
  var ComponentPullModule = {
1010
1600
  command: "pull <directory>",
1011
1601
  describe: "Pulls all component definitions to local files in a directory",
1012
- builder: (yargs25) => withConfiguration(
1602
+ builder: (yargs27) => withConfiguration(
1013
1603
  withApiOptions(
1014
1604
  withProjectOptions(
1015
1605
  withDiffOptions(
1016
- yargs25.positional("directory", {
1606
+ yargs27.positional("directory", {
1017
1607
  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.",
1018
1608
  type: "string"
1019
1609
  }).option("format", {
@@ -1090,11 +1680,11 @@ import { UncachedCanvasClient as UncachedCanvasClient4 } from "@uniformdev/canva
1090
1680
  var ComponentPushModule = {
1091
1681
  command: "push <directory>",
1092
1682
  describe: "Pushes all component definitions from files in a directory to Uniform Canvas",
1093
- builder: (yargs25) => withConfiguration(
1683
+ builder: (yargs27) => withConfiguration(
1094
1684
  withApiOptions(
1095
1685
  withProjectOptions(
1096
1686
  withDiffOptions(
1097
- yargs25.positional("directory", {
1687
+ yargs27.positional("directory", {
1098
1688
  describe: "Directory to read the component definitions from. If a filename is used, a package will be read instead.",
1099
1689
  type: "string"
1100
1690
  }).option("what-if", {
@@ -1159,10 +1749,10 @@ var ComponentRemoveModule = {
1159
1749
  command: "remove <id>",
1160
1750
  aliases: ["delete", "rm"],
1161
1751
  describe: "Delete a component definition",
1162
- builder: (yargs25) => withConfiguration(
1752
+ builder: (yargs27) => withConfiguration(
1163
1753
  withApiOptions(
1164
1754
  withProjectOptions(
1165
- yargs25.positional("id", { demandOption: true, describe: "Component definition public ID to delete" })
1755
+ yargs27.positional("id", { demandOption: true, describe: "Component definition public ID to delete" })
1166
1756
  )
1167
1757
  )
1168
1758
  ),
@@ -1179,10 +1769,10 @@ var ComponentUpdateModule = {
1179
1769
  command: "update <filename>",
1180
1770
  aliases: ["put"],
1181
1771
  describe: "Insert or update a component definition",
1182
- builder: (yargs25) => withConfiguration(
1772
+ builder: (yargs27) => withConfiguration(
1183
1773
  withApiOptions(
1184
1774
  withProjectOptions(
1185
- yargs25.positional("filename", { demandOption: true, describe: "Component definition file to put" })
1775
+ yargs27.positional("filename", { demandOption: true, describe: "Component definition file to put" })
1186
1776
  )
1187
1777
  )
1188
1778
  ),
@@ -1199,63 +1789,26 @@ var ComponentModule = {
1199
1789
  command: "component <command>",
1200
1790
  aliases: ["def"],
1201
1791
  describe: "Commands for Canvas component definitions",
1202
- builder: (yargs25) => yargs25.command(ComponentPullModule).command(ComponentPushModule).command(ComponentGetModule).command(ComponentRemoveModule).command(ComponentListModule).command(ComponentUpdateModule).demandCommand(),
1203
- handler: () => {
1204
- yargs2.help();
1205
- }
1206
- };
1207
-
1208
- // src/commands/canvas/commands/composition.ts
1209
- import yargs3 from "yargs";
1210
-
1211
- // src/commands/canvas/commands/composition/get.ts
1212
- import { UncachedCanvasClient as UncachedCanvasClient7 } from "@uniformdev/canvas";
1213
-
1214
- // src/commands/canvas/util.ts
1215
- import {
1216
- CANVAS_DRAFT_STATE,
1217
- CANVAS_PUBLISHED_STATE
1218
- } from "@uniformdev/canvas";
1219
- function prepCompositionForDisk(composition) {
1220
- const prepped = {
1221
- ...composition
1222
- };
1223
- delete prepped.projectId;
1224
- delete prepped.state;
1225
- return prepped;
1226
- }
1227
- function withStateOptions(yargs25) {
1228
- return yargs25.option("state", {
1229
- type: "string",
1230
- describe: `Composition state to fetch.`,
1231
- choices: ["preview", "published"],
1232
- default: "preview"
1233
- });
1234
- }
1235
- function convertCompositionState(state) {
1236
- const number = Number(state);
1237
- if (!isNaN(number)) {
1238
- return number;
1239
- }
1240
- if (!state) {
1241
- return CANVAS_PUBLISHED_STATE;
1242
- }
1243
- if (typeof state !== "string") {
1244
- throw new Error('state must be "published", "preview", or a number');
1792
+ builder: (yargs27) => yargs27.command(ComponentPullModule).command(ComponentPushModule).command(ComponentGetModule).command(ComponentRemoveModule).command(ComponentListModule).command(ComponentUpdateModule).demandCommand(),
1793
+ handler: () => {
1794
+ yargs3.help();
1245
1795
  }
1246
- return state === "preview" ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE;
1247
- }
1796
+ };
1797
+
1798
+ // src/commands/canvas/commands/composition.ts
1799
+ import yargs4 from "yargs";
1248
1800
 
1249
1801
  // src/commands/canvas/commands/composition/get.ts
1802
+ import { UncachedCanvasClient as UncachedCanvasClient7 } from "@uniformdev/canvas";
1250
1803
  var CompositionGetModule = {
1251
1804
  command: "get <id>",
1252
1805
  describe: "Fetch a composition",
1253
- builder: (yargs25) => withFormatOptions(
1806
+ builder: (yargs27) => withFormatOptions(
1254
1807
  withConfiguration(
1255
1808
  withApiOptions(
1256
1809
  withProjectOptions(
1257
1810
  withStateOptions(
1258
- yargs25.positional("id", { demandOption: true, describe: "Composition/pattern public ID to fetch" }).option({
1811
+ yargs27.positional("id", { demandOption: true, describe: "Composition/pattern public ID to fetch" }).option({
1259
1812
  resolvePatterns: {
1260
1813
  type: "boolean",
1261
1814
  default: false,
@@ -1326,12 +1879,12 @@ var CompositionListModule = {
1326
1879
  command: "list",
1327
1880
  describe: "List compositions",
1328
1881
  aliases: ["ls"],
1329
- builder: (yargs25) => withFormatOptions(
1882
+ builder: (yargs27) => withFormatOptions(
1330
1883
  withConfiguration(
1331
1884
  withApiOptions(
1332
1885
  withProjectOptions(
1333
1886
  withStateOptions(
1334
- yargs25.options({
1887
+ yargs27.options({
1335
1888
  offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
1336
1889
  limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
1337
1890
  resolvePatterns: {
@@ -1446,271 +1999,97 @@ function createComponentInstanceEngineDataSource({
1446
1999
  await client.updateComposition({ ...object.object, state: stateId });
1447
2000
  }
1448
2001
  };
1449
- }
1450
-
1451
- // src/commands/canvas/commands/composition/publish.ts
1452
- var CompositionPublishModule = {
1453
- command: "publish [ids]",
1454
- describe: "Publishes composition(s)",
1455
- builder: (yargs25) => withConfiguration(
1456
- withApiOptions(
1457
- withProjectOptions(
1458
- withDiffOptions(
1459
- yargs25.positional("ids", {
1460
- describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
1461
- type: "string"
1462
- }).option("all", {
1463
- alias: ["a"],
1464
- describe: "Publishes all compositions. Use compositionId to publish one instead.",
1465
- default: false,
1466
- type: "boolean"
1467
- }).option("what-if", {
1468
- alias: ["w"],
1469
- describe: "What-if mode reports what would be done but does not perform any publishing",
1470
- default: false,
1471
- type: "boolean"
1472
- }).option("onlyCompositions", {
1473
- describe: "Only publishing compositions and not patterns",
1474
- default: false,
1475
- type: "boolean"
1476
- }).option("onlyPatterns", {
1477
- describe: "Only pulling patterns and not compositions",
1478
- default: false,
1479
- type: "boolean",
1480
- hidden: true
1481
- })
1482
- )
1483
- )
1484
- )
1485
- ),
1486
- handler: async ({
1487
- apiHost,
1488
- apiKey,
1489
- proxy,
1490
- ids,
1491
- all,
1492
- whatIf,
1493
- project: projectId,
1494
- onlyCompositions,
1495
- onlyPatterns
1496
- }) => {
1497
- if (!all && !ids || all && ids) {
1498
- console.error(`Specify --all or composition ID(s) to publish.`);
1499
- process.exit(1);
1500
- }
1501
- const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
1502
- const fetch3 = nodeFetchProxy(proxy);
1503
- const client = new UncachedCanvasClient9({ apiKey, apiHost, fetch: fetch3, projectId });
1504
- const source = createComponentInstanceEngineDataSource({
1505
- client,
1506
- state: "preview",
1507
- compositionIDs: compositionIDsArray,
1508
- onlyCompositions,
1509
- onlyPatterns
1510
- });
1511
- const target = createComponentInstanceEngineDataSource({
1512
- client,
1513
- state: "published",
1514
- compositionIDs: compositionIDsArray,
1515
- onlyCompositions,
1516
- onlyPatterns
1517
- });
1518
- await syncEngine({
1519
- source,
1520
- target,
1521
- // Publishing is one-direction operation, so no need to support automatic un-publishing
1522
- mode: "createOrUpdate",
1523
- whatIf,
1524
- log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
1525
- });
1526
- }
1527
- };
1528
-
1529
- // src/commands/canvas/commands/composition/pull.ts
1530
- import { UncachedCanvasClient as UncachedCanvasClient10 } from "@uniformdev/canvas";
1531
-
1532
- // src/files/index.ts
1533
- import { preferredType } from "@thi.ng/mime";
1534
- import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
1535
- import { createHash } from "crypto";
1536
- import fsj from "fs-jetpack";
1537
- import sizeOf from "image-size";
1538
- import PQueue from "p-queue";
1539
- import { join as join2 } from "path";
1540
- var FILES_DIRECTORY_NAME = "files";
1541
- var urlToHash = (url) => {
1542
- const hash = createHash("sha256");
1543
- hash.update(url);
1544
- return hash.digest("hex");
1545
- };
1546
- var urlToFileName = (url) => {
1547
- const fileName = urlToHash(url);
1548
- const fileNameChunks = url.split(".");
1549
- const fileExtension = fileNameChunks.length > 1 ? fileNameChunks.at(-1) : "";
1550
- return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
1551
- };
1552
- var extractAndDownloadUniformFilesForObject = async (object, options) => {
1553
- const objectAsString = JSON.stringify(object);
1554
- const uniformFileUrlMatches = objectAsString.matchAll(
1555
- /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
1556
- );
1557
- if (uniformFileUrlMatches) {
1558
- const fileDownloadQueue = new PQueue({ concurrency: 10 });
1559
- for (const match of uniformFileUrlMatches) {
1560
- const url = new URL(match[1]);
1561
- fileDownloadQueue.add(async () => {
1562
- try {
1563
- const fetchUrl = `${url.origin}${url.pathname}?format=original`;
1564
- const fileName = urlToFileName(url.toString());
1565
- const fileAlreadyExists = await fsj.existsAsync(
1566
- join2(options.directory, FILES_DIRECTORY_NAME, fileName)
1567
- );
1568
- if (fileAlreadyExists) {
1569
- return;
1570
- }
1571
- const response = await fetch(fetchUrl);
1572
- if (!response.ok) {
1573
- return;
1574
- }
1575
- const fileBuffer = await response.arrayBuffer();
1576
- await fsj.writeAsync(
1577
- join2(options.directory, FILES_DIRECTORY_NAME, fileName),
1578
- Buffer.from(fileBuffer)
1579
- );
1580
- } catch {
1581
- console.warn(`Failed to download file ${url}`);
1582
- }
1583
- });
1584
- }
1585
- await fileDownloadQueue.onIdle();
1586
- }
1587
- return object;
1588
- };
1589
- var extractAndUploadUniformFilesForObject = async (object, options) => {
1590
- let objectAsString = JSON.stringify(object);
1591
- const uniformFileUrlMatches = objectAsString.matchAll(
1592
- /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
1593
- );
1594
- if (uniformFileUrlMatches) {
1595
- const fileUploadQueue = new PQueue({ concurrency: 3 });
1596
- for (const match of uniformFileUrlMatches) {
1597
- const url = match[1];
1598
- const hash = urlToHash(url);
1599
- fileUploadQueue.add(async () => {
1600
- try {
1601
- const fileAlreadyExistsChecks = await Promise.all([
1602
- options.fileClient.get({ url }).catch(() => null),
1603
- options.fileClient.get({ sourceId: hash }).catch(() => null)
1604
- ]);
1605
- if (fileAlreadyExistsChecks.some((check) => check !== null)) {
1606
- return;
1607
- }
1608
- const localFileName = urlToFileName(url);
1609
- const fileExistsLocally = await fsj.existsAsync(
1610
- join2(options.directory, FILES_DIRECTORY_NAME, localFileName)
1611
- );
1612
- if (!fileExistsLocally) {
1613
- console.warn(`Skipping file ${url} as we couldn't find a local copy`);
1614
- return;
1615
- }
1616
- const fileBuffer = await fsj.readAsync(
1617
- join2(options.directory, FILES_DIRECTORY_NAME, localFileName),
1618
- "buffer"
1619
- );
1620
- if (!fileBuffer) {
1621
- console.warn(`Skipping file ${url} as we couldn't read it`);
1622
- return;
1623
- }
1624
- const fileName = getFileNameFromUrl(url);
1625
- const { width, height } = (() => {
1626
- try {
1627
- return sizeOf(fileBuffer);
1628
- } catch {
1629
- return {
1630
- width: void 0,
1631
- height: void 0
1632
- };
1633
- }
1634
- })();
1635
- const { id, method, uploadUrl } = await options.fileClient.insert({
1636
- name: fileName,
1637
- mediaType: preferredType(url.split(".").at(-1) ?? ""),
1638
- size: fileBuffer.length,
1639
- width,
1640
- height,
1641
- sourceId: hash
1642
- });
1643
- const uploadResponse = await fetch(uploadUrl, {
1644
- method,
1645
- body: fileBuffer
1646
- });
1647
- if (!uploadResponse.ok) {
1648
- console.warn(`Failed to upload file ${url}`);
1649
- return;
1650
- }
1651
- const checkForFile = async () => {
1652
- const file = await options.fileClient.get({ id });
1653
- if (!file || file.state !== FILE_READY_STATE || !file.url) {
1654
- await new Promise((resolve2) => setTimeout(resolve2, 500));
1655
- return checkForFile();
1656
- }
1657
- return file.url;
1658
- };
1659
- const abortTimeout = setTimeout(() => {
1660
- throw new Error(`Failed to upload file ${url}`);
1661
- }, 1e4);
1662
- const uploadedFileUrl = await checkForFile();
1663
- clearTimeout(abortTimeout);
1664
- objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
1665
- } catch {
1666
- console.warn(`Failed to upload file ${url}`);
1667
- }
1668
- });
1669
- }
1670
- await fileUploadQueue.onIdle();
1671
- }
1672
- return JSON.parse(objectAsString);
1673
- };
1674
- var swapOutUniformFileUrlsForTargetProject = async (object, options) => {
1675
- let objectAsString = JSON.stringify(object);
1676
- const uniformFileUrlMatches = objectAsString.matchAll(
1677
- /"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
1678
- );
1679
- if (uniformFileUrlMatches) {
1680
- const fileUrlReplacementQueue = new PQueue({ concurrency: 3 });
1681
- for (const match of uniformFileUrlMatches) {
1682
- const url = match[1];
1683
- const hash = urlToHash(url);
1684
- fileUrlReplacementQueue.add(async () => {
1685
- try {
1686
- const fileAlreadyExistsChecks = await Promise.all([
1687
- options.fileClient.get({ url }).catch(() => null),
1688
- options.fileClient.get({ sourceId: hash }).catch(() => null)
1689
- ]);
1690
- const file = fileAlreadyExistsChecks.find((check) => check !== null);
1691
- if (!file) {
1692
- return;
1693
- }
1694
- objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
1695
- } catch {
1696
- }
1697
- });
2002
+ }
2003
+
2004
+ // src/commands/canvas/commands/composition/publish.ts
2005
+ var CompositionPublishModule = {
2006
+ command: "publish [ids]",
2007
+ describe: "Publishes composition(s)",
2008
+ builder: (yargs27) => withConfiguration(
2009
+ withApiOptions(
2010
+ withProjectOptions(
2011
+ withDiffOptions(
2012
+ yargs27.positional("ids", {
2013
+ describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
2014
+ type: "string"
2015
+ }).option("all", {
2016
+ alias: ["a"],
2017
+ describe: "Publishes all compositions. Use compositionId to publish one instead.",
2018
+ default: false,
2019
+ type: "boolean"
2020
+ }).option("what-if", {
2021
+ alias: ["w"],
2022
+ describe: "What-if mode reports what would be done but does not perform any publishing",
2023
+ default: false,
2024
+ type: "boolean"
2025
+ }).option("onlyCompositions", {
2026
+ describe: "Only publishing compositions and not patterns",
2027
+ default: false,
2028
+ type: "boolean"
2029
+ }).option("onlyPatterns", {
2030
+ describe: "Only pulling patterns and not compositions",
2031
+ default: false,
2032
+ type: "boolean",
2033
+ hidden: true
2034
+ })
2035
+ )
2036
+ )
2037
+ )
2038
+ ),
2039
+ handler: async ({
2040
+ apiHost,
2041
+ apiKey,
2042
+ proxy,
2043
+ ids,
2044
+ all,
2045
+ whatIf,
2046
+ project: projectId,
2047
+ onlyCompositions,
2048
+ onlyPatterns
2049
+ }) => {
2050
+ if (!all && !ids || all && ids) {
2051
+ console.error(`Specify --all or composition ID(s) to publish.`);
2052
+ process.exit(1);
1698
2053
  }
1699
- await fileUrlReplacementQueue.onIdle();
2054
+ const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
2055
+ const fetch3 = nodeFetchProxy(proxy);
2056
+ const client = new UncachedCanvasClient9({ apiKey, apiHost, fetch: fetch3, projectId });
2057
+ const source = createComponentInstanceEngineDataSource({
2058
+ client,
2059
+ state: "preview",
2060
+ compositionIDs: compositionIDsArray,
2061
+ onlyCompositions,
2062
+ onlyPatterns
2063
+ });
2064
+ const target = createComponentInstanceEngineDataSource({
2065
+ client,
2066
+ state: "published",
2067
+ compositionIDs: compositionIDsArray,
2068
+ onlyCompositions,
2069
+ onlyPatterns
2070
+ });
2071
+ await syncEngine({
2072
+ source,
2073
+ target,
2074
+ // Publishing is one-direction operation, so no need to support automatic un-publishing
2075
+ mode: "createOrUpdate",
2076
+ whatIf,
2077
+ log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
2078
+ });
1700
2079
  }
1701
- return JSON.parse(objectAsString);
1702
2080
  };
1703
2081
 
1704
2082
  // src/commands/canvas/commands/composition/pull.ts
2083
+ import { UncachedCanvasClient as UncachedCanvasClient10 } from "@uniformdev/canvas";
1705
2084
  var CompositionPullModule = {
1706
2085
  command: "pull <directory>",
1707
2086
  describe: "Pulls all compositions to local files in a directory",
1708
- builder: (yargs25) => withConfiguration(
2087
+ builder: (yargs27) => withConfiguration(
1709
2088
  withApiOptions(
1710
2089
  withProjectOptions(
1711
2090
  withStateOptions(
1712
2091
  withDiffOptions(
1713
- yargs25.positional("directory", {
2092
+ yargs27.positional("directory", {
1714
2093
  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.",
1715
2094
  type: "string"
1716
2095
  }).option("format", {
@@ -1801,16 +2180,16 @@ var CompositionPullModule = {
1801
2180
 
1802
2181
  // src/commands/canvas/commands/composition/push.ts
1803
2182
  import { UncachedCanvasClient as UncachedCanvasClient11 } from "@uniformdev/canvas";
1804
- import { FileClient as FileClient2 } from "@uniformdev/files";
2183
+ import { UncachedFileClient as UncachedFileClient2 } from "@uniformdev/files";
1805
2184
  var CompositionPushModule = {
1806
2185
  command: "push <directory>",
1807
2186
  describe: "Pushes all compositions from files in a directory to Uniform Canvas",
1808
- builder: (yargs25) => withConfiguration(
2187
+ builder: (yargs27) => withConfiguration(
1809
2188
  withApiOptions(
1810
2189
  withProjectOptions(
1811
2190
  withStateOptions(
1812
2191
  withDiffOptions(
1813
- yargs25.positional("directory", {
2192
+ yargs27.positional("directory", {
1814
2193
  describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
1815
2194
  type: "string"
1816
2195
  }).option("what-if", {
@@ -1871,7 +2250,7 @@ var CompositionPushModule = {
1871
2250
  });
1872
2251
  }
1873
2252
  const target = createComponentInstanceEngineDataSource({ client, state, onlyCompositions, onlyPatterns });
1874
- const fileClient = new FileClient2({ apiKey, apiHost, fetch: fetch3, projectId });
2253
+ const fileClient = new UncachedFileClient2({ apiKey, apiHost, fetch: fetch3, projectId });
1875
2254
  await syncEngine({
1876
2255
  source,
1877
2256
  target,
@@ -1880,15 +2259,13 @@ var CompositionPushModule = {
1880
2259
  log: createSyncEngineConsoleLogger({ diffMode }),
1881
2260
  onBeforeCompareObjects: async (sourceObject) => {
1882
2261
  return swapOutUniformFileUrlsForTargetProject(sourceObject, {
1883
- fileClient,
1884
- projectId
2262
+ fileClient
1885
2263
  });
1886
2264
  },
1887
2265
  onBeforeWriteObject: async (sourceObject) => {
1888
2266
  return extractAndUploadUniformFilesForObject(sourceObject, {
1889
2267
  directory,
1890
- fileClient,
1891
- projectId
2268
+ fileClient
1892
2269
  });
1893
2270
  }
1894
2271
  });
@@ -1901,10 +2278,10 @@ var CompositionRemoveModule = {
1901
2278
  command: "remove <id>",
1902
2279
  aliases: ["delete", "rm"],
1903
2280
  describe: "Delete a composition",
1904
- builder: (yargs25) => withConfiguration(
2281
+ builder: (yargs27) => withConfiguration(
1905
2282
  withApiOptions(
1906
2283
  withProjectOptions(
1907
- yargs25.positional("id", { demandOption: true, describe: "Composition/pattern public ID to delete" })
2284
+ yargs27.positional("id", { demandOption: true, describe: "Composition/pattern public ID to delete" })
1908
2285
  )
1909
2286
  )
1910
2287
  ),
@@ -1921,10 +2298,10 @@ import { diffJson as diffJson2 } from "diff";
1921
2298
  var CompositionUnpublishModule = {
1922
2299
  command: "unpublish [ids]",
1923
2300
  describe: "Unpublish a composition(s)",
1924
- builder: (yargs25) => withConfiguration(
2301
+ builder: (yargs27) => withConfiguration(
1925
2302
  withApiOptions(
1926
2303
  withProjectOptions(
1927
- yargs25.positional("ids", {
2304
+ yargs27.positional("ids", {
1928
2305
  describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
1929
2306
  type: "string"
1930
2307
  }).option("all", {
@@ -2018,11 +2395,11 @@ var CompositionUpdateModule = {
2018
2395
  command: "update <filename>",
2019
2396
  aliases: ["put"],
2020
2397
  describe: "Insert or update a composition",
2021
- builder: (yargs25) => withConfiguration(
2398
+ builder: (yargs27) => withConfiguration(
2022
2399
  withApiOptions(
2023
2400
  withProjectOptions(
2024
2401
  withStateOptions(
2025
- yargs25.positional("filename", { demandOption: true, describe: "Composition/pattern file to put" })
2402
+ yargs27.positional("filename", { demandOption: true, describe: "Composition/pattern file to put" })
2026
2403
  )
2027
2404
  )
2028
2405
  )
@@ -2040,26 +2417,26 @@ var CompositionModule = {
2040
2417
  command: "composition <command>",
2041
2418
  describe: "Commands for Canvas compositions",
2042
2419
  aliases: ["comp"],
2043
- builder: (yargs25) => yargs25.command(CompositionPullModule).command(CompositionPushModule).command(CompositionGetModule).command(CompositionRemoveModule).command(CompositionListModule).command(CompositionUpdateModule).command(CompositionPublishModule).command(CompositionUnpublishModule).demandCommand(),
2420
+ builder: (yargs27) => yargs27.command(CompositionPullModule).command(CompositionPushModule).command(CompositionGetModule).command(CompositionRemoveModule).command(CompositionListModule).command(CompositionUpdateModule).command(CompositionPublishModule).command(CompositionUnpublishModule).demandCommand(),
2044
2421
  handler: () => {
2045
- yargs3.help();
2422
+ yargs4.help();
2046
2423
  }
2047
2424
  };
2048
2425
 
2049
2426
  // src/commands/canvas/commands/contentType.ts
2050
- import yargs4 from "yargs";
2427
+ import yargs5 from "yargs";
2051
2428
 
2052
2429
  // src/commands/canvas/commands/contentType/get.ts
2053
2430
  import { ContentClient } from "@uniformdev/canvas";
2054
2431
  var ContentTypeGetModule = {
2055
2432
  command: "get <id>",
2056
2433
  describe: "Get a content type",
2057
- builder: (yargs25) => withConfiguration(
2434
+ builder: (yargs27) => withConfiguration(
2058
2435
  withFormatOptions(
2059
2436
  withApiOptions(
2060
2437
  withProjectOptions(
2061
2438
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2062
- yargs25.positional("id", { demandOption: true, describe: "Content type public ID to fetch" })
2439
+ yargs27.positional("id", { demandOption: true, describe: "Content type public ID to fetch" })
2063
2440
  )
2064
2441
  )
2065
2442
  )
@@ -2081,7 +2458,7 @@ import { ContentClient as ContentClient2 } from "@uniformdev/canvas";
2081
2458
  var ContentTypeListModule = {
2082
2459
  command: "list",
2083
2460
  describe: "List content types",
2084
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
2461
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
2085
2462
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
2086
2463
  const fetch3 = nodeFetchProxy(proxy);
2087
2464
  const client = new ContentClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
@@ -2128,11 +2505,11 @@ function createContentTypeEngineDataSource({
2128
2505
  var ContentTypePullModule = {
2129
2506
  command: "pull <directory>",
2130
2507
  describe: "Pulls all content types to local files in a directory",
2131
- builder: (yargs25) => withConfiguration(
2508
+ builder: (yargs27) => withConfiguration(
2132
2509
  withApiOptions(
2133
2510
  withProjectOptions(
2134
2511
  withDiffOptions(
2135
- yargs25.positional("directory", {
2512
+ yargs27.positional("directory", {
2136
2513
  describe: "Directory to save the content types to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2137
2514
  type: "string"
2138
2515
  }).option("format", {
@@ -2214,11 +2591,11 @@ import { ContentClient as ContentClient4 } from "@uniformdev/canvas";
2214
2591
  var ContentTypePushModule = {
2215
2592
  command: "push <directory>",
2216
2593
  describe: "Pushes all content types from files in a directory to Uniform",
2217
- builder: (yargs25) => withConfiguration(
2594
+ builder: (yargs27) => withConfiguration(
2218
2595
  withApiOptions(
2219
2596
  withProjectOptions(
2220
2597
  withDiffOptions(
2221
- yargs25.positional("directory", {
2598
+ yargs27.positional("directory", {
2222
2599
  describe: "Directory to read the content types from. If a filename is used, a package will be read instead.",
2223
2600
  type: "string"
2224
2601
  }).option("what-if", {
@@ -2288,10 +2665,10 @@ var ContentTypeRemoveModule = {
2288
2665
  command: "remove <id>",
2289
2666
  aliases: ["delete", "rm"],
2290
2667
  describe: "Delete a content type",
2291
- builder: (yargs25) => withConfiguration(
2668
+ builder: (yargs27) => withConfiguration(
2292
2669
  withApiOptions(
2293
2670
  withProjectOptions(
2294
- yargs25.positional("id", { demandOption: true, describe: "Content type public ID to delete" })
2671
+ yargs27.positional("id", { demandOption: true, describe: "Content type public ID to delete" })
2295
2672
  )
2296
2673
  )
2297
2674
  ),
@@ -2308,10 +2685,10 @@ var ContentTypeUpdateModule = {
2308
2685
  command: "update <filename>",
2309
2686
  aliases: ["put"],
2310
2687
  describe: "Insert or update a content type",
2311
- builder: (yargs25) => withConfiguration(
2688
+ builder: (yargs27) => withConfiguration(
2312
2689
  withApiOptions(
2313
2690
  withProjectOptions(
2314
- yargs25.positional("filename", { demandOption: true, describe: "Content type file to put" })
2691
+ yargs27.positional("filename", { demandOption: true, describe: "Content type file to put" })
2315
2692
  )
2316
2693
  )
2317
2694
  ),
@@ -2328,14 +2705,14 @@ var ContentTypeModule = {
2328
2705
  command: "contenttype <command>",
2329
2706
  aliases: ["ct"],
2330
2707
  describe: "Commands for Content Types",
2331
- builder: (yargs25) => yargs25.command(ContentTypeGetModule).command(ContentTypeListModule).command(ContentTypeRemoveModule).command(ContentTypeUpdateModule).command(ContentTypePullModule).command(ContentTypePushModule).demandCommand(),
2708
+ builder: (yargs27) => yargs27.command(ContentTypeGetModule).command(ContentTypeListModule).command(ContentTypeRemoveModule).command(ContentTypeUpdateModule).command(ContentTypePullModule).command(ContentTypePushModule).demandCommand(),
2332
2709
  handler: () => {
2333
- yargs4.help();
2710
+ yargs5.help();
2334
2711
  }
2335
2712
  };
2336
2713
 
2337
2714
  // src/commands/canvas/commands/dataType.ts
2338
- import yargs5 from "yargs";
2715
+ import yargs6 from "yargs";
2339
2716
 
2340
2717
  // src/commands/canvas/commands/dataType/get.ts
2341
2718
  import { DataTypeClient } from "@uniformdev/canvas";
@@ -2343,12 +2720,12 @@ var DataTypeGetModule = {
2343
2720
  command: "get <id>",
2344
2721
  describe: "Get a data type",
2345
2722
  aliases: ["ls"],
2346
- builder: (yargs25) => withConfiguration(
2723
+ builder: (yargs27) => withConfiguration(
2347
2724
  withFormatOptions(
2348
2725
  withApiOptions(
2349
2726
  withProjectOptions(
2350
2727
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2351
- yargs25.positional("id", { demandOption: true, describe: "Data type public ID to fetch" })
2728
+ yargs27.positional("id", { demandOption: true, describe: "Data type public ID to fetch" })
2352
2729
  )
2353
2730
  )
2354
2731
  )
@@ -2371,7 +2748,7 @@ var DataTypeListModule = {
2371
2748
  command: "list",
2372
2749
  describe: "List data types",
2373
2750
  aliases: ["ls"],
2374
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
2751
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
2375
2752
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
2376
2753
  const fetch3 = nodeFetchProxy(proxy);
2377
2754
  const client = new DataTypeClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
@@ -2424,11 +2801,11 @@ function createDataTypeEngineDataSource({
2424
2801
  var DataTypePullModule = {
2425
2802
  command: "pull <directory>",
2426
2803
  describe: "Pulls all data types to local files in a directory",
2427
- builder: (yargs25) => withConfiguration(
2804
+ builder: (yargs27) => withConfiguration(
2428
2805
  withApiOptions(
2429
2806
  withProjectOptions(
2430
2807
  withDiffOptions(
2431
- yargs25.positional("directory", {
2808
+ yargs27.positional("directory", {
2432
2809
  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.",
2433
2810
  type: "string"
2434
2811
  }).option("format", {
@@ -2510,11 +2887,11 @@ import { DataTypeClient as DataTypeClient4 } from "@uniformdev/canvas";
2510
2887
  var DataTypePushModule = {
2511
2888
  command: "push <directory>",
2512
2889
  describe: "Pushes all data types from files in a directory to Uniform",
2513
- builder: (yargs25) => withConfiguration(
2890
+ builder: (yargs27) => withConfiguration(
2514
2891
  withApiOptions(
2515
2892
  withProjectOptions(
2516
2893
  withDiffOptions(
2517
- yargs25.positional("directory", {
2894
+ yargs27.positional("directory", {
2518
2895
  describe: "Directory to read the data types from. If a filename is used, a package will be read instead.",
2519
2896
  type: "string"
2520
2897
  }).option("what-if", {
@@ -2584,10 +2961,10 @@ var DataTypeRemoveModule = {
2584
2961
  command: "remove <id>",
2585
2962
  aliases: ["delete", "rm"],
2586
2963
  describe: "Delete a data type",
2587
- builder: (yargs25) => withConfiguration(
2964
+ builder: (yargs27) => withConfiguration(
2588
2965
  withApiOptions(
2589
2966
  withProjectOptions(
2590
- yargs25.positional("id", { demandOption: true, describe: "Data type public ID to delete" })
2967
+ yargs27.positional("id", { demandOption: true, describe: "Data type public ID to delete" })
2591
2968
  )
2592
2969
  )
2593
2970
  ),
@@ -2604,10 +2981,10 @@ var DataTypeUpdateModule = {
2604
2981
  command: "update <filename>",
2605
2982
  aliases: ["put"],
2606
2983
  describe: "Insert or update a data type",
2607
- builder: (yargs25) => withConfiguration(
2984
+ builder: (yargs27) => withConfiguration(
2608
2985
  withApiOptions(
2609
2986
  withProjectOptions(
2610
- yargs25.positional("filename", { demandOption: true, describe: "Data type file to put" })
2987
+ yargs27.positional("filename", { demandOption: true, describe: "Data type file to put" })
2611
2988
  )
2612
2989
  )
2613
2990
  ),
@@ -2624,26 +3001,26 @@ var DataTypeModule = {
2624
3001
  command: "datatype <command>",
2625
3002
  aliases: ["dt"],
2626
3003
  describe: "Commands for Data Type definitions",
2627
- builder: (yargs25) => yargs25.command(DataTypeGetModule).command(DataTypePullModule).command(DataTypePushModule).command(DataTypeRemoveModule).command(DataTypeListModule).command(DataTypeUpdateModule).demandCommand(),
3004
+ builder: (yargs27) => yargs27.command(DataTypeGetModule).command(DataTypePullModule).command(DataTypePushModule).command(DataTypeRemoveModule).command(DataTypeListModule).command(DataTypeUpdateModule).demandCommand(),
2628
3005
  handler: () => {
2629
- yargs5.help();
3006
+ yargs6.help();
2630
3007
  }
2631
3008
  };
2632
3009
 
2633
3010
  // src/commands/canvas/commands/entry.ts
2634
- import yargs6 from "yargs";
3011
+ import yargs7 from "yargs";
2635
3012
 
2636
3013
  // src/commands/canvas/commands/entry/get.ts
2637
3014
  import { ContentClient as ContentClient7 } from "@uniformdev/canvas";
2638
3015
  var EntryGetModule = {
2639
3016
  command: "get <id>",
2640
3017
  describe: "Get an entry",
2641
- builder: (yargs25) => withConfiguration(
3018
+ builder: (yargs27) => withConfiguration(
2642
3019
  withFormatOptions(
2643
3020
  withApiOptions(
2644
3021
  withProjectOptions(
2645
3022
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2646
- yargs25.positional("id", { demandOption: true, describe: "Entry public ID to fetch" })
3023
+ yargs27.positional("id", { demandOption: true, describe: "Entry public ID to fetch" })
2647
3024
  )
2648
3025
  )
2649
3026
  )
@@ -2664,7 +3041,7 @@ import { ContentClient as ContentClient8 } from "@uniformdev/canvas";
2664
3041
  var EntryListModule = {
2665
3042
  command: "list",
2666
3043
  describe: "List entries",
2667
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
3044
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
2668
3045
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
2669
3046
  const fetch3 = nodeFetchProxy(proxy);
2670
3047
  const client = new ContentClient8({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
@@ -2722,12 +3099,12 @@ function createEntryEngineDataSource({
2722
3099
  var EntryPullModule = {
2723
3100
  command: "pull <directory>",
2724
3101
  describe: "Pulls all entries to local files in a directory",
2725
- builder: (yargs25) => withConfiguration(
3102
+ builder: (yargs27) => withConfiguration(
2726
3103
  withApiOptions(
2727
3104
  withProjectOptions(
2728
3105
  withStateOptions(
2729
3106
  withDiffOptions(
2730
- yargs25.positional("directory", {
3107
+ yargs27.positional("directory", {
2731
3108
  describe: "Directory to save the entries to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
2732
3109
  type: "string"
2733
3110
  }).option("format", {
@@ -2811,12 +3188,12 @@ import { ContentClient as ContentClient11 } from "@uniformdev/canvas";
2811
3188
  var EntryPushModule = {
2812
3189
  command: "push <directory>",
2813
3190
  describe: "Pushes all entries from files in a directory to Uniform",
2814
- builder: (yargs25) => withConfiguration(
3191
+ builder: (yargs27) => withConfiguration(
2815
3192
  withApiOptions(
2816
3193
  withProjectOptions(
2817
3194
  withStateOptions(
2818
3195
  withDiffOptions(
2819
- yargs25.positional("directory", {
3196
+ yargs27.positional("directory", {
2820
3197
  describe: "Directory to read the entries from. If a filename is used, a package will be read instead.",
2821
3198
  type: "string"
2822
3199
  }).option("what-if", {
@@ -2888,10 +3265,10 @@ var EntryRemoveModule = {
2888
3265
  command: "remove <id>",
2889
3266
  aliases: ["delete", "rm"],
2890
3267
  describe: "Delete an entry",
2891
- builder: (yargs25) => withConfiguration(
3268
+ builder: (yargs27) => withConfiguration(
2892
3269
  withApiOptions(
2893
3270
  withProjectOptions(
2894
- yargs25.positional("id", { demandOption: true, describe: "Entry public ID to delete" })
3271
+ yargs27.positional("id", { demandOption: true, describe: "Entry public ID to delete" })
2895
3272
  )
2896
3273
  )
2897
3274
  ),
@@ -2908,10 +3285,10 @@ var EntryUpdateModule = {
2908
3285
  command: "update <filename>",
2909
3286
  aliases: ["put"],
2910
3287
  describe: "Insert or update an entry",
2911
- builder: (yargs25) => withConfiguration(
3288
+ builder: (yargs27) => withConfiguration(
2912
3289
  withApiOptions(
2913
3290
  withProjectOptions(
2914
- yargs25.positional("filename", { demandOption: true, describe: "Entry file to put" })
3291
+ yargs27.positional("filename", { demandOption: true, describe: "Entry file to put" })
2915
3292
  )
2916
3293
  )
2917
3294
  ),
@@ -2927,14 +3304,14 @@ var EntryUpdateModule = {
2927
3304
  var EntryModule = {
2928
3305
  command: "entry <command>",
2929
3306
  describe: "Commands for Entries",
2930
- builder: (yargs25) => yargs25.command(EntryGetModule).command(EntryListModule).command(EntryRemoveModule).command(EntryUpdateModule).command(EntryPullModule).command(EntryPushModule).demandCommand(),
3307
+ builder: (yargs27) => yargs27.command(EntryGetModule).command(EntryListModule).command(EntryRemoveModule).command(EntryUpdateModule).command(EntryPullModule).command(EntryPushModule).demandCommand(),
2931
3308
  handler: () => {
2932
- yargs6.help();
3309
+ yargs7.help();
2933
3310
  }
2934
3311
  };
2935
3312
 
2936
3313
  // src/commands/canvas/commands/pattern.ts
2937
- import yargs7 from "yargs";
3314
+ import yargs8 from "yargs";
2938
3315
 
2939
3316
  // src/commands/canvas/commands/pattern/get.ts
2940
3317
  var PatternGetModule = {
@@ -2946,12 +3323,12 @@ var PatternGetModule = {
2946
3323
  var PatternListModule = {
2947
3324
  ...CompositionListModule,
2948
3325
  describe: "List patterns",
2949
- builder: (yargs25) => withFormatOptions(
3326
+ builder: (yargs27) => withFormatOptions(
2950
3327
  withConfiguration(
2951
3328
  withApiOptions(
2952
3329
  withProjectOptions(
2953
3330
  withStateOptions(
2954
- yargs25.options({
3331
+ yargs27.options({
2955
3332
  offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
2956
3333
  limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
2957
3334
  resolvePatterns: {
@@ -2989,11 +3366,11 @@ var PatternListModule = {
2989
3366
  var PatternPublishModule = {
2990
3367
  ...CompositionPublishModule,
2991
3368
  describe: "Publishes pattern(s)",
2992
- builder: (yargs25) => withConfiguration(
3369
+ builder: (yargs27) => withConfiguration(
2993
3370
  withApiOptions(
2994
3371
  withProjectOptions(
2995
3372
  withDiffOptions(
2996
- yargs25.positional("ids", {
3373
+ yargs27.positional("ids", {
2997
3374
  describe: "Publishes pattern(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
2998
3375
  type: "string"
2999
3376
  }).option("all", {
@@ -3031,12 +3408,12 @@ var PatternPublishModule = {
3031
3408
  var PatternPullModule = {
3032
3409
  ...CompositionPullModule,
3033
3410
  describe: "Pulls all patterns to local files in a directory",
3034
- builder: (yargs25) => withConfiguration(
3411
+ builder: (yargs27) => withConfiguration(
3035
3412
  withApiOptions(
3036
3413
  withProjectOptions(
3037
3414
  withStateOptions(
3038
3415
  withDiffOptions(
3039
- yargs25.positional("directory", {
3416
+ yargs27.positional("directory", {
3040
3417
  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.",
3041
3418
  type: "string"
3042
3419
  }).option("format", {
@@ -3067,20 +3444,280 @@ var PatternPullModule = {
3067
3444
  )
3068
3445
  )
3069
3446
  )
3070
- )
3447
+ )
3448
+ };
3449
+
3450
+ // src/commands/canvas/commands/pattern/push.ts
3451
+ var PatternPushModule = {
3452
+ ...CompositionPushModule,
3453
+ describe: "Pushes all patterns from files in a directory to Uniform Canvas",
3454
+ builder: (yargs27) => withConfiguration(
3455
+ withApiOptions(
3456
+ withProjectOptions(
3457
+ withStateOptions(
3458
+ withDiffOptions(
3459
+ yargs27.positional("directory", {
3460
+ describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
3461
+ type: "string"
3462
+ }).option("what-if", {
3463
+ alias: ["w"],
3464
+ describe: "What-if mode reports what would be done but changes nothing",
3465
+ default: false,
3466
+ type: "boolean"
3467
+ }).option("mode", {
3468
+ alias: ["m"],
3469
+ 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',
3470
+ choices: ["create", "createOrUpdate", "mirror"],
3471
+ default: "mirror",
3472
+ type: "string"
3473
+ }).option("onlyPatterns", {
3474
+ describe: "Only pulling patterns and not compositions",
3475
+ // This default differentiate this list command from composition list command
3476
+ default: true,
3477
+ type: "boolean",
3478
+ hidden: true
3479
+ })
3480
+ )
3481
+ )
3482
+ )
3483
+ )
3484
+ )
3485
+ };
3486
+
3487
+ // src/commands/canvas/commands/pattern/remove.ts
3488
+ var PatternRemoveModule = {
3489
+ ...CompositionRemoveModule,
3490
+ describe: "Delete a pattern"
3491
+ };
3492
+
3493
+ // src/commands/canvas/commands/pattern/unpublish.ts
3494
+ var PatternUnpublishModule = {
3495
+ command: "unpublish [ids]",
3496
+ describe: "Unpublish a pattern(s)",
3497
+ builder: (yargs27) => withConfiguration(
3498
+ withApiOptions(
3499
+ withProjectOptions(
3500
+ yargs27.positional("ids", {
3501
+ describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
3502
+ type: "string"
3503
+ }).option("all", {
3504
+ alias: ["a"],
3505
+ describe: "Un-pPublishes all compositions. Use compositionId to publish one instead.",
3506
+ default: false,
3507
+ type: "boolean"
3508
+ }).option("what-if", {
3509
+ alias: ["w"],
3510
+ describe: "What-if mode reports what would be done but does not perform any publishing",
3511
+ default: false,
3512
+ type: "boolean"
3513
+ }).option("onlyCompositions", {
3514
+ describe: "Only publishing compositions and not patterns",
3515
+ default: false,
3516
+ type: "boolean"
3517
+ }).option("onlyPatterns", {
3518
+ describe: "Only pulling patterns and not compositions",
3519
+ default: true,
3520
+ type: "boolean",
3521
+ hidden: true
3522
+ })
3523
+ )
3524
+ )
3525
+ ),
3526
+ handler: CompositionUnpublishModule.handler
3527
+ };
3528
+
3529
+ // src/commands/canvas/commands/pattern/update.ts
3530
+ var PatternUpdateModule = {
3531
+ ...CompositionUpdateModule,
3532
+ describe: "Insert or update a pattern"
3533
+ };
3534
+
3535
+ // src/commands/canvas/commands/pattern.ts
3536
+ var PatternModule = {
3537
+ command: "pattern <command>",
3538
+ describe: "Commands for Canvas patterns",
3539
+ builder: (yargs27) => yargs27.command(PatternPullModule).command(PatternPushModule).command(PatternGetModule).command(PatternRemoveModule).command(PatternListModule).command(PatternUpdateModule).command(PatternPublishModule).command(PatternUnpublishModule).demandCommand(),
3540
+ handler: () => {
3541
+ yargs8.help();
3542
+ }
3543
+ };
3544
+
3545
+ // src/commands/canvas/commands/prompts.ts
3546
+ import yargs9 from "yargs";
3547
+
3548
+ // src/commands/canvas/commands/prompts/get.ts
3549
+ import { PromptClient } from "@uniformdev/canvas";
3550
+ var PromptGetModule = {
3551
+ command: "get <id>",
3552
+ describe: "Get a prompt",
3553
+ builder: (yargs27) => withConfiguration(
3554
+ withFormatOptions(
3555
+ withApiOptions(
3556
+ withProjectOptions(
3557
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3558
+ yargs27.positional("id", { demandOption: true, describe: "Prompt ID to fetch" })
3559
+ )
3560
+ )
3561
+ )
3562
+ ),
3563
+ handler: async ({ apiHost, apiKey, proxy, id, format, filename, project: projectId }) => {
3564
+ const fetch3 = nodeFetchProxy(proxy);
3565
+ const client = new PromptClient({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3566
+ const res = await client.get({ promptId: id });
3567
+ if (!res.result) {
3568
+ throw new Error(`Prompt with ID ${id} not found`);
3569
+ }
3570
+ emitWithFormat(res.result, format, filename);
3571
+ }
3572
+ };
3573
+
3574
+ // src/commands/canvas/commands/prompts/list.ts
3575
+ import { PromptClient as PromptClient2 } from "@uniformdev/canvas";
3576
+ var PromptListModule = {
3577
+ command: "list",
3578
+ describe: "List prompts",
3579
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
3580
+ handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
3581
+ const fetch3 = nodeFetchProxy(proxy);
3582
+ const client = new PromptClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3583
+ const res = await client.getList();
3584
+ emitWithFormat(res.results, format, filename);
3585
+ }
3586
+ };
3587
+
3588
+ // src/commands/canvas/commands/prompts/pull.ts
3589
+ import { PromptClient as PromptClient3 } from "@uniformdev/canvas";
3590
+
3591
+ // src/commands/canvas/commands/prompts/_util.ts
3592
+ var selectPromptIdentifier = (e) => e.id;
3593
+ var selectPromptDisplayName = (e) => `${e.promptName ?? "Untitled"} (pid: ${e.id})`;
3594
+
3595
+ // src/commands/canvas/promptEngineDataSource.ts
3596
+ function createPromptEngineDataSource({
3597
+ client
3598
+ }) {
3599
+ async function* getObjects() {
3600
+ const { results: prompts } = await client.getList();
3601
+ for await (const prompt of prompts) {
3602
+ const result = {
3603
+ id: selectPromptIdentifier(prompt),
3604
+ displayName: selectPromptDisplayName(prompt),
3605
+ providerId: prompt.id,
3606
+ object: prompt
3607
+ };
3608
+ yield result;
3609
+ }
3610
+ }
3611
+ return {
3612
+ objects: getObjects(),
3613
+ deleteObject: async (providerId) => {
3614
+ await client.remove({ promptId: providerId });
3615
+ },
3616
+ writeObject: async ({ object }) => {
3617
+ await client.upsert({ data: object });
3618
+ }
3619
+ };
3620
+ }
3621
+
3622
+ // src/commands/canvas/commands/prompts/pull.ts
3623
+ var PromptPullModule = {
3624
+ command: "pull <directory>",
3625
+ describe: "Pulls all entries to local files in a directory",
3626
+ builder: (yargs27) => withConfiguration(
3627
+ withApiOptions(
3628
+ withProjectOptions(
3629
+ withStateOptions(
3630
+ withDiffOptions(
3631
+ yargs27.positional("directory", {
3632
+ describe: "Directory to save the entries to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
3633
+ type: "string"
3634
+ }).option("format", {
3635
+ alias: ["f"],
3636
+ describe: "Output format",
3637
+ default: "yaml",
3638
+ choices: ["yaml", "json"],
3639
+ type: "string"
3640
+ }).option("what-if", {
3641
+ alias: ["w"],
3642
+ describe: "What-if mode reports what would be done but changes no files",
3643
+ default: false,
3644
+ type: "boolean"
3645
+ }).option("mode", {
3646
+ alias: ["m"],
3647
+ 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',
3648
+ choices: ["create", "createOrUpdate", "mirror"],
3649
+ default: "mirror",
3650
+ type: "string"
3651
+ })
3652
+ )
3653
+ )
3654
+ )
3655
+ )
3656
+ ),
3657
+ handler: async ({
3658
+ apiHost,
3659
+ apiKey,
3660
+ proxy,
3661
+ directory,
3662
+ format,
3663
+ mode,
3664
+ whatIf,
3665
+ project: projectId,
3666
+ diff: diffMode
3667
+ }) => {
3668
+ const fetch3 = nodeFetchProxy(proxy);
3669
+ const client = new PromptClient3({
3670
+ apiKey,
3671
+ apiHost,
3672
+ fetch: fetch3,
3673
+ projectId,
3674
+ bypassCache: true
3675
+ });
3676
+ const source = createPromptEngineDataSource({ client });
3677
+ let target;
3678
+ const isPackage = isPathAPackageFile(directory);
3679
+ if (isPackage) {
3680
+ const packageContents = readCanvasPackage(directory, false);
3681
+ target = await createArraySyncEngineDataSource({
3682
+ objects: packageContents.prompts ?? [],
3683
+ selectIdentifier: selectPromptIdentifier,
3684
+ selectDisplayName: selectPromptDisplayName,
3685
+ onSyncComplete: async (_, synced) => {
3686
+ packageContents.prompts = synced;
3687
+ writeCanvasPackage(directory, packageContents);
3688
+ }
3689
+ });
3690
+ } else {
3691
+ target = await createFileSyncEngineDataSource({
3692
+ directory,
3693
+ selectIdentifier: selectPromptIdentifier,
3694
+ selectDisplayName: selectPromptDisplayName,
3695
+ format
3696
+ });
3697
+ }
3698
+ await syncEngine({
3699
+ source,
3700
+ target,
3701
+ mode,
3702
+ whatIf,
3703
+ allowEmptySource: true,
3704
+ log: createSyncEngineConsoleLogger({ diffMode })
3705
+ });
3706
+ }
3071
3707
  };
3072
3708
 
3073
- // src/commands/canvas/commands/pattern/push.ts
3074
- var PatternPushModule = {
3075
- ...CompositionPushModule,
3076
- describe: "Pushes all patterns from files in a directory to Uniform Canvas",
3077
- builder: (yargs25) => withConfiguration(
3709
+ // src/commands/canvas/commands/prompts/push.ts
3710
+ import { PromptClient as PromptClient4 } from "@uniformdev/canvas";
3711
+ var PromptPushModule = {
3712
+ command: "push <directory>",
3713
+ describe: "Pushes all prompts from files in a directory to Uniform",
3714
+ builder: (yargs27) => withConfiguration(
3078
3715
  withApiOptions(
3079
3716
  withProjectOptions(
3080
3717
  withStateOptions(
3081
3718
  withDiffOptions(
3082
- yargs25.positional("directory", {
3083
- describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
3719
+ yargs27.positional("directory", {
3720
+ describe: "Directory to read the prompts from. If a filename is used, a package will be read instead.",
3084
3721
  type: "string"
3085
3722
  }).option("what-if", {
3086
3723
  alias: ["w"],
@@ -3093,75 +3730,104 @@ var PatternPushModule = {
3093
3730
  choices: ["create", "createOrUpdate", "mirror"],
3094
3731
  default: "mirror",
3095
3732
  type: "string"
3096
- }).option("onlyPatterns", {
3097
- describe: "Only pulling patterns and not compositions",
3098
- // This default differentiate this list command from composition list command
3099
- default: true,
3100
- type: "boolean",
3101
- hidden: true
3102
3733
  })
3103
3734
  )
3104
3735
  )
3105
3736
  )
3106
3737
  )
3107
- )
3738
+ ),
3739
+ handler: async ({
3740
+ apiHost,
3741
+ apiKey,
3742
+ proxy,
3743
+ directory,
3744
+ mode,
3745
+ whatIf,
3746
+ project: projectId,
3747
+ diff: diffMode
3748
+ }) => {
3749
+ const fetch3 = nodeFetchProxy(proxy);
3750
+ const client = new PromptClient4({
3751
+ apiKey,
3752
+ apiHost,
3753
+ fetch: fetch3,
3754
+ projectId,
3755
+ bypassCache: true
3756
+ });
3757
+ let source;
3758
+ const isPackage = isPathAPackageFile(directory);
3759
+ if (isPackage) {
3760
+ const packageContents = readCanvasPackage(directory, true);
3761
+ source = await createArraySyncEngineDataSource({
3762
+ objects: packageContents.prompts ?? [],
3763
+ selectIdentifier: selectPromptIdentifier,
3764
+ selectDisplayName: selectPromptDisplayName
3765
+ });
3766
+ } else {
3767
+ source = await createFileSyncEngineDataSource({
3768
+ directory,
3769
+ selectIdentifier: selectPromptIdentifier,
3770
+ selectDisplayName: selectPromptDisplayName
3771
+ });
3772
+ }
3773
+ const target = createPromptEngineDataSource({ client });
3774
+ await syncEngine({
3775
+ source,
3776
+ target,
3777
+ mode,
3778
+ whatIf,
3779
+ log: createSyncEngineConsoleLogger({ diffMode })
3780
+ });
3781
+ }
3108
3782
  };
3109
3783
 
3110
- // src/commands/canvas/commands/pattern/remove.ts
3111
- var PatternRemoveModule = {
3112
- ...CompositionRemoveModule,
3113
- describe: "Delete a pattern"
3784
+ // src/commands/canvas/commands/prompts/remove.ts
3785
+ import { PromptClient as PromptClient5 } from "@uniformdev/canvas";
3786
+ var PromptRemoveModule = {
3787
+ command: "remove <id>",
3788
+ aliases: ["delete", "rm"],
3789
+ describe: "Delete a prompt",
3790
+ builder: (yargs27) => withConfiguration(
3791
+ withApiOptions(
3792
+ withProjectOptions(yargs27.positional("id", { demandOption: true, describe: "Prompt ID to delete" }))
3793
+ )
3794
+ ),
3795
+ handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
3796
+ const fetch3 = nodeFetchProxy(proxy);
3797
+ const client = new PromptClient5({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3798
+ await client.remove({ promptId: id });
3799
+ }
3114
3800
  };
3115
3801
 
3116
- // src/commands/canvas/commands/pattern/unpublish.ts
3117
- var PatternUnpublishModule = {
3118
- command: "unpublish [ids]",
3119
- describe: "Unpublish a pattern(s)",
3120
- builder: (yargs25) => withConfiguration(
3802
+ // src/commands/canvas/commands/prompts/update.ts
3803
+ import { PromptClient as PromptClient6 } from "@uniformdev/canvas";
3804
+ var PromptUpdateModule = {
3805
+ command: "update <filename>",
3806
+ aliases: ["put"],
3807
+ describe: "Insert or update a prompt",
3808
+ builder: (yargs27) => withConfiguration(
3121
3809
  withApiOptions(
3122
3810
  withProjectOptions(
3123
- yargs25.positional("ids", {
3124
- describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
3125
- type: "string"
3126
- }).option("all", {
3127
- alias: ["a"],
3128
- describe: "Un-pPublishes all compositions. Use compositionId to publish one instead.",
3129
- default: false,
3130
- type: "boolean"
3131
- }).option("what-if", {
3132
- alias: ["w"],
3133
- describe: "What-if mode reports what would be done but does not perform any publishing",
3134
- default: false,
3135
- type: "boolean"
3136
- }).option("onlyCompositions", {
3137
- describe: "Only publishing compositions and not patterns",
3138
- default: false,
3139
- type: "boolean"
3140
- }).option("onlyPatterns", {
3141
- describe: "Only pulling patterns and not compositions",
3142
- default: true,
3143
- type: "boolean",
3144
- hidden: true
3145
- })
3811
+ yargs27.positional("filename", { demandOption: true, describe: "Prompt file to put" })
3146
3812
  )
3147
3813
  )
3148
3814
  ),
3149
- handler: CompositionUnpublishModule.handler
3150
- };
3151
-
3152
- // src/commands/canvas/commands/pattern/update.ts
3153
- var PatternUpdateModule = {
3154
- ...CompositionUpdateModule,
3155
- describe: "Insert or update a pattern"
3815
+ handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
3816
+ const fetch3 = nodeFetchProxy(proxy);
3817
+ const client = new PromptClient6({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3818
+ const file = readFileToObject(filename);
3819
+ await client.upsert({ data: file });
3820
+ }
3156
3821
  };
3157
3822
 
3158
- // src/commands/canvas/commands/pattern.ts
3159
- var PatternModule = {
3160
- command: "pattern <command>",
3161
- describe: "Commands for Canvas patterns",
3162
- builder: (yargs25) => yargs25.command(PatternPullModule).command(PatternPushModule).command(PatternGetModule).command(PatternRemoveModule).command(PatternListModule).command(PatternUpdateModule).command(PatternPublishModule).command(PatternUnpublishModule).demandCommand(),
3823
+ // src/commands/canvas/commands/prompts.ts
3824
+ var PromptModule = {
3825
+ command: "prompt <command>",
3826
+ aliases: ["dt"],
3827
+ describe: "Commands for AI Prompt definitions",
3828
+ builder: (yargs27) => yargs27.command(PromptGetModule).command(PromptListModule).command(PromptPullModule).command(PromptPushModule).command(PromptRemoveModule).command(PromptUpdateModule).demandCommand(),
3163
3829
  handler: () => {
3164
- yargs7.help();
3830
+ yargs9.help();
3165
3831
  }
3166
3832
  };
3167
3833
 
@@ -3170,28 +3836,28 @@ var CanvasCommand = {
3170
3836
  command: "canvas <command>",
3171
3837
  aliases: ["cv", "pm", "presentation"],
3172
3838
  describe: "Uniform Canvas commands",
3173
- builder: (yargs25) => yargs25.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(CategoryModule).command(PatternModule).command(ContentTypeModule).command(EntryModule).demandCommand(),
3839
+ builder: (yargs27) => yargs27.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(CategoryModule).command(PatternModule).command(ContentTypeModule).command(EntryModule).command(PromptModule).command(AssetModule).demandCommand(),
3174
3840
  handler: () => {
3175
- yargs8.showHelp();
3841
+ yargs10.showHelp();
3176
3842
  }
3177
3843
  };
3178
3844
 
3179
3845
  // src/commands/context/index.ts
3180
- import yargs15 from "yargs";
3846
+ import yargs17 from "yargs";
3181
3847
 
3182
3848
  // src/commands/context/commands/aggregate.ts
3183
- import yargs9 from "yargs";
3849
+ import yargs11 from "yargs";
3184
3850
 
3185
3851
  // src/commands/context/commands/aggregate/get.ts
3186
3852
  import { UncachedAggregateClient } from "@uniformdev/context/api";
3187
3853
  var AggregateGetModule = {
3188
3854
  command: "get <id>",
3189
3855
  describe: "Fetch an aggregate",
3190
- builder: (yargs25) => withConfiguration(
3856
+ builder: (yargs27) => withConfiguration(
3191
3857
  withFormatOptions(
3192
3858
  withApiOptions(
3193
3859
  withProjectOptions(
3194
- yargs25.positional("id", { demandOption: true, describe: "Aggregate public ID to fetch" })
3860
+ yargs27.positional("id", { demandOption: true, describe: "Aggregate public ID to fetch" })
3195
3861
  )
3196
3862
  )
3197
3863
  )
@@ -3215,7 +3881,7 @@ var AggregateListModule = {
3215
3881
  command: "list",
3216
3882
  describe: "List aggregates",
3217
3883
  aliases: ["ls"],
3218
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
3884
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
3219
3885
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
3220
3886
  const fetch3 = nodeFetchProxy(proxy);
3221
3887
  const client = new UncachedAggregateClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -3281,11 +3947,11 @@ function writeContextPackage(filename, packageContents) {
3281
3947
  var AggregatePullModule = {
3282
3948
  command: "pull <directory>",
3283
3949
  describe: "Pulls all aggregates to local files in a directory",
3284
- builder: (yargs25) => withConfiguration(
3950
+ builder: (yargs27) => withConfiguration(
3285
3951
  withApiOptions(
3286
3952
  withProjectOptions(
3287
3953
  withDiffOptions(
3288
- yargs25.positional("directory", {
3954
+ yargs27.positional("directory", {
3289
3955
  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.",
3290
3956
  type: "string"
3291
3957
  }).option("format", {
@@ -3360,11 +4026,11 @@ import { UncachedAggregateClient as UncachedAggregateClient4 } from "@uniformdev
3360
4026
  var AggregatePushModule = {
3361
4027
  command: "push <directory>",
3362
4028
  describe: "Pushes all aggregates from files in a directory or package to Uniform",
3363
- builder: (yargs25) => withConfiguration(
4029
+ builder: (yargs27) => withConfiguration(
3364
4030
  withApiOptions(
3365
4031
  withProjectOptions(
3366
4032
  withDiffOptions(
3367
- yargs25.positional("directory", {
4033
+ yargs27.positional("directory", {
3368
4034
  describe: "Directory to read the aggregates from. If a filename is used, a package will be read instead.",
3369
4035
  type: "string"
3370
4036
  }).option("what-if", {
@@ -3429,10 +4095,10 @@ var AggregateRemoveModule = {
3429
4095
  command: "remove <id>",
3430
4096
  aliases: ["delete", "rm"],
3431
4097
  describe: "Delete an aggregate",
3432
- builder: (yargs25) => withConfiguration(
4098
+ builder: (yargs27) => withConfiguration(
3433
4099
  withApiOptions(
3434
4100
  withProjectOptions(
3435
- yargs25.positional("id", { demandOption: true, describe: "Aggregate public ID to delete" })
4101
+ yargs27.positional("id", { demandOption: true, describe: "Aggregate public ID to delete" })
3436
4102
  )
3437
4103
  )
3438
4104
  ),
@@ -3449,10 +4115,10 @@ var AggregateUpdateModule = {
3449
4115
  command: "update <filename>",
3450
4116
  aliases: ["put"],
3451
4117
  describe: "Insert or update an aggregate",
3452
- builder: (yargs25) => withConfiguration(
4118
+ builder: (yargs27) => withConfiguration(
3453
4119
  withApiOptions(
3454
4120
  withProjectOptions(
3455
- yargs25.positional("filename", { demandOption: true, describe: "Aggregate file to put" })
4121
+ yargs27.positional("filename", { demandOption: true, describe: "Aggregate file to put" })
3456
4122
  )
3457
4123
  )
3458
4124
  ),
@@ -3469,25 +4135,25 @@ var AggregateModule = {
3469
4135
  command: "aggregate <command>",
3470
4136
  aliases: ["agg", "intent", "audience"],
3471
4137
  describe: "Commands for Context aggregates (intents, audiences)",
3472
- builder: (yargs25) => yargs25.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
4138
+ builder: (yargs27) => yargs27.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
3473
4139
  handler: () => {
3474
- yargs9.help();
4140
+ yargs11.help();
3475
4141
  }
3476
4142
  };
3477
4143
 
3478
4144
  // src/commands/context/commands/enrichment.ts
3479
- import yargs10 from "yargs";
4145
+ import yargs12 from "yargs";
3480
4146
 
3481
4147
  // src/commands/context/commands/enrichment/get.ts
3482
4148
  import { UncachedEnrichmentClient } from "@uniformdev/context/api";
3483
4149
  var EnrichmentGetModule = {
3484
4150
  command: "get <id>",
3485
4151
  describe: "Fetch an enrichment category and its values",
3486
- builder: (yargs25) => withFormatOptions(
4152
+ builder: (yargs27) => withFormatOptions(
3487
4153
  withConfiguration(
3488
4154
  withApiOptions(
3489
4155
  withProjectOptions(
3490
- yargs25.positional("id", { demandOption: true, describe: "Enrichment category public ID to fetch" })
4156
+ yargs27.positional("id", { demandOption: true, describe: "Enrichment category public ID to fetch" })
3491
4157
  )
3492
4158
  )
3493
4159
  )
@@ -3512,7 +4178,7 @@ var EnrichmentListModule = {
3512
4178
  command: "list",
3513
4179
  describe: "List enrichments",
3514
4180
  aliases: ["ls"],
3515
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
4181
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
3516
4182
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
3517
4183
  const fetch3 = nodeFetchProxy(proxy);
3518
4184
  const client = new UncachedEnrichmentClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -3613,11 +4279,11 @@ var createEnrichmentValueEngineDataSource = ({
3613
4279
  var EnrichmentPullModule = {
3614
4280
  command: "pull <directory>",
3615
4281
  describe: "Pulls all enrichments to local files in a directory",
3616
- builder: (yargs25) => withConfiguration(
4282
+ builder: (yargs27) => withConfiguration(
3617
4283
  withApiOptions(
3618
4284
  withProjectOptions(
3619
4285
  withDiffOptions(
3620
- yargs25.positional("directory", {
4286
+ yargs27.positional("directory", {
3621
4287
  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.",
3622
4288
  type: "string"
3623
4289
  }).option("format", {
@@ -3692,11 +4358,11 @@ import { UncachedEnrichmentClient as UncachedEnrichmentClient4 } from "@uniformd
3692
4358
  var EnrichmentPushModule = {
3693
4359
  command: "push <directory>",
3694
4360
  describe: "Pushes all enrichments from files in a directory or package to Uniform",
3695
- builder: (yargs25) => withConfiguration(
4361
+ builder: (yargs27) => withConfiguration(
3696
4362
  withApiOptions(
3697
4363
  withProjectOptions(
3698
4364
  withDiffOptions(
3699
- yargs25.positional("directory", {
4365
+ yargs27.positional("directory", {
3700
4366
  describe: "Directory to read the enrichments from. If a filename is used, a package will be read instead.",
3701
4367
  type: "string"
3702
4368
  }).option("what-if", {
@@ -3760,10 +4426,10 @@ var EnrichmentRemoveModule = {
3760
4426
  command: "remove <id>",
3761
4427
  aliases: ["delete", "rm"],
3762
4428
  describe: "Delete an enrichment category and its values",
3763
- builder: (yargs25) => withConfiguration(
4429
+ builder: (yargs27) => withConfiguration(
3764
4430
  withApiOptions(
3765
4431
  withProjectOptions(
3766
- yargs25.positional("id", { demandOption: true, describe: "Enrichment category public ID to delete" })
4432
+ yargs27.positional("id", { demandOption: true, describe: "Enrichment category public ID to delete" })
3767
4433
  )
3768
4434
  )
3769
4435
  ),
@@ -3779,14 +4445,14 @@ var EnrichmentModule = {
3779
4445
  command: "enrichment <command>",
3780
4446
  aliases: ["enr"],
3781
4447
  describe: "Commands for Context enrichments",
3782
- builder: (yargs25) => yargs25.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
4448
+ builder: (yargs27) => yargs27.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
3783
4449
  handler: () => {
3784
- yargs10.help();
4450
+ yargs12.help();
3785
4451
  }
3786
4452
  };
3787
4453
 
3788
4454
  // src/commands/context/commands/manifest.ts
3789
- import yargs11 from "yargs";
4455
+ import yargs13 from "yargs";
3790
4456
 
3791
4457
  // src/commands/context/commands/manifest/get.ts
3792
4458
  import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
@@ -3797,10 +4463,10 @@ var ManifestGetModule = {
3797
4463
  command: "get [output]",
3798
4464
  aliases: ["dl", "download"],
3799
4465
  describe: "Download the Uniform Context manifest for a project",
3800
- builder: (yargs25) => withConfiguration(
4466
+ builder: (yargs27) => withConfiguration(
3801
4467
  withApiOptions(
3802
4468
  withProjectOptions(
3803
- yargs25.option("preview", {
4469
+ yargs27.option("preview", {
3804
4470
  describe: "If set, fetches the unpublished preview manifest (The API key must have permission)",
3805
4471
  default: false,
3806
4472
  type: "boolean",
@@ -3862,7 +4528,7 @@ import { exit as exit2 } from "process";
3862
4528
  var ManifestPublishModule = {
3863
4529
  command: "publish",
3864
4530
  describe: "Publish the Uniform Context manifest for a project",
3865
- builder: (yargs25) => withConfiguration(withApiOptions(withProjectOptions(yargs25))),
4531
+ builder: (yargs27) => withConfiguration(withApiOptions(withProjectOptions(yargs27))),
3866
4532
  handler: async ({ apiKey, apiHost, proxy, project }) => {
3867
4533
  const fetch3 = nodeFetchProxy(proxy);
3868
4534
  try {
@@ -3895,25 +4561,25 @@ var ManifestModule = {
3895
4561
  command: "manifest <command>",
3896
4562
  describe: "Commands for context manifests",
3897
4563
  aliases: ["man"],
3898
- builder: (yargs25) => yargs25.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
4564
+ builder: (yargs27) => yargs27.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
3899
4565
  handler: () => {
3900
- yargs11.help();
4566
+ yargs13.help();
3901
4567
  }
3902
4568
  };
3903
4569
 
3904
4570
  // src/commands/context/commands/quirk.ts
3905
- import yargs12 from "yargs";
4571
+ import yargs14 from "yargs";
3906
4572
 
3907
4573
  // src/commands/context/commands/quirk/get.ts
3908
4574
  import { UncachedQuirkClient } from "@uniformdev/context/api";
3909
4575
  var QuirkGetModule = {
3910
4576
  command: "get <id>",
3911
4577
  describe: "Fetch a quirk",
3912
- builder: (yargs25) => withConfiguration(
4578
+ builder: (yargs27) => withConfiguration(
3913
4579
  withFormatOptions(
3914
4580
  withApiOptions(
3915
4581
  withProjectOptions(
3916
- yargs25.positional("id", { demandOption: true, describe: "Quirk public ID to fetch" })
4582
+ yargs27.positional("id", { demandOption: true, describe: "Quirk public ID to fetch" })
3917
4583
  )
3918
4584
  )
3919
4585
  )
@@ -3937,11 +4603,11 @@ var QuirkListModule = {
3937
4603
  command: "list",
3938
4604
  describe: "List quirks",
3939
4605
  aliases: ["ls"],
3940
- builder: (yargs25) => withConfiguration(
4606
+ builder: (yargs27) => withConfiguration(
3941
4607
  withFormatOptions(
3942
4608
  withApiOptions(
3943
4609
  withProjectOptions(
3944
- yargs25.option("withIntegrations", {
4610
+ yargs27.option("withIntegrations", {
3945
4611
  alias: ["i"],
3946
4612
  describe: "Whether to include meta-quirks created by integrations in the list. Defaults to false.",
3947
4613
  type: "boolean"
@@ -3998,11 +4664,11 @@ function createQuirkEngineDataSource({
3998
4664
  var QuirkPullModule = {
3999
4665
  command: "pull <directory>",
4000
4666
  describe: "Pulls all quirks to local files in a directory",
4001
- builder: (yargs25) => withConfiguration(
4667
+ builder: (yargs27) => withConfiguration(
4002
4668
  withApiOptions(
4003
4669
  withProjectOptions(
4004
4670
  withDiffOptions(
4005
- yargs25.positional("directory", {
4671
+ yargs27.positional("directory", {
4006
4672
  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.",
4007
4673
  type: "string"
4008
4674
  }).option("format", {
@@ -4077,11 +4743,11 @@ import { UncachedQuirkClient as UncachedQuirkClient4 } from "@uniformdev/context
4077
4743
  var QuirkPushModule = {
4078
4744
  command: "push <directory>",
4079
4745
  describe: "Pushes all quirks from files in a directory or package to Uniform",
4080
- builder: (yargs25) => withConfiguration(
4746
+ builder: (yargs27) => withConfiguration(
4081
4747
  withApiOptions(
4082
4748
  withProjectOptions(
4083
4749
  withDiffOptions(
4084
- yargs25.positional("directory", {
4750
+ yargs27.positional("directory", {
4085
4751
  describe: "Directory to read the quirks from. If a filename is used, a package will be read instead.",
4086
4752
  type: "string"
4087
4753
  }).option("what-if", {
@@ -4145,10 +4811,10 @@ var QuirkRemoveModule = {
4145
4811
  command: "remove <id>",
4146
4812
  aliases: ["delete", "rm"],
4147
4813
  describe: "Delete a quirk",
4148
- builder: (yargs25) => withConfiguration(
4814
+ builder: (yargs27) => withConfiguration(
4149
4815
  withApiOptions(
4150
4816
  withProjectOptions(
4151
- yargs25.positional("id", { demandOption: true, describe: "Quirk public ID to delete" })
4817
+ yargs27.positional("id", { demandOption: true, describe: "Quirk public ID to delete" })
4152
4818
  )
4153
4819
  )
4154
4820
  ),
@@ -4165,10 +4831,10 @@ var QuirkUpdateModule = {
4165
4831
  command: "update <filename>",
4166
4832
  aliases: ["put"],
4167
4833
  describe: "Insert or update a quirk",
4168
- builder: (yargs25) => withConfiguration(
4834
+ builder: (yargs27) => withConfiguration(
4169
4835
  withApiOptions(
4170
4836
  withProjectOptions(
4171
- yargs25.positional("filename", { demandOption: true, describe: "Quirk file to put" })
4837
+ yargs27.positional("filename", { demandOption: true, describe: "Quirk file to put" })
4172
4838
  )
4173
4839
  )
4174
4840
  ),
@@ -4185,25 +4851,25 @@ var QuirkModule = {
4185
4851
  command: "quirk <command>",
4186
4852
  aliases: ["qk"],
4187
4853
  describe: "Commands for Context quirks",
4188
- builder: (yargs25) => yargs25.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
4854
+ builder: (yargs27) => yargs27.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
4189
4855
  handler: () => {
4190
- yargs12.help();
4856
+ yargs14.help();
4191
4857
  }
4192
4858
  };
4193
4859
 
4194
4860
  // src/commands/context/commands/signal.ts
4195
- import yargs13 from "yargs";
4861
+ import yargs15 from "yargs";
4196
4862
 
4197
4863
  // src/commands/context/commands/signal/get.ts
4198
4864
  import { UncachedSignalClient } from "@uniformdev/context/api";
4199
4865
  var SignalGetModule = {
4200
4866
  command: "get <id>",
4201
4867
  describe: "Fetch a signal",
4202
- builder: (yargs25) => withConfiguration(
4868
+ builder: (yargs27) => withConfiguration(
4203
4869
  withFormatOptions(
4204
4870
  withApiOptions(
4205
4871
  withProjectOptions(
4206
- yargs25.positional("id", { demandOption: true, describe: "Signal public ID to fetch" })
4872
+ yargs27.positional("id", { demandOption: true, describe: "Signal public ID to fetch" })
4207
4873
  )
4208
4874
  )
4209
4875
  )
@@ -4227,7 +4893,7 @@ var SignalListModule = {
4227
4893
  command: "list",
4228
4894
  describe: "List signals",
4229
4895
  aliases: ["ls"],
4230
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
4896
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
4231
4897
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
4232
4898
  const fetch3 = nodeFetchProxy(proxy);
4233
4899
  const client = new UncachedSignalClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -4276,11 +4942,11 @@ function createSignalEngineDataSource({
4276
4942
  var SignalPullModule = {
4277
4943
  command: "pull <directory>",
4278
4944
  describe: "Pulls all signals to local files in a directory",
4279
- builder: (yargs25) => withConfiguration(
4945
+ builder: (yargs27) => withConfiguration(
4280
4946
  withApiOptions(
4281
4947
  withProjectOptions(
4282
4948
  withDiffOptions(
4283
- yargs25.positional("directory", {
4949
+ yargs27.positional("directory", {
4284
4950
  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.",
4285
4951
  type: "string"
4286
4952
  }).option("format", {
@@ -4355,11 +5021,11 @@ import { UncachedSignalClient as UncachedSignalClient4 } from "@uniformdev/conte
4355
5021
  var SignalPushModule = {
4356
5022
  command: "push <directory>",
4357
5023
  describe: "Pushes all signals from files in a directory or package to Uniform",
4358
- builder: (yargs25) => withConfiguration(
5024
+ builder: (yargs27) => withConfiguration(
4359
5025
  withApiOptions(
4360
5026
  withProjectOptions(
4361
5027
  withDiffOptions(
4362
- yargs25.positional("directory", {
5028
+ yargs27.positional("directory", {
4363
5029
  describe: "Directory to read the signals from. If a filename is used, a package will be read instead.",
4364
5030
  type: "string"
4365
5031
  }).option("what-if", {
@@ -4423,10 +5089,10 @@ var SignalRemoveModule = {
4423
5089
  command: "remove <id>",
4424
5090
  aliases: ["delete", "rm"],
4425
5091
  describe: "Delete a signal",
4426
- builder: (yargs25) => withConfiguration(
5092
+ builder: (yargs27) => withConfiguration(
4427
5093
  withApiOptions(
4428
5094
  withProjectOptions(
4429
- yargs25.positional("id", { demandOption: true, describe: "Signal public ID to delete" })
5095
+ yargs27.positional("id", { demandOption: true, describe: "Signal public ID to delete" })
4430
5096
  )
4431
5097
  )
4432
5098
  ),
@@ -4443,10 +5109,10 @@ var SignalUpdateModule = {
4443
5109
  command: "update <filename>",
4444
5110
  aliases: ["put"],
4445
5111
  describe: "Insert or update a signal",
4446
- builder: (yargs25) => withConfiguration(
5112
+ builder: (yargs27) => withConfiguration(
4447
5113
  withApiOptions(
4448
5114
  withProjectOptions(
4449
- yargs25.positional("filename", { demandOption: true, describe: "Signal file to put" })
5115
+ yargs27.positional("filename", { demandOption: true, describe: "Signal file to put" })
4450
5116
  )
4451
5117
  )
4452
5118
  ),
@@ -4463,25 +5129,25 @@ var SignalModule = {
4463
5129
  command: "signal <command>",
4464
5130
  aliases: ["sig"],
4465
5131
  describe: "Commands for Context signals",
4466
- builder: (yargs25) => yargs25.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
5132
+ builder: (yargs27) => yargs27.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
4467
5133
  handler: () => {
4468
- yargs13.help();
5134
+ yargs15.help();
4469
5135
  }
4470
5136
  };
4471
5137
 
4472
5138
  // src/commands/context/commands/test.ts
4473
- import yargs14 from "yargs";
5139
+ import yargs16 from "yargs";
4474
5140
 
4475
5141
  // src/commands/context/commands/test/get.ts
4476
5142
  import { UncachedTestClient } from "@uniformdev/context/api";
4477
5143
  var TestGetModule = {
4478
5144
  command: "get <id>",
4479
5145
  describe: "Fetch a test",
4480
- builder: (yargs25) => withConfiguration(
5146
+ builder: (yargs27) => withConfiguration(
4481
5147
  withFormatOptions(
4482
5148
  withApiOptions(
4483
5149
  withProjectOptions(
4484
- yargs25.positional("id", { demandOption: true, describe: "Test public ID to fetch" })
5150
+ yargs27.positional("id", { demandOption: true, describe: "Test public ID to fetch" })
4485
5151
  )
4486
5152
  )
4487
5153
  )
@@ -4505,7 +5171,7 @@ var TestListModule = {
4505
5171
  command: "list",
4506
5172
  describe: "List tests",
4507
5173
  aliases: ["ls"],
4508
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
5174
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
4509
5175
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
4510
5176
  const fetch3 = nodeFetchProxy(proxy);
4511
5177
  const client = new UncachedTestClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -4554,11 +5220,11 @@ function createTestEngineDataSource({
4554
5220
  var TestPullModule = {
4555
5221
  command: "pull <directory>",
4556
5222
  describe: "Pulls all tests to local files in a directory",
4557
- builder: (yargs25) => withConfiguration(
5223
+ builder: (yargs27) => withConfiguration(
4558
5224
  withApiOptions(
4559
5225
  withProjectOptions(
4560
5226
  withDiffOptions(
4561
- yargs25.positional("directory", {
5227
+ yargs27.positional("directory", {
4562
5228
  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.",
4563
5229
  type: "string"
4564
5230
  }).option("format", {
@@ -4633,11 +5299,11 @@ import { UncachedTestClient as UncachedTestClient4 } from "@uniformdev/context/a
4633
5299
  var TestPushModule = {
4634
5300
  command: "push <directory>",
4635
5301
  describe: "Pushes all tests from files in a directory or package to Uniform",
4636
- builder: (yargs25) => withConfiguration(
5302
+ builder: (yargs27) => withConfiguration(
4637
5303
  withApiOptions(
4638
5304
  withProjectOptions(
4639
5305
  withDiffOptions(
4640
- yargs25.positional("directory", {
5306
+ yargs27.positional("directory", {
4641
5307
  describe: "Directory to read the tests from. If a filename is used, a package will be read instead.",
4642
5308
  type: "string"
4643
5309
  }).option("what-if", {
@@ -4701,10 +5367,10 @@ var TestRemoveModule = {
4701
5367
  command: "remove <id>",
4702
5368
  aliases: ["delete", "rm"],
4703
5369
  describe: "Delete a test",
4704
- builder: (yargs25) => withConfiguration(
5370
+ builder: (yargs27) => withConfiguration(
4705
5371
  withApiOptions(
4706
5372
  withProjectOptions(
4707
- yargs25.positional("id", { demandOption: true, describe: "Test public ID to delete" })
5373
+ yargs27.positional("id", { demandOption: true, describe: "Test public ID to delete" })
4708
5374
  )
4709
5375
  )
4710
5376
  ),
@@ -4721,9 +5387,9 @@ var TestUpdateModule = {
4721
5387
  command: "update <filename>",
4722
5388
  aliases: ["put"],
4723
5389
  describe: "Insert or update a test",
4724
- builder: (yargs25) => withConfiguration(
5390
+ builder: (yargs27) => withConfiguration(
4725
5391
  withApiOptions(
4726
- withProjectOptions(yargs25.positional("filename", { demandOption: true, describe: "Test file to put" }))
5392
+ withProjectOptions(yargs27.positional("filename", { demandOption: true, describe: "Test file to put" }))
4727
5393
  )
4728
5394
  ),
4729
5395
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
@@ -4738,9 +5404,9 @@ var TestUpdateModule = {
4738
5404
  var TestModule = {
4739
5405
  command: "test <command>",
4740
5406
  describe: "Commands for Context A/B tests",
4741
- builder: (yargs25) => yargs25.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
5407
+ builder: (yargs27) => yargs27.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
4742
5408
  handler: () => {
4743
- yargs14.help();
5409
+ yargs16.help();
4744
5410
  }
4745
5411
  };
4746
5412
 
@@ -4749,9 +5415,9 @@ var ContextCommand = {
4749
5415
  command: "context <command>",
4750
5416
  aliases: ["ctx"],
4751
5417
  describe: "Uniform Context commands",
4752
- builder: (yargs25) => yargs25.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
5418
+ builder: (yargs27) => yargs27.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
4753
5419
  handler: () => {
4754
- yargs15.showHelp();
5420
+ yargs17.showHelp();
4755
5421
  }
4756
5422
  };
4757
5423
 
@@ -4779,7 +5445,7 @@ import { PostHog } from "posthog-node";
4779
5445
  // package.json
4780
5446
  var package_default = {
4781
5447
  name: "@uniformdev/cli",
4782
- version: "19.60.0",
5448
+ version: "19.70.0",
4783
5449
  description: "Uniform command line interface tool",
4784
5450
  license: "SEE LICENSE IN LICENSE.txt",
4785
5451
  main: "./cli.js",
@@ -4796,11 +5462,13 @@ var package_default = {
4796
5462
  },
4797
5463
  dependencies: {
4798
5464
  "@thi.ng/mime": "^2.2.23",
5465
+ "@uniformdev/assets": "workspace:*",
4799
5466
  "@uniformdev/canvas": "workspace:*",
4800
5467
  "@uniformdev/context": "workspace:*",
4801
5468
  "@uniformdev/files": "workspace:*",
4802
5469
  "@uniformdev/project-map": "workspace:*",
4803
5470
  "@uniformdev/redirect": "workspace:*",
5471
+ "call-bind": "^1.0.2",
4804
5472
  colorette: "2.0.20",
4805
5473
  cosmiconfig: "8.3.6",
4806
5474
  "cosmiconfig-typescript-loader": "5.0.0",
@@ -4822,10 +5490,11 @@ var package_default = {
4822
5490
  ora: "7.0.1",
4823
5491
  "p-queue": "7.3.4",
4824
5492
  "posthog-node": "3.1.2",
5493
+ "registry-auth-token": "^5.0.0",
5494
+ "registry-url": "^6.0.0",
4825
5495
  slugify: "1.6.6",
4826
- "update-check": "^1.5.4",
4827
5496
  yargs: "^17.6.2",
4828
- zod: "3.21.4"
5497
+ zod: "3.22.4"
4829
5498
  },
4830
5499
  devDependencies: {
4831
5500
  "@types/diff": "5.0.5",
@@ -5497,24 +6166,6 @@ async function newHandler({
5497
6166
  previewPath: "/api/preview?secret=hello-world",
5498
6167
  installEnv: []
5499
6168
  }
5500
- },
5501
- javadrip: {
5502
- name: "Commerce Starter",
5503
- value: {
5504
- githubUri: "uniformdev/commerce-starter",
5505
- serverUrl: "http://localhost:3000",
5506
- previewPath: "/api/preview?secret=javadrip",
5507
- installEnv: []
5508
- }
5509
- },
5510
- uniformconf: {
5511
- name: "Marketing Site Starter",
5512
- value: {
5513
- githubUri: "uniformdev/uniformconf",
5514
- serverUrl: "http://localhost:3000",
5515
- previewPath: "/api/preview?secret=uniformconf",
5516
- installEnv: []
5517
- }
5518
6169
  }
5519
6170
  },
5520
6171
  nuxt: {
@@ -5526,15 +6177,6 @@ async function newHandler({
5526
6177
  previewPath: "/?preview=true",
5527
6178
  installEnv: [["NUXT_TELEMETRY_DISABLED", "1"]]
5528
6179
  }
5529
- },
5530
- uniformconf: {
5531
- name: "Marketing Site Starter",
5532
- value: {
5533
- githubUri: "uniformdev/uniformconf-nuxt",
5534
- serverUrl: "http://localhost:3000",
5535
- previewPath: "/?preview=true",
5536
- installEnv: [["NUXT_TELEMETRY_DISABLED", "1"]]
5537
- }
5538
6180
  }
5539
6181
  }
5540
6182
  };
@@ -5577,16 +6219,6 @@ async function newHandler({
5577
6219
  ] : []
5578
6220
  ).map(([name, value]) => `${name}='${value}'`).join("\n") + "\n";
5579
6221
  await done();
5580
- if (githubUri.endsWith("commerce-starter")) {
5581
- const stableFakecommerceId = "fakecommerce-d04dcf12-f811-401d-add8-1fb81cfdb8a5";
5582
- const canaryFakecommerceId = "fakecommerce-f94cf199-7ea4-46ce-ae8b-825668bb79bc";
5583
- done = await spin2("Installing Fake Commerce...");
5584
- await uniformClient.installIntegration({
5585
- projectId,
5586
- type: apiHost.includes("canary") ? canaryFakecommerceId : stableFakecommerceId
5587
- });
5588
- await done();
5589
- }
5590
6222
  const cloneStartTimestamp = Date.now();
5591
6223
  const { runNpmInstall } = await cloneStarter({
5592
6224
  githubPath: githubUri,
@@ -5823,10 +6455,10 @@ var NewMeshCmd = {
5823
6455
  };
5824
6456
 
5825
6457
  // src/commands/optimize/index.ts
5826
- import yargs17 from "yargs";
6458
+ import yargs19 from "yargs";
5827
6459
 
5828
6460
  // src/commands/optimize/manifest.ts
5829
- import yargs16 from "yargs";
6461
+ import yargs18 from "yargs";
5830
6462
 
5831
6463
  // src/commands/optimize/manifest/download.ts
5832
6464
  import { gray as gray4, green as green3, red as red5, yellow as yellow2 } from "colorette";
@@ -5841,7 +6473,7 @@ var UniformBaseUrl = "https://uniform.app";
5841
6473
  var module = {
5842
6474
  command: "download [output]",
5843
6475
  describe: "Download intent manifest",
5844
- builder: (yargs25) => yargs25.option("apiKey", {
6476
+ builder: (yargs27) => yargs27.option("apiKey", {
5845
6477
  alias: "k",
5846
6478
  demandOption: true,
5847
6479
  string: true,
@@ -5942,10 +6574,10 @@ var module2 = {
5942
6574
  command: "manifest <command>",
5943
6575
  describe: "Intent manifest commands",
5944
6576
  builder: () => {
5945
- return yargs16.command(download_default);
6577
+ return yargs18.command(download_default);
5946
6578
  },
5947
6579
  handler: () => {
5948
- yargs16.showHelp();
6580
+ yargs18.showHelp();
5949
6581
  }
5950
6582
  };
5951
6583
  var manifest_default = module2;
@@ -5956,29 +6588,29 @@ var OptimizeCommand = {
5956
6588
  aliases: ["opt"],
5957
6589
  describe: "Uniform Optimize commands",
5958
6590
  builder: () => {
5959
- return yargs17.command(manifest_default);
6591
+ return yargs19.command(manifest_default);
5960
6592
  },
5961
6593
  handler: () => {
5962
- yargs17.showHelp();
6594
+ yargs19.showHelp();
5963
6595
  }
5964
6596
  };
5965
6597
 
5966
6598
  // src/commands/project-map/index.ts
5967
- import yargs20 from "yargs";
6599
+ import yargs22 from "yargs";
5968
6600
 
5969
6601
  // src/commands/project-map/commands/projectMapDefinition.ts
5970
- import yargs18 from "yargs";
6602
+ import yargs20 from "yargs";
5971
6603
 
5972
6604
  // src/commands/project-map/commands/ProjectMapDefinition/get.ts
5973
6605
  import { UncachedProjectMapClient } from "@uniformdev/project-map";
5974
6606
  var ProjectMapDefinitionGetModule = {
5975
6607
  command: "get <id>",
5976
6608
  describe: "Fetch a project map",
5977
- builder: (yargs25) => withFormatOptions(
6609
+ builder: (yargs27) => withFormatOptions(
5978
6610
  withConfiguration(
5979
6611
  withApiOptions(
5980
6612
  withProjectOptions(
5981
- yargs25.positional("id", { demandOption: true, describe: "ProjectMap UUID to fetch" })
6613
+ yargs27.positional("id", { demandOption: true, describe: "ProjectMap UUID to fetch" })
5982
6614
  )
5983
6615
  )
5984
6616
  )
@@ -6002,7 +6634,7 @@ var ProjectMapDefinitionListModule = {
6002
6634
  command: "list",
6003
6635
  describe: "List of project maps",
6004
6636
  aliases: ["ls"],
6005
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
6637
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
6006
6638
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
6007
6639
  const fetch3 = nodeFetchProxy(proxy);
6008
6640
  const client = new UncachedProjectMapClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -6059,11 +6691,11 @@ function createProjectMapDefinitionEngineDataSource({
6059
6691
  var ProjectMapDefinitionPullModule = {
6060
6692
  command: "pull <directory>",
6061
6693
  describe: "Pulls all project maps to local files in a directory",
6062
- builder: (yargs25) => withConfiguration(
6694
+ builder: (yargs27) => withConfiguration(
6063
6695
  withApiOptions(
6064
6696
  withProjectOptions(
6065
6697
  withDiffOptions(
6066
- yargs25.positional("directory", {
6698
+ yargs27.positional("directory", {
6067
6699
  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.",
6068
6700
  type: "string"
6069
6701
  }).option("format", {
@@ -6128,6 +6760,7 @@ var ProjectMapDefinitionPullModule = {
6128
6760
  target,
6129
6761
  mode,
6130
6762
  whatIf,
6763
+ allowEmptySource: true,
6131
6764
  log: createSyncEngineConsoleLogger({ diffMode })
6132
6765
  });
6133
6766
  }
@@ -6138,11 +6771,11 @@ import { UncachedProjectMapClient as UncachedProjectMapClient4 } from "@uniformd
6138
6771
  var ProjectMapDefinitionPushModule = {
6139
6772
  command: "push <directory>",
6140
6773
  describe: "Pushes all project maps from files in a directory or package to Uniform",
6141
- builder: (yargs25) => withConfiguration(
6774
+ builder: (yargs27) => withConfiguration(
6142
6775
  withApiOptions(
6143
6776
  withProjectOptions(
6144
6777
  withDiffOptions(
6145
- yargs25.positional("directory", {
6778
+ yargs27.positional("directory", {
6146
6779
  describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
6147
6780
  type: "string"
6148
6781
  }).option("what-if", {
@@ -6206,9 +6839,9 @@ var ProjectMapDefinitionRemoveModule = {
6206
6839
  command: "remove <id>",
6207
6840
  aliases: ["delete", "rm"],
6208
6841
  describe: "Delete a project map",
6209
- builder: (yargs25) => withConfiguration(
6842
+ builder: (yargs27) => withConfiguration(
6210
6843
  withApiOptions(
6211
- withProjectOptions(yargs25.positional("id", { demandOption: true, describe: " UUID to delete" }))
6844
+ withProjectOptions(yargs27.positional("id", { demandOption: true, describe: " UUID to delete" }))
6212
6845
  )
6213
6846
  ),
6214
6847
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -6224,10 +6857,10 @@ var ProjectMapDefinitionUpdateModule = {
6224
6857
  command: "update <filename>",
6225
6858
  aliases: ["put"],
6226
6859
  describe: "Insert or update a project map",
6227
- builder: (yargs25) => withConfiguration(
6860
+ builder: (yargs27) => withConfiguration(
6228
6861
  withApiOptions(
6229
6862
  withProjectOptions(
6230
- yargs25.positional("filename", { demandOption: true, describe: "Project map file to put" })
6863
+ yargs27.positional("filename", { demandOption: true, describe: "Project map file to put" })
6231
6864
  )
6232
6865
  )
6233
6866
  ),
@@ -6243,25 +6876,25 @@ var ProjectMapDefinitionUpdateModule = {
6243
6876
  var ProjectMapDefinitionModule = {
6244
6877
  command: "definition <command>",
6245
6878
  describe: "Commands for ProjectMap Definitions",
6246
- builder: (yargs25) => yargs25.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
6879
+ builder: (yargs27) => yargs27.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
6247
6880
  handler: () => {
6248
- yargs18.help();
6881
+ yargs20.help();
6249
6882
  }
6250
6883
  };
6251
6884
 
6252
6885
  // src/commands/project-map/commands/projectMapNode.ts
6253
- import yargs19 from "yargs";
6886
+ import yargs21 from "yargs";
6254
6887
 
6255
6888
  // src/commands/project-map/commands/ProjectMapNode/get.ts
6256
6889
  import { UncachedProjectMapClient as UncachedProjectMapClient7 } from "@uniformdev/project-map";
6257
6890
  var ProjectMapNodeGetModule = {
6258
6891
  command: "get <id> <projectMapId>",
6259
6892
  describe: "Fetch a project map node",
6260
- builder: (yargs25) => withConfiguration(
6893
+ builder: (yargs27) => withConfiguration(
6261
6894
  withFormatOptions(
6262
6895
  withApiOptions(
6263
6896
  withProjectOptions(
6264
- yargs25.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to fetch" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
6897
+ yargs27.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to fetch" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
6265
6898
  )
6266
6899
  )
6267
6900
  )
@@ -6287,11 +6920,11 @@ var ProjectMapNodeListModule = {
6287
6920
  command: "list <projectMapId>",
6288
6921
  describe: "List project map nodes",
6289
6922
  aliases: ["ls"],
6290
- builder: (yargs25) => withConfiguration(
6923
+ builder: (yargs27) => withConfiguration(
6291
6924
  withFormatOptions(
6292
6925
  withApiOptions(
6293
6926
  withProjectOptions(
6294
- yargs25.positional("projectMapId", {
6927
+ yargs27.positional("projectMapId", {
6295
6928
  demandOption: true,
6296
6929
  describe: "ProjectMap UUID to fetch from"
6297
6930
  })
@@ -6362,11 +6995,11 @@ function createProjectMapNodeEngineDataSource({
6362
6995
  var ProjectMapNodePullModule = {
6363
6996
  command: "pull <directory>",
6364
6997
  describe: "Pulls all project maps nodes to local files in a directory",
6365
- builder: (yargs25) => withConfiguration(
6998
+ builder: (yargs27) => withConfiguration(
6366
6999
  withApiOptions(
6367
7000
  withProjectOptions(
6368
7001
  withDiffOptions(
6369
- yargs25.positional("directory", {
7002
+ yargs27.positional("directory", {
6370
7003
  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.",
6371
7004
  type: "string"
6372
7005
  }).option("format", {
@@ -6435,6 +7068,7 @@ var ProjectMapNodePullModule = {
6435
7068
  target,
6436
7069
  mode,
6437
7070
  whatIf,
7071
+ allowEmptySource: true,
6438
7072
  log: createSyncEngineConsoleLogger({ diffMode })
6439
7073
  });
6440
7074
  }
@@ -6445,11 +7079,11 @@ import { UncachedProjectMapClient as UncachedProjectMapClient10 } from "@uniform
6445
7079
  var ProjectMapNodePushModule = {
6446
7080
  command: "push <directory>",
6447
7081
  describe: "Pushes all project maps nodes from files in a directory or package to Uniform",
6448
- builder: (yargs25) => withConfiguration(
7082
+ builder: (yargs27) => withConfiguration(
6449
7083
  withApiOptions(
6450
7084
  withProjectOptions(
6451
7085
  withDiffOptions(
6452
- yargs25.positional("directory", {
7086
+ yargs27.positional("directory", {
6453
7087
  describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
6454
7088
  type: "string"
6455
7089
  }).option("what-if", {
@@ -6522,10 +7156,10 @@ var ProjectMapNodeRemoveModule = {
6522
7156
  command: "remove <id> <projectMapId>",
6523
7157
  aliases: ["delete", "rm"],
6524
7158
  describe: "Delete a project map node",
6525
- builder: (yargs25) => withConfiguration(
7159
+ builder: (yargs27) => withConfiguration(
6526
7160
  withApiOptions(
6527
7161
  withProjectOptions(
6528
- yargs25.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to delete" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to delete from" })
7162
+ yargs27.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to delete" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to delete from" })
6529
7163
  )
6530
7164
  )
6531
7165
  ),
@@ -6542,10 +7176,10 @@ var ProjectMapNodeUpdateModule = {
6542
7176
  command: "update <filename> <projectMapId>",
6543
7177
  aliases: ["put"],
6544
7178
  describe: "Insert or update a project map node",
6545
- builder: (yargs25) => withConfiguration(
7179
+ builder: (yargs27) => withConfiguration(
6546
7180
  withApiOptions(
6547
7181
  withProjectOptions(
6548
- yargs25.positional("filename", { demandOption: true, describe: "ProjectMap node file with nodes data" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to put into" })
7182
+ yargs27.positional("filename", { demandOption: true, describe: "ProjectMap node file with nodes data" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to put into" })
6549
7183
  )
6550
7184
  )
6551
7185
  ),
@@ -6561,9 +7195,9 @@ var ProjectMapNodeUpdateModule = {
6561
7195
  var ProjectMapNodeModule = {
6562
7196
  command: "node <command>",
6563
7197
  describe: "Commands for ProjectMap Nodes",
6564
- builder: (yargs25) => yargs25.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
7198
+ builder: (yargs27) => yargs27.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
6565
7199
  handler: () => {
6566
- yargs19.help();
7200
+ yargs21.help();
6567
7201
  }
6568
7202
  };
6569
7203
 
@@ -6572,28 +7206,28 @@ var ProjectMapCommand = {
6572
7206
  command: "project-map <command>",
6573
7207
  aliases: ["prm"],
6574
7208
  describe: "Uniform ProjectMap commands",
6575
- builder: (yargs25) => yargs25.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
7209
+ builder: (yargs27) => yargs27.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
6576
7210
  handler: () => {
6577
- yargs20.showHelp();
7211
+ yargs22.showHelp();
6578
7212
  }
6579
7213
  };
6580
7214
 
6581
7215
  // src/commands/redirect/index.ts
6582
- import yargs22 from "yargs";
7216
+ import yargs24 from "yargs";
6583
7217
 
6584
7218
  // src/commands/redirect/commands/redirect.ts
6585
- import yargs21 from "yargs";
7219
+ import yargs23 from "yargs";
6586
7220
 
6587
7221
  // src/commands/redirect/commands/RedirectDefinition/get.ts
6588
7222
  import { UncachedRedirectClient } from "@uniformdev/redirect";
6589
7223
  var RedirectDefinitionGetModule = {
6590
7224
  command: "get <id>",
6591
7225
  describe: "Fetch a redirect",
6592
- builder: (yargs25) => withConfiguration(
7226
+ builder: (yargs27) => withConfiguration(
6593
7227
  withFormatOptions(
6594
7228
  withApiOptions(
6595
7229
  withProjectOptions(
6596
- yargs25.positional("id", { demandOption: true, describe: "Redirect UUID to fetch" })
7230
+ yargs27.positional("id", { demandOption: true, describe: "Redirect UUID to fetch" })
6597
7231
  )
6598
7232
  )
6599
7233
  )
@@ -6617,7 +7251,7 @@ var RedirectDefinitionListModule = {
6617
7251
  command: "list",
6618
7252
  describe: "List of redirects",
6619
7253
  aliases: ["ls"],
6620
- builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
7254
+ builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
6621
7255
  handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
6622
7256
  const fetch3 = nodeFetchProxy(proxy);
6623
7257
  const client = new UncachedRedirectClient2({ apiKey, apiHost, fetch: fetch3, projectId });
@@ -6683,11 +7317,11 @@ function createRedirectDefinitionEngineDataSource({
6683
7317
  var RedirectDefinitionPullModule = {
6684
7318
  command: "pull <directory>",
6685
7319
  describe: "Pulls all redirects to local files in a directory",
6686
- builder: (yargs25) => withConfiguration(
7320
+ builder: (yargs27) => withConfiguration(
6687
7321
  withApiOptions(
6688
7322
  withProjectOptions(
6689
7323
  withDiffOptions(
6690
- yargs25.positional("directory", {
7324
+ yargs27.positional("directory", {
6691
7325
  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.",
6692
7326
  type: "string"
6693
7327
  }).option("format", {
@@ -6753,6 +7387,7 @@ var RedirectDefinitionPullModule = {
6753
7387
  target,
6754
7388
  mode,
6755
7389
  whatIf,
7390
+ allowEmptySource: true,
6756
7391
  log: createSyncEngineConsoleLogger({ diffMode })
6757
7392
  });
6758
7393
  }
@@ -6763,11 +7398,11 @@ import { UncachedRedirectClient as UncachedRedirectClient4 } from "@uniformdev/r
6763
7398
  var RedirectDefinitionPushModule = {
6764
7399
  command: "push <directory>",
6765
7400
  describe: "Pushes all redirects from files in a directory or package to Uniform",
6766
- builder: (yargs25) => withConfiguration(
7401
+ builder: (yargs27) => withConfiguration(
6767
7402
  withApiOptions(
6768
7403
  withProjectOptions(
6769
7404
  withDiffOptions(
6770
- yargs25.positional("directory", {
7405
+ yargs27.positional("directory", {
6771
7406
  describe: "Directory to read redirects from. If a filename is used, a package will be read instead.",
6772
7407
  type: "string"
6773
7408
  }).option("what-if", {
@@ -6831,9 +7466,9 @@ var RedirectDefinitionRemoveModule = {
6831
7466
  command: "remove <id>",
6832
7467
  aliases: ["delete", "rm"],
6833
7468
  describe: "Delete a redirect",
6834
- builder: (yargs25) => withConfiguration(
7469
+ builder: (yargs27) => withConfiguration(
6835
7470
  withApiOptions(
6836
- withProjectOptions(yargs25.positional("id", { demandOption: true, describe: " UUID to delete" }))
7471
+ withProjectOptions(yargs27.positional("id", { demandOption: true, describe: " UUID to delete" }))
6837
7472
  )
6838
7473
  ),
6839
7474
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
@@ -6849,10 +7484,10 @@ var RedirectDefinitionUpdateModule = {
6849
7484
  command: "update <filename>",
6850
7485
  aliases: ["put"],
6851
7486
  describe: "Insert or update a redirect",
6852
- builder: (yargs25) => withConfiguration(
7487
+ builder: (yargs27) => withConfiguration(
6853
7488
  withApiOptions(
6854
7489
  withProjectOptions(
6855
- yargs25.positional("filename", { demandOption: true, describe: "Redirect file to put" })
7490
+ yargs27.positional("filename", { demandOption: true, describe: "Redirect file to put" })
6856
7491
  )
6857
7492
  )
6858
7493
  ),
@@ -6868,9 +7503,9 @@ var RedirectDefinitionUpdateModule = {
6868
7503
  var RedirectDefinitionModule = {
6869
7504
  command: "definition <command>",
6870
7505
  describe: "Commands for Redirect Definitions",
6871
- builder: (yargs25) => yargs25.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
7506
+ builder: (yargs27) => yargs27.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
6872
7507
  handler: () => {
6873
- yargs21.help();
7508
+ yargs23.help();
6874
7509
  }
6875
7510
  };
6876
7511
 
@@ -6879,14 +7514,14 @@ var RedirectCommand = {
6879
7514
  command: "redirect <command>",
6880
7515
  aliases: ["red"],
6881
7516
  describe: "Uniform Redirect commands",
6882
- builder: (yargs25) => yargs25.command(RedirectDefinitionModule).demandCommand(),
7517
+ builder: (yargs27) => yargs27.command(RedirectDefinitionModule).demandCommand(),
6883
7518
  handler: () => {
6884
- yargs22.showHelp();
7519
+ yargs24.showHelp();
6885
7520
  }
6886
7521
  };
6887
7522
 
6888
7523
  // src/commands/sync/index.ts
6889
- import yargs23 from "yargs";
7524
+ import yargs25 from "yargs";
6890
7525
 
6891
7526
  // src/commands/sync/commands/util.ts
6892
7527
  import ora2 from "ora";
@@ -6917,11 +7552,11 @@ function spin(entityType) {
6917
7552
  var SyncPullModule = {
6918
7553
  command: "pull",
6919
7554
  describe: "Pulls whole project to local files in a directory",
6920
- builder: (yargs25) => withConfiguration(
7555
+ builder: (yargs27) => withConfiguration(
6921
7556
  withApiOptions(
6922
7557
  withProjectOptions(
6923
7558
  withDiffOptions(
6924
- yargs25.option("what-if", {
7559
+ yargs27.option("what-if", {
6925
7560
  alias: ["w"],
6926
7561
  describe: "What-if mode reports what would be done but changes no files",
6927
7562
  default: false,
@@ -6936,6 +7571,7 @@ var SyncPullModule = {
6936
7571
  const enabledEntities = Object.entries({
6937
7572
  category: CategoryPullModule,
6938
7573
  dataType: DataTypePullModule,
7574
+ prompt: PromptPullModule,
6939
7575
  quirk: QuirkPullModule,
6940
7576
  test: TestPullModule,
6941
7577
  signal: SignalPullModule,
@@ -6948,7 +7584,8 @@ var SyncPullModule = {
6948
7584
  projectMapNode: ProjectMapNodePullModule,
6949
7585
  redirect: RedirectDefinitionPullModule,
6950
7586
  entry: EntryPullModule,
6951
- contentType: ContentTypePullModule
7587
+ contentType: ContentTypePullModule,
7588
+ asset: AssetPullModule
6952
7589
  }).filter(([entityType]) => {
6953
7590
  var _a, _b, _c, _d, _e, _f;
6954
7591
  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;
@@ -7006,11 +7643,11 @@ var getFormat = (entityType, config2) => {
7006
7643
  var SyncPushModule = {
7007
7644
  command: "push",
7008
7645
  describe: "Pushes whole project data from files in a directory or package to Uniform",
7009
- builder: (yargs25) => withConfiguration(
7646
+ builder: (yargs27) => withConfiguration(
7010
7647
  withApiOptions(
7011
7648
  withProjectOptions(
7012
7649
  withDiffOptions(
7013
- yargs25.option("what-if", {
7650
+ yargs27.option("what-if", {
7014
7651
  alias: ["w"],
7015
7652
  describe: "What-if mode reports what would be done but changes nothing",
7016
7653
  default: false,
@@ -7026,6 +7663,7 @@ var SyncPushModule = {
7026
7663
  const enabledEntities = Object.entries({
7027
7664
  category: CategoryPushModule,
7028
7665
  dataType: DataTypePushModule,
7666
+ prompt: PromptPushModule,
7029
7667
  quirk: QuirkPushModule,
7030
7668
  test: TestPushModule,
7031
7669
  signal: SignalPushModule,
@@ -7038,7 +7676,8 @@ var SyncPushModule = {
7038
7676
  projectMapNode: ProjectMapNodePushModule,
7039
7677
  redirect: RedirectDefinitionPushModule,
7040
7678
  contentType: ContentTypePushModule,
7041
- entry: EntryPushModule
7679
+ entry: EntryPushModule,
7680
+ asset: AssetPushModule
7042
7681
  }).filter(([entityType]) => {
7043
7682
  var _a2, _b2, _c2, _d2, _e2, _f2;
7044
7683
  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;
@@ -7102,15 +7741,14 @@ var getFormat2 = (entityType, config2) => {
7102
7741
  var SyncCommand = {
7103
7742
  command: "sync <command>",
7104
7743
  describe: "Uniform Sync commands",
7105
- builder: (yargs25) => yargs25.command(SyncPullModule).command(SyncPushModule).demandCommand(),
7744
+ builder: (yargs27) => yargs27.command(SyncPullModule).command(SyncPushModule).demandCommand(),
7106
7745
  handler: () => {
7107
- yargs23.showHelp();
7746
+ yargs25.showHelp();
7108
7747
  }
7109
7748
  };
7110
7749
 
7111
7750
  // src/middleware/checkForUpdateMiddleware.ts
7112
7751
  import { bold, gray as gray5, green as green4 } from "colorette";
7113
- import updateCheck from "update-check";
7114
7752
 
7115
7753
  // src/log.ts
7116
7754
  import { reset } from "colorette";
@@ -7131,13 +7769,164 @@ function logCallout(options) {
7131
7769
  console.log("");
7132
7770
  }
7133
7771
 
7772
+ // src/updateCheck.ts
7773
+ import { existsSync as existsSync4, promises as fs5 } from "fs";
7774
+ import { get as getHttp } from "http";
7775
+ import { get as getHttps } from "https";
7776
+ import { tmpdir } from "os";
7777
+ import { join as join3 } from "path";
7778
+ import registryUrl from "registry-url";
7779
+ import { URL as URL2 } from "url";
7780
+ var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
7781
+ var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
7782
+ var getFile = async (details, distTag) => {
7783
+ const rootDir = tmpdir();
7784
+ const subDir = join3(rootDir, "update-check");
7785
+ if (!existsSync4(subDir)) {
7786
+ await fs5.mkdir(subDir);
7787
+ }
7788
+ let name = `${details.name}-${distTag}.json`;
7789
+ if (details.scope) {
7790
+ name = `${details.scope}-${name}`;
7791
+ }
7792
+ return join3(subDir, name);
7793
+ };
7794
+ var evaluateCache = async (file, time, interval) => {
7795
+ if (existsSync4(file)) {
7796
+ const content = await fs5.readFile(file, "utf8");
7797
+ const { lastUpdate, latest } = JSON.parse(content);
7798
+ const nextCheck = lastUpdate + interval;
7799
+ if (nextCheck > time) {
7800
+ return {
7801
+ shouldCheck: false,
7802
+ latest
7803
+ };
7804
+ }
7805
+ }
7806
+ return {
7807
+ shouldCheck: true,
7808
+ latest: null
7809
+ };
7810
+ };
7811
+ var updateCache = async (file, latest, lastUpdate) => {
7812
+ const content = JSON.stringify({
7813
+ latest,
7814
+ lastUpdate
7815
+ });
7816
+ await fs5.writeFile(file, content, "utf8");
7817
+ };
7818
+ var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve2, reject) => {
7819
+ const options = {
7820
+ host: url.hostname,
7821
+ path: url.pathname,
7822
+ port: url.port,
7823
+ headers: {
7824
+ accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
7825
+ },
7826
+ timeout
7827
+ };
7828
+ if (authInfo) {
7829
+ options.headers.authorization = `${authInfo.type} ${authInfo.token}`;
7830
+ }
7831
+ const get = url.protocol === "https:" ? getHttps : getHttp;
7832
+ get(options, (response) => {
7833
+ const { statusCode } = response;
7834
+ if (statusCode !== 200) {
7835
+ const error = new Error(`Request failed with code ${statusCode}`);
7836
+ error.code = statusCode;
7837
+ reject(error);
7838
+ response.resume();
7839
+ return;
7840
+ }
7841
+ let rawData = "";
7842
+ response.setEncoding("utf8");
7843
+ response.on("data", (chunk) => {
7844
+ rawData += chunk;
7845
+ });
7846
+ response.on("end", () => {
7847
+ try {
7848
+ const parsedData = JSON.parse(rawData);
7849
+ resolve2(parsedData);
7850
+ } catch (e) {
7851
+ reject(e);
7852
+ }
7853
+ });
7854
+ }).on("error", reject).on("timeout", () => reject(new Error("Request timeout")));
7855
+ });
7856
+ var getMostRecent = async ({ full, scope }, distTag, timeout) => {
7857
+ const regURL = registryUrl(scope ?? "");
7858
+ const url = new URL2(full, regURL);
7859
+ let spec = null;
7860
+ try {
7861
+ spec = await loadPackage({ url, timeout });
7862
+ } catch (err) {
7863
+ if ((err == null ? void 0 : err.code) && String(err.code).startsWith("4")) {
7864
+ const registryAuthToken = __require("registry-auth-token");
7865
+ const authInfo = registryAuthToken(regURL, { recursive: true });
7866
+ spec = await loadPackage({ url, timeout }, authInfo);
7867
+ } else {
7868
+ throw err;
7869
+ }
7870
+ }
7871
+ const version = spec["dist-tags"][distTag];
7872
+ if (!version) {
7873
+ throw new Error(`Distribution tag ${distTag} is not available`);
7874
+ }
7875
+ return version;
7876
+ };
7877
+ var defaultConfig = {
7878
+ interval: 36e5,
7879
+ distTag: "latest",
7880
+ timeout: 2e3
7881
+ };
7882
+ var getDetails = (name) => {
7883
+ const spec = {
7884
+ full: encode(name),
7885
+ name: "",
7886
+ scope: null
7887
+ };
7888
+ if (name.includes("/")) {
7889
+ const parts = name.split("/");
7890
+ spec.scope = parts[0];
7891
+ spec.name = parts[1];
7892
+ } else {
7893
+ spec.scope = null;
7894
+ spec.name = name;
7895
+ }
7896
+ return spec;
7897
+ };
7898
+ async function updateCheck_default(pkg, config2 = {}) {
7899
+ if (typeof pkg !== "object") {
7900
+ throw new Error("The first parameter should be your package.json file content");
7901
+ }
7902
+ const details = getDetails(pkg.name);
7903
+ const time = Date.now();
7904
+ const { distTag, interval, timeout } = Object.assign({}, defaultConfig, config2);
7905
+ const file = await getFile(details, distTag);
7906
+ let latest = null;
7907
+ let shouldCheck = true;
7908
+ ({ shouldCheck, latest } = await evaluateCache(file, time, interval));
7909
+ if (shouldCheck) {
7910
+ latest = await getMostRecent(details, distTag, timeout);
7911
+ await updateCache(file, latest, time);
7912
+ }
7913
+ const comparision = compareVersions(pkg.version, latest);
7914
+ if (comparision === -1) {
7915
+ return {
7916
+ latest,
7917
+ fromCache: !shouldCheck
7918
+ };
7919
+ }
7920
+ return null;
7921
+ }
7922
+
7134
7923
  // src/middleware/checkForUpdateMiddleware.ts
7135
7924
  async function checkForUpdateMiddleware() {
7136
7925
  try {
7137
7926
  if (process.env.NO_UPDATE_CHECK || process.env.CI) {
7138
7927
  return;
7139
7928
  }
7140
- const update = await updateCheck(package_default);
7929
+ const update = await updateCheck_default(package_default);
7141
7930
  if (update) {
7142
7931
  logCallout(`${bold("Update Available:")} ${gray5(package_default.version)} \u226B ${green4(update.latest)}`);
7143
7932
  }
@@ -7148,17 +7937,17 @@ async function checkForUpdateMiddleware() {
7148
7937
 
7149
7938
  // src/middleware/checkLocalDepsVersionsMiddleware.ts
7150
7939
  import { magenta, red as red6 } from "colorette";
7151
- import { join as join3 } from "path";
7940
+ import { join as join4 } from "path";
7152
7941
 
7153
7942
  // src/fs.ts
7154
- import { promises as fs5 } from "fs";
7943
+ import { promises as fs6 } from "fs";
7155
7944
  async function readJSON(path5) {
7156
- const fileContents = await fs5.readFile(path5, "utf-8");
7945
+ const fileContents = await fs6.readFile(path5, "utf-8");
7157
7946
  return JSON.parse(fileContents);
7158
7947
  }
7159
7948
  async function tryReadJSON(path5, missingValue = null) {
7160
7949
  try {
7161
- const stat = await fs5.stat(path5);
7950
+ const stat = await fs6.stat(path5);
7162
7951
  return stat.isFile() ? await readJSON(path5) : missingValue;
7163
7952
  } catch (e) {
7164
7953
  return missingValue;
@@ -7187,7 +7976,7 @@ var checkLocalDepsVersions = async (args) => {
7187
7976
  try {
7188
7977
  let isOutside = false;
7189
7978
  let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
7190
- const localPackages = await tryReadJSON(join3(process.cwd(), "package.json"));
7979
+ const localPackages = await tryReadJSON(join4(process.cwd(), "package.json"));
7191
7980
  if (!localPackages)
7192
7981
  return;
7193
7982
  let firstVersion;
@@ -7220,7 +8009,7 @@ First found was: v${firstVersion}`;
7220
8009
 
7221
8010
  // src/index.ts
7222
8011
  dotenv.config();
7223
- var yarggery = yargs24(hideBin(process.argv));
8012
+ var yarggery = yargs26(hideBin(process.argv));
7224
8013
  var inlineConfigurationFilePath = "config" in yarggery.argv && yarggery.argv.config;
7225
8014
  var configuration = loadConfig(inlineConfigurationFilePath || null);
7226
8015
  yarggery.option("verbose", {