flow update
This commit is contained in:
61
flow
61
flow
@ -15,25 +15,28 @@ CARGO_DEPENDENCIES=(cargo-pgrx==0.16.1)
|
|||||||
GITEA_ORGANIZATION="cellular"
|
GITEA_ORGANIZATION="cellular"
|
||||||
GITEA_REPOSITORY="jspg"
|
GITEA_REPOSITORY="jspg"
|
||||||
|
|
||||||
pgrx-prepare() {
|
pgrx-up() {
|
||||||
info "Initializing pgrx..."
|
info "Initializing pgrx..."
|
||||||
# Explicitly point to the postgresql@${POSTGRES_VERSION} pg_config, don't rely on 'which'
|
# Explicitly point to the postgresql@${POSTGRES_VERSION} pg_config, don't rely on 'which'
|
||||||
local POSTGRES_CONFIG_PATH="/opt/homebrew/opt/postgresql@${POSTGRES_VERSION}/bin/pg_config"
|
local POSTGRES_CONFIG_PATH="/opt/homebrew/opt/postgresql@${POSTGRES_VERSION}/bin/pg_config"
|
||||||
|
|
||||||
if [ ! -x "$POSTGRES_CONFIG_PATH" ]; then
|
if [ ! -x "$POSTGRES_CONFIG_PATH" ]; then
|
||||||
error "pg_config not found or not executable at $POSTGRES_CONFIG_PATH."
|
|
||||||
warning "Ensure postgresql@${POSTGRES_VERSION} is installed correctly via Homebrew."
|
warning "Ensure postgresql@${POSTGRES_VERSION} is installed correctly via Homebrew."
|
||||||
return 2
|
abort "pg_config not found or not executable at $POSTGRES_CONFIG_PATH." 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if cargo pgrx init --pg"$POSTGRES_VERSION"="$POSTGRES_CONFIG_PATH"; then
|
if cargo pgrx init --pg"$POSTGRES_VERSION"="$POSTGRES_CONFIG_PATH"; then
|
||||||
success "pgrx initialized successfully."
|
success "pgrx initialized successfully." && return 0
|
||||||
else
|
|
||||||
error "Failed to initialize pgrx. Check PostgreSQL development packages are installed and $POSTGRES_CONFIG_PATH is valid."
|
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
abort "Failed to initialize pgrx. Check PostgreSQL development packages are installed and $POSTGRES_CONFIG_PATH is valid." 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pgrx-down() {
|
||||||
|
info "Taking pgrx down..."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
local version
|
local version
|
||||||
version=$(get-version) || return $?
|
version=$(get-version) || return $?
|
||||||
@ -51,11 +54,10 @@ build() {
|
|||||||
info "Creating tarball: ${tarball_path}"
|
info "Creating tarball: ${tarball_path}"
|
||||||
# Set COPYFILE_DISABLE=1 to prevent macOS tar from including ._ metadata files
|
# Set COPYFILE_DISABLE=1 to prevent macOS tar from including ._ metadata files
|
||||||
if COPYFILE_DISABLE=1 tar --exclude='.git*' --exclude='./target' --exclude='./package' --exclude='./flows' --exclude='./flow' -czf "${tarball_path}" .; then
|
if COPYFILE_DISABLE=1 tar --exclude='.git*' --exclude='./target' --exclude='./package' --exclude='./flows' --exclude='./flow' -czf "${tarball_path}" .; then
|
||||||
success "Successfully created source tarball: ${tarball_path}"
|
success "Successfully created source tarball: ${tarball_path}" && return 0
|
||||||
else
|
|
||||||
error "Failed to create source tarball."
|
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
abort "Failed to create source tarball." 2
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
@ -66,8 +68,7 @@ install() {
|
|||||||
|
|
||||||
# Run the pgrx install command
|
# Run the pgrx install command
|
||||||
if ! cargo pgrx install; then
|
if ! cargo pgrx install; then
|
||||||
error "cargo pgrx install command failed."
|
abort "cargo pgrx install command failed." 2
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
success "PGRX extension v$version successfully built and installed."
|
success "PGRX extension v$version successfully built and installed."
|
||||||
|
|
||||||
@ -76,26 +77,23 @@ install() {
|
|||||||
pg_sharedir=$("$POSTGRES_CONFIG_PATH" --sharedir)
|
pg_sharedir=$("$POSTGRES_CONFIG_PATH" --sharedir)
|
||||||
local pg_config_status=$?
|
local pg_config_status=$?
|
||||||
if [ $pg_config_status -ne 0 ] || [ -z "$pg_sharedir" ]; then
|
if [ $pg_config_status -ne 0 ] || [ -z "$pg_sharedir" ]; then
|
||||||
error "Failed to determine PostgreSQL shared directory using pg_config."
|
abort "Failed to determine PostgreSQL shared directory using pg_config." 2
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
local installed_control_path="${pg_sharedir}/extension/jspg.control"
|
local installed_control_path="${pg_sharedir}/extension/jspg.control"
|
||||||
|
|
||||||
# Modify the control file
|
# Modify the control file
|
||||||
if [ ! -f "$installed_control_path" ]; then
|
if [ ! -f "$installed_control_path" ]; then
|
||||||
error "Installed control file not found: '$installed_control_path'"
|
abort "Installed control file not found: '$installed_control_path'" 2
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Modifying control file for non-superuser access: ${installed_control_path}"
|
info "Modifying control file for non-superuser access: ${installed_control_path}"
|
||||||
# Use sed -i '' for macOS compatibility
|
# Use sed -i '' for macOS compatibility
|
||||||
if sed -i '' '/^superuser = false/d' "$installed_control_path" && \
|
if sed -i '' '/^superuser = false/d' "$installed_control_path" && \
|
||||||
echo 'trusted = true' >> "$installed_control_path"; then
|
echo 'trusted = true' >> "$installed_control_path"; then
|
||||||
success "Control file modified successfully."
|
success "Control file modified successfully." && return 0
|
||||||
else
|
|
||||||
error "Failed to modify control file: ${installed_control_path}"
|
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
abort "Failed to modify control file: ${installed_control_path}" 2
|
||||||
}
|
}
|
||||||
|
|
||||||
test() {
|
test() {
|
||||||
@ -109,26 +107,27 @@ clean() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jspg-usage() {
|
jspg-usage() {
|
||||||
printf "prepare\tCheck OS, Cargo, and PGRX dependencies.\n"
|
echo "up|Check OS, Cargo, and PGRX dependencies."
|
||||||
printf "install\tBuild and install the extension locally (after prepare).\n"
|
echo "install|Build and install the extension locally (after up)."
|
||||||
printf "reinstall\tClean, build, and install the extension locally (after prepare).\n"
|
echo "reinstall|Clean, build, and install the extension locally (after up)."
|
||||||
printf "test-jspg\t\tRun pgrx integration tests.\n"
|
echo "test-jspg|Run pgrx integration tests."
|
||||||
printf "test-validator\t\tRun validator integration tests.\n"
|
echo "test-validator|Run validator integration tests."
|
||||||
printf "clean\t\tRemove pgrx build artifacts.\n"
|
echo "clean|Remove pgrx build artifacts."
|
||||||
}
|
}
|
||||||
|
|
||||||
jspg-flow() {
|
jspg-flow() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
prepare) prepare && cargo-prepare && pgrx-prepare; return $?;;
|
up) up && rust-up && pgrx-up; return $?;;
|
||||||
|
down) pgrx-down && rust-down && down; return $?;;
|
||||||
build) build; return $?;;
|
build) build; return $?;;
|
||||||
install) install; return $?;;
|
install) install; return $?;;
|
||||||
reinstall) clean && install; return $?;;
|
reinstall) clean && install; return $?;;
|
||||||
test) test "${@:2}"; return $?;;
|
test) test "${@:2}"; return $?;;
|
||||||
clean) clean; return $?;;
|
clean) clean; return $?;;
|
||||||
*) return 1 ;;
|
*) return 127 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
register-flow "jspg-usage" "jspg-flow"
|
register-flow "jspg"
|
||||||
|
|
||||||
dispatch "$@"
|
dispatch "$@"
|
||||||
2
flows
2
flows
Submodule flows updated: 404da626c7...185aff4504
Reference in New Issue
Block a user