UNPKG

shipthis

Version:

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

129 lines (126 loc) 4.34 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, b as Certificate } 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 AppleCertificateDelete extends BaseAppleCommand { static args = {}; static description = "Delete an iOS Distribution Certificate 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 Certificate in Apple (cannot be undone)", required: false }) }; async run() { const { flags } = await this.parse(AppleCertificateDelete); const { immediate, iAmSure, revokeInApple } = flags; const userCredentials = await getUserCredentials(); const userCerts = userCredentials.filter( (cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.CERTIFICATE && cred.isActive ); if (userCerts.length === 0) { this.error("No iOS Distribution Certificate found which can be deleted."); } const [cert] = userCerts; let appleCert = null; let authState = null; let ctx = null; if (revokeInApple) { authState = await this.refreshAppleAuthState(); ctx = authState.context; const appleCerts = await Certificate.getAsync(ctx, { query: { filter: { serialNumber: cert.serialNumber } } }); if (appleCerts.length !== 1) { this.error("The iOS Distribution Certificate was not found in Apple, so cannot be revoked there."); } appleCert = appleCerts[0]; } const getAreYouSure = async () => { if (iAmSure) return true; const confirmString = getShortUUID(cert.id); const prompt = getRenderedMarkdown({ filename: "confirm-delete-apple-credential.md.ejs", templateVars: { confirmString, credentialType: "iOS Distribution Certificate", exportCommand: `shipthis apple certificate export cert.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 iOS Distribution Certificate"); this.exit(0); } await deleteUserCredential({ credentialId: cert.id, isImmediate: immediate }); this.log("The iOS Distribution Certificate has been deleted from ShipThis."); if (revokeInApple && appleCert?.id) { Certificate.deleteAsync(ctx, { id: appleCert.id }); this.log("The iOS Distribution Certificate has been deleted in Apple."); } await this.config.runCommand(`apple:certificate:status`, [!revokeInApple ? "--noAppleAuth" : ""].filter(Boolean)); } } export { AppleCertificateDelete as default };