Update core components including CLI, Nushell libraries, plugins system, and utility scripts for the provisioning system. CLI Updates: - Command implementations - CLI utilities and dispatching - Help system improvements - Command validation Library Updates: - Configuration management system - Infrastructure validation - Extension system improvements - Secrets management - Workspace operations - Cache management system Plugin System: - Interactive form plugin (inquire) - KCL integration plugin - Performance optimization plugins - Plugin registration system Utilities: - Build and distribution scripts - Installation procedures - Testing utilities - Development tools Documentation: - Library module documentation - Extension API guides - Plugin usage guides - Service management documentation All changes are backward compatible. No breaking changes.
119 lines
4.9 KiB
Bash
Executable File
119 lines
4.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Info: Script to run Provisioning
|
|
# Author: JesusPerezLorenzo
|
|
# Release: 1.0.10
|
|
# Date: 2025-10-02
|
|
|
|
set +o errexit
|
|
set +o pipefail
|
|
|
|
export NU=$(type -P nu)
|
|
|
|
_release() {
|
|
grep "^# Release:" "$0" | sed "s/# Release: //g"
|
|
}
|
|
|
|
export PROVISIONING_VERS=$(_release)
|
|
|
|
set -o allexport
|
|
## shellcheck disable=SC1090
|
|
[ -n "$PROVISIONING_ENV" ] && [ -r "$PROVISIONING_ENV" ] && source "$PROVISIONING_ENV"
|
|
[ -r "../env-provisioning" ] && source ../env-provisioning
|
|
[ -r "env-provisioning" ] && source ./env-provisioning
|
|
#[ -r ".env" ] && source .env set
|
|
|
|
# Disable provisioning logo/banner output
|
|
export PROVISIONING_NO_TITLES=true
|
|
|
|
set +o allexport
|
|
|
|
export PROVISIONING=${PROVISIONING:-/usr/local/provisioning}
|
|
PROVIISONING_WKPATH=${PROVIISONING_WKPATH:-/tmp/tmp.}
|
|
|
|
RUNNER="provisioning"
|
|
|
|
[ "$1" == "" ] && shift
|
|
|
|
[ -z "$NU" ] || [ "$1" == "install" ] || [ "$1" == "reinstall" ] || [ "$1" == "mode" ] && exec bash $PROVISIONING/core/bin/install_nu.sh $PROVISIONING $1 $2
|
|
|
|
[ "$1" == "rmwk" ] && rm -rf "$PROVIISONING_WKPATH"* && echo "$PROVIISONING_WKPATH deleted" && exit
|
|
[ "$1" == "-x" ] && debug=-x && export PROVISIONING_DEBUG=true && shift
|
|
[ "$1" == "-xm" ] && export PROVISIONING_METADATA=true && shift
|
|
[ "$1" == "nu" ] && export PROVISIONING_DEBUG=true
|
|
[ "$1" == "--x" ] && set -x && debug=-x && export PROVISIONING_DEBUG=true && shift
|
|
[ "$1" == "-i" ] || [ "$2" == "-i" ] && echo "$(basename "$0") $(grep "^# Info:" "$0" | sed "s/# Info: //g") " && exit
|
|
[ "$1" == "-v" ] || [ "$1" == "--version" ] || [ "$2" == "-v" ] && _release && exit
|
|
CMD_ARGS=$@
|
|
|
|
# Note: Flag ordering is handled by Nushell's reorder_args function
|
|
# which automatically reorders flags before positional arguments.
|
|
# Flags can be placed anywhere on the command line.
|
|
case "$1" in
|
|
# Note: "setup" is now handled by the main provisioning CLI dispatcher
|
|
# No special module handling needed
|
|
-mod)
|
|
export PROVISIONING_MODULE=$(echo "$2" | sed 's/ //g' | cut -f1 -d"|")
|
|
PROVISIONING_MODULE_TASK=$(echo "$2" | sed 's/ //g' | cut -f2 -d"|")
|
|
[ "$PROVISIONING_MODULE" == "$PROVISIONING_MODULE_TASK" ] && PROVISIONING_MODULE_TASK=""
|
|
shift 2
|
|
CMD_ARGS=$@
|
|
;;
|
|
esac
|
|
NU_ARGS=""
|
|
|
|
DEFAULT_CONTEXT_TEMPLATE="default_context.yaml"
|
|
case "$(uname | tr '[:upper:]' '[:lower:]')" in
|
|
linux) PROVISIONING_USER_CONFIG="$HOME/.config/provisioning/nushell"
|
|
PROVISIONING_CONTEXT_PATH="$HOME/.config/provisioning/$DEFAULT_CONTEXT_TEMPLATE"
|
|
|
|
;;
|
|
darwin) PROVISIONING_USER_CONFIG="$HOME/Library/Application Support/provisioning/nushell"
|
|
PROVISIONING_CONTEXT_PATH="$HOME/Library/Application Support/provisioning/$DEFAULT_CONTEXT_TEMPLATE"
|
|
;;
|
|
*) PROVISIONING_USER_CONFIG="$HOME/.config/provisioning/nushell"
|
|
PROVISIONING_CONTEXT_PATH="$HOME/.config/provisioning/$DEFAULT_CONTEXT_TEMPLATE"
|
|
;;
|
|
esac
|
|
|
|
# FAST-PATH: Help commands and no-arguments case don't need full config loading
|
|
# Detect help-only commands and empty arguments, use minimal help system
|
|
if [ -z "$1" ] || [ "$1" = "help" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "--helpinfo" ]; then
|
|
category="${2:-}"
|
|
$NU -n -c "source '$PROVISIONING/core/nulib/help_minimal.nu'; provisioning-help '$category' | print" 2>/dev/null
|
|
exit $?
|
|
fi
|
|
|
|
if [ ! -d "$PROVISIONING_USER_CONFIG" ] || [ ! -r "$PROVISIONING_CONTEXT_PATH" ] ; then
|
|
[ ! -x "$PROVISIONING/core/nulib/provisioning setup" ] && echo "$PROVISIONING/core/nulib/provisioning setup not found" && exit 1
|
|
cd "$PROVISIONING/core/nulib"
|
|
./"provisioning setup"
|
|
echo ""
|
|
read -p "Use [enter] to continue or [ctrl-c] to cancel"
|
|
fi
|
|
[ ! -r "$PROVISIONING_USER_CONFIG/config.nu" ] && echo "$PROVISIONING_USER_CONFIG/config.nu not found" && exit 1
|
|
[ ! -r "$PROVISIONING_USER_CONFIG/env.nu" ] && echo "$PROVISIONING_USER_CONFIG/env.nu not found" && exit 1
|
|
|
|
NU_ARGS=(--config "$PROVISIONING_USER_CONFIG/config.nu" --env-config "$PROVISIONING_USER_CONFIG/env.nu")
|
|
export PROVISIONING_ARGS="$CMD_ARGS" NU_ARGS="$NU_ARGS"
|
|
#export NU_ARGS=${NU_ARGS//Application Support/Application\\ Support}
|
|
|
|
# Export NU_LIB_DIRS so Nushell can find modules during parsing
|
|
export NU_LIB_DIRS="$PROVISIONING/core/nulib:/opt/provisioning/core/nulib:/usr/local/provisioning/core/nulib"
|
|
|
|
if [ -n "$PROVISIONING_MODULE" ] ; then
|
|
if [[ -x $PROVISIONING/core/nulib/$RUNNER\ $PROVISIONING_MODULE ]] ; then
|
|
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/$RUNNER $PROVISIONING_MODULE" $PROVISIONING_MODULE_TASK $CMD_ARGS
|
|
else
|
|
echo "Error \"$PROVISIONING/core/nulib/$RUNNER $PROVISIONING_MODULE\" not found"
|
|
fi
|
|
else
|
|
# Only redirect stdin for non-interactive commands (nu command needs interactive stdin)
|
|
if [ "$1" = "nu" ]; then
|
|
# For interactive mode, ensure ENV variables are available
|
|
export PROVISIONING_CONFIG="$PROVISIONING_USER_CONFIG"
|
|
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/$RUNNER" $CMD_ARGS
|
|
else
|
|
$NU "${NU_ARGS[@]}" "$PROVISIONING/core/nulib/$RUNNER" $CMD_ARGS < /dev/null
|
|
fi
|
|
fi
|