There are many references to shared libraries on this site. You can either take a copy of them or use them in place as you wish. I'm always hitting a few problems with a) versions b) keysVersionsIn Google Apps Script, in theory, if you use development mode, it will use the latest code in your library. If you turn it off, it will use whatever version of the library you choose. If there are other libraries linked to that library, then the same rules should apply. This makes it very hard to orchestrate shared libraries with lots of shared dependencies, when people can choose which ones they want to use (various version may work together, other may not).
I usually keep everything in development mode so it always picks up the latest versions until I'm ready to release, but when someone other than me is using one of my libraries, they only get the selected library version. All this gets fairly complicated when you have many libraries.
Library infoHere's a way of finding out which versions of libraries are actually being used.
You'll find this button appearing on some of my pages. It will return JSON describing the libraries and dependency info of all my public libraries.
In each of your libraries, add this function, substituting your dependent libraries if any, along with the library key, name and version. You can update that as you create new versions or additional dependencies. Since each of your dependent libraries will have this function too (as will the dependents of their dependents etc..), you'll return a single object with info about all dependencies of all libraries as well as the versions currently being referenced.
function getLibraryInfo () { return { info: { name:'cDriverSheet', version:'2.00', key:'Mrckbr9_w7PCphJtOzhzA_Cz3TLx7pV4j', }, dependencies:[ cDriverMemory.getLibraryInfo(), cFlatten.getLibraryInfo(), cNamedLock.getLibraryInfo() ] }; } Use it like this to get the profile of a list of libraries.
function getLibraryData () { return getAllLibraries ( [ cDbAbstraction, cDriverDataStore ]); } function getAllLibraries (libraries) { var result = []; libraries.forEach ( function (l) { result.push ( l.getLibraryInfo() ); }); return result; } You'll get this[ { "info": { "name": "cDbAbstraction", "version": "2.00", "key": "MHfCjPQlweartW45xYs6hFai_d-phDA33" }, "dependencies": [ { "info": { "name": "cCacheHandler", "version": "2.00", "key": "M3reA5eBxtwxSqCEgPywb9ai_d-phDA33" }, "dependencies": [] }, { "info": { "name": "cUseful", "version": "2.00", "key": "Mcbr-v4SsYKJP7JMohttAZyz3TLx7pV4j" }, "dependencies": [] }, { "info": { "name": "cNamedLock", "version": "2.00", "key": "Mpv7vUR0126U53sfSMXsAPai_d-phDA33" }, "dependencies": [ { "info": { "name": "cCacheHandler", "version": "2.00", "key": "M3reA5eBxtwxSqCEgPywb9ai_d-phDA33" }, "dependencies": [] } ] }, { "info": { "name": "cFlatten", "version": "2.00", "key": "MqxKdBrlw18FDd-X5zQLd7yz3TLx7pV4j" }, "dependencies": [] }, { "info": { "name": "cUAMeasure", "version": "2.00", "key": "MIHfxr-fc_7bXa1l0Dkk0oqi_d-phDA33" }, "dependencies": [] } ] }, { "info": { "name": "cDriverDataStore", "version": "2.00", "key": "MPZF_EC6nOZFAjMRqCxEaUyz3TLx7pV4j" }, "dependencies": [ { "info": { "name": "cNamedLock", "version": "2.00", "key": "Mpv7vUR0126U53sfSMXsAPai_d-phDA33" }, "dependencies": [ { "info": { "name": "cCacheHandler", "version": "2.00", "key": "M3reA5eBxtwxSqCEgPywb9ai_d-phDA33" }, "dependencies": [] } ] }, { "info": { "name": "cFlatten", "version": "2.00", "key": "MqxKdBrlw18FDd-X5zQLd7yz3TLx7pV4j" }, "dependencies": [] } ] } ] Click on this
|
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >