Skip to content

Commit 6434d6c

Browse files
committedJan 13, 2015
use gulp-bitcore for gulp
1 parent 149b7fa commit 6434d6c

File tree

5 files changed

+11
-332
lines changed

5 files changed

+11
-332
lines changed
 

‎.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ apiref
1414
bower_components
1515
report
1616
.DS_Store
17-
browser
17+
18+
19+
bitcore.js
20+
bitcore.min.js
21+
tests.js

‎bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bitcore",
3-
"main": "browser/bitcore.min.js",
3+
"main": "./bitcore.min.js",
44
"version": "0.8.6",
55
"homepage": "http://bitcore.io",
66
"authors": [

‎gulpfile.js

+2-327
Original file line numberDiff line numberDiff line change
@@ -1,330 +1,5 @@
1-
/**
2-
* @file gulpfile.js
3-
*
4-
* Defines tasks that can be run on gulp.
5-
*
6-
* Summary: <ul>
7-
* <li> `test` - runs all the tests on node and the browser (mocha and karma)
8-
* <ul>
9-
* <li> `test:node`
10-
* <li> `test:node:nofail` - internally used for watching (due to bug on gulp-mocha)
11-
* <li> `test:browser`
12-
* </ul>`
13-
* <li> `watch:test` - watch for file changes and run tests
14-
* <ul>
15-
* <li> `watch:test:node`
16-
* <li> `watch:test:browser`
17-
* </ul>`
18-
* <li> `browser` - generate files needed for browser (browserify)
19-
* <ul>
20-
* <li> `browser:uncompressed` - build `browser/bitcore.js`
21-
* <li> `browser:compressed` - build `browser/bitcore.min.js`
22-
* <li> `browser:maketests` - build `browser/tests.js`, needed for testing without karma
23-
* </ul>`
24-
* <li> `lint` - run `jshint`
25-
* <li> `coverage` - run `istanbul` with mocha to generate a report of test coverage
26-
* <li> `jsdoc` - run `jsdoc` to generate the API reference
27-
* <li> `coveralls` - updates coveralls info
28-
* <li> `release` - automates release process (only for bitcore maintainers)
29-
* </ul>
30-
*/
31-
'use strict';
321

33-
var gulp = require('gulp');
342

35-
var bump = require('gulp-bump');
36-
var coveralls = require('gulp-coveralls');
37-
var git = require('gulp-git');
38-
var gutil = require('gulp-util');
39-
var jsdoc2md = require('jsdoc-to-markdown');
40-
var jshint = require('gulp-jshint');
41-
var mfs = require('more-fs');
42-
var mocha = require('gulp-mocha');
43-
var rename = require('gulp-rename');
44-
var runSequence = require('run-sequence');
45-
var shell = require('gulp-shell');
46-
var through = require('through2');
47-
var uglify = require('gulp-uglify');
3+
var gulp_bitcore = require('gulp-bitcore');
484

49-
50-
var files = ['lib/**/*.js'];
51-
var tests = ['test/**/*.js'];
52-
var alljs = files.concat(tests);
53-
54-
55-
function ignoreError() {
56-
/* jshint ignore:start */ // using `this` in this context is weird
57-
this.emit('end');
58-
/* jshint ignore:end */
59-
}
60-
61-
var testMocha = function() {
62-
return gulp.src(tests).pipe(new mocha({
63-
reporter: 'spec'
64-
}));
65-
};
66-
67-
var testKarma = shell.task([
68-
'./node_modules/karma/bin/karma start'
69-
]);
70-
71-
/**
72-
* Testing
73-
*/
74-
75-
gulp.task('test:node', testMocha);
76-
77-
gulp.task('test:node:nofail', function() {
78-
return testMocha().on('error', ignoreError);
79-
});
80-
81-
gulp.task('test:browser', ['browser:uncompressed', 'browser:maketests'], testKarma);
82-
83-
gulp.task('test', function(callback) {
84-
runSequence(['test:node'], ['test:browser'], callback);
85-
});
86-
87-
/**
88-
* File generation
89-
*/
90-
91-
gulp.task('browser:makefolder', shell.task([
92-
'if [ ! -d "browser" ]; then mkdir browser; fi'
93-
]));
94-
95-
gulp.task('browser:uncompressed', ['browser:makefolder'], shell.task([
96-
'./node_modules/.bin/browserify index.js --insert-global-vars=true --standalone=bitcore -o browser/bitcore.js'
97-
]));
98-
99-
gulp.task('browser:compressed', ['browser:uncompressed'], function() {
100-
return gulp.src('browser/bitcore.js')
101-
.pipe(uglify({
102-
mangle: true,
103-
compress: true
104-
}))
105-
.pipe(rename('bitcore.min.js'))
106-
.pipe(gulp.dest('browser'))
107-
.on('error', gutil.log);
108-
});
109-
110-
gulp.task('browser:maketests', ['browser:makefolder'], shell.task([
111-
'find test/ -type f -name "*.js" | xargs ./node_modules/.bin/browserify -t brfs -o browser/tests.js'
112-
]));
113-
114-
gulp.task('browser', function(callback) {
115-
runSequence(['browser:compressed'], ['browser:maketests'], callback);
116-
});
117-
118-
/**
119-
* Code quality and documentation
120-
*/
121-
122-
gulp.task('lint', function() {
123-
return gulp.src(alljs)
124-
.pipe(jshint())
125-
.pipe(jshint.reporter('default'));
126-
});
127-
128-
gulp.task('plato', shell.task(['plato -d report -r -l .jshintrc -t bitcore lib']));
129-
130-
gulp.task('jsdoc', function() {
131-
132-
function jsdoc() {
133-
return through.obj(function(file, enc, cb) {
134-
135-
if (file.isNull()) {
136-
cb(null, file);
137-
return;
138-
}
139-
if (file.isStream()) {
140-
cb(new gutil.PluginError('gulp-jsdoc2md', 'Streaming not supported'));
141-
return;
142-
}
143-
var destination = 'docs/api/' + file.path.replace(file.base, '').replace(/\.js$/, '.md');
144-
jsdoc2md.render(file.path, {})
145-
.on('error', function(err) {
146-
gutil.log(gutil.colors.red('jsdoc2md failed', err.message));
147-
})
148-
.pipe(mfs.writeStream(destination));
149-
cb(null, file);
150-
});
151-
}
152-
153-
return gulp.src(files).pipe(jsdoc());
154-
155-
});
156-
157-
gulp.task('coverage', shell.task(['node_modules/.bin/./istanbul cover node_modules/.bin/_mocha -- --recursive']));
158-
159-
gulp.task('coveralls', ['coverage'], function() {
160-
gulp.src('coverage/lcov.info').pipe(coveralls());
161-
});
162-
163-
/**
164-
* Watch tasks
165-
*/
166-
167-
gulp.task('watch:test', function() {
168-
// TODO: Only run tests that are linked to file changes by doing
169-
// something smart like reading through the require statements
170-
return gulp.watch(alljs, ['test']);
171-
});
172-
173-
gulp.task('watch:test:node', function() {
174-
// TODO: Only run tests that are linked to file changes by doing
175-
// something smart like reading through the require statements
176-
return gulp.watch(alljs, ['test:node']);
177-
});
178-
179-
gulp.task('watch:test:browser', function() {
180-
// TODO: Only run tests that are linked to file changes by doing
181-
// something smart like reading through the require statements
182-
return gulp.watch(alljs, ['test:browser']);
183-
});
184-
185-
gulp.task('watch:jsdoc', function() {
186-
// TODO: Only run tests that are linked to file changes by doing
187-
// something smart like reading through the require statements
188-
return gulp.watch(alljs, ['jsdoc']);
189-
});
190-
191-
gulp.task('watch:coverage', function() {
192-
// TODO: Only run tests that are linked to file changes by doing
193-
// something smart like reading through the require statements
194-
return gulp.watch(alljs, ['coverage']);
195-
});
196-
197-
gulp.task('watch:lint', function() {
198-
// TODO: Only lint files that are linked to file changes by doing
199-
// something smart like reading through the require statements
200-
return gulp.watch(alljs, ['lint']);
201-
});
202-
203-
gulp.task('watch:browser', function() {
204-
return gulp.watch(alljs, ['browser']);
205-
});
206-
207-
/**
208-
* Release automation
209-
*/
210-
211-
gulp.task('release:install', function() {
212-
return shell.task([
213-
'npm install',
214-
]);
215-
});
216-
217-
gulp.task('release:bump', function() {
218-
return gulp.src(['./bower.json', './package.json'])
219-
.pipe(bump({
220-
type: 'patch'
221-
}))
222-
.pipe(gulp.dest('./'));
223-
});
224-
225-
gulp.task('release:checkout-releases', function(cb) {
226-
git.checkout('releases', {
227-
args: ''
228-
}, cb);
229-
});
230-
231-
gulp.task('release:merge-master', function(cb) {
232-
git.merge('master', {
233-
args: ''
234-
}, cb);
235-
});
236-
237-
gulp.task('release:checkout-master', function(cb) {
238-
git.checkout('master', {
239-
args: ''
240-
}, cb);
241-
});
242-
243-
gulp.task('release:add-built-files', function() {
244-
return gulp.src(['./browser/bitcore.js', './browser/bitcore.min.js', './package.json', './bower.json'])
245-
.pipe(git.add({
246-
args: '-f'
247-
}));
248-
});
249-
250-
gulp.task('release:build-commit', ['release:add-built-files'], function() {
251-
var pjson = require('./package.json');
252-
return gulp.src(['./browser/bitcore.js', './browser/bitcore.min.js', './package.json', './bower.json'])
253-
.pipe(git.commit('Build: ' + pjson.version, {
254-
args: ''
255-
}));
256-
});
257-
258-
gulp.task('release:version-commit', function() {
259-
var pjson = require('./package.json');
260-
var files = ['./package.json', './bower.json'];
261-
return gulp.src(files)
262-
.pipe(git.commit('Bump package version to ' + pjson.version, {
263-
args: ''
264-
}));
265-
});
266-
267-
gulp.task('release:push-releases', function(cb) {
268-
git.push('bitpay', 'releases', {
269-
args: ''
270-
}, cb);
271-
});
272-
273-
gulp.task('release:push', function(cb) {
274-
git.push('bitpay', 'master', {
275-
args: ''
276-
}, cb);
277-
});
278-
279-
gulp.task('release:push-tag', function(cb) {
280-
var pjson = require('./package.json');
281-
var name = 'v' + pjson.version;
282-
git.tag(name, 'Release ' + name, function() {
283-
git.push('bitpay', name, cb);
284-
});
285-
});
286-
287-
gulp.task('release:publish', shell.task([
288-
'npm publish'
289-
]));
290-
291-
// requires https://hub.github.com/
292-
gulp.task('release', function(cb) {
293-
runSequence(
294-
// Checkout the `releases` branch
295-
['release:checkout-releases'],
296-
// Merge the master branch
297-
['release:merge-master'],
298-
// Run npm install
299-
['release:install'],
300-
// Build browser bundle
301-
['browser:compressed'],
302-
// Run tests with gulp test
303-
['test'],
304-
// Update package.json and bower.json
305-
['release:bump'],
306-
// Commit
307-
['release:build-commit'],
308-
// Run git push bitpay $VERSION
309-
['release:push-tag'],
310-
// Push to releases branch
311-
['release:push-releases'],
312-
// Run npm publish
313-
['release:publish'],
314-
// Checkout the `master` branch
315-
['release:checkout-master'],
316-
// Bump package.json and bower.json, again
317-
['release:bump'],
318-
// Version commit with no binary files to master
319-
['release:version-commit'],
320-
// Push to master
321-
['release:push'],
322-
cb);
323-
});
324-
325-
326-
/* Default task */
327-
gulp.task('default', function(callback) {
328-
return runSequence(['lint', 'jsdoc'], ['browser:uncompressed', 'test'], ['coverage', 'browser:compressed'],
329-
callback);
330-
});
5+
gulp_bitcore();

‎karma.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function(config) {
2323
},
2424
singleRun: true,
2525
files: [
26-
'browser/tests.js'
26+
'tests.js'
2727
],
2828
plugins: [
2929
'karma-mocha',

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"lint": "gulp lint",
99
"test": "gulp test",
1010
"coverage": "gulp coverage",
11-
"build": "gulp",
12-
"postinstall": "node ./lib/errors/build.js"
11+
"build": "gulp"
1312
},
1413
"contributors": [
1514
{
@@ -92,6 +91,7 @@
9291
"chai": "~1.10.0",
9392
"closure-compiler-jar": "git://github.com/eordano/closure-compiler-jar.git",
9493
"gulp": "^3.8.10",
94+
"gulp-bitcore": "git://github.com/maraoz/gulp-bitcore.git",
9595
"gulp-bump": "^0.1.11",
9696
"gulp-closure-compiler": "^0.2.9",
9797
"gulp-coveralls": "^0.1.3",

0 commit comments

Comments
 (0)
Please sign in to comment.