Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions scripts/install-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ while getopts "v:d" flag; do
SLACK_CLI_DEV_VERSION=$OPTARG
else
echo "Slack CLI requires a valid semver version number." >&2
exit 1
return 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 The exit command is replaced with a return to avoid ending the script altogether for later logic.

fi
;;
d)
Expand Down Expand Up @@ -102,8 +102,8 @@ install_slack_cli() {

echo -e "🔖 Try using an alias when installing to avoid name conflicts:\n"

echo -e "curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s your-preferred-alias\n"
exit 1
echo -e "curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s your-preferred-alias"
return 1
fi
else
if [ "$SLACK_CLI_DEV_VERSION" == "dev" ]; then
Expand Down Expand Up @@ -140,7 +140,7 @@ install_slack_cli() {
echo "🛑 Error: This installer is only supported on Linux and macOS"
echo "🔖 Try using a different installation method:"
echo "🔗 https://tools.slack.dev/slack-cli"
exit 1
return 1
fi

slack_cli_install_dir="$HOME/.slack/dev-build"
Expand Down Expand Up @@ -169,15 +169,15 @@ install_slack_cli() {
if [ ! -d /usr/local/bin ]; then
echo -e "⚠️ The /usr/local/bin directory does not exist!"
echo -e "🔐 Please create /usr/local/bin directory first and try again..."
exit 1
return 1
fi
if [ -w /usr/local/bin ]; then
ln -sf "$slack_cli_bin_path" "/usr/local/bin/$SLACK_CLI_NAME"
else
echo -e "⚠️ Failed to create a symbolic link!"
delay 0.1 "🔖 The installer doesn't have write access to /usr/local/bin"
echo -e "🔐 Please check the permission and try again..."
exit 1
echo -e "🔐 Please check permission and try again..."
return 1
fi

if [ $(command -v $SLACK_CLI_NAME) ]; then
Expand Down Expand Up @@ -272,7 +272,7 @@ maybe_update_deno_version() {
[Yy]*) deno upgrade --version $MIN_DENO_VERSION ;;
*)
echo "Please upgrade deno manually to at least $MIN_DENO_VERSION and re-run this script."
exit
return
;;
esac
;;
Expand Down Expand Up @@ -323,7 +323,7 @@ install_deno() {
ln -sf "$deno_path" /usr/local/bin/deno
else
echo -e "Installer doesn't have write access to /usr/local/bin to create a symbolic link. Please check permission and try again"
exit 1
return 1
fi
fi
fi
Expand All @@ -349,9 +349,15 @@ install_deno_vscode_extension() {
}

feedback_message() {
if [ $(command -v $SLACK_CLI_NAME) ]; then
CODE=$?
if [ $CODE -eq 0 ] && [ $(command -v $SLACK_CLI_NAME) ]; then
echo -e "\n💌 We would love to know how things are going. Really. All of it."
echo -e " Survey your development experience with \`$SLACK_CLI_NAME feedback\`"
else
echo -e "\x1b[0m"
echo -e "💌 We would love to know how things are going. Really. All of it."
echo -e " Submit installation issues: https://github.com/slackapi/slack-cli/issues"
exit $CODE
fi
}

Expand All @@ -369,8 +375,11 @@ next_step_message() {
}

main() {
set -e
trap 'feedback_message' ERR

set -eE
install_slack_cli "$@"

sleep 0.1
install_deno

Expand Down
33 changes: 24 additions & 9 deletions scripts/install-windows-dev.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function check_slack_binary_exist() {

Write-Host "`nTry using an alias when installing to avoid name conflicts:"
Write-Host "`nirm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 -Alias your-preferred-alias | iex"
Exit;
throw
}
}
$message = "It is the same Slack CLI! Upgrading to the latest version..."
Expand Down Expand Up @@ -116,7 +116,8 @@ function install_slack_cli {
}
}
catch {
throw "`nInstaller cannot find latest Slack CLI release version"
Write-Error "Installer cannot find latest Slack CLI release version"
throw
}

$slack_cli_dir = "${Home}\AppData\Local\slack-cli"
Expand All @@ -133,14 +134,16 @@ function install_slack_cli {
$slack_cli_dir = $alternative_slack_cli_dir
}
catch {
throw "`nInstaller cannot create folder in $($alternative_slack_cli_dir). `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
Write-Error "Installer cannot create folder in $($alternative_slack_cli_dir). `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
throw
}
}
}
}
}
catch {
throw "`nInstaller cannot create folder for Slack CLI, `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
Write-Error "Installer cannot create folder for Slack CLI, `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
throw
}

