Giter Club home page Giter Club logo

ggsrun's Introduction

ggsrun

MIT License

Overview

This is a CLI tool to execute Google Apps Script (GAS) on a terminal. Also this CLI tool can be used for managing files in Google Drive for OAuth2 and Service Account.

Demo

Description

Will you want to develop GAS on your local PC? Generally, when we develop GAS, we have to login to Google using own browser and develop it on the Script Editor. Recently, I have wanted to have more convenient local-environment for developing GAS. So I created this "ggsrun". The main work is to execute GAS on local terminal and retrieve the results from Google. Furthermore, this tool can be also used for managing files in own Google Drive (OAuth2) and Google Drive for Service Account.

Features of "ggsrun" are as follows.

  1. Develops GAS using your local terminal and text editor which got accustomed to using.Updated! (v1.4.0)
  2. Executes GAS by giving values to your script.
  3. Executes GAS made of CoffeeScript.
  4. Downloads spreadsheet, document and presentation, while executes GAS, simultaneously.
  5. Downloads files from Google Drive and Uploads files to Google Drive. Updated! (v1.4.1)
  6. Downloads standalone script and bound script. Updated! (v1.4.0)
  7. Downloads all files and folders in a specific folder. Updated! (v1.5.2)
  8. Upload script files and create project as standalone script and container-bound script. Updated! (v1.5.2)
  9. Update project. Updated! (v1.4.0)
  10. Retrieve revision files of Google Docs and retrieve versions of projects. Updated! (v1.4.0)
  11. Rearranges scripts in project. Updated! (v1.4.0)
  12. Modifies Manifests in project.
  13. Seach files in Google Drive using search query and regex Updated! (v1.6.0)
  14. Manage Permissions of files Updated! (v1.7.0)
  15. Get Drive Information. Updated! (v1.7.0)
  16. ggsrun got to be able to be used by not only OAuth2, but also Service Account. Updated! (v1.7.0)

How to Install

December 28, 2021: If you want to simply test ggsrun, you can also use this method.

1. Get ggsrun

Download an executable file of ggsrun from the release page and import to a directory with path.

or

Use go get.

$ go install github.com/tanaikech/ggsrun@latest
  • GO111MODULE=on

Before Basic setting flow

IMPORTANT: Please check this.

At April 8, 2019, the specification of Google Apps Script Project was changed. By this, when new GAS project is created after April 8, 2019, in order to use Goole API (Google Apps Script API and Drive API which can be used by ggsrun.), the GAS project is required to link to Cloud Platform Project. When you use the GAS project creted after April 8, 2019, at first, please do this flow.

After the GAS project was linked to Cloud Platform Project by above flow, please do "Basic setting flow" at the next section.

2. Basic setting flow

When you click each link of title, you can see the detail information.

  1. Setup ggsrun Server (at Google side)
    • Create new project and install the server as a library.
    • Deploy API executable. Choose "Only myself" as "Who has access to the script"
    • Install the server as a library. Script ID of the library is
      • 115-19njNHlbT-NI0hMPDnVO1sdrw2tJKCAJgOTIAPbi_jq3tOo4lVRov
    • After installed the library, please push the save button at the script editor. This is very important! By this, the library is completely reflected.
  2. Get Client ID, Client Secret
    • On the Script Editor
      • Resources -> Cloud Platform Project
      • Click the lower part of "This script is currently associated with project:"
      • In "Getting Started", Click "Enable APIs and get credentials like keys".
      • On "API APIs&services"
      • Click "Credentials" at left side.
      • At "Create Credentials", Click OAuth client ID.
      • Choose Other
      • Input Name (This is a name you want.)
      • done
      • Download a JSON file with Client ID and Client Secret as client_secret.json using download button.
  3. Enable APIs
    • ggsrun uses Google Apps Script API and Drive API. Please enable them at API console. You can directly access them as follows. Project ID can be seen at downloaded client_secret.json.
      • https://console.cloud.google.com/apis/library/script.googleapis.com/?project=### project ID ###
      • https://console.cloud.google.com/apis/api/drive.googleapis.com/?project=### project ID ###
  4. Create configure file for ggsrun
    • Run $ ggsrun auth at the directory with client_secret.json.
  5. Test Run
    • Create a sample script function main(){return Beacon()} as sample.gs.
    • Run $ ggsrun e2 -s sample.gs -i [Script ID] -j. Script ID is ID of the project installed the server.

