Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 21b5001

Browse files
author
Simon Stone
committed
[FABN-909] Move Config class into common package
Change-Id: I1a87203f1cc41480e0e34c28900a97dd6f455ead Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
1 parent 66af0c1 commit 21b5001

File tree

14 files changed

+38
-18
lines changed

14 files changed

+38
-18
lines changed

build/tasks/ca.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const DEPS = [
1313
'fabric-client/lib/hash.js',
1414
'fabric-client/lib/utils.js',
1515
'fabric-client/lib/BaseClient.js',
16-
'fabric-client/lib/Config.js',
1716
'fabric-client/lib/ProtoLoader.js',
1817
'fabric-client/lib/Remote.js',
1918
'fabric-client/lib/User.js',

build/tasks/test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ process.env.THIRDPARTY_IMG_TAG = thirdpartyImageTag;
7373

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

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

147+
gulp.task('mocha-fabric-common',
148+
() => {
149+
return gulp.src(['./fabric-common/test/**/*.js'], {read: false})
150+
.pipe(mocha({reporter: 'list', exit: true}));
151+
}
152+
);
153+
146154
gulp.task('mocha-fabric-ca-client',
147155
() => {
148156
return gulp.src(['./fabric-ca-client/test/**/*.js'], {read: false})

fabric-ca-client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@types/bytebuffer": "^5.0.34",
2525
"bn.js": "^4.11.3",
2626
"elliptic": "^6.2.3",
27+
"fabric-common": "file:../fabric-common",
2728
"fs-extra": "^6.0.1",
2829
"grpc": "1.14.2",
2930
"js-sha3": "^0.7.0",

fabric-client/lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const path = require('path');
2222
const os = require('os');
2323
const Long = require('long');
2424

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

2828
//

fabric-client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"bn.js": "^4.11.3",
2626
"callsite": "^1.0.0",
2727
"elliptic": "^6.2.3",
28+
"fabric-common": "file:../fabric-common",
2829
"fs-extra": "^6.0.1",
2930
"grpc": "1.14.2",
3031
"hoek": "^4.2.1",

fabric-common/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
7+
const Config = require('./lib/Config');
8+
9+
module.exports = {
10+
Config
11+
};

fabric-common/lib/.gitkeep

Lines changed: 0 additions & 5 deletions
This file was deleted.

fabric-client/lib/Config.js renamed to fabric-common/lib/Config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const nconf = require('nconf');
2020
// The class representing the hierarchy of configuration settings.
2121
//
2222

23-
const Config = class {
23+
class Config {
2424

2525
constructor() {
2626
nconf.use('memory');
@@ -110,6 +110,6 @@ const Config = class {
110110
this._config.set(name, value);
111111
}
112112

113-
};
113+
}
114114

115115
module.exports = Config;

fabric-common/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
"test": "nyc mocha --exclude 'test/data/**/*.js' --recursive -t 10000"
2222
},
2323
"dependencies": {
24+
"nconf": "^0.10.0"
2425
},
2526
"devDependencies": {
27+
"chai": "^4.1.2",
2628
"mocha": "^5.2.0",
2729
"nyc": "^12.0.2",
2830
"rewire": "^4.0.1",

fabric-common/test/.gitkeep

Lines changed: 0 additions & 5 deletions
This file was deleted.

fabric-client/test/Config.js renamed to fabric-common/test/Config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const ConfigRewire = rewire('../lib/Config');
2020
const nconf = require('nconf');
2121

2222
const sinon = require('sinon');
23+
const chai = require('chai');
24+
chai.should();
2325

2426
describe('Config', () => {
2527
let sandbox;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"scripts": {
1818
"test": "gulp test-headless",
19+
"test:common": "npm run coverage -- fabric-common/test",
1920
"test:ca-client": "npm run coverage -- fabric-ca-client/test",
2021
"test:client": "npm run coverage -- fabric-client/test",
2122
"test:network": "npm run coverage -- fabric-network/test",

scripts/Jenkins_Scripts/CI_Script.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ env_Info() {
126126

127127
# pull fabric, fabric-ca images from nexus
128128
pull_Docker_Images() {
129-
for IMAGES in peer orderer ca javaenv; do
129+
for IMAGES in peer orderer ca baseos ccenv javaenv nodeenv; do
130130
if [ $IMAGES == "javaenv" ]; then
131131
if [ $ARCH == "s390x" ]; then
132132
# Do not pull javaenv if OS_VER == s390x
@@ -142,6 +142,7 @@ pull_Docker_Images() {
142142
fi
143143
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES
144144
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${ARCH}-${VERSION}
145+
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${VERSION}
145146
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG}
146147
fi
147148
else
@@ -154,6 +155,7 @@ pull_Docker_Images() {
154155
fi
155156
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES
156157
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${ARCH}-${VERSION}
158+
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${VERSION}
157159
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG}
158160
fi
159161
done

scripts/Jenkins_Scripts/Publish_NPM_Modules.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ npmPublish() {
3434
export UNSTABLE_INCREMENT_VERSION=$RELEASE_VERSION.$UNSTABLE_INCREMENT
3535
echo "======> UNSTABLE_INCREMENT_VERSION:" $UNSTABLE_INCREMENT_VERSION
3636

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

58-
if [ "$1" = "fabric-network" ]; then
62+
if [ "$1" = "fabric-client" ]; then
63+
sed -i 's/\(.*\"fabric-common\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
64+
elif [ "$1" = "fabric-ca-client" ]; then
65+
sed -i 's/\(.*\"fabric-common\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
66+
elif [ "$1" = "fabric-network" ]; then
5967
sed -i 's/\(.*\"fabric-client\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
6068
sed -i 's/\(.*\"fabric-ca-client\"\: \"\)\(.*\)/\1'$CURRENT_TAG\"\,'/' package.json
6169
fi

0 commit comments

Comments
 (0)