-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfullUpdate.lua
More file actions
173 lines (128 loc) · 4.21 KB
/
Copy pathfullUpdate.lua
File metadata and controls
173 lines (128 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
local updatePackage = require "update-package"
if os.rename("config.lua", "config.lua") == nil then
print("Creating ./config.lua - please configure.")
local file = io.open("config.lua", "w")
file:write(
[=[local getSSS = function(game)
return game:GetService("ServerScriptService")
end
local getChatModules = function(game)
local Chat = game:GetService("Chat")
local ChatModules = Chat:FindFirstChild("ChatModules")
if not ChatModules then
ChatModules = Instance.new("Folder")
ChatModules.Name = "ChatModules"
local InsertDefaultModules = Instance.new("BoolValue")
InsertDefaultModules.Name = "InsertDefaultModules"
remodel.setRawProperty(InsertDefaultModules, "Value", "Bool", true)
InsertDefaultModules.Parent = ChatModules
ChatModules.Parent = Chat
end
return ChatModules
end
--[[
All package name keys must match the name of the top level instance
--]]
return {
--[[
Path to project file of the release version of each package
--]]
PackageProjectFiles = {
-- e.g
-- metaboard = "/path/to/metaboard/release.project.json"
},
--[[
Functions which retrieve the target parent instance of the package given
a DataModel (i.e. game).
--]]
PackageDestination = {
-- e.g.
-- metaboard = getSSS,
-- metaportal = getSSS,
-- AdminCommands = getChatModules,
},
--[[
PlaceIds of places to update packages in. Key does not need to match actual
publish name of place.
--]]
PlaceIds = {
-- e.g.
-- TRS = "123456789"
}
}
]=])
file:close()
return
end
local config = require "config"
local args = {...}
if #args >=2 or (#args == 1 and args[1] ~= "no_prompt") then
print("Incorrect usage. Please run one of the following")
print("remodel run fullUpdate.lua")
print("remodel run fullUpdate.lua no_prompt")
return
end
local noPrompt = args[1] == "no_prompt"
local function execute(command)
print("> " .. command)
local success = os.execute(command)
if not success then
os.exit(0)
end
end
if not next(config.PackageProjectFiles) then
print("No packages to build - configure config.lua (see PackageProjectFiles)")
end
local packages = {}
for packageName, projectFile in pairs(config.PackageProjectFiles) do
local packageFileName = packageName..".rbxm"
execute(
("rojo build -o \"%s\" \"%s\"")
:format(packageFileName, projectFile)
)
packages[packageName] = remodel.readModelFile(packageFileName)[1]
end
if not next(config.PlaceIds) then
print("No placeIds to download - configure config.lua (see PlaceIds)")
end
for placeName, placeId in pairs(config.PlaceIds) do
print(string.rep("-", 80))
print(placeName)
print(string.rep("-", 80))
print("Downloading placeId "..placeId)
local game = remodel.readPlaceAsset(placeId)
local packageChangeLogs = {}
for packageName, package in pairs(packages) do
local destination = config.PackageDestination[packageName](game)
packageChangeLogs[packageName] = updatePackage(package, destination, not noPrompt)
end
if next(packageChangeLogs) then
while true do
-- UTC timestamp that matches the format used in Version History
local timeStamp = os.date("!%m/%d/%Y %I:%M:%S %p")
local changeLog = "Update at "..timeStamp.."\n\n"
for packageName, packageChangeLog in pairs(packageChangeLogs) do
changeLog = changeLog..(("[%s]\n%s\n"):format(packageName, packageChangeLog))
end
local changeLogScript = game:GetService("ServerStorage"):FindFirstChild("PackageUpdateChangeLog")
if not changeLogScript then
changeLogScript = Instance.new("Script")
changeLogScript.Name = "PackageUpdateChangeLog"
changeLogScript.Parent = game:GetService("ServerStorage")
end
remodel.setRawProperty(changeLogScript, "Source", "String", "--[[\nTHIS SCRIPT WILL BE REPLACED EVERY PACKAGE UPDATE\n\n"..changeLog.."]]--")
print("Publishing updated place to "..placeId, "(timestamp: "..timeStamp..")")
local success, result = pcall(remodel.writeExistingPlaceAsset, game, placeId)
if success then
break
else
print("Publish failed:", result)
print("Retrying (in 5 seconds)...")
os.execute("sleep " .. tostring(5))
end
end
print(("Version History: https://www.roblox.com/places/%s/update#"):format(placeId))
else
print("No changes made to "..placeName..". Not publishing.")
end
end