Merge branch 'master' into feat/search-facet-by-type

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-12-29 10:43:33 +01:00
99 changed files with 1662 additions and 886 deletions
+16
View File
@@ -147,6 +147,22 @@ describe('CacheManager', () => {
});
});
it('shares memory across multiple instances of the memory client', () => {
const manager = CacheManager.fromConfig(defaultConfig());
const plugin = 'test-plugin';
// Instantiate two in-memory clients.
manager.forPlugin(plugin).getClient({ defaultTtl: 10 });
manager.forPlugin(plugin).getClient({ defaultTtl: 10 });
const cache = Keyv as unknown as jest.Mock;
const mockCall2 = cache.mock.calls.splice(-1)[0][0];
const mockCall1 = cache.mock.calls.splice(-1)[0][0];
// Note: .toBe() checks referential identity of object instances.
expect(mockCall1.store).toBe(mockCall2.store);
});
it('returns a memcache client when configured', () => {
const expectedHost = '127.0.0.1:11211';
const manager = CacheManager.fromConfig(
+8
View File
@@ -42,6 +42,13 @@ export class CacheManager {
none: this.getNoneClient,
};
/**
* Shared memory store for the in-memory cache client. Sharing the same Map
* instance ensures get/set/delete operations hit the same store, regardless
* of where/when a client is instantiated.
*/
private readonly memoryStore = new Map();
private readonly logger: Logger;
private readonly store: keyof CacheManager['storeFactories'];
private readonly connection: string;
@@ -133,6 +140,7 @@ export class CacheManager {
return new Keyv({
namespace: pluginId,
ttl: defaultTtl,
store: this.memoryStore,
});
}
+1 -1
View File
@@ -33,5 +33,5 @@ export default async (cmd: Command) => {
outputs = new Set([Output.types, Output.esm, Output.cjs]);
}
await buildPackage({ outputs });
await buildPackage({ outputs, minify: cmd.minify });
};
+1
View File
@@ -138,6 +138,7 @@ export function registerCommands(program: CommanderStatic) {
.command('build')
.description('Build a package for publishing')
.option('--outputs <formats>', 'List of formats to output [types,cjs,esm]')
.option('--minify', 'Minify the generated code')
.action(lazy(() => import('./build').then(m => m.default)));
program
+11 -3
View File
@@ -44,9 +44,17 @@ export async function loadCliConfig(options: Options) {
const project = new Project(paths.targetDir);
const packages = await project.getPackages();
const localPackageNames = options.fromPackage
? findPackages(packages, options.fromPackage)
: packages.map((p: any) => p.name);
let localPackageNames;
if (options.fromPackage) {
if (packages.length) {
localPackageNames = findPackages(packages, options.fromPackage);
} else {
// No packages: it means that it's not a monorepo (e.g. standalone plugin)
localPackageNames = [options.fromPackage];
}
} else {
localPackageNames = packages.map((p: any) => p.name);
}
const schema = await loadConfigSchema({
dependencies: localPackageNames,
+1 -1
View File
@@ -42,7 +42,7 @@
"json-schema-merge-allof": "^0.8.1",
"json-schema-traverse": "^1.0.0",
"node-fetch": "^2.6.1",
"typescript-json-schema": "^0.51.0",
"typescript-json-schema": "^0.52.0",
"yaml": "^1.9.2",
"yup": "^0.32.9"
},
@@ -81,6 +81,8 @@ async function main() {
apiRouter.use('/techdocs', await techdocs(techdocsEnv));
apiRouter.use('/proxy', await proxy(proxyEnv));
apiRouter.use('/search', await search(searchEnv));
// Add backends ABOVE this line; this 404 handler is the catch-all fallback
apiRouter.use(notFoundHandler());
const service = createServiceBuilder(module)
+1 -1
View File
@@ -36,7 +36,7 @@
"url": "https://github.com/backstage/backstage/issues"
},
"dependencies": {
"@azure/identity": "^1.5.0",
"@azure/identity": "^2.0.1",
"@azure/storage-blob": "^12.5.0",
"@backstage/backend-common": "^0.10.0",
"@backstage/catalog-model": "^0.9.7",