66 local config = function ()
77 return SCM .Config :getAll ()
88 end
9- local log = function (...) SCM .Log :log (... ) end
9+ local log = function (...) SCM .Log :log (... ) end
1010
1111 --- @param target string
1212 --- @param fileType string
1818 -- @TODO: Error handling
1919 return false
2020 end
21-
2221 local sourceObject = {
2322 name = nil ,
2423 source = {
25- [" default" ] = target
24+ [" default" ] = target ,
2625 },
26+ sourceName = " default" ,
2727 type = fileType
2828 }
29-
3029 if updateObj then sourceObject .name = updateObj .name end
3130
3231 -- Check for Pastebin
3332 local name , code = SCM .ScriptManager :splitNameCode (target )
3433 if name and code then
3534 sourceObject .name = name
36- return SCM .ScriptManager :addScript (self :downloadPastebin (sourceObject , code , config ()[fileType .. " Directory" ],
35+ return SCM .ScriptManager :addScript (self :downloadPastebin (sourceObject , code ,
36+ config ()[fileType .. " Directory" ],
3737 updateObj ))
3838 end
3939
4747 end
4848 local repository = target .. suffix
4949 sourceObject .name = target
50+
5051 return SCM .ScriptManager :addScript (self :downloadGit (sourceObject , repository , config ()[fileType .. " Directory" ],
5152 updateObj ))
5253 end
118119 file .close ()
119120
120121 local filePaths = {}
121- if fs then
122- file = fs .open (targetDirectory .. sourceObject .name
123- .. config ()[sourceObject .type .. " Suffix" ]
124- .. " /" .. config ()[" infoFile" ], " r" )
125-
126- local line = file .read ()
127- while line do
128- filePaths [# filePaths + 1 ] = line
129- line = file .read ()
130- end
131- file .close ()
132- else
133- file = fs .open (targetDirectory .. sourceObject .name
134- .. config ()[sourceObject .type .. " Suffix" ]
135- .. " /" .. config ()[" infoFile" ], " r" )
136- -- print(file.read())
137- local line = file .read ()
138- while line do
139- filePaths [# filePaths + 1 ] = line
140- line = file .read ()
141- end
142- file .close ()
122+ file = fs .open (targetDirectory .. sourceObject .name
123+ .. config ()[sourceObject .type .. " Suffix" ]
124+ .. " /" .. config ()[" infoFile" ], " r" )
125+ local line = file .readLine ()
126+ while line do
127+ filePaths [# filePaths + 1 ] = line
128+ line = file .readLine ()
143129 end
130+ file .close ()
144131 for i = 1 , # filePaths , 1 do
145132 local success = true
146133 local tmpRequest = http .get (baseUrl .. filePaths [i ])
175162
176163 -- create a link that calls the file within the program directory
177164 if sourceObject .type == " program" then
178- local progamLink = fs .open (sourceObject .name , " w" )
165+ local progamLink = fs .open (sourceObject .name .. " .lua " , " w" )
179166 progamLink .write (" shell.execute(\" " .. targetDirectory .. sourceObject .name ..
180167 config ()[sourceObject .type .. " Suffix" ]
181168 .. " /" .. sourceObject .name .. " .lua" .. " \" , ...)" )
219206 if not sourceObject .name then
220207 sourceObject .name = self :getNameFromURL (sourceObject .source [sourceName ])
221208 end
222-
223209 local request = http .get (sourceObject .source [sourceName ])
224210
225211 if request then
234220 end
235221 file .write (content )
236222 file .close ()
223+
237224 return sourceObject , true
238225 end
239226 end
344331 if not file then
345332 os.execute (" mkdir " .. config ()[" configDirectory" ])
346333 file = fs .open (config ()[" configDirectory" ] .. config ()[" repoScriptsFile" ], " w" )
347- end
334+ end
348335 if file then
349- file .write (" " .. textutils .serializeJSON (repoScripts ))
336+ file .write (" " .. textutils .serializeJSON (repoScripts ))
350337 file .close ()
351338 end
352339 end
353340
354- function Net :getNewestVersion ()
341+ function Net :getNewestVersion ()
355342 local githubAPIgetTags = config ()[" apiGithubGetTags" ]
356343 githubAPIgetTags = githubAPIgetTags :gsub (" <USER>" , config ()[" user" ])
357344 githubAPIgetTags = githubAPIgetTags :gsub (" <REPO>" , config ()[" repository" ])
358-
345+
359346 local request = http .get (githubAPIgetTags )
360-
347+
361348 if request then
362349 local content = request .readAll ()
363350 request .close ()
370357 end
371358end
372359
373- return Net
360+ return Net
0 commit comments