From e5bf3749ad0ed8789a861310acb0a7245c246699 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Thu, 12 Oct 2023 19:58:54 -0400 Subject: [PATCH 01/34] feat(catalog): support adding location analyzers in processing extension Signed-off-by: Phil Kuang --- .changeset/blue-bags-warn.md | 7 +++++++ .../api-report.md | 4 ++-- .../src/analyzers/GithubLocationAnalyzer.ts | 2 +- plugins/catalog-backend/api-report.md | 16 ++++------------ .../src/ingestion/LocationAnalyzer.ts | 3 ++- plugins/catalog-backend/src/ingestion/index.ts | 10 ++++++++-- plugins/catalog-backend/src/ingestion/types.ts | 16 ---------------- .../src/service/CatalogBuilder.ts | 3 ++- .../src/service/CatalogPlugin.ts | 13 +++++++++++++ plugins/catalog-node/alpha-api-report.md | 5 +++++ plugins/catalog-node/api-report.md | 15 +++++++++++++++ plugins/catalog-node/src/extensions.ts | 4 ++++ plugins/catalog-node/src/processing/index.ts | 2 ++ plugins/catalog-node/src/processing/types.ts | 18 ++++++++++++++++++ 14 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 .changeset/blue-bags-warn.md diff --git a/.changeset/blue-bags-warn.md b/.changeset/blue-bags-warn.md new file mode 100644 index 0000000000..9d74aa3320 --- /dev/null +++ b/.changeset/blue-bags-warn.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-backend': minor +'@backstage/plugin-catalog-node': minor +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Support adding location analyzers in catalog processing extension point and move `AnalyzeOptions` and `ScmLocationAnalyzer` types to `@backstage/plugin-catalog-node` diff --git a/plugins/catalog-backend-module-github/api-report.md b/plugins/catalog-backend-module-github/api-report.md index 4c44f95b61..eb43748aa1 100644 --- a/plugins/catalog-backend-module-github/api-report.md +++ b/plugins/catalog-backend-module-github/api-report.md @@ -3,7 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { AnalyzeOptions } from '@backstage/plugin-catalog-backend'; +import { AnalyzeOptions } from '@backstage/plugin-catalog-node'; import { CatalogProcessor } from '@backstage/plugin-catalog-node'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-node'; import { Config } from '@backstage/config'; @@ -21,7 +21,7 @@ import { Logger } from 'winston'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { ScmIntegrationRegistry } from '@backstage/integration'; -import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend'; +import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-node'; import { TaskRunner } from '@backstage/backend-tasks'; import { TokenManager } from '@backstage/backend-common'; import { UserEntity } from '@backstage/catalog-model'; diff --git a/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts b/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts index 9341743413..3353254400 100644 --- a/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts +++ b/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts @@ -27,7 +27,7 @@ import parseGitUrl from 'git-url-parse'; import { AnalyzeOptions, ScmLocationAnalyzer, -} from '@backstage/plugin-catalog-backend'; +} from '@backstage/plugin-catalog-node'; import { PluginEndpointDiscovery, TokenManager, diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index e426ca1d75..d9c241e99c 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -10,6 +10,7 @@ import { AnalyzeLocationExistingEntity as AnalyzeLocationExistingEntity_2 } from import { AnalyzeLocationGenerateEntity as AnalyzeLocationGenerateEntity_2 } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationRequest as AnalyzeLocationRequest_2 } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationResponse as AnalyzeLocationResponse_2 } from '@backstage/plugin-catalog-common'; +import { AnalyzeOptions } from '@backstage/plugin-catalog-node'; import { CatalogApi } from '@backstage/catalog-client'; import type { CatalogCollatorEntityTransformer as CatalogCollatorEntityTransformer_2 } from '@backstage/plugin-search-backend-module-catalog'; import { CatalogEntityDocument } from '@backstage/plugin-catalog-common'; @@ -50,6 +51,7 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { Router } from 'express'; import { ScmIntegrationRegistry } from '@backstage/integration'; +import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-node'; import { TokenManager } from '@backstage/backend-common'; import { UrlReader } from '@backstage/backend-common'; import { Validators } from '@backstage/catalog-model'; @@ -69,11 +71,7 @@ export type AnalyzeLocationRequest = AnalyzeLocationRequest_2; // @public @deprecated (undocumented) export type AnalyzeLocationResponse = AnalyzeLocationResponse_2; -// @public (undocumented) -export type AnalyzeOptions = { - url: string; - catalogFilename?: string; -}; +export { AnalyzeOptions }; // @public (undocumented) export class AnnotateLocationEntityProcessor implements CatalogProcessor_2 { @@ -468,13 +466,7 @@ export const processingResult: Readonly<{ readonly refresh: (key: string) => CatalogProcessorResult_2; }>; -// @public (undocumented) -export type ScmLocationAnalyzer = { - supports(url: string): boolean; - analyze(options: AnalyzeOptions): Promise<{ - existing: AnalyzeLocationExistingEntity[]; - }>; -}; +export { ScmLocationAnalyzer }; // @public (undocumented) export class UrlReaderProcessor implements CatalogProcessor_2 { diff --git a/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts b/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts index 761a0f8c0a..ad752b770d 100644 --- a/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts +++ b/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts @@ -18,11 +18,12 @@ import { Logger } from 'winston'; import parseGitUrl from 'git-url-parse'; import { Entity } from '@backstage/catalog-model'; import { ScmIntegrationRegistry } from '@backstage/integration'; -import { LocationAnalyzer, ScmLocationAnalyzer } from './types'; +import { LocationAnalyzer } from './types'; import { AnalyzeLocationRequest, AnalyzeLocationResponse, } from '@backstage/plugin-catalog-common'; +import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-node'; export class RepoLocationAnalyzer implements LocationAnalyzer { private readonly logger: Logger; diff --git a/plugins/catalog-backend/src/ingestion/index.ts b/plugins/catalog-backend/src/ingestion/index.ts index 0b00809043..86a8179d8d 100644 --- a/plugins/catalog-backend/src/ingestion/index.ts +++ b/plugins/catalog-backend/src/ingestion/index.ts @@ -21,6 +21,12 @@ export type { AnalyzeLocationRequest, AnalyzeLocationResponse, LocationAnalyzer, - ScmLocationAnalyzer, - AnalyzeOptions, } from './types'; + +/** + * @deprecated use the same type from `@backstage/plugin-catalog-node` instead + */ +export type { + AnalyzeOptions, + ScmLocationAnalyzer, +} from '@backstage/plugin-catalog-node'; diff --git a/plugins/catalog-backend/src/ingestion/types.ts b/plugins/catalog-backend/src/ingestion/types.ts index 78339b3b23..3875d3af03 100644 --- a/plugins/catalog-backend/src/ingestion/types.ts +++ b/plugins/catalog-backend/src/ingestion/types.ts @@ -78,19 +78,3 @@ export type LocationAnalyzer = { location: AnalyzeLocationRequest, ): Promise; }; -/** @public */ -export type AnalyzeOptions = { - url: string; - catalogFilename?: string; -}; - -/** @public */ -export type ScmLocationAnalyzer = { - /** The method that decides if this analyzer can work with the provided url */ - supports(url: string): boolean; - /** This function can return an array of already existing entities */ - analyze(options: AnalyzeOptions): Promise<{ - /** Existing entities in the analyzed location */ - existing: AnalyzeLocationExistingEntity[]; - }>; -}; diff --git a/plugins/catalog-backend/src/service/CatalogBuilder.ts b/plugins/catalog-backend/src/service/CatalogBuilder.ts index c12178e888..5cf76ee1ac 100644 --- a/plugins/catalog-backend/src/service/CatalogBuilder.ts +++ b/plugins/catalog-backend/src/service/CatalogBuilder.ts @@ -38,6 +38,7 @@ import { CatalogProcessor, CatalogProcessorParser, EntityProvider, + ScmLocationAnalyzer, } from '@backstage/plugin-catalog-node'; import { AnnotateLocationEntityProcessor, @@ -57,7 +58,7 @@ import { yamlPlaceholderResolver, } from '../modules/core/PlaceholderProcessor'; import { defaultEntityDataParser } from '../modules/util/parse'; -import { LocationAnalyzer, ScmLocationAnalyzer } from '../ingestion/types'; +import { LocationAnalyzer } from '../ingestion/types'; import { CatalogProcessingEngine } from '../processing'; import { DefaultProcessingDatabase } from '../database/DefaultProcessingDatabase'; import { applyDatabaseMigrations } from '../database/migrations'; diff --git a/plugins/catalog-backend/src/service/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index b8d5bdbeda..d112429fc4 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -25,6 +25,7 @@ import { import { CatalogProcessor, EntityProvider, + ScmLocationAnalyzer, } from '@backstage/plugin-catalog-node'; import { loggerToWinstonLogger } from '@backstage/backend-common'; import { PlaceholderResolver } from '../modules'; @@ -33,6 +34,7 @@ class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { #processors = new Array(); #entityProviders = new Array(); #placeholderResolvers: Record = {}; + #locationAnalyzers = new Array(); addProcessor( ...processors: Array> @@ -54,6 +56,12 @@ class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { this.#placeholderResolvers[key] = resolver; } + addLocationAnalyzers( + ...analyzers: Array> + ): void { + this.#locationAnalyzers.push(...analyzers.flat()); + } + get processors() { return this.#processors; } @@ -65,6 +73,10 @@ class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { get placeholderResolvers() { return this.#placeholderResolvers; } + + get locationAnalyzers() { + return this.#locationAnalyzers; + } } /** @@ -116,6 +128,7 @@ export const catalogPlugin = createBackendPlugin({ Object.entries(processingExtensions.placeholderResolvers).forEach( ([key, resolver]) => builder.setPlaceholderResolver(key, resolver), ); + builder.addLocationAnalyzers(...processingExtensions.locationAnalyzers); const { processingEngine, router } = await builder.build(); diff --git a/plugins/catalog-node/alpha-api-report.md b/plugins/catalog-node/alpha-api-report.md index 082228a58e..f3de6a8b33 100644 --- a/plugins/catalog-node/alpha-api-report.md +++ b/plugins/catalog-node/alpha-api-report.md @@ -8,6 +8,7 @@ import { CatalogProcessor } from '@backstage/plugin-catalog-node'; import { EntityProvider } from '@backstage/plugin-catalog-node'; import { ExtensionPoint } from '@backstage/backend-plugin-api'; import { PlaceholderResolver } from '@backstage/plugin-catalog-node'; +import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-node'; import { ServiceRef } from '@backstage/backend-plugin-api'; // @alpha (undocumented) @@ -17,6 +18,10 @@ export interface CatalogProcessingExtensionPoint { ...providers: Array> ): void; // (undocumented) + addLocationAnalyzers( + ...analyzers: Array> + ): void; + // (undocumented) addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void; // (undocumented) addProcessor( diff --git a/plugins/catalog-node/api-report.md b/plugins/catalog-node/api-report.md index 34d7a4bc9b..ef2c09e61f 100644 --- a/plugins/catalog-node/api-report.md +++ b/plugins/catalog-node/api-report.md @@ -5,12 +5,19 @@ ```ts /// +import { AnalyzeLocationExistingEntity } from '@backstage/plugin-catalog-common'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; import { JsonValue } from '@backstage/types'; import { LocationEntityV1alpha1 } from '@backstage/catalog-model'; import { LocationSpec as LocationSpec_2 } from '@backstage/plugin-catalog-common'; +// @public (undocumented) +export type AnalyzeOptions = { + url: string; + catalogFilename?: string; +}; + // @public (undocumented) export type CatalogProcessor = { getProcessorName(): string; @@ -198,4 +205,12 @@ export const processingResult: Readonly<{ readonly relation: (spec: EntityRelationSpec) => CatalogProcessorResult; readonly refresh: (key: string) => CatalogProcessorResult; }>; + +// @public (undocumented) +export type ScmLocationAnalyzer = { + supports(url: string): boolean; + analyze(options: AnalyzeOptions): Promise<{ + existing: AnalyzeLocationExistingEntity[]; + }>; +}; ``` diff --git a/plugins/catalog-node/src/extensions.ts b/plugins/catalog-node/src/extensions.ts index 5225ad7545..4e8f7127f1 100644 --- a/plugins/catalog-node/src/extensions.ts +++ b/plugins/catalog-node/src/extensions.ts @@ -18,6 +18,7 @@ import { EntityProvider, CatalogProcessor, PlaceholderResolver, + ScmLocationAnalyzer, } from '@backstage/plugin-catalog-node'; /** @@ -31,6 +32,9 @@ export interface CatalogProcessingExtensionPoint { ...providers: Array> ): void; addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void; + addLocationAnalyzers( + ...analyzers: Array> + ): void; } /** diff --git a/plugins/catalog-node/src/processing/index.ts b/plugins/catalog-node/src/processing/index.ts index 40cee63e25..8cffac6961 100644 --- a/plugins/catalog-node/src/processing/index.ts +++ b/plugins/catalog-node/src/processing/index.ts @@ -15,9 +15,11 @@ */ export type { + AnalyzeOptions, DeferredEntity, PlaceholderResolver, PlaceholderResolverParams, PlaceholderResolverRead, PlaceholderResolverResolveUrl, + ScmLocationAnalyzer, } from './types'; diff --git a/plugins/catalog-node/src/processing/types.ts b/plugins/catalog-node/src/processing/types.ts index b98e2da1b7..b6785c1b91 100644 --- a/plugins/catalog-node/src/processing/types.ts +++ b/plugins/catalog-node/src/processing/types.ts @@ -15,6 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; +import { AnalyzeLocationExistingEntity } from '@backstage/plugin-catalog-common'; import { JsonValue } from '@backstage/types'; import { CatalogProcessorEmit } from '../api'; @@ -50,3 +51,20 @@ export type PlaceholderResolverParams = { export type PlaceholderResolver = ( params: PlaceholderResolverParams, ) => Promise; + +/** @public */ +export type AnalyzeOptions = { + url: string; + catalogFilename?: string; +}; + +/** @public */ +export type ScmLocationAnalyzer = { + /** The method that decides if this analyzer can work with the provided url */ + supports(url: string): boolean; + /** This function can return an array of already existing entities */ + analyze(options: AnalyzeOptions): Promise<{ + /** Existing entities in the analyzed location */ + existing: AnalyzeLocationExistingEntity[]; + }>; +}; From 39aaeda5ce6cb843b0fc78c2170ab942a2870da5 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Mon, 16 Oct 2023 18:18:09 -0400 Subject: [PATCH 02/34] feat(catalog): move setting location analyzers to a new analysis extension Signed-off-by: Phil Kuang --- .changeset/blue-bags-warn.md | 2 +- plugins/catalog-backend/api-report.md | 12 ++++--- plugins/catalog-backend/src/deprecated.ts | 12 +++++++ .../catalog-backend/src/ingestion/index.ts | 8 ----- .../src/service/CatalogPlugin.ts | 35 +++++++++++++------ plugins/catalog-node/alpha-api-report.md | 15 +++++--- plugins/catalog-node/src/alpha.ts | 2 ++ plugins/catalog-node/src/extensions.ts | 20 +++++++++-- 8 files changed, 75 insertions(+), 31 deletions(-) diff --git a/.changeset/blue-bags-warn.md b/.changeset/blue-bags-warn.md index 9d74aa3320..734910f848 100644 --- a/.changeset/blue-bags-warn.md +++ b/.changeset/blue-bags-warn.md @@ -4,4 +4,4 @@ '@backstage/plugin-catalog-backend-module-github': patch --- -Support adding location analyzers in catalog processing extension point and move `AnalyzeOptions` and `ScmLocationAnalyzer` types to `@backstage/plugin-catalog-node` +Support adding location analyzers in new catalog analysis extension point and move `AnalyzeOptions` and `ScmLocationAnalyzer` types to `@backstage/plugin-catalog-node` diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index d9c241e99c..1aed0ea8b0 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -10,7 +10,7 @@ import { AnalyzeLocationExistingEntity as AnalyzeLocationExistingEntity_2 } from import { AnalyzeLocationGenerateEntity as AnalyzeLocationGenerateEntity_2 } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationRequest as AnalyzeLocationRequest_2 } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationResponse as AnalyzeLocationResponse_2 } from '@backstage/plugin-catalog-common'; -import { AnalyzeOptions } from '@backstage/plugin-catalog-node'; +import { AnalyzeOptions as AnalyzeOptions_2 } from '@backstage/plugin-catalog-node'; import { CatalogApi } from '@backstage/catalog-client'; import type { CatalogCollatorEntityTransformer as CatalogCollatorEntityTransformer_2 } from '@backstage/plugin-search-backend-module-catalog'; import { CatalogEntityDocument } from '@backstage/plugin-catalog-common'; @@ -51,7 +51,7 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { PluginTaskScheduler } from '@backstage/backend-tasks'; import { Router } from 'express'; import { ScmIntegrationRegistry } from '@backstage/integration'; -import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-node'; +import { ScmLocationAnalyzer as ScmLocationAnalyzer_2 } from '@backstage/plugin-catalog-node'; import { TokenManager } from '@backstage/backend-common'; import { UrlReader } from '@backstage/backend-common'; import { Validators } from '@backstage/catalog-model'; @@ -71,7 +71,8 @@ export type AnalyzeLocationRequest = AnalyzeLocationRequest_2; // @public @deprecated (undocumented) export type AnalyzeLocationResponse = AnalyzeLocationResponse_2; -export { AnalyzeOptions }; +// @public @deprecated (undocumented) +export type AnalyzeOptions = AnalyzeOptions_2; // @public (undocumented) export class AnnotateLocationEntityProcessor implements CatalogProcessor_2 { @@ -132,7 +133,7 @@ export class CatalogBuilder { ...providers: Array> ): CatalogBuilder; addLocationAnalyzers( - ...analyzers: Array> + ...analyzers: Array> ): CatalogBuilder; addPermissionRules( ...permissionRules: Array< @@ -466,7 +467,8 @@ export const processingResult: Readonly<{ readonly refresh: (key: string) => CatalogProcessorResult_2; }>; -export { ScmLocationAnalyzer }; +// @public @deprecated (undocumented) +export type ScmLocationAnalyzer = ScmLocationAnalyzer_2; // @public (undocumented) export class UrlReaderProcessor implements CatalogProcessor_2 { diff --git a/plugins/catalog-backend/src/deprecated.ts b/plugins/catalog-backend/src/deprecated.ts index c92ec719b7..f3c199cbd3 100644 --- a/plugins/catalog-backend/src/deprecated.ts +++ b/plugins/catalog-backend/src/deprecated.ts @@ -33,6 +33,8 @@ import { type EntityProvider as _EntityProvider, type EntityProviderConnection as _EntityProviderConnection, type EntityProviderMutation as _EntityProviderMutation, + type AnalyzeOptions as _AnalyzeOptions, + type ScmLocationAnalyzer as _ScmLocationAnalyzer, } from '@backstage/plugin-catalog-node'; import { type LocationSpec as _LocationSpec } from '@backstage/plugin-catalog-common'; @@ -141,3 +143,13 @@ export type EntityProviderMutation = _EntityProviderMutation; * @deprecated use the same type from `@backstage/plugin-catalog-common` instead */ export type LocationSpec = _LocationSpec; +/** + * @public + * @deprecated import from `@backstage/plugin-catalog-node` instead + */ +export type AnalyzeOptions = _AnalyzeOptions; +/** + * @public + * @deprecated import from `@backstage/plugin-catalog-node` instead + */ +export type ScmLocationAnalyzer = _ScmLocationAnalyzer; diff --git a/plugins/catalog-backend/src/ingestion/index.ts b/plugins/catalog-backend/src/ingestion/index.ts index 86a8179d8d..c97d029b5c 100644 --- a/plugins/catalog-backend/src/ingestion/index.ts +++ b/plugins/catalog-backend/src/ingestion/index.ts @@ -22,11 +22,3 @@ export type { AnalyzeLocationResponse, LocationAnalyzer, } from './types'; - -/** - * @deprecated use the same type from `@backstage/plugin-catalog-node` instead - */ -export type { - AnalyzeOptions, - ScmLocationAnalyzer, -} from '@backstage/plugin-catalog-node'; diff --git a/plugins/catalog-backend/src/service/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index d112429fc4..1957ba816d 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -19,6 +19,8 @@ import { } from '@backstage/backend-plugin-api'; import { CatalogBuilder } from './CatalogBuilder'; import { + CatalogAnalysisExtensionPoint, + catalogAnalysisExtensionPoint, CatalogProcessingExtensionPoint, catalogProcessingExtensionPoint, } from '@backstage/plugin-catalog-node/alpha'; @@ -30,11 +32,12 @@ import { import { loggerToWinstonLogger } from '@backstage/backend-common'; import { PlaceholderResolver } from '../modules'; -class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { +class CatalogProcessingExtensionPointImpl + implements CatalogProcessingExtensionPoint +{ #processors = new Array(); #entityProviders = new Array(); #placeholderResolvers: Record = {}; - #locationAnalyzers = new Array(); addProcessor( ...processors: Array> @@ -56,12 +59,6 @@ class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { this.#placeholderResolvers[key] = resolver; } - addLocationAnalyzers( - ...analyzers: Array> - ): void { - this.#locationAnalyzers.push(...analyzers.flat()); - } - get processors() { return this.#processors; } @@ -73,6 +70,18 @@ class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { get placeholderResolvers() { return this.#placeholderResolvers; } +} + +class CatalogAnalysisExtensionPointImpl + implements CatalogAnalysisExtensionPoint +{ + #locationAnalyzers = new Array(); + + addLocationAnalyzers( + ...analyzers: Array> + ): void { + this.#locationAnalyzers.push(...analyzers.flat()); + } get locationAnalyzers() { return this.#locationAnalyzers; @@ -86,13 +95,19 @@ class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { export const catalogPlugin = createBackendPlugin({ pluginId: 'catalog', register(env) { - const processingExtensions = new CatalogExtensionPointImpl(); + const processingExtensions = new CatalogProcessingExtensionPointImpl(); // plugins depending on this API will be initialized before this plugins init method is executed. env.registerExtensionPoint( catalogProcessingExtensionPoint, processingExtensions, ); + const analysisExtensions = new CatalogAnalysisExtensionPointImpl(); + env.registerExtensionPoint( + catalogAnalysisExtensionPoint, + analysisExtensions, + ); + env.registerInit({ deps: { logger: coreServices.logger, @@ -128,7 +143,7 @@ export const catalogPlugin = createBackendPlugin({ Object.entries(processingExtensions.placeholderResolvers).forEach( ([key, resolver]) => builder.setPlaceholderResolver(key, resolver), ); - builder.addLocationAnalyzers(...processingExtensions.locationAnalyzers); + builder.addLocationAnalyzers(...analysisExtensions.locationAnalyzers); const { processingEngine, router } = await builder.build(); diff --git a/plugins/catalog-node/alpha-api-report.md b/plugins/catalog-node/alpha-api-report.md index f3de6a8b33..754129f4a4 100644 --- a/plugins/catalog-node/alpha-api-report.md +++ b/plugins/catalog-node/alpha-api-report.md @@ -11,6 +11,17 @@ import { PlaceholderResolver } from '@backstage/plugin-catalog-node'; import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-node'; import { ServiceRef } from '@backstage/backend-plugin-api'; +// @alpha (undocumented) +export interface CatalogAnalysisExtensionPoint { + // (undocumented) + addLocationAnalyzers( + ...analyzers: Array> + ): void; +} + +// @alpha (undocumented) +export const catalogAnalysisExtensionPoint: ExtensionPoint; + // @alpha (undocumented) export interface CatalogProcessingExtensionPoint { // (undocumented) @@ -18,10 +29,6 @@ export interface CatalogProcessingExtensionPoint { ...providers: Array> ): void; // (undocumented) - addLocationAnalyzers( - ...analyzers: Array> - ): void; - // (undocumented) addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void; // (undocumented) addProcessor( diff --git a/plugins/catalog-node/src/alpha.ts b/plugins/catalog-node/src/alpha.ts index 4fb07bbc25..cec1a0eedb 100644 --- a/plugins/catalog-node/src/alpha.ts +++ b/plugins/catalog-node/src/alpha.ts @@ -17,3 +17,5 @@ export { catalogServiceRef } from './catalogService'; export type { CatalogProcessingExtensionPoint } from './extensions'; export { catalogProcessingExtensionPoint } from './extensions'; +export type { CatalogAnalysisExtensionPoint } from './extensions'; +export { catalogAnalysisExtensionPoint } from './extensions'; diff --git a/plugins/catalog-node/src/extensions.ts b/plugins/catalog-node/src/extensions.ts index 4e8f7127f1..0351c574f2 100644 --- a/plugins/catalog-node/src/extensions.ts +++ b/plugins/catalog-node/src/extensions.ts @@ -32,9 +32,6 @@ export interface CatalogProcessingExtensionPoint { ...providers: Array> ): void; addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void; - addLocationAnalyzers( - ...analyzers: Array> - ): void; } /** @@ -44,3 +41,20 @@ export const catalogProcessingExtensionPoint = createExtensionPoint({ id: 'catalog.processing', }); + +/** + * @alpha + */ +export interface CatalogAnalysisExtensionPoint { + addLocationAnalyzers( + ...analyzers: Array> + ): void; +} + +/** + * @alpha + */ +export const catalogAnalysisExtensionPoint = + createExtensionPoint({ + id: 'catalog.analysis', + }); From 3979524c74185c3d03254c7bb2af0b5bfd70d0bc Mon Sep 17 00:00:00 2001 From: Alex Crome Date: Thu, 19 Oct 2023 22:54:50 +0100 Subject: [PATCH 03/34] Add `domain_hint` support to Entra ID login When a user is logged in to multiple microsoft accounts, there can be be a little bit of friction in the Entra login process as users will be asked to select the account to login with. Scenarios in which a user may have multiple microsoft accounts 1. Someone logged in to your work Entra ID account, and a personal microsoft account 2. A consultant who has an Entra ID account at both their employer, as well as the company they're contracted out to. 3. A user has a regular account, as well as one or more high priviliged accounts. When a domain hint is provided, Entra will filter out all the accounts which don't belong to the tenant specified on the `domain_hint`. In many cases, this will filter to a single account, avoiding the need to select an account at all (e.g. scenario 1 & 2). This won't always happen (e.g. scenario 3). Additionally in the case a tenant has been configured to federate authentication elsewhere (e.g. to an on premise AD FS), setting the domain hint means entra can send the user straight to the federated authentication soruce, removing further steps If backstage is allowign authentication from multiple tenants, this field should be left blank. For more details, see https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/home-realm-discovery-policy 99% of the time, this value should be the same as the tenantId, so we could get rid of hte domain hint, and set it to the same value as the tenant id automatically. We'd need to provide a config option (e.g. `isMultiTenant: true`) to opt out of this. For those edge cases, this would be a breaking change. I decided to go with specifying the `domain_hint` seperatly for now just in case my assumptions are wrong and there are more cases wher ehte `domain_hint` will get in the way. We can always make this the default behaviour later on. Signed-off-by: Alex Crome --- .changeset/gentle-pumpkins-carry.md | 16 +++++ docs/auth/microsoft/provider.md | 7 ++- .../config.d.ts | 1 + .../src/authenticator.ts | 13 +++- .../src/module.test.ts | 61 ++++++++++++++++++- 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 .changeset/gentle-pumpkins-carry.md diff --git a/.changeset/gentle-pumpkins-carry.md b/.changeset/gentle-pumpkins-carry.md new file mode 100644 index 0000000000..22abd16798 --- /dev/null +++ b/.changeset/gentle-pumpkins-carry.md @@ -0,0 +1,16 @@ +--- +'@backstage/plugin-auth-backend-module-microsoft-provider': minor +--- + +Added support for specifying a `domain_hint` on Microsoft authentication provider configuration. +This should typically be set to the same value as your `tenantId`. +If you allow users from multiple tenants to authenticate, then leave this blank. + +```yaml +auth: + providers: + microsoft: + development: + #... + domainHint: ${AZURE_TENANT_ID} +``` diff --git a/docs/auth/microsoft/provider.md b/docs/auth/microsoft/provider.md index 583139cff1..2051a7aa0b 100644 --- a/docs/auth/microsoft/provider.md +++ b/docs/auth/microsoft/provider.md @@ -38,13 +38,18 @@ auth: clientId: ${AUTH_MICROSOFT_CLIENT_ID} clientSecret: ${AUTH_MICROSOFT_CLIENT_SECRET} tenantId: ${AUTH_MICROSOFT_TENANT_ID} + domainHint: ${AZURE_TENANT_ID} ``` -The Microsoft provider is a structure with three configuration keys: +The Microsoft provider is a structure with three mandatory configuration keys: - `clientId`: Application (client) ID, found on App Registration > Overview - `clientSecret`: Secret, found on App Registration > Certificates & secrets - `tenantId`: Directory (tenant) ID, found on App Registration > Overview +- `domainHint` (optional): Typically the same as `tenantId`. + Leave blank if your app registration is multi tenant. + When specified, this reduces login friction for users with accounts in multiple tenants by automatically filtering away accounts from other tenants. + For more details, see [Home Realm Discovery](https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/home-realm-discovery-policy) ## Outbound Network Access diff --git a/plugins/auth-backend-module-microsoft-provider/config.d.ts b/plugins/auth-backend-module-microsoft-provider/config.d.ts index 5f1fa958e5..ee1e45b720 100644 --- a/plugins/auth-backend-module-microsoft-provider/config.d.ts +++ b/plugins/auth-backend-module-microsoft-provider/config.d.ts @@ -26,6 +26,7 @@ export interface Config { */ tenantId: string; clientSecret: string; + domainHint?: string; callbackUrl?: string; }; }; diff --git a/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts b/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts index ba1d75adf8..edf985b0f2 100644 --- a/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts +++ b/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts @@ -22,6 +22,8 @@ import { PassportProfile, } from '@backstage/plugin-auth-node'; +let domainHint: string | undefined = undefined; + /** @public */ export const microsoftAuthenticator = createOAuthAuthenticator({ defaultProfileTransform: @@ -30,6 +32,7 @@ export const microsoftAuthenticator = createOAuthAuthenticator({ const clientId = config.getString('clientId'); const clientSecret = config.getString('clientSecret'); const tenantId = config.getString('tenantId'); + domainHint = config.getOptionalString('domainHint'); return PassportOAuthAuthenticatorHelper.from( new MicrosoftStrategy( @@ -58,9 +61,15 @@ export const microsoftAuthenticator = createOAuthAuthenticator({ }, async start(input, helper) { - return helper.start(input, { + const options: Record = { accessType: 'offline', - }); + }; + + if (domainHint !== undefined) { + options.domain_hint = domainHint; + } + + return helper.start(input, options); }, async authenticate(input, helper) { diff --git a/plugins/auth-backend-module-microsoft-provider/src/module.test.ts b/plugins/auth-backend-module-microsoft-provider/src/module.test.ts index 2cfedc5d5e..21f9a7e845 100644 --- a/plugins/auth-backend-module-microsoft-provider/src/module.test.ts +++ b/plugins/auth-backend-module-microsoft-provider/src/module.test.ts @@ -21,7 +21,7 @@ import request from 'supertest'; import { authModuleMicrosoftProvider } from './module'; describe('authModuleMicrosoftProvider', () => { - it('should start', async () => { + it('should start without domain hint', async () => { const { server } = await startTestBackend({ features: [ authPlugin, @@ -77,4 +77,63 @@ describe('authModuleMicrosoftProvider', () => { nonce: decodeURIComponent(nonceCookie.value), }); }); + + it('should start with domain hint', async () => { + const { server } = await startTestBackend({ + features: [ + authPlugin, + authModuleMicrosoftProvider, + mockServices.rootConfig.factory({ + data: { + app: { + baseUrl: 'http://localhost:3000', + }, + auth: { + providers: { + microsoft: { + development: { + clientId: 'another-client-id', + clientSecret: 'another-client-secret', + tenantId: 'another-tenant-id', + domainHint: 'somedomain', + }, + }, + }, + }, + }, + }), + ], + }); + + const agent = request.agent(server); + + const res = await agent.get('/api/auth/microsoft/start?env=development'); + + expect(res.status).toEqual(302); + + const nonceCookie = agent.jar.getCookie('microsoft-nonce', { + domain: 'localhost', + path: '/api/auth/microsoft/handler', + script: false, + secure: false, + }); + expect(nonceCookie).toBeDefined(); + + const startUrl = new URL(res.get('location')); + expect(startUrl.origin).toBe('https://login.microsoftonline.com'); + expect(startUrl.pathname).toBe('/another-tenant-id/oauth2/v2.0/authorize'); + expect(Object.fromEntries(startUrl.searchParams)).toEqual({ + response_type: 'code', + scope: 'user.read', + client_id: 'another-client-id', + redirect_uri: `http://localhost:${server.port()}/api/auth/microsoft/handler/frame`, + state: expect.any(String), + domain_hint: 'somedomain', + }); + + expect(decodeOAuthState(startUrl.searchParams.get('state')!)).toEqual({ + env: 'development', + nonce: decodeURIComponent(nonceCookie.value), + }); + }); }); From a539643cba48e35aec8f27a6959eb6b76a8d98b0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 24 Oct 2023 14:17:26 +0200 Subject: [PATCH 04/34] search-react: minor search bar analytics refactor Signed-off-by: Patrik Oldsberg --- .changeset/weak-zebras-cover.md | 5 +++++ .../src/components/SearchTracker/SearchTracker.tsx | 13 ++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 .changeset/weak-zebras-cover.md diff --git a/.changeset/weak-zebras-cover.md b/.changeset/weak-zebras-cover.md new file mode 100644 index 0000000000..f3290683e2 --- /dev/null +++ b/.changeset/weak-zebras-cover.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-react': patch +--- + +Minor refactor of search bar analytics capture diff --git a/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx b/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx index b19af6eef8..6cdfd205fc 100644 --- a/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx +++ b/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx @@ -19,23 +19,22 @@ import { useAnalytics } from '@backstage/core-plugin-api'; import { useSearch } from '../../context'; import usePrevious from 'react-use/lib/usePrevious'; +function useFallingEdge(next: boolean) { + const prev = usePrevious(next); + return prev && !next; +} + /** * Capture search event on term change. */ export const TrackSearch = ({ children }: { children: React.ReactChild }) => { - const useHasChanged = (value: any) => { - const previousVal = usePrevious(value); - return previousVal !== value; - }; - const analytics = useAnalytics(); const { term, result } = useSearch(); const numberOfResults = result.value?.numberOfResults ?? undefined; // Stops the analtyics event from firing before the new search engine response is returned - const hasStartedLoading = useHasChanged(result.loading); - const hasFinishedLoading = hasStartedLoading && !result.loading; + const hasFinishedLoading = useFallingEdge(result.loading); useEffect(() => { if (term && hasFinishedLoading) { From 74c57762b2ecc9afafc4d35c801621776204f71e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:14:34 +0000 Subject: [PATCH 05/34] chore(deps): update actions/setup-node action to v3.8.2 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 6 +++--- .github/workflows/deploy_docker-image.yml | 2 +- .github/workflows/deploy_microsite.yml | 2 +- .github/workflows/deploy_nightly.yml | 2 +- .github/workflows/deploy_packages.yml | 4 ++-- .github/workflows/sync_code-formatting.yml | 2 +- .github/workflows/sync_release-manifest.yml | 2 +- .github/workflows/sync_snyk-github-issues.yml | 2 +- .github/workflows/uffizzi-build.yml | 2 +- .github/workflows/verify_accessibility.yml | 2 +- .github/workflows/verify_e2e-kubernetes.yml | 2 +- .github/workflows/verify_e2e-linux.yml | 2 +- .github/workflows/verify_e2e-windows.yml | 2 +- .github/workflows/verify_microsite.yml | 2 +- .github/workflows/verify_storybook.yml | 2 +- .github/workflows/verify_windows.yml | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e3ec626d7..fd9ec8a415 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth @@ -70,7 +70,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth @@ -201,7 +201,7 @@ jobs: run: git fetch origin master - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/deploy_docker-image.yml b/.github/workflows/deploy_docker-image.yml index 69776da2d9..8c54ebf23b 100644 --- a/.github/workflows/deploy_docker-image.yml +++ b/.github/workflows/deploy_docker-image.yml @@ -25,7 +25,7 @@ jobs: ref: v${{ github.event.client_payload.version }} - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/deploy_microsite.yml b/.github/workflows/deploy_microsite.yml index f614db31ca..3b8d9a7a80 100644 --- a/.github/workflows/deploy_microsite.yml +++ b/.github/workflows/deploy_microsite.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js 18.x - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: 18.x registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/deploy_nightly.yml b/.github/workflows/deploy_nightly.yml index 7184557e12..dc2155bcd1 100644 --- a/.github/workflows/deploy_nightly.yml +++ b/.github/workflows/deploy_nightly.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: use node.js 18.x - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 + uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 with: node-version: 18.x registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/deploy_packages.yml b/.github/workflows/deploy_packages.yml index 32f4b139f2..10943ad7b4 100644 --- a/.github/workflows/deploy_packages.yml +++ b/.github/workflows/deploy_packages.yml @@ -63,7 +63,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth @@ -145,7 +145,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/sync_code-formatting.yml b/.github/workflows/sync_code-formatting.yml index 610ad323e2..90d1925a24 100644 --- a/.github/workflows/sync_code-formatting.yml +++ b/.github/workflows/sync_code-formatting.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/sync_release-manifest.yml b/.github/workflows/sync_release-manifest.yml index 46d5d5382a..bd7c42799b 100644 --- a/.github/workflows/sync_release-manifest.yml +++ b/.github/workflows/sync_release-manifest.yml @@ -13,7 +13,7 @@ jobs: egress-policy: audit # Setup node & install deps before checkout, keeping install quick - - uses: actions/setup-node@v3.8.1 + - uses: actions/setup-node@v3.8.2 with: node-version: 18.x - name: Install dependencies diff --git a/.github/workflows/sync_snyk-github-issues.yml b/.github/workflows/sync_snyk-github-issues.yml index 2be954746b..d958eb3dc4 100644 --- a/.github/workflows/sync_snyk-github-issues.yml +++ b/.github/workflows/sync_snyk-github-issues.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js 18.x - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: 18.x registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 375c6bdcd2..2ce2984fff 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v3.6.0 - name: setup-node - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: 18.x registry-url: https://registry.npmjs.org/ diff --git a/.github/workflows/verify_accessibility.yml b/.github/workflows/verify_accessibility.yml index f34f2f5506..9669483c1e 100644 --- a/.github/workflows/verify_accessibility.yml +++ b/.github/workflows/verify_accessibility.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: Use Node.js 18.x - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: 18.x - name: yarn install diff --git a/.github/workflows/verify_e2e-kubernetes.yml b/.github/workflows/verify_e2e-kubernetes.yml index ea77609614..a7f0f19d65 100644 --- a/.github/workflows/verify_e2e-kubernetes.yml +++ b/.github/workflows/verify_e2e-kubernetes.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/verify_e2e-linux.yml b/.github/workflows/verify_e2e-linux.yml index 6b61053628..4655a175d4 100644 --- a/.github/workflows/verify_e2e-linux.yml +++ b/.github/workflows/verify_e2e-linux.yml @@ -52,7 +52,7 @@ jobs: git config --global user.name 'GitHub e2e user' - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/verify_e2e-windows.yml b/.github/workflows/verify_e2e-windows.yml index 7ee5e596c5..0e1105e641 100644 --- a/.github/workflows/verify_e2e-windows.yml +++ b/.github/workflows/verify_e2e-windows.yml @@ -50,7 +50,7 @@ jobs: git config --global user.name 'GitHub e2e user' - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/verify_microsite.yml b/.github/workflows/verify_microsite.yml index f0705bedc7..6acaa4a781 100644 --- a/.github/workflows/verify_microsite.yml +++ b/.github/workflows/verify_microsite.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js 18.x - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: 18.x diff --git a/.github/workflows/verify_storybook.yml b/.github/workflows/verify_storybook.yml index fe481f9882..6f64d7c5a9 100644 --- a/.github/workflows/verify_storybook.yml +++ b/.github/workflows/verify_storybook.yml @@ -37,7 +37,7 @@ jobs: fetch-depth: 0 # Required to retrieve git history - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth diff --git a/.github/workflows/verify_windows.yml b/.github/workflows/verify_windows.yml index f2c61938d8..c40e1c7bc7 100644 --- a/.github/workflows/verify_windows.yml +++ b/.github/workflows/verify_windows.yml @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v3.6.0 - name: use node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.8.1 + uses: actions/setup-node@v3.8.2 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org/ # Needed for auth From c1f357715cbbe2d7f1bb8e569540c9616e732e41 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:09:12 +0000 Subject: [PATCH 06/34] chore(deps): update actions/setup-python action to v4.7.1 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/verify_e2e-techdocs.yml | 2 +- .github/workflows/verify_e2e-windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify_e2e-techdocs.yml b/.github/workflows/verify_e2e-techdocs.yml index 94f08a491f..de43a4f5ac 100644 --- a/.github/workflows/verify_e2e-techdocs.yml +++ b/.github/workflows/verify_e2e-techdocs.yml @@ -35,7 +35,7 @@ jobs: egress-policy: audit - uses: actions/checkout@v3.6.0 - - uses: actions/setup-python@v4.7.0 + - uses: actions/setup-python@v4.7.1 with: python-version: '3.9' diff --git a/.github/workflows/verify_e2e-windows.yml b/.github/workflows/verify_e2e-windows.yml index 7ee5e596c5..7eba130ed8 100644 --- a/.github/workflows/verify_e2e-windows.yml +++ b/.github/workflows/verify_e2e-windows.yml @@ -56,7 +56,7 @@ jobs: registry-url: https://registry.npmjs.org/ # Needed for auth - name: setup python - uses: actions/setup-python@v4.7.0 + uses: actions/setup-python@v4.7.1 with: python-version: '3.10' From 6c39010121679a50ee17b4697649cf020679a7ad Mon Sep 17 00:00:00 2001 From: David Festal Date: Tue, 24 Oct 2023 15:47:11 +0200 Subject: [PATCH 07/34] fix: CommonJSModuleLoader returning uncomplete list This fixes issue #20762 Signed-off-by: David Festal --- .../src/loader/CommonJSModuleLoader.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/backend-plugin-manager/src/loader/CommonJSModuleLoader.ts b/packages/backend-plugin-manager/src/loader/CommonJSModuleLoader.ts index dd64dc78f3..06a08117cd 100644 --- a/packages/backend-plugin-manager/src/loader/CommonJSModuleLoader.ts +++ b/packages/backend-plugin-manager/src/loader/CommonJSModuleLoader.ts @@ -24,8 +24,8 @@ export class CommonJSModuleLoader implements ModuleLoader { backstageRoot: string, dynamicPluginsPaths: string[], ): Promise { - const allowedNodeModulesPaths = [ - `${backstageRoot}/node_modules`, + const backstageRootNodeModulesPath = `${backstageRoot}/node_modules`; + const dynamicNodeModulesPaths = [ ...dynamicPluginsPaths.map(p => path.resolve(p, 'node_modules')), ]; const Module = require('module'); @@ -35,8 +35,12 @@ export class CommonJSModuleLoader implements ModuleLoader { if (!dynamicPluginsPaths.some(p => from.startsWith(p))) { return result; } - - const filtered = result.filter(p => allowedNodeModulesPaths.includes(p)); + const filtered = result.filter(nodeModulePath => { + return ( + nodeModulePath === backstageRootNodeModulesPath || + dynamicNodeModulesPaths.some(p => nodeModulePath.startsWith(p)) + ); + }); this.logger.debug( `Overriding node_modules search path for dynamic plugin ${from} to: ${filtered}`, ); From 88b673aa7652fee76fce52c973d5f23acbe11225 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Tue, 24 Oct 2023 12:27:36 -0400 Subject: [PATCH 08/34] refactor(CatalogAnalysisExtensionPoint): update function signature Signed-off-by: Phil Kuang --- .changeset/blue-bags-warn.md | 1 - .changeset/unlucky-houses-end.md | 5 +++++ plugins/catalog-backend/src/service/CatalogPlugin.ts | 6 ++---- plugins/catalog-node/alpha-api-report.md | 4 +--- plugins/catalog-node/src/extensions.ts | 4 +--- 5 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 .changeset/unlucky-houses-end.md diff --git a/.changeset/blue-bags-warn.md b/.changeset/blue-bags-warn.md index 734910f848..17fa5e89d6 100644 --- a/.changeset/blue-bags-warn.md +++ b/.changeset/blue-bags-warn.md @@ -1,7 +1,6 @@ --- '@backstage/plugin-catalog-backend': minor '@backstage/plugin-catalog-node': minor -'@backstage/plugin-catalog-backend-module-github': patch --- Support adding location analyzers in new catalog analysis extension point and move `AnalyzeOptions` and `ScmLocationAnalyzer` types to `@backstage/plugin-catalog-node` diff --git a/.changeset/unlucky-houses-end.md b/.changeset/unlucky-houses-end.md new file mode 100644 index 0000000000..48f5849002 --- /dev/null +++ b/.changeset/unlucky-houses-end.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Import `AnalyzeOptions` and `ScmLocationAnalyzer` types from `@backstage/plugin-catalog-node` diff --git a/plugins/catalog-backend/src/service/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index 1957ba816d..fa53ef510b 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -77,10 +77,8 @@ class CatalogAnalysisExtensionPointImpl { #locationAnalyzers = new Array(); - addLocationAnalyzers( - ...analyzers: Array> - ): void { - this.#locationAnalyzers.push(...analyzers.flat()); + addLocationAnalyzer(analyzer: ScmLocationAnalyzer): void { + this.#locationAnalyzers.push(analyzer); } get locationAnalyzers() { diff --git a/plugins/catalog-node/alpha-api-report.md b/plugins/catalog-node/alpha-api-report.md index 754129f4a4..c4dc6b12e1 100644 --- a/plugins/catalog-node/alpha-api-report.md +++ b/plugins/catalog-node/alpha-api-report.md @@ -14,9 +14,7 @@ import { ServiceRef } from '@backstage/backend-plugin-api'; // @alpha (undocumented) export interface CatalogAnalysisExtensionPoint { // (undocumented) - addLocationAnalyzers( - ...analyzers: Array> - ): void; + addLocationAnalyzer(analyzer: ScmLocationAnalyzer): void; } // @alpha (undocumented) diff --git a/plugins/catalog-node/src/extensions.ts b/plugins/catalog-node/src/extensions.ts index 0351c574f2..247ef142ad 100644 --- a/plugins/catalog-node/src/extensions.ts +++ b/plugins/catalog-node/src/extensions.ts @@ -46,9 +46,7 @@ export const catalogProcessingExtensionPoint = * @alpha */ export interface CatalogAnalysisExtensionPoint { - addLocationAnalyzers( - ...analyzers: Array> - ): void; + addLocationAnalyzer(analyzer: ScmLocationAnalyzer): void; } /** From 81efdd56abbd9d05710c7c8c2a05d36589fb7150 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:39:55 +0000 Subject: [PATCH 09/34] chore(deps): update dependency @types/archiver to v5.3.4 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 79972afd0b..74e8bb1262 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18102,11 +18102,11 @@ __metadata: linkType: hard "@types/archiver@npm:^5.1.0, @types/archiver@npm:^5.3.1": - version: 5.3.3 - resolution: "@types/archiver@npm:5.3.3" + version: 5.3.4 + resolution: "@types/archiver@npm:5.3.4" dependencies: "@types/readdir-glob": "*" - checksum: e660465ac9a622570ddbad86a306c7234c3272cb28eafe9c3ad7229f06e499dfadae9f0cb0caf41443318eea559b75ef662ea276ae64f19695e72018dae37ee7 + checksum: 4ef27b99091ada9b8f13017d5b9e6d42a439e35a7858b30e040c408e081d98d8db6307b0762500288b5da38cab9823c4756b6abae1fdd2658d42bfb09eb7c5fb languageName: node linkType: hard From 9ed0a6aff1d97faa1884d1869628d80d8132f2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 25 Oct 2023 15:42:16 +0200 Subject: [PATCH 10/34] remove yarn 3 warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- docs/tutorials/yarn-migration.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/tutorials/yarn-migration.md b/docs/tutorials/yarn-migration.md index 9e041a5969..204829b093 100644 --- a/docs/tutorials/yarn-migration.md +++ b/docs/tutorials/yarn-migration.md @@ -4,8 +4,6 @@ title: Migration to Yarn 3 description: Guide for how to migrate a Backstage project to use Yarn 3 --- -> NOTE: We do not yet recommend all projects to migrate to Yarn 3. Only do so if you have specific reasons for it. - While Backstage projects created with `@backstage/create-app` use [Yarn 1](https://classic.yarnpkg.com/) by default, it is possible to switch them to instead use [Yarn 3](https://yarnpkg.com/). Tools like `yarn backstage-cli versions:bump` will still work, as they recognize both lockfile formats. From 0964c2f81372ff1e43b3e90374e9108973b87ab4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:23:27 +0000 Subject: [PATCH 11/34] chore(deps): update dependency @types/core-js to v2.5.7 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 29b6606eb8..b31a56bf04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18371,9 +18371,9 @@ __metadata: linkType: hard "@types/core-js@npm:^2.5.4": - version: 2.5.6 - resolution: "@types/core-js@npm:2.5.6" - checksum: 05cfeea4c918c88afcff5949e05a66c9c6cccd67f3de80732609d2546da0fdbd4350d6ecb415d4301f877e5ae1073c8afc0d500233f2b8826dd66d14c6e0c854 + version: 2.5.7 + resolution: "@types/core-js@npm:2.5.7" + checksum: a5ddeaa7103772eaee156d0182779f11e98983cbd76f1b1784dc919b9d59fa4575c608c8e7a31bfe08035e1890d6686b82ee9484a1def17402a1b8983e22ffaf languageName: node linkType: hard From 77fd578ab1a2440f13834bca75418fdc6c0df35f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:36:45 +0000 Subject: [PATCH 12/34] chore(deps): update dependency @types/cross-spawn to v6.0.4 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7d6dbb8c53..87ba229c5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18397,11 +18397,11 @@ __metadata: linkType: hard "@types/cross-spawn@npm:^6.0.2": - version: 6.0.3 - resolution: "@types/cross-spawn@npm:6.0.3" + version: 6.0.4 + resolution: "@types/cross-spawn@npm:6.0.4" dependencies: "@types/node": "*" - checksum: 06d50fa1e1370ef60b9c9085b76adec7d7bc20728fbb02b3c2061d4d922312acf1ba56a7c94d88c27a22fc6241ab6b970c936f3294038a9c97a719fbc8eb8a76 + checksum: 45624a955c064dda167f8aae5560918307110e3a1221989b5957c52842208c2ee29e099c9120615b1dde66afe7a7c3db627c754e328f574a0ae313644e43ceef languageName: node linkType: hard From 507891226a1f5f44143c19adb8189c2330efbd02 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:21:34 +0000 Subject: [PATCH 13/34] chore(deps): update dependency @types/d3-force to v3.0.7 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1c7d335f57..758d8deaa8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18435,9 +18435,9 @@ __metadata: linkType: hard "@types/d3-force@npm:^3.0.0": - version: 3.0.6 - resolution: "@types/d3-force@npm:3.0.6" - checksum: 092d7a4efc1bef06de4a087e1bdb609e21588429ba2ce978785bb13e1ed7371dd08692408379d9582e03ed945c6cf117dff3b3ed1dd2141d94aac9e12994498d + version: 3.0.7 + resolution: "@types/d3-force@npm:3.0.7" + checksum: fd846e5d79dabd8d375b68c64cd218b4867e229eb6cb584b302ed9b96105cb267300fee63b0cd762417c28168d0a64047b7e6eff2acc8b5c561fded74f86fa8c languageName: node linkType: hard From c875e2db99bc00bdff00346298c948efc0c7a7ce Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:31:24 +0000 Subject: [PATCH 14/34] chore(deps): update dependency @types/d3-selection to v3.0.8 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 38f54f7fbb..710fc49f31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18474,9 +18474,9 @@ __metadata: linkType: hard "@types/d3-selection@npm:*, @types/d3-selection@npm:^3.0.1": - version: 3.0.7 - resolution: "@types/d3-selection@npm:3.0.7" - checksum: 715a0c7a78732650ae70b3487b3b6432b063482c1937bcd52c8b7a201563103170fdaa1f8c0ace882062521ac009f07fefb41198c8c43c5d3c518f8368c459d6 + version: 3.0.8 + resolution: "@types/d3-selection@npm:3.0.8" + checksum: 5655584116a97876d22c68387551d6e029d306894ca15c5b71635c2cc528288bddee67799ae2c677b028f2f26f99fcc8d598e47f5a67d5c1e3dd9b5507771f90 languageName: node linkType: hard From 8b4d44ed9d0b7a13d118c98fcd1013a242007952 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:24:43 +0000 Subject: [PATCH 15/34] chore(deps): update dependency @types/d3-shape to v3.1.4 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 710fc49f31..b8cebef446 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18481,20 +18481,20 @@ __metadata: linkType: hard "@types/d3-shape@npm:^1": - version: 1.3.9 - resolution: "@types/d3-shape@npm:1.3.9" + version: 1.3.10 + resolution: "@types/d3-shape@npm:1.3.10" dependencies: "@types/d3-path": ^1 - checksum: a4df0c09df4f97a017fbb229a096af6e25fe84e331dfb8c9b1f248a7f3df6f07c871879fabb31050cbec78f34127397a8134a16f2a2359ff681ec846cf886754 + checksum: c5fcb5da6388ffe5b0594d001940bf88589e174ca1b6cb6ffe3367fb8157b7bd70f15a555642abfa1acdf679860e0c1247bbc1f59395fcded29255638f661b55 languageName: node linkType: hard "@types/d3-shape@npm:^3.0.1, @types/d3-shape@npm:^3.1.0": - version: 3.1.3 - resolution: "@types/d3-shape@npm:3.1.3" + version: 3.1.4 + resolution: "@types/d3-shape@npm:3.1.4" dependencies: "@types/d3-path": "*" - checksum: ad17781ab4ce4b796954b86de7e14566c731726d39a1db7d73eaf50668a71e996d715450a0ff9f2720755e1b8643c3e88d47d45101a75c9d4ddbef51a636f6a0 + checksum: 3d529cc96127d8d58da05bc602e51bb7946171bdae96dcce9dae81c1549d3fd3f226a4e651c3302951a1ebf7803e86388c4afcdd654b0d40d203219ce68eb383 languageName: node linkType: hard From 042d58a31f224e3d8d70d969a64b3899411f4a0b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:00:04 +0000 Subject: [PATCH 16/34] chore(deps): update dependency @types/d3-zoom to v3.0.6 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 710fc49f31..f479fe8c9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18513,12 +18513,12 @@ __metadata: linkType: hard "@types/d3-zoom@npm:^3.0.1": - version: 3.0.5 - resolution: "@types/d3-zoom@npm:3.0.5" + version: 3.0.6 + resolution: "@types/d3-zoom@npm:3.0.6" dependencies: "@types/d3-interpolate": "*" "@types/d3-selection": "*" - checksum: acff15a30b2b81a99b46692c7aacc110c635a272e8d7e87af6aa5a01ebe9ebcafcaf475399d79ec73461a5ef037041dade49a6371d7587b759710123539b81b0 + checksum: 6b0ad10b6a7bab3acfdc92b0cd34c74698305a71e2fefb20eae1e3bac95cbf70c6434be5ea2c1c71bbe9fcb134c66da44fdd75673437199e9a90aea8aea0f7e7 languageName: node linkType: hard From b7f36ead90323d07b545afb0147f657130a836b1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:00:18 +0000 Subject: [PATCH 17/34] chore(deps): update actions/checkout action to v4 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/automate_changeset_feedback.yml | 2 +- .github/workflows/automate_merge_message.yml | 2 +- .github/workflows/ci.yml | 6 +++--- .github/workflows/deploy_docker-image.yml | 2 +- .github/workflows/deploy_microsite.yml | 2 +- .github/workflows/deploy_nightly.yml | 2 +- .github/workflows/deploy_packages.yml | 4 ++-- .github/workflows/scorecard.yml | 2 +- .github/workflows/sync_code-formatting.yml | 2 +- .github/workflows/sync_dependabot-changesets.yml | 2 +- .github/workflows/sync_release-manifest.yml | 4 ++-- .github/workflows/sync_renovate-changesets.yml | 2 +- .github/workflows/sync_snyk-github-issues.yml | 2 +- .github/workflows/sync_snyk-monitor.yml | 2 +- .github/workflows/sync_version-packages.yml | 2 +- .github/workflows/uffizzi-build.yml | 4 ++-- .github/workflows/verify_accessibility.yml | 2 +- .github/workflows/verify_codeql.yml | 2 +- .github/workflows/verify_docs-quality.yml | 2 +- .github/workflows/verify_e2e-kubernetes.yml | 2 +- .github/workflows/verify_e2e-linux.yml | 2 +- .github/workflows/verify_e2e-techdocs.yml | 2 +- .github/workflows/verify_e2e-windows.yml | 2 +- .github/workflows/verify_fossa.yml | 2 +- .github/workflows/verify_microsite.yml | 2 +- .github/workflows/verify_storybook.yml | 2 +- .github/workflows/verify_windows.yml | 2 +- 27 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/automate_changeset_feedback.yml b/.github/workflows/automate_changeset_feedback.yml index eac020cb8e..56aa3f58f8 100644 --- a/.github/workflows/automate_changeset_feedback.yml +++ b/.github/workflows/automate_changeset_feedback.yml @@ -27,7 +27,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 with: # Fetch the commit that's merged into the base rather than the target ref # This will let us diff only the contents of the PR, without fetching more history diff --git a/.github/workflows/automate_merge_message.yml b/.github/workflows/automate_merge_message.yml index 4cbf6c69a2..c7a02db354 100644 --- a/.github/workflows/automate_merge_message.yml +++ b/.github/workflows/automate_merge_message.yml @@ -28,7 +28,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 with: ref: '${{ github.event.pull_request.merge_commit_sha }}' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e3ec626d7..bd5a0385fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.8.1 @@ -67,7 +67,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.8.1 @@ -196,7 +196,7 @@ jobs: INTEGRATION_TEST_AZURE_TOKEN: ${{ secrets.INTEGRATION_TEST_AZURE_TOKEN }} steps: - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: fetch branch master run: git fetch origin master diff --git a/.github/workflows/deploy_docker-image.yml b/.github/workflows/deploy_docker-image.yml index 69776da2d9..68dfe9419a 100644 --- a/.github/workflows/deploy_docker-image.yml +++ b/.github/workflows/deploy_docker-image.yml @@ -19,7 +19,7 @@ jobs: egress-policy: audit - name: checkout - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: path: backstage ref: v${{ github.event.client_payload.version }} diff --git a/.github/workflows/deploy_microsite.yml b/.github/workflows/deploy_microsite.yml index f614db31ca..7012a34205 100644 --- a/.github/workflows/deploy_microsite.yml +++ b/.github/workflows/deploy_microsite.yml @@ -28,7 +28,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js 18.x uses: actions/setup-node@v3.8.1 diff --git a/.github/workflows/deploy_nightly.yml b/.github/workflows/deploy_nightly.yml index 7184557e12..721278b89a 100644 --- a/.github/workflows/deploy_nightly.yml +++ b/.github/workflows/deploy_nightly.yml @@ -19,7 +19,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: use node.js 18.x uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 diff --git a/.github/workflows/deploy_packages.yml b/.github/workflows/deploy_packages.yml index 32f4b139f2..595d8f0792 100644 --- a/.github/workflows/deploy_packages.yml +++ b/.github/workflows/deploy_packages.yml @@ -60,7 +60,7 @@ jobs: INTEGRATION_TEST_AZURE_TOKEN: ${{ secrets.INTEGRATION_TEST_AZURE_TOKEN }} steps: - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.8.1 @@ -142,7 +142,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.8.1 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 0f99453bba..3b017e759c 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -34,7 +34,7 @@ jobs: egress-policy: audit - name: 'Checkout code' - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: persist-credentials: false diff --git a/.github/workflows/sync_code-formatting.yml b/.github/workflows/sync_code-formatting.yml index 610ad323e2..af94d58d5a 100644 --- a/.github/workflows/sync_code-formatting.yml +++ b/.github/workflows/sync_code-formatting.yml @@ -14,7 +14,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: # Fetch changes to previous commit - required for 'only_changed' in Prettier action fetch-depth: 0 diff --git a/.github/workflows/sync_dependabot-changesets.yml b/.github/workflows/sync_dependabot-changesets.yml index 2ac6d7f0d0..40886015ca 100644 --- a/.github/workflows/sync_dependabot-changesets.yml +++ b/.github/workflows/sync_dependabot-changesets.yml @@ -16,7 +16,7 @@ jobs: egress-policy: audit - name: Checkout - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: fetch-depth: 2 ref: ${{ github.head_ref }} diff --git a/.github/workflows/sync_release-manifest.yml b/.github/workflows/sync_release-manifest.yml index 46d5d5382a..d56137412d 100644 --- a/.github/workflows/sync_release-manifest.yml +++ b/.github/workflows/sync_release-manifest.yml @@ -21,7 +21,7 @@ jobs: run: npm install semver@7.3.5 fs-extra@10.0.0 @manypkg/get-packages@1.1.1 - name: Checkout - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: path: backstage # 'v' prefix is added here for the tag, we keep it out of the manifest logic @@ -29,7 +29,7 @@ jobs: # Checkout backstage/versions into /backstage/versions, which is where store the output - name: Checkout versions - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: repository: backstage/versions path: backstage/versions diff --git a/.github/workflows/sync_renovate-changesets.yml b/.github/workflows/sync_renovate-changesets.yml index 738abcf773..88b1430784 100644 --- a/.github/workflows/sync_renovate-changesets.yml +++ b/.github/workflows/sync_renovate-changesets.yml @@ -16,7 +16,7 @@ jobs: egress-policy: audit - name: Checkout - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: fetch-depth: 2 ref: ${{ github.head_ref }} diff --git a/.github/workflows/sync_snyk-github-issues.yml b/.github/workflows/sync_snyk-github-issues.yml index 551ef559a1..aecf64a1f4 100644 --- a/.github/workflows/sync_snyk-github-issues.yml +++ b/.github/workflows/sync_snyk-github-issues.yml @@ -16,7 +16,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js 18.x uses: actions/setup-node@v3.8.1 diff --git a/.github/workflows/sync_snyk-monitor.yml b/.github/workflows/sync_snyk-monitor.yml index 3c41aedee3..9268fc4975 100644 --- a/.github/workflows/sync_snyk-monitor.yml +++ b/.github/workflows/sync_snyk-monitor.yml @@ -29,7 +29,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: Monitor and Synchronize Snyk Policies uses: snyk/actions/node@39091e69b560da335383b404e50d65b408f4f812 # master with: diff --git a/.github/workflows/sync_version-packages.yml b/.github/workflows/sync_version-packages.yml index 929fb9cc89..4ff6ce94f3 100644 --- a/.github/workflows/sync_version-packages.yml +++ b/.github/workflows/sync_version-packages.yml @@ -18,7 +18,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 with: fetch-depth: 20000 fetch-tags: true diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 375c6bdcd2..c53083307b 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -25,7 +25,7 @@ jobs: egress-policy: audit - name: checkout - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 - name: setup-node uses: actions/setup-node@v3.8.1 @@ -87,7 +87,7 @@ jobs: egress-policy: audit - name: Checkout git repo - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 - name: Render Compose File run: | BACKSTAGE_IMAGE=$(echo ${{ needs.build-backstage.outputs.tags }}) diff --git a/.github/workflows/verify_accessibility.yml b/.github/workflows/verify_accessibility.yml index f34f2f5506..ba85fcdb19 100644 --- a/.github/workflows/verify_accessibility.yml +++ b/.github/workflows/verify_accessibility.yml @@ -24,7 +24,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: Use Node.js 18.x uses: actions/setup-node@v3.8.1 with: diff --git a/.github/workflows/verify_codeql.yml b/.github/workflows/verify_codeql.yml index fb29fb78e1..59aa41ff55 100644 --- a/.github/workflows/verify_codeql.yml +++ b/.github/workflows/verify_codeql.yml @@ -47,7 +47,7 @@ jobs: egress-policy: audit - name: Checkout repository - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/.github/workflows/verify_docs-quality.yml b/.github/workflows/verify_docs-quality.yml index ce457a234f..f1932d5afa 100644 --- a/.github/workflows/verify_docs-quality.yml +++ b/.github/workflows/verify_docs-quality.yml @@ -16,7 +16,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 # Vale does not support file excludes, so we use the script to generate a list of files instead # The action also does not allow args or a local config file to be passed in, so the files array diff --git a/.github/workflows/verify_e2e-kubernetes.yml b/.github/workflows/verify_e2e-kubernetes.yml index ea77609614..2491282a13 100644 --- a/.github/workflows/verify_e2e-kubernetes.yml +++ b/.github/workflows/verify_e2e-kubernetes.yml @@ -26,7 +26,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.8.1 diff --git a/.github/workflows/verify_e2e-linux.yml b/.github/workflows/verify_e2e-linux.yml index 6b61053628..9ec1672d0b 100644 --- a/.github/workflows/verify_e2e-linux.yml +++ b/.github/workflows/verify_e2e-linux.yml @@ -44,7 +44,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: Configure Git run: | diff --git a/.github/workflows/verify_e2e-techdocs.yml b/.github/workflows/verify_e2e-techdocs.yml index de43a4f5ac..96645c9b0b 100644 --- a/.github/workflows/verify_e2e-techdocs.yml +++ b/.github/workflows/verify_e2e-techdocs.yml @@ -34,7 +34,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - uses: actions/setup-python@v4.7.1 with: python-version: '3.9' diff --git a/.github/workflows/verify_e2e-windows.yml b/.github/workflows/verify_e2e-windows.yml index 7eba130ed8..fa3568974a 100644 --- a/.github/workflows/verify_e2e-windows.yml +++ b/.github/workflows/verify_e2e-windows.yml @@ -42,7 +42,7 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: Configure Git run: | diff --git a/.github/workflows/verify_fossa.yml b/.github/workflows/verify_fossa.yml index 393bcf9631..7918efe333 100644 --- a/.github/workflows/verify_fossa.yml +++ b/.github/workflows/verify_fossa.yml @@ -19,7 +19,7 @@ jobs: egress-policy: audit - name: Checkout - uses: actions/checkout@v3.6.0 + uses: actions/checkout@v4.1.1 - name: Install Fossa run: "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash" diff --git a/.github/workflows/verify_microsite.yml b/.github/workflows/verify_microsite.yml index f0705bedc7..e69ca1fd3e 100644 --- a/.github/workflows/verify_microsite.yml +++ b/.github/workflows/verify_microsite.yml @@ -28,7 +28,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js 18.x uses: actions/setup-node@v3.8.1 diff --git a/.github/workflows/verify_storybook.yml b/.github/workflows/verify_storybook.yml index fe481f9882..3cf7e7e194 100644 --- a/.github/workflows/verify_storybook.yml +++ b/.github/workflows/verify_storybook.yml @@ -32,7 +32,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 # Required to retrieve git history diff --git a/.github/workflows/verify_windows.yml b/.github/workflows/verify_windows.yml index f2c61938d8..cbe312ed38 100644 --- a/.github/workflows/verify_windows.yml +++ b/.github/workflows/verify_windows.yml @@ -33,7 +33,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@v3.6.0 + - uses: actions/checkout@v4.1.1 - name: use node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.8.1 From 3b9821cfa30774057e20e43c7fce89af78f3e790 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:28:44 +0000 Subject: [PATCH 18/34] chore(deps): update dependency @types/dagre to v0.7.51 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 710fc49f31..b613014db0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18523,9 +18523,9 @@ __metadata: linkType: hard "@types/dagre@npm:^0.7.44": - version: 0.7.50 - resolution: "@types/dagre@npm:0.7.50" - checksum: a128048b5202c501a4595bbc17288aafbef90f3535e79385ddaf0842237e69aa5998dbc12bc2867244eefe3fb6c5026d9785bfdedea46d813f006066e06e8f44 + version: 0.7.51 + resolution: "@types/dagre@npm:0.7.51" + checksum: 6a23cc406082fe867dc0be0a117ae0c493bcfb6e08b83ea55a09b4f43e6eb5efc34a102d1a039fa82d2df700d55ee5481c0c3febdf710b972bb345c8a7f6c316 languageName: node linkType: hard From 1956882a3615b8cb4b45e9adfc3c7585acce5371 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:00:25 +0000 Subject: [PATCH 19/34] chore(deps): update dependency @types/diff to v5.0.7 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f479fe8c9b..8ba4eb6db7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18539,9 +18539,9 @@ __metadata: linkType: hard "@types/diff@npm:^5.0.0": - version: 5.0.6 - resolution: "@types/diff@npm:5.0.6" - checksum: 8ce79492a89d568b54792a8491d01b1ff69526e19560670ef2de078c467738cdc0aae81fc4f895e49f915a2b9bbf694f6f95a2e5544e7c0989448956eba9ff66 + version: 5.0.7 + resolution: "@types/diff@npm:5.0.7" + checksum: 38cad7b1e19789a11bfab2428409476ea204705e92c39dd13a9ba26b604930efcffb553352512296cb179adfb028e2d95e51f9df2b7443bb0a6ba306c8bc84d0 languageName: node linkType: hard From d7def5d0cb1d6ef630b73323aca1b49e4ab82c3b Mon Sep 17 00:00:00 2001 From: Alex Crome Date: Wed, 25 Oct 2023 21:49:23 +0100 Subject: [PATCH 20/34] PR Feedback * Tidy up passing of domain hint from initalisation to later methods * Tidy up change set Signed-off-by: Alex Crome --- .changeset/gentle-pumpkins-carry.md | 15 ++--------- .../src/authenticator.ts | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.changeset/gentle-pumpkins-carry.md b/.changeset/gentle-pumpkins-carry.md index 22abd16798..721fbe8195 100644 --- a/.changeset/gentle-pumpkins-carry.md +++ b/.changeset/gentle-pumpkins-carry.md @@ -1,16 +1,5 @@ --- -'@backstage/plugin-auth-backend-module-microsoft-provider': minor +'@backstage/plugin-auth-backend-module-microsoft-provider': patch --- -Added support for specifying a `domain_hint` on Microsoft authentication provider configuration. -This should typically be set to the same value as your `tenantId`. -If you allow users from multiple tenants to authenticate, then leave this blank. - -```yaml -auth: - providers: - microsoft: - development: - #... - domainHint: ${AZURE_TENANT_ID} -``` +Added support for specifying a domain hint on the Microsoft authentication provider configuration. diff --git a/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts b/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts index edf985b0f2..9687c7ce1a 100644 --- a/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts +++ b/plugins/auth-backend-module-microsoft-provider/src/authenticator.ts @@ -22,8 +22,6 @@ import { PassportProfile, } from '@backstage/plugin-auth-node'; -let domainHint: string | undefined = undefined; - /** @public */ export const microsoftAuthenticator = createOAuthAuthenticator({ defaultProfileTransform: @@ -32,9 +30,9 @@ export const microsoftAuthenticator = createOAuthAuthenticator({ const clientId = config.getString('clientId'); const clientSecret = config.getString('clientSecret'); const tenantId = config.getString('tenantId'); - domainHint = config.getOptionalString('domainHint'); + const domainHint = config.getOptionalString('domainHint'); - return PassportOAuthAuthenticatorHelper.from( + const helper = PassportOAuthAuthenticatorHelper.from( new MicrosoftStrategy( { clientID: clientId, @@ -58,25 +56,30 @@ export const microsoftAuthenticator = createOAuthAuthenticator({ }, ), ); + + return { + helper, + domainHint, + }; }, - async start(input, helper) { + async start(input, ctx) { const options: Record = { accessType: 'offline', }; - if (domainHint !== undefined) { - options.domain_hint = domainHint; + if (ctx.domainHint !== undefined) { + options.domain_hint = ctx.domainHint; } - return helper.start(input, options); + return ctx.helper.start(input, options); }, - async authenticate(input, helper) { - return helper.authenticate(input); + async authenticate(input, ctx) { + return ctx.helper.authenticate(input); }, - async refresh(input, helper) { - return helper.refresh(input); + async refresh(input, ctx) { + return ctx.helper.refresh(input); }, }); From 08aa1d0dbee30cf06b30fe7e687c6b69418d6f99 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:11:33 +0000 Subject: [PATCH 21/34] chore(deps): update dependency @types/event-source-polyfill to v1.0.3 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 344d73fbb2..95a36da1e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18625,9 +18625,9 @@ __metadata: linkType: hard "@types/event-source-polyfill@npm:^1.0.0": - version: 1.0.2 - resolution: "@types/event-source-polyfill@npm:1.0.2" - checksum: f0813edfee0af768e6e0994b48f9f618df7a5d9023c383a8f35e9e805dec560222dc40fc583d5f1404977febb7353c27c1d0606c67d948a2d18634c18ae437a9 + version: 1.0.3 + resolution: "@types/event-source-polyfill@npm:1.0.3" + checksum: ba525e521ff82de5dad727066174c61fc59680a5703324c4c62cbb11c0a14fbabeabf4d17e6d5051ef995c232a40ff43a8d1f4cea0dde9564bf28c92bb361726 languageName: node linkType: hard From 692e2397c23d19a8edbc8eea4f9657688887e496 Mon Sep 17 00:00:00 2001 From: Alex Crome Date: Wed, 25 Oct 2023 22:36:08 +0100 Subject: [PATCH 22/34] Update api report Signed-off-by: Alex Crome --- plugins/auth-backend-module-microsoft-provider/api-report.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/auth-backend-module-microsoft-provider/api-report.md b/plugins/auth-backend-module-microsoft-provider/api-report.md index 60192c5cbc..21bf77d545 100644 --- a/plugins/auth-backend-module-microsoft-provider/api-report.md +++ b/plugins/auth-backend-module-microsoft-provider/api-report.md @@ -15,7 +15,10 @@ export const authModuleMicrosoftProvider: () => BackendFeature; // @public (undocumented) export const microsoftAuthenticator: OAuthAuthenticator< - PassportOAuthAuthenticatorHelper, + { + helper: PassportOAuthAuthenticatorHelper; + domainHint: string | undefined; + }, PassportProfile >; From cbbd3bed2b6e8093c98a2972ee61088934757b1a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 22:08:11 +0000 Subject: [PATCH 23/34] chore(deps): update dependency @types/express-session to v1.17.9 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 95a36da1e6..3043208e89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18651,11 +18651,11 @@ __metadata: linkType: hard "@types/express-session@npm:^1.17.2": - version: 1.17.8 - resolution: "@types/express-session@npm:1.17.8" + version: 1.17.9 + resolution: "@types/express-session@npm:1.17.9" dependencies: "@types/express": "*" - checksum: e1af8797b321ce05e0732c58aa982f00ab34b6edb337c289092e66c789ae1bbb4ca14d2caa0e0ff02522047402bcff828873b035e2785fb92f2381a0eb34240c + checksum: e66d50742a27389f3f1bb03b30eb96d74daf357db6cc5e549265e6610f2cff14539fec7e2b72c3f98ab1174eff7ed347e3fe4d3a2b9273a6d1367d78ee0add71 languageName: node linkType: hard From 0143fc7e1e6a54189d559b18d10c954bd9d7ce0f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 23:08:06 +0000 Subject: [PATCH 24/34] chore(deps): update dependency @types/git-url-parse to v9.0.2 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3043208e89..bcec7042ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18688,9 +18688,9 @@ __metadata: linkType: hard "@types/git-url-parse@npm:^9.0.0": - version: 9.0.1 - resolution: "@types/git-url-parse@npm:9.0.1" - checksum: 9d1678a0aff50b6e77a172965070de34d2e89bc6ccc96c94ea3b2ecf250c602c0daff4b9f4e0eb830e53e81ee273b08f15f728d42ec087f1a95e4f51d57b594a + version: 9.0.2 + resolution: "@types/git-url-parse@npm:9.0.2" + checksum: af0a935b80d76f2441686f55b43755f5ccc3e5ddb21ae9663df0f55a4954aa9f1f4ddbcad729e3f2365cd09a2a38abb14baec95b9f26aa67e490fc90797d5e0b languageName: node linkType: hard From ee483ddb7b7b70a127cf29e2b717c3e25d82edb5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 00:38:53 +0000 Subject: [PATCH 25/34] chore(deps): update dependency @types/http-errors to v2.0.3 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bcec7042ce..3d00feb37a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18763,9 +18763,9 @@ __metadata: linkType: hard "@types/http-errors@npm:^2.0.0": - version: 2.0.2 - resolution: "@types/http-errors@npm:2.0.2" - checksum: d7f14045240ac4b563725130942b8e5c8080bfabc724c8ff3f166ea928ff7ae02c5194763bc8f6aaf21897e8a44049b0492493b9de3e058247e58fdfe0f86692 + version: 2.0.3 + resolution: "@types/http-errors@npm:2.0.3" + checksum: ea9530fb6e8a0400c4f9aac4dd628c5074f0adc8d01e2cdb917c0b97c230dedf4fcc67eadb491377b0eff5778e566648e63613a9719e383185318b9ec8c009b9 languageName: node linkType: hard From be93086cc8791c86583356aaa6b0b9683093b97d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 00:39:24 +0000 Subject: [PATCH 26/34] chore(deps): update dependency @types/http-proxy to v1.17.13 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bcec7042ce..d88080e9aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18781,11 +18781,11 @@ __metadata: linkType: hard "@types/http-proxy@npm:*, @types/http-proxy@npm:^1.17.4, @types/http-proxy@npm:^1.17.8": - version: 1.17.12 - resolution: "@types/http-proxy@npm:1.17.12" + version: 1.17.13 + resolution: "@types/http-proxy@npm:1.17.13" dependencies: "@types/node": "*" - checksum: 89700c8e3c8f2c59c87c8db8e7a070c97a3b30a4a38223aca6b8b817e6f2ca931f5a500e16ecadc1ebcfed2676cc60e073d8f887e621d84420298728ec6fd000 + checksum: 09e2d59db4689c46a6676496c355cac5499457ce61085121bfab64b8a825fde320574f22f981a8db3f1e9e977ddef55889f99da7f1ff485ac51f22b94308bf12 languageName: node linkType: hard From 557da147d23ec576a222e41c560a83ce738cc3b0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 01:41:12 +0000 Subject: [PATCH 27/34] chore(deps): update dependency @types/humanize-duration to v3.27.2 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3d00feb37a..1313e15eb1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18790,9 +18790,9 @@ __metadata: linkType: hard "@types/humanize-duration@npm:^3.18.1, @types/humanize-duration@npm:^3.25.1, @types/humanize-duration@npm:^3.27.1": - version: 3.27.1 - resolution: "@types/humanize-duration@npm:3.27.1" - checksum: d3d69b64918d0cee4aa69580dd04d1b96e3385645d398e27b1535f8c6d0252b0235defb16619379a6196c6bbdfc7b6032f010b25cac44903a32b09db8aa06f30 + version: 3.27.2 + resolution: "@types/humanize-duration@npm:3.27.2" + checksum: e33fd83f859085cc8e34884f492ec028d5a5d9992c3b1be66f7b4949daef6b248b299d3f96b09a5ee077b2884c2bd99cdc3bd98531863c86527d6e662b3e8a82 languageName: node linkType: hard From 08eb49248931c68551bb669d7a23bfdcf88d3e54 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 01:41:44 +0000 Subject: [PATCH 28/34] chore(deps): update dependency @types/inquirer to v8.2.9 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3d00feb37a..de7c43007c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18797,12 +18797,12 @@ __metadata: linkType: hard "@types/inquirer@npm:^8.1.3": - version: 8.2.7 - resolution: "@types/inquirer@npm:8.2.7" + version: 8.2.9 + resolution: "@types/inquirer@npm:8.2.9" dependencies: "@types/through": "*" rxjs: ^7.2.0 - checksum: 8f021bc2ad0cdcccbd55abd11a8ecc73f716ea108f2ffb5f8f605d23519b47acb46fdcac032d8c81e7c05f183c0f2300a0a394c449ad8980bc11f333708d4387 + checksum: eee240953215ec85901fdfa391595c2ee0b2e61fb9abf1c5708f665ae558effd1359252375956d3eb73364621c9edf5f74329e0c535814cd5fef68bc192408ca languageName: node linkType: hard From 38e6a415f01906c643249b30bb1aaa0bdc123822 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 02:11:43 +0000 Subject: [PATCH 29/34] chore(deps): update dependency @types/is-glob to v4.0.3 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 986b0a0a69..76761802a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18816,9 +18816,9 @@ __metadata: linkType: hard "@types/is-glob@npm:^4.0.2": - version: 4.0.2 - resolution: "@types/is-glob@npm:4.0.2" - checksum: 50b0a52b6d179781b36bfce35155e1e0dc66b62e2943153d7d7c7079c40ba6236528a254de8be6c52ff9a7a351996887802efd7fd763da3e2121315e4ffe2edf + version: 4.0.3 + resolution: "@types/is-glob@npm:4.0.3" + checksum: 65686e645f1e8125b5a01df5b2d2b247c8e5a23790363538005454d68ba7bd9662cd3bcfbdda9f8eb0a85fb5fccd164645555c8e0c34db63c8c65998fd5909dd languageName: node linkType: hard From dd832203644e29be996a39475c611d23ae76a28a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 02:35:14 +0000 Subject: [PATCH 30/34] chore(deps): update dependency @types/jest-when to v3.5.4 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7a2a759203..e82039b1df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18857,11 +18857,11 @@ __metadata: linkType: hard "@types/jest-when@npm:^3.5.0": - version: 3.5.3 - resolution: "@types/jest-when@npm:3.5.3" + version: 3.5.4 + resolution: "@types/jest-when@npm:3.5.4" dependencies: "@types/jest": "*" - checksum: 5dc2661ad570b80b8f97d7dabc50a0229f21818eefc73024b88a70216c2666f56bd97769fef565263d7242878f8187531bb14427dcb06709e9b98a1671668e9d + checksum: 58a9a7b2dd81cb2c87c3d3539d03dc82c72a66282b3930237ad30641d0c27d7c2b9de2cb9da05b0d287bb6d890f82601935ca4e616a1828e5e05ebb4fc444270 languageName: node linkType: hard From 00c779224466245666bb76bdecbf644cb9628c61 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 03:12:22 +0000 Subject: [PATCH 31/34] chore(deps): update dependency @types/jquery to v3.5.25 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1885ca7d2a..2ae2441f8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18886,11 +18886,11 @@ __metadata: linkType: hard "@types/jquery@npm:^3.3.34": - version: 3.5.22 - resolution: "@types/jquery@npm:3.5.22" + version: 3.5.25 + resolution: "@types/jquery@npm:3.5.25" dependencies: "@types/sizzle": "*" - checksum: b81c95e27bb30686c1ad5d3f414781243d0cbb468b91d5584dedd3d3ca07ac99796d876e257a7246d6d9b69916bbb0cd0508142ab9f88848605c6d431144d729 + checksum: 912ce4212447a7c640147345c6b46bde5b12bafc2c97e1abc76939174c3109e3dbb361a534af717be2da4e907bc257558a6bc631971fcc47f7e5f044d315183e languageName: node linkType: hard From d38570ec2527657be5acaf36d9bd8d4d42cf621d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 04:10:59 +0000 Subject: [PATCH 32/34] chore(deps): update dependency @types/jscodeshift to v0.11.9 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bd78794ab0..2ad4486c4e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18916,12 +18916,12 @@ __metadata: linkType: hard "@types/jscodeshift@npm:^0.11.0": - version: 0.11.7 - resolution: "@types/jscodeshift@npm:0.11.7" + version: 0.11.9 + resolution: "@types/jscodeshift@npm:0.11.9" dependencies: ast-types: ^0.14.1 recast: ^0.20.3 - checksum: c6b81d537dca08c24db76e5e75d6056ef7c5b7651aebc319277321e2f2421984cc237ac71593dec374e49f9eae28c22150a37de3a572f141d55382c193091899 + checksum: a5b0bc6250dad3dfbaa9af71f56e65979cbfb632ee3d8da43bd79e729eaf231bc15356cc5de45c7e1f634881ab541f712cdbf554f89032273819c49bc397882e languageName: node linkType: hard From b282e278560a58559b1bbbcfb4a9c5472c0d1956 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 04:11:29 +0000 Subject: [PATCH 33/34] chore(deps): update dependency @types/json-schema to v7.0.14 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bd78794ab0..2dd5b53a74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18946,9 +18946,9 @@ __metadata: linkType: hard "@types/json-schema@npm:*, @types/json-schema@npm:^7.0.11, @types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.6, @types/json-schema@npm:^7.0.7, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": - version: 7.0.13 - resolution: "@types/json-schema@npm:7.0.13" - checksum: 345df21a678fa72fb389f35f33de77833d09d4a142bb2bcb27c18690efa4cf70fc2876e43843cefb3fbdb9fcb12cd3e970a90936df30f53bbee899865ff605ab + version: 7.0.14 + resolution: "@types/json-schema@npm:7.0.14" + checksum: 4b3dd99616c7c808201c56f6c7f6552eb67b5c0c753ab3fa03a6cb549aae950da537e9558e53fa65fba23d1be624a1e4e8d20c15027efbe41e03ca56f2b04fb0 languageName: node linkType: hard From d86b2acec47bf571883f3b71faab451b873834ed Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Oct 2023 10:55:25 -0400 Subject: [PATCH 34/34] Fix VisitsStorageApi retrieveAll method to return all visits synchronously Signed-off-by: Benjamin --- .changeset/curvy-carrots-thank.md | 5 ++++ plugins/home/src/api/VisitsStorageApi.ts | 38 +++++++++++++++++------- 2 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 .changeset/curvy-carrots-thank.md diff --git a/.changeset/curvy-carrots-thank.md b/.changeset/curvy-carrots-thank.md new file mode 100644 index 0000000000..6303125314 --- /dev/null +++ b/.changeset/curvy-carrots-thank.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-home': patch +--- + +Fix bug where `retrieveAll` method wasn't fetching visits diff --git a/plugins/home/src/api/VisitsStorageApi.ts b/plugins/home/src/api/VisitsStorageApi.ts index daf24d716b..c72d4c5d64 100644 --- a/plugins/home/src/api/VisitsStorageApi.ts +++ b/plugins/home/src/api/VisitsStorageApi.ts @@ -117,23 +117,39 @@ export class VisitsStorageApi implements VisitsApi { } private async persistAll(visits: Array) { - const { userEntityRef } = await this.identityApi.getBackstageIdentity(); - const storageKey = `${this.storageKeyPrefix}:${userEntityRef}`; - + const storageKey = await this.getStorageKey(); return this.storageApi.set>(storageKey, visits); } private async retrieveAll(): Promise> { + const storageKey = await this.getStorageKey(); + // Handles for case when snapshot is and is not referenced per storaged type used + const snapshot = this.storageApi.snapshot>(storageKey); + if (snapshot?.presence !== 'unknown') { + return snapshot?.value ?? []; + } + + return new Promise((resolve, reject) => { + const subsription = this.storageApi + .observe$(storageKey) + .subscribe({ + next: next => { + const visits = next.value ?? []; + subsription.unsubscribe(); + resolve(visits); + }, + error: err => { + subsription.unsubscribe(); + reject(err); + }, + }); + }); + } + + private async getStorageKey(): Promise { const { userEntityRef } = await this.identityApi.getBackstageIdentity(); const storageKey = `${this.storageKeyPrefix}:${userEntityRef}`; - let visits: Array; - - try { - visits = this.storageApi.snapshot>(storageKey).value ?? []; - } catch { - visits = []; - } - return visits; + return storageKey; } // This assumes Visit fields are either numbers or strings