diff --git a/.gitignore b/.gitignore index 0ff231d00..d2f68f452 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ bruno.iml /blob-report/ # Development plan files +CLAUDE.md *.plan.md # packages dist diff --git a/packages/bruno-filestore/src/formats/yml/parseCollection.ts b/packages/bruno-filestore/src/formats/yml/parseCollection.ts index 6c411fb6c..c501d91ce 100644 --- a/packages/bruno-filestore/src/formats/yml/parseCollection.ts +++ b/packages/bruno-filestore/src/formats/yml/parseCollection.ts @@ -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 = { diff --git a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts index 4d0b74a2e..76b8ce574 100644 --- a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts +++ b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts @@ -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) {