Stucco
Stucco copied to clipboard
Update dependencies
Description
- Update dependencies/requirements in both the module and template itself.
- The Build/Test steps are failing due to a mismatch in
PowerShellBuild
version inpsake task FromModule
and the one defined inrequirements.psd1
Describe the solution you'd like
PR incoming!
Describe any alternatives you've considered
Updating them in my generated module but where's the fun in that ;)
Additional context
I also wanted to start a discussion in general about dependency management in PowerShell development:
- What's the best practice around this?
- I find it hard to consolidate the following features without complex code/Build processes:
- Module requirements
- Development only requirements
- Auto install/import modules when this module is required
- I do know there's
RequiredModules
in the Module Manifest but it only downloads the dependencies when installing it for the first time. - It doesn't have any more smarts like
npm
.
- I do know there's
- Dependency hell/version management/virtualenv
- I wonder how conflicting dependencies are managed in a shared shell environment. As in, when module x and y require different incompatible version of module z.
- Also while developing how can one do a form of
virtualenv
without polluting their shell? (I think PSDepend has something like this as long as all dependency management goes through it)
Elsewhere I've tried this:
- Use PSDepend with
requirements.psd1
andrequirements.dev.psd1
for their respective dependencies. -
Get-Dependency -Path requirements.psd1
and set the Module Manifest'sRequiredModules
(requirements.dev is not included)- if Version is
latest
do not set a version for the dependency in Manifest. - If Version is compatible with
[Version]
type then set that. -
RequiredModules
only works with [Version] type. PSDepend and PSGallery works with SemVer.
- if Version is
- Use a build.ps1 file to install dependencies, just like
Stucco
. - Therefore when developing the module, one can download/install both requirements and requirements.dev
- When installing the module from a repository as an end user, the injected details into
RequiredModules
should install the necessary modules. - I also toyed with the idea of just invoking PSDepend in the module thus all dependency management going through PSDepend at all levels. However it didn't seem right to bypass PowerShell's packagemanagement and also hinders general metadata/discoverability as the Module Manifest isn't fully descriptive of what the Module is doing/needs.
What do you think?