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.

Use this package as a library

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

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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

We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_configuration/angel_configuration.dart.

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.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 6 hints.

    Run dartfmt to format lib/angel_configuration.dart.

    Strong-mode analysis of lib/transformer.dart gave the following hint:

    line: 3 col: 1
    'barback' is deprecated and shouldn't be used.

  • 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.32.1
angel_framework ^1.1.0-alpha 1.1.4+3
barback ^0.15.2 0.15.2+16
dotenv ^0.1.0 0.1.3+3
file ^2.0.0 2.3.7 5.0.1
merge_map ^1.0.0 1.0.0
yaml ^2.0.0 2.1.14
Transitive dependencies
angel_http_exception 1.0.0
angel_model 1.0.0
angel_route 2.0.6
args 0.13.7 1.4.3
async 2.0.7
body_parser 1.1.0
charcode 1.1.1
code_buffer 1.0.0
collection 1.14.10
combinator 1.0.0
container 0.1.2
convert 2.0.1
crypto 2.0.3
csslib 0.14.4
dart2_constant 1.0.1+dart2
front_end 0.1.1
glob 1.1.5
html 0.13.3+1
http_parser 3.1.2
http_server 0.9.7
intl 0.15.6
json_god 2.0.0-beta+1
kernel 0.3.1
logging 0.11.3+1
matcher 0.12.2+1
meta 1.1.5
mime 0.9.6+1
package_config 1.0.3
path 1.6.0
plugin 0.2.0+2
pool 1.3.5
quiver_hashcode 1.0.0
random_string 0.0.1
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
tuple 1.0.1
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
Dev dependencies
test ^0.12.0