Added a build runner in line with starting the service.
This commit is contained in:
parent
e94154ba4b
commit
7903a255aa
@ -3,15 +3,13 @@
|
|||||||
var BaseService = require('./service');
|
var BaseService = require('./service');
|
||||||
var inherits = require('util').inherits;
|
var inherits = require('util').inherits;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var pkg = require('../package');
|
var exec = require('child_process').exec;
|
||||||
|
var pkg = require('../package.json');
|
||||||
|
|
||||||
var InsightUI = function(options) {
|
var InsightUI = function(options) {
|
||||||
BaseService.call(this, options);
|
BaseService.call(this, options);
|
||||||
// we don't use the options object for routePrefix and apiPrefix, since the
|
this.apiPrefix = options.apiPrefix || 'api';
|
||||||
// client must be rebuilt with the proper options. A future version of
|
this.routePrefix = options.routePrefix || '';
|
||||||
// Bitcore should allow for a service "build" step to make this better.
|
|
||||||
this.apiPrefix = pkg.insightConfig.apiPrefix;
|
|
||||||
this.routePrefix = pkg.insightConfig.routePrefix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
InsightUI.dependencies = ['insight-api'];
|
InsightUI.dependencies = ['insight-api'];
|
||||||
@ -19,8 +17,21 @@ InsightUI.dependencies = ['insight-api'];
|
|||||||
inherits(InsightUI, BaseService);
|
inherits(InsightUI, BaseService);
|
||||||
|
|
||||||
InsightUI.prototype.start = function(callback) {
|
InsightUI.prototype.start = function(callback) {
|
||||||
this.indexFile = this.filterIndexHTML(fs.readFileSync(__dirname + '/../public/index-template.html', {encoding: 'utf8'}));
|
|
||||||
setImmediate(callback);
|
var self = this;
|
||||||
|
pkg.insightConfig.apiPrefix = self.apiPrefix;
|
||||||
|
pkg.insightConfig.routePrefix = self.routePrefix;
|
||||||
|
|
||||||
|
fs.writeFileSync(__dirname + '/../package.json', JSON.stringify(pkg, null, 2));
|
||||||
|
exec('pushd ' + __dirname + '/../;' +
|
||||||
|
' npm run install-and-build; popd', function(err) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
self.indexFile = self.filterIndexHTML(fs.readFileSync(__dirname + '/../public/index-template.html', {encoding: 'utf8'}));
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
InsightUI.prototype.getRoutePrefix = function() {
|
InsightUI.prototype.getRoutePrefix = function() {
|
||||||
@ -31,7 +42,7 @@ InsightUI.prototype.setupRoutes = function(app, express) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
app.use(express.static(__dirname + '/../public'));
|
app.use(express.static(__dirname + '/../public'));
|
||||||
// if not in found, fall back to indexFile (404 is handled client-side)
|
// if not in found, fall back to indexFile (404 is handled client-side)
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html');
|
res.setHeader('Content-Type', 'text/html');
|
||||||
res.send(self.indexFile);
|
res.send(self.indexFile);
|
||||||
});
|
});
|
||||||
|
|||||||
34
package-lock.json
generated
34
package-lock.json
generated
@ -1,9 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "insight-ui",
|
"name": "insight-ui",
|
||||||
"version": "5.0.0-beta.1",
|
"version": "5.0.0-beta.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"CSSselect": {
|
||||||
|
"version": "0.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/CSSselect/-/CSSselect-0.4.1.tgz",
|
||||||
|
"integrity": "sha1-+Kt+H4QYzmPNput713ioXX7EkrI=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"CSSwhat": "0.4.7",
|
||||||
|
"domutils": "1.4.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CSSwhat": {
|
||||||
|
"version": "0.4.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz",
|
||||||
|
"integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"abbrev": {
|
"abbrev": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
|
||||||
@ -303,22 +319,6 @@
|
|||||||
"integrity": "sha1-xBuptrn+x3vKhxEuces6Ig71m8Q=",
|
"integrity": "sha1-xBuptrn+x3vKhxEuces6Ig71m8Q=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"CSSselect": {
|
|
||||||
"version": "0.4.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/CSSselect/-/CSSselect-0.4.1.tgz",
|
|
||||||
"integrity": "sha1-+Kt+H4QYzmPNput713ioXX7EkrI=",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"CSSwhat": "0.4.7",
|
|
||||||
"domutils": "1.4.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CSSwhat": {
|
|
||||||
"version": "0.4.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz",
|
|
||||||
"integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"dateformat": {
|
"dateformat": {
|
||||||
"version": "1.0.2-1.2.3",
|
"version": "1.0.2-1.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "insight-ui",
|
"name": "insight-ui",
|
||||||
"description": "An open-source frontend for the Insight API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.",
|
"description": "An open-source frontend for the Insight API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.",
|
||||||
"version": "5.0.0-beta.1",
|
"version": "5.0.0-beta.12",
|
||||||
"repository": "git://github.com/bitpay/insight-ui.git",
|
"repository": "git://github.com/bitpay/insight-ui.git",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/bitpay/insight-ui/issues"
|
"url": "https://github.com/bitpay/insight-ui/issues"
|
||||||
@ -18,12 +18,13 @@
|
|||||||
],
|
],
|
||||||
"bitcoreNode": "bitcore-node",
|
"bitcoreNode": "bitcore-node",
|
||||||
"insightConfig": {
|
"insightConfig": {
|
||||||
"apiPrefix": "insight-api",
|
"apiPrefix": "api",
|
||||||
"routePrefix": "insight"
|
"routePrefix": ""
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bower install && grunt compile",
|
"build": "bower install && grunt compile",
|
||||||
"watch": "grunt"
|
"watch": "grunt",
|
||||||
|
"install-and-build": "npm install && npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user