-
Notifications
You must be signed in to change notification settings - Fork 1
/
Repository-Setup.ps1
72 lines (55 loc) · 2.17 KB
/
Repository-Setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
## Delete me after project setup!
param (
[string]$ProjectName
)
# Validate that the project name is provided
if (-not $ProjectName) {
Write-Host "Please provide a valid Project Name. Example: Kentico.Xperience.Lucene"
exit 1
}
$searchText = "Kentico.Xperience.RepoTemplate"
$replaceText = "$ProjectName"
$files = Get-ChildItem -Path "./" `
-Recurse:$true | Where-Object {
@(".json", ".yml", ".props", ".md") -contains $_.Extension
}
foreach ($file in $files) {
# Read the file content
$content = Get-Content -Path $file.FullName
# Check if the file contains the search text
if ($content -like "*Kentico.Xperience.RepoTemplate*") {
Write-Host "Processing file: $($file.FullName)"
# Replace the text in the file content
$newContent = $content -replace $searchText, $replaceText
# Write the updated content back to the file
Set-Content -Path $file.FullName -Value $newContent
Write-Host "Replaced text in file: $($file.FullName)"
}
}
# Define project directories
$srcProjectPath = Join-Path "./src" $ProjectName
$testProjectPath = Join-Path "./tests" "$ProjectName.Tests"
$examplesProjectPath = Join-Path "./examples" "DancingGoat"
dotnet new classlib `
-n $ProjectName `
-o $srcProjectPath `
--no-restore
Write-Host "Created class library project: $srcProjectPath"
dotnet new nunit `
-n "$ProjectName.Tests" `
-o $testProjectPath `
--no-restore
Write-Host "Created NUnit test project: $testProjectPath"
dotnet new kentico-xperience-sample-mvc -n DancingGoat -o $examplesProjectPath --no-restore --allow-scripts Yes
Write-Host "Created Dancing Goat sample application: $examplesProjectPath"
dotnet add "$testProjectPath/$ProjectName.Tests.csproj" `
reference $srcProjectPath
Write-Host "Added reference from test project to class library project."
dotnet add "$examplesProjectPath/DancingGoat.csproj" `
reference $srcProjectPath
Write-Host "Added reference from Dancing Goat project to class library project."
dotnet new sln -n "$ProjectName"
dotnet sln add $srcProjectPath
dotnet sln add $testProjectPath
dotnet sln add $examplesProjectPath
Write-Host "Project setup complete."