local f=require("\064\108\117\110\101\047\102\115")local r=require("\046\047\108\105\098\047\101\120\101\099")local W=require("\046\047\108\105\098\047\103\101\116\080\114\111\106\101\099\116\070\105\108\101");(r({"\119\097\108\108\121";"\105\110\115\116\097\108\108"})):assert()if(r({"\114\111\106\111";"--\118\101\114\115\105\111\110"})).ok then local X=W()local Y=false if X then(r({"\114\111\106\111","\115\111\117\114\099\101\109\097\112";"-\111";"\115\111\117\114\099\101\109\097\112\046\106\115\111\110";X})):assert()Y=true end if(r({"\119\097\108\108\121-\112\097\099\107\097\103\101-\116\121\112\101\115";"--\118\101\114\115\105\111\110"})).ok and Y then if f.isDir("\080\097\099\107\097\103\101\115")then(r({"\119\097\108\108\121-\112\097\099\107\097\103\101-\116\121\112\101\115";"--\115\111\117\114\099\101\109\097\112","\115\111\117\114\099\101\109\097\112\046\106\115\111\110";"\046\047\080\097\099\107\097\103\101\115\047"})):assert()end if f.isDir("\083\101\114\118\101\114\080\097\099\107\097\103\101\115")then(r({"\119\097\108\108\121-\112\097\099\107\097\103\101-\116\121\112\101\115";"--\115\111\117\114\099\101\109\097\112";"\115\111\117\114\099\101\109\097\112\046\106\115\111\110","\046\047\083\101\114\118\101\114\080\097\099\107\097\103\101\115\047"})):assert()end if f.isDir("\068\101\118\080\097\099\107\097\103\101\115")then(r({"\119\097\108\108\121-\112\097\099\107\097\103\101-\116\121\112\101\115","--\115\111\117\114\099\101\109\097\112","\115\111\117\114\099\101\109\097\112\046\106\115\111\110";"\046\047\068\101\118\080\097\099\107\097\103\101\115\047"})):assert()end end if(r({"\119\097\108\108\121-\112\097\116\099\104-\112\097\099\107\097\103\101","--\118\101\114\115\105\111\110"})).ok then(r({"\119\097\108\108\121-\112\097\116\099\104-\112\097\099\107\097\103\101"})):assert()end end
--[=[ lunar
about = "Installs wally packages, with types and patches."
]=]

local fs = require("@lune/fs")

local exec = require("./lib/exec")
local getProjectFile = require("./lib/getProjectFile")

exec({ "wally", "install" }):assert()

if exec({ "rojo", "--version" }).ok then
	local projectFile = getProjectFile()
	
	local updatedSourcemap = false
	if projectFile then
		exec({ "rojo", "sourcemap", "-o", "sourcemap.json", projectFile }):assert()
		updatedSourcemap = true
	end

	if exec({ "wally-package-types", "--version" }).ok and updatedSourcemap then
		if fs.isDir("Packages") then
			exec({ "wally-package-types", "--sourcemap", "sourcemap.json", "./Packages/" }):assert()
		end
		if fs.isDir("ServerPackages") then
			exec({ "wally-package-types", "--sourcemap", "sourcemap.json", "./ServerPackages/" }):assert()
		end
		if fs.isDir("DevPackages") then
			exec({ "wally-package-types", "--sourcemap", "sourcemap.json", "./DevPackages/" }):assert()
		end
	end

	if exec({ "wally-patch-package", "--version" }).ok then
		exec({ "wally-patch-package" }):assert()
	end
end
