angel_configuration 1.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 91

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: ^1.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, which means you can access them like normal instance members.

main() {
  print(app.foo == app.configuration['foo']); // true
}

An instance of Configuration will also be injected to your application, and it works the same way:

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

main() async {
    var app = new Angel();
    var fileSystem = const LocalFileSystem();
    
    await app.configure(configuration(fileSystem)); // It's that easy!
    
    app.get('/foo', (Configuration config) {
      return config.some_key;
    });
}

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

In the Browser

You can easily load configuration values within your client-side app, and they will be automatically replaced by a Barback transformer.

In your pubspec.yaml:

transformers:
- angel_configuration

In your app:

import 'package:angel_configuration/browser.dart';

main() async {
    print(config("some_key.other.nested_key"));
}

You can also provide a dir or env argument, corresponding to the ones on the server-side.

1.0.5

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

1. Depend on it

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


dependencies:
  angel_configuration: "^1.1.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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';
        
Version Uploaded Documentation Archive
1.1.0 Dec 7, 2017 Go to the documentation of angel_configuration 1.1.0 Download angel_configuration 1.1.0 archive
1.0.5 Aug 16, 2017 Go to the documentation of angel_configuration 1.0.5 Download angel_configuration 1.0.5 archive
1.0.4 Jun 14, 2017 Go to the documentation of angel_configuration 1.0.4 Download angel_configuration 1.0.4 archive
1.0.3 Mar 8, 2017 Go to the documentation of angel_configuration 1.0.3 Download angel_configuration 1.0.3 archive
1.0.2 Mar 8, 2017 Go to the documentation of angel_configuration 1.0.2 Download angel_configuration 1.0.2 archive
1.0.1+8 Nov 28, 2016 Go to the documentation of angel_configuration 1.0.1+8 Download angel_configuration 1.0.1+8 archive
1.0.1+7 Nov 23, 2016 Go to the documentation of angel_configuration 1.0.1+7 Download angel_configuration 1.0.1+7 archive
1.0.1+6 Nov 23, 2016 Go to the documentation of angel_configuration 1.0.1+6 Download angel_configuration 1.0.1+6 archive
1.0.1+5 Nov 23, 2016 Go to the documentation of angel_configuration 1.0.1+5 Download angel_configuration 1.0.1+5 archive
1.0.1+4 Sep 19, 2016 Go to the documentation of angel_configuration 1.0.1+4 Download angel_configuration 1.0.1+4 archive

All 17 versions...

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
84 / 100
Health:
Code health derived from static analysis. [more]
97 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
91

Platforms

Detected platforms: other

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

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use angel_configuration.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0
analyzer >=0.28.1 <1.0.0 0.31.0+1
angel_framework ^1.1.0-alpha 1.1.0+3
barback ^0.15.2 0.15.2+14
dotenv ^0.1.0 0.1.3+3
file ^2.0.0 2.3.5
merge_map ^1.0.0 1.0.0
yaml ^2.0.0 2.1.13
Transitive dependencies
angel_http_exception 1.0.0
angel_model 1.0.0
angel_route 2.0.5
args 0.13.7 1.3.0
async 2.0.3
body_parser 1.0.3
charcode 1.1.1
cli_util 0.1.2+1
collection 1.14.5
combinator 1.0.0-beta+7
container 0.1.2
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
front_end 0.1.0-alpha.8
glob 1.1.5
html 0.13.2+2
http_server 0.9.7
intl 0.15.2
isolate 1.1.0
json_god 2.0.0-beta+1
kernel 0.3.0-alpha.5
logging 0.11.3+1
matcher 0.12.1+4
meta 1.1.2
mime 0.9.6
package_config 1.0.3
path 1.5.1
plugin 0.2.0+2
pool 1.3.4
quiver_hashcode 1.0.0
random_string 0.0.1
source_span 1.4.0
stack_trace 1.9.1
string_scanner 1.0.2
tuple 1.0.1
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
Dev dependencies
test ^0.12.0