Congratulation! You got ggsrun!

To users which are using ggsrun with v1.3.4 and/or less Updated! (v1.4.0)

Please reauthorize to include a new scope to the access token as follows.

  1. Confirm whether Google Apps Script API is enabled. You can directly access it as follows. Project ID can be seen at the downloaded client_secret.json.
  2. Add a scope of https://www.googleapis.com/auth/script.projects to ggsrun.cfg.
  3. Run the following command under the directory with client_secret.json and ggsrun.cfg.
    • $ ggsrun auth

Completed!

From version 1.7.0, ggsrun can access to Google Drive using Service Account. Updated! (v1.7.0)

ggsrun can access to Google Drive using Service Account. When OAuth2 is used, you can see the files and folders in own Google Drive. When Service Account is used, you can see them in Google Drive for Service Account. Namely, the Drive for OAuth2 is different from that for Service Account. Please be careful this. And when Service Account is used, there are what it can do and what it can't do. About them, please read here.

How to use ggsrun

  1. Executes GAS and Retrieves Result Values
  2. Executes GAS with Values and Retrieves Feedbacked Values
  3. For Debug
  4. Executes GAS with Values and Downloads File
  5. Executes Existing Functions on Project
  6. Download Files
  7. Downloads all files and folders in a specific folder.
  8. Upload Files
  9. Show File List
  10. Search Files
  11. Update Project
  12. Retrieve Revision Files and Versions of Projects
  13. Rearrange Script in Project
  14. Modify Manifests
  15. Seach Files using Query and Regex
  16. Manage Permissions of files
  17. Get Drive Information.
  18. ggsrun got to be able to be used by not only OAuth2, but also Service Account.

Applications

  1. For Sublime Text
  2. For CoffeeScript
  3. Create Triggers
  4. Link to Python script
  1. Authorization for Google Services for your script
  2. In the case that result is "Script Error on GAS side: Insufficient Permission"
  3. In the case that result is "message": "Requested entity was not found."
  4. In the case that result is "Script Error on GAS side: Script has attempted to perform an action that is not allowed when invoked through the Google Apps Script Execution API."
  5. In the case that result is "Missing ';' before statement."
  6. About library
  7. Order of directories for searching

Licence

MIT

Author

Tanaike

If you have any questions and commissions for me, feel free to tell me using e-mail [email protected]

Update History

You can see the Update History at here.

If you want to read the detail manual, please check here.

TOP

ggsrun's People

Contributors

dependabot[bot] avatar tanaikech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggsrun's Issues

Feature request: display download speed and percentage (d -j)

It would be a very nice addition to see the current or average download speed as well as percentage of file completion.
Seeing the progress in bytes is very difficult to understand at first glance.
Moving to Mbytes and above dynamically or having an option to choose the unit would be also nice to have.
Thanks.

panic: runtime error: index out of range [0] with length 0

I get an error:
panic: runtime error: index out of range [0] with length 0

when trying to run ggsrun auth

Windows 10 1909 x64, under powershell via windows terminal.
I don't really understand the error...

goroutine 1 [running]: main.(*AuthContainer).getNewAccesstoken(0xc00002ccc0, 0xc00002ccc0) D:/build/ggsrun/oauth.go:235 +0x1124 main.(*AuthContainer).reAuth(0xc00002ccc0) D:/build/ggsrun/oauth.go:55 +0x40 main.reAuth(0xc00002cc80, 0x2, 0x2) D:/build/ggsrun/handler.go:142 +0x5c github.com/urfave/cli.(*Command).Run(0xc000113680, 0xc00002cb40, 0x0, 0x0) C:/Go/projects/src/github.com/urfave/cli/command.go:161 +0x4e7 github.com/urfave/cli.(*App).RunContext(0xc000043200, 0x972340, 0xc0000200b0, 0xc000004480, 0x2, 0x2, 0x0, 0x0) C:/Go/projects/src/github.com/urfave/cli/app.go:301 +0x81b github.com/urfave/cli.(*App).Run(...) C:/Go/projects/src/github.com/urfave/cli/app.go:210 main.main() D:/build/ggsrun/ggsrun.go:565 +0x4dd5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.