@backstage/config-loader
Advanced tools
Comparing version 0.1.1-alpha.9 to 0.1.1-alpha.10
@@ -56,3 +56,3 @@ 'use strict'; | ||
const config2 = yaml2.parse(configYaml); | ||
async function transform(obj, path) { | ||
async function transform(obj, path2) { | ||
if (typeof obj !== "object") { | ||
@@ -65,3 +65,3 @@ return obj; | ||
for (const [index, value] of obj.entries()) { | ||
const out2 = await transform(value, `${path}[${index}]`); | ||
const out2 = await transform(value, `${path2}[${index}]`); | ||
if (out2 !== void 0) { | ||
@@ -75,3 +75,3 @@ arr.push(out2); | ||
if (!isObject(obj.$secret)) { | ||
throw TypeError(`Expected object at secret ${path}.$secret`); | ||
throw TypeError(`Expected object at secret ${path2}.$secret`); | ||
} | ||
@@ -81,3 +81,3 @@ try { | ||
} catch (error) { | ||
throw new Error(`Invalid secret at ${path}: ${error.message}`); | ||
throw new Error(`Invalid secret at ${path2}: ${error.message}`); | ||
} | ||
@@ -87,5 +87,7 @@ } | ||
for (const [key, value] of Object.entries(obj)) { | ||
const result = await transform(value, `${path}.${key}`); | ||
if (result !== void 0) { | ||
out[key] = result; | ||
if (value !== void 0) { | ||
const result = await transform(value, `${path2}.${key}`); | ||
if (result !== void 0) { | ||
out[key] = result; | ||
} | ||
} | ||
@@ -99,3 +101,3 @@ } | ||
} | ||
return finalConfig; | ||
return {data: finalConfig, context: path.basename(filePath)}; | ||
} | ||
@@ -107,3 +109,3 @@ | ||
var _a; | ||
let config2 = void 0; | ||
let data = void 0; | ||
for (const [name, value] of Object.entries(env)) { | ||
@@ -116,3 +118,3 @@ if (!value) { | ||
const keyParts = key.split("_"); | ||
let obj = config2 = config2 != null ? config2 : {}; | ||
let obj = data = data != null ? data : {}; | ||
for (const [index, part] of keyParts.entries()) { | ||
@@ -145,3 +147,3 @@ if (!CONFIG_KEY_PART_PATTERN.test(part)) { | ||
} | ||
return config2 ? [config2] : []; | ||
return data ? [{data, context: "env"}] : []; | ||
} | ||
@@ -148,0 +150,0 @@ |
import fs from 'fs-extra'; | ||
import { resolve, dirname, extname } from 'path'; | ||
import { resolve, dirname, basename, extname } from 'path'; | ||
import yaml2 from 'yaml'; | ||
@@ -50,3 +50,3 @@ import { object, string, lazy, array, ValidationError } from 'yup'; | ||
const config2 = yaml2.parse(configYaml); | ||
async function transform(obj, path) { | ||
async function transform(obj, path2) { | ||
if (typeof obj !== "object") { | ||
@@ -59,3 +59,3 @@ return obj; | ||
for (const [index, value] of obj.entries()) { | ||
const out2 = await transform(value, `${path}[${index}]`); | ||
const out2 = await transform(value, `${path2}[${index}]`); | ||
if (out2 !== void 0) { | ||
@@ -69,3 +69,3 @@ arr.push(out2); | ||
if (!isObject(obj.$secret)) { | ||
throw TypeError(`Expected object at secret ${path}.$secret`); | ||
throw TypeError(`Expected object at secret ${path2}.$secret`); | ||
} | ||
@@ -75,3 +75,3 @@ try { | ||
} catch (error) { | ||
throw new Error(`Invalid secret at ${path}: ${error.message}`); | ||
throw new Error(`Invalid secret at ${path2}: ${error.message}`); | ||
} | ||
@@ -81,5 +81,7 @@ } | ||
for (const [key, value] of Object.entries(obj)) { | ||
const result = await transform(value, `${path}.${key}`); | ||
if (result !== void 0) { | ||
out[key] = result; | ||
if (value !== void 0) { | ||
const result = await transform(value, `${path2}.${key}`); | ||
if (result !== void 0) { | ||
out[key] = result; | ||
} | ||
} | ||
@@ -93,3 +95,3 @@ } | ||
} | ||
return finalConfig; | ||
return {data: finalConfig, context: basename(filePath)}; | ||
} | ||
@@ -101,3 +103,3 @@ | ||
var _a; | ||
let config2 = void 0; | ||
let data = void 0; | ||
for (const [name, value] of Object.entries(env)) { | ||
@@ -110,3 +112,3 @@ if (!value) { | ||
const keyParts = key.split("_"); | ||
let obj = config2 = config2 != null ? config2 : {}; | ||
let obj = data = data != null ? data : {}; | ||
for (const [index, part] of keyParts.entries()) { | ||
@@ -139,3 +141,3 @@ if (!CONFIG_KEY_PART_PATTERN.test(part)) { | ||
} | ||
return config2 ? [config2] : []; | ||
return data ? [{data, context: "env"}] : []; | ||
} | ||
@@ -142,0 +144,0 @@ |
{ | ||
"name": "@backstage/config-loader", | ||
"description": "Config loading functionality used by Backstage backend, and CLI", | ||
"version": "0.1.1-alpha.9", | ||
"version": "0.1.1-alpha.10", | ||
"private": false, | ||
@@ -33,3 +33,3 @@ "publishConfig": { | ||
"dependencies": { | ||
"@backstage/config": "^0.1.1-alpha.7", | ||
"@backstage/config": "^0.1.1-alpha.10", | ||
"fs-extra": "^9.0.0", | ||
@@ -47,4 +47,4 @@ "yaml": "^1.9.2", | ||
], | ||
"gitHead": "89168d4d367e89017eb8992bef0db5b2c6317371", | ||
"gitHead": "1253f82057eeb5f59b4e7c9a1f5a186a0b3c229f", | ||
"module": "dist/index.esm.js" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27633
466
0
46