-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathdeployAutoTasks.js
More file actions
68 lines (60 loc) · 2.14 KB
/
Copy pathdeployAutoTasks.js
File metadata and controls
68 lines (60 loc) · 2.14 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
const {findEnvLocal} = require("@goldfinch-eng/utils")
require("dotenv").config({path: findEnvLocal()})
const resolve = require("@rollup/plugin-node-resolve").default
const commonjs = require("@rollup/plugin-commonjs")
const json = require("@rollup/plugin-json")
const builtins = require("builtin-modules")
const typescript = require("@rollup/plugin-typescript")
const rollup = require("rollup")
const {AutotaskClient} = require("defender-autotask-client")
async function buildAndDeploy(id, name, dir, autoTaskClient) {
let dirToUpload = `./${dir}/`
const inputOptions = {
input: `./${dir}/index.ts`,
plugins: [
resolve({preferBuiltins: true}),
commonjs(),
json({compact: true}),
typescript({
tsconfig: "./tsconfig.build.json",
sourceMap: true,
}),
],
external: [...builtins, "ethers", "web3", "axios", /^defender-relay-client(\/.*)?$/],
}
const outputOptions = {
sourcemap: true,
file: `./${dir}/dist/index.js`,
format: "cjs",
}
const bundle = await rollup.rollup(inputOptions)
await bundle.write(outputOptions)
await bundle.close()
dirToUpload = `./${dir}/dist/`
console.log(`Rolled up ${name}`)
console.log(`Updating ${name} (${id}) from ${dirToUpload}`)
await autoTaskClient.updateCodeFromFolder(id, dirToUpload)
console.log(`Finished updating ${name}`)
}
;(async () => {
const builds = [
{id: "98e14e44-4137-4f25-9560-984c000445c6", name: "MainnetAssessor", dir: "assessor"},
{id: "bc31d6f7-0ab4-4170-9ba0-4978a6ed6034", name: "Mainnet Unique Identity Signer", dir: "unique-identity-signer"},
{id: "6ba87b47-341d-4b0a-a8b8-02bc04f978f7", name: "SeniorPoolRedeem", dir: "senior-pool-redeemer"},
{id: "98012bea-fae5-40c2-bebe-c36c3536a5f1", name: "Mainnet Reserve Distributor", dir: "reserve-distributor"},
]
const autotaskClient = new AutotaskClient({
apiKey: process.env.AUTOTASK_API_KEY,
apiSecret: process.env.AUTOTASK_API_SECRET,
})
for (const item of builds) {
await buildAndDeploy(item.id, item.name, item.dir, autotaskClient)
}
})()
.then(() => {
process.exit(0)
})
.catch((e) => {
console.log(e)
process.exit(1)
})