Unverified Commit 9a401673 authored by Aral's ThinkPad's avatar Aral's ThinkPad
Browse files

Initial add

parents
Pipeline #884 canceled with stages
*.tar.gz
\ No newline at end of file
$emojisource = $(Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/catcher-in-the-try/Full-Emoji-List/master/Emoji.cs").Content
$AssemblyInfo = Add-Type -TypeDefinition $emojisource -Passthru
$AllEmojiInfo = $AssemblyInfo.GetMembers().Name | Where-Object {$_ -ne "Equals"} | ForEach-Object {
try {
$ba = [System.Text.Encoding]::UTF8.GetBytes([J3QQ4.Emoji]::$_)
$h = [System.BitConverter]::ToString($ba)
[pscustomobject]@{
Name = $_
ByteArray = $ba
Hex = $h
Emoji = [J3QQ4.Emoji]::$_
}
}
catch {}
}
Write-Output $AllEmojiInfo
################################################################################
#
# Site.js installation script for Windows 10 (requires PowerShell).
#
# Copyright (c) 2019 Aral Balkan.
# Released under the AGPL version 3.0 or later license.
# Made with <3 by Small Technology Foundation (https://small-tech.org)
# Like this? Fund us! (https://small-tech.org/fund-us)
#
################################################################################
# This is where the binary will be installed to.
$installationDirectory = 'C:\Program Files\site.js'
# Emoji encodings (because Powershell is from the Stone Age and cannot handle
# emoji literals in strings)
$satelliteBytes = 240, 159, 147, 161
$packageBytes = 240, 159, 147, 166
$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)
# Adds to the specified environment path without creating duplicates.
# Courtesy of https://gist.github.com/mkropat/c1226e0cc2ca941b23a9
# Via https://stackoverflow.com/questions/714877/setting-windows-powershell-environment-variables
function Add-EnvPath {
param(
[Parameter(Mandatory=$true)]
[string] $Path,
[ValidateSet('Machine', 'User', 'Session')]
[string] $Container = 'Session'
)
if ($Container -ne 'Session') {
$containerMapping = @{
Machine = [EnvironmentVariableTarget]::Machine
User = [EnvironmentVariableTarget]::User
}
$containerType = $containerMapping[$Container]
$persistedPaths = [Environment]::GetEnvironmentVariable('Path', $containerType) -split ';'
if ($persistedPaths -notcontains $Path) {
$persistedPaths = $persistedPaths + $Path | Where-Object { $_ }
[Environment]::SetEnvironmentVariable('Path', $persistedPaths -join ';', $containerType)
}
}
$envPaths = $env:Path -split ';'
if ($envPaths -notcontains $Path) {
$envPaths = $envPaths + $Path | Where-Object { $_ }
$env:Path = $envPaths -join ';'
}
}
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] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
#
# Installer is running with regular privileges. Start a new PowerShell session with elevated privileges.
#
$currentPath = (Get-Item -Path ".\").FullName
Start-Process -Verb RunAs powershell.exe -WorkingDirectory $currentPath -Wait -ArgumentList "$currentPath/test.ps1"
# We're back from the privileged window. Update this window's path immediately so that
# 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"
} else {
#
# Installer is running with elevated privileges.
#
Invoke-WebRequest -Uri "https://sitejs.org/releases/windows/12.6.0.tar.gz" -OutFile "12.6.0.tar.gz"
Write-Output " $packageEmoji Installing…"
# Gunzip and untar the binary.
tar -xvf 12.6.0.tar.gz
# 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
# 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"
}
# On Linux, macOS, and shells in other sane operating systems…
echo " 📡 Downloading Site.js v12.6.0…"
echo " 📦 Installing…"
echo " 🎉 Done!"
# On Windows 10 PowerShell…
$satelliteBytes = 240, 159, 147, 161
$packageBytes = 240, 159, 147, 166
$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
Write-Output " $satelliteEmoji Downloading Site.js v12.6.0$ellipsis"
Write-Output " $packageEmoji Installing$ellipsis"
Write-Output " $tadaEmoji Done! "
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