Add build-stork script

This commit is contained in:
Sam Carlton 2022-05-08 10:58:45 -05:00
parent 43ef3bd5ce
commit d90d109ca9
2 changed files with 53 additions and 0 deletions

48
build-stork.js Normal file
View file

@ -0,0 +1,48 @@
import execa from 'execa'
import fs from 'fs-extra'
import axios from 'axios'
import { isDarwin } from './helpers/environment.js'
const storkVersion = '1.4.2'
const storkExecutableName = 'stork-executable'
const storkExecutablePath = `./${ storkExecutableName }`
// https://stork-search.net/docs/install
const execDownloadUrls = {
darwin: `https://files.stork-search.net/releases/v${ storkVersion }/stork-macos-10-15`,
default: `https://files.stork-search.net/releases/v${ storkVersion }/stork-amazon-linux`
}
;(async () => {
const envKey = isDarwin() ? 'darwin' : 'default'
const execDownloadUrl = execDownloadUrls[ envKey ]
console.log( 'execDownloadUrl', execDownloadUrl )
// Delete any existing executable
await fs.remove( storkExecutableName )
// Download the executable
await execa( `curl`, [
execDownloadUrl,
'-o',
storkExecutableName
])
// const stat = await fs.stat( storkExecutableName )
// console.log( 'stat', stat )
// Make sure the executable is executable
await fs.chmod( storkExecutableName, '755' )
const output = await execa( storkExecutableName, [
'--version'
])
console.log( 'output', output )
})()