Skip to content

Commit

Permalink
feat: include solana-install-init program in distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jun 21, 2019
1 parent 74a501d commit d7901a7
Show file tree
Hide file tree
Showing 7 changed files with 952 additions and 39 deletions.
12 changes: 12 additions & 0 deletions .babelrc
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",
]
}
19 changes: 16 additions & 3 deletions .compilerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
["env", { "targets": { "electron": "1.6.0" } }],
"react"
],
"plugins": ["transform-async-to-generator", "transform-es2015-classes", "react-hot-loader/babel"],
"plugins": [
"transform-async-to-generator",
"transform-class-properties",
"transform-es2015-classes",
"transform-function-bind",
"transform-object-rest-spread",
"react-hot-loader/babel"
],
"sourceMaps": "inline"
}
},
Expand All @@ -16,9 +23,15 @@
["env", { "targets": { "electron": "1.6.0" } }],
"react"
],
"plugins": ["transform-async-to-generator", "transform-es2015-classes"],
"plugins": [
"transform-async-to-generator",
"transform-class-properties",
"transform-es2015-classes",
"transform-function-bind",
"transform-object-rest-spread"
],
"sourceMaps": "none"
}
}
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ out
.eslintcache
.DS_Store
yarn-error.log
solana-install-init
solana-install-init.exe
54 changes: 54 additions & 0 deletions fetch-solana-install-init.js
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);
});
6 changes: 6 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const os = require('os');

const dotexe = os.type() === 'Windows_NT' ? '.exe' : '';
const solanaInstallInit = `solana-install-init${dotexe}`;

module.exports = {
make_targets: {
win32: ['squirrel'],
Expand All @@ -7,6 +12,7 @@ module.exports = {
electronPackagerConfig: {
packageManager: 'yarn',
icon: 'src/images/icon/solminer',
extraResource: solanaInstallInit,
},
electronWinstallerConfig: {
name: 'solminer',
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"repository": "solana-labs/solminer",
"main": "src/index.js",
"scripts": {
"fetch-install-init": "babel-node fetch-solana-install-init.js",
"start": "electron-forge start",
"package": "electron-forge package",
"package": "run-s fetch-install-init electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"eslint": "eslint --cache --color --ext .jsx,.js .",
Expand All @@ -25,25 +26,36 @@
"electron-compile": "^6.4.4",
"electron-devtools-installer": "^2.1.0",
"electron-squirrel-startup": "^1.0.0",
"immutable": "^4.0.0-rc.12",
"javascript-terminal": "^1.0.2",
"node-fetch": "^2.6.0",
"npm-run-all": "^4.1.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-hot-loader": "^4.11.1",
"react-terminal-component": "^1.4.0",
"update-electron-app": "^1.4.2"
},
"devDependencies": {
"@semantic-release/github": "^5.4.0",
"babel-cli": "^6.26.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-function-bind": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"electron-forge": "^5.2.4",
"electron-prebuilt-compile": "4.0.0",
"eslint": "^4",
"eslint-config-airbnb": "^15",
"eslint-plugin-import": "^2",
"eslint-plugin-jsx-a11y": "^5",
"eslint-plugin-react": "^7",
"got": "^9.6.0",
"prettier": "^1.18.2",
"semantic-release": "^15.13.16"
},
Expand Down
Loading

0 comments on commit d7901a7

Please sign in to comment.