@uniformdev/cli 19.61.1-alpha.10 → 19.61.1-alpha.18
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.d.mts +1 -1
- package/dist/index.mjs +1640 -855
- package/package.json +13 -10
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
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";
|
|
@@ -9,24 +16,25 @@ var __dirname = /* @__PURE__ */ getDirname();
|
|
|
9
16
|
|
|
10
17
|
// src/index.ts
|
|
11
18
|
import * as dotenv from "dotenv";
|
|
12
|
-
import
|
|
19
|
+
import yargs26 from "yargs";
|
|
13
20
|
import { hideBin } from "yargs/helpers";
|
|
14
21
|
|
|
15
22
|
// src/commands/canvas/index.ts
|
|
16
|
-
import
|
|
23
|
+
import yargs10 from "yargs";
|
|
17
24
|
|
|
18
|
-
// src/commands/canvas/commands/
|
|
25
|
+
// src/commands/canvas/commands/asset.ts
|
|
19
26
|
import yargs from "yargs";
|
|
20
27
|
|
|
21
|
-
// src/commands/canvas/commands/
|
|
22
|
-
import {
|
|
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(
|
|
130
|
-
return
|
|
140
|
+
function withConfiguration(yargs27) {
|
|
141
|
+
return yargs27.option("serialization", {
|
|
131
142
|
skipValidation: true,
|
|
132
143
|
hidden: true
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
|
-
function withApiOptions(
|
|
136
|
-
return
|
|
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(
|
|
176
|
-
return
|
|
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(
|
|
187
|
-
return
|
|
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(
|
|
200
|
-
return
|
|
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/
|
|
617
|
-
var
|
|
631
|
+
// src/commands/canvas/commands/asset/get.ts
|
|
632
|
+
var AssetGetModule = {
|
|
618
633
|
command: "get <id>",
|
|
619
|
-
describe: "
|
|
620
|
-
builder: (
|
|
634
|
+
describe: "Get an asset",
|
|
635
|
+
builder: (yargs27) => withConfiguration(
|
|
621
636
|
withFormatOptions(
|
|
622
637
|
withApiOptions(
|
|
623
638
|
withProjectOptions(
|
|
624
|
-
|
|
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
|
|
645
|
+
handler: async ({ apiHost, apiKey, proxy, id, format, filename, project: projectId }) => {
|
|
630
646
|
const fetch3 = nodeFetchProxy(proxy);
|
|
631
|
-
const client = new
|
|
632
|
-
const res = await client.
|
|
633
|
-
|
|
634
|
-
|
|
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/
|
|
644
|
-
import {
|
|
645
|
-
var
|
|
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
|
|
648
|
-
|
|
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
|
|
653
|
-
const res = await client.
|
|
654
|
-
emitWithFormat(res.
|
|
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/
|
|
659
|
-
import {
|
|
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/
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
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
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
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
|
|
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
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
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: (
|
|
1444
|
+
builder: (yargs27) => withConfiguration(
|
|
855
1445
|
withApiOptions(
|
|
856
1446
|
withProjectOptions(
|
|
857
|
-
|
|
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: (
|
|
1464
|
+
builder: (yargs27) => withConfiguration(
|
|
875
1465
|
withApiOptions(
|
|
876
1466
|
withProjectOptions(
|
|
877
|
-
|
|
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: (
|
|
1484
|
+
builder: (yargs27) => yargs27.command(CategoryPullModule).command(CategoryPushModule).command(CategoryGetModule).command(CategoryRemoveModule).command(CategoryListModule).command(CategoryUpdateModule).demandCommand(),
|
|
895
1485
|
handler: () => {
|
|
896
|
-
|
|
1486
|
+
yargs2.help();
|
|
897
1487
|
}
|
|
898
1488
|
};
|
|
899
1489
|
|
|
900
1490
|
// src/commands/canvas/commands/component.ts
|
|
901
|
-
import
|
|
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: (
|
|
1505
|
+
builder: (yargs27) => withConfiguration(
|
|
916
1506
|
withFormatOptions(
|
|
917
1507
|
withApiOptions(
|
|
918
1508
|
withProjectOptions(
|
|
919
|
-
|
|
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: (
|
|
1543
|
+
builder: (yargs27) => withConfiguration(
|
|
954
1544
|
withFormatOptions(
|
|
955
1545
|
withApiOptions(
|
|
956
1546
|
withProjectOptions(
|
|
957
|
-
|
|
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: (
|
|
1602
|
+
builder: (yargs27) => withConfiguration(
|
|
1013
1603
|
withApiOptions(
|
|
1014
1604
|
withProjectOptions(
|
|
1015
1605
|
withDiffOptions(
|
|
1016
|
-
|
|
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: (
|
|
1683
|
+
builder: (yargs27) => withConfiguration(
|
|
1094
1684
|
withApiOptions(
|
|
1095
1685
|
withProjectOptions(
|
|
1096
1686
|
withDiffOptions(
|
|
1097
|
-
|
|
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: (
|
|
1752
|
+
builder: (yargs27) => withConfiguration(
|
|
1163
1753
|
withApiOptions(
|
|
1164
1754
|
withProjectOptions(
|
|
1165
|
-
|
|
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: (
|
|
1772
|
+
builder: (yargs27) => withConfiguration(
|
|
1183
1773
|
withApiOptions(
|
|
1184
1774
|
withProjectOptions(
|
|
1185
|
-
|
|
1775
|
+
yargs27.positional("filename", { demandOption: true, describe: "Component definition file to put" })
|
|
1186
1776
|
)
|
|
1187
1777
|
)
|
|
1188
1778
|
),
|
|
@@ -1194,68 +1784,31 @@ var ComponentUpdateModule = {
|
|
|
1194
1784
|
}
|
|
1195
1785
|
};
|
|
1196
1786
|
|
|
1197
|
-
// src/commands/canvas/commands/component.ts
|
|
1198
|
-
var ComponentModule = {
|
|
1199
|
-
command: "component <command>",
|
|
1200
|
-
aliases: ["def"],
|
|
1201
|
-
describe: "Commands for Canvas component definitions",
|
|
1202
|
-
builder: (
|
|
1203
|
-
handler: () => {
|
|
1204
|
-
|
|
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');
|
|
1787
|
+
// src/commands/canvas/commands/component.ts
|
|
1788
|
+
var ComponentModule = {
|
|
1789
|
+
command: "component <command>",
|
|
1790
|
+
aliases: ["def"],
|
|
1791
|
+
describe: "Commands for Canvas component definitions",
|
|
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
|
-
|
|
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: (
|
|
1806
|
+
builder: (yargs27) => withFormatOptions(
|
|
1254
1807
|
withConfiguration(
|
|
1255
1808
|
withApiOptions(
|
|
1256
1809
|
withProjectOptions(
|
|
1257
1810
|
withStateOptions(
|
|
1258
|
-
|
|
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: (
|
|
1882
|
+
builder: (yargs27) => withFormatOptions(
|
|
1330
1883
|
withConfiguration(
|
|
1331
1884
|
withApiOptions(
|
|
1332
1885
|
withProjectOptions(
|
|
1333
1886
|
withStateOptions(
|
|
1334
|
-
|
|
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: {
|
|
@@ -1451,266 +2004,92 @@ function createComponentInstanceEngineDataSource({
|
|
|
1451
2004
|
// src/commands/canvas/commands/composition/publish.ts
|
|
1452
2005
|
var CompositionPublishModule = {
|
|
1453
2006
|
command: "publish [ids]",
|
|
1454
|
-
describe: "Publishes composition(s)",
|
|
1455
|
-
builder: (
|
|
1456
|
-
withApiOptions(
|
|
1457
|
-
withProjectOptions(
|
|
1458
|
-
withDiffOptions(
|
|
1459
|
-
|
|
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
|
-
});
|
|
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
|
-
|
|
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: (
|
|
2087
|
+
builder: (yargs27) => withConfiguration(
|
|
1709
2088
|
withApiOptions(
|
|
1710
2089
|
withProjectOptions(
|
|
1711
2090
|
withStateOptions(
|
|
1712
2091
|
withDiffOptions(
|
|
1713
|
-
|
|
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 {
|
|
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: (
|
|
2187
|
+
builder: (yargs27) => withConfiguration(
|
|
1809
2188
|
withApiOptions(
|
|
1810
2189
|
withProjectOptions(
|
|
1811
2190
|
withStateOptions(
|
|
1812
2191
|
withDiffOptions(
|
|
1813
|
-
|
|
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
|
|
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: (
|
|
2281
|
+
builder: (yargs27) => withConfiguration(
|
|
1905
2282
|
withApiOptions(
|
|
1906
2283
|
withProjectOptions(
|
|
1907
|
-
|
|
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: (
|
|
2301
|
+
builder: (yargs27) => withConfiguration(
|
|
1925
2302
|
withApiOptions(
|
|
1926
2303
|
withProjectOptions(
|
|
1927
|
-
|
|
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: (
|
|
2398
|
+
builder: (yargs27) => withConfiguration(
|
|
2022
2399
|
withApiOptions(
|
|
2023
2400
|
withProjectOptions(
|
|
2024
2401
|
withStateOptions(
|
|
2025
|
-
|
|
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: (
|
|
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
|
-
|
|
2422
|
+
yargs4.help();
|
|
2046
2423
|
}
|
|
2047
2424
|
};
|
|
2048
2425
|
|
|
2049
2426
|
// src/commands/canvas/commands/contentType.ts
|
|
2050
|
-
import
|
|
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: (
|
|
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
|
-
|
|
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: (
|
|
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: (
|
|
2508
|
+
builder: (yargs27) => withConfiguration(
|
|
2132
2509
|
withApiOptions(
|
|
2133
2510
|
withProjectOptions(
|
|
2134
2511
|
withDiffOptions(
|
|
2135
|
-
|
|
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: (
|
|
2594
|
+
builder: (yargs27) => withConfiguration(
|
|
2218
2595
|
withApiOptions(
|
|
2219
2596
|
withProjectOptions(
|
|
2220
2597
|
withDiffOptions(
|
|
2221
|
-
|
|
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: (
|
|
2668
|
+
builder: (yargs27) => withConfiguration(
|
|
2292
2669
|
withApiOptions(
|
|
2293
2670
|
withProjectOptions(
|
|
2294
|
-
|
|
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: (
|
|
2688
|
+
builder: (yargs27) => withConfiguration(
|
|
2312
2689
|
withApiOptions(
|
|
2313
2690
|
withProjectOptions(
|
|
2314
|
-
|
|
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: (
|
|
2708
|
+
builder: (yargs27) => yargs27.command(ContentTypeGetModule).command(ContentTypeListModule).command(ContentTypeRemoveModule).command(ContentTypeUpdateModule).command(ContentTypePullModule).command(ContentTypePushModule).demandCommand(),
|
|
2332
2709
|
handler: () => {
|
|
2333
|
-
|
|
2710
|
+
yargs5.help();
|
|
2334
2711
|
}
|
|
2335
2712
|
};
|
|
2336
2713
|
|
|
2337
2714
|
// src/commands/canvas/commands/dataType.ts
|
|
2338
|
-
import
|
|
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: (
|
|
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
|
-
|
|
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: (
|
|
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 });
|
|
@@ -2392,12 +2769,8 @@ function createDataTypeEngineDataSource({
|
|
|
2392
2769
|
client
|
|
2393
2770
|
}) {
|
|
2394
2771
|
async function* getObjects() {
|
|
2395
|
-
var _a;
|
|
2396
2772
|
const dataTypes = (await client.get()).results;
|
|
2397
2773
|
for await (const dataType of dataTypes) {
|
|
2398
|
-
if (((_a = dataType.custom) == null ? void 0 : _a.uniformAutogenerated) === true) {
|
|
2399
|
-
continue;
|
|
2400
|
-
}
|
|
2401
2774
|
const result = {
|
|
2402
2775
|
id: selectIdentifier4(dataType),
|
|
2403
2776
|
displayName: selectDisplayName4(dataType),
|
|
@@ -2424,11 +2797,11 @@ function createDataTypeEngineDataSource({
|
|
|
2424
2797
|
var DataTypePullModule = {
|
|
2425
2798
|
command: "pull <directory>",
|
|
2426
2799
|
describe: "Pulls all data types to local files in a directory",
|
|
2427
|
-
builder: (
|
|
2800
|
+
builder: (yargs27) => withConfiguration(
|
|
2428
2801
|
withApiOptions(
|
|
2429
2802
|
withProjectOptions(
|
|
2430
2803
|
withDiffOptions(
|
|
2431
|
-
|
|
2804
|
+
yargs27.positional("directory", {
|
|
2432
2805
|
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
2806
|
type: "string"
|
|
2434
2807
|
}).option("format", {
|
|
@@ -2510,11 +2883,11 @@ import { DataTypeClient as DataTypeClient4 } from "@uniformdev/canvas";
|
|
|
2510
2883
|
var DataTypePushModule = {
|
|
2511
2884
|
command: "push <directory>",
|
|
2512
2885
|
describe: "Pushes all data types from files in a directory to Uniform",
|
|
2513
|
-
builder: (
|
|
2886
|
+
builder: (yargs27) => withConfiguration(
|
|
2514
2887
|
withApiOptions(
|
|
2515
2888
|
withProjectOptions(
|
|
2516
2889
|
withDiffOptions(
|
|
2517
|
-
|
|
2890
|
+
yargs27.positional("directory", {
|
|
2518
2891
|
describe: "Directory to read the data types from. If a filename is used, a package will be read instead.",
|
|
2519
2892
|
type: "string"
|
|
2520
2893
|
}).option("what-if", {
|
|
@@ -2584,10 +2957,10 @@ var DataTypeRemoveModule = {
|
|
|
2584
2957
|
command: "remove <id>",
|
|
2585
2958
|
aliases: ["delete", "rm"],
|
|
2586
2959
|
describe: "Delete a data type",
|
|
2587
|
-
builder: (
|
|
2960
|
+
builder: (yargs27) => withConfiguration(
|
|
2588
2961
|
withApiOptions(
|
|
2589
2962
|
withProjectOptions(
|
|
2590
|
-
|
|
2963
|
+
yargs27.positional("id", { demandOption: true, describe: "Data type public ID to delete" })
|
|
2591
2964
|
)
|
|
2592
2965
|
)
|
|
2593
2966
|
),
|
|
@@ -2604,10 +2977,10 @@ var DataTypeUpdateModule = {
|
|
|
2604
2977
|
command: "update <filename>",
|
|
2605
2978
|
aliases: ["put"],
|
|
2606
2979
|
describe: "Insert or update a data type",
|
|
2607
|
-
builder: (
|
|
2980
|
+
builder: (yargs27) => withConfiguration(
|
|
2608
2981
|
withApiOptions(
|
|
2609
2982
|
withProjectOptions(
|
|
2610
|
-
|
|
2983
|
+
yargs27.positional("filename", { demandOption: true, describe: "Data type file to put" })
|
|
2611
2984
|
)
|
|
2612
2985
|
)
|
|
2613
2986
|
),
|
|
@@ -2624,26 +2997,26 @@ var DataTypeModule = {
|
|
|
2624
2997
|
command: "datatype <command>",
|
|
2625
2998
|
aliases: ["dt"],
|
|
2626
2999
|
describe: "Commands for Data Type definitions",
|
|
2627
|
-
builder: (
|
|
3000
|
+
builder: (yargs27) => yargs27.command(DataTypeGetModule).command(DataTypePullModule).command(DataTypePushModule).command(DataTypeRemoveModule).command(DataTypeListModule).command(DataTypeUpdateModule).demandCommand(),
|
|
2628
3001
|
handler: () => {
|
|
2629
|
-
|
|
3002
|
+
yargs6.help();
|
|
2630
3003
|
}
|
|
2631
3004
|
};
|
|
2632
3005
|
|
|
2633
3006
|
// src/commands/canvas/commands/entry.ts
|
|
2634
|
-
import
|
|
3007
|
+
import yargs7 from "yargs";
|
|
2635
3008
|
|
|
2636
3009
|
// src/commands/canvas/commands/entry/get.ts
|
|
2637
3010
|
import { ContentClient as ContentClient7 } from "@uniformdev/canvas";
|
|
2638
3011
|
var EntryGetModule = {
|
|
2639
3012
|
command: "get <id>",
|
|
2640
3013
|
describe: "Get an entry",
|
|
2641
|
-
builder: (
|
|
3014
|
+
builder: (yargs27) => withConfiguration(
|
|
2642
3015
|
withFormatOptions(
|
|
2643
3016
|
withApiOptions(
|
|
2644
3017
|
withProjectOptions(
|
|
2645
3018
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2646
|
-
|
|
3019
|
+
yargs27.positional("id", { demandOption: true, describe: "Entry public ID to fetch" })
|
|
2647
3020
|
)
|
|
2648
3021
|
)
|
|
2649
3022
|
)
|
|
@@ -2664,7 +3037,7 @@ import { ContentClient as ContentClient8 } from "@uniformdev/canvas";
|
|
|
2664
3037
|
var EntryListModule = {
|
|
2665
3038
|
command: "list",
|
|
2666
3039
|
describe: "List entries",
|
|
2667
|
-
builder: (
|
|
3040
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
2668
3041
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
2669
3042
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2670
3043
|
const client = new ContentClient8({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
@@ -2722,12 +3095,12 @@ function createEntryEngineDataSource({
|
|
|
2722
3095
|
var EntryPullModule = {
|
|
2723
3096
|
command: "pull <directory>",
|
|
2724
3097
|
describe: "Pulls all entries to local files in a directory",
|
|
2725
|
-
builder: (
|
|
3098
|
+
builder: (yargs27) => withConfiguration(
|
|
2726
3099
|
withApiOptions(
|
|
2727
3100
|
withProjectOptions(
|
|
2728
3101
|
withStateOptions(
|
|
2729
3102
|
withDiffOptions(
|
|
2730
|
-
|
|
3103
|
+
yargs27.positional("directory", {
|
|
2731
3104
|
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
3105
|
type: "string"
|
|
2733
3106
|
}).option("format", {
|
|
@@ -2811,12 +3184,12 @@ import { ContentClient as ContentClient11 } from "@uniformdev/canvas";
|
|
|
2811
3184
|
var EntryPushModule = {
|
|
2812
3185
|
command: "push <directory>",
|
|
2813
3186
|
describe: "Pushes all entries from files in a directory to Uniform",
|
|
2814
|
-
builder: (
|
|
3187
|
+
builder: (yargs27) => withConfiguration(
|
|
2815
3188
|
withApiOptions(
|
|
2816
3189
|
withProjectOptions(
|
|
2817
3190
|
withStateOptions(
|
|
2818
3191
|
withDiffOptions(
|
|
2819
|
-
|
|
3192
|
+
yargs27.positional("directory", {
|
|
2820
3193
|
describe: "Directory to read the entries from. If a filename is used, a package will be read instead.",
|
|
2821
3194
|
type: "string"
|
|
2822
3195
|
}).option("what-if", {
|
|
@@ -2888,10 +3261,10 @@ var EntryRemoveModule = {
|
|
|
2888
3261
|
command: "remove <id>",
|
|
2889
3262
|
aliases: ["delete", "rm"],
|
|
2890
3263
|
describe: "Delete an entry",
|
|
2891
|
-
builder: (
|
|
3264
|
+
builder: (yargs27) => withConfiguration(
|
|
2892
3265
|
withApiOptions(
|
|
2893
3266
|
withProjectOptions(
|
|
2894
|
-
|
|
3267
|
+
yargs27.positional("id", { demandOption: true, describe: "Entry public ID to delete" })
|
|
2895
3268
|
)
|
|
2896
3269
|
)
|
|
2897
3270
|
),
|
|
@@ -2908,10 +3281,10 @@ var EntryUpdateModule = {
|
|
|
2908
3281
|
command: "update <filename>",
|
|
2909
3282
|
aliases: ["put"],
|
|
2910
3283
|
describe: "Insert or update an entry",
|
|
2911
|
-
builder: (
|
|
3284
|
+
builder: (yargs27) => withConfiguration(
|
|
2912
3285
|
withApiOptions(
|
|
2913
3286
|
withProjectOptions(
|
|
2914
|
-
|
|
3287
|
+
yargs27.positional("filename", { demandOption: true, describe: "Entry file to put" })
|
|
2915
3288
|
)
|
|
2916
3289
|
)
|
|
2917
3290
|
),
|
|
@@ -2927,14 +3300,14 @@ var EntryUpdateModule = {
|
|
|
2927
3300
|
var EntryModule = {
|
|
2928
3301
|
command: "entry <command>",
|
|
2929
3302
|
describe: "Commands for Entries",
|
|
2930
|
-
builder: (
|
|
3303
|
+
builder: (yargs27) => yargs27.command(EntryGetModule).command(EntryListModule).command(EntryRemoveModule).command(EntryUpdateModule).command(EntryPullModule).command(EntryPushModule).demandCommand(),
|
|
2931
3304
|
handler: () => {
|
|
2932
|
-
|
|
3305
|
+
yargs7.help();
|
|
2933
3306
|
}
|
|
2934
3307
|
};
|
|
2935
3308
|
|
|
2936
3309
|
// src/commands/canvas/commands/pattern.ts
|
|
2937
|
-
import
|
|
3310
|
+
import yargs8 from "yargs";
|
|
2938
3311
|
|
|
2939
3312
|
// src/commands/canvas/commands/pattern/get.ts
|
|
2940
3313
|
var PatternGetModule = {
|
|
@@ -2946,12 +3319,12 @@ var PatternGetModule = {
|
|
|
2946
3319
|
var PatternListModule = {
|
|
2947
3320
|
...CompositionListModule,
|
|
2948
3321
|
describe: "List patterns",
|
|
2949
|
-
builder: (
|
|
3322
|
+
builder: (yargs27) => withFormatOptions(
|
|
2950
3323
|
withConfiguration(
|
|
2951
3324
|
withApiOptions(
|
|
2952
3325
|
withProjectOptions(
|
|
2953
3326
|
withStateOptions(
|
|
2954
|
-
|
|
3327
|
+
yargs27.options({
|
|
2955
3328
|
offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
|
|
2956
3329
|
limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
|
|
2957
3330
|
resolvePatterns: {
|
|
@@ -2989,11 +3362,11 @@ var PatternListModule = {
|
|
|
2989
3362
|
var PatternPublishModule = {
|
|
2990
3363
|
...CompositionPublishModule,
|
|
2991
3364
|
describe: "Publishes pattern(s)",
|
|
2992
|
-
builder: (
|
|
3365
|
+
builder: (yargs27) => withConfiguration(
|
|
2993
3366
|
withApiOptions(
|
|
2994
3367
|
withProjectOptions(
|
|
2995
3368
|
withDiffOptions(
|
|
2996
|
-
|
|
3369
|
+
yargs27.positional("ids", {
|
|
2997
3370
|
describe: "Publishes pattern(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
|
|
2998
3371
|
type: "string"
|
|
2999
3372
|
}).option("all", {
|
|
@@ -3031,12 +3404,12 @@ var PatternPublishModule = {
|
|
|
3031
3404
|
var PatternPullModule = {
|
|
3032
3405
|
...CompositionPullModule,
|
|
3033
3406
|
describe: "Pulls all patterns to local files in a directory",
|
|
3034
|
-
builder: (
|
|
3407
|
+
builder: (yargs27) => withConfiguration(
|
|
3035
3408
|
withApiOptions(
|
|
3036
3409
|
withProjectOptions(
|
|
3037
3410
|
withStateOptions(
|
|
3038
3411
|
withDiffOptions(
|
|
3039
|
-
|
|
3412
|
+
yargs27.positional("directory", {
|
|
3040
3413
|
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
3414
|
type: "string"
|
|
3042
3415
|
}).option("format", {
|
|
@@ -3067,20 +3440,280 @@ var PatternPullModule = {
|
|
|
3067
3440
|
)
|
|
3068
3441
|
)
|
|
3069
3442
|
)
|
|
3070
|
-
)
|
|
3443
|
+
)
|
|
3444
|
+
};
|
|
3445
|
+
|
|
3446
|
+
// src/commands/canvas/commands/pattern/push.ts
|
|
3447
|
+
var PatternPushModule = {
|
|
3448
|
+
...CompositionPushModule,
|
|
3449
|
+
describe: "Pushes all patterns from files in a directory to Uniform Canvas",
|
|
3450
|
+
builder: (yargs27) => withConfiguration(
|
|
3451
|
+
withApiOptions(
|
|
3452
|
+
withProjectOptions(
|
|
3453
|
+
withStateOptions(
|
|
3454
|
+
withDiffOptions(
|
|
3455
|
+
yargs27.positional("directory", {
|
|
3456
|
+
describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
|
|
3457
|
+
type: "string"
|
|
3458
|
+
}).option("what-if", {
|
|
3459
|
+
alias: ["w"],
|
|
3460
|
+
describe: "What-if mode reports what would be done but changes nothing",
|
|
3461
|
+
default: false,
|
|
3462
|
+
type: "boolean"
|
|
3463
|
+
}).option("mode", {
|
|
3464
|
+
alias: ["m"],
|
|
3465
|
+
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',
|
|
3466
|
+
choices: ["create", "createOrUpdate", "mirror"],
|
|
3467
|
+
default: "mirror",
|
|
3468
|
+
type: "string"
|
|
3469
|
+
}).option("onlyPatterns", {
|
|
3470
|
+
describe: "Only pulling patterns and not compositions",
|
|
3471
|
+
// This default differentiate this list command from composition list command
|
|
3472
|
+
default: true,
|
|
3473
|
+
type: "boolean",
|
|
3474
|
+
hidden: true
|
|
3475
|
+
})
|
|
3476
|
+
)
|
|
3477
|
+
)
|
|
3478
|
+
)
|
|
3479
|
+
)
|
|
3480
|
+
)
|
|
3481
|
+
};
|
|
3482
|
+
|
|
3483
|
+
// src/commands/canvas/commands/pattern/remove.ts
|
|
3484
|
+
var PatternRemoveModule = {
|
|
3485
|
+
...CompositionRemoveModule,
|
|
3486
|
+
describe: "Delete a pattern"
|
|
3487
|
+
};
|
|
3488
|
+
|
|
3489
|
+
// src/commands/canvas/commands/pattern/unpublish.ts
|
|
3490
|
+
var PatternUnpublishModule = {
|
|
3491
|
+
command: "unpublish [ids]",
|
|
3492
|
+
describe: "Unpublish a pattern(s)",
|
|
3493
|
+
builder: (yargs27) => withConfiguration(
|
|
3494
|
+
withApiOptions(
|
|
3495
|
+
withProjectOptions(
|
|
3496
|
+
yargs27.positional("ids", {
|
|
3497
|
+
describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
|
|
3498
|
+
type: "string"
|
|
3499
|
+
}).option("all", {
|
|
3500
|
+
alias: ["a"],
|
|
3501
|
+
describe: "Un-pPublishes all compositions. Use compositionId to publish one instead.",
|
|
3502
|
+
default: false,
|
|
3503
|
+
type: "boolean"
|
|
3504
|
+
}).option("what-if", {
|
|
3505
|
+
alias: ["w"],
|
|
3506
|
+
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
3507
|
+
default: false,
|
|
3508
|
+
type: "boolean"
|
|
3509
|
+
}).option("onlyCompositions", {
|
|
3510
|
+
describe: "Only publishing compositions and not patterns",
|
|
3511
|
+
default: false,
|
|
3512
|
+
type: "boolean"
|
|
3513
|
+
}).option("onlyPatterns", {
|
|
3514
|
+
describe: "Only pulling patterns and not compositions",
|
|
3515
|
+
default: true,
|
|
3516
|
+
type: "boolean",
|
|
3517
|
+
hidden: true
|
|
3518
|
+
})
|
|
3519
|
+
)
|
|
3520
|
+
)
|
|
3521
|
+
),
|
|
3522
|
+
handler: CompositionUnpublishModule.handler
|
|
3523
|
+
};
|
|
3524
|
+
|
|
3525
|
+
// src/commands/canvas/commands/pattern/update.ts
|
|
3526
|
+
var PatternUpdateModule = {
|
|
3527
|
+
...CompositionUpdateModule,
|
|
3528
|
+
describe: "Insert or update a pattern"
|
|
3529
|
+
};
|
|
3530
|
+
|
|
3531
|
+
// src/commands/canvas/commands/pattern.ts
|
|
3532
|
+
var PatternModule = {
|
|
3533
|
+
command: "pattern <command>",
|
|
3534
|
+
describe: "Commands for Canvas patterns",
|
|
3535
|
+
builder: (yargs27) => yargs27.command(PatternPullModule).command(PatternPushModule).command(PatternGetModule).command(PatternRemoveModule).command(PatternListModule).command(PatternUpdateModule).command(PatternPublishModule).command(PatternUnpublishModule).demandCommand(),
|
|
3536
|
+
handler: () => {
|
|
3537
|
+
yargs8.help();
|
|
3538
|
+
}
|
|
3539
|
+
};
|
|
3540
|
+
|
|
3541
|
+
// src/commands/canvas/commands/prompts.ts
|
|
3542
|
+
import yargs9 from "yargs";
|
|
3543
|
+
|
|
3544
|
+
// src/commands/canvas/commands/prompts/get.ts
|
|
3545
|
+
import { PromptClient } from "@uniformdev/canvas";
|
|
3546
|
+
var PromptGetModule = {
|
|
3547
|
+
command: "get <id>",
|
|
3548
|
+
describe: "Get a prompt",
|
|
3549
|
+
builder: (yargs27) => withConfiguration(
|
|
3550
|
+
withFormatOptions(
|
|
3551
|
+
withApiOptions(
|
|
3552
|
+
withProjectOptions(
|
|
3553
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3554
|
+
yargs27.positional("id", { demandOption: true, describe: "Prompt ID to fetch" })
|
|
3555
|
+
)
|
|
3556
|
+
)
|
|
3557
|
+
)
|
|
3558
|
+
),
|
|
3559
|
+
handler: async ({ apiHost, apiKey, proxy, id, format, filename, project: projectId }) => {
|
|
3560
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
3561
|
+
const client = new PromptClient({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
3562
|
+
const res = await client.get({ promptId: id });
|
|
3563
|
+
if (!res) {
|
|
3564
|
+
throw new Error(`Prompt with ID ${id} not found`);
|
|
3565
|
+
}
|
|
3566
|
+
emitWithFormat(res, format, filename);
|
|
3567
|
+
}
|
|
3568
|
+
};
|
|
3569
|
+
|
|
3570
|
+
// src/commands/canvas/commands/prompts/list.ts
|
|
3571
|
+
import { PromptClient as PromptClient2 } from "@uniformdev/canvas";
|
|
3572
|
+
var PromptListModule = {
|
|
3573
|
+
command: "list",
|
|
3574
|
+
describe: "List prompts",
|
|
3575
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
3576
|
+
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
3577
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
3578
|
+
const client = new PromptClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
3579
|
+
const res = await client.get();
|
|
3580
|
+
emitWithFormat(res, format, filename);
|
|
3581
|
+
}
|
|
3582
|
+
};
|
|
3583
|
+
|
|
3584
|
+
// src/commands/canvas/commands/prompts/pull.ts
|
|
3585
|
+
import { PromptClient as PromptClient3 } from "@uniformdev/canvas";
|
|
3586
|
+
|
|
3587
|
+
// src/commands/canvas/commands/prompts/_util.ts
|
|
3588
|
+
var selectPromptIdentifier = (e) => e.id;
|
|
3589
|
+
var selectPromptDisplayName = (e) => `${e.name ?? "Untitled"} (pid: ${e.id})`;
|
|
3590
|
+
|
|
3591
|
+
// src/commands/canvas/promptEngineDataSource.ts
|
|
3592
|
+
function createPromptEngineDataSource({
|
|
3593
|
+
client
|
|
3594
|
+
}) {
|
|
3595
|
+
async function* getObjects() {
|
|
3596
|
+
const prompts = await client.get();
|
|
3597
|
+
for await (const prompt of prompts) {
|
|
3598
|
+
const result = {
|
|
3599
|
+
id: selectPromptIdentifier(prompt),
|
|
3600
|
+
displayName: selectPromptDisplayName(prompt),
|
|
3601
|
+
providerId: prompt.id,
|
|
3602
|
+
object: prompt
|
|
3603
|
+
};
|
|
3604
|
+
yield result;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
return {
|
|
3608
|
+
objects: getObjects(),
|
|
3609
|
+
deleteObject: async (providerId) => {
|
|
3610
|
+
await client.remove({ promptId: providerId });
|
|
3611
|
+
},
|
|
3612
|
+
writeObject: async ({ object }) => {
|
|
3613
|
+
await client.upsert({ data: object });
|
|
3614
|
+
}
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
// src/commands/canvas/commands/prompts/pull.ts
|
|
3619
|
+
var PromptPullModule = {
|
|
3620
|
+
command: "pull <directory>",
|
|
3621
|
+
describe: "Pulls all entries to local files in a directory",
|
|
3622
|
+
builder: (yargs27) => withConfiguration(
|
|
3623
|
+
withApiOptions(
|
|
3624
|
+
withProjectOptions(
|
|
3625
|
+
withStateOptions(
|
|
3626
|
+
withDiffOptions(
|
|
3627
|
+
yargs27.positional("directory", {
|
|
3628
|
+
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.",
|
|
3629
|
+
type: "string"
|
|
3630
|
+
}).option("format", {
|
|
3631
|
+
alias: ["f"],
|
|
3632
|
+
describe: "Output format",
|
|
3633
|
+
default: "yaml",
|
|
3634
|
+
choices: ["yaml", "json"],
|
|
3635
|
+
type: "string"
|
|
3636
|
+
}).option("what-if", {
|
|
3637
|
+
alias: ["w"],
|
|
3638
|
+
describe: "What-if mode reports what would be done but changes no files",
|
|
3639
|
+
default: false,
|
|
3640
|
+
type: "boolean"
|
|
3641
|
+
}).option("mode", {
|
|
3642
|
+
alias: ["m"],
|
|
3643
|
+
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',
|
|
3644
|
+
choices: ["create", "createOrUpdate", "mirror"],
|
|
3645
|
+
default: "mirror",
|
|
3646
|
+
type: "string"
|
|
3647
|
+
})
|
|
3648
|
+
)
|
|
3649
|
+
)
|
|
3650
|
+
)
|
|
3651
|
+
)
|
|
3652
|
+
),
|
|
3653
|
+
handler: async ({
|
|
3654
|
+
apiHost,
|
|
3655
|
+
apiKey,
|
|
3656
|
+
proxy,
|
|
3657
|
+
directory,
|
|
3658
|
+
format,
|
|
3659
|
+
mode,
|
|
3660
|
+
whatIf,
|
|
3661
|
+
project: projectId,
|
|
3662
|
+
diff: diffMode
|
|
3663
|
+
}) => {
|
|
3664
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
3665
|
+
const client = new PromptClient3({
|
|
3666
|
+
apiKey,
|
|
3667
|
+
apiHost,
|
|
3668
|
+
fetch: fetch3,
|
|
3669
|
+
projectId,
|
|
3670
|
+
bypassCache: true
|
|
3671
|
+
});
|
|
3672
|
+
const source = createPromptEngineDataSource({ client });
|
|
3673
|
+
let target;
|
|
3674
|
+
const isPackage = isPathAPackageFile(directory);
|
|
3675
|
+
if (isPackage) {
|
|
3676
|
+
const packageContents = readCanvasPackage(directory, false);
|
|
3677
|
+
target = await createArraySyncEngineDataSource({
|
|
3678
|
+
objects: packageContents.prompts ?? [],
|
|
3679
|
+
selectIdentifier: selectPromptIdentifier,
|
|
3680
|
+
selectDisplayName: selectPromptDisplayName,
|
|
3681
|
+
onSyncComplete: async (_, synced) => {
|
|
3682
|
+
packageContents.prompts = synced;
|
|
3683
|
+
writeCanvasPackage(directory, packageContents);
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
} else {
|
|
3687
|
+
target = await createFileSyncEngineDataSource({
|
|
3688
|
+
directory,
|
|
3689
|
+
selectIdentifier: selectPromptIdentifier,
|
|
3690
|
+
selectDisplayName: selectPromptDisplayName,
|
|
3691
|
+
format
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
await syncEngine({
|
|
3695
|
+
source,
|
|
3696
|
+
target,
|
|
3697
|
+
mode,
|
|
3698
|
+
whatIf,
|
|
3699
|
+
allowEmptySource: true,
|
|
3700
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
3701
|
+
});
|
|
3702
|
+
}
|
|
3071
3703
|
};
|
|
3072
3704
|
|
|
3073
|
-
// src/commands/canvas/commands/
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3705
|
+
// src/commands/canvas/commands/prompts/push.ts
|
|
3706
|
+
import { PromptClient as PromptClient4 } from "@uniformdev/canvas";
|
|
3707
|
+
var PromptPushModule = {
|
|
3708
|
+
command: "push <directory>",
|
|
3709
|
+
describe: "Pushes all prompts from files in a directory to Uniform",
|
|
3710
|
+
builder: (yargs27) => withConfiguration(
|
|
3078
3711
|
withApiOptions(
|
|
3079
3712
|
withProjectOptions(
|
|
3080
3713
|
withStateOptions(
|
|
3081
3714
|
withDiffOptions(
|
|
3082
|
-
|
|
3083
|
-
describe: "Directory to read the
|
|
3715
|
+
yargs27.positional("directory", {
|
|
3716
|
+
describe: "Directory to read the prompts from. If a filename is used, a package will be read instead.",
|
|
3084
3717
|
type: "string"
|
|
3085
3718
|
}).option("what-if", {
|
|
3086
3719
|
alias: ["w"],
|
|
@@ -3093,75 +3726,104 @@ var PatternPushModule = {
|
|
|
3093
3726
|
choices: ["create", "createOrUpdate", "mirror"],
|
|
3094
3727
|
default: "mirror",
|
|
3095
3728
|
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
3729
|
})
|
|
3103
3730
|
)
|
|
3104
3731
|
)
|
|
3105
3732
|
)
|
|
3106
3733
|
)
|
|
3107
|
-
)
|
|
3734
|
+
),
|
|
3735
|
+
handler: async ({
|
|
3736
|
+
apiHost,
|
|
3737
|
+
apiKey,
|
|
3738
|
+
proxy,
|
|
3739
|
+
directory,
|
|
3740
|
+
mode,
|
|
3741
|
+
whatIf,
|
|
3742
|
+
project: projectId,
|
|
3743
|
+
diff: diffMode
|
|
3744
|
+
}) => {
|
|
3745
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
3746
|
+
const client = new PromptClient4({
|
|
3747
|
+
apiKey,
|
|
3748
|
+
apiHost,
|
|
3749
|
+
fetch: fetch3,
|
|
3750
|
+
projectId,
|
|
3751
|
+
bypassCache: true
|
|
3752
|
+
});
|
|
3753
|
+
let source;
|
|
3754
|
+
const isPackage = isPathAPackageFile(directory);
|
|
3755
|
+
if (isPackage) {
|
|
3756
|
+
const packageContents = readCanvasPackage(directory, true);
|
|
3757
|
+
source = await createArraySyncEngineDataSource({
|
|
3758
|
+
objects: packageContents.prompts ?? [],
|
|
3759
|
+
selectIdentifier: selectPromptIdentifier,
|
|
3760
|
+
selectDisplayName: selectPromptDisplayName
|
|
3761
|
+
});
|
|
3762
|
+
} else {
|
|
3763
|
+
source = await createFileSyncEngineDataSource({
|
|
3764
|
+
directory,
|
|
3765
|
+
selectIdentifier: selectPromptIdentifier,
|
|
3766
|
+
selectDisplayName: selectPromptDisplayName
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
const target = createPromptEngineDataSource({ client });
|
|
3770
|
+
await syncEngine({
|
|
3771
|
+
source,
|
|
3772
|
+
target,
|
|
3773
|
+
mode,
|
|
3774
|
+
whatIf,
|
|
3775
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
3776
|
+
});
|
|
3777
|
+
}
|
|
3108
3778
|
};
|
|
3109
3779
|
|
|
3110
|
-
// src/commands/canvas/commands/
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3780
|
+
// src/commands/canvas/commands/prompts/remove.ts
|
|
3781
|
+
import { PromptClient as PromptClient5 } from "@uniformdev/canvas";
|
|
3782
|
+
var PromptRemoveModule = {
|
|
3783
|
+
command: "remove <id>",
|
|
3784
|
+
aliases: ["delete", "rm"],
|
|
3785
|
+
describe: "Delete a prompt",
|
|
3786
|
+
builder: (yargs27) => withConfiguration(
|
|
3787
|
+
withApiOptions(
|
|
3788
|
+
withProjectOptions(yargs27.positional("id", { demandOption: true, describe: "Prompt ID to delete" }))
|
|
3789
|
+
)
|
|
3790
|
+
),
|
|
3791
|
+
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
3792
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
3793
|
+
const client = new PromptClient5({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
3794
|
+
await client.remove({ promptId: id });
|
|
3795
|
+
}
|
|
3114
3796
|
};
|
|
3115
3797
|
|
|
3116
|
-
// src/commands/canvas/commands/
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3798
|
+
// src/commands/canvas/commands/prompts/update.ts
|
|
3799
|
+
import { PromptClient as PromptClient6 } from "@uniformdev/canvas";
|
|
3800
|
+
var PromptUpdateModule = {
|
|
3801
|
+
command: "update <filename>",
|
|
3802
|
+
aliases: ["put"],
|
|
3803
|
+
describe: "Insert or update a prompt",
|
|
3804
|
+
builder: (yargs27) => withConfiguration(
|
|
3121
3805
|
withApiOptions(
|
|
3122
3806
|
withProjectOptions(
|
|
3123
|
-
|
|
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
|
-
})
|
|
3807
|
+
yargs27.positional("filename", { demandOption: true, describe: "Prompt file to put" })
|
|
3146
3808
|
)
|
|
3147
3809
|
)
|
|
3148
3810
|
),
|
|
3149
|
-
handler:
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
describe: "Insert or update a pattern"
|
|
3811
|
+
handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
|
|
3812
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
3813
|
+
const client = new PromptClient6({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
3814
|
+
const file = readFileToObject(filename);
|
|
3815
|
+
await client.upsert({ data: file });
|
|
3816
|
+
}
|
|
3156
3817
|
};
|
|
3157
3818
|
|
|
3158
|
-
// src/commands/canvas/commands/
|
|
3159
|
-
var
|
|
3160
|
-
command: "
|
|
3161
|
-
|
|
3162
|
-
|
|
3819
|
+
// src/commands/canvas/commands/prompts.ts
|
|
3820
|
+
var PromptModule = {
|
|
3821
|
+
command: "prompt <command>",
|
|
3822
|
+
aliases: ["dt"],
|
|
3823
|
+
describe: "Commands for AI Prompt definitions",
|
|
3824
|
+
builder: (yargs27) => yargs27.command(PromptGetModule).command(PromptListModule).command(PromptPullModule).command(PromptPushModule).command(PromptRemoveModule).command(PromptUpdateModule).demandCommand(),
|
|
3163
3825
|
handler: () => {
|
|
3164
|
-
|
|
3826
|
+
yargs9.help();
|
|
3165
3827
|
}
|
|
3166
3828
|
};
|
|
3167
3829
|
|
|
@@ -3170,28 +3832,28 @@ var CanvasCommand = {
|
|
|
3170
3832
|
command: "canvas <command>",
|
|
3171
3833
|
aliases: ["cv", "pm", "presentation"],
|
|
3172
3834
|
describe: "Uniform Canvas commands",
|
|
3173
|
-
builder: (
|
|
3835
|
+
builder: (yargs27) => yargs27.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(CategoryModule).command(PatternModule).command(ContentTypeModule).command(EntryModule).command(PromptModule).command(AssetModule).demandCommand(),
|
|
3174
3836
|
handler: () => {
|
|
3175
|
-
|
|
3837
|
+
yargs10.showHelp();
|
|
3176
3838
|
}
|
|
3177
3839
|
};
|
|
3178
3840
|
|
|
3179
3841
|
// src/commands/context/index.ts
|
|
3180
|
-
import
|
|
3842
|
+
import yargs17 from "yargs";
|
|
3181
3843
|
|
|
3182
3844
|
// src/commands/context/commands/aggregate.ts
|
|
3183
|
-
import
|
|
3845
|
+
import yargs11 from "yargs";
|
|
3184
3846
|
|
|
3185
3847
|
// src/commands/context/commands/aggregate/get.ts
|
|
3186
3848
|
import { UncachedAggregateClient } from "@uniformdev/context/api";
|
|
3187
3849
|
var AggregateGetModule = {
|
|
3188
3850
|
command: "get <id>",
|
|
3189
3851
|
describe: "Fetch an aggregate",
|
|
3190
|
-
builder: (
|
|
3852
|
+
builder: (yargs27) => withConfiguration(
|
|
3191
3853
|
withFormatOptions(
|
|
3192
3854
|
withApiOptions(
|
|
3193
3855
|
withProjectOptions(
|
|
3194
|
-
|
|
3856
|
+
yargs27.positional("id", { demandOption: true, describe: "Aggregate public ID to fetch" })
|
|
3195
3857
|
)
|
|
3196
3858
|
)
|
|
3197
3859
|
)
|
|
@@ -3215,7 +3877,7 @@ var AggregateListModule = {
|
|
|
3215
3877
|
command: "list",
|
|
3216
3878
|
describe: "List aggregates",
|
|
3217
3879
|
aliases: ["ls"],
|
|
3218
|
-
builder: (
|
|
3880
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
3219
3881
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
3220
3882
|
const fetch3 = nodeFetchProxy(proxy);
|
|
3221
3883
|
const client = new UncachedAggregateClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -3281,11 +3943,11 @@ function writeContextPackage(filename, packageContents) {
|
|
|
3281
3943
|
var AggregatePullModule = {
|
|
3282
3944
|
command: "pull <directory>",
|
|
3283
3945
|
describe: "Pulls all aggregates to local files in a directory",
|
|
3284
|
-
builder: (
|
|
3946
|
+
builder: (yargs27) => withConfiguration(
|
|
3285
3947
|
withApiOptions(
|
|
3286
3948
|
withProjectOptions(
|
|
3287
3949
|
withDiffOptions(
|
|
3288
|
-
|
|
3950
|
+
yargs27.positional("directory", {
|
|
3289
3951
|
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
3952
|
type: "string"
|
|
3291
3953
|
}).option("format", {
|
|
@@ -3360,11 +4022,11 @@ import { UncachedAggregateClient as UncachedAggregateClient4 } from "@uniformdev
|
|
|
3360
4022
|
var AggregatePushModule = {
|
|
3361
4023
|
command: "push <directory>",
|
|
3362
4024
|
describe: "Pushes all aggregates from files in a directory or package to Uniform",
|
|
3363
|
-
builder: (
|
|
4025
|
+
builder: (yargs27) => withConfiguration(
|
|
3364
4026
|
withApiOptions(
|
|
3365
4027
|
withProjectOptions(
|
|
3366
4028
|
withDiffOptions(
|
|
3367
|
-
|
|
4029
|
+
yargs27.positional("directory", {
|
|
3368
4030
|
describe: "Directory to read the aggregates from. If a filename is used, a package will be read instead.",
|
|
3369
4031
|
type: "string"
|
|
3370
4032
|
}).option("what-if", {
|
|
@@ -3429,10 +4091,10 @@ var AggregateRemoveModule = {
|
|
|
3429
4091
|
command: "remove <id>",
|
|
3430
4092
|
aliases: ["delete", "rm"],
|
|
3431
4093
|
describe: "Delete an aggregate",
|
|
3432
|
-
builder: (
|
|
4094
|
+
builder: (yargs27) => withConfiguration(
|
|
3433
4095
|
withApiOptions(
|
|
3434
4096
|
withProjectOptions(
|
|
3435
|
-
|
|
4097
|
+
yargs27.positional("id", { demandOption: true, describe: "Aggregate public ID to delete" })
|
|
3436
4098
|
)
|
|
3437
4099
|
)
|
|
3438
4100
|
),
|
|
@@ -3449,10 +4111,10 @@ var AggregateUpdateModule = {
|
|
|
3449
4111
|
command: "update <filename>",
|
|
3450
4112
|
aliases: ["put"],
|
|
3451
4113
|
describe: "Insert or update an aggregate",
|
|
3452
|
-
builder: (
|
|
4114
|
+
builder: (yargs27) => withConfiguration(
|
|
3453
4115
|
withApiOptions(
|
|
3454
4116
|
withProjectOptions(
|
|
3455
|
-
|
|
4117
|
+
yargs27.positional("filename", { demandOption: true, describe: "Aggregate file to put" })
|
|
3456
4118
|
)
|
|
3457
4119
|
)
|
|
3458
4120
|
),
|
|
@@ -3469,25 +4131,25 @@ var AggregateModule = {
|
|
|
3469
4131
|
command: "aggregate <command>",
|
|
3470
4132
|
aliases: ["agg", "intent", "audience"],
|
|
3471
4133
|
describe: "Commands for Context aggregates (intents, audiences)",
|
|
3472
|
-
builder: (
|
|
4134
|
+
builder: (yargs27) => yargs27.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
|
|
3473
4135
|
handler: () => {
|
|
3474
|
-
|
|
4136
|
+
yargs11.help();
|
|
3475
4137
|
}
|
|
3476
4138
|
};
|
|
3477
4139
|
|
|
3478
4140
|
// src/commands/context/commands/enrichment.ts
|
|
3479
|
-
import
|
|
4141
|
+
import yargs12 from "yargs";
|
|
3480
4142
|
|
|
3481
4143
|
// src/commands/context/commands/enrichment/get.ts
|
|
3482
4144
|
import { UncachedEnrichmentClient } from "@uniformdev/context/api";
|
|
3483
4145
|
var EnrichmentGetModule = {
|
|
3484
4146
|
command: "get <id>",
|
|
3485
4147
|
describe: "Fetch an enrichment category and its values",
|
|
3486
|
-
builder: (
|
|
4148
|
+
builder: (yargs27) => withFormatOptions(
|
|
3487
4149
|
withConfiguration(
|
|
3488
4150
|
withApiOptions(
|
|
3489
4151
|
withProjectOptions(
|
|
3490
|
-
|
|
4152
|
+
yargs27.positional("id", { demandOption: true, describe: "Enrichment category public ID to fetch" })
|
|
3491
4153
|
)
|
|
3492
4154
|
)
|
|
3493
4155
|
)
|
|
@@ -3512,7 +4174,7 @@ var EnrichmentListModule = {
|
|
|
3512
4174
|
command: "list",
|
|
3513
4175
|
describe: "List enrichments",
|
|
3514
4176
|
aliases: ["ls"],
|
|
3515
|
-
builder: (
|
|
4177
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
3516
4178
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
3517
4179
|
const fetch3 = nodeFetchProxy(proxy);
|
|
3518
4180
|
const client = new UncachedEnrichmentClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -3613,11 +4275,11 @@ var createEnrichmentValueEngineDataSource = ({
|
|
|
3613
4275
|
var EnrichmentPullModule = {
|
|
3614
4276
|
command: "pull <directory>",
|
|
3615
4277
|
describe: "Pulls all enrichments to local files in a directory",
|
|
3616
|
-
builder: (
|
|
4278
|
+
builder: (yargs27) => withConfiguration(
|
|
3617
4279
|
withApiOptions(
|
|
3618
4280
|
withProjectOptions(
|
|
3619
4281
|
withDiffOptions(
|
|
3620
|
-
|
|
4282
|
+
yargs27.positional("directory", {
|
|
3621
4283
|
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
4284
|
type: "string"
|
|
3623
4285
|
}).option("format", {
|
|
@@ -3692,11 +4354,11 @@ import { UncachedEnrichmentClient as UncachedEnrichmentClient4 } from "@uniformd
|
|
|
3692
4354
|
var EnrichmentPushModule = {
|
|
3693
4355
|
command: "push <directory>",
|
|
3694
4356
|
describe: "Pushes all enrichments from files in a directory or package to Uniform",
|
|
3695
|
-
builder: (
|
|
4357
|
+
builder: (yargs27) => withConfiguration(
|
|
3696
4358
|
withApiOptions(
|
|
3697
4359
|
withProjectOptions(
|
|
3698
4360
|
withDiffOptions(
|
|
3699
|
-
|
|
4361
|
+
yargs27.positional("directory", {
|
|
3700
4362
|
describe: "Directory to read the enrichments from. If a filename is used, a package will be read instead.",
|
|
3701
4363
|
type: "string"
|
|
3702
4364
|
}).option("what-if", {
|
|
@@ -3760,10 +4422,10 @@ var EnrichmentRemoveModule = {
|
|
|
3760
4422
|
command: "remove <id>",
|
|
3761
4423
|
aliases: ["delete", "rm"],
|
|
3762
4424
|
describe: "Delete an enrichment category and its values",
|
|
3763
|
-
builder: (
|
|
4425
|
+
builder: (yargs27) => withConfiguration(
|
|
3764
4426
|
withApiOptions(
|
|
3765
4427
|
withProjectOptions(
|
|
3766
|
-
|
|
4428
|
+
yargs27.positional("id", { demandOption: true, describe: "Enrichment category public ID to delete" })
|
|
3767
4429
|
)
|
|
3768
4430
|
)
|
|
3769
4431
|
),
|
|
@@ -3779,14 +4441,14 @@ var EnrichmentModule = {
|
|
|
3779
4441
|
command: "enrichment <command>",
|
|
3780
4442
|
aliases: ["enr"],
|
|
3781
4443
|
describe: "Commands for Context enrichments",
|
|
3782
|
-
builder: (
|
|
4444
|
+
builder: (yargs27) => yargs27.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
|
|
3783
4445
|
handler: () => {
|
|
3784
|
-
|
|
4446
|
+
yargs12.help();
|
|
3785
4447
|
}
|
|
3786
4448
|
};
|
|
3787
4449
|
|
|
3788
4450
|
// src/commands/context/commands/manifest.ts
|
|
3789
|
-
import
|
|
4451
|
+
import yargs13 from "yargs";
|
|
3790
4452
|
|
|
3791
4453
|
// src/commands/context/commands/manifest/get.ts
|
|
3792
4454
|
import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
|
|
@@ -3797,10 +4459,10 @@ var ManifestGetModule = {
|
|
|
3797
4459
|
command: "get [output]",
|
|
3798
4460
|
aliases: ["dl", "download"],
|
|
3799
4461
|
describe: "Download the Uniform Context manifest for a project",
|
|
3800
|
-
builder: (
|
|
4462
|
+
builder: (yargs27) => withConfiguration(
|
|
3801
4463
|
withApiOptions(
|
|
3802
4464
|
withProjectOptions(
|
|
3803
|
-
|
|
4465
|
+
yargs27.option("preview", {
|
|
3804
4466
|
describe: "If set, fetches the unpublished preview manifest (The API key must have permission)",
|
|
3805
4467
|
default: false,
|
|
3806
4468
|
type: "boolean",
|
|
@@ -3862,7 +4524,7 @@ import { exit as exit2 } from "process";
|
|
|
3862
4524
|
var ManifestPublishModule = {
|
|
3863
4525
|
command: "publish",
|
|
3864
4526
|
describe: "Publish the Uniform Context manifest for a project",
|
|
3865
|
-
builder: (
|
|
4527
|
+
builder: (yargs27) => withConfiguration(withApiOptions(withProjectOptions(yargs27))),
|
|
3866
4528
|
handler: async ({ apiKey, apiHost, proxy, project }) => {
|
|
3867
4529
|
const fetch3 = nodeFetchProxy(proxy);
|
|
3868
4530
|
try {
|
|
@@ -3895,25 +4557,25 @@ var ManifestModule = {
|
|
|
3895
4557
|
command: "manifest <command>",
|
|
3896
4558
|
describe: "Commands for context manifests",
|
|
3897
4559
|
aliases: ["man"],
|
|
3898
|
-
builder: (
|
|
4560
|
+
builder: (yargs27) => yargs27.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
|
|
3899
4561
|
handler: () => {
|
|
3900
|
-
|
|
4562
|
+
yargs13.help();
|
|
3901
4563
|
}
|
|
3902
4564
|
};
|
|
3903
4565
|
|
|
3904
4566
|
// src/commands/context/commands/quirk.ts
|
|
3905
|
-
import
|
|
4567
|
+
import yargs14 from "yargs";
|
|
3906
4568
|
|
|
3907
4569
|
// src/commands/context/commands/quirk/get.ts
|
|
3908
4570
|
import { UncachedQuirkClient } from "@uniformdev/context/api";
|
|
3909
4571
|
var QuirkGetModule = {
|
|
3910
4572
|
command: "get <id>",
|
|
3911
4573
|
describe: "Fetch a quirk",
|
|
3912
|
-
builder: (
|
|
4574
|
+
builder: (yargs27) => withConfiguration(
|
|
3913
4575
|
withFormatOptions(
|
|
3914
4576
|
withApiOptions(
|
|
3915
4577
|
withProjectOptions(
|
|
3916
|
-
|
|
4578
|
+
yargs27.positional("id", { demandOption: true, describe: "Quirk public ID to fetch" })
|
|
3917
4579
|
)
|
|
3918
4580
|
)
|
|
3919
4581
|
)
|
|
@@ -3937,11 +4599,11 @@ var QuirkListModule = {
|
|
|
3937
4599
|
command: "list",
|
|
3938
4600
|
describe: "List quirks",
|
|
3939
4601
|
aliases: ["ls"],
|
|
3940
|
-
builder: (
|
|
4602
|
+
builder: (yargs27) => withConfiguration(
|
|
3941
4603
|
withFormatOptions(
|
|
3942
4604
|
withApiOptions(
|
|
3943
4605
|
withProjectOptions(
|
|
3944
|
-
|
|
4606
|
+
yargs27.option("withIntegrations", {
|
|
3945
4607
|
alias: ["i"],
|
|
3946
4608
|
describe: "Whether to include meta-quirks created by integrations in the list. Defaults to false.",
|
|
3947
4609
|
type: "boolean"
|
|
@@ -3998,11 +4660,11 @@ function createQuirkEngineDataSource({
|
|
|
3998
4660
|
var QuirkPullModule = {
|
|
3999
4661
|
command: "pull <directory>",
|
|
4000
4662
|
describe: "Pulls all quirks to local files in a directory",
|
|
4001
|
-
builder: (
|
|
4663
|
+
builder: (yargs27) => withConfiguration(
|
|
4002
4664
|
withApiOptions(
|
|
4003
4665
|
withProjectOptions(
|
|
4004
4666
|
withDiffOptions(
|
|
4005
|
-
|
|
4667
|
+
yargs27.positional("directory", {
|
|
4006
4668
|
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
4669
|
type: "string"
|
|
4008
4670
|
}).option("format", {
|
|
@@ -4077,11 +4739,11 @@ import { UncachedQuirkClient as UncachedQuirkClient4 } from "@uniformdev/context
|
|
|
4077
4739
|
var QuirkPushModule = {
|
|
4078
4740
|
command: "push <directory>",
|
|
4079
4741
|
describe: "Pushes all quirks from files in a directory or package to Uniform",
|
|
4080
|
-
builder: (
|
|
4742
|
+
builder: (yargs27) => withConfiguration(
|
|
4081
4743
|
withApiOptions(
|
|
4082
4744
|
withProjectOptions(
|
|
4083
4745
|
withDiffOptions(
|
|
4084
|
-
|
|
4746
|
+
yargs27.positional("directory", {
|
|
4085
4747
|
describe: "Directory to read the quirks from. If a filename is used, a package will be read instead.",
|
|
4086
4748
|
type: "string"
|
|
4087
4749
|
}).option("what-if", {
|
|
@@ -4145,10 +4807,10 @@ var QuirkRemoveModule = {
|
|
|
4145
4807
|
command: "remove <id>",
|
|
4146
4808
|
aliases: ["delete", "rm"],
|
|
4147
4809
|
describe: "Delete a quirk",
|
|
4148
|
-
builder: (
|
|
4810
|
+
builder: (yargs27) => withConfiguration(
|
|
4149
4811
|
withApiOptions(
|
|
4150
4812
|
withProjectOptions(
|
|
4151
|
-
|
|
4813
|
+
yargs27.positional("id", { demandOption: true, describe: "Quirk public ID to delete" })
|
|
4152
4814
|
)
|
|
4153
4815
|
)
|
|
4154
4816
|
),
|
|
@@ -4165,10 +4827,10 @@ var QuirkUpdateModule = {
|
|
|
4165
4827
|
command: "update <filename>",
|
|
4166
4828
|
aliases: ["put"],
|
|
4167
4829
|
describe: "Insert or update a quirk",
|
|
4168
|
-
builder: (
|
|
4830
|
+
builder: (yargs27) => withConfiguration(
|
|
4169
4831
|
withApiOptions(
|
|
4170
4832
|
withProjectOptions(
|
|
4171
|
-
|
|
4833
|
+
yargs27.positional("filename", { demandOption: true, describe: "Quirk file to put" })
|
|
4172
4834
|
)
|
|
4173
4835
|
)
|
|
4174
4836
|
),
|
|
@@ -4185,25 +4847,25 @@ var QuirkModule = {
|
|
|
4185
4847
|
command: "quirk <command>",
|
|
4186
4848
|
aliases: ["qk"],
|
|
4187
4849
|
describe: "Commands for Context quirks",
|
|
4188
|
-
builder: (
|
|
4850
|
+
builder: (yargs27) => yargs27.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
|
|
4189
4851
|
handler: () => {
|
|
4190
|
-
|
|
4852
|
+
yargs14.help();
|
|
4191
4853
|
}
|
|
4192
4854
|
};
|
|
4193
4855
|
|
|
4194
4856
|
// src/commands/context/commands/signal.ts
|
|
4195
|
-
import
|
|
4857
|
+
import yargs15 from "yargs";
|
|
4196
4858
|
|
|
4197
4859
|
// src/commands/context/commands/signal/get.ts
|
|
4198
4860
|
import { UncachedSignalClient } from "@uniformdev/context/api";
|
|
4199
4861
|
var SignalGetModule = {
|
|
4200
4862
|
command: "get <id>",
|
|
4201
4863
|
describe: "Fetch a signal",
|
|
4202
|
-
builder: (
|
|
4864
|
+
builder: (yargs27) => withConfiguration(
|
|
4203
4865
|
withFormatOptions(
|
|
4204
4866
|
withApiOptions(
|
|
4205
4867
|
withProjectOptions(
|
|
4206
|
-
|
|
4868
|
+
yargs27.positional("id", { demandOption: true, describe: "Signal public ID to fetch" })
|
|
4207
4869
|
)
|
|
4208
4870
|
)
|
|
4209
4871
|
)
|
|
@@ -4227,7 +4889,7 @@ var SignalListModule = {
|
|
|
4227
4889
|
command: "list",
|
|
4228
4890
|
describe: "List signals",
|
|
4229
4891
|
aliases: ["ls"],
|
|
4230
|
-
builder: (
|
|
4892
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
4231
4893
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
4232
4894
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4233
4895
|
const client = new UncachedSignalClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -4276,11 +4938,11 @@ function createSignalEngineDataSource({
|
|
|
4276
4938
|
var SignalPullModule = {
|
|
4277
4939
|
command: "pull <directory>",
|
|
4278
4940
|
describe: "Pulls all signals to local files in a directory",
|
|
4279
|
-
builder: (
|
|
4941
|
+
builder: (yargs27) => withConfiguration(
|
|
4280
4942
|
withApiOptions(
|
|
4281
4943
|
withProjectOptions(
|
|
4282
4944
|
withDiffOptions(
|
|
4283
|
-
|
|
4945
|
+
yargs27.positional("directory", {
|
|
4284
4946
|
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
4947
|
type: "string"
|
|
4286
4948
|
}).option("format", {
|
|
@@ -4355,11 +5017,11 @@ import { UncachedSignalClient as UncachedSignalClient4 } from "@uniformdev/conte
|
|
|
4355
5017
|
var SignalPushModule = {
|
|
4356
5018
|
command: "push <directory>",
|
|
4357
5019
|
describe: "Pushes all signals from files in a directory or package to Uniform",
|
|
4358
|
-
builder: (
|
|
5020
|
+
builder: (yargs27) => withConfiguration(
|
|
4359
5021
|
withApiOptions(
|
|
4360
5022
|
withProjectOptions(
|
|
4361
5023
|
withDiffOptions(
|
|
4362
|
-
|
|
5024
|
+
yargs27.positional("directory", {
|
|
4363
5025
|
describe: "Directory to read the signals from. If a filename is used, a package will be read instead.",
|
|
4364
5026
|
type: "string"
|
|
4365
5027
|
}).option("what-if", {
|
|
@@ -4423,10 +5085,10 @@ var SignalRemoveModule = {
|
|
|
4423
5085
|
command: "remove <id>",
|
|
4424
5086
|
aliases: ["delete", "rm"],
|
|
4425
5087
|
describe: "Delete a signal",
|
|
4426
|
-
builder: (
|
|
5088
|
+
builder: (yargs27) => withConfiguration(
|
|
4427
5089
|
withApiOptions(
|
|
4428
5090
|
withProjectOptions(
|
|
4429
|
-
|
|
5091
|
+
yargs27.positional("id", { demandOption: true, describe: "Signal public ID to delete" })
|
|
4430
5092
|
)
|
|
4431
5093
|
)
|
|
4432
5094
|
),
|
|
@@ -4443,10 +5105,10 @@ var SignalUpdateModule = {
|
|
|
4443
5105
|
command: "update <filename>",
|
|
4444
5106
|
aliases: ["put"],
|
|
4445
5107
|
describe: "Insert or update a signal",
|
|
4446
|
-
builder: (
|
|
5108
|
+
builder: (yargs27) => withConfiguration(
|
|
4447
5109
|
withApiOptions(
|
|
4448
5110
|
withProjectOptions(
|
|
4449
|
-
|
|
5111
|
+
yargs27.positional("filename", { demandOption: true, describe: "Signal file to put" })
|
|
4450
5112
|
)
|
|
4451
5113
|
)
|
|
4452
5114
|
),
|
|
@@ -4463,25 +5125,25 @@ var SignalModule = {
|
|
|
4463
5125
|
command: "signal <command>",
|
|
4464
5126
|
aliases: ["sig"],
|
|
4465
5127
|
describe: "Commands for Context signals",
|
|
4466
|
-
builder: (
|
|
5128
|
+
builder: (yargs27) => yargs27.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
|
|
4467
5129
|
handler: () => {
|
|
4468
|
-
|
|
5130
|
+
yargs15.help();
|
|
4469
5131
|
}
|
|
4470
5132
|
};
|
|
4471
5133
|
|
|
4472
5134
|
// src/commands/context/commands/test.ts
|
|
4473
|
-
import
|
|
5135
|
+
import yargs16 from "yargs";
|
|
4474
5136
|
|
|
4475
5137
|
// src/commands/context/commands/test/get.ts
|
|
4476
5138
|
import { UncachedTestClient } from "@uniformdev/context/api";
|
|
4477
5139
|
var TestGetModule = {
|
|
4478
5140
|
command: "get <id>",
|
|
4479
5141
|
describe: "Fetch a test",
|
|
4480
|
-
builder: (
|
|
5142
|
+
builder: (yargs27) => withConfiguration(
|
|
4481
5143
|
withFormatOptions(
|
|
4482
5144
|
withApiOptions(
|
|
4483
5145
|
withProjectOptions(
|
|
4484
|
-
|
|
5146
|
+
yargs27.positional("id", { demandOption: true, describe: "Test public ID to fetch" })
|
|
4485
5147
|
)
|
|
4486
5148
|
)
|
|
4487
5149
|
)
|
|
@@ -4505,7 +5167,7 @@ var TestListModule = {
|
|
|
4505
5167
|
command: "list",
|
|
4506
5168
|
describe: "List tests",
|
|
4507
5169
|
aliases: ["ls"],
|
|
4508
|
-
builder: (
|
|
5170
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
4509
5171
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
4510
5172
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4511
5173
|
const client = new UncachedTestClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -4554,11 +5216,11 @@ function createTestEngineDataSource({
|
|
|
4554
5216
|
var TestPullModule = {
|
|
4555
5217
|
command: "pull <directory>",
|
|
4556
5218
|
describe: "Pulls all tests to local files in a directory",
|
|
4557
|
-
builder: (
|
|
5219
|
+
builder: (yargs27) => withConfiguration(
|
|
4558
5220
|
withApiOptions(
|
|
4559
5221
|
withProjectOptions(
|
|
4560
5222
|
withDiffOptions(
|
|
4561
|
-
|
|
5223
|
+
yargs27.positional("directory", {
|
|
4562
5224
|
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
5225
|
type: "string"
|
|
4564
5226
|
}).option("format", {
|
|
@@ -4633,11 +5295,11 @@ import { UncachedTestClient as UncachedTestClient4 } from "@uniformdev/context/a
|
|
|
4633
5295
|
var TestPushModule = {
|
|
4634
5296
|
command: "push <directory>",
|
|
4635
5297
|
describe: "Pushes all tests from files in a directory or package to Uniform",
|
|
4636
|
-
builder: (
|
|
5298
|
+
builder: (yargs27) => withConfiguration(
|
|
4637
5299
|
withApiOptions(
|
|
4638
5300
|
withProjectOptions(
|
|
4639
5301
|
withDiffOptions(
|
|
4640
|
-
|
|
5302
|
+
yargs27.positional("directory", {
|
|
4641
5303
|
describe: "Directory to read the tests from. If a filename is used, a package will be read instead.",
|
|
4642
5304
|
type: "string"
|
|
4643
5305
|
}).option("what-if", {
|
|
@@ -4701,10 +5363,10 @@ var TestRemoveModule = {
|
|
|
4701
5363
|
command: "remove <id>",
|
|
4702
5364
|
aliases: ["delete", "rm"],
|
|
4703
5365
|
describe: "Delete a test",
|
|
4704
|
-
builder: (
|
|
5366
|
+
builder: (yargs27) => withConfiguration(
|
|
4705
5367
|
withApiOptions(
|
|
4706
5368
|
withProjectOptions(
|
|
4707
|
-
|
|
5369
|
+
yargs27.positional("id", { demandOption: true, describe: "Test public ID to delete" })
|
|
4708
5370
|
)
|
|
4709
5371
|
)
|
|
4710
5372
|
),
|
|
@@ -4721,9 +5383,9 @@ var TestUpdateModule = {
|
|
|
4721
5383
|
command: "update <filename>",
|
|
4722
5384
|
aliases: ["put"],
|
|
4723
5385
|
describe: "Insert or update a test",
|
|
4724
|
-
builder: (
|
|
5386
|
+
builder: (yargs27) => withConfiguration(
|
|
4725
5387
|
withApiOptions(
|
|
4726
|
-
withProjectOptions(
|
|
5388
|
+
withProjectOptions(yargs27.positional("filename", { demandOption: true, describe: "Test file to put" }))
|
|
4727
5389
|
)
|
|
4728
5390
|
),
|
|
4729
5391
|
handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
|
|
@@ -4738,9 +5400,9 @@ var TestUpdateModule = {
|
|
|
4738
5400
|
var TestModule = {
|
|
4739
5401
|
command: "test <command>",
|
|
4740
5402
|
describe: "Commands for Context A/B tests",
|
|
4741
|
-
builder: (
|
|
5403
|
+
builder: (yargs27) => yargs27.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
|
|
4742
5404
|
handler: () => {
|
|
4743
|
-
|
|
5405
|
+
yargs16.help();
|
|
4744
5406
|
}
|
|
4745
5407
|
};
|
|
4746
5408
|
|
|
@@ -4749,9 +5411,9 @@ var ContextCommand = {
|
|
|
4749
5411
|
command: "context <command>",
|
|
4750
5412
|
aliases: ["ctx"],
|
|
4751
5413
|
describe: "Uniform Context commands",
|
|
4752
|
-
builder: (
|
|
5414
|
+
builder: (yargs27) => yargs27.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
|
|
4753
5415
|
handler: () => {
|
|
4754
|
-
|
|
5416
|
+
yargs17.showHelp();
|
|
4755
5417
|
}
|
|
4756
5418
|
};
|
|
4757
5419
|
|
|
@@ -4779,7 +5441,7 @@ import { PostHog } from "posthog-node";
|
|
|
4779
5441
|
// package.json
|
|
4780
5442
|
var package_default = {
|
|
4781
5443
|
name: "@uniformdev/cli",
|
|
4782
|
-
version: "19.
|
|
5444
|
+
version: "19.75.1",
|
|
4783
5445
|
description: "Uniform command line interface tool",
|
|
4784
5446
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
4785
5447
|
main: "./cli.js",
|
|
@@ -4796,11 +5458,13 @@ var package_default = {
|
|
|
4796
5458
|
},
|
|
4797
5459
|
dependencies: {
|
|
4798
5460
|
"@thi.ng/mime": "^2.2.23",
|
|
5461
|
+
"@uniformdev/assets": "workspace:*",
|
|
4799
5462
|
"@uniformdev/canvas": "workspace:*",
|
|
4800
5463
|
"@uniformdev/context": "workspace:*",
|
|
4801
5464
|
"@uniformdev/files": "workspace:*",
|
|
4802
5465
|
"@uniformdev/project-map": "workspace:*",
|
|
4803
5466
|
"@uniformdev/redirect": "workspace:*",
|
|
5467
|
+
"call-bind": "^1.0.2",
|
|
4804
5468
|
colorette: "2.0.20",
|
|
4805
5469
|
cosmiconfig: "8.3.6",
|
|
4806
5470
|
"cosmiconfig-typescript-loader": "5.0.0",
|
|
@@ -4821,11 +5485,12 @@ var package_default = {
|
|
|
4821
5485
|
open: "9.1.0",
|
|
4822
5486
|
ora: "7.0.1",
|
|
4823
5487
|
"p-queue": "7.3.4",
|
|
4824
|
-
"posthog-node": "3.1.
|
|
5488
|
+
"posthog-node": "3.1.3",
|
|
5489
|
+
"registry-auth-token": "^5.0.0",
|
|
5490
|
+
"registry-url": "^6.0.0",
|
|
4825
5491
|
slugify: "1.6.6",
|
|
4826
|
-
"update-check": "^1.5.4",
|
|
4827
5492
|
yargs: "^17.6.2",
|
|
4828
|
-
zod: "3.22.
|
|
5493
|
+
zod: "3.22.4"
|
|
4829
5494
|
},
|
|
4830
5495
|
devDependencies: {
|
|
4831
5496
|
"@types/diff": "5.0.5",
|
|
@@ -5497,24 +6162,6 @@ async function newHandler({
|
|
|
5497
6162
|
previewPath: "/api/preview?secret=hello-world",
|
|
5498
6163
|
installEnv: []
|
|
5499
6164
|
}
|
|
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
6165
|
}
|
|
5519
6166
|
},
|
|
5520
6167
|
nuxt: {
|
|
@@ -5526,15 +6173,6 @@ async function newHandler({
|
|
|
5526
6173
|
previewPath: "/?preview=true",
|
|
5527
6174
|
installEnv: [["NUXT_TELEMETRY_DISABLED", "1"]]
|
|
5528
6175
|
}
|
|
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
6176
|
}
|
|
5539
6177
|
}
|
|
5540
6178
|
};
|
|
@@ -5577,16 +6215,6 @@ async function newHandler({
|
|
|
5577
6215
|
] : []
|
|
5578
6216
|
).map(([name, value]) => `${name}='${value}'`).join("\n") + "\n";
|
|
5579
6217
|
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
6218
|
const cloneStartTimestamp = Date.now();
|
|
5591
6219
|
const { runNpmInstall } = await cloneStarter({
|
|
5592
6220
|
githubPath: githubUri,
|
|
@@ -5823,10 +6451,10 @@ var NewMeshCmd = {
|
|
|
5823
6451
|
};
|
|
5824
6452
|
|
|
5825
6453
|
// src/commands/optimize/index.ts
|
|
5826
|
-
import
|
|
6454
|
+
import yargs19 from "yargs";
|
|
5827
6455
|
|
|
5828
6456
|
// src/commands/optimize/manifest.ts
|
|
5829
|
-
import
|
|
6457
|
+
import yargs18 from "yargs";
|
|
5830
6458
|
|
|
5831
6459
|
// src/commands/optimize/manifest/download.ts
|
|
5832
6460
|
import { gray as gray4, green as green3, red as red5, yellow as yellow2 } from "colorette";
|
|
@@ -5841,7 +6469,7 @@ var UniformBaseUrl = "https://uniform.app";
|
|
|
5841
6469
|
var module = {
|
|
5842
6470
|
command: "download [output]",
|
|
5843
6471
|
describe: "Download intent manifest",
|
|
5844
|
-
builder: (
|
|
6472
|
+
builder: (yargs27) => yargs27.option("apiKey", {
|
|
5845
6473
|
alias: "k",
|
|
5846
6474
|
demandOption: true,
|
|
5847
6475
|
string: true,
|
|
@@ -5942,10 +6570,10 @@ var module2 = {
|
|
|
5942
6570
|
command: "manifest <command>",
|
|
5943
6571
|
describe: "Intent manifest commands",
|
|
5944
6572
|
builder: () => {
|
|
5945
|
-
return
|
|
6573
|
+
return yargs18.command(download_default);
|
|
5946
6574
|
},
|
|
5947
6575
|
handler: () => {
|
|
5948
|
-
|
|
6576
|
+
yargs18.showHelp();
|
|
5949
6577
|
}
|
|
5950
6578
|
};
|
|
5951
6579
|
var manifest_default = module2;
|
|
@@ -5956,29 +6584,29 @@ var OptimizeCommand = {
|
|
|
5956
6584
|
aliases: ["opt"],
|
|
5957
6585
|
describe: "Uniform Optimize commands",
|
|
5958
6586
|
builder: () => {
|
|
5959
|
-
return
|
|
6587
|
+
return yargs19.command(manifest_default);
|
|
5960
6588
|
},
|
|
5961
6589
|
handler: () => {
|
|
5962
|
-
|
|
6590
|
+
yargs19.showHelp();
|
|
5963
6591
|
}
|
|
5964
6592
|
};
|
|
5965
6593
|
|
|
5966
6594
|
// src/commands/project-map/index.ts
|
|
5967
|
-
import
|
|
6595
|
+
import yargs22 from "yargs";
|
|
5968
6596
|
|
|
5969
6597
|
// src/commands/project-map/commands/projectMapDefinition.ts
|
|
5970
|
-
import
|
|
6598
|
+
import yargs20 from "yargs";
|
|
5971
6599
|
|
|
5972
6600
|
// src/commands/project-map/commands/ProjectMapDefinition/get.ts
|
|
5973
6601
|
import { UncachedProjectMapClient } from "@uniformdev/project-map";
|
|
5974
6602
|
var ProjectMapDefinitionGetModule = {
|
|
5975
6603
|
command: "get <id>",
|
|
5976
6604
|
describe: "Fetch a project map",
|
|
5977
|
-
builder: (
|
|
6605
|
+
builder: (yargs27) => withFormatOptions(
|
|
5978
6606
|
withConfiguration(
|
|
5979
6607
|
withApiOptions(
|
|
5980
6608
|
withProjectOptions(
|
|
5981
|
-
|
|
6609
|
+
yargs27.positional("id", { demandOption: true, describe: "ProjectMap UUID to fetch" })
|
|
5982
6610
|
)
|
|
5983
6611
|
)
|
|
5984
6612
|
)
|
|
@@ -6002,7 +6630,7 @@ var ProjectMapDefinitionListModule = {
|
|
|
6002
6630
|
command: "list",
|
|
6003
6631
|
describe: "List of project maps",
|
|
6004
6632
|
aliases: ["ls"],
|
|
6005
|
-
builder: (
|
|
6633
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
6006
6634
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
6007
6635
|
const fetch3 = nodeFetchProxy(proxy);
|
|
6008
6636
|
const client = new UncachedProjectMapClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -6059,11 +6687,11 @@ function createProjectMapDefinitionEngineDataSource({
|
|
|
6059
6687
|
var ProjectMapDefinitionPullModule = {
|
|
6060
6688
|
command: "pull <directory>",
|
|
6061
6689
|
describe: "Pulls all project maps to local files in a directory",
|
|
6062
|
-
builder: (
|
|
6690
|
+
builder: (yargs27) => withConfiguration(
|
|
6063
6691
|
withApiOptions(
|
|
6064
6692
|
withProjectOptions(
|
|
6065
6693
|
withDiffOptions(
|
|
6066
|
-
|
|
6694
|
+
yargs27.positional("directory", {
|
|
6067
6695
|
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
6696
|
type: "string"
|
|
6069
6697
|
}).option("format", {
|
|
@@ -6128,6 +6756,7 @@ var ProjectMapDefinitionPullModule = {
|
|
|
6128
6756
|
target,
|
|
6129
6757
|
mode,
|
|
6130
6758
|
whatIf,
|
|
6759
|
+
allowEmptySource: true,
|
|
6131
6760
|
log: createSyncEngineConsoleLogger({ diffMode })
|
|
6132
6761
|
});
|
|
6133
6762
|
}
|
|
@@ -6138,11 +6767,11 @@ import { UncachedProjectMapClient as UncachedProjectMapClient4 } from "@uniformd
|
|
|
6138
6767
|
var ProjectMapDefinitionPushModule = {
|
|
6139
6768
|
command: "push <directory>",
|
|
6140
6769
|
describe: "Pushes all project maps from files in a directory or package to Uniform",
|
|
6141
|
-
builder: (
|
|
6770
|
+
builder: (yargs27) => withConfiguration(
|
|
6142
6771
|
withApiOptions(
|
|
6143
6772
|
withProjectOptions(
|
|
6144
6773
|
withDiffOptions(
|
|
6145
|
-
|
|
6774
|
+
yargs27.positional("directory", {
|
|
6146
6775
|
describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
|
|
6147
6776
|
type: "string"
|
|
6148
6777
|
}).option("what-if", {
|
|
@@ -6206,9 +6835,9 @@ var ProjectMapDefinitionRemoveModule = {
|
|
|
6206
6835
|
command: "remove <id>",
|
|
6207
6836
|
aliases: ["delete", "rm"],
|
|
6208
6837
|
describe: "Delete a project map",
|
|
6209
|
-
builder: (
|
|
6838
|
+
builder: (yargs27) => withConfiguration(
|
|
6210
6839
|
withApiOptions(
|
|
6211
|
-
withProjectOptions(
|
|
6840
|
+
withProjectOptions(yargs27.positional("id", { demandOption: true, describe: " UUID to delete" }))
|
|
6212
6841
|
)
|
|
6213
6842
|
),
|
|
6214
6843
|
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
@@ -6224,10 +6853,10 @@ var ProjectMapDefinitionUpdateModule = {
|
|
|
6224
6853
|
command: "update <filename>",
|
|
6225
6854
|
aliases: ["put"],
|
|
6226
6855
|
describe: "Insert or update a project map",
|
|
6227
|
-
builder: (
|
|
6856
|
+
builder: (yargs27) => withConfiguration(
|
|
6228
6857
|
withApiOptions(
|
|
6229
6858
|
withProjectOptions(
|
|
6230
|
-
|
|
6859
|
+
yargs27.positional("filename", { demandOption: true, describe: "Project map file to put" })
|
|
6231
6860
|
)
|
|
6232
6861
|
)
|
|
6233
6862
|
),
|
|
@@ -6243,25 +6872,25 @@ var ProjectMapDefinitionUpdateModule = {
|
|
|
6243
6872
|
var ProjectMapDefinitionModule = {
|
|
6244
6873
|
command: "definition <command>",
|
|
6245
6874
|
describe: "Commands for ProjectMap Definitions",
|
|
6246
|
-
builder: (
|
|
6875
|
+
builder: (yargs27) => yargs27.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
|
|
6247
6876
|
handler: () => {
|
|
6248
|
-
|
|
6877
|
+
yargs20.help();
|
|
6249
6878
|
}
|
|
6250
6879
|
};
|
|
6251
6880
|
|
|
6252
6881
|
// src/commands/project-map/commands/projectMapNode.ts
|
|
6253
|
-
import
|
|
6882
|
+
import yargs21 from "yargs";
|
|
6254
6883
|
|
|
6255
6884
|
// src/commands/project-map/commands/ProjectMapNode/get.ts
|
|
6256
6885
|
import { UncachedProjectMapClient as UncachedProjectMapClient7 } from "@uniformdev/project-map";
|
|
6257
6886
|
var ProjectMapNodeGetModule = {
|
|
6258
6887
|
command: "get <id> <projectMapId>",
|
|
6259
6888
|
describe: "Fetch a project map node",
|
|
6260
|
-
builder: (
|
|
6889
|
+
builder: (yargs27) => withConfiguration(
|
|
6261
6890
|
withFormatOptions(
|
|
6262
6891
|
withApiOptions(
|
|
6263
6892
|
withProjectOptions(
|
|
6264
|
-
|
|
6893
|
+
yargs27.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to fetch" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
|
|
6265
6894
|
)
|
|
6266
6895
|
)
|
|
6267
6896
|
)
|
|
@@ -6287,11 +6916,11 @@ var ProjectMapNodeListModule = {
|
|
|
6287
6916
|
command: "list <projectMapId>",
|
|
6288
6917
|
describe: "List project map nodes",
|
|
6289
6918
|
aliases: ["ls"],
|
|
6290
|
-
builder: (
|
|
6919
|
+
builder: (yargs27) => withConfiguration(
|
|
6291
6920
|
withFormatOptions(
|
|
6292
6921
|
withApiOptions(
|
|
6293
6922
|
withProjectOptions(
|
|
6294
|
-
|
|
6923
|
+
yargs27.positional("projectMapId", {
|
|
6295
6924
|
demandOption: true,
|
|
6296
6925
|
describe: "ProjectMap UUID to fetch from"
|
|
6297
6926
|
})
|
|
@@ -6362,11 +6991,11 @@ function createProjectMapNodeEngineDataSource({
|
|
|
6362
6991
|
var ProjectMapNodePullModule = {
|
|
6363
6992
|
command: "pull <directory>",
|
|
6364
6993
|
describe: "Pulls all project maps nodes to local files in a directory",
|
|
6365
|
-
builder: (
|
|
6994
|
+
builder: (yargs27) => withConfiguration(
|
|
6366
6995
|
withApiOptions(
|
|
6367
6996
|
withProjectOptions(
|
|
6368
6997
|
withDiffOptions(
|
|
6369
|
-
|
|
6998
|
+
yargs27.positional("directory", {
|
|
6370
6999
|
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
7000
|
type: "string"
|
|
6372
7001
|
}).option("format", {
|
|
@@ -6435,6 +7064,7 @@ var ProjectMapNodePullModule = {
|
|
|
6435
7064
|
target,
|
|
6436
7065
|
mode,
|
|
6437
7066
|
whatIf,
|
|
7067
|
+
allowEmptySource: true,
|
|
6438
7068
|
log: createSyncEngineConsoleLogger({ diffMode })
|
|
6439
7069
|
});
|
|
6440
7070
|
}
|
|
@@ -6445,11 +7075,11 @@ import { UncachedProjectMapClient as UncachedProjectMapClient10 } from "@uniform
|
|
|
6445
7075
|
var ProjectMapNodePushModule = {
|
|
6446
7076
|
command: "push <directory>",
|
|
6447
7077
|
describe: "Pushes all project maps nodes from files in a directory or package to Uniform",
|
|
6448
|
-
builder: (
|
|
7078
|
+
builder: (yargs27) => withConfiguration(
|
|
6449
7079
|
withApiOptions(
|
|
6450
7080
|
withProjectOptions(
|
|
6451
7081
|
withDiffOptions(
|
|
6452
|
-
|
|
7082
|
+
yargs27.positional("directory", {
|
|
6453
7083
|
describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
|
|
6454
7084
|
type: "string"
|
|
6455
7085
|
}).option("what-if", {
|
|
@@ -6522,10 +7152,10 @@ var ProjectMapNodeRemoveModule = {
|
|
|
6522
7152
|
command: "remove <id> <projectMapId>",
|
|
6523
7153
|
aliases: ["delete", "rm"],
|
|
6524
7154
|
describe: "Delete a project map node",
|
|
6525
|
-
builder: (
|
|
7155
|
+
builder: (yargs27) => withConfiguration(
|
|
6526
7156
|
withApiOptions(
|
|
6527
7157
|
withProjectOptions(
|
|
6528
|
-
|
|
7158
|
+
yargs27.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to delete" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to delete from" })
|
|
6529
7159
|
)
|
|
6530
7160
|
)
|
|
6531
7161
|
),
|
|
@@ -6542,10 +7172,10 @@ var ProjectMapNodeUpdateModule = {
|
|
|
6542
7172
|
command: "update <filename> <projectMapId>",
|
|
6543
7173
|
aliases: ["put"],
|
|
6544
7174
|
describe: "Insert or update a project map node",
|
|
6545
|
-
builder: (
|
|
7175
|
+
builder: (yargs27) => withConfiguration(
|
|
6546
7176
|
withApiOptions(
|
|
6547
7177
|
withProjectOptions(
|
|
6548
|
-
|
|
7178
|
+
yargs27.positional("filename", { demandOption: true, describe: "ProjectMap node file with nodes data" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to put into" })
|
|
6549
7179
|
)
|
|
6550
7180
|
)
|
|
6551
7181
|
),
|
|
@@ -6561,9 +7191,9 @@ var ProjectMapNodeUpdateModule = {
|
|
|
6561
7191
|
var ProjectMapNodeModule = {
|
|
6562
7192
|
command: "node <command>",
|
|
6563
7193
|
describe: "Commands for ProjectMap Nodes",
|
|
6564
|
-
builder: (
|
|
7194
|
+
builder: (yargs27) => yargs27.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
|
|
6565
7195
|
handler: () => {
|
|
6566
|
-
|
|
7196
|
+
yargs21.help();
|
|
6567
7197
|
}
|
|
6568
7198
|
};
|
|
6569
7199
|
|
|
@@ -6572,28 +7202,28 @@ var ProjectMapCommand = {
|
|
|
6572
7202
|
command: "project-map <command>",
|
|
6573
7203
|
aliases: ["prm"],
|
|
6574
7204
|
describe: "Uniform ProjectMap commands",
|
|
6575
|
-
builder: (
|
|
7205
|
+
builder: (yargs27) => yargs27.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
|
|
6576
7206
|
handler: () => {
|
|
6577
|
-
|
|
7207
|
+
yargs22.showHelp();
|
|
6578
7208
|
}
|
|
6579
7209
|
};
|
|
6580
7210
|
|
|
6581
7211
|
// src/commands/redirect/index.ts
|
|
6582
|
-
import
|
|
7212
|
+
import yargs24 from "yargs";
|
|
6583
7213
|
|
|
6584
7214
|
// src/commands/redirect/commands/redirect.ts
|
|
6585
|
-
import
|
|
7215
|
+
import yargs23 from "yargs";
|
|
6586
7216
|
|
|
6587
7217
|
// src/commands/redirect/commands/RedirectDefinition/get.ts
|
|
6588
7218
|
import { UncachedRedirectClient } from "@uniformdev/redirect";
|
|
6589
7219
|
var RedirectDefinitionGetModule = {
|
|
6590
7220
|
command: "get <id>",
|
|
6591
7221
|
describe: "Fetch a redirect",
|
|
6592
|
-
builder: (
|
|
7222
|
+
builder: (yargs27) => withConfiguration(
|
|
6593
7223
|
withFormatOptions(
|
|
6594
7224
|
withApiOptions(
|
|
6595
7225
|
withProjectOptions(
|
|
6596
|
-
|
|
7226
|
+
yargs27.positional("id", { demandOption: true, describe: "Redirect UUID to fetch" })
|
|
6597
7227
|
)
|
|
6598
7228
|
)
|
|
6599
7229
|
)
|
|
@@ -6617,7 +7247,7 @@ var RedirectDefinitionListModule = {
|
|
|
6617
7247
|
command: "list",
|
|
6618
7248
|
describe: "List of redirects",
|
|
6619
7249
|
aliases: ["ls"],
|
|
6620
|
-
builder: (
|
|
7250
|
+
builder: (yargs27) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs27)))),
|
|
6621
7251
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
6622
7252
|
const fetch3 = nodeFetchProxy(proxy);
|
|
6623
7253
|
const client = new UncachedRedirectClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -6683,11 +7313,11 @@ function createRedirectDefinitionEngineDataSource({
|
|
|
6683
7313
|
var RedirectDefinitionPullModule = {
|
|
6684
7314
|
command: "pull <directory>",
|
|
6685
7315
|
describe: "Pulls all redirects to local files in a directory",
|
|
6686
|
-
builder: (
|
|
7316
|
+
builder: (yargs27) => withConfiguration(
|
|
6687
7317
|
withApiOptions(
|
|
6688
7318
|
withProjectOptions(
|
|
6689
7319
|
withDiffOptions(
|
|
6690
|
-
|
|
7320
|
+
yargs27.positional("directory", {
|
|
6691
7321
|
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
7322
|
type: "string"
|
|
6693
7323
|
}).option("format", {
|
|
@@ -6753,6 +7383,7 @@ var RedirectDefinitionPullModule = {
|
|
|
6753
7383
|
target,
|
|
6754
7384
|
mode,
|
|
6755
7385
|
whatIf,
|
|
7386
|
+
allowEmptySource: true,
|
|
6756
7387
|
log: createSyncEngineConsoleLogger({ diffMode })
|
|
6757
7388
|
});
|
|
6758
7389
|
}
|
|
@@ -6763,11 +7394,11 @@ import { UncachedRedirectClient as UncachedRedirectClient4 } from "@uniformdev/r
|
|
|
6763
7394
|
var RedirectDefinitionPushModule = {
|
|
6764
7395
|
command: "push <directory>",
|
|
6765
7396
|
describe: "Pushes all redirects from files in a directory or package to Uniform",
|
|
6766
|
-
builder: (
|
|
7397
|
+
builder: (yargs27) => withConfiguration(
|
|
6767
7398
|
withApiOptions(
|
|
6768
7399
|
withProjectOptions(
|
|
6769
7400
|
withDiffOptions(
|
|
6770
|
-
|
|
7401
|
+
yargs27.positional("directory", {
|
|
6771
7402
|
describe: "Directory to read redirects from. If a filename is used, a package will be read instead.",
|
|
6772
7403
|
type: "string"
|
|
6773
7404
|
}).option("what-if", {
|
|
@@ -6831,9 +7462,9 @@ var RedirectDefinitionRemoveModule = {
|
|
|
6831
7462
|
command: "remove <id>",
|
|
6832
7463
|
aliases: ["delete", "rm"],
|
|
6833
7464
|
describe: "Delete a redirect",
|
|
6834
|
-
builder: (
|
|
7465
|
+
builder: (yargs27) => withConfiguration(
|
|
6835
7466
|
withApiOptions(
|
|
6836
|
-
withProjectOptions(
|
|
7467
|
+
withProjectOptions(yargs27.positional("id", { demandOption: true, describe: " UUID to delete" }))
|
|
6837
7468
|
)
|
|
6838
7469
|
),
|
|
6839
7470
|
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
@@ -6849,10 +7480,10 @@ var RedirectDefinitionUpdateModule = {
|
|
|
6849
7480
|
command: "update <filename>",
|
|
6850
7481
|
aliases: ["put"],
|
|
6851
7482
|
describe: "Insert or update a redirect",
|
|
6852
|
-
builder: (
|
|
7483
|
+
builder: (yargs27) => withConfiguration(
|
|
6853
7484
|
withApiOptions(
|
|
6854
7485
|
withProjectOptions(
|
|
6855
|
-
|
|
7486
|
+
yargs27.positional("filename", { demandOption: true, describe: "Redirect file to put" })
|
|
6856
7487
|
)
|
|
6857
7488
|
)
|
|
6858
7489
|
),
|
|
@@ -6868,9 +7499,9 @@ var RedirectDefinitionUpdateModule = {
|
|
|
6868
7499
|
var RedirectDefinitionModule = {
|
|
6869
7500
|
command: "definition <command>",
|
|
6870
7501
|
describe: "Commands for Redirect Definitions",
|
|
6871
|
-
builder: (
|
|
7502
|
+
builder: (yargs27) => yargs27.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
|
|
6872
7503
|
handler: () => {
|
|
6873
|
-
|
|
7504
|
+
yargs23.help();
|
|
6874
7505
|
}
|
|
6875
7506
|
};
|
|
6876
7507
|
|
|
@@ -6879,14 +7510,14 @@ var RedirectCommand = {
|
|
|
6879
7510
|
command: "redirect <command>",
|
|
6880
7511
|
aliases: ["red"],
|
|
6881
7512
|
describe: "Uniform Redirect commands",
|
|
6882
|
-
builder: (
|
|
7513
|
+
builder: (yargs27) => yargs27.command(RedirectDefinitionModule).demandCommand(),
|
|
6883
7514
|
handler: () => {
|
|
6884
|
-
|
|
7515
|
+
yargs24.showHelp();
|
|
6885
7516
|
}
|
|
6886
7517
|
};
|
|
6887
7518
|
|
|
6888
7519
|
// src/commands/sync/index.ts
|
|
6889
|
-
import
|
|
7520
|
+
import yargs25 from "yargs";
|
|
6890
7521
|
|
|
6891
7522
|
// src/commands/sync/commands/util.ts
|
|
6892
7523
|
import ora2 from "ora";
|
|
@@ -6917,11 +7548,11 @@ function spin(entityType) {
|
|
|
6917
7548
|
var SyncPullModule = {
|
|
6918
7549
|
command: "pull",
|
|
6919
7550
|
describe: "Pulls whole project to local files in a directory",
|
|
6920
|
-
builder: (
|
|
7551
|
+
builder: (yargs27) => withConfiguration(
|
|
6921
7552
|
withApiOptions(
|
|
6922
7553
|
withProjectOptions(
|
|
6923
7554
|
withDiffOptions(
|
|
6924
|
-
|
|
7555
|
+
yargs27.option("what-if", {
|
|
6925
7556
|
alias: ["w"],
|
|
6926
7557
|
describe: "What-if mode reports what would be done but changes no files",
|
|
6927
7558
|
default: false,
|
|
@@ -6936,6 +7567,7 @@ var SyncPullModule = {
|
|
|
6936
7567
|
const enabledEntities = Object.entries({
|
|
6937
7568
|
category: CategoryPullModule,
|
|
6938
7569
|
dataType: DataTypePullModule,
|
|
7570
|
+
prompt: PromptPullModule,
|
|
6939
7571
|
quirk: QuirkPullModule,
|
|
6940
7572
|
test: TestPullModule,
|
|
6941
7573
|
signal: SignalPullModule,
|
|
@@ -6948,7 +7580,8 @@ var SyncPullModule = {
|
|
|
6948
7580
|
projectMapNode: ProjectMapNodePullModule,
|
|
6949
7581
|
redirect: RedirectDefinitionPullModule,
|
|
6950
7582
|
entry: EntryPullModule,
|
|
6951
|
-
contentType: ContentTypePullModule
|
|
7583
|
+
contentType: ContentTypePullModule,
|
|
7584
|
+
asset: AssetPullModule
|
|
6952
7585
|
}).filter(([entityType]) => {
|
|
6953
7586
|
var _a, _b, _c, _d, _e, _f;
|
|
6954
7587
|
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 +7639,11 @@ var getFormat = (entityType, config2) => {
|
|
|
7006
7639
|
var SyncPushModule = {
|
|
7007
7640
|
command: "push",
|
|
7008
7641
|
describe: "Pushes whole project data from files in a directory or package to Uniform",
|
|
7009
|
-
builder: (
|
|
7642
|
+
builder: (yargs27) => withConfiguration(
|
|
7010
7643
|
withApiOptions(
|
|
7011
7644
|
withProjectOptions(
|
|
7012
7645
|
withDiffOptions(
|
|
7013
|
-
|
|
7646
|
+
yargs27.option("what-if", {
|
|
7014
7647
|
alias: ["w"],
|
|
7015
7648
|
describe: "What-if mode reports what would be done but changes nothing",
|
|
7016
7649
|
default: false,
|
|
@@ -7026,6 +7659,7 @@ var SyncPushModule = {
|
|
|
7026
7659
|
const enabledEntities = Object.entries({
|
|
7027
7660
|
category: CategoryPushModule,
|
|
7028
7661
|
dataType: DataTypePushModule,
|
|
7662
|
+
prompt: PromptPushModule,
|
|
7029
7663
|
quirk: QuirkPushModule,
|
|
7030
7664
|
test: TestPushModule,
|
|
7031
7665
|
signal: SignalPushModule,
|
|
@@ -7038,7 +7672,8 @@ var SyncPushModule = {
|
|
|
7038
7672
|
projectMapNode: ProjectMapNodePushModule,
|
|
7039
7673
|
redirect: RedirectDefinitionPushModule,
|
|
7040
7674
|
contentType: ContentTypePushModule,
|
|
7041
|
-
entry: EntryPushModule
|
|
7675
|
+
entry: EntryPushModule,
|
|
7676
|
+
asset: AssetPushModule
|
|
7042
7677
|
}).filter(([entityType]) => {
|
|
7043
7678
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
7044
7679
|
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 +7737,14 @@ var getFormat2 = (entityType, config2) => {
|
|
|
7102
7737
|
var SyncCommand = {
|
|
7103
7738
|
command: "sync <command>",
|
|
7104
7739
|
describe: "Uniform Sync commands",
|
|
7105
|
-
builder: (
|
|
7740
|
+
builder: (yargs27) => yargs27.command(SyncPullModule).command(SyncPushModule).demandCommand(),
|
|
7106
7741
|
handler: () => {
|
|
7107
|
-
|
|
7742
|
+
yargs25.showHelp();
|
|
7108
7743
|
}
|
|
7109
7744
|
};
|
|
7110
7745
|
|
|
7111
7746
|
// src/middleware/checkForUpdateMiddleware.ts
|
|
7112
7747
|
import { bold, gray as gray5, green as green4 } from "colorette";
|
|
7113
|
-
import updateCheck from "update-check";
|
|
7114
7748
|
|
|
7115
7749
|
// src/log.ts
|
|
7116
7750
|
import { reset } from "colorette";
|
|
@@ -7131,13 +7765,164 @@ function logCallout(options) {
|
|
|
7131
7765
|
console.log("");
|
|
7132
7766
|
}
|
|
7133
7767
|
|
|
7768
|
+
// src/updateCheck.ts
|
|
7769
|
+
import { existsSync as existsSync4, promises as fs5 } from "fs";
|
|
7770
|
+
import { get as getHttp } from "http";
|
|
7771
|
+
import { get as getHttps } from "https";
|
|
7772
|
+
import { tmpdir } from "os";
|
|
7773
|
+
import { join as join3 } from "path";
|
|
7774
|
+
import registryUrl from "registry-url";
|
|
7775
|
+
import { URL as URL2 } from "url";
|
|
7776
|
+
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
7777
|
+
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
7778
|
+
var getFile = async (details, distTag) => {
|
|
7779
|
+
const rootDir = tmpdir();
|
|
7780
|
+
const subDir = join3(rootDir, "update-check");
|
|
7781
|
+
if (!existsSync4(subDir)) {
|
|
7782
|
+
await fs5.mkdir(subDir);
|
|
7783
|
+
}
|
|
7784
|
+
let name = `${details.name}-${distTag}.json`;
|
|
7785
|
+
if (details.scope) {
|
|
7786
|
+
name = `${details.scope}-${name}`;
|
|
7787
|
+
}
|
|
7788
|
+
return join3(subDir, name);
|
|
7789
|
+
};
|
|
7790
|
+
var evaluateCache = async (file, time, interval) => {
|
|
7791
|
+
if (existsSync4(file)) {
|
|
7792
|
+
const content = await fs5.readFile(file, "utf8");
|
|
7793
|
+
const { lastUpdate, latest } = JSON.parse(content);
|
|
7794
|
+
const nextCheck = lastUpdate + interval;
|
|
7795
|
+
if (nextCheck > time) {
|
|
7796
|
+
return {
|
|
7797
|
+
shouldCheck: false,
|
|
7798
|
+
latest
|
|
7799
|
+
};
|
|
7800
|
+
}
|
|
7801
|
+
}
|
|
7802
|
+
return {
|
|
7803
|
+
shouldCheck: true,
|
|
7804
|
+
latest: null
|
|
7805
|
+
};
|
|
7806
|
+
};
|
|
7807
|
+
var updateCache = async (file, latest, lastUpdate) => {
|
|
7808
|
+
const content = JSON.stringify({
|
|
7809
|
+
latest,
|
|
7810
|
+
lastUpdate
|
|
7811
|
+
});
|
|
7812
|
+
await fs5.writeFile(file, content, "utf8");
|
|
7813
|
+
};
|
|
7814
|
+
var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve2, reject) => {
|
|
7815
|
+
const options = {
|
|
7816
|
+
host: url.hostname,
|
|
7817
|
+
path: url.pathname,
|
|
7818
|
+
port: url.port,
|
|
7819
|
+
headers: {
|
|
7820
|
+
accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
|
|
7821
|
+
},
|
|
7822
|
+
timeout
|
|
7823
|
+
};
|
|
7824
|
+
if (authInfo) {
|
|
7825
|
+
options.headers.authorization = `${authInfo.type} ${authInfo.token}`;
|
|
7826
|
+
}
|
|
7827
|
+
const get = url.protocol === "https:" ? getHttps : getHttp;
|
|
7828
|
+
get(options, (response) => {
|
|
7829
|
+
const { statusCode } = response;
|
|
7830
|
+
if (statusCode !== 200) {
|
|
7831
|
+
const error = new Error(`Request failed with code ${statusCode}`);
|
|
7832
|
+
error.code = statusCode;
|
|
7833
|
+
reject(error);
|
|
7834
|
+
response.resume();
|
|
7835
|
+
return;
|
|
7836
|
+
}
|
|
7837
|
+
let rawData = "";
|
|
7838
|
+
response.setEncoding("utf8");
|
|
7839
|
+
response.on("data", (chunk) => {
|
|
7840
|
+
rawData += chunk;
|
|
7841
|
+
});
|
|
7842
|
+
response.on("end", () => {
|
|
7843
|
+
try {
|
|
7844
|
+
const parsedData = JSON.parse(rawData);
|
|
7845
|
+
resolve2(parsedData);
|
|
7846
|
+
} catch (e) {
|
|
7847
|
+
reject(e);
|
|
7848
|
+
}
|
|
7849
|
+
});
|
|
7850
|
+
}).on("error", reject).on("timeout", () => reject(new Error("Request timeout")));
|
|
7851
|
+
});
|
|
7852
|
+
var getMostRecent = async ({ full, scope }, distTag, timeout) => {
|
|
7853
|
+
const regURL = registryUrl(scope ?? "");
|
|
7854
|
+
const url = new URL2(full, regURL);
|
|
7855
|
+
let spec = null;
|
|
7856
|
+
try {
|
|
7857
|
+
spec = await loadPackage({ url, timeout });
|
|
7858
|
+
} catch (err) {
|
|
7859
|
+
if ((err == null ? void 0 : err.code) && String(err.code).startsWith("4")) {
|
|
7860
|
+
const registryAuthToken = __require("registry-auth-token");
|
|
7861
|
+
const authInfo = registryAuthToken(regURL, { recursive: true });
|
|
7862
|
+
spec = await loadPackage({ url, timeout }, authInfo);
|
|
7863
|
+
} else {
|
|
7864
|
+
throw err;
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
const version = spec["dist-tags"][distTag];
|
|
7868
|
+
if (!version) {
|
|
7869
|
+
throw new Error(`Distribution tag ${distTag} is not available`);
|
|
7870
|
+
}
|
|
7871
|
+
return version;
|
|
7872
|
+
};
|
|
7873
|
+
var defaultConfig = {
|
|
7874
|
+
interval: 36e5,
|
|
7875
|
+
distTag: "latest",
|
|
7876
|
+
timeout: 2e3
|
|
7877
|
+
};
|
|
7878
|
+
var getDetails = (name) => {
|
|
7879
|
+
const spec = {
|
|
7880
|
+
full: encode(name),
|
|
7881
|
+
name: "",
|
|
7882
|
+
scope: null
|
|
7883
|
+
};
|
|
7884
|
+
if (name.includes("/")) {
|
|
7885
|
+
const parts = name.split("/");
|
|
7886
|
+
spec.scope = parts[0];
|
|
7887
|
+
spec.name = parts[1];
|
|
7888
|
+
} else {
|
|
7889
|
+
spec.scope = null;
|
|
7890
|
+
spec.name = name;
|
|
7891
|
+
}
|
|
7892
|
+
return spec;
|
|
7893
|
+
};
|
|
7894
|
+
async function updateCheck_default(pkg, config2 = {}) {
|
|
7895
|
+
if (typeof pkg !== "object") {
|
|
7896
|
+
throw new Error("The first parameter should be your package.json file content");
|
|
7897
|
+
}
|
|
7898
|
+
const details = getDetails(pkg.name);
|
|
7899
|
+
const time = Date.now();
|
|
7900
|
+
const { distTag, interval, timeout } = Object.assign({}, defaultConfig, config2);
|
|
7901
|
+
const file = await getFile(details, distTag);
|
|
7902
|
+
let latest = null;
|
|
7903
|
+
let shouldCheck = true;
|
|
7904
|
+
({ shouldCheck, latest } = await evaluateCache(file, time, interval));
|
|
7905
|
+
if (shouldCheck) {
|
|
7906
|
+
latest = await getMostRecent(details, distTag, timeout);
|
|
7907
|
+
await updateCache(file, latest, time);
|
|
7908
|
+
}
|
|
7909
|
+
const comparision = compareVersions(pkg.version, latest);
|
|
7910
|
+
if (comparision === -1) {
|
|
7911
|
+
return {
|
|
7912
|
+
latest,
|
|
7913
|
+
fromCache: !shouldCheck
|
|
7914
|
+
};
|
|
7915
|
+
}
|
|
7916
|
+
return null;
|
|
7917
|
+
}
|
|
7918
|
+
|
|
7134
7919
|
// src/middleware/checkForUpdateMiddleware.ts
|
|
7135
7920
|
async function checkForUpdateMiddleware() {
|
|
7136
7921
|
try {
|
|
7137
7922
|
if (process.env.NO_UPDATE_CHECK || process.env.CI) {
|
|
7138
7923
|
return;
|
|
7139
7924
|
}
|
|
7140
|
-
const update = await
|
|
7925
|
+
const update = await updateCheck_default(package_default);
|
|
7141
7926
|
if (update) {
|
|
7142
7927
|
logCallout(`${bold("Update Available:")} ${gray5(package_default.version)} \u226B ${green4(update.latest)}`);
|
|
7143
7928
|
}
|
|
@@ -7148,17 +7933,17 @@ async function checkForUpdateMiddleware() {
|
|
|
7148
7933
|
|
|
7149
7934
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
7150
7935
|
import { magenta, red as red6 } from "colorette";
|
|
7151
|
-
import { join as
|
|
7936
|
+
import { join as join4 } from "path";
|
|
7152
7937
|
|
|
7153
7938
|
// src/fs.ts
|
|
7154
|
-
import { promises as
|
|
7939
|
+
import { promises as fs6 } from "fs";
|
|
7155
7940
|
async function readJSON(path5) {
|
|
7156
|
-
const fileContents = await
|
|
7941
|
+
const fileContents = await fs6.readFile(path5, "utf-8");
|
|
7157
7942
|
return JSON.parse(fileContents);
|
|
7158
7943
|
}
|
|
7159
7944
|
async function tryReadJSON(path5, missingValue = null) {
|
|
7160
7945
|
try {
|
|
7161
|
-
const stat = await
|
|
7946
|
+
const stat = await fs6.stat(path5);
|
|
7162
7947
|
return stat.isFile() ? await readJSON(path5) : missingValue;
|
|
7163
7948
|
} catch (e) {
|
|
7164
7949
|
return missingValue;
|
|
@@ -7187,7 +7972,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
7187
7972
|
try {
|
|
7188
7973
|
let isOutside = false;
|
|
7189
7974
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
7190
|
-
const localPackages = await tryReadJSON(
|
|
7975
|
+
const localPackages = await tryReadJSON(join4(process.cwd(), "package.json"));
|
|
7191
7976
|
if (!localPackages)
|
|
7192
7977
|
return;
|
|
7193
7978
|
let firstVersion;
|
|
@@ -7220,7 +8005,7 @@ First found was: v${firstVersion}`;
|
|
|
7220
8005
|
|
|
7221
8006
|
// src/index.ts
|
|
7222
8007
|
dotenv.config();
|
|
7223
|
-
var yarggery =
|
|
8008
|
+
var yarggery = yargs26(hideBin(process.argv));
|
|
7224
8009
|
var inlineConfigurationFilePath = "config" in yarggery.argv && yarggery.argv.config;
|
|
7225
8010
|
var configuration = loadConfig(inlineConfigurationFilePath || null);
|
|
7226
8011
|
yarggery.option("verbose", {
|