-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush-win.ps1
More file actions
178 lines (146 loc) · 3.75 KB
/
push-win.ps1
File metadata and controls
178 lines (146 loc) · 3.75 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
param(
[string]$Message = "Update Live CSS Editor"
)
$ErrorActionPreference = "Stop"
$RepoUrl = "https://github.com/crissymoon/Live-CSS-Editor.git"
Set-Location $PSScriptRoot
function Invoke-PythonScript {
param(
[Parameter(Mandatory = $true)][string]$ScriptPath,
[string[]]$Arguments = @(),
[switch]$AllowFailure
)
if (-not (Test-Path $ScriptPath)) {
Write-Host "--- Skipping missing script: $ScriptPath"
return $false
}
if (Get-Command py -ErrorAction SilentlyContinue) {
& py -3 $ScriptPath @Arguments | Out-Host
} elseif (Get-Command python -ErrorAction SilentlyContinue) {
& python $ScriptPath @Arguments | Out-Host
} else {
Write-Host "WARNING: Python not found; skipping $ScriptPath"
return $false
}
if ($LASTEXITCODE -ne 0) {
if ($AllowFailure) {
Write-Host "WARNING: script failed (continuing): $ScriptPath"
return $false
}
throw "Script failed: $ScriptPath"
}
return $true
}
Write-Host "--- push-win.ps1: working in $PWD"
Write-Host "--- push-win.ps1: remote $RepoUrl"
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
throw "git is not installed or not on PATH."
}
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
throw "GitHub CLI (gh) is not installed or not on PATH. Install from https://cli.github.com/."
}
if (-not (Test-Path .gitignore)) {
@"
# Environment and secrets
.env
.env.*
*.env
secrets.*
config.local.*
# macOS
.DS_Store
.AppleDouble
.LSOverride
# Editor/IDE directories
.vscode/
.idea/
*.suo
*.ntvs*
*.njsproj
*.sln
# Logs and temp files
*.log
*.tmp
*.swp
*.swo
*~
# PHP cache
/vendor/
# Build output
/dist/
/build/
# Python virtual environments
dev-browser/venv/
dev-browser/.venv/
.venv/
# Python compiled files
__pycache__/
*.pyc
*.pyo
*.pyd
# Tauri build output
**/src-tauri/target/
**/src-tauri/www/
**/src-tauri/gen/
"@ | Set-Content -Encoding utf8 .gitignore
Write-Host ".gitignore created."
}
if (-not (Test-Path .git)) {
git init | Out-Host
Write-Host "Git repository initialized."
}
$hasOrigin = $true
try {
git remote get-url origin *> $null
} catch {
$hasOrigin = $false
}
if ($hasOrigin) {
git remote set-url origin $RepoUrl | Out-Host
Write-Host "Remote 'origin' updated to $RepoUrl"
} else {
git remote add origin $RepoUrl | Out-Host
Write-Host "Remote 'origin' added: $RepoUrl"
}
Write-Host "--- git remote -v:"
git remote -v | Out-Host
if (Test-Path make_readme.py) {
Write-Host "--- Updating README.md..."
Invoke-PythonScript -ScriptPath "make_readme.py" | Out-Null
}
if (Test-Path "dev-tools/zyx_planning_and_visuals/make_report.py") {
Write-Host "--- Generating workspace reports..."
Invoke-PythonScript -ScriptPath "dev-tools/zyx_planning_and_visuals/make_report.py" -AllowFailure | Out-Null
}
Write-Host "--- Running: git add ."
git add . | Out-Host
Write-Host "--- git add complete"
Write-Host "--- Staged files:"
git diff --cached --name-status | Out-Host
$hasStagedChanges = $true
git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
$hasStagedChanges = $false
}
if ($hasStagedChanges) {
Write-Host "--- Running: git commit"
git commit -m $Message | Out-Host
} else {
Write-Host "--- Nothing new to commit."
}
Write-Host "--- Checking GitHub CLI auth"
$authOk = $true
try {
gh auth status | Out-Host
} catch {
$authOk = $false
}
if (-not $authOk) {
throw "gh is not authenticated. Run: gh auth login"
}
Write-Host "--- Running: gh auth setup-git"
gh auth setup-git | Out-Host
$branch = (git rev-parse --abbrev-ref HEAD).Trim()
Write-Host "--- Running: git push -v -u origin $branch"
git push -v -u origin $branch | Out-Host
Write-Host "--- Done: pushed to $RepoUrl ($branch)."