@config-bound/cli 0.2.0 → 0.2.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/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/package.json +25 -21
- package/scripts/generate-docs.ts +1 -1
- package/src/services/bind-generator.service.ts +2 -2
- package/src/services/config-discovery.service.spec.ts +10 -10
- package/src/services/config-discovery.service.ts +26 -41
- package/src/services/config-loader.service.ts +8 -16
- package/src/services/schema-export.service.spec.ts +19 -21
- package/src/services/schema-export.service.ts +6 -11
package/CHANGELOG.md
CHANGED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Robert Keyser
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@config-bound/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "CLI tool for ConfigBound schema export and management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -17,21 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"main": "./dist/main.js",
|
|
19
19
|
"types": "./dist/main.d.ts",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsc",
|
|
22
|
-
"clean": "rimraf dist coverage .turbo",
|
|
23
|
-
"dev": "tsx src/main.ts",
|
|
24
|
-
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
|
25
|
-
"test:dev": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
|
|
26
|
-
"test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
|
|
27
|
-
"lint": "eslint src/**/*.ts --fix",
|
|
28
|
-
"lint:ci": "eslint src/**/*.ts",
|
|
29
|
-
"format": "prettier --write --config ../../.config/.prettierrc --ignore-path ../../.config/.prettierignore src/**/*.ts",
|
|
30
|
-
"format:ci": "prettier --check --config ../../.config/.prettierrc --ignore-path ../../.config/.prettierignore src/**/*.ts"
|
|
31
|
-
},
|
|
32
20
|
"dependencies": {
|
|
33
|
-
"@config-bound/config-bound": "*",
|
|
34
|
-
"@config-bound/schema-export": "*",
|
|
35
21
|
"@nestjs/common": "^11.1.18",
|
|
36
22
|
"@nestjs/core": "^11.1.18",
|
|
37
23
|
"chalk": "^4.1.2",
|
|
@@ -39,26 +25,44 @@
|
|
|
39
25
|
"nest-commander": "^3.15.0",
|
|
40
26
|
"reflect-metadata": "^0.2.2",
|
|
41
27
|
"ts-morph": "^24.0.0",
|
|
42
|
-
"tsx": "^4.20.6"
|
|
28
|
+
"tsx": "^4.20.6",
|
|
29
|
+
"@config-bound/core": "1.0.0",
|
|
30
|
+
"@config-bound/schema-export": "0.1.3"
|
|
43
31
|
},
|
|
44
32
|
"devDependencies": {
|
|
45
|
-
"@config-bound/eslint-config": "*",
|
|
46
33
|
"@nestjs/testing": "^11.1.18",
|
|
47
34
|
"@types/jest": "^30.0.0",
|
|
48
|
-
"@types/node": "^24.10.
|
|
35
|
+
"@types/node": "^24.10.0",
|
|
49
36
|
"eslint": "^9.39.1",
|
|
50
37
|
"jest": "^30.2.0",
|
|
51
38
|
"markdown-table": "^3.0.4",
|
|
52
|
-
"rimraf": "^6.1.
|
|
39
|
+
"rimraf": "^6.1.0",
|
|
53
40
|
"ts-jest": "^29.4.5",
|
|
54
|
-
"typescript": "^6.0.0"
|
|
41
|
+
"typescript": "^6.0.0",
|
|
42
|
+
"@config-bound/eslint-config": "0.0.0",
|
|
43
|
+
"@config-bound/typescript-config": "0.0.0"
|
|
55
44
|
},
|
|
56
45
|
"publishConfig": {
|
|
57
46
|
"access": "public",
|
|
58
47
|
"registry": "https://registry.npmjs.org"
|
|
59
48
|
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=22"
|
|
51
|
+
},
|
|
60
52
|
"repository": {
|
|
61
53
|
"type": "git",
|
|
62
54
|
"url": "https://github.com/notr-ai/ConfigBound"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc",
|
|
58
|
+
"clean": "rimraf dist coverage .turbo",
|
|
59
|
+
"dev": "tsx src/main.ts",
|
|
60
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
|
61
|
+
"test:dev": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
|
|
62
|
+
"test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
|
|
63
|
+
"lint": "eslint src/**/*.ts --fix",
|
|
64
|
+
"lint:ci": "eslint src/**/*.ts",
|
|
65
|
+
"format": "prettier --write --config ../../.config/.prettierrc --ignore-path ../../.config/.prettierignore src/**/*.ts",
|
|
66
|
+
"format:ci": "prettier --check --config ../../.config/.prettierrc --ignore-path ../../.config/.prettierignore src/**/*.ts"
|
|
63
67
|
}
|
|
64
|
-
}
|
|
68
|
+
}
|
package/scripts/generate-docs.ts
CHANGED
|
@@ -311,7 +311,7 @@ The factory pattern pre-loads values into a cache at startup. \`retrieve()\` rea
|
|
|
311
311
|
{ text: 'Create a custom bind', link: '/how-to/custom-bind' },
|
|
312
312
|
{
|
|
313
313
|
text: '`Bind` API reference',
|
|
314
|
-
link: '/reference/api/@config-bound.
|
|
314
|
+
link: '/reference/api/@config-bound.core.bind.bind.Class.Bind',
|
|
315
315
|
},
|
|
316
316
|
],
|
|
317
317
|
};
|
|
@@ -100,7 +100,7 @@ export class BindGeneratorService {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
private renderBindClass(names: BindNames): string {
|
|
103
|
-
return `import { Bind } from '@config-bound/
|
|
103
|
+
return `import { Bind } from '@config-bound/core/bind';
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Options for constructing a ${names.pascal}Bind.
|
|
@@ -191,7 +191,7 @@ export class ${names.pascal}Bind extends Bind {
|
|
|
191
191
|
"keywords": ["configbound", "config", "${names.kebab}"],
|
|
192
192
|
"license": "MIT",
|
|
193
193
|
"dependencies": {
|
|
194
|
-
"@config-bound/
|
|
194
|
+
"@config-bound/core": "^0.1.0"
|
|
195
195
|
},
|
|
196
196
|
"devDependencies": {
|
|
197
197
|
"@eslint/js": "^9.0.0",
|
|
@@ -45,7 +45,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
45
45
|
createTempFile(
|
|
46
46
|
'config.ts',
|
|
47
47
|
`
|
|
48
|
-
import { ConfigBound } from '@config-bound/
|
|
48
|
+
import { ConfigBound } from '@config-bound/core';
|
|
49
49
|
|
|
50
50
|
export const appConfig = ConfigBound.createConfig({
|
|
51
51
|
name: 'MyApp',
|
|
@@ -66,7 +66,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
66
66
|
createTempFile(
|
|
67
67
|
'config.ts',
|
|
68
68
|
`
|
|
69
|
-
import { createConfig } from '@config-bound/
|
|
69
|
+
import { createConfig } from '@config-bound/core';
|
|
70
70
|
|
|
71
71
|
export const dbConfig = createConfig({
|
|
72
72
|
name: 'Database',
|
|
@@ -86,7 +86,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
86
86
|
createTempFile(
|
|
87
87
|
'config.ts',
|
|
88
88
|
`
|
|
89
|
-
import { ConfigBound } from '@config-bound/
|
|
89
|
+
import { ConfigBound } from '@config-bound/core';
|
|
90
90
|
|
|
91
91
|
export default ConfigBound.createConfig({
|
|
92
92
|
name: 'DefaultConfig',
|
|
@@ -107,7 +107,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
107
107
|
createTempFile(
|
|
108
108
|
'configs.ts',
|
|
109
109
|
`
|
|
110
|
-
import { createConfig } from '@config-bound/
|
|
110
|
+
import { createConfig } from '@config-bound/core';
|
|
111
111
|
|
|
112
112
|
export const config1 = createConfig({ name: 'Config1', sections: {} });
|
|
113
113
|
export const config2 = createConfig({ name: 'Config2', sections: {} });
|
|
@@ -126,7 +126,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
126
126
|
createTempFile(
|
|
127
127
|
'config1.ts',
|
|
128
128
|
`
|
|
129
|
-
import { createConfig } from '@config-bound/
|
|
129
|
+
import { createConfig } from '@config-bound/core';
|
|
130
130
|
export const config1 = createConfig({ name: 'Config1', sections: {} });
|
|
131
131
|
`
|
|
132
132
|
);
|
|
@@ -134,7 +134,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
134
134
|
createTempFile(
|
|
135
135
|
'subdir/config2.ts',
|
|
136
136
|
`
|
|
137
|
-
import { createConfig } from '@config-bound/
|
|
137
|
+
import { createConfig } from '@config-bound/core';
|
|
138
138
|
export const config2 = createConfig({ name: 'Config2', sections: {} });
|
|
139
139
|
`
|
|
140
140
|
);
|
|
@@ -148,7 +148,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
148
148
|
createTempFile(
|
|
149
149
|
'config1.ts',
|
|
150
150
|
`
|
|
151
|
-
import { createConfig } from '@config-bound/
|
|
151
|
+
import { createConfig } from '@config-bound/core';
|
|
152
152
|
export const config1 = createConfig({ name: 'Config1', sections: {} });
|
|
153
153
|
`
|
|
154
154
|
);
|
|
@@ -156,7 +156,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
156
156
|
createTempFile(
|
|
157
157
|
'subdir/config2.ts',
|
|
158
158
|
`
|
|
159
|
-
import { createConfig } from '@config-bound/
|
|
159
|
+
import { createConfig } from '@config-bound/core';
|
|
160
160
|
export const config2 = createConfig({ name: 'Config2', sections: {} });
|
|
161
161
|
`
|
|
162
162
|
);
|
|
@@ -170,7 +170,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
170
170
|
createTempFile(
|
|
171
171
|
'config.ts',
|
|
172
172
|
`
|
|
173
|
-
import { createConfig } from '@config-bound/
|
|
173
|
+
import { createConfig } from '@config-bound/core';
|
|
174
174
|
const privateConfig = createConfig({ name: 'Private', sections: {} });
|
|
175
175
|
`
|
|
176
176
|
);
|
|
@@ -184,7 +184,7 @@ describe('ConfigDiscoveryService', () => {
|
|
|
184
184
|
createTempFile(
|
|
185
185
|
'config.spec.ts',
|
|
186
186
|
`
|
|
187
|
-
import { createConfig } from '@config-bound/
|
|
187
|
+
import { createConfig } from '@config-bound/core';
|
|
188
188
|
export const testConfig = createConfig({ name: 'Test', sections: {} });
|
|
189
189
|
`
|
|
190
190
|
);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { Project, Node, SyntaxKind, SourceFile } from 'ts-morph';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import { glob } from 'node:fs/promises';
|
|
6
|
+
import { ensureError } from '@config-bound/core/utilities';
|
|
6
7
|
|
|
7
8
|
export interface DiscoveredConfig {
|
|
8
9
|
filePath: string;
|
|
@@ -18,7 +19,7 @@ export class ConfigDiscoveryService {
|
|
|
18
19
|
searchPath: string,
|
|
19
20
|
recursive: boolean = true
|
|
20
21
|
): Promise<DiscoveredConfig[]> {
|
|
21
|
-
const tsFiles = this.findTypeScriptFiles(searchPath, recursive);
|
|
22
|
+
const tsFiles = await this.findTypeScriptFiles(searchPath, recursive);
|
|
22
23
|
const discovered: DiscoveredConfig[] = [];
|
|
23
24
|
|
|
24
25
|
// Create a single project instance for all files
|
|
@@ -171,11 +172,10 @@ export class ConfigDiscoveryService {
|
|
|
171
172
|
return undefined;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
private findTypeScriptFiles(
|
|
175
|
+
private async findTypeScriptFiles(
|
|
175
176
|
searchPath: string,
|
|
176
177
|
recursive: boolean
|
|
177
|
-
): string[] {
|
|
178
|
-
const files: string[] = [];
|
|
178
|
+
): Promise<string[]> {
|
|
179
179
|
const excludedDirs = new Set([
|
|
180
180
|
'node_modules',
|
|
181
181
|
'dist',
|
|
@@ -192,46 +192,31 @@ export class ConfigDiscoveryService {
|
|
|
192
192
|
'env'
|
|
193
193
|
]);
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
} catch {
|
|
200
|
-
// Skip directories we can't read
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
195
|
+
const stats = await fs.stat(searchPath);
|
|
196
|
+
if (stats.isFile()) {
|
|
197
|
+
return searchPath.endsWith('.ts') ? [searchPath] : [];
|
|
198
|
+
}
|
|
203
199
|
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
const pattern = recursive ? '**/*.ts' : '*.ts';
|
|
201
|
+
const files: string[] = [];
|
|
206
202
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
) {
|
|
222
|
-
files.push(fullPath);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
203
|
+
for await (const file of glob(pattern, {
|
|
204
|
+
cwd: searchPath,
|
|
205
|
+
exclude: (p) =>
|
|
206
|
+
p
|
|
207
|
+
.split(path.sep)
|
|
208
|
+
.some((part) => excludedDirs.has(part) || part.startsWith('.'))
|
|
209
|
+
})) {
|
|
210
|
+
const name = path.basename(file);
|
|
211
|
+
if (
|
|
212
|
+
!name.endsWith('.spec.ts') &&
|
|
213
|
+
!name.endsWith('.test.ts') &&
|
|
214
|
+
!name.endsWith('.d.ts')
|
|
215
|
+
) {
|
|
216
|
+
files.push(path.join(searchPath, file));
|
|
225
217
|
}
|
|
226
218
|
}
|
|
227
219
|
|
|
228
|
-
const stats = fs.statSync(searchPath);
|
|
229
|
-
if (stats.isDirectory()) {
|
|
230
|
-
traverse(searchPath);
|
|
231
|
-
} else if (stats.isFile() && searchPath.endsWith('.ts')) {
|
|
232
|
-
files.push(searchPath);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
220
|
return files;
|
|
236
221
|
}
|
|
237
222
|
}
|
|
@@ -2,10 +2,9 @@ import { Injectable } from '@nestjs/common';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
|
-
import { Section } from '@config-bound/
|
|
5
|
+
import { Section } from '@config-bound/core/section';
|
|
6
6
|
import {
|
|
7
7
|
ConfigBound,
|
|
8
|
-
TypedConfigBound,
|
|
9
8
|
ConfigSchema,
|
|
10
9
|
ConfigLoaderException,
|
|
11
10
|
ConfigFileNotFoundException,
|
|
@@ -16,12 +15,12 @@ import {
|
|
|
16
15
|
InvalidConfigBoundInstanceException,
|
|
17
16
|
ConfigFileParseException,
|
|
18
17
|
MissingDependencyException
|
|
19
|
-
} from '@config-bound/
|
|
18
|
+
} from '@config-bound/core';
|
|
20
19
|
|
|
21
20
|
export interface LoadedConfig {
|
|
22
21
|
name: string;
|
|
23
|
-
sections: Section
|
|
24
|
-
instance: ConfigBound
|
|
22
|
+
sections: ReadonlyArray<Section>;
|
|
23
|
+
instance: ConfigBound<ConfigSchema>;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
@Injectable()
|
|
@@ -94,10 +93,7 @@ export class ConfigLoaderService {
|
|
|
94
93
|
const fileURL = pathToFileURL(fileToLoad).href;
|
|
95
94
|
const module = await import(fileURL);
|
|
96
95
|
|
|
97
|
-
let configInstance:
|
|
98
|
-
| ConfigBound
|
|
99
|
-
| TypedConfigBound<ConfigSchema>
|
|
100
|
-
| undefined;
|
|
96
|
+
let configInstance: ConfigBound<ConfigSchema> | undefined;
|
|
101
97
|
|
|
102
98
|
if (exportName && exportName !== 'default') {
|
|
103
99
|
configInstance = module[exportName];
|
|
@@ -156,9 +152,7 @@ export class ConfigLoaderService {
|
|
|
156
152
|
);
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
configInstance = configExports[0][1] as
|
|
160
|
-
| ConfigBound
|
|
161
|
-
| TypedConfigBound<ConfigSchema>;
|
|
155
|
+
configInstance = configExports[0][1] as ConfigBound<ConfigSchema>;
|
|
162
156
|
} else {
|
|
163
157
|
// exportName === 'default' was explicitly requested, so use it even if invalid
|
|
164
158
|
configInstance = defaultExport;
|
|
@@ -320,9 +314,7 @@ export class ConfigLoaderService {
|
|
|
320
314
|
exportName !== 'default' &&
|
|
321
315
|
this.isConfigBoundInstance(exportValue)
|
|
322
316
|
) {
|
|
323
|
-
const typedValue = exportValue as
|
|
324
|
-
| ConfigBound
|
|
325
|
-
| TypedConfigBound<ConfigSchema>;
|
|
317
|
+
const typedValue = exportValue as ConfigBound<ConfigSchema>;
|
|
326
318
|
configs.set(exportName, {
|
|
327
319
|
name: typedValue.name,
|
|
328
320
|
sections: typedValue.sections,
|
|
@@ -365,7 +357,7 @@ export class ConfigLoaderService {
|
|
|
365
357
|
|
|
366
358
|
private isConfigBoundInstance(
|
|
367
359
|
value: unknown
|
|
368
|
-
): value is ConfigBound
|
|
360
|
+
): value is ConfigBound<ConfigSchema> {
|
|
369
361
|
return (
|
|
370
362
|
value !== null &&
|
|
371
363
|
value !== undefined &&
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
2
2
|
import { SchemaExportService } from './schema-export.service.js';
|
|
3
3
|
import { describe, beforeEach, it, expect } from '@jest/globals';
|
|
4
|
-
import { ConfigBound } from '@config-bound/
|
|
5
|
-
import { Section } from '@config-bound/
|
|
6
|
-
import { Element } from '@config-bound/
|
|
4
|
+
import { ConfigBound } from '@config-bound/core';
|
|
5
|
+
import { Section } from '@config-bound/core/section';
|
|
6
|
+
import { Element } from '@config-bound/core/element';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
9
|
describe('SchemaExportService', () => {
|
|
@@ -18,25 +18,23 @@ describe('SchemaExportService', () => {
|
|
|
18
18
|
|
|
19
19
|
service = module.get<SchemaExportService>(SchemaExportService);
|
|
20
20
|
|
|
21
|
-
const hostElement = new Element<string>(
|
|
22
|
-
'host',
|
|
23
|
-
'Database host',
|
|
24
|
-
'localhost',
|
|
25
|
-
|
|
26
|
-
false,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
21
|
+
const hostElement = new Element<string>({
|
|
22
|
+
name: 'host',
|
|
23
|
+
description: 'Database host',
|
|
24
|
+
default: 'localhost',
|
|
25
|
+
sensitive: false,
|
|
26
|
+
omitFromSchema: false,
|
|
27
|
+
validator: z.string()
|
|
28
|
+
});
|
|
30
29
|
|
|
31
|
-
const portElement = new Element<number>(
|
|
32
|
-
'port',
|
|
33
|
-
'Database port',
|
|
34
|
-
5432,
|
|
35
|
-
|
|
36
|
-
false,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
30
|
+
const portElement = new Element<number>({
|
|
31
|
+
name: 'port',
|
|
32
|
+
description: 'Database port',
|
|
33
|
+
default: 5432,
|
|
34
|
+
sensitive: false,
|
|
35
|
+
omitFromSchema: false,
|
|
36
|
+
validator: z.number()
|
|
37
|
+
});
|
|
40
38
|
|
|
41
39
|
const databaseSection = new Section(
|
|
42
40
|
'database',
|
|
@@ -5,13 +5,9 @@ import {
|
|
|
5
5
|
formatAsYAML,
|
|
6
6
|
formatAsEnvExample
|
|
7
7
|
} from '@config-bound/schema-export';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ConfigSchema
|
|
12
|
-
} from '@config-bound/config-bound';
|
|
13
|
-
import { Section } from '@config-bound/config-bound/section';
|
|
14
|
-
import { EnvVarBind } from '@config-bound/config-bound/bind/binds/envVar';
|
|
8
|
+
import { ConfigBound, ConfigSchema } from '@config-bound/core';
|
|
9
|
+
import { Section } from '@config-bound/core/section';
|
|
10
|
+
import { EnvVarBind } from '@config-bound/core/binds/env';
|
|
15
11
|
|
|
16
12
|
export type ExportFormat = 'json' | 'yaml' | 'env';
|
|
17
13
|
|
|
@@ -25,8 +21,8 @@ export interface ExportSchemaOptions {
|
|
|
25
21
|
export class SchemaExportService {
|
|
26
22
|
exportToString(
|
|
27
23
|
configName: string,
|
|
28
|
-
sections: Section
|
|
29
|
-
configInstance: ConfigBound
|
|
24
|
+
sections: ReadonlyArray<Section>,
|
|
25
|
+
configInstance: ConfigBound<ConfigSchema>,
|
|
30
26
|
options: ExportSchemaOptions
|
|
31
27
|
): string {
|
|
32
28
|
const includeOmitted = options.includeOmitted || false;
|
|
@@ -41,7 +37,6 @@ export class SchemaExportService {
|
|
|
41
37
|
return formatAsYAML(schema);
|
|
42
38
|
|
|
43
39
|
case 'env': {
|
|
44
|
-
// Extract prefix from EnvVarBind if present
|
|
45
40
|
const prefix = this.extractEnvVarPrefix(configInstance);
|
|
46
41
|
return formatAsEnvExample(schema, prefix);
|
|
47
42
|
}
|
|
@@ -52,7 +47,7 @@ export class SchemaExportService {
|
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
private extractEnvVarPrefix(
|
|
55
|
-
configInstance: ConfigBound
|
|
50
|
+
configInstance: ConfigBound<ConfigSchema>
|
|
56
51
|
): string | undefined {
|
|
57
52
|
if (!configInstance || !configInstance.binds) {
|
|
58
53
|
return undefined;
|