Hey #devops #git peeps, mind if I pick your brains for a bit?

I maintain a couple of internal GitHub repos at $Employer for various windows app install scripts (PowerShell), that are used to deploy our EDR, DLP, and other such tools. These all grew out of a script template (or if I’m feeling fancy, framework) that was meant to abstract away some differences in behavior between a couple legacy MDM platforms and our planned future platform.

Changes to these scripts fall into three gross categories:

  • Bumps of the app version, generally without any other changes.
  • Changes to the template logic.
  • Changes to the app-specific logic.
  • I’m gonna skip version changes, because they’re essentially a subclass of app-specific logic.

    My workflow in developing the template generally goes something like this:

  • Work on an app-specific logic change.
  • Determine this is actually something more broadly usable than just that one app, and move the change out of the app-specific logic and into the template logic.
  • Increment the template version in the front-matter of the app-specific script.
  • Diff the app-specific script against the template, and merge in the changes in the template logic, ignoring the app specific logic (actual logic in the app script, placeholder in the template)
  • Diff the updated template script against each of the other app-specific scripts, and merge in the template logic, ignoring the app-specific logic (placeholder logic in the template, actual logic in the app script).
  • What I’m interested in is automating step 5, so that on push of an updated template version, all my scripts update too. Automating step 4, so that on push of an app-specific script containing updated template logic, the template repo gets updated would be pretty cool too.

    What I don’t understand is how I could programmatically merge in only the desired changes (template logic) , and not undesirable ones (app-specific logic)?

    @ajn142
    Can you move app-specific logic to another file?
    @FritzAdalis maybe? The hard part of any change is validating it against the handful of systems it supports now.
    @ajn142
    Either that or put the app specific code in another file in the repo and 'compile' it back into the main file for deployment.
    @FritzAdalis that may be an option, though the linter will throw an absolute fit about the app-specific code calling functions that aren’t declared (because they come from the template file)
    @ajn142
    Build before linting?
    @FritzAdalis you mean tolerate the linter errors in my IDE while developing the code?
    /le shock

    @ajn142
    I suppose that's a drawback.

    Make it a module and import-module ./filename.psm1? Thinking about it that seems like it'd be the mostest correctest.