flavored_env

Last updated:

0 purchases

flavored_env Image
flavored_env Images
Add to Cart

Description:

flavored env

flavored_env #




Generate and synchronize dotenv and dart configuration classes for your firebase application.
Flavored_env is useful if you need to maintain a common set of constants between your cloud functions and your flutter application. It generates dotenv files for your cloud function deployments as well as corresponding dart class for your application. It supports flavors and the ability to create copies in multiple locations.
The tools was developed for a personal project to help keep constants in sync during development. Hopefully it can be helpful to others. Do let me know if you are interested in additional features.
Features #

Manage all application and cloud constants in single file
Create dotenv and Dart classes from configuration
Supports multiple flavors, copies and locations

Installation #
This package is intended to support development of Dart projects with
[package:build][]. In general, put it under [dev_dependencies][], in your
[pubspec.yaml][pubspec].
dev_dependencies:
build_runner:
copied to clipboard
Built-in Commands #
The flavord_env package exposes a binary by the same name, which can be
invoked using dart run flavored_env <command>.
The available commands are

create-yaml: create a sample flavored_env.yaml file.
generate: generate the configuration files based on yaml file
edits and does rebuilds as necessary.

flavored_env.yaml #
Create a template flavored_env.yaml in your project root by running:
pub run flavored_env --create-yaml
The default sample will look like this
# flavored_env example

dotenv_to:
# list of existing subfolders where to generate the .env files.
- lib/config
- functions

class_to:
# List of existing subfolders where to generate the dart config files.
- lib # (default)
- lib/config

# Name of the dart class to encaspulate all the constants. The same class
# is generated for each flavor, but the file name will have a _<flavor> suffix
class_name: EnvConfig

flavors:
# List of application flavors.
default:
# The default flavor will become .env.default
keys:
user_collection_name: # key name
value: "users" # key value
info: "user collection name" # optional info to keep with the output.

show_exception_on_crash:
value: false
info: "display exception to users upon app crash"

additional_debug_timeout:
value: 0
info: "additional timeout added to the app for testing"

development:
# The development flavor will become .env.development
keys:
# the collection name will be propagated from the 'default' configuration for dart.

show_exception_on_crash: # overriden constant for development.
value: true
info: "display exception to users upon app crash"

additional_debug_timeout: # overriden constant for development.
value: 0
info: "additional timeout added to the app for testing"

slack_url:
value: https://slack.com/abcd_dev
info: webhook url for development environment
beta:
keys:
slack_url:
value: https://slack.com/jkdl_beta
info: webhook url for development environment

production:
keys:
slack_url:
value: https://slack.com/xyz_production
info: webhook url for development environment

fancy_value_prod_only:
value: 42
info: constant only available in production

copied to clipboard
After config is specified in YAML file run following command
pub run flavored_env --generate
Yaml Specification #
dotenv_to to indicate the list of relative paths where to create the dotenv files.
class_to to indicate the list of relative paths where to create the dart files.
class_name to specivy the name of the class to use, default to EnvConfig
flavors to specify each flavor or development environment
default environment (optional) is used for the base configuration. Its content will be used to generate .env.default. When generating the dart files for other flavors, the keys from the default environment that are not overriden are merged to make sure all constants are available to your flutter app.
keys to specify the list of constants for the specific environment. Each key is specified by its name and can take two attributes; value that represents the constant value to use and info that provides one line descriptions that will be used as comments in the generated files.
Upon generation, the key names will be converted to camel case for the dart files and upper case separated by underscore for the dotenv to match normal conventions.
Any environment listed in the file will translate into .env.environment and env_config_environment.dart in each of the specified locations.
Limitations #

Destination paths are relative only. No absolute paths
Destination paths must exist and are not created
Opiniated format for keys in dart and dotenv for now

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.