-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-table-generator.ts
More file actions
23 lines (21 loc) · 978 Bytes
/
config-table-generator.ts
File metadata and controls
23 lines (21 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// eslint-disable-next-line import/no-extraneous-dependencies -- its cool, this is a dev only file
import { markdownTable } from 'markdown-table'
import { SchemaObj } from 'convict'
import config from './src/config.js'
export function configSchemaAsTable(): string {
const schema = config.getSchema() as unknown as {
_cvtProperties: {
[key: string]: SchemaObj<string>
}
}
const configValuesInTables = Object.entries(schema._cvtProperties).map(([key, propertySchema]) => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const format = `${propertySchema.format}${propertySchema.nullable ? ' (nullable)' : ''}`
return [key, propertySchema.env, propertySchema.doc, format, propertySchema.default] as string[]
})
return markdownTable([['Field', 'Environment', 'Description', 'Format', 'Default'], ...configValuesInTables], {
padding: false,
alignDelimiters: false,
})
}
console.log(configSchemaAsTable())