#!/usr/bin/env bash for osDependency in $OS_DEPENDENCIES ; do if ! hash $osDependency; then jjCliLog jjLogWarning "bashUtils/ensureDependency.sh Unable to find OS package '$osDependency'. Installing now..." eval "$PACKAGE_MANAGER_INSTALL $osDependency" jjCliLog "jjLogSuccess" 'bashUtils/ensureDependency.sh OS package '$osDependency' has been installed' fi done if [[ -e $ASDF_DIR/asdf.sh ]]; then source $ASDF_DIR/asdf.sh fi if ! hash asdf || \ [[ ! -e $JJ_DATA_DIR/~~tmp/deps/asdf-tools-installed ]] \ || jjIsFileNewerFile "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" "$JJ_DATA_DIR/~~tmp/deps/asdf-tools-installed" ; then rm -rf $ASDF_DIR git -c advice.detachedHead=false clone -q https://github.com/asdf-vm/asdf.git $ASDF_DIR --branch $ASDF_VERSION source $ASDF_DIR/asdf.sh rm -rf $ASDF_DIR/.git jjCliLog jjLogSuccess $scriptFileName "OS package 'asdf' has been installed" set +e while read tool_and_version; do jjCliLog jjLog "... checking tool: $tool_and_version" tool_and_version_split=(${tool_and_version}) echo ${tool_and_version_split[0]} echo ${tool_and_version_split[1]} asdf plugin add ${tool_and_version_split[0]} || true asdf install ${tool_and_version_split[0]} ${tool_and_version_split[1]} done <${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME} asdf install set -e rm -rf $JJ_DATA_DIR/~~tmp/deps mkdir -p "$JJ_DATA_DIR/~~tmp/deps" touch $JJ_DATA_DIR/~~tmp/deps/asdf-tools-installed jjCliLog jjLogSuccess "Asdf and tools installed" fi if [[ -e $ASDF_DIR/asdf.sh ]]; then source $ASDF_DIR/asdf.sh fi if [[ ! -e $JJ_DATA_DIR/~~tmp/deps/bun-packages-installed ]] \ || jjIsFileNewerFile "$JJ_WORKSPACE_DIR/package.json" "$JJ_DATA_DIR/~~tmp/deps/bun-packages-installed" \ || jjIsFileNewerFile "$JJ_WORKSPACE_DIR/bun.lockb" "$JJ_DATA_DIR/~~tmp/deps/bun-packages-installed" \ ; then pushd $JJ_WORKSPACE_DIR > /dev/null bun install popd > /dev/null touch $JJ_DATA_DIR/~~tmp/deps/bun-packages-installed jjCliLog jjLogSuccess "Bun dependencies successfully installed" fi if [[ ! -e $JJ_DATA_DIR/~~tmp/deps/python-packages-installed ]] \ || jjIsFileNewerFile "$JJ_WORKSPACE_DIR/requirements.txt" "$JJ_DATA_DIR/~~tmp/deps/python-packages-installed" \ ; then pushd $JJ_WORKSPACE_DIR > /dev/null pip install -r requirements.txt || pip3 install -r requirements.txt popd > /dev/null touch $JJ_DATA_DIR/~~tmp/deps/python-packages-installed jjCliLog jjLogSuccess "Python dependencies successfully installed" fi if [[ ! -e $JJ_DATA_DIR/~~tmp/deps/npmGlobalDependencies-installed ]] \ || jjIsFileNewerFile "$JJ_DATA_DIR/~~tmp/npmGlobalDependencies.txt" "$JJ_DATA_DIR/~~tmp/deps/npmGlobalDependencies-installed" \ ; then pushd $JJ_WORKSPACE_DIR > /dev/null eval "npm i -g $BUN_GLOBAL_DEPENDENCIES" popd > /dev/null touch $JJ_DATA_DIR/~~tmp/deps/npmGlobalDependencies-installed jjCliLog jjLogSuccess "Global dependencies successfully installed" fi if [[ ! -e $JJ_DATA_DIR/~~tmp/deps/libpq-installed ]]; then if [[ ${UNAME} == "Linux" ]]; then eval "$PACKAGE_MANAGER_INSTALL libpq-dev g++ make" else eval "$PACKAGE_MANAGER_INSTALL libpq" eval "$PACKAGE_MANAGER_INSTALL postgresql@14" fi touch $JJ_DATA_DIR/~~tmp/deps/libpq-installed fi if [[ ! -d "$JJ_GIT_METADATA_DIR" ]]; then jjCliLog jjLogWarning "JJ_GIT_METADATA_DIR is not exist. cloning" git clone -b "${JJ_GIT_METADATA_BRANCH}" $JJ_GIT_METADATA_MAIN_ORIGIN "${JJ_GIT_METADATA_DIR}" fi