代码拉取完成,页面将自动刷新
# set output encoding
$OutputEncoding = [Text.UTF8Encoding]::UTF8
# company name placeholder
$oldCompanyName="AbpCompanyName"
# your company name
$newCompanyName="YourCompanyName"
# project name placeholder
$oldProjectName="EventCloud"
# your project name
$newProjectName="YourProjectName"
# file type
$fileType="FileInfo"
# directory type
$dirType="DirectoryInfo"
# copy
Write-Host 'Start copy folders...'
$newRoot=$newCompanyName+"."+$newProjectName
mkdir $newRoot
Copy-Item -Recurse .\aspnet-core\ .\$newRoot\
Copy-Item -Recurse .\vue\ .\$newRoot\
Copy-Item .gitignore .\$newRoot\
Copy-Item LICENSE .\$newRoot\
Copy-Item README.md .\$newRoot\
# folders to deal with
$slnFolder = (Get-Item -Path "./$newRoot/aspnet-core/" -Verbose).FullName
$vueFolder = (Get-Item -Path "./$newRoot/vue/" -Verbose).FullName
function Rename {
param (
$TargetFolder,
$PlaceHolderCompanyName,
$PlaceHolderProjectName,
$NewCompanyName,
$NewProjectName
)
# file extensions to deal with
$include=@("*.cs","*.cshtml","*.asax","*.ps1","*.ts","*.csproj","*.sln","*.xaml","*.json","*.js","*.xml","*.config","Dockerfile")
$elapsed = [System.Diagnostics.Stopwatch]::StartNew()
Write-Host "[$TargetFolder]Start rename folder..."
# rename folder
Ls $TargetFolder -Recurse | Where { $_.GetType().Name -eq $dirType -and ($_.Name.Contains($PlaceHolderCompanyName) -or $_.Name.Contains($PlaceHolderProjectName)) } | ForEach-Object{
Write-Host 'directory ' $_.FullName
$newDirectoryName=$_.Name.Replace($PlaceHolderCompanyName,$NewCompanyName).Replace($PlaceHolderProjectName,$NewProjectName)
Rename-Item $_.FullName $newDirectoryName
}
Write-Host "[$TargetFolder]End rename folder."
Write-Host '-------------------------------------------------------------'
# replace file content and rename file name
Write-Host "[$TargetFolder]Start replace file content and rename file name..."
Ls $TargetFolder -Include $include -Recurse | Where { $_.GetType().Name -eq $fileType} | ForEach-Object{
$fileText = Get-Content $_ -Raw -Encoding UTF8
if($fileText.Length -gt 0 -and ($fileText.contains($PlaceHolderCompanyName) -or $fileText.contains($PlaceHolderProjectName))){
$fileText.Replace($PlaceHolderCompanyName,$NewCompanyName).Replace($PlaceHolderProjectName,$NewProjectName) | Set-Content $_ -Encoding UTF8
Write-Host 'file(change text) ' $_.FullName
}
If($_.Name.contains($PlaceHolderCompanyName) -or $_.Name.contains($PlaceHolderProjectName)){
$newFileName=$_.Name.Replace($PlaceHolderCompanyName,$NewCompanyName).Replace($PlaceHolderProjectName,$NewProjectName)
Rename-Item $_.FullName $newFileName
Write-Host 'file(change name) ' $_.FullName
}
}
Write-Host "[$TargetFolder]End replace file content and rename file name."
Write-Host '-------------------------------------------------------------'
$elapsed.stop()
write-host "[$TargetFolder]Total Time Cost: $($elapsed.Elapsed.ToString())"
}
Rename -TargetFolder $slnFolder -PlaceHolderCompanyName $oldCompanyName -PlaceHolderProjectName $oldProjectName -NewCompanyName $newCompanyName -NewProjectName $newProjectName
Rename -TargetFolder $vueFolder -PlaceHolderCompanyName $oldCompanyName -PlaceHolderProjectName $oldProjectName -NewCompanyName $newCompanyName -NewProjectName $newProjectName
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。