if ($Version -eq "dev") {
Expand All @@ -153,7 +156,8 @@ function install_slack_cli {
Invoke-WebRequest -Uri "https://downloads.slack-edge.com/slack-cli/slack_cli_$($SLACK_CLI_VERSION)_windows_64-bit.zip" -OutFile "$($slack_cli_dir)\slack_cli.zip"
}
catch {
throw "`nInstaller cannot download Slack CLI"
Write-Error "Installer cannot download Slack CLI"
throw
}

$slack_cli_bin_dir = "$($slack_cli_dir)\bin"
Expand Down Expand Up @@ -243,7 +247,8 @@ function install_deno {
Write-Host "Comparing the currently installed Deno version... Found: v$deno_version_local"
}
else {
throw "Deno is not installed! Please install Deno to at least v$MIN_DENO_VERSION and try again."
Write-Error "Deno is not installed! Please install Deno to at least v$MIN_DENO_VERSION and try again."
throw
}

if ($deno_version_latest -eq "v$deno_version_local") {
Expand All @@ -262,7 +267,8 @@ function install_deno {
Write-Host "Nice! Your Deno version has been updated and is ready!"
}
catch {
throw "`nDeno is not installed, please install deno manually to at least $MIN_DENO_VERSION and re-run this script."
Write-Error "Deno is not installed, please install deno manually to at least $MIN_DENO_VERSION and re-run this script."
throw
}
}
else {
Expand All @@ -280,7 +286,8 @@ function install_deno {
Write-Host "Your Deno version is compatible with the Slack CLI!"
}
catch {
throw "`nDeno is not installed, please install Deno manually to at least $MIN_DENO_VERSION and re-run this script."
Write-Error "Deno is not installed, please install Deno manually to at least $MIN_DENO_VERSION and re-run this script."
throw
}
}
}
Expand Down Expand Up @@ -339,11 +346,19 @@ function next_step_message {
Write-Host " Then, authorize your CLI in your workspace with ``$confirmed_alias login``.`n"
}
catch {
throw "`nSlack CLI is not installed.`nPlease reach out to [email protected] to share the issues you are facing.`nMeanwhile you can try the manual installation: https://tools.slack.dev/slack-cli.`n"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💌 We now have an issue tracker to direct the most kind folks to!

Write-Error "Slack CLI was not installed."
Write-Host "`nFind help troubleshooting: https://tools.slack.dev/slack-cli"
throw
}
}
}

trap {
Write-Host "`nWe would love to know how things are going. Really. All of it."
Write-Host "Submit installation issues: https://github.com/slackapi/slack-cli/issues"
exit 1
}

install_slack_cli $Alias $Version
install_deno $SkipDeno
Write-Host "`nAdding developer tooling for an enhanced experience..."
Expand Down
33 changes: 24 additions & 9 deletions scripts/install-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function check_slack_binary_exist() {

Write-Host "`nTry using an alias when installing to avoid name conflicts:"
Write-Host "`nirm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 -Alias your-preferred-alias | iex"
Exit;
throw
}
}
$message = "It is the same Slack CLI! Upgrading to the latest version..."
Expand Down Expand Up @@ -113,7 +113,8 @@ function install_slack_cli {
}
}
catch {
throw "`nInstaller cannot find latest Slack CLI release version"
Write-Error "Installer cannot find latest Slack CLI release version"
throw
}

$slack_cli_dir = "${Home}\AppData\Local\slack-cli"
Expand All @@ -131,20 +132,23 @@ function install_slack_cli {
$slack_cli_dir = $alternative_slack_cli_dir
}
catch {
throw "`nInstaller cannot create folder in $($alternative_slack_cli_dir). `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
Write-Error "Installer cannot create folder in $($alternative_slack_cli_dir). `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
throw
}
}
}
}
}
catch {
throw "`nInstaller cannot create folder for Slack CLI, `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
Write-Error "Installer cannot create folder for Slack CLI, `nPlease manually create $($slack_cli_dir) folder and re-run the installation script"
throw
}
try {
Invoke-WebRequest -Uri "https://downloads.slack-edge.com/slack-cli/slack_cli_$($SLACK_CLI_VERSION)_windows_64-bit.zip" -OutFile "$($slack_cli_dir)\slack_cli.zip"
}
catch {
throw "`nInstaller cannot download Slack CLI"
Write-Error "Installer cannot download Slack CLI"
throw
}

$slack_cli_bin_dir = "$($slack_cli_dir)\bin"
Expand Down Expand Up @@ -234,7 +238,8 @@ function install_deno {
Write-Host "Comparing the currently installed Deno version... Found: v$deno_version_local"
}
else {
throw "Deno is not installed! Please install Deno to at least v$MIN_DENO_VERSION and try again."
Write-Error "Deno is not installed! Please install Deno to at least v$MIN_DENO_VERSION and try again."
throw
}

