Flag | Description | Usage |
---|---|---|
-env |
Specifies the environment configuration file. Defaults to global configuration if unspecified. Must exist in env folder. Prompts user to create if missing. Only one argument accepted. Additional arguments ignored. User-specified files override global settings for overlapping variables. |
-env prod |
hulak's Introduction
hulak's People
hulak's Issues
Parsing `.env` files
Work Summary: Parsing .env
Files and Variable Setup
The task focuses on enabling the application to read and parse environment variable files (.env
), including the ability to manage and switch between different environment contexts (e.g., GLOBAL and collection-specific environments). The goal is to facilitate a flexible and dynamic configuration system that allows users to define variables within .env
files and reference these variables within their application, thereby tailoring their API testing environment to specific needs.
Objectives:
-
Environment File Parsing: Implement functionality to accurately parse
.env
files, supporting variables without quotes, or with quotes for string values. This includes interpreting lines likePASSWORD=mypassword
andUSERNAME="randomName"
correctly, and handling edge cases such as spaces around the=
sign. -
Variable Reference Resolution: Develop a mechanism to replace variable references within the application (e.g.,
{{PASSWORD}}
) with their corresponding values from the active environment. This involves scanning input strings for variable patterns and substituting them with the actual values stored in memory. -
Environment Context Management: Create a system that allows users to switch between different environment contexts. By default, variables from the GLOBAL environment (
env/.env.global
) should be accessible, but users should be able to switch to collection-specific environments as needed.
Tasks to Complete:
-
Parse
.env
Files: โ- Write a parser that reads
.env
files line by line, extracting key-value pairs. - Ensure the parser can handle both quoted and unquoted values, stripping quotes where necessary.
- Write a parser that reads
-
Store and Manage Environment Variables: โ
- Implement a storage mechanism (e.g., a map or dictionary) in memory to hold environment variables.
- Include functionality to update this storage with variables from parsed
.env
files.
-
Implement Variable Reference Resolution: โ
- Develop a function to search for
{{variableName}}
patterns in strings and replace them with the actual variable values from the current active environment.
- Develop a function to search for
-
Environment Switching Capability: โ
- Enable command-line arguments or commands within the application for users to switch the active environment context.
- Ensure that switching contexts updates the set of available environment variables accordingly.
-
Default to GLOBAL Environment: โ
- Set the application to use variables from
env/.env.global
by default upon startup. - Allow for these global variables to be overridden by collection-specific variables when a different environment context is activated.
- Set the application to use variables from
-
Testing and Validation: โ
- Write unit tests for the
.env
file parser to cover various edge cases. - Test the variable reference resolution feature with different input scenarios.
- Verify the environment switching functionality works as expected, with proper fallbacks to the GLOBAL environment.
- Write unit tests for the
-
Variable Error Resolution: โ
- Throw clear errors if the variable is not found.
Parsing Collections
- Create Binary we can use. โ
- Collections can also contain
.env
files that can be used to for collection specific variables.folder_name/request_name.yaml
||folder_name/request_name.yml
provided by the user. Folder name is always unique. Search the root folder.- If the collection has
.env
file in it, create a final map with this file as the highest priority.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.