private void CreateExportsFiles(SlipeConfig config) { string clientExports = ""; foreach (SlipeExport export in config.exports) { if (export.type == "client") { clientExports += string.Format("function {0}(...)\n\t{1}(...)\nend\n", export.niceName, export.name); } } clientExports += ""; Directory.CreateDirectory("Dist/Client"); File.WriteAllText("Dist/Client/Exports.lua", clientExports); string serverExports = ""; foreach (SlipeExport export in config.exports) { if (export.type == "server") { serverExports += string.Format("function {0}(...)\n\t{1}(...)\nend\n", export.niceName, export.name); } } serverExports += ""; Directory.CreateDirectory("Dist/Server"); File.WriteAllText("Dist/Server/Exports.lua", serverExports); }
private void CreateSystemElements(SlipeConfig config) { foreach (string systemComponent in config.systemComponents) { XmlElement element = meta.CreateElement("script"); element.SetAttribute("src", "Slipe/Lua/System/" + systemComponent); element.SetAttribute("type", "shared"); root.AppendChild(element); } foreach (SlipeModule module in config.modules) { if (module.systemComponents != null) { foreach (string systemComponent in module.systemComponents) { XmlElement element = meta.CreateElement("script"); element.SetAttribute("src", module.path + "/Lua/SystemComponents/" + systemComponent); element.SetAttribute("type", "shared"); root.AppendChild(element); } } if (module.backingLua != null) { foreach (string backingFile in module.backingLua) { XmlElement element = meta.CreateElement("script"); element.SetAttribute("src", module.path + "/Lua/Backing/" + backingFile); element.SetAttribute("type", "shared"); root.AppendChild(element); } } } }
public override void Run() { string name = string.Format("./slipe-{0}", DateTime.Now.ToShortDateString()); string path = name + ".zip"; new WebClient().DownloadFile("http://mta-slipe.com/slipe-core.zip", path); ZipFile.ExtractToDirectory(path, name); // copy Slipe/Core from zip to project string sourcePath = name + "/Slipe/Core"; string destinationPath = "./Slipe/Core"; if (Directory.Exists(destinationPath)) { Directory.Delete(destinationPath, true); } foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(sourcePath, destinationPath)); } foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(sourcePath, destinationPath), true); } SlipeConfig newConfig = ConfigHelper.Read(name + "/.slipe"); SlipeModule newModuleConfig = new SlipeModule(); // locate core module config for (int i = 0; i < newConfig.modules.Count; i++) { var module = newConfig.modules[i]; if (module.name == "SlipeCore") { newModuleConfig = module; break; } } for (int i = 0; i < config.modules.Count; i++) { var module = config.modules[i]; if (module.name == "SlipeCore") { config.modules[i] = newModuleConfig; break; } } // clean up Directory.Delete(name, true); File.Delete(path); }
private void CreateModuleTableFile(SlipeConfig config) { string moduleTable = "moduleTable = {"; foreach (SlipeModule module in config.modules) { moduleTable += string.Format("\"{0}\", ", module.path); } moduleTable += "}"; File.WriteAllText("Dist/Client/Modules.lua", moduleTable); File.WriteAllText("Dist/Server/Modules.lua", moduleTable); }
private void CreateFileElements(SlipeConfig config) { foreach (SlipeAssetDirectory directory in config.assetDirectories) { IndexDirectoryForFiles(directory.path, directory.downloads); } foreach (SlipeModule module in config.modules) { foreach (SlipeAssetDirectory directory in module.assetDirectories) { IndexDirectoryForFiles(module.path + "/" + directory.path, directory.downloads); } } }
private void UpdateCoreModule() { string name = string.Format("./slipe-{0}", DateTime.Now.ToShortDateString().Replace("/", "-").Replace("\\", "-")); string path = name + ".zip"; string coreUrl = options.ContainsKey("dev") ? Urls.devResourceTemplateUrl : Urls.resourceTemplateUrl; new WebClient().DownloadFile(coreUrl, path); ZipFile.ExtractToDirectory(path, name); // copy Slipe/Core from zip to project string sourcePath = name + "/Slipe/Core"; string destinationPath = "./Slipe/Core"; CopyFiles(sourcePath, destinationPath); CopyFiles(name + "/Slipe/Compiler", "./Slipe/Compiler"); CopyFiles(name + "/Slipe/Lua", "./Slipe/Lua"); SlipeConfig newConfig = ConfigHelper.Read(name + "/.slipe"); SlipeModule newModuleConfig = new SlipeModule(); // locate core module config for (int i = 0; i < newConfig.modules.Count; i++) { var module = newConfig.modules[i]; if (module.name == "SlipeCore") { newModuleConfig = module; break; } } for (int i = 0; i < config.modules.Count; i++) { var module = config.modules[i]; if (module.name == "SlipeCore") { config.modules[i] = newModuleConfig; break; } } // clean up Directory.Delete(name, true); File.Delete(path); }
private void CreateExportElements(SlipeConfig config) { foreach (SlipeExport export in config.exports) { XmlElement element = meta.CreateElement("export"); element.SetAttribute("function", export.niceName); element.SetAttribute("type", export.type); if (export.isHttp) { element.SetAttribute("http", "true"); } root.AppendChild(element); } }
public override void ParseArguments(string[] args) { config = ConfigHelper.Read(); base.ParseArguments(args); if (options.ContainsKey("module")) { SlipeConfig config = ConfigHelper.Read(); foreach (SlipeModule module in config.modules) { if (module.name == options["module"]) { targetModule = module; targetsModule = true; break; } } } }