shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
125 lines (122 loc) • 4.42 kB
JavaScript
import { Flags } from '@oclif/core';
import { c as BaseGameCommand, g as getShortUUID, a as getRenderedMarkdown, b as getInput } from '../../../../baseGameCommand-8VL7xe-O.js';
import { P as Platform, C as CredentialsType } from '../../../../baseCommand-CTn3KGH3.js';
import 'node:fs';
import 'axios';
import 'crypto-js';
import 'uuid';
import 'luxon';
import { a as getProjectCredentials, b as deleteProjectCredential } from '../../../../index-BW7z-5sB.js';
import 'react/jsx-runtime';
import 'ink';
import 'ink-spinner';
import 'react';
import '@tanstack/react-query';
import { q as queryAppleProfiles } from '../../../../useAppleProfiles-DY-H0420.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 'qrcode';
import 'node:crypto';
import 'node:path';
import 'node:readline';
import 'node:url';
import 'readline-sync';
import 'isomorphic-git';
import 'fs';
import 'path';
import 'marked';
import 'marked-terminal';
import 'chalk';
import '@expo/apple-utils/build/index.js';
import 'deepmerge';
import 'ini';
class GameIosProfileDelete extends BaseGameCommand {
static args = {};
static description = "Delete an iOS Mobile Provisioning Profile from ShipThis and optionally from Apple";
static examples = [
"<%= config.bin %> <%= command.id %>",
"<%= config.bin %> <%= command.id %> --revokeInApple --immediate --iAmSure"
];
static flags = {
...BaseGameCommand.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 Profile in Apple (cannot be undone)",
required: false
})
};
async run() {
const { flags } = await this.parse(GameIosProfileDelete);
const { immediate, iAmSure, revokeInApple } = flags;
const game = await this.getGame();
const projectCredentials = await getProjectCredentials(game.id);
const userAppleProfileCredentials = projectCredentials.filter(
(cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.CERTIFICATE && cred.isActive
);
if (userAppleProfileCredentials.length === 0) {
this.error("No active Mobile Provisioning Profile found which can be deleted.");
}
const [profile] = userAppleProfileCredentials;
let appleProfile = null;
if (revokeInApple) {
const authState = await this.refreshAppleAuthState();
const ctx = authState.context;
const appleProfiles = await queryAppleProfiles({ ctx });
appleProfile = appleProfiles.find((p) => {
const profileSerialNumber = p.attributes.certificates?.[0]?.attributes.serialNumber;
return profileSerialNumber === profile.serialNumber;
});
if (!appleProfile?.id) {
this.error("The Mobile Provisioning Profile was not found in Apple, so cannot be revoked there.");
}
}
const getAreYouSure = async () => {
if (iAmSure) return true;
const confirmString = getShortUUID(profile.id);
const prompt = getRenderedMarkdown({
filename: "confirm-delete-apple-credential.md.ejs",
templateVars: {
confirmString,
credentialType: "Mobile Provisioning Profile",
exportCommand: `shipthis game ios profile export userProfile.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 - Mobile Provisioning Profile not deleted");
this.exit(0);
}
await deleteProjectCredential(game.id, {
credentialId: profile.id,
isImmediate: immediate
});
this.log("The Mobile Provisioning Profile has been deleted from ShipThis.");
if (revokeInApple && appleProfile?.id) {
await appleProfile.deleteAsync();
this.log("The Mobile Provisioning Profile has been deleted in Apple.");
}
}
}
export { GameIosProfileDelete as default };