这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c5c6de3
Add flag to .env file to turn off auto-update
ZIMkaRU Nov 23, 2022
7499626
Add option to electron-builder conf to turn off auto-update
ZIMkaRU Nov 23, 2022
aa7084d
Add option to github action workflow to turn off auto-update
ZIMkaRU Nov 23, 2022
111dbf7
Add env var to docker-compose file to turn off auto-update
ZIMkaRU Nov 23, 2022
f874a0d
Add option to bash scripts to turn off auto-update
ZIMkaRU Nov 23, 2022
15bdc9b
Add helper to detect that auto-update is disabled
ZIMkaRU Nov 23, 2022
2f12b1a
Add ability to turn off auto-update
ZIMkaRU Nov 23, 2022
7779bd3
Add option to readme file about turn off auto-update
ZIMkaRU Nov 23, 2022
48b4271
Change auto-update management via env var
ZIMkaRU Nov 24, 2022
e272bcf
Add electronEnv.json.example file
ZIMkaRU Nov 24, 2022
edd2d37
Add electronEnv.json file to dockerignore
ZIMkaRU Nov 24, 2022
b0c9e67
Change bash scripts to manage auto-update via env var
ZIMkaRU Nov 24, 2022
f36c164
Change gh actions workflow to manage auto-update via env var
ZIMkaRU Nov 24, 2022
cea7198
Fix url to get api keys
ZIMkaRU Dec 6, 2022
c90d7d1
Merge pull request #172 from ZIMkaRU/bugfix/fix-url-to-get-api-keys
ezewer Dec 6, 2022
6b6fe3f
Bump version up to v4.0.0
ZIMkaRU Dec 9, 2022
8a50278
Add changelog for v4.0.0
ZIMkaRU Dec 9, 2022
38d1a6f
Merge pull request #170 from ZIMkaRU/feature/add-ability-to-turn-off-…
prdn Dec 9, 2022
2fdf6f6
Update sub-modules
ZIMkaRU Dec 14, 2022
2223bae
Merge pull request #174 from ZIMkaRU/feature/release-electron-app
ezewer Dec 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*Dockerfile*
*docker-compose*
lastCommit.json
electronEnv.json
dev-app-update.yml
dist
bfx-reports-framework/db/*.db
Expand Down
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
REPO_BRANCH=master
IS_BFX_API_STAGING=0
IS_DEV_ENV=0
IS_AUTO_UPDATE_DISABLED=0
EP_GH_IGNORE_TIME=true
GH_TOKEN=
11 changes: 11 additions & 0 deletions .github/workflows/build-electron-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
version:
description: 'Release version'
required: false
isAutoUpdateDisabled:
description: 'Is auto-update disabled (true / 1)?'
required: false

env:
DOCKER_BUILDKIT: 1
Expand All @@ -38,6 +41,10 @@ jobs:
sed -i -e \
"s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/g" \
"./package.json"
- if: contains(fromJson('["true", "1", true, 1]'), github.event.inputs.isAutoUpdateDisabled)
name: Turn off auto-update
run: |
echo "IS_AUTO_UPDATE_DISABLED=1" >> $GITHUB_ENV
- name: Cache Docker images
uses: ScribeMD/docker-cache@0.1.4
env:
Expand Down Expand Up @@ -92,6 +99,10 @@ jobs:
sed -i -e \
"s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/g" \
"./package.json"
- if: contains(fromJson('["true", "1", true, 1]'), github.event.inputs.isAutoUpdateDisabled)
name: Turn off auto-update
run: |
echo "IS_AUTO_UPDATE_DISABLED=1" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: 14.16.0
Expand Down
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.0.0] - 2022-12-09

### Added

- Added `ENET` errors for reconnection when fetching data from the `BFX api_v2`. PR: [bfx-report#273](https://github.com/bitfinexcom/bfx-report/pull/273)
- Added ability to use the `inner max` request limit to the `BFX api_v2` to seed up syncing data. PR: [bfx-report#274](https://github.com/bitfinexcom/bfx-report/pull/274)
- Added ability to display minimum derivative fees between sub-accounts. PR: [bfx-reports-framework#241](https://github.com/bitfinexcom/bfx-reports-framework/pull/241)
- Added ability to turn off the auto-update while building releases using the env var `IS_AUTO_UPDATE_DISABLED=1` or the popup of GitHub Actions for `beta` releases [bfx-report-electron#170](https://github.com/bitfinexcom/bfx-report-electron/pull/170)
- Added reports for Turkey. PR: [bfx-report-ui#561](https://github.com/bitfinexcom/bfx-report-ui/pull/561)
- Implemented selected auth type persisting if the `Remember Me` option is selected for improving UX during page/app reloading. PR: [bfx-report-ui#568](https://github.com/bitfinexcom/bfx-report-ui/pull/568)
- Implemented sub-accounts handling progress indicator, to improve UX for the cases when creation/updating requests can take some time due to slow network connection, etc. PR: [bfx-report-ui#573](https://github.com/bitfinexcom/bfx-report-ui/pull/573)

### Changed

- Provided a `new Sync Core` to use temp tables during sync processing. PR: [bfx-reports-framework#240](https://github.com/bitfinexcom/bfx-reports-framework/pull/240). The main idea is to put data fetched from the BFX api_v2 to temp tables to have consistent data in the main tables and allow users to request reports from all sections any time even sync is going on, except the first sync when the DB is empty. When the sync is finished and temp tables are filled all data will be moved to the main tables in one atomic transaction thus users don't have to experience transitional processes. Basic changes:
- Implemened `new Sync Core` to use temp tables
- Improved transaction flow to fix the `database is locked` issue
- Improved handling `ENET` errors from the `BFX api_v2`, added fetching data retries. Related to PR: [bfx-report#275](https://github.com/bitfinexcom/bfx-report/pull/275)
- Added DB migration `v31`
- Added create and update timestamps to service tables for easier debugging
- Significantly reduced the number of requests to the `BFX api_v2`, which increases the speed of the sync
- Fixed WebSocket timeout connection issue
- Reduced pragma `analysis_limit` to `400` for performance
- Used `inner max` request limit to `BFX api_v2` for syncing data to speed up
- Actualized Spanish translations PR: [bfx-report-ui#562](https://github.com/bitfinexcom/bfx-report-ui/pull/562)
- Improved invoices for not merchant users. PR: [bfx-report-ui#565](https://github.com/bitfinexcom/bfx-report-ui/pull/565)
- Increased `Fee Perc` precision in the `Trades` report to 3 decimals for better representation. PR: [bfx-report-ui#570](https://github.com/bitfinexcom/bfx-report-ui/pull/570)

### Fixed

- Fixed WebSocket `GRENACHE_WS_IS_CLOCED` error. PR: [bfx-reports-framework#239](https://github.com/bitfinexcom/bfx-reports-framework/pull/239)
- Fixed `URL` to get API keys when sign-in. PRs: [bfx-report-electron#172](https://github.com/bitfinexcom/bfx-report-electron/pull/172), [bfx-report-ui#582](https://github.com/bitfinexcom/bfx-report-ui/pull/582)
- Fixed incorrect `rate` filter param type and value passing from `Public Funding` report. PR: [bfx-report-ui#553](https://github.com/bitfinexcom/bfx-report-ui/pull/553)
- Fixed reports exporting. PR: [bfx-report-ui#558](https://github.com/bitfinexcom/bfx-report-ui/pull/558)
- Fixed wrong auth via WebSockets for `sub-accounts`. PR: [bfx-report-ui#566](https://github.com/bitfinexcom/bfx-report-ui/pull/566)
- Prevented redirection to the `Sign In` screen after the successful adding a sub-account for improving UX if the user wants to add several sub-accounts in a row. PR: [bfx-report-ui#571](https://github.com/bitfinexcom/bfx-report-ui/pull/571)
- Fixed the possibility of creating several sub-accounts with one request in the `Multiple Accounts` sign up modal same way as we have in the main `Sub Accounts` section. PR: [bfx-report-ui#572](https://github.com/bitfinexcom/bfx-report-ui/pull/572)
- Fixed missed time frame start/end params provided during exporting in CSV for `Average Win/Loss`, `Traded Volume`, `Account Balance`, `Loan` and `Fees` reports. PR: [bfx-report-ui#575](https://github.com/bitfinexcom/bfx-report-ui/pull/575)
- Prevented the possibility for already created `sub-accounts` to being selected for the creation of new one. PR: [bfx-report-ui#576](https://github.com/bitfinexcom/bfx-report-ui/pull/576)
- Fixed issue with the staled `Master Account` still selected after the dropping database, restarting the backend and reloading the app. PR: [bfx-report-ui#577](https://github.com/bitfinexcom/bfx-report-ui/pull/577)
- Prevented the possibility of `Sub Account` creation submission if the `Master Account` hadn't been selected or registered, fixed `Sign Up` modal overlay styling. PR: [bfx-report-ui#578](https://github.com/bitfinexcom/bfx-report-ui/pull/578)
- Fixed issue with stuck sync progress percentage when the main worker is restarted while the synchronization is in progress and UI performs a successful reconnection via WebSockets. PR: [bfx-report-ui#579](https://github.com/bitfinexcom/bfx-report-ui/pull/579)
- Fixed `USDt` symbols and pairs parsing. PR: [bfx-report-ui#580](https://github.com/bitfinexcom/bfx-report-ui/pull/580)
- Fixed `sign-out` issue by providing token. PR: [bfx-report-ui#583](https://github.com/bitfinexcom/bfx-report-ui/pull/583)
- Fixed issues with unavailability for selection registered users while creating `Sub Accounts` in some cases. PR: [bfx-report-ui#584](https://github.com/bitfinexcom/bfx-report-ui/pull/584)

### Security

- Updated dependencies versions to fix vulnerabilities. PRs: [bfx-facs-db-better-sqlite#4](https://github.com/bitfinexcom/bfx-facs-db-better-sqlite/pull/4), [bfx-report-express#28](https://github.com/bitfinexcom/bfx-report-express/pull/28), [bfx-report#276](https://github.com/bitfinexcom/bfx-report/pull/276), [bfx-reports-framework#242](https://github.com/bitfinexcom/bfx-reports-framework/pull/242)

## [3.8.1] - 2022-09-29

### Changed
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Options:
-o Sync only sub-modules
-s Use staging BFX API
-d Set development environment
-u Turn off auto-update
-h Display help
```

Expand Down Expand Up @@ -137,6 +138,7 @@ Options:
-o Sync only sub-modules
-s Use staging BFX API
-d Set development environment
-u Turn off auto-update
-p Publish artifacts
-h Display help
```
Expand Down
2 changes: 1 addition & 1 deletion bfx-report-ui
Submodule bfx-report-ui updated 169 files
2 changes: 1 addition & 1 deletion bfx-reports-framework
Submodule bfx-reports-framework updated 68 files
+1 −1 bfx-report-ui
+7 −8 package.json
+1 −1 test/6-update-sub-account.spec.js
+3 −1 test/helpers/helpers.core.js
+9 −0 test/test-cases/api-sync-mode-sqlite-test-cases.js
+2 −1 workers/api.framework.report.wrk.js
+26 −5 workers/loc.api/di/app.deps.js
+2 −2 workers/loc.api/di/factories/data-inserter-factory.js
+3 −1 workers/loc.api/di/factories/index.js
+36 −0 workers/loc.api/di/factories/sync-user-step-data-factory.js
+5 −1 workers/loc.api/di/types.js
+33 −5 workers/loc.api/errors/index.js
+58 −8 workers/loc.api/helpers/utils.js
+4 −1 workers/loc.api/process.message.manager/index.js
+48 −31 workers/loc.api/service.report.framework.js
+85 −65 workers/loc.api/sync/authenticator/index.js
+85 −11 workers/loc.api/sync/currency.converter/index.js
+354 −165 workers/loc.api/sync/dao/dao.better.sqlite.js
+13 −6 workers/loc.api/sync/dao/dao.js
+1 −4 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/abstract.migration.js
+15 −0 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/helpers/const.js
+5 −3 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/helpers/get-sql-arr-to-modify-columns.js
+1 −4 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v28.js
+1 −2 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v3.js
+339 −0 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v31.js
+1 −2 workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v5.js
+21 −12 workers/loc.api/sync/dao/helpers/get-index-creation-query.js
+2 −2 workers/loc.api/sync/dao/helpers/get-insertable-array-objects-filter.js
+15 −6 workers/loc.api/sync/dao/helpers/get-table-creation-query.js
+19 −7 workers/loc.api/sync/dao/helpers/get-trigger-creation-query.js
+13 −17 workers/loc.api/sync/dao/helpers/manage-transaction/index.js
+5 −4 workers/loc.api/sync/dao/helpers/serialization/serialize-obj.js
+6 −2 workers/loc.api/sync/dao/sqlite-worker/db-worker-actions/action-run-in-trans.js
+0 −14 workers/loc.api/sync/data.inserter/data.checker/helpers/compare-elems-db-and-api.js
+1 −11 workers/loc.api/sync/data.inserter/data.checker/helpers/index.js
+0 −11 workers/loc.api/sync/data.inserter/data.checker/helpers/invert-sort.js
+0 −73 workers/loc.api/sync/data.inserter/data.checker/helpers/push-configurable-data-start-conf.js
+415 −492 workers/loc.api/sync/data.inserter/data.checker/index.js
+9 −4 workers/loc.api/sync/data.inserter/helpers/get-method-arg-map.js
+7 −5 workers/loc.api/sync/data.inserter/helpers/search-close-price-and-sum-amount.js
+15 −4 workers/loc.api/sync/data.inserter/helpers/utils.js
+39 −8 workers/loc.api/sync/data.inserter/hooks/convert.currency.hook.js
+89 −31 workers/loc.api/sync/data.inserter/hooks/recalc.sub.account.ledgers.balances.hook.js
+457 −453 workers/loc.api/sync/data.inserter/index.js
+145 −0 workers/loc.api/sync/data.inserter/sync.temp.tables.manager/index.js
+7 −0 workers/loc.api/sync/data.inserter/sync.user.step.manager/helpers/index.js
+13 −0 workers/loc.api/sync/data.inserter/sync.user.step.manager/helpers/invert-orders.js
+450 −0 workers/loc.api/sync/data.inserter/sync.user.step.manager/index.js
+124 −0 workers/loc.api/sync/data.inserter/sync.user.step.manager/sync.user.step.data.js
+4 −0 workers/loc.api/sync/helpers/calc-grouped-data.js
+5 −0 workers/loc.api/sync/helpers/group-by-timeframe.js
+43 −5 workers/loc.api/sync/helpers/redirect-requests-to-api.js
+36 −11 workers/loc.api/sync/index.js
+19 −8 workers/loc.api/sync/positions.snapshot/index.js
+27 −9 workers/loc.api/sync/schema/colls.types.js
+35 −0 workers/loc.api/sync/schema/common.constraints.js
+40 −0 workers/loc.api/sync/schema/common.triggers.js
+111 −179 workers/loc.api/sync/schema/models.js
+13 −23 workers/loc.api/sync/schema/sync-schema.js
+2 −2 workers/loc.api/sync/schema/tables-names.js
+48 −44 workers/loc.api/sync/schema/utils/check-coll-type.js
+10 −12 workers/loc.api/sync/schema/utils/index.js
+123 −94 workers/loc.api/sync/sub.account/index.js
+55 −132 workers/loc.api/sync/sync.colls.manager/index.js
+69 −15 workers/loc.api/sync/sync.queue/index.js
+25 −30 workers/loc.api/sync/trades/index.js
+5 −5 workers/loc.api/sync/win.loss.vs.account.balance/index.js
+13 −13 workers/loc.api/sync/win.loss/index.js
3 changes: 3 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
COMMON_DIST_FOLDER: /dist
IS_BFX_API_STAGING: ${IS_BFX_API_STAGING:-0}
IS_DEV_ENV: ${IS_DEV_ENV:-0}
IS_AUTO_UPDATE_DISABLED: ${IS_AUTO_UPDATE_DISABLED:-0}
IS_PUBLISHED: ${IS_PUBLISHED:-0}
GH_TOKEN: ${GH_TOKEN:-}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
Expand All @@ -49,6 +50,7 @@ services:
COMMON_DIST_FOLDER: /dist
IS_BFX_API_STAGING: ${IS_BFX_API_STAGING:-0}
IS_DEV_ENV: ${IS_DEV_ENV:-0}
IS_AUTO_UPDATE_DISABLED: ${IS_AUTO_UPDATE_DISABLED:-0}
IS_PUBLISHED: ${IS_PUBLISHED:-0}
GH_TOKEN: ${GH_TOKEN:-}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
Expand All @@ -72,6 +74,7 @@ services:
COMMON_DIST_FOLDER: /dist
IS_BFX_API_STAGING: ${IS_BFX_API_STAGING:-0}
IS_DEV_ENV: ${IS_DEV_ENV:-0}
IS_AUTO_UPDATE_DISABLED: ${IS_AUTO_UPDATE_DISABLED:-0}
IS_PUBLISHED: ${IS_PUBLISHED:-0}
GH_TOKEN: ${GH_TOKEN:-}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
Expand Down
4 changes: 4 additions & 0 deletions electronEnv.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"NODE_ENV": "production",
"IS_AUTO_UPDATE_DISABLED": false
}
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict'

try {
const { NODE_ENV } = require('./electronEnv.json')
const envVars = require('./electronEnv.json')

if (
!process.env.NODE_ENV &&
NODE_ENV
) {
process.env.NODE_ENV = NODE_ENV
for (const [key, val] of Object.entries(envVars)) {
if (typeof process.env[key] !== 'undefined') {
continue
}

process.env[key] = val
}
} catch (err) {}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-report-electron",
"version": "3.8.1",
"version": "4.0.0",
"repository": "https://github.com/bitfinexcom/bfx-report-electron",
"description": "Reporting tool",
"author": "bitfinex.com",
Expand Down
25 changes: 23 additions & 2 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ buildWin=0
buildMac=0
isBfxApiStaging=${IS_BFX_API_STAGING:-0}
isDevEnv=${IS_DEV_ENV:-0}
isAutoUpdateDisabled=${IS_AUTO_UPDATE_DISABLED:-0}
isPublished=${IS_PUBLISHED:-0}

function usage {
Expand All @@ -67,6 +68,7 @@ function usage {
-m Build Mac release
-s Use staging BFX API
-d Set development environment
-u Turn off auto-update
-p Publish artifacts
-h Display help\
${COLOR_NORMAL}" 1>&2
Expand All @@ -85,6 +87,7 @@ while getopts "lwmsdph" opt; do
m) buildMac=1;;
s) isBfxApiStaging=1;;
d) isDevEnv=1;;
u) isAutoUpdateDisabled=1;;
p) isPublished=1;;
h)
usage
Expand Down Expand Up @@ -129,15 +132,33 @@ if [ $buildMac == 1 ]; then
targetPlatform="mac"
fi

cp "$ROOT/$ELECTRON_ENV_FILE_NAME.example" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"

if [ $isBfxApiStaging == 1 ]; then
bfxApiUrl="$STAGING_BFX_API_URL"
fi
if [ $isDevEnv == 1 ]; then
echo -e "\n${COLOR_YELLOW}Developer environment is turned on!${COLOR_NORMAL}"

echo "{\"NODE_ENV\":\"development\"}" > "$ROOT/$ELECTRON_ENV_FILE_NAME"
sed -i -e \
"s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"development\"/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
else
sed -i -e \
"s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"production\"/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
fi
if [ $isAutoUpdateDisabled == 1 ]; then
echo -e "\n${COLOR_YELLOW}Auto-update is turned off!${COLOR_NORMAL}"

sed -i -e \
"s/\"IS_AUTO_UPDATE_DISABLED\": .*/\"IS_AUTO_UPDATE_DISABLED\": true/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
else
rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME"
sed -i -e \
"s/\"IS_AUTO_UPDATE_DISABLED\": .*/\"IS_AUTO_UPDATE_DISABLED\": false/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
fi

