forked from daostack/arc.js_legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-scripts.js
173 lines (163 loc) · 6.54 KB
/
package-scripts.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* eslint-disable quotes */
const fs = require("fs");
const {
series,
rimraf,
copy,
mkdirp
} = require("nps-utils");
const env = require("env-variable")();
const joinPath = require("path.join");
const cwd = require("cwd")();
const Config = require("./config/default.json");
/**
* environment variables you can use to configure stuff like migrateContracts
*/
const pathArcJsRoot = env.pathArcJsRoot || cwd;
const pathArcJsContracts =
env.pathArcJsContracts || joinPath(pathArcJsRoot, "migrated_contracts");
const pathDaostackArcRepo =
env.pathDaostackArcRepo ||
joinPath(pathArcJsRoot, "node_modules/@daostack/arc");
const pathArcTest =
env.pathArcTest ||
joinPath(pathArcJsRoot, "test");
const pathArcTestBuild =
env.pathArcTestBuild ||
joinPath(pathArcJsRoot, "test-dist");
const pathDaostackArcGanacheDb = joinPath(pathArcJsRoot, "ganacheDb");
const pathDaostackArcGanacheDbZip = joinPath(pathArcJsRoot, "ganacheDb.zip");
const network = env.network || Config.network || "ganache";
// this is needed to force travis to use our modified version of truffle
const truffleIsInternal = fs.existsSync(joinPath(pathArcJsRoot, "node_modules", "truffle-core-migrate-without-compile"));
const truffleCommand = `node ${joinPath(pathArcJsRoot, truffleIsInternal ? "node_modules" : "../../", "truffle-core-migrate-without-compile", "cli")}`;
const ganacheCommand = `ganache-cli -l ${Config.gasLimit_deployment} --account="0x8d4408014d165ec69d8cc9f091d8f4578ac5564f376f21887e98a6d33a6e3549,9999999999999999999999999999999999999999999" --account="0x2215f0a41dd3bb93f03049514949aaafcf136e6965f4a066d6bf42cc9f75a106,9999999999999999999999999999999999999999999" --account="0x6695c8ef58fecfc7410bf8b80c17319eaaca8b9481cc9c682fd5da116f20ef05,9999999999999999999999999999999999999999999" --account="0xb9a8635b40a60ad5b78706d4ede244ddf934dc873262449b473076de0c1e2959,9999999999999999999999999999999999999999999" --account="0x55887c2c6107237ac3b50fb17d9ff7313cad67757e44d1be5eb7bbf9fc9ca2ea,9999999999999999999999999999999999999999999" --account="0xb16a587ad59c2b3a3f47679ed2df348d6828a3bb5c6bb3797a1d5a567ce823cb,9999999999999999999999999999999999999999999"`;
const ganacheDbCommand = `ganache-cli --db ${pathDaostackArcGanacheDb} -l ${Config.gasLimit_deployment} --networkId 1512051714758 --mnemonic "behave pipe turkey animal voyage dial relief menu blush match jeans general"`;
module.exports = {
scripts: {
lint: {
default: series(
"nps lint.ts",
"nps lint.js"
),
ts: {
default: "tslint lib/**/* custom_typings/system.d.ts index.d.ts",
andFix: "nps \"lint.ts --fix\""
},
js: {
default: "eslint .",
andFix: "nps \"lint.js --fix\""
},
andFix: series(
"nps lint.ts.andFix",
"nps lint.js.andFix"
)
},
test: {
default: series("nps lint", "nps test.automated"),
automated: {
default: series(
"nps test.build",
"mocha --require babel-register --require babel-polyfill --require chai --timeout 999999"),
bail: series(
'nps "test.automated --bail"'
),
},
watch: series(
'nps "test.automated --watch"'
),
bail: (
'nps test.automated.bail'
),
ganache: {
run: ganacheCommand,
},
ganacheDb: {
run: series(
mkdirp(pathDaostackArcGanacheDb),
ganacheDbCommand,
),
clean: rimraf(pathDaostackArcGanacheDb),
zip: `node ./package-scripts/archiveGanacheDb.js ${pathDaostackArcGanacheDbZip} ${pathDaostackArcGanacheDb}`,
unzip: series(
"nps test.ganacheDb.clean",
`node ./package-scripts/unArchiveGanacheDb.js ${pathDaostackArcGanacheDbZip} ${pathArcJsRoot}`
),
restoreFromZip: series(
"nps test.ganacheDb.clean",
"nps test.ganacheDb.unzip"
)
},
build: {
default: series(
"nps test.build.clean",
mkdirp(pathArcTestBuild),
`node node_modules/typescript/bin/tsc --outDir ${pathArcTestBuild} --project ${pathArcTest}`
),
clean: rimraf(joinPath(pathArcTestBuild, "*"))
},
},
build: {
default: series(
"nps build.clean",
mkdirp(joinPath(pathArcJsRoot, "dist")),
`node node_modules/typescript/bin/tsc --outDir ${joinPath(pathArcJsRoot, "dist")}`
),
clean: rimraf(joinPath(pathArcJsRoot, "dist"))
},
deploy: {
pack: series("nps build", "npm pack"),
publish: series("nps build", "npm publish")
},
/**
* See README.md for how to use these scripts in a workflow to migrate contracts
*/
migrateContracts: {
/**
* Migrate contracts.
*
* Truffle will merge this migration with whatever previous ones are already present in the contract json files.
*
* Run migrateContracts.fetchFromArc first if you want to start with fresh unmigrated contracts from @daostack/arc.
*/
default: series(
`nps build`,
`${truffleCommand} migrate --contracts_build_directory ${pathArcJsContracts} --without-compile --network ${network}`
),
/**
* Clean the outputted contract json files, optionally andMigrate.
*
* IMPORTANT! Only do this if you aren't worried about losing
* previously-performed migrations to other networks. By cleaning, you'll lose them, starting
* from scratch. Otherwise, truffle will merge your migrations into whatever previous
* ones exist.
*/
clean: {
default: rimraf(joinPath(pathArcJsContracts, "*")),
/**
* clean and fetch.
* Run this ONLY when you want to start with fresh UNMIGRATED contracts from @daostack/arc.
*/
andFetchFromArc: series(
"nps migrateContracts.clean",
"nps migrateContracts.fetchFromArc"
),
/**
* clean, fetch and migrate.
* Run this ONLY when you want to start with fresh UNMIGRATED contracts from @daostack/arc.
*/
andMigrate: series(
"nps migrateContracts.clean.andFetchFromArc",
"nps migrateContracts"
)
},
/**
* Fetch the unmigrated contract json files from DAOstack Arc.
* Run this ONLY when you want to start with fresh UNMIGRATED contracts from DAOstack Arc.
* Best to run "migrateContracts.clean" first.
*/
fetchFromArc: copy(`${joinPath(pathDaostackArcRepo, "build", "contracts", "*")} ${pathArcJsContracts}`)
},
"docs": "node ./package-scripts/docs/createMarkdown.js"
}
};