简体   繁体   English

Google Apps Script 是否支持外部 IDE?

[英]Does Google Apps Script support external IDEs?

I am using Google Apps Script and was wondering if I could use any sort of editor outside of the one Google provides.我正在使用 Google Apps Script,想知道是否可以使用 Google 提供的编辑器之外的任何类型的编辑器。 (I purchased Sublime Text and would like to use that.) (我购买了 Sublime Text 并想使用它。)

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.谷歌提供的很恶心,虽然我有一个巨大的屏幕和语法颜色,但我发现在带有小文本的白色背景上有点难以区分,但我没有像大量自定义那样拥有 Sublime 的美感键盘快捷键,我所有的包,等等。

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.截至今天(2018 年 5 月),您在 Google App Scripts(包括 Google Drive 上的脚本,如电子表格)上添加的每个脚本都可以通过https://script.google.com访问,并且将具有您可以访问的特定 ID通过打开它的网址。

By using clasp which handle a project (like git), you can do:通过使用处理项目(如 git)的clasp ,您可以执行以下操作:

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 . Google 已在 Eclipse 中放弃对 Apps Script 的支持,但您可以使用Apps Script Starter kit 和CLASP在 VS Code 中设置本地开发环境。

Here's a video tutorial to help you get started.这是一个视频教程,可帮助您入门。

  1. The eclipse plug-in is migrated now. eclipse插件现已迁移 You should install many files.您应该安装许多文件。 lastly it couldn't import my google script files.最后它无法导入我的谷歌脚本文件。
  2. nod-google-apps-script is depercated. nod-google-apps-script已弃用。
  3. gdrive can't handle google scripts beyond exporting the project in single json file.除了在单个json文件中导出项目之外,gdrive 无法处理 google 脚本。 issue issue 问题问题
  4. sublime-editor-plug-in has n't worked for me (I read the whole documents & issues) sublime-editor-plug-in 对我不起作用(我阅读了整个文档和问题)

The only working solution for me (ubuntu xenial) is clasp .对我来说唯一可行的解​​决方案(ubuntu xenial)是clasp

According to doc it can :根据文档,它可以:

Develop Locally : clasp allows you to develop your Apps Script projects locally.本地开发:clasp 允许您在本地开发 Apps 脚本项目。 That means you can check-in your code into source control, collaborate with other developers, and use your favorite tools to develop Apps Script.这意味着您可以将代码签入源代码管理,与其他开发人员协作,并使用您喜欢的工具来开发 Apps 脚本。

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.结构代码: clasp 自动将您在 script.google.com 上的平面项目转换为文件夹。 For example:例如:

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

locally: tests/ slides.js sheets.js本地:tests/slides.js sheet.js

NB:.注意:。 The fature of 'Manage Deployment Versions' isn't supported by eclipse plug in. Eclipse 插件不支持“管理部署版本”的功能。

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编辑GAS 编辑器自动完成

Thanks to @tehhowch comment.感谢@tehhowch 评论。

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).谷歌对象的自动完成几乎是在线 GAS 编辑器独有的,如果您使用任何外部编辑器,您将只能自动完成您自己脚本的函数和变量(我不确定 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.要显示自动完成建议,请选择菜单项编辑 > 内容辅助或按 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.每当您在返回 Apps 脚本类的全局对象、枚举或方法调用后键入句点时,自动完成建议也会自动出现。 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).您可以使用node-google-apps-script在本地编辑脚本(在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.与 eclipse 插件一样,node-google-apps-script 要求您的附加组件是一个独立的脚本。
  • Debugging still requires google's script editor.调试仍然需要谷歌的脚本编辑器。 With some additional setup you could run functions via the Execution API通过一些额外的设置,您可以通过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)如果有一个用于谷歌库方法代码补全的 Sublime Text 插件,那就太棒了,但我还没有找到(我认为他们的默认浏览器编辑器甚至不提供这个)

我还没有尝试过,但看起来很有希望: https//github.com/revolunet/sublimetext-google-apps-scripts

This is an answer for basic/beginner users of Intellij that are looking for code completion when writing Google App Scripts apps.这是 Intellij 的基本/初学者用户在编写 Google App Scripts 应用程序时寻找代码完成的答案。 Most of the answers above were helpful for getting me going, especially with Clasp.上面的大多数答案都有助于我前进,尤其是使用 Clasp。 But none of them actually got Intellij to do the code complete.但他们中没有人真正让 Intellij 完成代码。 But this does:但这确实:

Select File, Settings, Languages & Frameworks, JavaScript, Libraries.选择文件、设置、语言和框架、JavaScript、库。

Then on the right select Download, the scroll down to 'google-app-scripts'.然后在右侧选择下载,向下滚动到“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.另一个值得考虑的选择:使用“AppsScript Color”谷歌浏览器插件和 GAS 编辑器快捷方式。

Here you have a list of most useful shortcuts: https://opensourceseo.org/useful-tips-for-using-the-google-apps-script-editor/这里有一个最有用的快捷方式列表: https : //opensourceseo.org/useful-tips-for-using-the-google-apps-script-editor/

You can just install a Google Drive command line client (eg https://github.com/prasmussen/gdrive ) and edit .gs scripts directly.您只需安装 Google Drive 命令行客户端(例如https://github.com/prasmussen/gdrive )并直接编辑 .gs 脚本。

There's also a way to edit Google Apps Scripts in Eclipse, which may be interesting.还有一种在 Eclipse 中编辑 Google Apps 脚本的方法,这可能很有趣。 https://developers.google.com/eclipse/docs/apps_script https://developers.google.com/eclipse/docs/apps_script

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM