This is an automated email from the ASF dual-hosted git repository.
msciabarra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git
The following commit(s) were added to refs/heads/main by this push:
new 2217ab7 installation on windows
2217ab7 is described below
commit 2217ab7d6f95c1e79c8a19fe6877810fb4d4df03
Author: Michele Sciabarra <[email protected]>
AuthorDate: Fri Aug 9 10:35:34 2024 +0200
installation on windows
---
cli.code-workspace | 2 +-
install.ps1 | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 78 insertions(+), 2 deletions(-)
diff --git a/cli.code-workspace b/cli.code-workspace
index 68e91f6..cd70ba5 100644
--- a/cli.code-workspace
+++ b/cli.code-workspace
@@ -12,6 +12,6 @@
"titleBar.activeForeground": "#28075d",
"statusBar.background": "#28075d"
},
- "go.goroot":
"/nix/store/16g3awzjv3341s27hkkkv1vk5dw4206m-go-1.22.5/share/go"
+ "go.goroot":
"/nix/store/0jjqri305gwmzg8j1zjpkjbgllfv209s-go-1.22.5/share/go"
}
}
diff --git a/install.ps1 b/install.ps1
index c38058a..f3c1f2b 100644
--- a/install.ps1
+++ b/install.ps1
@@ -1 +1,77 @@
-echo "Sorry this is just placeholder - TODO"
\ No newline at end of file
+$OS = (uname -s)
+$ARCH = (uname -m)
+$CMD = "ops"
+$WINDOWS = $false
+
+switch ("$OS-$ARCH") {
+ "Linux-x86_64" {
+ $SUFFIX = "_linux_amd64"
+ $EXT = ".tar.gz"
+ }
+ "Linux-arm64" {
+ $SUFFIX = "_linux_arm64"
+ $EXT = ".tar.gz"
+ }
+ "Darwin-x86_64" {
+ $SUFFIX = "_darwin_amd64"
+ $EXT = ".tar.gz"
+ }
+ "Darwin-arm64" {
+ $SUFFIX = "_darwin_arm64"
+ $EXT = ".tar.gz"
+ }
+ { $_ -like "MINGW64_NT-*" } {
+ $SUFFIX = "_windows_amd64"
+ $EXT = ".zip"
+ $CMD = "ops.exe"
+ }
+ default {
+ Write-Host "Unknown system - exiting"
+ exit 1
+ }
+}
+
+$OPSROOT =
"https://raw.githubusercontent.com/apache/openserverless-task/0.1.0/opsroot.json"
+$VERSION = (Invoke-RestMethod -Uri $OPSROOT).version
+$FILE = "openserverless-cli_${VERSION}$SUFFIX$EXT"
+$URL =
"https://github.com/apache/openserverless-cli/releases/download/v$VERSION/$FILE"
+
+# Create the directory if it doesn't exist
+$BinPath = "$HOME/.local/bin"
+if (-not (Test-Path -Path $BinPath)) {
+ New-Item -ItemType Directory -Force -Path $BinPath | Out-Null
+}
+
+# Download the file
+Invoke-WebRequest -Uri $URL -OutFile "$FILE"
+
+# Unpack the file based on its extension
+if ($EXT -eq ".zip") {
+ Expand-Archive -Path "$FILE" -DestinationPath $BinPath -Force
+} else {
+ tar -xzvf "$FILE" -C $BinPath $CMD
+}
+
+# Verify installation
+if (-not (Test-Path "$BinPath/$CMD*")) {
+ Write-Host "Cannot install ops - download and unpack it in a folder in the
path from here:"
+ Write-Host $URL
+ exit 1
+}
+
+# Check if the bin path is in the user's PATH
+if (-not ($env:PATH -contains $BinPath)) {
+ if($WINDOWS) {
+ $existingPath = [System.Environment]::GetEnvironmentVariable("Path",
[System.EnvironmentVariableTarget]::User)
+ $newPath = "$BinPath;$existingPath"
+ [System.Environment]::SetEnvironmentVariable("Path", $newPath,
[System.EnvironmentVariableTarget]::User)
+ Write-Host "Please restart your terminal to find ops in your path"
+ } else {
+ Write-Host "$BinPath is not in the PATH - adding it"
+ Add-Content -Path "$HOME\.bashrc" -Value "`nexport
PATH=`"$BinPath`:`$PATH`""
+ Add-Content -Path "$HOME\.zshrc" -Value "`nexport
PATH=`"$BinPath`:`$PATH`""
+ Write-Host "Please restart your terminal to find ops in your path"
+ }
+}
+
+exit 0