Skip to content

Commit

Permalink
Adding version updating to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerr committed Nov 5, 2016
1 parent eed9a8c commit 0ea49ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion updater/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void updateScript(ScriptData script, File zip) {

String url = "https://tribot.org/repository/script/edit/#/source/".replace("#", script.id);
LinkedHashMap<String, String> params = new LinkedHashMap<>();
params.put("version", script.version);
params.put("version", Packer.getVersion(script.name));

try {
MultipartFormDataUtil multipartRequest = new MultipartFormDataUtil(url, params, zip);
Expand Down
10 changes: 8 additions & 2 deletions updater/packer/Packer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Packer {
private static HashMap<String, Set<String>> scriptDependencyMap = new HashMap<>();
private static HashMap<Class, String> scriptNameMap = new HashMap<>();
private static HashMap<String, File> zips = new HashMap<>();
private static HashMap<String, String> versions = new HashMap<>();

static {
try {
Expand Down Expand Up @@ -125,7 +126,7 @@ public static void load(HashMap<String, List<String>> scriptPaths) throws IOExce
if (scriptPaths.get(scriptName).size() == 0) return;

List<File> sourceDirs = scriptPaths.get(scriptName).stream().map(s -> new File(s)).collect(Collectors.toList());
File zip = pack(scriptClass, sourceDirs);
File zip = pack(scriptClass, sourceDirs, scriptName);
if (zip != null) zips.put(scriptName, zip);
}
}
Expand All @@ -138,7 +139,11 @@ public static File getZip(String name) {
return zips.containsKey(name) ? zips.get(name) : null;
}

public static File pack(Class<? extends Script> script, List<File> dirs) {
public static String getVersion(String name) {
return versions.containsKey(name) ? versions.get(name) : "1.0";
}

public static File pack(Class<? extends Script> script, List<File> dirs, String name) {
try {
List<File> sources = new ArrayList<>();
File e = new File(JAR_FILE.getParentFile(), "zips");
Expand All @@ -152,6 +157,7 @@ public static File pack(Class<? extends Script> script, List<File> dirs) {
if(script.isAnnotationPresent(ScriptManifest.class)) {
ScriptManifest codeSrc = script.getAnnotation(ScriptManifest.class);
scriptName = codeSrc.name() + " V" + codeSrc.version();
versions.put(name, codeSrc.version() + "");
} else {
Logger.getLogger("Logger").log(Level.WARNING, "No script manifest found!");
scriptName = script.getSimpleName();
Expand Down

0 comments on commit 0ea49ff

Please sign in to comment.