GoogleContactsEventsNotifier
GoogleContactsEventsNotifier copied to clipboard
Document/automate using GAS REST import-export in git workflow?
According to the Google documentation it is possible to sync latest commits to the scripts on Google Drive via the REST interface, so it would be nice to document that (at least for maintainer/collaborators-use) so we can avoid the whole copy-paste-update-vars tango whenever we want to test things, and users who want to do it that way can avoid the same tango whenever they want to sync an updated version from master. What would be even nicer would be to add a git-hook (which the user must copy into place if they want that, so other users don't get scared by automatic-background activity happening when they pull from github) with the following logic:
if [master-has-changed] (or if [development-has-changed] for us) {
curl -X PUT --upload-file "{code-customized.gs,unit-tests.gs}" http://blahblahblah
}
or for that matter the hook could be a nodejs script like what they show at the nodejs google drive api quickstart - but that would require having nodejs installed (maybe it would be better for the hook to be in a more commonly-installed language like perl or python... of course using curl-invocations in a shell is probably the least dependency-heavy - for non-windows people anyway)
This could be really useful, but I would postpone it giving precedence to the work on the development branch which I think is almost ready for a new release.
A much better and easier solution seems to have presented itself. In January the clasp tool was released. A key part of the description is this:
clasp lets you to develop your Apps Script projects locally. You can write code on your
own computer and upload it to Apps Script when you're done. You can also download
existing Apps Script projects so that you can edit them when you're offline. Since the
code is local, you can use your favorite development tools like git when building Apps
Script projects.
I think this will ultimately allow users to just:
- npm-install clasp
- git-clone GCEN
- edit configuration at top of
code.gs
- upload with clasp
- with clasp trigger
notifStart()
, interactively OK-ing permissions when requested
I haven't checked but I guess the clasp tool must handle running a function on the uploaded script (like notifStart()
), interactive authorization of permissions when required, etc...?
...answering my own question here: also in January the Apps Script API was made available, allowing programmatic control of everything (deploying, remote function triggering, etc).
:-)
This is really nice: I'll try playing with it this afternoon
I tried clasp and as far as I can tell it's exactly what we were looking for relative to the automatic deployment on Google Scripts to test a new version of GCEN. Having clasp installed on our local machines it should be easy to write a simple script to edit the configuration of the script and push it to our personal test environment.
I tried to jot down some ideas for a test-deployment workflow and came up with this:
Setup:
-
clasp clone
into/testing/
(so that/testing/
becomes the root of the "personalized" version of the project - add
/testing/
to.gitignore
so that each collaborator can have its own test workflow for his own OS (from what I understand some of us work on Linux and other on Windows machines) and with his own personalizations
Test-deployment workflow:
- copy
/*.gs
into/testing/*.js
(by default clasps clones the files as.js
, don't know if there is asetting to change that) - edit
/testing/code.js
changing the settings (language, filters, notification day/hour or anything else that needs to be changed) to any personalized value -
clasp push
- remotely execute any test function (this would be done via Apps Script API although I did not look into this at all)