Skip to content

Instantly share code, notes, and snippets.

@ThiagoBarradas
Created February 8, 2018 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThiagoBarradas/b4d86cc32edd3ccd6219f6d07b886e11 to your computer and use it in GitHub Desktop.
Save ThiagoBarradas/b4d86cc32edd3ccd6219f6d07b886e11 to your computer and use it in GitHub Desktop.
##########################################
## ##
## Script for generate new hub apps ##
## run: ##
## .\generate-app.ps1 AppName ##
## ##
##########################################
Param (
[Parameter(Mandatory=$True)]
[ValidateNotNull()]
$AppName
)
# Init
$AppNameLower=$AppName.ToLower()
$AppNameUpper=$AppName.ToUpper()
$GitDir="hub-internalapp-$AppNameLower"
# Remove exist folder with same name
if ( Test-Path $GitDir ) {
echo "Remove existing folder with same name"
rm -r -force $GitDir
}
echo "Generating $AppName app..."
# Clone template
git clone https://ed75746b9799f7033694cbe00079f333439641c9@github.com/mundipagg/hub-internalapp-template $GitDir
# Remove .git
echo "Removing .git"
rm -r -force $GitDir\.git
# Rename files
echo "Renaming files"
mv $GitDir\Hub.InternalApp.Template.sln $GitDir\Hub.InternalApp.$AppName.sln
mv $GitDir\Hub.InternalApp.Template\Hub.InternalApp.Template.csproj $GitDir\Hub.InternalApp.Template\Hub.InternalApp.$AppName.csproj
mv $GitDir\Hub.InternalApp.Template.Tests\Hub.InternalApp.Template.Tests.csproj $GitDir\Hub.InternalApp.Template.Tests\Hub.InternalApp.$AppName.Tests.csproj
# Rename folders
echo "Renaming folders"
mv $GitDir\Hub.InternalApp.Template $GitDir\Hub.InternalApp.$AppName
mv $GitDir\Hub.InternalApp.Template.Tests $GitDir\Hub.InternalApp.$AppName.Tests
# Replace app name
echo "Replace app name"
$filenames = Get-ChildItem $GitDir -Recurse | Where-Object { !$_.PSIsContainer } | select -expand fullname
foreach ($filename in $filenames)
{
echo "Replacing in file $filename"
(Get-Content $fileName) -creplace 'Template', $AppName | Set-Content $fileName
(Get-Content $fileName) -creplace 'TEMPLATE', $AppNameUpper | Set-Content $fileName
(Get-Content $fileName) -creplace 'template', $AppNameLower | Set-Content $fileName
}
# Set application name with ASCII II Art
echo "Set application name with ASCII II Art"
$AppNameASCII = Invoke-WebRequest http://artii.herokuapp.com/make?text=$AppName
$Filename="$GitDir\Hub.InternalApp.Pipedrive\Utilities\ApplicationUtility.cs"
(Get-Content $Filename) -creplace 'ASCII_TITLE', "`n$AppNameASCII" | Set-Content $fileName
echo "`n`nFinish!`n`n"
echo $AppNameASCII.Content
echo "`n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment