@backstage/frontend-defaults 0.1.2-next.2 → 0.1.2

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/frontend-defaults
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 44b82da: The default config loader no longer requires `process.env.APP_CONFIG` to be set, allowing config to be read from other sources instead.
8
+ - Updated dependencies
9
+ - @backstage/config@1.3.0
10
+ - @backstage/errors@1.2.5
11
+ - @backstage/frontend-app-api@0.10.1
12
+ - @backstage/frontend-plugin-api@0.9.1
13
+ - @backstage/plugin-app@0.1.2
14
+
3
15
  ## 0.1.2-next.2
4
16
 
5
17
  ### Patch Changes
@@ -1,12 +1,12 @@
1
1
  function defaultConfigLoaderSync(runtimeConfigJson = "__APP_INJECTED_RUNTIME_CONFIG__") {
2
- const appConfig = process.env.APP_CONFIG;
3
- if (!appConfig) {
4
- throw new Error("No static configuration provided");
5
- }
6
- if (!Array.isArray(appConfig)) {
7
- throw new Error("Static configuration has invalid format");
2
+ const configs = new Array();
3
+ const staticConfig = process.env.APP_CONFIG;
4
+ if (staticConfig) {
5
+ if (!Array.isArray(staticConfig)) {
6
+ throw new Error("Static configuration has invalid format");
7
+ }
8
+ configs.push(...staticConfig);
8
9
  }
9
- const configs = appConfig.slice();
10
10
  const configScripts = document.querySelectorAll(
11
11
  'script[type="backstage.io/config"]'
12
12
  );
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfigLoader.esm.js","sources":["../../../../../core-app-api/src/app/defaultConfigLoader.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 { AppConfig } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport { AppConfigLoader } from './types';\n\n/**\n * The default config loader, which expects that config is available at compile-time\n * in `process.env.APP_CONFIG`. APP_CONFIG should be an array of config objects as\n * returned by the config loader.\n *\n * It will also load runtime config from the __APP_INJECTED_RUNTIME_CONFIG__ string,\n * which can be rewritten at runtime to contain an additional JSON config object.\n * If runtime config is present, it will be placed first in the config array, overriding\n * other config values.\n *\n * @public\n */\nexport const defaultConfigLoader: AppConfigLoader = async () =>\n defaultConfigLoaderSync();\n\n/** @internal */\nexport function defaultConfigLoaderSync(\n // This string may be replaced at runtime to provide additional config.\n // It should be replaced by a JSON-serialized config object.\n // It's a param so we can test it, but at runtime this will always fall back to default.\n runtimeConfigJson: string = '__APP_INJECTED_RUNTIME_CONFIG__',\n) {\n const appConfig = process.env.APP_CONFIG;\n if (!appConfig) {\n throw new Error('No static configuration provided');\n }\n if (!Array.isArray(appConfig)) {\n throw new Error('Static configuration has invalid format');\n }\n const configs = appConfig.slice() as unknown as AppConfig[];\n\n // Check if we have any config script tags, otherwise fall back to injected config\n const configScripts = document.querySelectorAll(\n 'script[type=\"backstage.io/config\"]',\n );\n if (configScripts.length > 0) {\n for (const el of configScripts) {\n try {\n const content = el.textContent;\n if (!content) {\n throw new Error('tag is empty');\n }\n let data;\n try {\n data = JSON.parse(content);\n } catch (error) {\n throw new Error(`failed to parse config; ${error}`);\n }\n if (!Array.isArray(data)) {\n throw new Error('data is not an array');\n }\n configs.push(...data);\n } catch (error) {\n throw new Error(\n `Failed to load config from script tag, ${error.message}`,\n );\n }\n }\n } else if (\n runtimeConfigJson !==\n // Avoiding this string also being replaced at runtime\n '__app_injected_runtime_config__'.toLocaleUpperCase('en-US')\n ) {\n try {\n const data = JSON.parse(runtimeConfigJson) as JsonObject;\n if (Array.isArray(data)) {\n configs.push(...data);\n } else {\n configs.push({ data, context: 'env' });\n }\n } catch (error) {\n throw new Error(`Failed to load runtime configuration, ${error}`);\n }\n }\n\n const windowAppConfig = (window as any).__APP_CONFIG__;\n if (windowAppConfig) {\n configs.push({\n context: 'window',\n data: windowAppConfig,\n });\n }\n return configs;\n}\n"],"names":[],"mappings":"AAoCgB,SAAA,uBAAA,CAId,oBAA4B,iCAC5B,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,UAAA;AAC9B,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA;AAAA;AAEpD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC7B,IAAM,MAAA,IAAI,MAAM,yCAAyC,CAAA;AAAA;AAE3D,EAAM,MAAA,OAAA,GAAU,UAAU,KAAM,EAAA;AAGhC,EAAA,MAAM,gBAAgB,QAAS,CAAA,gBAAA;AAAA,IAC7B;AAAA,GACF;AACA,EAAI,IAAA,aAAA,CAAc,SAAS,CAAG,EAAA;AAC5B,IAAA,KAAA,MAAW,MAAM,aAAe,EAAA;AAC9B,MAAI,IAAA;AACF,QAAA,MAAM,UAAU,EAAG,CAAA,WAAA;AACnB,QAAA,IAAI,CAAC,OAAS,EAAA;AACZ,UAAM,MAAA,IAAI,MAAM,cAAc,CAAA;AAAA;AAEhC,QAAI,IAAA,IAAA;AACJ,QAAI,IAAA;AACF,UAAO,IAAA,GAAA,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,iBAClB,KAAO,EAAA;AACd,UAAA,MAAM,IAAI,KAAA,CAAM,CAA2B,wBAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAEpD,QAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAG,EAAA;AACxB,UAAM,MAAA,IAAI,MAAM,sBAAsB,CAAA;AAAA;AAExC,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,eACb,KAAO,EAAA;AACd,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,uCAAA,EAA0C,MAAM,OAAO,CAAA;AAAA,SACzD;AAAA;AACF;AACF,GAEA,MAAA,IAAA,iBAAA;AAAA,EAEA,iCAAA,CAAkC,iBAAkB,CAAA,OAAO,CAC3D,EAAA;AACA,IAAI,IAAA;AACF,MAAM,MAAA,IAAA,GAAO,IAAK,CAAA,KAAA,CAAM,iBAAiB,CAAA;AACzC,MAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAG,EAAA;AACvB,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,OACf,MAAA;AACL,QAAA,OAAA,CAAQ,IAAK,CAAA,EAAE,IAAM,EAAA,OAAA,EAAS,OAAO,CAAA;AAAA;AACvC,aACO,KAAO,EAAA;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAyC,sCAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAClE;AAGF,EAAA,MAAM,kBAAmB,MAAe,CAAA,cAAA;AACxC,EAAA,IAAI,eAAiB,EAAA;AACnB,IAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,MACX,OAAS,EAAA,QAAA;AAAA,MACT,IAAM,EAAA;AAAA,KACP,CAAA;AAAA;AAEH,EAAO,OAAA,OAAA;AACT;;;;"}
1
+ {"version":3,"file":"defaultConfigLoader.esm.js","sources":["../../../../../core-app-api/src/app/defaultConfigLoader.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 { AppConfig } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport { AppConfigLoader } from './types';\n\n/**\n * The default config loader, which expects that config is available at compile-time\n * in `process.env.APP_CONFIG`. APP_CONFIG should be an array of config objects as\n * returned by the config loader.\n *\n * It will also load runtime config from the __APP_INJECTED_RUNTIME_CONFIG__ string,\n * which can be rewritten at runtime to contain an additional JSON config object.\n * If runtime config is present, it will be placed first in the config array, overriding\n * other config values.\n *\n * @public\n */\nexport const defaultConfigLoader: AppConfigLoader = async () =>\n defaultConfigLoaderSync();\n\n/** @internal */\nexport function defaultConfigLoaderSync(\n // This string may be replaced at runtime to provide additional config.\n // It should be replaced by a JSON-serialized config object.\n // It's a param so we can test it, but at runtime this will always fall back to default.\n runtimeConfigJson: string = '__APP_INJECTED_RUNTIME_CONFIG__',\n) {\n const configs = new Array<AppConfig>();\n\n const staticConfig = process.env.APP_CONFIG;\n if (staticConfig) {\n if (!Array.isArray(staticConfig)) {\n throw new Error('Static configuration has invalid format');\n }\n configs.push(...staticConfig);\n }\n\n // Check if we have any config script tags, otherwise fall back to injected config\n const configScripts = document.querySelectorAll(\n 'script[type=\"backstage.io/config\"]',\n );\n if (configScripts.length > 0) {\n for (const el of configScripts) {\n try {\n const content = el.textContent;\n if (!content) {\n throw new Error('tag is empty');\n }\n let data;\n try {\n data = JSON.parse(content);\n } catch (error) {\n throw new Error(`failed to parse config; ${error}`);\n }\n if (!Array.isArray(data)) {\n throw new Error('data is not an array');\n }\n configs.push(...data);\n } catch (error) {\n throw new Error(\n `Failed to load config from script tag, ${error.message}`,\n );\n }\n }\n } else if (\n runtimeConfigJson !==\n // Avoiding this string also being replaced at runtime\n '__app_injected_runtime_config__'.toLocaleUpperCase('en-US')\n ) {\n try {\n const data = JSON.parse(runtimeConfigJson) as JsonObject;\n if (Array.isArray(data)) {\n configs.push(...data);\n } else {\n configs.push({ data, context: 'env' });\n }\n } catch (error) {\n throw new Error(`Failed to load runtime configuration, ${error}`);\n }\n }\n\n const windowAppConfig = (window as any).__APP_CONFIG__;\n if (windowAppConfig) {\n configs.push({\n context: 'window',\n data: windowAppConfig,\n });\n }\n return configs;\n}\n"],"names":[],"mappings":"AAoCgB,SAAA,uBAAA,CAId,oBAA4B,iCAC5B,EAAA;AACA,EAAM,MAAA,OAAA,GAAU,IAAI,KAAiB,EAAA;AAErC,EAAM,MAAA,YAAA,GAAe,QAAQ,GAAI,CAAA,UAAA;AACjC,EAAA,IAAI,YAAc,EAAA;AAChB,IAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,YAAY,CAAG,EAAA;AAChC,MAAM,MAAA,IAAI,MAAM,yCAAyC,CAAA;AAAA;AAE3D,IAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,YAAY,CAAA;AAAA;AAI9B,EAAA,MAAM,gBAAgB,QAAS,CAAA,gBAAA;AAAA,IAC7B;AAAA,GACF;AACA,EAAI,IAAA,aAAA,CAAc,SAAS,CAAG,EAAA;AAC5B,IAAA,KAAA,MAAW,MAAM,aAAe,EAAA;AAC9B,MAAI,IAAA;AACF,QAAA,MAAM,UAAU,EAAG,CAAA,WAAA;AACnB,QAAA,IAAI,CAAC,OAAS,EAAA;AACZ,UAAM,MAAA,IAAI,MAAM,cAAc,CAAA;AAAA;AAEhC,QAAI,IAAA,IAAA;AACJ,QAAI,IAAA;AACF,UAAO,IAAA,GAAA,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,iBAClB,KAAO,EAAA;AACd,UAAA,MAAM,IAAI,KAAA,CAAM,CAA2B,wBAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAEpD,QAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAG,EAAA;AACxB,UAAM,MAAA,IAAI,MAAM,sBAAsB,CAAA;AAAA;AAExC,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,eACb,KAAO,EAAA;AACd,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,uCAAA,EAA0C,MAAM,OAAO,CAAA;AAAA,SACzD;AAAA;AACF;AACF,GAEA,MAAA,IAAA,iBAAA;AAAA,EAEA,iCAAA,CAAkC,iBAAkB,CAAA,OAAO,CAC3D,EAAA;AACA,IAAI,IAAA;AACF,MAAM,MAAA,IAAA,GAAO,IAAK,CAAA,KAAA,CAAM,iBAAiB,CAAA;AACzC,MAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAG,EAAA;AACvB,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,OACf,MAAA;AACL,QAAA,OAAA,CAAQ,IAAK,CAAA,EAAE,IAAM,EAAA,OAAA,EAAS,OAAO,CAAA;AAAA;AACvC,aACO,KAAO,EAAA;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAyC,sCAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAClE;AAGF,EAAA,MAAM,kBAAmB,MAAe,CAAA,cAAA;AACxC,EAAA,IAAI,eAAiB,EAAA;AACnB,IAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,MACX,OAAS,EAAA,QAAA;AAAA,MACT,IAAM,EAAA;AAAA,KACP,CAAA;AAAA;AAEH,EAAO,OAAA,OAAA;AACT;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/frontend-defaults",
3
- "version": "0.1.2-next.2",
3
+ "version": "0.1.2",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -31,17 +31,17 @@
31
31
  "test": "backstage-cli package test"
32
32
  },
33
33
  "dependencies": {
34
- "@backstage/config": "1.2.0",
35
- "@backstage/errors": "1.2.4",
36
- "@backstage/frontend-app-api": "0.10.1-next.2",
37
- "@backstage/frontend-plugin-api": "0.9.1-next.2",
38
- "@backstage/plugin-app": "0.1.2-next.2",
34
+ "@backstage/config": "^1.3.0",
35
+ "@backstage/errors": "^1.2.5",
36
+ "@backstage/frontend-app-api": "^0.10.1",
37
+ "@backstage/frontend-plugin-api": "^0.9.1",
38
+ "@backstage/plugin-app": "^0.1.2",
39
39
  "@react-hookz/web": "^24.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@backstage/cli": "0.29.0-next.3",
43
- "@backstage/core-plugin-api": "1.10.0",
44
- "@backstage/test-utils": "1.7.1-next.0",
42
+ "@backstage/cli": "^0.29.0",
43
+ "@backstage/core-plugin-api": "^1.10.1",
44
+ "@backstage/test-utils": "^1.7.1",
45
45
  "@testing-library/jest-dom": "^6.0.0",
46
46
  "@testing-library/react": "^16.0.0",
47
47
  "@types/react": "^18.0.0",