Skip to content

Commit

Permalink
Merge pull request #125 from aldbr/main_FIX_node-absolute-path
Browse files Browse the repository at this point in the history
fix(diracx-web): support absolute paths
  • Loading branch information
chaen authored Dec 18, 2024
2 parents 83688ba + a665d21 commit 8ad3ec2
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions run_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,16 @@ for src_dir in "$@"; do

# Do we find subdirectories called the same way as the package
if [ -n "$(find "${src_dir}" -mindepth 3 -maxdepth 3 -type d -path "*src/${pkg_name}")" ]; then
# And are there mulftiple pyprojects
# And are there multiple pyprojects
if [ -n "$(find "${src_dir}" -mindepth 2 -maxdepth 2 -type f -name "pyproject.toml")" ]; then
# Then let's add all these
while IFS= read -r sub_pkg_dir
do
diracx_and_extensions_pkgs+=("$(basename "${src_dir}")/$(basename "${sub_pkg_dir}")");
done < <(find "${src_dir}" -mindepth 1 -maxdepth 1 -type d -name "${pkg_name}-*" )

continue;
fi;
continue
fi
fi

fi
Expand All @@ -301,35 +301,38 @@ for src_dir in "$@"; do
fi

# Node packages: we keep a single package, the last one found
node_pkg_path=""
while IFS='' read -r pkg_json; do
node_pkg_name="$(basename "$(dirname "${pkg_json}")")"
node_pkg_path=$src_dir
done < <(find "$src_dir" -mindepth 1 -maxdepth 1 -type f -name 'package.json')
done
node_pkg_name="$(basename "${node_pkg_path}")"


if [ ${#diracx_and_extensions_pkgs[@]} -gt 0 ]; then
printf "%b Found Diracx/Extensions package directories for: %s\n" ${UNICORN_EMOJI} "${diracx_and_extensions_pkgs[*]}"
fi
if [ ${#python_pkg_names[@]} -gt 0 ]; then
printf "%b Found Python package directories for: %s\n" ${UNICORN_EMOJI} "${python_pkg_names[*]}"
fi
if [ "${node_pkg_name}" != "" ]; then
printf "%b Found Node package directory for: %s\n" ${UNICORN_EMOJI} "${node_pkg_name}"

pkg_json="${node_pkg_name}/package.json"
pkg_json="${node_pkg_path}/package.json"

# Check for workspaces in the package.json
if [ "$(jq -e ".workspaces | type== \"array\"" "$pkg_json")" == "true" ]; then
readarray -t node_pkg_workspaces < <(jq -r ".workspaces[]" "$pkg_json")
node_pkg_workspaces=("${node_pkg_workspaces[@]}")
printf "%b Found Node package workspaces for: %s\n" ${UNICORN_EMOJI} "$(IFS=' '; echo "${node_pkg_workspaces[*]}")"
fi

# Ensure node_modules exist, else create them, as volumes will be mounted there
mkdir -p "${node_pkg_name}"/node_modules
mkdir -p "${node_pkg_path}"/node_modules
for workspace in "${node_pkg_workspaces[@]}"; do
mkdir -p "${node_pkg_name}/${workspace}"/node_modules
mkdir -p "${node_pkg_path}/${workspace}"/node_modules
done
done

if [ ${#diracx_and_extensions_pkgs[@]} -gt 0 ]; then
printf "%b Found Diracx/Extensions package directories for: %s\n" ${UNICORN_EMOJI} "${diracx_and_extensions_pkgs[*]}"
fi
if [ ${#python_pkg_names[@]} -gt 0 ]; then
printf "%b Found Python package directories for: %s\n" ${UNICORN_EMOJI} "${python_pkg_names[*]}"
fi
if [ "${node_pkg_name}" != "" ]; then
printf "%b Found Node package directory for: %s\n" ${UNICORN_EMOJI} "${node_pkg_name}"
fi
if [ ${#node_pkg_workspaces[@]} -gt 0 ]; then
printf "%b Found Node package workspaces for: %s\n" ${UNICORN_EMOJI} "$(IFS=' '; echo "${node_pkg_workspaces[*]}")"
fi

trap "cleanup" EXIT
Expand Down Expand Up @@ -504,7 +507,7 @@ sed "s#{{ mounted_python_modules }}#${json}#g" "${demo_dir}/values.yaml.bak" > "
mv "${demo_dir}/values.yaml" "${demo_dir}/values.yaml.bak"

# Add the node package and its workspaces
sed "s/{{ node_module_to_mount }}/${node_pkg_name}/g" "${demo_dir}/values.yaml.bak" > "${demo_dir}/values.yaml"
sed "s#{{ node_module_to_mount }}#${node_pkg_name}#g" "${demo_dir}/values.yaml.bak" > "${demo_dir}/values.yaml"
mv "${demo_dir}/values.yaml" "${demo_dir}/values.yaml.bak"

json="["
Expand Down

0 comments on commit 8ad3ec2

Please sign in to comment.