spring-cli icon indicating copy to clipboard operation
spring-cli copied to clipboard

Execute OpenRewrite from Catalog

Open fabapp2 opened this issue 2 years ago • 0 comments

Spike on a solution that allows users to execute recipes by name. A new "Recipe Catalog" has mappings from the Recipe name to the recipe's artifact. The Recipe Catalog also provides information about required and optional Recipe parameters.

Recipe Catalog

recipeCatalog:
  - recipeId: AddLicenseHeader
    artifactGav: org.openrewrite:rewrite-java:8.13.4
    recipeName: org.openrewrite.java.AddLicenseHeader
    description: Adds the provided licenseText as license header to all Java files.
    repositoryUrl: https://github.com/openrewrite/rewrite
    parameters:
      - name: licenseText
        type: String
        required: true

Providing Recipe Parameters

The mapping from command line arguments to Recipe parameters becomes quickly very complex. For simple recipes with just String parameters like AddLicenseHeader that's not an issue. But for more complex parameters, I'd change the API to expect parameters to be provided as JSON?

recipe byName <recipe-name> --parameters="{\"stringProperty\"=\"some string\", \"aList\"=[\"of\", \"strings\"]}"

fabapp2 avatar Feb 05 '24 09:02 fabapp2