changeDirOwnershipToCurrUser "$ELECTRON_CACHE" "$(id -u):$(id -g)"
Expand Down
19 changes: 12 additions & 7 deletions scripts/build-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ COLOR_YELLOW=${COLOR_YELLOW:-"\033[33m"}
COLOR_BLUE=${COLOR_BLUE:-"\033[34m"}
COLOR_NORMAL=${COLOR_NORMAL:-"\033[39m"}

BFX_API_URL="${BFX_API_URL:-"https://api-pub.bitfinex.com"}"
STAGING_BFX_API_URL="${STAGING_BFX_API_URL:-"https://api.staging.bitfinex.com"}"
BFX_HOME_URL="${BFX_HOME_URL:-"https://bitfinex.com"}"
BFX_KEY_URL="${BFX_KEY_URL:-"https://setting.bitfinex.com/api"}"
STAGING_BFX_HOME_URL="${STAGING_BFX_HOME_URL:-"https://staging.bitfinex.com"}"
STAGING_BFX_KEY_URL="${STAGING_BFX_KEY_URL:-"https://bfx-ui-settings.staging.bitfinex.com/api"}"
BACKEND_ADDRESS="${BACKEND_ADDRESS:-"localhost:34343"}"

UI_FOLDER="${UI_FOLDER:-"$ROOT/bfx-report-ui"}"
Expand All @@ -35,7 +37,8 @@ source "$ROOT/scripts/helpers/escape-string.sh"
source "$ROOT/scripts/helpers/change-dir-ownership-to-curr-user.sh"

