backstage / backstage

Backstage is an open framework for building developer portals
https://backstage.io/
Apache License 2.0
28.5k stars 6.04k forks source link

πŸ› Bug Report: incorrect PluginCacheManager and CacheManager deprecation warnings #26791

Open ericis opened 2 months ago

ericis commented 2 months ago

πŸ“œ Description

Incorrect deprecation recommendations

Use of PluginCacheManager from the "@backstage/backend-common" package includes an invalid deprecation warning to:

Use PluginCacheManager from the @backstage/backend-defaults package instead

https://backstage.io/docs/reference/backend-common.plugincachemanager/

The "@backstage/backend-common" package also contains the deprecated CacheManager that recommends:

Use CacheManager from the @backstage/backend-defaults package instead

https://backstage.io/docs/reference/backend-common.cachemanager/

However, the "@backstage/backend-defaults" package does not contain a PluginCacheManager or CacheManager.

https://backstage.io/docs/reference/backend-defaults/

Example of a correct deprecation recommendation

The "@backstage/backend-common" package also includes the deprecated cacheToPluginCacheManager() function and recommends:

Migrate to use the new CacheService instead.

https://backstage.io/docs/reference/backend-common.cachetoplugincachemanager/

*Note: this deprecation message could probably also benefit from noting that it is in the "@backstage/backend-plugin-api" package.

πŸ‘ Expected behavior

Clearer deprecation notices that are possible to take action on.

πŸ‘Ž Actual Behavior with Screenshots

See links and descriptions in bug report.

πŸ‘Ÿ Reproduction steps

n/a

πŸ“ƒ Provide the context for the Bug.

n/a

πŸ–₯️ Your Environment

n/a

πŸ‘€ Have you spent some time to check if this bug has been raised before?

🏒 Have you read the Code of Conduct?

Are you willing to submit PR?

No, I don't have time to work on this right now

camilaibs commented 1 month ago

Hi @ericis πŸ‘‹πŸ» , you can import CacheManager from the @backstage-defaults/cache subpath, here is an example:

import { CacheManager } from "@backstage-defaults/cache";

And you can call the CacheManager.forPlugin method to get a CacheService for a plugin.

knowacki23 commented 1 month ago

Hi @ericis πŸ‘‹πŸ» , you can import CacheManager from the @backstage-defaults/cache subpath, here is an example:

import { CacheManager } from "@backstage-defaults/cache";

And you can call the CacheManager.forPlugin method to get a CacheService for a plugin.

Hey, I think the import should be:

import { CacheManager } from "@backstage/backend-defaults/cache";