Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Filelist script uses git instead of directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick committed Feb 13, 2019
1 parent 0f25520 commit 8987a78
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
51 changes: 34 additions & 17 deletions build_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,56 @@
# Author: Stephen Leitnick
# Date: February 12, 2019

import os
import json
import subprocess

FILELIST_NAME = "filelist.json"
FILELIST_MIN_NAME = "filelist.min.json"
FILELIST_INDENT = 2

FETCH_PREFIX = "https://raw.githubusercontent.com/Sleitnick/AeroGameFramework/master/"
ROOT_DIR = os.path.join(".", "src")

def path_to_dictionary(path):
d = {
"name": os.path.basename(path),
"type": "file"
}
if os.path.isdir(path):
d["type"] = "directory"
d["children"] = [path_to_dictionary(os.path.join(path, p)) for p in os.listdir(path)]
return d

def write_json_to_file(filename, json_obj, indent):
with open(filename, "w") as f:
json.dump(json_obj, f, indent=FILELIST_INDENT if indent else None)

def build():
def find(ar, name):
a = [x for x in ar if x["name"] == name]
if len(a) > 0:
return a[0]
else:
return None

if __name__ == "__main__":

print("Building file list...")

paths_data = []
query = subprocess.check_output(["git", "ls-tree", "--name-only", "-r", "master", "src"])
paths = query.split("\n")
for path in paths:
path_array = path.split("/")
current = paths_data
for p in path_array:
item = find(current, p)
if not item:
is_file = p.endswith(".lua")
item = {
"type": "file" if is_file else "directory",
"name": p
}
if not is_file:
item["children"] = []
current.append(item)
if item["type"] == "directory":
current = item["children"]

data = {
"url": FETCH_PREFIX,
"paths": path_to_dictionary(ROOT_DIR)
"paths": paths_data[0]
}

write_json_to_file(FILELIST_NAME, data, True)
write_json_to_file(FILELIST_MIN_NAME, data, False)

