mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
feat: opencollection presets
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -53,6 +53,7 @@ bruno.iml
|
||||
/blob-report/
|
||||
|
||||
# Development plan files
|
||||
CLAUDE.md
|
||||
*.plan.md
|
||||
|
||||
# packages dist
|
||||
|
||||
@@ -26,6 +26,17 @@ const parseCollection = (ymlString: string): ParsedCollection => {
|
||||
brunoConfig.ignore = oc.extensions.ignore;
|
||||
}
|
||||
|
||||
// presets
|
||||
if (oc.extensions?.presets) {
|
||||
const presets = oc.extensions.presets as any;
|
||||
if (presets.request) {
|
||||
brunoConfig.presets = {
|
||||
requestType: presets.request.type || [],
|
||||
requestUrl: presets.request.url || []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// protobuf
|
||||
if (oc.config?.protobuf) {
|
||||
brunoConfig.protobuf = {
|
||||
|
||||
@@ -46,14 +46,20 @@ const hasRequestScripts = (collectionRoot: any): boolean => {
|
||||
|| (collectionRoot.request?.tests);
|
||||
};
|
||||
|
||||
const hasPresets = (brunoConfig: any): boolean => {
|
||||
return brunoConfig?.presets?.requestType?.length
|
||||
|| brunoConfig?.presets?.requestUrl?.length;
|
||||
};
|
||||
|
||||
const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
|
||||
console.log('brunoConfig', brunoConfig);
|
||||
try {
|
||||
const oc: OpenCollection = {};
|
||||
|
||||
oc.opencollection = '1.0.0';
|
||||
oc.info = {
|
||||
name: brunoConfig.name || 'Untitled Collection'
|
||||
};
|
||||
oc.opencollection = '1.0.0';
|
||||
|
||||
// collection config
|
||||
if (hasCollectionConfig(brunoConfig)) {
|
||||
@@ -179,6 +185,18 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
|
||||
});
|
||||
oc.extensions.ignore = ignoreList;
|
||||
}
|
||||
if (hasPresets(brunoConfig)) {
|
||||
const presetsRequest: any = {};
|
||||
if (brunoConfig.presets.requestType?.length) {
|
||||
presetsRequest.type = brunoConfig.presets.requestType;
|
||||
}
|
||||
if (brunoConfig.presets.requestUrl?.length) {
|
||||
presetsRequest.url = brunoConfig.presets.requestUrl;
|
||||
}
|
||||
oc.extensions.presets = {
|
||||
request: presetsRequest
|
||||
} as any;
|
||||
}
|
||||
|
||||
return stringifyYml(oc);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user