@uniformdev/cli 20.49.5-alpha.10 → 20.49.5-alpha.11
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/defaultConfig.d.mts
CHANGED
|
@@ -6,12 +6,27 @@ type StateArgs = {
|
|
|
6
6
|
type SyncMode = 'mirror' | 'createOrUpdate' | 'create';
|
|
7
7
|
type EntityTypes = 'aggregate' | 'asset' | 'category' | 'workflow' | 'webhook' | 'component' | 'composition' | 'contentType' | 'dataType' | 'enrichment' | 'entry' | 'entryPattern' | 'locale' | 'componentPattern' | 'compositionPattern' | 'policyDocument' | 'projectMapDefinition' | 'projectMapNode' | 'previewUrl' | 'previewViewport' | 'prompt' | 'quirk' | 'redirect' | 'signal' | 'test';
|
|
8
8
|
type SyncFileFormat = 'yaml' | 'json';
|
|
9
|
-
type
|
|
9
|
+
type EntityConfigurationBase = {
|
|
10
10
|
mode?: SyncMode;
|
|
11
11
|
directory?: string;
|
|
12
12
|
format?: SyncFileFormat;
|
|
13
13
|
disabled?: true;
|
|
14
14
|
};
|
|
15
|
+
type EntityFilterInclude = {
|
|
16
|
+
/** If set, only entities whose ID matches one of these values will be synced. Cannot be combined with `exclude`. */
|
|
17
|
+
include: string[];
|
|
18
|
+
exclude?: never;
|
|
19
|
+
};
|
|
20
|
+
type EntityFilterExclude = {
|
|
21
|
+
include?: never;
|
|
22
|
+
/** If set, entities whose ID matches one of these values will be excluded from sync. Cannot be combined with `include`. */
|
|
23
|
+
exclude: string[];
|
|
24
|
+
};
|
|
25
|
+
type EntityFilterNone = {
|
|
26
|
+
include?: never;
|
|
27
|
+
exclude?: never;
|
|
28
|
+
};
|
|
29
|
+
type EntityConfiguration = EntityConfigurationBase & (EntityFilterInclude | EntityFilterExclude | EntityFilterNone);
|
|
15
30
|
type EntityWithStateConfiguration = EntityConfiguration & Partial<StateArgs>;
|
|
16
31
|
type PublishableEntitiesConfiguration = EntityWithStateConfiguration & {
|
|
17
32
|
publish?: boolean;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { C as CLIConfiguration } from './index-
|
|
2
|
+
export { C as CLIConfiguration } from './index-fzc0-h1F.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -558,6 +558,34 @@ async function createArraySyncEngineDataSource({
|
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
+
// src/sync/entityFilter.ts
|
|
562
|
+
function resolveEntityFilter(entityConfig, operation) {
|
|
563
|
+
const directional = entityConfig?.[operation];
|
|
564
|
+
const include = directional?.include ?? entityConfig?.include;
|
|
565
|
+
const exclude = directional?.exclude ?? entityConfig?.exclude;
|
|
566
|
+
return createEntityFilter(include, exclude);
|
|
567
|
+
}
|
|
568
|
+
function createEntityFilter(include, exclude) {
|
|
569
|
+
if (include?.length && exclude?.length) {
|
|
570
|
+
throw new Error("Entity filter cannot have both `include` and `exclude` defined. Use one or the other.");
|
|
571
|
+
}
|
|
572
|
+
if (!include?.length && !exclude?.length) {
|
|
573
|
+
return void 0;
|
|
574
|
+
}
|
|
575
|
+
if (include?.length) {
|
|
576
|
+
const includeSet = new Set(include);
|
|
577
|
+
return (obj) => {
|
|
578
|
+
const ids = Array.isArray(obj.id) ? obj.id : [obj.id];
|
|
579
|
+
return ids.some((id) => includeSet.has(id));
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
const excludeSet = new Set(exclude);
|
|
583
|
+
return (obj) => {
|
|
584
|
+
const ids = Array.isArray(obj.id) ? obj.id : [obj.id];
|
|
585
|
+
return !ids.some((id) => excludeSet.has(id));
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
561
589
|
// src/sync/fileSyncEngineDataSource.ts
|
|
562
590
|
import { red } from "colorette";
|
|
563
591
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
@@ -656,9 +684,13 @@ async function createFileSyncEngineDataSource({
|
|
|
656
684
|
const fullFilename = join(directory, filename);
|
|
657
685
|
try {
|
|
658
686
|
const contents = readFileToObject(fullFilename);
|
|
687
|
+
const id = selectIdentifier18(contents);
|
|
688
|
+
if (id === void 0 || id === null || Array.isArray(id) && id.length === 0) {
|
|
689
|
+
throw new Error(`File does not contain a valid identifier.`);
|
|
690
|
+
}
|
|
659
691
|
const displayName = selectDisplayName18(contents);
|
|
660
692
|
const object4 = {
|
|
661
|
-
id
|
|
693
|
+
id,
|
|
662
694
|
displayName: Array.isArray(displayName) ? displayName[0] : displayName,
|
|
663
695
|
providerId: fullFilename,
|
|
664
696
|
object: omit(contents, ["$schema"])
|
|
@@ -773,6 +805,16 @@ function serializedDequal(foo, bar) {
|
|
|
773
805
|
|
|
774
806
|
// src/sync/syncEngine.ts
|
|
775
807
|
var syncEngineEvents = mitt();
|
|
808
|
+
var _syncObjectFilter;
|
|
809
|
+
async function withSyncEngineFilter(filter, fn) {
|
|
810
|
+
const prev = _syncObjectFilter;
|
|
811
|
+
_syncObjectFilter = filter;
|
|
812
|
+
try {
|
|
813
|
+
return await fn();
|
|
814
|
+
} finally {
|
|
815
|
+
_syncObjectFilter = prev;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
776
818
|
async function syncEngine({
|
|
777
819
|
source,
|
|
778
820
|
target,
|
|
@@ -789,8 +831,10 @@ async function syncEngine({
|
|
|
789
831
|
//verbose = false,
|
|
790
832
|
}) {
|
|
791
833
|
const status = new ReactiveStatusUpdate((status2) => syncEngineEvents.emit("statusUpdate", status2));
|
|
834
|
+
const objectFilter = _syncObjectFilter;
|
|
792
835
|
const targetItems = /* @__PURE__ */ new Map();
|
|
793
836
|
const deleteTracker = /* @__PURE__ */ new Set();
|
|
837
|
+
const getFirstId = (id) => Array.isArray(id) ? id[0] : id;
|
|
794
838
|
const processDelete = async (object4) => {
|
|
795
839
|
if (deleteTracker.has(object4)) return;
|
|
796
840
|
deleteTracker.add(object4);
|
|
@@ -808,7 +852,7 @@ async function syncEngine({
|
|
|
808
852
|
} finally {
|
|
809
853
|
log2({
|
|
810
854
|
action: "delete",
|
|
811
|
-
id: object4.id
|
|
855
|
+
id: getFirstId(object4.id),
|
|
812
856
|
providerId: object4.providerId,
|
|
813
857
|
displayName: object4.displayName ?? object4.providerId,
|
|
814
858
|
whatIf,
|
|
@@ -817,6 +861,9 @@ async function syncEngine({
|
|
|
817
861
|
}
|
|
818
862
|
};
|
|
819
863
|
for await (const obj of target.objects) {
|
|
864
|
+
if (objectFilter && !objectFilter(obj)) {
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
820
867
|
status.fetched++;
|
|
821
868
|
if (Array.isArray(obj.id)) {
|
|
822
869
|
obj.id.forEach((o) => targetItems.set(o, obj));
|
|
@@ -827,6 +874,9 @@ async function syncEngine({
|
|
|
827
874
|
const actions = [];
|
|
828
875
|
let sourceHasItems = false;
|
|
829
876
|
for await (let sourceObject of source.objects) {
|
|
877
|
+
if (objectFilter && !objectFilter(sourceObject)) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
830
880
|
sourceHasItems = true;
|
|
831
881
|
if (onBeforeProcessObject) {
|
|
832
882
|
await onBeforeProcessObject(sourceObject);
|
|
@@ -12704,19 +12754,23 @@ var SyncPullModule = {
|
|
|
12704
12754
|
return entityConfig2 !== void 0 && "state" in entityConfig2;
|
|
12705
12755
|
};
|
|
12706
12756
|
const entityConfig = config2.entitiesConfig?.[entityType];
|
|
12757
|
+
const entityFilter = resolveEntityFilter(entityConfig, "pull");
|
|
12707
12758
|
try {
|
|
12708
12759
|
await spinPromise(
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12760
|
+
withSyncEngineFilter(
|
|
12761
|
+
entityFilter,
|
|
12762
|
+
() => module.handler({
|
|
12763
|
+
...otherParams,
|
|
12764
|
+
state: entityConfigSupportsPullState(entityConfig) ? entityConfig.state ?? 0 : 0,
|
|
12765
|
+
format: getFormat(entityType, config2),
|
|
12766
|
+
onlyCompositions: entityType === "composition" ? true : void 0,
|
|
12767
|
+
onlyPatterns: ["pattern", "componentPattern", "compositionPattern"].includes(entityType) ? true : void 0,
|
|
12768
|
+
patternType: entityType === "compositionPattern" ? "composition" : entityType === "componentPattern" ? "component" : void 0,
|
|
12769
|
+
mode: getPullMode(entityType, config2),
|
|
12770
|
+
directory: getPullFilename(entityType, config2),
|
|
12771
|
+
allowEmptySource: config2.allowEmptySource
|
|
12772
|
+
})
|
|
12773
|
+
),
|
|
12720
12774
|
{
|
|
12721
12775
|
text: `${entityType}\u2026`,
|
|
12722
12776
|
successText: entityType,
|
|
@@ -12868,19 +12922,24 @@ var SyncPushModule = {
|
|
|
12868
12922
|
);
|
|
12869
12923
|
}
|
|
12870
12924
|
for (const [entityType, module] of enabledEntities) {
|
|
12925
|
+
const entityConfig = config2.entitiesConfig?.[entityType];
|
|
12926
|
+
const entityFilter = resolveEntityFilter(entityConfig, "push");
|
|
12871
12927
|
try {
|
|
12872
12928
|
await spinPromise(
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12929
|
+
withSyncEngineFilter(
|
|
12930
|
+
entityFilter,
|
|
12931
|
+
() => module.handler({
|
|
12932
|
+
...otherParams,
|
|
12933
|
+
state: 0,
|
|
12934
|
+
format: getFormat2(entityType, config2),
|
|
12935
|
+
onlyCompositions: entityType === "composition" ? true : void 0,
|
|
12936
|
+
onlyPatterns: ["pattern", "componentPattern", "compositionPattern"].includes(entityType) ? true : void 0,
|
|
12937
|
+
patternType: entityType === "compositionPattern" ? "composition" : entityType === "componentPattern" ? "component" : void 0,
|
|
12938
|
+
mode: getPushMode(entityType, config2),
|
|
12939
|
+
directory: getPushFilename(entityType, config2),
|
|
12940
|
+
allowEmptySource: config2.allowEmptySource
|
|
12941
|
+
})
|
|
12942
|
+
),
|
|
12884
12943
|
{
|
|
12885
12944
|
text: `${entityType}...`,
|
|
12886
12945
|
successText: entityType,
|
|
@@ -12896,15 +12955,19 @@ var SyncPushModule = {
|
|
|
12896
12955
|
}
|
|
12897
12956
|
}
|
|
12898
12957
|
if (config2.entitiesConfig?.componentPattern && config2.entitiesConfig?.componentPattern?.push?.disabled !== true && config2.entitiesConfig?.componentPattern?.publish) {
|
|
12958
|
+
const publishFilter = resolveEntityFilter(config2.entitiesConfig.componentPattern, "push");
|
|
12899
12959
|
try {
|
|
12900
12960
|
await spinPromise(
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12961
|
+
withSyncEngineFilter(
|
|
12962
|
+
publishFilter,
|
|
12963
|
+
() => ComponentPatternPublishModule.handler({
|
|
12964
|
+
...otherParams,
|
|
12965
|
+
patternType: "component",
|
|
12966
|
+
onlyPatterns: true,
|
|
12967
|
+
all: true,
|
|
12968
|
+
directory: getPushFilename("componentPattern", config2)
|
|
12969
|
+
})
|
|
12970
|
+
),
|
|
12908
12971
|
{
|
|
12909
12972
|
text: "publishing component patterns...",
|
|
12910
12973
|
successText: "published component patterns",
|
|
@@ -12920,15 +12983,19 @@ var SyncPushModule = {
|
|
|
12920
12983
|
}
|
|
12921
12984
|
}
|
|
12922
12985
|
if (config2.entitiesConfig?.compositionPattern && config2.entitiesConfig?.compositionPattern?.push?.disabled !== true && config2.entitiesConfig?.compositionPattern?.publish) {
|
|
12986
|
+
const publishFilter = resolveEntityFilter(config2.entitiesConfig.compositionPattern, "push");
|
|
12923
12987
|
try {
|
|
12924
12988
|
await spinPromise(
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12989
|
+
withSyncEngineFilter(
|
|
12990
|
+
publishFilter,
|
|
12991
|
+
() => CompositionPatternPublishModule.handler({
|
|
12992
|
+
...otherParams,
|
|
12993
|
+
all: true,
|
|
12994
|
+
onlyPatterns: true,
|
|
12995
|
+
patternType: "composition",
|
|
12996
|
+
directory: getPushFilename("compositionPattern", config2)
|
|
12997
|
+
})
|
|
12998
|
+
),
|
|
12932
12999
|
{
|
|
12933
13000
|
text: "publishing composition patterns...",
|
|
12934
13001
|
successText: "published composition patterns",
|
|
@@ -12944,14 +13011,18 @@ var SyncPushModule = {
|
|
|
12944
13011
|
}
|
|
12945
13012
|
}
|
|
12946
13013
|
if (config2.entitiesConfig?.composition && config2.entitiesConfig?.composition?.push?.disabled !== true && config2.entitiesConfig?.composition?.publish) {
|
|
13014
|
+
const publishFilter = resolveEntityFilter(config2.entitiesConfig.composition, "push");
|
|
12947
13015
|
try {
|
|
12948
13016
|
await spinPromise(
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
13017
|
+
withSyncEngineFilter(
|
|
13018
|
+
publishFilter,
|
|
13019
|
+
() => CompositionPublishModule.handler({
|
|
13020
|
+
...otherParams,
|
|
13021
|
+
all: true,
|
|
13022
|
+
onlyCompositions: true,
|
|
13023
|
+
directory: getPushFilename("composition", config2)
|
|
13024
|
+
})
|
|
13025
|
+
),
|
|
12955
13026
|
{
|
|
12956
13027
|
text: "publishing compositions...",
|
|
12957
13028
|
successText: "published compositions",
|
|
@@ -12967,13 +13038,17 @@ var SyncPushModule = {
|
|
|
12967
13038
|
}
|
|
12968
13039
|
}
|
|
12969
13040
|
if (config2.entitiesConfig?.entry && config2.entitiesConfig?.entry?.push?.disabled !== true && config2.entitiesConfig?.entry?.publish) {
|
|
13041
|
+
const publishFilter = resolveEntityFilter(config2.entitiesConfig.entry, "push");
|
|
12970
13042
|
try {
|
|
12971
13043
|
await spinPromise(
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
13044
|
+
withSyncEngineFilter(
|
|
13045
|
+
publishFilter,
|
|
13046
|
+
() => EntryPublishModule.handler({
|
|
13047
|
+
...otherParams,
|
|
13048
|
+
all: true,
|
|
13049
|
+
directory: getPushFilename("entry", config2)
|
|
13050
|
+
})
|
|
13051
|
+
),
|
|
12977
13052
|
{
|
|
12978
13053
|
text: "publishing entries...",
|
|
12979
13054
|
successText: "published entries",
|
|
@@ -12989,13 +13064,17 @@ var SyncPushModule = {
|
|
|
12989
13064
|
}
|
|
12990
13065
|
}
|
|
12991
13066
|
if (config2.entitiesConfig?.entryPattern && config2.entitiesConfig?.entryPattern?.push?.disabled !== true && config2.entitiesConfig?.entryPattern?.publish) {
|
|
13067
|
+
const publishFilter = resolveEntityFilter(config2.entitiesConfig.entryPattern, "push");
|
|
12992
13068
|
try {
|
|
12993
13069
|
await spinPromise(
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
13070
|
+
withSyncEngineFilter(
|
|
13071
|
+
publishFilter,
|
|
13072
|
+
() => EntryPatternPublishModule.handler({
|
|
13073
|
+
...otherParams,
|
|
13074
|
+
all: true,
|
|
13075
|
+
directory: getPushFilename("entryPattern", config2)
|
|
13076
|
+
})
|
|
13077
|
+
),
|
|
12999
13078
|
{
|
|
13000
13079
|
text: "publishing entry patterns...",
|
|
13001
13080
|
successText: "published entry patterns",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.49.5-alpha.
|
|
3
|
+
"version": "20.49.5-alpha.11+4c766b7688",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@inquirer/prompts": "^7.10.1",
|
|
30
30
|
"@thi.ng/mime": "^2.2.23",
|
|
31
|
-
"@uniformdev/assets": "20.49.5-alpha.
|
|
32
|
-
"@uniformdev/canvas": "20.49.5-alpha.
|
|
33
|
-
"@uniformdev/context": "20.49.5-alpha.
|
|
34
|
-
"@uniformdev/files": "20.49.5-alpha.
|
|
35
|
-
"@uniformdev/project-map": "20.49.5-alpha.
|
|
36
|
-
"@uniformdev/redirect": "20.49.5-alpha.
|
|
37
|
-
"@uniformdev/richtext": "20.49.5-alpha.
|
|
31
|
+
"@uniformdev/assets": "20.49.5-alpha.11+4c766b7688",
|
|
32
|
+
"@uniformdev/canvas": "20.49.5-alpha.11+4c766b7688",
|
|
33
|
+
"@uniformdev/context": "20.49.5-alpha.11+4c766b7688",
|
|
34
|
+
"@uniformdev/files": "20.49.5-alpha.11+4c766b7688",
|
|
35
|
+
"@uniformdev/project-map": "20.49.5-alpha.11+4c766b7688",
|
|
36
|
+
"@uniformdev/redirect": "20.49.5-alpha.11+4c766b7688",
|
|
37
|
+
"@uniformdev/richtext": "20.49.5-alpha.11+4c766b7688",
|
|
38
38
|
"call-bind": "^1.0.2",
|
|
39
39
|
"colorette": "2.0.20",
|
|
40
40
|
"cosmiconfig": "9.0.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "4c766b76885644538ea47a284a10cdb1ffc31388"
|
|
85
85
|
}
|