Sync asset registry on build.

refs #37
This commit is contained in:
softsimon 2020-05-02 14:04:33 +07:00
parent 11b1d9bbd3
commit ac9e718ef1
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
3 changed files with 29 additions and 2 deletions

4
frontend/.gitignore vendored
View File

@ -44,3 +44,7 @@ testem.log
# System Files
.DS_Store
Thumbs.db
src/assets/assets.json
src/assets/assets.minimal.json
src/assets/asset.icons.json

View File

@ -21,8 +21,10 @@
"main": "index.ts",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --prod",
"start": "npm run sync-assets-dev && ng serve --proxy-config proxy.conf.json",
"build": "ng build --prod && npm run sync-assets",
"sync-assets": "node sync-asset-registry.js",
"sync-assets-dev": "node sync-asset-registry.js dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"

View File

@ -0,0 +1,21 @@
var https = require('https');
var fs = require('fs');
var PATH = 'dist/mempool/assets/';
if (process.argv[2] && process.argv[2] === 'dev') {
PATH = 'src/assets/';
}
function download(filename, url) {
var file = fs.createWriteStream(filename);
https.get(url, function(response) {
response.pipe(file);
});
}
console.log('Downloading assets');
download(PATH + 'assets.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.json');
console.log('Downloading assets minimal');
download(PATH + 'assets.minimal.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.minimal.json');
console.log('Downloading asset icons');
download(PATH + 'asset.icons.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/icons.json');