21 changed files with 358 additions and 103 deletions
@ -0,0 +1,43 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/format.sh |
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/run-job.sh |
||||
|
|
||||
|
GIT_REVISION=$(git rev-parse HEAD) |
||||
|
export GIT_REVISION |
||||
|
|
||||
|
export SENTRY_URL='https://db8f5b9b021048d4a401f045371701cb@sentry.io/274561' |
||||
|
export JOBS='max' |
||||
|
|
||||
|
echo |
||||
|
formatEnvVar 'GIT_REVISION' |
||||
|
formatEnvVar 'SENTRY_URL' |
||||
|
echo |
||||
|
|
||||
|
runJob \ |
||||
|
"clearing dist..." \ |
||||
|
"dist cleared" \ |
||||
|
"failed to clear dist" \ |
||||
|
<<EOF |
||||
|
rm -rf dist |
||||
|
EOF |
||||
|
|
||||
|
runJob \ |
||||
|
"building internal bundle..." \ |
||||
|
"internal bundle built" \ |
||||
|
"failed to build internal bundle" \ |
||||
|
<<EOF |
||||
|
NODE_ENV=production yarn run webpack-cli --mode production --config webpack/internals.config.js |
||||
|
EOF |
||||
|
|
||||
|
runJob \ |
||||
|
"building main & renderer bundles..." \ |
||||
|
"main & renderer bundles built" \ |
||||
|
"failed to build main & renderer bundles" \ |
||||
|
<<EOF |
||||
|
NODE_ENV=production yarn run electron-webpack |
||||
|
EOF |
@ -0,0 +1,20 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/run-job.sh |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/display-env.sh |
||||
|
|
||||
|
yarn compile |
||||
|
|
||||
|
runJob \ |
||||
|
"building app..." \ |
||||
|
"app built successfully" \ |
||||
|
"failed to build app" \ |
||||
|
"verbose" \ |
||||
|
<<EOF |
||||
|
DEBUG=electron-builder electron-builder --dir -c.compression=store -c.mac.identity=null |
||||
|
EOF |
@ -0,0 +1,45 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
# 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 |
||||
|
# some context: |
||||
|
# - https://github.com/electron-userland/electron-builder/issues/2577 |
||||
|
# - https://github.com/electron-userland/electron-builder/issues/2269 |
||||
|
if [[ $(uname) == 'Linux' ]]; then |
||||
|
runJob \ |
||||
|
"dirty fix to handle linux icon..." \ |
||||
|
"successfully applied dirty fix to handle linux icon" \ |
||||
|
"failed to apply dirty fix to handle linux icon" \ |
||||
|
<<EOF |
||||
|
mv build/icon.png /tmp |
||||
|
EOF |
||||
|
fi |
||||
|
|
||||
|
yarn compile |
||||
|
|
||||
|
runJob \ |
||||
|
"building and packaging app..." \ |
||||
|
"app built and packaged successfully" \ |
||||
|
"failed to build app" \ |
||||
|
"verbose" \ |
||||
|
<<EOF |
||||
|
DEBUG=electron-builder electron-builder |
||||
|
EOF |
||||
|
|
||||
|
# hilarious fix continuation: put back the icon where it was |
||||
|
if [[ $(uname) == 'Linux' ]]; then |
||||
|
runJob \ |
||||
|
"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" \ |
||||
|
<<EOF |
||||
|
mv /tmp/icon.png build |
||||
|
EOF |
||||
|
fi |
@ -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,43 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/format.sh |
||||
|
|
||||
|
function runJob { |
||||
|
|
||||
|
progressMsg=$1 |
||||
|
successMsg=$2 |
||||
|
errMsg=$3 |
||||
|
logLevel=$4 |
||||
|
|
||||
|
tmpErrFile=$(mktemp) |
||||
|
|
||||
|
job=$(</dev/stdin) |
||||
|
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 |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/hash.sh |
||||
|
|
||||
|
yarnLockHash=$(md5sum package.json | cut -d ' ' -f 1) |
||||
|
cachedYarnLockHash=$(getHash 'yarn.lock') |
||||
|
|
||||
|
if [ "$cachedYarnLockHash" == "$yarnLockHash" ]; then |
||||
|
echo "> Skipping yarn install" |
||||
|
else |
||||
|
yarn install |
||||
|
setHash 'yarn.lock' "$yarnLockHash" |
||||
|
fi |
@ -1,13 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
set -e |
|
||||
|
|
||||
GIT_REVISION=$(git rev-parse HEAD) |
|
||||
export GIT_REVISION |
|
||||
export SENTRY_URL=https://db8f5b9b021048d4a401f045371701cb@sentry.io/274561 |
|
||||
export JOBS=max |
|
||||
|
|
||||
rm -rf ./node_modules/.cache dist |
|
||||
yarn |
|
||||
NODE_ENV=production yarn run webpack-cli --mode production --config webpack/internals.config.js |
|
||||
NODE_ENV=production yarn run electron-webpack |
|
@ -1,3 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
yarn compile && DEBUG=electron-builder electron-builder --dir -c.compression=store -c.mac.identity=null |
|
@ -1,16 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
# hilarious fix: to make linux icon we have to remove icon.png from build folder |
|
||||
# some context: |
|
||||
# - https://github.com/electron-userland/electron-builder/issues/2577 |
|
||||
# - https://github.com/electron-userland/electron-builder/issues/2269 |
|
||||
if [[ $(uname) == 'Linux' ]]; then |
|
||||
mv build/icon.png /tmp |
|
||||
fi |
|
||||
|
|
||||
yarn compile && DEBUG=electron-builder electron-builder |
|
||||
|
|
||||
# hilarious fix continuation: put back the icon where it was |
|
||||
if [[ $(uname) == 'Linux' ]]; then |
|
||||
mv /tmp/icon.png build |
|
||||
fi |
|
@ -1,14 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
# shellcheck disable=SC1091 |
|
||||
source scripts/helpers/hash.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,45 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
# shellcheck disable=SC1091 |
|
||||
source scripts/helpers/hash.sh |
|
||||
|
|
||||
function MAIN { |
|
||||
if [ "$CI" != "1" ]; then |
|
||||
REBUILD_ELECTRON_NATIVE_DEPS |
|
||||
fi |
|
||||
INSTALL_FLOW_TYPED |
|
||||
} |
|
||||
|
|
||||
function INSTALL_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') |
|
||||
if [ "$LATEST_FLOW_TYPED_COMMIT_HASH" == "$CURRENT_FLOW_TYPED_HASH" ]; then |
|
||||
echo "> Flow-typed definitions are up to date. Skipping" |
|
||||
else |
|
||||
echo "> Installing flow-typed defs" |
|
||||
flow-typed install -s --overwrite |
|
||||
echo "> Removing broken flow definitions" |
|
||||
rm flow-typed/npm/{react-i18next_v7.x.x.js,styled-components_v3.x.x.js,redux_*,winston*} |
|
||||
SET_HASH 'flow-typed' "$LATEST_FLOW_TYPED_COMMIT_HASH" |
|
||||
fi |
|
||||
} |
|
||||
|
|
||||
function REBUILD_ELECTRON_NATIVE_DEPS { |
|
||||
# for strange/fancy os-es |
|
||||
if [[ $(uname) == 'Darwin' ]]; then |
|
||||
PACKAGE_JSON_HASH=$(md5 package.json | 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 |
|
||||
echo "> Installing electron native deps" |
|
||||
DEBUG=electron-builder electron-builder install-app-deps |
|
||||
SET_HASH 'package.json' "$PACKAGE_JSON_HASH" |
|
||||
fi |
|
||||
} |
|
||||
|
|
||||
MAIN |
|
@ -0,0 +1,83 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
# shellcheck disable=SC1091 |
||||
|
source scripts/helpers/display-env.sh |
||||
|
# shellcheck disable=SC1091 |
||||
|
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 { |
||||
|
|
||||
|
# native dependencies |
||||
|
|
||||
|
if [ "$CI" != "true" ] && hashDiffers yarn.lock "$(getYarnHash)"; then |
||||
|
rebuildElectronNativeDeps |
||||
|
else |
||||
|
formatSkip "native module build" "already up-to-date" |
||||
|
fi |
||||
|
|
||||
|
# flow-typed |
||||
|
|
||||
|
formatProgress "Checking if flow-typed definitions are up-to-date..." |
||||
|
latestFlowTypedCommitHash=$(curl --silent --header "Accept: application/vnd.github.VERSION.sha" --location https://api.github.com/repos/flowtype/flow-typed/commits/master) |
||||
|
clearLine |
||||
|
|
||||
|
if [[ $latestFlowTypedCommitHash =~ ^\{ ]]; then |
||||
|
formatError "Failed to retrieve flow-typed definitions" |
||||
|
echo "$latestFlowTypedCommitHash" |
||||
|
exit 1 |
||||
|
else |
||||
|
if hashDiffers flow-typed "$latestFlowTypedCommitHash"; then |
||||
|
installFlowTyped |
||||
|
else |
||||
|
formatSkip "flow-typed installation" "already up-to-date" |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
echo |
||||
|
|
||||
|
} |
||||
|
|
||||
|
function installFlowTyped { |
||||
|
runJob \ |
||||
|
"Installing flow-typed definitions..." \ |
||||
|
"Installed flow-typed definitions" \ |
||||
|
"Failed installing flow-typed definitions" \ |
||||
|
<<EOF |
||||
|
flow-typed install -s --overwrite |
||||
|
EOF |
||||
|
rm flow-typed/npm/{react-i18next_v7.x.x.js,styled-components_v3.x.x.js,redux_*,winston*} |
||||
|
formatSuccess "Removed broken flow-typed definitions" |
||||
|
setHash flow-typed "$latestFlowTypedCommitHash" |
||||
|
formatSuccess "Installed flow-typed definitions" |
||||
|
} |
||||
|
|
||||
|
function rebuildElectronNativeDeps { |
||||
|
runJob \ |
||||
|
"Building native electron dependencies..." \ |
||||
|
"Successfully builded native modules for electron" \ |
||||
|
"Build failed" \ |
||||
|
"verbose" \ |
||||
|
<<EOF |
||||
|
DEBUG=electron-builder electron-builder install-app-deps |
||||
|
EOF |
||||
|
setHash yarn.lock "$(getYarnHash)" |
||||
|
} |
||||
|
|
||||
|
function getYarnHash { |
||||
|
if [[ $(uname) == 'Darwin' ]]; then |
||||
|
yarnHash=$(md5 yarn.lock | cut -d ' ' -f 1) |
||||
|
else |
||||
|
yarnHash=$(md5sum yarn.lock | cut -d ' ' -f 1) |
||||
|
fi |
||||
|
echo "$yarnHash" |
||||
|
} |
||||
|
|
||||
|
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