@abtnode/webapp 中文文档教程
ABT Node Web
用于管理 ABT 节点的 Web 仪表板
建立在:
- @abtnode/qgl
- @abtnode/client
- @abtnode/cli
1. Configuration
- create
.env.development
- copy follow texts to
.env.development
, changeABT_NODE_BASE_URL
to your local lan ip
# CAUTION: this is required to eliminate create-react-scripts complainings
SKIP_PREFLIGHT_CHECK=true
ABT_NODE_SESSION_SECRET="49bcf865c77a15993d87245b124bbc5125d2c3997437d1fda3"
ABT_NODE_SESSION_TTL="1d"
ABT_NODE_SK="0x338003c9b11cd9cb49a8c68db3ddeb860b394ab8d926d94cd917c14c1b9a805b6d4cba304e7f957facb2bfa11132a6688c233d75fa710f8bde469be6cbba5a81"
ABT_NODE_PORT="3030"
ABT_NODE_MODE="production"
ABT_NODE_NAME="ABT Node (Dev)"
ABT_NODE_DESCRIPTION="Web Interface to manage your ABT Node"
# e.g. http://192.168.1.2:3030
ABT_NODE_BASE_URL="http://<YOUR LOCAL LAN IP>:3030"
ABT_NODE_LOG_LEVEL="info"
2. Start the webapp
您需要 4 个终端窗口来分别启动客户端和服务器:
cd core/webapp
DEBUG=* npm run start:hub
DEBUG=@abtnode/*,@arcblock/* npm run start:daemon
DEBUG=@abtnode/*,@arcblock/* npm run start:service
DEBUG=@abtnode/* npm run start:client
现在,您已准备好破解 ABT 节点仪表板。
How to run as production from your local source?
以下步骤要求您对存储库进行有效设置,这意味着您可以在开发模式下启动仪表板。
Build the dashboard
cd core/webapp && npm run build:client && npm run build:daemon
Create symbolic link for CLI
ln -s /path/to/abtnode-repo/core/cli/bin/abtnode.js /usr/local/bin/an
Run your local copy
# optional: create a new instance for test
an stop
rm -rf ~/.abtnode*
an init
# start with latest code
an start
如果你本地的 nginx 不能监听 80 和 443 端口,你可以让它监听其他端口:
ABT_NODE_HTTP_PORT=8080 ABT_NODE_HTTPS_PORT=8443 an start
然后,使用端口转发从 80 重定向流量 =>; 8080 和 443 => 8443:
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef -
Coverage
此包的覆盖范围包含 3 个部分:
- api: collected using jest, configured in
jest.config.js
, result incoverage-api
- src: collected using react-script, configured in
jest
inpackage.json
, result incoverage
- e2e: collected using cypress, configured in
nyc
inpackage.json
, result incoverage-e2e
Develop blocklet in dev server
确保您的开发服务器正在运行
Goto blocklet root dir
Run command
(将/core/cli/tool/dev.js
替换为您的自定义文件夹)
为 dev.js 创建一个链接,
- Run command
ln -s <blocklet-server-source-dir>/core/cli/tool/dev.js /usr/local/bin/bn-dev
- Then you can use
bn-dev
to develop blocklet in dev server
Run migration for dev server
cd core/webapp && npm run dev:migration -- --from-version <version>
例如 npm run dev:migration -- --from-version 1.6.20
将运行高于 1.6.20 的迁移脚本
ABT Node Web
Web Dashboard to manage ABT Node
Built upon:
- @abtnode/qgl
- @abtnode/client
- @abtnode/cli
1. Configuration
- create
.env.development
- copy follow texts to
.env.development
, changeABT_NODE_BASE_URL
to your local lan ip
# CAUTION: this is required to eliminate create-react-scripts complainings
SKIP_PREFLIGHT_CHECK=true
ABT_NODE_SESSION_SECRET="49bcf865c77a15993d87245b124bbc5125d2c3997437d1fda3"
ABT_NODE_SESSION_TTL="1d"
ABT_NODE_SK="0x338003c9b11cd9cb49a8c68db3ddeb860b394ab8d926d94cd917c14c1b9a805b6d4cba304e7f957facb2bfa11132a6688c233d75fa710f8bde469be6cbba5a81"
ABT_NODE_PORT="3030"
ABT_NODE_MODE="production"
ABT_NODE_NAME="ABT Node (Dev)"
ABT_NODE_DESCRIPTION="Web Interface to manage your ABT Node"
# e.g. http://192.168.1.2:3030
ABT_NODE_BASE_URL="http://<YOUR LOCAL LAN IP>:3030"
ABT_NODE_LOG_LEVEL="info"
2. Start the webapp
You need 4 terminal windows to start the client and server separately:
cd core/webapp
DEBUG=* npm run start:hub
DEBUG=@abtnode/*,@arcblock/* npm run start:daemon
DEBUG=@abtnode/*,@arcblock/* npm run start:service
DEBUG=@abtnode/* npm run start:client
Now, you are ready to hacking the ABT Node Dashboard.
How to run as production from your local source?
Following steps requires you have a valid setup of the repo, which means you can start the dashboard in development mode.
Build the dashboard
cd core/webapp && npm run build:client && npm run build:daemon
Create symbolic link for CLI
ln -s /path/to/abtnode-repo/core/cli/bin/abtnode.js /usr/local/bin/an
Run your local copy
# optional: create a new instance for test
an stop
rm -rf ~/.abtnode*
an init
# start with latest code
an start
If your local nginx can not listen on port 80 and port 443, you can make it listen on other ports:
ABT_NODE_HTTP_PORT=8080 ABT_NODE_HTTPS_PORT=8443 an start
Then, use port forwarding to redirect traffic from 80 => 8080, and 443 => 8443:
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef -
Coverage
Coverage for this package contains 3 parts:
- api: collected using jest, configured in
jest.config.js
, result incoverage-api
- src: collected using react-script, configured in
jest
inpackage.json
, result incoverage
- e2e: collected using cypress, configured in
nyc
inpackage.json
, result incoverage-e2e
Develop blocklet in dev server
Make sure your dev server is running
Goto blocklet root dir
Run command
<blocklet-server-source-dir>/core/cli/tool/dev.js
(Replace<blocklet-server-source-dir>
to your custom folder)
Create a link for dev.js
- Run command
ln -s <blocklet-server-source-dir>/core/cli/tool/dev.js /usr/local/bin/bn-dev
- Then you can use
bn-dev
to develop blocklet in dev server
Run migration for dev server
cd core/webapp && npm run dev:migration -- --from-version <version>
e.g. npm run dev:migration -- --from-version 1.6.20
will run migration scripts greater than 1.6.20