@uniformdev/cli 19.38.3-alpha.70 → 19.38.3-alpha.78
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 +2 -2
- package/dist/index.mjs +1248 -300
- package/package.json +14 -10
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { cosmiconfigSync } from "cosmiconfig";
|
|
5
|
-
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
6
4
|
import * as dotenv from "dotenv";
|
|
7
|
-
import
|
|
8
|
-
import yargs22 from "yargs";
|
|
5
|
+
import yargs24 from "yargs";
|
|
9
6
|
import { hideBin } from "yargs/helpers";
|
|
10
7
|
|
|
11
8
|
// src/commands/canvas/index.ts
|
|
12
|
-
import
|
|
9
|
+
import yargs8 from "yargs";
|
|
13
10
|
|
|
14
11
|
// src/commands/canvas/commands/category.ts
|
|
15
12
|
import yargs from "yargs";
|
|
@@ -78,6 +75,9 @@ import { readdir, unlink } from "fs/promises";
|
|
|
78
75
|
import { extname as extname2, join } from "path";
|
|
79
76
|
|
|
80
77
|
// src/util.ts
|
|
78
|
+
import { cosmiconfigSync } from "cosmiconfig";
|
|
79
|
+
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
80
|
+
import fs from "fs";
|
|
81
81
|
var omit = (object, keys) => {
|
|
82
82
|
const result = keys.reduce((current, key) => {
|
|
83
83
|
const { [key]: _, ...rest } = current;
|
|
@@ -88,6 +88,30 @@ var omit = (object, keys) => {
|
|
|
88
88
|
var cleanFileName = (proposedFileName) => {
|
|
89
89
|
return proposedFileName.replace(/[/<>$+%>!`&*'|{}?"=:\\@]/g, "-");
|
|
90
90
|
};
|
|
91
|
+
var loadConfig = (configPath) => {
|
|
92
|
+
const moduleName = "uniform";
|
|
93
|
+
const syncCosmicExplorer = cosmiconfigSync("uniform", {
|
|
94
|
+
searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.json`],
|
|
95
|
+
loaders: {
|
|
96
|
+
".ts": TypeScriptLoader()
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (configPath) {
|
|
100
|
+
if (!fs.existsSync(configPath)) {
|
|
101
|
+
throw new Error(`Invalid configuration file path: ${configPath}. File does not exist.`);
|
|
102
|
+
}
|
|
103
|
+
const configFile = syncCosmicExplorer.load(configPath);
|
|
104
|
+
if (!(configFile == null ? void 0 : configFile.config.serialization)) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Invalid configuration file: ${configPath}. Missing config.serialization configuration.`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return applyDefaultSyncConfiguration((configFile == null ? void 0 : configFile.config) ?? {});
|
|
110
|
+
} else {
|
|
111
|
+
const searchedForm = syncCosmicExplorer.search();
|
|
112
|
+
return applyDefaultSyncConfiguration((searchedForm == null ? void 0 : searchedForm.config) ?? {});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
91
115
|
|
|
92
116
|
// src/sync/util.ts
|
|
93
117
|
import { readFileSync, writeFileSync } from "fs";
|
|
@@ -95,14 +119,14 @@ import httpsProxyAgent from "https-proxy-agent";
|
|
|
95
119
|
import unfetch from "isomorphic-unfetch";
|
|
96
120
|
import { dump, load } from "js-yaml";
|
|
97
121
|
import { extname } from "path";
|
|
98
|
-
function withConfiguration(
|
|
99
|
-
return
|
|
122
|
+
function withConfiguration(yargs25) {
|
|
123
|
+
return yargs25.option("serialization", {
|
|
100
124
|
skipValidation: true,
|
|
101
125
|
hidden: true
|
|
102
126
|
});
|
|
103
127
|
}
|
|
104
|
-
function withApiOptions(
|
|
105
|
-
return
|
|
128
|
+
function withApiOptions(yargs25) {
|
|
129
|
+
return yargs25.option("apiKey", {
|
|
106
130
|
describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
|
|
107
131
|
default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
|
|
108
132
|
process.env.CANVAS_CLI_API_KEY ?? // deprecated
|
|
@@ -141,8 +165,8 @@ function nodeFetchProxy(proxy) {
|
|
|
141
165
|
};
|
|
142
166
|
return wrappedFetch;
|
|
143
167
|
}
|
|
144
|
-
function withProjectOptions(
|
|
145
|
-
return
|
|
168
|
+
function withProjectOptions(yargs25) {
|
|
169
|
+
return yargs25.option("project", {
|
|
146
170
|
describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
|
|
147
171
|
default: process.env.UNIFORM_CLI_PROJECT_ID ?? // deprecated
|
|
148
172
|
process.env.CANVAS_CLI_PROJECT_ID ?? // deprecated
|
|
@@ -152,8 +176,8 @@ function withProjectOptions(yargs23) {
|
|
|
152
176
|
alias: ["p"]
|
|
153
177
|
});
|
|
154
178
|
}
|
|
155
|
-
function withFormatOptions(
|
|
156
|
-
return
|
|
179
|
+
function withFormatOptions(yargs25) {
|
|
180
|
+
return yargs25.option("format", {
|
|
157
181
|
alias: ["f"],
|
|
158
182
|
describe: "Output format",
|
|
159
183
|
default: "yaml",
|
|
@@ -165,8 +189,8 @@ function withFormatOptions(yargs23) {
|
|
|
165
189
|
type: "string"
|
|
166
190
|
});
|
|
167
191
|
}
|
|
168
|
-
function withDiffOptions(
|
|
169
|
-
return
|
|
192
|
+
function withDiffOptions(yargs25) {
|
|
193
|
+
return yargs25.option("diff", {
|
|
170
194
|
describe: "Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",
|
|
171
195
|
default: process.env.UNIFORM_CLI_DIFF_MODE ?? "off",
|
|
172
196
|
type: "string",
|
|
@@ -228,7 +252,7 @@ async function* paginateAsync(fetchPage, options) {
|
|
|
228
252
|
}
|
|
229
253
|
var defaultSyncConfiguration = {
|
|
230
254
|
entitiesConfig: {},
|
|
231
|
-
|
|
255
|
+
directory: "uniform-data",
|
|
232
256
|
format: "yaml",
|
|
233
257
|
mode: "mirror"
|
|
234
258
|
};
|
|
@@ -248,8 +272,10 @@ var applyDefaultSyncConfiguration = (config2) => {
|
|
|
248
272
|
const entityTypeCasted = entityType;
|
|
249
273
|
const entityConfig = mergedConfig.serialization.entitiesConfig[entityTypeCasted];
|
|
250
274
|
if (Object.keys(entityConfig).length === 0) {
|
|
251
|
-
const separator = mergedConfig.serialization.
|
|
252
|
-
mergedConfig.serialization.entitiesConfig[entityTypeCasted].
|
|
275
|
+
const separator = mergedConfig.serialization.directory[mergedConfig.serialization.directory.length - 1] === "/" ? "" : "/";
|
|
276
|
+
mergedConfig.serialization.entitiesConfig[entityTypeCasted].directory = isPathAPackageFile(
|
|
277
|
+
mergedConfig.serialization.directory
|
|
278
|
+
) ? mergedConfig.serialization.directory : `${mergedConfig.serialization.directory}${separator}${entityTypeCasted}`;
|
|
253
279
|
}
|
|
254
280
|
}
|
|
255
281
|
return mergedConfig;
|
|
@@ -278,17 +304,17 @@ var getDirectoryOrFilename = ({
|
|
|
278
304
|
operation
|
|
279
305
|
}) => {
|
|
280
306
|
var _a, _b, _c, _d, _e, _f;
|
|
281
|
-
if ((_b = (_a = config2.entitiesConfig[entityType]) == null ? void 0 : _a[operation]) == null ? void 0 : _b.
|
|
282
|
-
return (_d = (_c = config2.entitiesConfig[entityType]) == null ? void 0 : _c[operation]) == null ? void 0 : _d.
|
|
307
|
+
if ((_b = (_a = config2.entitiesConfig[entityType]) == null ? void 0 : _a[operation]) == null ? void 0 : _b.directory) {
|
|
308
|
+
return (_d = (_c = config2.entitiesConfig[entityType]) == null ? void 0 : _c[operation]) == null ? void 0 : _d.directory;
|
|
283
309
|
}
|
|
284
|
-
if ((_e = config2.entitiesConfig[entityType]) == null ? void 0 : _e.
|
|
285
|
-
return (_f = config2.entitiesConfig[entityType]) == null ? void 0 : _f.
|
|
310
|
+
if ((_e = config2.entitiesConfig[entityType]) == null ? void 0 : _e.directory) {
|
|
311
|
+
return (_f = config2.entitiesConfig[entityType]) == null ? void 0 : _f.directory;
|
|
286
312
|
}
|
|
287
|
-
const isPackage = isPathAPackageFile(config2.
|
|
313
|
+
const isPackage = isPathAPackageFile(config2.directory);
|
|
288
314
|
if (isPackage) {
|
|
289
|
-
return config2.
|
|
315
|
+
return config2.directory;
|
|
290
316
|
}
|
|
291
|
-
return `${config2.
|
|
317
|
+
return `${config2.directory}/${entityType}`;
|
|
292
318
|
};
|
|
293
319
|
|
|
294
320
|
// src/sync/fileSyncEngineDataSource.ts
|
|
@@ -352,9 +378,9 @@ ${e == null ? void 0 : e.message}`));
|
|
|
352
378
|
}
|
|
353
379
|
|
|
354
380
|
// src/sync/package.ts
|
|
355
|
-
import
|
|
381
|
+
import fs2 from "fs";
|
|
356
382
|
function readUniformPackage(filename, assertExists) {
|
|
357
|
-
if (!assertExists && !
|
|
383
|
+
if (!assertExists && !fs2.existsSync(filename)) {
|
|
358
384
|
return {};
|
|
359
385
|
}
|
|
360
386
|
const packageContents = readFileToObject(filename);
|
|
@@ -385,7 +411,9 @@ async function syncEngine({
|
|
|
385
411
|
whatIf = false,
|
|
386
412
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
387
413
|
log = () => {
|
|
388
|
-
}
|
|
414
|
+
},
|
|
415
|
+
onBeforeCompareObjects,
|
|
416
|
+
onBeforeWriteObject
|
|
389
417
|
}) {
|
|
390
418
|
var _a, _b;
|
|
391
419
|
const targetItems = /* @__PURE__ */ new Map();
|
|
@@ -419,18 +447,20 @@ async function syncEngine({
|
|
|
419
447
|
}
|
|
420
448
|
const actions = [];
|
|
421
449
|
let sourceHasItems = false;
|
|
422
|
-
for await (
|
|
450
|
+
for await (let sourceObject of source.objects) {
|
|
423
451
|
sourceHasItems = true;
|
|
424
452
|
const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
|
|
425
453
|
const targetObject = targetItems.get(ids[0]);
|
|
426
454
|
const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => (o == null ? void 0 : o.object) !== (targetObject == null ? void 0 : targetObject.object));
|
|
427
455
|
if (targetObject && invalidTargetObjects.length == 0) {
|
|
456
|
+
sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, targetObject) : sourceObject;
|
|
428
457
|
if (!compareContents(sourceObject, targetObject)) {
|
|
429
458
|
if (mode === "createOrUpdate" || mode === "mirror") {
|
|
430
459
|
const process2 = async (sourceObject2, targetObject2) => {
|
|
431
460
|
if (!whatIf) {
|
|
432
461
|
try {
|
|
433
|
-
await
|
|
462
|
+
const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
|
|
463
|
+
await target.writeObject(finalSourceObject, targetObject2);
|
|
434
464
|
} catch (e) {
|
|
435
465
|
throw new SyncEngineError(e, sourceObject2);
|
|
436
466
|
}
|
|
@@ -452,7 +482,8 @@ async function syncEngine({
|
|
|
452
482
|
const process2 = async (sourceObject2, id) => {
|
|
453
483
|
if (!whatIf) {
|
|
454
484
|
try {
|
|
455
|
-
await
|
|
485
|
+
const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2) : sourceObject2;
|
|
486
|
+
await target.writeObject(finalSourceObject);
|
|
456
487
|
} catch (e) {
|
|
457
488
|
throw new SyncEngineError(e, sourceObject2);
|
|
458
489
|
}
|
|
@@ -548,11 +579,11 @@ function createSyncEngineConsoleLogger(options) {
|
|
|
548
579
|
var CategoryGetModule = {
|
|
549
580
|
command: "get <id>",
|
|
550
581
|
describe: "Fetch a category",
|
|
551
|
-
builder: (
|
|
582
|
+
builder: (yargs25) => withConfiguration(
|
|
552
583
|
withFormatOptions(
|
|
553
584
|
withApiOptions(
|
|
554
585
|
withProjectOptions(
|
|
555
|
-
|
|
586
|
+
yargs25.positional("id", { demandOption: true, describe: "Category UUID to fetch" })
|
|
556
587
|
)
|
|
557
588
|
)
|
|
558
589
|
)
|
|
@@ -577,7 +608,7 @@ var CategoryListModule = {
|
|
|
577
608
|
command: "list",
|
|
578
609
|
describe: "List categories",
|
|
579
610
|
aliases: ["ls"],
|
|
580
|
-
builder: (
|
|
611
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25.options({}))))),
|
|
581
612
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
582
613
|
const fetch3 = nodeFetchProxy(proxy);
|
|
583
614
|
const client = new UncachedCategoryClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -634,11 +665,11 @@ function writeCanvasPackage(filename, packageContents) {
|
|
|
634
665
|
var CategoryPullModule = {
|
|
635
666
|
command: "pull <directory>",
|
|
636
667
|
describe: "Pulls all categories to local files in a directory",
|
|
637
|
-
builder: (
|
|
668
|
+
builder: (yargs25) => withConfiguration(
|
|
638
669
|
withApiOptions(
|
|
639
670
|
withProjectOptions(
|
|
640
671
|
withDiffOptions(
|
|
641
|
-
|
|
672
|
+
yargs25.positional("directory", {
|
|
642
673
|
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.",
|
|
643
674
|
type: "string"
|
|
644
675
|
}).option("format", {
|
|
@@ -713,11 +744,11 @@ import { UncachedCategoryClient as UncachedCategoryClient4 } from "@uniformdev/c
|
|
|
713
744
|
var CategoryPushModule = {
|
|
714
745
|
command: "push <directory>",
|
|
715
746
|
describe: "Pushes all categories from files in a directory to Uniform Canvas",
|
|
716
|
-
builder: (
|
|
747
|
+
builder: (yargs25) => withConfiguration(
|
|
717
748
|
withApiOptions(
|
|
718
749
|
withProjectOptions(
|
|
719
750
|
withDiffOptions(
|
|
720
|
-
|
|
751
|
+
yargs25.positional("directory", {
|
|
721
752
|
describe: "Directory to read the categories from. If a filename is used, a package will be read instead.",
|
|
722
753
|
type: "string"
|
|
723
754
|
}).option("what-if", {
|
|
@@ -781,10 +812,10 @@ var CategoryRemoveModule = {
|
|
|
781
812
|
command: "remove <id>",
|
|
782
813
|
aliases: ["delete", "rm"],
|
|
783
814
|
describe: "Delete a category",
|
|
784
|
-
builder: (
|
|
815
|
+
builder: (yargs25) => withConfiguration(
|
|
785
816
|
withApiOptions(
|
|
786
817
|
withProjectOptions(
|
|
787
|
-
|
|
818
|
+
yargs25.positional("id", { demandOption: true, describe: "Category UUID to delete" })
|
|
788
819
|
)
|
|
789
820
|
)
|
|
790
821
|
),
|
|
@@ -801,10 +832,10 @@ var CategoryUpdateModule = {
|
|
|
801
832
|
command: "update <filename>",
|
|
802
833
|
aliases: ["put"],
|
|
803
834
|
describe: "Insert or update a category",
|
|
804
|
-
builder: (
|
|
835
|
+
builder: (yargs25) => withConfiguration(
|
|
805
836
|
withApiOptions(
|
|
806
837
|
withProjectOptions(
|
|
807
|
-
|
|
838
|
+
yargs25.positional("filename", { demandOption: true, describe: "Category file to put" })
|
|
808
839
|
)
|
|
809
840
|
)
|
|
810
841
|
),
|
|
@@ -821,7 +852,7 @@ var CategoryModule = {
|
|
|
821
852
|
command: "category <command>",
|
|
822
853
|
aliases: ["cat"],
|
|
823
854
|
describe: "Commands for Canvas categories",
|
|
824
|
-
builder: (
|
|
855
|
+
builder: (yargs25) => yargs25.command(CategoryPullModule).command(CategoryPushModule).command(CategoryGetModule).command(CategoryRemoveModule).command(CategoryListModule).command(CategoryUpdateModule).demandCommand(),
|
|
825
856
|
handler: () => {
|
|
826
857
|
yargs.help();
|
|
827
858
|
}
|
|
@@ -842,11 +873,11 @@ var selectSchemaUrl = () => "/schemas/json-schema/component-definition/v1.json";
|
|
|
842
873
|
var ComponentGetModule = {
|
|
843
874
|
command: "get <id>",
|
|
844
875
|
describe: "Fetch a component definition",
|
|
845
|
-
builder: (
|
|
876
|
+
builder: (yargs25) => withConfiguration(
|
|
846
877
|
withFormatOptions(
|
|
847
878
|
withApiOptions(
|
|
848
879
|
withProjectOptions(
|
|
849
|
-
|
|
880
|
+
yargs25.positional("id", {
|
|
850
881
|
demandOption: true,
|
|
851
882
|
describe: "Component definition public ID to fetch"
|
|
852
883
|
})
|
|
@@ -880,11 +911,11 @@ var ComponentListModule = {
|
|
|
880
911
|
command: "list",
|
|
881
912
|
describe: "List component definitions",
|
|
882
913
|
aliases: ["ls"],
|
|
883
|
-
builder: (
|
|
914
|
+
builder: (yargs25) => withConfiguration(
|
|
884
915
|
withFormatOptions(
|
|
885
916
|
withApiOptions(
|
|
886
917
|
withProjectOptions(
|
|
887
|
-
|
|
918
|
+
yargs25.options({
|
|
888
919
|
offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
|
|
889
920
|
limit: { describe: "Number of rows to fetch", type: "number", default: 20 }
|
|
890
921
|
})
|
|
@@ -939,11 +970,11 @@ function createComponentDefinitionEngineDataSource({
|
|
|
939
970
|
var ComponentPullModule = {
|
|
940
971
|
command: "pull <directory>",
|
|
941
972
|
describe: "Pulls all component definitions to local files in a directory",
|
|
942
|
-
builder: (
|
|
973
|
+
builder: (yargs25) => withConfiguration(
|
|
943
974
|
withApiOptions(
|
|
944
975
|
withProjectOptions(
|
|
945
976
|
withDiffOptions(
|
|
946
|
-
|
|
977
|
+
yargs25.positional("directory", {
|
|
947
978
|
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.",
|
|
948
979
|
type: "string"
|
|
949
980
|
}).option("format", {
|
|
@@ -1019,11 +1050,11 @@ import { UncachedCanvasClient as UncachedCanvasClient4 } from "@uniformdev/canva
|
|
|
1019
1050
|
var ComponentPushModule = {
|
|
1020
1051
|
command: "push <directory>",
|
|
1021
1052
|
describe: "Pushes all component definitions from files in a directory to Uniform Canvas",
|
|
1022
|
-
builder: (
|
|
1053
|
+
builder: (yargs25) => withConfiguration(
|
|
1023
1054
|
withApiOptions(
|
|
1024
1055
|
withProjectOptions(
|
|
1025
1056
|
withDiffOptions(
|
|
1026
|
-
|
|
1057
|
+
yargs25.positional("directory", {
|
|
1027
1058
|
describe: "Directory to read the component definitions from. If a filename is used, a package will be read instead.",
|
|
1028
1059
|
type: "string"
|
|
1029
1060
|
}).option("what-if", {
|
|
@@ -1088,10 +1119,10 @@ var ComponentRemoveModule = {
|
|
|
1088
1119
|
command: "remove <id>",
|
|
1089
1120
|
aliases: ["delete", "rm"],
|
|
1090
1121
|
describe: "Delete a component definition",
|
|
1091
|
-
builder: (
|
|
1122
|
+
builder: (yargs25) => withConfiguration(
|
|
1092
1123
|
withApiOptions(
|
|
1093
1124
|
withProjectOptions(
|
|
1094
|
-
|
|
1125
|
+
yargs25.positional("id", { demandOption: true, describe: "Component definition public ID to delete" })
|
|
1095
1126
|
)
|
|
1096
1127
|
)
|
|
1097
1128
|
),
|
|
@@ -1108,10 +1139,10 @@ var ComponentUpdateModule = {
|
|
|
1108
1139
|
command: "update <filename>",
|
|
1109
1140
|
aliases: ["put"],
|
|
1110
1141
|
describe: "Insert or update a component definition",
|
|
1111
|
-
builder: (
|
|
1142
|
+
builder: (yargs25) => withConfiguration(
|
|
1112
1143
|
withApiOptions(
|
|
1113
1144
|
withProjectOptions(
|
|
1114
|
-
|
|
1145
|
+
yargs25.positional("filename", { demandOption: true, describe: "Component definition file to put" })
|
|
1115
1146
|
)
|
|
1116
1147
|
)
|
|
1117
1148
|
),
|
|
@@ -1128,7 +1159,7 @@ var ComponentModule = {
|
|
|
1128
1159
|
command: "component <command>",
|
|
1129
1160
|
aliases: ["def"],
|
|
1130
1161
|
describe: "Commands for Canvas component definitions",
|
|
1131
|
-
builder: (
|
|
1162
|
+
builder: (yargs25) => yargs25.command(ComponentPullModule).command(ComponentPushModule).command(ComponentGetModule).command(ComponentRemoveModule).command(ComponentListModule).command(ComponentUpdateModule).demandCommand(),
|
|
1132
1163
|
handler: () => {
|
|
1133
1164
|
yargs2.help();
|
|
1134
1165
|
}
|
|
@@ -1150,8 +1181,8 @@ function prepCompositionForDisk(composition) {
|
|
|
1150
1181
|
delete prepped.state;
|
|
1151
1182
|
return prepped;
|
|
1152
1183
|
}
|
|
1153
|
-
function withStateOptions(
|
|
1154
|
-
return
|
|
1184
|
+
function withStateOptions(yargs25) {
|
|
1185
|
+
return yargs25.option("state", {
|
|
1155
1186
|
type: "string",
|
|
1156
1187
|
describe: `Composition state to fetch.`,
|
|
1157
1188
|
choices: ["preview", "published"],
|
|
@@ -1176,12 +1207,12 @@ function convertCompositionState(state) {
|
|
|
1176
1207
|
var CompositionGetModule = {
|
|
1177
1208
|
command: "get <id>",
|
|
1178
1209
|
describe: "Fetch a composition",
|
|
1179
|
-
builder: (
|
|
1210
|
+
builder: (yargs25) => withFormatOptions(
|
|
1180
1211
|
withConfiguration(
|
|
1181
1212
|
withApiOptions(
|
|
1182
1213
|
withProjectOptions(
|
|
1183
1214
|
withStateOptions(
|
|
1184
|
-
|
|
1215
|
+
yargs25.positional("id", { demandOption: true, describe: "Composition/pattern public ID to fetch" }).option({
|
|
1185
1216
|
resolvePatterns: {
|
|
1186
1217
|
type: "boolean",
|
|
1187
1218
|
default: false,
|
|
@@ -1252,12 +1283,12 @@ var CompositionListModule = {
|
|
|
1252
1283
|
command: "list",
|
|
1253
1284
|
describe: "List compositions",
|
|
1254
1285
|
aliases: ["ls"],
|
|
1255
|
-
builder: (
|
|
1286
|
+
builder: (yargs25) => withFormatOptions(
|
|
1256
1287
|
withConfiguration(
|
|
1257
1288
|
withApiOptions(
|
|
1258
1289
|
withProjectOptions(
|
|
1259
1290
|
withStateOptions(
|
|
1260
|
-
|
|
1291
|
+
yargs25.options({
|
|
1261
1292
|
offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
|
|
1262
1293
|
limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
|
|
1263
1294
|
resolvePatterns: {
|
|
@@ -1377,13 +1408,13 @@ function createComponentInstanceEngineDataSource({
|
|
|
1377
1408
|
// src/commands/canvas/commands/composition/publish.ts
|
|
1378
1409
|
var CompositionPublishModule = {
|
|
1379
1410
|
command: "publish [ids]",
|
|
1380
|
-
describe: "Publishes
|
|
1381
|
-
builder: (
|
|
1411
|
+
describe: "Publishes composition(s)",
|
|
1412
|
+
builder: (yargs25) => withConfiguration(
|
|
1382
1413
|
withApiOptions(
|
|
1383
1414
|
withProjectOptions(
|
|
1384
1415
|
withDiffOptions(
|
|
1385
|
-
|
|
1386
|
-
describe: "Publishes composition
|
|
1416
|
+
yargs25.positional("ids", {
|
|
1417
|
+
describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
|
|
1387
1418
|
type: "string"
|
|
1388
1419
|
}).option("all", {
|
|
1389
1420
|
alias: ["a"],
|
|
@@ -1395,12 +1426,32 @@ var CompositionPublishModule = {
|
|
|
1395
1426
|
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
1396
1427
|
default: false,
|
|
1397
1428
|
type: "boolean"
|
|
1429
|
+
}).option("onlyCompositions", {
|
|
1430
|
+
describe: "Only publishing compositions and not patterns",
|
|
1431
|
+
default: false,
|
|
1432
|
+
type: "boolean"
|
|
1433
|
+
}).option("onlyPatterns", {
|
|
1434
|
+
describe: "Only pulling patterns and not compositions",
|
|
1435
|
+
default: false,
|
|
1436
|
+
type: "boolean",
|
|
1437
|
+
hidden: true
|
|
1398
1438
|
})
|
|
1399
1439
|
)
|
|
1400
1440
|
)
|
|
1401
1441
|
)
|
|
1402
1442
|
),
|
|
1403
|
-
handler: async ({
|
|
1443
|
+
handler: async ({
|
|
1444
|
+
apiHost,
|
|
1445
|
+
apiKey,
|
|
1446
|
+
proxy,
|
|
1447
|
+
ids,
|
|
1448
|
+
all,
|
|
1449
|
+
whatIf,
|
|
1450
|
+
project: projectId,
|
|
1451
|
+
diff: diffMode,
|
|
1452
|
+
onlyCompositions,
|
|
1453
|
+
onlyPatterns
|
|
1454
|
+
}) => {
|
|
1404
1455
|
if (!all && !ids || all && ids) {
|
|
1405
1456
|
console.error(`Specify --all or composition ID(s) to publish.`);
|
|
1406
1457
|
process.exit(1);
|
|
@@ -1411,17 +1462,22 @@ var CompositionPublishModule = {
|
|
|
1411
1462
|
const source = createComponentInstanceEngineDataSource({
|
|
1412
1463
|
client,
|
|
1413
1464
|
state: "preview",
|
|
1414
|
-
compositionIDs: compositionIDsArray
|
|
1465
|
+
compositionIDs: compositionIDsArray,
|
|
1466
|
+
onlyCompositions,
|
|
1467
|
+
onlyPatterns
|
|
1415
1468
|
});
|
|
1416
1469
|
const target = createComponentInstanceEngineDataSource({
|
|
1417
1470
|
client,
|
|
1418
1471
|
state: "published",
|
|
1419
|
-
compositionIDs: compositionIDsArray
|
|
1472
|
+
compositionIDs: compositionIDsArray,
|
|
1473
|
+
onlyCompositions,
|
|
1474
|
+
onlyPatterns
|
|
1420
1475
|
});
|
|
1421
1476
|
await syncEngine({
|
|
1422
1477
|
source,
|
|
1423
1478
|
target,
|
|
1424
|
-
|
|
1479
|
+
// Publishing is one-direction operation, so no need to support automatic un-publishing
|
|
1480
|
+
mode: "createOrUpdate",
|
|
1425
1481
|
whatIf,
|
|
1426
1482
|
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1427
1483
|
});
|
|
@@ -1430,15 +1486,190 @@ var CompositionPublishModule = {
|
|
|
1430
1486
|
|
|
1431
1487
|
// src/commands/canvas/commands/composition/pull.ts
|
|
1432
1488
|
import { UncachedCanvasClient as UncachedCanvasClient10 } from "@uniformdev/canvas";
|
|
1489
|
+
|
|
1490
|
+
// src/files/index.ts
|
|
1491
|
+
import { preferredType } from "@thi.ng/mime";
|
|
1492
|
+
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
|
|
1493
|
+
import { createHash } from "crypto";
|
|
1494
|
+
import fsj from "fs-jetpack";
|
|
1495
|
+
import sizeOf from "image-size";
|
|
1496
|
+
import PQueue from "p-queue";
|
|
1497
|
+
import { join as join2 } from "path";
|
|
1498
|
+
var FILES_DIRECTORY_NAME = "files";
|
|
1499
|
+
var urlToHash = (url) => {
|
|
1500
|
+
const hash = createHash("sha256");
|
|
1501
|
+
hash.update(url);
|
|
1502
|
+
return hash.digest("hex");
|
|
1503
|
+
};
|
|
1504
|
+
var urlToFileName = (url) => {
|
|
1505
|
+
const fileName = urlToHash(url);
|
|
1506
|
+
const fileNameChunks = url.split(".");
|
|
1507
|
+
const fileExtension = fileNameChunks.length > 1 ? fileNameChunks.at(-1) : "";
|
|
1508
|
+
return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
|
|
1509
|
+
};
|
|
1510
|
+
var extractAndDownloadUniformFilesForObject = async (object, options) => {
|
|
1511
|
+
const objectAsString = JSON.stringify(object);
|
|
1512
|
+
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1513
|
+
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1514
|
+
);
|
|
1515
|
+
if (uniformFileUrlMatches) {
|
|
1516
|
+
const fileDownloadQueue = new PQueue({ concurrency: 10 });
|
|
1517
|
+
for (const match of uniformFileUrlMatches) {
|
|
1518
|
+
const url = new URL(match[1]);
|
|
1519
|
+
fileDownloadQueue.add(async () => {
|
|
1520
|
+
try {
|
|
1521
|
+
const fetchUrl = `${url.origin}${url.pathname}?format=original`;
|
|
1522
|
+
const fileName = urlToFileName(url.toString());
|
|
1523
|
+
const fileAlreadyExists = await fsj.existsAsync(
|
|
1524
|
+
join2(options.directory, FILES_DIRECTORY_NAME, fileName)
|
|
1525
|
+
);
|
|
1526
|
+
if (fileAlreadyExists) {
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
const response = await fetch(fetchUrl);
|
|
1530
|
+
if (!response.ok) {
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
const fileBuffer = await response.arrayBuffer();
|
|
1534
|
+
await fsj.writeAsync(
|
|
1535
|
+
join2(options.directory, FILES_DIRECTORY_NAME, fileName),
|
|
1536
|
+
Buffer.from(fileBuffer)
|
|
1537
|
+
);
|
|
1538
|
+
} catch {
|
|
1539
|
+
console.warn(`Failed to download file ${url}`);
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
await fileDownloadQueue.onIdle();
|
|
1544
|
+
}
|
|
1545
|
+
return object;
|
|
1546
|
+
};
|
|
1547
|
+
var extractAndUploadUniformFilesForObject = async (object, options) => {
|
|
1548
|
+
let objectAsString = JSON.stringify(object);
|
|
1549
|
+
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1550
|
+
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1551
|
+
);
|
|
1552
|
+
if (uniformFileUrlMatches) {
|
|
1553
|
+
const fileUploadQueue = new PQueue({ concurrency: 3 });
|
|
1554
|
+
for (const match of uniformFileUrlMatches) {
|
|
1555
|
+
const url = match[1];
|
|
1556
|
+
const hash = urlToHash(url);
|
|
1557
|
+
fileUploadQueue.add(async () => {
|
|
1558
|
+
try {
|
|
1559
|
+
const fileAlreadyExistsChecks = await Promise.all([
|
|
1560
|
+
options.fileClient.getFile({ projectId: options.projectId, url }).catch(() => null),
|
|
1561
|
+
options.fileClient.getFile({ projectId: options.projectId, sourceId: hash }).catch(() => null)
|
|
1562
|
+
]);
|
|
1563
|
+
if (fileAlreadyExistsChecks.some((check) => check !== null)) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
const localFileName = urlToFileName(url);
|
|
1567
|
+
const fileExistsLocally = await fsj.existsAsync(
|
|
1568
|
+
join2(options.directory, FILES_DIRECTORY_NAME, localFileName)
|
|
1569
|
+
);
|
|
1570
|
+
if (!fileExistsLocally) {
|
|
1571
|
+
console.warn(`Skipping file ${url} as we couldn't find a local copy`);
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
const fileBuffer = await fsj.readAsync(
|
|
1575
|
+
join2(options.directory, FILES_DIRECTORY_NAME, localFileName),
|
|
1576
|
+
"buffer"
|
|
1577
|
+
);
|
|
1578
|
+
if (!fileBuffer) {
|
|
1579
|
+
console.warn(`Skipping file ${url} as we couldn't read it`);
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
const fileName = getFileNameFromUrl(url);
|
|
1583
|
+
const { width, height } = (() => {
|
|
1584
|
+
try {
|
|
1585
|
+
return sizeOf(fileBuffer);
|
|
1586
|
+
} catch {
|
|
1587
|
+
return {
|
|
1588
|
+
width: void 0,
|
|
1589
|
+
height: void 0
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
})();
|
|
1593
|
+
const { id, method, uploadUrl } = await options.fileClient.createNewProjectFile({
|
|
1594
|
+
name: fileName,
|
|
1595
|
+
mediaType: preferredType(url.split(".").at(-1) ?? ""),
|
|
1596
|
+
size: fileBuffer.length,
|
|
1597
|
+
width,
|
|
1598
|
+
height,
|
|
1599
|
+
projectId: options.projectId,
|
|
1600
|
+
sourceId: hash
|
|
1601
|
+
});
|
|
1602
|
+
const uploadResponse = await fetch(uploadUrl, {
|
|
1603
|
+
method,
|
|
1604
|
+
body: fileBuffer
|
|
1605
|
+
});
|
|
1606
|
+
if (!uploadResponse.ok) {
|
|
1607
|
+
console.warn(`Failed to upload file ${url}`);
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
const checkForFile = async () => {
|
|
1611
|
+
const file = await options.fileClient.getFile({ id });
|
|
1612
|
+
if (!file || file.state !== FILE_READY_STATE) {
|
|
1613
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1614
|
+
return checkForFile();
|
|
1615
|
+
}
|
|
1616
|
+
return file.url;
|
|
1617
|
+
};
|
|
1618
|
+
const abortTimeout = setTimeout(() => {
|
|
1619
|
+
throw new Error(`Failed to upload file ${url}`);
|
|
1620
|
+
}, 1e4);
|
|
1621
|
+
const uploadedFileUrl = await checkForFile();
|
|
1622
|
+
clearTimeout(abortTimeout);
|
|
1623
|
+
objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
|
|
1624
|
+
} catch {
|
|
1625
|
+
console.warn(`Failed to upload file ${url}`);
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
await fileUploadQueue.onIdle();
|
|
1630
|
+
}
|
|
1631
|
+
return JSON.parse(objectAsString);
|
|
1632
|
+
};
|
|
1633
|
+
var swapOutUniformFileUrlsForTargetProject = async (object, options) => {
|
|
1634
|
+
let objectAsString = JSON.stringify(object);
|
|
1635
|
+
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1636
|
+
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1637
|
+
);
|
|
1638
|
+
if (uniformFileUrlMatches) {
|
|
1639
|
+
const fileUrlReplacementQueue = new PQueue({ concurrency: 3 });
|
|
1640
|
+
for (const match of uniformFileUrlMatches) {
|
|
1641
|
+
const url = match[1];
|
|
1642
|
+
const hash = urlToHash(url);
|
|
1643
|
+
fileUrlReplacementQueue.add(async () => {
|
|
1644
|
+
try {
|
|
1645
|
+
const fileAlreadyExistsChecks = await Promise.all([
|
|
1646
|
+
options.fileClient.getFile({ projectId: options.projectId, url }).catch(() => null),
|
|
1647
|
+
options.fileClient.getFile({ projectId: options.projectId, sourceId: hash }).catch(() => null)
|
|
1648
|
+
]);
|
|
1649
|
+
const file = fileAlreadyExistsChecks.find((check) => check !== null);
|
|
1650
|
+
if (!file) {
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
|
|
1654
|
+
} catch {
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
await fileUrlReplacementQueue.onIdle();
|
|
1659
|
+
}
|
|
1660
|
+
return JSON.parse(objectAsString);
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
// src/commands/canvas/commands/composition/pull.ts
|
|
1433
1664
|
var CompositionPullModule = {
|
|
1434
1665
|
command: "pull <directory>",
|
|
1435
1666
|
describe: "Pulls all compositions to local files in a directory",
|
|
1436
|
-
builder: (
|
|
1667
|
+
builder: (yargs25) => withConfiguration(
|
|
1437
1668
|
withApiOptions(
|
|
1438
1669
|
withProjectOptions(
|
|
1439
1670
|
withStateOptions(
|
|
1440
1671
|
withDiffOptions(
|
|
1441
|
-
|
|
1672
|
+
yargs25.positional("directory", {
|
|
1442
1673
|
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.",
|
|
1443
1674
|
type: "string"
|
|
1444
1675
|
}).option("format", {
|
|
@@ -1516,22 +1747,28 @@ var CompositionPullModule = {
|
|
|
1516
1747
|
target,
|
|
1517
1748
|
mode,
|
|
1518
1749
|
whatIf,
|
|
1519
|
-
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1750
|
+
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
1751
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
1752
|
+
return extractAndDownloadUniformFilesForObject(sourceObject, {
|
|
1753
|
+
directory
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1520
1756
|
});
|
|
1521
1757
|
}
|
|
1522
1758
|
};
|
|
1523
1759
|
|
|
1524
1760
|
// src/commands/canvas/commands/composition/push.ts
|
|
1525
1761
|
import { UncachedCanvasClient as UncachedCanvasClient11 } from "@uniformdev/canvas";
|
|
1762
|
+
import { FileClient as FileClient2 } from "@uniformdev/files";
|
|
1526
1763
|
var CompositionPushModule = {
|
|
1527
1764
|
command: "push <directory>",
|
|
1528
1765
|
describe: "Pushes all compositions from files in a directory to Uniform Canvas",
|
|
1529
|
-
builder: (
|
|
1766
|
+
builder: (yargs25) => withConfiguration(
|
|
1530
1767
|
withApiOptions(
|
|
1531
1768
|
withProjectOptions(
|
|
1532
1769
|
withStateOptions(
|
|
1533
1770
|
withDiffOptions(
|
|
1534
|
-
|
|
1771
|
+
yargs25.positional("directory", {
|
|
1535
1772
|
describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
|
|
1536
1773
|
type: "string"
|
|
1537
1774
|
}).option("what-if", {
|
|
@@ -1592,12 +1829,26 @@ var CompositionPushModule = {
|
|
|
1592
1829
|
});
|
|
1593
1830
|
}
|
|
1594
1831
|
const target = createComponentInstanceEngineDataSource({ client, state, onlyCompositions, onlyPatterns });
|
|
1832
|
+
const fileClient = new FileClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
1595
1833
|
await syncEngine({
|
|
1596
1834
|
source,
|
|
1597
1835
|
target,
|
|
1598
1836
|
mode,
|
|
1599
1837
|
whatIf,
|
|
1600
|
-
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1838
|
+
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
1839
|
+
onBeforeCompareObjects: async (sourceObject) => {
|
|
1840
|
+
return swapOutUniformFileUrlsForTargetProject(sourceObject, {
|
|
1841
|
+
fileClient,
|
|
1842
|
+
projectId
|
|
1843
|
+
});
|
|
1844
|
+
},
|
|
1845
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
1846
|
+
return extractAndUploadUniformFilesForObject(sourceObject, {
|
|
1847
|
+
directory,
|
|
1848
|
+
fileClient,
|
|
1849
|
+
projectId
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1601
1852
|
});
|
|
1602
1853
|
}
|
|
1603
1854
|
};
|
|
@@ -1608,10 +1859,10 @@ var CompositionRemoveModule = {
|
|
|
1608
1859
|
command: "remove <id>",
|
|
1609
1860
|
aliases: ["delete", "rm"],
|
|
1610
1861
|
describe: "Delete a composition",
|
|
1611
|
-
builder: (
|
|
1862
|
+
builder: (yargs25) => withConfiguration(
|
|
1612
1863
|
withApiOptions(
|
|
1613
1864
|
withProjectOptions(
|
|
1614
|
-
|
|
1865
|
+
yargs25.positional("id", { demandOption: true, describe: "Composition/pattern public ID to delete" })
|
|
1615
1866
|
)
|
|
1616
1867
|
)
|
|
1617
1868
|
),
|
|
@@ -1624,23 +1875,99 @@ var CompositionRemoveModule = {
|
|
|
1624
1875
|
|
|
1625
1876
|
// src/commands/canvas/commands/composition/unpublish.ts
|
|
1626
1877
|
import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2, UncachedCanvasClient as UncachedCanvasClient13 } from "@uniformdev/canvas";
|
|
1878
|
+
import { diffJson as diffJson2 } from "diff";
|
|
1627
1879
|
var CompositionUnpublishModule = {
|
|
1628
|
-
command: "unpublish
|
|
1629
|
-
describe: "Unpublish a composition",
|
|
1630
|
-
builder: (
|
|
1880
|
+
command: "unpublish [ids]",
|
|
1881
|
+
describe: "Unpublish a composition(s)",
|
|
1882
|
+
builder: (yargs25) => withConfiguration(
|
|
1631
1883
|
withApiOptions(
|
|
1632
1884
|
withProjectOptions(
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1885
|
+
yargs25.positional("ids", {
|
|
1886
|
+
describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
|
|
1887
|
+
type: "string"
|
|
1888
|
+
}).option("all", {
|
|
1889
|
+
alias: ["a"],
|
|
1890
|
+
describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
|
|
1891
|
+
default: false,
|
|
1892
|
+
type: "boolean"
|
|
1893
|
+
}).option("what-if", {
|
|
1894
|
+
alias: ["w"],
|
|
1895
|
+
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
1896
|
+
default: false,
|
|
1897
|
+
type: "boolean"
|
|
1898
|
+
}).option("onlyCompositions", {
|
|
1899
|
+
describe: "Only publishing compositions and not patterns",
|
|
1900
|
+
default: false,
|
|
1901
|
+
type: "boolean"
|
|
1902
|
+
}).option("onlyPatterns", {
|
|
1903
|
+
describe: "Only pulling patterns and not compositions",
|
|
1904
|
+
default: false,
|
|
1905
|
+
type: "boolean",
|
|
1906
|
+
hidden: true
|
|
1636
1907
|
})
|
|
1637
1908
|
)
|
|
1638
1909
|
)
|
|
1639
1910
|
),
|
|
1640
|
-
handler: async ({
|
|
1911
|
+
handler: async ({
|
|
1912
|
+
apiHost,
|
|
1913
|
+
apiKey,
|
|
1914
|
+
proxy,
|
|
1915
|
+
ids,
|
|
1916
|
+
all,
|
|
1917
|
+
onlyCompositions,
|
|
1918
|
+
onlyPatterns,
|
|
1919
|
+
project: projectId,
|
|
1920
|
+
diff,
|
|
1921
|
+
whatIf
|
|
1922
|
+
}) => {
|
|
1923
|
+
if (!all && !ids || all && ids) {
|
|
1924
|
+
console.error(`Specify --all or composition ID(s) to publish.`);
|
|
1925
|
+
process.exit(1);
|
|
1926
|
+
}
|
|
1927
|
+
const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
|
|
1928
|
+
const targetItems = /* @__PURE__ */ new Map();
|
|
1641
1929
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1642
1930
|
const client = new UncachedCanvasClient13({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
1643
|
-
|
|
1931
|
+
const source = createComponentInstanceEngineDataSource({
|
|
1932
|
+
client,
|
|
1933
|
+
state: "published",
|
|
1934
|
+
compositionIDs: compositionIDsArray,
|
|
1935
|
+
onlyCompositions,
|
|
1936
|
+
onlyPatterns
|
|
1937
|
+
});
|
|
1938
|
+
const target = createComponentInstanceEngineDataSource({
|
|
1939
|
+
client,
|
|
1940
|
+
state: "preview",
|
|
1941
|
+
compositionIDs: compositionIDsArray,
|
|
1942
|
+
onlyCompositions,
|
|
1943
|
+
onlyPatterns
|
|
1944
|
+
});
|
|
1945
|
+
const actions = [];
|
|
1946
|
+
const log = createSyncEngineConsoleLogger({ diffMode: diff });
|
|
1947
|
+
for await (const obj of target.objects) {
|
|
1948
|
+
if (Array.isArray(obj.id)) {
|
|
1949
|
+
obj.id.forEach((o) => targetItems.set(o, obj));
|
|
1950
|
+
} else {
|
|
1951
|
+
targetItems.set(obj.id, obj);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
for await (const sourceObject of source.objects) {
|
|
1955
|
+
const id = Array.isArray(sourceObject.id) ? sourceObject.id[0] : sourceObject.id;
|
|
1956
|
+
const targetObject = targetItems.get(id);
|
|
1957
|
+
if (!targetObject) {
|
|
1958
|
+
console.log(`Composition ${id} was not found`);
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
actions.push(client.removeComposition({ compositionId: id, state: CANVAS_PUBLISHED_STATE2 }));
|
|
1962
|
+
log({
|
|
1963
|
+
action: "update",
|
|
1964
|
+
id,
|
|
1965
|
+
providerId: sourceObject.providerId,
|
|
1966
|
+
displayName: sourceObject.displayName ?? sourceObject.providerId,
|
|
1967
|
+
whatIf,
|
|
1968
|
+
diff: diffJson2(targetObject.object, sourceObject.object)
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1644
1971
|
}
|
|
1645
1972
|
};
|
|
1646
1973
|
|
|
@@ -1650,11 +1977,11 @@ var CompositionUpdateModule = {
|
|
|
1650
1977
|
command: "update <filename>",
|
|
1651
1978
|
aliases: ["put"],
|
|
1652
1979
|
describe: "Insert or update a composition",
|
|
1653
|
-
builder: (
|
|
1980
|
+
builder: (yargs25) => withConfiguration(
|
|
1654
1981
|
withApiOptions(
|
|
1655
1982
|
withProjectOptions(
|
|
1656
1983
|
withStateOptions(
|
|
1657
|
-
|
|
1984
|
+
yargs25.positional("filename", { demandOption: true, describe: "Composition/pattern file to put" })
|
|
1658
1985
|
)
|
|
1659
1986
|
)
|
|
1660
1987
|
)
|
|
@@ -1672,14 +1999,291 @@ var CompositionModule = {
|
|
|
1672
1999
|
command: "composition <command>",
|
|
1673
2000
|
describe: "Commands for Canvas compositions",
|
|
1674
2001
|
aliases: ["comp"],
|
|
1675
|
-
builder: (
|
|
2002
|
+
builder: (yargs25) => yargs25.command(CompositionPullModule).command(CompositionPushModule).command(CompositionGetModule).command(CompositionRemoveModule).command(CompositionListModule).command(CompositionUpdateModule).command(CompositionPublishModule).command(CompositionUnpublishModule).demandCommand(),
|
|
2003
|
+
handler: () => {
|
|
2004
|
+
yargs3.help();
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
// src/commands/canvas/commands/contentType.ts
|
|
2009
|
+
import yargs4 from "yargs";
|
|
2010
|
+
|
|
2011
|
+
// src/commands/canvas/commands/contentType/get.ts
|
|
2012
|
+
import { ContentClient } from "@uniformdev/canvas";
|
|
2013
|
+
var ContentTypeGetModule = {
|
|
2014
|
+
command: "get <id>",
|
|
2015
|
+
describe: "Get a content type",
|
|
2016
|
+
builder: (yargs25) => withFormatOptions(
|
|
2017
|
+
withApiOptions(
|
|
2018
|
+
withProjectOptions(
|
|
2019
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2020
|
+
yargs25.positional("id", { demandOption: true, describe: "Content type public ID to fetch" })
|
|
2021
|
+
)
|
|
2022
|
+
)
|
|
2023
|
+
),
|
|
2024
|
+
handler: async ({ apiHost, apiKey, proxy, id, format, filename, project: projectId }) => {
|
|
2025
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2026
|
+
const client = new ContentClient({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2027
|
+
const res = await client.getContentTypes({ offset: 0, limit: 1e3 });
|
|
2028
|
+
const found = res.contentTypes.find((f) => f.id === id);
|
|
2029
|
+
if (!found) {
|
|
2030
|
+
throw new Error(`Content type with ID ${id} not found`);
|
|
2031
|
+
}
|
|
2032
|
+
emitWithFormat(found, format, filename);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
|
|
2036
|
+
// src/commands/canvas/commands/contentType/list.ts
|
|
2037
|
+
import { ContentClient as ContentClient2 } from "@uniformdev/canvas";
|
|
2038
|
+
var ContentTypeListModule = {
|
|
2039
|
+
command: "list",
|
|
2040
|
+
describe: "List content types",
|
|
2041
|
+
builder: (yargs25) => withFormatOptions(withApiOptions(withProjectOptions(yargs25))),
|
|
2042
|
+
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
2043
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2044
|
+
const client = new ContentClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2045
|
+
const res = await client.getContentTypes({ offset: 0, limit: 1e3 });
|
|
2046
|
+
emitWithFormat(res.contentTypes, format, filename);
|
|
2047
|
+
}
|
|
2048
|
+
};
|
|
2049
|
+
|
|
2050
|
+
// src/commands/canvas/commands/contentType/pull.ts
|
|
2051
|
+
import { ContentClient as ContentClient3 } from "@uniformdev/canvas";
|
|
2052
|
+
|
|
2053
|
+
// src/commands/canvas/commands/contentType/_util.ts
|
|
2054
|
+
var selectContentTypeIdentifier = (ct) => ct.id;
|
|
2055
|
+
var selectContentTypeDisplayName = (ct) => `${ct.name} (pid: ${ct.id})`;
|
|
2056
|
+
|
|
2057
|
+
// src/commands/canvas/contentTypeEngineDataSource.ts
|
|
2058
|
+
function createContentTypeEngineDataSource({
|
|
2059
|
+
client
|
|
2060
|
+
}) {
|
|
2061
|
+
async function* getObjects() {
|
|
2062
|
+
const { contentTypes } = await client.getContentTypes({ offset: 0, limit: 1e3 });
|
|
2063
|
+
for await (const ct of contentTypes) {
|
|
2064
|
+
const result = {
|
|
2065
|
+
id: selectContentTypeIdentifier(ct),
|
|
2066
|
+
displayName: selectContentTypeDisplayName(ct),
|
|
2067
|
+
providerId: ct.id,
|
|
2068
|
+
object: ct
|
|
2069
|
+
};
|
|
2070
|
+
yield result;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
return {
|
|
2074
|
+
objects: getObjects(),
|
|
2075
|
+
deleteObject: async (providerId) => {
|
|
2076
|
+
await client.deleteContentType({ contentTypeId: providerId });
|
|
2077
|
+
},
|
|
2078
|
+
writeObject: async ({ object }) => {
|
|
2079
|
+
await client.upsertContentType({ contentType: object });
|
|
2080
|
+
}
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
// src/commands/canvas/commands/contentType/pull.ts
|
|
2085
|
+
var ContentTypePullModule = {
|
|
2086
|
+
command: "pull <directory>",
|
|
2087
|
+
describe: "Pulls all content types to local files in a directory",
|
|
2088
|
+
builder: (yargs25) => withApiOptions(
|
|
2089
|
+
withProjectOptions(
|
|
2090
|
+
withDiffOptions(
|
|
2091
|
+
yargs25.positional("directory", {
|
|
2092
|
+
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.",
|
|
2093
|
+
type: "string"
|
|
2094
|
+
}).option("format", {
|
|
2095
|
+
alias: ["f"],
|
|
2096
|
+
describe: "Output format",
|
|
2097
|
+
default: "yaml",
|
|
2098
|
+
choices: ["yaml", "json"],
|
|
2099
|
+
type: "string"
|
|
2100
|
+
}).option("what-if", {
|
|
2101
|
+
alias: ["w"],
|
|
2102
|
+
describe: "What-if mode reports what would be done but changes no files",
|
|
2103
|
+
default: false,
|
|
2104
|
+
type: "boolean"
|
|
2105
|
+
}).option("mode", {
|
|
2106
|
+
alias: ["m"],
|
|
2107
|
+
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',
|
|
2108
|
+
choices: ["create", "createOrUpdate", "mirror"],
|
|
2109
|
+
default: "mirror",
|
|
2110
|
+
type: "string"
|
|
2111
|
+
})
|
|
2112
|
+
)
|
|
2113
|
+
)
|
|
2114
|
+
),
|
|
2115
|
+
handler: async ({
|
|
2116
|
+
apiHost,
|
|
2117
|
+
apiKey,
|
|
2118
|
+
proxy,
|
|
2119
|
+
directory,
|
|
2120
|
+
format,
|
|
2121
|
+
mode,
|
|
2122
|
+
whatIf,
|
|
2123
|
+
project: projectId,
|
|
2124
|
+
diff: diffMode
|
|
2125
|
+
}) => {
|
|
2126
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2127
|
+
const client = new ContentClient3({
|
|
2128
|
+
apiKey,
|
|
2129
|
+
apiHost,
|
|
2130
|
+
fetch: fetch3,
|
|
2131
|
+
projectId,
|
|
2132
|
+
bypassCache: true
|
|
2133
|
+
});
|
|
2134
|
+
const source = createContentTypeEngineDataSource({ client });
|
|
2135
|
+
let target;
|
|
2136
|
+
const isPackage = isPathAPackageFile(directory);
|
|
2137
|
+
if (isPackage) {
|
|
2138
|
+
const packageContents = readCanvasPackage(directory, false);
|
|
2139
|
+
target = await createArraySyncEngineDataSource({
|
|
2140
|
+
objects: packageContents.contentTypes ?? [],
|
|
2141
|
+
selectIdentifier: selectContentTypeIdentifier,
|
|
2142
|
+
selectDisplayName: selectContentTypeDisplayName,
|
|
2143
|
+
onSyncComplete: async (_, synced) => {
|
|
2144
|
+
packageContents.contentTypes = synced;
|
|
2145
|
+
writeCanvasPackage(directory, packageContents);
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2148
|
+
} else {
|
|
2149
|
+
target = await createFileSyncEngineDataSource({
|
|
2150
|
+
directory,
|
|
2151
|
+
selectIdentifier: selectContentTypeIdentifier,
|
|
2152
|
+
selectDisplayName: selectContentTypeDisplayName,
|
|
2153
|
+
format
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
await syncEngine({
|
|
2157
|
+
source,
|
|
2158
|
+
target,
|
|
2159
|
+
mode,
|
|
2160
|
+
whatIf,
|
|
2161
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2166
|
+
// src/commands/canvas/commands/contentType/push.ts
|
|
2167
|
+
import { ContentClient as ContentClient4 } from "@uniformdev/canvas";
|
|
2168
|
+
var ContentTypePushModule = {
|
|
2169
|
+
command: "push <directory>",
|
|
2170
|
+
describe: "Pushes all content types from files in a directory to Uniform",
|
|
2171
|
+
builder: (yargs25) => withApiOptions(
|
|
2172
|
+
withProjectOptions(
|
|
2173
|
+
withDiffOptions(
|
|
2174
|
+
yargs25.positional("directory", {
|
|
2175
|
+
describe: "Directory to read the content types from. If a filename is used, a package will be read instead.",
|
|
2176
|
+
type: "string"
|
|
2177
|
+
}).option("what-if", {
|
|
2178
|
+
alias: ["w"],
|
|
2179
|
+
describe: "What-if mode reports what would be done but changes nothing",
|
|
2180
|
+
default: false,
|
|
2181
|
+
type: "boolean"
|
|
2182
|
+
}).option("mode", {
|
|
2183
|
+
alias: ["m"],
|
|
2184
|
+
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',
|
|
2185
|
+
choices: ["create", "createOrUpdate", "mirror"],
|
|
2186
|
+
default: "mirror",
|
|
2187
|
+
type: "string"
|
|
2188
|
+
})
|
|
2189
|
+
)
|
|
2190
|
+
)
|
|
2191
|
+
),
|
|
2192
|
+
handler: async ({
|
|
2193
|
+
apiHost,
|
|
2194
|
+
apiKey,
|
|
2195
|
+
proxy,
|
|
2196
|
+
directory,
|
|
2197
|
+
mode,
|
|
2198
|
+
whatIf,
|
|
2199
|
+
project: projectId,
|
|
2200
|
+
diff: diffMode
|
|
2201
|
+
}) => {
|
|
2202
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2203
|
+
const client = new ContentClient4({
|
|
2204
|
+
apiKey,
|
|
2205
|
+
apiHost,
|
|
2206
|
+
fetch: fetch3,
|
|
2207
|
+
projectId,
|
|
2208
|
+
bypassCache: true
|
|
2209
|
+
});
|
|
2210
|
+
let source;
|
|
2211
|
+
const isPackage = isPathAPackageFile(directory);
|
|
2212
|
+
if (isPackage) {
|
|
2213
|
+
const packageContents = readCanvasPackage(directory, true);
|
|
2214
|
+
source = await createArraySyncEngineDataSource({
|
|
2215
|
+
objects: packageContents.contentTypes ?? [],
|
|
2216
|
+
selectIdentifier: selectContentTypeIdentifier,
|
|
2217
|
+
selectDisplayName: selectContentTypeDisplayName
|
|
2218
|
+
});
|
|
2219
|
+
} else {
|
|
2220
|
+
source = await createFileSyncEngineDataSource({
|
|
2221
|
+
directory,
|
|
2222
|
+
selectIdentifier: selectContentTypeIdentifier,
|
|
2223
|
+
selectDisplayName: selectContentTypeDisplayName
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
const target = createContentTypeEngineDataSource({ client });
|
|
2227
|
+
await syncEngine({
|
|
2228
|
+
source,
|
|
2229
|
+
target,
|
|
2230
|
+
mode,
|
|
2231
|
+
whatIf,
|
|
2232
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
// src/commands/canvas/commands/contentType/remove.ts
|
|
2238
|
+
import { ContentClient as ContentClient5 } from "@uniformdev/canvas";
|
|
2239
|
+
var ContentTypeRemoveModule = {
|
|
2240
|
+
command: "remove <id>",
|
|
2241
|
+
aliases: ["delete", "rm"],
|
|
2242
|
+
describe: "Delete a content type",
|
|
2243
|
+
builder: (yargs25) => withApiOptions(
|
|
2244
|
+
withProjectOptions(
|
|
2245
|
+
yargs25.positional("id", { demandOption: true, describe: "Content type public ID to delete" })
|
|
2246
|
+
)
|
|
2247
|
+
),
|
|
2248
|
+
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
2249
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2250
|
+
const client = new ContentClient5({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2251
|
+
await client.deleteContentType({ contentTypeId: id });
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
|
|
2255
|
+
// src/commands/canvas/commands/contentType/update.ts
|
|
2256
|
+
import { ContentClient as ContentClient6 } from "@uniformdev/canvas";
|
|
2257
|
+
var ContentTypeUpdateModule = {
|
|
2258
|
+
command: "update <filename>",
|
|
2259
|
+
aliases: ["put"],
|
|
2260
|
+
describe: "Insert or update a content type",
|
|
2261
|
+
builder: (yargs25) => withApiOptions(
|
|
2262
|
+
withProjectOptions(
|
|
2263
|
+
yargs25.positional("filename", { demandOption: true, describe: "Content type file to put" })
|
|
2264
|
+
)
|
|
2265
|
+
),
|
|
2266
|
+
handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
|
|
2267
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2268
|
+
const client = new ContentClient6({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2269
|
+
const file = readFileToObject(filename);
|
|
2270
|
+
await client.upsertContentType({ contentType: file });
|
|
2271
|
+
}
|
|
2272
|
+
};
|
|
2273
|
+
|
|
2274
|
+
// src/commands/canvas/commands/contentType.ts
|
|
2275
|
+
var ContentTypeModule = {
|
|
2276
|
+
command: "contenttype <command>",
|
|
2277
|
+
aliases: ["ct"],
|
|
2278
|
+
describe: "Commands for Content Types",
|
|
2279
|
+
builder: (yargs25) => yargs25.command(ContentTypeGetModule).command(ContentTypeListModule).command(ContentTypeRemoveModule).command(ContentTypeUpdateModule).command(ContentTypePullModule).command(ContentTypePushModule).demandCommand(),
|
|
1676
2280
|
handler: () => {
|
|
1677
|
-
|
|
2281
|
+
yargs4.help();
|
|
1678
2282
|
}
|
|
1679
2283
|
};
|
|
1680
2284
|
|
|
1681
2285
|
// src/commands/canvas/commands/dataType.ts
|
|
1682
|
-
import
|
|
2286
|
+
import yargs5 from "yargs";
|
|
1683
2287
|
|
|
1684
2288
|
// src/commands/canvas/commands/dataType/get.ts
|
|
1685
2289
|
import { DataTypeClient } from "@uniformdev/canvas";
|
|
@@ -1687,12 +2291,12 @@ var DataTypeGetModule = {
|
|
|
1687
2291
|
command: "get <id>",
|
|
1688
2292
|
describe: "Get a data type",
|
|
1689
2293
|
aliases: ["ls"],
|
|
1690
|
-
builder: (
|
|
2294
|
+
builder: (yargs25) => withConfiguration(
|
|
1691
2295
|
withFormatOptions(
|
|
1692
2296
|
withApiOptions(
|
|
1693
2297
|
withProjectOptions(
|
|
1694
2298
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1695
|
-
|
|
2299
|
+
yargs25.positional("id", { demandOption: true, describe: "Data type public ID to fetch" })
|
|
1696
2300
|
)
|
|
1697
2301
|
)
|
|
1698
2302
|
)
|
|
@@ -1715,7 +2319,7 @@ var DataTypeListModule = {
|
|
|
1715
2319
|
command: "list",
|
|
1716
2320
|
describe: "List data types",
|
|
1717
2321
|
aliases: ["ls"],
|
|
1718
|
-
builder: (
|
|
2322
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
1719
2323
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
1720
2324
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1721
2325
|
const client = new DataTypeClient2({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
@@ -1764,11 +2368,11 @@ function createDataTypeEngineDataSource({
|
|
|
1764
2368
|
var DataTypePullModule = {
|
|
1765
2369
|
command: "pull <directory>",
|
|
1766
2370
|
describe: "Pulls all data types to local files in a directory",
|
|
1767
|
-
builder: (
|
|
2371
|
+
builder: (yargs25) => withConfiguration(
|
|
1768
2372
|
withApiOptions(
|
|
1769
2373
|
withProjectOptions(
|
|
1770
2374
|
withDiffOptions(
|
|
1771
|
-
|
|
2375
|
+
yargs25.positional("directory", {
|
|
1772
2376
|
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.",
|
|
1773
2377
|
type: "string"
|
|
1774
2378
|
}).option("format", {
|
|
@@ -1849,11 +2453,11 @@ import { DataTypeClient as DataTypeClient4 } from "@uniformdev/canvas";
|
|
|
1849
2453
|
var DataTypePushModule = {
|
|
1850
2454
|
command: "push <directory>",
|
|
1851
2455
|
describe: "Pushes all data types from files in a directory to Uniform",
|
|
1852
|
-
builder: (
|
|
2456
|
+
builder: (yargs25) => withConfiguration(
|
|
1853
2457
|
withApiOptions(
|
|
1854
2458
|
withProjectOptions(
|
|
1855
2459
|
withDiffOptions(
|
|
1856
|
-
|
|
2460
|
+
yargs25.positional("directory", {
|
|
1857
2461
|
describe: "Directory to read the data types from. If a filename is used, a package will be read instead.",
|
|
1858
2462
|
type: "string"
|
|
1859
2463
|
}).option("what-if", {
|
|
@@ -1923,10 +2527,10 @@ var DataTypeRemoveModule = {
|
|
|
1923
2527
|
command: "remove <id>",
|
|
1924
2528
|
aliases: ["delete", "rm"],
|
|
1925
2529
|
describe: "Delete a data type",
|
|
1926
|
-
builder: (
|
|
2530
|
+
builder: (yargs25) => withConfiguration(
|
|
1927
2531
|
withApiOptions(
|
|
1928
2532
|
withProjectOptions(
|
|
1929
|
-
|
|
2533
|
+
yargs25.positional("id", { demandOption: true, describe: "Data type public ID to delete" })
|
|
1930
2534
|
)
|
|
1931
2535
|
)
|
|
1932
2536
|
),
|
|
@@ -1943,10 +2547,10 @@ var DataTypeUpdateModule = {
|
|
|
1943
2547
|
command: "update <filename>",
|
|
1944
2548
|
aliases: ["put"],
|
|
1945
2549
|
describe: "Insert or update a data type",
|
|
1946
|
-
builder: (
|
|
2550
|
+
builder: (yargs25) => withConfiguration(
|
|
1947
2551
|
withApiOptions(
|
|
1948
2552
|
withProjectOptions(
|
|
1949
|
-
|
|
2553
|
+
yargs25.positional("filename", { demandOption: true, describe: "Data type file to put" })
|
|
1950
2554
|
)
|
|
1951
2555
|
)
|
|
1952
2556
|
),
|
|
@@ -1963,14 +2567,287 @@ var DataTypeModule = {
|
|
|
1963
2567
|
command: "datatype <command>",
|
|
1964
2568
|
aliases: ["dt"],
|
|
1965
2569
|
describe: "Commands for Data Type definitions",
|
|
1966
|
-
builder: (
|
|
2570
|
+
builder: (yargs25) => yargs25.command(DataTypeGetModule).command(DataTypePullModule).command(DataTypePushModule).command(DataTypeRemoveModule).command(DataTypeListModule).command(DataTypeUpdateModule).demandCommand(),
|
|
1967
2571
|
handler: () => {
|
|
1968
|
-
|
|
2572
|
+
yargs5.help();
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
2575
|
+
|
|
2576
|
+
// src/commands/canvas/commands/entry.ts
|
|
2577
|
+
import yargs6 from "yargs";
|
|
2578
|
+
|
|
2579
|
+
// src/commands/canvas/commands/entry/get.ts
|
|
2580
|
+
import { ContentClient as ContentClient7 } from "@uniformdev/canvas";
|
|
2581
|
+
var EntryGetModule = {
|
|
2582
|
+
command: "get <id>",
|
|
2583
|
+
describe: "Get an entry",
|
|
2584
|
+
builder: (yargs25) => withFormatOptions(
|
|
2585
|
+
withApiOptions(
|
|
2586
|
+
withProjectOptions(
|
|
2587
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2588
|
+
yargs25.positional("id", { demandOption: true, describe: "Entry public ID to fetch" })
|
|
2589
|
+
)
|
|
2590
|
+
)
|
|
2591
|
+
),
|
|
2592
|
+
handler: async ({ apiHost, apiKey, proxy, id, format, filename, project: projectId }) => {
|
|
2593
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2594
|
+
const client = new ContentClient7({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2595
|
+
const res = await client.getEntries({ offset: 0, limit: 1, entryIDs: [id] });
|
|
2596
|
+
if (res.entries.length !== 1) {
|
|
2597
|
+
throw new Error(`Entry with ID ${id} not found`);
|
|
2598
|
+
}
|
|
2599
|
+
emitWithFormat(res.entries[0], format, filename);
|
|
2600
|
+
}
|
|
2601
|
+
};
|
|
2602
|
+
|
|
2603
|
+
// src/commands/canvas/commands/entry/list.ts
|
|
2604
|
+
import { ContentClient as ContentClient8 } from "@uniformdev/canvas";
|
|
2605
|
+
var EntryListModule = {
|
|
2606
|
+
command: "list",
|
|
2607
|
+
describe: "List entries",
|
|
2608
|
+
builder: (yargs25) => withFormatOptions(withApiOptions(withProjectOptions(yargs25))),
|
|
2609
|
+
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
2610
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2611
|
+
const client = new ContentClient8({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2612
|
+
const res = await client.getEntries({ offset: 0, limit: 1e3 });
|
|
2613
|
+
emitWithFormat(res.entries, format, filename);
|
|
2614
|
+
}
|
|
2615
|
+
};
|
|
2616
|
+
|
|
2617
|
+
// src/commands/canvas/commands/entry/pull.ts
|
|
2618
|
+
import { ContentClient as ContentClient9 } from "@uniformdev/canvas";
|
|
2619
|
+
|
|
2620
|
+
// src/commands/canvas/commands/entry/_util.ts
|
|
2621
|
+
var selectEntryIdentifier = (e) => e.entry._id;
|
|
2622
|
+
var selectEntryDisplayName = (e) => `${e.entry._name ?? "Untitled"} (pid: ${e.entry._id})`;
|
|
2623
|
+
|
|
2624
|
+
// src/commands/canvas/entryEngineDataSource.ts
|
|
2625
|
+
function createEntryEngineDataSource({
|
|
2626
|
+
client
|
|
2627
|
+
}) {
|
|
2628
|
+
async function* getObjects() {
|
|
2629
|
+
const { entries } = await client.getEntries({ offset: 0, limit: 1e3 });
|
|
2630
|
+
for await (const e of entries) {
|
|
2631
|
+
const result = {
|
|
2632
|
+
id: selectEntryIdentifier(e),
|
|
2633
|
+
displayName: selectEntryDisplayName(e),
|
|
2634
|
+
providerId: e.entry._id,
|
|
2635
|
+
object: e
|
|
2636
|
+
};
|
|
2637
|
+
yield result;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
return {
|
|
2641
|
+
objects: getObjects(),
|
|
2642
|
+
deleteObject: async (providerId) => {
|
|
2643
|
+
await client.deleteEntry({ entryId: providerId });
|
|
2644
|
+
},
|
|
2645
|
+
writeObject: async ({ object }) => {
|
|
2646
|
+
await client.upsertEntry(object);
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
// src/commands/canvas/commands/entry/pull.ts
|
|
2652
|
+
var EntryPullModule = {
|
|
2653
|
+
command: "pull <directory>",
|
|
2654
|
+
describe: "Pulls all entries to local files in a directory",
|
|
2655
|
+
builder: (yargs25) => withApiOptions(
|
|
2656
|
+
withProjectOptions(
|
|
2657
|
+
withDiffOptions(
|
|
2658
|
+
yargs25.positional("directory", {
|
|
2659
|
+
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.",
|
|
2660
|
+
type: "string"
|
|
2661
|
+
}).option("format", {
|
|
2662
|
+
alias: ["f"],
|
|
2663
|
+
describe: "Output format",
|
|
2664
|
+
default: "yaml",
|
|
2665
|
+
choices: ["yaml", "json"],
|
|
2666
|
+
type: "string"
|
|
2667
|
+
}).option("what-if", {
|
|
2668
|
+
alias: ["w"],
|
|
2669
|
+
describe: "What-if mode reports what would be done but changes no files",
|
|
2670
|
+
default: false,
|
|
2671
|
+
type: "boolean"
|
|
2672
|
+
}).option("mode", {
|
|
2673
|
+
alias: ["m"],
|
|
2674
|
+
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',
|
|
2675
|
+
choices: ["create", "createOrUpdate", "mirror"],
|
|
2676
|
+
default: "mirror",
|
|
2677
|
+
type: "string"
|
|
2678
|
+
})
|
|
2679
|
+
)
|
|
2680
|
+
)
|
|
2681
|
+
),
|
|
2682
|
+
handler: async ({
|
|
2683
|
+
apiHost,
|
|
2684
|
+
apiKey,
|
|
2685
|
+
proxy,
|
|
2686
|
+
directory,
|
|
2687
|
+
format,
|
|
2688
|
+
mode,
|
|
2689
|
+
whatIf,
|
|
2690
|
+
project: projectId,
|
|
2691
|
+
diff: diffMode
|
|
2692
|
+
}) => {
|
|
2693
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2694
|
+
const client = new ContentClient9({
|
|
2695
|
+
apiKey,
|
|
2696
|
+
apiHost,
|
|
2697
|
+
fetch: fetch3,
|
|
2698
|
+
projectId,
|
|
2699
|
+
bypassCache: true
|
|
2700
|
+
});
|
|
2701
|
+
const source = createEntryEngineDataSource({ client });
|
|
2702
|
+
let target;
|
|
2703
|
+
const isPackage = isPathAPackageFile(directory);
|
|
2704
|
+
if (isPackage) {
|
|
2705
|
+
const packageContents = readCanvasPackage(directory, false);
|
|
2706
|
+
target = await createArraySyncEngineDataSource({
|
|
2707
|
+
objects: packageContents.entries ?? [],
|
|
2708
|
+
selectIdentifier: selectEntryIdentifier,
|
|
2709
|
+
selectDisplayName: selectEntryDisplayName,
|
|
2710
|
+
onSyncComplete: async (_, synced) => {
|
|
2711
|
+
packageContents.entries = synced;
|
|
2712
|
+
writeCanvasPackage(directory, packageContents);
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
} else {
|
|
2716
|
+
target = await createFileSyncEngineDataSource({
|
|
2717
|
+
directory,
|
|
2718
|
+
selectIdentifier: selectEntryIdentifier,
|
|
2719
|
+
selectDisplayName: selectEntryDisplayName,
|
|
2720
|
+
format
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
await syncEngine({
|
|
2724
|
+
source,
|
|
2725
|
+
target,
|
|
2726
|
+
mode,
|
|
2727
|
+
whatIf,
|
|
2728
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
};
|
|
2732
|
+
|
|
2733
|
+
// src/commands/canvas/commands/entry/push.ts
|
|
2734
|
+
import { ContentClient as ContentClient10 } from "@uniformdev/canvas";
|
|
2735
|
+
var EntryPushModule = {
|
|
2736
|
+
command: "push <directory>",
|
|
2737
|
+
describe: "Pushes all entries from files in a directory to Uniform",
|
|
2738
|
+
builder: (yargs25) => withApiOptions(
|
|
2739
|
+
withProjectOptions(
|
|
2740
|
+
withDiffOptions(
|
|
2741
|
+
yargs25.positional("directory", {
|
|
2742
|
+
describe: "Directory to read the entries from. If a filename is used, a package will be read instead.",
|
|
2743
|
+
type: "string"
|
|
2744
|
+
}).option("what-if", {
|
|
2745
|
+
alias: ["w"],
|
|
2746
|
+
describe: "What-if mode reports what would be done but changes nothing",
|
|
2747
|
+
default: false,
|
|
2748
|
+
type: "boolean"
|
|
2749
|
+
}).option("mode", {
|
|
2750
|
+
alias: ["m"],
|
|
2751
|
+
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',
|
|
2752
|
+
choices: ["create", "createOrUpdate", "mirror"],
|
|
2753
|
+
default: "mirror",
|
|
2754
|
+
type: "string"
|
|
2755
|
+
})
|
|
2756
|
+
)
|
|
2757
|
+
)
|
|
2758
|
+
),
|
|
2759
|
+
handler: async ({
|
|
2760
|
+
apiHost,
|
|
2761
|
+
apiKey,
|
|
2762
|
+
proxy,
|
|
2763
|
+
directory,
|
|
2764
|
+
mode,
|
|
2765
|
+
whatIf,
|
|
2766
|
+
project: projectId,
|
|
2767
|
+
diff: diffMode
|
|
2768
|
+
}) => {
|
|
2769
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2770
|
+
const client = new ContentClient10({
|
|
2771
|
+
apiKey,
|
|
2772
|
+
apiHost,
|
|
2773
|
+
fetch: fetch3,
|
|
2774
|
+
projectId,
|
|
2775
|
+
bypassCache: true
|
|
2776
|
+
});
|
|
2777
|
+
let source;
|
|
2778
|
+
const isPackage = isPathAPackageFile(directory);
|
|
2779
|
+
if (isPackage) {
|
|
2780
|
+
const packageContents = readCanvasPackage(directory, true);
|
|
2781
|
+
source = await createArraySyncEngineDataSource({
|
|
2782
|
+
objects: packageContents.entries ?? [],
|
|
2783
|
+
selectIdentifier: selectEntryIdentifier,
|
|
2784
|
+
selectDisplayName: selectEntryDisplayName
|
|
2785
|
+
});
|
|
2786
|
+
} else {
|
|
2787
|
+
source = await createFileSyncEngineDataSource({
|
|
2788
|
+
directory,
|
|
2789
|
+
selectIdentifier: selectEntryIdentifier,
|
|
2790
|
+
selectDisplayName: selectEntryDisplayName
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
const target = createEntryEngineDataSource({ client });
|
|
2794
|
+
await syncEngine({
|
|
2795
|
+
source,
|
|
2796
|
+
target,
|
|
2797
|
+
mode,
|
|
2798
|
+
whatIf,
|
|
2799
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
};
|
|
2803
|
+
|
|
2804
|
+
// src/commands/canvas/commands/entry/remove.ts
|
|
2805
|
+
import { ContentClient as ContentClient11 } from "@uniformdev/canvas";
|
|
2806
|
+
var EntryRemoveModule = {
|
|
2807
|
+
command: "remove <id>",
|
|
2808
|
+
aliases: ["delete", "rm"],
|
|
2809
|
+
describe: "Delete an entry",
|
|
2810
|
+
builder: (yargs25) => withApiOptions(
|
|
2811
|
+
withProjectOptions(
|
|
2812
|
+
yargs25.positional("id", { demandOption: true, describe: "Entry public ID to delete" })
|
|
2813
|
+
)
|
|
2814
|
+
),
|
|
2815
|
+
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
2816
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2817
|
+
const client = new ContentClient11({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2818
|
+
await client.deleteEntry({ entryId: id });
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
|
|
2822
|
+
// src/commands/canvas/commands/entry/update.ts
|
|
2823
|
+
import { ContentClient as ContentClient12 } from "@uniformdev/canvas";
|
|
2824
|
+
var EntryUpdateModule = {
|
|
2825
|
+
command: "update <filename>",
|
|
2826
|
+
aliases: ["put"],
|
|
2827
|
+
describe: "Insert or update an entry",
|
|
2828
|
+
builder: (yargs25) => withApiOptions(
|
|
2829
|
+
withProjectOptions(yargs25.positional("filename", { demandOption: true, describe: "Entry file to put" }))
|
|
2830
|
+
),
|
|
2831
|
+
handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
|
|
2832
|
+
const fetch3 = nodeFetchProxy(proxy);
|
|
2833
|
+
const client = new ContentClient12({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
|
|
2834
|
+
const file = readFileToObject(filename);
|
|
2835
|
+
await client.upsertEntry(file);
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
|
|
2839
|
+
// src/commands/canvas/commands/entry.ts
|
|
2840
|
+
var EntryModule = {
|
|
2841
|
+
command: "entry <command>",
|
|
2842
|
+
describe: "Commands for Entries",
|
|
2843
|
+
builder: (yargs25) => yargs25.command(EntryGetModule).command(EntryListModule).command(EntryRemoveModule).command(EntryUpdateModule).command(EntryPullModule).command(EntryPushModule).demandCommand(),
|
|
2844
|
+
handler: () => {
|
|
2845
|
+
yargs6.help();
|
|
1969
2846
|
}
|
|
1970
2847
|
};
|
|
1971
2848
|
|
|
1972
2849
|
// src/commands/canvas/commands/pattern.ts
|
|
1973
|
-
import
|
|
2850
|
+
import yargs7 from "yargs";
|
|
1974
2851
|
|
|
1975
2852
|
// src/commands/canvas/commands/pattern/get.ts
|
|
1976
2853
|
var PatternGetModule = {
|
|
@@ -1982,12 +2859,12 @@ var PatternGetModule = {
|
|
|
1982
2859
|
var PatternListModule = {
|
|
1983
2860
|
...CompositionListModule,
|
|
1984
2861
|
describe: "List patterns",
|
|
1985
|
-
builder: (
|
|
2862
|
+
builder: (yargs25) => withFormatOptions(
|
|
1986
2863
|
withConfiguration(
|
|
1987
2864
|
withApiOptions(
|
|
1988
2865
|
withProjectOptions(
|
|
1989
2866
|
withStateOptions(
|
|
1990
|
-
|
|
2867
|
+
yargs25.options({
|
|
1991
2868
|
offset: { describe: "Number of rows to skip before fetching", type: "number", default: 0 },
|
|
1992
2869
|
limit: { describe: "Number of rows to fetch", type: "number", default: 20 },
|
|
1993
2870
|
resolvePatterns: {
|
|
@@ -2024,19 +2901,55 @@ var PatternListModule = {
|
|
|
2024
2901
|
// src/commands/canvas/commands/pattern/publish.ts
|
|
2025
2902
|
var PatternPublishModule = {
|
|
2026
2903
|
...CompositionPublishModule,
|
|
2027
|
-
describe: "Publishes
|
|
2904
|
+
describe: "Publishes pattern(s)",
|
|
2905
|
+
builder: (yargs25) => withConfiguration(
|
|
2906
|
+
withApiOptions(
|
|
2907
|
+
withProjectOptions(
|
|
2908
|
+
withDiffOptions(
|
|
2909
|
+
yargs25.positional("ids", {
|
|
2910
|
+
describe: "Publishes pattern(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
|
|
2911
|
+
type: "string"
|
|
2912
|
+
}).option("all", {
|
|
2913
|
+
alias: ["a"],
|
|
2914
|
+
describe: "Publishes all patterns. Use compositionId to publish one instead.",
|
|
2915
|
+
default: false,
|
|
2916
|
+
type: "boolean"
|
|
2917
|
+
}).option("what-if", {
|
|
2918
|
+
alias: ["w"],
|
|
2919
|
+
describe: "What-if mode reports what would be done but does not perform any un-publishing",
|
|
2920
|
+
default: false,
|
|
2921
|
+
type: "boolean"
|
|
2922
|
+
}).option("publishingState", {
|
|
2923
|
+
describe: 'Publishing state to update to. Can be "published" or "preview".',
|
|
2924
|
+
default: "published",
|
|
2925
|
+
type: "string",
|
|
2926
|
+
hidden: true
|
|
2927
|
+
}).option("onlyCompositions", {
|
|
2928
|
+
describe: "Only publishing compositions and not patterns",
|
|
2929
|
+
default: false,
|
|
2930
|
+
type: "boolean"
|
|
2931
|
+
}).option("onlyPatterns", {
|
|
2932
|
+
describe: "Only pulling patterns and not compositions",
|
|
2933
|
+
default: true,
|
|
2934
|
+
type: "boolean",
|
|
2935
|
+
hidden: true
|
|
2936
|
+
})
|
|
2937
|
+
)
|
|
2938
|
+
)
|
|
2939
|
+
)
|
|
2940
|
+
)
|
|
2028
2941
|
};
|
|
2029
2942
|
|
|
2030
2943
|
// src/commands/canvas/commands/pattern/pull.ts
|
|
2031
2944
|
var PatternPullModule = {
|
|
2032
2945
|
...CompositionPullModule,
|
|
2033
2946
|
describe: "Pulls all patterns to local files in a directory",
|
|
2034
|
-
builder: (
|
|
2947
|
+
builder: (yargs25) => withConfiguration(
|
|
2035
2948
|
withApiOptions(
|
|
2036
2949
|
withProjectOptions(
|
|
2037
2950
|
withStateOptions(
|
|
2038
2951
|
withDiffOptions(
|
|
2039
|
-
|
|
2952
|
+
yargs25.positional("directory", {
|
|
2040
2953
|
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.",
|
|
2041
2954
|
type: "string"
|
|
2042
2955
|
}).option("format", {
|
|
@@ -2074,12 +2987,12 @@ var PatternPullModule = {
|
|
|
2074
2987
|
var PatternPushModule = {
|
|
2075
2988
|
...CompositionPushModule,
|
|
2076
2989
|
describe: "Pushes all patterns from files in a directory to Uniform Canvas",
|
|
2077
|
-
builder: (
|
|
2990
|
+
builder: (yargs25) => withConfiguration(
|
|
2078
2991
|
withApiOptions(
|
|
2079
2992
|
withProjectOptions(
|
|
2080
2993
|
withStateOptions(
|
|
2081
2994
|
withDiffOptions(
|
|
2082
|
-
|
|
2995
|
+
yargs25.positional("directory", {
|
|
2083
2996
|
describe: "Directory to read the compositions/patterns from. If a filename is used, a package will be read instead.",
|
|
2084
2997
|
type: "string"
|
|
2085
2998
|
}).option("what-if", {
|
|
@@ -2115,8 +3028,38 @@ var PatternRemoveModule = {
|
|
|
2115
3028
|
|
|
2116
3029
|
// src/commands/canvas/commands/pattern/unpublish.ts
|
|
2117
3030
|
var PatternUnpublishModule = {
|
|
2118
|
-
|
|
2119
|
-
describe: "Unpublish a pattern"
|
|
3031
|
+
command: "unpublish [ids]",
|
|
3032
|
+
describe: "Unpublish a pattern(s)",
|
|
3033
|
+
builder: (yargs25) => withConfiguration(
|
|
3034
|
+
withApiOptions(
|
|
3035
|
+
withProjectOptions(
|
|
3036
|
+
yargs25.positional("ids", {
|
|
3037
|
+
describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
|
|
3038
|
+
type: "string"
|
|
3039
|
+
}).option("all", {
|
|
3040
|
+
alias: ["a"],
|
|
3041
|
+
describe: "Un-pPublishes all compositions. Use compositionId to publish one instead.",
|
|
3042
|
+
default: false,
|
|
3043
|
+
type: "boolean"
|
|
3044
|
+
}).option("what-if", {
|
|
3045
|
+
alias: ["w"],
|
|
3046
|
+
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
3047
|
+
default: false,
|
|
3048
|
+
type: "boolean"
|
|
3049
|
+
}).option("onlyCompositions", {
|
|
3050
|
+
describe: "Only publishing compositions and not patterns",
|
|
3051
|
+
default: false,
|
|
3052
|
+
type: "boolean"
|
|
3053
|
+
}).option("onlyPatterns", {
|
|
3054
|
+
describe: "Only pulling patterns and not compositions",
|
|
3055
|
+
default: true,
|
|
3056
|
+
type: "boolean",
|
|
3057
|
+
hidden: true
|
|
3058
|
+
})
|
|
3059
|
+
)
|
|
3060
|
+
)
|
|
3061
|
+
),
|
|
3062
|
+
handler: CompositionUnpublishModule.handler
|
|
2120
3063
|
};
|
|
2121
3064
|
|
|
2122
3065
|
// src/commands/canvas/commands/pattern/update.ts
|
|
@@ -2129,9 +3072,9 @@ var PatternUpdateModule = {
|
|
|
2129
3072
|
var PatternModule = {
|
|
2130
3073
|
command: "pattern <command>",
|
|
2131
3074
|
describe: "Commands for Canvas patterns",
|
|
2132
|
-
builder: (
|
|
3075
|
+
builder: (yargs25) => yargs25.command(PatternPullModule).command(PatternPushModule).command(PatternGetModule).command(PatternRemoveModule).command(PatternListModule).command(PatternUpdateModule).command(PatternPublishModule).command(PatternUnpublishModule).demandCommand(),
|
|
2133
3076
|
handler: () => {
|
|
2134
|
-
|
|
3077
|
+
yargs7.help();
|
|
2135
3078
|
}
|
|
2136
3079
|
};
|
|
2137
3080
|
|
|
@@ -2140,28 +3083,28 @@ var CanvasCommand = {
|
|
|
2140
3083
|
command: "canvas <command>",
|
|
2141
3084
|
aliases: ["cv", "pm", "presentation"],
|
|
2142
3085
|
describe: "Uniform Canvas commands",
|
|
2143
|
-
builder: (
|
|
3086
|
+
builder: (yargs25) => yargs25.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(CategoryModule).command(PatternModule).command(ContentTypeModule).command(EntryModule).demandCommand(),
|
|
2144
3087
|
handler: () => {
|
|
2145
|
-
|
|
3088
|
+
yargs8.showHelp();
|
|
2146
3089
|
}
|
|
2147
3090
|
};
|
|
2148
3091
|
|
|
2149
3092
|
// src/commands/context/index.ts
|
|
2150
|
-
import
|
|
3093
|
+
import yargs15 from "yargs";
|
|
2151
3094
|
|
|
2152
3095
|
// src/commands/context/commands/aggregate.ts
|
|
2153
|
-
import
|
|
3096
|
+
import yargs9 from "yargs";
|
|
2154
3097
|
|
|
2155
3098
|
// src/commands/context/commands/aggregate/get.ts
|
|
2156
3099
|
import { UncachedAggregateClient } from "@uniformdev/context/api";
|
|
2157
3100
|
var AggregateGetModule = {
|
|
2158
3101
|
command: "get <id>",
|
|
2159
3102
|
describe: "Fetch an aggregate",
|
|
2160
|
-
builder: (
|
|
3103
|
+
builder: (yargs25) => withConfiguration(
|
|
2161
3104
|
withFormatOptions(
|
|
2162
3105
|
withApiOptions(
|
|
2163
3106
|
withProjectOptions(
|
|
2164
|
-
|
|
3107
|
+
yargs25.positional("id", { demandOption: true, describe: "Aggregate public ID to fetch" })
|
|
2165
3108
|
)
|
|
2166
3109
|
)
|
|
2167
3110
|
)
|
|
@@ -2185,7 +3128,7 @@ var AggregateListModule = {
|
|
|
2185
3128
|
command: "list",
|
|
2186
3129
|
describe: "List aggregates",
|
|
2187
3130
|
aliases: ["ls"],
|
|
2188
|
-
builder: (
|
|
3131
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
2189
3132
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
2190
3133
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2191
3134
|
const client = new UncachedAggregateClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -2251,11 +3194,11 @@ function writeContextPackage(filename, packageContents) {
|
|
|
2251
3194
|
var AggregatePullModule = {
|
|
2252
3195
|
command: "pull <directory>",
|
|
2253
3196
|
describe: "Pulls all aggregates to local files in a directory",
|
|
2254
|
-
builder: (
|
|
3197
|
+
builder: (yargs25) => withConfiguration(
|
|
2255
3198
|
withApiOptions(
|
|
2256
3199
|
withProjectOptions(
|
|
2257
3200
|
withDiffOptions(
|
|
2258
|
-
|
|
3201
|
+
yargs25.positional("directory", {
|
|
2259
3202
|
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.",
|
|
2260
3203
|
type: "string"
|
|
2261
3204
|
}).option("format", {
|
|
@@ -2330,11 +3273,11 @@ import { UncachedAggregateClient as UncachedAggregateClient4 } from "@uniformdev
|
|
|
2330
3273
|
var AggregatePushModule = {
|
|
2331
3274
|
command: "push <directory>",
|
|
2332
3275
|
describe: "Pushes all aggregates from files in a directory or package to Uniform",
|
|
2333
|
-
builder: (
|
|
3276
|
+
builder: (yargs25) => withConfiguration(
|
|
2334
3277
|
withApiOptions(
|
|
2335
3278
|
withProjectOptions(
|
|
2336
3279
|
withDiffOptions(
|
|
2337
|
-
|
|
3280
|
+
yargs25.positional("directory", {
|
|
2338
3281
|
describe: "Directory to read the aggregates from. If a filename is used, a package will be read instead.",
|
|
2339
3282
|
type: "string"
|
|
2340
3283
|
}).option("what-if", {
|
|
@@ -2399,10 +3342,10 @@ var AggregateRemoveModule = {
|
|
|
2399
3342
|
command: "remove <id>",
|
|
2400
3343
|
aliases: ["delete", "rm"],
|
|
2401
3344
|
describe: "Delete an aggregate",
|
|
2402
|
-
builder: (
|
|
3345
|
+
builder: (yargs25) => withConfiguration(
|
|
2403
3346
|
withApiOptions(
|
|
2404
3347
|
withProjectOptions(
|
|
2405
|
-
|
|
3348
|
+
yargs25.positional("id", { demandOption: true, describe: "Aggregate public ID to delete" })
|
|
2406
3349
|
)
|
|
2407
3350
|
)
|
|
2408
3351
|
),
|
|
@@ -2419,10 +3362,10 @@ var AggregateUpdateModule = {
|
|
|
2419
3362
|
command: "update <filename>",
|
|
2420
3363
|
aliases: ["put"],
|
|
2421
3364
|
describe: "Insert or update an aggregate",
|
|
2422
|
-
builder: (
|
|
3365
|
+
builder: (yargs25) => withConfiguration(
|
|
2423
3366
|
withApiOptions(
|
|
2424
3367
|
withProjectOptions(
|
|
2425
|
-
|
|
3368
|
+
yargs25.positional("filename", { demandOption: true, describe: "Aggregate file to put" })
|
|
2426
3369
|
)
|
|
2427
3370
|
)
|
|
2428
3371
|
),
|
|
@@ -2439,25 +3382,25 @@ var AggregateModule = {
|
|
|
2439
3382
|
command: "aggregate <command>",
|
|
2440
3383
|
aliases: ["agg", "intent", "audience"],
|
|
2441
3384
|
describe: "Commands for Context aggregates (intents, audiences)",
|
|
2442
|
-
builder: (
|
|
3385
|
+
builder: (yargs25) => yargs25.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
|
|
2443
3386
|
handler: () => {
|
|
2444
|
-
|
|
3387
|
+
yargs9.help();
|
|
2445
3388
|
}
|
|
2446
3389
|
};
|
|
2447
3390
|
|
|
2448
3391
|
// src/commands/context/commands/enrichment.ts
|
|
2449
|
-
import
|
|
3392
|
+
import yargs10 from "yargs";
|
|
2450
3393
|
|
|
2451
3394
|
// src/commands/context/commands/enrichment/get.ts
|
|
2452
3395
|
import { UncachedEnrichmentClient } from "@uniformdev/context/api";
|
|
2453
3396
|
var EnrichmentGetModule = {
|
|
2454
3397
|
command: "get <id>",
|
|
2455
3398
|
describe: "Fetch an enrichment category and its values",
|
|
2456
|
-
builder: (
|
|
3399
|
+
builder: (yargs25) => withFormatOptions(
|
|
2457
3400
|
withConfiguration(
|
|
2458
3401
|
withApiOptions(
|
|
2459
3402
|
withProjectOptions(
|
|
2460
|
-
|
|
3403
|
+
yargs25.positional("id", { demandOption: true, describe: "Enrichment category public ID to fetch" })
|
|
2461
3404
|
)
|
|
2462
3405
|
)
|
|
2463
3406
|
)
|
|
@@ -2482,7 +3425,7 @@ var EnrichmentListModule = {
|
|
|
2482
3425
|
command: "list",
|
|
2483
3426
|
describe: "List enrichments",
|
|
2484
3427
|
aliases: ["ls"],
|
|
2485
|
-
builder: (
|
|
3428
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
2486
3429
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
2487
3430
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2488
3431
|
const client = new UncachedEnrichmentClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -2583,11 +3526,11 @@ var createEnrichmentValueEngineDataSource = ({
|
|
|
2583
3526
|
var EnrichmentPullModule = {
|
|
2584
3527
|
command: "pull <directory>",
|
|
2585
3528
|
describe: "Pulls all enrichments to local files in a directory",
|
|
2586
|
-
builder: (
|
|
3529
|
+
builder: (yargs25) => withConfiguration(
|
|
2587
3530
|
withApiOptions(
|
|
2588
3531
|
withProjectOptions(
|
|
2589
3532
|
withDiffOptions(
|
|
2590
|
-
|
|
3533
|
+
yargs25.positional("directory", {
|
|
2591
3534
|
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.",
|
|
2592
3535
|
type: "string"
|
|
2593
3536
|
}).option("format", {
|
|
@@ -2662,11 +3605,11 @@ import { UncachedEnrichmentClient as UncachedEnrichmentClient4 } from "@uniformd
|
|
|
2662
3605
|
var EnrichmentPushModule = {
|
|
2663
3606
|
command: "push <directory>",
|
|
2664
3607
|
describe: "Pushes all enrichments from files in a directory or package to Uniform",
|
|
2665
|
-
builder: (
|
|
3608
|
+
builder: (yargs25) => withConfiguration(
|
|
2666
3609
|
withApiOptions(
|
|
2667
3610
|
withProjectOptions(
|
|
2668
3611
|
withDiffOptions(
|
|
2669
|
-
|
|
3612
|
+
yargs25.positional("directory", {
|
|
2670
3613
|
describe: "Directory to read the enrichments from. If a filename is used, a package will be read instead.",
|
|
2671
3614
|
type: "string"
|
|
2672
3615
|
}).option("what-if", {
|
|
@@ -2730,10 +3673,10 @@ var EnrichmentRemoveModule = {
|
|
|
2730
3673
|
command: "remove <id>",
|
|
2731
3674
|
aliases: ["delete", "rm"],
|
|
2732
3675
|
describe: "Delete an enrichment category and its values",
|
|
2733
|
-
builder: (
|
|
3676
|
+
builder: (yargs25) => withConfiguration(
|
|
2734
3677
|
withApiOptions(
|
|
2735
3678
|
withProjectOptions(
|
|
2736
|
-
|
|
3679
|
+
yargs25.positional("id", { demandOption: true, describe: "Enrichment category public ID to delete" })
|
|
2737
3680
|
)
|
|
2738
3681
|
)
|
|
2739
3682
|
),
|
|
@@ -2749,14 +3692,14 @@ var EnrichmentModule = {
|
|
|
2749
3692
|
command: "enrichment <command>",
|
|
2750
3693
|
aliases: ["enr"],
|
|
2751
3694
|
describe: "Commands for Context enrichments",
|
|
2752
|
-
builder: (
|
|
3695
|
+
builder: (yargs25) => yargs25.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
|
|
2753
3696
|
handler: () => {
|
|
2754
|
-
|
|
3697
|
+
yargs10.help();
|
|
2755
3698
|
}
|
|
2756
3699
|
};
|
|
2757
3700
|
|
|
2758
3701
|
// src/commands/context/commands/manifest.ts
|
|
2759
|
-
import
|
|
3702
|
+
import yargs11 from "yargs";
|
|
2760
3703
|
|
|
2761
3704
|
// src/commands/context/commands/manifest/get.ts
|
|
2762
3705
|
import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
|
|
@@ -2767,10 +3710,10 @@ var ManifestGetModule = {
|
|
|
2767
3710
|
command: "get [output]",
|
|
2768
3711
|
aliases: ["dl", "download"],
|
|
2769
3712
|
describe: "Download the Uniform Context manifest for a project",
|
|
2770
|
-
builder: (
|
|
3713
|
+
builder: (yargs25) => withConfiguration(
|
|
2771
3714
|
withApiOptions(
|
|
2772
3715
|
withProjectOptions(
|
|
2773
|
-
|
|
3716
|
+
yargs25.option("preview", {
|
|
2774
3717
|
describe: "If set, fetches the unpublished preview manifest (The API key must have permission)",
|
|
2775
3718
|
default: false,
|
|
2776
3719
|
type: "boolean",
|
|
@@ -2832,7 +3775,7 @@ import { exit as exit2 } from "process";
|
|
|
2832
3775
|
var ManifestPublishModule = {
|
|
2833
3776
|
command: "publish",
|
|
2834
3777
|
describe: "Publish the Uniform Context manifest for a project",
|
|
2835
|
-
builder: (
|
|
3778
|
+
builder: (yargs25) => withConfiguration(withApiOptions(withProjectOptions(yargs25))),
|
|
2836
3779
|
handler: async ({ apiKey, apiHost, proxy, project }) => {
|
|
2837
3780
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2838
3781
|
try {
|
|
@@ -2865,25 +3808,25 @@ var ManifestModule = {
|
|
|
2865
3808
|
command: "manifest <command>",
|
|
2866
3809
|
describe: "Commands for context manifests",
|
|
2867
3810
|
aliases: ["man"],
|
|
2868
|
-
builder: (
|
|
3811
|
+
builder: (yargs25) => yargs25.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
|
|
2869
3812
|
handler: () => {
|
|
2870
|
-
|
|
3813
|
+
yargs11.help();
|
|
2871
3814
|
}
|
|
2872
3815
|
};
|
|
2873
3816
|
|
|
2874
3817
|
// src/commands/context/commands/quirk.ts
|
|
2875
|
-
import
|
|
3818
|
+
import yargs12 from "yargs";
|
|
2876
3819
|
|
|
2877
3820
|
// src/commands/context/commands/quirk/get.ts
|
|
2878
3821
|
import { UncachedQuirkClient } from "@uniformdev/context/api";
|
|
2879
3822
|
var QuirkGetModule = {
|
|
2880
3823
|
command: "get <id>",
|
|
2881
3824
|
describe: "Fetch a quirk",
|
|
2882
|
-
builder: (
|
|
3825
|
+
builder: (yargs25) => withConfiguration(
|
|
2883
3826
|
withFormatOptions(
|
|
2884
3827
|
withApiOptions(
|
|
2885
3828
|
withProjectOptions(
|
|
2886
|
-
|
|
3829
|
+
yargs25.positional("id", { demandOption: true, describe: "Quirk public ID to fetch" })
|
|
2887
3830
|
)
|
|
2888
3831
|
)
|
|
2889
3832
|
)
|
|
@@ -2907,11 +3850,11 @@ var QuirkListModule = {
|
|
|
2907
3850
|
command: "list",
|
|
2908
3851
|
describe: "List quirks",
|
|
2909
3852
|
aliases: ["ls"],
|
|
2910
|
-
builder: (
|
|
3853
|
+
builder: (yargs25) => withConfiguration(
|
|
2911
3854
|
withFormatOptions(
|
|
2912
3855
|
withApiOptions(
|
|
2913
3856
|
withProjectOptions(
|
|
2914
|
-
|
|
3857
|
+
yargs25.option("withIntegrations", {
|
|
2915
3858
|
alias: ["i"],
|
|
2916
3859
|
describe: "Whether to include meta-quirks created by integrations in the list. Defaults to false.",
|
|
2917
3860
|
type: "boolean"
|
|
@@ -2968,11 +3911,11 @@ function createQuirkEngineDataSource({
|
|
|
2968
3911
|
var QuirkPullModule = {
|
|
2969
3912
|
command: "pull <directory>",
|
|
2970
3913
|
describe: "Pulls all quirks to local files in a directory",
|
|
2971
|
-
builder: (
|
|
3914
|
+
builder: (yargs25) => withConfiguration(
|
|
2972
3915
|
withApiOptions(
|
|
2973
3916
|
withProjectOptions(
|
|
2974
3917
|
withDiffOptions(
|
|
2975
|
-
|
|
3918
|
+
yargs25.positional("directory", {
|
|
2976
3919
|
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.",
|
|
2977
3920
|
type: "string"
|
|
2978
3921
|
}).option("format", {
|
|
@@ -3047,11 +3990,11 @@ import { UncachedQuirkClient as UncachedQuirkClient4 } from "@uniformdev/context
|
|
|
3047
3990
|
var QuirkPushModule = {
|
|
3048
3991
|
command: "push <directory>",
|
|
3049
3992
|
describe: "Pushes all quirks from files in a directory or package to Uniform",
|
|
3050
|
-
builder: (
|
|
3993
|
+
builder: (yargs25) => withConfiguration(
|
|
3051
3994
|
withApiOptions(
|
|
3052
3995
|
withProjectOptions(
|
|
3053
3996
|
withDiffOptions(
|
|
3054
|
-
|
|
3997
|
+
yargs25.positional("directory", {
|
|
3055
3998
|
describe: "Directory to read the quirks from. If a filename is used, a package will be read instead.",
|
|
3056
3999
|
type: "string"
|
|
3057
4000
|
}).option("what-if", {
|
|
@@ -3115,10 +4058,10 @@ var QuirkRemoveModule = {
|
|
|
3115
4058
|
command: "remove <id>",
|
|
3116
4059
|
aliases: ["delete", "rm"],
|
|
3117
4060
|
describe: "Delete a quirk",
|
|
3118
|
-
builder: (
|
|
4061
|
+
builder: (yargs25) => withConfiguration(
|
|
3119
4062
|
withApiOptions(
|
|
3120
4063
|
withProjectOptions(
|
|
3121
|
-
|
|
4064
|
+
yargs25.positional("id", { demandOption: true, describe: "Quirk public ID to delete" })
|
|
3122
4065
|
)
|
|
3123
4066
|
)
|
|
3124
4067
|
),
|
|
@@ -3135,10 +4078,10 @@ var QuirkUpdateModule = {
|
|
|
3135
4078
|
command: "update <filename>",
|
|
3136
4079
|
aliases: ["put"],
|
|
3137
4080
|
describe: "Insert or update a quirk",
|
|
3138
|
-
builder: (
|
|
4081
|
+
builder: (yargs25) => withConfiguration(
|
|
3139
4082
|
withApiOptions(
|
|
3140
4083
|
withProjectOptions(
|
|
3141
|
-
|
|
4084
|
+
yargs25.positional("filename", { demandOption: true, describe: "Quirk file to put" })
|
|
3142
4085
|
)
|
|
3143
4086
|
)
|
|
3144
4087
|
),
|
|
@@ -3155,25 +4098,25 @@ var QuirkModule = {
|
|
|
3155
4098
|
command: "quirk <command>",
|
|
3156
4099
|
aliases: ["qk"],
|
|
3157
4100
|
describe: "Commands for Context quirks",
|
|
3158
|
-
builder: (
|
|
4101
|
+
builder: (yargs25) => yargs25.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
|
|
3159
4102
|
handler: () => {
|
|
3160
|
-
|
|
4103
|
+
yargs12.help();
|
|
3161
4104
|
}
|
|
3162
4105
|
};
|
|
3163
4106
|
|
|
3164
4107
|
// src/commands/context/commands/signal.ts
|
|
3165
|
-
import
|
|
4108
|
+
import yargs13 from "yargs";
|
|
3166
4109
|
|
|
3167
4110
|
// src/commands/context/commands/signal/get.ts
|
|
3168
4111
|
import { UncachedSignalClient } from "@uniformdev/context/api";
|
|
3169
4112
|
var SignalGetModule = {
|
|
3170
4113
|
command: "get <id>",
|
|
3171
4114
|
describe: "Fetch a signal",
|
|
3172
|
-
builder: (
|
|
4115
|
+
builder: (yargs25) => withConfiguration(
|
|
3173
4116
|
withFormatOptions(
|
|
3174
4117
|
withApiOptions(
|
|
3175
4118
|
withProjectOptions(
|
|
3176
|
-
|
|
4119
|
+
yargs25.positional("id", { demandOption: true, describe: "Signal public ID to fetch" })
|
|
3177
4120
|
)
|
|
3178
4121
|
)
|
|
3179
4122
|
)
|
|
@@ -3197,7 +4140,7 @@ var SignalListModule = {
|
|
|
3197
4140
|
command: "list",
|
|
3198
4141
|
describe: "List signals",
|
|
3199
4142
|
aliases: ["ls"],
|
|
3200
|
-
builder: (
|
|
4143
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
3201
4144
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
3202
4145
|
const fetch3 = nodeFetchProxy(proxy);
|
|
3203
4146
|
const client = new UncachedSignalClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -3246,11 +4189,11 @@ function createSignalEngineDataSource({
|
|
|
3246
4189
|
var SignalPullModule = {
|
|
3247
4190
|
command: "pull <directory>",
|
|
3248
4191
|
describe: "Pulls all signals to local files in a directory",
|
|
3249
|
-
builder: (
|
|
4192
|
+
builder: (yargs25) => withConfiguration(
|
|
3250
4193
|
withApiOptions(
|
|
3251
4194
|
withProjectOptions(
|
|
3252
4195
|
withDiffOptions(
|
|
3253
|
-
|
|
4196
|
+
yargs25.positional("directory", {
|
|
3254
4197
|
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.",
|
|
3255
4198
|
type: "string"
|
|
3256
4199
|
}).option("format", {
|
|
@@ -3325,11 +4268,11 @@ import { UncachedSignalClient as UncachedSignalClient4 } from "@uniformdev/conte
|
|
|
3325
4268
|
var SignalPushModule = {
|
|
3326
4269
|
command: "push <directory>",
|
|
3327
4270
|
describe: "Pushes all signals from files in a directory or package to Uniform",
|
|
3328
|
-
builder: (
|
|
4271
|
+
builder: (yargs25) => withConfiguration(
|
|
3329
4272
|
withApiOptions(
|
|
3330
4273
|
withProjectOptions(
|
|
3331
4274
|
withDiffOptions(
|
|
3332
|
-
|
|
4275
|
+
yargs25.positional("directory", {
|
|
3333
4276
|
describe: "Directory to read the signals from. If a filename is used, a package will be read instead.",
|
|
3334
4277
|
type: "string"
|
|
3335
4278
|
}).option("what-if", {
|
|
@@ -3393,10 +4336,10 @@ var SignalRemoveModule = {
|
|
|
3393
4336
|
command: "remove <id>",
|
|
3394
4337
|
aliases: ["delete", "rm"],
|
|
3395
4338
|
describe: "Delete a signal",
|
|
3396
|
-
builder: (
|
|
4339
|
+
builder: (yargs25) => withConfiguration(
|
|
3397
4340
|
withApiOptions(
|
|
3398
4341
|
withProjectOptions(
|
|
3399
|
-
|
|
4342
|
+
yargs25.positional("id", { demandOption: true, describe: "Signal public ID to delete" })
|
|
3400
4343
|
)
|
|
3401
4344
|
)
|
|
3402
4345
|
),
|
|
@@ -3413,10 +4356,10 @@ var SignalUpdateModule = {
|
|
|
3413
4356
|
command: "update <filename>",
|
|
3414
4357
|
aliases: ["put"],
|
|
3415
4358
|
describe: "Insert or update a signal",
|
|
3416
|
-
builder: (
|
|
4359
|
+
builder: (yargs25) => withConfiguration(
|
|
3417
4360
|
withApiOptions(
|
|
3418
4361
|
withProjectOptions(
|
|
3419
|
-
|
|
4362
|
+
yargs25.positional("filename", { demandOption: true, describe: "Signal file to put" })
|
|
3420
4363
|
)
|
|
3421
4364
|
)
|
|
3422
4365
|
),
|
|
@@ -3433,25 +4376,25 @@ var SignalModule = {
|
|
|
3433
4376
|
command: "signal <command>",
|
|
3434
4377
|
aliases: ["sig"],
|
|
3435
4378
|
describe: "Commands for Context signals",
|
|
3436
|
-
builder: (
|
|
4379
|
+
builder: (yargs25) => yargs25.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
|
|
3437
4380
|
handler: () => {
|
|
3438
|
-
|
|
4381
|
+
yargs13.help();
|
|
3439
4382
|
}
|
|
3440
4383
|
};
|
|
3441
4384
|
|
|
3442
4385
|
// src/commands/context/commands/test.ts
|
|
3443
|
-
import
|
|
4386
|
+
import yargs14 from "yargs";
|
|
3444
4387
|
|
|
3445
4388
|
// src/commands/context/commands/test/get.ts
|
|
3446
4389
|
import { UncachedTestClient } from "@uniformdev/context/api";
|
|
3447
4390
|
var TestGetModule = {
|
|
3448
4391
|
command: "get <id>",
|
|
3449
4392
|
describe: "Fetch a test",
|
|
3450
|
-
builder: (
|
|
4393
|
+
builder: (yargs25) => withConfiguration(
|
|
3451
4394
|
withFormatOptions(
|
|
3452
4395
|
withApiOptions(
|
|
3453
4396
|
withProjectOptions(
|
|
3454
|
-
|
|
4397
|
+
yargs25.positional("id", { demandOption: true, describe: "Test public ID to fetch" })
|
|
3455
4398
|
)
|
|
3456
4399
|
)
|
|
3457
4400
|
)
|
|
@@ -3475,7 +4418,7 @@ var TestListModule = {
|
|
|
3475
4418
|
command: "list",
|
|
3476
4419
|
describe: "List tests",
|
|
3477
4420
|
aliases: ["ls"],
|
|
3478
|
-
builder: (
|
|
4421
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
3479
4422
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
3480
4423
|
const fetch3 = nodeFetchProxy(proxy);
|
|
3481
4424
|
const client = new UncachedTestClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -3524,11 +4467,11 @@ function createTestEngineDataSource({
|
|
|
3524
4467
|
var TestPullModule = {
|
|
3525
4468
|
command: "pull <directory>",
|
|
3526
4469
|
describe: "Pulls all tests to local files in a directory",
|
|
3527
|
-
builder: (
|
|
4470
|
+
builder: (yargs25) => withConfiguration(
|
|
3528
4471
|
withApiOptions(
|
|
3529
4472
|
withProjectOptions(
|
|
3530
4473
|
withDiffOptions(
|
|
3531
|
-
|
|
4474
|
+
yargs25.positional("directory", {
|
|
3532
4475
|
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.",
|
|
3533
4476
|
type: "string"
|
|
3534
4477
|
}).option("format", {
|
|
@@ -3603,11 +4546,11 @@ import { UncachedTestClient as UncachedTestClient4 } from "@uniformdev/context/a
|
|
|
3603
4546
|
var TestPushModule = {
|
|
3604
4547
|
command: "push <directory>",
|
|
3605
4548
|
describe: "Pushes all tests from files in a directory or package to Uniform",
|
|
3606
|
-
builder: (
|
|
4549
|
+
builder: (yargs25) => withConfiguration(
|
|
3607
4550
|
withApiOptions(
|
|
3608
4551
|
withProjectOptions(
|
|
3609
4552
|
withDiffOptions(
|
|
3610
|
-
|
|
4553
|
+
yargs25.positional("directory", {
|
|
3611
4554
|
describe: "Directory to read the tests from. If a filename is used, a package will be read instead.",
|
|
3612
4555
|
type: "string"
|
|
3613
4556
|
}).option("what-if", {
|
|
@@ -3671,10 +4614,10 @@ var TestRemoveModule = {
|
|
|
3671
4614
|
command: "remove <id>",
|
|
3672
4615
|
aliases: ["delete", "rm"],
|
|
3673
4616
|
describe: "Delete a test",
|
|
3674
|
-
builder: (
|
|
4617
|
+
builder: (yargs25) => withConfiguration(
|
|
3675
4618
|
withApiOptions(
|
|
3676
4619
|
withProjectOptions(
|
|
3677
|
-
|
|
4620
|
+
yargs25.positional("id", { demandOption: true, describe: "Test public ID to delete" })
|
|
3678
4621
|
)
|
|
3679
4622
|
)
|
|
3680
4623
|
),
|
|
@@ -3691,9 +4634,9 @@ var TestUpdateModule = {
|
|
|
3691
4634
|
command: "update <filename>",
|
|
3692
4635
|
aliases: ["put"],
|
|
3693
4636
|
describe: "Insert or update a test",
|
|
3694
|
-
builder: (
|
|
4637
|
+
builder: (yargs25) => withConfiguration(
|
|
3695
4638
|
withApiOptions(
|
|
3696
|
-
withProjectOptions(
|
|
4639
|
+
withProjectOptions(yargs25.positional("filename", { demandOption: true, describe: "Test file to put" }))
|
|
3697
4640
|
)
|
|
3698
4641
|
),
|
|
3699
4642
|
handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
|
|
@@ -3708,9 +4651,9 @@ var TestUpdateModule = {
|
|
|
3708
4651
|
var TestModule = {
|
|
3709
4652
|
command: "test <command>",
|
|
3710
4653
|
describe: "Commands for Context A/B tests",
|
|
3711
|
-
builder: (
|
|
4654
|
+
builder: (yargs25) => yargs25.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
|
|
3712
4655
|
handler: () => {
|
|
3713
|
-
|
|
4656
|
+
yargs14.help();
|
|
3714
4657
|
}
|
|
3715
4658
|
};
|
|
3716
4659
|
|
|
@@ -3719,9 +4662,9 @@ var ContextCommand = {
|
|
|
3719
4662
|
command: "context <command>",
|
|
3720
4663
|
aliases: ["ctx"],
|
|
3721
4664
|
describe: "Uniform Context commands",
|
|
3722
|
-
builder: (
|
|
4665
|
+
builder: (yargs25) => yargs25.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
|
|
3723
4666
|
handler: () => {
|
|
3724
|
-
|
|
4667
|
+
yargs15.showHelp();
|
|
3725
4668
|
}
|
|
3726
4669
|
};
|
|
3727
4670
|
|
|
@@ -3749,7 +4692,7 @@ import { PostHog } from "posthog-node";
|
|
|
3749
4692
|
// package.json
|
|
3750
4693
|
var package_default = {
|
|
3751
4694
|
name: "@uniformdev/cli",
|
|
3752
|
-
version: "19.
|
|
4695
|
+
version: "19.46.0",
|
|
3753
4696
|
description: "Uniform command line interface tool",
|
|
3754
4697
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
3755
4698
|
main: "./cli.js",
|
|
@@ -3757,7 +4700,7 @@ var package_default = {
|
|
|
3757
4700
|
sideEffects: false,
|
|
3758
4701
|
scripts: {
|
|
3759
4702
|
uniform: "node ./cli.js",
|
|
3760
|
-
build: "tsup",
|
|
4703
|
+
build: "tsc --noEmit && tsup",
|
|
3761
4704
|
dev: "tsup --watch",
|
|
3762
4705
|
clean: "rimraf dist",
|
|
3763
4706
|
test: "jest --maxWorkers=1 --passWithNoTests",
|
|
@@ -3765,8 +4708,10 @@ var package_default = {
|
|
|
3765
4708
|
format: 'prettier --write "src/**/*.{js,ts,tsx}"'
|
|
3766
4709
|
},
|
|
3767
4710
|
dependencies: {
|
|
4711
|
+
"@thi.ng/mime": "^2.2.23",
|
|
3768
4712
|
"@uniformdev/canvas": "workspace:*",
|
|
3769
4713
|
"@uniformdev/context": "workspace:*",
|
|
4714
|
+
"@uniformdev/files": "workspace:*",
|
|
3770
4715
|
"@uniformdev/project-map": "workspace:*",
|
|
3771
4716
|
"@uniformdev/redirect": "workspace:*",
|
|
3772
4717
|
colorette: "2.0.20",
|
|
@@ -3776,10 +4721,11 @@ var package_default = {
|
|
|
3776
4721
|
dotenv: "^16.0.3",
|
|
3777
4722
|
execa: "5.1.1",
|
|
3778
4723
|
"fs-jetpack": "5.1.0",
|
|
3779
|
-
graphql: "16.
|
|
4724
|
+
graphql: "16.8.0",
|
|
3780
4725
|
"graphql-request": "6.1.0",
|
|
3781
4726
|
"https-proxy-agent": "^7.0.0",
|
|
3782
|
-
|
|
4727
|
+
"image-size": "^1.0.2",
|
|
4728
|
+
inquirer: "9.2.10",
|
|
3783
4729
|
"isomorphic-git": "1.24.5",
|
|
3784
4730
|
"isomorphic-unfetch": "^3.1.0",
|
|
3785
4731
|
"js-yaml": "^4.1.0",
|
|
@@ -3787,6 +4733,7 @@ var package_default = {
|
|
|
3787
4733
|
"lodash.isequalwith": "^4.4.0",
|
|
3788
4734
|
open: "9.1.0",
|
|
3789
4735
|
ora: "6.3.1",
|
|
4736
|
+
"p-queue": "7.3.4",
|
|
3790
4737
|
"posthog-node": "3.1.1",
|
|
3791
4738
|
slugify: "1.6.6",
|
|
3792
4739
|
"update-check": "^1.5.4",
|
|
@@ -3799,7 +4746,7 @@ var package_default = {
|
|
|
3799
4746
|
"@types/js-yaml": "4.0.5",
|
|
3800
4747
|
"@types/jsonwebtoken": "9.0.2",
|
|
3801
4748
|
"@types/lodash.isequalwith": "4.4.7",
|
|
3802
|
-
"@types/node": "18.17.
|
|
4749
|
+
"@types/node": "18.17.5",
|
|
3803
4750
|
"@types/yargs": "17.0.24"
|
|
3804
4751
|
},
|
|
3805
4752
|
bin: {
|
|
@@ -4123,8 +5070,8 @@ ${err.message}`);
|
|
|
4123
5070
|
|
|
4124
5071
|
// src/projects/cloneStarter.ts
|
|
4125
5072
|
import crypto2 from "crypto";
|
|
4126
|
-
import
|
|
4127
|
-
import
|
|
5073
|
+
import fs3 from "fs";
|
|
5074
|
+
import fsj2 from "fs-jetpack";
|
|
4128
5075
|
import * as git from "isomorphic-git";
|
|
4129
5076
|
import * as http from "isomorphic-git/http/node/index.js";
|
|
4130
5077
|
import os from "os";
|
|
@@ -4140,7 +5087,7 @@ async function cloneStarter({
|
|
|
4140
5087
|
const [user, repo, ...pathSegments] = githubPath.split("/");
|
|
4141
5088
|
try {
|
|
4142
5089
|
await git.clone({
|
|
4143
|
-
fs:
|
|
5090
|
+
fs: fs3,
|
|
4144
5091
|
http,
|
|
4145
5092
|
url: `https://github.com/${user}/${repo}`,
|
|
4146
5093
|
dir: cloneDir,
|
|
@@ -4151,13 +5098,13 @@ async function cloneStarter({
|
|
|
4151
5098
|
throw new Error(`Failed to fetch starter code: ${err.message}`);
|
|
4152
5099
|
}
|
|
4153
5100
|
await done();
|
|
4154
|
-
if (
|
|
5101
|
+
if (fs3.existsSync(targetDir) && fs3.readdirSync(targetDir).length > 0) {
|
|
4155
5102
|
throw new Error(`"${targetDir}" is not empty`);
|
|
4156
5103
|
}
|
|
4157
5104
|
const starterDir = path.join(cloneDir, ...pathSegments);
|
|
4158
|
-
|
|
5105
|
+
fsj2.copy(starterDir, targetDir, { overwrite: true });
|
|
4159
5106
|
if (dotEnvFile) {
|
|
4160
|
-
|
|
5107
|
+
fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
|
|
4161
5108
|
}
|
|
4162
5109
|
console.log(`
|
|
4163
5110
|
Your project now lives in ${targetDir} \u2728`);
|
|
@@ -4173,7 +5120,7 @@ Installing project dependencies...
|
|
|
4173
5120
|
}
|
|
4174
5121
|
|
|
4175
5122
|
// src/projects/getOrCreateProject.ts
|
|
4176
|
-
import
|
|
5123
|
+
import fs4, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
4177
5124
|
import inquirer2 from "inquirer";
|
|
4178
5125
|
import path2 from "path";
|
|
4179
5126
|
import slugify from "slugify";
|
|
@@ -4300,9 +5247,9 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
|
|
|
4300
5247
|
if (!existsSync2(targetDir)) {
|
|
4301
5248
|
mkdirSync2(targetDir, { recursive: true });
|
|
4302
5249
|
}
|
|
4303
|
-
if (
|
|
5250
|
+
if (fs4.readdirSync(targetDir).length > 0) {
|
|
4304
5251
|
targetDir = path2.resolve(targetDir, projectNameSlug);
|
|
4305
|
-
if (
|
|
5252
|
+
if (fs4.existsSync(targetDir)) {
|
|
4306
5253
|
throw new Error(`${targetDir} already exists, choose a different name.`);
|
|
4307
5254
|
}
|
|
4308
5255
|
}
|
|
@@ -4787,10 +5734,10 @@ var NewMeshCmd = {
|
|
|
4787
5734
|
};
|
|
4788
5735
|
|
|
4789
5736
|
// src/commands/optimize/index.ts
|
|
4790
|
-
import
|
|
5737
|
+
import yargs17 from "yargs";
|
|
4791
5738
|
|
|
4792
5739
|
// src/commands/optimize/manifest.ts
|
|
4793
|
-
import
|
|
5740
|
+
import yargs16 from "yargs";
|
|
4794
5741
|
|
|
4795
5742
|
// src/commands/optimize/manifest/download.ts
|
|
4796
5743
|
import { gray as gray4, green as green3, red as red5, yellow as yellow2 } from "colorette";
|
|
@@ -4805,7 +5752,7 @@ var UniformBaseUrl = "https://uniform.app";
|
|
|
4805
5752
|
var module = {
|
|
4806
5753
|
command: "download [output]",
|
|
4807
5754
|
describe: "Download intent manifest",
|
|
4808
|
-
builder: (
|
|
5755
|
+
builder: (yargs25) => yargs25.option("apiKey", {
|
|
4809
5756
|
alias: "k",
|
|
4810
5757
|
demandOption: true,
|
|
4811
5758
|
string: true,
|
|
@@ -4906,10 +5853,10 @@ var module2 = {
|
|
|
4906
5853
|
command: "manifest <command>",
|
|
4907
5854
|
describe: "Intent manifest commands",
|
|
4908
5855
|
builder: () => {
|
|
4909
|
-
return
|
|
5856
|
+
return yargs16.command(download_default);
|
|
4910
5857
|
},
|
|
4911
5858
|
handler: () => {
|
|
4912
|
-
|
|
5859
|
+
yargs16.showHelp();
|
|
4913
5860
|
}
|
|
4914
5861
|
};
|
|
4915
5862
|
var manifest_default = module2;
|
|
@@ -4920,29 +5867,29 @@ var OptimizeCommand = {
|
|
|
4920
5867
|
aliases: ["opt"],
|
|
4921
5868
|
describe: "Uniform Optimize commands",
|
|
4922
5869
|
builder: () => {
|
|
4923
|
-
return
|
|
5870
|
+
return yargs17.command(manifest_default);
|
|
4924
5871
|
},
|
|
4925
5872
|
handler: () => {
|
|
4926
|
-
|
|
5873
|
+
yargs17.showHelp();
|
|
4927
5874
|
}
|
|
4928
5875
|
};
|
|
4929
5876
|
|
|
4930
5877
|
// src/commands/project-map/index.ts
|
|
4931
|
-
import
|
|
5878
|
+
import yargs20 from "yargs";
|
|
4932
5879
|
|
|
4933
5880
|
// src/commands/project-map/commands/projectMapDefinition.ts
|
|
4934
|
-
import
|
|
5881
|
+
import yargs18 from "yargs";
|
|
4935
5882
|
|
|
4936
5883
|
// src/commands/project-map/commands/ProjectMapDefinition/get.ts
|
|
4937
5884
|
import { UncachedProjectMapClient } from "@uniformdev/project-map";
|
|
4938
5885
|
var ProjectMapDefinitionGetModule = {
|
|
4939
5886
|
command: "get <id>",
|
|
4940
5887
|
describe: "Fetch a project map",
|
|
4941
|
-
builder: (
|
|
5888
|
+
builder: (yargs25) => withFormatOptions(
|
|
4942
5889
|
withConfiguration(
|
|
4943
5890
|
withApiOptions(
|
|
4944
5891
|
withProjectOptions(
|
|
4945
|
-
|
|
5892
|
+
yargs25.positional("id", { demandOption: true, describe: "ProjectMap UUID to fetch" })
|
|
4946
5893
|
)
|
|
4947
5894
|
)
|
|
4948
5895
|
)
|
|
@@ -4966,7 +5913,7 @@ var ProjectMapDefinitionListModule = {
|
|
|
4966
5913
|
command: "list",
|
|
4967
5914
|
describe: "List of project maps",
|
|
4968
5915
|
aliases: ["ls"],
|
|
4969
|
-
builder: (
|
|
5916
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
4970
5917
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
4971
5918
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4972
5919
|
const client = new UncachedProjectMapClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -5023,11 +5970,11 @@ function createProjectMapDefinitionEngineDataSource({
|
|
|
5023
5970
|
var ProjectMapDefinitionPullModule = {
|
|
5024
5971
|
command: "pull <directory>",
|
|
5025
5972
|
describe: "Pulls all project maps to local files in a directory",
|
|
5026
|
-
builder: (
|
|
5973
|
+
builder: (yargs25) => withConfiguration(
|
|
5027
5974
|
withApiOptions(
|
|
5028
5975
|
withProjectOptions(
|
|
5029
5976
|
withDiffOptions(
|
|
5030
|
-
|
|
5977
|
+
yargs25.positional("directory", {
|
|
5031
5978
|
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.",
|
|
5032
5979
|
type: "string"
|
|
5033
5980
|
}).option("format", {
|
|
@@ -5102,11 +6049,11 @@ import { UncachedProjectMapClient as UncachedProjectMapClient4 } from "@uniformd
|
|
|
5102
6049
|
var ProjectMapDefinitionPushModule = {
|
|
5103
6050
|
command: "push <directory>",
|
|
5104
6051
|
describe: "Pushes all project maps from files in a directory or package to Uniform",
|
|
5105
|
-
builder: (
|
|
6052
|
+
builder: (yargs25) => withConfiguration(
|
|
5106
6053
|
withApiOptions(
|
|
5107
6054
|
withProjectOptions(
|
|
5108
6055
|
withDiffOptions(
|
|
5109
|
-
|
|
6056
|
+
yargs25.positional("directory", {
|
|
5110
6057
|
describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
|
|
5111
6058
|
type: "string"
|
|
5112
6059
|
}).option("what-if", {
|
|
@@ -5170,9 +6117,9 @@ var ProjectMapDefinitionRemoveModule = {
|
|
|
5170
6117
|
command: "remove <id>",
|
|
5171
6118
|
aliases: ["delete", "rm"],
|
|
5172
6119
|
describe: "Delete a project map",
|
|
5173
|
-
builder: (
|
|
6120
|
+
builder: (yargs25) => withConfiguration(
|
|
5174
6121
|
withApiOptions(
|
|
5175
|
-
withProjectOptions(
|
|
6122
|
+
withProjectOptions(yargs25.positional("id", { demandOption: true, describe: " UUID to delete" }))
|
|
5176
6123
|
)
|
|
5177
6124
|
),
|
|
5178
6125
|
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
@@ -5188,10 +6135,10 @@ var ProjectMapDefinitionUpdateModule = {
|
|
|
5188
6135
|
command: "update <filename>",
|
|
5189
6136
|
aliases: ["put"],
|
|
5190
6137
|
describe: "Insert or update a project map",
|
|
5191
|
-
builder: (
|
|
6138
|
+
builder: (yargs25) => withConfiguration(
|
|
5192
6139
|
withApiOptions(
|
|
5193
6140
|
withProjectOptions(
|
|
5194
|
-
|
|
6141
|
+
yargs25.positional("filename", { demandOption: true, describe: "Project map file to put" })
|
|
5195
6142
|
)
|
|
5196
6143
|
)
|
|
5197
6144
|
),
|
|
@@ -5207,25 +6154,25 @@ var ProjectMapDefinitionUpdateModule = {
|
|
|
5207
6154
|
var ProjectMapDefinitionModule = {
|
|
5208
6155
|
command: "definition <command>",
|
|
5209
6156
|
describe: "Commands for ProjectMap Definitions",
|
|
5210
|
-
builder: (
|
|
6157
|
+
builder: (yargs25) => yargs25.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
|
|
5211
6158
|
handler: () => {
|
|
5212
|
-
|
|
6159
|
+
yargs18.help();
|
|
5213
6160
|
}
|
|
5214
6161
|
};
|
|
5215
6162
|
|
|
5216
6163
|
// src/commands/project-map/commands/projectMapNode.ts
|
|
5217
|
-
import
|
|
6164
|
+
import yargs19 from "yargs";
|
|
5218
6165
|
|
|
5219
6166
|
// src/commands/project-map/commands/ProjectMapNode/get.ts
|
|
5220
6167
|
import { UncachedProjectMapClient as UncachedProjectMapClient7 } from "@uniformdev/project-map";
|
|
5221
6168
|
var ProjectMapNodeGetModule = {
|
|
5222
6169
|
command: "get <id> <projectMapId>",
|
|
5223
6170
|
describe: "Fetch a project map node",
|
|
5224
|
-
builder: (
|
|
6171
|
+
builder: (yargs25) => withConfiguration(
|
|
5225
6172
|
withFormatOptions(
|
|
5226
6173
|
withApiOptions(
|
|
5227
6174
|
withProjectOptions(
|
|
5228
|
-
|
|
6175
|
+
yargs25.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to fetch" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to fetch from" })
|
|
5229
6176
|
)
|
|
5230
6177
|
)
|
|
5231
6178
|
)
|
|
@@ -5251,11 +6198,11 @@ var ProjectMapNodeListModule = {
|
|
|
5251
6198
|
command: "list <projectMapId>",
|
|
5252
6199
|
describe: "List project map nodes",
|
|
5253
6200
|
aliases: ["ls"],
|
|
5254
|
-
builder: (
|
|
6201
|
+
builder: (yargs25) => withConfiguration(
|
|
5255
6202
|
withFormatOptions(
|
|
5256
6203
|
withApiOptions(
|
|
5257
6204
|
withProjectOptions(
|
|
5258
|
-
|
|
6205
|
+
yargs25.positional("projectMapId", {
|
|
5259
6206
|
demandOption: true,
|
|
5260
6207
|
describe: "ProjectMap UUID to fetch from"
|
|
5261
6208
|
})
|
|
@@ -5326,11 +6273,11 @@ function createProjectMapNodeEngineDataSource({
|
|
|
5326
6273
|
var ProjectMapNodePullModule = {
|
|
5327
6274
|
command: "pull <directory>",
|
|
5328
6275
|
describe: "Pulls all project maps nodes to local files in a directory",
|
|
5329
|
-
builder: (
|
|
6276
|
+
builder: (yargs25) => withConfiguration(
|
|
5330
6277
|
withApiOptions(
|
|
5331
6278
|
withProjectOptions(
|
|
5332
6279
|
withDiffOptions(
|
|
5333
|
-
|
|
6280
|
+
yargs25.positional("directory", {
|
|
5334
6281
|
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.",
|
|
5335
6282
|
type: "string"
|
|
5336
6283
|
}).option("format", {
|
|
@@ -5409,11 +6356,11 @@ import { UncachedProjectMapClient as UncachedProjectMapClient10 } from "@uniform
|
|
|
5409
6356
|
var ProjectMapNodePushModule = {
|
|
5410
6357
|
command: "push <directory>",
|
|
5411
6358
|
describe: "Pushes all project maps nodes from files in a directory or package to Uniform",
|
|
5412
|
-
builder: (
|
|
6359
|
+
builder: (yargs25) => withConfiguration(
|
|
5413
6360
|
withApiOptions(
|
|
5414
6361
|
withProjectOptions(
|
|
5415
6362
|
withDiffOptions(
|
|
5416
|
-
|
|
6363
|
+
yargs25.positional("directory", {
|
|
5417
6364
|
describe: "Directory to read project maps from. If a filename is used, a package will be read instead.",
|
|
5418
6365
|
type: "string"
|
|
5419
6366
|
}).option("what-if", {
|
|
@@ -5486,10 +6433,10 @@ var ProjectMapNodeRemoveModule = {
|
|
|
5486
6433
|
command: "remove <id> <projectMapId>",
|
|
5487
6434
|
aliases: ["delete", "rm"],
|
|
5488
6435
|
describe: "Delete a project map node",
|
|
5489
|
-
builder: (
|
|
6436
|
+
builder: (yargs25) => withConfiguration(
|
|
5490
6437
|
withApiOptions(
|
|
5491
6438
|
withProjectOptions(
|
|
5492
|
-
|
|
6439
|
+
yargs25.positional("id", { demandOption: true, describe: "ProjectMap Node UUID to delete" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to delete from" })
|
|
5493
6440
|
)
|
|
5494
6441
|
)
|
|
5495
6442
|
),
|
|
@@ -5506,10 +6453,10 @@ var ProjectMapNodeUpdateModule = {
|
|
|
5506
6453
|
command: "update <filename> <projectMapId>",
|
|
5507
6454
|
aliases: ["put"],
|
|
5508
6455
|
describe: "Insert or update a project map node",
|
|
5509
|
-
builder: (
|
|
6456
|
+
builder: (yargs25) => withConfiguration(
|
|
5510
6457
|
withApiOptions(
|
|
5511
6458
|
withProjectOptions(
|
|
5512
|
-
|
|
6459
|
+
yargs25.positional("filename", { demandOption: true, describe: "ProjectMap node file with nodes data" }).positional("projectMapId", { demandOption: true, describe: "ProjectMap UUID to put into" })
|
|
5513
6460
|
)
|
|
5514
6461
|
)
|
|
5515
6462
|
),
|
|
@@ -5525,9 +6472,9 @@ var ProjectMapNodeUpdateModule = {
|
|
|
5525
6472
|
var ProjectMapNodeModule = {
|
|
5526
6473
|
command: "node <command>",
|
|
5527
6474
|
describe: "Commands for ProjectMap Nodes",
|
|
5528
|
-
builder: (
|
|
6475
|
+
builder: (yargs25) => yargs25.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
|
|
5529
6476
|
handler: () => {
|
|
5530
|
-
|
|
6477
|
+
yargs19.help();
|
|
5531
6478
|
}
|
|
5532
6479
|
};
|
|
5533
6480
|
|
|
@@ -5536,28 +6483,28 @@ var ProjectMapCommand = {
|
|
|
5536
6483
|
command: "project-map <command>",
|
|
5537
6484
|
aliases: ["prm"],
|
|
5538
6485
|
describe: "Uniform ProjectMap commands",
|
|
5539
|
-
builder: (
|
|
6486
|
+
builder: (yargs25) => yargs25.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
|
|
5540
6487
|
handler: () => {
|
|
5541
|
-
|
|
6488
|
+
yargs20.showHelp();
|
|
5542
6489
|
}
|
|
5543
6490
|
};
|
|
5544
6491
|
|
|
5545
6492
|
// src/commands/redirect/index.ts
|
|
5546
|
-
import
|
|
6493
|
+
import yargs22 from "yargs";
|
|
5547
6494
|
|
|
5548
6495
|
// src/commands/redirect/commands/redirect.ts
|
|
5549
|
-
import
|
|
6496
|
+
import yargs21 from "yargs";
|
|
5550
6497
|
|
|
5551
6498
|
// src/commands/redirect/commands/RedirectDefinition/get.ts
|
|
5552
6499
|
import { UncachedRedirectClient } from "@uniformdev/redirect";
|
|
5553
6500
|
var RedirectDefinitionGetModule = {
|
|
5554
6501
|
command: "get <id>",
|
|
5555
6502
|
describe: "Fetch a redirect",
|
|
5556
|
-
builder: (
|
|
6503
|
+
builder: (yargs25) => withConfiguration(
|
|
5557
6504
|
withFormatOptions(
|
|
5558
6505
|
withApiOptions(
|
|
5559
6506
|
withProjectOptions(
|
|
5560
|
-
|
|
6507
|
+
yargs25.positional("id", { demandOption: true, describe: "Redirect UUID to fetch" })
|
|
5561
6508
|
)
|
|
5562
6509
|
)
|
|
5563
6510
|
)
|
|
@@ -5581,7 +6528,7 @@ var RedirectDefinitionListModule = {
|
|
|
5581
6528
|
command: "list",
|
|
5582
6529
|
describe: "List of redirects",
|
|
5583
6530
|
aliases: ["ls"],
|
|
5584
|
-
builder: (
|
|
6531
|
+
builder: (yargs25) => withConfiguration(withFormatOptions(withApiOptions(withProjectOptions(yargs25)))),
|
|
5585
6532
|
handler: async ({ apiHost, apiKey, proxy, format, filename, project: projectId }) => {
|
|
5586
6533
|
const fetch3 = nodeFetchProxy(proxy);
|
|
5587
6534
|
const client = new UncachedRedirectClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
@@ -5647,11 +6594,11 @@ function createRedirectDefinitionEngineDataSource({
|
|
|
5647
6594
|
var RedirectDefinitionPullModule = {
|
|
5648
6595
|
command: "pull <directory>",
|
|
5649
6596
|
describe: "Pulls all redirects to local files in a directory",
|
|
5650
|
-
builder: (
|
|
6597
|
+
builder: (yargs25) => withConfiguration(
|
|
5651
6598
|
withApiOptions(
|
|
5652
6599
|
withProjectOptions(
|
|
5653
6600
|
withDiffOptions(
|
|
5654
|
-
|
|
6601
|
+
yargs25.positional("directory", {
|
|
5655
6602
|
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.",
|
|
5656
6603
|
type: "string"
|
|
5657
6604
|
}).option("format", {
|
|
@@ -5727,11 +6674,11 @@ import { UncachedRedirectClient as UncachedRedirectClient4 } from "@uniformdev/r
|
|
|
5727
6674
|
var RedirectDefinitionPushModule = {
|
|
5728
6675
|
command: "push <directory>",
|
|
5729
6676
|
describe: "Pushes all redirects from files in a directory or package to Uniform",
|
|
5730
|
-
builder: (
|
|
6677
|
+
builder: (yargs25) => withConfiguration(
|
|
5731
6678
|
withApiOptions(
|
|
5732
6679
|
withProjectOptions(
|
|
5733
6680
|
withDiffOptions(
|
|
5734
|
-
|
|
6681
|
+
yargs25.positional("directory", {
|
|
5735
6682
|
describe: "Directory to read redirects from. If a filename is used, a package will be read instead.",
|
|
5736
6683
|
type: "string"
|
|
5737
6684
|
}).option("what-if", {
|
|
@@ -5795,9 +6742,9 @@ var RedirectDefinitionRemoveModule = {
|
|
|
5795
6742
|
command: "remove <id>",
|
|
5796
6743
|
aliases: ["delete", "rm"],
|
|
5797
6744
|
describe: "Delete a redirect",
|
|
5798
|
-
builder: (
|
|
6745
|
+
builder: (yargs25) => withConfiguration(
|
|
5799
6746
|
withApiOptions(
|
|
5800
|
-
withProjectOptions(
|
|
6747
|
+
withProjectOptions(yargs25.positional("id", { demandOption: true, describe: " UUID to delete" }))
|
|
5801
6748
|
)
|
|
5802
6749
|
),
|
|
5803
6750
|
handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
|
|
@@ -5813,10 +6760,10 @@ var RedirectDefinitionUpdateModule = {
|
|
|
5813
6760
|
command: "update <filename>",
|
|
5814
6761
|
aliases: ["put"],
|
|
5815
6762
|
describe: "Insert or update a redirect",
|
|
5816
|
-
builder: (
|
|
6763
|
+
builder: (yargs25) => withConfiguration(
|
|
5817
6764
|
withApiOptions(
|
|
5818
6765
|
withProjectOptions(
|
|
5819
|
-
|
|
6766
|
+
yargs25.positional("filename", { demandOption: true, describe: "Redirect file to put" })
|
|
5820
6767
|
)
|
|
5821
6768
|
)
|
|
5822
6769
|
),
|
|
@@ -5832,9 +6779,9 @@ var RedirectDefinitionUpdateModule = {
|
|
|
5832
6779
|
var RedirectDefinitionModule = {
|
|
5833
6780
|
command: "definition <command>",
|
|
5834
6781
|
describe: "Commands for Redirect Definitions",
|
|
5835
|
-
builder: (
|
|
6782
|
+
builder: (yargs25) => yargs25.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
|
|
5836
6783
|
handler: () => {
|
|
5837
|
-
|
|
6784
|
+
yargs21.help();
|
|
5838
6785
|
}
|
|
5839
6786
|
};
|
|
5840
6787
|
|
|
@@ -5843,24 +6790,24 @@ var RedirectCommand = {
|
|
|
5843
6790
|
command: "redirect <command>",
|
|
5844
6791
|
aliases: ["red"],
|
|
5845
6792
|
describe: "Uniform Redirect commands",
|
|
5846
|
-
builder: (
|
|
6793
|
+
builder: (yargs25) => yargs25.command(RedirectDefinitionModule).demandCommand(),
|
|
5847
6794
|
handler: () => {
|
|
5848
|
-
|
|
6795
|
+
yargs22.showHelp();
|
|
5849
6796
|
}
|
|
5850
6797
|
};
|
|
5851
6798
|
|
|
5852
6799
|
// src/commands/sync/index.ts
|
|
5853
|
-
import
|
|
6800
|
+
import yargs23 from "yargs";
|
|
5854
6801
|
|
|
5855
6802
|
// src/commands/sync/commands/pull.ts
|
|
5856
6803
|
var SyncPullModule = {
|
|
5857
6804
|
command: "pull",
|
|
5858
6805
|
describe: "Pulls whole project to local files in a directory",
|
|
5859
|
-
builder: (
|
|
6806
|
+
builder: (yargs25) => withConfiguration(
|
|
5860
6807
|
withApiOptions(
|
|
5861
6808
|
withProjectOptions(
|
|
5862
6809
|
withDiffOptions(
|
|
5863
|
-
|
|
6810
|
+
yargs25.option("what-if", {
|
|
5864
6811
|
alias: ["w"],
|
|
5865
6812
|
describe: "What-if mode reports what would be done but changes no files",
|
|
5866
6813
|
default: false,
|
|
@@ -5894,6 +6841,7 @@ var SyncPullModule = {
|
|
|
5894
6841
|
await module3.handler({
|
|
5895
6842
|
...otherParams,
|
|
5896
6843
|
state: 0,
|
|
6844
|
+
format: getFormat(entityType, config2),
|
|
5897
6845
|
onlyCompositions: entityType === "composition" ? true : void 0,
|
|
5898
6846
|
onlyPatterns: entityType === "pattern" ? true : void 0,
|
|
5899
6847
|
mode: getPullMode(entityType, config2),
|
|
@@ -5917,16 +6865,24 @@ var getPullFilename = (entityType, config2) => {
|
|
|
5917
6865
|
entityType
|
|
5918
6866
|
});
|
|
5919
6867
|
};
|
|
6868
|
+
var getFormat = (entityType, config2) => {
|
|
6869
|
+
return getEntityOption({
|
|
6870
|
+
optionName: "format",
|
|
6871
|
+
operation: "pull",
|
|
6872
|
+
config: config2,
|
|
6873
|
+
entityType
|
|
6874
|
+
});
|
|
6875
|
+
};
|
|
5920
6876
|
|
|
5921
6877
|
// src/commands/sync/commands/push.ts
|
|
5922
6878
|
var SyncPushModule = {
|
|
5923
6879
|
command: "push",
|
|
5924
6880
|
describe: "Pushes whole project data from files in a directory or package to Uniform",
|
|
5925
|
-
builder: (
|
|
6881
|
+
builder: (yargs25) => withConfiguration(
|
|
5926
6882
|
withApiOptions(
|
|
5927
6883
|
withProjectOptions(
|
|
5928
6884
|
withDiffOptions(
|
|
5929
|
-
|
|
6885
|
+
yargs25.option("what-if", {
|
|
5930
6886
|
alias: ["w"],
|
|
5931
6887
|
describe: "What-if mode reports what would be done but changes nothing",
|
|
5932
6888
|
default: false,
|
|
@@ -5961,6 +6917,7 @@ var SyncPushModule = {
|
|
|
5961
6917
|
await module3.handler({
|
|
5962
6918
|
...otherParams,
|
|
5963
6919
|
state: 0,
|
|
6920
|
+
format: getFormat2(entityType, config2),
|
|
5964
6921
|
onlyCompositions: entityType === "composition" ? true : void 0,
|
|
5965
6922
|
onlyPatterns: entityType === "pattern" ? true : void 0,
|
|
5966
6923
|
mode: getPushMode(entityType, config2),
|
|
@@ -5990,14 +6947,22 @@ var getPushFilename = (entityType, config2) => {
|
|
|
5990
6947
|
entityType
|
|
5991
6948
|
});
|
|
5992
6949
|
};
|
|
6950
|
+
var getFormat2 = (entityType, config2) => {
|
|
6951
|
+
return getEntityOption({
|
|
6952
|
+
optionName: "format",
|
|
6953
|
+
operation: "push",
|
|
6954
|
+
config: config2,
|
|
6955
|
+
entityType
|
|
6956
|
+
});
|
|
6957
|
+
};
|
|
5993
6958
|
|
|
5994
6959
|
// src/commands/sync/index.ts
|
|
5995
6960
|
var SyncCommand = {
|
|
5996
6961
|
command: "sync <command>",
|
|
5997
6962
|
describe: "Uniform Sync commands",
|
|
5998
|
-
builder: (
|
|
6963
|
+
builder: (yargs25) => yargs25.command(SyncPullModule).command(SyncPushModule).demandCommand(),
|
|
5999
6964
|
handler: () => {
|
|
6000
|
-
|
|
6965
|
+
yargs23.showHelp();
|
|
6001
6966
|
}
|
|
6002
6967
|
};
|
|
6003
6968
|
|
|
@@ -6041,17 +7006,17 @@ async function checkForUpdateMiddleware() {
|
|
|
6041
7006
|
|
|
6042
7007
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
6043
7008
|
import { magenta, red as red6 } from "colorette";
|
|
6044
|
-
import { join as
|
|
7009
|
+
import { join as join3 } from "path";
|
|
6045
7010
|
|
|
6046
7011
|
// src/fs.ts
|
|
6047
|
-
import { promises as
|
|
7012
|
+
import { promises as fs5 } from "fs";
|
|
6048
7013
|
async function readJSON(path4) {
|
|
6049
|
-
const fileContents = await
|
|
7014
|
+
const fileContents = await fs5.readFile(path4, "utf-8");
|
|
6050
7015
|
return JSON.parse(fileContents);
|
|
6051
7016
|
}
|
|
6052
7017
|
async function tryReadJSON(path4, missingValue = null) {
|
|
6053
7018
|
try {
|
|
6054
|
-
const stat = await
|
|
7019
|
+
const stat = await fs5.stat(path4);
|
|
6055
7020
|
return stat.isFile() ? await readJSON(path4) : missingValue;
|
|
6056
7021
|
} catch (e) {
|
|
6057
7022
|
return missingValue;
|
|
@@ -6080,7 +7045,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
6080
7045
|
try {
|
|
6081
7046
|
let isOutside = false;
|
|
6082
7047
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
6083
|
-
const localPackages = await tryReadJSON(
|
|
7048
|
+
const localPackages = await tryReadJSON(join3(process.cwd(), "package.json"));
|
|
6084
7049
|
if (!localPackages)
|
|
6085
7050
|
return;
|
|
6086
7051
|
let firstVersion;
|
|
@@ -6113,30 +7078,13 @@ First found was: v${firstVersion}`;
|
|
|
6113
7078
|
|
|
6114
7079
|
// src/index.ts
|
|
6115
7080
|
dotenv.config();
|
|
6116
|
-
var yarggery =
|
|
6117
|
-
var
|
|
6118
|
-
var
|
|
6119
|
-
searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.json`],
|
|
6120
|
-
loaders: {
|
|
6121
|
-
".ts": TypeScriptLoader()
|
|
6122
|
-
}
|
|
6123
|
-
});
|
|
6124
|
-
var searchedForm = syncCosmicExplorer.search();
|
|
6125
|
-
var cosmicConfig = applyDefaultSyncConfiguration((searchedForm == null ? void 0 : searchedForm.config) ?? {});
|
|
7081
|
+
var yarggery = yargs24(hideBin(process.argv));
|
|
7082
|
+
var inlineConfigurationFilePath = "config" in yarggery.argv && yarggery.argv.config;
|
|
7083
|
+
var configuration = loadConfig(inlineConfigurationFilePath || null);
|
|
6126
7084
|
yarggery.option("verbose", {
|
|
6127
7085
|
describe: "Include verbose logging",
|
|
6128
7086
|
default: false,
|
|
6129
7087
|
type: "boolean"
|
|
6130
|
-
}).scriptName("uniform").config(
|
|
6131
|
-
|
|
6132
|
-
throw new Error(`Invalid configuration file path: ${configPath}. File does not exist.`);
|
|
6133
|
-
}
|
|
6134
|
-
const config2 = syncCosmicExplorer.load(configPath);
|
|
6135
|
-
if (!(config2 == null ? void 0 : config2.config.serialization)) {
|
|
6136
|
-
throw new Error(
|
|
6137
|
-
`Invalid configuration file: ${configPath}. Missing config.serialization configuration.`
|
|
6138
|
-
);
|
|
6139
|
-
}
|
|
6140
|
-
const configuration = applyDefaultSyncConfiguration((config2 == null ? void 0 : config2.config) ?? {});
|
|
6141
|
-
return { serialization: configuration.serialization };
|
|
7088
|
+
}).scriptName("uniform").config(configuration).config("config", function() {
|
|
7089
|
+
return {};
|
|
6142
7090
|
}).command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(RedirectCommand).command(SyncCommand).command(NewCmd).command(NewMeshCmd).command(OptimizeCommand).demandCommand(1, "").strict().help().middleware([checkForUpdateMiddleware, checkLocalDepsVersions]).argv;
|