From 1689a7a2619b40a216eec71d9a7e43c777301730 Mon Sep 17 00:00:00 2001 From: Daniel Taiakin Date: Sat, 24 Dec 2022 03:34:57 +0300 Subject: [PATCH 1/7] convinient way to exec commands --- toncli-docker.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 toncli-docker.sh diff --git a/toncli-docker.sh b/toncli-docker.sh new file mode 100755 index 0000000..e72c54e --- /dev/null +++ b/toncli-docker.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +TONCLI_CMD="toncli-local" + +# ./toncli-docker update_libs /path/to/toncli_conf_dir/ +if [[ $1 == "update_libs" ]]; then + docker run --rm -it \ + -v "$(pwd)":/code \ + -v "$2":/root/.config \ + $TONCLI_CMD update_libs +# ./toncli-docker deploy /path/to/toncli_conf_dir/ +elif [[ $1 == "deploy" ]]; then + docker run --rm -it \ + -v "$(pwd)":/code \ + -v "$2":/root/.config \ + $TONCLI_CMD deploy $@:3 +else + docker run --rm -it \ + -v "$(pwd)":/code \ + $TONCLI_CMD $@ +fi + +# all commands w/ toncli: https://github.com/disintar/toncli/blob/master/docs/advanced/commands.md \ No newline at end of file From 71838fccd4a0d90dc3bd5b3b7f997506ba83a978 Mon Sep 17 00:00:00 2001 From: Daniel Taiakin Date: Sat, 24 Dec 2022 03:37:39 +0300 Subject: [PATCH 2/7] Update README.md --- README.md | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ad25086..da873c6 100644 --- a/README.md +++ b/README.md @@ -51,37 +51,33 @@ docker build . -t toncli-local \ ## Use - You're going to need to pass your workdir as a volume to make things happen + Go to the path, where you are going to create your project (e.g. ~/your/path/dev/) ### Creating project - Run - + Run + ``` console - docker run --rm -it \ - -v ~/Dev:/code \ - toncli-local start --name test_project wallet + ./toncli-docker.sh start --name test_project wallet ``` - You're going to see the toncli project structure in *~/Dev/test_project* + You're going to see the toncli project structure in *~/your/path/dev/test_project* `README.md build fift func project.yaml tests` ### Building + + Go to your project path by `cd ~/your/path/dev/test_project` and Run - + ``` console - docker run --rm -it \ - -v ~/Dev/test_project:/code \ - toncli-local build + ./toncli-docker.sh build ``` ### Running tests - - ``` console - docker run --rm -it \ - -v ~/Dev/test_project:/code \ - toncli-local run_tests - ``` + + ``` console + ./toncli-docker.sh run_tests + ``` ### Deploying contract Now here is the tricky part. @@ -95,6 +91,13 @@ docker build . -t toncli-local \ -v /path/to/toncli_conf_dir/:/root/.config \ toncli-local update_libs ``` + + Or + + ``` console + ./toncli-docker.sh update_libs /path/to/toncli_conf_dir/ + ``` + After that you should go through standard toncli initialization dialog and pass absolute paths to the binaries - /usr/local/bin/func - /usr/local/bin/fift @@ -121,6 +124,12 @@ docker build . -t toncli-local \ -v /path/to/toncli_conf_dir/:/root/.config \ toncli-local deploy --net testnet ``` + + Or + + ``` console + ./toncli-docker.sh deploy /path/to/toncli_conf_dir/ --net testnet + ``` **wallet** directory would be created inside your local config dir with all the usefull deployment information ### General usage From 3fa90463feb3c8b31db03b48913b765339534106 Mon Sep 17 00:00:00 2001 From: Daniel <46612778+taiakindaniil@users.noreply.github.com> Date: Sat, 24 Dec 2022 15:58:52 +0300 Subject: [PATCH 3/7] Rename toncli-docker.sh to toncli-docker --- toncli-docker.sh => toncli-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename toncli-docker.sh => toncli-docker (94%) diff --git a/toncli-docker.sh b/toncli-docker similarity index 94% rename from toncli-docker.sh rename to toncli-docker index e72c54e..60904a8 100755 --- a/toncli-docker.sh +++ b/toncli-docker @@ -20,4 +20,4 @@ else $TONCLI_CMD $@ fi -# all commands w/ toncli: https://github.com/disintar/toncli/blob/master/docs/advanced/commands.md \ No newline at end of file +# all commands w/ toncli: https://github.com/disintar/toncli/blob/master/docs/advanced/commands.md From 9f2172268fe2bea69752677ef7a78ee033a9d1da Mon Sep 17 00:00:00 2001 From: Daniel <46612778+taiakindaniil@users.noreply.github.com> Date: Sat, 24 Dec 2022 16:10:38 +0300 Subject: [PATCH 4/7] Update README.md --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index da873c6..26ffc03 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,20 @@ docker build . -t toncli-local \ ## Use + + It's also useful to copy `toncli-docker` binary to your path (or copy it to /usr/local/bin) so you can access it from anywhere. + + ``` console + cp ./toncli-docker /usr/local/bin/toncli-docker + ``` - Go to the path, where you are going to create your project (e.g. ~/your/path/dev/) + Now go to the path, where you are going to create your project (e.g. ~/your/path/dev/) ### Creating project Run ``` console - ./toncli-docker.sh start --name test_project wallet + toncli-docker start --name test_project wallet ``` You're going to see the toncli project structure in *~/your/path/dev/test_project* @@ -70,13 +76,13 @@ docker build . -t toncli-local \ Run ``` console - ./toncli-docker.sh build + toncli-docker build ``` ### Running tests ``` console - ./toncli-docker.sh run_tests + toncli-docker run_tests ``` ### Deploying contract @@ -95,7 +101,7 @@ docker build . -t toncli-local \ Or ``` console - ./toncli-docker.sh update_libs /path/to/toncli_conf_dir/ + toncli-docker update_libs /path/to/toncli_conf_dir/ ``` After that you should go through standard toncli initialization dialog and pass absolute paths to the binaries @@ -128,7 +134,7 @@ docker build . -t toncli-local \ Or ``` console - ./toncli-docker.sh deploy /path/to/toncli_conf_dir/ --net testnet + toncli-docker deploy /path/to/toncli_conf_dir/ --net testnet ``` **wallet** directory would be created inside your local config dir with all the usefull deployment information From 4cf438777e38aaeedc8faef96c84534fced98034 Mon Sep 17 00:00:00 2001 From: Daniel Taiakin Date: Tue, 27 Dec 2022 00:23:53 +0300 Subject: [PATCH 5/7] added parmanent storage for vars, added customization support --- toncli-docker | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/toncli-docker b/toncli-docker index 60904a8..ed6db0a 100755 --- a/toncli-docker +++ b/toncli-docker @@ -1,23 +1,74 @@ #!/bin/bash +# where permanent variables are stored +CONFIG_VAR_PATH="$HOME/.toncli-config" + +# Usage: kv_validate_key +kv_validate_key() { + [[ "$1" =~ ^[0-9a-zA-Z._:-]+$ ]] +} + +# Usage: kvget +kvget() { + key="$1" + kv_validate_key "$key" || { + kv_echo_err_box 'invalid param "key"' 'kvget()' + return 1 + } + kv_user_dir=${KV_USER_DIR:-$CONFIG_VAR_PATH} + VALUE="$([ -f "$CONFIG_VAR_PATH/$key" ] && cat "$CONFIG_VAR_PATH/$key")" + echo "$VALUE" + + [ "$VALUE" != "" ] +} + +# Usage: kvset [value] +kvset() { + key="$1" + value="$2" + kv_validate_key "$key" || { + kv_echo_err_box 'invalid param "key"' 'kvset()' + return 1 + } + kv_user_dir=${KV_USER_DIR:-$CONFIG_VAR_PATH} + test -d "$kv_user_dir" || mkdir "$kv_user_dir" + echo "$value" > "$kv_user_dir/$key" +} + +# Usage: kvdel +kvdel() { + key="$1" + kv_validate_key "$key" || { + kv_echo_err_box 'invalid param "key"' 'kvdel()' + return 1 + } + kv_user_dir=${KV_USER_DIR:-$CONFIG_VAR_PATH} + test -f "$kv_user_dir/$key" && rm -f "$kv_user_dir/$key" +} + + TONCLI_CMD="toncli-local" +# where toncli stores deployment info +DEPLOY_PATH=$(kvget DEPLOY_PATH) || "$HOME/.toncli-deploy" # ./toncli-docker update_libs /path/to/toncli_conf_dir/ if [[ $1 == "update_libs" ]]; then docker run --rm -it \ -v "$(pwd)":/code \ - -v "$2":/root/.config \ + -v "$DEPLOY_PATH":/root/.config \ $TONCLI_CMD update_libs # ./toncli-docker deploy /path/to/toncli_conf_dir/ elif [[ $1 == "deploy" ]]; then docker run --rm -it \ -v "$(pwd)":/code \ - -v "$2":/root/.config \ + -v "$DEPLOY_PATH":/root/.config \ $TONCLI_CMD deploy $@:3 +elif [[ $1 == "--set-deployment-path" ]]; then + kvset DEPLOY_PATH "$2" else docker run --rm -it \ -v "$(pwd)":/code \ $TONCLI_CMD $@ fi -# all commands w/ toncli: https://github.com/disintar/toncli/blob/master/docs/advanced/commands.md +# all commands w/ toncli: https://github.com/disintar/toncli/blob/master/docs/advanced/commands.md \ No newline at end of file From 71b2e3b676d388155a3e9ae371f8a499eb9c8c29 Mon Sep 17 00:00:00 2001 From: Daniel Taiakin Date: Tue, 27 Dec 2022 00:24:23 +0300 Subject: [PATCH 6/7] Update README.md --- README.md | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 26ffc03..55c7dfb 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,6 @@ docker build . -t toncli-local \ ``` - ## Use It's also useful to copy `toncli-docker` binary to your path (or copy it to /usr/local/bin) so you can access it from anywhere. @@ -89,19 +88,15 @@ docker build . -t toncli-local \ Now here is the tricky part. **Toncli** stores deployment info in it's config directory instead of your project directory. So we're going to have to create another volume for that to persist. - - Run + ``` console - docker run --rm -it \ - -v ~/Dev/test_project:/code \ - -v /path/to/toncli_conf_dir/:/root/.config \ - toncli-local update_libs + toncli-docker update_libs ``` - Or - + The deployment info is stored in the `~/.toncli-deploy` dir by default. + If you want to change this path, you can run this command: ``` console - toncli-docker update_libs /path/to/toncli_conf_dir/ + toncli-docker --set-deployment-path /your/custom/path ``` After that you should go through standard toncli initialization dialog and pass absolute paths to the binaries @@ -122,23 +117,14 @@ docker build . -t toncli-local \ Now you can use it in the deploy or any other process like so. - Run - - ``` console - docker run --rm -it \ - -v /path/to/project:/code \ - -v /path/to/toncli_conf_dir/:/root/.config \ - toncli-local deploy --net testnet - ``` - - Or + Run ``` console - toncli-docker deploy /path/to/toncli_conf_dir/ --net testnet + toncli-docker deploy --net testnet ``` **wallet** directory would be created inside your local config dir with all the usefull deployment information -### General usage +### General usage without toncli-docker wrapper ``` console docker run --rm -it \ -v \ From 5a89d965b9260381c8c837ec8422a84574f6757b Mon Sep 17 00:00:00 2001 From: Daniel Taiakin Date: Wed, 28 Dec 2022 16:53:01 +0300 Subject: [PATCH 7/7] bug fix --- toncli-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toncli-docker b/toncli-docker index ed6db0a..beb55fa 100755 --- a/toncli-docker +++ b/toncli-docker @@ -62,7 +62,7 @@ elif [[ $1 == "deploy" ]]; then docker run --rm -it \ -v "$(pwd)":/code \ -v "$DEPLOY_PATH":/root/.config \ - $TONCLI_CMD deploy $@:3 + $TONCLI_CMD deploy $@ elif [[ $1 == "--set-deployment-path" ]]; then kvset DEPLOY_PATH "$2" else