-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPakify.ps1
More file actions
122 lines (102 loc) · 4.31 KB
/
Pakify.ps1
File metadata and controls
122 lines (102 loc) · 4.31 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
# Made by Svznify, PLEASE CREDIT ME FOR THIS PS1 (MIT LICENSE)
function Write-Section($title) {
Write-Host "`n`e[95m[*] $title`e[0m"
Write-Host ('=' * 38)
}
function Write-Check($message, [switch]$Success) {
if ($Success) {
Write-Host "[√] $message" -ForegroundColor Green
} else {
Write-Host "[X] $message" -ForegroundColor Red
}
}
function Install-Rust {
Write-Check "Rust not found. Installing Rust..." -Success:$false
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "rustup-init.exe"
Start-Process -FilePath "rustup-init.exe" -ArgumentList "-y" -Wait
Remove-Item "rustup-init.exe"
Write-Check "Rust installed." -Success
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""
exit
}
function Install-VSBuildTools {
Write-Check "Installing Visual Studio C++ Build Tools..." -Success:$false
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vs_BuildTools.exe" -OutFile "vs_BuildTools.exe"
Start-Process -FilePath "vs_BuildTools.exe" -ArgumentList "--quiet --wait --norestart --nocache --installPath C:\\BuildTools --add Microsoft.VisualStudio.Workload.VCTools" -Wait
Remove-Item "vs_BuildTools.exe" -Force
Write-Check "VS Build Tools installed. Restarting script..." -Success
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""
exit
}
function Check-Dependencies {
Write-Section "Checking Dependencies"
if (Get-Command node -ErrorAction SilentlyContinue) {
Write-Check "NodeJS is already installed." -Success
} else {
Write-Check "NodeJS not found. Please install Node.js manually." -Success:$false
Start-Process "https://nodejs.org"; exit
}
if (Get-Command rustc -ErrorAction SilentlyContinue) {
Write-Check "Rust is already installed." -Success
} else {
Install-Rust
}
if (-not (Get-Command link.exe -ErrorAction SilentlyContinue)) {
Write-Check "MSVC Build Tools not found." -Success:$false
Install-VSBuildTools
} else {
Write-Check "MSVC Build Tools found." -Success
}
if (Get-Command pake -ErrorAction SilentlyContinue) {
Write-Check "pake-cli is already installed." -Success
} else {
Write-Host "Installing pake-cli globally..."
npm install -g pake-cli
}
}
function Get-AppConfiguration {
Write-Section "App Configuration"
$global:site = Read-Host "Website URL [https://example.com]"
if (-not $site) { $site = "https://example.com" }
$global:appName = Read-Host "App Name [MyPakeApp]"
if (-not $appName) { $appName = "MyPakeApp" }
$global:icon = Read-Host "Icon path (.ico, optional) []"
$global:flags = "--name `"$appName`""
if ($icon) { $flags += " --icon `"$icon`"" }
$opt1 = Read-Host "Enable fullscreen? (y/n) [n]"
if ($opt1 -eq 'y') { $flags += " --fullscreen" }
$opt2 = Read-Host "Hide title bar? (y/n) [n]"
if ($opt2 -eq 'y') { $flags += " --hide-title-bar" }
$opt3 = Read-Host "Disable web shortcuts? (y/n) [n]"
if ($opt3 -eq 'y') { $flags += " --disable-web-shortcuts" }
}
function Run-Pake {
Write-Section "Launching pake"
try {
$pakePath = "$env:APPDATA\npm\pake.cmd"
if (Test-Path $pakePath) {
Start-Process -FilePath $pakePath -ArgumentList "`"$site`" $flags" -Wait -NoNewWindow
Write-Check "Build complete. '$appName' should be in the output folder." -Success
} else {
Write-Check "Could not locate pake.cmd at expected path: $pakePath" -Success:$false
}
} catch {
Write-Check "Failed to run pake. Check if npm bin is in your PATH." -Success:$false
}
Write-Host "`n[!] Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
Write-Host @"
______ _ _ __
| ___ \ | | (_)/ _|
| |_/ /_ _| | ___| |_ _ _
| __/ _` | |/ / | _| | | |
| | | (_| | <| | | | |_| |
\_| \__,_|_|\_\_|_| \__, |
__/ |
|___/
Pakify - Web App to Desktop App Builder using Pake CLI
"@
Check-Dependencies
Get-AppConfiguration
Run-Pake