diff --git a/.changeset/eighty-geese-return.md b/.changeset/eighty-geese-return.md new file mode 100644 index 0000000000..49361de8e7 --- /dev/null +++ b/.changeset/eighty-geese-return.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-msgraph': patch +--- + +Revert using `baseUrl` for MS Graph provider as it breaks token retrieval diff --git a/.changeset/gentle-pears-clean.md b/.changeset/gentle-pears-clean.md new file mode 100644 index 0000000000..d92c3709ae --- /dev/null +++ b/.changeset/gentle-pears-clean.md @@ -0,0 +1,5 @@ +--- +'@backstage/eslint-plugin': patch +--- + +Fixing a bug that we should check internal dependencies too diff --git a/.changeset/polite-chicken-do.md b/.changeset/polite-chicken-do.md new file mode 100644 index 0000000000..33e4149253 --- /dev/null +++ b/.changeset/polite-chicken-do.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-vault-backend': patch +--- + +Ignore the `eslint` error diff --git a/.changeset/spotty-bees-tell.md b/.changeset/spotty-bees-tell.md new file mode 100644 index 0000000000..5267d8a6a0 --- /dev/null +++ b/.changeset/spotty-bees-tell.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch +'@backstage/plugin-catalog-backend-module-aws': patch +--- + +Fix missing `dependencies` in `package.json` diff --git a/.changeset/swift-bags-wave.md b/.changeset/swift-bags-wave.md new file mode 100644 index 0000000000..8f57c7f89b --- /dev/null +++ b/.changeset/swift-bags-wave.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-sonarqube-react': patch +'@backstage/plugin-sonarqube': patch +--- + +Moved imports from `/alpha` to main public exports. diff --git a/packages/e2e-test/package.json b/packages/e2e-test/package.json index ee447a1736..718f8fd079 100644 --- a/packages/e2e-test/package.json +++ b/packages/e2e-test/package.json @@ -28,6 +28,7 @@ "bin": "bin/e2e-test", "dependencies": { "@backstage/cli-common": "workspace:^", + "@backstage/create-app": "workspace:^", "@backstage/errors": "workspace:^", "chalk": "^4.0.0", "commander": "^9.1.0", diff --git a/packages/eslint-plugin/lib/visitImports.js b/packages/eslint-plugin/lib/visitImports.js index 43401bf5f9..1a344c1101 100644 --- a/packages/eslint-plugin/lib/visitImports.js +++ b/packages/eslint-plugin/lib/visitImports.js @@ -34,6 +34,7 @@ const getPackages = require('./getPackages'); * @property {'value' | 'type'} kind * @property {string} path * @property {import('./getPackages').ExtendedPackage} package + * @property {string} packageName */ /** @@ -160,6 +161,7 @@ module.exports = function visitImports(context, visitor) { kind: info.kind, path: subPath, package: pkg, + packageName, }); } diff --git a/packages/eslint-plugin/rules/no-undeclared-imports.js b/packages/eslint-plugin/rules/no-undeclared-imports.js index 42624beb5c..b1e11d1b97 100644 --- a/packages/eslint-plugin/rules/no-undeclared-imports.js +++ b/packages/eslint-plugin/rules/no-undeclared-imports.js @@ -151,11 +151,18 @@ module.exports = { } return visitImports(context, (node, imp) => { - if (imp.type !== 'external') { + // We leave checking of type imports to the repo-tools check, + // and we skip builtins and local imports + if ( + imp.kind === 'type' || + imp.type === 'builtin' || + imp.type === 'local' + ) { return; } - // We leave checking of type imports to the repo-tools check - if (imp.kind === 'type') { + + // We skip imports for the package itself + if (imp.packageName === localPkg.packageJson.name) { return; } diff --git a/packages/eslint-plugin/src/__fixtures__/monorepo/packages/node_modules/@internal/foo/index.js b/packages/eslint-plugin/src/__fixtures__/monorepo/packages/node_modules/@internal/foo/index.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/eslint-plugin/src/__fixtures__/monorepo/packages/node_modules/@internal/foo/package.json b/packages/eslint-plugin/src/__fixtures__/monorepo/packages/node_modules/@internal/foo/package.json new file mode 100644 index 0000000000..c15a2c1718 --- /dev/null +++ b/packages/eslint-plugin/src/__fixtures__/monorepo/packages/node_modules/@internal/foo/package.json @@ -0,0 +1,17 @@ +{ + "name": "@internal/foo", + "main": "index.js", + "dependencies": { + "@internal/bar": "1.0.0" + }, + "devDependencies": { + "lodash": "*" + }, + "peerDependencies": { + "react": "*" + }, + "files": [ + "dist", + "type-utils" + ] +} diff --git a/packages/eslint-plugin/src/no-undeclared-imports.test.ts b/packages/eslint-plugin/src/no-undeclared-imports.test.ts index 1b5cbee853..78844899ba 100644 --- a/packages/eslint-plugin/src/no-undeclared-imports.test.ts +++ b/packages/eslint-plugin/src/no-undeclared-imports.test.ts @@ -236,5 +236,16 @@ ruleTester.run(RULE, rule, { ), ], }, + { + code: `import '@internal/foo'`, + filename: joinPath(FIXTURE, 'packages/bar/src/index.ts'), + errors: [ + ERR_UNDECLARED( + '@internal/foo', + 'dependencies', + joinPath('packages', 'bar'), + ), + ], + }, ], }); diff --git a/plugins/auth-backend/package.json b/plugins/auth-backend/package.json index 3481ae2714..dee7f6e442 100644 --- a/plugins/auth-backend/package.json +++ b/plugins/auth-backend/package.json @@ -78,6 +78,7 @@ "devDependencies": { "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", + "@backstage/test-utils": "workspace:^", "@types/body-parser": "^1.19.0", "@types/cookie-parser": "^1.4.2", "@types/express-session": "^1.17.2", diff --git a/plugins/catalog-backend-module-aws/package.json b/plugins/catalog-backend-module-aws/package.json index 4082a4f83b..f583d64792 100644 --- a/plugins/catalog-backend-module-aws/package.json +++ b/plugins/catalog-backend-module-aws/package.json @@ -41,7 +41,9 @@ "@backstage/errors": "workspace:^", "@backstage/integration": "workspace:^", "@backstage/plugin-catalog-backend": "workspace:^", + "@backstage/plugin-catalog-common": "workspace:^", "@backstage/plugin-catalog-node": "workspace:^", + "@backstage/plugin-kubernetes-common": "workspace:^", "@backstage/types": "workspace:^", "aws-sdk": "^2.840.0", "lodash": "^4.17.21", diff --git a/plugins/catalog-backend-module-incremental-ingestion/package.json b/plugins/catalog-backend-module-incremental-ingestion/package.json index 9a09ea6ca2..ff8272e29e 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/package.json +++ b/plugins/catalog-backend-module-incremental-ingestion/package.json @@ -34,6 +34,7 @@ }, "dependencies": { "@backstage/backend-common": "workspace:^", + "@backstage/backend-defaults": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-tasks": "workspace:^", "@backstage/catalog-model": "workspace:^", diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/run.ts b/plugins/catalog-backend-module-incremental-ingestion/src/run.ts index e9cc7dbb2a..eb66140fe2 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/run.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/run.ts @@ -13,8 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { coreServices } from '@backstage/backend-plugin-api'; -import { startTestBackend } from '@backstage/backend-test-utils'; +import { createBackend } from '@backstage/backend-defaults'; +import { + coreServices, + createServiceFactory, +} from '@backstage/backend-plugin-api'; import { ConfigReader } from '@backstage/config'; import { catalogPlugin } from '@backstage/plugin-catalog-backend'; import { @@ -46,25 +49,33 @@ async function main() { }, }; - await startTestBackend({ - services: [[coreServices.config, new ConfigReader(config)]], - extensionPoints: [], - features: [ - catalogPlugin(), - incrementalIngestionEntityProviderCatalogModule({ - providers: [ - { - provider: provider, - options: { - burstInterval: { seconds: 1 }, - burstLength: { seconds: 10 }, - restLength: { seconds: 10 }, - }, - }, - ], + const backend = createBackend({ + services: [ + createServiceFactory({ + service: coreServices.config, + deps: {}, + factory: () => new ConfigReader(config), }), ], }); + + backend.add(catalogPlugin()); + backend.add( + incrementalIngestionEntityProviderCatalogModule({ + providers: [ + { + provider: provider, + options: { + burstInterval: { seconds: 1 }, + burstLength: { seconds: 10 }, + restLength: { seconds: 10 }, + }, + }, + ], + }), + ); + + await backend.start(); } main().catch(error => { diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts index f7d98f12c6..f621b4d924 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts @@ -53,7 +53,7 @@ describe('MicrosoftGraphClient', () => { expect(await response.json()).toEqual({ value: 'example' }); expect(tokenCredential.getToken).toHaveBeenCalledTimes(1); expect(tokenCredential.getToken).toHaveBeenCalledWith( - 'https://example.com/.default', + 'https://graph.microsoft.com/.default', ); }); diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts index 7a685b258d..c644e545d6 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts @@ -219,7 +219,7 @@ export class MicrosoftGraphClient { ): Promise { // Make sure that we always have a valid access token (might be cached) const token = await this.tokenCredential.getToken( - `${this.baseUrl}/.default`, + 'https://graph.microsoft.com/.default', ); if (!token) { diff --git a/plugins/sonarqube-react/api-report.md b/plugins/sonarqube-react/api-report.md index be84c45cce..6ffa98915b 100644 --- a/plugins/sonarqube-react/api-report.md +++ b/plugins/sonarqube-react/api-report.md @@ -6,7 +6,7 @@ import { ApiRef } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; -// @alpha (undocumented) +// @public (undocumented) export interface FindingSummary { // (undocumented) getComponentMeasuresUrl: SonarUrlProcessorFunc; @@ -25,7 +25,7 @@ export interface FindingSummary { // @public (undocumented) export const isSonarQubeAvailable: (entity: Entity) => boolean; -// @alpha (undocumented) +// @public (undocumented) export type MetricKey = | 'alert_status' | 'bugs' @@ -39,7 +39,7 @@ export type MetricKey = | 'coverage' | 'duplicated_lines_density'; -// @alpha +// @public export type Metrics = { [key in MetricKey]: string | undefined; }; @@ -47,7 +47,7 @@ export type Metrics = { // @public (undocumented) export const SONARQUBE_PROJECT_KEY_ANNOTATION = 'sonarqube.org/project-key'; -// @alpha (undocumented) +// @public (undocumented) export type SonarQubeApi = { getFindingSummary(options: { componentKey?: string; @@ -55,13 +55,13 @@ export type SonarQubeApi = { }): Promise; }; -// @alpha (undocumented) +// @public (undocumented) export const sonarQubeApiRef: ApiRef; -// @alpha (undocumented) +// @public (undocumented) export type SonarUrlProcessorFunc = (identifier: string) => string; -// @alpha +// @public export const useProjectInfo: (entity: Entity) => { projectInstance: string | undefined; projectKey: string | undefined; diff --git a/plugins/sonarqube-react/src/api/SonarQubeApi.ts b/plugins/sonarqube-react/src/api/SonarQubeApi.ts index ee6b1bb6a3..13517d97fe 100644 --- a/plugins/sonarqube-react/src/api/SonarQubeApi.ts +++ b/plugins/sonarqube-react/src/api/SonarQubeApi.ts @@ -16,7 +16,7 @@ import { createApiRef } from '@backstage/core-plugin-api'; -/** @alpha */ +/** @public */ export type MetricKey = // alert status | 'alert_status' @@ -43,11 +43,11 @@ export type MetricKey = // duplicated lines | 'duplicated_lines_density'; -/** @alpha */ +/** @public */ export type SonarUrlProcessorFunc = (identifier: string) => string; /** - * @alpha + * @public * * Define a type to make sure that all metrics are used */ @@ -55,7 +55,7 @@ export type Metrics = { [key in MetricKey]: string | undefined; }; -/** @alpha */ +/** @public */ export interface FindingSummary { lastAnalysis: string; metrics: Metrics; @@ -65,12 +65,12 @@ export interface FindingSummary { getSecurityHotspotsUrl: () => string; } -/** @alpha */ +/** @public */ export const sonarQubeApiRef = createApiRef({ id: 'plugin.sonarqube.service', }); -/** @alpha */ +/** @public */ export type SonarQubeApi = { getFindingSummary(options: { componentKey?: string; diff --git a/plugins/sonarqube-react/src/hooks/useProjectInfo.ts b/plugins/sonarqube-react/src/hooks/useProjectInfo.ts index 119e568e46..3336bd1805 100644 --- a/plugins/sonarqube-react/src/hooks/useProjectInfo.ts +++ b/plugins/sonarqube-react/src/hooks/useProjectInfo.ts @@ -25,7 +25,7 @@ export const SONARQUBE_PROJECT_INSTANCE_SEPARATOR = '/'; * * If part or all info are not found, they will default to undefined * - * @alpha + * @public * @param entity - entity to find the sonarqube information from. * @returns a ProjectInfo properly populated. */ diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index f77c66ac59..db3f38e31d 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -42,7 +42,7 @@ export const SonarQubeCard: (props: { duplicationRatings?: DuplicationRating[]; }) => JSX.Element; -// @alpha (undocumented) +// @public (undocumented) export class SonarQubeClient implements SonarQubeApi { constructor({ discoveryApi, diff --git a/plugins/sonarqube/src/api/SonarQubeClient.ts b/plugins/sonarqube/src/api/SonarQubeClient.ts index f742fe026f..14c7936e92 100644 --- a/plugins/sonarqube/src/api/SonarQubeClient.ts +++ b/plugins/sonarqube/src/api/SonarQubeClient.ts @@ -23,7 +23,7 @@ import { import { InstanceUrlWrapper, FindingsWrapper } from './types'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; -/** @alpha */ +/** @public */ export class SonarQubeClient implements SonarQubeApi { discoveryApi: DiscoveryApi; identityApi: IdentityApi; diff --git a/plugins/vault-backend/src/service/standaloneApplication.ts b/plugins/vault-backend/src/service/standaloneApplication.ts index bcec8ca419..ba4c0edc3e 100644 --- a/plugins/vault-backend/src/service/standaloneApplication.ts +++ b/plugins/vault-backend/src/service/standaloneApplication.ts @@ -28,6 +28,10 @@ import helmet from 'helmet'; import { Logger } from 'winston'; import { createRouter } from './router'; import { ConfigReader } from '@backstage/config'; + +// Think this file will probably go away once we move to backend system +// And restructure into the /dev folder +// eslint-disable-next-line @backstage/no-undeclared-imports import { TestDatabases } from '@backstage/backend-test-utils'; import { TaskScheduler } from '@backstage/backend-tasks'; diff --git a/yarn.lock b/yarn.lock index 550c230ba3..7d905a0873 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3964,7 +3964,7 @@ __metadata: languageName: unknown linkType: soft -"@backstage/create-app@workspace:*, @backstage/create-app@workspace:packages/create-app": +"@backstage/create-app@workspace:*, @backstage/create-app@workspace:^, @backstage/create-app@workspace:packages/create-app": version: 0.0.0-use.local resolution: "@backstage/create-app@workspace:packages/create-app" dependencies: @@ -4438,6 +4438,7 @@ __metadata: "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" "@backstage/plugin-auth-node": "workspace:^" + "@backstage/test-utils": "workspace:^" "@backstage/types": "workspace:^" "@davidzemon/passport-okta-oauth": ^0.0.5 "@google-cloud/firestore": ^6.0.0 @@ -4795,7 +4796,9 @@ __metadata: "@backstage/errors": "workspace:^" "@backstage/integration": "workspace:^" "@backstage/plugin-catalog-backend": "workspace:^" + "@backstage/plugin-catalog-common": "workspace:^" "@backstage/plugin-catalog-node": "workspace:^" + "@backstage/plugin-kubernetes-common": "workspace:^" "@backstage/types": "workspace:^" "@types/lodash": ^4.14.151 aws-sdk: ^2.840.0 @@ -4997,6 +5000,7 @@ __metadata: dependencies: "@backstage/backend-app-api": "workspace:^" "@backstage/backend-common": "workspace:^" + "@backstage/backend-defaults": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-tasks": "workspace:^" "@backstage/backend-test-utils": "workspace:^" @@ -21023,6 +21027,7 @@ __metadata: dependencies: "@backstage/cli": "workspace:^" "@backstage/cli-common": "workspace:^" + "@backstage/create-app": "workspace:^" "@backstage/errors": "workspace:^" "@types/fs-extra": ^9.0.1 "@types/node": ^16.11.26