From b60b620f16ab1374b85587247c71902afab52265 Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 31 Aug 2023 20:52:09 -0400 Subject: [PATCH] kill some duplication and just go ahead and get a process model repo if there is none --- .../bin/find_sample_process_models | 19 ++++++++----------- spiffworkflow-backend/bin/run_server_locally | 17 ++++++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/spiffworkflow-backend/bin/find_sample_process_models b/spiffworkflow-backend/bin/find_sample_process_models index f78894b7..dd77c561 100755 --- a/spiffworkflow-backend/bin/find_sample_process_models +++ b/spiffworkflow-backend/bin/find_sample_process_models @@ -10,21 +10,18 @@ set -o errtrace -o errexit -o nounset -o pipefail if [[ -z "${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../../sample-process-models" + sibling_to_arena_root="${script_dir}/../../../sample-process-models" + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="$sibling_to_arena_root" if [[ ! -d "$SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR" ]]; then - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../sample-process-models" + sibling_to_backend_root="${script_dir}/../../sample-process-models" + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="$sibling_to_backend_root" if [[ ! -d "$SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR" ]]; then - >&2 echo "ERROR: Could not find a process model repo. Last tried: ${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR}. Please set SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR to the absolute path of the git repo where you want to store process models. This could be an empty git repo, or if you want you could clone https://github.com/sartography/sample-process-models.git so that spiff-arena and sample-process-models are in the same directory." - exit 1 + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="$sibling_to_arena_root" + process_model_clone_url="https://github.com/sartography/sample-process-models.git" + >&2 echo "could not find process model dir. cloning ${process_model_clone_url} to ${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR}" + git clone "$process_model_clone_url" "$SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR" fi fi - - pushd "$SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR" >/dev/null 2>&1 - if [[ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]]; then - >&2 echo "ERROR: please do not use the main branch of sample-process-models. use dev" - exit 1 - fi - popd >/dev/null 2>&1 fi realpath "$SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR" diff --git a/spiffworkflow-backend/bin/run_server_locally b/spiffworkflow-backend/bin/run_server_locally index 5d5b61e3..e4d5ba8f 100755 --- a/spiffworkflow-backend/bin/run_server_locally +++ b/spiffworkflow-backend/bin/run_server_locally @@ -10,20 +10,23 @@ set -o errtrace -o errexit -o nounset -o pipefail port="${SPIFFWORKFLOW_BACKEND_PORT:-7000}" process_model_dir="${1:-}" + +if [[ -z "${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then + if [[ -n "${process_model_dir}" ]] && [[ -d "${process_model_dir}" ]]; then + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="$process_model_dir" + else + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) + fi + export SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR +fi + if [[ "$process_model_dir" == "acceptance" ]]; then export SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA=true export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=acceptance_tests.yml - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) elif [[ "$process_model_dir" == "localopenid" ]]; then export SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL="http://localhost:$port/openid" export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME="example.yml" - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) -elif [[ -n "$process_model_dir" ]]; then - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="$process_model_dir" -else - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) fi -export SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then export SPIFFWORKFLOW_BACKEND_ENV=local_development