Skip to content

Commit

Permalink
[FABN-909] Move Config class into common package
Browse files Browse the repository at this point in the history
Change-Id: I1a87203f1cc41480e0e34c28900a97dd6f455ead
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
  • Loading branch information
Simon Stone committed Jan 10, 2019
1 parent 66af0c1 commit 21b5001
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 18 deletions.
1 change: 0 additions & 1 deletion build/tasks/ca.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const DEPS = [
'fabric-client/lib/hash.js',
'fabric-client/lib/utils.js',
'fabric-client/lib/BaseClient.js',
'fabric-client/lib/Config.js',
'fabric-client/lib/ProtoLoader.js',
'fabric-client/lib/Remote.js',
'fabric-client/lib/User.js',
Expand Down
10 changes: 9 additions & 1 deletion build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ process.env.THIRDPARTY_IMG_TAG = thirdpartyImageTag;

gulp.task('pre-test', () => {
return gulp.src([
'fabric-common/lib/**/*.js',
'fabric-network/lib/**/*.js',
'fabric-client/lib/**/*.js',
'fabric-ca-client/lib/FabricCAClientImpl.js',
Expand Down Expand Up @@ -139,10 +140,17 @@ gulp.task('test-cucumber', shell.task('npx nyc npm run test:cucumber'));

// Definition of Mocha (unit) test suites
gulp.task('run-test-mocha', (done) => {
const tasks = ['mocha-fabric-ca-client', 'mocha-fabric-client', 'mocha-fabric-network'];
const tasks = ['mocha-fabric-common', 'mocha-fabric-ca-client', 'mocha-fabric-client', 'mocha-fabric-network'];
runSequence(...tasks, done);
});

gulp.task('mocha-fabric-common',
() => {
return gulp.src(['./fabric-common/test/**/*.js'], {read: false})
.pipe(mocha({reporter: 'list', exit: true}));
}
);

gulp.task('mocha-fabric-ca-client',
() => {
return gulp.src(['./fabric-ca-client/test/**/*.js'], {read: false})
Expand Down
1 change: 1 addition & 0 deletions fabric-ca-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@types/bytebuffer": "^5.0.34",
"bn.js": "^4.11.3",
"elliptic": "^6.2.3",
"fabric-common": "file:../fabric-common",
"fs-extra": "^6.0.1",
"grpc": "1.14.2",
"js-sha3": "^0.7.0",
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const path = require('path');
const os = require('os');
const Long = require('long');

const Config = require('./Config.js');
const {Config} = require('fabric-common');
const sjcl = require('sjcl');

//
Expand Down
1 change: 1 addition & 0 deletions fabric-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"bn.js": "^4.11.3",
"callsite": "^1.0.0",
"elliptic": "^6.2.3",
"fabric-common": "file:../fabric-common",
"fs-extra": "^6.0.1",
"grpc": "1.14.2",
"hoek": "^4.2.1",
Expand Down
6 changes: 6 additions & 0 deletions fabric-common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
*
* SPDX-License-Identifier: Apache-2.0
*/

const Config = require('./lib/Config');

module.exports = {
Config
};
5 changes: 0 additions & 5 deletions fabric-common/lib/.gitkeep

This file was deleted.

4 changes: 2 additions & 2 deletions fabric-client/lib/Config.js → fabric-common/lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const nconf = require('nconf');
// The class representing the hierarchy of configuration settings.
//

const Config = class {
class Config {

constructor() {
nconf.use('memory');
Expand Down Expand Up @@ -110,6 +110,6 @@ const Config = class {
this._config.set(name, value);
}

};
}

module.exports = Config;
2 changes: 2 additions & 0 deletions fabric-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
"test": "nyc mocha --exclude 'test/data/**/*.js' --recursive -t 10000"
},
"dependencies": {
"nconf": "^0.10.0"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^5.2.0",
"nyc": "^12.0.2",
"rewire": "^4.0.1",
Expand Down
5 changes: 0 additions & 5 deletions fabric-common/test/.gitkeep

This file was deleted.

2 changes: 2 additions & 0 deletions fabric-client/test/Config.js → fabric-common/test/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const ConfigRewire = rewire('../lib/Config');
const nconf = require('nconf');

const sinon = require('sinon');
const chai = require('chai');
chai.should();

describe('Config', () => {
let sandbox;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"scripts": {
"test": "gulp test-headless",
"test:common": "npm run coverage -- fabric-common/test",
"test:ca-client": "npm run coverage -- fabric-ca-client/test",
"test:client": "npm run coverage -- fabric-client/test",
"test:network": "npm run coverage -- fabric-network/test",
Expand Down
4 changes: 3 additions & 1 deletion scripts/Jenkins_Scripts/CI_Script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ env_Info() {

# pull fabric, fabric-ca images from nexus
pull_Docker_Images() {
for IMAGES in peer orderer ca javaenv; do
for IMAGES in peer orderer ca baseos ccenv javaenv nodeenv; do
if [ $IMAGES == "javaenv" ]; then
if [ $ARCH == "s390x" ]; then
# Do not pull javaenv if OS_VER == s390x
Expand All @@ -142,6 +142,7 @@ pull_Docker_Images() {
fi
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${ARCH}-${VERSION}
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${VERSION}
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG}
fi
else
Expand All @@ -154,6 +155,7 @@ pull_Docker_Images() {
fi
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${ARCH}-${VERSION}
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${VERSION}
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG}
fi
done
Expand Down
12 changes: 10 additions & 2 deletions scripts/Jenkins_Scripts/Publish_NPM_Modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ npmPublish() {
export UNSTABLE_INCREMENT_VERSION=$RELEASE_VERSION.$UNSTABLE_INCREMENT
echo "======> UNSTABLE_INCREMENT_VERSION:" $UNSTABLE_INCREMENT_VERSION

if [ "$1" = "fabric-network" ]; then
if [ "$1" = "fabric-client" ]; then
sed -i 's/\(.*\"fabric-common\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
elif [ "$1" = "fabric-ca-client" ]; then
sed -i 's/\(.*\"fabric-common\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
elif [ "$1" = "fabric-network" ]; then
sed -i 's/\(.*\"fabric-client\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
sed -i 's/\(.*\"fabric-ca-client\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
fi
Expand All @@ -55,7 +59,11 @@ npmPublish() {
# Publish node modules on latest tag
echo -e "\033[32m ========> PUBLISH $RELEASE_VERSION" "\033[0m"

if [ "$1" = "fabric-network" ]; then
if [ "$1" = "fabric-client" ]; then
sed -i 's/\(.*\"fabric-common\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
elif [ "$1" = "fabric-ca-client" ]; then
sed -i 's/\(.*\"fabric-common\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
elif [ "$1" = "fabric-network" ]; then
sed -i 's/\(.*\"fabric-client\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
sed -i 's/\(.*\"fabric-ca-client\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
fi
Expand Down

0 comments on commit 21b5001

Please sign in to comment.