Reputation: 151
So a while ago my fiancée asked me to help her create a spreadsheet to manage her new small business. Come to find out she was actually looking for a fully-fledged CRM. Being the good future husband I am, I decided I could tackled this with some GoogleSheets macros. About two weeks in, I have basic inventory handling down, but the project has gotten way bigger than I had ever anticipated. The in-browser Syder IDE and basic version management isn't really cutting it any more.
My question now: I would like to begin managing this project in gitHub, but I can't find a graceful way to do so. I've found this blog post on stand-alone apps script files, but I can't seem to find my macro (.gs) files in my Google Drive.
My questions: Where are these files located? Is there a way to use e.g. eclipse to develop my macros and store them back to the spreadsheet while also using git or other version control?
Edit: Got some great feedback so far, but apparently Cloud Tools for Eclipse do not allow for Apps Script editing in the same way the Google Plugin for Eclipse did, see here.
Upvotes: 2
Views: 236
Reputation: 8964
Once you're done migrating your code to a stand-alone script as per Michelle's instructions you may want to check out this Chrome Extension:
Google Apps Script Github Assistant
It integrates with the Apps Script GUI to push and pull source to and from github. Its a pretty handy tool.
P.S. The Chrome extension also works with bound scripts, but I've found that Apps Script code is easier to reuse when they are stand-alone scripts.
Upvotes: 3
Reputation:
As Anton said, it is impossible to access a spreadsheet-bound script file outside of Google Sheets interface. You can copy-paste all of the code in a new stand-alone Google Script file. However, this will likely take some code changes, described below.
The calls to SpreadsheetApp.getActiveSpreadsheet
will need to be replaced by SpreadsheetApp.openById
, with the Id of the spreadsheet hardcoded. Other getActive* methods like getActiveSheet
and getActiveRange
can be invoked on that spreadsheet object, instead of SpreadsheetApp directly.
Any simple triggers such as onOpen or onEdit will need to be replaced by installable triggers that are installed in the spreadsheet by the standalone script. So, the script should have a function installing, say, onOpen, that will need to be executed manually once. See sample code for installing a trigger.
Upvotes: 1