Fablo fails with jq error when no fabric-shim dep is provided in package.json
It shouldn't since, it may be a peer dependency or a dependency of a dependency
Current output:
jq: error (at /xxx/package.json:75): null (null) and string ("1.4.") cannot have their containment checked
Hey @dzikowski is fablo still facing this issue? if yes can you guide me a bit reproduce this and if possible some more context will be helpful while addressing this issue.
Long story short we use jq to detect which version of fabric-shim the chaincode uses. Depending on the version of fabric-shim we are able to recommend node version to use:
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
This check is wrong because of two reasons:
fabric-shiminstead of a direct dependency might be a dependency of dependency. In this case it is missing inpackage.jsonand the check fails.- Our code for recommending Node.js version does not cover newer Fabric releases that use Node 18, see: https://github.com/hyperledger/fabric-chaincode-node/blob/main/COMPATIBILITY.md
To address the first issue, we should probably check version in $CHAINCODE_DIR_PATH/node_modules/fabric-shim/package.json instead of $CHAINCODE_DIR_PATH/package.json.
To address the second issue, we should cover wider range of recommended versions, as in https://github.com/hyperledger/fabric-chaincode-node/blob/main/COMPATIBILITY.md