From c9059c9905a6e922ec0f44c20ab06786b8e6fba2 Mon Sep 17 00:00:00 2001 From: naman-bruno Date: Mon, 2 Feb 2026 19:35:17 +0530 Subject: [PATCH] refactor: update opencollection extension for bruno (#7013) * refactor: update YML parsing and stringification to utilize 'bruno' extensions for ignore and presets * fix --- .../collection/opencollection.yml | 7 ++-- .../src/formats/yml/parseCollection.ts | 10 +++-- .../src/formats/yml/stringifyCollection.ts | 42 ++++++++++++------- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/packages/bruno-cli/tests/runner/fixtures/opencollection/collection/opencollection.yml b/packages/bruno-cli/tests/runner/fixtures/opencollection/collection/opencollection.yml index 576169fc3..5714a6544 100644 --- a/packages/bruno-cli/tests/runner/fixtures/opencollection/collection/opencollection.yml +++ b/packages/bruno-cli/tests/runner/fixtures/opencollection/collection/opencollection.yml @@ -3,9 +3,10 @@ info: name: Test OpenCollection extensions: - ignore: - - node_modules - - .git + bruno: + ignore: + - node_modules + - .git request: headers: diff --git a/packages/bruno-filestore/src/formats/yml/parseCollection.ts b/packages/bruno-filestore/src/formats/yml/parseCollection.ts index 27234861c..3fa916a3f 100644 --- a/packages/bruno-filestore/src/formats/yml/parseCollection.ts +++ b/packages/bruno-filestore/src/formats/yml/parseCollection.ts @@ -24,13 +24,15 @@ const parseCollection = (ymlString: string): ParsedCollection => { type: 'collection', ignore: [] }; - if (oc.extensions?.ignore && Array.isArray(oc.extensions.ignore)) { - brunoConfig.ignore = oc.extensions.ignore; + + const brunoExtension = (oc.extensions as any)?.bruno; + if (brunoExtension?.ignore && Array.isArray(brunoExtension.ignore)) { + brunoConfig.ignore = brunoExtension.ignore; } // presets - if (oc.extensions?.presets) { - const presets = oc.extensions.presets as any; + if (brunoExtension?.presets) { + const presets = brunoExtension.presets as any; if (presets.request) { brunoConfig.presets = { requestType: presets.request.type || [], diff --git a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts index f4e240a95..66c8864e0 100644 --- a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts +++ b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts @@ -211,24 +211,34 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => { // extensions oc.extensions = {}; - if (brunoConfig.ignore?.length) { - const ignoreList: string[] = []; - brunoConfig.ignore.forEach((ignore: string) => { - ignoreList.push(ignore); - }); - oc.extensions.ignore = ignoreList; - } - if (hasPresets(brunoConfig)) { - const presetsRequest: any = {}; - if (brunoConfig.presets.requestType?.length) { - presetsRequest.type = brunoConfig.presets.requestType; + + const hasBrunoExtensions = brunoConfig.ignore?.length || hasPresets(brunoConfig); + + if (hasBrunoExtensions) { + const brunoExtension: any = {}; + + if (brunoConfig.ignore?.length) { + const ignoreList: string[] = []; + brunoConfig.ignore.forEach((ignore: string) => { + ignoreList.push(ignore); + }); + brunoExtension.ignore = ignoreList; } - if (brunoConfig.presets.requestUrl?.length) { - presetsRequest.url = brunoConfig.presets.requestUrl; + + 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; + } + brunoExtension.presets = { + request: presetsRequest + }; } - oc.extensions.presets = { - request: presetsRequest - } as any; + + oc.extensions.bruno = brunoExtension; } // bruno-specific script extensions