Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit edc3305

Browse files
committedMar 3, 2019
initial commit
0 parents  commit edc3305

File tree

125 files changed

+11448
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+11448
-0
lines changed
 

‎Create-ShellApp.ps1

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<#
2+
.SYNOPSIS
3+
Create Shell App Template for Prism for Xamarin Forms projects
4+
.DESCRIPTION
5+
This script can create a single or multiple projects in a single shot. All project directories are automatically created
6+
in the OutputPath. If no OutputPath is specified it will use the current operating directory. The OutputPath does not need
7+
to exist at the time the command is executed.
8+
.NOTES
9+
Author : Dan Siegel - dsiegel@avantipoint.com
10+
.LINK
11+
https://dansiegel.net/
12+
.EXAMPLE
13+
Create-ShellApp -Projects "Contoso.Auth","Contoso.Settings","Contoso.UserProfile" -CompanyName Contoso
14+
.EXAMPLE
15+
Create-ShellApp -Projects "Contoso.Auth","Contoso.Settings","Contoso.UserProfile" -CompanyName Contoso -OutputPath C:\Repos\ContosoApp
16+
#>
17+
18+
Param(
19+
[Parameter(Mandatory=$true)]
20+
[string[]]$Projects,
21+
[string]$CompanyName,
22+
[string]$OutputPath,
23+
[int]$SyslogPort = 514
24+
)
25+
26+
function Update-TemplateFile {
27+
Param(
28+
[string]$FilePath,
29+
[string]$Pattern,
30+
[string]$Replacement
31+
)
32+
((Get-Content -Path $FilePath -Raw) -replace $Pattern, $Replacement) | Set-Content -Path $FilePath
33+
}
34+
35+
[string]$shellResources = Join-Path -Path (Split-Path $MyInvocation.MyCommand.Definition) -ChildPath "resources"
36+
[string]$currentDirectory = Get-Location
37+
38+
if([string]::IsNullOrEmpty($CompanyName)) {
39+
$CompanyName = "avantipoint"
40+
}
41+
42+
if([string]::IsNullOrEmpty($OutputPath) -eq $false) {
43+
$currentDirectory = $OutputPath
44+
mkdir $currentDirectory -Force | Out-Null
45+
}
46+
47+
$nugetPath = "$env:TEMP\nuget.exe"
48+
if(!(Test-Path -Path $nugetPath)) {
49+
Write-Host "Downloading latest NuGet.exe to Temp directory"
50+
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $nugetPath
51+
}
52+
53+
$localIPAddress = Get-NetIPAddress | Where-Object {$_.PrefixOrigin -eq 'Dhcp' -or $_.PrefixOrigin -eq 'Manual' } | Select-Object -First 1 -ExpandProperty IPAddress
54+
55+
foreach($project in $Projects) {
56+
$projectDir = Join-Path -Path $currentDirectory -ChildPath $project
57+
mkdir $projectDir -Force | Out-Null
58+
Set-Location -Path $projectDir | Out-Null
59+
60+
$projectName = $project -replace ".*\.",""
61+
Write-Host "Project Name: $($project) - ($($projectName)Module)"
62+
$bundleId = "$($CompanyName).$($projectName)".ToLower()
63+
Write-Host "Bundle Id: com.$($bundleId)"
64+
65+
Copy-Item -Force -Recurse $shellResources\* -Destination $projectDir
66+
67+
$secrets = @{
68+
AppCenterSecret = ""
69+
BackendUri = "https://localhost:8443"
70+
Host = "$localIPAddress"
71+
Port = "$SyslogPort"
72+
AppName = "$project"
73+
}
74+
75+
$secrets | ConvertTo-Json | Out-File $projectDir\shell\ShellApp\secrets.json
76+
77+
Update-TemplateFile -FilePath $projectDir\ShellApp.sln -Pattern 'MyProject' -Replacement $project
78+
Update-TemplateFile -FilePath $projectDir\ReadMe.md -Pattern 'MyProject' -Replacement $project
79+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp\ShellApp.csproj -Pattern 'MyProject' -Replacement $project
80+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp\App.xaml.cs -Pattern 'MyProjectModule' -Replacement "$($projectName)Module"
81+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp\App.xaml.cs -Pattern 'MyProject' -Replacement $project
82+
Update-TemplateFile -FilePath $projectDir\src\MyProject\MyProjectModule.cs -Pattern 'MyProjectModule' -Replacement "$($projectName)Module"
83+
Update-TemplateFile -FilePath $projectDir\src\MyProject\MyProjectModule.cs -Pattern 'MyProject' -Replacement $project
84+
Update-TemplateFile -FilePath $projectDir\src\MyProject\i18n\Resources.Designer.cs -Pattern 'MyProject' -Replacement $project
85+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.Tests\Mocks\Logging\XunitLogger.cs -Pattern 'MyProject' -Replacement $project
86+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.Tests\Mocks\XunitApp.cs -Pattern 'MyProject' -Replacement $project
87+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.Tests\Mocks\XunitPlatformInitializer.cs -Pattern 'MyProject' -Replacement $project
88+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.Tests\Tests\AppFixture.cs -Pattern 'MyProject' -Replacement $project
89+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.Tests\Tests\ModuleTests.cs -Pattern 'MyProject' -Replacement $project
90+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\AppManager.cs -Pattern 'avantipoint.myproject' -Replacement $bundleId
91+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\AppManager.cs -Pattern 'MyProject' -Replacement $project
92+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\BaseTestFixture.cs -Pattern 'MyProject' -Replacement $project
93+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\Pages\BasePage.cs -Pattern 'MyProject' -Replacement $project
94+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\Pages\MainPage.cs -Pattern 'MyProject' -Replacement $project
95+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\PlatformQuery.cs -Pattern 'MyProject' -Replacement $project
96+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\Tests.cs -Pattern 'MyProject' -Replacement $project
97+
Update-TemplateFile -FilePath $projectDir\tests\MyProject.UITests\WaitTimes.cs -Pattern 'MyProject' -Replacement $project
98+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp.Android\Properties\AndroidManifest.xml -Pattern 'myproject' -Replacement $bundleId
99+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp.Android\Properties\AndroidManifest.xml -Pattern 'MyProject' -Replacement $project
100+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp.iOS\Info.plist -Pattern 'avantipoint.myproject' -Replacement $bundleId
101+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp.iOS\Info.plist -Pattern 'MyProject' -Replacement $project
102+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp.iOS\Entitlements.plist -Pattern 'avantipoint.myproject' -Replacement $bundleId
103+
Update-TemplateFile -FilePath $projectDir\shell\ShellApp.iOS\Entitlements.plist -Pattern 'MyProject' -Replacement $project
104+
105+
Move-Item -Path $projectDir\ShellApp.sln -Destination "$projectDir\$project.sln"
106+
Move-Item -Path $projectDir\src\MyProject\MyProject.csproj -Destination "$projectDir\src\MyProject\$project.csproj"
107+
Move-Item -Path $projectDir\src\MyProject\MyProjectModule.cs -Destination "$projectDir\src\MyProject\$($projectName)Module.cs"
108+
Move-Item -Path $projectDir\src\MyProject\ -Destination "$projectDir\src\$project\"
109+
Move-Item -Path $projectDir\tests\MyProject.Tests\MyProject.Tests.csproj -Destination "$projectDir\tests\MyProject.Tests\$project.Tests.csproj"
110+
Move-Item -Path $projectDir\tests\MyProject.Tests\ -Destination "$projectDir\tests\$project.Tests\"
111+
Move-Item -Path $projectDir\tests\MyProject.UITests\MyProject.UITests.csproj -Destination "$projectDir\tests\MyProject.UITests\$project.UITests.csproj"
112+
Move-Item -Path $projectDir\tests\MyProject.UITests\ -Destination "$projectDir\tests\$project.UITests\"
113+
114+
git init --quiet
115+
Write-Host "Initialized empty git repository for $project"
116+
117+
git add * 2> $null
118+
Write-Host "Staging Files"
119+
120+
git commit -m "Initial Commit" --quiet
121+
Write-Host "Added Initial Commit"
122+
123+
Invoke-Expression -Command "$nugetPath restore" | Out-Null
124+
Write-Host "Restored NuGet Pacakges"
125+
}
126+
127+
Remove-Item -Path $nugetPath
128+
Set-Location -Path $currentDirectory

‎LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2018 Dan Siegel
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)
Please sign in to comment.