@backstage/plugin-app-backend 0.5.13-next.2 → 0.5.13
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,17 @@
|
|
|
1
1
|
# @backstage/plugin-app-backend
|
|
2
2
|
|
|
3
|
+
## 0.5.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.9.0
|
|
9
|
+
- @backstage/errors@1.3.0
|
|
10
|
+
- @backstage/plugin-auth-node@0.7.0
|
|
11
|
+
- @backstage/config-loader@1.10.10
|
|
12
|
+
- @backstage/config@1.3.7
|
|
13
|
+
- @backstage/plugin-app-node@0.1.44
|
|
14
|
+
|
|
3
15
|
## 0.5.13-next.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectConfigIntoHtml.cjs.js","sources":["../../../src/lib/config/injectConfigIntoHtml.ts"],"sourcesContent":["/*\n * Copyright 2024 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 fs from 'fs-extra';\nimport { resolve as resolvePath } from 'node:path';\nimport { InjectOptions } from './types';\nimport compileTemplate from 'lodash/template';\nimport { Config, ConfigReader } from '@backstage/config';\n\nconst HTML_TEMPLATE_NAME = 'index.html.tmpl';\n\n/** @internal */\nexport async function injectConfigIntoHtml(\n options: InjectOptions,\n): Promise<Buffer | undefined> {\n const { rootDir, appConfigs } = options;\n\n const templatePath = resolvePath(rootDir, HTML_TEMPLATE_NAME);\n\n if (!(await fs.exists(templatePath))) {\n return undefined;\n }\n\n const templateContent = await fs.readFile(\n resolvePath(rootDir, HTML_TEMPLATE_NAME),\n 'utf8',\n );\n\n const config = ConfigReader.fromConfigs(appConfigs);\n\n const templateSource = compileTemplate(templateContent, {\n interpolate: /<%=([\\s\\S]+?)%>/g,\n });\n\n const publicPath = resolvePublicPath(config);\n const indexHtmlContent = templateSource({\n config,\n publicPath,\n });\n\n const indexHtmlContentWithConfig = indexHtmlContent.replace(\n '</head>',\n `\n<script type=\"backstage.io/config\">\n${JSON.stringify(appConfigs, null, 2)\n // Note on the security aspects of this: We generally trust the app config to\n // be safe, since control of the app config effectively means full control of\n // the app. These substitutions are here as an extra precaution to avoid\n // unintentionally breaking the app, to avoid this being flagged, and in case\n // someone decides to hook up user input to the app config in their own setup.\n .replaceAll('</script', '')\n .replaceAll('<!--', '')}\n</script>\n</head>`,\n );\n\n return Buffer.from(indexHtmlContentWithConfig, 'utf8');\n}\n\
|
|
1
|
+
{"version":3,"file":"injectConfigIntoHtml.cjs.js","sources":["../../../src/lib/config/injectConfigIntoHtml.ts"],"sourcesContent":["/*\n * Copyright 2024 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 fs from 'fs-extra';\nimport { resolve as resolvePath } from 'node:path';\nimport { InjectOptions } from './types';\nimport compileTemplate from 'lodash/template';\nimport { Config, ConfigReader } from '@backstage/config';\n\nconst HTML_TEMPLATE_NAME = 'index.html.tmpl';\n\n/** @internal */\nexport async function injectConfigIntoHtml(\n options: InjectOptions,\n): Promise<Buffer | undefined> {\n const { rootDir, appConfigs } = options;\n\n const templatePath = resolvePath(rootDir, HTML_TEMPLATE_NAME);\n\n if (!(await fs.exists(templatePath))) {\n return undefined;\n }\n\n const templateContent = await fs.readFile(\n resolvePath(rootDir, HTML_TEMPLATE_NAME),\n 'utf8',\n );\n\n const config = ConfigReader.fromConfigs(appConfigs);\n\n const templateSource = compileTemplate(templateContent, {\n interpolate: /<%=([\\s\\S]+?)%>/g,\n });\n\n const publicPath = resolvePublicPath(config);\n const indexHtmlContent = templateSource({\n config,\n publicPath,\n });\n\n const indexHtmlContentWithConfig = indexHtmlContent.replace(\n '</head>',\n `\n<script type=\"backstage.io/config\">\n${JSON.stringify(appConfigs, null, 2)\n // Note on the security aspects of this: We generally trust the app config to\n // be safe, since control of the app config effectively means full control of\n // the app. These substitutions are here as an extra precaution to avoid\n // unintentionally breaking the app, to avoid this being flagged, and in case\n // someone decides to hook up user input to the app config in their own setup.\n .replaceAll('</script', '')\n .replaceAll('<!--', '')}\n</script>\n</head>`,\n );\n\n return Buffer.from(indexHtmlContentWithConfig, 'utf8');\n}\n\nfunction resolvePublicPath(config: Config) {\n const baseUrl = new URL(\n config.getOptionalString('app.baseUrl') ?? '/',\n 'http://localhost:7007',\n );\n return baseUrl.pathname.replace(/\\/+$/, '');\n}\n"],"names":["resolvePath","fs","config","ConfigReader","compileTemplate"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,kBAAA,GAAqB,iBAAA;AAG3B,eAAsB,qBACpB,OAAA,EAC6B;AAC7B,EAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAW,GAAI,OAAA;AAEhC,EAAA,MAAM,YAAA,GAAeA,iBAAA,CAAY,OAAA,EAAS,kBAAkB,CAAA;AAE5D,EAAA,IAAI,CAAE,MAAMC,mBAAA,CAAG,MAAA,CAAO,YAAY,CAAA,EAAI;AACpC,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,eAAA,GAAkB,MAAMA,mBAAA,CAAG,QAAA;AAAA,IAC/BD,iBAAA,CAAY,SAAS,kBAAkB,CAAA;AAAA,IACvC;AAAA,GACF;AAEA,EAAA,MAAME,QAAA,GAASC,mBAAA,CAAa,WAAA,CAAY,UAAU,CAAA;AAElD,EAAA,MAAM,cAAA,GAAiBC,iCAAgB,eAAA,EAAiB;AAAA,IACtD,WAAA,EAAa;AAAA,GACd,CAAA;AAED,EAAA,MAAM,UAAA,GAAa,kBAAkBF,QAAM,CAAA;AAC3C,EAAA,MAAM,mBAAmB,cAAA,CAAe;AAAA,YACtCA,QAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,6BAA6B,gBAAA,CAAiB,OAAA;AAAA,IAClD,SAAA;AAAA,IACA;AAAA;AAAA,EAEF,IAAA,CAAK,SAAA,CAAU,UAAA,EAAY,IAAA,EAAM,CAAC,CAAA,CAMjC,UAAA,CAAW,WAAA,EAAY,EAAE,CAAA,CACzB,UAAA,CAAW,MAAA,EAAQ,EAAE,CAAC;AAAA;AAAA,OAAA;AAAA,GAGvB;AAEA,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,0BAAA,EAA4B,MAAM,CAAA;AACvD;AAEA,SAAS,kBAAkB,MAAA,EAAgB;AACzC,EAAA,MAAM,UAAU,IAAI,GAAA;AAAA,IAClB,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA,IAAK,GAAA;AAAA,IAC3C;AAAA,GACF;AACA,EAAA,OAAO,OAAA,CAAQ,QAAA,CAAS,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AAC5C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-app-backend",
|
|
3
|
-
"version": "0.5.13
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "A Backstage backend plugin that serves the Backstage frontend app",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"test": "backstage-cli package test"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@backstage/backend-plugin-api": "1.9.0
|
|
66
|
-
"@backstage/config": "1.3.7
|
|
67
|
-
"@backstage/config-loader": "1.10.10
|
|
68
|
-
"@backstage/errors": "1.3.0
|
|
69
|
-
"@backstage/plugin-app-node": "0.1.44
|
|
70
|
-
"@backstage/plugin-auth-node": "0.7.0
|
|
71
|
-
"@backstage/types": "1.2.2",
|
|
65
|
+
"@backstage/backend-plugin-api": "^1.9.0",
|
|
66
|
+
"@backstage/config": "^1.3.7",
|
|
67
|
+
"@backstage/config-loader": "^1.10.10",
|
|
68
|
+
"@backstage/errors": "^1.3.0",
|
|
69
|
+
"@backstage/plugin-app-node": "^0.1.44",
|
|
70
|
+
"@backstage/plugin-auth-node": "^0.7.0",
|
|
71
|
+
"@backstage/types": "^1.2.2",
|
|
72
72
|
"express": "^4.22.0",
|
|
73
73
|
"express-promise-router": "^4.1.0",
|
|
74
74
|
"fs-extra": "^11.2.0",
|
|
@@ -80,11 +80,11 @@
|
|
|
80
80
|
"yn": "^4.0.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@backstage/backend-app-api": "1.6.1
|
|
84
|
-
"@backstage/backend-defaults": "0.
|
|
85
|
-
"@backstage/backend-test-utils": "1.11.2
|
|
86
|
-
"@backstage/cli": "0.36.1
|
|
87
|
-
"@backstage/types": "1.2.2",
|
|
83
|
+
"@backstage/backend-app-api": "^1.6.1",
|
|
84
|
+
"@backstage/backend-defaults": "^0.17.0",
|
|
85
|
+
"@backstage/backend-test-utils": "^1.11.2",
|
|
86
|
+
"@backstage/cli": "^0.36.1",
|
|
87
|
+
"@backstage/types": "^1.2.2",
|
|
88
88
|
"@types/express": "^4.17.6",
|
|
89
89
|
"@types/supertest": "^2.0.8",
|
|
90
90
|
"supertest": "^7.0.0"
|