Skip to content

Commit

Permalink
Adds script for installation
Browse files Browse the repository at this point in the history
  • Loading branch information
skycube19 committed Oct 22, 2024
1 parent 24a745b commit 73a34fe
Show file tree
Hide file tree
Showing 3,403 changed files with 653,077 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bower_components
build/Release

# Dependency directories
node_modules/
# node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
Expand Down
204 changes: 204 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
$ErrorActionPreference = 'Stop'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

#region Variables
$spicetifyFolderPath = "$env:LOCALAPPDATA\spicetify"
$spicetifyOldFolderPath = "$HOME\spicetify-cli"
#endregion Variables

#region Functions
function Write-Success {
[CmdletBinding()]
param ()
process {
Write-Host -Object ' > OK' -ForegroundColor 'Green'
}
}

function Write-Unsuccess {
[CmdletBinding()]
param ()
process {
Write-Host -Object ' > ERROR' -ForegroundColor 'Red'
}
}

function Test-Admin {
[CmdletBinding()]
param ()
begin {
Write-Host -Object "Checking if the script is not being run as administrator..." -NoNewline
}
process {
$currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
-not $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
}

function Test-PowerShellVersion {
[CmdletBinding()]
param ()
begin {
$PSMinVersion = [version]'5.1'
}
process {
Write-Host -Object 'Checking if your PowerShell version is compatible...' -NoNewline
$PSVersionTable.PSVersion -ge $PSMinVersion
}
}

function Move-OldSpicetifyFolder {
[CmdletBinding()]
param ()
process {
if (Test-Path -Path $spicetifyOldFolderPath) {
Write-Host -Object 'Moving the old spicetify folder...' -NoNewline
Copy-Item -Path "$spicetifyOldFolderPath\*" -Destination $spicetifyFolderPath -Recurse -Force
Remove-Item -Path $spicetifyOldFolderPath -Recurse -Force
Write-Success
}
}
}

function Get-Spicetify {
[CmdletBinding()]
param ()
begin {
if ($env:PROCESSOR_ARCHITECTURE -eq 'AMD64') {
$architecture = 'x64'
}
elseif ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') {
$architecture = 'arm64'
}
else {
$architecture = 'x32'
}
if ($v) {
if ($v -match '^\d+\.\d+\.\d+$') {
$targetVersion = $v
}
else {
Write-Warning -Message "You have spicefied an invalid spicetify version: $v `nThe version must be in the following format: 1.2.3"
Pause
exit
}
}
else {
Write-Host -Object 'Fetching the latest spicetify version...' -NoNewline
$latestRelease = Invoke-RestMethod -Uri 'https://api.github.com/repos/spicetify/cli/releases/latest'
$targetVersion = $latestRelease.tag_name -replace 'v', ''
Write-Success
}
$archivePath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), "spicetify.zip")
}
process {
Write-Host -Object "Downloading spicetify v$targetVersion..." -NoNewline
$Parameters = @{
Uri = "https://github.com/spicetify/cli/releases/download/v$targetVersion/spicetify-$targetVersion-windows-$architecture.zip"
UseBasicParsin = $true
OutFile = $archivePath
}
Invoke-WebRequest @Parameters
Write-Success
}
end {
$archivePath
}
}

function Add-SpicetifyToPath {
[CmdletBinding()]
param ()
begin {
Write-Host -Object 'Making spicetify available in the PATH...' -NoNewline
$user = [EnvironmentVariableTarget]::User
$path = [Environment]::GetEnvironmentVariable('PATH', $user)
}
process {
$path = $path -replace "$([regex]::Escape($spicetifyOldFolderPath))\\*;*", ''
if ($path -notlike "*$spicetifyFolderPath*") {
$path = "$path;$spicetifyFolderPath"
}
}
end {
[Environment]::SetEnvironmentVariable('PATH', $path, $user)
$env:PATH = $path
Write-Success
}
}

function Install-Spicetify {
[CmdletBinding()]
param ()
begin {
Write-Host -Object 'Installing spicetify...'
}
process {
$archivePath = Get-Spicetify
Write-Host -Object 'Extracting spicetify...' -NoNewline
Expand-Archive -Path $archivePath -DestinationPath $spicetifyFolderPath -Force
Write-Success
Add-SpicetifyToPath
}
end {
Remove-Item -Path $archivePath -Force -ErrorAction 'SilentlyContinue'
Write-Host -Object 'spicetify was successfully installed!' -ForegroundColor 'Green'
}
}
#endregion Functions

#region Main
#region Checks
if (-not (Test-PowerShellVersion)) {
Write-Unsuccess
Write-Warning -Message 'PowerShell 5.1 or higher is required to run this script'
Write-Warning -Message "You are running PowerShell $($PSVersionTable.PSVersion)"
Write-Host -Object 'PowerShell 5.1 install guide:'
Write-Host -Object 'https://learn.microsoft.com/skypeforbusiness/set-up-your-computer-for-windows-powershell/download-and-install-windows-powershell-5-1'
Write-Host -Object 'PowerShell 7 install guide:'
Write-Host -Object 'https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows'
Pause
exit
}
else {
Write-Success
}
if (-not (Test-Admin)) {
Write-Unsuccess
Write-Warning -Message "The script was run as administrator. This can result in problems with the installation process or unexpected behavior. Do not continue if you do not know what you are doing."
$Host.UI.RawUI.Flushinputbuffer()
$choices = [System.Management.Automation.Host.ChoiceDescription[]] @(
(New-Object System.Management.Automation.Host.ChoiceDescription '&Yes', 'Abort installation.'),
(New-Object System.Management.Automation.Host.ChoiceDescription '&No', 'Resume installation.')
)
$choice = $Host.UI.PromptForChoice('', 'Do you want to abort the installation process?', $choices, 0)
if ($choice -eq 0) {
Write-Host -Object 'spicetify installation aborted' -ForegroundColor 'Yellow'
Pause
exit
}
}
else {
Write-Success
}
#endregion Checks

#region Spicetify
Move-OldSpicetifyFolder
Install-Spicetify
Write-Host -Object "`nRun" -NoNewline
Write-Host -Object ' spicetify -h ' -NoNewline -ForegroundColor 'Cyan'
Write-Host -Object 'to get started'
#endregion Spicetify

$path = spicetify -c

$path = $path.Replace('Roaming', 'Local')
$path = $path.Replace('config-xpui.ini', 'CustomApps\Enhancify')

echo $path

git clone https://github.com/rrk0804/Enhancify.git $path

spicetify config custom_apps Enhancify
spicetify apply
12 changes: 12 additions & 0 deletions node_modules/.bin/autoprefixer

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/autoprefixer.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/autoprefixer.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/browserslist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/browserslist.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/browserslist.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/cssesc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/cssesc.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/cssesc.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 73a34fe

Please sign in to comment.