External Editor Support for Google Apps Script

◇◆丶佛笑我妖孽 提交于 2019-11-30 00:02:30

Google has dropped support for Apps Script inside Eclipse but you can set up a local development environment inside VS Code using the Apps Script Starter kit and CLASP.

Here's a video tutorial to help you get started.

As of today (May 2018), every scripts that you add on Google App Scripts (including scripts on Google Drive like spreadsheets) will get accessible through https://script.google.com and will have a specific id that you can get through the url by opening it.

By using clasp which handle a project (like git), you can do:

clasp clone {id}

to have your script in a local folder. Then, after editing your file with your favorite text editor, upload it back with :

clasp push
  1. The eclipse plug-in is migrated now. You should install many files. lastly it couldn't import my google script files.
  2. nod-google-apps-script is depercated.
  3. gdrive can't handle google scripts beyond exporting the project in single json file. issue issue
  4. sublime-editor-plug-in has n't worked for me (I read the whole documents & issues)

The only working solution for me (ubuntu xenial) is clasp.

According to doc it can :

Develop Locally: clasp allows you to develop your Apps Script projects locally. That means you can check-in your code into source control, collaborate with other developers, and use your favorite tools to develop Apps Script.

Manage Deployment Versions: Create, update, and view your multiple deployments of your project.

Structure Code: clasp automatically converts your flat project on script.google.com into folders. For example:

On script.google.com: tests/slides.gs tests/sheets.gs

locally: tests/ slides.js sheets.js

N.B:. The fature of 'Manage Deployment Versions' isn't supported by eclipse plug in.

It give the following commands:

clasp login [--no-localhost]
clasp logout
clasp create [scriptTitle] [scriptParentId]
clasp clone <scriptId>
clasp pull
clasp push
clasp open
clasp deployments
clasp deploy [version] [description]
clasp redeploy <deploymentId> <version> <description>
clasp version [description]
clasp versions

By using it; you can use your favorite script editor; then push the changes.

Edit GAS Editor Autocomplete

Thanks to @tehhowch comment.

Auto complete of google objects is almost exclusive for online GAS editor, If you use any external editor , you will only get auto complete for the functions & variables of your own script (I am not sure about eclipse).

But online editor provides autocomplete which reveals the global objects as well as methods and enums that are valid in the script's current context.

To show autocomplete suggestions, select the menu item Edit > Content assist or press Ctrl+Space. Autocomplete suggestions also appear automatically whenever you type a period after a global object, enum, or method call that returns an Apps Script class. For example:

  • If you click on a blank line in the script editor and activate autocomplete, you will see a list of the global objects.
  • If you type the full name of a global object or select one from autocomplete, then type . (a period), you will see all methods and enums for that class.
  • If you type a few characters and activate autocomplete, you will see all valid suggestions that begin with those characters.

You can use node-google-apps-script to edit scripts locally (described in this blog post from the google apps developer blog on 2015-12-17). This way you can use a more comfortable editor, version control and build scripts.

Caveats:

  • Like the eclipse plugin, node-google-apps-script requires that your add-on is a standalone script.
  • Debugging still requires google's script editor. With some additional setup you could run functions via the Execution API
  • It would be awesome if there was a Sublime Text plugin for code completion of google library methods, but I haven't found one (I don't think their default browser editor even offers this, though)

I haven't tried it yet but this looks promising: https://github.com/revolunet/sublimetext-google-apps-scripts

Another option to contemplate: using "AppsScript Color" Google Chrome plugin and GAS editor shortcuts.

Here you have a list of most useful shortcuts: https://opensourceseo.org/useful-tips-for-using-the-google-apps-script-editor/

You can just install a Google Drive command line client (e.g. https://github.com/prasmussen/gdrive) and edit .gs scripts directly.

There's also a way to edit Google Apps Scripts in Eclipse, which may be interesting. https://developers.google.com/eclipse/docs/apps_script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!