Crates.io | env-yoink |
lib.rs | env-yoink |
version | 1.0.1 |
source | src |
created_at | 2023-09-23 12:35:21.347903 |
updated_at | 2024-09-17 18:06:42.680278 |
description | env-yoink is a Rust CLI tool for effortless extraction of environment variables from source code, supporting regex and language presets. |
homepage | https://github.com/assemmarwan/env-yoink |
repository | https://github.com/assemmarwan/env-yoink |
max_upload_size | |
id | 981211 |
size | 28,718 |
env-yoink
is a versatile command-line tool written in Rust that simplifies the process of extracting environment variables from source code. Whether you're working with code written in JavaScript, Go, Python, or any other programming language, env-yoink
offers a convenient way to identify and collect environment variable references. You can use it to enhance your development workflow and manage configuration.
Regex and Language Presets: env-yoink
gives you the flexibility to extract environment variables using regular expressions or predefined language presets.
Multi-Language Support: With built-in support for popular programming languages like JavaScript, Go, Python, and more.
Recursive Scanning: Using the amazing ripgrep, easily scan entire projects or directories recursively, while respecting .gitignore
d files ensuring that no environment variable references are overlooked, even in complex codebases.
As of now, the best way to install env-yoink
is through cargo
command. Make sure to have Rust installed on your machine and then run:
cargo install env-yoink
A platform specific installation method will be available soon across platforms (Homebrew, pacman, APT, etc...)
Coming Soon...
env-yoink --help
Tool to grab (yoink) env variables from a workspace into env example file
Usage: env-yoink [OPTIONS] <WORKSPACE_DIRECTORY>
Arguments:
<WORKSPACE_DIRECTORY> Workspace Directory
Options:
-o, --out <OUTPUT_DIRECTORY>
Output Directory [default: ./]
-e, --example-file-name <EXAMPLE_FILE_NAME>
Env example file [default: .env.example]
-x, --regex-pattern <REGEX_PATTERN>
Custom Regex pattern to capture the env variables
-p, --preset <PRESET>
Use from the list of regex presets based on the language [possible values: js, python, rust, go]
-h, --help
Print help
-V, --version
Print version
env-yoink './src' --preset js
env-yoink './src' --regex-pattern 'process.env.([A-Z_]+)'
Suppose we have this file in our project directory.
// my-project/config.ts
// Get the env variables
const API_URL = process.env.API_URL;
const SECRET_KEY = process.env['SECRET_KEY']; // This incosistency is intentional and for demo purposes only, relax :)
// Initialize the client
const client = new Client(API_URL, SECRET_KEY);
// Call the API...
While in the project directory, run:
env-yoink . --preset=js
This will write to the file .env.example
(by default) as show below:
# .env.example
API_URL=
SECRET_KEY=
.env.example
instead of overwriting itPull requests are welcome and appreciated 😄.
For major changes, please open an issue first to discuss what you would like to change.