shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
131 lines (128 loc) • 4.71 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { Flags } from '@oclif/core';
import { render } from 'ink';
import { i as BetaGroup } from '../../../../baseCommand-CTn3KGH3.js';
import 'node:fs';
import 'axios';
import 'crypto-js';
import 'uuid';
import 'luxon';
import 'node:path';
import 'chalk';
import { c as BaseGameCommand, b as getInput } from '../../../../baseGameCommand-8VL7xe-O.js';
import 'ink-spinner';
import 'react';
import '@tanstack/react-query';
import { q as queryAppleApp } from '../../../../useAppleApp-CR847GWc.js';
import 'fast-glob';
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 { R as RunWithSpinner } from '../../../../RunWithSpinner-DucRnFp6.js';
import { C as Command } from '../../../../Command-Cj6F5B5a.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';
const TEST_GROUP_NAME = "ShipThis Test Group";
class GameIosAppAddTester extends BaseGameCommand {
static args = {};
static description = "Adds a test user to the game in App Store Connect.";
static examples = ["<%= config.bin %> <%= command.id %>"];
static flags = {
email: Flags.string({ char: "e", description: "The email address of the tester" }),
firstName: Flags.string({ char: "f", description: "The first name of the tester" }),
gameId: Flags.string({ char: "g", description: "The ID of the game" }),
lastName: Flags.string({ char: "l", description: "The last name of the tester" }),
quiet: Flags.boolean({ char: "q", description: "Avoid output except for interactions and errors" }),
self: Flags.boolean({
char: "s",
default: false,
description: "Add yourself as a tester (uses your Apple ID email and name)"
})
};
async run() {
const game = await this.getGame();
const authState = await this.refreshAppleAuthState();
const ctx = authState.context;
const { flags } = this;
const getEmail = async () => {
if (flags.self) return authState.session.user.emailAddress;
if (flags.email) return flags.email;
const question = `Please enter the email address of the tester: `;
const enteredEmail = await getInput(question);
if (!enteredEmail) this.error("No email address provided");
return enteredEmail;
};
const getFirstName = async () => {
if (flags.self) return authState.session.user.firstName;
if (flags.firstName) return flags.firstName;
const suggestedName = "John";
const question = `Please enter the first name of the tester, or press enter to use ${suggestedName}: `;
const enteredName = await getInput(question);
return enteredName || suggestedName;
};
const getLastName = async () => {
if (flags.self) return authState.session.user.lastName;
if (flags.lastName) return flags.lastName;
const suggestedName = "Doe";
const question = `Please enter the last name of the tester, or press enter to use ${suggestedName}: `;
const enteredName = await getInput(question);
return enteredName || suggestedName;
};
const email = await getEmail();
const firstName = await getFirstName();
const lastName = await getLastName();
const addTestUser = async () => {
const { app } = await queryAppleApp({ ctx, iosBundleId: game.details?.iosBundleId });
if (!app) return this.error("No app found");
const groups = await BetaGroup.getAsync(ctx, {});
let shipThisGroup = groups.find(
(group) => group.attributes.name === TEST_GROUP_NAME && group.attributes.isInternalGroup
);
if (!shipThisGroup) {
shipThisGroup = await BetaGroup.createAsync(ctx, {
hasAccessToAllBuilds: true,
id: app.id,
isInternalGroup: true,
name: TEST_GROUP_NAME
});
}
await shipThisGroup.createBulkBetaTesterAssignmentsAsync([
{
email,
firstName,
lastName
}
]);
};
const handleComplete = async () => {
};
if (flags.quiet) return await addTestUser();
render(
/* @__PURE__ */ jsx(Command, { command: this, children: /* @__PURE__ */ jsx(
RunWithSpinner,
{
executeMethod: addTestUser,
msgComplete: "Added test user",
msgInProgress: "Adding test user...",
onComplete: handleComplete
}
) })
);
}
}
export { GameIosAppAddTester as default };