Skip to content

Commit

Permalink
Removed file copying
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-chambers committed Jan 22, 2025
1 parent 63c4797 commit c703926
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions docker/upgrade-connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@ set -eu -o pipefail
connector_path="${HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH:-/functions}"
target_connector_version="$(cat /scripts/CONNECTOR_VERSION)"

rm -rf /tmp/connector-upgrade
mkdir /tmp/connector-upgrade

# We copy the package.json and package-lock.json to a temporary directory
# so that we can upgrade the @hasura/ndc-lambda-sdk package without touching the
# existing node_modules directory. This is because the existing node_modules directory
# may have been installed on a different platform since it is being volume mounted
# into a Linux container
echo -n "Copying package.json, package-lock.json to a temporary location for upgrade... "
cd "$connector_path"
cp "package.json" "package-lock.json" /tmp/connector-upgrade/
echo "done"


cd /tmp/connector-upgrade

set +e
existing_connector_version=$(jq '.dependencies["@hasura/ndc-lambda-sdk"]' -r package.json)
Expand All @@ -37,6 +23,9 @@ else
echo "Upgrading @hasura/ndc-lambda-sdk package from version $existing_connector_version to version $target_connector_version"
fi

# We do a --package-lock-only because we don't want to change the node_modules directory.
# This is because the existing node_modules directory may have been installed on a
# different platform since it is being volume mounted into a Linux container
npm install "@hasura/ndc-lambda-sdk@$target_connector_version" --save-exact --no-update-notifier --package-lock-only
exit_status=$?
set -e
Expand All @@ -47,13 +36,5 @@ if [ $exit_status -ne 0 ]; then
exit 1
fi

# We overwrite the existing file contents instead of copying because this causes the existing
# file permissions/ownership to be retained, which is important since the container is likely
# running as a different user to what's running on the docker host machine
echo -n "Copying upgraded package.json, package-lock.json back to connector files... "
cat package.json > "$connector_path/package.json"
cat package-lock.json > "$connector_path/package-lock.json"
echo "done"

echo "Successfully upgraded @hasura/ndc-lambda-sdk package to version $target_connector_version"
echo "You may need to run 'npm install' to install the new dependencies locally"

0 comments on commit c703926

Please sign in to comment.