diff --git a/build/tasks/tslint.js b/build/tasks/tslint.js index 45a9778946..97e2e27d3f 100644 --- a/build/tasks/tslint.js +++ b/build/tasks/tslint.js @@ -4,9 +4,11 @@ # SPDX-License-Identifier: Apache-2.0 */ const gulp = require('gulp'); -const tslint = require('gulp-tslint'); +const gulpTslint = require('gulp-tslint'); +const tslint = require('tslint'); gulp.task('tslint', () => { + const program = tslint.Linter.createProgram('tslint.json'); return gulp.src([ 'fabric-client/**/*.ts', 'fabric-network/**/*.ts', @@ -16,9 +18,10 @@ gulp.task('tslint', () => { '!fabric-network/node_modules/**', '!fabric-client/coverage/**', '!fabric-client/node_modules/**', - ]).pipe(tslint({ - formatter: 'prose' - })).pipe(tslint.report({ + ]).pipe(gulpTslint({ + formatter: 'prose', + program + })).pipe(gulpTslint.report({ summarizeFailureOutput: true })); }); diff --git a/fabric-network/src/impl/wallet/hsmx509identity.ts b/fabric-network/src/impl/wallet/hsmx509identity.ts index 8d47c14438..83c7658786 100644 --- a/fabric-network/src/impl/wallet/hsmx509identity.ts +++ b/fabric-network/src/impl/wallet/hsmx509identity.ts @@ -102,6 +102,6 @@ export class HsmX509Provider implements IdentityProvider { username: name, }; const user: Client.User = await client.createUser(userData); - client.setUserContext(user, true); + await client.setUserContext(user, true); } } diff --git a/fabric-network/src/impl/wallet/x509identity.ts b/fabric-network/src/impl/wallet/x509identity.ts index 379cfac2ea..6aa50b5f64 100644 --- a/fabric-network/src/impl/wallet/x509identity.ts +++ b/fabric-network/src/impl/wallet/x509identity.ts @@ -75,6 +75,6 @@ export class X509Provider implements IdentityProvider { username: name, }; const user: Client.User = await client.createUser(userData); - client.setUserContext(user, true); + await client.setUserContext(user, true); } } diff --git a/package.json b/package.json index 3d5ef1be69..040f6af4f3 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "test:network": "npm run compile-src && npm run coverage -- 'fabric-network/test/**/*.{js,ts}'", "test:protos": "npm run coverage -- 'fabric-protos/test/**/*.{js,ts}", "test:cucumber": "cucumber-js ./test/scenario/features/*.feature", - "test:ts-cucumber": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register", - "test:ts-cucumber-tagged": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register --tags @lifecycle", - "test:all": "nyc npm run unit-test:all", + "test:ts-cucumber": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register", + "test:ts-cucumber-tagged": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register --tags @lifecycle", + "test:all": "nyc npm run unit-test:all", "unit-test:all": "npm run unit-test -- 'fabric-common/test/**/*.{js,ts}' && npm run unit-test -- 'fabric-ca-client/test/**/*.{js,ts}' && npm run unit-test -- 'fabric-client/test/**/*.{js,ts}' && npm run unit-test -- 'fabric-network/test/**/*.{js,ts}'", "unit-test": "mocha --require ts-node/register --exclude 'fabric-client/test/data/**'", "compile": "npm run compile-src && npm run compile-test", diff --git a/scripts/utility/fabric_images.sh b/scripts/utility/fabric_images.sh index 6cb4d77eb1..5ff6beea8d 100755 --- a/scripts/utility/fabric_images.sh +++ b/scripts/utility/fabric_images.sh @@ -16,23 +16,26 @@ NEXUS_URL=nexus3.hyperledger.org:10001 ORG_NAME="hyperledger/fabric" ARCH=$1 : ${STABLE_VERSION:=$2} -STABLE_TAG=$ARCH-$STABLE_VERSION -echo "---------> STABLE_VERSION:" $STABLE_VERSION +STABLE_TAG="${ARCH}-${STABLE_VERSION}" +VERSION_TAG="${STABLE_VERSION%%-*}" +echo "---------> STABLE_VERSION: ${STABLE_VERSION}" dockerTag() { for IMAGES in ca peer orderer ccenv baseos nodeenv javaenv tools; do - echo "Images: $IMAGES" + echo "Images: ${IMAGES}" echo - docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG + NEXUS_IMAGE="${NEXUS_URL}/${ORG_NAME}-${IMAGES}:${STABLE_TAG}" + docker pull "${NEXUS_IMAGE}" if [ $? != 0 ]; then - echo "FAILED: Docker Pull Failed on $IMAGES" + echo "FAILED: Docker Pull Failed on ${IMAGES}" exit 1 fi - docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES - docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES:$STABLE_TAG - echo "$ORG_NAME-$IMAGES:$STABLE_TAG" + IMAGE_NAME="${ORG_NAME}-${IMAGES}" + docker tag "${NEXUS_IMAGE}" "${IMAGE_NAME}" + docker tag "${NEXUS_IMAGE}" "${IMAGE_NAME}:${VERSION_TAG}" + echo "${IMAGE_NAME}:${VERSION_TAG}" echo "Deleting Nexus docker images: $IMAGES" - docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG + docker rmi -f "${NEXUS_IMAGE}" done } diff --git a/test/ts-scenario/steps/lib/deprecatedSDK.ts b/test/ts-scenario/steps/lib/deprecatedSDK.ts index 38684c69ae..aa2b24a6e6 100644 --- a/test/ts-scenario/steps/lib/deprecatedSDK.ts +++ b/test/ts-scenario/steps/lib/deprecatedSDK.ts @@ -18,7 +18,7 @@ const supportedLanguageTypes: string[] = ['node', 'golang']; export async function sdk_chaincode_install_for_org(ccType: 'golang' | 'car' | 'java' | 'node', ccName: string, ccVersion: string, chaincodeId: string, tls: boolean, ccp: CommonConnectionProfileHelper, orgName: string, channelName: string): Promise { if (!supportedLanguageTypes.includes(ccType)) { - Promise.reject(`Unsupported test ccType ${ccType}`); + throw new Error(`Unsupported test ccType ${ccType}`); } Client.setConfigSetting('request-timeout', Constants.INSTALL_TIMEOUT); @@ -134,7 +134,7 @@ export async function sdk_chaincode_install_for_org(ccType: 'golang' | 'car' | ' */ export async function sdk_chaincode_instantiate(ccName: string, ccType: 'golang' | 'car' | 'java' | 'node', ccVersion: string, chaincodeId: string, args: string, upgrade: boolean, tls: boolean, ccp: CommonConnectionProfileHelper, orgName: string, channelName: string, policy: any): Promise { if (!supportedLanguageTypes.includes(ccType)) { - Promise.reject(`Unsupported test ccType: ${ccType}`); + throw new Error(`Unsupported test ccType: ${ccType}`); } Client.setConfigSetting('request-timeout', Constants.INSTANTIATE_TIMEOUT); @@ -213,7 +213,7 @@ export async function sdk_chaincode_instantiate(ccName: string, ccType: 'golang' const proposal: Client.Proposal = results[1]; for (const proposalResponse of proposalResponses) { if (!((proposalResponse as Client.ProposalResponse).response && (proposalResponse as Client.ProposalResponse).response.status === 200)) { - Promise.reject(`The proposal of type ${type} was bad: ${JSON.stringify(proposalResponse)}`); + throw new Error(`The proposal of type ${type} was bad: ${JSON.stringify(proposalResponse)}`); } } diff --git a/tslint.json b/tslint.json index f47cc57438..dc18dc8156 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1,5 @@ { - "extends": [ - "tslint:recommended" - ], + "extends": "tslint:recommended", "rules": { "trailing-comma": [ false, @@ -24,7 +22,6 @@ "forin": false, "max-line-length": false, "no-string-literal": false, - "no-use-before-declare": true, "object-literal-sort-keys": false, "object-literal-shorthand": false, "ordered-imports": false,