Public/Coding/New-EdenService.ps1
function New-EdenService { [CmdletBinding()] param( [Alias("n")] [String] $Name, [Alias("t")] [String] $Template, [Alias("sn")] [String] $SolutionName, [Alias("gn")] [String] $GitHubName, [Alias("go")] [String] $GitHubOrg, [Alias("f")] [Switch] $Force ) $location = Get-Location try { $loggingPrefix = "Eden Coding" if (!$Template) { $Template = "NewBlankService" } if ($GithubName) { if ([String]::IsNullOrEmpty($GitHubOrg)) { $GitHubOrg = "Eden-CLI" } $Template = "https://github.com/$GitHubOrg/Eden-Service-$GitHubName.git" } if (!$SolutionName) { $location = Get-Location $SolutionName = Split-Path $location -Leaf } if ($Template.EndsWith(".git")) { if ((Test-Path "./$Name")) { Write-EdenError "The service already exists." $loggingPrefix return } Copy-GitRepo $Template $Name $loggingPrefix Set-StringReplacement "./$Name/*" "MyEdenSolution" $SolutionName Set-StringReplacement "./$Name/*" "MyEdenService" $Name } else { Write-EdenInfo "Creating a new Eden service: '$Name'." $loggingPrefix New-Item "./" -ItemType Directory -Name $Name [string] $sourceDirectory = "./Eden/Templates/$Template/*" if (!(Test-Path $sourceDirectory)) { $sourceDirectory = "$PSScriptRoot/../Templates/NewBlankSolution/Eden/Templates/NewBlankService/*" } [string] $destinationDirectory = "./$Name" Copy-Item $sourceDirectory -Destination $destinationDirectory -Force -Recurse -Verbose Write-EdenInfo "Finished creating a new Eden service." $loggingPrefix } } catch { Write-EdenError "Error creating a new Eden service. Message: '$($_.Exception.Message)'" $loggingPrefix } finally { Set-Location $location } } New-Alias ` -Name e-cs ` -Value New-EdenService ` -Force |