UNPKG

shipthis

Version:

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

120 lines (117 loc) 4.01 kB
import { Flags } from '@oclif/core'; import { B as BaseAppleCommand } from '../../../baseAppleCommand-Aq-Eaw_K.js'; import 'node:fs'; import 'axios'; import 'crypto-js'; import 'uuid'; import { P as Platform, C as CredentialsType, A as ApiKey } from '../../../baseCommand-CTn3KGH3.js'; import 'luxon'; import { g as getUserCredentials, d as deleteUserCredential } from '../../../index-BW7z-5sB.js'; import 'node:path'; import 'chalk'; import { g as getShortUUID, a as getRenderedMarkdown, b as getInput } from '../../../baseGameCommand-8VL7xe-O.js'; import 'react/jsx-runtime'; import 'ink'; import 'ink-spinner'; import 'react'; import '@tanstack/react-query'; import 'fast-glob'; import 'yazl'; import 'socket.io-client'; import 'fullscreen-ink'; import 'string-length'; import 'strip-ansi'; import 'open'; import '@inkjs/ui'; import 'qrcode'; 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'; import 'marked'; import 'marked-terminal'; class AppleApiKeyDelete extends BaseAppleCommand { static args = {}; static description = "Delete an Apple API Key from ShipThis and optionally from Apple"; static examples = [ "<%= config.bin %> <%= command.id %>", "<%= config.bin %> <%= command.id %> --immediate --revokeInApple --iAmSure" ]; static flags = { immediate: Flags.boolean({ char: "i", description: "Remove from storage immediately (rather than waiting for automatic cleanup - cannot be undone)", required: false }), iAmSure: Flags.boolean({ char: "y", description: "I am sure I want to do this - do not prompt me", required: false }), revokeInApple: Flags.boolean({ char: "a", description: "Also revoke the API Key in Apple (cannot be undone)", required: false }) }; async run() { const { flags } = await this.parse(AppleApiKeyDelete); const { immediate, iAmSure, revokeInApple } = flags; const userCredentials = await getUserCredentials(); const userKeys = userCredentials.filter( (cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.KEY && cred.isActive ); if (userKeys.length === 0) { this.error("No App Store Connect API Key found which can be deleted."); } const [key] = userKeys; let appleKey = null; if (revokeInApple) { const authState = await this.refreshAppleAuthState(); const ctx = authState.context; appleKey = await ApiKey.infoAsync(ctx, { id: key.serialNumber }); if (!appleKey?.id) { this.error("The App Store Connect API Key was not found in Apple, so cannot be revoked there."); } } const getAreYouSure = async () => { if (iAmSure) return true; const confirmString = getShortUUID(key.id); const prompt = getRenderedMarkdown({ filename: "confirm-delete-apple-credential.md.ejs", templateVars: { confirmString, credentialType: "App Store Connect API Key", exportCommand: `shipthis apple apiKey export appleApiKey.zip`, immediate, revokeInApple } }); this.log(prompt); const input = await getInput(""); return input.trim().toLowerCase() === confirmString.toLowerCase(); }; const areYouSure = await getAreYouSure(); if (!areYouSure) { this.log("Aborting - not deleting the API Key"); this.exit(0); } await deleteUserCredential({ credentialId: key.id, isImmediate: immediate }); this.log("The API Key has been deleted from ShipThis."); if (revokeInApple && appleKey?.id) { await appleKey.revokeAsync(); this.log("The API Key has been revoked in Apple."); } await this.config.runCommand(`apple:apiKey:status`, [!revokeInApple ? "--noAppleAuth" : ""].filter(Boolean)); } } export { AppleApiKeyDelete as default };