From e7d595c70a0beddf6eedeb320d3f4f4ea6e17472 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 5 Oct 2023 11:53:27 +0000 Subject: [PATCH] Fix script names --- .../base/script/PredefinedScriptStore.java | 27 +++---------------- .../ext/base/resources/scripts/clink.bat | 19 +++++++++++++ .../base/resources/scripts/starship_cmd.bat | 24 +++++------------ .../resources/scripts/starship_powershell.ps1 | 8 ++++++ 4 files changed, 37 insertions(+), 41 deletions(-) create mode 100644 ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/clink.bat create mode 100644 ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_powershell.ps1 diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/PredefinedScriptStore.java b/ext/base/src/main/java/io/xpipe/ext/base/script/PredefinedScriptStore.java index feba8b1d..da94a6ae 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/PredefinedScriptStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/PredefinedScriptStore.java @@ -19,7 +19,7 @@ public enum PredefinedScriptStore { () -> SimpleScriptStore.builder() .group(PredefinedScriptGroup.CLINK.getEntry()) .minimumDialect(ShellDialects.CMD) - .commands(file("starship_cmd.bat")) + .commands(file("clink.bat")) .executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY) .build()), CLINK_INJECT( @@ -46,18 +46,7 @@ public enum PredefinedScriptStore { .group(PredefinedScriptGroup.STARSHIP.getEntry()) .minimumDialect(ShellDialects.CMD) .script(SETUP_CLINK.getEntry()) - .commands( - """ - WHERE starship >NUL 2>NUL - IF NOT %ERRORLEVEL%==0 ( - winget install starship - SET "PATH=%PATH%;C:\\Program Files\\starship\\bin" - ) - - MKDIR "%USERPROFILE%\\.xpipe\\scriptdata\\starship" >NUL 2>NUL - echo load(io.popen('starship init cmd'):read("*a"))() > "%USERPROFILE%\\.xpipe\\scriptdata\\starship\\starship.lua" - clink inject --quiet --profile "%USERPROFILE%\\.xpipe\\scriptdata\\starship" - """) + .commands(file("starship_cmd.bat")) .executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY) .build()), STARSHIP_POWERSHELL( @@ -65,17 +54,7 @@ public enum PredefinedScriptStore { () -> SimpleScriptStore.builder() .group(PredefinedScriptGroup.STARSHIP.getEntry()) .minimumDialect(ShellDialects.POWERSHELL) - .commands( - """ - if (-not $(Get-Command -ErrorAction SilentlyContinue starship)) { - winget install starship - - # Update current process PATH environment variable - $env:Path=([System.Environment]::GetEnvironmentVariable("Path", "Machine"), [System.Environment]::GetEnvironmentVariable("Path", "User")) -match '.' -join ';' - } - - Invoke-Expression (&starship init powershell) - """) + .commands(file("starship_powershell.ps1")) .executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY) .build()); diff --git a/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/clink.bat b/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/clink.bat new file mode 100644 index 00000000..41b1f824 --- /dev/null +++ b/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/clink.bat @@ -0,0 +1,19 @@ +WHERE clink >NUL 2>NUL +IF %ERRORLEVEL%==0 ( + exit /b 0 +) + +SET "PATH=%PATH%;%USERPROFILE%\.xpipe\scriptdata\clink" +WHERE clink >NUL 2>NUL +IF %ERRORLEVEL%==0 ( + exit /b 0 +) + +echo ^ +$downloader = New-Object System.Net.WebClient;^ +$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials;^ +if ($defaultCreds) {^ + $downloader.Credentials = $defaultCreds^ +}^ +$downloader.DownloadFile("https://github.com/chrisant996/clink/releases/download/v1.5.7/clink.1.5.7.36d0c6.zip", "$env:TEMP\clink.zip");^ +Expand-Archive -Force -LiteralPath "$env:TEMP\clink.zip" -DestinationPath "$env:USERPROFILE\.xpipe\scriptdata\clink"; | powershell -NoLogo >NUL diff --git a/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_cmd.bat b/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_cmd.bat index 41b1f824..3d7b6019 100644 --- a/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_cmd.bat +++ b/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_cmd.bat @@ -1,19 +1,9 @@ -WHERE clink >NUL 2>NUL -IF %ERRORLEVEL%==0 ( - exit /b 0 +WHERE starship >NUL 2>NUL +IF NOT %ERRORLEVEL%==0 ( + winget install starship + SET "PATH=%PATH%;C:\\Program Files\\starship\\bin" ) -SET "PATH=%PATH%;%USERPROFILE%\.xpipe\scriptdata\clink" -WHERE clink >NUL 2>NUL -IF %ERRORLEVEL%==0 ( - exit /b 0 -) - -echo ^ -$downloader = New-Object System.Net.WebClient;^ -$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials;^ -if ($defaultCreds) {^ - $downloader.Credentials = $defaultCreds^ -}^ -$downloader.DownloadFile("https://github.com/chrisant996/clink/releases/download/v1.5.7/clink.1.5.7.36d0c6.zip", "$env:TEMP\clink.zip");^ -Expand-Archive -Force -LiteralPath "$env:TEMP\clink.zip" -DestinationPath "$env:USERPROFILE\.xpipe\scriptdata\clink"; | powershell -NoLogo >NUL +MKDIR "%USERPROFILE%\\.xpipe\\scriptdata\\starship" >NUL 2>NUL +echo load(io.popen('starship init cmd'):read("*a"))() > "%USERPROFILE%\\.xpipe\\scriptdata\\starship\\starship.lua" +clink inject --quiet --profile "%USERPROFILE%\\.xpipe\\scriptdata\\starship" \ No newline at end of file diff --git a/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_powershell.ps1 b/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_powershell.ps1 new file mode 100644 index 00000000..571f12f5 --- /dev/null +++ b/ext/base/src/main/resources/io/xpipe/ext/base/resources/scripts/starship_powershell.ps1 @@ -0,0 +1,8 @@ +if (-not $(Get-Command -ErrorAction SilentlyContinue starship)) { + winget install starship + + # Update current process PATH environment variable + $env:Path=([System.Environment]::GetEnvironmentVariable("Path", "Machine"), [System.Environment]::GetEnvironmentVariable("Path", "User")) -match '.' -join ';' +} + +Invoke-Expression (&starship init powershell) \ No newline at end of file