platform/packages/configuration
2021-02-14 13:22:25 +08:00
..
example configuration: Apply pedantic fixes 2020-05-03 11:24:22 -04:00
lib configuration: finish 2.2.0, update readme 2020-05-04 12:05:14 -04:00
test configuration: finish 2.2.0, update readme 2020-05-04 12:05:14 -04:00
.gitignore Add 'packages/configuration/' from commit 'a7902feaa0a360848777b1e7b7c20d9ff848d19b' 2020-02-15 18:28:56 -05:00
.travis.yml Add 'packages/configuration/' from commit 'a7902feaa0a360848777b1e7b7c20d9ff848d19b' 2020-02-15 18:28:56 -05:00
analysis_options.yaml configuration: Add pedantic to analysis options 2020-05-03 11:21:21 -04:00
CHANGELOG.md configuration: Load files via _include 2020-05-04 11:59:33 -04:00
LICENSE Add 'packages/configuration/' from commit 'a7902feaa0a360848777b1e7b7c20d9ff848d19b' 2020-02-15 18:28:56 -05:00
pubspec.yaml Updated dart requirements to 2.10 2021-02-14 13:22:25 +08:00
README.md configuration: finish 2.2.0, update readme 2020-05-04 12:05:14 -04:00

configuration

Pub build status

Automatic YAML configuration loader for Angel.

About

Any web app needs different configuration for development and production. This plugin will search for a config/default.yaml file. If it is found, configuration from it is loaded into app.configuration. Then, it will look for a config/$ANGEL_ENV file. (i.e. config/development.yaml). If this found, all of its configuration be loaded, and will override anything loaded from the default.yaml file. This allows for your app to work under different conditions without you re-coding anything. :)

Installation

In pubspec.yaml:

dependencies:
    angel_configuration: ^2.0.0

Usage

Example Configuration

# Define normal YAML objects
some_key: foo
this_is_a_map:
  a_string: "string"
  another_string: "string"
  

You can also load configuration from the environment:

# Loaded from the environment
system_path: $PATH

If a .env file is present in your configuration directory (i.e. config/.env), then it will be loaded before applying YAML configuration.

You can also include values from one file into another:

_include:
  - "./include-prod.yaml"
  - "./include-misc.yaml"
_include: "just-one-file.yaml"

Server-side Call configuration(). The loaded configuration will be available in your application's configuration map.

configuration also accepts a sourceDirectory or overrideEnvironmentName parameter. The former will allow you to search in a directory other than config, and the latter lets you override $ANGEL_ENV by specifying a specific configuration name to look for (i.e. production).

This package uses package:merge_map internally, so existing configurations can be deeply merged.

Example:

# default.yaml
foo:
  bar: baz
  quux: hello
  
# production.yaml
foo:
  quux: goodbye
  yellow: submarine
  
# Propagates to:
foo:
  bar: baz
  quux: goodbye
  yellow: submarine