Giter Club home page Giter Club logo

flavored_env's Introduction

flavored_env

style: very good analysis License: MIT coverage pub package ci

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:

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

output_formats:
  dotenv:
    # Dotenv output options
    build_to:
      - functions
  dart:
    # Dart output options
    build_to:
      - "functions/lib/config"
    class_name: "FlavoredEnv"

  typescript:
    # Typescript output options
    build_to:
      - "functions/src"

flavors:
  default:
    keys:
      COLLECTION_USER_PROFILES:
        value: "users"
        info: collection of user profiles

      COLLECTION_AVATARS:
        value: "avatars"
        info: collection of user avatars

      COLLECTION_USER_SESSIONS:
        value: "sessions"
        info: collection of sessions for user

      DEBUG_DELAY:
        value: 0
        info: A delay in milliseconds used for testing


  staging:
    keys:
      DEBUG_DELAY:
        value: 1000
        info: A delay in milliseconds used for testing

  development:
    keys:
      DEBUG_DELAY:
        value: 4000
        info: A delay in milliseconds used for testing

  production:
    keys:

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

flavored_env's People

Watchers

DavidB avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.