Merge branch 'master' of github.com:spotify/backstage into mob/prepare-from-catalog

* 'master' of github.com:spotify/backstage: (60 commits)
  packages,plugins: remove main:src and fix some main fields
  packages/config: added get and getOptional
  changed  down caret to be up caret on user profile in the sidebar
  packages/config: add getOptionalConfig and getOptionalConfigArray to mirror other accessors
  packages/config-loader,core: update config usage to include context
  build(deps): bump @types/react from 16.9.25 to 16.9.37 (#1342)
  build(deps): bump rollup-plugin-esbuild from 2.0.0 to 2.1.0 (#1361)
  build(deps-dev): bump lint-staged from 10.2.9 to 10.2.11 (#1359)
  Polishing the Create page (#1353)
  Add some air between sidebar sections (#1355)
  Starred icon is yellow (#1351)
  Updated FAQ with Gitlab link (#1352)
  build(deps): bump react-helmet from 6.0.0 to 6.1.0 (#1327)
  packages/config: added context to keep track of where config is from for error messages
  packages/config: added .keys()
  packages/config: keep track of key prefix to display better error messages
  packages/config: optimize some error message handling
  packages/config: allow config readers to be backed by undefined data
  packages/config: flip around must* and get* to get* and getOptional*
  packages/core-api: fix invocation order when continuing to app after sign-in
  ...
This commit is contained in:
blam
2020-06-18 14:00:29 +02:00
108 changed files with 2045 additions and 1379 deletions
+11 -9
View File
@@ -1,6 +1,6 @@
{
"name": "example-backend",
"version": "0.1.1-alpha.8",
"version": "0.1.1-alpha.9",
"main": "dist/index.cjs.js",
"types": "src/index.ts",
"private": true,
@@ -17,20 +17,22 @@
"migrate:create": "knex migrate:make -x ts"
},
"dependencies": {
"@backstage/backend-common": "^0.1.1-alpha.8",
"@backstage/catalog-model": "^0.1.1-alpha.8",
"@backstage/plugin-auth-backend": "^0.1.1-alpha.8",
"@backstage/plugin-catalog-backend": "^0.1.1-alpha.8",
"@backstage/plugin-identity-backend": "^0.1.1-alpha.8",
"@backstage/plugin-scaffolder-backend": "^0.1.1-alpha.8",
"@backstage/plugin-sentry-backend": "^0.1.1-alpha.8",
"@backstage/backend-common": "^0.1.1-alpha.9",
"@backstage/catalog-model": "^0.1.1-alpha.9",
"@backstage/config": "^0.1.1-alpha.9",
"@backstage/config-loader": "^0.1.1-alpha.9",
"@backstage/plugin-auth-backend": "^0.1.1-alpha.9",
"@backstage/plugin-catalog-backend": "^0.1.1-alpha.9",
"@backstage/plugin-identity-backend": "^0.1.1-alpha.9",
"@backstage/plugin-scaffolder-backend": "^0.1.1-alpha.9",
"@backstage/plugin-sentry-backend": "^0.1.1-alpha.9",
"express": "^4.17.1",
"knex": "^0.21.1",
"sqlite3": "^4.2.0",
"winston": "^3.2.1"
},
"devDependencies": {
"@backstage/cli": "^0.1.1-alpha.8",
"@backstage/cli": "^0.1.1-alpha.9",
"@types/express": "^4.17.6",
"@types/express-serve-static-core": "^4.17.5",
"@types/helmet": "^0.0.47"
+19 -11
View File
@@ -27,6 +27,8 @@ import {
getRootLogger,
useHotMemoize,
} from '@backstage/backend-common';
import { ConfigReader, AppConfig } from '@backstage/config';
import { loadConfig } from '@backstage/config-loader';
import knex from 'knex';
import auth from './plugins/auth';
import catalog from './plugins/catalog';
@@ -35,20 +37,26 @@ import scaffolder from './plugins/scaffolder';
import sentry from './plugins/sentry';
import { PluginEnvironment } from './types';
function createEnv(plugin: string): PluginEnvironment {
const logger = getRootLogger().child({ type: 'plugin', plugin });
const database = knex({
client: 'sqlite3',
connection: ':memory:',
useNullAsDefault: true,
});
database.client.pool.on('createSuccess', (_eventId: any, resource: any) => {
resource.run('PRAGMA foreign_keys = ON', () => {});
});
return { logger, database };
function makeCreateEnv(loadedConfigs: AppConfig[]) {
const config = ConfigReader.fromConfigs(loadedConfigs);
return (plugin: string): PluginEnvironment => {
const logger = getRootLogger().child({ type: 'plugin', plugin });
const database = knex({
client: 'sqlite3',
connection: ':memory:',
useNullAsDefault: true,
});
database.client.pool.on('createSuccess', (_eventId: any, resource: any) => {
resource.run('PRAGMA foreign_keys = ON', () => {});
});
return { logger, database, config };
};
}
async function main() {
const createEnv = makeCreateEnv(await loadConfig());
const catalogEnv = useHotMemoize(module, () => createEnv('catalog'));
const scaffolderEnv = useHotMemoize(module, () => createEnv('scaffolder'));
const authEnv = useHotMemoize(module, () => createEnv('auth'));
+5 -2
View File
@@ -17,6 +17,9 @@
import { createRouter } from '@backstage/plugin-auth-backend';
import { PluginEnvironment } from '../types';
export default async function createPlugin({ logger }: PluginEnvironment) {
return await createRouter({ logger });
export default async function createPlugin({
logger,
config,
}: PluginEnvironment) {
return await createRouter({ logger, config });
}
+2
View File
@@ -16,8 +16,10 @@
import Knex from 'knex';
import { Logger } from 'winston';
import { Config } from '@backstage/config';
export type PluginEnvironment = {
logger: Logger;
database: Knex;
config: Config;
};