programname=$0
bfxApiUrl="$BFX_API_URL"
bfxHomeUrl="$BFX_HOME_URL"
bfxKeyUrl="$BFX_KEY_URL"

isBfxApiStaging=${IS_BFX_API_STAGING:-0}
isDevEnv=${IS_DEV_ENV:-0}
Expand Down Expand Up @@ -70,7 +73,8 @@ while getopts "sdh" opt; do
done

if [ $isBfxApiStaging == 1 ]; then
bfxApiUrl="$STAGING_BFX_API_URL"
bfxHomeUrl="$STAGING_BFX_HOME_URL"
bfxKeyUrl="$STAGING_BFX_KEY_URL"
fi
if [ $isDevEnv == 1 ]; then
echo -e "\n${COLOR_YELLOW}UI developer environment is turned on!${COLOR_NORMAL}"
Expand All @@ -87,9 +91,10 @@ fi

echo -e "\n${COLOR_BLUE}Setting UI configs${COLOR_NORMAL}"

escapedBfxApiUrl=$(escapeString $bfxApiUrl)
escapedBfxHomeUrl=$(escapeString $bfxHomeUrl)
escapedBfxKeyUrl=$(escapeString $bfxKeyUrl)
sed -i -e \
"s/HOME_URL: .*,/HOME_URL: \'$escapedBfxApiUrl\',/g" \
"s/HOME_URL: .*,/HOME_URL: \'$escapedBfxHomeUrl\',/g" \
"$UI_CONFIGS_FILE"
sed -i -e \
"s/API_URL: .*,/API_URL: \'http:\/\/${BACKEND_ADDRESS}\/api\',/g" \
Expand All @@ -98,7 +103,7 @@ sed -i -e \
"s/WS_ADDRESS: .*,/WS_ADDRESS: \'ws:\/\/${BACKEND_ADDRESS}\/ws\',/g" \
"$UI_CONFIGS_FILE"
sed -i -e \
"s/KEY_URL: .*,/KEY_URL: \'$escapedBfxApiUrl\/api\',/g" \
"s/KEY_URL: .*,/KEY_URL: \'$escapedBfxKeyUrl\/api\',/g" \
"$UI_CONFIGS_FILE"

