mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Update version checkers to support mini changelogs
This commit is contained in:
@@ -20,35 +20,48 @@ end
|
|||||||
|
|
||||||
function CheckBridgeVersion()
|
function CheckBridgeVersion()
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
Wait(4000)
|
Wait(4000)
|
||||||
local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version')
|
local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version')
|
||||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, newestVersionRaw, headers)
|
--PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/test.txt', function(err, body, headers)
|
||||||
if not newestVersionRaw then
|
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, body, headers)
|
||||||
print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)")
|
if not body then
|
||||||
return
|
print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)")
|
||||||
end
|
return
|
||||||
|
end
|
||||||
|
|
||||||
newestVersionRaw = newestVersionRaw:match("[^\r\n]+")
|
local lines = {}
|
||||||
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw)
|
for line in body:gmatch("[^\r\n]+") do
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
|
||||||
if compareResult == 0 then
|
local newestVersionRaw = lines[1] or "0.0.0"
|
||||||
print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)")
|
local changelog = {}
|
||||||
elseif compareResult < 0 then
|
for i = 2, #lines do
|
||||||
-- Made the check a bit more obvious
|
table.insert(changelog, lines[i])
|
||||||
print("^1----------------------------------------------------------------------^7")
|
end
|
||||||
print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)")
|
|
||||||
print("^1----------------------------------------------------------------------^7")
|
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw)
|
||||||
SetTimeout(1200000, function()
|
|
||||||
-- Do a naughty repeat message every 20 minutes until the the script is updated
|
if compareResult == 0 then
|
||||||
CheckBridgeVersion()
|
print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)")
|
||||||
end)
|
elseif compareResult < 0 then
|
||||||
else
|
print("^1----------------------------------------------------------------------^7")
|
||||||
print("^7'^3jim_bridge^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)")
|
print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)")
|
||||||
end
|
for _, line in ipairs(changelog) do
|
||||||
end)
|
print((line:find("http") and "^7" or "^5")..line)
|
||||||
end)
|
end
|
||||||
end
|
print("^1----------------------------------------------------------------------^7")
|
||||||
|
SetTimeout(1200000, function()
|
||||||
|
CheckBridgeVersion()
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
print("^7'^3jim_bridge^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
CheckBridgeVersion()
|
CheckBridgeVersion()
|
||||||
@@ -15,7 +15,7 @@ function compareVersions(current, newest)
|
|||||||
if c < n then return -1
|
if c < n then return -1
|
||||||
elseif c > n then return 1 end
|
elseif c > n then return 1 end
|
||||||
end
|
end
|
||||||
return 0 -- equal
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function capitalize(str)
|
function capitalize(str)
|
||||||
@@ -33,51 +33,63 @@ function CheckVersion()
|
|||||||
if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then
|
if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
Wait(4000)
|
Wait(4000)
|
||||||
|
|
||||||
local script = getScript()
|
local script = getScript()
|
||||||
local currentVersionRaw = GetResourceMetadata(script, 'version')
|
local currentVersionRaw = GetResourceMetadata(script, 'version')
|
||||||
|
|
||||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers)
|
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers)
|
||||||
if not newestVersionRaw then
|
if not newestVersionRaw then
|
||||||
|
-- fallback
|
||||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers)
|
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers)
|
||||||
if not fallbackVersionRaw then
|
if not fallbackVersionRaw then
|
||||||
print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)")
|
print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
fallbackVersionRaw = fallbackVersionRaw:match("[^\r\n]+"):gsub("v", "")
|
local lines = {}
|
||||||
|
for line in fallbackVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
|
||||||
|
local fallbackVersion = (lines[1] or "0.0.0"):gsub("v", "")
|
||||||
|
local changelog = {}
|
||||||
|
for i = 2, #lines do table.insert(changelog, lines[i]) end
|
||||||
|
|
||||||
local compareResult = compareVersions(currentVersionRaw, fallbackVersionRaw)
|
local compareResult = compareVersions(currentVersionRaw, fallbackVersion)
|
||||||
if compareResult == 0 then
|
if compareResult == 0 then
|
||||||
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
|
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
|
||||||
elseif compareResult < 0 then
|
elseif compareResult < 0 then
|
||||||
print("^1----------------------------------------------------------------------^7")
|
print("^1----------------------------------------------------------------------^7")
|
||||||
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersionRaw.."^7)")
|
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersion.."^7)")
|
||||||
|
if #changelog > 0 then
|
||||||
|
for _, line in ipairs(changelog) do
|
||||||
|
print((line:find("http") and "^7" or "^5")..line)
|
||||||
|
end
|
||||||
|
end
|
||||||
print("^1----------------------------------------------------------------------^7")
|
print("^1----------------------------------------------------------------------^7")
|
||||||
SetTimeout(1200000, function()
|
SetTimeout(1200000, function() CheckVersion() end)
|
||||||
-- Do a naughty repeat message every 20 minutes until the the script is updated
|
|
||||||
CheckVersion()
|
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersionRaw.."^7)")
|
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersion.."^7)")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
newestVersionRaw = newestVersionRaw:match("[^\r\n]+"):gsub("v", "")
|
local lines = {}
|
||||||
|
for line in newestVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
|
||||||
|
local newestVersion = (lines[1] or "0.0.0"):gsub("v", "")
|
||||||
|
local changelog = {}
|
||||||
|
for i = 2, #lines do table.insert(changelog, lines[i]) end
|
||||||
|
|
||||||
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw)
|
local compareResult = compareVersions(currentVersionRaw, newestVersion)
|
||||||
if compareResult == 0 then
|
if compareResult == 0 then
|
||||||
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
|
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
|
||||||
elseif compareResult < 0 then
|
elseif compareResult < 0 then
|
||||||
print("^1----------------------------------------------------------------------^7")
|
print("^1----------------------------------------------------------------------^7")
|
||||||
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)")
|
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersion.."^7)")
|
||||||
|
if #changelog > 0 then
|
||||||
|
for _, line in ipairs(changelog) do
|
||||||
|
print((line:find("http") and "^7" or "^5")..line)
|
||||||
|
end
|
||||||
|
end
|
||||||
print("^1----------------------------------------------------------------------^7")
|
print("^1----------------------------------------------------------------------^7")
|
||||||
SetTimeout(1200000, function()
|
SetTimeout(1200000, function() CheckVersion() end)
|
||||||
-- Do a naughty repeat message every 20 minutes until the the script is updated
|
|
||||||
CheckVersion()
|
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)")
|
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -85,4 +97,4 @@ function CheckVersion()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
CheckVersion()
|
CheckVersion()
|
||||||
|
|||||||
Reference in New Issue
Block a user