if ($deno_version_latest -eq "v$deno_version_local") {
Expand All @@ -253,7 +258,8 @@ function install_deno {
Write-Host "Nice! Your Deno version has been updated and is ready!"
}
catch {
throw "`nDeno is not installed, please install deno manually to at least $MIN_DENO_VERSION and re-run this script."
Write-Error "Deno is not installed, please install deno manually to at least $MIN_DENO_VERSION and re-run this script."
throw
}
}
else {
Expand All @@ -271,7 +277,8 @@ function install_deno {
Write-Host "Your Deno version is compatible with the Slack CLI!"
}
catch {
throw "`nDeno is not installed, please install Deno manually to at least $MIN_DENO_VERSION and re-run this script."
Write-Error "Deno is not installed, please install Deno manually to at least $MIN_DENO_VERSION and re-run this script."
throw
}
}
}
Expand Down Expand Up @@ -330,11 +337,19 @@ function next_step_message {
Write-Host " Then, authorize your CLI in your workspace with ``$confirmed_alias login``.`n"
}
catch {
throw "`nSlack CLI is not installed.`nPlease reach out to [email protected] to share the issues you are facing.`nMeanwhile you can try the manual installation: https://tools.slack.dev/slack-cli`n"
Write-Error "Slack CLI was not installed."
Write-Host "`nFind help troubleshooting: https://tools.slack.dev/slack-cli"
throw
}
}
}

trap {
Write-Host "`nWe would love to know how things are going. Really. All of it."
Write-Host "Submit installation issues: https://github.com/slackapi/slack-cli/issues"
exit 1
}

install_slack_cli $Alias $Version
install_deno $SkipDeno
Write-Host "`nAdding developer tooling for an enhanced experience..."
Expand Down
30 changes: 19 additions & 11 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ while getopts "v:d" flag; do
SLACK_CLI_VERSION=$OPTARG
else
echo "Slack CLI requires a valid semver version number." >&2
exit 1
return 1
fi
;;
d)
Expand Down Expand Up @@ -88,8 +88,8 @@ install_slack_cli() {

echo -e "🔖 Try using an alias when installing to avoid name conflicts:\n"

echo -e "curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s your-preferred-alias\n"
exit 1
echo -e "curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s your-preferred-alias"
return 1
fi
else
if [ -z "$SLACK_CLI_VERSION" ]; then
Expand All @@ -110,7 +110,7 @@ install_slack_cli() {
if [ -z "$LATEST_SLACK_CLI_VERSION" ]; then
echo "🛑 Error: Installer cannot find the latest Slack CLI version!"
echo "🔖 Check the status of https://slack-status.com/ and try again"
exit 1
return 1
fi
echo -e "💾 Release v$LATEST_SLACK_CLI_VERSION was found! Downloading now..."
SLACK_CLI_VERSION=$LATEST_SLACK_CLI_VERSION
Expand Down Expand Up @@ -142,7 +142,7 @@ install_slack_cli() {
echo "🛑 Error: This installer is only supported on Linux and macOS"
echo "🔖 Try using a different installation method:"
echo "🔗 https://tools.slack.dev/slack-cli"
exit 1
return 1
fi

slack_cli_install_dir="$HOME/.slack"
Expand All @@ -167,15 +167,15 @@ install_slack_cli() {
if [ ! -d /usr/local/bin ]; then
echo -e "⚠️ The /usr/local/bin directory does not exist!"
echo -e "🔐 Please create /usr/local/bin directory first and try again..."
exit 1
return 1
fi
if [ -w /usr/local/bin ]; then
ln -sf "$slack_cli_bin_path" "/usr/local/bin/$SLACK_CLI_NAME"
else
echo -e "⚠️ Failed to create a symbolic link!"
delay 0.1 "🔖 The installer doesn't have write access to /usr/local/bin"
echo -e "🔐 Please check permission and try again..."
exit 1
return 1
fi

if [ $(command -v $SLACK_CLI_NAME) ]; then
Expand Down Expand Up @@ -271,7 +271,7 @@ maybe_update_deno_version() {
[Yy]*) deno upgrade --version $MIN_DENO_VERSION ;;
*)
echo "Please upgrade deno manually to at least $MIN_DENO_VERSION and re-run this script."
exit
return
;;
esac
;;
Expand Down Expand Up @@ -322,7 +322,7 @@ install_deno() {
ln -sf "$deno_path" /usr/local/bin/deno
else
echo -e "Installer doesn't have write access to /usr/local/bin to create a symbolic link. Please check permission and try again"
exit 1
return 1
fi
fi
fi
Expand All @@ -348,9 +348,15 @@ install_deno_vscode_extension() {
}

feedback_message() {
if [ $(command -v $SLACK_CLI_NAME) ]; then
CODE=$?
if [ $CODE -eq 0 ] && [ $(command -v $SLACK_CLI_NAME) ]; then
echo -e "\n💌 We would love to know how things are going. Really. All of it."
echo -e " Survey your development experience with \`$SLACK_CLI_NAME feedback\`"
else
echo -e "\x1b[0m"
echo -e "💌 We would love to know how things are going. Really. All of it."
echo -e " Submit installation issues: https://github.com/slackapi/slack-cli/issues"
exit $CODE
fi
}

Expand All @@ -368,7 +374,9 @@ next_step_message() {
}

main() {
set -e
trap 'feedback_message' ERR

set -eE
install_slack_cli "$@"

sleep 0.1
Expand Down
Loading