configorama 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -21
- package/cli.js +1 -0
- package/package.json +2 -2
- package/src/main.js +197 -50
- package/src/resolvers/valueFromEnv.js +1 -0
- package/src/resolvers/valueFromGit.js +2 -0
- package/src/resolvers/valueFromNumber.js +1 -0
- package/src/resolvers/valueFromOptions.js +2 -0
- package/src/utils/PromiseTracker.js +3 -2
- package/src/utils/cleanVariable.js +30 -2
- package/src/utils/cleanVariable.test.js +98 -0
- package/src/utils/find-nested-variables.js +227 -0
- package/src/utils/find-nested-variables.test.js +99 -0
- package/src/utils/splitByComma.js +57 -45
- package/src/utils/splitByComma.test.js +84 -0
package/README.md
CHANGED
|
@@ -80,6 +80,9 @@ const config = configorama.sync(myConfigFilePath, {
|
|
|
80
80
|
|
|
81
81
|
```yml
|
|
82
82
|
apiKey: ${env:SECRET_KEY}
|
|
83
|
+
|
|
84
|
+
# Fallback to default value if env var not found
|
|
85
|
+
apiKeyWithFallback: ${env:SECRET_KEY, 'defaultApiKey'}
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
### CLI option flags
|
|
@@ -90,6 +93,9 @@ bar: ${opt:stage}
|
|
|
90
93
|
|
|
91
94
|
# Composed example makes `foo: dev-hello`
|
|
92
95
|
foo: ${opt:stage}-hello
|
|
96
|
+
|
|
97
|
+
# You can also provide a default value. If no --stage flag is provided, it will use 'dev'
|
|
98
|
+
foo: ${opt:stage, 'dev'}
|
|
93
99
|
```
|
|
94
100
|
|
|
95
101
|
### Self references
|
|
@@ -97,26 +103,34 @@ foo: ${opt:stage}-hello
|
|
|
97
103
|
```yml
|
|
98
104
|
foo: bar
|
|
99
105
|
|
|
106
|
+
zaz:
|
|
107
|
+
matazaz: 1
|
|
108
|
+
wow:
|
|
109
|
+
cool: 2
|
|
110
|
+
|
|
100
111
|
# Self file reference. Resolves to `bar`
|
|
101
112
|
one: ${self:foo}
|
|
102
113
|
|
|
103
114
|
# Shorthand self reference. Resolves to `bar`
|
|
104
|
-
two: ${foo}
|
|
115
|
+
two: ${foo}
|
|
116
|
+
|
|
117
|
+
# Dot prop reference will traverse the object. Resolves to `2`
|
|
118
|
+
three: ${zaz.wow.cool}
|
|
105
119
|
```
|
|
106
120
|
|
|
107
121
|
### File references
|
|
108
122
|
|
|
109
123
|
```yml
|
|
110
|
-
#
|
|
111
|
-
|
|
124
|
+
# Import full yml/json/toml file via relative path
|
|
125
|
+
fileRef: ${file(./subFile.yml)}
|
|
112
126
|
|
|
113
|
-
#
|
|
114
|
-
|
|
127
|
+
# Import sub values from files. This imports other-config.yml `topLevel:` value
|
|
128
|
+
fileValue: ${file(./other-config.yml):topLevel}
|
|
115
129
|
|
|
116
|
-
#
|
|
117
|
-
|
|
130
|
+
# Import sub values from files. This imports other-config.json `nested.value` value
|
|
131
|
+
fileValueSubKey: ${file(./other-config.json):nested.value}
|
|
118
132
|
|
|
119
|
-
#
|
|
133
|
+
# Fallback to default value if file not found
|
|
120
134
|
fallbackValueExample: ${file(./not-found.yml), 'fall back value'}
|
|
121
135
|
```
|
|
122
136
|
|
|
@@ -131,46 +145,74 @@ asyncJSValue: ${file(./async-value.js)}
|
|
|
131
145
|
|
|
132
146
|
```js
|
|
133
147
|
/* async-value.js */
|
|
134
|
-
|
|
135
|
-
return
|
|
148
|
+
function delay(t, v) {
|
|
149
|
+
return new Promise((resolve) => setTimeout(resolve.bind(null, v), t))
|
|
136
150
|
}
|
|
137
151
|
|
|
138
|
-
function fetchSecretsFromRemoteStore() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
})
|
|
152
|
+
async function fetchSecretsFromRemoteStore(config) {
|
|
153
|
+
await delay(1000)
|
|
154
|
+
return 'asyncval'
|
|
142
155
|
}
|
|
143
156
|
|
|
144
|
-
|
|
145
|
-
return new Promise((resolve) => setTimeout(resolve.bind(null, v), t))
|
|
146
|
-
}
|
|
157
|
+
module.exports = fetchSecretsFromRemoteStore
|
|
147
158
|
```
|
|
148
159
|
|
|
149
160
|
### Git references
|
|
150
161
|
|
|
151
162
|
Resolve values from `cwd` git data.
|
|
152
163
|
|
|
164
|
+
<!-- doc-gen CODE src=tests/gitVariables/gitVariables.yml -->
|
|
153
165
|
```yml
|
|
166
|
+
########################
|
|
167
|
+
# Git Variables
|
|
168
|
+
########################
|
|
169
|
+
|
|
170
|
+
# Repo owner/name. E.g. DavidWells/configorama
|
|
171
|
+
repo: ${git:repo}
|
|
154
172
|
repository: ${git:repository}
|
|
155
173
|
|
|
156
|
-
|
|
174
|
+
# Repo owner. E.g. DavidWells
|
|
175
|
+
owner: ${git:owner}
|
|
176
|
+
repoOwner: ${git:repoOwner}
|
|
177
|
+
repoOwnerDashed: ${git:repo-owner}
|
|
178
|
+
|
|
179
|
+
# Url. E.g. https://github.com/DavidWells/configorama
|
|
180
|
+
url: ${git:url}
|
|
181
|
+
repoUrl: ${git:repoUrl}
|
|
182
|
+
repoUrlDashed: ${git:repo-url}
|
|
157
183
|
|
|
184
|
+
# Directory. E.g. https://github.com/DavidWells/configorama/tree/master/tests/gitVariables
|
|
185
|
+
dir: ${git:dir}
|
|
186
|
+
directory: ${git:directory}
|
|
187
|
+
|
|
188
|
+
# Branch
|
|
158
189
|
branch: ${git:branch}
|
|
159
190
|
|
|
191
|
+
# Commits. E.g. 785fa6b982d67b079d53099d57c27fa87c075211
|
|
160
192
|
commit: ${git:commit}
|
|
161
193
|
|
|
194
|
+
# Sha1. E.g. 785fa6b
|
|
162
195
|
sha1: ${git:sha1}
|
|
163
196
|
|
|
197
|
+
# Message. E.g. 'Initial commit'
|
|
164
198
|
message: ${git:message}
|
|
165
199
|
|
|
200
|
+
# Remotes. E.g. https://github.com/DavidWells/configorama
|
|
166
201
|
remote: ${git:remote}
|
|
167
|
-
|
|
168
202
|
remoteDefined: ${git:remote('origin')}
|
|
169
|
-
|
|
170
203
|
remoteDefinedNoQuotes: ${git:remote(origin)}
|
|
171
204
|
|
|
172
|
-
|
|
205
|
+
# Tags. E.g. v0.5.2-1-g785fa6b
|
|
206
|
+
tag: ${git:tag}
|
|
207
|
+
# Describe. E.g. v0.5.2-1-g785fa6b
|
|
208
|
+
describe: ${git:describe}
|
|
209
|
+
|
|
210
|
+
# Timestamp. E.g. 2025-01-28T07:28:53.000Z
|
|
211
|
+
gitTimestampRelativePath: ${git:timestamp('../../package.json')}
|
|
212
|
+
# Timestamp. E.g. 2025-01-28T07:28:53.000Z
|
|
213
|
+
gitTimestampAbsolutePath: ${git:timestamp('package.json')}
|
|
173
214
|
```
|
|
215
|
+
<!-- end-doc-gen -->
|
|
174
216
|
|
|
175
217
|
### Filters (experimental)
|
|
176
218
|
|
package/cli.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "configorama",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Variable support for configuration files",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"traverse": "^0.6.8"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"markdown-magic": "^
|
|
66
|
+
"markdown-magic": "^3.4.0",
|
|
67
67
|
"uvu": "^0.5.6",
|
|
68
68
|
"watchlist": "^0.3.1"
|
|
69
69
|
}
|