diff --git a/.changeset/shaggy-gorillas-occur.md b/.changeset/shaggy-gorillas-occur.md index 94b0f6c21d..149ff6f424 100644 --- a/.changeset/shaggy-gorillas-occur.md +++ b/.changeset/shaggy-gorillas-occur.md @@ -2,6 +2,8 @@ '@backstage/plugin-linguist-backend': patch --- +**BREAKING**: Removed public constructor from `LinguistBackendApi`. Removed export of `LinguistBackendDatabase` and `LinguistBackendDatabase` + Several improvements to the Linguist backend have been made: - Added tests for the `LinguistBackendDatabase` and `LinguistBackendApi` diff --git a/plugins/linguist-backend/src/api/LinguistBackendClient.ts b/plugins/linguist-backend/src/api/LinguistBackendClient.ts index 0bd6370ac3..5a84201bcb 100644 --- a/plugins/linguist-backend/src/api/LinguistBackendClient.ts +++ b/plugins/linguist-backend/src/api/LinguistBackendClient.ts @@ -170,7 +170,6 @@ export class LinguistBackendClient implements LinguistBackendApi { try { await this.generateEntityLanguages(entityRef, url); } catch (error) { - console.log(error); assertError(error); this.logger.error( `Unable to process "${entityRef}" using "${url}", message: ${error.message}, stack: ${error.stack}`, diff --git a/plugins/linguist-backend/src/db/LinguistBackendDatabase.ts b/plugins/linguist-backend/src/db/LinguistBackendDatabase.ts index 2a15b2d823..12f44a5dca 100644 --- a/plugins/linguist-backend/src/db/LinguistBackendDatabase.ts +++ b/plugins/linguist-backend/src/db/LinguistBackendDatabase.ts @@ -93,7 +93,7 @@ export class LinguistBackendDatabase implements LinguistBackendStore { .where({ entity_ref: entityRef }) .first(); - if (!entityResults) { + if (!entityResults || !entityResults.languages) { const emptyResults: Languages = { languageCount: 0, totalBytes: 0, @@ -104,7 +104,7 @@ export class LinguistBackendDatabase implements LinguistBackendStore { } try { - return JSON.parse(entityResults.languages as string); + return JSON.parse(entityResults.languages); } catch (error) { throw new Error(`Failed to parse languages for '${entityRef}', ${error}`); }