forked from airgap-it/airgap-vault
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy-builtin-modules.js
More file actions
81 lines (72 loc) · 1.98 KB
/
copy-builtin-modules.js
File metadata and controls
81 lines (72 loc) · 1.98 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
80
81
const fs = require('fs')
const path = require('path')
const browserify = require('browserify')
const rootdir = './'
const assetsdir = path.join(rootdir, 'src/assets')
const modules = [
{ path: path.join(rootdir, 'node_modules/@airgap/aeternity') },
{
path: path.join(rootdir, 'node_modules/@airgap/astar'),
jsenv: {
android: 'webview'
}
},
{ path: path.join(rootdir, 'node_modules/@airgap/bitcoin') },
{ path: path.join(rootdir, 'node_modules/@airgap/cosmos') },
{
path: path.join(rootdir, 'node_modules/@airgap/ethereum'),
jsenv: {
android: 'webview'
}
},
{ path: path.join(rootdir, 'node_modules/@airgap/groestlcoin') },
{
path: path.join(rootdir, 'node_modules/@airgap/icp'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/moonbeam'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/polkadot'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/tezos'),
jsenv: {
android: 'webview'
}
}
]
function createAssetModule(module) {
const packageJson = require(`./${path.join(module.path, 'package.json')}`)
const namespace = module.path.split('/').slice(-1)[0]
const outputDir = path.join(assetsdir, `protocol_modules/${namespace}`)
const outputFile = 'index.browserify.js'
fs.mkdirSync(outputDir, { recursive: true })
browserify(`${module.path}/v1/module.js`, { standalone: namespace })
.bundle()
.pipe(fs.createWriteStream(path.join(outputDir, outputFile)))
const manifest = {
name: packageJson.name,
version: packageJson.version,
author: packageJson.author,
signature: "" /* TODO */,
src: {
namespace
},
include: [
outputFile
],
jsenv: module.jsenv
}
fs.writeFileSync(path.join(outputDir, 'manifest.json'), JSON.stringify(manifest, null, 2), 'utf8')
}
modules.forEach((path) => createAssetModule(path))