forked from solana-labs/solminer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: include solana-install-init program in distribution
- Loading branch information
Showing
7 changed files
with
952 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
"env", | ||
"flow", | ||
"react", | ||
"stage-2", | ||
], | ||
"plugins": [ | ||
"transform-class-properties", | ||
"transform-function-bind", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ out | |
.eslintcache | ||
.DS_Store | ||
yarn-error.log | ||
solana-install-init | ||
solana-install-init.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Fetches the latest solana-install-init program for the current platform | ||
import os from 'os'; | ||
import assert from 'assert'; | ||
import fetch from 'node-fetch'; | ||
import got from 'got'; | ||
import fs from 'fs'; | ||
|
||
const channel = 'edge'; | ||
//const channel = 'github-release'; | ||
|
||
async function download(assetName, dest) { | ||
let downloadUrl; | ||
if (channel === 'github-release') { | ||
const releaseUrl = 'https://api.github.com/repos/solana-labs/solana/releases/latest'; | ||
console.log(`Fetching ${releaseUrl}...`); | ||
const response = await fetch(releaseUrl); | ||
const latestRelease = await response.json(); | ||
|
||
const asset = latestRelease.assets.find(asset => asset.name === assetName); | ||
|
||
if (!asset) { | ||
throw new Error(`Unable to locate a release asset named ${assetName}`); | ||
} | ||
downloadUrl = asset.browser_download_url; | ||
} else { | ||
downloadUrl = `http://release.solana.com/${channel}/${assetName}`; | ||
} | ||
console.log(`Fetching ${downloadUrl}...`); | ||
|
||
got.stream(downloadUrl).pipe(fs.createWriteStream(dest)); | ||
console.log(`Wrote ${dest}`); | ||
} | ||
|
||
async function main() { | ||
assert(os.arch() === 'x64', `Unsupported architecture: ${os.arch()}`); | ||
switch (os.type()) { | ||
case 'Windows_NT': | ||
download('solana-install-init-x86_64-pc-windows-msvc.exe', 'solana-install-init.exe'); | ||
break; | ||
case 'Darwin': | ||
download('solana-install-init-x86_64-apple-darwin', 'solana-install-init'); | ||
break; | ||
case 'Linux': | ||
download('solana-install-init-x86_64-unknown-linux-gnu', 'solana-install-init'); | ||
break; | ||
default: | ||
throw new Error(`Unsupported OS type: ${os.type()}`); | ||
} | ||
} | ||
|
||
main().catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.