init commit
This commit is contained in:
113
Initialize-PPT.ps1
Normal file
113
Initialize-PPT.ps1
Normal file
@@ -0,0 +1,113 @@
|
||||
function Initialize-PPT {
|
||||
[CmdLetBinding()]
|
||||
Param (
|
||||
$Path = (Get-Location).Path
|
||||
)
|
||||
|
||||
begin {
|
||||
$PSScriptRoo = "C:\Users\DC21520\OneDrive - Defense Information Systems Agency\Documents\WindowsPowerShell\Modules\posh-PowerPlatformToolkit"
|
||||
|
||||
$Path = @{
|
||||
qualifier = (Split-Path -Path $Path -Qualifier)
|
||||
parent = (Split-Path -Path $Path)
|
||||
leaf = (Split-Path -Path $Path -Leaf)
|
||||
path = $Path
|
||||
pathBuild = (Join-Path -Path $Path -ChildPath 'Build')
|
||||
pathConfig = (Join-Path -Path $Path -ChildPath 'Build\config.json')
|
||||
sourcePath = (Join-Path -Path $PSScriptRoot -ChildPath 'source')
|
||||
sourceConfig = (Join-Path -Path $PSScriptRoot -ChildPath 'source\config.ps1')
|
||||
sourceIgnore = (Join-Path -Path $PSScriptRoot -ChildPath 'source\.gitignore')
|
||||
}
|
||||
|
||||
Write-Host "`nInitializing Power Platform Toolkit in:" -ForegroundColor Cyan
|
||||
Write-Host "$($Path.path)" -BackgroundColor DarkCyan -ForegroundColor Black
|
||||
|
||||
do {
|
||||
$initContinue = Read-Host "`nDo you want to continue (y/n) "
|
||||
$initContinue = $initContinue.ToLower()
|
||||
} while ($initContinue -notmatch 'y|n')
|
||||
|
||||
}
|
||||
|
||||
process {
|
||||
|
||||
switch ($initContinue) {
|
||||
|
||||
'y' { Write-Host "Initializing Power Platform Toolkit..." -ForegroundColor Cyan; $initContinue = $null }
|
||||
'n' { Write-Host "Seems like you need to give this a little more thought... I can wait." -ForegroundColor Yellow; $initContinue = $null; return }
|
||||
default { Write-Warning "Unexpected error"; $initContinue = $null; return }
|
||||
|
||||
}
|
||||
|
||||
if(Test-Path -Path $Path.pathConfig) {
|
||||
|
||||
Write-Host "`nPower Platform Toolkit was already initialized for this directory!" -ForegroundColor Yellow
|
||||
Write-Host "Initializing again will overwrite your current configuration." -BackgroundColor DarkYellow -ForegroundColor Black
|
||||
|
||||
do {
|
||||
$initContinue = Read-Host "`nDo you want to continue (y/n) "
|
||||
$initContinue = $initContinue.ToLower()
|
||||
} while ($initContinue -notmatch 'y|n')
|
||||
|
||||
switch ($initContinue) {
|
||||
|
||||
'y' { Write-Host "Initializing Power Platform Toolkit..." -ForegroundColor Cyan; $initContinue = $null }
|
||||
'n' { Write-Host "Seems like you need to give this a little more thought... I can wait." -ForegroundColor Yellow; $initContinue = $null; return }
|
||||
default { Write-Warning -Message "Unexpected error"; $initContinue = $null; return }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
New-Item -Path $Path.PathBuild -ItemType Directory -Verbose -Force -ErrorAction Stop > $null
|
||||
New-Item -Path $Path.pathConfig -ItemType File -Verbose -Force -ErrorAction Stop > $null
|
||||
Copy-Item -Path $Path.sourceIgnore -Destination $Path.path -Verbose -Force -ErrorAction Stop > $null
|
||||
Copy-Item -Path "$($Path.sourcePath)\README.md" -Destination $Path.path -Verbose -Force -ErrorAction Stop > $null
|
||||
. $Path.sourceConfig | ConvertTo-Json -Verbose > $Path.pathConfig
|
||||
|
||||
} catch [System.Exception] {
|
||||
|
||||
Write-Warning -Message "$($_.Exception.Message)"
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
|
||||
# FEATURE DEVELOPMENT ON LATER RELEASE
|
||||
<#
|
||||
do {
|
||||
|
||||
Write-Host "`nGit Repository Parent Group Options" -BackgroundColor DarkCyan -ForegroundColor Black
|
||||
Write-Host "Select the Parent Group for " -NoNewline -ForegroundColor Cyan; Write-Host "$($Path.leaf)" -ForegroundColor Green
|
||||
for ($i = 0; $i -lt $pptConfig.gitParentGroup.Count; $i++) {
|
||||
Write-Host "[$($i + 1)] $($Global:pptConfig.gitParentGroup[$i])"
|
||||
}
|
||||
$parentGroup = Read-Host "Group "
|
||||
|
||||
} while ($parentGroup -notin (1..$pptConfig.gitParentGroup.Count))
|
||||
do {
|
||||
|
||||
Write-Host "`nGit Repository Child Group Options" -BackgroundColor DarkCyan -ForegroundColor Black
|
||||
Write-Host "Select the Child Group for " -NoNewline -ForegroundColor Cyan; Write-Host "$($Path.leaf)" -ForegroundColor Green
|
||||
for ($i = 0; $i -lt $pptConfig.gitChildGroup.Count; $i++) {
|
||||
Write-Host "[$($i + 1)] $($Global:pptConfig.gitChildGroup[$i])"
|
||||
}
|
||||
$childGroup = Read-Host "Group "
|
||||
|
||||
} while ($childGroup -notin (1..$pptConfig.gitChildGroup.Count))
|
||||
#>
|
||||
# FEATURE DEVELOPMENT ON LATER RELEASE
|
||||
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# EXPORT ALIAS
|
||||
New-Alias -Name init -Value Initialize-PPT -Description 'posh-PowerPlatformToolkit - Initialize-PPT alias' -Force
|
||||
Reference in New Issue
Block a user