shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
48 lines (45 loc) • 1.27 kB
JavaScript
import { promises } from 'node:fs';
import axios from 'axios';
import { o as API_URL, p as getAuthedHeaders } from './baseCommand-CTn3KGH3.js';
async function getNewImportTicket(projectId) {
const url = projectId ? `${API_URL}/projects/${projectId}/credentials/import/url` : `${API_URL}/credentials/import/url`;
const headers = getAuthedHeaders();
const { data: importInfo } = await axios({
headers,
method: "post",
url
});
return importInfo;
}
async function importCredential({
platform,
projectId,
type,
zipPath
}) {
const importTicket = await getNewImportTicket(projectId);
const zipBuffer = await promises.readFile(zipPath);
await axios.put(importTicket.url, zipBuffer, {
headers: {
"Content-Type": "application/zip",
"Content-length": zipBuffer.length
}
});
const headers = getAuthedHeaders();
const url = projectId ? `${API_URL}/projects/${projectId}/credentials/import` : `${API_URL}/credentials/import`;
const { data: publicCredential } = await axios({
data: {
platform,
type,
uuid: importTicket.uuid
},
headers,
method: "post",
url
});
if (projectId) {
return publicCredential;
}
return publicCredential;
}
export { importCredential as i };