Browse Source

Removed babel and gulp.

master
Emilio Almansi 7 years ago
parent
commit
21de53de46
  1. 3
      .gitignore
  2. 2
      LICENSE
  3. 13
      LICENSE.js
  4. 61917
      dist/bitcoincash-0.1.9.js
  5. 14
      dist/bitcoincash-0.1.9.min.js
  6. 1
      dist/bitcoincashjs.0.1.9.min.js
  7. 125
      gulpfile.js
  8. 2
      karma.conf.js
  9. 3778
      package-lock.json
  10. 40
      package.json
  11. 18
      scripts/build-tests.js
  12. 23
      scripts/build.js
  13. 13
      scripts/lint.js
  14. 17
      src/address.js
  15. 4
      src/bitcoincash.js
  16. 2
      test/index.html

3
.gitignore

@ -15,6 +15,5 @@ bower_components
report
.DS_Store
build/
.build/
.nyc_output/
lib/

2
LICENSE

@ -1,4 +1,4 @@
Copyright (c) 2017 Emilio Almansi
Copyright (c) 2017-2018 Emilio Almansi
Parts of this software are based on bitcore-lib
Copyright (c) 2013-2017 BitPay, Inc.

13
LICENSE.js

@ -0,0 +1,13 @@
/**
* @license
* https://github.com/bitcoincashjs/bitcoincashjs
* Copyright (c) 2017-2018 Emilio Almansi
* Copyright (c) 2013-2017 BitPay, Inc.
* Copyright (c) 2009-2015 The Bitcoin Core developers
* Copyright (c) 2014 Ryan X. Charles
* Copyright (c) 2014 reddit, Inc.
* Copyright (c) 2011 Stefan Thomas <justmoon@members.fsf.org>
* Copyright (c) 2011 Google Inc.
* Distributed under the MIT software license, see the accompanying
* file LICENSE or http://www.opensource.org/licenses/mit-license.php.
*/

61917
dist/bitcoincash-0.1.9.js

File diff suppressed because one or more lines are too long

14
dist/bitcoincash-0.1.9.min.js

File diff suppressed because one or more lines are too long

1
dist/bitcoincashjs.0.1.9.min.js

File diff suppressed because one or more lines are too long

125
gulpfile.js

@ -1,125 +0,0 @@
/**
* @file gulpfile.js
*
* Defines tasks that can be run on gulp.
*
* Summary:
* <ul>
* <li> `test` - an alias for `test:node`
* <li> `test:node` - runs all the tests on node (mocha)
* <li> `test:browser` - runs all the tests in the browser (karma)
* <li> `build` - generate files needed for browser (browserify)
* <li> `build:test` - generate files needed for testing in the browser
* <li> `lint` - run `jshint`
* <li> `coveralls` - updates coveralls info
* </ul>
*/
'use strict';
const gulp = require('gulp');
const shell = require('gulp-shell');
const npmPackage = require('./package.json');
gulp.task(
'build',
['build:node', 'build:browser']
);
gulp.task(
'build:node',
shell.task([[
'rm -rf lib', '&&',
'mkdir -p lib', '&&',
'npx babel-cli src --out-dir lib',
].join(' ')])
);
gulp.task(
'build:browser',
['build:node'],
shell.task([[
'rm -rf dist', '&&',
'mkdir -p dist', '&&',
'npx browserify lib/bitcoincash.js --s bch', '|',
`npx minify --out-file dist/bitcoincashjs.${npmPackage.version}.min.js`,
].join(' ')])
);
gulp.task(
'build:test',
['build:node'],
shell.task([[
'rm -rf build', '&&',
'mkdir -p build', '&&',
'find test/ -type f -name "*.js" | xargs npx browserify -t brfs -o build/tests.js'
].join(' ')])
);
gulp.task(
'test',
['test:node']
);
gulp.task(
'test:all',
['test:node', 'test:browser']
);
gulp.task(
'test:node',
['build:node'],
shell.task([
`npx nyc --reporter=html --reporter=text npx mocha ${getTaskArgs()}`,
])
);
gulp.task(
'test:browser',
['build:test'],
shell.task([
'npx karma start',
])
);
gulp.task(
'lint',
shell.task([
'find gulpfile.js src/ test/ -type f -name "*.js" | xargs npx jshint',
])
);
gulp.task(
'coveralls',
shell.task([
'npx nyc report --reporter=text-lcov | npx coveralls',
])
);
gulp.task(
'version',
['build'],
shell.task([[
'npx mustache package.json README.tpl.md > README.md', '&&',
'git add -A dist README.md',
].join(' ')])
);
gulp.task(
'postversion',
shell.task([[
'git push', '&&',
'git push --tags', '&&',
'npm publish',
].join(' ')])
);
function getTaskArgs() {
if (process.argv.length < 4) {
return '';
}
const args = process.argv.splice(3);
const argsWithQuotes = args.map(a => a.indexOf(' ') !== -1 ? `"${a}"` : a);
return argsWithQuotes.join(' ');
}

