KevinMarquette / PSGraph

A set of utilities for working with Graphviz in Powershell
MIT License
205 stars 49 forks source link

Export-PSGraph does not find graphviz on Ubuntu in default location #78

Closed tigerfansga closed 2 years ago

tigerfansga commented 6 years ago

On Ubuntu, the default install location is /usr/bin/dot I feel this should be added to the default search list

        $GraphVizPath = (
            'C:\Program Files\NuGet\Packages\Graphviz*\dot.exe',
            'C:\program files*\GraphViz*\bin\dot.exe',
            '/usr/local/bin/dot'
        ),

If you agree, I can do a PR if you like.

KevinMarquette commented 6 years ago

Absolutely. That looks like a good path to add to the list.

tigerfansga commented 5 years ago

PR submitted. I know you have login in Install-GraphViz for Windows and MacOS. For Linux, because of the variability in distos and package managers, I'm not sure of the best options for this command.

For ubuntu (and other debian distros), you would use sudo apt install graphviz for REHL and other similar distros, it would probably be a yum command.

KevinMarquette commented 5 years ago

I wasn't sure how to handle all those possibilities either and I'm not sure that command belongs in this module.

tigerfansga commented 5 years ago

I was thinking more displaying the command but not executing it

KevinMarquette commented 5 years ago

I would be good with that solution. That lets the user make the call.

I guess I we should also include a link to the graphviz documentation on how to download it. https://www.graphviz.org/download

Stephanevg commented 5 years ago

hi, guys,

I think it would be too bad to have the user usability be diffferent for linux then for macosx and windows. I perhaps have a small suggestion. Please let me know if this is something that could be acceptable:

    <#
        .Description
        Installs GraphViz package using online provider
        .Example
        Install-GraphViz
    #>
    [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "High" )]
    param()

    process
    {
        try
        {
            if ( $IsOSX )
            {
                if ( $PSCmdlet.ShouldProcess( 'Install graphviz' ) )
                {
                    brew install graphviz
                }
            }Elseif($IsLinux){
                #Get the version, with something like this:
                #https://www.cyberciti.biz/faq/how-to-check-os-version-in-linux-command-line/
                $LinuxOs = ""

                switch($LinuxOs){
                    "RHEL" {yum graphviz;break}
                    "Ubuntu"{sudo apt install graphviz;break}
                    "Default"{throw "Os not supported yet. please open an issue here: https://github.com/KevinMarquette/PSGraph/issues"}

                }

            }
            else
            {
                if ( $PSCmdlet.ShouldProcess('Register Chocolatey provider and install graphviz' ) )
                {
                    if ( -Not ( Get-PackageProvider | Where-Object ProviderName -eq 'Chocolatey' ) )
                    {
                        Register-PackageSource -Name Chocolatey -ProviderName Chocolatey -Location http://chocolatey.org/api/v2/
                    }

                    Find-Package graphviz | Install-Package -Verbose -ForceBootstrap
                }
            }
        }
        catch
        {
            $PSCmdlet.ThrowTerminatingError( $PSitem )
        }
    }

I have no linux machine to test this one unfortunatley. perhaps @tigerfansga could give it a shot?

tigerfansga commented 5 years ago

One option to look at these is WSL on Windows 10.

I can do some checking on a few different distributions, but the variability in the Linux world will create gaps.

I can't confirm, but you will most likely need to use sudo for REHL with yum.