UNPKG

shipthis

Version:

ShipThis manages building and uploading your Godot games to the App Store and Google Play.

61 lines (58 loc) 1.74 kB
import axios from 'axios'; import { o as API_URL, p as getAuthedHeaders } from './baseCommand-CTn3KGH3.js'; async function getNewUploadTicket(projectId = null) { const url = projectId ? `${API_URL}/projects/${projectId}/credentials/url` : `${API_URL}/credentials/url`; const headers = getAuthedHeaders(); const { data: uploadInfo } = await axios({ headers, method: "post", url }); return uploadInfo; } async function uploadUserCredentials({ contents, platform, serialNumber, type }) { const uploadInfo = await getNewUploadTicket(); const jsonBuffer = Buffer.from(JSON.stringify(contents)); await axios.put(uploadInfo.url, jsonBuffer, { headers: { "Content-Type": "application/json", "Content-length": jsonBuffer.length } }); const headers = getAuthedHeaders(); return await axios({ data: { platform, serialNumber, type, uuid: uploadInfo.uuid }, headers, method: "post", url: `${API_URL}/credentials` }); } async function uploadProjectCredentials(projectId, { contents, identifier, platform, serialNumber, type }) { const uploadInfo = await getNewUploadTicket(projectId); const jsonBuffer = Buffer.from(JSON.stringify(contents)); await axios.put(uploadInfo.url, jsonBuffer, { headers: { "Content-Type": "application/json", "Content-length": jsonBuffer.length } }); const headers = getAuthedHeaders(); return await axios({ data: { identifier, platform, serialNumber, type, uuid: uploadInfo.uuid }, headers, method: "post", url: `${API_URL}/projects/${projectId}/credentials` }); } export { uploadProjectCredentials as a, uploadUserCredentials as u };