sed -i -e \
Expand Down
6 changes: 6 additions & 0 deletions scripts/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ syncRepo=0
syncSubModules=0
isBfxApiStaging=${IS_BFX_API_STAGING:-0}
isDevEnv=${IS_DEV_ENV:-0}
isAutoUpdateDisabled=${IS_AUTO_UPDATE_DISABLED:-0}
isPublished=${IS_PUBLISHED:-0}

function usage {
Expand All @@ -42,6 +43,7 @@ function usage {
-o Sync only sub-modules
-s Use staging BFX API
-d Set development environment
-u Turn off auto-update
-p Publish artifacts
-h Display help\
${COLOR_NORMAL}" 1>&2
Expand All @@ -67,6 +69,7 @@ while getopts "alwmrosdph" opt; do
o) syncSubModules=1;;
s) isBfxApiStaging=1;;
d) isDevEnv=1;;
u) isAutoUpdateDisabled=1;;
p) isPublished=1;;
h)
usage
Expand Down Expand Up @@ -94,6 +97,9 @@ fi
if [ $isDevEnv == 1 ]; then
export IS_DEV_ENV=1
fi
if [ $isAutoUpdateDisabled == 1 ]; then
export IS_AUTO_UPDATE_DISABLED=1
fi
if [ $isPublished == 1 ]; then
export IS_PUBLISHED=1
fi
Expand Down
25 changes: 23 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ syncRepo=0
syncSubModules=0
isBfxApiStaging=${IS_BFX_API_STAGING:-0}
isDevEnv=${IS_DEV_ENV:-0}
isAutoUpdateDisabled=${IS_AUTO_UPDATE_DISABLED:-0}

