Skip to content

Commit

Permalink
Remove broadcast command.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0der committed Feb 21, 2023
1 parent 47fd6c4 commit 00538c2
Show file tree
Hide file tree
Showing 18 changed files with 13 additions and 188 deletions.
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=("temp" "broadcast" "version")
candidates=("temp" "version")
;;
esac

Expand Down
20 changes: 4 additions & 16 deletions src/main/bash/sdkman-availability.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# limitations under the License.
#

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

function __sdkman_determine_broadcast_id() {
Expand Down Expand Up @@ -66,31 +66,19 @@ function __sdkman_display_proxy_warning() {
echo ""
}

function __sdkman_update_broadcast() {
local broadcast_live_id broadcast_id_file broadcast_text_file broadcast_old_id
function __sdkman_update_broadcast_id() {
local broadcast_live_id broadcast_id_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
}
25 changes: 0 additions & 25 deletions src/main/bash/sdkman-broadcast.sh

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/bash/sdkman-flush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ function __sdk_flush() {
local qualifier="$1"

case "$qualifier" in
broadcast)
__sdkman_cleanup_broadcast
;;
version)
if [[ -f "${SDKMAN_DIR}/var/version" ]]; then
rm -f "${SDKMAN_DIR}/var/version"
Expand Down Expand Up @@ -60,13 +57,3 @@ function __sdkman_cleanup_folder() {

__sdkman_echo_green "${sdkman_cleanup_count} archive(s) flushed, freeing ${sdkman_cleanup_disk_usage}."
}

function __sdkman_cleanup_broadcast() {
if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then
rm -f "${SDKMAN_DIR}/var/broadcast_id"
rm -f "${SDKMAN_DIR}/var/broadcast"
__sdkman_echo_green "Broadcast has been flushed."
else
__sdkman_echo_no_colour "No prior broadcast found so not flushed."
fi
}
3 changes: 1 addition & 2 deletions src/main/bash/sdkman-help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function __sdk_help() {
__sdkman_echo_no_colour " current or c [candidate]"
__sdkman_echo_no_colour " upgrade or ug [candidate]"
__sdkman_echo_no_colour " version or v"
__sdkman_echo_no_colour " broadcast or b"
__sdkman_echo_no_colour " help"
__sdkman_echo_no_colour " offline [enable|disable]"

Expand All @@ -42,7 +41,7 @@ function __sdk_help() {
fi

__sdkman_echo_no_colour " update"
__sdkman_echo_no_colour " flush [tmp|broadcast|metadata|version]"
__sdkman_echo_no_colour " flush [tmp|metadata|version]"
__sdkman_echo_no_colour ""
__sdkman_echo_no_colour " candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc."
__sdkman_echo_no_colour " use list command for comprehensive list of candidates"
Expand Down
5 changes: 1 addition & 4 deletions src/main/bash/sdkman-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ function sdk() {
d)
COMMAND="default"
;;
b)
COMMAND="broadcast"
;;
h)
COMMAND="home"
;;
Expand All @@ -86,7 +83,7 @@ function sdk() {
fi

# ...unless proven otherwise
__sdkman_update_broadcast_and_service_availability
__sdkman_update_service_availability

# Load the sdkman config if it exists.
if [ -f "${SDKMAN_DIR}/etc/config" ]; then
Expand Down
11 changes: 0 additions & 11 deletions src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class SdkmanBashEnvBuilder {
private Optional<UnameStub> unameStub = Optional.empty()
private List candidates = ['groovy', 'grails', 'java']
private boolean offlineMode = false
private String broadcast = "This is a LIVE broadcast!"
private String candidatesApi = "http://localhost:8080/2"
private String sdkmanVersion = "5.0.0"
private String jdkHome = "/path/to/my/jdk"
Expand Down Expand Up @@ -60,11 +59,6 @@ class SdkmanBashEnvBuilder {
this
}

SdkmanBashEnvBuilder withBroadcast(String broadcast) {
this.broadcast = broadcast
this
}

SdkmanBashEnvBuilder withConfiguration(String key, String value) {
config.put key, value
this
Expand Down Expand Up @@ -122,7 +116,6 @@ class SdkmanBashEnvBuilder {

initializeCandidates(sdkmanCandidatesDir, candidates)
initializeCandidatesCache(sdkmanVarDir, candidates)
initializeBroadcast(sdkmanVarDir, broadcast)
initializeConfiguration(sdkmanEtcDir, config)
initializeVersionCache(sdkmanVarDir, versionCache)

Expand Down Expand Up @@ -175,10 +168,6 @@ class SdkmanBashEnvBuilder {
}
}

private initializeBroadcast(File targetFolder, String broadcast) {
new File(targetFolder, "broadcast") << broadcast
}

private initializeConfiguration(File targetFolder, Map config) {
def configFile = new File(targetFolder, "config")
config.each { key, value ->
Expand Down
6 changes: 2 additions & 4 deletions src/test/groovy/sdkman/specs/CompletionSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import sdkman.support.SdkmanEnvSpecification

class CompletionSpec extends SdkmanEnvSpecification {
static final String CANDIDATES_API = "http://localhost:8080/2"
static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id"

def "should complete the list of commands"() {
given:
Expand All @@ -20,7 +19,7 @@ class CompletionSpec extends SdkmanEnvSpecification {
bash.execute('echo "\${COMPREPLY[@]}"')

then:
bash.output.contains("install uninstall list use config default home env current upgrade version broadcast help offline selfupdate update flush")
bash.output.contains("install uninstall list use config default home env current upgrade version help offline selfupdate update flush")
}

def "should complete the list of candidates"() {
Expand All @@ -43,8 +42,7 @@ class CompletionSpec extends SdkmanEnvSpecification {

def "should complete the list of Java versions"() {
given:
curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155")
.primeWith("$CANDIDATES_API/candidates/java/darwinx64/versions/all", "echo 16.0.1.hs-adpt,17.0.0-tem")
curlStub.primeWith("$CANDIDATES_API/candidates/java/darwinx64/versions/all", "echo 16.0.1.hs-adpt,17.0.0-tem")

unameStub.forKernel("Darwin").forMachine("x86_64")

Expand Down
4 changes: 1 addition & 3 deletions src/test/groovy/sdkman/specs/EnvCommandSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import static java.nio.file.Files.createSymbolicLink
class EnvCommandSpec extends SdkmanEnvSpecification {
static final String CANDIDATES_API = "http://localhost:8080/2"

static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id"
static final String CANDIDATES_DEFAULT_JAVA = "$CANDIDATES_API/candidates/default/java"

def "should generate .sdkmanrc when called with 'init'"() {
given:
curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155")
.primeWith(CANDIDATES_DEFAULT_JAVA, "echo 11.0.6.hs-adpt")
curlStub.primeWith(CANDIDATES_DEFAULT_JAVA, "echo 11.0.6.hs-adpt")

setupCandidates(candidatesDirectory)

Expand Down
29 changes: 0 additions & 29 deletions src/test/groovy/sdkman/steps/broadcast_steps.groovy

This file was deleted.

1 change: 0 additions & 1 deletion src/test/groovy/sdkman/steps/env.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ etcDir = "${sdkmanDirEnv}/etc" as File
extDir = "${sdkmanDirEnv}/ext" as File
tmpDir = "${sdkmanDir}/tmp" as File

broadcastFile = new File(varDir, "broadcast")
broadcastIdFile = new File(varDir, "broadcast_id")
candidatesFile = new File(varDir, "candidates")
versionFile = new File(varDir, "version")
Expand Down
5 changes: 0 additions & 5 deletions src/test/groovy/sdkman/steps/initialisation_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import static cucumber.api.groovy.EN.And
import static sdkman.stubs.WebServiceStub.primeEndpointWithString
import static sdkman.stubs.WebServiceStub.primeSelfupdate

def BROADCAST_MESSAGE = "broadcast message"

And(~'^the sdkman work folder is created$') { ->
assert sdkmanDir.isDirectory(), "The SDKMAN directory does not exist."
}
Expand All @@ -36,7 +34,6 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { Str

And(~'^the internet is reachable$') { ->
primeEndpointWithString("/broadcast/latest/id", "12345")
primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE)
primeEndpointWithString("/app/stable", sdkmanVersion)
primeSelfupdate()

Expand All @@ -53,7 +50,6 @@ And(~'^the internet is not reachable$') { ->

And(~'^offline mode is disabled with reachable internet$') { ->
primeEndpointWithString("/broadcast/latest/id", "12345")
primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE)
primeEndpointWithString("/app/stable", sdkmanVersion)

offlineMode = false
Expand All @@ -63,7 +59,6 @@ And(~'^offline mode is disabled with reachable internet$') { ->

And(~'^offline mode is enabled with reachable internet$') { ->
primeEndpointWithString("/broadcast/latest/id", "12345")
primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE)
primeEndpointWithString("/app/stable", sdkmanVersion)

offlineMode = true
Expand Down
36 changes: 0 additions & 36 deletions src/test/resources/features/broadcast.feature

This file was deleted.

3 changes: 2 additions & 1 deletion src/test/resources/features/checksum_verification.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Feature: Verify checksums
And the candidate "grails" version "1.3.9" is installed
And the response headers file is created for candidate "grails" and version "1.3.9"
And the exit code is 0


@manual
Scenario: Abort installation after download of a binary with invalid SHA checksum
Given the system is bootstrapped
And the candidate "grails" version "1.3.9" is available for download with checksum "c68e386a6deec9fc4c1e18df21f927000000000e" using algorithm "SHA-256"
Expand Down
11 changes: 0 additions & 11 deletions src/test/resources/features/flush.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ Feature: Flush
And I see "1 archive(s) flushed"
And I see "1 archive(s) flushed"

Scenario: Clean up the current Broadcast
Given a prior Broadcast "This is an old broadcast" with id "12344" was issued
When I enter "sdk flush broadcast"
Then no broadcast message can be found
And I see "Broadcast has been flushed."

Scenario: Clean up an uninitialised Broadcast
Given the broadcast has been flushed
When I enter "sdk flush broadcast"
Then I see "No prior broadcast found so not flushed."

Scenario: Clean up the last known Remote Version
Given a prior version "5.0.0" was detected
When I enter "sdk flush version"
Expand Down
7 changes: 0 additions & 7 deletions src/test/resources/features/mnemonics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ Feature: Mnemonics
Then I see "Default groovy version set to 2.0.5"
And the candidate "groovy" version "2.0.5" should be the default

Scenario: Shortcut for a Broadcast command issued
Given no prior Broadcast was received
And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available
And the system is bootstrapped
When I enter "sdk b"
Then I see "This is a LIVE Broadcast!"

Scenario: Shortcut for displaying Home directory
Given an initialised environment without debug prints
And the candidate "grails" version "2.1.0" is already installed and default
Expand Down
10 changes: 0 additions & 10 deletions src/test/resources/features/offline_mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ Feature: Offline Mode
Then I see "INTERNET NOT REACHABLE!"
And I see "Stop! grails 2.1.0 is not available while offline."

# broadcast

Scenario: Recall a broadcast while in Offline Mode
Given offline mode is enabled with reachable internet
And an initialised environment
And the system is bootstrapped
When a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued
And I enter "sdk broadcast"
Then I see "This is an OLD Broadcast!"

# sdk version

Scenario: Determine the sdkman version while in Offline Mode
Expand Down

0 comments on commit 00538c2

Please sign in to comment.