shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
37 lines (34 loc) • 1.04 kB
JavaScript
import * as fs from 'node:fs';
import axios from 'axios';
import { o as API_URL, p as getAuthedHeaders } from './index-BwnzoldS.js';
async function exportCredential({ credentialId, projectId, zipPath }) {
const headers = getAuthedHeaders();
const url = projectId ? `${API_URL}/projects/${projectId}/credentials/${credentialId}/export` : `${API_URL}/credentials/${credentialId}/export`;
const { data } = await axios.post(
url,
{},
// no-body
{ headers }
);
const downloadUrl = data.url;
return await downloadFile(downloadUrl, zipPath);
}
async function downloadFile(url, destination) {
const response = await axios({
method: "GET",
responseType: "stream",
url
});
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(destination);
response.data.pipe(file);
file.on("finish", () => {
file.close();
resolve();
});
file.on("error", (err) => {
fs.unlink(destination, () => reject(err));
});
});
}
export { exportCredential as e };