记录一个confidence插件,简单明了地根据不同环境变量更换配置。平时我们写 config 或者 settings 文件要仔细区分环境,参数值比较混乱,难管理。有了 confidence 插件之后,再也不用担心环境参数混乱的问题了。
confidence 地址
https://github.com/hapipal/confidence
基本结构
结构很清晰,根据不同的环境变量获取不同的值。还能做一些范围控制。使用起来很简单,只要配置标准参数(如:$filter)即可。
{
"key1": "abc",
"key2": {
"$filter": "env",
"production": {
"deeper": {
"$value": "value"
}
},
"$default": {
"$filter": "platform",
"android": 0,
"ios": 1,
"$default": 2
}
},
"ab": {
"$filter": "random.a",
"$range": [
{ "limit": 10, "value": 4 },
{ "limit": 20, "value": 5 }
],
"$default": 6
},
"$meta": {
"description": "example file"
}
}