committed by
GitHub
18 changed files with 371 additions and 329 deletions
@ -1,47 +1,24 @@ |
|||||
version: 2 |
version: 2 |
||||
|
|
||||
docker_defaults: &docker_defaults |
defaults: &defaults |
||||
|
working_directory: ~/ledger-live-desktop |
||||
docker: |
docker: |
||||
- image: circleci/node:9.5 |
- image: circleci/node:8.11.3-stretch-browsers |
||||
|
|
||||
jobs: |
jobs: |
||||
build: |
build: |
||||
<<: *docker_defaults |
<<: *defaults |
||||
branches: |
|
||||
ignore: |
|
||||
- gh-pages |
|
||||
steps: |
steps: |
||||
- checkout |
- checkout |
||||
- restore_cache: |
- restore_cache: |
||||
name: Restore Yarn Package Cache |
|
||||
keys: |
keys: |
||||
- v2-yarn-packages-{{ checksum "yarn.lock" }} |
- v7-yarn-packages-{{ checksum "yarn.lock" }} |
||||
- run: |
- run: yarn install |
||||
name: Install Dependencies |
|
||||
command: bash scripts/install-ci-deps.sh |
|
||||
- save_cache: |
- save_cache: |
||||
name: Save Yarn Package Cache |
key: v7-yarn-packages-{{ checksum "yarn.lock" }} |
||||
key: v2-yarn-packages-{{ checksum "yarn.lock" }} |
|
||||
paths: |
paths: |
||||
- node_modules/ |
- node_modules |
||||
- run: |
- run: yarn lint |
||||
name: Lint |
- run: ./node_modules/.bin/prettier -l "{src,webpack,.storybook,static/i18n}/**/*.js" |
||||
command: yarn lint |
- run: yarn flow --quiet |
||||
- run: |
- run: yarn release |
||||
name: Prettier |
|
||||
command: ./node_modules/.bin/prettier -l "{src,webpack,.storybook}/**/*.js" |
|
||||
- run: |
|
||||
name: Flow |
|
||||
command: yarn flow --quiet |
|
||||
# - run: |
|
||||
# name: Test |
|
||||
# command: yarn test |
|
||||
# - run: |
|
||||
# name: Build |
|
||||
# command: yarn dist:dir |
|
||||
# - run: |
|
||||
# name: Generate build stats |
|
||||
# command: "du -h dist | sort -h > /tmp/build-stats.txt" |
|
||||
# - store_artifacts: |
|
||||
# path: /tmp/build-stats.txt |
|
||||
# destination: build-stats.txt |
|
||||
|
@ -1,3 +1,18 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
yarn compile && DEBUG=electron-builder electron-builder --dir -c.compression=store -c.mac.identity=null |
set -e |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/run-job.sh |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/display-env.sh |
||||
|
|
||||
|
yarn compile |
||||
|
|
||||
|
runJob \ |
||||
|
"DEBUG=electron-builder electron-builder --dir -c.compression=store -c.mac.identity=null" \ |
||||
|
"building app..." \ |
||||
|
"app built successfully" \ |
||||
|
"failed to build app" \ |
||||
|
"verbose" |
||||
|
@ -1,16 +1,41 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
export JOBS=max |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/run-job.sh |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/display-env.sh |
||||
|
|
||||
# hilarious fix: to make linux icon we have to remove icon.png from build folder |
# hilarious fix: to make linux icon we have to remove icon.png from build folder |
||||
# some context: |
# some context: |
||||
# - https://github.com/electron-userland/electron-builder/issues/2577 |
# - https://github.com/electron-userland/electron-builder/issues/2577 |
||||
# - https://github.com/electron-userland/electron-builder/issues/2269 |
# - https://github.com/electron-userland/electron-builder/issues/2269 |
||||
if [[ $(uname) == 'Linux' ]]; then |
if [[ $(uname) == 'Linux' ]]; then |
||||
mv build/icon.png /tmp |
runJob \ |
||||
|
"mv build/icon.png /tmp" \ |
||||
|
"dirty fix to handle linux icon..." \ |
||||
|
"successfully applied dirty fix to handle linux icon" \ |
||||
|
"failed to apply dirty fix to handle linux icon" |
||||
fi |
fi |
||||
|
|
||||
yarn compile && DEBUG=electron-builder electron-builder |
yarn compile |
||||
|
|
||||
|
runJob \ |
||||
|
"DEBUG=electron-builder electron-builder" \ |
||||
|
"building and packaging app..." \ |
||||
|
"app built and packaged successfully" \ |
||||
|
"failed to build app" \ |
||||
|
"verbose" |
||||
|
|
||||
# hilarious fix continuation: put back the icon where it was |
# hilarious fix continuation: put back the icon where it was |
||||
if [[ $(uname) == 'Linux' ]]; then |
if [[ $(uname) == 'Linux' ]]; then |
||||
mv /tmp/icon.png build |
runJob \ |
||||
|
"mv /tmp/icon.png build" \ |
||||
|
"cleaning dirty fix to handle linux icon..." \ |
||||
|
"successfully applied clean dirty fix to handle linux icon" \ |
||||
|
"failed to apply clean dirty fix to handle linux icon" |
||||
fi |
fi |
||||
|
@ -1,26 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
function GET_HASH_PATH { |
|
||||
HASH_NAME=$1 |
|
||||
echo "./node_modules/.cache/LEDGER_HASH_$HASH_NAME.hash" |
|
||||
} |
|
||||
|
|
||||
function GET_HASH { |
|
||||
HASH_NAME=$1 |
|
||||
HASH_PATH=$(GET_HASH_PATH "$HASH_NAME") |
|
||||
if [ ! -e "$HASH_PATH" ]; then |
|
||||
echo '' |
|
||||
else |
|
||||
HASH_CONTENT=$(cat "$HASH_PATH") |
|
||||
echo "$HASH_CONTENT" |
|
||||
fi |
|
||||
} |
|
||||
|
|
||||
function SET_HASH { |
|
||||
HASH_NAME=$1 |
|
||||
HASH_CONTENT=$2 |
|
||||
echo "setting hash $HASH_NAME to $HASH_CONTENT" |
|
||||
HASH_PATH=$(GET_HASH_PATH "$HASH_NAME") |
|
||||
mkdir -p ./node_modules/.cache |
|
||||
echo "$HASH_CONTENT" > "$HASH_PATH" |
|
||||
} |
|
@ -0,0 +1,20 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/format.sh |
||||
|
|
||||
|
appVersion=$(grep version package.json | sed 's/.*"\(.*\)",$/\1/') |
||||
|
|
||||
|
echo |
||||
|
printf " │ \\e[4;1m%s\\e[0;0m\\n" "Ledger Live Desktop - ${appVersion}" |
||||
|
printf " │ \\e[1;30m%s\\e[1;0m\\n" "$(uname -srmo)" |
||||
|
printf " │ \\e[2;1mcommit \\e[0;33m%s\\e[0;0m\\n" "$(git rev-parse HEAD)" |
||||
|
echo |
||||
|
|
||||
|
formatEnvVar "CI" |
||||
|
formatEnvVar "NODE_ENV" |
||||
|
formatEnvVar "JOBS" |
||||
|
|
||||
|
echo |
||||
|
formatGeneric "node" "$(node --version)" |
||||
|
echo |
@ -0,0 +1,48 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
colSize=20 |
||||
|
|
||||
|
function formatJobTitle { |
||||
|
echo "[$1]" |
||||
|
echo |
||||
|
} |
||||
|
|
||||
|
function formatEnvVar { |
||||
|
key=$1 |
||||
|
value=$(eval echo \$"${key}") |
||||
|
color="32" |
||||
|
if [ "$value" == "" ]; then color="34"; value="unset" |
||||
|
elif [ "$value" == "1" ]; then color="32" |
||||
|
elif [ "$value" == "0" ]; then color="35" |
||||
|
else value="'$value'" |
||||
|
fi |
||||
|
printf " %-${colSize}s\\e[2;${color}m%s\\e[1;0m\\n" "$key" "$value" |
||||
|
} |
||||
|
|
||||
|
function formatGeneric { |
||||
|
printf " %-${colSize}s\\e[0;2m%s\\e[0m\\n" "$1" "$2" |
||||
|
} |
||||
|
|
||||
|
function formatDiscret { |
||||
|
printf "\\e[2;34m%s\\e[2;0m\\n" "$1" |
||||
|
} |
||||
|
|
||||
|
function formatSkip { |
||||
|
printf "\\e[2;34m[-] skipping %s (%s)\\e[0;0m\\n" "$1" "$2" |
||||
|
} |
||||
|
|
||||
|
function clearLine { |
||||
|
echo -en "\\r\\e[0K" |
||||
|
} |
||||
|
|
||||
|
function formatError { |
||||
|
printf "\\e[0;31m[✘] %s\\e[0;0m\\n" "$1" |
||||
|
} |
||||
|
|
||||
|
function formatProgress { |
||||
|
printf "\\e[0;35m[⬇] %s\\e[0;0m" "$1" |
||||
|
} |
||||
|
|
||||
|
function formatSuccess { |
||||
|
printf "\\e[0;36m[✔] %s\\e[0;0m\\n" "$1" |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/format.sh |
||||
|
|
||||
|
function _getHashPath { |
||||
|
HASH_NAME=$1 |
||||
|
echo "./node_modules/.cache/LEDGER_HASH_$HASH_NAME.hash" |
||||
|
} |
||||
|
|
||||
|
function getHash { |
||||
|
HASH_NAME=$1 |
||||
|
HASH_PATH=$(_getHashPath "$HASH_NAME") |
||||
|
if [ ! -e "$HASH_PATH" ]; then |
||||
|
echo '' |
||||
|
else |
||||
|
HASH_CONTENT=$(cat "$HASH_PATH") |
||||
|
echo "$HASH_CONTENT" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
function setHash { |
||||
|
HASH_NAME=$1 |
||||
|
HASH_CONTENT=$2 |
||||
|
formatSuccess "$HASH_NAME hash set to $HASH_CONTENT" |
||||
|
HASH_PATH=$(_getHashPath "$HASH_NAME") |
||||
|
mkdir -p ./node_modules/.cache |
||||
|
echo "$HASH_CONTENT" > "$HASH_PATH" |
||||
|
} |
||||
|
|
||||
|
function hashDiffers { |
||||
|
cachedHash=$(getHash "$1") |
||||
|
hash=$2 |
||||
|
if [ "$cachedHash" == "$hash" ]; then |
||||
|
return 1 |
||||
|
else |
||||
|
return 0 |
||||
|
fi |
||||
|
} |
@ -0,0 +1,62 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/format.sh |
||||
|
|
||||
|
operatingSystem=$(uname -s) |
||||
|
if [ "$operatingSystem" != "Linux" ] && [ "$operatingSystem" != "Darwin" ]; then |
||||
|
operatingSystem="Windows" |
||||
|
fi |
||||
|
|
||||
|
function runJob { |
||||
|
|
||||
|
local job=$1 |
||||
|
local progressMsg=$2 |
||||
|
local successMsg=$3 |
||||
|
local errMsg=$4 |
||||
|
local logLevel=$5 |
||||
|
|
||||
|
local tmpScript |
||||
|
local tmpErrFile |
||||
|
local childPid |
||||
|
local returnCode |
||||
|
|
||||
|
# let's absolutely don't take care of this fake os |
||||
|
if [ "$operatingSystem" == "Windows" ]; then |
||||
|
tmpScript=$(mktemp) |
||||
|
echo "$job" > "$tmpScript" |
||||
|
bash "$tmpScript" |
||||
|
rm "$tmpScript" |
||||
|
return $? |
||||
|
fi |
||||
|
|
||||
|
tmpErrFile=$(mktemp) |
||||
|
|
||||
|
formatProgress "$progressMsg" |
||||
|
|
||||
|
if [ "$logLevel" == "verbose" ]; then |
||||
|
echo |
||||
|
echo "$job" | bash & |
||||
|
else |
||||
|
echo "$job" | bash >/dev/null 2>"$tmpErrFile" & |
||||
|
fi |
||||
|
|
||||
|
childPid=$! |
||||
|
|
||||
|
# prevent set -e to exit if child fail |
||||
|
wait $childPid && returnCode=$? || returnCode=$? |
||||
|
|
||||
|
if [ "$logLevel" != "verbose" ]; then |
||||
|
clearLine |
||||
|
fi |
||||
|
|
||||
|
if [ $returnCode -eq 0 ]; then |
||||
|
formatSuccess "$successMsg" |
||||
|
else |
||||
|
formatError "$errMsg" |
||||
|
formatError "$(cat "$tmpErrFile")" |
||||
|
fi |
||||
|
|
||||
|
rm "$tmpErrFile" |
||||
|
return $returnCode |
||||
|
} |
@ -1,14 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
# shellcheck disable=SC1091 |
|
||||
source scripts/hash-utils.sh |
|
||||
|
|
||||
PACKAGE_JSON_HASH=$(md5sum package.json | cut -d ' ' -f 1) |
|
||||
CACHED_PACKAGE_JSON_HASH=$(GET_HASH 'package.json') |
|
||||
|
|
||||
if [ "$CACHED_PACKAGE_JSON_HASH" == "$PACKAGE_JSON_HASH" ]; then |
|
||||
echo "> Skipping yarn install" |
|
||||
else |
|
||||
yarn install |
|
||||
SET_HASH 'package.json' "$PACKAGE_JSON_HASH" |
|
||||
fi |
|
@ -1,135 +0,0 @@ |
|||||
// This is a work in progress
|
|
||||
// The goal is to provide a cli which allow interact
|
|
||||
// with device & libcore for faster iterations
|
|
||||
|
|
||||
require('babel-polyfill') |
|
||||
require('babel-register') |
|
||||
|
|
||||
const chalk = require('chalk') |
|
||||
const inquirer = require('inquirer') |
|
||||
const path = require('path') |
|
||||
const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid').default |
|
||||
|
|
||||
const { serializeAccounts, encodeAccount, decodeAccount } = require('../src/reducers/accounts') |
|
||||
const { doSignAndBroadcast } = require('../src/commands/libcoreSignAndBroadcast') |
|
||||
|
|
||||
const coreHelper = require('../src/helpers/libcore') |
|
||||
const withLibcore = require('../src/helpers/withLibcore').default |
|
||||
|
|
||||
if (!process.env.LEDGER_LIVE_SQLITE_PATH) { |
|
||||
throw new Error('you must define process.env.LEDGER_LIVE_SQLITE_PATH first') |
|
||||
} |
|
||||
|
|
||||
const LOCAL_DIRECTORY_PATH = path.resolve(process.env.LEDGER_LIVE_SQLITE_PATH, '../') |
|
||||
|
|
||||
gimmeDeviceAndLibCore(async ({ device, core, njsWalletPool }) => { |
|
||||
const raw = require(path.join(LOCAL_DIRECTORY_PATH, 'accounts.json')) // eslint-disable-line import/no-dynamic-require
|
|
||||
const accounts = serializeAccounts(raw.data) |
|
||||
const accountToUse = await chooseAccount('Which account to use?', accounts) |
|
||||
await actionLoop({ account: accountToUse, accounts, core, njsWalletPool, device }) |
|
||||
process.exit(0) |
|
||||
}) |
|
||||
|
|
||||
async function actionLoop(props) { |
|
||||
try { |
|
||||
const { account, accounts, core, njsWalletPool, device } = props |
|
||||
const actionToDo = await chooseAction(`What do you want to do with [${account.name}] ?`) |
|
||||
if (actionToDo === 'send funds') { |
|
||||
const transport = await TransportNodeHid.open(device.path) |
|
||||
const accountToReceive = await chooseAccount('To which account?', accounts) |
|
||||
const receiveAddress = await getFreshAddress({ |
|
||||
account: accountToReceive, |
|
||||
core, |
|
||||
njsWalletPool, |
|
||||
}) |
|
||||
console.log(`the receive address is ${receiveAddress}`) |
|
||||
const rawAccount = encodeAccount(account) |
|
||||
console.log(`trying to sign and broadcast...`) |
|
||||
const rawOp = await doSignAndBroadcast({ |
|
||||
account: rawAccount, |
|
||||
transaction: { |
|
||||
amount: 4200000, |
|
||||
recipient: receiveAddress, |
|
||||
feePerByte: 16, |
|
||||
isRBF: false, |
|
||||
}, |
|
||||
deviceId: device.path, |
|
||||
core, |
|
||||
transport, |
|
||||
}) |
|
||||
console.log(rawOp) |
|
||||
} else if (actionToDo === 'sync') { |
|
||||
console.log(`\nLaunch sync...\n`) |
|
||||
const rawAccount = encodeAccount(account) |
|
||||
const syncedAccount = await coreHelper.syncAccount({ rawAccount, core, njsWalletPool }) |
|
||||
console.log(`\nEnd sync...\n`) |
|
||||
console.log(`updated account: `, displayAccount(syncedAccount, 'red')) |
|
||||
} else if (actionToDo === 'quit') { |
|
||||
return true |
|
||||
} |
|
||||
} catch (err) { |
|
||||
console.log(`x Something went wrong`) |
|
||||
console.log(err) |
|
||||
process.exit(1) |
|
||||
} |
|
||||
return actionLoop(props) |
|
||||
} |
|
||||
|
|
||||
async function chooseInList(msg, list, formatItem = i => i) { |
|
||||
const choices = list.map(formatItem) |
|
||||
const { choice } = await inquirer.prompt([ |
|
||||
{ |
|
||||
type: 'list', |
|
||||
name: 'choice', |
|
||||
message: msg, |
|
||||
choices, |
|
||||
}, |
|
||||
]) |
|
||||
const index = choices.indexOf(choice) |
|
||||
return list[index] |
|
||||
} |
|
||||
|
|
||||
async function chooseAction(msg) { |
|
||||
return chooseInList(msg, ['sync', 'send funds', 'quit']) |
|
||||
} |
|
||||
|
|
||||
function chooseAccount(msg, accounts) { |
|
||||
return chooseInList(msg, accounts, acc => displayAccount(acc)) |
|
||||
} |
|
||||
|
|
||||
async function gimmeDeviceAndLibCore(cb) { |
|
||||
withLibcore((core, njsWalletPool) => { |
|
||||
TransportNodeHid.listen({ |
|
||||
error: () => {}, |
|
||||
complete: () => {}, |
|
||||
next: async e => { |
|
||||
if (!e.device) { |
|
||||
return |
|
||||
} |
|
||||
if (e.type === 'add') { |
|
||||
const { device } = e |
|
||||
cb({ device, core, njsWalletPool }) |
|
||||
} |
|
||||
}, |
|
||||
}) |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
function displayAccount(acc, color = null) { |
|
||||
const isRawAccount = typeof acc.lastSyncDate === 'string' |
|
||||
if (isRawAccount) { |
|
||||
acc = decodeAccount(acc) |
|
||||
} |
|
||||
const str = `[${acc.name}] ${acc.isSegwit ? '' : '(legacy) '}${acc.unit.code} ${acc.balance} - ${ |
|
||||
acc.operations.length |
|
||||
} txs` |
|
||||
return color ? chalk[color](str) : str |
|
||||
} |
|
||||
|
|
||||
async function getFreshAddress({ account, core, njsWalletPool }) { |
|
||||
const njsAccount = await coreHelper.getNJSAccount({ account, njsWalletPool }) |
|
||||
const unsub = await core.syncAccount(njsAccount) |
|
||||
unsub() |
|
||||
const rawAddresses = await njsAccount.getFreshPublicAddresses() |
|
||||
return rawAddresses[0] |
|
||||
} |
|
@ -1,63 +0,0 @@ |
|||||
// Utility to human-read the accounts.json file
|
|
||||
// You have to pass it in parameter, because the location
|
|
||||
// differ depending on the OS.
|
|
||||
|
|
||||
const { |
|
||||
formatCurrencyUnit, |
|
||||
getCryptoCurrencyById, |
|
||||
} = require('@ledgerhq/live-common/lib/helpers/currencies') |
|
||||
const chalk = require('chalk') |
|
||||
const padStart = require('lodash/padStart') |
|
||||
const padEnd = require('lodash/padEnd') |
|
||||
|
|
||||
const { argv } = process |
|
||||
|
|
||||
const [, , FILE_PATH] = argv |
|
||||
|
|
||||
if (!FILE_PATH) { |
|
||||
console.log(`You need to specify a file`) |
|
||||
process.exit(1) |
|
||||
} |
|
||||
|
|
||||
const { data: wrappedAccounts } = require(FILE_PATH) // eslint-disable-line
|
|
||||
|
|
||||
const str = wrappedAccounts |
|
||||
.map(({ data: account }) => { |
|
||||
const currency = getCryptoCurrencyById(account.currencyId) |
|
||||
const unit = currency.units[0] |
|
||||
const headline = `${account.isSegwit ? '[SEGWIT]' : '[NOT SEGWIT]'} ${account.name} | ${ |
|
||||
account.id |
|
||||
} | ${account.path} | balance: ${formatCurrencyUnit(unit, account.balance, { |
|
||||
showCode: true, |
|
||||
alwaysShowSign: true, |
|
||||
})}` |
|
||||
return [ |
|
||||
headline, |
|
||||
headline |
|
||||
.split('') |
|
||||
.map(() => '-') |
|
||||
.join(''), |
|
||||
account.operations |
|
||||
.map(op => { |
|
||||
const opType = op.amount < 0 ? 'SEND' : 'RECEIVE' |
|
||||
return [ |
|
||||
padEnd(opType, 8), |
|
||||
op.date.substr(0, 10), |
|
||||
chalk[opType === 'SEND' ? 'red' : 'green']( |
|
||||
padStart( |
|
||||
formatCurrencyUnit(unit, op.amount, { |
|
||||
showCode: true, |
|
||||
alwaysShowSign: true, |
|
||||
}), |
|
||||
15, |
|
||||
), |
|
||||
), |
|
||||
op.hash, |
|
||||
].join(' ') |
|
||||
}) |
|
||||
.join('\n'), |
|
||||
].join('\n') |
|
||||
}) |
|
||||
.join('\n\n') |
|
||||
|
|
||||
console.log(str) |
|
@ -1,45 +1,85 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
export JOBS=max |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/display-env.sh |
||||
# shellcheck disable=SC1091 |
# shellcheck disable=SC1091 |
||||
source scripts/hash-utils.sh |
source scripts/helpers/format.sh |
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/hash.sh |
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/run-job.sh |
||||
|
|
||||
|
latestFlowTypedCommitHash='' |
||||
|
|
||||
function MAIN { |
function main { |
||||
if ! $CI; then |
|
||||
REBUILD_ELECTRON_NATIVE_DEPS |
# native dependencies |
||||
|
|
||||
|
if hashDiffers yarn.lock "$(getYarnHash)"; then |
||||
|
rebuildElectronNativeDeps |
||||
|
else |
||||
|
formatSkip "native module build" "already up-to-date" |
||||
fi |
fi |
||||
INSTALL_FLOW_TYPED |
|
||||
} |
|
||||
|
|
||||
function INSTALL_FLOW_TYPED { |
# flow-typed |
||||
LATEST_FLOW_TYPED_COMMIT_HASH=$(curl --silent --header "Accept: application/vnd.github.VERSION.sha" --location https://api.github.com/repos/flowtype/flow-typed/commits/master) |
|
||||
CURRENT_FLOW_TYPED_HASH=$(GET_HASH 'flow-typed') |
formatProgress "Checking if flow-typed definitions are up-to-date..." |
||||
if [ "$LATEST_FLOW_TYPED_COMMIT_HASH" == "$CURRENT_FLOW_TYPED_HASH" ]; then |
latestFlowTypedCommitHash=$(curl --silent --header "Accept: application/vnd.github.VERSION.sha" --location https://api.github.com/repos/flowtype/flow-typed/commits/master) |
||||
echo "> Flow-typed definitions are up to date. Skipping" |
clearLine |
||||
|
|
||||
|
if [[ $latestFlowTypedCommitHash =~ ^\{ ]]; then |
||||
|
formatError "Failed to retrieve flow-typed definitions" |
||||
|
echo "$latestFlowTypedCommitHash" |
||||
|
exit 1 |
||||
else |
else |
||||
echo "> Installing flow-typed defs" |
if hashDiffers flow-typed "$latestFlowTypedCommitHash"; then |
||||
flow-typed install -s --overwrite |
installFlowTyped |
||||
echo "> Removing broken flow definitions" |
else |
||||
rm flow-typed/npm/{react-i18next_v7.x.x.js,styled-components_v3.x.x.js,redux_*,winston*} |
formatSkip "flow-typed installation" "already up-to-date" |
||||
SET_HASH 'flow-typed' "$LATEST_FLOW_TYPED_COMMIT_HASH" |
fi |
||||
fi |
fi |
||||
|
|
||||
|
echo |
||||
|
|
||||
|
} |
||||
|
|
||||
|
function installFlowTyped { |
||||
|
runJob \ |
||||
|
"flow-typed install -s --overwrite" \ |
||||
|
"Installing flow-typed definitions..." \ |
||||
|
"Installed flow-typed definitions" \ |
||||
|
"Failed installing flow-typed definitions" |
||||
|
|
||||
|
runJob \ |
||||
|
"rm flow-typed/npm/{react-i18next_v7.x.x.js,styled-components_v3.x.x.js,redux_*,winston*}" \ |
||||
|
"Removing broken flow-typed definitions" \ |
||||
|
"Removed broken flow-typed definitions" \ |
||||
|
"Failed removing broken flow-typed definitions" |
||||
|
|
||||
|
setHash flow-typed "$latestFlowTypedCommitHash" |
||||
|
} |
||||
|
|
||||
|
function rebuildElectronNativeDeps { |
||||
|
runJob \ |
||||
|
"DEBUG=electron-builder electron-builder install-app-deps" \ |
||||
|
"Building native electron dependencies..." \ |
||||
|
"Successfully builded native modules for electron" \ |
||||
|
"Build failed" \ |
||||
|
"verbose" |
||||
|
setHash yarn.lock "$(getYarnHash)" |
||||
} |
} |
||||
|
|
||||
function REBUILD_ELECTRON_NATIVE_DEPS { |
function getYarnHash { |
||||
# for strange/fancy os-es |
|
||||
if [[ $(uname) == 'Darwin' ]]; then |
if [[ $(uname) == 'Darwin' ]]; then |
||||
PACKAGE_JSON_HASH=$(md5 package.json | cut -d ' ' -f 1) |
yarnHash=$(md5 yarn.lock | cut -d ' ' -f 1) |
||||
else |
|
||||
# for normal os-es |
|
||||
PACKAGE_JSON_HASH=$(md5sum package.json | cut -d ' ' -f 1) |
|
||||
fi |
|
||||
CACHED_PACKAGE_JSON_HASH=$(GET_HASH 'package.json') |
|
||||
if [ "$CACHED_PACKAGE_JSON_HASH" == "$PACKAGE_JSON_HASH" ]; then |
|
||||
echo "> Electron native deps are up to date. Skipping" |
|
||||
else |
else |
||||
echo "> Installing electron native deps" |
yarnHash=$(md5sum yarn.lock | cut -d ' ' -f 1) |
||||
DEBUG=electron-builder electron-builder install-app-deps |
|
||||
SET_HASH 'package.json' "$PACKAGE_JSON_HASH" |
|
||||
fi |
fi |
||||
|
echo "$yarnHash" |
||||
} |
} |
||||
|
|
||||
MAIN |
main |
||||
|
@ -1,5 +1,8 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/display-env.sh |
||||
|
|
||||
concurrently --raw --kill-others \ |
concurrently --raw --kill-others \ |
||||
"cross-env NODE_ENV=development webpack-cli --mode development --watch --config webpack/internals.config.js" \ |
"cross-env NODE_ENV=development webpack-cli --mode development --watch --config webpack/internals.config.js" \ |
||||
"cross-env NODE_ENV=development electron-webpack dev" |
"cross-env NODE_ENV=development electron-webpack dev" |
||||
|
Loading…
Reference in new issue