From bea144f29fca92a3499c5b8210ee7e4f2db54211 Mon Sep 17 00:00:00 2001 From: Diego Calero Date: Tue, 25 May 2021 16:36:47 -0300 Subject: [PATCH] Fix for BinUtils().extractFormulaParams() and adding appsscript.json to release. --- .github/workflows/build.yml | 21 ++++++++++++++++++--- README.md | 19 +++++++++++-------- appsscript.json | 2 +- misc/utils.gs | 17 ++++++++++++----- tasks/do-orders-table.gs | 1 + 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac32565..a94ed8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,13 +27,18 @@ jobs: echo "::set-output name=filename::$filename" echo "::set-output name=filepath::$filepath" - - name: Upload as artifact + - name: Upload BINANCE.gs as artifact uses: actions/upload-artifact@v1 with: name: ${{ steps.build_file.outputs.filename }} path: ${{ steps.build_file.outputs.filepath }} + - name: Upload appsscript.json as artifact + uses: actions/upload-artifact@v1 + with: + name: appsscript.json + path: appsscript.json - - name: Upload as release asset + - name: Upload BINANCE.gs as release asset id: upload_release uses: actions/upload-release-asset@v1 env: @@ -42,4 +47,14 @@ jobs: upload_url: ${{ github.event.release.upload_url }} asset_name: ${{ steps.build_file.outputs.filename }} asset_path: ${{ steps.build_file.outputs.filepath }} - asset_content_type: application/javascript \ No newline at end of file + asset_content_type: application/javascript + - name: Upload appsscript.json as release asset + id: upload_appsscript + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_name: appsscript.json + asset_path: appsscript.json + asset_content_type: application/json \ No newline at end of file diff --git a/README.md b/README.md index fad2fba..902388e 100644 --- a/README.md +++ b/README.md @@ -32,18 +32,20 @@ First of all, open your desired Google Spreadsheet and configure it properly: ### The quick'n easy way for everybody -Just [download the latest **BINANCE.gs**](https://github.com/diegomanuel/binance-to-google-sheets/releases/latest/download/BINANCE.gs) _all-in-one_ file and **copy & paste** its contents following these steps: +Just [download the latest **BINANCE.gs**](https://github.com/diegomanuel/binance-to-google-sheets/releases/latest/download/BINANCE.gs) _all-in-one_ file + [**appsscript.json**](https://github.com/diegomanuel/binance-to-google-sheets/releases/latest/download/appsscript.json) and **copy & paste** its contents following these steps: 1. With your desired `Google Spreadsheet` opened, go to `Tools -> Script editor`. - * It should open a new page with a `Code.gs` file containing an empty function. -2. Remove any contents from `Code.gs` and paste the contents from the downloaded `BINANCE.gs` file. -3. Save the project at `File -> Save`. Give any name you want. -4. Refresh/reload your Google Spreadsheet (hit `F5` on the browser). + * It should open an editor in a new page with a `Code.gs` file containing an empty function. + * Remove any contents from `Code.gs` and save the project at `File -> Save`. Give any name you want. +2. Go to project properties and make sure to select `Show "appsscript.json" manifest file in editor` checkbox. +3. Go back to code editor, select the `Code.gs` file and paste the contents from the downloaded `BINANCE.gs` file. +4. Do the same for `appsscript.json` and optionally set your desired timezone. +5. Save the project again and refresh/reload your Google Spreadsheet (hit `F5` on the browser). * Once reloaded, you should see a little message box (toast) at the bottom-right corner. -5. Go to `Binance` item at your spreadsheet's main menu and click on the `Authorize add-on!` item. -6. A Google's dialog should appear asking for permissions, proceed with all the steps and click `Allow`. +6. Go to `Binance` item at your spreadsheet's main menu and click on the `Authorize add-on!` item. +7. A Google's dialog should appear asking for permissions, proceed with all the steps and click `Allow`. * The popup will close and nothing will change on your spreadsheet yet! -7. Once the add-on is authorized, repeat step `5` (click `Authorize add-on!` again) and voila! +8. Once the add-on is authorized, repeat step `5` (click `Authorize add-on!` again) and voila! ### If you are a developer =] @@ -55,6 +57,7 @@ You will need [node](https://nodejs.org) and [clasp](https://github.com/google/c 1. With your `Google Spreadsheet` open, go to `Tools -> Script editor`. 2. At the `Google Script` screen, go to `File -> Project properties`. 3. The needed ID is the one under the `Script ID` label! + 4. Make sure to select `Show "appsscript.json" manifest file in editor` checkbox. 4. Just for the first time, run the target `make setup SCRIPT_ID=my-script-id` replacing `my-script-id` with the ID obtained at point `3`. * It should create the file `.clasp.json` with your `scriptId` inside for future use. * **NOTE:** You only need to re-run this step if you want to change the configured `scriptId`. diff --git a/appsscript.json b/appsscript.json index 4608c08..13979ee 100644 --- a/appsscript.json +++ b/appsscript.json @@ -21,5 +21,5 @@ } } }, - "urlFetchWhitelist": ["https://api.binance.com/"] + "urlFetchWhitelist": ["https://api.binance.com/", "https://fapi.binance.com/"] } \ No newline at end of file diff --git a/misc/utils.gs b/misc/utils.gs index 1257e96..7780956 100644 --- a/misc/utils.gs +++ b/misc/utils.gs @@ -225,24 +225,31 @@ function BinUtils() { range_or_cell = extracted[1]; options = extracted[2]; } else { - // 2 params formula - regex_formula = base_regex+"(.*)\\s*\\)"; + // 2 params formula with string 2nd param + regex_formula = base_regex+"\"(.*)\""; extracted = new RegExp(regex_formula, "ig").exec(formula); if (extracted && extracted[1]) { range_or_cell = extracted[1]; + } else { + // 2 params formula with NOT-string 2nd param + regex_formula = base_regex+"(.*)\\s*\\)"; + extracted = new RegExp(regex_formula, "ig").exec(formula); + if (extracted && extracted[1]) { + range_or_cell = extracted[1]; + } } } } if (DEBUG) { - Logger.log("FORMULA: "+JSON.stringify(formula)); + Logger.log("FORMULA: "+formula); if (extracted) { extracted.map(function(val) { Logger.log("REGEXP VAL: "+val); }); } - Logger.log("RANGE OR CELL: "+JSON.stringify(range_or_cell)); - Logger.log("OPTIONS: "+JSON.stringify(options)); + Logger.log("RANGE OR CELL: "+range_or_cell); + Logger.log("OPTIONS: "+options); } return [range_or_cell, parseOptions(options)]; diff --git a/tasks/do-orders-table.gs b/tasks/do-orders-table.gs index 364f1d9..27c7ed0 100644 --- a/tasks/do-orders-table.gs +++ b/tasks/do-orders-table.gs @@ -118,6 +118,7 @@ function BinDoOrdersTable() { if (!range.length) { throw new Error("A range with crypto symbols must be given!"); } + Logger.log("[BinDoOrdersTable] Processing "+range.length+" sheet's assets: "+range); _setStatus(sheet, "fetching data.."); const opts = {