Automate .env.example file generation by scanning existing .env files in projects, masking sensitive information, and creating corresponding .env.example files with placeholders. This efficiently maintains up-to-date example configurations while keeping actual values secure.
- Automatically generate a
.env.examplefile based on the existing.envfile. - Support for multiple
.env.*files (e.g..env.test,.env.production). The extension can generate corresponding.env.*.examplefiles. - Update
.env.exampleeach time the.envfile is saved. - Replace sensitive data with placeholders.
- Preserve comments from the
.envfile in the generated.env.examplefile. - Minimize manual intervention by automating the updating process.
- Exclude specific
.envfiles from being processed using a flag in the first line (e.g.,#noexample). - Newly introduced configuration option to specify an inclusion flag,
#example, for processing .env files. If this configuration is set, only the .env files with#exampleon the first line will generate the respective .env.example files.
- Install the extension from the Visual Studio Code Marketplace.
- Open a project that contains a
.envfile or multiple.env.*files. - The extension automatically generates corresponding
.env.exampleor.env.*.examplefiles when you open the project. You can also use the "Generate .env.example from .env" command from the Command Palette (pressCtrl+Shift+PorCmd+Shift+Pon macOS) or simply save your.envor.env.*file to trigger an update of.env.exampleor.env.*.examplefiles. - Comments in your
.envor.env.*files that follow a#symbol on the same line as a variable assignment will be preserved in the generated.env.exampleor.env.*.examplefiles. This provides context for each configuration item while keeping the actual values masked. - To exclude a specific
.envfile from being processed, simply add#noexampleas the first line in the file. The extension will ignore this file when generating the.env.examplefiles. - To set the new configuration option, go to the VS Code settings and search for "Env Auto Example". When the "Only Generate From Marked Files" option is checked (
true), the extension will only process .env files with a#exampleflag in the first line. In this case,.env.examplefiles will be created only for.envfiles marked with#example, and if the flag is removed, the corresponding.env.examplefile will be deleted. When the option is unchecked (false), the extension will generate.env.examplefiles for all.envfiles, unless they are marked with#noexample. If a.envfile is marked with#noexample, it will be ignored and no corresponding.env.examplefile will be created. This feature provides the option to decide whether the extension should automatically process all.envfiles for generating corresponding.env.examplefiles, or only those specifically marked with a '#example' flag. This capability enables granular control over which.envfiles should be processed, allowing for privacy of certain environment configurations while exposing others. It is particularly useful in larger projects where multiple environment configurations exist, or when certain sensitive configurations are best left without a corresponding example file.