- Add lib/conf_path_resolve.sh (canonical conf under projects/ or ia_dev/projects/) - Apply resolution in project_git_root_from_conf, deploy-conf-handling, orchestrator - pousse: monorepo-relative build_dirs when path starts with ../ - deploy-by-script-to: resolve secrets_path and deploy_script_path - Sync smart_ide/enso conf.json with relative paths; document in projects/README
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Resolve paths in projects/<id>/conf.json: absolute paths unchanged; others relative to smart_ide monorepo root.
|
|
# Monorepo root is the directory that contains ./projects/ (conf at .../projects/<id>/conf.json) or, when the
|
|
# file lives under .../ia_dev/projects/<id>/conf.json, the parent of ./ia_dev/.
|
|
|
|
# ia_dev_smart_ide_monorepo_root_from_conf <path_to_conf.json>
|
|
ia_dev_smart_ide_monorepo_root_from_conf() {
|
|
local conf="${1:?}"
|
|
local c="$conf"
|
|
if command -v realpath >/dev/null 2>&1; then
|
|
c="$(realpath "$conf" 2>/dev/null)" || c="$conf"
|
|
else
|
|
c="$(readlink -f "$conf" 2>/dev/null)" || c="$conf"
|
|
fi
|
|
local d
|
|
d="$(dirname "$c")"
|
|
if [[ "$c" == */ia_dev/projects/*/conf.json ]]; then
|
|
( cd "$d/../../.." && pwd )
|
|
return
|
|
fi
|
|
if [[ "$c" == */projects/*/conf.json ]]; then
|
|
( cd "$d/../.." && pwd )
|
|
return
|
|
fi
|
|
( cd "$d/../.." && pwd )
|
|
}
|
|
|
|
# ia_dev_resolve_path_from_conf <path_to_conf.json> <path_field>
|
|
ia_dev_resolve_path_from_conf() {
|
|
local conf="${1:?}"
|
|
local p="${2:-}"
|
|
p="${p//$'\r'/}"
|
|
if [[ -z "$p" || "$p" == "null" ]]; then
|
|
printf '%s\n' ""
|
|
return 0
|
|
fi
|
|
if [[ "$p" = /* ]]; then
|
|
printf '%s\n' "$p"
|
|
return 0
|
|
fi
|
|
local root
|
|
root="$(ia_dev_smart_ide_monorepo_root_from_conf "$conf")"
|
|
if ( cd "$root" && realpath -m "$p" >/dev/null 2>&1 ); then
|
|
( cd "$root" && realpath -m "$p" )
|
|
else
|
|
printf '%s\n' "$root/$p"
|
|
fi
|
|
}
|