UNPKG

shipthis

Version:

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

143 lines (138 loc) 5.8 kB
import { jsxs, jsx, Fragment } from 'react/jsx-runtime'; import { Flags } from '@oclif/core'; import { Box, Text, render } from 'ink'; import { b as getShortDate, m as Profile, n as ProfileType, C as CredentialsType, P as Platform, c as BaseGameCommand } 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 { P as ProjectCredentialsTable } from '../../../../ProjectCredentialsTable-BMKgv99h.js'; import 'open'; import '@inkjs/ui'; import '../../../../ejs-DirFZbza.js'; import 'marked'; import 'marked-terminal'; import 'qrcode'; import '../../../../index-hoHfGrjg.js'; import { u as useProjectCredentials } from '../../../../useProjectCredentials-DxdwJCfU.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 'fs'; import 'path'; import '../../../../index-CJWMt1s-.js'; import '../../../../useAndroidServiceAccountTestResult-CwKeW0ED.js'; async function queryAppleProfiles({ ctx }) { const appleProfiles = await Profile.getAsync(ctx, { query: { filter: { profileType: [ProfileType.IOS_APP_STORE] } } }); return appleProfiles; } const canAppleProfileBeUsed = (appleProfile, project, projectCredentials) => { try { if (!appleProfile.isValid) return false; const profileBundleId = appleProfile.attributes.bundleId?.attributes.identifier; const profileCertificateSerialNumber = appleProfile.attributes.certificates?.[0]?.attributes.serialNumber; if (profileBundleId !== project.details?.iosBundleId) return false; return projectCredentials.some( (credential) => credential.isActive && credential.serialNumber === profileCertificateSerialNumber ); } catch (error) { console.log(error); return false; } }; function getAppleProfileSummary(appleProfile, project, projectCredentials) { return { canBeUsed: canAppleProfileBeUsed(appleProfile, project, projectCredentials), expires: getShortDate(DateTime.fromISO(appleProfile.attributes.expirationDate)), id: appleProfile.id, name: appleProfile.attributes.name, platform: appleProfile.attributes.platform }; } const useAppleProfiles = (props) => { const queryResult = useQuery({ queryFn: () => queryAppleProfiles(props), queryKey: ["appleProfiles"] }); return queryResult; }; const AppleProfilesTable = ({ ctx, project, ...boxProps }) => { const { data: credentialsResponse } = useProjectCredentials({ platform: Platform.IOS, projectId: project.id, type: CredentialsType.CERTIFICATE }); const { data: profiles, isLoading } = useAppleProfiles({ ctx }); const hasUsable = profiles && credentialsResponse && profiles.some((cert) => canAppleProfileBeUsed(cert, project, credentialsResponse.data)); return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, ...boxProps, children: [ /* @__PURE__ */ jsx(Title, { children: "Mobile Provisioning Profiles in your Apple account" }), isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }), profiles && credentialsResponse && /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, marginLeft: 2, children: [ /* @__PURE__ */ jsx(Text, { children: `You have ${profiles.length} Mobile Provisioning Profiles in your Apple account` }), /* @__PURE__ */ jsx(Text, { children: `${hasUsable ? "One" : "None"} of these can be used by ShipThis` }) ] }), profiles.length > 0 && /* @__PURE__ */ jsx(Table, { data: profiles.map((cert) => getAppleProfileSummary(cert, project, credentialsResponse.data)) }), !hasUsable && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "You do not have a usable Mobile Provisioning Profile. To ship an iOS game, you will need a usable Mobile Provisioning Profile." }) }) ] }), profiles && !hasUsable && /* @__PURE__ */ jsx(NextSteps, { steps: ["shipthis game ios profile create"] }) ] }); }; class GameIosProfileStatus extends BaseGameCommand { static args = {}; static description = "Shows the Game iOS Mobile Provisioning Profile Status."; static examples = ["<%= config.bin %> <%= command.id %>"]; static flags = { gameId: Flags.string({ char: "g", description: "The ID of the game" }), noAppleAuth: Flags.boolean({ char: "f" }) }; async run() { const { flags } = this; const showApple = !flags.noAppleAuth; const game = await this.getGame(); let ctx = null; if (showApple) { const authState = await this.refreshAppleAuthState(); ctx = authState.context; } render( /* @__PURE__ */ jsxs(Command, { command: this, children: [ /* @__PURE__ */ jsx( ProjectCredentialsTable, { credentialTypeName: "Mobile Provisioning Profile", queryProps: { platform: Platform.IOS, projectId: game.id, type: CredentialsType.CERTIFICATE } } ), showApple && /* @__PURE__ */ jsx(AppleProfilesTable, { ctx, project: game }) ] }) ); } } export { GameIosProfileStatus as default };