@backstage/plugin-app-backend 0.3.34 → 0.3.36-next.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,29 @@
1
1
  # @backstage/plugin-app-backend
2
2
 
3
+ ## 0.3.36-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
8
+ - 8872cc735d: Fixed a bug where the database option to skip migrations was ignored.
9
+ - Updated dependencies
10
+ - @backstage/backend-common@0.15.1-next.0
11
+ - @backstage/config-loader@1.1.4-next.0
12
+
13
+ ## 0.3.35
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @backstage/backend-common@0.15.0
19
+
20
+ ## 0.3.35-next.0
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+ - @backstage/backend-common@0.15.0-next.0
26
+
3
27
  ## 0.3.34
4
28
 
5
29
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -33,12 +33,18 @@ async function injectConfig(options) {
33
33
  const content = await fs__default["default"].readFile(path$1, "utf8");
34
34
  if (content.includes("__APP_INJECTED_RUNTIME_CONFIG__")) {
35
35
  logger.info(`Injecting env config into ${jsFile}`);
36
- const newContent = content.replace('"__APP_INJECTED_RUNTIME_CONFIG__"', injected);
36
+ const newContent = content.replace(
37
+ '"__APP_INJECTED_RUNTIME_CONFIG__"',
38
+ injected
39
+ );
37
40
  await fs__default["default"].writeFile(path$1, newContent, "utf8");
38
41
  return;
39
42
  } else if (content.includes("__APP_INJECTED_CONFIG_MARKER__")) {
40
43
  logger.info(`Replacing injected env config in ${jsFile}`);
41
- const newContent = content.replace(/\/\*__APP_INJECTED_CONFIG_MARKER__\*\/.*\/\*__INJECTED_END__\*\//, injected);
44
+ const newContent = content.replace(
45
+ /\/\*__APP_INJECTED_CONFIG_MARKER__\*\/.*\/\*__INJECTED_END__\*\//,
46
+ injected
47
+ );
42
48
  await fs__default["default"].writeFile(path$1, newContent, "utf8");
43
49
  return;
44
50
  }
@@ -53,10 +59,15 @@ async function readConfigs(options) {
53
59
  const serializedSchema = await fs__default["default"].readJson(schemaPath);
54
60
  try {
55
61
  const schema = await configLoader.loadConfigSchema({ serialized: serializedSchema });
56
- const frontendConfigs = await schema.process([{ data: config.get(), context: "app" }], { visibility: ["frontend"], withDeprecatedKeys: true });
62
+ const frontendConfigs = await schema.process(
63
+ [{ data: config.get(), context: "app" }],
64
+ { visibility: ["frontend"], withDeprecatedKeys: true }
65
+ );
57
66
  appConfigs.push(...frontendConfigs);
58
67
  } catch (error) {
59
- throw new Error(`Invalid app bundle schema. If this error is unexpected you need to run \`yarn build\` in the app. If that doesn't help you should make sure your config schema is correct and rebuild the app bundle again. Caused by the following schema error, ${error}`);
68
+ throw new Error(
69
+ `Invalid app bundle schema. If this error is unexpected you need to run \`yarn build\` in the app. If that doesn't help you should make sure your config schema is correct and rebuild the app bundle again. Caused by the following schema error, ${error}`
70
+ );
60
71
  }
61
72
  }
62
73
  return appConfigs;
@@ -81,28 +92,47 @@ var __privateSet = (obj, member, value, setter) => {
81
92
  return value;
82
93
  };
83
94
  var _db, _logger;
84
- const migrationsDir = backendCommon.resolvePackagePath("@backstage/plugin-app-backend", "migrations");
95
+ const migrationsDir = backendCommon.resolvePackagePath(
96
+ "@backstage/plugin-app-backend",
97
+ "migrations"
98
+ );
85
99
  const _StaticAssetsStore = class {
86
- constructor(options) {
100
+ constructor(client, logger) {
87
101
  __privateAdd(this, _db, void 0);
88
102
  __privateAdd(this, _logger, void 0);
89
- __privateSet(this, _db, options.database);
90
- __privateSet(this, _logger, options.logger);
103
+ __privateSet(this, _db, client);
104
+ __privateSet(this, _logger, logger);
91
105
  }
92
106
  static async create(options) {
93
- await options.database.migrate.latest({
94
- directory: migrationsDir
95
- });
96
- return new _StaticAssetsStore(options);
107
+ var _a;
108
+ const { database } = options;
109
+ const client = await database.getClient();
110
+ if (!((_a = database.migrations) == null ? void 0 : _a.skip)) {
111
+ await client.migrate.latest({
112
+ directory: migrationsDir
113
+ });
114
+ }
115
+ return new _StaticAssetsStore(client, options.logger);
97
116
  }
98
117
  async storeAssets(assets) {
99
- const existingRows = await __privateGet(this, _db).call(this, "static_assets_cache").whereIn("path", assets.map((a) => a.path));
118
+ const existingRows = await __privateGet(this, _db).call(this, "static_assets_cache").whereIn(
119
+ "path",
120
+ assets.map((a) => a.path)
121
+ );
100
122
  const existingAssetPaths = new Set(existingRows.map((r) => r.path));
101
- const [modified, added] = partition__default["default"](assets, (asset) => existingAssetPaths.has(asset.path));
102
- __privateGet(this, _logger).info(`Storing ${modified.length} updated assets and ${added.length} new assets`);
123
+ const [modified, added] = partition__default["default"](
124
+ assets,
125
+ (asset) => existingAssetPaths.has(asset.path)
126
+ );
127
+ __privateGet(this, _logger).info(
128
+ `Storing ${modified.length} updated assets and ${added.length} new assets`
129
+ );
103
130
  await __privateGet(this, _db).call(this, "static_assets_cache").update({
104
131
  last_modified_at: __privateGet(this, _db).fn.now()
105
- }).whereIn("path", modified.map((a) => a.path));
132
+ }).whereIn(
133
+ "path",
134
+ modified.map((a) => a.path)
135
+ );
106
136
  for (const asset of added) {
107
137
  await __privateGet(this, _db).call(this, "static_assets_cache").insert({
108
138
  path: asset.path,
@@ -125,7 +155,11 @@ const _StaticAssetsStore = class {
125
155
  }
126
156
  async trimAssets(options) {
127
157
  const { maxAgeSeconds } = options;
128
- await __privateGet(this, _db).call(this, "static_assets_cache").where("last_modified_at", "<=", __privateGet(this, _db).client.config.client.includes("sqlite3") ? __privateGet(this, _db).raw(`datetime('now', ?)`, [`-${maxAgeSeconds} seconds`]) : __privateGet(this, _db).raw(`now() + interval '${-maxAgeSeconds} seconds'`)).delete();
158
+ await __privateGet(this, _db).call(this, "static_assets_cache").where(
159
+ "last_modified_at",
160
+ "<=",
161
+ __privateGet(this, _db).client.config.client.includes("sqlite3") ? __privateGet(this, _db).raw(`datetime('now', ?)`, [`-${maxAgeSeconds} seconds`]) : __privateGet(this, _db).raw(`now() + interval '${-maxAgeSeconds} seconds'`)
162
+ ).delete();
129
163
  }
130
164
  };
131
165
  let StaticAssetsStore = _StaticAssetsStore;
@@ -153,23 +187,25 @@ function createStaticAssetMiddleware(store) {
153
187
  next();
154
188
  return;
155
189
  }
156
- Promise.resolve((async () => {
157
- const path$1 = req.path.startsWith("/") ? req.path.slice(1) : req.path;
158
- const asset = await store.getAsset(path$1);
159
- if (!asset) {
160
- next();
161
- return;
162
- }
163
- const ext = path.extname(asset.path);
164
- if (ext) {
165
- res.type(ext);
166
- } else {
167
- res.type("bin");
168
- }
169
- res.setHeader("Cache-Control", CACHE_CONTROL_MAX_CACHE);
170
- res.setHeader("Last-Modified", asset.lastModifiedAt.toUTCString());
171
- res.send(asset.content);
172
- })()).catch(next);
190
+ Promise.resolve(
191
+ (async () => {
192
+ const path$1 = req.path.startsWith("/") ? req.path.slice(1) : req.path;
193
+ const asset = await store.getAsset(path$1);
194
+ if (!asset) {
195
+ next();
196
+ return;
197
+ }
198
+ const ext = path.extname(asset.path);
199
+ if (ext) {
200
+ res.type(ext);
201
+ } else {
202
+ res.type("bin");
203
+ }
204
+ res.setHeader("Cache-Control", CACHE_CONTROL_MAX_CACHE);
205
+ res.setHeader("Last-Modified", asset.lastModifiedAt.toUTCString());
206
+ res.send(asset.content);
207
+ })()
208
+ ).catch(next);
173
209
  };
174
210
  }
175
211
 
@@ -178,7 +214,9 @@ async function createRouter(options) {
178
214
  const appDistDir = backendCommon.resolvePackagePath(appPackageName, "dist");
179
215
  const staticDir = path.resolve(appDistDir, "static");
180
216
  if (!await fs__default["default"].pathExists(staticDir)) {
181
- logger.warn(`Can't serve static app content from ${staticDir}, directory doesn't exist`);
217
+ logger.warn(
218
+ `Can't serve static app content from ${staticDir}, directory doesn't exist`
219
+ );
182
220
  return Router__default["default"]();
183
221
  }
184
222
  logger.info(`Serving static app content from ${appDistDir}`);
@@ -193,15 +231,17 @@ async function createRouter(options) {
193
231
  const router = Router__default["default"]();
194
232
  router.use(helmet__default["default"].frameguard({ action: "deny" }));
195
233
  const staticRouter = Router__default["default"]();
196
- staticRouter.use(express__default["default"].static(path.resolve(appDistDir, "static"), {
197
- setHeaders: (res) => {
198
- res.setHeader("Cache-Control", CACHE_CONTROL_MAX_CACHE);
199
- }
200
- }));
234
+ staticRouter.use(
235
+ express__default["default"].static(path.resolve(appDistDir, "static"), {
236
+ setHeaders: (res) => {
237
+ res.setHeader("Cache-Control", CACHE_CONTROL_MAX_CACHE);
238
+ }
239
+ })
240
+ );
201
241
  if (options.database) {
202
242
  const store = await StaticAssetsStore.create({
203
243
  logger,
204
- database: await options.database.getClient()
244
+ database: options.database
205
245
  });
206
246
  const assets = await findStaticAssets(staticDir);
207
247
  await store.storeAssets(assets);
@@ -213,13 +253,15 @@ async function createRouter(options) {
213
253
  }
214
254
  staticRouter.use(backendCommon.notFoundHandler());
215
255
  router.use("/static", staticRouter);
216
- router.use(express__default["default"].static(appDistDir, {
217
- setHeaders: (res, path) => {
218
- if (express__default["default"].static.mime.lookup(path) === "text/html") {
219
- res.setHeader("Cache-Control", CACHE_CONTROL_NO_CACHE);
256
+ router.use(
257
+ express__default["default"].static(appDistDir, {
258
+ setHeaders: (res, path) => {
259
+ if (express__default["default"].static.mime.lookup(path) === "text/html") {
260
+ res.setHeader("Cache-Control", CACHE_CONTROL_NO_CACHE);
261
+ }
220
262
  }
221
- }
222
- }));
263
+ })
264
+ );
223
265
  router.get("/*", (_req, res) => {
224
266
  res.sendFile(path.resolve(appDistDir, "index.html"), {
225
267
  headers: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/lib/config.ts","../src/lib/assets/StaticAssetsStore.ts","../src/lib/assets/findStaticAssets.ts","../src/lib/headers.ts","../src/lib/assets/createStaticAssetMiddleware.ts","../src/service/router.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 fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { Logger } from 'winston';\nimport { AppConfig, Config } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport { loadConfigSchema, readEnvConfig } from '@backstage/config-loader';\n\ntype InjectOptions = {\n appConfigs: AppConfig[];\n // Directory of the static JS files to search for file to inject\n staticDir: string;\n logger: Logger;\n};\n\n/**\n * Injects configs into the app bundle, replacing any existing injected config.\n */\nexport async function injectConfig(options: InjectOptions) {\n const { staticDir, logger, appConfigs } = options;\n\n const files = await fs.readdir(staticDir);\n const jsFiles = files.filter(file => file.endsWith('.js'));\n\n const escapedData = JSON.stringify(appConfigs).replace(/(\"|'|\\\\)/g, '\\\\$1');\n const injected = `/*__APP_INJECTED_CONFIG_MARKER__*/\"${escapedData}\"/*__INJECTED_END__*/`;\n\n for (const jsFile of jsFiles) {\n const path = resolvePath(staticDir, jsFile);\n\n const content = await fs.readFile(path, 'utf8');\n if (content.includes('__APP_INJECTED_RUNTIME_CONFIG__')) {\n logger.info(`Injecting env config into ${jsFile}`);\n\n const newContent = content.replace(\n '\"__APP_INJECTED_RUNTIME_CONFIG__\"',\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return;\n } else if (content.includes('__APP_INJECTED_CONFIG_MARKER__')) {\n logger.info(`Replacing injected env config in ${jsFile}`);\n\n const newContent = content.replace(\n /\\/\\*__APP_INJECTED_CONFIG_MARKER__\\*\\/.*\\/\\*__INJECTED_END__\\*\\//,\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return;\n }\n }\n logger.info('Env config not injected');\n}\n\ntype ReadOptions = {\n env: { [name: string]: string | undefined };\n appDistDir: string;\n config: Config;\n};\n\n/**\n * Read config from environment and process the backend config using the\n * schema that is embedded in the frontend build.\n */\nexport async function readConfigs(options: ReadOptions): Promise<AppConfig[]> {\n const { env, appDistDir, config } = options;\n\n const appConfigs = readEnvConfig(env);\n\n const schemaPath = resolvePath(appDistDir, '.config-schema.json');\n if (await fs.pathExists(schemaPath)) {\n const serializedSchema = await fs.readJson(schemaPath);\n\n try {\n const schema = await loadConfigSchema({ serialized: serializedSchema });\n\n const frontendConfigs = await schema.process(\n [{ data: config.get() as JsonObject, context: 'app' }],\n { visibility: ['frontend'], withDeprecatedKeys: true },\n );\n appConfigs.push(...frontendConfigs);\n } catch (error) {\n throw new Error(\n 'Invalid app bundle schema. If this error is unexpected you need to run `yarn build` in the app. ' +\n `If that doesn't help you should make sure your config schema is correct and rebuild the app bundle again. ` +\n `Caused by the following schema error, ${error}`,\n );\n }\n }\n\n return appConfigs;\n}\n","/*\n * Copyright 2021 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 { resolvePackagePath } from '@backstage/backend-common';\nimport { Knex } from 'knex';\nimport { Logger } from 'winston';\nimport { DateTime } from 'luxon';\nimport partition from 'lodash/partition';\nimport { StaticAsset, StaticAssetInput, StaticAssetProvider } from './types';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-app-backend',\n 'migrations',\n);\n\ninterface StaticAssetRow {\n path: string;\n content: Buffer;\n last_modified_at: Date;\n}\n\n/** @internal */\nexport interface StaticAssetsStoreOptions {\n database: Knex;\n logger: Logger;\n}\n\n/**\n * A storage for static assets that are assumed to be immutable.\n *\n * @internal\n */\nexport class StaticAssetsStore implements StaticAssetProvider {\n #db: Knex;\n #logger: Logger;\n\n static async create(options: StaticAssetsStoreOptions) {\n await options.database.migrate.latest({\n directory: migrationsDir,\n });\n return new StaticAssetsStore(options);\n }\n\n private constructor(options: StaticAssetsStoreOptions) {\n this.#db = options.database;\n this.#logger = options.logger;\n }\n\n /**\n * Store the provided assets.\n *\n * If an asset for a given path already exists the modification time will be\n * updated, but the contents will not.\n */\n async storeAssets(assets: StaticAssetInput[]) {\n const existingRows = await this.#db<StaticAssetRow>(\n 'static_assets_cache',\n ).whereIn(\n 'path',\n assets.map(a => a.path),\n );\n const existingAssetPaths = new Set(existingRows.map(r => r.path));\n\n const [modified, added] = partition(assets, asset =>\n existingAssetPaths.has(asset.path),\n );\n\n this.#logger.info(\n `Storing ${modified.length} updated assets and ${added.length} new assets`,\n );\n\n await this.#db('static_assets_cache')\n .update({\n last_modified_at: this.#db.fn.now(),\n })\n .whereIn(\n 'path',\n modified.map(a => a.path),\n );\n\n for (const asset of added) {\n // We ignore conflicts with other nodes, it doesn't matter if someone else\n // added the same asset just before us.\n await this.#db('static_assets_cache')\n .insert({\n path: asset.path,\n content: await asset.content(),\n })\n .onConflict('path')\n .ignore();\n }\n }\n\n /**\n * Retrieve an asset from the store with the given path.\n */\n async getAsset(path: string): Promise<StaticAsset | undefined> {\n const [row] = await this.#db<StaticAssetRow>('static_assets_cache').where({\n path,\n });\n if (!row) {\n return undefined;\n }\n return {\n path: row.path,\n content: row.content,\n lastModifiedAt:\n typeof row.last_modified_at === 'string'\n ? DateTime.fromSQL(row.last_modified_at, { zone: 'UTC' }).toJSDate()\n : row.last_modified_at,\n };\n }\n\n /**\n * Delete any assets from the store whose modification time is older than the max age.\n */\n async trimAssets(options: { maxAgeSeconds: number }) {\n const { maxAgeSeconds } = options;\n await this.#db<StaticAssetRow>('static_assets_cache')\n .where(\n 'last_modified_at',\n '<=',\n this.#db.client.config.client.includes('sqlite3')\n ? this.#db.raw(`datetime('now', ?)`, [`-${maxAgeSeconds} seconds`])\n : this.#db.raw(`now() + interval '${-maxAgeSeconds} seconds'`),\n )\n .delete();\n }\n}\n","/*\n * Copyright 2021 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 globby from 'globby';\nimport { StaticAssetInput } from './types';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\n\n/**\n * Finds all static assets within a directory\n *\n * @internal\n */\nexport async function findStaticAssets(\n staticDir: string,\n): Promise<StaticAssetInput[]> {\n const assetPaths = await globby('**/*', {\n ignore: ['**/*.map'], // Ignore source maps since they're quite large\n cwd: staticDir,\n dot: true,\n });\n\n return assetPaths.map(path => ({\n path,\n content: async () => fs.readFile(resolveSafeChildPath(staticDir, path)),\n }));\n}\n","/*\n * Copyright 2021 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\nexport const CACHE_CONTROL_NO_CACHE = 'no-store, max-age=0';\nexport const CACHE_CONTROL_MAX_CACHE = 'public, max-age=1209600'; // 14 days\n","/*\n * Copyright 2021 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 { extname } from 'path';\nimport { RequestHandler } from 'express';\nimport { StaticAssetProvider } from './types';\nimport { CACHE_CONTROL_MAX_CACHE } from '../headers';\n\n/**\n * Creates a middleware that serves static assets from a static asset provider\n *\n * @internal\n */\nexport function createStaticAssetMiddleware(\n store: StaticAssetProvider,\n): RequestHandler {\n return (req, res, next) => {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n next();\n return;\n }\n\n // Let's not assume we're in promise-router\n Promise.resolve(\n (async () => {\n // Drop leading slashes from the incoming path\n const path = req.path.startsWith('/') ? req.path.slice(1) : req.path;\n\n const asset = await store.getAsset(path);\n if (!asset) {\n next();\n return;\n }\n\n // Set the Content-Type header, falling back to octet-stream\n const ext = extname(asset.path);\n if (ext) {\n res.type(ext);\n } else {\n res.type('bin');\n }\n\n // Same as our express.static override\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n res.setHeader('Last-Modified', asset.lastModifiedAt.toUTCString());\n\n res.send(asset.content);\n })(),\n ).catch(next);\n };\n}\n","/*\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 {\n notFoundHandler,\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport { Config } from '@backstage/config';\nimport helmet from 'helmet';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { Logger } from 'winston';\nimport { injectConfig, readConfigs } from '../lib/config';\nimport {\n StaticAssetsStore,\n findStaticAssets,\n createStaticAssetMiddleware,\n} from '../lib/assets';\nimport {\n CACHE_CONTROL_MAX_CACHE,\n CACHE_CONTROL_NO_CACHE,\n} from '../lib/headers';\n\n// express uses mime v1 while we only have types for mime v2\ntype Mime = { lookup(arg0: string): string };\n\nexport interface RouterOptions {\n config: Config;\n logger: Logger;\n\n /**\n * If a database is provided it will be used to cache previously deployed static assets.\n *\n * This is a built-in alternative to using a `staticFallbackHandler`.\n */\n database?: PluginDatabaseManager;\n\n /**\n * The name of the app package that content should be served from. The same app package should be\n * added as a dependency to the backend package in order for it to be accessible at runtime.\n *\n * In a typical setup with a single app package this would be set to 'app'.\n */\n appPackageName: string;\n\n /**\n * A request handler to handle requests for static content that are not present in the app bundle.\n *\n * This can be used to avoid issues with clients on older deployment versions trying to access lazy\n * loaded content that is no longer present. Typically the requests would fall back to a long-term\n * object store where all recently deployed versions of the app are present.\n *\n * Another option is to provide a `database` that will take care of storing the static assets instead.\n *\n * If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve\n * static assets first, and if they are not found, the `staticFallbackHandler` will be called.\n */\n staticFallbackHandler?: express.Handler;\n\n /**\n * Disables the configuration injection. This can be useful if you're running in an environment\n * with a read-only filesystem, or for some other reason don't want configuration to be injected.\n *\n * Note that this will cause the configuration used when building the app bundle to be used, unless\n * a separate configuration loading strategy is set up.\n *\n * This also disables configuration injection though `APP_CONFIG_` environment variables.\n */\n disableConfigInjection?: boolean;\n}\n\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { config, logger, appPackageName, staticFallbackHandler } = options;\n\n const appDistDir = resolvePackagePath(appPackageName, 'dist');\n const staticDir = resolvePath(appDistDir, 'static');\n\n if (!(await fs.pathExists(staticDir))) {\n logger.warn(\n `Can't serve static app content from ${staticDir}, directory doesn't exist`,\n );\n\n return Router();\n }\n\n logger.info(`Serving static app content from ${appDistDir}`);\n\n if (!options.disableConfigInjection) {\n const appConfigs = await readConfigs({\n config,\n appDistDir,\n env: process.env,\n });\n\n await injectConfig({ appConfigs, logger, staticDir });\n }\n\n const router = Router();\n\n router.use(helmet.frameguard({ action: 'deny' }));\n\n // Use a separate router for static content so that a fallback can be provided by backend\n const staticRouter = Router();\n staticRouter.use(\n express.static(resolvePath(appDistDir, 'static'), {\n setHeaders: res => {\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n },\n }),\n );\n\n if (options.database) {\n const store = await StaticAssetsStore.create({\n logger,\n database: await options.database.getClient(),\n });\n\n const assets = await findStaticAssets(staticDir);\n await store.storeAssets(assets);\n // Remove any assets that are older than 7 days\n await store.trimAssets({ maxAgeSeconds: 60 * 60 * 24 * 7 });\n\n staticRouter.use(createStaticAssetMiddleware(store));\n }\n\n if (staticFallbackHandler) {\n staticRouter.use(staticFallbackHandler);\n }\n staticRouter.use(notFoundHandler());\n\n router.use('/static', staticRouter);\n router.use(\n express.static(appDistDir, {\n setHeaders: (res, path) => {\n // The Cache-Control header instructs the browser to not cache html files since it might\n // link to static assets from recently deployed versions.\n if (\n (express.static.mime as unknown as Mime).lookup(path) === 'text/html'\n ) {\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n }\n },\n }),\n );\n router.get('/*', (_req, res) => {\n res.sendFile(resolvePath(appDistDir, 'index.html'), {\n headers: {\n // The Cache-Control header instructs the browser to not cache the index.html since it might\n // link to static assets from recently deployed versions.\n 'cache-control': CACHE_CONTROL_NO_CACHE,\n },\n });\n });\n\n return router;\n}\n"],"names":["fs","path","resolvePath","readEnvConfig","loadConfigSchema","resolvePackagePath","partition","DateTime","globby","resolveSafeChildPath","extname","Router","helmet","express","notFoundHandler"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,eAAe,YAAY,CAAC,OAAO,EAAE;AAC5C,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,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AE,CAAC,GAAG,EAAE,IAAI,KAAK;AAC/B,MAAM,IAAIA,2BAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE;AAC5D,QAAQ,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC;AAC/D,OAAO;AACP,KAAK;AACL,GAAG,CAAC,CAAC,CAAC;AACN,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK;AAClC,IAAI,GAAG,CAAC,QAAQ,CAACX,YAAW,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE;AACxD,MAAM,OAAO,EAAE;AACf,QAAQ,eAAe,EAAE,sBAAsB;AAC/C,OAAO;AACP,KAAK,CAAC,CAAC;AACP,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/lib/config.ts","../src/lib/assets/StaticAssetsStore.ts","../src/lib/assets/findStaticAssets.ts","../src/lib/headers.ts","../src/lib/assets/createStaticAssetMiddleware.ts","../src/service/router.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 fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { Logger } from 'winston';\nimport { AppConfig, Config } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport { loadConfigSchema, readEnvConfig } from '@backstage/config-loader';\n\ntype InjectOptions = {\n appConfigs: AppConfig[];\n // Directory of the static JS files to search for file to inject\n staticDir: string;\n logger: Logger;\n};\n\n/**\n * Injects configs into the app bundle, replacing any existing injected config.\n */\nexport async function injectConfig(options: InjectOptions) {\n const { staticDir, logger, appConfigs } = options;\n\n const files = await fs.readdir(staticDir);\n const jsFiles = files.filter(file => file.endsWith('.js'));\n\n const escapedData = JSON.stringify(appConfigs).replace(/(\"|'|\\\\)/g, '\\\\$1');\n const injected = `/*__APP_INJECTED_CONFIG_MARKER__*/\"${escapedData}\"/*__INJECTED_END__*/`;\n\n for (const jsFile of jsFiles) {\n const path = resolvePath(staticDir, jsFile);\n\n const content = await fs.readFile(path, 'utf8');\n if (content.includes('__APP_INJECTED_RUNTIME_CONFIG__')) {\n logger.info(`Injecting env config into ${jsFile}`);\n\n const newContent = content.replace(\n '\"__APP_INJECTED_RUNTIME_CONFIG__\"',\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return;\n } else if (content.includes('__APP_INJECTED_CONFIG_MARKER__')) {\n logger.info(`Replacing injected env config in ${jsFile}`);\n\n const newContent = content.replace(\n /\\/\\*__APP_INJECTED_CONFIG_MARKER__\\*\\/.*\\/\\*__INJECTED_END__\\*\\//,\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return;\n }\n }\n logger.info('Env config not injected');\n}\n\ntype ReadOptions = {\n env: { [name: string]: string | undefined };\n appDistDir: string;\n config: Config;\n};\n\n/**\n * Read config from environment and process the backend config using the\n * schema that is embedded in the frontend build.\n */\nexport async function readConfigs(options: ReadOptions): Promise<AppConfig[]> {\n const { env, appDistDir, config } = options;\n\n const appConfigs = readEnvConfig(env);\n\n const schemaPath = resolvePath(appDistDir, '.config-schema.json');\n if (await fs.pathExists(schemaPath)) {\n const serializedSchema = await fs.readJson(schemaPath);\n\n try {\n const schema = await loadConfigSchema({ serialized: serializedSchema });\n\n const frontendConfigs = await schema.process(\n [{ data: config.get() as JsonObject, context: 'app' }],\n { visibility: ['frontend'], withDeprecatedKeys: true },\n );\n appConfigs.push(...frontendConfigs);\n } catch (error) {\n throw new Error(\n 'Invalid app bundle schema. If this error is unexpected you need to run `yarn build` in the app. ' +\n `If that doesn't help you should make sure your config schema is correct and rebuild the app bundle again. ` +\n `Caused by the following schema error, ${error}`,\n );\n }\n }\n\n return appConfigs;\n}\n","/*\n * Copyright 2021 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 {\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport { Knex } from 'knex';\nimport { Logger } from 'winston';\nimport { DateTime } from 'luxon';\nimport partition from 'lodash/partition';\nimport { StaticAsset, StaticAssetInput, StaticAssetProvider } from './types';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-app-backend',\n 'migrations',\n);\n\ninterface StaticAssetRow {\n path: string;\n content: Buffer;\n last_modified_at: Date;\n}\n\n/** @internal */\nexport interface StaticAssetsStoreOptions {\n database: PluginDatabaseManager;\n logger: Logger;\n}\n\n/**\n * A storage for static assets that are assumed to be immutable.\n *\n * @internal\n */\nexport class StaticAssetsStore implements StaticAssetProvider {\n #db: Knex;\n #logger: Logger;\n\n static async create(options: StaticAssetsStoreOptions) {\n const { database } = options;\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new StaticAssetsStore(client, options.logger);\n }\n\n private constructor(client: Knex, logger: Logger) {\n this.#db = client;\n this.#logger = logger;\n }\n\n /**\n * Store the provided assets.\n *\n * If an asset for a given path already exists the modification time will be\n * updated, but the contents will not.\n */\n async storeAssets(assets: StaticAssetInput[]) {\n const existingRows = await this.#db<StaticAssetRow>(\n 'static_assets_cache',\n ).whereIn(\n 'path',\n assets.map(a => a.path),\n );\n const existingAssetPaths = new Set(existingRows.map(r => r.path));\n\n const [modified, added] = partition(assets, asset =>\n existingAssetPaths.has(asset.path),\n );\n\n this.#logger.info(\n `Storing ${modified.length} updated assets and ${added.length} new assets`,\n );\n\n await this.#db('static_assets_cache')\n .update({\n last_modified_at: this.#db.fn.now(),\n })\n .whereIn(\n 'path',\n modified.map(a => a.path),\n );\n\n for (const asset of added) {\n // We ignore conflicts with other nodes, it doesn't matter if someone else\n // added the same asset just before us.\n await this.#db('static_assets_cache')\n .insert({\n path: asset.path,\n content: await asset.content(),\n })\n .onConflict('path')\n .ignore();\n }\n }\n\n /**\n * Retrieve an asset from the store with the given path.\n */\n async getAsset(path: string): Promise<StaticAsset | undefined> {\n const [row] = await this.#db<StaticAssetRow>('static_assets_cache').where({\n path,\n });\n if (!row) {\n return undefined;\n }\n return {\n path: row.path,\n content: row.content,\n lastModifiedAt:\n typeof row.last_modified_at === 'string'\n ? DateTime.fromSQL(row.last_modified_at, { zone: 'UTC' }).toJSDate()\n : row.last_modified_at,\n };\n }\n\n /**\n * Delete any assets from the store whose modification time is older than the max age.\n */\n async trimAssets(options: { maxAgeSeconds: number }) {\n const { maxAgeSeconds } = options;\n await this.#db<StaticAssetRow>('static_assets_cache')\n .where(\n 'last_modified_at',\n '<=',\n this.#db.client.config.client.includes('sqlite3')\n ? this.#db.raw(`datetime('now', ?)`, [`-${maxAgeSeconds} seconds`])\n : this.#db.raw(`now() + interval '${-maxAgeSeconds} seconds'`),\n )\n .delete();\n }\n}\n","/*\n * Copyright 2021 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 globby from 'globby';\nimport { StaticAssetInput } from './types';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\n\n/**\n * Finds all static assets within a directory\n *\n * @internal\n */\nexport async function findStaticAssets(\n staticDir: string,\n): Promise<StaticAssetInput[]> {\n const assetPaths = await globby('**/*', {\n ignore: ['**/*.map'], // Ignore source maps since they're quite large\n cwd: staticDir,\n dot: true,\n });\n\n return assetPaths.map(path => ({\n path,\n content: async () => fs.readFile(resolveSafeChildPath(staticDir, path)),\n }));\n}\n","/*\n * Copyright 2021 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\nexport const CACHE_CONTROL_NO_CACHE = 'no-store, max-age=0';\nexport const CACHE_CONTROL_MAX_CACHE = 'public, max-age=1209600'; // 14 days\n","/*\n * Copyright 2021 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 { extname } from 'path';\nimport { RequestHandler } from 'express';\nimport { StaticAssetProvider } from './types';\nimport { CACHE_CONTROL_MAX_CACHE } from '../headers';\n\n/**\n * Creates a middleware that serves static assets from a static asset provider\n *\n * @internal\n */\nexport function createStaticAssetMiddleware(\n store: StaticAssetProvider,\n): RequestHandler {\n return (req, res, next) => {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n next();\n return;\n }\n\n // Let's not assume we're in promise-router\n Promise.resolve(\n (async () => {\n // Drop leading slashes from the incoming path\n const path = req.path.startsWith('/') ? req.path.slice(1) : req.path;\n\n const asset = await store.getAsset(path);\n if (!asset) {\n next();\n return;\n }\n\n // Set the Content-Type header, falling back to octet-stream\n const ext = extname(asset.path);\n if (ext) {\n res.type(ext);\n } else {\n res.type('bin');\n }\n\n // Same as our express.static override\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n res.setHeader('Last-Modified', asset.lastModifiedAt.toUTCString());\n\n res.send(asset.content);\n })(),\n ).catch(next);\n };\n}\n","/*\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 {\n notFoundHandler,\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport { Config } from '@backstage/config';\nimport helmet from 'helmet';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { Logger } from 'winston';\nimport { injectConfig, readConfigs } from '../lib/config';\nimport {\n StaticAssetsStore,\n findStaticAssets,\n createStaticAssetMiddleware,\n} from '../lib/assets';\nimport {\n CACHE_CONTROL_MAX_CACHE,\n CACHE_CONTROL_NO_CACHE,\n} from '../lib/headers';\n\n// express uses mime v1 while we only have types for mime v2\ntype Mime = { lookup(arg0: string): string };\n\nexport interface RouterOptions {\n config: Config;\n logger: Logger;\n\n /**\n * If a database is provided it will be used to cache previously deployed static assets.\n *\n * This is a built-in alternative to using a `staticFallbackHandler`.\n */\n database?: PluginDatabaseManager;\n\n /**\n * The name of the app package that content should be served from. The same app package should be\n * added as a dependency to the backend package in order for it to be accessible at runtime.\n *\n * In a typical setup with a single app package this would be set to 'app'.\n */\n appPackageName: string;\n\n /**\n * A request handler to handle requests for static content that are not present in the app bundle.\n *\n * This can be used to avoid issues with clients on older deployment versions trying to access lazy\n * loaded content that is no longer present. Typically the requests would fall back to a long-term\n * object store where all recently deployed versions of the app are present.\n *\n * Another option is to provide a `database` that will take care of storing the static assets instead.\n *\n * If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve\n * static assets first, and if they are not found, the `staticFallbackHandler` will be called.\n */\n staticFallbackHandler?: express.Handler;\n\n /**\n * Disables the configuration injection. This can be useful if you're running in an environment\n * with a read-only filesystem, or for some other reason don't want configuration to be injected.\n *\n * Note that this will cause the configuration used when building the app bundle to be used, unless\n * a separate configuration loading strategy is set up.\n *\n * This also disables configuration injection though `APP_CONFIG_` environment variables.\n */\n disableConfigInjection?: boolean;\n}\n\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { config, logger, appPackageName, staticFallbackHandler } = options;\n\n const appDistDir = resolvePackagePath(appPackageName, 'dist');\n const staticDir = resolvePath(appDistDir, 'static');\n\n if (!(await fs.pathExists(staticDir))) {\n logger.warn(\n `Can't serve static app content from ${staticDir}, directory doesn't exist`,\n );\n\n return Router();\n }\n\n logger.info(`Serving static app content from ${appDistDir}`);\n\n if (!options.disableConfigInjection) {\n const appConfigs = await readConfigs({\n config,\n appDistDir,\n env: process.env,\n });\n\n await injectConfig({ appConfigs, logger, staticDir });\n }\n\n const router = Router();\n\n router.use(helmet.frameguard({ action: 'deny' }));\n\n // Use a separate router for static content so that a fallback can be provided by backend\n const staticRouter = Router();\n staticRouter.use(\n express.static(resolvePath(appDistDir, 'static'), {\n setHeaders: res => {\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n },\n }),\n );\n\n if (options.database) {\n const store = await StaticAssetsStore.create({\n logger,\n database: options.database,\n });\n\n const assets = await findStaticAssets(staticDir);\n await store.storeAssets(assets);\n // Remove any assets that are older than 7 days\n await store.trimAssets({ maxAgeSeconds: 60 * 60 * 24 * 7 });\n\n staticRouter.use(createStaticAssetMiddleware(store));\n }\n\n if (staticFallbackHandler) {\n staticRouter.use(staticFallbackHandler);\n }\n staticRouter.use(notFoundHandler());\n\n router.use('/static', staticRouter);\n router.use(\n express.static(appDistDir, {\n setHeaders: (res, path) => {\n // The Cache-Control header instructs the browser to not cache html files since it might\n // link to static assets from recently deployed versions.\n if (\n (express.static.mime as unknown as Mime).lookup(path) === 'text/html'\n ) {\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n }\n },\n }),\n );\n router.get('/*', (_req, res) => {\n res.sendFile(resolvePath(appDistDir, 'index.html'), {\n headers: {\n // The Cache-Control header instructs the browser to not cache the index.html since it might\n // link to static assets from recently deployed versions.\n 'cache-control': CACHE_CONTROL_NO_CACHE,\n },\n });\n });\n\n return router;\n}\n"],"names":["fs","path","resolvePath","readEnvConfig","loadConfigSchema","resolvePackagePath","partition","DateTime","globby","resolveSafeChildPath","extname","Router","helmet","express","notFoundHandler"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,eAAe,YAAY,CAAC,OAAO,EAAE;AAC5C,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;AACpD,EAAE,MAAM,KAAK,GAAG,MAAMA,sBAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5C,EAAE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/D,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAC9E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S,EAAE,YAAY,CAAC,CAAC;AACtC,EAAE,MAAM,CAAC,GAAG;AACZ,IAAID,2BAAO,CAAC,MAAM,CAAC,UAAU,EAAE;AAC/B,MAAM,UAAU,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK;AACjC,QAAQ,IAAIA,2BAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE;AAC9D,UAAU,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC;AACjE,SAAS;AACT,OAAO;AACP,KAAK,CAAC;AACN,GAAG,CAAC;AACJ,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK;AAClC,IAAI,GAAG,CAAC,QAAQ,CAACX,YAAW,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE;AACxD,MAAM,OAAO,EAAE;AACf,QAAQ,eAAe,EAAE,sBAAsB;AAC/C,OAAO;AACP,KAAK,CAAC,CAAC;AACP,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-app-backend",
3
3
  "description": "A Backstage backend plugin that serves the Backstage frontend app",
4
- "version": "0.3.34",
4
+ "version": "0.3.36-next.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -33,9 +33,9 @@
33
33
  "clean": "backstage-cli package clean"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/backend-common": "^0.14.1",
36
+ "@backstage/backend-common": "^0.15.1-next.0",
37
37
  "@backstage/config": "^1.0.1",
38
- "@backstage/config-loader": "^1.1.3",
38
+ "@backstage/config-loader": "^1.1.4-next.0",
39
39
  "@backstage/types": "^1.0.0",
40
40
  "@types/express": "^4.17.6",
41
41
  "express": "^4.17.1",
@@ -50,12 +50,12 @@
50
50
  "yn": "^4.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@backstage/backend-test-utils": "^0.1.26",
54
- "@backstage/cli": "^0.18.0",
53
+ "@backstage/backend-test-utils": "^0.1.28-next.0",
54
+ "@backstage/cli": "^0.18.2-next.0",
55
55
  "@backstage/types": "^1.0.0",
56
56
  "@types/supertest": "^2.0.8",
57
57
  "mock-fs": "^5.1.0",
58
- "msw": "^0.44.0",
58
+ "msw": "^0.45.0",
59
59
  "supertest": "^6.1.3"
60
60
  },
61
61
  "files": [
@@ -63,5 +63,5 @@
63
63
  "migrations/**/*.{js,d.ts}",
64
64
  "static"
65
65
  ],
66
- "gitHead": "999878d8f1ae30f6a15925816af2016cb9d717a1"
66
+ "gitHead": "c6c0b1978a7ab4d29d813996c56beb7e6b48a268"
67
67
  }