Skip to content

Commit fb4372e

Browse files
authored
Update examples.html
1 parent 2e5776d commit fb4372e

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

src/examples.html

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// <!--
22
/**
33
* ScriptSync Library
4-
* @version 2.0.5
4+
* @version 2.0.6
55
* @description This script performs an update,
66
* adding new files from the template project
77
* to the current user script.
@@ -150,6 +150,77 @@
150150
151151
152152
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+
153224
/* WITHIN LIBRARY */
154225
// You can use internal class methods with prefix `_`.
155226
// The 'lib_prototype' file is used to link to the script.

0 commit comments

Comments
 (0)