devblackops / building-powershell-modules-feedback

Feedback on the PowerShell Module Development book
6 stars 1 forks source link

Topic proposal: Use and proper placement of module configuration/data files #1

Open techthoughts2 opened 4 years ago

techthoughts2 commented 4 years ago

Topic

Some modules are simple and self contained. Others have external download dependencies, or user specific settings. Some have independent theme files (ex. oh-my-posh). Where should these be stored?

Why should this be included?

There is not a lot best practice established on where files used by a module should be stored. Some potential use cases:

Where should these files be stored? Where should they be stored to ensure that the module is cross-platform?

Just a thought. Would be nice to have a brief section that basically hit this high level point:

If your module will be working with files that don't ship with the core module file set, you should use the following location for storing and working with those files...

It could be something straightforward like this which I've seen used:

function Get-ThemesLocation {
    $folderName = "PoshThemes"
    if ($PROFILE) {
        return (Join-Path (Split-Path -Parent $PROFILE) $folderName)
    }
    return "~\${$folderName}"
}

Or maybe that's horrid and there is a much preffered way.

I think it would add a lot of value to have an established, best practice way of downloading/writing to/referencing external config files that worked on windows/linux/macos.

devblackops commented 4 years ago

Were you thinking about a section on how to use the Configuration module or PSFramework's configuration system?

techthoughts2 commented 4 years ago

Those look like they would belong in the same section, yes. In reviewing those it seems like it adds additional use cases.

Yeah - I'm not advocating for a whole chapter on this topic or anything but I think there is value in providing guidance/suggestions on this.