-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-windows.ps1
107 lines (75 loc) · 2.64 KB
/
deploy-windows.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
$CODE_ROOT_DIR_NAME=code
@'
Installing nvm-windows
'@
@'
download from https://github.com/coreybutler/nvm-windows/releases and then install it
'@
@'
Installing pyenv-win
'@
# Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
(new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1") | iex
@'
Installing PsGet and posh-git
'@
(new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/psget/psget/master/GetPsGet.ps1") | iex
# $PSVersionTable
Install-Module posh-git -Scope CurrentUser
# $env:PSModulePath
# $env:PSModulePath.split(";")[0]
# # code $PROFILE
Add-PoshGitToProfile
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
@'
Import-Module posh-git
$GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = true
$GitPromptSettings.DefaultPromptWriteStatusFirst = $true
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n'
'@ >> $PROFILE
@'
Adding Clone-Git command to PROFILE
'@
@'
function Clone-Git
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false)]
[string] $SshKeyFilePath,
[Parameter(Mandatory=$false, Position=0)]
[string] $Url
)
Process
{
if (!$Url) {
Write-Error "Usage: ${0} [-SshKeyFilePath SSH-KEY-FILE-PATH] [email protected]:owner/project.git|https://gitserver.com/owner/project.git"
return
}
$PathItems = $Url -replace '.git$', '' -replace '(.*@|(https|http|ssh)://)([a-z0-9\.-]+)(:[0-9]+/|:|/)(.*)/(.*)', '$3 $5 $6' -split ' '
$Path = [string]::Join('\', $env:USERPROFILE, $CODE_ROOT_DIR_NAME, $PathItems[0], $PathItems[1]);
$RepoName = $PathItems[2]
Write-Host "Cloning $Url into $Path/ as $RepoName ..."
New-Item -ItemType Directory $Path -ErrorAction SilentlyContinue
Push-Location $Path
if ($Url -match '^http' || !$SshKeyFilePath) {
git clone $Url
} else {
$SshKeyFilePath = $SshKeyFilePath -replace '^~', $env:USERPROFILE -replace '\\', '/'
# Write-Host $SshKeyFilePath
git clone -c core.sshCommand="ssh -i $SshKeyFilePath" $Url
}
Pop-Location
}
}
'@ >> $PROFILE
#
# ```
# Import-Module posh-git
# $GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = true
# $GitPromptSettings.DefaultPromptWriteStatusFirst = $true
# $GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n'
# ```
Clear-Variable -Name CODE_ROOT_DIR_NAME