Skip to content

Commit 8878704

Browse files
committed
Readme updated + package version for bower
1 parent 4065401 commit 8878704

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ Said that, let's go to configure the plugin and learn how to use it.
4040

4141
### Configuration
4242

43-
Once installed, you need to inject the `envServiceProvider` into your Angular App config area and then, add your environments under `domains` and `vars` objects, adding also the array of domains which belongs to each environment and also for vars.
44-
45-
Finally, in the same config area, you need to check in what context your application is running, by adding `envServiceProvider.check()` which will automatically set the appropriate environment based on given domains.
43+
* Once installed, inject the `envServiceProvider` into your Angular App config area.
44+
* Organize the environments as you wish under `domains` and `vars` objects.
45+
* You can use wildcards (`*`) to describe your domains, i.e.: `*.domain.com`.
46+
* As optional, you can set defaults variables under `defaults` object within `vars`, to catch not-defined variables in the environments.
47+
* Finally, in the same config area, you will need to check in which context your application is running, by adding `envServiceProvider.check()` which will automatically set the appropriate environment based on given domains.
4648

4749
Here's a full example:
4850

@@ -52,28 +54,38 @@ angular.module('yourApp', ['environment']).
5254
// set the domains and variables for each environment
5355
envServiceProvider.config({
5456
domains: {
55-
development: ['localhost', 'dev.local'],
56-
production: ['acme.com', 'acme.net', 'acme.org']
57-
// anotherStage: ['domain1', 'domain2'],
57+
development: ['localhost', 'acme.dev.local'],
58+
production: ['acme.com', '*.acme.com', 'acme.dev.prod']
59+
test: ['test.acme.com', 'acme.dev.test', 'acme.*.com'],
5860
// anotherStage: ['domain1', 'domain2']
5961
},
6062
vars: {
6163
development: {
62-
apiUrl: '//localhost/api',
63-
staticUrl: '//localhost/static'
64+
apiUrl: '//api.acme.dev.local/v1',
65+
staticUrl: '//static.acme.dev.local'
6466
// antoherCustomVar: 'lorem',
6567
// antoherCustomVar: 'ipsum'
6668
},
69+
test: {
70+
apiUrl: '//api.acme.dev.test/v1',
71+
staticUrl: '//static.acme.dev.test',
72+
// antoherCustomVar: 'lorem',
73+
// antoherCustomVar: 'ipsum'
74+
}
6775
production: {
68-
apiUrl: '//api.acme.com/v2',
76+
apiUrl: '//api.acme.com/v1',
6977
staticUrl: '//static.acme.com'
7078
// antoherCustomVar: 'lorem',
7179
// antoherCustomVar: 'ipsum'
72-
}
80+
},
7381
// anotherStage: {
7482
// customVar: 'lorem',
7583
// customVar: 'ipsum'
7684
// }
85+
defaults: {
86+
apiUrl: '//api.default.com/v1',
87+
staticUrl: '//static.default.com'
88+
}
7789
}
7890
});
7991

@@ -83,10 +95,6 @@ angular.module('yourApp', ['environment']).
8395
});
8496
```
8597

86-
**For now, it's very important** to not use wildcards (`*`) or regex in your environment domains. If you want to match any subdomain (i.e `sub.domain.acme.com`), you should add the main TLD: `acme.com` or `sub.domain.acme.com` in case you want to match the exact domain.
87-
88-
*In the next release of this plugin you'll be able to add domains using wildcards and regex*
89-
9098
### Usage
9199

92100
In order to read the configured environment variables alongside your Angular App, you need to inject `envService` into your controllers or services:
@@ -124,19 +132,21 @@ else {
124132
```
125133

126134
#### read(*string[var]*)
127-
Returns the desired environment variable. If the argument is `all`, this method will return all variables associated to the current environment.
135+
Returns the desired environment variable. If no argument is passed, this method will return all variables associated to the current environment.
128136

129137
```javascript
130138
var apiUrl = envService.read('apiUrl'); // gets '//localhost/api'
131139

132-
var allVars = envService.read('all'); // gets all variables configured under the current environment
140+
var allVars = envService.read(); // gets all variables configured under the current environment
133141
```
134142

143+
If the desired variable passed as argument doesn't exists in the current environment, the plugin will check into `defaults` object.
144+
135145
## To-Do
136146

137-
* Support for adding domains with wildcards or ~~regex~~
138-
* Comprobe Add logic to `check()`
139-
* Testing
147+
* ~~Support for adding domains with wildcards or regex~~.
148+
* Unit testing.
149+
* Support for protocols.
140150

141151
## Support
142152

@@ -148,7 +158,7 @@ Please feel free to contribute to the plugin with new issues, requests, unit tes
148158

149159
## License
150160

151-
Copyright 2015, [Juan Pablo Barrientos Lagos (juanpablob)](http://twitter.com/juanpablob)
161+
Copyright 2015-2017, [Juan Pablo Barrientos Lagos (juanpablob)](http://twitter.com/juanpablob)
152162

153163
Licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php)<br/>
154164
Redistributions of files must retain the above copyright notice.

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-environment",
33
"main": "dist/angular-environment.js",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"homepage": "https://github.com/juanpablob/angular-environment",
66
"authors": [
77
"juanpablob <[email protected]>"
@@ -15,7 +15,8 @@
1515
"angular",
1616
"angularjs",
1717
"env",
18-
"environment"
18+
"environment",
19+
"variables"
1920
],
2021
"license": "MIT",
2122
"ignore": [

0 commit comments

Comments
 (0)