|
| 1 | +/** |
| 2 | + * ScriptSync Library |
| 3 | + * @version 2.0.4 |
| 4 | + * @description This script performs an update, |
| 5 | + * adding new files from the template project |
| 6 | + * to the current user script. |
| 7 | + * @author https://t.me/sergnovi |
| 8 | + * @see https://github.com/githnow |
| 9 | + */ |
| 10 | +// external calls for class methods |
| 11 | +// ► ╒════════════════╕ |
| 12 | +// ► │ ══ GENERAL ══ │ |
| 13 | +// ► ╘════════════════╛ |
| 14 | + |
| 15 | +/** |
| 16 | + * Returns current script_id of the template. |
| 17 | + * @memberof {ScriptSync} |
| 18 | + * @returns {string} template_script_id. |
| 19 | + */ |
| 20 | +function getTemplateId() { return this._getTemplateId(...arguments) } |
| 21 | +ScriptSync.prototype.getTemplateId = function(...args) { return getTemplateId.apply(this,[...args]) }; |
| 22 | + |
| 23 | + |
| 24 | +/** |
| 25 | + * Undo any non-committed changes in files. |
| 26 | + * @memberof {ScriptSync} |
| 27 | + * @returns {ScriptSync} |
| 28 | + */ |
| 29 | +function drop() { return this._drop(...arguments) } |
| 30 | +ScriptSync.prototype.drop = function(...args) { return drop.apply(this,[...args]) }; |
| 31 | + |
| 32 | + |
| 33 | +/** |
| 34 | + * ### This function makes changes to the current script file! |
| 35 | + * Save changes in the user script file. |
| 36 | + * @memberof {ScriptSync} |
| 37 | + * @param {boolean} forceCommit Whether to perform a forced commit |
| 38 | + * operation, even in case of errors. |
| 39 | + * @returns {boolean} Result of the function execution. |
| 40 | + */ |
| 41 | +function commit(forceCommit=true) { return this._commit(...arguments) } |
| 42 | +ScriptSync.prototype.commit = function(...args) { return commit.apply(this,[...args]) }; |
| 43 | + |
| 44 | + |
| 45 | +/** |
| 46 | + * Get the changes in a user script file. |
| 47 | + * @memberof {ScriptSync} |
| 48 | + * @param {number} slice_number Trim source code for viewing. |
| 49 | + * Number of characters to display. |
| 50 | + * @returns {Object} |
| 51 | + */ |
| 52 | +function getChanges(slice_number) { return this._getChanges(...arguments) } |
| 53 | +ScriptSync.prototype.getChanges = function(...args) { return getChanges.apply(this,[...args]) }; |
| 54 | + |
| 55 | + |
| 56 | +/** |
| 57 | + * Shows the changes in a user script file. |
| 58 | + * @memberof {ScriptSync} |
| 59 | + * @param {number} slice_number Trim source code for viewing. |
| 60 | + * Number of characters to display. |
| 61 | + * @returns {ScriptSync} |
| 62 | + */ |
| 63 | +function viewChanges(slice_number) { return this._viewChanges(...arguments) } |
| 64 | +ScriptSync.prototype.viewChanges = function(...args) { return viewChanges.apply(this,[...args]) }; |
| 65 | + |
| 66 | + |
| 67 | +// ► ╒═════════════════════════╕ |
| 68 | +// ► │ ═ FILE OPERATIONS ═ │ |
| 69 | +// ► ╘═════════════════════════╛ |
| 70 | + |
| 71 | +// *** WRITE *** |
| 72 | +/** |
| 73 | + * ### Description |
| 74 | + * Adds a new file from a template to the current script. from another third-party script. |
| 75 | + * If the file exists, it will be updated. |
| 76 | + * @memberof {ScriptSync} |
| 77 | + * @param {string} fromFileName Filename (in template script) from which the new data is copied. |
| 78 | + * @param {string} [toFileName] **optional**: Filename (in this script) to which the new data is being copied. |
| 79 | + * If empty, the file name specified in the remote script is used. |
| 80 | + * @param {boolean} [throwWithError] Interrupt with an error. Default - false. |
| 81 | + * @throws {Error} If cannot add the file to user script (if 'throwWithError' is enabled). |
| 82 | + * @returns {ScriptSync} |
| 83 | + */ |
| 84 | +function AddNewFile(fromFileName, toFileName, throwWithError=false) { return this._AddNewFile(...arguments) } |
| 85 | +ScriptSync.prototype.AddNewFile = function(...args) { return AddNewFile.apply(this,[...args]) }; |
| 86 | + |
| 87 | + |
| 88 | +/** |
| 89 | + * Renames a file in the file object. |
| 90 | + * @memberof {ScriptSync} |
| 91 | + * @param {string} fn The name of the file to rename. |
| 92 | + * @param {string} toFn The new name of the file. |
| 93 | + * @param {string} [extension] The file extension, if it needs to be changed. \ |
| 94 | + * (`'json'`, `'gs'` or `'html'`) |
| 95 | + * @returns {ScriptSync} |
| 96 | + */ |
| 97 | +function renameFile(fn, toFn, extension) { return this._renameFile(...arguments) } |
| 98 | +ScriptSync.prototype.renameFile = function(...args) { return renameFile.apply(this,[...args]) }; |
| 99 | + |
| 100 | + |
| 101 | +/** |
| 102 | + * Creates a blank file for further processing. |
| 103 | + * @memberof {ScriptSync} |
| 104 | + * @param {string} fn Filename in the user script. |
| 105 | + * @param {string} extension The file extension. \ |
| 106 | + * (`'json'`, `'gs'` or `'html'`) |
| 107 | + * @returns {ScriptSync} |
| 108 | + */ |
| 109 | +function createBlankFile(fn, extension) { return this._createBlankFile(...arguments) } |
| 110 | +ScriptSync.prototype.createBlankFile = function(...args) { return createBlankFile.apply(this,[...args]) }; |
| 111 | + |
| 112 | + |
| 113 | +/** |
| 114 | + * Sets a custom data source for the script file. |
| 115 | + * @memberof {ScriptSync} |
| 116 | + * @param {string} fn Filename in the user script. |
| 117 | + * @param {string} [extension] The file extension if needed. \ |
| 118 | + * (`'json'`, `'gs'` or `'html'`) |
| 119 | + * @param {string} custom_source Source code. |
| 120 | + * @returns {ScriptSync} |
| 121 | + */ |
| 122 | +function setCustomSource(fn, extension, custom_source) { return this._setCustomSource(...arguments) } |
| 123 | +ScriptSync.prototype.setCustomSource = function(...args) { return setCustomSource.apply(this,[...args]) }; |
| 124 | + |
| 125 | + |
| 126 | +// *** ADVANCED *** |
| 127 | +/** |
| 128 | + * Set whole the source a file in the user script object. |
| 129 | + * @param {string} savedFileName The filename inside the script file that needs to be updated or added. |
| 130 | + * @param {EntityFileData} newJson The new file that will be added to target script file. |
| 131 | + * @returns {boolean} Result of the function execution. |
| 132 | + */ |
| 133 | +function addFileToUserJson(savedFileName, newJson) { return this._addFileToUserJson(...arguments) } |
| 134 | +ScriptSync.prototype.addFileToUserJson = function(...args) { return addFileToUserJson.apply(this,[...args]) }; |
0 commit comments