Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from sdkman:master #105

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
f61702c
Add Homebrew support (#1042)
Mar 7, 2022
fd2ed04
Fix selfupdate bug.
marc0der Mar 9, 2022
57ccc4e
Disable Homebrew packager
Mar 11, 2022
bd2558a
Enable Homebrew packager (#1067)
Mar 14, 2022
9881a42
Add platform to appease Homebrew packager (#1070)
Mar 14, 2022
17d70f0
Run jreleaserFullRelease to create files required by Homebrew (#1071)
Mar 17, 2022
1e59a34
Consider unsupported platforms as exotic
parttimenerd Jan 25, 2022
282e11f
Update test and init
parttimenerd Mar 15, 2022
87b8176
Fix test
parttimenerd Mar 15, 2022
19eeef8
Code tweak in install source.
marc0der Mar 20, 2022
08e7402
Check zip integrity before checksum.
marc0der Mar 20, 2022
06fd043
Fix broken tests to do with platform inference.
marc0der Mar 20, 2022
3ab1da7
Upgrade JReleaser to 0.10.0.
marc0der Mar 21, 2022
3125e13
Upgrade JReleaser to 1.0.0-M3 (#1076)
Mar 25, 2022
31d2765
Replace template tag with version (#1079)
Mar 26, 2022
b7781e5
Add dependabot.yml (#1078)
Mar 31, 2022
d8e3bf8
Bump actions/checkout from 2 to 3
dependabot[bot] Mar 31, 2022
92277bf
Bump kentaro-m/auto-assign-action from 1.1.2 to 1.2.1
dependabot[bot] Mar 31, 2022
94ccfd0
Do not trigger beta releases on changes to the workflows
Mar 31, 2022
535e3c9
Remove local caching of candidates (#1077)
hgeraldino Apr 3, 2022
c8fec73
Improve Homebrew README (#1084)
Apr 7, 2022
c7f88ad
Bump actions/setup-java from 2 to 3 (#1085)
dependabot[bot] Apr 11, 2022
469f83b
Pass platform identifier to selfupdate beta script.
marc0der Apr 18, 2022
0906561
#1087 Fix sdkman_auto_env when PROMPT_COMMAND ends with space (#1088)
speedlog Apr 21, 2022
9f86a55
Bump JReleaser from 1.0.0-M3 to 1.0.0 (#1091)
Apr 27, 2022
ccf6770
Fix typos in CONTRIBUTING.md (#1107)
marcwrobel Jul 23, 2022
8adeaf9
Pass platform identifier to selfupdate stable script.
marc0der Aug 6, 2022
f26c250
Accommodate platform in selfupdate stub.
marc0der Aug 6, 2022
826ee2c
Bump kentaro-m/auto-assign-action from 1.2.1 to 1.2.3 (#1118)
dependabot[bot] Sep 7, 2022
324e920
Bump kentaro-m/auto-assign-action from 1.2.3 to 1.2.4 (#1135)
dependabot[bot] Oct 14, 2022
65b95fb
Fix test failures in OSX/Intel when inferring the platform (#1141)
hgeraldino Dec 19, 2022
c37a9fd
Remove home command hack
marc0der Dec 29, 2022
bb119b8
Remove legacy completion command workaround
marc0der Dec 29, 2022
e4fc020
Display native help, falling back to legacy help
marc0der Feb 7, 2023
b5ed847
Give precedence to native home command
marc0der Feb 7, 2023
3215879
Simplify native command invocation
marc0der Feb 11, 2023
47fd6c4
Run Mongo release from Docker
marc0der Feb 12, 2023
00538c2
Remove broadcast command.
marc0der Feb 17, 2023
010736e
Simplify parameter propagation in the main sdk function.
marc0der Mar 1, 2023
a89a8cc
Strip out the broadcast id and rename to healthcheck where needed.
marc0der Mar 1, 2023
4b172a6
Remove auto-update feature.
marc0der Mar 3, 2023
6540277
chore: Improve `sdk env` error handling (#1193)
Mar 19, 2023
40d3c2f
Removes version cache refresh.
marc0der Mar 16, 2023
e784383
Update sdk env.
marc0der Mar 16, 2023
8a8c69d
Fix selfupdate.
marc0der Mar 18, 2023
c7374b7
Preparation for considering native version in selfupdate.
marc0der Mar 18, 2023
6d2bcda
Consider native version in selfupdate, fix tests and add coverage.
marc0der Mar 18, 2023
6bd587d
Clean up.
marc0der Mar 18, 2023
5e33c36
Address PR comments.
marc0der Mar 19, 2023
71c9490
Fix broken build.
marc0der Mar 20, 2023
b524183
Do not check and warn of stale candidates cache.
marc0der Mar 31, 2023
babd5fb
Remove obsolete candidates cache spec.
marc0der Mar 31, 2023
84222a3
chore: Upgrade to Gradle 8.0.1, setup caching for GH workflows
Feb 24, 2023
7e46af3
Bump kentaro-m/auto-assign-action from 1.2.4 to 1.2.5
dependabot[bot] Apr 1, 2023
c880cd1
chore: Support Mastodon announcer
Jan 9, 2023
82e06b4
Do not validate candidate for native commands.
marc0der Apr 6, 2023
41a2743
Remove obsolete pre-installation hooks.
marc0der Apr 1, 2023
c05c7e4
Only infer MSYS and MINGW on Windows.
marc0der May 13, 2023
33a4adf
Read platform from descriptor file.
marc0der May 14, 2023
a5f07d6
Fix broken platform tests and remove obsolete PlatformSpec.
marc0der May 14, 2023
f284bc4
Read platform file from var folder.
marc0der May 14, 2023
19e5c08
Add missing quotes when handling file paths within install command
kr5ture Jun 3, 2023
1d4b5eb
Remove rosetta 2 compatible flag from brew formula
marc0der Oct 15, 2023
4600793
Rename pull_request_tempalte.md to pull_request_template.md
coiouhkc Oct 18, 2023
6529e01
Bump actions/setup-java from 3 to 4 (#1259)
dependabot[bot] Nov 30, 2023
67de99c
Update README
marc0der Apr 17, 2024
f33f264
Add notice to README
marc0der May 26, 2024
2bcdc63
chore: Remove Homebrew packager (#1298)
Jun 18, 2024
89199f5
Update support request template.
marc0der Jul 24, 2024
42b1af6
Update CONTRIBUTING.md
marc0der Aug 19, 2024
8e6d096
Update feature_request.md
marc0der Aug 19, 2024
e6b29b6
Update support_request.md
marc0der Aug 19, 2024
47e4c6c
Update config.yml
marc0der Aug 19, 2024
ec6d5e0
Update README
marc0der Nov 23, 2024
0e15c94
Use shields.io for all badges
marc0der Nov 23, 2024
cbbef0f
Update feature request template.
marc0der Nov 25, 2024
b24e3ee
Fixes to bug report template.
marc0der Nov 25, 2024
42c95ac
Improve support request template.
marc0der Nov 25, 2024
6035719
Observe the sdkman_native_enable feature flag
marc0der Dec 18, 2024
7280765
Explicitly disable native extensions in tests
marc0der Dec 18, 2024
f8f97f8
Issue deprecation notice for eclipsed legacy commands
marc0der Dec 18, 2024
9c657e9
Improve deprecation message formatting
marc0der Dec 18, 2024
cadd725
Update deprecation link
marc0der Dec 19, 2024
b8d230b
Update deprecation link again
marc0der Dec 21, 2024
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
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ assignees: ''

---
<!-- DO NOT DELETE THIS TEMPLATE AND PLEASE READ IT WITH CARE! -->
<!-- Thank you for using the SDKMAN! issue tracker. Please fill in everything to the best of your ability. If you are unsure if it is a bug, then please use our Slack user-issues channel before creating a new issue. Please understand that we cannot offer regular support through GitHub issues and will close the issue if it is not an actual bug. -->
<!-- Thank you for using the SDKMAN! issue tracker. Please fill in everything to the best of your ability. If you need clarification on whether it is a bug, please use our #help Discord channel before creating a new issue. Please know that we cannot offer regular support through GitHub issues and will close the issue without warning if it is not a bug. -->

**Bug report**
<!-- A clear and concise description of the bug you encountered -->

**To reproduce**
<!-- Steps to reproduce the behavior or verify the issue -->
<!-- Steps to reproduce the behaviour or verify the issue -->

**System info**
<!-- Please add relevant information about your system:
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ contact_links:
- name: SDKMAN! usage documentation
url: https://sdkman.io/usage
about: Find documentation about the available commands here.
- name: SDKMAN! Slack community
url: https://slack.sdkman.io/
about: Please ask and answer questions about usage of SDKMAN! here.
- name: SDKMAN! Discord server
url: https://discord.gg/y9mVJYVyu4
about: Please ask and answer questions about the usage of SDKMAN! here.
- name: SDKMAN! on Stack Overflow
url: https://stackoverflow.com/questions/tagged/sdkman
about: You might find help to common issues here.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ labels: 'enhancement'
assignees: ''
---

<!-- Thank you for suggesting a new feature. Please discuss your idea on our #cli-development Slack channel before requesting a new feature. -->
<!-- Thank you for suggesting a new feature. Please discuss your idea on our #discussions Discord channel before requesting a new feature. -->

- [ ] I have read the [CONTRIBUTING guidelines](CONTRIBUTING.md)
- [ ] I've had a conversation on the [#cli-development](https://sdkman.slack.com/app_redirect?channel=cli-development) Slack channel about this request.
- [ ] I've had a conversation on our community [Discord](https://discord.gg/y9mVJYVyu4) server.

**Feature request**
<!-- A clear and precise description of what new or changed feature you want. Please include the reason, why you would need the feature. E.g. what problem does it solve? Or which workflow is currently frustrating and will be improved by this? -->
<!-- A clear and precise description of your desired new or changed feature. Please include the reason why you would need the feature. E.g. what problem does it solve? Or which workflow is currently frustrating and will be improved by this? -->

8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/support_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ labels: 'support'
assignees: ''

---
<!-- Thank you for using SDKMAN!. We want to help users using the software, but we also try to avoid filling the issue tracker with too many support requests. We kindly ask you to use our Slack channel #user-issues before posting.
<!-- Thank you for using SDKMAN!. We want to help users using the software but also avoid filling the issue tracker with too many support requests. Please talk to us on our Discord server before posting.

Please consider the following things. Note, that ignoring all of these might lead to the issue simply being closed. -->
Please consider the following things. Just so you know, ignoring any of these might lead to the issue being closed abruptly. -->

- [ ] I have checked [the documentation](https://sdkman.io/usage)
- [ ] I have done a quick search in [past issues](https://github.com/rclone/rclone/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems
- [ ] I have brought up a conversation in the [Slack User Issues Channel](https://sdkman.slack.com/app_redirect?channel=user-issues)
- [ ] I have performed a quick search in [past issues](https://github.com/sdkman/sdkman-cli/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems
- [ ] I have brought up a conversation in the community [Discord](https://discord.gg/y9mVJYVyu4) server

**Question**
<!-- A clear and concise description of the issue you are encountering -->
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
File renamed without changes.
7 changes: 5 additions & 2 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches:
- master
paths-ignore:
- .github/workflows/*

jobs:
pre-release:
Expand All @@ -15,11 +17,12 @@ jobs:
ports:
- 27017:27017
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Run tests
run: ./gradlew clean test --info
- name: Set short git hash
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-java@v2
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Run with Gradle
run: ./gradlew clean test --info
- uses: kentaro-m/auto-assign-action@v1.1.2
- uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: ".github/auto_assign.yml"
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ jobs:
JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN}}
services:
mongodb:
image: mongo:3.2
ports:
- 27017:27017
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v2
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Run tests
run: ./gradlew clean test --info
- name: Build artifacts
run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} clean assemble
- name: Release
run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} jreleaserRelease
run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} jreleaserFullRelease --exclude-announcer=twitter
- name: Update MongoDB
env:
MONGO_URL: ${{ secrets.MONGO_URL }}
Expand Down
2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=11.0.13-tem
java=11.0.17-tem
13 changes: 5 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

We greatly value the feedback and contributions of our users.

We keep a distinction between Bugs/Issues, New Features and Support Requests. We also try to minimise the noise in our GitHub Issues stream and prefer having a conversation on [SDKMAN Slack](https://slack.sdkman.io) before creating new issues, if you are not fully sure how to categorize your request. Simply sign up and join one of the following channels:
We distinguish between Bugs/Issues, New Features and Support Requests. We also try to minimise the noise in our GitHub Issues stream and prefer having a conversation on [SDKMAN Discord](https://discord.gg/y9mVJYVyu4) before creating new issues if you are not entirely sure how to categorize your request. Sign up and join our Help channel.

- User Issues can be raised in our [User Issues channel](https://sdkman.slack.com/app_redirect?channel=user-issues).
- New Features or Enhancements can be discussed in our [CLI Development channel](https://sdkman.slack.com/app_redirect?channel=cli-development).
The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required information.

The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required informations.

**Unfortunately we might simply close any Github Issues that have not followed the requested template.**
**Unfortunately, we might close any GitHub Issues that have not followed the requested template.**

### Pull Requests

Pull Requests are _always_ very welcome, but require a valid GitHub Issue as decribed above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the Github Issue number by replacing `#XXX` with the appropriate issue reference.
Pull Requests are _always_ very welcome but require a valid GitHub Issue as described above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the GitHub Issue number by replacing `#XXX` with the appropriate issue reference.

Each PR should also be accompanied by a passing test(s) proving it's validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue.
Each PR should also be accompanied by a passing test(s) proving its validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue.
41 changes: 12 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# SDKMAN! CLI
### The Software Development Kit Manager Command Line Interface

[![Backers on Open Collective](https://opencollective.com/sdkman/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/sdkman/sponsors/badge.svg)](#sponsors)
[![Slack](https://slack.sdkman.io/badge.svg)](https://slack.sdkman.io)
[![Backers on Open Collective](https://img.shields.io/opencollective/backers/sdkman)](#backers)
[![Sponsors on Open Collective](https://img.shields.io/opencollective/sponsors/sdkman)](#sponsors)
[![Discord](https://img.shields.io/discord/1245471991117512754)](https://discord.gg/y9mVJYVyu4)

SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix based system. It provides a convenient command line interface for installing, switching, removing and listing Candidates.
SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix-based system. It provides a convenient command-line interface for installing, switching, removing, and listing Candidates.

See documentation on the [SDKMAN! website](https://sdkman.io).

## NOTICE

**We are rewriting all the commands for SDKMAN! in [Rust](https://www.rust-lang.org/) under a [new project](https://github.com/sdkman/sdkman-cli-native) that supplements this one. Only bug fixes to supporting code will be
accepted in this project. As a result, no further enhancements will be accepted on the commands in this project, and the commands here will be phased out in due course. This project will eventually form a lightweight
wrapper/launcher for the replacement Rust commands.**

## Installation

Open your favourite terminal and enter the following:
Expand All @@ -23,32 +29,9 @@ All SDKMAN's BDD tests describing the CLI behaviour are written in Cucumber and

$ ./gradlew test

To perform development, you will need to have a JDK 8 or higher installed which can be obtained by running the following after installing SDKMAN:

$ sdk install java

### Using Docker for tests

You can run the tests in a Docker container to guarantee a clean test environment.

$ docker build --tag=sdkman-cli/gradle .
$ docker run --rm -it sdkman-cli/gradle test

By running the following command, you don't need to wait for downloading Gradle wrapper and other dependencies. The test reports can be found under the local `build` directory.

$ docker run --rm -it -v $PWD:/usr/src/app -v $HOME/.gradle:/root/.gradle sdkman-cli/gradle test

### Local Installation

To install SDKMAN locally running against your local server, run the following commands:

$ ./gradlew install
$ source ~/.sdkman/bin/sdkman-init.sh

Or run install locally with Production configuration:
To perform development, you will need to have a JDK 11 installed which can be obtained by running the following after installing SDKMAN:

$ ./gradlew -Penv=production install
$ source ~/.sdkman/bin/sdkman-init.sh
$ sdk env install

## Contributors

Expand Down
7 changes: 6 additions & 1 deletion bin/release-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ fi

echo "Release: $FIELD as $VERSION"

mongo "${MONGO_URL}" --username="${MONGO_USERNAME}" --password="${MONGO_PASSWORD}" -eval "db.application.updateOne({}, {\$set: { \"$FIELD\": \"$VERSION\"}});"
docker run mongo:3.2 mongo "${MONGO_URL}" \
--username="${MONGO_USERNAME}" \
--password="${MONGO_PASSWORD}" \
--quiet \
--eval "db.application.updateOne({}, {\$set: { \"$FIELD\": \"$VERSION\"}});"

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id('groovy')
id('org.jreleaser').version('0.8.0').apply(false)
id('org.jreleaser').version('1.4.0').apply(false)
}

String userHome = System.getProperty('user.home')
Expand Down
4 changes: 2 additions & 2 deletions contrib/completion/bash/sdk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ __sdkman_complete_command() {

case $command in
sdk)
candidates=("install" "uninstall" "list" "use" "config" "default" "home" "env" "current" "upgrade" "version" "broadcast" "help" "offline" "selfupdate" "update" "flush")
candidates=("install" "uninstall" "list" "use" "config" "default" "home" "env" "current" "upgrade" "version" "help" "offline" "selfupdate" "update" "flush")
;;
current|c|default|d|home|h|uninstall|rm|upgrade|ug|use|u)
local -r candidate_paths=("${SDKMAN_CANDIDATES_DIR}"/*)
Expand All @@ -45,7 +45,7 @@ __sdkman_complete_command() {
candidates=("force")
;;
flush)
candidates=("archives" "temp" "broadcast" "version")
candidates=("temp" "version")
;;
esac

Expand Down
1 change: 0 additions & 1 deletion gradle/archive.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ task prepareBin(type: Copy) {
filter(
ReplaceTokens,
tokens: [
SDKMAN_VERSION : sdkmanVersion,
SDKMAN_CANDIDATES_API: candidatesApi
]
)
Expand Down
8 changes: 7 additions & 1 deletion gradle/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ jreleaser {
distributionType = 'BINARY'
artifact {
path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip"
extraProperties.put("universal", "true")
}
}
}

announce {
twitter {
active = 'RELEASE'
status = 'Released version {{tagName}} of SDKMAN! {{releaseNotesUrl}}'
}
mastodon {
active = 'RELEASE'
status = 'Released version {{tagName}} of SDKMAN! {{releaseNotesUrl}}'
host = 'https://fosstodon.org'
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
52 changes: 11 additions & 41 deletions src/main/bash/sdkman-availability.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,25 @@
# limitations under the License.
#

function __sdkman_update_broadcast_and_service_availability() {
local broadcast_live_id=$(__sdkman_determine_broadcast_id)
__sdkman_set_availability "$broadcast_live_id"
__sdkman_update_broadcast "$broadcast_live_id"
function __sdkman_update_service_availability() {
local healthcheck_status=$(__sdkman_determine_healthcheck_status)
__sdkman_set_availability "$healthcheck_status"
}

function __sdkman_determine_broadcast_id() {
function __sdkman_determine_healthcheck_status() {
if [[ "$SDKMAN_OFFLINE_MODE" == "true" || "$COMMAND" == "offline" && "$QUALIFIER" == "enable" ]]; then
echo ""
else
echo $(__sdkman_secure_curl_with_timeouts "${SDKMAN_CANDIDATES_API}/broadcast/latest/id")
echo $(__sdkman_secure_curl_with_timeouts "${SDKMAN_CANDIDATES_API}/healthcheck")
fi
}

function __sdkman_set_availability() {
local broadcast_id="$1"
local detect_html="$(echo "$broadcast_id" | tr '[:upper:]' '[:lower:]' | grep 'html')"
if [[ -z "$broadcast_id" ]]; then
local healthcheck_status="$1"
local detect_html="$(echo "$healthcheck_status" | tr '[:upper:]' '[:lower:]' | grep 'html')"
if [[ -z "$healthcheck_status" ]]; then
SDKMAN_AVAILABLE="false"
__sdkman_display_offline_warning "$broadcast_id"
__sdkman_display_offline_warning "$healthcheck_status"
elif [[ -n "$detect_html" ]]; then
SDKMAN_AVAILABLE="false"
__sdkman_display_proxy_warning
Expand All @@ -45,8 +44,8 @@ function __sdkman_set_availability() {
}

function __sdkman_display_offline_warning() {
local broadcast_id="$1"
if [[ -z "$broadcast_id" && "$COMMAND" != "offline" && "$SDKMAN_OFFLINE_MODE" != "true" ]]; then
local healthcheck_status="$1"
if [[ -z "$healthcheck_status" && "$COMMAND" != "offline" && "$SDKMAN_OFFLINE_MODE" != "true" ]]; then
__sdkman_echo_red "==== INTERNET NOT REACHABLE! ==================================================="
__sdkman_echo_red ""
__sdkman_echo_red " Some functionality is disabled or only partially available."
Expand All @@ -65,32 +64,3 @@ function __sdkman_display_proxy_warning() {
__sdkman_echo_red "================================================================================"
echo ""
}

function __sdkman_update_broadcast() {
local broadcast_live_id broadcast_id_file broadcast_text_file broadcast_old_id

broadcast_live_id="$1"
broadcast_id_file="${SDKMAN_DIR}/var/broadcast_id"
broadcast_text_file="${SDKMAN_DIR}/var/broadcast"
broadcast_old_id=""

if [[ -f "$broadcast_id_file" ]]; then
broadcast_old_id=$(< "$broadcast_id_file")
fi

if [[ -f "$broadcast_text_file" ]]; then
BROADCAST_OLD_TEXT=$(< "$broadcast_text_file")
fi

if [[ "$SDKMAN_AVAILABLE" == "true" && "$broadcast_live_id" != "$broadcast_old_id" && "$COMMAND" != "selfupdate" && "$COMMAND" != "flush" ]]; then
mkdir -p "${SDKMAN_DIR}/var"

echo "$broadcast_live_id" | tee "$broadcast_id_file" > /dev/null

BROADCAST_LIVE_TEXT=$(__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/broadcast/latest")
echo "$BROADCAST_LIVE_TEXT" | tee "$broadcast_text_file" > /dev/null
if [[ "$COMMAND" != "broadcast" ]]; then
__sdkman_echo_cyan "$BROADCAST_LIVE_TEXT"
fi
fi
}
Loading
Loading