|
1 | 1 | // <!--
|
2 | 2 | /**
|
3 | 3 | * ScriptSync Library
|
4 |
| - * @version 2.0.5 |
| 4 | + * @version 2.0.6 |
5 | 5 | * @description This script performs an update,
|
6 | 6 | * adding new files from the template project
|
7 | 7 | * to the current user script.
|
|
150 | 150 |
|
151 | 151 |
|
152 | 152 |
|
| 153 | +// library changes 1 |
| 154 | +function UPDATER_Example_6() { |
| 155 | +
|
| 156 | + // nothing to assign |
| 157 | + const updater = ScriptSync.assignTemplate(); |
| 158 | +
|
| 159 | + // Your Library ID |
| 160 | + const library_id = "1nUiaj..."; |
| 161 | +
|
| 162 | + // get library fields from this script: { "userSymbol": "ScriptSync", "libraryId": "1nUiaj...", "version": "5" } |
| 163 | + var library_info = updater.getLibraryInfo("script", library_id); |
| 164 | +
|
| 165 | + // change any |
| 166 | + library_info.version = "150"; // set a new version |
| 167 | + library_info.libraryId = "library_id-will_be_changed"; // set a new library id |
| 168 | + library_info.userSymbol = "MyLIB"; // set a new name (userSymbol) |
| 169 | +
|
| 170 | + // update library info, args: (new_library_info, old_library_id) |
| 171 | + updater.updateLibraryInfo(library_info, library_id); |
| 172 | +
|
| 173 | + // displays changes |
| 174 | + updater.viewChanges(680); |
| 175 | +
|
| 176 | + // save it |
| 177 | + updater.commit(); |
| 178 | +
|
| 179 | +} |
| 180 | +
|
| 181 | +
|
| 182 | +
|
| 183 | +// library changes 2 |
| 184 | +function UPDATER_Example_7() { |
| 185 | +
|
| 186 | + // =============================================================== |
| 187 | + // This is an example of a short version of the previous function |
| 188 | + // =============================================================== |
| 189 | +
|
| 190 | +
|
| 191 | + // * - assign your template |
| 192 | + const updater = ScriptSync.assignTemplate(); |
| 193 | + const library_id = "the required - library id"; |
| 194 | +
|
| 195 | +
|
| 196 | + // HOW TO UPDATE THE VERSION ONLY |
| 197 | + // -------------------------------------- |
| 198 | + updater.updateLibraryInfo( |
| 199 | + {libraryId: library_id, version: "150"} |
| 200 | + ).commit(); |
| 201 | +
|
| 202 | + // OR |
| 203 | +
|
| 204 | + // get (from template*) & update with saving (in the script) |
| 205 | + updater.updateLibraryInfo( |
| 206 | + Object.assign(updater.getLibraryInfo("template", library_id), {version: "150"}) |
| 207 | + ).commit(); |
| 208 | +
|
| 209 | +
|
| 210 | + // HOW TO UPDATE THE LIBRARY ID &V FROM TEMPLATE SCRIPT |
| 211 | + // (if library id was changed in the template) |
| 212 | + // ----------------------------------------------------- |
| 213 | + const library_info_t = updater.getLibraryInfo("template", '', library_name); |
| 214 | + const library_info_s = updater.getLibraryInfo("script", '', library_name); |
| 215 | +
|
| 216 | + updater.updateLibraryInfo( |
| 217 | + library_info_t, library_info_s.libraryId |
| 218 | + ).commit(); |
| 219 | +
|
| 220 | +} |
| 221 | +
|
| 222 | +
|
| 223 | +
|
153 | 224 | /* WITHIN LIBRARY */
|
154 | 225 | // You can use internal class methods with prefix `_`.
|
155 | 226 | // The 'lib_prototype' file is used to link to the script.
|
|
0 commit comments