Skip to content

Commit

Permalink
Only grab the latest build in the Updater check
Browse files Browse the repository at this point in the history
  • Loading branch information
LadyCailin committed Mar 30, 2024
1 parent c21762f commit acc50ac
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 11 deletions.
1 change: 1 addition & 0 deletions scripts/bash/update-apps-api
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function StartMain {

Status "Generating Node Server"
java -jar "$GeneratorJar" generate -i "$InputSpec" -l nodejs-server -o "$NodeRepo" --disable-examples --template-dir "$TemplateDir"
npx swagger-typescript-api -p "$InputSpec" -o "$NodeRepo\models" --clean-output --no-client

Status "Done!"
}
Expand Down
1 change: 1 addition & 0 deletions scripts/windows/update-apps-api.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function Start-Main([string] $SwaggerGenerator,

Status "Generating Node Server"
java -jar $GeneratorJar generate -i $InputSpec -l nodejs-server -o $NodeRepo "--disable-examples" "--template-dir" $TemplateDir
npx swagger-typescript-api -p $InputSpec -o "$NodeRepo\models" --clean-output --no-client

Status "Done!"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/laytonsmith/core/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Date getDateFromString(String date) throws ParseException {
}

public static BuildArtifact getLatestVersionInfo() throws ApiException, ParseException {
List<BuildArtifact> versions = API.buildsArtifactGet(DEFAULT_UPDATE_CHANNEL);
List<BuildArtifact> versions = API.buildsArtifactGet(DEFAULT_UPDATE_CHANNEL, true);
BuildArtifact maxVersion = null;
for(int i = 0; i < versions.size(); i++) {
BuildArtifact version = versions.get(i);
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/io/swagger/client/api/BuildsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public void setApiClient(ApiClient apiClient) {
/**
* Build call for buildsArtifactGet
* @param artifact The artifact type to list builds for. (required)
* @param latest (optional)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call buildsArtifactGetCall(String artifact, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
public com.squareup.okhttp.Call buildsArtifactGetCall(String artifact, Boolean latest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
Expand All @@ -71,6 +72,8 @@ public com.squareup.okhttp.Call buildsArtifactGetCall(String artifact, final Pro

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (latest != null)
localVarQueryParams.addAll(apiClient.parameterToPair("latest", latest));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Expand Down Expand Up @@ -105,13 +108,13 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch
}

@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call buildsArtifactGetValidateBeforeCall(String artifact, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private com.squareup.okhttp.Call buildsArtifactGetValidateBeforeCall(String artifact, Boolean latest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'artifact' is set
if (artifact == null) {
throw new ApiException("Missing the required parameter 'artifact' when calling buildsArtifactGet(Async)");
}

com.squareup.okhttp.Call call = buildsArtifactGetCall(artifact, progressListener, progressRequestListener);
com.squareup.okhttp.Call call = buildsArtifactGetCall(artifact, latest, progressListener, progressRequestListener);
return call;


Expand All @@ -124,23 +127,25 @@ private com.squareup.okhttp.Call buildsArtifactGetValidateBeforeCall(String arti
* Provides a list of builds of the specified artifact available for download.
* Provides a list of builds of the specified artifact available for download. Note that the order of the returned artifacts is arbitrary.
* @param artifact The artifact type to list builds for. (required)
* @param latest (optional)
* @return List&lt;BuildArtifact&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public List<BuildArtifact> buildsArtifactGet(String artifact) throws ApiException {
ApiResponse<List<BuildArtifact>> resp = buildsArtifactGetWithHttpInfo(artifact);
public List<BuildArtifact> buildsArtifactGet(String artifact, Boolean latest) throws ApiException {
ApiResponse<List<BuildArtifact>> resp = buildsArtifactGetWithHttpInfo(artifact, latest);
return resp.getData();
}

/**
* Provides a list of builds of the specified artifact available for download.
* Provides a list of builds of the specified artifact available for download. Note that the order of the returned artifacts is arbitrary.
* @param artifact The artifact type to list builds for. (required)
* @param latest (optional)
* @return ApiResponse&lt;List&lt;BuildArtifact&gt;&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<List<BuildArtifact>> buildsArtifactGetWithHttpInfo(String artifact) throws ApiException {
com.squareup.okhttp.Call call = buildsArtifactGetValidateBeforeCall(artifact, null, null);
public ApiResponse<List<BuildArtifact>> buildsArtifactGetWithHttpInfo(String artifact, Boolean latest) throws ApiException {
com.squareup.okhttp.Call call = buildsArtifactGetValidateBeforeCall(artifact, latest, null, null);
Type localVarReturnType = new TypeToken<List<BuildArtifact>>(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
Expand All @@ -149,11 +154,12 @@ public ApiResponse<List<BuildArtifact>> buildsArtifactGetWithHttpInfo(String art
* Provides a list of builds of the specified artifact available for download. (asynchronously)
* Provides a list of builds of the specified artifact available for download. Note that the order of the returned artifacts is arbitrary.
* @param artifact The artifact type to list builds for. (required)
* @param latest (optional)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call buildsArtifactGetAsync(String artifact, final ApiCallback<List<BuildArtifact>> callback) throws ApiException {
public com.squareup.okhttp.Call buildsArtifactGetAsync(String artifact, Boolean latest, final ApiCallback<List<BuildArtifact>> callback) throws ApiException {

ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
Expand All @@ -174,7 +180,7 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don
};
}

com.squareup.okhttp.Call call = buildsArtifactGetValidateBeforeCall(artifact, progressListener, progressRequestListener);
com.squareup.okhttp.Call call = buildsArtifactGetValidateBeforeCall(artifact, latest, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<List<BuildArtifact>>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
Expand Down
91 changes: 91 additions & 0 deletions src/main/java/io/swagger/client/model/BuildsArtifactBody.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* MethodScript Apps
* This is the api for the apps.methodscript.com server. This provides various public functionality for users of the MethodScript programming language.
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

package io.swagger.client.model;

import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.IOException;
/**
* BuildsArtifactBody
*/


public class BuildsArtifactBody {
@SerializedName("latest")
private Boolean latest = null;

public BuildsArtifactBody latest(Boolean latest) {
this.latest = latest;
return this;
}

/**
* Get latest
* @return latest
**/
@Schema(description = "")
public Boolean isLatest() {
return latest;
}

public void setLatest(Boolean latest) {
this.latest = latest;
}


@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BuildsArtifactBody buildsArtifactBody = (BuildsArtifactBody) o;
return Objects.equals(this.latest, buildsArtifactBody.latest);
}

@Override
public int hashCode() {
return Objects.hash(latest);
}


@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class BuildsArtifactBody {\n");

sb.append(" latest: ").append(toIndentedString(latest)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}
3 changes: 2 additions & 1 deletion src/main/resources/apps.methodscript.com/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ interface builds {
@operationId("buildsArtifactGet")
@get buildsArtifact(
@doc("The artifact type to list builds for.")
artifact: string
artifact: string,
@query latest?: boolean,
) : Array<BuildArtifact> | Build404;

@summary("Downloads a specific build of the specified artifact type.")
Expand Down

0 comments on commit acc50ac

Please sign in to comment.