@h3ravel/config 1.3.0 → 1.3.1
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/package.json +7 -4
- package/CHANGELOG.md +0 -250
- package/src/ConfigRepository.ts +0 -52
- package/src/Contracts/.gitkeep +0 -0
- package/src/EnvLoader.ts +0 -16
- package/src/Helpers.ts +0 -1
- package/src/Providers/ConfigServiceProvider.ts +0 -46
- package/src/index.ts +0 -8
- package/tests/.gitkeep +0 -0
- package/tsconfig.json +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/config",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Environment/config loading and management system for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"types": "./dist/index.d.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
16
19
|
"publishConfig": {
|
|
17
20
|
"access": "public"
|
|
18
21
|
},
|
|
@@ -33,12 +36,12 @@
|
|
|
33
36
|
"laravel"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@h3ravel/shared": "^0.16.
|
|
37
|
-
"@h3ravel/support": "^0.8.
|
|
39
|
+
"@h3ravel/shared": "^0.16.1",
|
|
40
|
+
"@h3ravel/support": "^0.8.1"
|
|
38
41
|
},
|
|
39
42
|
"devDependencies": {
|
|
40
43
|
"typescript": "^5.4.0",
|
|
41
|
-
"@h3ravel/core": "^1.4.
|
|
44
|
+
"@h3ravel/core": "^1.4.1"
|
|
42
45
|
},
|
|
43
46
|
"scripts": {
|
|
44
47
|
"barrel": "barrelsby --directory src --delete --singleQuotes",
|
package/CHANGELOG.md
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
# @h3ravel/config
|
|
2
|
-
|
|
3
|
-
## 1.3.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 79f4045: feat: add add exports to package.json
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- Updated dependencies [79f4045]
|
|
12
|
-
- @h3ravel/support@0.8.0
|
|
13
|
-
- @h3ravel/shared@0.16.0
|
|
14
|
-
|
|
15
|
-
## 1.2.0
|
|
16
|
-
|
|
17
|
-
### Minor Changes
|
|
18
|
-
|
|
19
|
-
- feat: implement full IoC container resolution
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- Updated dependencies
|
|
24
|
-
- @h3ravel/shared@0.15.4
|
|
25
|
-
|
|
26
|
-
## 1.1.7
|
|
27
|
-
|
|
28
|
-
### Patch Changes
|
|
29
|
-
|
|
30
|
-
- feat: add homepage and repository to all packages.
|
|
31
|
-
- Updated dependencies
|
|
32
|
-
- @h3ravel/shared@0.15.2
|
|
33
|
-
- @h3ravel/support@0.7.5
|
|
34
|
-
|
|
35
|
-
## 1.1.6
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- chore: update readme accros all packages
|
|
40
|
-
- Updated dependencies
|
|
41
|
-
- @h3ravel/shared@0.15.1
|
|
42
|
-
- @h3ravel/support@0.7.4
|
|
43
|
-
|
|
44
|
-
## 1.1.5
|
|
45
|
-
|
|
46
|
-
### Patch Changes
|
|
47
|
-
|
|
48
|
-
- Updated dependencies [d07ff49]
|
|
49
|
-
- @h3ravel/shared@0.15.0
|
|
50
|
-
- @h3ravel/support@0.7.3
|
|
51
|
-
|
|
52
|
-
## 1.1.4
|
|
53
|
-
|
|
54
|
-
### Patch Changes
|
|
55
|
-
|
|
56
|
-
- db0dd70: chore: revert to old workspace core dependency
|
|
57
|
-
|
|
58
|
-
## 1.1.3
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- fix dependency.
|
|
63
|
-
|
|
64
|
-
## 1.1.2
|
|
65
|
-
|
|
66
|
-
### Patch Changes
|
|
67
|
-
|
|
68
|
-
- chore: require the latest dependencies from the framework
|
|
69
|
-
- Updated dependencies
|
|
70
|
-
- @h3ravel/support@0.7.3
|
|
71
|
-
- @h3ravel/core@1.1.2
|
|
72
|
-
|
|
73
|
-
## 1.1.1
|
|
74
|
-
|
|
75
|
-
### Patch Changes
|
|
76
|
-
|
|
77
|
-
- Updated dependencies
|
|
78
|
-
- @h3ravel/shared@0.14.0
|
|
79
|
-
- @h3ravel/core@1.1.1
|
|
80
|
-
- @h3ravel/support@0.7.2
|
|
81
|
-
|
|
82
|
-
## 1.1.0
|
|
83
|
-
|
|
84
|
-
### Minor Changes
|
|
85
|
-
|
|
86
|
-
- 6e249fe: feat: bind view as a self contained method to render views
|
|
87
|
-
|
|
88
|
-
### Patch Changes
|
|
89
|
-
|
|
90
|
-
- Updated dependencies [6e249fe]
|
|
91
|
-
- @h3ravel/shared@0.13.0
|
|
92
|
-
- @h3ravel/core@1.1.0
|
|
93
|
-
- @h3ravel/support@0.7.2
|
|
94
|
-
|
|
95
|
-
## 1.0.9
|
|
96
|
-
|
|
97
|
-
### Patch Changes
|
|
98
|
-
|
|
99
|
-
- chore: regularize all interfaces.
|
|
100
|
-
- Updated dependencies
|
|
101
|
-
- @h3ravel/core@1.0.9
|
|
102
|
-
- @h3ravel/shared@0.12.1
|
|
103
|
-
- @h3ravel/support@0.7.2
|
|
104
|
-
|
|
105
|
-
## 1.0.8
|
|
106
|
-
|
|
107
|
-
### Patch Changes
|
|
108
|
-
|
|
109
|
-
- Updated dependencies
|
|
110
|
-
- @h3ravel/shared@0.12.0
|
|
111
|
-
- @h3ravel/core@1.0.8
|
|
112
|
-
- @h3ravel/support@0.7.1
|
|
113
|
-
|
|
114
|
-
## 1.0.7
|
|
115
|
-
|
|
116
|
-
### Patch Changes
|
|
117
|
-
|
|
118
|
-
- Updated dependencies
|
|
119
|
-
- @h3ravel/shared@0.11.0
|
|
120
|
-
- @h3ravel/core@1.0.7
|
|
121
|
-
- @h3ravel/support@0.7.1
|
|
122
|
-
|
|
123
|
-
## 1.0.6
|
|
124
|
-
|
|
125
|
-
### Patch Changes
|
|
126
|
-
|
|
127
|
-
- Updated dependencies
|
|
128
|
-
- @h3ravel/shared@0.10.0
|
|
129
|
-
- @h3ravel/core@1.0.6
|
|
130
|
-
- @h3ravel/support@0.7.1
|
|
131
|
-
|
|
132
|
-
## 1.0.5
|
|
133
|
-
|
|
134
|
-
### Patch Changes
|
|
135
|
-
|
|
136
|
-
- Updated dependencies
|
|
137
|
-
- @h3ravel/shared@0.9.0
|
|
138
|
-
- @h3ravel/core@1.0.5
|
|
139
|
-
- @h3ravel/support@0.7.1
|
|
140
|
-
|
|
141
|
-
## 1.0.4
|
|
142
|
-
|
|
143
|
-
### Patch Changes
|
|
144
|
-
|
|
145
|
-
- Updated dependencies
|
|
146
|
-
- @h3ravel/shared@0.8.0
|
|
147
|
-
- @h3ravel/core@1.0.4
|
|
148
|
-
- @h3ravel/support@0.7.1
|
|
149
|
-
|
|
150
|
-
## 1.0.3
|
|
151
|
-
|
|
152
|
-
### Patch Changes
|
|
153
|
-
|
|
154
|
-
- chore: add download count to readme
|
|
155
|
-
- Updated dependencies
|
|
156
|
-
- @h3ravel/core@1.0.3
|
|
157
|
-
- @h3ravel/shared@0.7.1
|
|
158
|
-
- @h3ravel/support@0.7.1
|
|
159
|
-
|
|
160
|
-
## 1.0.2
|
|
161
|
-
|
|
162
|
-
### Patch Changes
|
|
163
|
-
|
|
164
|
-
- Updated dependencies [b0d1b7c]
|
|
165
|
-
- Updated dependencies [ce51a92]
|
|
166
|
-
- @h3ravel/support@0.7.0
|
|
167
|
-
- @h3ravel/shared@0.7.0
|
|
168
|
-
- @h3ravel/core@1.0.2
|
|
169
|
-
|
|
170
|
-
## 1.0.0
|
|
171
|
-
|
|
172
|
-
### Major Changes
|
|
173
|
-
|
|
174
|
-
- b40caeb: feat: make service providers sortable and unique while only loading the core providers by default.
|
|
175
|
-
Service providers are no longer loaded by default, asides the ones provided by @h3ravel/core
|
|
176
|
-
Service provides are sorted by an optional order and priority property.
|
|
177
|
-
|
|
178
|
-
### Patch Changes
|
|
179
|
-
|
|
180
|
-
- Updated dependencies [b40caeb]
|
|
181
|
-
- @h3ravel/core@1.0.0
|
|
182
|
-
- @h3ravel/shared@0.6.0
|
|
183
|
-
- @h3ravel/support@0.6.0
|
|
184
|
-
|
|
185
|
-
## 0.5.2
|
|
186
|
-
|
|
187
|
-
### Patch Changes
|
|
188
|
-
|
|
189
|
-
- dynamically import dotenv
|
|
190
|
-
|
|
191
|
-
## 0.5.1
|
|
192
|
-
|
|
193
|
-
### Patch Changes
|
|
194
|
-
|
|
195
|
-
- feat: hide all dotenv debug info
|
|
196
|
-
|
|
197
|
-
## 0.5.0
|
|
198
|
-
|
|
199
|
-
### Minor Changes
|
|
200
|
-
|
|
201
|
-
- rebuild all dependencies
|
|
202
|
-
|
|
203
|
-
### Patch Changes
|
|
204
|
-
|
|
205
|
-
- Updated dependencies
|
|
206
|
-
- @h3ravel/core@0.5.0
|
|
207
|
-
- @h3ravel/shared@0.5.0
|
|
208
|
-
- @h3ravel/support@0.5.0
|
|
209
|
-
|
|
210
|
-
## 0.4.0
|
|
211
|
-
|
|
212
|
-
### Minor Changes
|
|
213
|
-
|
|
214
|
-
- 8ceb2c1: implement the Application class directly since it already implements the IClass contract
|
|
215
|
-
|
|
216
|
-
### Patch Changes
|
|
217
|
-
|
|
218
|
-
- a27f452: chore: fix all linting issues.
|
|
219
|
-
- c906050: chore: migrate tests suite to jest
|
|
220
|
-
- Updated dependencies [8ceb2c1]
|
|
221
|
-
- Updated dependencies [a27f452]
|
|
222
|
-
- Updated dependencies [c906050]
|
|
223
|
-
- @h3ravel/core@0.4.0
|
|
224
|
-
- @h3ravel/shared@0.4.0
|
|
225
|
-
- @h3ravel/support@0.4.0
|
|
226
|
-
|
|
227
|
-
## 0.3.0
|
|
228
|
-
|
|
229
|
-
### Minor Changes
|
|
230
|
-
|
|
231
|
-
- 3ff97bf: refactor: add a shared package to be extended by others to avoid cyclic dependency issues.
|
|
232
|
-
|
|
233
|
-
### Patch Changes
|
|
234
|
-
|
|
235
|
-
- Updated dependencies [3ff97bf]
|
|
236
|
-
- @h3ravel/core@0.3.0
|
|
237
|
-
- @h3ravel/shared@0.3.0
|
|
238
|
-
- @h3ravel/support@0.3.0
|
|
239
|
-
|
|
240
|
-
## 0.2.0
|
|
241
|
-
|
|
242
|
-
### Minor Changes
|
|
243
|
-
|
|
244
|
-
- aea734f: Fix all known bugs and improved interdependecy between packages.
|
|
245
|
-
|
|
246
|
-
### Patch Changes
|
|
247
|
-
|
|
248
|
-
- Updated dependencies [aea734f]
|
|
249
|
-
- @h3ravel/core@0.2.0
|
|
250
|
-
- @h3ravel/support@0.2.0
|
package/src/ConfigRepository.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { DotNestedKeys, DotNestedValue, safeDot, setNested } from '@h3ravel/support'
|
|
2
|
-
|
|
3
|
-
import { Application } from '@h3ravel/core'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
import { readdir } from 'node:fs/promises'
|
|
6
|
-
|
|
7
|
-
export class ConfigRepository {
|
|
8
|
-
private loaded: boolean = false
|
|
9
|
-
private configs: Record<string, Record<string, any>> = {}
|
|
10
|
-
|
|
11
|
-
constructor(protected app: Application) { }
|
|
12
|
-
|
|
13
|
-
// get<X extends Record<string, any>> (): X
|
|
14
|
-
// get<X extends Record<string, any>, T extends Extract<keyof X, string>> (key: T): X[T]
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get the defined configurations
|
|
18
|
-
*/
|
|
19
|
-
get<X extends Record<string, any>> (): X
|
|
20
|
-
get<X extends Record<string, any>, K extends DotNestedKeys<X>> (key: K, def?: any): DotNestedValue<X, K>
|
|
21
|
-
get<X extends Record<string, any>, K extends DotNestedKeys<X>> (key?: K, def?: any): any {
|
|
22
|
-
return safeDot(this.configs, key) ?? def
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Modify the defined configurations
|
|
27
|
-
*/
|
|
28
|
-
set<T extends string> (key: T, value: any): void {
|
|
29
|
-
setNested(this.configs, key, value)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async load () {
|
|
33
|
-
if (!this.loaded) {
|
|
34
|
-
const configPath = this.app.getPath('config')
|
|
35
|
-
|
|
36
|
-
const files = (await readdir(configPath)).filter((e) => {
|
|
37
|
-
return !e.includes('.d.ts') && !e.includes('.map')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
for (let i = 0; i < files.length; i++) {
|
|
41
|
-
const configModule = await import(path.join(configPath, files[i]))
|
|
42
|
-
const name = files[i].replaceAll(/\.ts|\.js/g, '')
|
|
43
|
-
if (typeof configModule.default === 'function') {
|
|
44
|
-
this.configs[name] = configModule.default(this.app)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.loaded = true
|
|
49
|
-
}
|
|
50
|
-
return this
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/Contracts/.gitkeep
DELETED
|
File without changes
|
package/src/EnvLoader.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DotNestedKeys, DotNestedValue, safeDot } from '@h3ravel/support'
|
|
2
|
-
|
|
3
|
-
import { Application } from '@h3ravel/core'
|
|
4
|
-
|
|
5
|
-
export class EnvLoader {
|
|
6
|
-
constructor(protected _app: Application) { }
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Get the defined environment vars
|
|
10
|
-
*/
|
|
11
|
-
get<X extends NodeJS.ProcessEnv> (): X
|
|
12
|
-
get<X extends NodeJS.ProcessEnv, K extends DotNestedKeys<X>> (key: K, def?: any): DotNestedValue<X, K>
|
|
13
|
-
get<X extends NodeJS.ProcessEnv, K extends DotNestedKeys<X>> (key?: K, def?: any): any {
|
|
14
|
-
return safeDot(process.env, key) ?? def
|
|
15
|
-
}
|
|
16
|
-
}
|
package/src/Helpers.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default class { }
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ConfigRepository, EnvLoader } from '..'
|
|
2
|
-
|
|
3
|
-
import { Bindings } from '@h3ravel/shared';
|
|
4
|
-
import { ServiceProvider } from '@h3ravel/core'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Loads configuration and environment files.
|
|
8
|
-
*
|
|
9
|
-
* Load .env and merge with config files.
|
|
10
|
-
* Bind ConfigRepository to the container.
|
|
11
|
-
*
|
|
12
|
-
* Auto-Registered
|
|
13
|
-
*/
|
|
14
|
-
export class ConfigServiceProvider extends ServiceProvider {
|
|
15
|
-
public static priority = 998;
|
|
16
|
-
// public static order = 'before:AppServiceProvider';
|
|
17
|
-
|
|
18
|
-
async register () {
|
|
19
|
-
/**
|
|
20
|
-
* Create singleton to load env
|
|
21
|
-
*/
|
|
22
|
-
this.app.singleton('env', () => {
|
|
23
|
-
return new EnvLoader(this.app).get
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Initialize the configuration through the repository
|
|
28
|
-
*/
|
|
29
|
-
const repo = new ConfigRepository(this.app)
|
|
30
|
-
await repo.load()
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create singleton to load configurations
|
|
34
|
-
*/
|
|
35
|
-
this.app.singleton('config', () => {
|
|
36
|
-
return {
|
|
37
|
-
get: (key, def) => repo.get(key as any, def),
|
|
38
|
-
set: repo.set
|
|
39
|
-
} as Bindings['config']
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
this.app.make('http.app').use(e => {
|
|
43
|
-
repo.set('app.url', e.url.origin)
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
}
|
package/src/index.ts
DELETED
package/tests/.gitkeep
DELETED
|
File without changes
|