UNPKG

shipthis

Version:

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

119 lines (116 loc) 4.46 kB
import { jsx } from 'react/jsx-runtime'; import { Flags } from '@oclif/core'; import { render } from 'ink'; import { d as getGodotAppleBundleIdentifier, e as BundleId, f as App } from '../../../../baseCommand-CTn3KGH3.js'; import 'node:fs'; import 'axios'; import 'crypto-js'; import 'uuid'; import 'luxon'; import 'node:path'; import 'chalk'; import { c as BaseGameCommand, b as getInput, d as generatePackageName } from '../../../../baseGameCommand-8VL7xe-O.js'; 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 'marked'; import 'marked-terminal'; import 'qrcode'; import { R as RunWithSpinner } from '../../../../RunWithSpinner-DucRnFp6.js'; import { C as Command } from '../../../../Command-Cj6F5B5a.js'; 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'; class GameIosAppCreate extends BaseGameCommand { static args = {}; static description = "Creates an App and BundleId in the Apple Developer Portal."; static examples = ["<%= config.bin %> <%= command.id %>"]; static flags = { appName: Flags.string({ char: "n", description: "The name of the App in the Apple Developer Portal" }), bundleId: Flags.string({ char: "b", description: "The BundleId in the Apple Developer Portal" }), force: Flags.boolean({ char: "f" }), // not used but don't remove or the wizard breaks 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 { appName, bundleId } = flags; const getAppName = async () => { if (appName) return appName; const suggestedName = game.name; const question = `Please enter the name of the App in the Apple Developer Portal, or press enter to use ${suggestedName}: `; const enteredName = await getInput(question); return enteredName || suggestedName; }; const getBundleIdentifier = async () => { if (bundleId) return bundleId; const generatedBundleId = generatePackageName(game.name); const suggestedBundleId = game.details?.iosBundleId || getGodotAppleBundleIdentifier() || generatedBundleId || "com.example.game"; const question = `Please enter the BundleId in the Apple Developer Portal, or press enter to use ${suggestedBundleId}: `; const enteredBundleId = await getInput(question); return enteredBundleId || suggestedBundleId; }; const name = await getAppName(); const iosBundleId = await getBundleIdentifier(); const createApp = async () => { this.log(`Checking for ${iosBundleId} in apple portal...`); let bundleId2 = await BundleId.findAsync(ctx, { identifier: iosBundleId }); if (!bundleId2) { this.log(`Creating BundleId ${iosBundleId} in apple portal...`); bundleId2 = await BundleId.createAsync(ctx, { identifier: iosBundleId, name }); } let app = await App.findAsync(ctx, { bundleId: iosBundleId }); if (!app) { this.log(`Creating App ${iosBundleId} in apple portal...`); app = await App.createAsync(ctx, { bundleId: iosBundleId, name, primaryLocale: "en-US" // TODO }); } await this.updateGame({ details: { ...game.details, iosBundleId } }); }; const handleComplete = async () => { await this.config.runCommand("game:ios:app:sync", ["--gameId", game.id]); process.exit(0); }; if (this.flags.quiet) return await createApp(); render( /* @__PURE__ */ jsx(Command, { command: this, children: /* @__PURE__ */ jsx( RunWithSpinner, { executeMethod: createApp, msgComplete: "App and BundleId created", msgInProgress: "Creating App and BundleId in the Apple Developer Portal", onComplete: handleComplete } ) }) ); } } export { GameIosAppCreate as default };