angel_configuration 2.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 87

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

2.2.0 #

  • Allow including one configuration within another.
  • Badly-formatted .env files will no longer issue a warning, but instead throw an exception.

2.1.0 #

  • Add loadStandaloneConfiguration.

2.0.0 #

  • Use Angel 2.

1.2.0-rc.0 #

  • Removed the Configuration class.
  • Removed the ConfigurationTransformer class.
  • Use Map casting to prevent runtime cast errors.

1.1.0 (Retroactive changelog) #

  • Use package:file.

1.0.5 #

  • Now using package:merge_map to merge configurations. Resolves #5.
  • You can now specify a custom envPath.

example/main.dart

import 'dart:async';

import 'package:angel_configuration/angel_configuration.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:file/local.dart';

Future<void> main() async {
  var app = Angel();
  var fs = const LocalFileSystem();
  await app.configure(configuration(fs));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_configuration: ^2.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angel_configuration/angel_configuration.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
87
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (dotenv).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
angel_framework ^2.0.0 2.1.1
dotenv ^1.0.0 1.0.0 2.0.0
file ^5.0.0 5.1.0
merge_map ^1.0.0 1.0.2
yaml ^2.0.0 2.2.1
Transitive dependencies
angel_container 1.1.0
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.1.0+1
args 1.6.0
charcode 1.1.3
code_buffer 1.0.1
collection 1.14.12
combinator 1.1.0
convert 2.1.1
crypto 2.1.5
dart2_constant 1.0.2+dart2
http2 1.0.0
http_parser 3.1.4
http_server 0.9.8+3
intl 0.16.1
matcher 0.12.6
meta 1.1.8
mime 0.9.6+3
mock_request 1.0.7
path 1.7.0
quiver 2.1.3
quiver_hashcode 2.0.0
recase 2.0.1 3.0.0
source_span 1.7.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.3
typed_data 1.1.6
uuid 2.0.4
Dev dependencies
io ^0.3.2
logging ^0.11.0 0.11.4
pedantic ^1.0.0
pretty_logging ^1.0.0
test ^1.0.0