meta: add repo quickset/quickstart script
This commit is contained in:
parent
0365649ad6
commit
2dbe573b70
222
repoquickset.ps1
Normal file
222
repoquickset.ps1
Normal file
|
@ -0,0 +1,222 @@
|
|||
# common setup script for forge repositories
|
||||
# structure:
|
||||
#
|
||||
# Shared Repository/Monorepository (a la Integrated Project)
|
||||
# ├── .git/
|
||||
# ├── Game
|
||||
# │ ├── .gitignore (from Unity.gitignore)
|
||||
# │ ├── .gitattributes (from Unity.gitattributes)
|
||||
# │ └── ...
|
||||
# ├── Modelling
|
||||
# │ ├── .gitattributes (from Modelling.gitattributes)
|
||||
# │ └── ...
|
||||
# └── ...
|
||||
#
|
||||
# Game (Unity) Repository Folder
|
||||
# ├── .git/
|
||||
# ├── .gitignore (from Unity.gitignore)
|
||||
# ├── .gitattributes (from Unity.gitattributes)
|
||||
# └── ...
|
||||
#
|
||||
# Modelling (Maya / Z Brush / Substance Painter) Repository Folder
|
||||
# ├── .git/
|
||||
# ├── .gitattributes (from Modelling.gitattributes)
|
||||
# └── ...
|
||||
|
||||
# git files
|
||||
$GIT_IGNR_UNITY="https://forge.joshwel.co/mark/common/raw/branch/main/Unity.gitignore"
|
||||
$GIT_ATTR_UNITY="https://forge.joshwel.co/mark/common/raw/branch/main/Unity.gitattributes"
|
||||
$GIT_ATTR_MODEL="https://forge.joshwel.co/mark/common/raw/branch/main/Modelling.gitattributes"
|
||||
$GIT_ATTR_GENRC="https://forge.joshwel.co/mark/common/raw/branch/main/Generic.gitattributes"
|
||||
$GIT_ATTR_DESGN="https://forge.joshwel.co/mark/common/raw/branch/main/Design.gitattributes"
|
||||
$GIT_ATTR_GITHB="https://forge.joshwel.co/mark/common/raw/branch/main/GitHub.gitattributes"
|
||||
|
||||
# functions
|
||||
function setupSharedRepository {
|
||||
# ask if the repo will be pushed to github or the forge
|
||||
Write-Output ("`n!!! will this repo be pushed to github or the forge? (g/f)`n" +
|
||||
"!!! - [g]ithub: github.com`n" +
|
||||
"!!! - [f]orge: forge.joshwel.co`n" +
|
||||
"!!!`n" +
|
||||
"!!! (this will affect how git lfs is setup, but it will be enabled regardless`n" +
|
||||
"!!! ---`n" +
|
||||
"!!! github has a 1gb lfs storage/bandwidth limit, while the forge doesn't care`n" +
|
||||
"!!! saying 'f' will use actually defined .gitattributes,`n" +
|
||||
"!!! while saying 'g' will use a basic .gitattributes that MIGHT not wreck your`n" +
|
||||
"!!! 1gb git lfs allowance as long as you dont commit files bigger than 100mb)")
|
||||
|
||||
while ($true) {
|
||||
$repoHost = Read-Host
|
||||
if ($repoHost -eq "g" -or $repoHost -eq "f") {
|
||||
break
|
||||
}
|
||||
Write-Output "!!! expected: 'g', 'f'"
|
||||
}
|
||||
|
||||
# re-set variables if the repo will be pushed to the github (use github.gitattributes)
|
||||
if ($repoHost -eq "g") {
|
||||
$GIT_ATTR_UNITY=$GIT_ATTR_GITHB
|
||||
$GIT_ATTR_MODEL=$GIT_ATTR_GITHB
|
||||
$GIT_ATTR_DESGN=$GIT_ATTR_GITHB
|
||||
$GIT_ATTR_GENRC=$GIT_ATTR_GITHB
|
||||
}
|
||||
|
||||
# make folders
|
||||
if (-not (Test-Path -Path "Game")) {
|
||||
New-Item -ItemType Directory -Name "Game"
|
||||
}
|
||||
if (-not (Test-Path -Path "Modelling")) {
|
||||
New-Item -ItemType Directory -Name "Modelling"
|
||||
}
|
||||
if (-not (Test-Path -Path "Design")) {
|
||||
New-Item -ItemType Directory -Name "Design"
|
||||
}
|
||||
|
||||
# download .gitignore and .gitattributes
|
||||
Write-Output ">>> shared/game: dl '$GIT_IGNR_UNITY' -> 'Game/.gitignore'"
|
||||
Invoke-WebRequest -Uri $GIT_IGNR_UNITY -OutFile "Game/.gitignore"
|
||||
|
||||
Write-Output ">>> shared/game: dl '$GIT_ATTR_UNITY' -> 'Game/.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_UNITY -OutFile "Game/.gitattributes"
|
||||
|
||||
Write-Output ">>> shared/modelling: dl '$GIT_ATTR_MODEL' -> 'Modelling/.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_MODEL -OutFile "Modelling/.gitattributes"
|
||||
|
||||
Write-Output ">>> shared/design: dl '$GIT_ATTR_DESGN' -> 'Design/.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_DESGN -OutFile "Design/.gitattributes"
|
||||
|
||||
Write-Output ">>> shared/generic: dl '$GIT_ATTR_GENRC' -> '.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_GENRC -OutFile ".gitattributes"
|
||||
|
||||
# warn that shared repos cant be pushed to github for free due to git lfs restrictions
|
||||
Write-Output ("`n!!! the shared repo CANT be pushed to github for free due to git lfs restrictions" +
|
||||
"`n!!! use the forge instead")
|
||||
}
|
||||
|
||||
function setupSingleRepository {
|
||||
# ask if it is a maya, unity, design, or other (generic) project
|
||||
Write-Output ("`n!!! what type of project is this? (m/u/d/g)`n" +
|
||||
"!!! - [m]odelling: maya, zbrush, substance painter`n" +
|
||||
"!!! - [u]nity: unity lol`n" +
|
||||
"!!! - [d]esign: adobe design files, audiovisual files, figma`n" +
|
||||
"!!! - [g]eneric: other project")
|
||||
|
||||
while ($true) {
|
||||
$projectType = Read-Host
|
||||
if ($projectType -eq "m" -or $projectType -eq "u" -or $projectType -eq "d" -or $projectType -eq "g") {
|
||||
break
|
||||
}
|
||||
Write-Output "!!! expected: 'm', 'u', 'd', 'g'"
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
|
||||
# ask if the repo will be pushed to github or the forge
|
||||
Write-Output ("`n!!! will this repo be pushed to github or the forge? (g/f)`n" +
|
||||
"!!! - [g]ithub: github.com`n" +
|
||||
"!!! - [f]orge: forge.joshwel.co`n" +
|
||||
"!!!`n" +
|
||||
"!!! (this will affect how git lfs is setup, but it will be enabled regardless`n" +
|
||||
"!!! ---`n" +
|
||||
"!!! github has a 1gb lfs storage/bandwidth limit, while the forge doesn't care`n" +
|
||||
"!!! saying 'f' will use actually defined .gitattributes,`n" +
|
||||
"!!! while saying 'g' will use a basic .gitattributes that MIGHT not wreck your`n" +
|
||||
"!!! 1gb git lfs allowance as long as you dont commit files bigger than 100mb)")
|
||||
|
||||
while ($true) {
|
||||
$repoHost = Read-Host
|
||||
if ($repoHost -eq "g" -or $repoHost -eq "f") {
|
||||
break
|
||||
}
|
||||
Write-Output "!!! expected: 'g', 'f'"
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
|
||||
# re-set variables if the repo will be pushed to the github (use github.gitattributes)
|
||||
if ($repoHost -eq "g") {
|
||||
$GIT_ATTR_UNITY=$GIT_ATTR_GITHB
|
||||
$GIT_ATTR_MODEL=$GIT_ATTR_GITHB
|
||||
$GIT_ATTR_DESGN=$GIT_ATTR_GITHB
|
||||
$GIT_ATTR_GENRC=$GIT_ATTR_GITHB
|
||||
}
|
||||
|
||||
# download appropriate .gitattribute and .gitignore
|
||||
if ($projectType -eq "m") {
|
||||
Write-Output ">>> modelling: dl '$GIT_ATTR_MODEL' -> '.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_MODEL -OutFile ".gitattributes"
|
||||
|
||||
} elseif ($projectType -eq "u") {
|
||||
Write-Output ">>> unity: dl '$GIT_IGNR_UNITY' -> '.gitignore'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_UNITY -OutFile ".gitattributes"
|
||||
Write-Output ">>> unity: dl '$GIT_ATTR_UNITY' -> '.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_IGNR_UNITY -OutFile ".gitignore"
|
||||
|
||||
} elseif ($projectType -eq "d") {
|
||||
Write-Output ">>> design: dl '$GIT_ATTR_DESGN' -> '.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_DESGN -OutFile ".gitattributes"
|
||||
|
||||
} else {
|
||||
Write-Output ">>> generic: dl '$GIT_ATTR_GENRC' -> '.gitattributes'"
|
||||
Invoke-WebRequest -Uri $GIT_ATTR_GENRC -OutFile ".gitattributes"
|
||||
}
|
||||
}
|
||||
|
||||
# pre-script setup
|
||||
$oldErrorActionPreference = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
Write-Output ("`nforge/lfs-compatible repo quickstart setup`n" +
|
||||
"with all my heart, mark 2024`n")
|
||||
|
||||
# check if .git exists in current directory
|
||||
# if not, 'git init' to create a new repository
|
||||
if (-not (Test-Path -Path ".git")) {
|
||||
Write-Output ">> 'git init' (.git repo folder not found)"
|
||||
git init
|
||||
}
|
||||
|
||||
Write-Output ">> 'git lfs install'"
|
||||
git lfs install
|
||||
|
||||
# ask the user if it is a shared or a single repository
|
||||
# validate the input via a loop
|
||||
Write-Output ("`n!!! shared repository: multiple projects in one repository`n" +
|
||||
"!!! |-- .git/`n" +
|
||||
"!!! |-- Game`n" +
|
||||
"!!! | |-- .gitignore`n" +
|
||||
"!!! | |-- .gitattributes`n" +
|
||||
"!!! | ``-- ...`n" +
|
||||
"!!! |-- Modelling`n" +
|
||||
"!!! | |-- .gitattributes`n" +
|
||||
"!!! | ``-- ...`n" +
|
||||
"!!! ``-- ...`n" +
|
||||
"!!!`n" +
|
||||
"!!! single repository/monorepo: one project`n" +
|
||||
"!!! |-- .git/`n" +
|
||||
"!!! |-- .gitignore`n" +
|
||||
"!!! |-- .gitattributes`n" +
|
||||
"!!! ``-- ...`n" +
|
||||
"!!!`n" +
|
||||
"!!! is this a shared or mono repository? (s/m)")
|
||||
|
||||
while ($true) {
|
||||
$repoType = Read-Host
|
||||
if ($repoType -eq "s" -or $repoType -eq "m") {
|
||||
break
|
||||
}
|
||||
Write-Output "!!! expected: 's', 'm'"
|
||||
}
|
||||
|
||||
# setup the repository
|
||||
if ($repoType -eq "s") {
|
||||
setupSharedRepository
|
||||
} else {
|
||||
setupSingleRepository
|
||||
}
|
||||
|
||||
# reset error action preference
|
||||
$ErrorActionPreference = $oldErrorActionPreference
|
||||
|
||||
Write-Output ("`ndone~! ☆*: .。. o(≧▽≦)o .。.:*☆`n" | Out-String -Stream)
|
Loading…
Reference in a new issue