109 lines
3.9 KiB
Bash
Executable File
109 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
# source "$JJ_SOURCE_DIR/bashUtils/index.sh"
|
|
|
|
osDependencies=(${=OS_DEPENDENCIES})
|
|
|
|
for osDependency in $osDependencies ; 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
|
|
|
|
|
|
asdfInstalledVersionPrefix=$(asdf info 2> /dev/null | grep -A 1 'ASDF VERSION' | tail -1 | grep "^${ASDF_VERSION}")
|
|
|
|
if [[ -z "${asdfInstalledVersionPrefix}" ]] || \
|
|
! hash asdf || \
|
|
[[ "${asdfInstalledVersionPrefix}" != "$ASDF_VERSION" ]] || \
|
|
[[ ! -e $JJ_SOURCE_DIR/~~tmp/deps/asdf-tools-installed ]] \
|
|
|| jjIsFileNewerFile "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" "$JJ_SOURCE_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[1]}
|
|
# echo ${tool_and_version_split[2]}
|
|
asdf plugin add ${tool_and_version_split[1]} || true
|
|
asdf install ${tool_and_version_split[1]} ${tool_and_version_split[2]}
|
|
done <${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME}
|
|
asdf install
|
|
set -e
|
|
rm -rf $JJ_SOURCE_DIR/~~tmp/deps
|
|
mkdir -p "$JJ_SOURCE_DIR/~~tmp/deps"
|
|
touch $JJ_SOURCE_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_SOURCE_DIR/~~tmp/deps/bun-packages-installed ]] \
|
|
|| jjIsFileNewerFile "$JJ_WORKSPACE_DIR/package.json" "$JJ_SOURCE_DIR/~~tmp/deps/bun-packages-installed" \
|
|
|| jjIsFileNewerFile "$JJ_WORKSPACE_DIR/bun.lockb" "$JJ_SOURCE_DIR/~~tmp/deps/bun-packages-installed" \
|
|
; then
|
|
|
|
pushd $JJ_WORKSPACE_DIR > /dev/null
|
|
bun install --production
|
|
popd > /dev/null
|
|
touch $JJ_SOURCE_DIR/~~tmp/deps/bun-packages-installed
|
|
jjCliLog jjLogSuccess "Bun dependencies successfully installed"
|
|
fi
|
|
|
|
if [[ ! -e $JJ_SOURCE_DIR/~~tmp/deps/python-packages-installed ]] \
|
|
|| jjIsFileNewerFile "$JJ_WORKSPACE_DIR/requirements.txt" "$JJ_SOURCE_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_SOURCE_DIR/~~tmp/deps/python-packages-installed
|
|
jjCliLog jjLogSuccess "Python dependencies successfully installed"
|
|
fi
|
|
|
|
if [[ ! -e $JJ_SOURCE_DIR/~~tmp/deps/npmGlobalDependencies-installed ]] \
|
|
|| jjIsFileNewerFile "$JJ_SOURCE_DIR/~~tmp/npmGlobalDependencies.txt" "$JJ_SOURCE_DIR/~~tmp/deps/npmGlobalDependencies-installed" \
|
|
; then
|
|
|
|
pushd $JJ_WORKSPACE_DIR > /dev/null
|
|
eval "npm i -g $BUN_GLOBAL_DEPENDENCIES"
|
|
popd > /dev/null
|
|
touch $JJ_SOURCE_DIR/~~tmp/deps/npmGlobalDependencies-installed
|
|
jjCliLog jjLogSuccess "Global dependencies successfully installed"
|
|
fi
|
|
|
|
if [[ ! -e $JJ_SOURCE_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_SOURCE_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 |