@backstage/config-loader
Advanced tools
Comparing version 0.5.0 to 0.5.1
# @backstage/config-loader | ||
## 0.5.1 | ||
### Patch Changes | ||
- 062df71db: Bump `config-loader` to `ajv` 7, to enable v7 feature use elsewhere | ||
- e9aab60c7: Each piece of the configuration schema is now validated upfront, in order to produce more informative errors. | ||
## 0.5.0 | ||
@@ -4,0 +11,0 @@ |
@@ -226,6 +226,8 @@ 'use strict'; | ||
allErrors: true, | ||
allowUnionTypes: true, | ||
schemas: { | ||
"https://backstage.io/schema/config-v1": true | ||
} | ||
}).addKeyword("visibility", { | ||
}).addKeyword({ | ||
keyword: "visibility", | ||
metaSchema: { | ||
@@ -236,8 +238,8 @@ type: "string", | ||
compile(visibility) { | ||
return (_data, dataPath) => { | ||
if (!dataPath) { | ||
return (_data, context) => { | ||
if ((context == null ? void 0 : context.dataPath) === void 0) { | ||
return false; | ||
} | ||
if (visibility && visibility !== "backend") { | ||
const normalizedPath = dataPath.replace(/\['?(.*?)'?\]/g, (_, segment) => `.${segment}`); | ||
const normalizedPath = context.dataPath.replace(/\['?(.*?)'?\]/g, (_, segment) => `/${segment}`); | ||
visibilityByPath.set(normalizedPath, visibility); | ||
@@ -249,2 +251,9 @@ } | ||
}); | ||
for (const schema of schemas) { | ||
try { | ||
ajv2.compile(schema.value); | ||
} catch (error) { | ||
throw new Error(`Schema at ${schema.path} is invalid, ${error}`); | ||
} | ||
} | ||
const merged = mergeAllOf__default['default']({allOf: schemas.map((_) => _.value)}, { | ||
@@ -343,3 +352,3 @@ ignoreAdditionalProperties: true, | ||
} | ||
await Promise.all(depNames.map((name2) => processItem({name: name2, parentPath: pkgPath}))); | ||
await Promise.all(depNames.map((depName) => processItem({name: depName, parentPath: pkgPath}))); | ||
} | ||
@@ -405,3 +414,3 @@ await Promise.all(packageNames.map((name) => processItem({name}))); | ||
for (const [index, value] of jsonVal.entries()) { | ||
const out = transform(value, `${path}.${index}`); | ||
const out = transform(value, `${path}/${index}`); | ||
if (out !== void 0) { | ||
@@ -422,3 +431,3 @@ arr.push(out); | ||
} | ||
const out = transform(value, `${path}.${key}`); | ||
const out = transform(value, `${path}/${key}`); | ||
if (out !== void 0) { | ||
@@ -425,0 +434,0 @@ outObj[key] = out; |
@@ -215,6 +215,8 @@ import yaml2 from 'yaml'; | ||
allErrors: true, | ||
allowUnionTypes: true, | ||
schemas: { | ||
"https://backstage.io/schema/config-v1": true | ||
} | ||
}).addKeyword("visibility", { | ||
}).addKeyword({ | ||
keyword: "visibility", | ||
metaSchema: { | ||
@@ -225,8 +227,8 @@ type: "string", | ||
compile(visibility) { | ||
return (_data, dataPath) => { | ||
if (!dataPath) { | ||
return (_data, context) => { | ||
if ((context == null ? void 0 : context.dataPath) === void 0) { | ||
return false; | ||
} | ||
if (visibility && visibility !== "backend") { | ||
const normalizedPath = dataPath.replace(/\['?(.*?)'?\]/g, (_, segment) => `.${segment}`); | ||
const normalizedPath = context.dataPath.replace(/\['?(.*?)'?\]/g, (_, segment) => `/${segment}`); | ||
visibilityByPath.set(normalizedPath, visibility); | ||
@@ -238,2 +240,9 @@ } | ||
}); | ||
for (const schema of schemas) { | ||
try { | ||
ajv2.compile(schema.value); | ||
} catch (error) { | ||
throw new Error(`Schema at ${schema.path} is invalid, ${error}`); | ||
} | ||
} | ||
const merged = mergeAllOf({allOf: schemas.map((_) => _.value)}, { | ||
@@ -332,3 +341,3 @@ ignoreAdditionalProperties: true, | ||
} | ||
await Promise.all(depNames.map((name2) => processItem({name: name2, parentPath: pkgPath}))); | ||
await Promise.all(depNames.map((depName) => processItem({name: depName, parentPath: pkgPath}))); | ||
} | ||
@@ -394,3 +403,3 @@ await Promise.all(packageNames.map((name) => processItem({name}))); | ||
for (const [index, value] of jsonVal.entries()) { | ||
const out = transform(value, `${path}.${index}`); | ||
const out = transform(value, `${path}/${index}`); | ||
if (out !== void 0) { | ||
@@ -411,3 +420,3 @@ arr.push(out); | ||
} | ||
const out = transform(value, `${path}.${key}`); | ||
const out = transform(value, `${path}/${key}`); | ||
if (out !== void 0) { | ||
@@ -414,0 +423,0 @@ outObj[key] = out; |
{ | ||
"name": "@backstage/config-loader", | ||
"description": "Config loading functionality used by Backstage backend, and CLI", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"private": false, | ||
@@ -35,3 +35,3 @@ "publishConfig": { | ||
"@backstage/config": "^0.1.1", | ||
"ajv": "^6.12.5", | ||
"ajv": "^7.0.3", | ||
"fs-extra": "^9.0.0", | ||
@@ -56,4 +56,3 @@ "json-schema": "^0.2.5", | ||
], | ||
"gitHead": "4ff4ba2e7ea872d68f8c233d577182a84c894093", | ||
"module": "dist/index.esm.js" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1081
128326
8
+ Addedajv@7.2.4(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
- Removedajv@6.12.6(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
Updatedajv@^7.0.3