@platformatic/config
Advanced tools
Comparing version 0.17.1 to 0.18.0
13
index.js
@@ -10,3 +10,3 @@ 'use strict' | ||
const { FileWatcher } = require('@platformatic/utils') | ||
const { getParser } = require('@platformatic/metaconfig') | ||
const { getParser, analyze } = require('@platformatic/metaconfig') | ||
@@ -135,2 +135,12 @@ class ConfigManager extends EventEmitter { | ||
this.current = this._parser(await this.replaceEnv(configString)) | ||
// try updating the config format to latest | ||
try { | ||
let meta = await analyze({ config: this.current }) | ||
while (typeof meta.up === 'function') { | ||
meta = meta.up() | ||
} | ||
this.current = meta.config | ||
} catch { | ||
// nothing to do | ||
} | ||
} | ||
@@ -194,2 +204,3 @@ const validationResult = this.validate() | ||
} | ||
await this._transformConfig() | ||
this.emit('update', this.current) | ||
@@ -196,0 +207,0 @@ return true |
{ | ||
"name": "@platformatic/config", | ||
"version": "0.17.1", | ||
"version": "0.18.0", | ||
"description": "Platformatic DB Config Manager", | ||
@@ -29,4 +29,4 @@ "main": "index.js", | ||
"pupa": "^3.1.0", | ||
"@platformatic/utils": "0.17.1", | ||
"@platformatic/metaconfig": "0.17.1" | ||
"@platformatic/utils": "0.18.0", | ||
"@platformatic/metaconfig": "0.18.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "scripts": { |
@@ -111,1 +111,23 @@ 'use strict' | ||
}) | ||
test('should automatically update', { only: true }, async ({ same }) => { | ||
const cm = new ConfigManager({ | ||
source: resolve(__dirname, './fixtures/db-0.16.0.json'), | ||
env: { PLT_FOOBAR: 'foobar' } | ||
}) | ||
await cm.parse() | ||
same(cm.current, { | ||
$schema: 'https://platformatic.dev/schemas/v0.18.0/db', | ||
server: { hostname: '127.0.0.1', port: '3042', logger: { level: 'info' } }, | ||
metrics: { auth: { username: 'plt-db', password: 'plt-db' } }, | ||
plugins: { paths: ['./plugin-sum.js'] }, | ||
db: { | ||
connectionString: 'postgres://postgres:postgres@localhost:5432/postgres', | ||
graphiql: true, | ||
ignore: { versions: true } | ||
}, | ||
migrations: { dir: './demo/migrations', validateChecksums: false }, | ||
dashboard: { path: '/' }, | ||
authorization: { adminSecret: 'plt-db' } | ||
}) | ||
}) |
@@ -9,3 +9,3 @@ 'use strict' | ||
test('should update valid config without updating the file', async ({ same, teardown, pass, plan }) => { | ||
plan(3) | ||
plan(5) | ||
const config = { | ||
@@ -38,2 +38,5 @@ name: 'Platformatic', | ||
}) | ||
cm._transformConfig = (config) => { | ||
pass('transform config') | ||
} | ||
cm.on('update', () => { | ||
@@ -40,0 +43,0 @@ pass('new config available') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45170
21
1166
+ Added@platformatic/metaconfig@0.18.0(transitive)
+ Added@platformatic/utils@0.18.0(transitive)
- Removed@platformatic/metaconfig@0.17.1(transitive)
- Removed@platformatic/utils@0.17.1(transitive)
Updated@platformatic/utils@0.18.0