angel_configuration 2.1.0

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, then it will be loaded before applying YAML configuration.

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.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 'package:angel_configuration/angel_configuration.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:file/local.dart';

main() async {
  var app = new 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.1.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]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on Sep 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:angel_configuration/angel_configuration.dart with components: io.

Health suggestions

Fix lib/angel_configuration.dart. (-2.96 points)

Analysis of lib/angel_configuration.dart reported 6 hints, including:

line 41 col 9: DO use curly braces for all flow control structures.

line 48 col 7: DO use curly braces for all flow control structures.

line 55 col 5: DO use curly braces for all flow control structures.

line 61 col 1: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 62 col 26: Use = to separate a named parameter from its default value.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
angel_framework ^2.0.0-alpha 2.0.4+1
dotenv ^1.0.0 1.0.0
file ^5.0.0 5.0.10
merge_map ^1.0.0 1.0.2
yaml ^2.0.0 2.1.16
Transitive dependencies
angel_container 1.0.4
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.0.6
args 1.5.2
charcode 1.1.2
code_buffer 1.0.1
collection 1.14.12
combinator 1.1.0
convert 2.1.1
crypto 2.1.3
dart2_constant 1.0.2+dart2
http2 1.0.0
http_parser 3.1.3
http_server 0.9.8+3
intl 0.16.0
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
mime 0.9.6+3
mock_request 1.0.6
path 1.6.4
pedantic 1.8.0+1
quiver 2.0.5
quiver_hashcode 2.0.0
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.2
typed_data 1.1.6
uuid 2.0.2
Dev dependencies
io ^0.3.2
test ^1.0.0