Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(marketplace): add marketplace-cli and generate command #348

Merged

Conversation

kadel
Copy link
Member

@kadel kadel commented Jan 28, 2025

Hey, I just made a Pull Request!

Related to https://issues.redhat.com/browse/RHIDP-5290

This adds new marketplace-cli and implements generate command.
This command generates Plugin entities based on the information from the dynamic-plugins.default.yaml and wrapper's package.json. It assumes that all packages in the config files are wrappers.

Usage: marketplace-cli generate [options]

Generate a Plugin entities for the marketplace. By default, it will output entities to the standard output

Options:
  -p, --default-dynamic-plugins-config [path]  Path to the default dynamic plugins file (usually dynamic-plugins.default.yaml in rhdh source code)
  -o, --output-dir [path]                      Path to the output directory. Each entity will be written to a separate file
  --namespace [namespace]                      metadata.namespace for the generated Package entities
  --owner [owner]                              spec.owner for the generated Package entities (default: "system/rhdh")
  -h, --help                                   display help for command

example:

▶ packages/cli/bin/marketplace-cli generate \
  -p ~/Code/rhdh/dynamic-plugins.default.yaml  \
  --output-dir ~/Code/rhdh/catalog-entities/plugins/
▶ cat ~/Code/rhdh/catalog-entities/plugins/backstage-community-plugin-tekton.yaml
kind: Package
apiVersion: marketplace.backstage.io/v1alpha1
metadata:
  name: backstage-community-plugin-tekton
  title: "@backstage-community/plugin-tekton"
  owner: system/rhdh
  links:
    - url: https://red.ht/rhdh
      title: Homepage
    - url: https://issues.redhat.com/browse/RHIDP
      title: Bugs
    - title: Source Code
      url: https://github.com/redhat-developer/rhdh/tree/main/dynamic-plugins/wrappers/backstage-community-plugin-tekton
  annotations:
    backstage.io/source-location: url
      https://github.com/redhat-developer/rhdh/tree/main/dynamic-plugins/wrappers/backstage-community-plugin-tekton
  tags: []
spec:
  packageName: "@backstage-community/plugin-tekton"
  dynamicArtifact: ./dynamic-plugins/dist/backstage-community-plugin-tekton
  version: 3.17.0
  backstage:
    role: frontend-plugin
    supportedVersions: 1.35.0
  author: Red Hat
  support: production
  lifecycle: active
  partOf:
    - tekton
  appConfigExamples:
    - title: Default configuration
      content:
        dynamicPlugins:
          frontend:
            backstage-community.plugin-tekton:
              mountPoints:
                - mountPoint: entity.page.ci/cards
                  importName: TektonCI
                  config:
                    layout:
                      gridColumn: 1 / -1
                    if:
                      allOf:
                        - isTektonCIAvailable
Screenshot 2025-01-31 at 12 06 55 #### ✔️ Checklist
  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

@christoph-jerolimov christoph-jerolimov changed the title feat(marketplace-cli): add marketplace-cli and generate command feat(marketplace): add marketplace-cli and generate command Jan 28, 2025
@kadel kadel force-pushed the generate-plugin-entities branch from bea5e1b to 0441d92 Compare January 29, 2025 16:01
@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Jan 29, 2025

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/marketplace-cli workspaces/marketplace/packages/cli patch v0.0.0

@kadel kadel force-pushed the generate-plugin-entities branch 5 times, most recently from 45dd0c4 to fb266c6 Compare January 31, 2025 10:47
@kadel
Copy link
Member Author

kadel commented Jan 31, 2025

Failed conditions
12.0% Duplication on New Code (required ≤ 3%)

sonar cube is complaining about duplication because the marketplace-cli is based on the rhdh-cli in this repo

@kadel
Copy link
Member Author

kadel commented Jan 31, 2025

Not sure what is going on with the test. The failure seems unrelated to changes in this PR and I see the same error on the main as well

it generates Package entities based on the RHDH's
dynamic-plugins.default.yaml
@kadel kadel force-pushed the generate-plugin-entities branch from fb266c6 to 102fc45 Compare January 31, 2025 11:09
Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome @kadel !

Thanks for that. I reviewed the code and it lgtm.

Can you just please revert the changes in the root of rhdh-plugins and double-check your dependencies.

After that feel free to add a changeset so that we can ship it. :)

@kadel kadel force-pushed the generate-plugin-entities branch from 1f760d1 to 0e0b8ea Compare January 31, 2025 12:51
Comment on lines +7 to +29
```
Usage: marketplace-cli [options] [command]

Options:
-h, --help

Commands:
generate [options]
help [command]
```

### `marketplace-cli generate`

```
Usage: marketplace-cli generate [options]

Options:
-p, --default-dynamic-plugins-config [path]
-o, --output-dir [path]
--namespace [namespace]
--owner [owner]
-h, --help
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How awesome is this cli report 🤯 🥳

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally and it works well already. We can merge it when you want. I added two small comments below anyway. ;)

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
12.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@christoph-jerolimov christoph-jerolimov merged commit 3c12103 into redhat-developer:main Jan 31, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants