Unverified Commit 1086a1f0 authored by Aral's ThinkPad's avatar Aral's ThinkPad
Browse files

Improve the experience; document the one-line install command

parent 2de22e2e
Pipeline #887 canceled with stages
......@@ -21,6 +21,7 @@ $tadaBytes = 240, 159, 142, 137
$satelliteEmoji = [System.Text.Encoding]::UTF8.GetString($satelliteBytes)
$packageEmoji = [System.Text.Encoding]::UTF8.GetString($packageBytes)
$tadaEmoji = [System.Text.Encoding]::UTF8.GetString($tadaBytes)
$ellipsis = [char]0x2026
# Adds to the specified environment path without creating duplicates.
# Courtesy of https://gist.github.com/mkropat/c1226e0cc2ca941b23a9
......@@ -55,8 +56,6 @@ function Add-EnvPath {
}
}
Write-Output "\n $satelliteEmoji Downloading Site.js v12.6.0…"
# Check if we're running with elevated privileges, if not, start a new
# PowerShell windows with elevated privileges and continue there.
if (!([Security.Principal.WindowsPrincipal] `
......@@ -65,6 +64,9 @@ if (!([Security.Principal.WindowsPrincipal] `
#
# Installer is running with regular privileges. Start a new PowerShell session with elevated privileges.
#
Write-Output ''
Write-Output " $satelliteEmoji Downloading Site.js v12.6.0$ellipsis"
$currentPath = (Get-Item -Path ".\").FullName
Start-Process -Verb RunAs powershell.exe -WorkingDirectory $currentPath -Wait -ArgumentList "$currentPath/install.ps1"
......@@ -72,27 +74,45 @@ if (!([Security.Principal.WindowsPrincipal] `
# the person can use the site command right away from the current session.
$env:Path += ";$installationDirectory"
# Recreate the output from the other window for consistency.
Write-Output " $packageEmoji Installing…"
Write-Output " $tadaEmoji Done!\n"
# Recreate the output from the other window for consistency with other platforms.
Write-Output " $packageEmoji Installing$ellipsis"
Write-Output " $tadaEmoji Done! "
Write-Output ''
} else {
#
# Installer is running with elevated privileges.
#
Write-Output "`n`n`n`n`n`n"
Write-Output ' Installing Site.js using administrator privileges...'
Write-Output ''
Write-Output ' * Downloading Site.js v12.6.0...'
Invoke-WebRequest -Uri "https://sitejs.org/releases/windows/12.6.0.tar.gz" -OutFile "12.6.0.tar.gz"
Write-Output " $packageEmoji Installing…"
Write-Output ''
Write-Output ' * Extracting binary...'
# Gunzip and untar the binary.
tar -xvf 12.6.0.tar.gz
tar -xf 12.6.0.tar.gz
Write-Output ''
Write-Output ' * Installing binary...'
# Ensure that the folder we want to copy the binary to exists.
New-Item -Force -ItemType directory -Path $installationDirectory
Copy-Item -Force -Path ./site.exe -Destination $installationDirectory
New-Item -Force -ItemType directory -Path $installationDirectory | Out-Null
Copy-Item -Force -Path ./site.exe -Destination $installationDirectory | Out-Null
Write-Output ''
Write-Output ' * Adding to system path...'
# Persist the installation directory to the system path
# (if it doesn't already exist).
Add-EnvPath -Container Machine -Path $installationDirectory
Write-Output " $tadaEmoji Done!\n"
Write-Output ''
Write-Output ' * Done!'
Write-Output ''
# Give people a chance to read the output.
Start-Sleep -Seconds 2
}
......@@ -4,6 +4,16 @@ The installer is pretty much working (see install.ps1).
The hardest part was getting the emoji to work! :facepalm: (see output.ps1).
## Installation command
Copy and paste into PowerShell window under Windows Terminal:
```powershell
$installer = Invoke-WebRequest -UseBasicParsing 'https://source.ind.ie/site.js/spikes/windows-10-powershell-installer/raw/master/install.ps1'; Invoke-Expression $installer.Content
```
(In final version, the script will be served from SiteJS.org, of course.)
## TODO
- Work in a temporary directory, not the current one.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment