-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.js
100 lines (87 loc) · 2.78 KB
/
run.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Node.js script to run the complete project.
// require('dotenv').config();
// Check if -dev flag is present
var isDev = process.argv.indexOf('-dev') > -1;
// Run Foundry deploy scripts
if (isDev) {
/*
Deploy the smart contracts to the local node.
- Run anvil local node
- Deploy the smart contracts
- Deploy
Run the following linux commands in sequence:
anvil
forge script script/DeployExchange.s.sol:DeployExchange --rpc-url local --broadcast -vv
forge script script/DeployTrade.s.sol:DeployTrade --rpc-url local --broadcast -vv
forge script script/DeployTokens.s.sol:DeployTokens --rpc-url local --broadcast -vv
*/
// Run the commands
var exec = require('child_process').exec;
var cmd_arr = [
'anvil',
'forge script script/DeployExchange.s.sol:DeployExchange --rpc-url local --broadcast -vv',
'forge script script/DeployTrade.s.sol:DeployTrade --rpc-url local --broadcast -vv',
'forge script script/DeployTokens.s.sol:DeployTokens --rpc-url local --broadcast -vv'
];
var cmd = cmd_arr.join(' && ');
console.log(cmd);
var child = exec(cmd, function(error, stdout, stderr) {
console.log(stdout);
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
} else {
// Check if the contracts are deployed to the mainnet. If not, deploy them.
// Check if envdata contains the mainnet addresses
//...
// Check wether contracts are deployed to the mainnet addresses
//...
// If not, deploy them
//...
}
// Run the ui
if (isDev){
// Run the ui in dev mode
// Go to the ui folder
// Execute the following commands:
// Run npm start
// Run the commands
var exec = require('child_process').exec;
var cmd_arr = [
'cd ui',
'npm start'
];
var cmd = cmd_arr.join(' && ');
console.log(cmd);
var child = exec(cmd, function(error, stdout, stderr) {
console.log(stdout);
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
} else {
// Run the ui in production mode
//...
}
// Run the backend api
if (isDev){
// Run the backend api
// Go to the "api" folder
// Execute the following commands:
// node server.js
// Run the commands
var exec = require('child_process').exec;
var cmd_arr = [
'cd api',
'node server.js'
];
var cmd = cmd_arr.join(' && ');
console.log(cmd);
var child = exec(cmd, function(error, stdout, stderr) {
console.log(stdout);
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
} else {
// Run the backend api in production mode
//...
}