shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
44 lines (41 loc) • 1.91 kB
JavaScript
import { M as getGoogleStatus, N as getGodotAndroidPackageName } from './baseCommand-CTn3KGH3.js';
import { c as BaseGameCommand, d as generatePackageName, b as getInput } from './baseGameCommand-8VL7xe-O.js';
class BaseGameAndroidCommand extends BaseGameCommand {
async checkGoogleAuth(waitForAuth = false) {
let status = await getGoogleStatus();
if (status.isAuthenticated) return;
if (!waitForAuth)
this.error("You must connect to Google first. Run `shipthis game android apiKey connect`", { exit: 1 });
this.log("Waiting for Google authentication...");
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
for (let i = 0; i < 600; i++) {
process.stdout.write(".");
await sleep(1e3 * 10);
status = await getGoogleStatus();
if (status.isAuthenticated) return;
}
this.error("Google authentication failed. Please try again.", { exit: 1 });
}
// Forces us to have the androidPackageName in the game details
async ensureWeHaveAndroidPackageName() {
const game = await this.getGame();
if (!game.details?.androidPackageName) {
const androidPackageName = await this.getAndroidPackageName(game.id);
await this.updateGame({ details: { ...game.details, androidPackageName } });
}
}
// Prompts the user for the Android package name
async getAndroidPackageName(gameId) {
const game = await this.getGame();
const generated = generatePackageName(game.name);
const suggested = game.details?.iosBundleId || getGodotAndroidPackageName() || generated || "com.example.game";
const question = `Please enter the Android Package Name, or press enter to use ${suggested}: `;
const entered = await getInput(question);
return entered || suggested;
}
async init() {
await super.init();
await this.ensureWeHaveAndroidPackageName();
}
}
export { BaseGameAndroidCommand as B };