if __name__ == "__main__":
print("Building file list...")
build()
print("File list built")
24 changes: 12 additions & 12 deletions filelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@
"type": "directory",
"name": "DataStoreCache",
"children": [
{
"type": "file",
"name": "init.lua"
},
{
"type": "directory",
"name": "SafeDataStore",
"children": [
{
"type": "file",
"name": "init.lua"
"name": "MockDataStoreService.lua"
},
{
"type": "file",
"name": "MockDataStoreService.lua"
"name": "init.lua"
}
]
},
{
"type": "file",
"name": "init.lua"
}
]
}
Expand Down Expand Up @@ -176,10 +176,6 @@
"type": "file",
"name": "Gamepad.lua"
},
{
"type": "file",
"name": "init.lua"
},
{
"type": "file",
"name": "Keyboard.lua"
Expand All @@ -191,6 +187,10 @@
{
"type": "file",
"name": "Mouse.lua"
},
{
"type": "file",
"name": "init.lua"
}
]
}
Expand Down Expand Up @@ -228,11 +228,11 @@
"children": [
{
"type": "file",
"name": "init.lua"
"name": "SmoothDamp.lua"
},
{
"type": "file",
"name": "SmoothDamp.lua"
"name": "init.lua"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion filelist.min.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"url": "https://raw.githubusercontent.com/Sleitnick/AeroGameFramework/master/", "paths": {"type": "directory", "name": "src", "children": [{"type": "directory", "name": "ReplicatedFirst", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "file", "name": "AeroLoad.client.lua"}]}]}, {"type": "directory", "name": "ReplicatedStorage", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "directory", "name": "Internal", "children": [{"type": "file", "name": "FastSpawn.lua"}]}, {"type": "directory", "name": "Shared", "children": [{"type": "file", "name": "Base64.lua"}, {"type": "file", "name": "Date.lua"}, {"type": "file", "name": "Event.lua"}, {"type": "file", "name": "ListenerList.lua"}, {"type": "file", "name": "TableUtil.lua"}]}]}]}, {"type": "directory", "name": "ServerScriptService", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "file", "name": "AeroServer.server.lua"}]}]}, {"type": "directory", "name": "ServerStorage", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "directory", "name": "Modules", "children": [{"type": "directory", "name": "DataStoreCache", "children": [{"type": "file", "name": "init.lua"}, {"type": "directory", "name": "SafeDataStore", "children": [{"type": "file", "name": "init.lua"}, {"type": "file", "name": "MockDataStoreService.lua"}]}]}]}, {"type": "directory", "name": "Services", "children": [{"type": "file", "name": "DataService.lua"}, {"type": "file", "name": "StoreService.lua"}]}]}]}, {"type": "directory", "name": "StarterPlayer", "children": [{"type": "directory", "name": "StarterPlayerScripts", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "file", "name": "AeroClient.client.lua"}, {"type": "directory", "name": "Controllers", "children": [{"type": "file", "name": "Fade.lua"}, {"type": "file", "name": "TaskScheduler.lua"}, {"type": "directory", "name": "UserInput", "children": [{"type": "file", "name": "Gamepad.lua"}, {"type": "file", "name": "init.lua"}, {"type": "file", "name": "Keyboard.lua"}, {"type": "file", "name": "Mobile.lua"}, {"type": "file", "name": "Mouse.lua"}]}]}, {"type": "directory", "name": "Modules", "children": [{"type": "directory", "name": "CameraShaker", "children": [{"type": "file", "name": "CameraShakeInstance.lua"}, {"type": "file", "name": "CameraShakePresets.lua"}, {"type": "file", "name": "init.lua"}]}, {"type": "file", "name": "PID.lua"}, {"type": "directory", "name": "Smooth", "children": [{"type": "file", "name": "init.lua"}, {"type": "file", "name": "SmoothDamp.lua"}]}, {"type": "directory", "name": "Tween", "children": [{"type": "file", "name": "Easing.lua"}, {"type": "file", "name": "init.lua"}]}]}]}]}]}]}}
{"url": "https://raw.githubusercontent.com/Sleitnick/AeroGameFramework/master/", "paths": {"type": "directory", "name": "src", "children": [{"type": "directory", "name": "ReplicatedFirst", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "file", "name": "AeroLoad.client.lua"}]}]}, {"type": "directory", "name": "ReplicatedStorage", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "directory", "name": "Internal", "children": [{"type": "file", "name": "FastSpawn.lua"}]}, {"type": "directory", "name": "Shared", "children": [{"type": "file", "name": "Base64.lua"}, {"type": "file", "name": "Date.lua"}, {"type": "file", "name": "Event.lua"}, {"type": "file", "name": "ListenerList.lua"}, {"type": "file", "name": "TableUtil.lua"}]}]}]}, {"type": "directory", "name": "ServerScriptService", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "file", "name": "AeroServer.server.lua"}]}]}, {"type": "directory", "name": "ServerStorage", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "directory", "name": "Modules", "children": [{"type": "directory", "name": "DataStoreCache", "children": [{"type": "directory", "name": "SafeDataStore", "children": [{"type": "file", "name": "MockDataStoreService.lua"}, {"type": "file", "name": "init.lua"}]}, {"type": "file", "name": "init.lua"}]}]}, {"type": "directory", "name": "Services", "children": [{"type": "file", "name": "DataService.lua"}, {"type": "file", "name": "StoreService.lua"}]}]}]}, {"type": "directory", "name": "StarterPlayer", "children": [{"type": "directory", "name": "StarterPlayerScripts", "children": [{"type": "directory", "name": "Aero", "children": [{"type": "file", "name": "AeroClient.client.lua"}, {"type": "directory", "name": "Controllers", "children": [{"type": "file", "name": "Fade.lua"}, {"type": "file", "name": "TaskScheduler.lua"}, {"type": "directory", "name": "UserInput", "children": [{"type": "file", "name": "Gamepad.lua"}, {"type": "file", "name": "Keyboard.lua"}, {"type": "file", "name": "Mobile.lua"}, {"type": "file", "name": "Mouse.lua"}, {"type": "file", "name": "init.lua"}]}]}, {"type": "directory", "name": "Modules", "children": [{"type": "directory", "name": "CameraShaker", "children": [{"type": "file", "name": "CameraShakeInstance.lua"}, {"type": "file", "name": "CameraShakePresets.lua"}, {"type": "file", "name": "init.lua"}]}, {"type": "file", "name": "PID.lua"}, {"type": "directory", "name": "Smooth", "children": [{"type": "file", "name": "SmoothDamp.lua"}, {"type": "file", "name": "init.lua"}]}, {"type": "directory", "name": "Tween", "children": [{"type": "file", "name": "Easing.lua"}, {"type": "file", "name": "init.lua"}]}]}]}]}]}]}}

0 comments on commit 8987a78

Please sign in to comment.