2
karma.conf.js

@ -23,7 +23,7 @@ module.exports = function(config) {
},
singleRun: true,
files: [
'build/tests.js'
'.build/tests.js'
],
plugins: [
'karma-mocha',

3778
package-lock.json

File diff suppressed because it is too large

40
package.json

@ -3,25 +3,24 @@
"version": "0.1.9",
"description": "A simple, safe, and powerful JavaScript Bitcoin Cash library.",
"author": "Emilio Almansi <hi@ealmansi.com>",
"main": "lib/bitcoincash.js",
"main": "src/bitcoincash.js",
"files": [
"lib/",
"src/",
"dist/"
],
"scripts": {
"build": "npm install && npx gulp build",
"build:node": "npm install && npx gulp build:node",
"build:browser": "npm install && npx gulp build:browser",
"build:test": "npm install && npx gulp build:test",
"test": "npm install && npx gulp test",
"test:all": "npm install && npx gulp test:all",
"test:node": "npm install && npx gulp test:node",
"test:browser": "npm install && npx gulp test:browser",
"lint": "npm install && npx gulp lint",
"coveralls": "npm install && npx gulp coveralls",
"preversion": "npm install && npm test",
"version": "npm install && npx gulp version",
"postversion": "npm install && npx gulp postversion",
"build": "node scripts/build.js",
"build:tests": "node scripts/build-tests.js",
"test": "npm run test:node",
"test:all": "npm run test:node && npm run test:browser",
"test:node": "nyc --reporter=html --reporter=text mocha",
"test:browser": "npm run build:tests && karma start",
"lint": "node scripts/lint.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"preversion": "npm test",
"readme": "mustache package.json README.tpl.md > README.md",
"version": "npm run build && npm run readme && git add -A dist README.md",
"postversion": "git push && git push --tags && npm publish",
"bump": "npm version patch -m 'Bump version to %s.'"
},
"keywords": [
@ -52,24 +51,17 @@
"bn.js": "=2.0.4",
"bs58": "=2.0.0",
"buffer-compare": "=1.0.0",
"cashaddrjs": "^0.1.4",
"cashaddrjs": "^0.2.8",
"elliptic": "=3.0.3",
"inherits": "=2.0.1",
"lodash": "^4.17.4",
"unorm": "^1.4.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-minify": "^0.2.0",
"babel-preset-env": "^1.6.1",
"babelify": "^8.0.0",
"brfs": "^1.4.3",
"browserify": "^14.5.0",
"chai": "^1.10.0",
"coveralls": "^3.0.0",
"gulp": "^3.8.10",
"gulp-shell": "^0.6.5",
"jsdoc": "^3.5.5",
"jshint": "^2.9.5",
"karma": "^2.0.0",
@ -80,7 +72,7 @@
"mocha": "^4.1.0",
"mustache": "^2.3.0",
"nyc": "^11.4.1",
"run-sequence": "^2.2.0",
"shelljs": "^0.8.0",
"sinon": "^1.13.0",
"uglify-js": "^3.3.4"
},

18
scripts/build-tests.js

@ -0,0 +1,18 @@
/**
* @license
* https://github.com/bitcoincashjs/bitcoincashjs
* Copyright (c) 2018 Emilio Almansi
* Distributed under the MIT software license, see the accompanying
* file LICENSE or http://www.opensource.org/licenses/mit-license.php.
*/
var shell = require('shelljs')
shell.config.fatal = true
shell.rm('-rf', '.build')
shell.mkdir('-p', '.build')
shell.exec('find test/ -type f -name "*.js"', { silent: true })
.exec('xargs npx browserify -t brfs', { silent: true })
.to('.build/tests.js')
shell.echo('Generated file: .build/tests.js.')

23
scripts/build.js

@ -0,0 +1,23 @@
/**
* @license
* https://github.com/bitcoincashjs/bitcoincashjs
* Copyright (c) 2018 Emilio Almansi
* Distributed under the MIT software license, see the accompanying
* file LICENSE or http://www.opensource.org/licenses/mit-license.php.
*/
var shell = require('shelljs')
shell.config.fatal = true
var version = require('../package.json').version
shell.rm('-rf', 'dist')
shell.mkdir('-p', 'dist')
shell.exec('npx browserify src/bitcoincash.js --s bch', { silent: true })
.to('dist/bitcoincash-' + version + '.js')
shell.echo('Generated file: dist/bitcoincash-' + version + '.js.')
shell.cp('LICENSE.js', 'dist/bitcoincash-' + version + '.min.js')
shell.exec('cat dist/bitcoincash-' + version + '.js | npx uglifyjs -c', { silent: true })
.toEnd('dist/bitcoincash-' + version + '.min.js')
shell.echo('Generated file: dist/bitcoincash-' + version + '.min.js.')

13
scripts/lint.js

@ -0,0 +1,13 @@
/**
* @license
* https://github.com/bitcoincashjs/bitcoincashjs
* Copyright (c) 2018 Emilio Almansi
* Distributed under the MIT software license, see the accompanying
* file LICENSE or http://www.opensource.org/licenses/mit-license.php.
*/
var shell = require('shelljs')
shell.config.fatal = false
shell.exec('find src/ test/ scripts/ -type f -name "*.js"', { silent: true })
.exec('xargs npx jshint')

17
src/address.js

@ -10,8 +10,8 @@ var Hash = require('./crypto/hash');
var JSUtil = require('./util/js');
var PublicKey = require('./publickey');
const BITPAY_P2PKH_VERSION_BYTE = 28;
const BITPAY_P2SH_VERSION_BYTE = 40;
var BITPAY_P2PKH_VERSION_BYTE = 28;
var BITPAY_P2SH_VERSION_BYTE = 40;
/**
* Instantiate an address from an address String or Buffer, a public key or script hash Buffer,
@ -312,7 +312,7 @@ Address._transformString = function(data, network, type, format) {
* @private
*/
Address._transformStringLegacy = function(data, network, type) {
const addressBuffer = Base58Check.decode(data);
var addressBuffer = Base58Check.decode(data);
return Address._transformBuffer(addressBuffer, network, type);
};
@ -326,7 +326,7 @@ Address._transformStringLegacy = function(data, network, type) {
* @private
*/
Address._transformStringBitpay = function(data, network, type) {
const addressBuffer = Base58Check.decode(data);
var addressBuffer = Base58Check.decode(data);
if (addressBuffer[0] === BITPAY_P2PKH_VERSION_BYTE) {
addressBuffer[0] = 0;
}
@ -604,7 +604,7 @@ Address.prototype._toStringLegacy = function() {
* @returns {string} Bitcoin address
*/
Address.prototype._toStringBitpay = function() {
let buffer = this.toBuffer();
var buffer = this.toBuffer();
if (this.network.toString() === 'livenet') {
if (this.type === Address.PayToPublicKeyHash) {
buffer[0] = BITPAY_P2PKH_VERSION_BYTE;
@ -622,10 +622,9 @@ Address.prototype._toStringBitpay = function() {
* @returns {string} Bitcoin address
*/
Address.prototype._toStringCashAddr = function() {
const prefix = this.network.toString() === 'livenet' ? 'bitcoincash' : 'bchtest';
const type = this.type === Address.PayToPublicKeyHash ? 'P2PKH' : 'P2SH';
const hash = [...this.hashBuffer];
return cashaddr.encode(prefix, type, hash);
var prefix = this.network.toString() === 'livenet' ? 'bitcoincash' : 'bchtest';
var type = this.type === Address.PayToPublicKeyHash ? 'P2PKH' : 'P2SH';
return cashaddr.encode(prefix, type, this.hashBuffer);
}
/**

4
src/bitcoincash.js

@ -1,12 +1,12 @@
'use strict';
const bch = module.exports;
var bch = module.exports;
// module information
bch.version = 'v' + require('../package.json').version;
bch.versionGuard = function(version) {
if (version !== undefined) {
const message = 'More than one instance of bitcoincashjs found. ' +
var message = 'More than one instance of bitcoincashjs found. ' +
'Please make sure to require bitcoincashjs and check that submodules do' +
' not also include their own bitcoincashjs dependency.';
throw new Error(message);

2
test/index.html

@ -10,7 +10,7 @@
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="../build/tests.js"></script>
<script src="../.build/tests.js"></script>
<script>
mocha.run();
</script>

Loading…
Cancel
Save