community-plugins icon indicating copy to clipboard operation
community-plugins copied to clipboard

🔧 Repository: `backstage-cli repo fix --publish` guesses wrong when no `backstage.pluginId` or `pluginPackage` set in package.json

Open nickboldt opened this issue 1 year ago • 0 comments

📜 Description

I'm using the cli command .../node_modules/@backstage/cli/bin/backstage-cli repo fix --publish (version 0.26.11)

Seems like it's always using this for workspaces in the community plugins repo:

    "pluginId": "catalog",
    "pluginPackage": "@backstage/plugin-catalog-backend"

instead of

    "pluginId": "scaffolder-relation-processor",
    "pluginPackage": "@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor"

ref: https://github.com/backstage/community-plugins/pull/851

Yet when I run this in another repo, I get:

Error: Failed to guess plugin ID for "plugin-catalog-backend-module-scaffolder-relation-processor", please set the 'backstage.pluginId' field manually in "dynamic-plugins/wrappers/plugin-catalog-backend-module-scaffolder-relation-processor/package.json"

If I set the ID ...

     "pluginId": "plugin-catalog-backend-module-scaffolder-relation-processor"

... I get ...

     "pluginId": "plugin-catalog-backend-module-scaffolder-relation-processor",
     "pluginPackages": [
       "plugin-catalog-backend-module-scaffolder-relation-processor"
     ]

So that seems to be working.

How does it compute the correct values to use when run in a community plugins workspace?

👍 Expected behavior

repo fix --publish should not change the pluginId to catalog if missing.

👎 Current Behavior

See above

👟 Reproduction steps

  1. check out repo https://github.com/backstage/community-plugins/
  2. edit workspaces/scaffolder-relation-processor/plugins/catalog-backend-module-scaffolder-relation-processor/package.json to remove the values of backstage.pluginId and backstage.pluginPackage - it'll look like this:
  "backstage": {
    "role": "backend-plugin-module"
  },
  1. run ../../node_modules/@backstage/cli/bin/backstage-cli repo fix --publish .

  2. note that the backstage.pluginId and backstage.pluginPackage are now reusing the same pluginId = catalog and an incorrect pluginPackage:

  "backstage": {
    "role": "backend-plugin-module",
    "pluginId": "catalog",
    "pluginPackage": "@backstage/plugin-catalog-backend"
  },

📃 Provide the context for the Bug.

similar issue in https://github.com/backstage/community-plugins/issues/624 but this is more about the content being generated than the need to run the command to generate it.

I've also opened PR https://github.com/backstage/community-plugins/pull/851 to fix the incorrect metadata (by hand, as the cli won't do this for me)

👀 Have you spent some time to check if this bug has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

Yes I am willing to submit a PR!

nickboldt avatar Aug 15 '24 13:08 nickboldt