Does Google Apps Script support external IDEs? - google-apps-script

I am using Google Apps Script and was wondering if I could use any sort of editor outside of the one Google provides. (I purchased Sublime Text and would like to use that.)
The one Google provides is disgusting, with tiny text even though I have a giant screen and syntax colors that I find a bit difficult to distinguish on a white background with small text, and I don't have the beauties of Sublime like tons of custom keyboard shortcuts, all of my packages, etc.

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

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.

The eclipse plug-in is migrated now. You should install many
files. lastly it couldn't import my google script files.
nod-google-apps-script is depercated.
gdrive can't handle google scripts beyond exporting the project in single json file. issue issue
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)

This is an answer for basic/beginner users of Intellij that are looking for code completion when writing Google App Scripts apps. Most of the answers above were helpful for getting me going, especially with Clasp. But none of them actually got Intellij to do the code complete. But this does:
Select File, Settings, Languages & Frameworks, JavaScript, Libraries.
Then on the right select Download, the scroll down to 'google-app-scripts'. (Lots of scrolling) Download and install and you're done. Almost so easy that it really shouldn't have been so hard to find.

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

Related

How to create Google scripts on desktop using WebStorm?

Scripting on google's IDE is a big pain, it's very laggy and it just sucks.
How can I make the google script editor work on my PC?
I tried downloading this Clasp
Also I added a library from google to javascript.
but when I run it it gives me this error:
var ss = SpreadsheetApp.getActiveSpreadsheet();
^
ReferenceError: SpreadsheetApp is not defined
How can I fix this?
What I'm basically trying to do with this script is to send an email based on a bunch of conditions on a google sheets.
Solution
In order to be able to run an Apps Script project remotely from your local machine, you need to use the clasp command run as you will be required to also use some kind of authorization (you will basically need to connect your local project to your remote Apps Script project and verify it is you the one trying to run it).
Here is a complete guide on how to use this command but just to summarise a bit you basically will need to set up a Project ID and create an OAuth Client ID to then be able to login using the credentials obtained from it clasp login --creds creds.json1.
This is an example of running a function using the command run:
clasp run 'functionName'
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
Adding the google-apps-script library to webstorm might also help you out.
Follow the instructions here, but search for "google-apps-script" in the download library modal. Instead of "chrome" which is what this article is about.
How do I use WebStorm for Chrome Extension Development?
You'll then be able to create *.gs files. Open them as javascript.

Multiple copies of script in Google Apps Script

When I click on Tools -> Script Editor in a Google Doc, I am presented with the following screen, whereas before I would be directed straight to the script editor:
I am worried that there are now two instances of my script. Is there a place I can easily see and manage the scripts and projects in Google Apps Script? I have checked out Google Cloud Platform Project through the script editor menu (Resources -> Cloud Platform project), but the resulting dashboard is not very intuitive to me.
As some background: I was trying to test Google Apps Script code deployment using Clasp and after the test, I wound up with the above issue. I don't know if the issue came about when I used Clasp commands or if it was when I copied the existing document before trying out Clasp.
Thank you for taking the time to read this. Any info is appreciated.
You can bind multiple script projects to a container (the container in this case being your document).
When you have multiple projects bound to a container and you open the script editor, you are provided with a menu with a list of your projects.
You can easily delete the duplicate project. Just select it, and then when you're in the Apps Script GUI editor, navigate to File > Delete Project.
G-Suite Developer Hub
You can access all of your scripts at G-Suite Developer Hub. You can even monitor script performance from there.
Same Named Scripts
You will want to avoid scripts with the same name within a project but it's okay if they are in different projects.
Backups
If you want to make a backup of a project you can just copy it. In the case of a container app you can make a copy of the container and you will be making a copy of the scripts it contains at the same time.

Google Apps Script Library removes itself from standalone projects

I've published a standalone Google Apps Script project, and I include this code in 4 different scripts bound to 4 sheets. I develop locally using Clasp in combination with TypeScript, according to this setup.
The problem I experience is that sometimes when I push edits through Clasp my code in those standalone scripts (I never edit my library code) seems to remove the included library. Obviously, my code in the standalone scripts then fails to execute. I then have to manually re-add the library in all 4 bound scripts.
Development mode is turned off in all scripts.
One can include libraries in the appsscript.json file. This way, the library is properly attached to the code.

How to download (export) an apps script add-on project?

How will I download an apps-script Google Docs add-on project, which was opened from Tools > Script editor of Google Docs.
File > make a copy of the project do not seem to be any use. since it makes online copy itself. Any alternative ways to achieve?
Google launched clasp last year, an official tool to import and export apps scripts projects. It works great!
You should not develop you add-on directly in a document (I made this mistake too). Instead you need to have an independant script that you bound to a document with the options to test it as an addon (this way).
Doing so you'll have the capacity to export (and import) your script with the Google Drive rest api.To my knowledge there is two tools that you can use:
gapps writen in node
python-gas-cli, a python tool (never tested it)
You should also have a look at this post that explain quite well how it work

Google apps script post-install tooltip

I have created an add-on in Google Apps Script. There has to be post-install tool tip in add-on. The tool tip is seen at the add-on menu item after installation is complete. Could any one please tell me what is the method to do so or what is the exact procedure to show the tool-tip post install.
The post install tool-tip seen when installing an Addon is not built into the Addon itself, rather it's provided at the time that you publish the Addon. This isn't well documented however, merely lightly implied under 'Publishing instructions' -> 'Prepare and deploy your add-on' when it says 'In the Deploy as Add-on dialog, fill all required fields. The add-on’s name must be the same as the name of the Apps Script project. See the style guide for more information on the other fields.'
The Style Guide then has a section on the 'Post-install tip', implying that this is when it's filled. It could, however, be a lot clearer.
From the script you go to "Publish > Deploy as Docs add-on..." and from there you can add a Post-install tip.