shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
78 lines (74 loc) • 2.6 kB
JavaScript
import { Flags } from '@oclif/core';
import { a3 as Auth, B as BaseAuthenticatedCommand } from '../../index-BwnzoldS.js';
import { a as getInput, e as getMaskedInput } from '../../index-CJWMt1s-.js';
import 'node:fs';
import 'axios';
import 'crypto-js';
import 'uuid';
import 'luxon';
import 'node:path';
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 '@tanstack/react-query';
import 'react';
import 'fast-glob';
import 'yazl';
import 'socket.io-client';
import 'fullscreen-ink';
import 'ink';
async function getNewAuthState(username, password) {
const authState = await Auth.loginAsync({
password,
username
});
return authState;
}
class AppleLogin extends BaseAuthenticatedCommand {
static args = {};
static description = "Authenticate with Apple - saves the session to the auth file";
static examples = [
"<%= config.bin %> <%= command.id %>",
"<%= config.bin %> <%= command.id %> --force --appleEmail me@email.nowhere"
];
static flags = {
appleEmail: Flags.string({
char: "e",
description: "Your Apple Developer email address"
}),
force: Flags.boolean({ char: "f" }),
quiet: Flags.boolean({ char: "q", description: "Avoid output except for interactions and errors" })
};
async run() {
const { flags } = this;
const isLoggedIn = await this.hasValidAppleAuthState();
if (isLoggedIn && !flags.force) {
throw new Error("You are already logged in to Apple. Use --force to re-authenticate.");
}
const getAppleEmail = async () => {
if (flags.appleEmail) return flags.appleEmail;
const appleEmail2 = await getInput("Please enter your Apple Developer account email address: ");
if (!appleEmail2) throw new Error("Email address is required");
return appleEmail2;
};
const getApplePassword = async () => {
const applePassword2 = await getMaskedInput("Please enter your Apple Developer password: ");
if (!applePassword2) throw new Error("Password is required");
return applePassword2;
};
const appleEmail = await getAppleEmail();
const applePassword = await getApplePassword();
const authState = await getNewAuthState(appleEmail, applePassword);
if (!authState) {
throw new Error("Failed to authenticate with Apple");
}
await this.setAppleCookies(authState.cookies);
if (!this.flags.quiet) await this.config.runCommand(`apple:status`);
}
}
export { AppleLogin as default };