Scripts/New-ProjectFromTemplate.ps1
function New-ProjectFromTemplate { [CmdletBinding()] Param( [string] [Parameter(Mandatory= $true)] $ProjectName, [string] [Parameter(Mandatory= $true)] $ProjectPath ) try { $global:devops_gitRepo = $ProjectName $global:devops_projectLocation = "$ProjectPath\$ProjectName" if (!(Test-Path -Path "$global:devops_projectLocation") -and !($null -eq $ProjectPath)) { Write-Host "Creating Project Folder" New-Item -Path $ProjectPath -Name $global:devops_gitRepo -ItemType Directory Set-Location -Path "$global:devops_projectLocation" $message = "Setting up PowerPlatform.DevOps Project" Write-Host $message Remove-Item -Path (Join-Path $PSScriptRoot ..\FrameworkTemplate\node_modules) -Recurse -Force -ErrorAction Ignore Copy-Item -Path (Join-Path $PSScriptRoot ..\FrameworkTemplate\*) -Destination $global:devops_projectLocation\ -Recurse -Force Remove-Item .git -Recurse -Force -ErrorAction SilentlyContinue git config --global init.defaultBranch master git init Write-Host "Rename PowerPlatformDevOps.sln to $global:devops_gitRepo.sln" Rename-Item -Path $global:devops_projectLocation\PowerPlatformDevOps.sln -NewName "$global:devops_gitRepo.sln" Write-Host "Rename dot files" Rename-Item -Path $global:devops_projectLocation\file.gitignore -NewName ".gitignore" Rename-Item -Path $global:devops_projectLocation\file.artifactignore -NewName ".artifactignore" Rename-Item -Path $global:devops_projectLocation\file.gitattributes -NewName ".gitattributes" Rename-Item -Path $global:devops_projectLocation\SolutionTemplate\file.eslintrc.json -NewName ".eslintrc.json" Rename-Item -Path $global:devops_projectLocation\SolutionTemplate\file.prettierrc.json -NewName ".prettierrc.json" git add -A git commit -m "Initial Commit" } } catch{ } } |