@@ -77,24 +77,22 @@ module.exports = {
77
77
return
78
78
}
79
79
80
+ let result = await fetch ( 'https://api.github.com/repos/LimeChain/matchstick/releases/latest' )
81
+ let json = await result . json ( )
82
+ let latest_version = json . tag_name
83
+
80
84
if ( docker_opt ) {
81
- runDocker ( coverage_opt , datasource , version_opt , print )
85
+ runDocker ( coverage_opt , datasource , version_opt , latest_version , print )
82
86
} else {
83
- runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt , print )
87
+ runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt , latest_version , print )
84
88
}
85
89
}
86
90
}
87
91
88
- async function runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt , print ) {
92
+ async function runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt , latest_version , print ) {
89
93
const platform = getPlatform ( logs_opt )
90
94
91
- if ( ! version_opt ) {
92
- let result = await fetch ( 'https://api.github.com/repos/LimeChain/matchstick/releases/latest' )
93
- let json = await result . json ( )
94
- version_opt = json . tag_name
95
- }
96
-
97
- const url = `https://github.com/LimeChain/matchstick/releases/download/${ version_opt } /${ platform } `
95
+ const url = `https://github.com/LimeChain/matchstick/releases/download/${ version_opt || latest_version } /${ platform } `
98
96
99
97
if ( logs_opt ) {
100
98
console . log ( `Download link: ${ url } ` )
@@ -144,7 +142,7 @@ function getPlatform(logs_opt) {
144
142
throw new Error ( `Unsupported platform: ${ type } ${ arch } ${ majorVersion } ` )
145
143
}
146
144
147
- function runDocker ( coverage_opt , datasource , version_opt , print ) {
145
+ function runDocker ( coverage_opt , datasource , version_opt , latest_version , print ) {
148
146
// Remove binary-install-raw binaries, because docker has permission issues
149
147
// when building the docker images
150
148
fs . rmSync ( "node_modules/binary-install-raw/bin" , { force : true , recursive : true } ) ;
@@ -156,7 +154,7 @@ function runDocker(coverage_opt, datasource, version_opt, print) {
156
154
}
157
155
158
156
try {
159
- fs . writeFileSync ( `${ dir } /Dockerfile` , dockerfile ( version_opt ) )
157
+ fs . writeFileSync ( `${ dir } /Dockerfile` , dockerfile ( version_opt , latest_version ) )
160
158
print . info ( 'Successfully generated Dockerfile.' ) ;
161
159
} catch ( error ) {
162
160
print . info ( 'A problem occurred while generating the Dockerfile. Please attend to the errors below:' ) ;
@@ -217,7 +215,7 @@ function runDocker(coverage_opt, datasource, version_opt, print) {
217
215
}
218
216
219
217
// TODO: Move these in separate file (in a function maybe)
220
- function dockerfile ( version_opt ) {
218
+ function dockerfile ( version_opt , latest_version ) {
221
219
return `
222
220
FROM ubuntu:20.04
223
221
ENV ARGS=""
@@ -232,7 +230,7 @@ function dockerfile(version_opt) {
232
230
RUN npm install -g @graphprotocol/graph-cli
233
231
234
232
# Download the latest linux binary
235
- RUN curl -OL https://github.com/LimeChain/matchstick/releases/download/${ version_opt || "0.2.2a" } /binary-linux-20
233
+ RUN curl -OL https://github.com/LimeChain/matchstick/releases/download/${ version_opt || latest_version } /binary-linux-20
236
234
237
235
# Make it executable
238
236
RUN chmod a+x binary-linux-20
0 commit comments