diff --git a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-raft-explorer.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-raft-explorer.json.test.ts.snap index e61f8f44..874e9864 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-raft-explorer.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-raft-explorer.json.test.ts.snap @@ -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 @@ -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)" diff --git a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap index 285db2bd..a4661b8e 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap @@ -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 @@ -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)" diff --git a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap index ac9973f3..2c889703 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap @@ -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 @@ -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)" diff --git a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap index 283f90b1..44fbec80 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap @@ -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 @@ -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)" diff --git a/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap index b1db86d3..59c39919 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap @@ -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 @@ -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)" diff --git a/package-lock.json b/package-lock.json index 41a98db1..3f67801b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "js-yaml": "^4.1.0", "jsonschema": "^1.2.6", "lodash": "^4.17.21", + "winston": "^2.4.7", "yeoman-generator": "^5.10.0" }, "devDependencies": { @@ -3999,8 +4000,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", "integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw==", - "devOptional": true, - "peer": true, "engines": { "node": ">=0.1.90" } @@ -4158,6 +4157,14 @@ "node": ">= 8" } }, + "node_modules/cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha512-TVF6svNzeQCOpjCqsy0/CSy8VgObG3wXusJ73xW2GbG5rGx7lC8zxDSURicsXI2UsGdi2L0QNRCi745/wUDvsA==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/damerau-levenshtein": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", @@ -5636,6 +5643,14 @@ "node": ">=4" } }, + "node_modules/eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", + "engines": { + "node": "> 0.1.90" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -7009,6 +7024,11 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "node_modules/isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" + }, "node_modules/istanbul-lib-coverage": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", @@ -11576,6 +11596,14 @@ "node": ">= 8" } }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "engines": { + "node": "*" + } + }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -13001,6 +13029,30 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, + "node_modules/winston": { + "version": "2.4.7", + "resolved": "https://registry.npmjs.org/winston/-/winston-2.4.7.tgz", + "integrity": "sha512-vLB4BqzCKDnnZH9PHGoS2ycawueX4HLqENXQitvFHczhgW2vFpSOn31LZtVr1KU8YTw7DS4tM+cqyovxo8taVg==", + "dependencies": { + "async": "^2.6.4", + "colors": "1.0.x", + "cycle": "1.0.x", + "eyes": "0.1.x", + "isstream": "0.1.x", + "stack-trace": "0.0.x" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/winston/node_modules/async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dependencies": { + "lodash": "^4.17.14" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -17453,9 +17505,7 @@ "colors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", - "integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw==", - "devOptional": true, - "peer": true + "integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw==" }, "combined-stream": { "version": "1.0.8", @@ -17580,6 +17630,11 @@ "which": "^2.0.1" } }, + "cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha512-TVF6svNzeQCOpjCqsy0/CSy8VgObG3wXusJ73xW2GbG5rGx7lC8zxDSURicsXI2UsGdi2L0QNRCi745/wUDvsA==" + }, "damerau-levenshtein": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", @@ -18697,6 +18752,11 @@ "tmp": "^0.0.33" } }, + "eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -19716,6 +19776,11 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" + }, "istanbul-lib-coverage": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", @@ -23169,6 +23234,11 @@ "minipass": "^3.1.1" } }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==" + }, "stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -24245,6 +24315,29 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, + "winston": { + "version": "2.4.7", + "resolved": "https://registry.npmjs.org/winston/-/winston-2.4.7.tgz", + "integrity": "sha512-vLB4BqzCKDnnZH9PHGoS2ycawueX4HLqENXQitvFHczhgW2vFpSOn31LZtVr1KU8YTw7DS4tM+cqyovxo8taVg==", + "requires": { + "async": "^2.6.4", + "colors": "1.0.x", + "cycle": "1.0.x", + "eyes": "0.1.x", + "isstream": "0.1.x", + "stack-trace": "0.0.x" + }, + "dependencies": { + "async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "requires": { + "lodash": "^4.17.14" + } + } + } + }, "word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/package.json b/package.json index 1fd58280..59d7b10b 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "js-yaml": "^4.1.0", "jsonschema": "^1.2.6", "lodash": "^4.17.21", + "winston": "^2.4.7", "yeoman-generator": "^5.10.0" }, "devDependencies": { diff --git a/src/setup-docker/templates/fabric-docker/scripts/chaincode-functions-v2.sh b/src/setup-docker/templates/fabric-docker/scripts/chaincode-functions-v2.sh index d89afe8e..f35d4c26 100644 --- a/src/setup-docker/templates/fabric-docker/scripts/chaincode-functions-v2.sh +++ b/src/setup-docker/templates/fabric-docker/scripts/chaincode-functions-v2.sh @@ -9,6 +9,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 @@ -34,13 +59,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)"