function usage {
echo -e "\
Expand All @@ -49,6 +50,7 @@ function usage {
-o Sync only sub-modules
-s Use staging BFX API
-d Set development environment
-u Turn off auto-update
-h Display help\
${COLOR_NORMAL}" 1>&2
}
Expand All @@ -59,6 +61,7 @@ while getopts "rosdh" opt; do
o) syncSubModules=1;;
s) isBfxApiStaging=1;;
d) isDevEnv=1;;
u) isAutoUpdateDisabled=1;;
h)
usage
exit 0
Expand All @@ -71,15 +74,33 @@ while getopts "rosdh" opt; do
esac
done

cp "$ROOT/$ELECTRON_ENV_FILE_NAME.example" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"

if [ $isBfxApiStaging == 1 ]; then
bfxApiUrl="$STAGING_BFX_API_URL"
fi
if [ $isDevEnv == 1 ]; then
echo -e "\n${COLOR_YELLOW}Developer environment is turned on!${COLOR_NORMAL}"

echo "{\"NODE_ENV\":\"development\"}" > "$ROOT/$ELECTRON_ENV_FILE_NAME"
sed -i -e \
"s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"development\"/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
else
sed -i -e \
"s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"production\"/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
fi
if [ $isAutoUpdateDisabled == 1 ]; then
echo -e "\n${COLOR_YELLOW}Auto-update is turned off!${COLOR_NORMAL}"

sed -i -e \
"s/\"IS_AUTO_UPDATE_DISABLED\": .*/\"IS_AUTO_UPDATE_DISABLED\": true/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
else
rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME"
sed -i -e \
"s/\"IS_AUTO_UPDATE_DISABLED\": .*/\"IS_AUTO_UPDATE_DISABLED\": false/g" \
"$ROOT/$ELECTRON_ENV_FILE_NAME"
fi

if [ $syncRepo == 1 ]; then
Expand Down
Loading