mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: update protobuf and import path handling in opencollection (#7166)
This commit is contained in:
@@ -24,7 +24,7 @@ const toOpenCollectionConfig = (brunoConfig: BrunoConfig | undefined): Collectio
|
||||
if (brunoConfig.protobuf.importPaths?.length) {
|
||||
config.protobuf.importPaths = brunoConfig.protobuf.importPaths.map((p) => {
|
||||
const importPath: { path: string; disabled?: boolean } = { path: p.path };
|
||||
if (p.disabled) {
|
||||
if (p.enabled === false) {
|
||||
importPath.disabled = true;
|
||||
}
|
||||
return importPath;
|
||||
|
||||
@@ -48,7 +48,7 @@ const fromOpenCollectionConfig = (oc: OpenCollection): BrunoConfig => {
|
||||
})),
|
||||
importPaths: config.protobuf.importPaths?.map((p) => ({
|
||||
path: p.path,
|
||||
disabled: p.disabled || false
|
||||
enabled: p.disabled !== true
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ export interface BrunoConfig {
|
||||
};
|
||||
protobuf?: {
|
||||
protoFiles?: { path: string }[];
|
||||
importPaths?: { path: string; disabled?: boolean }[];
|
||||
importPaths?: { path: string; enabled?: boolean }[];
|
||||
};
|
||||
proxy?: {
|
||||
disabled?: boolean;
|
||||
|
||||
@@ -58,12 +58,12 @@ const parseCollection = (ymlString: string): ParsedCollection => {
|
||||
// protobuf
|
||||
if (oc.config?.protobuf) {
|
||||
brunoConfig.protobuf = {
|
||||
protofFiles: oc.config.protobuf.protoFiles?.map((protoFile: any) => ({
|
||||
protoFiles: oc.config.protobuf.protoFiles?.map((protoFile: any) => ({
|
||||
path: protoFile.path
|
||||
})) || [],
|
||||
importPaths: oc.config.protobuf.importPaths?.map((importPath: any) => ({
|
||||
path: importPath.path,
|
||||
disabled: importPath.disabled || false
|
||||
enabled: importPath.disabled !== true
|
||||
})) || []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import type { Auth } from '@opencollection/types/common/auth';
|
||||
const hasCollectionConfig = (brunoConfig: any): boolean => {
|
||||
// protobuf
|
||||
const hasProtobuf = (
|
||||
brunoConfig.protobuf?.protofFiles?.length > 0
|
||||
brunoConfig.protobuf?.protoFiles?.length > 0
|
||||
|| brunoConfig.protobuf?.importPaths?.length > 0
|
||||
);
|
||||
|
||||
@@ -77,17 +77,25 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
|
||||
if (hasCollectionConfig(brunoConfig)) {
|
||||
oc.config = {};
|
||||
|
||||
if (brunoConfig.protobuf?.protofFiles?.length) {
|
||||
oc.config.protobuf = {
|
||||
protoFiles: brunoConfig.protobuf.protofFiles.map((protoFile: any): ProtoFileItem => ({
|
||||
if (brunoConfig.protobuf?.protoFiles?.length || brunoConfig.protobuf?.importPaths?.length) {
|
||||
oc.config.protobuf = {};
|
||||
|
||||
if (brunoConfig.protobuf.protoFiles?.length) {
|
||||
oc.config.protobuf.protoFiles = brunoConfig.protobuf.protoFiles.map((protoFile: any): ProtoFileItem => ({
|
||||
type: 'file' as const,
|
||||
path: protoFile.path
|
||||
})),
|
||||
importPaths: brunoConfig.protobuf.importPaths.map((importPath: any): ProtoFileImportPath => ({
|
||||
path: importPath.path,
|
||||
disabled: importPath.disabled
|
||||
}))
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
if (brunoConfig.protobuf.importPaths?.length) {
|
||||
oc.config.protobuf.importPaths = brunoConfig.protobuf.importPaths.map((importPath: any): ProtoFileImportPath => {
|
||||
const item: ProtoFileImportPath = { path: importPath.path };
|
||||
if (importPath.enabled === false) {
|
||||
item.disabled = true;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// proxy - only write newer format
|
||||
|
||||
Reference in New Issue
Block a user