@uniformdev/cli 20.55.2-alpha.2 → 20.55.2-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +374 -214
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -324,8 +324,8 @@ async function readJSON(path8) {
|
|
|
324
324
|
}
|
|
325
325
|
async function tryReadJSON(path8, missingValue = null) {
|
|
326
326
|
try {
|
|
327
|
-
const
|
|
328
|
-
return
|
|
327
|
+
const stat2 = await fs.stat(path8);
|
|
328
|
+
return stat2.isFile() ? await readJSON(path8) : missingValue;
|
|
329
329
|
} catch {
|
|
330
330
|
return missingValue;
|
|
331
331
|
}
|
|
@@ -1128,7 +1128,7 @@ var package_default = {
|
|
|
1128
1128
|
build: "tsc --noEmit && tsup",
|
|
1129
1129
|
dev: "tsup --watch",
|
|
1130
1130
|
clean: "rimraf dist",
|
|
1131
|
-
test: "
|
|
1131
|
+
test: "vitest run",
|
|
1132
1132
|
lint: 'eslint "src/**/*.{js,ts,tsx}"',
|
|
1133
1133
|
format: 'prettier --write "src/**/*.{js,ts,tsx}"'
|
|
1134
1134
|
},
|
|
@@ -3795,7 +3795,148 @@ var ComponentModule = {
|
|
|
3795
3795
|
// src/commands/canvas/commands/componentPattern.ts
|
|
3796
3796
|
import yargs7 from "yargs";
|
|
3797
3797
|
|
|
3798
|
+
// src/commands/canvas/util/entityTypeValidation.ts
|
|
3799
|
+
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2 } from "@uniformdev/canvas";
|
|
3800
|
+
function getCompositionActualType(composition) {
|
|
3801
|
+
return composition.pattern ? composition.patternType === "component" ? "component-pattern" : "composition-pattern" : "composition";
|
|
3802
|
+
}
|
|
3803
|
+
function getEntryActualType(entry) {
|
|
3804
|
+
return entry.pattern ? "entry-pattern" : "entry";
|
|
3805
|
+
}
|
|
3806
|
+
async function validateCompositionType(client, id, expectedType) {
|
|
3807
|
+
try {
|
|
3808
|
+
const composition = await client.getCompositionById({
|
|
3809
|
+
compositionId: id,
|
|
3810
|
+
skipDataResolution: true,
|
|
3811
|
+
state: CANVAS_DRAFT_STATE2
|
|
3812
|
+
});
|
|
3813
|
+
const actualType = getCompositionActualType(composition);
|
|
3814
|
+
return {
|
|
3815
|
+
actualType,
|
|
3816
|
+
isValid: actualType === expectedType,
|
|
3817
|
+
exists: true
|
|
3818
|
+
};
|
|
3819
|
+
} catch (error) {
|
|
3820
|
+
if (error && typeof error === "object" && "statusCode" in error && error.statusCode === 404) {
|
|
3821
|
+
return {
|
|
3822
|
+
actualType: expectedType,
|
|
3823
|
+
isValid: false,
|
|
3824
|
+
exists: false
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
throw error;
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
async function validateEntryType(client, id, expectedType) {
|
|
3831
|
+
const res = await client.getEntries({
|
|
3832
|
+
offset: 0,
|
|
3833
|
+
limit: 1,
|
|
3834
|
+
entryIDs: [id],
|
|
3835
|
+
skipDataResolution: true,
|
|
3836
|
+
state: CANVAS_DRAFT_STATE2
|
|
3837
|
+
});
|
|
3838
|
+
if (res.entries.length !== 1) {
|
|
3839
|
+
return {
|
|
3840
|
+
actualType: expectedType,
|
|
3841
|
+
isValid: false,
|
|
3842
|
+
exists: false
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3845
|
+
const entry = res.entries[0];
|
|
3846
|
+
const actualType = getEntryActualType(entry);
|
|
3847
|
+
return {
|
|
3848
|
+
actualType,
|
|
3849
|
+
isValid: actualType === expectedType,
|
|
3850
|
+
exists: true
|
|
3851
|
+
};
|
|
3852
|
+
}
|
|
3853
|
+
function getCompositionDisplayNameWithArticle(type) {
|
|
3854
|
+
switch (type) {
|
|
3855
|
+
case "composition":
|
|
3856
|
+
return "a composition";
|
|
3857
|
+
case "composition-pattern":
|
|
3858
|
+
return "a composition pattern";
|
|
3859
|
+
case "component-pattern":
|
|
3860
|
+
return "a component pattern";
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
function getEntryDisplayNameWithArticle(type) {
|
|
3864
|
+
return type === "entry" ? "an entry" : "an entry pattern";
|
|
3865
|
+
}
|
|
3866
|
+
function getCompositionDisplayName(type) {
|
|
3867
|
+
switch (type) {
|
|
3868
|
+
case "composition":
|
|
3869
|
+
return "Composition";
|
|
3870
|
+
case "composition-pattern":
|
|
3871
|
+
return "Composition Pattern";
|
|
3872
|
+
case "component-pattern":
|
|
3873
|
+
return "Component Pattern";
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
function getEntryDisplayName(type) {
|
|
3877
|
+
return type === "entry" ? "Entry" : "Entry Pattern";
|
|
3878
|
+
}
|
|
3879
|
+
function getCommandVerb(action) {
|
|
3880
|
+
return action === "delete" ? "remove" : action;
|
|
3881
|
+
}
|
|
3882
|
+
function formatCompositionTypeError(id, actualType, expectedType, action) {
|
|
3883
|
+
const actualDisplayName = getCompositionDisplayNameWithArticle(actualType);
|
|
3884
|
+
const expectedDisplayName = getCompositionDisplayNameWithArticle(expectedType);
|
|
3885
|
+
return `Error: The provided ID belongs to ${actualDisplayName}, not ${expectedDisplayName}.
|
|
3886
|
+
To ${action} ${actualDisplayName}, use: uniform canvas ${actualType} ${getCommandVerb(action)} ${id}`;
|
|
3887
|
+
}
|
|
3888
|
+
function formatEntryTypeError(id, actualType, expectedType, action) {
|
|
3889
|
+
const actualDisplayName = getEntryDisplayNameWithArticle(actualType);
|
|
3890
|
+
const expectedDisplayName = getEntryDisplayNameWithArticle(expectedType);
|
|
3891
|
+
return `Error: The provided ID belongs to ${actualDisplayName}, not ${expectedDisplayName}.
|
|
3892
|
+
To ${action} ${actualDisplayName}, use: uniform canvas ${actualType} ${getCommandVerb(action)} ${id}`;
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3798
3895
|
// src/commands/canvas/commands/composition/get.ts
|
|
3896
|
+
function createCompositionGetHandler(expectedType) {
|
|
3897
|
+
return async ({
|
|
3898
|
+
apiHost,
|
|
3899
|
+
edgeApiHost,
|
|
3900
|
+
apiKey,
|
|
3901
|
+
proxy,
|
|
3902
|
+
id,
|
|
3903
|
+
format,
|
|
3904
|
+
filename,
|
|
3905
|
+
state,
|
|
3906
|
+
project: projectId,
|
|
3907
|
+
resolvePatterns,
|
|
3908
|
+
resolveOverrides,
|
|
3909
|
+
componentIDs,
|
|
3910
|
+
resolveData,
|
|
3911
|
+
diagnostics,
|
|
3912
|
+
resolutionDepth,
|
|
3913
|
+
verbose
|
|
3914
|
+
}) => {
|
|
3915
|
+
const parameters = {
|
|
3916
|
+
compositionId: id,
|
|
3917
|
+
state: convertStateOption(state),
|
|
3918
|
+
skipPatternResolution: !resolvePatterns,
|
|
3919
|
+
skipOverridesResolution: !resolveOverrides,
|
|
3920
|
+
withComponentIDs: componentIDs,
|
|
3921
|
+
skipDataResolution: !resolveData,
|
|
3922
|
+
diagnostics: resolveData ? diagnostics : void 0,
|
|
3923
|
+
resolutionDepth: resolveData ? resolutionDepth : void 0
|
|
3924
|
+
};
|
|
3925
|
+
if (verbose) {
|
|
3926
|
+
console.log(`\u{1F41B} get ${expectedType}:`, parameters);
|
|
3927
|
+
}
|
|
3928
|
+
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
3929
|
+
const client = getCanvasClient({ apiKey, edgeApiHost, apiHost, fetch: fetch2, projectId });
|
|
3930
|
+
const composition = await client.getCompositionById(parameters);
|
|
3931
|
+
const actualType = getCompositionActualType(composition);
|
|
3932
|
+
if (actualType !== expectedType) {
|
|
3933
|
+
console.error(formatCompositionTypeError(id, actualType, expectedType, "get"));
|
|
3934
|
+
process.exit(1);
|
|
3935
|
+
}
|
|
3936
|
+
const res = prepCompositionForDisk(composition);
|
|
3937
|
+
emitWithFormat(res, format, filename);
|
|
3938
|
+
};
|
|
3939
|
+
}
|
|
3799
3940
|
var CompositionGetModule = {
|
|
3800
3941
|
command: "get <id>",
|
|
3801
3942
|
describe: "Fetch a composition",
|
|
@@ -3807,7 +3948,7 @@ var CompositionGetModule = {
|
|
|
3807
3948
|
withDebugOptions(
|
|
3808
3949
|
yargs43.positional("id", {
|
|
3809
3950
|
demandOption: true,
|
|
3810
|
-
describe: "Composition
|
|
3951
|
+
describe: "Composition public ID to fetch"
|
|
3811
3952
|
}).option({
|
|
3812
3953
|
resolvePatterns: {
|
|
3813
3954
|
type: "boolean",
|
|
@@ -3846,48 +3987,14 @@ var CompositionGetModule = {
|
|
|
3846
3987
|
)
|
|
3847
3988
|
)
|
|
3848
3989
|
),
|
|
3849
|
-
handler:
|
|
3850
|
-
apiHost,
|
|
3851
|
-
edgeApiHost,
|
|
3852
|
-
apiKey,
|
|
3853
|
-
proxy,
|
|
3854
|
-
id,
|
|
3855
|
-
format,
|
|
3856
|
-
filename,
|
|
3857
|
-
state,
|
|
3858
|
-
project: projectId,
|
|
3859
|
-
resolvePatterns,
|
|
3860
|
-
resolveOverrides,
|
|
3861
|
-
componentIDs,
|
|
3862
|
-
resolveData,
|
|
3863
|
-
diagnostics,
|
|
3864
|
-
resolutionDepth,
|
|
3865
|
-
verbose
|
|
3866
|
-
}) => {
|
|
3867
|
-
const parameters = {
|
|
3868
|
-
compositionId: id,
|
|
3869
|
-
state: convertStateOption(state),
|
|
3870
|
-
skipPatternResolution: !resolvePatterns,
|
|
3871
|
-
skipOverridesResolution: !resolveOverrides,
|
|
3872
|
-
withComponentIDs: componentIDs,
|
|
3873
|
-
skipDataResolution: !resolveData,
|
|
3874
|
-
diagnostics: resolveData ? diagnostics : void 0,
|
|
3875
|
-
resolutionDepth: resolveData ? resolutionDepth : void 0
|
|
3876
|
-
};
|
|
3877
|
-
if (verbose) {
|
|
3878
|
-
console.log(`\u{1F41B} get composition:`, parameters);
|
|
3879
|
-
}
|
|
3880
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
3881
|
-
const client = getCanvasClient({ apiKey, edgeApiHost, apiHost, fetch: fetch2, projectId });
|
|
3882
|
-
const res = prepCompositionForDisk(await client.getCompositionById(parameters));
|
|
3883
|
-
emitWithFormat(res, format, filename);
|
|
3884
|
-
}
|
|
3990
|
+
handler: createCompositionGetHandler("composition")
|
|
3885
3991
|
};
|
|
3886
3992
|
|
|
3887
3993
|
// src/commands/canvas/commands/componentPattern/get.ts
|
|
3888
3994
|
var ComponentPatternGetModule = {
|
|
3889
3995
|
...CompositionGetModule,
|
|
3890
|
-
describe: "Fetch a component pattern"
|
|
3996
|
+
describe: "Fetch a component pattern",
|
|
3997
|
+
handler: createCompositionGetHandler("component-pattern")
|
|
3891
3998
|
};
|
|
3892
3999
|
|
|
3893
4000
|
// src/commands/canvas/commands/composition/list.ts
|
|
@@ -4611,6 +4718,37 @@ var ComponentPatternPushModule = {
|
|
|
4611
4718
|
};
|
|
4612
4719
|
|
|
4613
4720
|
// src/commands/canvas/commands/composition/remove.ts
|
|
4721
|
+
function createCompositionRemoveHandler(expectedType) {
|
|
4722
|
+
return async ({
|
|
4723
|
+
apiHost,
|
|
4724
|
+
apiKey,
|
|
4725
|
+
proxy,
|
|
4726
|
+
id,
|
|
4727
|
+
project: projectId,
|
|
4728
|
+
verbose,
|
|
4729
|
+
whatIf
|
|
4730
|
+
}) => {
|
|
4731
|
+
if (verbose) {
|
|
4732
|
+
console.log(`\u{1F41B} remove ${expectedType}: (id: ${id})`);
|
|
4733
|
+
}
|
|
4734
|
+
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
4735
|
+
const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
4736
|
+
const validation = await validateCompositionType(client, id, expectedType);
|
|
4737
|
+
if (!validation.exists) {
|
|
4738
|
+
console.error(`Error: ${getCompositionDisplayName(expectedType)} with ID "${id}" not found.`);
|
|
4739
|
+
process.exit(1);
|
|
4740
|
+
}
|
|
4741
|
+
if (!validation.isValid) {
|
|
4742
|
+
console.error(formatCompositionTypeError(id, validation.actualType, expectedType, "delete"));
|
|
4743
|
+
process.exit(1);
|
|
4744
|
+
}
|
|
4745
|
+
if (!whatIf) {
|
|
4746
|
+
await client.removeComposition({ compositionId: id });
|
|
4747
|
+
} else {
|
|
4748
|
+
whatIfSimpleLog({ id, displayName: getCompositionDisplayName(expectedType), action: "delete" });
|
|
4749
|
+
}
|
|
4750
|
+
};
|
|
4751
|
+
}
|
|
4614
4752
|
var CompositionRemoveModule = {
|
|
4615
4753
|
command: "remove <id>",
|
|
4616
4754
|
aliases: ["delete", "rm"],
|
|
@@ -4621,30 +4759,21 @@ var CompositionRemoveModule = {
|
|
|
4621
4759
|
withProjectOptions(
|
|
4622
4760
|
yargs43.positional("id", {
|
|
4623
4761
|
demandOption: true,
|
|
4624
|
-
describe: "Composition
|
|
4762
|
+
describe: "Composition public ID to delete"
|
|
4625
4763
|
})
|
|
4626
4764
|
)
|
|
4627
4765
|
)
|
|
4628
4766
|
)
|
|
4767
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4629
4768
|
),
|
|
4630
|
-
handler:
|
|
4631
|
-
if (verbose) {
|
|
4632
|
-
console.log(`\u{1F41B} remove composition: (id: ${id})`);
|
|
4633
|
-
}
|
|
4634
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
4635
|
-
const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
4636
|
-
if (!whatIf) {
|
|
4637
|
-
await client.removeComposition({ compositionId: id });
|
|
4638
|
-
} else {
|
|
4639
|
-
whatIfSimpleLog({ id, displayName: `Composition`, action: "delete" });
|
|
4640
|
-
}
|
|
4641
|
-
}
|
|
4769
|
+
handler: createCompositionRemoveHandler("composition")
|
|
4642
4770
|
};
|
|
4643
4771
|
|
|
4644
4772
|
// src/commands/canvas/commands/componentPattern/remove.ts
|
|
4645
4773
|
var ComponentPatternRemoveModule = {
|
|
4646
4774
|
...CompositionRemoveModule,
|
|
4647
|
-
describe: "Delete a component pattern"
|
|
4775
|
+
describe: "Delete a component pattern",
|
|
4776
|
+
handler: createCompositionRemoveHandler("component-pattern")
|
|
4648
4777
|
};
|
|
4649
4778
|
|
|
4650
4779
|
// src/commands/canvas/commands/composition/unpublish.ts
|
|
@@ -4805,6 +4934,40 @@ var ComponentPatternUnpublishModule = {
|
|
|
4805
4934
|
};
|
|
4806
4935
|
|
|
4807
4936
|
// src/commands/canvas/commands/composition/update.ts
|
|
4937
|
+
function createCompositionUpdateHandler(expectedType) {
|
|
4938
|
+
return async ({
|
|
4939
|
+
apiHost,
|
|
4940
|
+
apiKey,
|
|
4941
|
+
proxy,
|
|
4942
|
+
filename,
|
|
4943
|
+
project: projectId,
|
|
4944
|
+
state,
|
|
4945
|
+
verbose,
|
|
4946
|
+
whatIf
|
|
4947
|
+
}) => {
|
|
4948
|
+
if (verbose) {
|
|
4949
|
+
console.log(`\u{1F41B} update ${expectedType}: (filename: ${filename}, state: ${convertStateOption(state)})`);
|
|
4950
|
+
}
|
|
4951
|
+
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
4952
|
+
const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
4953
|
+
const file = readFileToObject(filename);
|
|
4954
|
+
const id = file.composition._id;
|
|
4955
|
+
const validation = await validateCompositionType(client, id, expectedType);
|
|
4956
|
+
if (validation.exists && !validation.isValid) {
|
|
4957
|
+
console.error(formatCompositionTypeError(id, validation.actualType, expectedType, "update"));
|
|
4958
|
+
process.exit(1);
|
|
4959
|
+
}
|
|
4960
|
+
if (!whatIf) {
|
|
4961
|
+
await client.updateComposition({ ...file, state: convertStateOption(state) });
|
|
4962
|
+
} else {
|
|
4963
|
+
whatIfSimpleLog({
|
|
4964
|
+
id,
|
|
4965
|
+
displayName: `${getCompositionDisplayName(expectedType)}: ${file.composition._name}`,
|
|
4966
|
+
action: "update"
|
|
4967
|
+
});
|
|
4968
|
+
}
|
|
4969
|
+
};
|
|
4970
|
+
}
|
|
4808
4971
|
var CompositionUpdateModule = {
|
|
4809
4972
|
command: "update <filename>",
|
|
4810
4973
|
aliases: ["put"],
|
|
@@ -4823,29 +4986,14 @@ var CompositionUpdateModule = {
|
|
|
4823
4986
|
)
|
|
4824
4987
|
)
|
|
4825
4988
|
),
|
|
4826
|
-
handler:
|
|
4827
|
-
if (verbose) {
|
|
4828
|
-
console.log(`\u{1F41B} update composition: (filename: ${filename}, state: ${convertStateOption(state)})`);
|
|
4829
|
-
}
|
|
4830
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
4831
|
-
const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
4832
|
-
const file = readFileToObject(filename);
|
|
4833
|
-
if (!whatIf) {
|
|
4834
|
-
await client.updateComposition({ ...file, state: convertStateOption(state) });
|
|
4835
|
-
} else {
|
|
4836
|
-
whatIfSimpleLog({
|
|
4837
|
-
id: file.composition._id,
|
|
4838
|
-
displayName: `Composition: ${file.composition._name}`,
|
|
4839
|
-
action: "update"
|
|
4840
|
-
});
|
|
4841
|
-
}
|
|
4842
|
-
}
|
|
4989
|
+
handler: createCompositionUpdateHandler("composition")
|
|
4843
4990
|
};
|
|
4844
4991
|
|
|
4845
4992
|
// src/commands/canvas/commands/componentPattern/update.ts
|
|
4846
4993
|
var ComponentPatternUpdateModule = {
|
|
4847
4994
|
...CompositionUpdateModule,
|
|
4848
|
-
describe: "Insert or update a component pattern"
|
|
4995
|
+
describe: "Insert or update a component pattern",
|
|
4996
|
+
handler: createCompositionUpdateHandler("component-pattern")
|
|
4849
4997
|
};
|
|
4850
4998
|
|
|
4851
4999
|
// src/commands/canvas/commands/componentPattern.ts
|
|
@@ -4876,7 +5024,8 @@ import yargs9 from "yargs";
|
|
|
4876
5024
|
// src/commands/canvas/commands/compositionPattern/get.ts
|
|
4877
5025
|
var CompositionPatternGetModule = {
|
|
4878
5026
|
...CompositionGetModule,
|
|
4879
|
-
describe: "Fetch a composition pattern"
|
|
5027
|
+
describe: "Fetch a composition pattern",
|
|
5028
|
+
handler: createCompositionGetHandler("composition-pattern")
|
|
4880
5029
|
};
|
|
4881
5030
|
|
|
4882
5031
|
// src/commands/canvas/commands/compositionPattern/list.ts
|
|
@@ -5059,7 +5208,8 @@ var CompositionPatternPushModule = {
|
|
|
5059
5208
|
// src/commands/canvas/commands/compositionPattern/remove.ts
|
|
5060
5209
|
var CompositionPatternRemoveModule = {
|
|
5061
5210
|
...CompositionRemoveModule,
|
|
5062
|
-
describe: "Delete a composition pattern"
|
|
5211
|
+
describe: "Delete a composition pattern",
|
|
5212
|
+
handler: createCompositionRemoveHandler("composition-pattern")
|
|
5063
5213
|
};
|
|
5064
5214
|
|
|
5065
5215
|
// src/commands/canvas/commands/compositionPattern/unpublish.ts
|
|
@@ -5099,7 +5249,8 @@ var CompositionPatternUnpublishModule = {
|
|
|
5099
5249
|
// src/commands/canvas/commands/compositionPattern/update.ts
|
|
5100
5250
|
var CompositionPatternUpdateModule = {
|
|
5101
5251
|
...CompositionUpdateModule,
|
|
5102
|
-
describe: "Insert or update a composition pattern"
|
|
5252
|
+
describe: "Insert or update a composition pattern",
|
|
5253
|
+
handler: createCompositionUpdateHandler("composition-pattern")
|
|
5103
5254
|
};
|
|
5104
5255
|
|
|
5105
5256
|
// src/commands/canvas/commands/compositionPattern.ts
|
|
@@ -5831,6 +5982,54 @@ var DataTypeModule = {
|
|
|
5831
5982
|
import yargs13 from "yargs";
|
|
5832
5983
|
|
|
5833
5984
|
// src/commands/canvas/commands/entry/get.ts
|
|
5985
|
+
function createEntryGetHandler(expectedType) {
|
|
5986
|
+
return async ({
|
|
5987
|
+
apiHost,
|
|
5988
|
+
edgeApiHost,
|
|
5989
|
+
apiKey,
|
|
5990
|
+
proxy,
|
|
5991
|
+
id,
|
|
5992
|
+
format,
|
|
5993
|
+
filename,
|
|
5994
|
+
project: projectId,
|
|
5995
|
+
state,
|
|
5996
|
+
resolveData,
|
|
5997
|
+
diagnostics,
|
|
5998
|
+
resolutionDepth,
|
|
5999
|
+
withComponentIDs,
|
|
6000
|
+
verbose
|
|
6001
|
+
}) => {
|
|
6002
|
+
if (verbose) {
|
|
6003
|
+
console.log(`\u{1F41B} get ${expectedType}: (id: ${id})`);
|
|
6004
|
+
}
|
|
6005
|
+
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
6006
|
+
const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
|
|
6007
|
+
const res = await client.getEntries({
|
|
6008
|
+
offset: 0,
|
|
6009
|
+
limit: 1,
|
|
6010
|
+
entryIDs: [id],
|
|
6011
|
+
state: convertStateOption(state),
|
|
6012
|
+
skipOverridesResolution: true,
|
|
6013
|
+
skipPatternResolution: true,
|
|
6014
|
+
skipDataResolution: !resolveData,
|
|
6015
|
+
diagnostics: resolveData ? diagnostics : void 0,
|
|
6016
|
+
resolutionDepth: resolveData ? resolutionDepth : void 0,
|
|
6017
|
+
withComponentIDs,
|
|
6018
|
+
pattern: expectedType === "entry-pattern" ? true : void 0
|
|
6019
|
+
});
|
|
6020
|
+
if (res.entries.length !== 1) {
|
|
6021
|
+
console.error(`Error: ${getEntryDisplayName(expectedType)} with ID "${id}" not found.`);
|
|
6022
|
+
process.exit(1);
|
|
6023
|
+
}
|
|
6024
|
+
const entry = res.entries[0];
|
|
6025
|
+
const actualType = getEntryActualType(entry);
|
|
6026
|
+
if (actualType !== expectedType) {
|
|
6027
|
+
console.error(formatEntryTypeError(id, actualType, expectedType, "get"));
|
|
6028
|
+
process.exit(1);
|
|
6029
|
+
}
|
|
6030
|
+
emitWithFormat(entry, format, filename);
|
|
6031
|
+
};
|
|
6032
|
+
}
|
|
5834
6033
|
var EntryGetModule = {
|
|
5835
6034
|
command: "get <id>",
|
|
5836
6035
|
describe: "Get an entry",
|
|
@@ -5870,41 +6069,7 @@ var EntryGetModule = {
|
|
|
5870
6069
|
)
|
|
5871
6070
|
)
|
|
5872
6071
|
),
|
|
5873
|
-
handler:
|
|
5874
|
-
apiHost,
|
|
5875
|
-
edgeApiHost,
|
|
5876
|
-
apiKey,
|
|
5877
|
-
proxy,
|
|
5878
|
-
id,
|
|
5879
|
-
format,
|
|
5880
|
-
filename,
|
|
5881
|
-
project: projectId,
|
|
5882
|
-
state,
|
|
5883
|
-
resolveData,
|
|
5884
|
-
diagnostics,
|
|
5885
|
-
resolutionDepth,
|
|
5886
|
-
withComponentIDs,
|
|
5887
|
-
verbose
|
|
5888
|
-
}) => {
|
|
5889
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
5890
|
-
const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
|
|
5891
|
-
const res = await client.getEntries({
|
|
5892
|
-
offset: 0,
|
|
5893
|
-
limit: 1,
|
|
5894
|
-
entryIDs: [id],
|
|
5895
|
-
state: convertStateOption(state),
|
|
5896
|
-
skipOverridesResolution: true,
|
|
5897
|
-
skipPatternResolution: true,
|
|
5898
|
-
skipDataResolution: !resolveData,
|
|
5899
|
-
diagnostics: resolveData ? diagnostics : void 0,
|
|
5900
|
-
resolutionDepth: resolveData ? resolutionDepth : void 0,
|
|
5901
|
-
withComponentIDs
|
|
5902
|
-
});
|
|
5903
|
-
if (res.entries.length !== 1) {
|
|
5904
|
-
throw new Error(`Entry with ID ${id} not found`);
|
|
5905
|
-
}
|
|
5906
|
-
emitWithFormat(res.entries[0], format, filename);
|
|
5907
|
-
}
|
|
6072
|
+
handler: createEntryGetHandler("entry")
|
|
5908
6073
|
};
|
|
5909
6074
|
|
|
5910
6075
|
// src/commands/canvas/commands/entry/list.ts
|
|
@@ -6340,6 +6505,37 @@ var EntryPushModule = {
|
|
|
6340
6505
|
};
|
|
6341
6506
|
|
|
6342
6507
|
// src/commands/canvas/commands/entry/remove.ts
|
|
6508
|
+
function createEntryRemoveHandler(expectedType) {
|
|
6509
|
+
return async ({
|
|
6510
|
+
apiHost,
|
|
6511
|
+
apiKey,
|
|
6512
|
+
proxy,
|
|
6513
|
+
id,
|
|
6514
|
+
project: projectId,
|
|
6515
|
+
verbose,
|
|
6516
|
+
whatIf
|
|
6517
|
+
}) => {
|
|
6518
|
+
if (verbose) {
|
|
6519
|
+
console.log(`\u{1F41B} remove ${expectedType}: (id: ${id})`);
|
|
6520
|
+
}
|
|
6521
|
+
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
6522
|
+
const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
6523
|
+
const validation = await validateEntryType(client, id, expectedType);
|
|
6524
|
+
if (!validation.exists) {
|
|
6525
|
+
console.error(`Error: ${getEntryDisplayName(expectedType)} with ID "${id}" not found.`);
|
|
6526
|
+
process.exit(1);
|
|
6527
|
+
}
|
|
6528
|
+
if (!validation.isValid) {
|
|
6529
|
+
console.error(formatEntryTypeError(id, validation.actualType, expectedType, "delete"));
|
|
6530
|
+
process.exit(1);
|
|
6531
|
+
}
|
|
6532
|
+
if (!whatIf) {
|
|
6533
|
+
await client.deleteEntry({ entryId: id });
|
|
6534
|
+
} else {
|
|
6535
|
+
whatIfSimpleLog({ id, displayName: getEntryDisplayName(expectedType), action: "delete" });
|
|
6536
|
+
}
|
|
6537
|
+
};
|
|
6538
|
+
}
|
|
6343
6539
|
var EntryRemoveModule = {
|
|
6344
6540
|
command: "remove <id>",
|
|
6345
6541
|
aliases: ["delete", "rm"],
|
|
@@ -6353,15 +6549,7 @@ var EntryRemoveModule = {
|
|
|
6353
6549
|
)
|
|
6354
6550
|
)
|
|
6355
6551
|
),
|
|
6356
|
-
handler:
|
|
6357
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
6358
|
-
const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
6359
|
-
if (!whatIf) {
|
|
6360
|
-
await client.deleteEntry({ entryId: id });
|
|
6361
|
-
} else {
|
|
6362
|
-
whatIfSimpleLog({ id, displayName: `Entry`, action: "delete" });
|
|
6363
|
-
}
|
|
6364
|
-
}
|
|
6552
|
+
handler: createEntryRemoveHandler("entry")
|
|
6365
6553
|
};
|
|
6366
6554
|
|
|
6367
6555
|
// src/commands/canvas/commands/entry/unpublish.ts
|
|
@@ -6455,22 +6643,8 @@ var EntryUnpublishModule = {
|
|
|
6455
6643
|
};
|
|
6456
6644
|
|
|
6457
6645
|
// src/commands/canvas/commands/entry/update.ts
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
aliases: ["put"],
|
|
6461
|
-
describe: "Insert or update an entry",
|
|
6462
|
-
builder: (yargs43) => withConfiguration(
|
|
6463
|
-
withDebugOptions(
|
|
6464
|
-
withApiOptions(
|
|
6465
|
-
withProjectOptions(
|
|
6466
|
-
withStateOptions(
|
|
6467
|
-
yargs43.positional("filename", { demandOption: true, describe: "Entry file to put" })
|
|
6468
|
-
)
|
|
6469
|
-
)
|
|
6470
|
-
)
|
|
6471
|
-
)
|
|
6472
|
-
),
|
|
6473
|
-
handler: async ({
|
|
6646
|
+
function createEntryUpdateHandler(expectedType) {
|
|
6647
|
+
return async ({
|
|
6474
6648
|
apiHost,
|
|
6475
6649
|
edgeApiHost,
|
|
6476
6650
|
apiKey,
|
|
@@ -6481,15 +6655,45 @@ var EntryUpdateModule = {
|
|
|
6481
6655
|
verbose,
|
|
6482
6656
|
whatIf
|
|
6483
6657
|
}) => {
|
|
6658
|
+
if (verbose) {
|
|
6659
|
+
console.log(`\u{1F41B} update ${expectedType}: (filename: ${filename}, state: ${convertStateOption(state)})`);
|
|
6660
|
+
}
|
|
6484
6661
|
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
6485
6662
|
const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
|
|
6486
6663
|
const file = readFileToObject(filename);
|
|
6664
|
+
const id = file.entry._id;
|
|
6665
|
+
const validation = await validateEntryType(client, id, expectedType);
|
|
6666
|
+
if (validation.exists && !validation.isValid) {
|
|
6667
|
+
console.error(formatEntryTypeError(id, validation.actualType, expectedType, "update"));
|
|
6668
|
+
process.exit(1);
|
|
6669
|
+
}
|
|
6487
6670
|
if (!whatIf) {
|
|
6488
6671
|
await client.upsertEntry({ ...file, state: convertStateOption(state) });
|
|
6489
6672
|
} else {
|
|
6490
|
-
whatIfSimpleLog({
|
|
6673
|
+
whatIfSimpleLog({
|
|
6674
|
+
id,
|
|
6675
|
+
displayName: `${getEntryDisplayName(expectedType)}: ${file.entry._name}`,
|
|
6676
|
+
action: "update"
|
|
6677
|
+
});
|
|
6491
6678
|
}
|
|
6492
|
-
}
|
|
6679
|
+
};
|
|
6680
|
+
}
|
|
6681
|
+
var EntryUpdateModule = {
|
|
6682
|
+
command: "update <filename>",
|
|
6683
|
+
aliases: ["put"],
|
|
6684
|
+
describe: "Insert or update an entry",
|
|
6685
|
+
builder: (yargs43) => withConfiguration(
|
|
6686
|
+
withDebugOptions(
|
|
6687
|
+
withApiOptions(
|
|
6688
|
+
withProjectOptions(
|
|
6689
|
+
withStateOptions(
|
|
6690
|
+
yargs43.positional("filename", { demandOption: true, describe: "Entry file to put" })
|
|
6691
|
+
)
|
|
6692
|
+
)
|
|
6693
|
+
)
|
|
6694
|
+
)
|
|
6695
|
+
),
|
|
6696
|
+
handler: createEntryUpdateHandler("entry")
|
|
6493
6697
|
};
|
|
6494
6698
|
|
|
6495
6699
|
// src/commands/canvas/commands/entry.ts
|
|
@@ -6515,10 +6719,22 @@ var EntryPatternGetModule = {
|
|
|
6515
6719
|
withApiOptions(
|
|
6516
6720
|
withProjectOptions(
|
|
6517
6721
|
withStateOptions(
|
|
6518
|
-
yargs43.positional("id", {
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6722
|
+
yargs43.positional("id", { demandOption: true, describe: "Entry pattern public ID to fetch" }).option({
|
|
6723
|
+
resolveData: {
|
|
6724
|
+
type: "boolean",
|
|
6725
|
+
default: false,
|
|
6726
|
+
describe: "Resolve all data resources used by the entry pattern"
|
|
6727
|
+
},
|
|
6728
|
+
diagnostics: {
|
|
6729
|
+
type: "boolean",
|
|
6730
|
+
default: false,
|
|
6731
|
+
describe: "Include diagnostics information when resolving data"
|
|
6732
|
+
},
|
|
6733
|
+
resolutionDepth: {
|
|
6734
|
+
type: "number",
|
|
6735
|
+
default: 1,
|
|
6736
|
+
describe: "Controls how many levels deep content references should be resolved"
|
|
6737
|
+
},
|
|
6522
6738
|
withComponentIDs: {
|
|
6523
6739
|
type: "boolean",
|
|
6524
6740
|
default: false,
|
|
@@ -6532,36 +6748,7 @@ var EntryPatternGetModule = {
|
|
|
6532
6748
|
)
|
|
6533
6749
|
)
|
|
6534
6750
|
),
|
|
6535
|
-
handler:
|
|
6536
|
-
apiHost,
|
|
6537
|
-
apiKey,
|
|
6538
|
-
proxy,
|
|
6539
|
-
id,
|
|
6540
|
-
format,
|
|
6541
|
-
filename,
|
|
6542
|
-
project: projectId,
|
|
6543
|
-
state,
|
|
6544
|
-
withComponentIDs,
|
|
6545
|
-
verbose
|
|
6546
|
-
}) => {
|
|
6547
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
6548
|
-
const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
6549
|
-
const res = await client.getEntries({
|
|
6550
|
-
offset: 0,
|
|
6551
|
-
limit: 1,
|
|
6552
|
-
entryIDs: [id],
|
|
6553
|
-
state: convertStateOption(state),
|
|
6554
|
-
skipOverridesResolution: true,
|
|
6555
|
-
skipPatternResolution: true,
|
|
6556
|
-
skipDataResolution: true,
|
|
6557
|
-
pattern: true,
|
|
6558
|
-
withComponentIDs
|
|
6559
|
-
});
|
|
6560
|
-
if (res.entries.length !== 1) {
|
|
6561
|
-
throw new Error(`Entry pattern with ID ${id} not found`);
|
|
6562
|
-
}
|
|
6563
|
-
emitWithFormat(res.entries[0], format, filename);
|
|
6564
|
-
}
|
|
6751
|
+
handler: createEntryGetHandler("entry-pattern")
|
|
6565
6752
|
};
|
|
6566
6753
|
|
|
6567
6754
|
// src/commands/canvas/commands/entryPattern/list.ts
|
|
@@ -6925,15 +7112,7 @@ var EntryPatternRemoveModule = {
|
|
|
6925
7112
|
)
|
|
6926
7113
|
)
|
|
6927
7114
|
),
|
|
6928
|
-
handler:
|
|
6929
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
6930
|
-
const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
|
|
6931
|
-
if (!whatIf) {
|
|
6932
|
-
await client.deleteEntry({ entryId: id });
|
|
6933
|
-
} else {
|
|
6934
|
-
whatIfSimpleLog({ id, displayName: `Entry Pattern`, action: "delete" });
|
|
6935
|
-
}
|
|
6936
|
-
}
|
|
7115
|
+
handler: createEntryRemoveHandler("entry-pattern")
|
|
6937
7116
|
};
|
|
6938
7117
|
|
|
6939
7118
|
// src/commands/canvas/commands/entryPattern/unpublish.ts
|
|
@@ -7042,30 +7221,7 @@ var EntryPatternUpdateModule = {
|
|
|
7042
7221
|
)
|
|
7043
7222
|
)
|
|
7044
7223
|
),
|
|
7045
|
-
handler:
|
|
7046
|
-
apiHost,
|
|
7047
|
-
edgeApiHost,
|
|
7048
|
-
apiKey,
|
|
7049
|
-
proxy,
|
|
7050
|
-
filename,
|
|
7051
|
-
project: projectId,
|
|
7052
|
-
state,
|
|
7053
|
-
verbose,
|
|
7054
|
-
whatIf
|
|
7055
|
-
}) => {
|
|
7056
|
-
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
7057
|
-
const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
|
|
7058
|
-
const file = readFileToObject(filename);
|
|
7059
|
-
if (!whatIf) {
|
|
7060
|
-
await client.upsertEntry({ ...file, state: convertStateOption(state) });
|
|
7061
|
-
} else {
|
|
7062
|
-
whatIfSimpleLog({
|
|
7063
|
-
id: file.entry._id,
|
|
7064
|
-
displayName: `Entry Pattern: ${file.entry._name}`,
|
|
7065
|
-
action: "update"
|
|
7066
|
-
});
|
|
7067
|
-
}
|
|
7068
|
-
}
|
|
7224
|
+
handler: createEntryUpdateHandler("entry-pattern")
|
|
7069
7225
|
};
|
|
7070
7226
|
|
|
7071
7227
|
// src/commands/canvas/commands/entryPattern.ts
|
|
@@ -11340,8 +11496,7 @@ var PolicyDocumentsPullModule = {
|
|
|
11340
11496
|
};
|
|
11341
11497
|
|
|
11342
11498
|
// src/commands/policy-documents/commands/push.ts
|
|
11343
|
-
import {
|
|
11344
|
-
import { readdir as readdir2 } from "fs/promises";
|
|
11499
|
+
import { readdir as readdir2, stat } from "fs/promises";
|
|
11345
11500
|
import { extname as extname2, join as join11 } from "path";
|
|
11346
11501
|
async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
11347
11502
|
const files = await readdir2(directory);
|
|
@@ -11458,11 +11613,16 @@ var PolicyDocumentsPushModule = {
|
|
|
11458
11613
|
allowEmptySource,
|
|
11459
11614
|
verbose
|
|
11460
11615
|
}) => {
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11616
|
+
try {
|
|
11617
|
+
const dirStat = await stat(directory);
|
|
11618
|
+
if (!dirStat.isDirectory()) {
|
|
11619
|
+
throw new Error(`Path "${directory}" is not a directory`);
|
|
11620
|
+
}
|
|
11621
|
+
} catch (e) {
|
|
11622
|
+
if (e.code === "ENOENT") {
|
|
11623
|
+
throw new Error(`Directory "${directory}" does not exist`);
|
|
11464
11624
|
}
|
|
11465
|
-
|
|
11625
|
+
throw e;
|
|
11466
11626
|
}
|
|
11467
11627
|
const fetch2 = nodeFetchProxy(proxy, verbose);
|
|
11468
11628
|
const localDocs = await readLocalPolicyDocuments(directory, format, verbose);
|
|
@@ -13282,7 +13442,7 @@ var WebhookCommand = {
|
|
|
13282
13442
|
import { bold as bold3, gray as gray6, green as green7 } from "colorette";
|
|
13283
13443
|
|
|
13284
13444
|
// src/updateCheck.ts
|
|
13285
|
-
import { existsSync as
|
|
13445
|
+
import { existsSync as existsSync5, promises as fs8 } from "fs";
|
|
13286
13446
|
import { get as getHttp } from "http";
|
|
13287
13447
|
import { get as getHttps } from "https";
|
|
13288
13448
|
import { tmpdir } from "os";
|
|
@@ -13294,7 +13454,7 @@ var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
|
13294
13454
|
var getFile = async (details, distTag) => {
|
|
13295
13455
|
const rootDir = tmpdir();
|
|
13296
13456
|
const subDir = join12(rootDir, "update-check");
|
|
13297
|
-
if (!
|
|
13457
|
+
if (!existsSync5(subDir)) {
|
|
13298
13458
|
await fs8.mkdir(subDir);
|
|
13299
13459
|
}
|
|
13300
13460
|
let name = `${details.name}-${distTag}.json`;
|
|
@@ -13304,7 +13464,7 @@ var getFile = async (details, distTag) => {
|
|
|
13304
13464
|
return join12(subDir, name);
|
|
13305
13465
|
};
|
|
13306
13466
|
var evaluateCache = async (file, time, interval) => {
|
|
13307
|
-
if (
|
|
13467
|
+
if (existsSync5(file)) {
|
|
13308
13468
|
const content = await fs8.readFile(file, "utf8");
|
|
13309
13469
|
const { lastUpdate, latest } = JSON.parse(content);
|
|
13310
13470
|
const nextCheck = lastUpdate + interval;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.55.2-alpha.
|
|
3
|
+
"version": "20.55.2-alpha.7+696a3fee53",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"build": "tsc --noEmit && tsup",
|
|
22
22
|
"dev": "tsup --watch",
|
|
23
23
|
"clean": "rimraf dist",
|
|
24
|
-
"test": "
|
|
24
|
+
"test": "vitest run",
|
|
25
25
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
26
26
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@inquirer/prompts": "^7.10.1",
|
|
30
30
|
"@thi.ng/mime": "^2.2.23",
|
|
31
|
-
"@uniformdev/assets": "20.55.2-alpha.
|
|
32
|
-
"@uniformdev/canvas": "20.55.2-alpha.
|
|
33
|
-
"@uniformdev/context": "20.55.2-alpha.
|
|
34
|
-
"@uniformdev/files": "20.55.2-alpha.
|
|
35
|
-
"@uniformdev/project-map": "20.55.2-alpha.
|
|
36
|
-
"@uniformdev/redirect": "20.55.2-alpha.
|
|
37
|
-
"@uniformdev/richtext": "20.55.2-alpha.
|
|
31
|
+
"@uniformdev/assets": "20.55.2-alpha.7+696a3fee53",
|
|
32
|
+
"@uniformdev/canvas": "20.55.2-alpha.7+696a3fee53",
|
|
33
|
+
"@uniformdev/context": "20.55.2-alpha.7+696a3fee53",
|
|
34
|
+
"@uniformdev/files": "20.55.2-alpha.7+696a3fee53",
|
|
35
|
+
"@uniformdev/project-map": "20.55.2-alpha.7+696a3fee53",
|
|
36
|
+
"@uniformdev/redirect": "20.55.2-alpha.7+696a3fee53",
|
|
37
|
+
"@uniformdev/richtext": "20.55.2-alpha.7+696a3fee53",
|
|
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": "696a3fee53d2c4667de4f6e98201b11cebe042da"
|
|
85
85
|
}
|