shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
134 lines (129 loc) • 5.47 kB
JavaScript
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
import { Flags } from '@oclif/core';
import { Box, Text, render } from 'ink';
import { b as getShortDate, k as Certificate, l as CertificateType, P as Platform, C as CredentialsType, B as BaseAuthenticatedCommand } from '../../../index-BwnzoldS.js';
import Spinner from 'ink-spinner';
import 'node:crypto';
import 'node:fs';
import 'node:path';
import 'node:readline';
import 'node:url';
import 'readline-sync';
import { DateTime } from 'luxon';
import 'axios';
import 'isomorphic-git';
import { useQuery } from '@tanstack/react-query';
import 'react';
import 'crypto-js';
import 'uuid';
import 'fast-glob';
import 'yazl';
import 'socket.io-client';
import 'fullscreen-ink';
import 'string-length';
import 'strip-ansi';
import 'open';
import { u as useUserCredentials, U as UserCredentialsTable } from '../../../UserCredentialsTable-CUrTDzTK.js';
import '@inkjs/ui';
import '../../../ejs-DirFZbza.js';
import 'marked';
import 'marked-terminal';
import 'qrcode';
import '../../../index-hoHfGrjg.js';
import { g as getShortUUID } from '../../../index-CJWMt1s-.js';
import { T as Table } from '../../../Table-FaNgpyeq.js';
import { T as Title } from '../../../Title-BCQtayg6.js';
import { N as NextSteps } from '../../../NextSteps-DbJHmscQ.js';
import { C as Command } from '../../../Command-DN1j3tjt.js';
import '@expo/apple-utils/build/index.js';
import 'deepmerge';
import 'ini';
import '../../../useAndroidServiceAccountTestResult-CwKeW0ED.js';
import 'fs';
import 'path';
async function queryAppleCertificates({ ctx }) {
const appleCerts = await Certificate.getAsync(ctx, {
query: {
filter: {
certificateType: [CertificateType.DISTRIBUTION, CertificateType.IOS_DISTRIBUTION]
}
}
});
return appleCerts;
}
const canAppleCertificateBeUsed = (cert, userCredentials) => {
if (cert.attributes.status !== "Issued") return false;
return userCredentials.some((cred) => cred.isActive && cred.serialNumber === cert.attributes.serialNumber);
};
function getAppleCertificateSummary(cert, userCredentials) {
const summary = {};
summary.id = getShortUUID(cert.id);
summary.name = cert.attributes.name;
summary.serial = cert.attributes.serialNumber;
summary.expires = getShortDate(DateTime.fromISO(cert.attributes.expirationDate));
summary.canBeUsed = canAppleCertificateBeUsed(cert, userCredentials);
return summary;
}
const useAppleCertificates = (props) => {
const queryResult = useQuery({
queryFn: () => queryAppleCertificates(props),
queryKey: ["appleCertificates"]
});
return queryResult;
};
const AppleCertificatesTable = ({ ctx, ...boxProps }) => {
const { data: userCredentialsResponse } = useUserCredentials({
platform: Platform.IOS,
type: CredentialsType.CERTIFICATE
});
const { data: certs, isLoading } = useAppleCertificates({ ctx });
const hasUsable = certs && userCredentialsResponse && certs.some((cert) => canAppleCertificateBeUsed(cert, userCredentialsResponse.data));
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, ...boxProps, children: [
/* @__PURE__ */ jsx(Title, { children: "Distribution Certificates in your Apple account" }),
isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
certs && userCredentialsResponse && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, marginLeft: 2, children: [
/* @__PURE__ */ jsx(Text, { children: `You have ${certs.length} Distribution Certificates in your Apple account` }),
/* @__PURE__ */ jsx(Text, { children: `${hasUsable ? "One" : "None"} of these can be used by ShipThis` })
] }),
certs.length > 0 && /* @__PURE__ */ jsx(Table, { data: certs.map((cert) => getAppleCertificateSummary(cert, userCredentialsResponse.data)) }),
!hasUsable && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "You do not have a usable Distribution Certificate. To ship an iOS game, you will need a usable Distribution Certificate." }) })
] })
] }),
certs && !hasUsable && /* @__PURE__ */ jsx(NextSteps, { steps: ["shipthis apple certificate create"] })
] });
};
class AppleCertificateStatus extends BaseAuthenticatedCommand {
static args = {};
static description = "Displays the status of the iOS Distribution certificates in your Apple and ShipThis accounts.\nThese are used to sign all of your iOS apps.";
static examples = [
"<%= config.bin %> <%= command.id %>",
"<%= config.bin %> <%= command.id %> --noAppleAuth"
];
static flags = {
noAppleAuth: Flags.boolean({ char: "f" })
};
async run() {
const { flags } = this;
const showApple = !flags.noAppleAuth;
let ctx = null;
if (showApple) {
const authState = await this.refreshAppleAuthState();
ctx = authState.context;
}
render(
/* @__PURE__ */ jsxs(Command, { command: this, children: [
/* @__PURE__ */ jsx(
UserCredentialsTable,
{
credentialTypeName: "Apple iOS Distribution Certificate",
queryProps: { platform: Platform.IOS, type: CredentialsType.CERTIFICATE }
}
),
showApple && /* @__PURE__ */ jsx(AppleCertificatesTable, { ctx })
] })
);
}
}
export { AppleCertificateStatus as default };