-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Feat/ Add Multiline Support for Enviroment Variables #5438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/ Add Multiline Support for Enviroment Variables #5438
Conversation
if (value && (value.includes('\n') || value.includes('\r'))) { | ||
// Use multiline format with triple quotes | ||
const indentedValue = value.split('\n').map(line => ` ${line}`).join('\n'); | ||
return ` ${prefix}${name}: '''\n${indentedValue}\n'''`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pragadesh-45 i guess we will need to add indentation, '''
should start indented, I guess we should also indent the multiline value as shown, rather than it being inline with abc
vars : {
abc: '''
{
key:value
}
'''
}
If we don't indent the value, it may look like
vars : {
abc: '''
key:value
key2: value
'''
}
let me know your thoughts on this, i believe i did with the indentation within grpc, we should have a conversation on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, i'll update the pr
@@ -113,15 +116,43 @@ const sem = grammar.createSemantics().addAttribute('ast', { | |||
}, | |||
pair(_1, key, _2, _3, _4, value, _5) { | |||
let res = {}; | |||
res[key.ast] = value.ast ? value.ast.trim() : ''; | |||
res[key.ast] = value.ast !== undefined ? value.ast : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pragadesh44-Bruno what is the impact on removing the trim(), I think this can cause some inconsistencies or regression as this has been used for quite some time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have added this to preserve the white spaces since it is important for the values to be handled properly (especially for multiline)
5698d4f
to
a43a113
Compare
- Updated SingleLineEditor to allow newlines when `allowNewlines` prop is true, otherwise runs the handler on Shift-Enter. - Modified grammar in envToJson to support multiline text blocks with triple quotes. - Updated jsonToEnv to format values with newlines using triple quotes for better readability. - refactor: replace `SingleLineEditor` with `MultilineEditor` to support newLines
83a4195
to
99ed018
Compare
- Simplified multiline string processing in envToJson by removing unnecessary checks and directly slicing leading spaces. - Introduced getValueString function in jsonToEnv to handle multiline strings with proper indentation and formatting. - Added indentString4 utility function for consistent 4-space indentation across the codebase.
- Updated grammar to define start and end for multiline text blocks. - Simplified value extraction for multiline strings by directly returning the AST. - Improved indentation handling by removing leading spaces from multiline content.
- Implemented tests to read and create multiline environment variables. - Verified successful request execution and response handling for multiline JSON data. - Added necessary collection and environment files for testing.
- Deleted the `bruMultiline.spec.js` file as it is no longer needed. - This cleanup helps maintain a lean test suite and reduces redundancy.
- Updated `jsonToEnv` to use `indentString` for consistent indentation of variable names and values. - Simplified `getValueString` to trim trailing whitespace and ensure proper formatting of multiline values. - Removed unnecessary parameters for cleaner utility functions.
752748e
to
a616d81
Compare
Fixes: #4518 #1581 #1953
Related to: #4827
Description
This PR adds support for multiline environment variables by updating the environment parsing logic in
envToJson
andjsonToEnv
has been enhanced to handle multiline values using triple quotes ('''
) for better readability and formatting.Comprehensive tests have been added, including integration tests for round-trip conversion between JSON and
.bru
formats, as well as expanded unit tests covering edge cases like special characters, empty values, and global environment variables.Contribution Checklist:
COLLECTION ENVIRONMENTS


GLOBAL ENVIRONMENTS

