You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
2.6 KiB
114 lines
2.6 KiB
11 years ago
|
'use strict';
|
||
|
|
||
|
/*
|
||
|
*
|
||
|
* The key parameter 'pack'
|
||
|
* The supplied 'custom_prelude.js' file is needed for
|
||
|
* .load function of soop.
|
||
|
*/
|
||
|
|
||
|
var fs = require('fs');
|
||
|
var browserify = require('browserify');
|
||
|
var browserPack = require('browser-pack');
|
||
11 years ago
|
var program = require('commander');
|
||
11 years ago
|
|
||
11 years ago
|
// concat browser vendor files
|
||
|
var exec = require('child_process').exec;
|
||
|
var sys = require('sys');
|
||
|
var puts = function(error, stdout, stderr) {
|
||
|
if (error) console.log(error);
|
||
|
sys.puts(stdout);
|
||
|
sys.puts(stderr);
|
||
|
};
|
||
|
|
||
|
exec('cd browser; sh concat.sh', puts);
|
||
|
|
||
11 years ago
|
var list = function(val) {
|
||
|
return val.split(',');
|
||
|
};
|
||
|
|
||
|
program
|
||
|
.version('0.0.1')
|
||
|
.option('-a, --includeall', 'Include all submodules.')
|
||
|
.option('-s, --submodules <items>', 'Include the listed comma-separated submodules.', list)
|
||
|
.parse(process.argv);
|
||
|
|
||
|
if (!program.includeall && (!program.submodules || program.submodules.length === 0)) {
|
||
|
console.log('Must use either -s or -a option. For more info use the --help option');
|
||
|
process.exit(1);
|
||
|
}
|
||
11 years ago
|
|
||
|
var pack = function (params) {
|
||
11 years ago
|
var preludePath = 'node_modules/soop/example/custom_prelude.js';
|
||
11 years ago
|
params.raw = true;
|
||
|
params.sourceMapPrefix = '//#';
|
||
11 years ago
|
params.prelude = fs.readFileSync(preludePath, 'utf8');
|
||
|
params.preludePath = preludePath;
|
||
11 years ago
|
return browserPack(params);
|
||
|
};
|
||
|
|
||
|
var modules = [
|
||
|
'Address',
|
||
|
'Block',
|
||
|
'Bloom',
|
||
|
'Buffers.monkey',
|
||
11 years ago
|
'Connection',
|
||
11 years ago
|
'Deserialize',
|
||
|
'Gruntfile',
|
||
|
'Number.monkey',
|
||
|
'Opcode',
|
||
|
'Peer',
|
||
|
'PeerManager',
|
||
|
'PrivateKey',
|
||
|
'RpcClient',
|
||
11 years ago
|
'Key',
|
||
11 years ago
|
'SIN',
|
||
|
'SINKey',
|
||
|
'Script',
|
||
|
'ScriptInterpreter',
|
||
|
'Sign',
|
||
|
'Transaction',
|
||
|
'Wallet',
|
||
|
'WalletKey',
|
||
|
'config',
|
||
|
'const',
|
||
|
'networks',
|
||
|
];
|
||
|
|
||
11 years ago
|
var opts = {};
|
||
11 years ago
|
opts.pack = pack;
|
||
11 years ago
|
opts.debug = true;
|
||
|
opts.standalone = 'bitcore';
|
||
|
opts.insertGlobals = true;
|
||
|
|
||
11 years ago
|
var b = browserify(opts);
|
||
|
b.require('browserify-bignum/bignumber.js', {expose: 'bignum'} );
|
||
|
b.require('browserify-buffertools/buffertools.js', {expose:'buffertools'});
|
||
11 years ago
|
b.require('./bitcore', {expose: 'bitcore'});
|
||
11 years ago
|
b.require('base58-native');
|
||
|
b.require('./util/log');
|
||
|
b.require('./util/util');
|
||
|
b.require('./util/EncodedData');
|
||
|
b.require('./util/VersionedData');
|
||
|
modules.forEach(function(m) {
|
||
11 years ago
|
if (program.includeall || program.submodules.indexOf(m) > -1) {
|
||
|
console.log('Including '+m+' in the browser bundle');
|
||
|
b.require('./' + m + '.js' , {expose: './'+m} );
|
||
|
}
|
||
11 years ago
|
});
|
||
|
b.require('soop');
|
||
|
|
||
|
b.bundle().pipe(fs.createWriteStream('browser/bundle.js'));
|
||
|
|
||
|
|
||
|
opts.standalone = 'testdata';
|
||
|
var tb = browserify(opts);
|
||
|
tb.require('./test/testdata', {expose: 'testdata'});
|
||
|
tb.transform('brfs');
|
||
11 years ago
|
|
||
11 years ago
|
tb.bundle().pipe(fs.createWriteStream('browser/testdata.js'));
|
||
11 years ago
|
|
||
|
|
||
|
|
||
|
|