shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
51 lines (47 loc) • 2.43 kB
JavaScript
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { o as API_URL, p as getAuthedHeaders } from './index-BwnzoldS.js';
const cacheKeys = {
androidKeyTestResult: (props) => ["androidKeyTestResult", ...Object.values(props)],
androidSetupStatus: (props) => ["androidSetupStatus", ...Object.values(props)],
builds: (props) => ["builds", ...Object.values(props)],
googleStatus: () => ["googleStatus"],
job: (props) => ["job", ...Object.values(props)],
jobLogs: (props) => ["jobLogs", ...Object.values(props)],
jobs: (props) => ["jobs", ...Object.values(props)],
projectCredentials: (props) => ["projectCredentials", ...Object.values(props)],
userCredentials: (props) => ["userCredentials", ...Object.values(props)]
};
var KeyTestStatus = /* @__PURE__ */ ((KeyTestStatus2) => {
KeyTestStatus2["ERROR"] = "error";
KeyTestStatus2["SUCCESS"] = "success";
return KeyTestStatus2;
})(KeyTestStatus || {});
var KeyTestError = /* @__PURE__ */ ((KeyTestError2) => {
KeyTestError2["APP_NOT_FOUND"] = "app_not_found";
KeyTestError2["NO_PACKAGE_NAME"] = "no_package_name";
KeyTestError2["NO_SERVICE_ACCOUNT_KEY"] = "no_service_account_key";
KeyTestError2["NOT_INVITED"] = "not_invited";
return KeyTestError2;
})(KeyTestError || {});
const KeyTestErrorMessage = {
["app_not_found" /* APP_NOT_FOUND */]: "Application not found in Google Play Console",
["no_package_name" /* NO_PACKAGE_NAME */]: "Android Package Name has not been set",
["no_service_account_key" /* NO_SERVICE_ACCOUNT_KEY */]: "Service Account API Key not found in your account",
["not_invited" /* NOT_INVITED */]: "Service Account has not been invited to Google Play"
};
function niceError(keyError) {
return keyError ? KeyTestErrorMessage[keyError] : void 0;
}
const fetchKeyTestResult = async ({ projectId }, config) => {
if (!projectId) throw new Error("projectId is required");
const url = `${API_URL}/projects/${projectId}/credentials/android/key/test`;
const headers = getAuthedHeaders();
const { data } = await axios.post(url, {}, { headers, ...config });
return data;
};
const useAndroidServiceAccountTestResult = (props) => useQuery({
queryFn: () => fetchKeyTestResult(props),
queryKey: cacheKeys.androidKeyTestResult(props)
});
export { KeyTestStatus as K, KeyTestError as a, cacheKeys as c, fetchKeyTestResult as f, niceError as n, useAndroidServiceAccountTestResult as u };