From 62d27713ded46d3f8f18dfc1eb3d80aa85137e64 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 17 Feb 2022 18:32:58 -0500 Subject: [PATCH 1/4] wip --- scripts/install.bat | 46 +++++++++++++++++++++++++++++++++++ scripts/install.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 scripts/install.bat create mode 100644 scripts/install.sh diff --git a/scripts/install.bat b/scripts/install.bat new file mode 100644 index 0000000..284f26f --- /dev/null +++ b/scripts/install.bat @@ -0,0 +1,46 @@ +@REM Installation (Note: you need to start cmd or powershell in administrator mode.) +@echo off +setlocal ENABLEDELAYEDEXPANSION + +@REM curl https://api.github.com/repos/%Owner%/%Repo%/releases/latest > response.txt +@REM FOR /F "tokens=*" %%g IN ('FIND "tag_name" "response.txt"') do set result=%%g +@REM set "tag_name=%result:"tag_name": "=%" +@REM set "tag_name=%tag_name:",=%" + +@REM Get the latest version of spp-cli. +set FLAG="FALSE" +set VERSION= UNKNOWN +curl -LO "https://raw.githubusercontent.com/apache/skywalking-website/master/data/releases.yml" +if EXIST "releases.yml" ( + for /F "tokens=1,2,*" %%i in ('FINDSTR "name version" "./releases.yml"') do ( + if !FLAG! EQU "TRUE" ( + set FLAG="FALSE" + set VERSION=%%k + ) + if "%%k" == "SkyWalking CLI" (set FLAG="TRUE") + ) +) +set VERSION=%VERSION:~1% +@echo The latest version of spp-cli is %VERSION% + +@REM Download the binary package. +curl -LO "https://github.com/sourceplusplus/interface-cli/releases/download/%VERSION%/spp-cli-%VERSION%-win64.zip" +if EXIST "spp-cli-%VERSION%-win64.zip" ( + tar -xf ".\spp-cli-%VERSION%-win64.zip" + + mkdir "C:\Program Files\spp-cli" + @REM %USERPROFILE%\bin + + @REM Add spp-cli to the environment variable PATH. + copy ".\spp-cli.exe" "C:\Program Files\swctl-cli\swctl.exe" + setx "Path" "C:\Program Files\swctl-cli\;%path%" /m + + @REM Delete unnecessary files. + del ".\skywalking-cli-%VERSION%-bin.tgz" ".\verify.txt" + del ".\skywalking-cli-%VERSION%-bin.tgz.sha512" ".\releases.yml" + rd /S /Q ".\skywalking-cli-%VERSION%-bin" + + @echo Reopen the terminal and type 'spp-cli --help' to get more information. +) else ( + @echo Failed to download spp-cli-%VERSION%-win64.zip +) diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..75f776a --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Treat unset variables and parameters other than the special parameters ‘@’ or ‘*’ as an error. +set -u + +# Exit the script with a message. +abort() { + printf "%s\n" "$@" + exit 1 +} + +# Check if there is a bash. +if [ -z "${BASH_VERSION:-}" ]; then + abort "Bash is required to interpret this install script." +fi + +# Check OS. +OS="$(uname)" +if [[ "$OS" != "Darwin" && "$OS" != "Linux" ]]; then + abort "The install script is only supported on macOS and Linux." +fi + +check_cmd() { + if ! command -v "$@" &> /dev/null + then + abort "You must install "$@" before running the install script." + fi +} + +# Check if the commands to be used exist. +for cmd in curl unzip; do + check_cmd $cmd +done + +get_latest_release_number() { + curl --silent "https://github.com/sourceplusplus/interface-cli/releases/latest" | sed 's#.*tag/\(.*\)\".*#\1#' +} + +# Get the latest version of spp-cli. +VERSION=$(get_latest_release_number) +echo "Installing spp-cli $VERSION" + +# Download the binary package. +curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/spp-cli-$VERSION-linux64.zip" > /dev/null +if [ -f "spp-cli-$VERSION-linux64.zip" ]; then + unzip -q spp-cli-$VERSION-linux64.zip + + echo "Adding spp-cli to your PATH" + # Add spp-cli to the environment variable PATH. + sudo mv spp-cli /usr/local/bin/spp-cli + + # Delete unnecessary files. + rm "./spp-cli-$VERSION-linux64.zip" + echo "Installation complete." + + echo "Type 'spp-cli --help' to get more information." +else + abort "Failed to download spp-cli-$VERSION-linux64.zip" +fi From f363c5970ca858825a278df9d821cca53dfdfe7d Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 17 Feb 2022 20:14:11 -0500 Subject: [PATCH 2/4] windows install --- scripts/install.bat | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/scripts/install.bat b/scripts/install.bat index 284f26f..5141782 100644 --- a/scripts/install.bat +++ b/scripts/install.bat @@ -2,25 +2,13 @@ @echo off setlocal ENABLEDELAYEDEXPANSION -@REM curl https://api.github.com/repos/%Owner%/%Repo%/releases/latest > response.txt -@REM FOR /F "tokens=*" %%g IN ('FIND "tag_name" "response.txt"') do set result=%%g -@REM set "tag_name=%result:"tag_name": "=%" -@REM set "tag_name=%tag_name:",=%" - @REM Get the latest version of spp-cli. set FLAG="FALSE" set VERSION= UNKNOWN -curl -LO "https://raw.githubusercontent.com/apache/skywalking-website/master/data/releases.yml" -if EXIST "releases.yml" ( - for /F "tokens=1,2,*" %%i in ('FINDSTR "name version" "./releases.yml"') do ( - if !FLAG! EQU "TRUE" ( - set FLAG="FALSE" - set VERSION=%%k - ) - if "%%k" == "SkyWalking CLI" (set FLAG="TRUE") - ) -) -set VERSION=%VERSION:~1% +curl -s https://api.github.com/repos/sourceplusplus/interface-cli/releases/latest > response.txt +FOR /F "tokens=*" %%g IN ('FIND "tag_name" "response.txt"') do set result=%%g +set "tag_name=%result:"tag_name": "=%" +set "VERSION=%tag_name:",=%" @echo The latest version of spp-cli is %VERSION% @REM Download the binary package. @@ -29,16 +17,14 @@ if EXIST "spp-cli-%VERSION%-win64.zip" ( tar -xf ".\spp-cli-%VERSION%-win64.zip" mkdir "C:\Program Files\spp-cli" - @REM %USERPROFILE%\bin @REM Add spp-cli to the environment variable PATH. - copy ".\spp-cli.exe" "C:\Program Files\swctl-cli\swctl.exe" - setx "Path" "C:\Program Files\swctl-cli\;%path%" /m + copy ".\spp-cli.exe" "C:\Program Files\spp-cli\spp-cli.exe" + setx "Path" "C:\Program Files\spp-cli\;%path%" /m @REM Delete unnecessary files. - del ".\skywalking-cli-%VERSION%-bin.tgz" ".\verify.txt" - del ".\skywalking-cli-%VERSION%-bin.tgz.sha512" ".\releases.yml" - rd /S /Q ".\skywalking-cli-%VERSION%-bin" + del ".\response.txt" + del ".\spp-cli-%VERSION%-win64.zip" @echo Reopen the terminal and type 'spp-cli --help' to get more information. ) else ( From c119a1c084b46f215fc5bd922702ca114f2fa27f Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 17 Feb 2022 20:17:45 -0500 Subject: [PATCH 3/4] readme --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index fd32e0d..5297f95 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,31 @@ This project provides a command-line interface to [Source++](https://github.com/sourceplusplus/live-platform), the open-source live coding platform. +## Install + +### Quick install + +#### Linux or macOS + +Install the latest version with the following command: + +```shell +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/sourceplusplus/interface-cli/master/scripts/install.sh)" +``` + +#### Windows + +Note: you need to start cmd or powershell in administrator mode. + +```shell +curl -LO "https://raw.githubusercontent.com/sourceplusplus/interface-cli/master/scripts/install.bat" && .\install.bat +``` + +### Install by available binaries + +Go to the [releases page](https://github.com/sourceplusplus/interface-cli/releases) to download all available binaries, +including macOS, Linux, Windows. + # Usage Try executing `spp-cli --help` to output the usage instructions like so: From ade62388df4935b085fa59bbc3186973b3d91ca6 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Fri, 18 Feb 2022 15:07:22 -0500 Subject: [PATCH 4/4] readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5297f95..ea06039 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ This project provides a command-line interface to [Source++](https://github.com/sourceplusplus/live-platform), the open-source live coding platform. -## Install +# Install -### Quick install +## Quick install -#### Linux or macOS +### Linux or macOS Install the latest version with the following command: @@ -20,15 +20,15 @@ Install the latest version with the following command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/sourceplusplus/interface-cli/master/scripts/install.sh)" ``` -#### Windows +### Windows -Note: you need to start cmd or powershell in administrator mode. +Note: you need to start cmd or PowerShell in administrator mode. ```shell curl -LO "https://raw.githubusercontent.com/sourceplusplus/interface-cli/master/scripts/install.bat" && .\install.bat ``` -### Install by available binaries +## Install by available binaries Go to the [releases page](https://github.com/sourceplusplus/interface-cli/releases) to download all available binaries, including macOS, Linux, Windows.