Comparison

prosodyctl @ 10155:ebe39918d430

prosodyctl: Removed the development commands magic, get_modules and write_rockspec
author João Duarte <jvsDuarte08@gmail.com>
date Wed, 24 Jul 2019 04:24:29 -0700
parent 10154:ad081451291f
child 10157:c6e166272d94
comparison
equal deleted inserted replaced
10154:ad081451291f 10155:ebe39918d430
82 82
83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; 83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2;
84 ----------------------- 84 -----------------------
85 local commands = {}; 85 local commands = {};
86 local command = table.remove(arg, 1); 86 local command = table.remove(arg, 1);
87
88 function commands.magic(arg)
89 --print("Getting all the available modules")
90 --os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules")
91 local i, popen = 0, io.popen
92 local flag = "mod_"
93 os.execute("mkdir repository")
94 local pfile = popen('ls -a "'..arg[1]..'"')
95 for filename in pfile:lines() do
96 i = i + 1
97 if filename:sub(1, #flag) == flag then
98 local file = io.open("repository/"..filename.."-scm-1.rockspec", "w")
99 file:write('package = "'..filename..'"', '\n')
100 file:write('version = "scm-1"', '\n')
101 file:write('source = {', '\n')
102 file:write('\turl = "hg+https://hg.prosody.im/prosody-modules",', '\n')
103 file:write('\tdir = "prosody-modules"', '\n')
104 file:write('}', '\n')
105 file:write('description = {', '\n')
106 file:write('\thomepage = "https://prosody.im/",', '\n')
107 file:write('\tlicense = "MIT"', '\n')
108 file:write('}', '\n')
109 file:write('dependencies = {', '\n')
110 file:write('\t"lua >= 5.1"', '\n')
111 file:write('}', '\n')
112 file:write('build = {', '\n')
113 file:write('\ttype = "builtin",', '\n')
114 file:write('\tmodules = {', '\n')
115 file:write('\t\t["'..filename..'.'..filename..'"] = "'..filename..'/'..filename..'.lua"', '\n')
116 file:write('\t}', '\n')
117 file:write('}', '\n')
118 file:close()
119 end
120 end
121 pfile:close()
122 os.execute("cd repository/ && luarocks-admin make_manifest ./ && chmod -R 644 ./*")
123 end
124
125 -- This function receives no arguments. It clones all the plugins from prosody's plugin repository
126 function commands.get_modules(arg)
127 if arg[1] == "--help" then
128 show_usage([[get_modules]], [[Downloads all available modules]]);
129 return 1;
130 end
131 if os.execute '[ -e "./downloaded_modules" ]' then
132 print("The modules have already been imported")
133 print("Do you want to re-import?(Y/N)")
134 local answer = io.read()
135 if answer == "Y" then
136 print("Deleting previous imports")
137 os.execute("rm -rf downloaded_modules")
138 print("Downloading plugins")
139 os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules")
140 print("Done!")
141 return 0;
142 else
143 print("We keep what we have then!")
144 return 0;
145 end
146 else
147 print("Getting all the available modules")
148 os.execute("hg clone https://hg.prosody.im/prosody-modules/ downloaded_modules")
149 print("Done!")
150 return 0;
151 end
152 end
153
154 -- Function to write rockspecs from a module at working_directory/downloaded_modules
155 -- Receives the module's name as an argument
156 -- The rockspec is saved inside its module's folder
157 function commands.write_rockspec(arg)
158 if arg[1] == "--help" then
159 show_usage([[write_rockspec]], [[Picks up a module and writes an initial rockspec]]);
160 return 1;
161 end
162 print("Writing rockspec for "..arg[1])
163 os.execute("luarocks write_rockspec "..arg[1].." ./downloaded_modules/"..arg[1])
164 print("Rockspec created! Moving it into the ./downloaded_modules/"..arg[1].." folder")
165 os.execute("mv "..arg[1].."-scm-1.rockspec ./downloaded_modules/"..arg[1])
166 print("Done!")
167 return 0;
168 end
169 87
170 -- Command to install a rockspec with local sources 88 -- Command to install a rockspec with local sources
171 -- The module is installed at the plugins folder 89 -- The module is installed at the plugins folder
172 function commands.make(arg) 90 function commands.make(arg)
173 if arg[1] == "--help" then 91 if arg[1] == "--help" then