Skip to content

Commit ec44807

Browse files
dacarleynachomazzara
authored andcommitted
Feature/exact version dependencies (web3#1130)
* Specify the "--exact" flag when running `lerna publish` to pin dependencies to exact released versions on all the web3-* packages. * Fixed package versioning. Fixed the `gulp version` task so that it updates all the necessary files, including `.versions` Changed the `release` npm script to update all versions (via lerna), *then* rebuild the dist files, then do the full `lerna publish` step. * Simplified the `npm run release` script, removed version update of meteor files. * Discovered a more global way of ensuring that lerna always publishes with exact versions. * Fixed blocking test in eth.sendTransaction.js
1 parent d2226c8 commit ec44807

File tree

4 files changed

+88
-54
lines changed

4 files changed

+88
-54
lines changed

gulpfile.js

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
'use strict';
44

5-
var version = require('./lerna.json');
5+
var lernaJSON = require('./lerna.json');
66
var path = require('path');
77

88
var del = require('del');
@@ -24,74 +24,74 @@ var packages = [{
2424
fileName: 'web3',
2525
expose: 'Web3',
2626
src: './packages/web3/src/index.js',
27-
ignore: ['xmlhttprequest','websocket']
28-
},{
27+
ignore: ['xmlhttprequest', 'websocket']
28+
}, {
2929
fileName: 'web3-utils',
3030
expose: 'Web3Utils',
3131
src: './packages/web3-utils/src/index.js'
32-
},{
32+
}, {
3333
fileName: 'web3-eth',
3434
expose: 'Web3Eth',
3535
src: './packages/web3-eth/src/index.js'
36-
},{
36+
}, {
3737
fileName: 'web3-eth-accounts',
3838
expose: 'Web3EthAccounts',
3939
src: './packages/web3-eth-accounts/src/index.js'
40-
},{
40+
}, {
4141
fileName: 'web3-eth-contract',
4242
expose: 'Web3EthContract',
4343
src: './packages/web3-eth-contract/src/index.js'
44-
},{
44+
}, {
4545
fileName: 'web3-eth-personal',
4646
expose: 'Web3EthPersonal',
4747
src: './packages/web3-eth-personal/src/index.js'
48-
},{
48+
}, {
4949
fileName: 'web3-eth-iban',
5050
expose: 'Web3EthIban',
5151
src: './packages/web3-eth-iban/src/index.js'
52-
},{
52+
}, {
5353
fileName: 'web3-eth-abi',
5454
expose: 'Web3EthAbi',
5555
src: './packages/web3-eth-abi/src/index.js'
56-
},{
56+
}, {
5757
fileName: 'web3-net',
5858
expose: 'Web3Net',
5959
src: './packages/web3-net/src/index.js'
60-
},{
60+
}, {
6161
fileName: 'web3-shh',
6262
expose: 'Web3Shh',
6363
src: './packages/web3-shh/src/index.js'
64-
},{
64+
}, {
6565
fileName: 'web3-bzz',
6666
expose: 'Web3Bzz',
6767
src: './packages/web3-bzz/src/index.js'
68-
},{
68+
}, {
6969
fileName: 'web3-providers-ipc',
7070
expose: 'Web3IpcProvider',
7171
src: './packages/web3-providers-ipc/src/index.js'
72-
},{
72+
}, {
7373
fileName: 'web3-providers-http',
7474
expose: 'Web3HttpProvider',
7575
src: './packages/web3-providers-http/src/index.js',
7676
ignore: ['xmlhttprequest']
77-
},{
77+
}, {
7878
fileName: 'web3-providers-ws',
7979
expose: 'Web3WsProvider',
8080
src: './packages/web3-providers-ws/src/index.js',
8181
ignore: ['websocket']
82-
},{
82+
}, {
8383
fileName: 'web3-core-subscriptions',
8484
expose: 'Web3Subscriptions',
8585
src: './packages/web3-core-subscriptions/src/index.js'
86-
},{
86+
}, {
8787
fileName: 'web3-core-requestmanager',
8888
expose: 'Web3RequestManager',
8989
src: './packages/web3-core-requestmanager/src/index.js'
90-
},{
90+
}, {
9191
fileName: 'web3-core-promievent',
9292
expose: 'Web3PromiEvent',
9393
src: './packages/web3-core-promievent/src/index.js'
94-
},{
94+
}, {
9595
fileName: 'web3-core-method',
9696
expose: 'Web3Method',
9797
src: './packages/web3-core-method/src/index.js'
@@ -107,88 +107,93 @@ var browserifyOptions = {
107107
};
108108

109109
var ugliyOptions = {
110-
compress:{
111-
dead_code : true, // jshint ignore:line
112-
drop_debugger : true, // jshint ignore:line
113-
global_defs : { // jshint ignore:line
110+
compress: {
111+
dead_code: true, // jshint ignore:line
112+
drop_debugger: true, // jshint ignore:line
113+
global_defs: { // jshint ignore:line
114114
"DEBUG": false // matters for some libraries
115115
}
116116
}
117117
};
118118

119-
gulp.task('version', function(){
120-
if(!version.version) return;
121-
122-
gulp.src(['./package.json'])
123-
.pipe(replace(/\"version\"\: \"([\.0-9\-a-z]*)\"/, '"version": "'+ version.version + '"'))
124-
.pipe(gulp.dest('./'));
125-
gulp.src(['./bower.json'])
126-
.pipe(replace(/\"version\"\: \"([\.0-9\-a-z]*)\"/, '"version": "'+ version.version + '"'))
127-
.pipe(gulp.dest('./'));
128-
gulp.src(['./package.js'])
129-
.pipe(replace(/version\: \'([\.0-9\-a-z]*)\'/, "version: '"+ version.version + "'"))
130-
.pipe(gulp.dest('./'));
119+
gulp.task('version', function () {
120+
if (!lernaJSON.version) {
121+
throw new Error("version property is missing from lerna.json");
122+
}
123+
124+
var version = lernaJSON.version;
125+
var jsonPattern = /"version": "[.0-9\-a-z]*"/;
126+
var jsPattern = /version: '[.0-9\-a-z]*'/;
127+
var glob = [
128+
'./package.json',
129+
'./bower.json',
130+
'./package.js'
131+
];
132+
133+
gulp.src(glob, {base: './'})
134+
.pipe(replace(jsonPattern, '"version": "' + version + '"'))
135+
.pipe(replace(jsPattern, "version: '" + version + "'"))
136+
.pipe(gulp.dest('./'));
131137
});
132138

133-
gulp.task('bower', ['version'], function(cb){
134-
bower.commands.install().on('end', function (installed){
139+
gulp.task('bower', ['version'], function (cb) {
140+
bower.commands.install().on('end', function (installed) {
135141
console.log(installed);
136142
cb();
137143
});
138144
});
139145

140-
gulp.task('lint', [], function(){
146+
gulp.task('lint', [], function () {
141147
return gulp.src(['./*.js', './lib/*.js'])
142148
.pipe(jshint())
143149
.pipe(jshint.reporter('default'));
144150
});
145151

146-
gulp.task('clean', ['lint'], function(cb) {
147-
del([ DEST ]).then(cb.bind(null, null));
152+
gulp.task('clean', ['lint'], function (cb) {
153+
del([DEST]).then(cb.bind(null, null));
148154
});
149155

150-
packages.forEach(function(pckg, i){
151-
var prevPckg = (!i) ? 'clean' : packages[i-1].fileName;
156+
packages.forEach(function (pckg, i) {
157+
var prevPckg = (!i) ? 'clean' : packages[i - 1].fileName;
152158

153159
gulp.task(pckg.fileName, [prevPckg], function () {
154160
browserifyOptions.standalone = pckg.expose;
155161

156162
var pipe = browserify(browserifyOptions)
157-
.require(pckg.src, {expose: pckg.expose})
158-
.require('bn.js', {expose: 'BN'}) // expose it to dapp developers
163+
.require(pckg.src, { expose: pckg.expose })
164+
.require('bn.js', { expose: 'BN' }) // expose it to dapp developers
159165
.add(pckg.src);
160166

161-
if(pckg.ignore) {
167+
if (pckg.ignore) {
162168
pckg.ignore.forEach(function (ignore) {
163169
pipe.ignore(ignore);
164170
});
165171
}
166172

167173
return pipe.bundle()
168-
.pipe(exorcist(path.join( DEST, pckg.fileName + '.js.map')))
174+
.pipe(exorcist(path.join(DEST, pckg.fileName + '.js.map')))
169175
.pipe(source(pckg.fileName + '.js'))
170176
.pipe(streamify(babel({
171177
compact: false,
172178
presets: ['env']
173179
})))
174-
.pipe(gulp.dest( DEST ))
180+
.pipe(gulp.dest(DEST))
175181
.pipe(streamify(babel({
176182
compact: true,
177183
presets: ['env']
178184
})))
179185
.pipe(streamify(uglify(ugliyOptions)))
180186
.on('error', function (err) { console.error(err); })
181187
.pipe(rename(pckg.fileName + '.min.js'))
182-
.pipe(gulp.dest( DEST ));
188+
.pipe(gulp.dest(DEST));
183189
});
184190
});
185191

186-
187-
gulp.task('watch', function() {
192+
gulp.task('watch', function () {
188193
gulp.watch(['./packages/web3/src/*.js'], ['lint', 'build']);
189194
});
190195

191-
gulp.task('all', ['version', 'lint', 'clean', packages[packages.length-1].fileName]);
196+
gulp.task('all', ['version', 'lint', 'clean', packages[packages.length - 1].fileName]);
192197

193198
gulp.task('default', ['version', 'lint', 'clean', packages[0].fileName]);
194199

lerna.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
{
22
"version": "1.0.0-beta.26",
33
"lerna": "2.0.0",
4+
"command": {
5+
"init": {
6+
"exact": true
7+
},
8+
"publish": {
9+
"exact": true,
10+
"skipGit": true
11+
}
12+
},
413
"packages": [
514
"packages/*"
615
]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"postinstall": "lerna bootstrap",
1313
"build": "gulp",
1414
"build-all": "gulp all",
15-
"release": "lerna bootstrap; gulp; lerna publish --skip-git; gulp version;",
15+
"release": "lerna bootstrap; lerna publish; gulp version; gulp",
1616
"watch": "gulp watch",
1717
"docs": "cd docs; make html;",
1818
"lint": "jshint *.js packages",

test/eth.sendTransaction.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ describe(method, function () {
242242
assert.deepEqual(payload.params, test.formattedArgs2 || []);
243243
});
244244
}
245-
245+
246246
provider.injectResult(null);
247247
provider.injectValidation(function (payload) {
248248
assert.equal(payload.method, 'eth_getTransactionReceipt');
249249
});
250-
250+
251251

252252
// if notification its sendTransaction, which needs two more results, subscription and receipt
253253
if(test.notification) {
@@ -327,6 +327,26 @@ describe(method, function () {
327327
}
328328

329329

330+
provider.injectResult(null);
331+
provider.injectValidation(function (payload) {
332+
assert.equal(payload.method, 'eth_getTransactionReceipt');
333+
});
334+
335+
336+
// if notification its sendTransaction, which needs two more results, subscription and receipt
337+
if(test.notification) {
338+
// inject receipt
339+
provider.injectResult({
340+
"blockHash": "0x6fd9e2a26ab",
341+
"blockNumber": "0x15df",
342+
"transactionHash": "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
343+
"transactionIndex": "0x1",
344+
"contractAddress": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
345+
"cumulativeGasUsed": "0x7f110",
346+
"gasUsed": "0x7f110"
347+
});
348+
}
349+
330350
var args = clone(test.args);
331351

332352
if(test.error) {

0 commit comments

Comments
 (0)