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

Ideas for simplifying accelerators.yaml #4

Open
ericbottard opened this issue Sep 22, 2022 · 0 comments
Open

Ideas for simplifying accelerators.yaml #4

ericbottard opened this issue Sep 22, 2022 · 0 comments

Comments

@ericbottard
Copy link

After looking at the machine generated accelerator.yaml file in a bit more detail, I think the following recipes could be used to make it more "natural" (and concise):

  1. All of the preprocessor #if x #endif directives could be replaced by a ReplaceText with regex, e.g. like so:
  - include:
    - src/MyProjectGroup.Common/MyProjectGroup.Common.csproj
    chain:
    - type: ReplaceText
      substitutions:
      - text: |2-
                  <!--#if configserver -->
                  <PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="3.1.3" />
                  <!--#endif -->
        with: "''"
      condition: '!(#configserver)'
    - type: ReplaceText
      substitutions:
      - text: |2-
                  <!--#if configserver -->
                  <PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="3.1.3" />
                  <!--#endif -->
        with: "'        <PackageReference Include=\"Steeltoe.Extensions.Configuration.ConfigServerCore\" Version=\"3.1.3\" />'"
      condition: '#configserver'

becomes

  - include:
    - src/MyProjectGroup.Common/MyProjectGroup.Common.csproj
    chain:
    - type: ReplaceText
      regex:
        pattern: '(?s)<!--#if configserver -->(.*?)<!--#endif -->'
        with: "#configserver ? '$1' : ''"

but then of course, there is no need to have this snippet per file, so the include can become

- include: ['**/*.csproj', '**/*.xml']

and handle all files in one swoop.

You're then left with one snippet per option + comment format (xml-like, C-like, etc.)
I believe this can apply to lines 70 to 800 and scale with the number of options instead of the number of files to touch.
If you're adventurous, this could be reduced to one snippet per option if you make the regex cope with all comment styles.

  1. Then, all the RewritePath of the form
  - type: RewritePath
    regex: config/DotnetAccelerator-Development.yaml
    rewriteTo: "'config/' + #artifactId + '-Development.yaml'"
  - type: RewritePath
    regex: config/DotnetAccelerator-LocalMySQL.yaml
    rewriteTo: "'config/' + #artifactId + '-LocalMySQL.yaml'"
etc...

can be rewritten to a couple of RewritePath using capturing groups:

  - type: RewritePath
    regex: (config/)DotnetAccelerator(-Development\\.yaml)
    rewriteTo: "#g1 + #artifactId + #g2"
etc...
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

No branches or pull requests

1 participant