From 44f38b2ec8dd47fa5451deaffd3c7eb3124d3f04 Mon Sep 17 00:00:00 2001 From: Walter Caffiero Date: Tue, 8 Jul 2025 17:35:17 +0200 Subject: [PATCH 1/9] ENG-5564 fixed check-env base-develop --- bin/mod/ent-check-env | 2 +- test/integration/test-int-install.sh | 34 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/integration/test-int-install.sh diff --git a/bin/mod/ent-check-env b/bin/mod/ent-check-env index 90bebfcd..c2fff11b 100755 --- a/bin/mod/ent-check-env +++ b/bin/mod/ent-check-env @@ -26,7 +26,7 @@ RUN() { # DEVELOP TOOLS - $M_DEVL && check-env.develop.minimal-tools-requirements + $M_DEVL_BASE && check-env.develop.minimal-tools-requirements # ENT-LOCAL NODE $M_DEVL_BASE && check-env.check-node diff --git a/test/integration/test-int-install.sh b/test/integration/test-int-install.sh new file mode 100644 index 00000000..2b9e50e4 --- /dev/null +++ b/test/integration/test-int-install.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +XDEV_TEST.BEFORE_FILE() { + export TEST_PROFILE="ent-integration-tests" +} + +#TEST:integration,profile +test_install() { + + if [[ -z "$ENTANDO_RELEASE_TO_TEST" || -z "$ENT_VERSION_TO_TEST" ]]; then + return 0 + fi + + ( _IT "should install 7.3.2 with bundle 1.2.1" + + bash <(curl -L "https://get.entando.org/cli") --update --release="$ENTANDO_RELEASE_TO_TEST" --cli-version="$ENT_VERSION_TO_TEST" + # shellcheck disable=SC1091 + source "$HOME/.entando/activate" --force + + if [ -n "$BUNDLE_CLI_VERSION_TO_TEST" ]; then + ent check-env base-develop --yes --entando-bundle-cli-version="$BUNDLE_CLI_VERSION_TO_TEST" --verbose --lenient + else + ent check-env base-develop --yes --verbose --lenient + fi + + #~ + + ent status --full + + _ASSERT -v ENT_VER "$(ent version)" = "v7.3.2" + _ASSERT -v ENT_BUNDLE_VER "$(ent bundle version)" = "v1.2.1-SNAPSHOT" + + ) || _SOE +} From 7a8268b1a0ad3c22ee740109426ed2ea234c53d8 Mon Sep 17 00:00:00 2001 From: Walter Caffiero Date: Wed, 9 Jul 2025 23:10:31 +0200 Subject: [PATCH 2/9] ESB-666 The entando-cli should be able to autodetermine the application name --- bin/ent | 2 +- bin/mod/ent-app | 4 +++- bin/mod/ent-app-info | 3 +++ bin/mod/ent-host | 2 ++ bin/mod/ent-profile | 18 ++++++++++++++---- s/_conf.sh | 4 ++++ s/_root-helper.sh | 16 ++++++++++++++++ s/check-app-status.sh | 1 + s/sys-utils.sh | 21 +++++++++++++++++++++ s/utils.sh | 4 ++++ 10 files changed, 69 insertions(+), 6 deletions(-) diff --git a/bin/ent b/bin/ent index 36d6ad73..56e4c518 100755 --- a/bin/ent +++ b/bin/ent @@ -59,7 +59,7 @@ RUN() { handle_status_config ENTANDO_APPVER "$@" ;; "appname") #H: sets the default application names - handle_status_config ENTANDO_APPNAME "$@" + handle_appname "$@" ;; "profile"|"P"|"pro") #H: helps creating and managing profiles # shellcheck disable=SC1090 diff --git a/bin/mod/ent-app b/bin/mod/ent-app index d1ef77b7..19656e67 100755 --- a/bin/mod/ent-app +++ b/bin/mod/ent-app @@ -50,9 +50,11 @@ RUN() { determine_namespace ENTANDO_NAMESPACE "$@" args_or_ask -h "$HH" -n -p ENTANDO_APPNAME "--appname/ext_ic_id//%sp the application name" "$@" args_or_ask -h "$HH" -n -F WATCH "--watch///" "$@" - + [ -n "$HH" ] && exit 0 + kube.discover-and-set-app-name-if-needed + if $WATCH; then ent app-info watch "$ENTANDO_APPNAME" "$ENTANDO_NAMESPACE" else diff --git a/bin/mod/ent-app-info b/bin/mod/ent-app-info index fdcb1e2f..082e9823 100755 --- a/bin/mod/ent-app-info +++ b/bin/mod/ent-app-info @@ -39,6 +39,9 @@ WATCH=false; [ "$1" = "watch" ] && { WATCH=true; shift; } reload_cfg [ -n "$1" ] && ENTANDO_APPNAME="$1" && shift + +kube.discover-and-set-app-name-if-needed + [ "$ENTANDO_APPNAME" = "" ] && echo "please provide the app name" 1>&2 && exit 1 [ -n "$1" ] && ENTANDO_NAMESPACE="$1" && shift [ "$ENTANDO_NAMESPACE" = "" ] && echo "please provide the namespace name" 1>&2 && exit 1 diff --git a/bin/mod/ent-host b/bin/mod/ent-host index c900c071..f685e8a0 100755 --- a/bin/mod/ent-host +++ b/bin/mod/ent-host @@ -78,6 +78,8 @@ RUN() { set_nn_dn "ENTANDO_NAMESPACE" "${CFG_ARR[0]}" set_nn_dn "ENTANDO_APPNAME" "${CFG_ARR[1]}" set_nn_fdn "ENTANDO_SUFFIX" "${CFG_ARR[2]}" + + kube.discover-and-set-app-name-if-needed _log_i "In VM: $VM_NAME" _log_i "Found NAMESPACE: $ENTANDO_NAMESPACE" diff --git a/bin/mod/ent-profile b/bin/mod/ent-profile index 5403fe6b..4ce08a9d 100755 --- a/bin/mod/ent-profile +++ b/bin/mod/ent-profile @@ -162,7 +162,7 @@ _use_or_list_profile() { setup_curr_profile() { HH="$(parse_help_option "$@")" - args_or_ask -h "$HH" ENTANDO_APPNAME "--appname/ext_ic_id/$PROFILE/%sp EntandoApp name" "$@" && { + args_or_ask -h "$HH" ENTANDO_APPNAME "--appname/ext_ic_id/:auto/%sp EntandoApp name" "$@" && { save_cfg_value ENTANDO_APPNAME "$ENTANDO_APPNAME" } args_or_ask -h "$HH" ENTANDO_NAMESPACE "--namespace/ext_ic_id/$PROFILE/%sp default namespace" "$@" && { @@ -233,7 +233,7 @@ use_profile() { . "$COMMAND_FILE" --full activate_designated_workdir --temporary else - set_curr_profile "$DESIGNATED_PROFILE" "$DESIGNATED_PROFILE_HOME" "$DESIGNATED_PROFILE_SUB" + set_curr_profile "$DESIGNATED_PROFILE" "" "$DESIGNATED_PROFILE_SUB" activate_designated_workdir fi } @@ -414,11 +414,20 @@ select_profile_item() { _set_var "$res_var" "$_tmp_result" } +assert_appname_param() { + [[ "$2" == "" || "$2" == ":auto" ]] && return 0 + assert_ext_ic_id "$@" +} + + parse_basic_profile_args() { local from="$1" shift - args_or_ask -h "$HH" -a ENTANDO_APPNAME "$((from + 0))/ext_ic_id/$PROFILE/%sp EntandoApp name" "$@" - args_or_ask -h "$HH" -a ENTANDO_NAMESPACE "$((from + 1))/ext_ic_id/$PROFILE/%sp default namespace" "$@" + args_or_ask ${HH:+"$HH"} -a ENTANDO_NAMESPACE "$((from + 0))/ext_ic_id/$PROFILE/%sp default namespace" "$@" + args_or_ask ${HH:+"$HH"} -a ENTANDO_APPNAME "$((from + 1))/appname_param//%sp EntandoApp name" "$@" + if [ "$ENTANDO_APPNAME" == "" ]; then + ENTANDO_APPNAME=":auto" + fi } _determine_profile_dir() { @@ -545,6 +554,7 @@ delete_profile() { true ) && { DESIGNATED_PROFILE="" DESIGNATED_PROFILE_SUB="" DESIGNATED_PROFILE_HOME="" + THIS_PROFILE="" reload_cfg "$ENTANDO_GLOBAL_CFG" if [ "$PROFILE" = "$THIS_APP_PROFILE" ]; then diff --git a/s/_conf.sh b/s/_conf.sh index 0c99e84d..13b82358 100755 --- a/s/_conf.sh +++ b/s/_conf.sh @@ -151,6 +151,10 @@ ENTANDO_CLI_HIDE_PRIVATE_NODEJS="true" ENTANDO_NPM_REGISTRY_NO_SCHEMA="npm.pkg.github.com" ENTANDO_NPM_REGISTRY="https://$ENTANDO_NPM_REGISTRY_NO_SCHEMA" +# KUBERNETES RELATED VALUES +ENTANDO_APPNAME=":auto" +ENTANDO_DISABLE_APPNAME_DISCOVERY=false + # UNPRIVILEDGED TOKEN USED FOR ANONYMOUS ACCESS TO GITHUB PACKAGES # THE TOKEN HAS IN FACT NO PERMISSION BUT repository:read # it's obfuscated just to avoid false positives from security scanners diff --git a/s/_root-helper.sh b/s/_root-helper.sh index aa8503f0..0040671b 100644 --- a/s/_root-helper.sh +++ b/s/_root-helper.sh @@ -136,6 +136,22 @@ print_config_file() { print-secrets-leak-warning } +handle_appname() { + bgn_help_parsing "${BASH_SOURCE[0]}" "$@" + args_or_ask -h "$HH" -a -n -- APPNAME '1///%sp the EntandoApp name' "$@" + if [ -z "$APPNAME" ]; then + args_or_ask -h "$HH" -n -f -- '--auto///%sp tries to auto-discover the EntandoApp name by checking the namespace' "$@" && { + # shellcheck disable=SC2034 + ENTANDO_APPNAME=":auto" + kube.discover-and-set-app-name-if-needed + exit 0 + } + fi + end_help_parsing + + handle_status_config ENTANDO_APPNAME "$APPNAME" +} + handle_status_config() { if [ "$V" = "--del" ]; then ent config --set "" diff --git a/s/check-app-status.sh b/s/check-app-status.sh index 99979af1..2949b792 100755 --- a/s/check-app-status.sh +++ b/s/check-app-status.sh @@ -9,6 +9,7 @@ cd "$DIR/.." || { # PARAMS [ -n "$1" ] && ENTANDO_APPNAME="$1" && shift +kube.discover-and-set-app-name-if-needed [ "$ENTANDO_APPNAME" = "" ] && echo "please provide the app name" 1>&2 && exit 1 [ -n "$1" ] && ENTANDO_NAMESPACE="$1" && shift diff --git a/s/sys-utils.sh b/s/sys-utils.sh index 1e18eabf..71fb41b0 100755 --- a/s/sys-utils.sh +++ b/s/sys-utils.sh @@ -632,3 +632,24 @@ _ent.extension-module.execute() { _ent.sys.is-stdout-tty() { perl -e 'print -t STDOUT ? exit 0 : exit 1;' } + +kube.discover-and-set-app-name() { + local an + read -ra an < <(_kubectl get entandoapp -o custom-columns=NAME:.metadata.name --no-headers 2>/dev/null) + + [ "${#an[@]}" -gt 1 ] && _FATAL -s "It's not possible to auto-determine the appname on a namespace with more than one EntandoApp present" + ENTANDO_APPNAME="${an[0]}" + export ENTANDO_APPNAME + ent config --set ENTANDO_APPNAME "$ENTANDO_APPNAME" +} + +kube.discover-and-set-app-name-if-needed() { + if [ "${ENTANDO_DISABLE_APPNAME_DISCOVERY}" != "true" ]; then + if [ "$ENTANDO_APPNAME" == ":auto" ]; then + kube.discover-and-set-app-name + if [ "$ENTANDO_ENT_DEBUG" == "true" ]; then + _log_i "Discovered the appname \"$ENTANDO_APPNAME\" for the namespace \"$ENTANDO_NAMESPACE\"" + fi + fi + fi +} diff --git a/s/utils.sh b/s/utils.sh index 19840363..0c5ffbbb 100755 --- a/s/utils.sh +++ b/s/utils.sh @@ -911,10 +911,12 @@ print_current_profile_info() { fi $VERBOSE && { + echo " - CONFIG FILE: ${CFG_FILE}" echo " - APPNAME: ${ENTANDO_APPNAME:-}" echo " - APPVER: ${ENTANDO_APPVER:-}" echo " - NAMESPACE: ${ENTANDO_NAMESPACE:-}" echo " - K8S CONTEXT: ${DESIGNATED_KUBECTX:-}" + echo " - K8S CONFIG: ${DESIGNATED_KUBECONFIG:-}" } } @@ -974,6 +976,8 @@ app-get-main-ingresses() { local OUT=() local JSON="$(_kubectl get ingresses.v1.networking.k8s.io -o json)" + kube.discover-and-set-app-name-if-needed + #~~~ local JQ=".items[] | select(.metadata.name==$(_str_quote "$ENTANDO_APPNAME-ingress")).spec | .tls[0].hosts[0] // \"-\", .rules[0].host" stdin_to_arr $'\n\r' OUT < <(_jq "$JQ" -r <<< "$JSON") From 037d69ce66c57f60fdee55def63e126066d1ddd1 Mon Sep 17 00:00:00 2001 From: Walter Caffiero Date: Wed, 9 Jul 2025 23:13:38 +0200 Subject: [PATCH 3/9] ENG-5564 check-env source mode to avoid running tests --- bin/mod/ent-check-env | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/mod/ent-check-env b/bin/mod/ent-check-env index c2fff11b..ef8eef7c 100755 --- a/bin/mod/ent-check-env +++ b/bin/mod/ent-check-env @@ -224,22 +224,24 @@ check-env.check-bundle-cli() { parse-version-flags FLAGS VER_ENTANDO_BUNDLE_CLI_DEF VER_ENTANDO_BUNDLE_CLI_REQ ENTANDO_BUNDLE_CLI_VERSION_OVERRIDE _str_contains "$FLAGS" ",f," && FORCE=true - if [[ "$VER_ENTANDO_BUNDLE_CLI_REQ" == "v1.2.0" || "$VER_ENTANDO_BUNDLE_CLI_REQ" == *"v1.0"* ]]; then - local SOURCE_BASED=true - _str_contains "$FLAGS" ",r," && SOURCE_BASED=false - else + if [[ "$VER_ENTANDO_BUNDLE_CLI_REQ" == *"v1.2.0"* || "$VER_ENTANDO_BUNDLE_CLI_REQ" == *"v1.0"* ]]; then + # OLD VERSIONS local SOURCE_BASED=false _str_contains "$FLAGS" ",g," && SOURCE_BASED=true + else + # NEW VERSIONS + local SOURCE_BASED=true + _str_contains "$FLAGS" ",r," && SOURCE_BASED=false fi - + if $SOURCE_BASED; then - check-env.npm-registry-package entando-registry "entando-bundle-cli" "@entando/entando-bundle-cli" \ + check_npm_git_package --full "$REPO_ENTANDO_BUNDLE_CLI_ADDR" \ "$VER_ENTANDO_BUNDLE_CLI_REQ" "$VER_ENTANDO_BUNDLE_CLI_DEF" \ + "$C_ENTANDO_BUNDLE_CLI_DIR" "$C_ENTANDO_BUNDLE_CLI_DIR" \ "$FORCE" else - check_npm_git_package --full "$REPO_ENTANDO_BUNDLE_CLI_ADDR" \ + check-env.npm-registry-package entando-registry "entando-bundle-cli" "@entando/entando-bundle-cli" \ "$VER_ENTANDO_BUNDLE_CLI_REQ" "$VER_ENTANDO_BUNDLE_CLI_DEF" \ - "$C_ENTANDO_BUNDLE_CLI_DIR" "$C_ENTANDO_BUNDLE_CLI_DIR" \ "$FORCE" fi } @@ -403,8 +405,7 @@ check_npm_git_package() { ) || _SOE # ACTUAL INSTALLATION - - ___npm "PHASE 2" install --global + ___npm "PHASE 2" install --ignore-scripts --global date > .entando-finalized echo '~~~'$'\n' From b31b72cf0748da0ba712db31b78361ba497e619b Mon Sep 17 00:00:00 2001 From: ffalqui Date: Wed, 19 Nov 2025 11:32:23 +0100 Subject: [PATCH 4/9] auto-discovery app name: - fix :auto parameter in ent profile set - menage exceptions if ENTANDO_DISABLE_APPNAME_DISCOVERY = true --- bin/mod/ent-app | 12 +++++++++--- bin/mod/ent-app-info | 6 ++++++ bin/mod/ent-host | 8 +++++++- bin/mod/ent-profile | 11 +++++++++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/bin/mod/ent-app b/bin/mod/ent-app index 19656e67..e2cd3912 100755 --- a/bin/mod/ent-app +++ b/bin/mod/ent-app @@ -48,13 +48,19 @@ RUN() { "status") #H: prints status information about the current EntandoApp local WATCH determine_namespace ENTANDO_NAMESPACE "$@" - args_or_ask -h "$HH" -n -p ENTANDO_APPNAME "--appname/ext_ic_id//%sp the application name" "$@" + args_or_ask -h "$HH" -n -p ENTANDO_APPNAME "--appname/appname_param//%sp the application name" "$@" args_or_ask -h "$HH" -n -F WATCH "--watch///" "$@" - + [ -n "$HH" ] && exit 0 kube.discover-and-set-app-name-if-needed - + + if [[ "$ENTANDO_APPNAME" == ":auto" && "${ENTANDO_DISABLE_APPNAME_DISCOVERY}" == "true" ]]; then + _log_e "Auto-discovery is disabled (ENTANDO_DISABLE_APPNAME_DISCOVERY=true)" + _log_e "Cannot use ':auto' - please provide an explicit app name" + exit 1 + fi + if $WATCH; then ent app-info watch "$ENTANDO_APPNAME" "$ENTANDO_NAMESPACE" else diff --git a/bin/mod/ent-app-info b/bin/mod/ent-app-info index 082e9823..34a6d269 100755 --- a/bin/mod/ent-app-info +++ b/bin/mod/ent-app-info @@ -42,6 +42,12 @@ reload_cfg kube.discover-and-set-app-name-if-needed +if [[ "$ENTANDO_APPNAME" == ":auto" && "${ENTANDO_DISABLE_APPNAME_DISCOVERY}" == "true" ]]; then + _log_e "Auto-discovery is disabled (ENTANDO_DISABLE_APPNAME_DISCOVERY=true)" + _log_e "Cannot use ':auto' - please provide an explicit app name" + exit 1 +fi + [ "$ENTANDO_APPNAME" = "" ] && echo "please provide the app name" 1>&2 && exit 1 [ -n "$1" ] && ENTANDO_NAMESPACE="$1" && shift [ "$ENTANDO_NAMESPACE" = "" ] && echo "please provide the namespace name" 1>&2 && exit 1 diff --git a/bin/mod/ent-host b/bin/mod/ent-host index f685e8a0..33ac91c3 100755 --- a/bin/mod/ent-host +++ b/bin/mod/ent-host @@ -78,9 +78,15 @@ RUN() { set_nn_dn "ENTANDO_NAMESPACE" "${CFG_ARR[0]}" set_nn_dn "ENTANDO_APPNAME" "${CFG_ARR[1]}" set_nn_fdn "ENTANDO_SUFFIX" "${CFG_ARR[2]}" - + kube.discover-and-set-app-name-if-needed + if [[ "$ENTANDO_APPNAME" == ":auto" && "${ENTANDO_DISABLE_APPNAME_DISCOVERY}" == "true" ]]; then + _log_e "Auto-discovery is disabled (ENTANDO_DISABLE_APPNAME_DISCOVERY=true)" + _log_e "Cannot use ':auto' - please provide an explicit app name" + exit 1 + fi + _log_i "In VM: $VM_NAME" _log_i "Found NAMESPACE: $ENTANDO_NAMESPACE" _log_i "Found APPNAME: $ENTANDO_APPNAME" diff --git a/bin/mod/ent-profile b/bin/mod/ent-profile index 4ce08a9d..b1afe5d7 100755 --- a/bin/mod/ent-profile +++ b/bin/mod/ent-profile @@ -162,7 +162,7 @@ _use_or_list_profile() { setup_curr_profile() { HH="$(parse_help_option "$@")" - args_or_ask -h "$HH" ENTANDO_APPNAME "--appname/ext_ic_id/:auto/%sp EntandoApp name" "$@" && { + args_or_ask -h "$HH" ENTANDO_APPNAME "--appname/appname_param/:auto/%sp EntandoApp name" "$@" && { save_cfg_value ENTANDO_APPNAME "$ENTANDO_APPNAME" } args_or_ask -h "$HH" ENTANDO_NAMESPACE "--namespace/ext_ic_id/$PROFILE/%sp default namespace" "$@" && { @@ -415,7 +415,14 @@ select_profile_item() { } assert_appname_param() { - [[ "$2" == "" || "$2" == ":auto" ]] && return 0 + if [[ "$2" == "" || "$2" == ":auto" ]]; then + if [ "${ENTANDO_DISABLE_APPNAME_DISCOVERY}" == "true" ]; then + _log_e "Auto-discovery is disabled (ENTANDO_DISABLE_APPNAME_DISCOVERY=true)" + _log_e "Please provide an explicit app name instead of ':auto'" + return 1 + fi + return 0 + fi assert_ext_ic_id "$@" } From 2bbcaf4d986dbe053fdfcc55bab6566e61a79b06 Mon Sep 17 00:00:00 2001 From: ffalqui Date: Wed, 19 Nov 2025 16:56:02 +0100 Subject: [PATCH 5/9] nodejs user: - jhipster and generator-jhipster-entando use user's node (break compatibility with private node v14.20.0) when ENTANDO_CLI_HIDE_PRIVATE_NODEJS=false - advice for user to use node v16.20.2 for jhipster --- bin/mod/ent-check-env | 136 +++++++++++++++++++++++++++++++++++++++--- s/node-utils.sh | 41 ++++++++++--- s/sys-utils.sh | 12 +++- 3 files changed, 170 insertions(+), 19 deletions(-) diff --git a/bin/mod/ent-check-env b/bin/mod/ent-check-env index ef8eef7c..d0adf534 100755 --- a/bin/mod/ent-check-env +++ b/bin/mod/ent-check-env @@ -208,11 +208,17 @@ check-env.check-jhipster() { parse-version-flags FLAGS VER_JHIPSTER_DEF VER_JHIPSTER_REQ ENTANDO_JHIPSTER_VERSION_OVERRIDE _str_contains "$FLAGS" ",f," && FORCE=true - check-env.npm-registry-package central-registry "jhipster" "generator-jhipster" \ - "$VER_JHIPSTER_REQ" \ - "$VER_JHIPSTER_DEF" \ - "$ENTANDO_JHIPSTER_VERSION_OVERRIDE" \ - "$FORCE" + if [ "${ENTANDO_CLI_HIDE_PRIVATE_NODEJS}" == "true" ]; then + # Use user's node - only check user's installation + check-env.check-jhipster-in-user-node "$VER_JHIPSTER_DEF" "$FORCE" + else + # Use ent's private node - only check ent's installation + check-env.npm-registry-package central-registry "jhipster" "generator-jhipster" \ + "$VER_JHIPSTER_REQ" \ + "$VER_JHIPSTER_DEF" \ + "$ENTANDO_JHIPSTER_VERSION_OVERRIDE" \ + "$FORCE" + fi } @@ -251,10 +257,122 @@ check-env.check-generator-jhipster-entando() { parse-version-flags FLAGS VER_GENERATOR_JHIPSTER_ENTANDO_DEF VER_GENERATOR_JHIPSTER_ENTANDO_REQ ENTANDO_GENERATOR_JHIPSTER_VERSION_OVERRIDE _str_contains "$FLAGS" ",f," && FORCE=true - check_npm_git_package "$REPO_GENERATOR_JHIPSTER_ENTANDO_ADDR" \ - "$VER_GENERATOR_JHIPSTER_ENTANDO_REQ" "$VER_GENERATOR_JHIPSTER_ENTANDO_DEF" \ - "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" \ - "$FORCE" + if [ "${ENTANDO_CLI_HIDE_PRIVATE_NODEJS}" == "true" ]; then + # Use user's node - only check user's installation + check-env.check-generator-jhipster-entando-in-user-node "$VER_GENERATOR_JHIPSTER_ENTANDO_DEF" "$FORCE" + else + # Use ent's private node - only check ent's installation + check_npm_git_package "$REPO_GENERATOR_JHIPSTER_ENTANDO_ADDR" \ + "$VER_GENERATOR_JHIPSTER_ENTANDO_REQ" "$VER_GENERATOR_JHIPSTER_ENTANDO_DEF" \ + "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" \ + "$FORCE" + fi +} + +check-env.check-jhipster-in-user-node() { + local VER_DEF="$1" + local FORCE="$2" + + _log_i "Checking user's node installation of jhipster.." + + # Filter out ent's private node from PATH to use only user's node + local ENT_NODE_PREFIX="$ENT_OPTS/node-" + local FILTERED_PATH=$(echo "$PATH" | tr ':' '\n' | grep -v "^${ENT_NODE_PREFIX}" | tr '\n' ':' | sed 's/:$//') + + # Run npm commands with user's node only + ( + export PATH="$FILTERED_PATH" + + # Check if user has node installed + if ! command -v node &> /dev/null; then + _log_w "User's node.js is not found in PATH" + _log_w "Please install Node.js v16 or later (recommended: Node v16.20.2)" + _log_w "Visit https://nodejs.org/ or use nvm: https://github.com/nvm-sh/nvm" + return 1 + fi + + local USER_NODE_VERSION=$(node --version 2>/dev/null) + _log_i "\tUser's node version: $USER_NODE_VERSION" + + # Check if version is compatible (v16.x recommended) + local NODE_MAJOR_VERSION=$(echo "$USER_NODE_VERSION" | sed 's/v\([0-9]*\).*/\1/') + if [[ "$NODE_MAJOR_VERSION" -lt 16 ]]; then + _log_w "\tWARNING: Node.js $USER_NODE_VERSION may not be compatible with JHipster 7.9.3" + _log_w "\tRecommended: Node v16.20.2 (tested and verified to work)" + _log_w "\tTo switch: nvm install v16.20.2 && nvm use v16.20.2" + elif [[ "$NODE_MAJOR_VERSION" -gt 20 ]]; then + _log_w "\tWARNING: Node.js $USER_NODE_VERSION has not been tested with JHipster 7.9.3" + _log_w "\tRecommended: Node v16.20.2 (tested and verified to work)" + _log_w "\tTo switch: nvm install v16.20.2 && nvm use v16.20.2" + elif [[ "$NODE_MAJOR_VERSION" -ne 16 ]]; then + _log_i "\tNote: You're using Node.js $USER_NODE_VERSION. If you encounter issues, try Node v16.20.2" + fi + + if npm list -g generator-jhipster 2>/dev/null | grep -q "generator-jhipster@"; then + _log_i "\tgenerator-jhipster is already installed in user's node => OK" + else + _log_i "\tgenerator-jhipster not found in user's node" + if ask "Should I install generator-jhipster@$VER_DEF in your node?" "y"; then + _log_i "\tInstalling generator-jhipster@$VER_DEF globally in user's node.." + npm install -g "generator-jhipster@$VER_DEF" || { + _log_w "Failed to install in user's node. You may need to install it manually with:" + _log_w " npm install -g generator-jhipster@$VER_DEF" + } + else + _log_w "Skipping installation in user's node. JHipster commands may not work with user's node." + fi + fi + ) +} + +check-env.check-generator-jhipster-entando-in-user-node() { + local VER_DEF="$1" + local FORCE="$2" + + _log_i "Checking user's node installation of generator-jhipster-entando.." + + # Filter out ent's private node from PATH to use only user's node + local ENT_NODE_PREFIX="$ENT_OPTS/node-" + local FILTERED_PATH=$(echo "$PATH" | tr ':' '\n' | grep -v "^${ENT_NODE_PREFIX}" | tr '\n' ':' | sed 's/:$//') + + # Run npm commands with user's node only + ( + export PATH="$FILTERED_PATH" + + # Check if user has node installed + if ! command -v node &> /dev/null; then + _log_w "User's node.js is not found in PATH" + _log_w "Please install Node.js v16 or later (recommended: Node v16.20.2)" + return 1 + fi + + # Check if version is compatible (v16.x recommended) + local USER_NODE_VERSION=$(node --version 2>/dev/null) + local NODE_MAJOR_VERSION=$(echo "$USER_NODE_VERSION" | sed 's/v\([0-9]*\).*/\1/') + if [[ "$NODE_MAJOR_VERSION" -lt 16 ]]; then + _log_w "\tWARNING: Node.js $USER_NODE_VERSION may not be compatible with JHipster 7.9.3" + _log_w "\tRecommended: Node v16.20.2 (tested and verified to work)" + elif [[ "$NODE_MAJOR_VERSION" -gt 20 ]]; then + _log_w "\tWARNING: Node.js $USER_NODE_VERSION has not been tested with JHipster 7.9.3" + _log_w "\tRecommended: Node v16.20.2 (tested and verified to work)" + fi + + if npm list -g generator-jhipster-entando 2>/dev/null | grep -q "generator-jhipster-entando@"; then + _log_i "\tgenerator-jhipster-entando is already installed in user's node => OK" + else + _log_i "\tgenerator-jhipster-entando not found in user's node" + if ask "Should I install generator-jhipster-entando@$VER_DEF from ent's installation in your node?" "y"; then + _log_i "\tInstalling generator-jhipster-entando from $ENT_OPTS_ENTANDO/generator-jhipster-entando/$VER_DEF" + # Install from the already-built git source in ent's private directory + npm install -g "$ENT_OPTS_ENTANDO/generator-jhipster-entando/$VER_DEF" || { + _log_w "Failed to install in user's node. You may need to install it manually with:" + _log_w " npm install -g $ENT_OPTS_ENTANDO/generator-jhipster-entando/$VER_DEF" + } + else + _log_w "Skipping installation in user's node. JHipster commands may not work with user's node." + fi + fi + ) } check-env.check-bundler() { diff --git a/s/node-utils.sh b/s/node-utils.sh index d281b572..bea95442 100755 --- a/s/node-utils.sh +++ b/s/node-utils.sh @@ -156,23 +156,38 @@ _ent-npm_direct() { ) } -# Runs the ent private installation of jhipster +# Runs the ent private/user installation of jhipster _ent-jhipster() { if [ "$1" == "--ent-help" ]; then echo "Wrapper of the ent-internal installation of jhipster" return 0 fi - + require_develop_checked --full - - node.activate_environment + + # Check if we should use user's node instead of ent's private node + # By default, respect ENTANDO_CLI_HIDE_PRIVATE_NODEJS setting + local USE_USER_NODE=false + if [ "${ENTANDO_CLI_HIDE_PRIVATE_NODEJS}" == "true" ]; then + USE_USER_NODE=true + fi + + if ! $USE_USER_NODE; then + node.activate_environment + fi + if [[ "$1" == "--ent-get-version" || "$1" == "--version" || "$1" == "-V" ]]; then - _mp_node_exec jhipster -V 2>/dev/null | grep -v INFO + if $USE_USER_NODE; then + # Use user's jhipster + jhipster -V 2>/dev/null | grep -v INFO || npx jhipster -V 2>/dev/null | grep -v INFO + else + _mp_node_exec jhipster -V 2>/dev/null | grep -v INFO + fi return 0 fi - + print_entando_banner - + [[ ! -f "$C_ENT_PRJ_FILE" ]] && { ask "The project dir doesn't seem to be initialized, should I do it now?" "y" && { ent-init-project-dir @@ -180,7 +195,17 @@ _ent-jhipster() { } # RUN - _mp_node_exec jhipster "$@" + if $USE_USER_NODE; then + # Use user's node and jhipster (from PATH or local node_modules) + activate_shell_login_environment + if command -v jhipster &> /dev/null; then + jhipster "$@" + else + npx jhipster "$@" + fi + else + _mp_node_exec jhipster "$@" + fi } # Executes a node command in any of the sypported platforms diff --git a/s/sys-utils.sh b/s/sys-utils.sh index 71fb41b0..24c1e2dd 100755 --- a/s/sys-utils.sh +++ b/s/sys-utils.sh @@ -241,8 +241,16 @@ function ent-init-project-dir() { ask "Should I init it again?" "n" || return 1 } require_develop_checked - _ent-npm init --yes - _ent-npm link "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" + + # Use user's npm if ENTANDO_CLI_HIDE_PRIVATE_NODEJS is true + if [ "${ENTANDO_CLI_HIDE_PRIVATE_NODEJS}" == "true" ]; then + npm init --yes + npm link "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" + else + _ent-npm init --yes + _ent-npm link "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" + fi + rm -rf package.json package-lock.json generate_ent_project_file } From d5113458ce5167ad9c3e652c1d1e4105ba119f4b Mon Sep 17 00:00:00 2001 From: ffalqui Date: Fri, 21 Nov 2025 10:35:31 +0100 Subject: [PATCH 6/9] fix reset profile variable ENTANDO_APPNAME when app-info fails, fix autodiscovered app-name in ent profile new --- bin/mod/ent-profile | 5 +---- s/sys-utils.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/mod/ent-profile b/bin/mod/ent-profile index b1afe5d7..1039f76f 100755 --- a/bin/mod/ent-profile +++ b/bin/mod/ent-profile @@ -431,10 +431,7 @@ parse_basic_profile_args() { local from="$1" shift args_or_ask ${HH:+"$HH"} -a ENTANDO_NAMESPACE "$((from + 0))/ext_ic_id/$PROFILE/%sp default namespace" "$@" - args_or_ask ${HH:+"$HH"} -a ENTANDO_APPNAME "$((from + 1))/appname_param//%sp EntandoApp name" "$@" - if [ "$ENTANDO_APPNAME" == "" ]; then - ENTANDO_APPNAME=":auto" - fi + args_or_ask ${HH:+"$HH"} -a ENTANDO_APPNAME "$((from + 1))/appname_param/:auto/%sp EntandoApp name" "$@" } _determine_profile_dir() { diff --git a/s/sys-utils.sh b/s/sys-utils.sh index 24c1e2dd..1b4cbf5e 100755 --- a/s/sys-utils.sh +++ b/s/sys-utils.sh @@ -644,8 +644,13 @@ _ent.sys.is-stdout-tty() { kube.discover-and-set-app-name() { local an read -ra an < <(_kubectl get entandoapp -o custom-columns=NAME:.metadata.name --no-headers 2>/dev/null) - - [ "${#an[@]}" -gt 1 ] && _FATAL -s "It's not possible to auto-determine the appname on a namespace with more than one EntandoApp present" + + if [ "${#an[@]}" -gt 1 ]; then + _FATAL -s "It's not possible to auto-determine the appname on a namespace with more than one EntandoApp present" + elif [ "${#an[@]}" -eq 0 ] || [ -z "${an[0]}" ]; then + _FATAL -s "It's not possible to auto-determine the appname: no EntandoApp found in namespace \"$ENTANDO_NAMESPACE\"" + fi + ENTANDO_APPNAME="${an[0]}" export ENTANDO_APPNAME ent config --set ENTANDO_APPNAME "$ENTANDO_APPNAME" From a6c41ccb19c265bbccd28c1dcdf978ad7397a702 Mon Sep 17 00:00:00 2001 From: ffalqui Date: Wed, 10 Dec 2025 10:30:31 +0100 Subject: [PATCH 7/9] fix save_cfg_value failed --- s/utils.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/s/utils.sh b/s/utils.sh index 0c5ffbbb..e819f288 100755 --- a/s/utils.sh +++ b/s/utils.sh @@ -48,6 +48,9 @@ save_cfg_value() { shift local config_file="$CFG_FILE"; [ -n "$1" ] && { config_file="$1"; shift; } + # Skip saving if no config file is available (e.g., no profile is active) + [ -z "$config_file" ] && return 0 + if [ "$(echo "$value" | wc -l)" -gt 1 ]; then _FATAL "save_cfg_value: multiline values are not supported (variable: \"$name\")" fi From d59e5462cf33dd9edf6c88742dd513e3445b1806 Mon Sep 17 00:00:00 2001 From: ffalqui Date: Wed, 10 Dec 2025 10:45:53 +0100 Subject: [PATCH 8/9] fix ent-app-info quickstart --- s/quickstart-helper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s/quickstart-helper.sh b/s/quickstart-helper.sh index 331d0eda..2075a7ee 100755 --- a/s/quickstart-helper.sh +++ b/s/quickstart-helper.sh @@ -241,8 +241,8 @@ QS.CREATE-QS-PROFILE() { ent-profile-delete "qs-localhost" --yes ent-profile-new "qs-localhost" \ - "$ENTANDO_APPNAME" \ "$ENTANDO_NAMESPACE" \ + "$ENTANDO_APPNAME" \ --auto-use=false \ ; sourced-ent-profile-use "qs-localhost" @@ -474,7 +474,7 @@ QS.MANIFEST.v7.SET-PLACEHOLDERS() { local MANIFEST_TEMPLATE_FILE="$1" local APPVER="7.0" local REPLICA="1" - local IMGTYPE="eap" + local IMGTYPE="tomcat" local DB="${OVERRIDE_DB_TYPE:-"embedded"}" local ENTANDO_HOSTNAME="${SINGLE_HOSTNAME}" [ -z "$ENTANDO_HOSTNAME" ] || [ "$ENTANDO_HOSTNAME" = "~" ] && ENTANDO_HOSTNAME="$ENTANDO_APPNAME.$FQADDR" @@ -609,8 +609,8 @@ QS.VM.CREATE-QS-PROFILE() { ent-profile-delete "qs-$ENTANDO_VM_NAME" --yes ent-profile-delete "qs-$ENTANDO_VM_NAME" --yes ent-profile-new "qs-$ENTANDO_VM_NAME" \ - "$ENTANDO_APPNAME" \ "$ENTANDO_NAMESPACE" \ + "$ENTANDO_APPNAME" \ --auto-use=false \ ; # shellcheck disable=SC1091 From e3c967016e8902265fca7c66606c6587f894260d Mon Sep 17 00:00:00 2001 From: ffalqui Date: Wed, 17 Dec 2025 17:53:27 +0100 Subject: [PATCH 9/9] fix installation of jhipster in user nodejs --- bin/mod/ent-check-env | 6 +++++- s/node-utils.sh | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/mod/ent-check-env b/bin/mod/ent-check-env index d0adf534..fffdd15a 100755 --- a/bin/mod/ent-check-env +++ b/bin/mod/ent-check-env @@ -258,7 +258,11 @@ check-env.check-generator-jhipster-entando() { _str_contains "$FLAGS" ",f," && FORCE=true if [ "${ENTANDO_CLI_HIDE_PRIVATE_NODEJS}" == "true" ]; then - # Use user's node - only check user's installation + # Use user's node - first ensure the package is cloned/built, then install to user's node + check_npm_git_package --no-local-install "$REPO_GENERATOR_JHIPSTER_ENTANDO_ADDR" \ + "$VER_GENERATOR_JHIPSTER_ENTANDO_REQ" "$VER_GENERATOR_JHIPSTER_ENTANDO_DEF" \ + "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" "$C_GENERATOR_JHIPSTER_ENTANDO_NAME" \ + "$FORCE" check-env.check-generator-jhipster-entando-in-user-node "$VER_GENERATOR_JHIPSTER_ENTANDO_DEF" "$FORCE" else # Use ent's private node - only check ent's installation diff --git a/s/node-utils.sh b/s/node-utils.sh index bea95442..4bf87ec5 100755 --- a/s/node-utils.sh +++ b/s/node-utils.sh @@ -179,7 +179,7 @@ _ent-jhipster() { if [[ "$1" == "--ent-get-version" || "$1" == "--version" || "$1" == "-V" ]]; then if $USE_USER_NODE; then # Use user's jhipster - jhipster -V 2>/dev/null | grep -v INFO || npx jhipster -V 2>/dev/null | grep -v INFO + jhipster -V 2>/dev/null | grep -v INFO || npx --package=generator-jhipster -- jhipster -V 2>/dev/null | grep -v INFO else _mp_node_exec jhipster -V 2>/dev/null | grep -v INFO fi @@ -201,7 +201,7 @@ _ent-jhipster() { if command -v jhipster &> /dev/null; then jhipster "$@" else - npx jhipster "$@" + npx --package=generator-jhipster -- jhipster "$@" fi else _mp_node_exec jhipster "$@"