shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
94 lines (91 loc) • 3.51 kB
JavaScript
import { Args, Flags } from '@oclif/core';
import { R as inviteServiceAccount } from '../../../../baseCommand-CTn3KGH3.js';
import 'node:fs';
import 'node:path';
import 'chalk';
import { n as fetchKeyTestResult, K as KeyTestStatus, p as KeyTestError, o as niceError, b as getInput } from '../../../../baseGameCommand-8VL7xe-O.js';
import 'react/jsx-runtime';
import 'ink';
import 'ink-spinner';
import 'react';
import '@tanstack/react-query';
import 'axios';
import 'luxon';
import 'fast-glob';
import 'uuid';
import 'yazl';
import 'socket.io-client';
import 'fullscreen-ink';
import 'string-length';
import 'strip-ansi';
import 'open';
import '@inkjs/ui';
import 'marked';
import 'marked-terminal';
import 'qrcode';
import { B as BaseGameAndroidCommand } from '../../../../baseGameAndroidCommand-DRzVMKuG.js';
import 'crypto-js';
import '@expo/apple-utils/build/index.js';
import 'node:crypto';
import 'node:readline';
import 'node:url';
import 'readline-sync';
import 'isomorphic-git';
import 'deepmerge';
import 'ini';
import 'fs';
import 'path';
class GameAndroidApiKeyInvite extends BaseGameAndroidCommand {
static args = {
accountId: Args.string({ description: "The Google Play Account ID", required: false })
};
static description = "Invites the Service Account to your Google Play Account.";
static examples = ["<%= config.bin %> <%= command.id %>"];
static flags = {
...BaseGameAndroidCommand.flags,
prompt: Flags.boolean({ char: "p", description: "Prompt for the Google Play Account ID" }),
waitForAuth: Flags.boolean({ char: "w", description: "Wait for Google Authentication (10 mins)." }),
waitForGoogleApp: Flags.boolean({ char: "p", description: "Waits for the Google Play app to be created (10 mins)." })
};
async run() {
const game = await this.getGame();
const { prompt, waitForAuth, waitForGoogleApp } = this.flags;
this.checkGoogleAuth(waitForAuth);
const getAccountId = async () => {
if (!prompt) return this.args.accountId;
const entered = await getInput(`Please enter the Google Play Account ID: `);
return entered;
};
const waitForApp = async () => {
console.log("Waiting for Google Play app to be created...");
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
let testResult2 = await fetchKeyTestResult({ projectId: game.id });
while (testResult2.error === KeyTestError.APP_NOT_FOUND) {
process.stdout.write(".");
await sleep(1e3 * 30);
testResult2 = await fetchKeyTestResult({ projectId: game.id });
}
return testResult2;
};
const accountId = await getAccountId();
if (!accountId) {
this.error("You must provide a Google Play Account ID.", { exit: 1 });
}
let testResult = await fetchKeyTestResult({ projectId: game.id });
if (testResult.status === KeyTestStatus.SUCCESS) {
this.error("The Service Account API Key is working and does not need to be invited.", {
exit: 1
});
}
if (testResult.error === KeyTestError.APP_NOT_FOUND && waitForGoogleApp) {
this.log("Waiting for Google Play app to be created...");
testResult = await waitForApp();
}
if (testResult.error !== KeyTestError.NOT_INVITED) {
this.error(`${niceError(testResult.error)}`);
}
await inviteServiceAccount(game.id, accountId);
await this.config.runCommand(`game:android:apiKey:status`, ["--gameId", game.id]);
}
}
export { GameAndroidApiKeyInvite as default };