UNPKG

shipthis

Version:

ShipThis manages building and uploading your Godot games to the App Store and Google Play.

98 lines (94 loc) 3.21 kB
import { Flags } from '@oclif/core'; import { $ as Auth } from '../../baseCommand-CTn3KGH3.js'; import { B as BaseAuthenticatedCommand, b as getInput, r as getMaskedInput } from '../../baseGameCommand-8VL7xe-O.js'; import 'node:fs'; import 'node:path'; import 'chalk'; import 'axios'; import 'crypto-js'; import 'uuid'; import 'luxon'; 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'; import 'react/jsx-runtime'; import 'ink-spinner'; import 'string-length'; import 'strip-ansi'; import 'open'; import '@inkjs/ui'; import 'fs'; import 'path'; import 'marked'; import 'marked-terminal'; import 'qrcode'; 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", "<%= config.bin %> <%= command.id %> --logout" ]; 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" }), logout: Flags.boolean({ char: "l", description: "Forget the saved Apple session (log out)" }) }; async run() { const { flags } = this; if (flags.logout) { await this.setAppleCookies(void 0); if (!this.flags.quiet) this.log("You have been logged out of Apple."); await this.config.runCommand(`apple:status`); return; } 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 };