@backstage/config-loader 1.9.6 → 1.10.0
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
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @backstage/config-loader
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2fd73aa: The include transforms applied during config loading will now only apply to the known keys `$file`, `$env`, and `$include`. Any other key that begins with a `# @backstage/config-loader will now be passed through as is.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f422984: Added `@types/minimist` to `devDependencies`
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/cli-common@0.1.15
|
|
14
|
+
- @backstage/config@1.3.2
|
|
15
|
+
- @backstage/errors@1.2.7
|
|
16
|
+
- @backstage/types@1.2.1
|
|
17
|
+
|
|
18
|
+
## 1.10.0-next.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 2fd73aa: The include transforms applied during config loading will now only apply to the known keys `$file`, `$env`, and `$include`. Any other key that begins with a `# @backstage/config-loader will now be passed through as is.
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/cli-common@0.1.15
|
|
28
|
+
- @backstage/config@1.3.2
|
|
29
|
+
- @backstage/errors@1.2.7
|
|
30
|
+
- @backstage/types@1.2.1
|
|
31
|
+
|
|
3
32
|
## 1.9.6
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
10
10
|
|
|
11
|
+
const INCLUDE_KEYS = ["$file", "$env", "$include"];
|
|
11
12
|
const includeFileParser = {
|
|
12
13
|
".json": async (content) => JSON.parse(content),
|
|
13
14
|
".yaml": async (content) => yaml__default.default.parse(content),
|
|
@@ -22,7 +23,9 @@ function createIncludeTransform(env, readFile, substitute) {
|
|
|
22
23
|
if (!utils.isObject(input)) {
|
|
23
24
|
return { applied: false };
|
|
24
25
|
}
|
|
25
|
-
const [includeKey] = Object.keys(input).filter(
|
|
26
|
+
const [includeKey] = Object.keys(input).filter(
|
|
27
|
+
(key) => INCLUDE_KEYS.includes(key)
|
|
28
|
+
);
|
|
26
29
|
if (includeKey) {
|
|
27
30
|
if (Object.keys(input).length !== 1) {
|
|
28
31
|
throw new Error(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"include.cjs.js","sources":["../../../src/sources/transform/include.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport yaml from 'yaml';\nimport { extname, dirname, resolve as resolvePath } from 'path';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport { isObject } from './utils';\nimport { TransformFunc, ReadFileFunc } from './types';\nimport { SubstitutionFunc } from '../types';\n\n// Parsers for each type of included file\nconst includeFileParser: {\n [ext in string]: (content: string) => Promise<JsonObject>;\n} = {\n '.json': async content => JSON.parse(content),\n '.yaml': async content => yaml.parse(content),\n '.yml': async content => yaml.parse(content),\n};\n\n/**\n * Transforms a include description into the actual included value.\n */\nexport function createIncludeTransform(\n env: SubstitutionFunc,\n readFile: ReadFileFunc,\n substitute: TransformFunc,\n): TransformFunc {\n return async (input, context) => {\n const { dir } = context;\n if (!dir) {\n throw new Error('Include transform requires a base directory');\n }\n if (!isObject(input)) {\n return { applied: false };\n }\n // Check if there's any key that starts with a '$', in that case we treat\n // this entire object as an include description.\n const [includeKey] = Object.keys(input).filter(key
|
|
1
|
+
{"version":3,"file":"include.cjs.js","sources":["../../../src/sources/transform/include.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport yaml from 'yaml';\nimport { extname, dirname, resolve as resolvePath } from 'path';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport { isObject } from './utils';\nimport { TransformFunc, ReadFileFunc } from './types';\nimport { SubstitutionFunc } from '../types';\n\nconst INCLUDE_KEYS = ['$file', '$env', '$include'];\n\n// Parsers for each type of included file\nconst includeFileParser: {\n [ext in string]: (content: string) => Promise<JsonObject>;\n} = {\n '.json': async content => JSON.parse(content),\n '.yaml': async content => yaml.parse(content),\n '.yml': async content => yaml.parse(content),\n};\n\n/**\n * Transforms a include description into the actual included value.\n */\nexport function createIncludeTransform(\n env: SubstitutionFunc,\n readFile: ReadFileFunc,\n substitute: TransformFunc,\n): TransformFunc {\n return async (input, context) => {\n const { dir } = context;\n if (!dir) {\n throw new Error('Include transform requires a base directory');\n }\n if (!isObject(input)) {\n return { applied: false };\n }\n // Check if there's any key that starts with a '$', in that case we treat\n // this entire object as an include description.\n const [includeKey] = Object.keys(input).filter(key =>\n INCLUDE_KEYS.includes(key),\n );\n if (includeKey) {\n if (Object.keys(input).length !== 1) {\n throw new Error(\n `include key ${includeKey} should not have adjacent keys`,\n );\n }\n } else {\n return { applied: false };\n }\n\n const rawIncludedValue = input[includeKey];\n if (typeof rawIncludedValue !== 'string') {\n throw new Error(`${includeKey} include value is not a string`);\n }\n\n const substituteResults = await substitute(rawIncludedValue, { dir });\n const includeValue = substituteResults.applied\n ? substituteResults.value\n : rawIncludedValue;\n\n // The second string check is needed for Typescript to know this is a string.\n if (includeValue === undefined || typeof includeValue !== 'string') {\n throw new Error(`${includeKey} substitution value was undefined`);\n }\n\n switch (includeKey) {\n case '$file':\n try {\n const value = await readFile(resolvePath(dir, includeValue));\n return { applied: true, value: value.trimEnd() };\n } catch (error) {\n throw new Error(`failed to read file ${includeValue}, ${error}`);\n }\n case '$env':\n try {\n return { applied: true, value: await env(includeValue) };\n } catch (error) {\n throw new Error(`failed to read env ${includeValue}, ${error}`);\n }\n\n case '$include': {\n const [filePath, dataPath] = includeValue.split(/#(.*)/);\n\n const ext = extname(filePath);\n const parser = includeFileParser[ext];\n if (!parser) {\n throw new Error(\n `no configuration parser available for included file ${filePath}`,\n );\n }\n\n const path = resolvePath(dir, filePath);\n const content = await readFile(path);\n const newDir = dirname(path);\n\n const parts = dataPath ? dataPath.split('.') : [];\n\n let value: JsonValue | undefined;\n try {\n value = await parser(content);\n } catch (error) {\n throw new Error(\n `failed to parse included file ${filePath}, ${error}`,\n );\n }\n\n // This bit handles selecting a subtree in the included file, if a path was provided after a #\n for (const [index, part] of parts.entries()) {\n if (!isObject(value)) {\n const errPath = parts.slice(0, index).join('.');\n throw new Error(\n `value at '${errPath}' in included file ${filePath} is not an object`,\n );\n }\n value = value[part];\n }\n\n if (typeof value === 'string') {\n const substituted = await substitute(value, { dir: newDir });\n if (substituted.applied) {\n value = substituted.value;\n }\n }\n\n return {\n applied: true,\n value,\n newDir: newDir !== dir ? newDir : undefined,\n };\n }\n\n default:\n throw new Error(`unknown include ${includeKey}`);\n }\n };\n}\n"],"names":["yaml","isObject","resolvePath","extname","path","dirname"],"mappings":";;;;;;;;;;AAuBA,MAAM,YAAe,GAAA,CAAC,OAAS,EAAA,MAAA,EAAQ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UACA,MAAA,EAAQ,MAAW,KAAA,GAAA,GAAM,MAAS,GAAA,KAAA;AAAA,SACpC;AAAA;AACF,MAEA;AACE,QAAA,MAAM,IAAI,KAAA,CAAM,CAAmB,gBAAA,EAAA,UAAU,CAAE,CAAA,CAAA;AAAA;AACnD,GACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/config-loader",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Config loading functionality used by Backstage backend, and CLI",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -53,18 +53,12 @@
|
|
|
53
53
|
"yaml": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@backstage/backend-test-utils": "^1.3.
|
|
57
|
-
"@backstage/cli": "^0.
|
|
56
|
+
"@backstage/backend-test-utils": "^1.3.1",
|
|
57
|
+
"@backstage/cli": "^0.31.0",
|
|
58
58
|
"@types/json-schema-merge-allof": "^0.6.0",
|
|
59
|
+
"@types/minimist": "^1.2.5",
|
|
59
60
|
"msw": "^1.0.0",
|
|
60
61
|
"zen-observable": "^0.10.0"
|
|
61
62
|
},
|
|
62
|
-
"typesVersions": {
|
|
63
|
-
"*": {
|
|
64
|
-
"index": [
|
|
65
|
-
"dist/index.d.ts"
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
63
|
"module": "dist/index.esm.js"
|
|
70
64
|
}
|