define_env 0.3.0 define_env: ^0.3.0 copied to clipboard
Load variables from a `.env` file into a dart-define string and copy it to your IDE Config or to the clipboard.
define_env #
Load variables from a .env
file into a dart-define string and copy it to your IDE Config or to the
clipboard.
Usage #
Get the latest version from pub:
$ dart pub global activate define_env
Print #
$ dart pub global run define_env # generate dart define string and print it to stdout
You can skip printing using the --no-print
flag
Copy to clipboard #
$ dart pub global run define_env -c # generate dart define string and copy to clipboard
Copy to IDE #
Note
- When copying to IDE config,
define_env
tries to preserve existing arguments and overwrites only the dart-define statements. This is not thoroughly tested and if you face problems with additional arguments please create an issue.
VS Code launch.json
$ dart pub global run define_env -l # generate dart define string and copy it to launch.json
By default, all configurations in launch.json
are updated. If you want to update only a specific
configuration, you can do the following
$ dart pub global run define_env -l -n staging # generate dart define string and copy it to "staging" configuration in launch.json
Note
launch.json
may sometimes contain comments. These comments cannot be preserved as of now. If this is important then you should avoid this package
Android Studio
$ dart pub global run define_env -a # generate dart define string and copy it to all run configs
By default, all configurations in .idea/workspace.xml
and .run/
are updated. If you want to
update only a specific configuration, you can do the following
$ dart pub global run define_env -a -n staging # generate dart define string and copy it to "staging" configuration only
Env Validation #
You can add validation for your env by defining a define_env.yaml
or adding a define_env
section
to your pubspec.yaml
define_env:
fields:
<FIELD_NAME>:
type: enum # String | bool | int | enum
default: # If it is set the field in the env is optional.
enum_values: # Defines the possible values of the enum. Required field when the type is enum.
- value1
- value2
Discussion #
Use the issue tracker for bug reports and feature requests.
Roadmap #
- Add support for Android Studio and Intellij.
- Add validation support to see warn if any environment variable is missing.
- Make Android Studio and VS Code extensions and plugins to update config automatically
when
.env
files are updated. - Generate
Config
class from.env
files which extract values from environment. - Copy config name directly from
.env
files. ex.env.staging
is copied to staging config. - Simplify command usage. ex
define_env:print
define_env:copy
define_env:vscode
etc.