forked from EdgeApp/edge-react-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy-plugin.js
More file actions
79 lines (71 loc) · 2.4 KB
/
copy-plugin.js
File metadata and controls
79 lines (71 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* eslint-disable flowtype/require-valid-file-annotation */
const fs = require('fs')
const path = require('path')
const { plugins } = require('./package.json')
const pluginsFile = './src/assets/plugins.json'
const androidDir = './android/app/src/main/assets/plugins/'
const iosDir = './ios/plugins/'
const platforms = [androidDir, iosDir]
const pluginManifests = {
buysell: [
{
pluginId: 'com.libertyx',
pluginURL: 'https://libertyx.com/a/',
name: 'LibertyX',
subtitle: 'Buy Bitcoin with cash at US merchants\nBTC\nFee: 3-8% / Settlement: Instant',
provider: 'Edge Wallet',
iconUrl: 'https://edge.app/wp-content/uploads/2019/05/libertyXlogo.png',
environment: {},
permissions: ['location'],
lockDomain: true
},
{
pluginId: 'io.moonpay.buy',
pluginURL: 'https://buy.moonpay.io?apiKey=pk_live_Y1vQHUgfppB4oMEZksB8DYNQAdA4sauy',
name: 'MoonPay',
subtitle: 'Buy crypto with credit card or Apple Pay\nBTC, ETH, XRP, LTC, BCH\nFee: 5.5% / Settlement: 10 mins',
provider: 'Edge Wallet',
iconUrl: 'https://edge.app/wp-content/uploads/2019/05/icon_black_small.png',
environment: {}
},
{
pluginId: 'io.safello',
pluginURL: 'https://safello.com/edge/',
name: 'Safello',
subtitle: 'Buy crypto with credit card\nBTC, ETH, XRP, BCH\nFee: 5.75% / Settlement: Instant',
provider: 'Edge Wallet',
iconUrl: 'https://edge.app/wp-content/uploads/2019/06/Safello-Logo-Green-background.png',
environment: {}
}
],
spend: []
}
platforms.forEach(platform => {
if (!fs.existsSync(platform)) {
fs.mkdirSync(platform)
}
})
function copyAssets (plugin) {
const manifest = require(`./node_modules/${plugin}/manifest.json`)
platforms.forEach(platformDir => {
const pluginDir = path.join(platformDir, manifest.pluginId)
if (!fs.existsSync(pluginDir)) {
fs.mkdirSync(pluginDir)
}
fs.copyFile(`./node_modules/${plugin}/target/index.html`, `${pluginDir}/index.html`, () => {})
})
return manifest
}
if (plugins.buysell) {
plugins.buysell.forEach(function (plugin) {
const manifest = copyAssets(plugin)
pluginManifests.buysell.push(manifest)
})
}
if (plugins.spend) {
plugins.spend.forEach(function (plugin) {
const manifest = copyAssets(plugin)
pluginManifests.spend.push(manifest)
})
}
fs.writeFileSync(pluginsFile, JSON.stringify(pluginManifests, null, 2))