diff --git a/.circleci/config.yml b/.circleci/config.yml index 7e245a37..4c88ec55 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,47 +1,24 @@ version: 2 -docker_defaults: &docker_defaults +defaults: &defaults + working_directory: ~/ledger-live-desktop docker: - - image: circleci/node:9.5 + - image: circleci/node:8.11.3-stretch-browsers jobs: build: - <<: *docker_defaults - branches: - ignore: - - gh-pages + <<: *defaults steps: - checkout - restore_cache: - name: Restore Yarn Package Cache keys: - - v2-yarn-packages-{{ checksum "yarn.lock" }} - - run: - name: Install Dependencies - command: bash scripts/install-ci-deps.sh + - v7-yarn-packages-{{ checksum "yarn.lock" }} + - run: yarn install - save_cache: - name: Save Yarn Package Cache - key: v2-yarn-packages-{{ checksum "yarn.lock" }} + key: v7-yarn-packages-{{ checksum "yarn.lock" }} paths: - - node_modules/ - - run: - name: Lint - command: yarn lint - - run: - 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 + - node_modules + - run: yarn lint + - run: ./node_modules/.bin/prettier -l "{src,webpack,.storybook,static/i18n}/**/*.js" + - run: yarn flow --quiet + - run: yarn release diff --git a/package.json b/package.json index 74769625..d2e5b857 100644 --- a/package.json +++ b/package.json @@ -7,20 +7,19 @@ "author": "Ledger", "license": "MIT", "scripts": { - "compile": "bash ./scripts/compile.sh", - "dist:dir": "bash ./scripts/dist-dir.sh", + "postinstall": "bash ./scripts/postinstall.sh", + "start": "bash ./scripts/start.sh", + "release": "bash ./scripts/release.sh", "dist": "bash ./scripts/dist.sh", - "test": "jest", - "flow": "flow", + "dist:dir": "bash ./scripts/dist-dir.sh", + "compile": "bash ./scripts/compile.sh", "lint": "eslint src webpack .storybook", - "ci": "yarn lint && yarn flow && yarn prettier", - "postinstall": "bash ./scripts/postinstall.sh", + "flow": "flow", "prettier": "prettier --write \"{src,webpack,.storybook,static/i18n}/**/*.{js,json}\"", - "publish-storybook": "bash ./scripts/publish-storybook.sh", - "release": "bash ./scripts/release.sh", - "start": "bash ./scripts/start.sh", + "ci": "yarn lint && yarn flow && yarn prettier", "storybook": "NODE_ENV=development STORYBOOK_ENV=1 start-storybook -s ./static -p 4444", - "reset-files": "bash ./scripts/reset-files.sh" + "publish-storybook": "bash ./scripts/legacy/publish-storybook.sh", + "reset-files": "bash ./scripts/legacy/reset-files.sh" }, "electronWebpack": { "title": true, @@ -31,9 +30,6 @@ "webpackConfig": "./webpack/main.config.js" } }, - "resolutions": { - "webpack-sources": "1.0.1" - }, "dependencies": { "@ledgerhq/hw-app-btc": "4.20.0", "@ledgerhq/hw-app-eth": "^4.14.0", diff --git a/scripts/compile.sh b/scripts/compile.sh old mode 100644 new mode 100755 index a47eac75..fe1bb191 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -2,12 +2,38 @@ set -e -GIT_REVISION=$(git rev-parse HEAD) +# shellcheck disable=SC1091 +source scripts/helpers/format.sh +# shellcheck disable=SC1091 +source scripts/helpers/run-job.sh + +if [ "$GIT_REVISION" == "" ]; then + GIT_REVISION=$(git rev-parse HEAD) +fi 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 +export SENTRY_URL='https://db8f5b9b021048d4a401f045371701cb@sentry.io/274561' +export JOBS='max' + +echo +formatEnvVar 'GIT_REVISION' +formatEnvVar 'SENTRY_URL' +echo + +runJob \ + "rm -rf dist" \ + "clearing dist..." \ + "dist cleared" \ + "failed to clear dist" + +runJob \ + "NODE_ENV=production yarn run webpack-cli --mode production --config webpack/internals.config.js" \ + "building internal bundle..." \ + "internal bundle built" \ + "failed to build internal bundle" + +runJob \ + "NODE_ENV=production yarn run electron-webpack" \ + "building main & renderer bundles..." \ + "main & renderer bundles built" \ + "failed to build main & renderer bundles" diff --git a/scripts/dist-dir.sh b/scripts/dist-dir.sh old mode 100644 new mode 100755 index 64097c15..9a61b12d --- a/scripts/dist-dir.sh +++ b/scripts/dist-dir.sh @@ -1,3 +1,18 @@ #!/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" diff --git a/scripts/dist.sh b/scripts/dist.sh index 51f4fcee..109af19d 100755 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -1,16 +1,41 @@ #!/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 # 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 + 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 -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 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 diff --git a/scripts/hash-utils.sh b/scripts/hash-utils.sh deleted file mode 100644 index 07b1ab73..00000000 --- a/scripts/hash-utils.sh +++ /dev/null @@ -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" -} diff --git a/scripts/helpers/display-env.sh b/scripts/helpers/display-env.sh new file mode 100644 index 00000000..2407d0f9 --- /dev/null +++ b/scripts/helpers/display-env.sh @@ -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 diff --git a/scripts/helpers/format.sh b/scripts/helpers/format.sh new file mode 100644 index 00000000..8a2b826f --- /dev/null +++ b/scripts/helpers/format.sh @@ -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" +} diff --git a/scripts/helpers/hash.sh b/scripts/helpers/hash.sh new file mode 100644 index 00000000..3f52f5d0 --- /dev/null +++ b/scripts/helpers/hash.sh @@ -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 +} diff --git a/scripts/helpers/run-job.sh b/scripts/helpers/run-job.sh new file mode 100644 index 00000000..89b03f4b --- /dev/null +++ b/scripts/helpers/run-job.sh @@ -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 +} diff --git a/scripts/install-ci-deps.sh b/scripts/install-ci-deps.sh deleted file mode 100644 index 3ed79367..00000000 --- a/scripts/install-ci-deps.sh +++ /dev/null @@ -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 diff --git a/scripts/live-cli.js b/scripts/live-cli.js deleted file mode 100644 index b08b40c4..00000000 --- a/scripts/live-cli.js +++ /dev/null @@ -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] -} diff --git a/scripts/parse-accounts.js b/scripts/parse-accounts.js deleted file mode 100644 index f5b0b8c2..00000000 --- a/scripts/parse-accounts.js +++ /dev/null @@ -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) diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index eeed781a..0d302214 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -1,45 +1,85 @@ #!/bin/bash +set -e + +export JOBS=max + +# shellcheck disable=SC1091 +source scripts/helpers/display-env.sh # 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 { - if ! $CI; then - REBUILD_ELECTRON_NATIVE_DEPS +function main { + + # native dependencies + + if hashDiffers yarn.lock "$(getYarnHash)"; then + rebuildElectronNativeDeps + else + formatSkip "native module build" "already up-to-date" 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" + # 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 - 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" + if hashDiffers flow-typed "$latestFlowTypedCommitHash"; then + installFlowTyped + else + formatSkip "flow-typed installation" "already up-to-date" + fi fi + + echo + } -function REBUILD_ELECTRON_NATIVE_DEPS { - # for strange/fancy os-es +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 getYarnHash { 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" + yarnHash=$(md5 yarn.lock | cut -d ' ' -f 1) else - echo "> Installing electron native deps" - DEBUG=electron-builder electron-builder install-app-deps - SET_HASH 'package.json' "$PACKAGE_JSON_HASH" + yarnHash=$(md5sum yarn.lock | cut -d ' ' -f 1) fi + echo "$yarnHash" } -MAIN +main diff --git a/scripts/release.sh b/scripts/release.sh index 29efdf21..fb3afae7 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -2,6 +2,22 @@ set -e +# shellcheck disable=SC1091 +source scripts/helpers/run-job.sh + +# shellcheck disable=SC1091 +source scripts/helpers/display-env.sh + +if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then + echo "You are not on master. Exiting properly. (CI)" + exit 0 +fi + +if ! git describe --exact-match --tags 2>/dev/null >/dev/null; then + echo "You are not on a tag. Exiting properly. (CI)" + exit 0 +fi + if [ -z "$GH_TOKEN" ]; then echo "GH_TOKEN is unset. can't release" >&2 exit 1 @@ -21,4 +37,10 @@ fi # TODO check if local git HEAD is EXACTLY our remote master HEAD yarn compile -DEBUG=electron-builder yarn run electron-builder build --publish always + +runJob \ + "DEBUG=electron-builder electron-builder build --publish always" \ + "building, packaging and publishing app..." \ + "app built, packaged and published successfully" \ + "failed to build app" \ + "verbose" diff --git a/scripts/reset-files.sh b/scripts/reset-files.sh old mode 100644 new mode 100755 diff --git a/scripts/start.sh b/scripts/start.sh index 01a7084e..3bb0aa45 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,5 +1,8 @@ #!/bin/bash +# shellcheck disable=SC1091 +source scripts/helpers/display-env.sh + concurrently --raw --kill-others \ "cross-env NODE_ENV=development webpack-cli --mode development --watch --config webpack/internals.config.js" \ "cross-env NODE_ENV=development electron-webpack dev" diff --git a/yarn.lock b/yarn.lock index a7acbc9c..9c534274 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14712,13 +14712,20 @@ webpack-merge@^4.1.2: dependencies: lodash "^4.17.5" -webpack-sources@1.0.1, webpack-sources@^1.0.1, webpack-sources@^1.1.0: +webpack-sources@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" dependencies: source-list-map "^2.0.0" source-map "~0.5.3" +webpack-sources@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54" + dependencies: + source-list-map "^2.0.0" + source-map "~0.6.1" + webpack@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.12.0.tgz#3f9e34360370602fcf639e97939db486f4ec0d74"