UNPKG

shipthis

Version:

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

133 lines (130 loc) 5.11 kB
import { jsx } from 'react/jsx-runtime'; import { Flags } from '@oclif/core'; import axios from 'axios'; import { render } from 'ink'; import 'node:fs'; import 'crypto-js'; import 'uuid'; import { c as BaseGameCommand, P as Platform, C as CredentialsType, k as Certificate, l as CertificateType, m as Profile, n as ProfileType } from '../../../../index-BwnzoldS.js'; import 'luxon'; import { a as getProjectCredentials, g as getUserCredentials } from '../../../../index-izrACZbC.js'; import 'ink-spinner'; import 'node:crypto'; import 'node:path'; import 'node:readline'; import 'node:url'; import 'readline-sync'; import 'isomorphic-git'; import '@tanstack/react-query'; import 'react'; import { f as fetchBundleId } from '../../../../useAppleBundleId-DvMXAvWD.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 '../../../../ejs-DirFZbza.js'; import 'marked'; import 'marked-terminal'; import 'qrcode'; import { R as RunWithSpinner } from '../../../../RunWithSpinner-DucRnFp6.js'; import '../../../../index-hoHfGrjg.js'; import { C as Command } from '../../../../Command-DN1j3tjt.js'; import { a as uploadProjectCredentials } from '../../../../upload-D19OQsbn.js'; import '@expo/apple-utils/build/index.js'; import 'deepmerge'; import 'ini'; import 'fs'; import 'path'; import '../../../../index-CJWMt1s-.js'; import '../../../../useAndroidServiceAccountTestResult-CwKeW0ED.js'; class GameIosProfileCreate extends BaseGameCommand { static args = {}; static description = "Creates a Mobile Provisioning Profile in the Apple Developer Portal."; static examples = ["<%= config.bin %> <%= command.id %>"]; static flags = { force: Flags.boolean({ char: "f" }), gameId: Flags.string({ char: "g", description: "The ID of the game" }), quiet: Flags.boolean({ char: "q", description: "Avoid output except for interactions and errors" }) }; async run() { const game = await this.getGame(); const authState = await this.refreshAppleAuthState(); const ctx = authState.context; const { flags } = this; const { force } = flags; const projectCredentials = await getProjectCredentials(game.id); const projectAppleProfileCredentials = projectCredentials.filter( (cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.CERTIFICATE ); if (projectAppleProfileCredentials.length > 0 && !force) { this.error("A Mobile Provisioning Profile already exists. Use --force to overwrite it."); } const createProfile = async () => { if (!game.details?.iosBundleId) throw new Error("iosBundleId not found in game details"); const { iosBundleId } = game.details; const { bundleId } = await fetchBundleId({ ctx, iosBundleId }); if (!bundleId) throw new Error("BundleId not found"); const appleCerts = await Certificate.getAsync(ctx, { query: { filter: { certificateType: [CertificateType.DISTRIBUTION, CertificateType.IOS_DISTRIBUTION] } } }); const userCerts = await getUserCredentials(); const validCert = userCerts.find( (cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.CERTIFICATE && cred.isActive === true ); const validAppleCert = appleCerts.find( (cert) => validCert && cert.attributes.serialNumber === validCert.serialNumber ); if (!validCert || !validAppleCert) throw new Error( 'No usable iOS Distribution Certificate found. Please run "shipthis apple certificate create" first.' ); const profile = await Profile.createAsync(ctx, { bundleId: bundleId.id, certificates: [validAppleCert.id], devices: [], name: `ShipThis Profile for ${iosBundleId}`, profileType: ProfileType.IOS_APP_STORE }); const { data: contents } = await axios({ method: "get", url: validCert.url }); const userCertContent = contents; const projectCertContent = { ...userCertContent, mobileProvisionBase64: `${profile.attributes.profileContent}` }; await uploadProjectCredentials(game.id, { contents: projectCertContent, identifier: iosBundleId, platform: Platform.IOS, serialNumber: validCert.serialNumber, type: CredentialsType.CERTIFICATE }); }; const handleComplete = async () => { await this.config.runCommand("game:ios:profile:status", ["--gameId", game.id]); }; if (this.flags.quiet) return await createProfile(); render( /* @__PURE__ */ jsx(Command, { command: this, children: /* @__PURE__ */ jsx( RunWithSpinner, { executeMethod: createProfile, msgComplete: "Mobile Provisioning Profile created", msgInProgress: "Creating Mobile Provisioning Profile in the Apple Developer Portal", onComplete: handleComplete } ) }) ); } } export { GameIosProfileCreate as default };