Skip to content

Commit

Permalink
Merge pull request #442 from Sanket-0510/fabric-shim
Browse files Browse the repository at this point in the history
fix:  node_version check for the fabric-shim
  • Loading branch information
dzikowski authored Sep 10, 2024
2 parents df0d444 + d8d00bf commit e26f374
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,31 @@ dockerPullIfMissing() {
fi
}
node_version_check() {
local fabric_shim_version="$1"
local nodejs_version
if [[ "$fabric_shim_version" == *"1.4."* ]]; then
nodejs_version=8.9
elif [[ "$fabric_shim_version" == *"2.2."* || "$fabric_shim_version" == *"2.3."* ]]; then
nodejs_version=12.13
elif [[ "$fabric_shim_version" == *"2.4."* ]]; then
nodejs_version=16.16
elif [[ "$fabric_shim_version" == *"2.5."* ]]; then
nodejs_version=18.12
else
nodejs_version=18.12
fi
echo $nodejs_version
}
chaincodeBuild() {
local CHAINCODE_NAME=$1
local CHAINCODE_LANG=$2
Expand All @@ -2501,13 +2526,9 @@ chaincodeBuild() {
fi
if [ "$CHAINCODE_LANG" = "node" ]; then
NODE_VERSION="$(node --version)"
USES_OLD_FABRIC_SHIM="$(jq '.dependencies."fabric-shim" | contains("1.4.")' "$CHAINCODE_DIR_PATH/package.json")"
if [ "$USES_OLD_FABRIC_SHIM" == "true" ]; then
RECOMMENDED_NODE_VERSION="8.9"
fi
NODE_VERSION=$(node --version)
fabric_shim_version=$(jq -r '.dependencies."fabric-shim"' "$CHAINCODE_DIR_PATH/package.json")
RECOMMENDED_NODE_VERSION=$(node_version_check "$fabric_shim_version")
if ! echo "$NODE_VERSION" | grep -q "v$RECOMMENDED_NODE_VERSION"; then
echo "Warning: Your Node.js version is $NODE_VERSION, but recommended is $RECOMMENDED_NODE_VERSION)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,31 @@ dockerPullIfMissing() {
fi
}
node_version_check() {
local fabric_shim_version="$1"
local nodejs_version
if [[ "$fabric_shim_version" == *"1.4."* ]]; then
nodejs_version=8.9
elif [[ "$fabric_shim_version" == *"2.2."* || "$fabric_shim_version" == *"2.3."* ]]; then
nodejs_version=12.13
elif [[ "$fabric_shim_version" == *"2.4."* ]]; then
nodejs_version=16.16
elif [[ "$fabric_shim_version" == *"2.5."* ]]; then
nodejs_version=18.12
else
nodejs_version=18.12
fi
echo $nodejs_version
}
chaincodeBuild() {
local CHAINCODE_NAME=$1
local CHAINCODE_LANG=$2
Expand All @@ -2365,13 +2390,9 @@ chaincodeBuild() {
fi
if [ "$CHAINCODE_LANG" = "node" ]; then
NODE_VERSION="$(node --version)"
USES_OLD_FABRIC_SHIM="$(jq '.dependencies."fabric-shim" | contains("1.4.")' "$CHAINCODE_DIR_PATH/package.json")"
if [ "$USES_OLD_FABRIC_SHIM" == "true" ]; then
RECOMMENDED_NODE_VERSION="8.9"
fi
NODE_VERSION=$(node --version)
fabric_shim_version=$(jq -r '.dependencies."fabric-shim"' "$CHAINCODE_DIR_PATH/package.json")
RECOMMENDED_NODE_VERSION=$(node_version_check "$fabric_shim_version")
if ! echo "$NODE_VERSION" | grep -q "v$RECOMMENDED_NODE_VERSION"; then
echo "Warning: Your Node.js version is $NODE_VERSION, but recommended is $RECOMMENDED_NODE_VERSION)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3266,6 +3266,31 @@ dockerPullIfMissing() {
fi
}
node_version_check() {
local fabric_shim_version="$1"
local nodejs_version
if [[ "$fabric_shim_version" == *"1.4."* ]]; then
nodejs_version=8.9
elif [[ "$fabric_shim_version" == *"2.2."* || "$fabric_shim_version" == *"2.3."* ]]; then
nodejs_version=12.13
elif [[ "$fabric_shim_version" == *"2.4."* ]]; then
nodejs_version=16.16
elif [[ "$fabric_shim_version" == *"2.5."* ]]; then
nodejs_version=18.12
else
nodejs_version=18.12
fi
echo $nodejs_version
}
chaincodeBuild() {
local CHAINCODE_NAME=$1
local CHAINCODE_LANG=$2
Expand All @@ -3291,13 +3316,9 @@ chaincodeBuild() {
fi
if [ "$CHAINCODE_LANG" = "node" ]; then
NODE_VERSION="$(node --version)"
USES_OLD_FABRIC_SHIM="$(jq '.dependencies."fabric-shim" | contains("1.4.")' "$CHAINCODE_DIR_PATH/package.json")"
if [ "$USES_OLD_FABRIC_SHIM" == "true" ]; then
RECOMMENDED_NODE_VERSION="8.9"
fi
NODE_VERSION=$(node --version)
fabric_shim_version=$(jq -r '.dependencies."fabric-shim"' "$CHAINCODE_DIR_PATH/package.json")
RECOMMENDED_NODE_VERSION=$(node_version_check "$fabric_shim_version")
if ! echo "$NODE_VERSION" | grep -q "v$RECOMMENDED_NODE_VERSION"; then
echo "Warning: Your Node.js version is $NODE_VERSION, but recommended is $RECOMMENDED_NODE_VERSION)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4673,6 +4673,31 @@ dockerPullIfMissing() {
fi
}
node_version_check() {
local fabric_shim_version="$1"
local nodejs_version
if [[ "$fabric_shim_version" == *"1.4."* ]]; then
nodejs_version=8.9
elif [[ "$fabric_shim_version" == *"2.2."* || "$fabric_shim_version" == *"2.3."* ]]; then
nodejs_version=12.13
elif [[ "$fabric_shim_version" == *"2.4."* ]]; then
nodejs_version=16.16
elif [[ "$fabric_shim_version" == *"2.5."* ]]; then
nodejs_version=18.12
else
nodejs_version=18.12
fi
echo $nodejs_version
}
chaincodeBuild() {
local CHAINCODE_NAME=$1
local CHAINCODE_LANG=$2
Expand All @@ -4698,13 +4723,9 @@ chaincodeBuild() {
fi
if [ "$CHAINCODE_LANG" = "node" ]; then
NODE_VERSION="$(node --version)"
USES_OLD_FABRIC_SHIM="$(jq '.dependencies."fabric-shim" | contains("1.4.")' "$CHAINCODE_DIR_PATH/package.json")"
if [ "$USES_OLD_FABRIC_SHIM" == "true" ]; then
RECOMMENDED_NODE_VERSION="8.9"
fi
NODE_VERSION=$(node --version)
fabric_shim_version=$(jq -r '.dependencies."fabric-shim"' "$CHAINCODE_DIR_PATH/package.json")
RECOMMENDED_NODE_VERSION=$(node_version_check "$fabric_shim_version")
if ! echo "$NODE_VERSION" | grep -q "v$RECOMMENDED_NODE_VERSION"; then
echo "Warning: Your Node.js version is $NODE_VERSION, but recommended is $RECOMMENDED_NODE_VERSION)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5180,6 +5180,31 @@ dockerPullIfMissing() {
fi
}
node_version_check() {
local fabric_shim_version="$1"
local nodejs_version
if [[ "$fabric_shim_version" == *"1.4."* ]]; then
nodejs_version=8.9
elif [[ "$fabric_shim_version" == *"2.2."* || "$fabric_shim_version" == *"2.3."* ]]; then
nodejs_version=12.13
elif [[ "$fabric_shim_version" == *"2.4."* ]]; then
nodejs_version=16.16
elif [[ "$fabric_shim_version" == *"2.5."* ]]; then
nodejs_version=18.12
else
nodejs_version=18.12
fi
echo $nodejs_version
}
chaincodeBuild() {
local CHAINCODE_NAME=$1
local CHAINCODE_LANG=$2
Expand All @@ -5205,13 +5230,9 @@ chaincodeBuild() {
fi
if [ "$CHAINCODE_LANG" = "node" ]; then
NODE_VERSION="$(node --version)"
USES_OLD_FABRIC_SHIM="$(jq '.dependencies."fabric-shim" | contains("1.4.")' "$CHAINCODE_DIR_PATH/package.json")"
if [ "$USES_OLD_FABRIC_SHIM" == "true" ]; then
RECOMMENDED_NODE_VERSION="8.9"
fi
NODE_VERSION=$(node --version)
fabric_shim_version=$(jq -r '.dependencies."fabric-shim"' "$CHAINCODE_DIR_PATH/package.json")
RECOMMENDED_NODE_VERSION=$(node_version_check "$fabric_shim_version")
if ! echo "$NODE_VERSION" | grep -q "v$RECOMMENDED_NODE_VERSION"; then
echo "Warning: Your Node.js version is $NODE_VERSION, but recommended is $RECOMMENDED_NODE_VERSION)"
Expand Down
Loading

0 comments on commit e26f374

Please sign in to comment.