RamblingCookieMonster / PSDepend

PowerShell Dependency Handler
MIT License
285 stars 76 forks source link

Functionality: Import-Dependency #2

Closed RamblingCookieMonster closed 8 years ago

RamblingCookieMonster commented 8 years ago

It may be worthwhile to provide functionality to read a depend.psd1 file, install dependencies if they are missing (iffy on this, maybe require a -Force), and import supported dependencies (e.g. a PSGalleryModule would be easy to handle)

Used in conjunction with options that allow saving to a non-PSModulePath, this could help enable a virtual-environment-lite scenario.

beatcracker commented 8 years ago

+1 on this. I'd like to be able to create "portable" packages with no external dependencies. For ex., if I have a script that uses modules and functions from *.ps1 files, I'd like to build it as one package and have dependecies automatically injected into it via some kind of loader function.

RamblingCookieMonster commented 8 years ago

Initial code is in place, but untested. Current state:

# List dependencies, with a DependencyExists column tacked on with the test output
Get-Dependency ... | Test-Dependency

# Check if any dependencies do not exist - quiet switch returns only test result per dependency
( Get-Dependency ... | Test-Dependency -Quiet ) -Contains $False

To do:

On a related note, 'global options' are up and running, where you might specify defaults for certain dependency fields (target, parameters, source, etc.) that you could override on individual dependencies. e.g.:

@{
    # Both dependencies below will get these defaults for Target and Parameters
    PSDependOptions = @{
        Target = 'C:\ProjectX'
        Parameters = @{
            Force = $True
        }
    }

    BuildHelpers = '0.0.20'
    PSDeploy_0_1_21 = @{
        DependencyType = 'PSGalleryNuget'
        Name = 'PSDeploy'
        Version = '0.1.21'
    }
}

This might help with tediousness of specifying the same target for every dependency...

Cheers!

RamblingCookieMonster commented 8 years ago

Alrighty, the code is in place, and an example of this scenario is documented here.

Still need more thorough testing, but closing this out...