@beplus/be 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/be +22 -11
  2. package/package.json +1 -1
package/bin/be CHANGED
@@ -64,7 +64,7 @@ function n_grep() {
64
64
  # Setup and state
65
65
  #
66
66
 
67
- VERSION="v0.4.0"
67
+ VERSION="v0.6.0"
68
68
 
69
69
  BE_PREFIX="${BE_PREFIX-/usr/local}"
70
70
  BE_PREFIX=${BE_PREFIX%/}
@@ -919,10 +919,17 @@ function display_compatible_file_field {
919
919
 
920
920
  function tarball_url() {
921
921
  local version="$1"
922
+
923
+ # Full release version (used in GitHub tag / path)
922
924
  local url_version="${version//+/%2B}"
923
- local ext=gz
925
+
926
+ # Artifact version (filename MUST NOT contain +suffix)
927
+ local artifact_version="${version%%+*}"
928
+
929
+ local ext="gz"
924
930
  [ "$BE_USE_XZ" = "true" ] && ext="xz"
925
- echo "${g_mirror_url}/v${url_version}/beplus-cli-v${url_version}-$(display_tarball_platform).tar.${ext}"
931
+
932
+ echo "${g_mirror_url}/v${url_version}/beplus-cli-v${artifact_version}-$(display_tarball_platform).tar.${ext}"
926
933
  }
927
934
 
928
935
  #
@@ -1075,7 +1082,12 @@ function get_latest_resolved_version() {
1075
1082
  g_target_beplus="${simple_version}"
1076
1083
  else
1077
1084
  # Complicated recognising exact version, KISS and lookup.
1085
+ # display_remote_versions lists newest first and may return several matches
1086
+ # (e.g. 'be 1' -> every 1.x); keep the newest as the single install target.
1078
1087
  g_target_beplus=$(display_remote_versions "$version")
1088
+ local status=$?
1089
+ g_target_beplus="${g_target_beplus%%$'\n'*}"
1090
+ return "${status}"
1079
1091
  fi
1080
1092
  }
1081
1093
 
@@ -1128,8 +1140,9 @@ function display_remote_versions() {
1128
1140
  is_exact_numeric_version "${version}" && match_count=1
1129
1141
  # Quote any dots in version so they are literal for expression
1130
1142
  match="${version//\./\.}"
1131
- # Avoid 1.2 matching 1.23
1132
- match="^${match}[^0-9]"
1143
+ # Anchor the end so '1' matches v1.x but not v10.x, while an exact
1144
+ # 'v1.2.3' still matches its bare name (which has no trailing separator).
1145
+ match="^${match}([^0-9]|$)"
1133
1146
  else
1134
1147
  abort "invalid version '$1'"
1135
1148
  fi
@@ -1138,12 +1151,10 @@ function display_remote_versions() {
1138
1151
  # local index_url="https://beplus.s3.amazonaws.com/cli/releases.json"
1139
1152
  local index_url="${BE_RELEASE_INDEX_URL:-https://beplus.s3.amazonaws.com/cli/releases.json}"
1140
1153
 
1141
- for row in $(do_get_index "${index_url}" | jq -r '.[] | @base64'); do
1142
- _jq() {
1143
- echo ${row} | base64 --decode | jq -r ${1}
1144
- }
1145
- echo $(_jq '.name')
1146
- done | awk "NR<=${match_count}" \
1154
+ do_get_index "${index_url}" \
1155
+ | jq -r '.[] | .name' \
1156
+ | n_grep -E "${match}" \
1157
+ | awk "NR<=${match_count}" \
1147
1158
  | cut -f 1 \
1148
1159
  | n_grep -E -o '[^v].*'
1149
1160
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beplus/be",
3
3
  "description": "Interactively Manage beplus CLI Versions",
4
- "version": "0.4.0",
4
+ "version": "0.6.0",
5
5
  "author": "Igor Lamos <igor@be.plus>",
6
6
  "homepage": "https://github.com/beplus/be",
7
7
  "bugs": "https://github.com/beplus/be",